akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	int direct, left_in, right_in;
	
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	(a - c) > 0 ? (direct = a - c) : (direct = c - a);
	
	if (d >= direct){
		printf("Yes\n");
		return (0);
	}
	
	(a - b) > 0 ? (left_in = a - b) : (left_in = b - a);
	(b - c) > 0 ? (right_in = b - c) : (right_in = c - b);
	
	if (d >= left_in && d >= right_in){
		printf("Yes\n");
		return (0);
	}
	else {
		printf("No\n");
		return (0);
	}
}


Measured memory_bytes: 128
N = int(input())
X = list(map(int, input().split()))
MOD = 10 ** 9 + 7

cnt = [0] * (N + 1)
for i in reversed(range(N)):
    cnt[i] = cnt[i + 1] + X[i] % MOD

res = 0
for i in range(N):
    res += X[i] * cnt[i + 1] % MOD
    res %= MOD
print(res)


Measured memory_bytes: 94084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Math;

class Program{
    static void Main(){
        string[] s = Console.ReadLine().Split();
        int r,g,b,n;
        r = int.Parse(s[0]);
        g = int.Parse(s[1]);
        b = int.Parse(s[2]);
        n = int.Parse(s[3]);

        int ans = 0;
        for (int i = 0;i * r <= n;i++){
            for (int j = 0;j * g <= n;j++){
                if (r*i + g*j > n) continue;
                if ((n - r * i - g * j) % b == 0) ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
def countint_sort(A, k):
  B = [0] * (len(A))
  C = [0] * (k + 1)
  for j in range(len(A)):
    C[A[j]] += 1
  for i in range(1, k + 1):
    C[i] = C[i] + C[i - 1]
  for j in range(len(A)):
    ib = C[A[j]] - 1
    B[ib] = A[j]
    C[A[j]] -= 1
  return B

n = int(input())
A = list(map(int, input().split()))
print(" ".join(map(str, countint_sort(A, max(A)))))

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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong x, y;
    cin >> x >> y;
    if (x % y == 0) cout << -1 << endl;
    else cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

template<typename T> class Edge{
    public:
        int to;
        T cost;

        Edge(){}
        Edge(int t, T c){
            this->to = t;
            this->cost = c;
        }
        bool operator<(Edge e){return this->cost < e.cost;}
        bool operator>(Edge e){return this->cost > e.cost;}
};

template<typename T> class Graph_list{
    public:
        vector<vector<Edge<T>>> list;

        Graph_list(int n);
        void add(int f, int t, T c);
        void add(int f, int t);
        int size();
        vector<Edge<T>> operator[](int i){
            return list[i];
        }
};

template<typename T> Graph_list<T>::Graph_list(int n){
    list = vector<vector<Edge<T>>>(n + 1, vector<Edge<T>>());
}

template<typename T> void Graph_list<T>::add(int f, int t, T c){
    list[f].push_back(Edge<T>(t, c));
}
template<typename T> void Graph_list<T>::add(int f, int t){
    list[f].push_back(Edge<T>(t, 1));
}
template<typename T> int Graph_list<T>::size(){
    return (int)list.size();
}

template<typename T>
vector<T> bfs_graph(Graph_list<T>& g, int s){
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(g.size(), INF);

    queue<T> que;
    que.push(s);
    dist[s] = 0;
    while(que.size()){
        int p = que.front(); que.pop();
        for (auto e : g[p]){
            if (dist[e.to] == INF){
                dist[e.to] = dist[p] + e.cost;
                que.push(e.to);
            }
        }
    }
    return dist;
}


int main(){
    int n;
    cin >> n;
    Graph_list<ll> G(n);
    REP(i,0,n - 1){
        int a, b, c;
        cin >> a >> b >> c;
        G.add(a, b, c);
        G.add(b, a, c);
    }

    int q, k;
    cin >> q >> k;
    vector<ll> d = bfs_graph<ll>(G, k);
    REP(i,0,q){
        int x, y;
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 11904
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> cnt(n);
    int max = 0;
    int i;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        cnt[tmp]++;
        max = MAX(max, tmp);
    }
    int bad = 0;
    if (max % 2) {
        for (i = 0; i <= max; i++) {
            if (i < (max+1) / 2) {
                if (cnt[i]) {
                    bad = 1;
                    break;
                }
            }
            else if (i == (max + 1) / 2) {
                if (cnt[i] != 2) {
                    bad = 1;
                    break;
                }
            }
            else {
                if (cnt[i] == 0) {
                    bad = 1;
                    break;
                }
            }
        }
    }
    else {
        for (i = 0; i <= max; i++) {
            if (i < max / 2) {
                if (cnt[i]) {
                    bad = 1;
                    break;
                }
            }
            else if (i == max / 2) {
                if (cnt[i] != 1) {
                    bad = 1;
                    break;
                }
            }
            else {
                if (cnt[i] == 0) {
                    bad = 1;
                    break;
                }
            }
        }
    }
    if (bad) {
        printf("Impossible\n");
    }
    else {
        printf("Possible\n");
    }

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
long long int minx(long long int v[],int n){
	int i,j,k;
	long long int tmp;
	tmp=v[0];
	for(i=1;i<=n-1;i++){
		if(tmp>v[i])
		tmp=v[i];}
		return tmp;}
int maxx(int v[],int n){
	int i,j,k,tmp;
	tmp=v[0];
	for(i=1;i<=n-1;i++){
		if(tmp<v[i])
		tmp=v[i];}
		return tmp;}
int max(int n1,int n2,int n3){
	int tmp;
	tmp=n1;
	if(n2>tmp)
	tmp=n2;
	if(n3>tmp)
	tmp=n3;
	return tmp;}
int max2(int n1,int n2){
	int tmp;
	tmp=n1;
	if(n2>tmp)
	tmp=n2;
	return tmp;}
int min3(int n1,int n2,int n3){
	int tmp;
	tmp=n1;
	if(n2<tmp)
	tmp=n2;
	if(n3<tmp)
	tmp=n3;
	return tmp;}
int min2(int n1,int n2){
	int tmp;
	tmp=n1;
	if(n2<tmp)
	tmp=n2;
	return tmp;}
long long int abs(long long int n){
	if(n>=0)
	return n;
	else return(-1)*n;
}
int main(void)
{int N,A,M,B,j,i,k,H,W,l,m,sum,flag;
	sum=0;
	int T[100],P[100],X[100];
	scanf("%d",&N);
	for(i=0;i<=N-1;i++){
		scanf("%d",&T[i]);}
		scanf("%d",&M);
		for(i=0;i<=M-1;i++){
			scanf("%d%d",&P[i],&X[i]);}
			
			for(i=0;i<=N-1;i++){
				sum+=T[i];}
    for(i=0;i<=M-1;i++){
    	printf("%d\n",sum-T[P[i]-1]+X[i]);}
    	
		

	return 0;
}


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

int main() {
  long long N,M;
  cin >> N >> M;
  vector<long long> A(N);
  vector<long long> B(N);
  for (long long i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  
  vector<pair<long long, long long>> p(N);
  for (long long i = 0; i < N; i++) {
    p.at(i) = make_pair(A.at(i),B.at(i));
  }
  
  sort(p.begin(),p.end());
  long long sum = 0;
  long long cost = 0;
  for (int i = 0;i < N; i++) {
    sum += p[i].second;
    cost += p[i].first * p[i].second;
    if (sum >= M) {
      cost -= p[i].first * (sum - M);
      cout << cost << endl;
      break;
    }
  }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

const int N=2*1e5+1;
const int inf = 1e18;
int dp[N][3];
bool vis[N][3];

int n;
int a[N];

int solve(int id,int have){
	if(id>n){
		if(have<=1)
			return 0;
		return -inf;
	}
	
	int &tmp = dp[id][have];
	if(vis[id][have])
		return tmp;
	vis[id][have]=1;
	if(!have)
		tmp = solve(id+2,have)+a[id];
	else{
		tmp =solve(id+2,have)+a[id];
		tmp = max(tmp,solve(id+1,have-1));
	}
	return tmp;
}

int32_t main() { 
    boost;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    int ans ;
    if(n%2)
    	ans = max(solve(1,2),solve(2,1));
    else
    	ans = max(solve(1,1),solve(2,0));
    cout<<ans<<endl;
}           





Measured memory_bytes: 15172
#include <iostream>
#include <cstdio>
#include<cctype>

int main()
{
	char ch;
	while (1) {
		scanf("%c", &ch);

		if (isalpha(ch)) {
			if (islower(ch)) {
				printf("%c", toupper(ch));
			}

			else {
				printf("%c", tolower(ch));
		}

		}
		else if (ch == '\n') {
			printf("\n");
			break;
		}
		else {
			printf("%c", ch);
		}
	}
	
	return 0;
}

Measured memory_bytes: 3108
n = input()
a, b, c, d = int(n[0]), int(n[1]), int(n[2]), int(n[3])

if a + b + c + d == 7:
    print('%d+%d+%d+%d=7' % (a, b, c, d))
elif a + b + c - d == 7:
    print('%d+%d+%d-%d=7' % (a, b, c, d))
elif a + b - c + d == 7:
    print('%d+%d-%d+%d=7' % (a, b, c, d))
elif a + b - c - d == 7:
    print('%d+%d-%d-%d=7' % (a, b, c, d))
elif a - b + c + d == 7:
    print('%d-%d+%d+%d=7' % (a, b, c, d))
elif a - b + c - d == 7:
    print('%d-%d+%d-%d=7' % (a, b, c, d))
elif a - b - c + d == 7:
    print('%d-%d-%d+%d=7' % (a, b, c, d))
else:
    print('%d-%d-%d-%d=7' % (a, b, c, d))

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d = a/b;
	r = a%b;
	f = (1.0*a)/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
s = input()
t= "".join(c for c in s if c!="x")
if t!=t[::-1]:
    print(-1)
else:
    ans=0
    i=0
    j=0
    l=len(s)
    while i+j<l-1:
        if s[i] != s[l-1-j]:
            ans+=1
            if s[i] == "x" : i+=1
            else : j+=1
        else:
            i+=1
            j+=1
    print(ans)

Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	int num = (N + 1000 - 1) / 1000 * 1000;
	cout << num - N << endl;
}


Measured memory_bytes: 3596
n, m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for y in range(n-m+1):
    for x in range(n-m+1):
        flag = [False for _ in range(m)]
        for j in range(m):
            if a[y+j][x:m+x] == b[j]:
                flag[j] = True
        if all(flag):
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 整数の入力
    	int a = sc.nextInt();
    	// スペース区切りの整数の入力
    	int b = sc.nextInt();
    	System.out.println(a+b>9?"error":(a+b));
    }
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	string s;
	cin >> s;

	if(s.find('7') != string::npos){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3624
def solve(A, N):
    B = [0] * len(A)
    for i in range(1, N+1)[::-1]:
        A2 = A[i*2] if i*2 <= N else 0
        x = A[i]
        for j in range(i*2, N+1, i):
            x ^= B[j]
        B[i] = x
    return B

#from random import randint
#solve([0] + list(randint(0, 1) for _ in range(1000)), 1000)
def main():
    N = int(input())
    A = [0] + [int(x) for x in input().split()]
    B = solve(A, N)
    print(sum(B))
    for i in range(1, N+1):
        if B[i]:
            print(i)

main()


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

int main(){
  int a,b;
  cin >> a >> b;
  
  int m = (a+b)/2;
  
  if((a%2)==(b%2)){
    cout << m;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
template<class T>
bool chmax(T &a, const T &b) {
    if(a<b) {
        a=b;
        return true;
    }

    return false;
}
struct Artist {
    int e,s;
    Artist(int e=0,int s=0) :
        e(e),s(s) {}
};
void input(int len, Artist *a) {
    rep(i,len) {
        string ss;
        int e,s;
        cin>>ss>>e>>s;
        a[i]=Artist(e,s);
    }
}
Artist artist1[102], artist2[102];
// ??????????????????????????°?????????
int dp1[102][5][1003];
int dp2[102][102][1003];

int lim,n,m,x;

void solve() {
    rep(i,102) rep(j,5) rep(k,1003) dp1[i][j][k]=-1;
    rep(i,102) rep(j,102) rep(k,1003) dp2[i][j][k]=-1;

    input(n,artist1);
    input(m,artist2);
    dp1[0][0][0]=dp2[0][0][0]=0;

    rep(i,n) rep(j,3) rep(k,lim) {
        Artist a=artist1[i];
        int lim_n = k+a.e;
        if(lim_n <= lim&&dp1[i][j][k]!=-1) 
            chmax(dp1[i+1][j+1][lim_n],dp1[i][j][k]+a.s);
        chmax(dp1[i+1][j][k],dp1[i][j][k]);
    }
    rep(i,m) rep(j,m) rep(k,lim) {
        Artist a=artist2[i];
        int lim_n = k+a.e;
        if(lim_n <= lim&&dp2[i][j][k]!=-1) 
            chmax(dp2[i+1][j+1][lim_n],dp2[i][j][k]+a.s);
        chmax(dp2[i+1][j][k],dp2[i][j][k]);
    }

    //rep(i,20) printf("%d %d\n",i,dp1[n][2][i]);
    //rep(i,20) printf("%d %d\n",i,dp2[m][2][i]);

    int ans=0;
    rep(i,lim) {
        int max1=max(dp1[n][1][i],dp1[n][2][i]);
        int max2=0;
        for(int j=x;j<=m;j++) for(int k=0;k<=lim-i;k++) chmax(max2,dp2[m][j][k]);

        chmax(ans,max1+max2);
        // printf("%d %d : %d\n",i,lim-i,max1+max2);
    }

    cout<<ans<<endl;
}

int main() {
    while(cin>>lim>>n>>m>>x) {
        if(lim+n+m+x==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 43968
import itertools
def main():
    n,m,x = map(int, input().split())
    c = [list(map(int, input().split())) for _ in range(n)]
    ans = 10**9

    for i in range(2**n):
        bit = format(i, f'0={n}b')
        rikaido = [0]*m
        kingaku = 0
        for num, val in enumerate(bit):
            if val == '1':
                kingaku += c[num][0]
                for num2, val2 in enumerate(c[num][1:]): rikaido[num2] += val2
        if min(rikaido) >= x:
            ans = min(kingaku, ans)

    print(-1) if ans == 10**9 else print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9212
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> A, B;


  return (A*500 >= B ? "Yes" : "No");
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
 
	long long int s,c;
 
	cin>>s>>c;
	if(s>=c/2){
		cout<<c/2<<endl;
	}
 
	if(c/2>s){
		cout<<s+(c-s*2)/4<<endl;
	}
 
	return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)



function isOk(a, b, c)
    return (a + b > c) && (b + c > a) && (c + a > b) 
end

function main()
N = parseInt(readline())
L = parseMap(split(readline()))
ans = 0
for i in 1:N
    for j in i+1:N
        for k in j+1:N
            if (k == i) || (k == j)
                continue
            else
                if (L[i] != L[k]) && (L[k] != L[j]) && (L[i] != L[j]) && isOk(L[i], L[j], L[k])
                    ans += 1
                end
            end
        end
    end
end
println(ans)
end

main()

Measured memory_bytes: 165096
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int l;
	long num;
	while(cin>>num>>l){
		if(num==0 && l==0) break;
		vector<long> a;
		a.push_back(num);
		int c=0,d=-1;
		while(1){
			vector<int> number;
			for(int i=0;i<l;i++){
				number.push_back(num%10);
				num /=10;
			}
			sort(number.begin(),number.end());
			long max=0,min=0;
			int t=1;
			for(int i=0;i<l;i++){
				max += t*number[i];
				min += t*number[number.size()-1-i];
				t *=10;
			}
			num=max-min;
			c++;
			for(int i=0;i<a.size();i++){
				if(num==a[i]){
					d=i;
					break;
				}
			}
			if(d>=0) break;
			a.push_back(num);
		}
		cout<<d<<" "<<num<<" "<<c-d<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int ans=0;
int main(){
    int n;
    cin>>n;
    lint dp[n+1];
    vector <int>v;
    v.pb(1);
    for(int i=6;i<n+1;i++){
        if(i%9==0){
            double temp=i;
            while(temp>=9){
                temp/=9;
            }
            if(temp==1){
                v.pb(i);
            }
        }
        if(i%6==0){
            double temp=i;
            while(temp>=6){
                temp/=6;
            }
            if(temp==1){
                v.pb(i);
            }
        }
    }
    rep(i,n+1){
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=1;i<n+1;i++){
        for(int j=0;j<v.size();j++){
            if(i-v[j]>=0){
                dp[i] = min(dp[i - v[j]] + 1, dp[i]);
            }
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */

/*struct*/
struct aaa {
	aaa() {
		cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

signed main()
{
//input
	int n; cin >> n;
	map<string, int,less<>> ms;

    REP(i, n){
      string s;cin >> s;
      ms[s]++;
    }
  
    int m;cin >> m;
    REP(i, m) {
      string s;cin >> s;
      ms[s]--;
    }

//process



//output
    int ans = 0;
    for(const auto& p : ms){
      ans = max(ans, p.second);
    }
    cout << ans << endl;

	return 0;
}

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

int main() {
  int N , T , Ans , Y , M ;
  cin >> N >> T ;
  
  M = 0;
  Y = 0;
  
  vector<int> vec(N);
  for (int i=0 ; i<N ; i++){
    cin >> vec.at(i) ; 
}
  for (int i=0 ; i<N-1 ; i++){
    int d = vec.at(i+1) - vec.at(i) ; 
    if (d >= T) M++ ;
    else Y = Y + d ;
  }
  // cout << T << endl << M << endl << Y << endl ;
  Ans = T + M*T + Y ;
  cout << Ans ; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  long long S;
  cin >> N >> M >> S;
  int NN = N * 5002;
  vector<vector<pair<int, long long>>> graph(NN);
  auto inf = [&](int v) { return v * 5002 + 5001; };
  auto node = [&](int v, int c) { return c > 5000 ? inf(v) : v * 5002 + c; };
  for (int i = 0; i < M; i++) {
    int U, V, A;
    long long B;
    cin >> U >> V >> A >> B;
    U--, V--;
    graph[inf(U)].emplace_back(inf(V), B);
    graph[inf(V)].emplace_back(inf(U), B);
    for (int c = A; c <= 5000; c++) {
      graph[node(U, c)].emplace_back(node(V, c - A), B);
      graph[node(V, c)].emplace_back(node(U, c - A), B);
    }
  }
  for (int i = 0; i < N; i++) {
    long long C, D;
    cin >> C >> D;
    for (int c = 0; c <= 5000; c++) {
      graph[node(i, c)].emplace_back(node(i, c + C), D);
    }
  }
  long long dist[NN];
  const long long INF = LLONG_MAX / 10;
  fill(dist, dist + NN, INF);
  dist[node(0, S)] = 0;
  priority_queue<pair<long long, int>> que;
  que.push(make_pair(0, node(0, S)));
  while (!que.empty()) {
    int v;
    long long d;
    tie(d, v) = que.top();
    que.pop();
    d = -d;
    if (dist[v] < d) continue;
    for (auto e : graph[v]) {
      int u = e.first;
      if (dist[u] > dist[v] + e.second) {
        dist[u] = dist[v] + e.second;
        que.push(make_pair(-dist[u], u));
      }
    }
  }
  for (int i = 1; i < N; i++) {
    long long ans = INF;
    for (int c = 0; c <= 5001; c++) {
      ans = min(ans, dist[node(i, c)]);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 44384
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int X, Y, Z;
	cin >> X >> Y >> Z;

	cout << Z << ' ' << X << ' ' << Y << endl;

	return 0;
}

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

using namespace std;
typedef pair<int, int> p;

int main(){
  int n, m;

  while(cin >> n && cin >> m){
    set<int> start;
    set<int> end;
    
    for(int i = 0; i < m; i++){
      int t1, t2;
      cin >> t1; cin >> t2;
      
      if(t1 == 1) start.insert(t2);
      if(t2 == n) end.insert(t1);
    }

    bool flg = false;    
    for(auto i = start.begin(); i != start.end(); i++){
      if(end.count(*i) == 1){
	flg = true;
	break;
      }
    }

    if (flg) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  REP(i, n) {
    cout << s[i] << t[i];
  }
}

Measured memory_bytes: 256
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int pc(int x)
{
	int s=0;
	while(x)
		s+=x&1,x>>=1;
	return s;
}
int n,m;
typedef pair<int,int> pii;
#define mp make_pair
ll ans=0;
priority_queue<pii> q;
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;++i)
	{
		int x=read();
		q.push(mp(x-x/2,x));
	}
	while(m--)
	{
		int x=(q.top()).second;
		q.pop();
		x/=2;
		q.push(mp(x-x/2,x));
	}
	while(!q.empty())
	{
		ans+=(q.top()).second;
		q.pop();
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	unordered_map<char, int> m = {{'M',0}, {'A',0}, {'R',0}, {'C',0}, {'H',0}};
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		auto it = m.find(s[0]);
		if (it != m.end()) it->second++;
	}
	vector<long long> v;
	v.reserve(5);
	for (auto&& p : m) v.push_back(p.second);
	long long count = 0;
	for (int i = 0; i < 3; i++)
		for (int j = i+1; j < 4; j++)
			for (int k = j+1; k < 5; k++)
				count += v[i]*v[j]*v[k];
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

vector<int> Zalgo(const string &S) {
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}


struct TopologicalSort {
    vector<vector<int>> E; TopologicalSort(int N) { E.resize(N); }
    void add_edge(int a, int b) { E[a].push_back(b); }
    bool visit(int v, vector<int>& order, vector<int>& color) { color[v] = 1;
        for (int u : E[v]) { if (color[u] == 2) continue; if (color[u] == 1) return false;
            if (!visit(u, order, color)) return false; } order.push_back(v); color[v] = 2; return true; }
    bool sort(vector<int> &order) { int n = E.size(); vector<int> color(n);
        for (int u = 0; u < n; u++) if (!color[u] && !visit(u, order, color)) return false;
        reverse(order.begin(), order.end()); return true; } };

int main(){
    string S, T;
    int NS, NT;
    int dp[2010101] = {0};

    cin >> S >> T;
    string s = S;
    while (S.length() < T.length()) S += s;
    NS = S.length();
    NT = T.length();
    string match = T + "#" + S + S;
    vector<int> z;
    z = Zalgo(match);
    TopologicalSort ts(NS);

    REP(i ,NT+1, NT+1+ NS + NS) {
        if (z[i] == NT) {
            ts.add_edge(i % NS, (i + NT) % NS);
//            cout << i << endl;
        }
    }

    vector<int> ord;
    bool res = ts.sort(ord);
    if (res == false) {
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    for (auto cu: ord) {
        chmax(ans, dp[cu]);
        for (auto to: ts.E[cu]) chmax(dp[to], dp[cu] + 1);
    }

    cout << ans << endl;



}

Measured memory_bytes: 93024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n, m;
    while(cin >> n >> m) {
        if(!n && !m) break;
        vector<int> v1(n), v2(m);
        int sum1 = 0, sum2 = 0;
        rep(i,0,n) {
            cin >> v1[i];
            sum1 += v1[i];
        }
        rep(i,0,m) {
            cin >> v2[i];
            sum2 += v2[i];
        }

        int s = INF;
        pii ans;
        rep(i,0,n) {
            rep(j,0,m) {
                int t1 = sum1 - v1[i] + v2[j];
                int t2 = sum2 - v2[j] + v1[i];
                if(t1 == t2 && v1[i] + v2[j] < s){
                    s = v1[i] + v2[j];
                    ans = pii(v1[i], v2[j]);
                }
            }
        }
        if(s == INF) cout << -1 << endl;
        else printf("%lld %lld\n", ans.fr, ans.sc);
    }
    return 0;
}

Measured memory_bytes: 3160
a, b = input().split(" ")
x = int(a)
y = int(b)

amt = 0
if x == 1:
    amt += 300000
elif x == 2:
    amt += 200000
elif x == 3:
    amt += 100000

if y == 1:
    amt += 300000
elif y == 2:
    amt += 200000
elif y == 3:
    amt += 100000

if x == 1 and y == 1:
    amt += 400000

print (amt)

Measured memory_bytes: 3064
import sys

n = int(input())
pos = input().split()
#print(len(pos))

xmin = int(min(pos))
xmax = int(max(pos))

for ii in range(xmin, xmax+1):
    
    nowmax = 0

    for p in pos:
        nowmax = nowmax + pow((ii - int(p)),2)

    nextmax = 0
    for p in pos:
        nextmax = nextmax + pow(((ii+1) - int(p)),2)

    if nextmax >= nowmax:
        print(nowmax)
        sys.exit()

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

/////////////////////////////////////////////////////////////////////////////////////////

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	int n;
	string str;
	cin>>n>>str;
	int sum=0,l=0,r=0,ok=0;
	for(int i=0;i<n;i++)
		if(str[i]=='(')
			l++;
		else if(l>0){
			l--;
			ok++;
			r++;
		}
		else
			r++;
	r-=ok;
	for(int i=1;i<=r;i++)
		str="("+str;
	for(int i=1;i<=l;i++)
		str=str+")";
	cout<<str;
	return 0;
}


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

ll Q, H, S, D, N;

int main() {
    cin >> Q >> H >> S >> D >> N;

    ll S_min = min(S, min(2*H, min(H+2*Q, 4*Q)));
    ll D_min = min(D, 2*S_min);

    ll ans = N/2*D_min + (N%2)*S_min;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int color[200][200];
bool flg[200][200];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int w,h,n,c,d,x,y;

void dfs(int ny,int nx,int gy,int gx){
	flg[ny][nx]=true;
	rep(i,4){
		int nex=nx+dx[i];
		int ney=ny+dy[i];
		if(nex>=w || nex<0 || ney>=h || ney<0)continue;
		if(color[ney][nex]==color[ny][nx] && flg[ney][nex]==false)dfs(ney,nex,gy,gx);
	}
	return;
}

int main(){
	pair<int,int> s,g;
	while(1){
		rep(i,200)rep(j,200)color[i][j]=flg[i][j]=0;
		cin>>w>>h;
		if(w==0 && h==0)break;
		cin>>s.first>>s.second;
		cin>>g.first>>g.second;
		cin>>n;
		rep(i,n){
			cin>>c>>d>>x>>y;
			if(d==0){
				rep(j,2){
					rep(k,4){
						color[y-1+j][x-1+k]=c;
					}
				}
			}else{
				rep(j,4){
					rep(k,2){
						color[y-1+j][x-1+k]=c;
					}
				}
			}
		}
		dfs(s.second-1,s.first-1,g.second-1,g.first-1);
		if(flg[g.second-1][g.first-1])cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
	}
	return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a,b,c;
    cin >> a >> b >> c;
    if(a<=c && c<=b) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) a[i] -= (i + 1);

  ll ans = 0;
  sort(a.begin(), a.end());
  ll b = a[n / 2];
  rep(i, n) ans += abs(a[i] - b);
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
#include <cstring>
using namespace std;
int main() {
    int n;
    cin>>n;
    if(n>=30) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
char a[200];
int b[200];
set<int>s;
set<int>ss;
int main()
{
    int anss=0,n;
    scanf("%d",&n);
    scanf("%s",a);
    for(int i=0;i<n;i++)
    {
        s.clear();
        ss.clear();
        int ans=0;
        for(int j=0;j<i;j++)
        {
            s.insert(a[j]-'a');
        }
        for(int j=i;j<n;j++)
        {
            if(s.count(a[j]-'a')&&!ss.count(a[j]-'a'))
            {
                ans++;
                ss.insert(a[j]-'a');
            }
        }
        anss=max(anss,ans);
    }
    printf("%d\n",anss);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX 1100

int N;
int C[MAX];
vector<pair<int,int>> G[MAX];

int solve(int node){
	int res = 0;
	
	for(pair<int,int> y : G[node]){
		if(C[y.first]) res += y.second;
		else res += min(y.second, solve(y.first));
	}
	
	return res;
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int u, v, p;
	
	cin>>N;
	
	for(int i = 1; i < N; i++){
		cin>>C[i];
	}
	
	for(int i = 0; i < N-1; i++){
		cin>>u>>v>>p;
		
		G[u].push_back(make_pair(v,p));
	}
	
	cout<<solve(0)<<endl;
	
	return 0;
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define has_bit(bit_mask, x) ((bit_mask) & (1Uint << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1Uint << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1Uint << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define int ll
#define double ld
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    bool arr[3] {};
    arr[a-1] = true;
    arr[b-1] = true;
    for (int i = 0; i < 3; ++i)
    {
        if (!arr[i])
        {
            cout << i+1 << '\n';
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
int N,K;
vi A;
int datas[1145141]={0};
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
ll forodd[514514];
map<pair<ll,ll>, int> exi;
vector<pair<ll,ll> >kouho,data;
int main(){
	cin>>N;
	int ans=N;
	rep(i,N){
		ll x,y;
		cin>>x>>y;
		exi[mp(x,y)]=1;
		data.pb(mp(x,y));
	}
	for(int i=0;i<N;i++)for(int j=0;j<N;j++){
		if(i!=j){
			ll p=data[i].first-data[j].first;
			ll q=data[i].second-data[j].second;
			int ans_=N;
			rep(k,N){
				int nowx=data[k].first,nowy=data[k].second;
				if(exi[mp(nowx-p,nowy-q)])ans_--;
			}
			ans=min(ans,ans_);
		}
	}
	cout<<ans<<endl;

}





Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)
using namespace std; 
const int N=2e5+40;
int n,a[N],b[N],aa[N],bb[N],ans;
int main(){ 
	/*
#ifndef ONLINE_JUDGE
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
*/
	scanf("%d",&n);
	rep(i,1,n)scanf("%d",a+i);
	rep(i,1,n)scanf("%d",b+i);
	lop(k,0,29){
		int qwq=(1<<(k+1))-1;
		rep(i,1,n)aa[i]=a[i]&qwq;
		rep(i,1,n)bb[i]=b[i]&qwq;
		sort(aa+1,aa+n+1);
		sort(bb+1,bb+n+1);
		rep(i,1,n)Pr("%d ",aa[i]);Pr("\n");
		rep(i,1,n)Pr("%d ",bb[i]);Pr("\n");
		int tot=0,l1=n+1,r1=n+1,l2=n;
		rep(i,1,n){
			while(l1-1>=1&&aa[i]+bb[l1-1]>=(1<<k))--l1;
			while(r1-1>=1&&aa[i]+bb[r1-1]>=(1<<(k+1)))--r1;
			while(l2>=1&&aa[i]+bb[l2]>=((1<<(k+1))+(1<<k)))--l2;
			tot^=(r1-l1)&1;
			tot^=(n-l2)&1;
			Pr("%d,%d,%d %d,%d\n",i,l1,r1,l2,n);
		}
		if(tot)ans+=1<<k;
	}
	printf("%d\n",ans);
    return 0; 
}


Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;

public static class Program {
    public static void Main() {
        int[]nW=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n=nW[0];
        int W=nW[1];
        int[]w=new int[n];
        long[]v=new long[n];
        for(int i=0;i<n;i++){
            int[]wv=Console.ReadLine().Split().Select(int.Parse).ToArray();
            w[i]=wv[0];
            v[i]=(long)wv[1];
        }
        long[]dp=new long[W+1];
        for(int i=0;i<n;i++) {
            for(int j=W-w[i];j>=0;j--){
                Chmax(ref dp[j+w[i]], dp[j]+v[i]);
            }
        }
        long ans=0;
        for(int i=0;i<=W;i++){
            Chmax(ref ans, dp[i]);
        }
        Console.WriteLine(ans);
    }
    public static void Chmax(ref long x, long y) {
        x = Math.Max(x, y);
    }
}



Measured memory_bytes: 13920
#include<iostream>
#include<cstdio>
using namespace std;
int n,ans,cntw,cntr; char s[2002020];
int main()
{
	cin>>n;
	scanf("%s",s+1);
	int l=1,r=n,ans=0;
	while(l<=r){
		while(s[l]=='R' && l<=r)++l;
		while(s[r]=='W' && l<=r)--r;
		if(l>r)break;
		++l; --r; ++ans;
	} cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3824