akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;

void main()
{
    auto a = readln().strip;
    auto b = readln().strip;
    size_t sub = 0;
    while (true)
    {
        sub = a.indexOf(b, sub);
        if (sub == cast(size_t)-1)
        {
            break;
        }
        else
        {
            writeln(sub);
            sub++;
        }
    }
}


Measured memory_bytes: 2500
import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
	private static BufferedReader br = null;
	
	public static void main(String[] args) {
		String n = read(1)[0];
		
		char x1 = n.charAt(2);
		for (int i = 1; i >= 0; i--) {
			if (x1 > n.charAt(i)) {
				x1 = (char)(n.charAt(i) + 1);
			} else {
				x1 = n.charAt(i);
			}
		}
		
		System.out.println("" + x1 + x1 + x1);
	}
	
	private static String[] read(int len) {
		List<String> strList = new ArrayList<>();
		
		try {
			if (br == null) {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			
			for (int i = 0; i < len; i++) {
				strList.add(br.readLine());
			}
		} catch (IOException e) {
		}
		
		return strList.toArray(new String[0]);
	}
	
	private static void close() {
		try {
			if (br != null) {
				br.close();
			}
		} catch (IOException e) {
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int mod = 1e9 + 7;

ll powmod(ll a, ll b) {
	ll ret = 1;
	rep(i, b) {
		ret = (ret * a) % mod;
	}
	return ret;
}

int main() {
	ll n;
	cin >> n;
	ll ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
	ans %= mod;
	cout << (ans + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    char s[101];
    char a[101];
    char b[101];
    long long leng;

    cin >> s;
    leng = strlen(s);
    if (leng % 2 == 0){
        cout << "No" << endl;
        return 0;
    }
    
    for (int i = 0; i < (leng / 2); i++){
        //cout << s[i] << s[i+(leng/2+1)] << endl;
        if (s[i] != s[i+(leng/2)+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[100000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	int minA = 1e+15;
	int sumA = 0;
	int cnt = 0;
	rep(i, n) {
		if (a[i] < 0) {
			cnt++;
		}
		sumA += abs(a[i]);
		minA = min(minA, abs(a[i]));
	}
	
	if (cnt % 2 == 0) { cout << sumA << endl; return 0; }
	cout << sumA - 2 * minA << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>


using namespace std;


int main(){
    
    int w,n,a,b;
    cin >> w >> n;
    vector<int> ans;
    for(int i=0;i<=w;i++){
        ans.push_back(i);
    }

    for(int i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        swap(ans[a],ans[b]);
    }
    for(int i=1;i<=w;i++){
        cout << ans[i] << endl;
    }
    
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>

using namespace std;

int main()
{
  int N;
  int d[100];
  cin>> N;
  for(int i=0;i<N;i++)cin>> d[i];

  set<int> s;
  for(int i=0;i<N;i++)
  {
    s.insert(d[i]);
  }
  cout<< s.size()<< endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int x = c + b - d, y = d - a + c, z = a - d + b, w = b + c - a;
	cout << x << " " << y << " " << z << " " << w << endl;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = Counter(list(map(int, input().split())))
M = int(input())
B = Counter(list(map(int, input().split())))

ok = True
for k, v in B.items():
    if not k in A.keys():
        ok = False
        break
    elif A[k] < v:
        ok = False
        break
print("YES" if ok else "NO")

Measured memory_bytes: 55256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const ll INF = 1ll<<50;
const int maxN = 110;
const int maxK = 16;
const int MOD = 1000000007;

vector<int> rd[maxN];     //原来的图 
int vis[maxN][maxN];              //每个节点的数 
char a[maxN];


int main()
{
	scanf("%s",a+1); 
	if(a[1] == a[3])
		puts("Yes");
	else
		puts("No");
	return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)

ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n){string s;while(n){s+=(n%2)+'0';n/=2;}reverse(all(s));return s;} // only sufficient bits
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
 	int r;
 	cin>>r;
 	cout<<pows(r,2)<<"\n";   
}

Measured memory_bytes: 7424
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[derive(Clone)]
struct Edge {
    to: usize,
    idx: usize,
}

fn dfs(
    cur: usize,
    parent: usize,
    goal: usize,
    edges: &Vec<Vec<Edge>>,
    throughed: &mut Vec<usize>,
) -> bool {
    if cur == goal {
        return true;
    }
    for &Edge { to, idx } in edges[cur].iter() {
        if to == parent {
            continue;
        }
        if dfs(to, cur, goal, edges, throughed) {
            throughed.push(idx);
            return true;
        }
    }
    false
}

fn main() {
    let n = read::<usize>();
    let mut edges = vec![vec![]; n];
    for i in 0..n - 1 {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        edges[a].push(Edge { to: b, idx: i });
        edges[b].push(Edge { to: a, idx: i });
    }

    let m = read::<usize>();
    let mut constraints = vec![];
    for _ in 0..m {
        let v = read_vec::<usize>();
        let (u, v) = (v[0] - 1, v[1] - 1);
        constraints.push((u, v));
    }

    let mut disallowed = vec![0i64; m];

    for i in 0..m {
        let mut throughed = vec![];
        let (u, v) = constraints[i];
        dfs(u, n + 1, v, &edges, &mut throughed);
        for idx in throughed {
            disallowed[i] |= 1 << idx;
        }
    }

    let mut ans = 0i64;
    for state in 0..1 << m {
        let mut flags = 0i64;

        for j in 0..m {
            if state >> j & 1 == 1 {
                flags |= disallowed[j];
            }
        }

        if (state as u64).count_ones() % 2 == 0 {
            ans += 1 << (n as u32 - 1 - flags.count_ones());
        } else {
            ans -= 1 << (n as u32 - 1 - flags.count_ones());
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int A, B, X;
  cin >> A >> B >> X;

  if (A + B >= X && X >= A)
    cout << "YES\n";
  else
    cout << "NO\n";

  return 0;
}

Measured memory_bytes: 256
import Control.Monad (replicateM)
import Data.List (sortBy)

main = do
    nums <- replicateM 20 readLn :: IO [Int]
    let ws = take 10 nums
    let ks = drop 10 nums
    putStrLn $ unwords $ map show [point ws, point ks]
    where
    point xs = sum $ take 3 $ sortBy (flip compare) xs

Measured memory_bytes: 3736
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<string> v;

int main(void){
	int n,i,k,p=1,q,m=0;
	string s,t,ans;
	cin >> n >> k; --k;
	cin >> s;
	t = s;
	reverse(s.begin(),s.end());
	t += s;
	reverse(s.begin(),s.end());
	for(i=0; i<n; ++i){
		v.push_back(t.substr(i,n));
	}
	sort(v.begin(),v.end());
	while(p<n && v[0][p-1] == v[0][p]){
		++p;
	}
	q = p;
	while(k){
		q *= 2;
		if(q > n){
			break;
		}
		--k;
	}
	q -= p;
	for(i=0; i<q; ++i){
		if(m<n){
			ans.push_back(v[0][0]);
			++m;
		}
	}
	for(i=0; i<n; ++i){
		if(m<n){
			ans.push_back(v[0][i]);
			++m;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 40192
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
using namespace std;
int main() {

	long long N = 0;
	long long A = 0;
	long long B = 0;
	long long max;
	long long min;
	cin >> N;
	cin >> A;
	cin >> B;

	if (N > 100 || N < 1) {
		cout << "error" << endl;
	}

	if (A > N || A < 0) {
		cout << "error" << endl;
	}

	if (B > N || B < 0) {
		cout << "error" << endl;
	}

	if (N == A && N == B) {
		max = N;
		min = N;
	}
	else {
		if ((A + B) <= N) {
			if (A > B) {
				max = B;
				min = 0;
			}
			else if (A < B) {
				max = A;
				min = 0;
			}
			else if (A == B) {
				max = A;
				min = 0;
			}
		}
		if ((A + B) > N) {
			if (A > B) {
				max = B;
				min = (A + B) - N;
			}
			else if (A < B) {
				max = A;
				min = (A + B) - N;
			}
			else if (A == B) {
				max = A;
				min = (A + B) - N;
			}
		}
	}
	
	cout << max << " " << min << endl;

}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: usize = read();
    let w: usize = read();
    let k: usize = read();
    let mut ans = 0;

    let mut map: Vec<Vec<char>> = vec![];

    for _ in 0..h {
        let row: Vec<char> = read::<String>().chars().collect();
        map.push(row);
    }

    for i in 0..2_u32.pow(h as u32) {
        for j in 0..2_u32.pow(w as u32) {
            let mut cnt = 0;
            for hi in 0..h {
                for wi in 0..w {
                    if i >> hi & 1 == 0 {
                        continue;
                    }
                    if j >> wi & 1 == 0 {
                        continue;
                    }
                    if map[hi][wi] == '#' {
                        cnt += 1;
                    }
                }
            }

            if cnt == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int n;

bool dfs(pii p, int c, set<pii> &S, map<pii, int> &color, map<pii, pii> &same){
    if(S.find(p) == S.end()){
        return color[p] == c;
    }
    color[p] = c;
    S.erase(p);
    rep(i, 4){
        pii np = {p.fi + dx[i], p.se + dy[i]};
        if(color.find(np) == color.end()) continue;
        int nc = (np == same[p] ? c ^ 1 : c);
        if(!dfs(np, nc, S, color, same)) return false;
    }
    return true;
}

void solve(){
    map<pii, int> color;
    map<pii, pii> same;
    set<pii> S;
    rep(i, n){
        int x, y; char dir;
        scanf("%d%d %c", &x, &y, &dir);
        int nx = x, ny = y;
        if(dir == 'x') ++nx;
        else ++ny;
        same[{x, y}] = {nx, ny};
        same[{nx, ny}] = {x, y};
        color[{x, y}] = color[{nx, ny}] = -1;
        S.emplace(x, y);
        S.emplace(nx, ny);
    }

    while(!S.empty()){
        if(!dfs(*S.begin(), 0, S, color, same)){
            puts("No");
            return;
        }
    }
    puts("Yes");
}

int main(){
    while(scanf("%d", &n) && n){
        solve();
    }
}


Measured memory_bytes: 15660
#include <iostream>
using namespace std;

long long p = 998244353;
long long mod_fact[300008];

void mod_fact_init(){
    mod_fact[0]=mod_fact[1]=1;
    for(int i=2;i<300008;i++)
        mod_fact[i]=(mod_fact[i-1]*i)%p;
}


long long mod_pow(long long a, long long b){
    a%=p;
    if(b==0)
        return 1;
    else if(b%2==0)
        return mod_pow(a*a, b/2)%p;
    else
        return (a*mod_pow(a, b-1))%p;
}

long long mod_comb(long long a, long long b){
    long long c = (mod_fact[a]*mod_pow(mod_fact[a-b], p-2))%p;
    return (c*mod_pow(mod_fact[b], p-2))%p;
}

int main(void){
    long long n,a,b,k,m=0;
    cin>>n>>a>>b>>k;
    mod_fact_init();
    for(long long i=0;i<=min(k/a,n);i++){
        if((k-i*a)%b==0){
            long long j=(k-i*a)/b;
            if(j<=n)m=(m+(mod_comb(n,i)*mod_comb(n,j))%p)%p;
        }
    }
    cout<<m<<endl;

    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

int main(void){
	char str[1001];
	int i, len;
	
	scanf("%s", str);
	
	len = strlen(str);
	
	for (i = 0; i < len; i++){
		switch (str[i]){
			case 'A': str[i] = 'X'; break;
			case 'B': str[i] = 'Y'; break;
			case 'C': str[i] = 'Z'; break;
			case 'D': str[i] = 'A'; break;
			case 'E': str[i] = 'B'; break;
			case 'F': str[i] = 'C'; break;
			case 'G': str[i] = 'D'; break;
			case 'H': str[i] = 'E'; break;
			case 'I': str[i] = 'F'; break;
			case 'J': str[i] = 'G'; break;
			case 'K': str[i] = 'H'; break;
			case 'L': str[i] = 'I'; break;
			case 'M': str[i] = 'J'; break;
			case 'N': str[i] = 'K'; break;
			case 'O': str[i] = 'L'; break;
			case 'P': str[i] = 'M'; break;
			case 'Q': str[i] = 'N'; break;
			case 'R': str[i] = 'O'; break;
			case 'S': str[i] = 'P'; break;
			case 'T': str[i] = 'Q'; break;
			case 'U': str[i] = 'R'; break;
			case 'V': str[i] = 'S'; break;
			case 'W': str[i] = 'T'; break;
			case 'X': str[i] = 'U'; break;
			case 'Y': str[i] = 'V'; break;
			case 'Z': str[i] = 'W'; break;
		}
	}
	
	printf("%s\n", str);
				
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;

int main() {
 int h, w;
 cin >> h >> w;
 int hei,wid;
 int ans = 0;

 string board[2000];

 for (int i = 0; i < h; ++i) cin >> board[i];

 int l[h][w];
 int r[h][w];
 int d[h][w];
 int u[h][w];

 int hold = 0;

 for (int i = 0; i < h; ++i){
	 hold = 0;
  for(int j = 0; j < w; ++j){
	if(board[i][j]=='#') {
		l[i][j]=0;
		hold=0;
		}
	else{
	  ++hold;
	  l[i][j] = hold; 
	}
  }
 }
 hold = 0;
 for (int i = 0; i < h; ++i){
	 hold =0;
  for(int j = w-1; j >= 0; --j){
	if(board[i][j]=='#') {
		r[i][j]=0;
		hold=0;
		}
	else{
	  ++hold;
	  r[i][j] = hold; 
	}
  }
 }
 hold = 0;
 for (int j = 0; j < w; ++j){
	 hold = 0;
  for(int i = 0; i < h; ++i){
	if(board[i][j]=='#') {
		d[i][j]=0;
		hold=0;
		}
	else{
	  ++hold;
	  d[i][j] = hold; 
	}
  }
 }
 hold = 0;
 for (int j = 0; j < w; ++j){
	 hold = 0;
  for(int i = h-1; i >= 0; --i){
	if(board[i][j]=='#') {
		u[i][j]=0;
		hold=0;
		}
	else{
	  ++hold;
	  u[i][j] = hold; 
	}
  }
 }

 int check;

 for (int i = 0; i < h; ++i){
  for(int j = 0; j < w; ++j){
   check = l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3;
   if(check>ans) {
	   ans = check;
	   //cout << i << " " << j << endl;
  }
 }
 }

 //cout << l[1][2] << " " << r[1][2] << " " << d[1][2] << " " << u[1][2] << endl;

 cout << ans << endl;
}


Measured memory_bytes: 66816
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

/*-----------Main-----------*/

func main() {
	n := readS()
	a := n[len(n)-1]
	switch a {
	case '2':
		fallthrough
	case '4':
		fallthrough
	case '5':
		fallthrough
	case '7':
		fallthrough
	case '9':
		fmt.Println("hon")
	case '0':
		fallthrough
	case '1':
		fallthrough
	case '6':
		fallthrough
	case '8':
		fmt.Println("pon")
	case '3':
		fmt.Println("bon")
	}
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-3.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1780
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main()
{
    int a[100005];
    int n,sum,i,x,y;
    a[0]=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    sum=0;
    for(i=1;i<=n+1;i++)
    {
        if(i!=n+1)
        {
            sum=sum+fabs(a[i]-a[i-1]);
        }
        else
        {
            sum=sum+fabs(a[0]-a[n]);
        }
    }
    for(i=1;i<=n;i++)
    {
        if(i!=n)
        {
          x=fabs(a[i+1]-a[i-1]);
          y=fabs(a[i]-a[i-1])+fabs(a[i+1]-a[i]);
        }
        if(i==n)
        {
            x=fabs(a[0]-a[i-1]);
            y=fabs(a[i]-a[i-1])+fabs(a[0]-a[i]);
        }
        if(x<=y)
        {
            printf("%d\n",sum-(y-x));
        }
        if(x>y)
        {
            printf("%d\n",sum+(x-y));
        }
    }
    return 0;
}


Measured memory_bytes: 1664
func gcd(x: Int, _ y: Int) -> Int {
    if y == 0 {
        return x
    } else {
        return gcd(y, x%y)
    }
}
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let x = (readLine()!.characters.split(" ").map{Int(String($0))!} + [input[1]]).sort()
let d = (0..<input[0]).map{x[$0+1]-x[$0]}
var ans = 0
for i in d {
    ans = gcd(i, ans)
}
print(ans)

Measured memory_bytes: 6332
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 100010;

int a[N*3];
int n;

int main(){
	n=get();
	fo(i,1,n*3)a[i]=get();
	sort(a+1,a+1+n*3);
	LL ans=0;
	for(int i=n*3-1,j=1;j<=n;i-=2,j++)ans=ans+a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, M;
  cin >> N >> M;
  vector<long long int> a_v(M+1, -1);
  vector<long long int> f(N+1, 0);
  for (int i = 0; i < M; i++) {
    cin >> a_v.at(i);
  }
  // f_n = f_{n-1} + f_{n-2}
  // f_0 = 1
  // f_1 = 1
  // f_2 = 2
  // f_3 = 3
  long long int j = 0;
  for (int i = 0; i <= N; i++) {
    if (a_v[j] == i) {
      j++;
    }
    else {
      if (i >= 2) {
        f[i] = (f[i-1] + f[i-2]) % 1000000007;
      }
      else if (i == 1) {
        f[i] = f[i-1] + 0;
      }
      else if (i == 0) {
        f[i] = 1;
      }
 
    }
  }
  for (int i = 0; i <= N; i++) {
    //cout << "f" << f[i] << endl;
  }
  //cout << "j:" << j << endl;
 
  cout << f[N]%1000000007 << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<vector<int>> a(3, vector<int>(3));
  vector<vector<bool>> c(3, vector<bool>(3, false));
  for (auto&& v : a) {
    for (auto&& e : v) {
      cin >> e;
    }
  }
  int n;
  cin >> n;
  while (n--) {
    int b;
    cin >> b;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (a[i][j] == b) c[i][j] = true;
      }
    }
  }
  bool bingo = false;
  for (int i = 0; i < 3; i++) {
    bool ok = true;
    for (int j = 0; j < 3; j++) {
      if (!c[i][j]) ok = false;
    }
    if (ok) bingo = true;
  }
  for (int i = 0; i < 3; i++) {
    bool ok = true;
    for (int j = 0; j < 3; j++) {
      if (!c[j][i]) ok = false;
    }
    if (ok) bingo = true;
  }
  bool ok = true;
  for (int i = 0; i < 3; i++) {
    if (!c[i][i]) ok = false;
  }
  if (ok) bingo = true;
  ok = true;
  for (int i = 0; i < 3; i++) {
    int j = 2;
    if (i == 1)
      j = 1;
    else if (i == 2)
      j = 0;
    if (!c[i][j]) ok = false;
  }
  if (ok) bingo = true;
  cout << (bingo ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;

int main(){  
int num;

cin>>num;
int A[num];
for(int j=0;j<num;j++){
    cin>>A[j];
}

int max=A[0];
int low=A[0];

for(int i=0;i<num;i++){
    if(max<A[i]){
        max=A[i];
    }

    if(low>A[i]){
        low=A[i];
    }
}
    cout<<max-low<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;

int main(){
    int N,i,j,left,right,ans,tmp;
    char c;
    cin >> N;
    string S;
    cin >> S;
    ans = 0;
    for(i=1;i<N;i++){
        tmp = 0;
        for(c='a';c<='z';c++){
            left = 0; right = 0;
            for(j=0;j<i;j++){
                if(S.at(j)==c)left = 1;
            }
            for(j = i; j < N; j++){
                if(S.at(j)==c)right = 1;
            }
            tmp += left * right;
        }
        if(ans < tmp) ans = tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();

    stdin.read_line(&mut buf).unwrap();
    let sum = buf.trim().split_whitespace().fold(0u8, |acc, e| acc + e.parse::<u8>().unwrap());

    if sum > 21 {
        println!("bust");
    } else {
        println!("win");
    }
}


Measured memory_bytes: 4352
inputs = readlines

hash = Hash.new(0)

inputs.map(&:chomp).each do |line|
  nums = line.split(' ')
  nums.map!(&:to_i)

  if nums.size == 1
    unless hash.empty?
      no_user = true
      hash.each do |k,v|
        if v >= 1_000_000
          puts k
          no_user = false
        end
      end
      puts "NA" if no_user
      hash.clear
    end
    exit if nums[0].zero?
  else nums.size == 3
    hash[ nums[0] ] += (nums[1] * nums[2])
  end
end


Measured memory_bytes: 6924
from sys import exit, setrecursionlimit
setrecursionlimit(1000000)

def dfs(v, dp, to):
  t = dp[v]
  if t >= 0:
    return t
  dp[v] = 0
  t = 0
  for u in to[v]:
    res = dfs(u, dp, to)
    if res == 0:
      print('-1')
      exit()
    if res > t:
      t = res
  t += 1
  dp[v] = t
  return t

def toId(i, j, id_db):
  if i < j:
    return id_db[i][j]
  else:
    return id_db[j][i]

def main():
  N = int(input())
  a = [[int(e) - 1 for e in input().split()] for _ in range(N)]

  id_db = [[0] * N for _ in range(N)]

  dp = [-1] * (N * (N - 1) // 2)
  to = [[] for _ in range(N * (N - 1) // 2)]

  v = 0
  for i in range(N):
    for j in range(i + 1, N):
      id_db[i][j] = v
      v += 1

  for i in range(N):
    for j in range(N - 1):
      a[i][j] = toId(i, a[i][j], id_db)
    for j in range(N - 2):
      to[a[i][j]].append(a[i][j + 1])

  print(max(dfs(i, dp, to) for i in range(N * (N - 1) // 2)))

main()


Measured memory_bytes: 115248
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){
        cout << arr[i] << " ";
    }
    cout << arr[sz-1] << endl;
}


int main(){
    ll n; cin >> n;
    vector<ll> p(n);
    vector<ll> p_num(n);
    rep(i,n){
        cin >> p[i];
        p_num[p[i]-1] = i+1;//one-based
    }
    multiset<ll> st;
    st.insert(0);st.insert(0);
    st.insert(n+1);st.insert(n+1);
    vector<ll> c(n);
    for(ll i = n-1;0 <= i;i--){
        st.insert(p_num[i]);
        // auto st_itr = st.begin();
        // rep(i,st.size()){
        //     cout << *st_itr << " ";
        //     st_itr++;
        // }
        // cout << endl;
        auto itr = st.lower_bound(p_num[i]);
        itr--;itr--;
        ll num[5];
        rep(i,5){
            num[i] = *itr;
            itr++;
        }
        // print(num);
        c[i] = (num[1] - num[0]) * (num[3] - num[2]) + (num[2] - num[1]) * (num[4] - num[3]);
    }

    ll ans = 0;
    rep(i,n){
        ans += (i+1) * c[i];
    }
    // print(p_num);
    // print(c);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;//1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v, LL st = -1, LL en = -1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL H, W;
	cin >> H >> W;
	if (W == 1)cout << 1 << "\n";
	else if (H == 1)cout << 1 << "\n";
	else if (W % 2 == 0) {
		cout << H * W / 2 << "\n";
	}
	else {
		LL ans = 0;
		for (LL y = 1; y <= H; y++) {
			ans += W / 2;
			if (y & 1)ans++;
		}
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	string w1,w2,w[n];
	for(int i=0;i<n;i++){
		cin>>w2;
		w[i]=w2;
		if(i!=0 && w1[w1.size()-1]!=w2[0]){
			cout<<"No"<<endl;
			return 0;
		}
		for(int j=0;j<i;j++){
			if(w[i]==w[j]){
				cout<<"No"<<endl;
				return 0;
			}
		}
		w1=w2;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N, A, B;
    ll answer;

    cin >> N >> A >> B;

    cout << min(N * A, B) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    cout << n + (m/2) << endl;
    return 0;
}

Measured memory_bytes: 256
/* dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll ,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,k,i,j;
	cin>>n>>k;
	if(k==0){cout<<n*n;return 0;}
	ll sum=0;
	for(i=k+1;i<=n;i++)
	{
		ll cy=(n/i);
		ll ans=0;
        ans+=(i-k)*cy;
        ll tt=i*cy+k;
     //   cout<<ans<<"\n";
        if(n-tt+1>0)ans+=n-tt+1;
        sum+=ans;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 3010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define form(l, r, i)	for(int i = l; i <= r; ++i)
#define forv(r, l, i)	for(int i = r; i >= l; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const ll inf = 1e9 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 7;
 
using namespace std;

lld dp[N][N]; // pref:tails
lld a[N];

int main()
{
	barnarnar
	int n;
	cin >> n;
	forn1(i, n)	cin >> a[i];
	dp[0][0] = 1;
	forn1(i, n)
	{
		for(int j = 0; j <= i; j++)
		{
			dp[i][j] = dp[i - 1][j] * (1 - a[i]) + dp[i - 1][j - 1] * a[i];
		}
	}
	lld ans = 0;
	for(int i = n / 2 + n % 2; i <= n; i++)	ans += dp[n][i];
	cout << setprecision(10) << fixed;
	cout << ans;
	return 0;
}
/*
5
11000
11100
01100
00000
00000
*/

Measured memory_bytes: 139776
N, A, B = map(int, input().split())
hs = [int(input()) for i in range(N)]

INF = int(1e9)
l, m, r = 0, INF//2, INF + 1

def calc(n):
    global N, A, B
    d = A - B
    remain = n
    for h in hs:
        tmp = h - B * n
        if tmp > 0:
            remain -= (tmp + d - 1) // d
    return remain >= 0

while r - l > 1:
    if calc(m):
        r = m
    else:
        l = m
    m = (r + l + 1) // 2

print(m)

Measured memory_bytes: 7072
n,d=[int(x) for x in input().split()]
x=[]
for i in range(n):
  X=[int(x) for x in input().split()]
  x.append(X)
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    dis=0
    for k in range(d):
      dis+=(x[i][k]-x[j][k])**2
    for l in range(181):
      if dis==l**2:
        ans+=1
        break
print(ans)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

class SegmentTree {
private:
    int n;
    vector<ll> node;
    ll INF = (1ll << 31) - 1;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, INF);
    }

    void update(int i, ll x) {
        i += (n - 1);
        node[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return node[k];
        ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }

};


int main() {
    int n, q;
    cin >> n >> q;
    ll com, x, y;
    SegmentTree st(n);
    int N = 1;
    while (N < n) N *= 2;
    for (int i = 0; i < q; i++) {
        cin >> com >> x >> y;
        if (com == 0) {
            st.update(x, y);
        } else {
            cout << st.query(x, y + 1, 0, 0, N) << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 4888
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;

	vector<int> v(K);
	for (int i = 0; i < K; i++) {
		cin >> v.at(i);
	}

	while (1) {
		int n = N;
		while (1) {
			if (count(v.begin(), v.end(), n % 10)) {
				N++;
				break;
			} else{
				if (!n) {
					cout << N;
					return 0;
				}
				else {
					n /= 10;
					if (!n) {
						cout << N;
						return 0;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <map>

using namespace std;
int main()
{
	char a,b;
	scanf("%c %c",&a,&b);
//	cout<<a<<" "<<b;
	if(a==b)
	printf("H\n");
	else
	printf("D\n");
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
 
L, R = 0, N
for _ in range(M):
    l, r = map(int, input().split())
    l-=1
    r-=1
    L = max(l, L)
    R = min(r, R)

print(R-L+1 if R-L>=0 else 0)


Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>

using namespace std;



int main() {

	int n;
	cin >> n;
	long long int a[100002] = {};
	long long int b[100002] = {};
	long long int cnt = 0;
	long long int ans = 0;
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
		cnt += a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	int c;
	for (int i = 0; i < n; i++) {
		if (a[i] > 0) {
			if (b[i] - a[i] >= 0) {
				c = a[i];
				b[i] -= a[i];
				a[i] = 0;
			}
			else {
				a[i] -= b[i];
				b[i] = 0;
			}
		}
		if (a[i + 1] > 0) {
			if (b[i] - a[i + 1] >= 0) {
				c = a[i + 1];
				b[i] -= a[i + 1];
				a[i + 1] = 0;
			}
			else {
				a[i + 1] -= b[i];
				b[i] = 0;
			}
		}
	}
	for (int i = 0; i < n + 1; i++) {
		ans += a[i];
	}
	cout << (cnt - ans) << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include <stdlib.h>
 
int main(void)
{
    int s_length,left=0,mid,i,j, q_length,C = 0;
    scanf("%d", &s_length);
    int right=s_length;
    int *s, *q;
    s = (int *)malloc(sizeof(int) * s_length);
    for(i = 0;i < s_length;i++){
        scanf("%d", &s[i]);
    }
     
    scanf("%d", &q_length);
     
    q = (int *)malloc(sizeof(int) * q_length);
    for(i = 0;i < q_length;i++){
        scanf("%d", &q[i]);
    }
     
     
    for(i=0;i<q_length;i++){
        while(left<right){
            mid=(left+right)/2;
            if(s[mid]==q[i]){
                C++;
                break;
            }
            else if(s[mid]>q[i]){
                right=mid;
            }
            else{
                left=mid+1;
            }
        }
        right = s_length;
                left = 0;
    }
    printf("%d\n",C);
    return(0);
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int p[33]={0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
	int N;
	cin >> N;
	cout << p[N] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;


int main() {
  int N, M;
  cin >> N >> M;
  
  map<int, int> obs;
  map<int, int> obs_nice;
  for (int i = 0; i < N; i++) {
    long H;
    cin >> H;
    obs[i + 1] = H;
    obs_nice[i + 1] = 1;
  }
  
  
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    
    if (obs[A] < obs[B]) {
      obs_nice[A] = 0;
    }
    else if (obs[A] == obs[B]) {
      obs_nice[A] = 0;
      obs_nice[B] = 0;
    }
    else {
      obs_nice[B] = 0;
    }
  }
  
  for (int i = 0; i < N; i++) {
    if (obs_nice[i + 1] == 0) {
      obs_nice.erase(i + 1);
    }
  }
  cout << obs_nice.size();
}


Measured memory_bytes: 13008
N,M,Q = map(int,input().split())
l = [[0 for i in range(N)] for j in range(N)]

for _ in range(M):
    L,R = map(int,input().split())
    l[L-1][R-1] += 1

csum = [[0 for i in range(N+1)] for j in range(N+1)]

for i in range(1,N+1):
    for j in range(1,N+1):
        csum[i][j] = csum[i][j-1] + csum[i-1][j] - csum[i-1][j-1] + l[i-1][j-1]

for _ in range(Q):
    p,q = map(int,input().split())
    print(csum[q][q]-csum[q][p-1]-csum[p-1][q]+csum[p-1][p-1])

Measured memory_bytes: 20960
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<int, int> m;
    for(ll i=1;i<=n;i++){
        m[i] = 0;
    }
    rep(i,n-1){
        cin >> a[i];
        m[a[i]]++;
    }
    for(auto x:m){
        cout << x.second << endl;
    }
}

Measured memory_bytes: 14344
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans = 3;
    if(a == b && b==c)ans = 1;
    else if(a == b)ans --;
    else if(a == c)ans--;
    else if(b == c)ans--;
    cout<< ans <<endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let x: i64 = read();
    let mut xv: Vec<bool> = vec![false; x as usize + 1];
    let mut ans = (0, 0);

    for i in 0..120 {
        for j in 0..120 {
            let a = i * i * i * i * i as i64;
            let b = j * j * j * j * j as i64;
            let c = a as i64 * -1;
            let d = b as i64 * -1;
            if a - b == x {
                ans = (i, j);
                break;
            }
            if c - b == x {
                ans = (-i, j);
                break;
            }
            if a - d == x {
                ans = (i, -j);
                break;
            }
            if c - d == x {
                ans = (-i, -j);
                break;
            }
        }
    }
    println!("{} {}", ans.0, ans.1);
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int N;
int A[200010];
int B[200010];

int main(){

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }

    int eq = 0;
    for(int i = 0; i < N; i++){
        if(A[i] == B[i]){
            eq++;
        }
    }
    if(eq == N){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    ll min_b = 1 << 30;
    for(int i = 0; i < N; i++){
        ans += A[i];
        if(A[i]>B[i])
            min_b=min(min_b, (ll)B[i]);
    }
    ans -= min_b;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    string s, t; cin >> s >> t;
    if(s + t[t.size()-1] == t && s.size()+1 == t.size()) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
constexpr long MOD = 1e9 + 7;
using namespace std;

#define MAXSUM 3000
long dp[51][MAXSUM][51];
int xs[51];


int main() {
    int n, a;
    cin >> n >> a;
    REP(i,n) {
        cin >> xs[i+1];
    }
    
    dp[0][0][0] = 1;
    
    for (int i = 1; i < 51; i++) {
        REP(j,MAXSUM) {
            REP(k,51) {
                if (j-xs[i] >= 0 && k > 0) {
                    dp[i][j][k] = dp[i-1][j-xs[i]][k-1] + dp[i-1][j][k];
                } else {
                    dp[i][j][k] = dp[i-1][j][k];
                }
            }
        }
    }
    
    long ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += dp[n][a*i][i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 60032
#include <bits/stdc++.h>

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 2e5;
const ll inf = 1e18;
const ll mod = 1e9 + 7;


 
int main(){
	fastio;
	ll a,b,c;
	string s,t;
	ll ans = inf;
	cin >> s >> t;
	f(i,0,s.size() - t.size()+1){
		ll aux = 0;
		f(j,0,t.size()) if(s[i+j] != t[j]) aux++;
		ans = min(ans,aux);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b;
    cin >>  a >> b;
    if (a * b == 15) {
        puts("*");
    } else if (a + b == 15) {
        puts("+");
    } else {
        puts("x");
    }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;


int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A.at(i);
  }
  ll ans = 0;
  rep(i,N){
    if(i>0){
      if(A.at(i)<A.at(i-1)){
        ans += A.at(i-1) - A.at(i);
        A.at(i) = A.at(i-1);
        //cout << i << ":" << ans << endl;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 4716