akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static int res = 0;

	public static void main(String[] args) throws Exception {

		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < a.length; i++)
			a[i] = sc.nextInt();
		for (int i = 0; i < a.length; i++)
			b[i] = sc.nextInt();
		for (int i = 0; i < a.length; i++)
			c[i] = sc.nextInt();

		System.out.println(helper(a, b, c));

	}

	private static long helper(int[] a, int[] b, int[] c) {
		// TODO Auto-generated method stub
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);

		long[] A = new long[a.length];
		long[] B = new long[a.length];
		Arrays.fill(A, -1);
		Arrays.fill(B, -1);
		int j=a.length-1;
		for (int i = a.length-1; i >=0; i--) {
			for (; j >=0; j--) {
				if (a[j] < b[i]) {
					A[i] =j+1;
					break;
				}
			}
			if (j < 0)
				break;
		}
		j = 0;
		for (int i = 0; i < a.length; i++) {
			for (; j < b.length; j++) {
				if (c[j] > b[i]) {
					B[i] = a.length - j;
					break;
				}
			}
			if (j > b.length)
				break;
		}
		long res = 0;

		for (int i = 0; i < a.length; i++) {
			if(A[i]>0&&B[i]>0)
			res+=A[i]*B[i];
		}
		return res;
	}

	private static void out(int[] c) {
		for(int i=0;i<c.length;i++) 
			System.out.print(c[i]+" ");
		System.out.println();
	}
}

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

int main(){
  int r, g, b, k;
  cin >> r >> g >> b >> k;
  rep(i,k){
    if(r >= g) g *= 2;
    else if(g >= b) b*= 2;
  }
  if(r<g && g<b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>

int main() {
  std::string S;

  std::cin >> S;

  int ans = 0;

  for (auto const c : S) {
    if (c == '+')
      ans++;
    else if (c == '-')
      ans--;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
A = list(map(int, input().split()))

A_max = max(A)
# A_str = format(A_max, "b")
# A_len = len(A_str)

# print("A_max: {} A_str: {} A_len: {}".format(A_max, A_str, A_len))
# format_opt = "0{}b".format(A_len)
# print("format_opt: {}".format(format_opt))
mask = 0
for a in A:
    mask = mask ^ a
# print(mask)

ans = []
for a in A:
    ans.append(a ^ mask)

print(*ans)

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N), C(M), D(M);
  for(int i=0; i<N; i++){
    cin >> A.at(i) >> B.at(i);
  }
  for(int i=0; i<M; i++){
    cin >> C.at(i) >> D.at(i);
  }
  vector<int> I(N, 0);
  int L=800000000;
  for(int i=0; i<N; i++){
    L=800000000;
    for(int j=0; j<M; j++){
      int X=abs(A.at(i)-C.at(j))+abs(B.at(i)-D.at(j));
      if(X<L){
        L=X;
        I.at(i)=j+1;
      }
    }
  }
  for(int i=0; i<N; i++){
    cout << I.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	int n;
	
	cin >> n;
	
	vector<int> v(n);
	
	for (int i=0; i<n; i++) {
		
		cin >> v[i];
		
	}
		
	int counter = 0;
	
	for (int i=1; i<=n-2; i++) {
	
		if(v[i-1] > v[i] && v[i] > v[i+1]){
		
		counter++;	
			
		}
		
		if(v[i-1] < v[i] && v[i] < v[i+1]){
		
		counter++;	
			
		}
		

    }
	
	cout << counter <<endl;
	
    return 0;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
ll gcd(ll x, ll y) {
	if (!y)return abs(x);
	return gcd(abs(y), abs(x % y));
}
int main() {
//	file();
	fast();
	int k; cin >> k;
	ll ans = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int z = 1; z <= k; z++) {
				ans += gcd(gcd(i, j), z);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
using namespace std;
int t;
main()
{
	cin>>t;
	while(t--)
	{
		unsigned int a[8],c,k=0,d=1,m=0;
		for(int i=0;i<8;i++)scanf("%x",&a[i]);
		scanf("%x",&c);
		for(int i=0;i<32;i++)
		{
			unsigned int now=0,sum=0;
			for(int j=0;j<8;j++)
			{
				now+=a[j]/d%2;
				sum+=(a[j]&m)^k;
			}
			now+=sum/d;
			k|=(c/d%2!=now%2)*d;
			d<<=1;
			m=d-1;
		}
		printf("%x\n",k);
	}
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	int n;	cin>>n;
	n*=2;
	int i,l[n];
	for(i=0;i<n;i++){
		cin>>l[i];
	}
	sort(l,l+n);
	int ans=0;
	for(i=0;i<n;i+=2){
		ans+=l[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,r;
    cin>>n>>m>>r;
    vector<int> t(r);
    for(int i=0;i<r;i++)cin>>t[i];
    for(int i=0;i<r;i++)t[i]--;

    //グラフの初期化
    int d[201][201];
    for(int i=0;i<201;i++){
        for(int j=0;j<201;j++){
            d[i][j]=inf;
        }
    }

    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        d[a][b]=c;
        d[b][a]=c;
    }

    //ワ―シャルフロイド
    for(int k=0;k<200;k++){
        for(int i=0;i<200;i++){
            for(int j=0;j<200;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }

    //next_permutationで全部調べる
    int res=inf;
    sort(All(t));
    do{
        int sd=0;
        for(int i=1;i<r;i++){
            sd+=d[t[i-1]][t[i]];
        }
        res=min(res,sd);
    }while(next_permutation(All(t)));

    cout<<res<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -1e18
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}


void solve()
{
  
  char c;
  cin >> c;
  cout<<(char)(c+1)<<endl;

}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001;
const ll INF=1LL<<60;

int main(){
    
    int N,M;cin>>N>>M;
    vector<int> A(100001,0);
    for(int i=0;i<M;i++){
        int a;cin>>a;
        A[a]++;
    }
    
    int dp[N+1];
    for(int i=0;i<N+1;i++){
        dp[i]=0;
    }
    dp[0]=1;
    
    for(int i=1;i<=N;i++){
        if(i==1){
            if(A[i]) dp[i]=0;
            else dp[i]=1;
        }else{
            if(A[i]) dp[i]=0;
            else{
                dp[i]=(dp[i-2]+dp[i-1])%mod;
            }
        }
    }
    
    cout<<dp[N]<<endl;
}



Measured memory_bytes: 1024
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def solve(n, x):
    ans = 0
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i + j + k == x:
                    ans += 1
    return ans


def main():
    nx = map(int, read().split())

    for n, x in zip(*[iter(nx)]*2):
        if (n, x) == (0, 0):
            exit()
        print(solve(n, x))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

// 双方向DP
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, t;
  cin >> n >> t;
  vector<pair<int, int>> dishes(n+1);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    dishes[i+1] = make_pair(a, b);
  }
  vector<vector<ll>> dp1(n+2, vector<ll>(t+1, 0));
  vector<vector<ll>> dp2(n+2, vector<ll>(t+1, 0));

  for (int i = 1; i < n+1; i++) {
    rep(j, t+1) {
      if (dishes[i].first > j) {  // 食べ終わらない
        dp1[i][j] = dp1[i-1][j];
      } else {
        dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-dishes[i].first] + dishes[i].second);
      }
    }
  }

  for (int i = n; i > 0; i--) {
    rep(j, t+1) {
      if (dishes[i].first > j) {
        dp2[i][j] = dp2[i+1][j];
      } else {
        dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j-dishes[i].first] + dishes[i].second);
      }
    }
  }

  ll ans = 0;
  for (int i = 1; i < n+1; i++) {
    for (int j = 0; j < t; j++) {
      chmax(ans, dp1[i-1][j] + dp2[i+1][t-1-j] + dishes[i].second);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 141312
//mOzis_
/////*31022618*/////
//****//MONU KUMAR\****//
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define p1(x) cout <<x <<"\n"
#define p2(x,y) cout <<x <<" " <<y <<"\n"
#define p3(x,y,z) cout <<x <<" " <<y <<" " <<z <<"\n"
#define nL cout<<"\n"
#define lp(i,l,r) for (long long int i = l; i < r; i++)
#define mem(a,x) memset(a,x,sizeof(a))              //set elements of array to some value
#define pi 3.1415926535897932384626
#define mod 1000000007
#define pb(x) push_back(x)
#define ff first
#define ss second
#define siz 256                        //characters are stored using 8 bit and there can be
bool anagram(char *s1, char *s2)     //256 possible characters only in lowercase alphabet
{
	ll count[siz];
    mem(count,0) ;
    ll i;
    for (i = 0; s1[i] && s2[i];  i++)
    {
        count[s1[i]]++;
        count[s2[i]]--;
    }
    if (s1[i] || s2[i])
    {
      return false;
    }
    lp(i,0,siz)
    {
    	 if (count[i])
    	 {
    	 	 return false;
    	 }
    }
     return true;

}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	ll t=0;
	//cin>>t;
	clock_t launch=clock();
	ll n,sum=0;
	cin>>n;
	ll a[n+1],b[n];
	lp(i,0,n+1)
	{
		cin>>a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin>>b[i];
	}
	for (int i = 0; i < n; ++i)
	{
		if (a[i]>=b[i])
		{
			sum+=b[i];
		}
		else
		{
			sum+=a[i];
			b[i]-=a[i];
			if (a[i+1]>=b[i])
			{
				sum+=b[i];
				a[i+1]-=b[i];
			}
			else
			{
				sum+=a[i+1];
				a[i+1]=0;

			}
		}

	}
	cout<<sum<<"\n";

	clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
	return 0;
}
//////////*********************end of program*********************//////////



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define inf 1e18;
#define PI acos(-1)
const int M = 1000000007;
const int N=2e5+5;
//#define local
#ifdef local
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif



void solve() {

    int s , w;
    cin >> s >> w;
    if(w >= s){
        cout << "unsafe\n";
    }
    else{
        cout << "safe\n";
    }
}


signed main()
{
    FAST;
    //TODO:  check test cases are there or not?
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++)
    {
        solve();
    }
}

Measured memory_bytes: 3652
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
a,b=n1()

if a>12:
    ans=b
elif a>=6:
    ans=b//2
else:
    ans=0
print(ans)

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

int N, K;

vector<int> d;
vector<vector<int>> A;


void input(){
    cin >> N >> K;
    d.resize(K);
    A.resize(K, vector<int>());
    for(int i = 0; i < K; i++){
        cin >> d[i];
        A[i].resize(d[i]);
        for(int j = 0; j < d[i]; j++){
            cin >> A[i][j];
        }
    }
}

void solve() {
    int ans = 0;
    for(int i = 1; i <= N; i++){
        bool have = false;
        for(auto v : A){
            for(auto p : v){
                if(p == i) have = true;
            }
        }
        if(!have) ans++;
    }
    cout << ans << endl;
}
  
int main(){
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int main(){
    int w,n,a,b,i,te;
    int da[100];
    scanf("%d",&w);
    scanf("%d",&n);
    for(i=1;i<=w;i++) da[i]=i;
    for(i=1;i<=n;i++){
        scanf("%d,%d",&a,&b);
        te=da[a];
        da[a]=da[b];
        da[b]=te;
    }
    for(i=1;i<=w;i++) printf("%d\n",da[i]);
    return 0;
}

Measured memory_bytes: 596
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  n=I()

  for i in range(n):
    if s[i]!='1':
      return s[i]

  return 1

print(main())


Measured memory_bytes: 5420
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    int k,n;cin>>k>>n;
    int maxlength=0;
    int a[2000001];
    rep(i,n)cin>>a[i];
    rep(i,n-1)maxlength=max(a[i+1]-a[i],maxlength);
    maxlength=max(k-a[n-1]+a[0],maxlength);

    cout << k-maxlength <<endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

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

#define MAX 220

int main(void)
{
	int n;
	while (cin >> n, n) {
		vector<pii> pos;
		pos.push_back(pii(0, 0));
		rep(i, n-1) {
			int p, d;
			cin >> p >> d;
			int x = pos[p].first, y = pos[p].second;
			pos.push_back(pii(x+dx[d], y+dy[d]));
		}
		int x1, y1, x2, y2;
		x1 = x2 = pos[0].first;
		y1 = y2 = pos[0].second;
		REP(i, 1, pos.size()) {
			if (x1 < pos[i].first) x1 = pos[i].first;
			if (x2 > pos[i].first) x2 = pos[i].first;
			if (y1 < pos[i].second) y1 = pos[i].second;
			if (y2 > pos[i].second) y2 = pos[i].second;
		}
		printf("%d %d\n", abs(x1-x2)+1, abs(y1-y2)+1);
	}
	return 0;
}

Measured memory_bytes: 1180
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
int a[50];


int main () {
  string s;
  int count = 0;
  cin >> s;
  rep(i,4) a[s[i] - 'A']++;
  rep(i,40) if(a[i] == 2) count++;
  if(count == 2) s = "Yes";
  else s = "No";
  cout << s << endl; 
}


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

int main(){
    int W, H;
    
    while(true){
        cin >> H >> W;
        if(W==0 && H==0) break;
        for(int i=0; i<W; i++){
            cout << "#";
        }
        cout << endl;
        for(int i=1; i< H-1; i++){
            cout << "#";
            for(int j=1; j < W-1; j++){
                cout<<".";
            }
            cout<<"#"<< endl;
        }
        for(int i=0; i<W; i++){
            cout << "#";
        }
        cout << endl;
        cout << endl;
    }
    
    
    return 0;
    
}


Measured memory_bytes: 3092
from operator import mul
from functools import reduce
def cmb(n,r):
  if n<r:
    return 0
  r = min(n-r,r)
  if r == 0: return 1
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1,r + 1))
  return over // under
from collections import Counter as cnt
n=int(input())
l=list(map(int,input().split()))

dic=cnt(l)

s1={}
s2={}
for k,v in dic.items():
  s1[k]=cmb(v,2)
  s2[k]=cmb(v-1,2)
s=sum(s1.values())
for i in range(n):
  x=l[i]
  print(s-s1[x]+s2[x])

Measured memory_bytes: 114508
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
ll f(ll x,ll y,ll z){
    return x*x+y*y+z*z+x*y+y*z+z*x;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    map<ll,ll> mp;
    ll n;
    cin>>n;
    rep3(i,1,sqrt(n+1)){
        rep3(j,1,sqrt(n+1)){
            rep3(k,1,sqrt(n+1)){
                mp[f(i,j,k)]++;
            }
        }
    }
    rep3(i,1,n+1){
        cout<<mp[i]<<endl;
    }
}


Measured memory_bytes: 5964
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> ls[100000];
int cost[100000];
int main(){
	int v,e,r;	cin>>v>>e>>r;
	for(int i=0;i<e;i++){
		int s,t,d;	cin>>s>>t>>d;
		ls[s].push_back(make_pair(t,d));
	}
	for(int i=0;i<100000;i++)	cost[i]=INT_MAX;
	cost[r]=0;
	priority_queue<pair<int,int>> pq;
	pq.push(make_pair(0,r));
	while(!pq.empty()){
		auto cur=pq.top();	pq.pop();
		int dist=-cur.first,now=cur.second;
		if(dist>cost[now])	continue;
		for(int i=0;i<(int)ls[now].size();i++){
			int to=ls[now][i].first,d=ls[now][i].second;
			if(dist+d<cost[to]){
				cost[to]=dist+d;
				pq.push(make_pair(-cost[to],to));
			}
		}
	}
	for(int i=0;i<v;i++){
		if(cost[i]==INT_MAX)	cout<<"INF"<<endl;
		else 	cout<<cost[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13012
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w", stdout);
    // #endif
  int n,m; cin>>n>>m;
  vector<int> a(m);
  ll sum=0;
  for(int i=0;i<m;i++){
    cin>>a[i];
    sum+=a[i];
  }
  if(sum>n)
    cout<<"-1\n";
  else
    cout<<n-sum<<"\n";

  return 0;
}

Measured memory_bytes: 3700
import numpy as np
from queue import Queue
n,k = map(int,input().split())
A = [a-1 for a in list(map(int,input().split()))]
A = np.cumsum(+np.array([0]+A))%k

dic = {}
ans = 0
Q = Queue()
for a in A:
    Q.put(a)
    if a in dic:
        ans += dic[a]
        dic[a] += 1
    else:
        dic[a] = 1
    if Q.qsize() == k:
        q = Q.get()
        dic[q] -= 1
    # print(dic)
print(ans)

Measured memory_bytes: 39532
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                count += 1 
print(count)

Measured memory_bytes: 3060
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: i64 = sc.get();
    let B: i64 = sc.get();
    if A > 9 || B > 9 {
        println!("-1");
    } else {
        println!("{}", A*B);
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		simpleCalculator();

	}
	
	public static void simpleCalculator() {
		
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			
			int a = Integer.parseInt(sc.next());
			char[] op = (sc.next()).toCharArray();
			int b = Integer.parseInt(sc.next());

			if (op[0] == '+') {
				System.out.println(a + b);
			} else if (op[0] == '-') {
				System.out.println(a - b);
			} else if (op[0] == '*') {
				System.out.println(a * b);
			} else if (op[0] == '/') {
				System.out.println(a / b);
			} else if (op[0] == '?') {
				break;
			}
		}
	}
	
}


Measured memory_bytes: 26048
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int sx,sy;
int tx,ty;
int main(){
	cin >> sx >> sy;
	cin >> tx >> ty;
	int dx = tx-sx;
	int dy = ty-sy;
	for(int i=0;i<dy;i++){
		cout << 'U';
	}
	for(int i=0;i<dx+1;i++){
		cout << 'R';
	}
	for(int i=0;i<dy+1;i++){
		cout << 'D';
	}
	for(int i=0;i<dx+1;i++){
		cout << 'L';
	}
	cout << 'U';
	cout << 'L';
	for(int i=0;i<dy+1;i++){
		cout << 'U';
	}
	for(int i=0;i<dx+1;i++){
		cout << 'R';
	}
	for(int i=0;i<dy+1;i++){
		cout << 'D';
	}
	for(int i=0;i<dx;i++){
		cout << 'L';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n = 0, m = 0, i = 0, j = 0, a[55] = {0}, b[55] = {0}, c[55] = {0}, d[55] = {0}, dif = 0, total = 0, dif1 = 0, x = 0;
    cin >> n >> m;
    for(i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
    }
    for(i = 1; i <= m; i++)
    {
        cin >> c[i] >> d[i];
    }
    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= m; j++)
        {
            if(a[i] - c[j] < 0)
            {
                dif = dif + (a[i] - c[j]) * -1;
            }
            else
            {
                dif = dif + (a[i] - c[j]);

            }
             if(b[i] - d[j] < 0)
            {
                dif1 = dif1 + (b[i] - d[j]) * -1;
            }
            else
            {
                dif1 = dif1 + b[i] - d[j];
            }
            if(j == 1)
            {
                total = dif + dif1 + 1;
            }


            if(dif + dif1 < total)
            {
                total = dif + dif1;
                x = j;
            }
                dif = 0;
                dif1 = 0;

        }
        cout << x << endl;

    }

return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }
    else if(a < b){
        cout << "a < b" << endl;
    }
    else{
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int a, b, c;
    cin >> a >> b >> c;
	
  	set<int> s;
  	s.insert(a);
  	s.insert(b);
  	s.insert(c);
  
  	if(s.size() == 2)
      	cout << "Yes" << endl;
    else
	    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    int n;
    cin>>n;
    int sum=0;
    rep(i,n)sum+=(i+1);
    cout<<sum<<endl;

    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;
template <typename T>
using V = std::vector<T>;

using namespace std;

int main() {
  V<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(all(a));
  out(a[2] - a[0]);
}


Measured memory_bytes: 3636
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}
const ll N=1e5+5;
   ll ar[100005];
   ll size[100005];
    void start(ll n)
    {
        for(ll i=0;i<=n;i++)
          {ar[i]=i;size[i]=1;}
    }
    ll root(ll i)
    {
       while(i!=ar[i])
       {
         ar[i]=ar[ar[i]];
         i=ar[i];
       }
       return i;
    }
    void uni(ll a,ll b)
    {
       ll root_a=root(a);
       ll root_b=root(b);
       if(root_a==root_b)
        return;
       if(size[root_a]<size[root_b])
       {
          ar[root_a]=ar[root_b];
          size[root_b]+=size[root_a];
       }
       else
       {
         ar[root_b]=ar[root_a];
         size[root_a]+=size[root_b];
       }
    }
    set<ll> v[N];
    set<ll> s[N];
int32_t main()
{   
     IOS;
     ll n,m,i,j,k;
     cin>>n>>m>>k;
     start(n);
     for(i=0;i<m;i++)
     {
       ll uu,vv;
       cin>>uu>>vv;
       uni(uu,vv);
       v[uu].insert(vv);
       v[vv].insert(uu);
     }
     for(i=0;i<k;i++)
     {
      ll uu,vv;
      cin>>uu>>vv;
      if(root(uu)==root(vv))
      {
        v[uu].insert(vv);
        v[vv].insert(uu);
      }
     }
     for(i=1;i<=n;i++)
     {
       ll ri=root(i);
       // cout<<i<<" "<<root(i)<<endl;
       s[ri].insert(i);
     }
     for(i=1;i<=n;i++)
     {
       ll ri=root(i);
       // cout<<s[ri].size()<<endl;
       cout<<(s[ri].size()-v[i].size()-1)<<" ";
       // cout<<temp.size()-1<<" ";

     }
    
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 35200
#include <stdio.h>

int main(void)
{
	int i, j;
	char str[100];
	int n;
	
	while (scanf("%s", str) != EOF){
		i = 0;
		while (str[i] != '\0'){
			if (str[i] == '@'){
				str[i + 1] -= '0';
				for (j = 1; j < str[i + 1]; j++){
					printf("%c", str[i + 2]);
				}
				i += 2;
			}
			
			printf("%c", str[i]);
			i++;
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 1e6+5;
int main()
{
	sync;
	ll k;
	cin >> k;
	if(k % 7 == 0)
		k /= 7;
	ll sum = 0, pow = 1;
	for(ll i = 0 ; i <= 1e6; i++)
	{
		sum = (sum + pow) % k;
		if(!sum)
			return cout << i + 1, 0;
		pow = (pow * 10) % k;
	}
	cout << -1 ;
}
	

Measured memory_bytes: 3588
import java.io.*;
import java.util.*;

public class Main {
    private void solve() {
        int n = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int[] ans = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                int d = j - i;
                d = Math.min(d, Math.abs(i - x) + 1 + Math.abs(j - y));
                d = Math.min(d, Math.abs(i - y) + 1 + Math.abs(j - x));
                ++ans[d];
            }
        }

        for (int i = 1; i < n; ++i) {
            out.println(ans[i]);
        }
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 23124
A,B=map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c=set(prime_factorize(A))
d=set(prime_factorize(B))
ans=len(c.intersection(d))
print(ans+1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    string s;
    int rei=0,one=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){
            rei++;
        }
        if(s[i]=='1'){
            one++;
        }
    }
    cout<<min(rei,one)*2<<"\n";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
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; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int A,B,K;
int main() {
  cin >> A >> B >> K;
  ll n = gcd(A,B);
  int cnt = 0;
  for (int i=n; i > 0; i--) {
    if (n % i != 0) continue;
    cnt++;
    if (cnt == K) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  ll res = 0;
  rep(i, s.size()) {
    if (s.at(i) == '1') res++;
  }
  cout << res << endl;
}

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

int memo[1111][11][1111];

int solve(int bit, int n, int s){
  
  if(!n && !s) return memo[bit][n][s] = 1;
  if(!n || s < 0) return memo[bit][n][s] = 0;
  if(~memo[bit][n][s]) return memo[bit][n][s];

  int ans = 0;
  for(int i=0;i<10;i++){
    if(!(bit&(1<<i))) ans += solve(bit|(1<<i), n-1, s-i*n);
  }

  return memo[bit][n][s] = ans;
}

int main(){

  int n, s;
  memset(memo, -1, sizeof(memo));
  
  while(cin >> n >> s) cout << solve(0, n, s) << endl;
  
}

Measured memory_bytes: 54204
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    string O, E;
    cin >> O >> E;
    rep(i, E.size()) cout << O[i] << E[i];
    if (O.size() > E.size()) cout << O[O.size() - 1];
    cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <bitset>
using namespace std;


inline bool in(int a, int b, int c){
	return a <= b && b < c;
}


int main(){
	int m, n, d, s;
	while( scanf("%d%d%d", &m, &n, &d), m != 0 ){
		int sz = m * n;
		vector<bitset<626> > v(sz);
		bitset<625> used;

		int p = 0;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < m; ++j, ++p){
				v[p][p] = true;
				
				for(int k = 0; k < d; ++k){
					if( in(0, i - d + k, n) && in(0, j + k, m) ){
						v[p][(i - d + k) * m + (j + k)] = true;
					}
					if( in(0, i + k, n) && in(0, j + d - k, m) ){
						v[p][(i + k) * m + (j + d - k)] = true;
					}
					if( in(0, i + d - k, n) && in(0, j - k, m) ){
						v[p][(i + d - k) * m + (j - k)] = true;
					}
					if( in(0, i - k, n) && in(0, j - d + k, m) ){
						v[p][(i - k) * m + (j - d + k)] = true;
					}
				}

				scanf("%d", &s);
				if( s != 0 ){
					v[p][sz] = true;
				}
			}
		}

		for(int i = 0; i < sz; ++i){
			int index = -1;

			for(int j = 0; j < sz; ++j){
				if( !used[j] && v[j][i] ){
					index = j;
					used[j] = true;
					break;
				}
			}

			if( index >= 0 ){
				for(int j = 0; j < sz; ++j){
					if( j == index || !v[j][i] ) continue;

					for(int k = 0; k <= sz; ++k){
						if( v[index][k] ){
							v[j].flip(k);
						}
					}
				}
			}
		}


		int ans = 1;
		for(int i = 0; i < sz; ++i){
			if( v[i][sz] && v[i].count() == 1 ){
				ans = 0;
				break;
			}
		}
		
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1084
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		b = new boolean[101];
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			lists = new ArrayList[101];
			for (int i = 0; i < 101; i++)
				lists[i] = new ArrayList<Integer>();
			while (n-- > 0) {
				int from = scanner.nextInt();
				int to = scanner.nextInt();
				lists[from].add(to);
				lists[to].add(from);
			}
			ans = 0;
			
			for (int i = 0; i < 101; i++) {
				if (lists[i].isEmpty())
					continue;
				b[i] = true;
				slove(i, 1);
				b[i] = false;
			}
			System.out.println(ans);
		}
	}

	private void slove(int from, int step) {

		ans = Math.max(ans, step);
		for (int to : lists[from]) {
			if (b[to])
				continue;
			b[to] = true;
			slove(to, step + 1);
			b[to] = false;
		}
	}

	int ans;
	boolean[] b;
	List<Integer>[] lists;
}

Measured memory_bytes: 282436
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,sum = 0,tmp,cnt = 0,i;
    string str,str1;
   cin>>str>>str1;
    str+=str1;
    stringstream geek(str);
    geek>>tmp;
    int tmp2 = sqrt(tmp);
    if(tmp2*tmp2==tmp)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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

int n, k;
ll a[101010];

const long long int MOD = 1000000007;
const int MAX_K = 202020;

long long int fac[MAX_K], finv[MAX_K], inv[MAX_K];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX_K; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long int COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main()
{
    COMinit();
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    
    ll maxX = 0;
    sort(a, a + n);
    rep(i, n)
    {
        maxX += ((a[i] + MOD) * COM(i, k - 1)) % MOD;
        maxX %= MOD;
    }
    //cout << maxX << endl;

    ll minX = 0;
    reverse(a, a + n);
    rep(i, n)
    {
        minX += ((a[i] + MOD) * COM(i, k - 1)) % MOD;
        minX %= MOD;
    }
    //cout << minX << endl;
    ll res = maxX - minX;
    if(res < 0) res += MOD;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l,i,k;
    string s[100];
    scanf("%d%d",&n,&l);
    for(i=0; i<n; i++)
        cin >> s[i];
    sort(s,s+n);
    for(i=0; i<n; i++)
        cout << s[i];
    return 0;
}


Measured memory_bytes: 3696
#include <iostream>

using namespace std;

int main() {
  int l[10], v1, v2;
  while (!cin.eof()) {
    int len = 0;
    for (int i = 0; i < 10; i++) {
      cin >> l[i];
      cin.ignore();
      len += l[i];
      if (cin.eof()) return 0;
    }
    cin >> v1; cin.ignore();
    cin >> v2;
    double dist = (double)len * v1 / (v1 + v2);
    int i = 0;
    for (int s = 0; s < dist && i < 10; s += l[i], i++) {}
    cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  double av;
  int x[200000]={},m[200000]={},n,a,b;
  cin>>n;
  for(int i=0;i<n;i++){cin>>x[i];m[i]=x[i];}
  sort(m,m+n);
  a=m[n/2];
  b=m[n/2-1];
  av=(a+b)/2;
  for(int i=0;i<n;i++)
    if(av>=x[i])cout<<a<<endl;
    else cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 3712