akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from datetime import date

n = [0]*101
for s in sys.stdin:
  d = int(s)
  n[d] += 1
m = max(n)
for i in [ j for j in range(len(n)) if n[j] == m ]:
  print i

Measured memory_bytes: 4396
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <climits>
#include <queue>
#include <bitset>
#include <complex>
#include <stack>
#include <unordered_set>

using namespace std;

//#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define len(v) (int)v.size()
#define pii pair<int, int>
#define x first
#define y second

typedef long double ld;
typedef long long ll;

signed main() {
    
    iostream::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    string s;
    cin >> s;
    if (len(s) >= 4 && s.substr(0, 4) == "YAKI") {
        cout << "Yes";
    }
    else
        cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
# ALDS_1_B.

def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def get_gcd(x, y):
    if x < y: return get_gcd(y, x)
    # x >= yのときはx % yを計算してyとx % yの話にする。
    # ここでx % yのところが0ならばyが求める答えとなる。
    if y == 0: return x
    return get_gcd(y, x % y)

def main():
    a = intinput()
    x = a[0]; y = a[1]
    # Pythonではa, bのswapはa, b = b, aとか書く。
    print(get_gcd(x, y))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5600
#include <cstdio>
#ifdef _MSC_VER
#include <conio.h>
#else
#define getch()
#endif
#define MY_LIMIT 50

inline int ABS(int A){
	return A>=0?A:-A;
}

int main(){
	int N=0;
	int M=0;
	int DataX[MY_LIMIT]={};
	int DataY[MY_LIMIT]={};
	int PointX[MY_LIMIT]={};
	int PointY[MY_LIMIT]={};
	scanf(" %d %d",&N,&M);
	for(int i=0;i<N;i++){
		scanf(" %d %d",&DataX[i],&DataY[i]);
	}
	for(int i=0;i<M;i++){
		scanf(" %d %d",&PointX[i],&PointY[i]);
	}
	for(int i=0;i<N;i++){
		int NowNum=0;
		int NowMin=ABS(DataX[i]-PointX[0])+ABS(DataY[i]-PointY[0]);
		for(int j=1;j<M;j++){
			int Temp=ABS(DataX[i]-PointX[j])+ABS(DataY[i]-PointY[j]);
			if(Temp<NowMin){
				NowNum=j;
				NowMin=Temp;
			}
		}
		printf("%d\n",NowNum+1);
	}
	getch();
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>

int c[3][3];
bool check(int temp_a) {
	int a[3], b[3];

	a[0] = temp_a; 
	b[0] = c[0][0] - a[0];

	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];

	b[1] = c[0][1] - a[0];
	b[2] = c[0][2] - a[0];

	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			if (a[i] + b[j] != c[i][j])
				return false;
	return true;
}
int main() {
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			scanf("%d", &c[i][j]);

	bool res = false;
	for (int i = -200; i <= 200; i++)
		res |= check(i);
	
	printf("%s\n", res ? "Yes" : "No");
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
	int n, k, x;
	int num[10] = {0};

	scanf("%d%d", &n, &k);
	for(int i=0; i < k; i++) {
		scanf("%d", &x);
		num[x] = 1;
	}

	while(1) {
		x = n;
		while(x) {
			if(num[x%10])
				break;
			x /= 10;
		}
		if(x == 0) {
			printf("%d", n);
			break;
		}
		n++;
	}

	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<fstream>

#define rep(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005
#define pb push_back
#define MP make_pair

using namespace std;

int main(){
	lint n,a[SIZE]={},ans=0;
	cin>>n;
	int c;
	rep(i,0,n){
		cin>>c;
		a[c]++;
	}
	int i=1;
	rep(i,1,100000){
		if(a[i]>1)ans+=a[i]-1;
	}
	if(ans%2==1)ans++;
	ans=n-ans;
	cout<<ans;
return 0;
}

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

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main(void){
    int n, comp, ans;
    cin >> n;
    comp = n / 100;
    ans = comp*100 + comp*10 + comp;
    if(ans >= n) cout << ans << endl;
    else cout << (comp + 1)*100 + (comp + 1)*10 + comp + 1 << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
int main() {
  int N,A,B;
  string S;
  cin >> N >> A >> B;
  cin >> S;
  int gakusei=0,kaigai=0;
  for(int i=0;i<N;i++){
    if(S[i]=='a'&&gakusei<A+B){
      gakusei++;
      Yes();
    }
    else if(S[i]=='b'&&gakusei<A+B&&kaigai<B){
      gakusei++;
      kaigai++;
      Yes();
    }
    else{
      No();
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

void check(string S){
    vector<bool> YY(2,false);
    vector<bool> MM(2,false);

    for(int i = 0;i<4;i+=2){
        int a = S[i] - '0';
        int b = S[i+1] - '0';

        int n = a * 10 + b;
        //cout << n << endl;

        if(n > 0 and n <= 12) MM[i/2] = true;
        if(n >= 0) YY[i/2] = true;
    }
    if(YY[0] and YY[1] and MM[0] and MM[1]) cout <<"AMBIGUOUS";
    else if(YY[0] and MM[1]) cout <<"YYMM";
    else if(YY[1] and MM[0]) cout <<"MMYY";
    else cout << "NA";
}

int main(){
    string S;
    cin >> S;
    check(S);

    return 0;
}




Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const k = parseInt(args[0][0], 10)
	console.log(Math.floor(k / 2) * Math.floor((k + 1) / 2))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
#define all(v) ((v).begin()),((v).end())
#define clr(v,val) memset(v,val,sizeof v)
void file(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);  
#endif
}
void fast(){
	std::ios_base::sync_with_stdio(0); cin.tie(NULL);
}
const int N = 510 + 20;
int dist(pair<int,int>a,pair<int,int>b){
	int x = abs(a.first-b.first);
	int y = abs(a.second -b.second);
	return x + y;
}
/***You***Can***Do***It***/
int main()
{
	fast();
	int n;
	while (cin >> n){
		vector < pair<int, int>>p(n);
		vector<int>t1(n);
		map<pair<int, int>,int>mp;
		bool ok = 1;
		for (int i = 0; i < n; i++){
			cin >> t1[i] >> p[i].first >> p[i].second;
			
		}
		int t = 0;
		pair<int, int>nw(0,0);
		nw.first = 0;
		nw.second = 0;
		for (int i = 0; i < n; i++){
			int di = dist(nw, p[i]);
			if (nw == p[i]){
				ok = 0;
				break;
			}
			if ((di >(t1[i] - t))|| (di%2==0&&di!=(t1[i]-t))){
				ok = 0;
				break;
			}
			nw = p[i];
			t = t1[i];
		}
		if (ok)
			cout << "Yes" << endl;
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1408
def main():
  n = int(input())
  X = tuple(map(int, input().split(" ")))

  mx = max(X)
  mn = min(X)

  ans = float("inf")

  for p in range(mn, mx + 1):
    ans = min(ans, sum([(x - p) ** 2 for x in X]))

  print(ans)


main()


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

ll gcd(ll a, ll b){
    if(b==0) return a;
    else return gcd(b, a%b);
}

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

    vector<int> Left(N);
    Left[0] = A[0];
    for(int i=1; i<N; i++){
        Left[i] = gcd(Left[i-1], A[i]);
    }
    vector<int> Right(N);
    Right[N-1] = A[N-1];
    for(int i=N-2; i>=0; i--){
        Right[i] = gcd(Right[i+1], A[i]);
    }

    int ans = max(Left[N-2], Right[1]);
    for(int i=1; i<=N-2; i++){
        int tmp = gcd(Left[i-1], Right[i+1]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}   

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int n,m,h,w;
int p[26];
signed main(){
	int i,j,k;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cin>>n;
	b=min(b,a*2);
	c=min(c,b*2);
	d=min(d,c*2);
	int ans=0;
	if(n%2)
		ans=(n/2)*d+c;
	else
		ans=(n/2)*d;
	cout<<ans<<endl;
}

Measured memory_bytes: 764
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [[-1,0] for i in range(K+1)]
for i in range(K+1):
    for j in range(N):
        if i+a[j]<=K:
            if dp[i+a[j]][1] == 0:
                dp[i+a[j]][0] = dp[i][0]*(-1)
                dp[i+a[j]][1] = 1
            else:
                if dp[i][0] == -1:
                    dp[i+a[j]][0] = 1 
if dp[K][0] == 1:
    print('First')
else:
    print('Second')

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
vec<vll> dp;
vii restore;
/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(30);

    int n,weight; cin >> n >> weight;
    vi w(n), v(n); rep(i,n) cin >> w[i] >> v[i];
    dp.resize(n+1, vll(weight+1));
    restore.resize(n+1, vi(weight+1));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= weight; ++j) {
            if(j-w[i] >= 0) {
                if(chmax(dp[i+1][j], dp[i][j-w[i]] + v[i])) {
                    restore[i+1][j] = j-w[i];
                }
            }
            if(chmax(dp[i+1][j], dp[i][j])) {
                restore[i+1][j] = j;
            }
        }
    }
    cout << dp[n][weight] << '\n';

// 復元
    // stack<int> answers;
    // int j = weight;
    // for(int i = n-1; i >= 0; --i) {
    //     if(restore[i+1][j] == j-w[i]) {
    //         answers.emplace(i+1);
    //     }
    //     j = restore[i+1][j];
    // }
    // while(answers.size()) {
    //     cout << answers.top() << '\n';
    //     answers.pop();
    // }
}

Measured memory_bytes: 119280
using System;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var x = int.Parse(Console.ReadLine());

            Console.WriteLine(x>=30 ? "Yes": "No");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27456
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
int n,m;
int li[maxn],ri[maxn];
int c[maxn];
int res;
int ans;
int main()
{
	scanf("%d%d",&n,&m);
	memset(c,0,sizeof(c));
	for(int i=1;i<=m;i++){
		scanf("%d%d",&li[i],&ri[i]);
		c[li[i]]+=1;
		c[ri[i]+1]-=1;
	}
	
	for(int i=1;i<=n;i++){
		res+=c[i];
		if(res==m) ans++;
	}
	
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      cout<<"Yes"<<endl;
      return(0);
    }
  }
  cout<<"No"<<endl;
  return(0);
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
#include<iostream>

using namespace std;

int main()
{
	string s1;
	cin >> s1;
	
	string s2 = "AKIHABARA";
	int idx = 0;
	int f = 1;
	
	int take[100]={0};
	if (s2.size() < s1.size()) f = 0;
	
	
	
	for (int i = 0; i < s1.size(); i++)
	{
		if (idx >= s2.size())
		{
			f = 0;
			break;
		}
		
		while (s1[i]!=s2[idx])
		{
			idx++;
			if (idx >= s2.size())
			{
				f = 0;
				break;
			}
		}
		take[idx]=1;
		idx++;
	}
	
	for (int i = 0; i < s2.size(); i++)
	{
		if (!take[i] && s2[i]!='A') f = 0;
	}
	
	if (f)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

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

int
main ()
{

  string str;
  cin >> str;
  int n;
  cin >> n;

  for (int i = 0; i < n; i++){
      
      string a = "";
      int b = 0;
      int c = 0;
      string d = "";
      cin >> a;
      cin>>b>> c;
      
 
      if (a == "replace")
	{
	  cin >> d;
	  str.replace (b, c - b + 1, d);

	}
      else if (a == "reverse")
	{
	  string s=str.substr (b, c - b + 1);
	  reverse (s.begin (),s.end ());
           str=str.substr(0,b)+s+str.substr(c+1,str.length());
           
          
	}
      else if (a=="print")
	{
	  cout << str.substr (b, c - b + 1) << endl;

	}
  }

  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  if(n==10) {
    cout << 9 << endl;
    return 0;
  }
  bool ok = false;
  repr(i,n,0) {
    rep(j,1,10){
      rep(k,1,33){
        if(i==pow(k,j)) ok = true;
      }
    }
    if(ok){
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;
const double PI = 3.14159265358979323846;
//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

ll L,R,d;
  cin>>L>>R>>d;
  ll counter=0;
  for(int i=L;i<R+1;i++){
    if(i%d==0){
      counter++;
    }
  }
  cout<<counter<<endl;
  
}



Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

// 0-based index
// tree size: 2 * NN - 1
// leaves indices: [NN - 1, 2 * NN - 1)
template<class T>
struct SegTree {
    int NN;
    T default_value;
    vector<T> data;

    T aggr(T a, T b) {
        return max(a, b);
    }

    SegTree(int N, T val) {
        default_value = val;
        NN = 1; while (NN < N) NN <<= 1;
        data = vector<T>(2 * NN, val);
    }

    SegTree(const vector<T> v, T val) {
        default_value = val;
        int N = v.size();
        NN = 1; while (NN < N) NN <<= 1;
        data = vector<T>(2 * NN, val);
        copy(v.begin(), v.end(), data.begin() + (NN - 1));
        build(0, 0, NN);
    }

    void build(int u, int l, int r) {
        if (r - l == 1) return;
        int m = (l + r) / 2;
        build(u * 2 + 1, l, m);
        build(u * 2 + 2, m, r);
        data[u] = aggr(data[2 * u + 1], data[2 * u + 2]);
    }

    T query(int a, int b, int u, int l, int r) {
        if (l >= b || r <= a)
            return default_value;
        if (l >= a && r <= b)
            return data[u];
        int m = (l + r) / 2;
        T res1 = query(a, b, u * 2 + 1, l, m);
        T res2 = query(a, b, u * 2 + 2, m, r);
        return aggr(res1, res2);
    }

    void update(int idx, T x, int u, int l, int r) {
        if (idx < l || idx >= r)
            return;
        if (idx == l && r - l == 1) {
            data[u] = x;
            return;
        }
        int m = (l + r) / 2;
        update(idx, x, u * 2 + 1, l, m);
        update(idx, x, u * 2 + 2, m, r);
        data[u] = aggr(data[2 * u + 1], data[2 * u + 2]);
    }

    void increment(int idx, T x, int u, int l, int r) {
        update(idx, data[NN - 1 + idx] + x, u, l, r);
    }
};

template <class T>
ostream & operator << (ostream &out, const SegTree<T> &seg) {
    out << "SegTree(NN=" << seg.NN << ", ";
    for (int u = seg.NN - 1, sz = seg.NN; sz >= 1; u /= 2, sz /= 2) {
        out << "[ ";
        for (int i = 0; i < sz; i++) {
            out << seg.data[u + i] << " ";
        }
        out << "]";
    }
    out << ")";
    return out;
}

int solve() {
    int H, W, M;
    cin >> H >> W >> M;

    auto cntR = vector<int>(H, 0);
    auto cntC = vector<int>(W, 0);
    auto t = vector<vector<int>>(H, vector<int>());
    for (int i = 0; i < M; i++) {
        int r, c; 
        cin >> r >> c;
        r--; c--;
        cntR[r]++;
        cntC[c]++;
        t[r].push_back(c);
    }

    auto seg = SegTree<int>(cntC, 0);
    // cout << seg << endl;
    int ans = -1;
    for (int r = 0; r < H; r++) {
        for (auto c : t[r]) {
            seg.increment(c, -1, 0, 0, seg.NN);
        }
        // cout << seg << endl;
        int val = cntR[r] + seg.query(0, W, 0, 0, seg.NN);
        ans = max(ans, val);
        for (auto c : t[r]) {
            seg.increment(c, +1, 0, 0, seg.NN);
        }
    }
    return ans;
}

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

    cout << solve() << endl;

    return 0;
}

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

int n;
int ret;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		int x;scanf("%d",&x);
		if(i%2&&x%2)++ret;
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 3760
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);++i)

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

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

int A, B, C, K;

int main() {
    cin >> A >> B >> C >> K;
    int ans = 0;

    int k = K;

    if (A <= k) {
        ans += A;
        k -= A;
    } else {
        ans += k;
        k = 0;
    }

    k -= B;

    if (k > 0) {
        if (C <= k) {
            ans -= C;
        } else {
            ans -= k;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}



class Program
{
    static int MAX_V = 100 * 100;
    
    class Edge {
	public int to, cap, rev;
	public Edge(int _to, int _cap, int _rev)
	{
	    to = _to; cap = _cap; rev = _rev;
	}
    }

    static List<Edge>[] G;
    static bool[] used;

    static void AddEdge(int from, int to, int cap)
    {
	G[from].Add(new Edge(to, cap, G[to].Count));
	G[to].Add(new Edge(from, 0, G[from].Count - 1));
    }

    static int dfs (int v, int t, int f)
    {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].Count; i++)
	{
	    Edge e = G[v][i];
	    if (!used[e.to] && e.cap > 0)
	    {
		int d = dfs(e.to, t, Math.Min(f, e.cap));
		if (d > 0)
		{
		    e.cap -= d;
		    G[e.to][e.rev].cap += d;
		    return d;
		}
	    }
	}
	return 0;
    }

    static int MaxFlow(int s, int t)
    {
	int flow = 0;
	while (true)
	{
	    used = new bool[MAX_V];
	    int f = dfs(s, t, 1000000000);
	    if (f == 0) return flow;
	    flow += f;
	}
    }
    
    public static void Main()
    {
	G = new List<Edge>[MAX_V];
	for (int i = 0; i < MAX_V; i++)
	    G[i] = new List<Edge>();

	int n = int.Parse(ReadLine());
	int[] a = new int[n];
	int[] b = new int[n];
	int[] c = new int[n];
	int[] d = new int[n];

	for (int i = 0; i < n; i++)
	{
	    var tmp = ReadIntArray();
	    a[i] = tmp[0]; b[i] = tmp[1];
	}
	for (int i = 0; i < n; i++)
	{
	    var tmp = ReadIntArray();
	    c[i] = tmp[0]; d[i] = tmp[1];
	}

	// node#
	//  red : 1 .. n
	//  blue: n+1 .. 2n
	//  s:0, t: 2n+1
	for (int i = 0; i < n; i++)
	{
	    for (int j = 0; j < n; j++)
	    {
		if (a[i] < c[j] && b[i] < d[j])
		{
		    AddEdge(i+1, n+j+1, 1);
		}
	    }
	}

	for (int i = 1; i <= n; i++)
	{
	    AddEdge(0, i, 1);
	    AddEdge(n+i, 2*n+1, 1);
	}

	WriteLine(MaxFlow(0, 2*n+1));
    }
}


Measured memory_bytes: 15028
X=[0]*60
M=10**9+7
N=int(input())
T=500000004

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

for a in A:
    for k in range(60):
        X[k]+=a%2
        a>>=1


Y=0
y=1
for b in X:
    Y+=b*(N-b)*y
    Y%=M
    y<<=1
print(Y)


Measured memory_bytes: 124316
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int get_int(char *line, int size) {
  if(!fgets(line, size, stdin)) return 0;
  int num;
  sscanf(line, "%d", &num);
  return num;
}
#define BUF_SIZE 6
#define NUM_MAX 200

int main(void) {
  char line[BUF_SIZE];
  int maximum = get_int(line, BUF_SIZE);
  int ans = 0;
  int num, j;
  for(num = 1; num <= maximum; num+=2) {
      int cnt = 0;
      for(j = 1; j <= num; j+=2) {
          if(num % j == 0) cnt++;
      }
      if(cnt == 8) ans++;
  }

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
// ------------------------------------
// Date:2018/ 4/ 7
// Problem:/ / / c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  vector< int > d(3);
  int even, odd;
  even = odd = 0;
  int evenMax, oddMax;
  evenMax = oddMax = 0;
  REP(i, 3) {
    cin >> d[i];
    if (d[i] & 1) {
      odd++;
      oddMax = max(oddMax, d[i]);
    }else {
      even++;
      evenMax = max(evenMax, d[i]);
    }
  }

  sort(ALL(d));

  int tmp;
  ll ans = 0ll;
  if (odd == 0 or even == 0) {
    while(1) {
      if (d[0] == d[1] && d[0] == d[2]) break;
      ans++;
      d[0] += 2;
      sort(ALL(d));
    }
  } else {
    if (odd == 1) {
      RREP(i, 3) {
	if (d[i] & 1) {
	  tmp = i;
	  break;
	}
      }
      // oddをevenのmax+1にしてからのこりを揃える
      while(d[tmp] < evenMax) {
	ans++;
	d[tmp] += 2;
      }
      sort(ALL(d));
      while(1) {
	if (d[0] == d[1]) break;
	ans++;
	d[0] += 2;
	sort(ALL(d));
      }
      ans += d[2] - d[1];
    } else {
      RREP(i, 3) {
	if (!(d[i] & 1)) {
	  tmp = i;
	  break;
	}
      }
      // oddをevenのmax+1にしてからのこりを揃える
      while(d[tmp] < oddMax) {
	ans++;
	d[tmp] += 2;
      }
      sort(ALL(d));
      while(1) {
	if (d[0] == d[1]) break;
	ans++;
	d[0] += 2;
	sort(ALL(d));
      }
      ans += d[2] - d[1];
    }
  }

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



Measured memory_bytes: 256
from collections import deque
def make_wall(maze,h,w):
    maze=deque(maze)
    for i in range(h):
        maze[i]="."+maze[i]+"."
    maze.appendleft("."*(w+2))
    maze.append("."*(w+2))
    return list(maze)

h,w=map(int,input().split())
s=[input() for _ in range(h)]
s=make_wall(s,h,w)
ans="Yes"
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=="#":
            if "#" not in (s[i-1][j], s[i+1][j], s[i][j-1], s[i][j+1]):
                ans="No"
                break
    else:
        continue
    break
print(ans)


Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e16;
const ll mod=1000000007;
typedef pair<ll,ll> pi;

void solve()
{
ll n;
cin>>n;
vector<ll>a(n);
for(ll i=0;i<n;i++) cin>>a[i];
ll ans=0;
ll m=a[0];
for(ll i=1;i<n;i++)
{
    ans+=max(0LL,m-a[i]);
    m=max(m,a[i]);
}
cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    t=1;
    for(ll i=1;i<=t;i++)
    {
        solve();
        cout<<endl;

    }
    return 0;
}


Measured memory_bytes: 4744
import copy
def board_check(tmp_board):
    count=0
    for i in range(H):
        for j in range(W):
            if tmp_board[i][j]=='#':
                count+=1
    if count == K:
        return 1
    else:
        return 0
if __name__ == "__main__":
    H,W,K = map(int,input().split())
    board = [list(input()) for _ in range(H)]
    n_H=2**H
    n_W = 2**W
    cnt = 0
    for i in range(n_H):
        l_h=[]
        for ih in range(H):
            if i>>ih & 1:
                l_h.append(ih)
        for j in range(n_W):
            tmp_board=copy.deepcopy(board)
            #print(tmp_board)
            l_w =[]
            for jw in range(W):
                if j >> jw & 1:
                    l_w.append(jw)
            #print("l_h:",l_h)
            #print("l_w:",l_w)
            #処理
            #print(l_h,l_w)
            if l_h :
                for x in l_h:
                    for j in range(W):
                        tmp_board[x][j] = 'x'
                #print(tmp_board)
            if l_w:
                for x in l_w:
                    for j in range(H):
                        tmp_board[j][x] = 'x'
            if board_check(tmp_board)==1:
                #print("ok")
                #print(l_h,l_w)
                cnt+=board_check(tmp_board)
    print(cnt)


Measured memory_bytes: 9236
import fractions

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

l = sorted(list(set(make_divisors(A)) & set(make_divisors(B))))
#print(l)
i = 0
while i < len(l):
    v = l[i]
    if v == 1:
        i += 1
        continue
    l = l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:]))
#    print(l)
    i += 1
print(len(l))

Measured memory_bytes: 7160
def dfs(n,k,a)
  return [] if n<0
  return (n.zero? ? a : []) if k==K.size
  r1=dfs(n-K[k], k, a+[S[K[k]]]).sort.reverse
  r2=dfs(n, k+1, a).sort.reverse
  return r2 if r1.empty?
  return r1 if r2.empty?
  return r2 if r1.size < r2.size
  return r1 if r2.size < r1.size
  r1.to_s<r2.to_s ? r2 : r1
end

B=[0,2,5,5,4,5,6,3,7,6]

N,M=gets.split.map(&:to_i)
A=gets.split.map(&:to_i)

S=Hash.new{|h,k|h[k]=0}
A.each do |a|
  S[B[a]]=[S[B[a]],a].max
end
K=S.keys.sort

n,r=N.divmod(K[0])
m=[10,n-1].min
n-=m
r+=K[0]*m
f=l=""
dfs(r,0,[]).each do |c|
  S[K[0]]<c ? f+=c.to_s : l+=c.to_s
end
puts f + S[K[0]].to_s*n + l

Measured memory_bytes: 3964
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
using namespace std;

void test() {
    int a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    long long dis = abs(a - b);
    if (w >= v) {
        cout << "NO\n";
        return;
    }
    cout << (dis > 1ll * (v - w) * t ? "NO\n" : "YES\n");
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


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

using namespace std;

const int N = 5005 * 5005;

int jual[3][3], beli[3][3];
long long dp[N];

int main() {
  int n;
  scanf("%d", &n);
  int a[3], b[3];
  for (int i = 0; i < 3; ++i)
    scanf("%d", a+i);
  for (int i = 0; i < 3; ++i)
    scanf("%d", b+i);
  for (int i = 0; i < 3; ++i) {
    jual[0][i] = a[i];
    beli[0][i] = b[i];

    jual[1][i] = b[i];
    beli[1][i] = a[i];

    jual[2][i] = a[i];
    beli[2][i] = a[i];
  }
  long long ans = 0;
  for (int k = 0; k < 2; ++k) {
    for (int i = 0; i <= n; ++i) {
      dp[i] = i;
      for (int j = 0; j < 3; ++j) {
        if (jual[k][j] > i) continue;
        dp[i] = max(dp[i-jual[k][j]] + beli[k][j], dp[i]);
      }
      ans = max(ans, dp[i]);
    }
    n = ans;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 195584
#include <iostream>
using namespace std;
int main()
{
    int N,X,g,m[101];
    int min = 1001;
    cin >> N >> X;
    for(int i=0;i<N;++i)
    {
        cin >> m[i];
        X = X - m[i];
        if(min>m[i])
        {
            min = m[i];
        }
    }
    int ans = N + X/min;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
  int n,x,y;
  cin >> n;
  for(x=0;x<100/7;x++){
    for(y=0;y<100/4;y++){
      if(7*x+4*y==n){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n;
  cin>>n;
  vl a(n);
  map<ll,ll>M;
  rep(i,n)cin>>a[i];
  rep(i,n){
    M[a[i]+1]++;
    M[a[i]]++;
    M[a[i]-1]++;
  }
  ll MAX=0;
  for(auto p:M){
    MAX=max(MAX,p.second);
  }
  cout<<MAX<<endl;
}

Measured memory_bytes: 6912
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans = 1;
    int cnt = 1;
    for (int i=1; i<=100; ++i){
        cnt = cnt - 1 + a;
        if(cnt >= b){
            ans = i;
            break;
        }
    }
    if(b == 1){
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define MINF INT_MIN
#define ll long long
#define PB push_back
#define PF push_front
#define P_F pop_front
#define P_B pop_back
#define F front
#define B back
#define MP make_pair
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define forit(i, s) for(__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define foritr(i, s) for(__typeof ((s).rend ()) i = (s).rbegin (); i != (s).rend (); ++i)
 
using namespace std;

int main(){
  ll N;
  cin >> N;
  vector<ll> alts(N), mins(N, INF);
  
  FOR(i, 0, N)
    cin >> alts[i];
    
  mins[0] = 0;
  mins[1] = abs(alts[1] - alts[0]);
  
  FOR(i, 2, N)
    mins[i] = min(mins[i-1] + abs(alts[i-1] - alts[i]), mins[i-2] + abs(alts[i-2] - alts[i]));
  
  cout << mins[N-1] << "\n";
  
  return 0;
}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
using data=pair<long,long>;
int main(){
  int i,j,N,cnt=0,max=1,p;
  cin>>N;
  long a,b;
  p=N*(N-1)/2;
  if(N<3){printf("1\n");return 0;}
  vector<long> x(N),y(N);
  data bf;
  vector<data> pq(p);
  for(i=0;i<N;i++){
    scanf("%ld",&x[i]);
    scanf("%ld",&y[i]);
  }
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      a=x[i]-x[j];
      b=y[i]-y[j];
      if(a+b<0){
        pq[cnt++]=data(-a,-b);
      }else{
        pq[cnt++]=data(a,b);
      }
    }
  }
  sort(pq.begin(),pq.end());
  j=1;
  bf=pq[0];
  for(i=1;i<cnt;i++){
    if(pq[i]==bf){
      j++;
    }else{
      j=1;
      bf=pq[i];
    }
    if(j>max)max=j;
  }
  printf("%d\n",N-max);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n; string s;
int main()
{
    cin >> n >> s;
    int r = 0;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='R')
        {
            r++;
        }
    }
  	int c=0;
    for(int i=r;i<n;i++)
    {
      if(s[i]=='R')
        c++;
    }
  cout<<c;
}

Measured memory_bytes: 3696
MOD = 10 ** 9 + 7


def main():
    n, k = map(int, raw_input().split())
    a = aa = n + 1 - k
    b = 1
    bb = k
    for i in xrange(1, k + 1):
        print a * b % MOD
        aa -= 1
        a = a * aa / (i + 1)
        bb -= 1
        b = b * bb / i
        # print comb(n + 1 - k, i) * comb(k - 1, i - 1) % MOD


if __name__ == '__main__':
    main()


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

const int N = 4005;
const int mod = 998244353;

int n, k;
int c[N][N];
int pw2[N];
int dp[N][N], sum_dp[N][N];

int candy(int n, int k) {
	if (n == 0 && k == 0) return 1;
	if (k <= 0) return 0;
	return c[n + k - 1][k - 1];
}

void make_sum(int i) {
	sum_dp[i][0] = dp[i][0];
	for (int j = 1; j < N; ++j) {
		sum_dp[i][j] = (sum_dp[i][j - 1] + dp[i][j]) % mod;
	}
}

void prepare() {
	// comb
	for (int i = 0; i < N; ++i) {
		c[i][0] = 1;
	}

	for (int i = 1; i < N; ++i) {
		for (int j = 1; j < N; ++j) {
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
		}
	}

	// pw2
	pw2[0] = 1;
	for (int i = 1; i < N; ++i) {
		pw2[i] = 2LL * pw2[i - 1] % mod;
	}

	// dp
	dp[0][0] = 1;
	make_sum(0);
	for (int i = 1; i < N; ++i) {
		dp[i][0] = 1;
		for (int j = 1; j < N; ++j) {
			dp[i][j] = (sum_dp[i - 1][j] + sum_dp[i - 1][j - 1]) % mod;
		}
		make_sum(i);
	}
}

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

	prepare();

	cin >> k >> n;

	for (int t = 2; t <= 2 * k; ++t) {
		int x = 0, y = 0;
		for (int i = 1; i <= t && i <= k; ++i) {
			if (i < t - i && t - i <= k) ++x;
			else if (i < t - i) ++y;
		}
		y += max(0, k - t + 1);

		int cur = 0;
		for (int i = 0; i <= n; ++i) {
			int mul = dp[x][i];
			cur = (cur + 1LL * candy(n - i, y) * mul) % mod;
		}

		if (t % 2 == 0) { // (t / 2) + (t / 2) -> only one
			for (int i = 0; i <= n - 1; ++i) {
				int mul = dp[x][i];
				cur = (cur + 1LL * candy(n - 1 - i, y) * mul) % mod;
			}
		}

		if (cur < 0) cur += mod;
		printf("%d\n", cur);
	}	
}

Measured memory_bytes: 188288
#include <string.h>

int main(void) {

	char p[100],q[100];
	int r = 0,s = 0, t = 0;
	for (int i = 0; i < 100; i++) {
		p[i] = 0;
		q[i] = 0;
	}

	scanf("%d", &t);
	for (int i = 0; i < t; i++) {
		scanf("%s%s", &p, &q);
		for (int x = 0; x < 100; x++) {
			if (p[x] - '0' < q[x] - '0') {
				s += 3;
				break;
			}
			else if (p[x] - '0' > q[x] - '0') {
				r += 3;
				break;
			}
			else if (x == strlen(p) || x == strlen(q)){
				if (strlen(p) < strlen(q)) {
					s += 3;
					break;
				}
				else if (strlen(p) > strlen(q)) {
					r += 3;
					break;
				}
				else {
					s += 1;
					r += 1;
					break;
				}
			}
		}
	}
	printf("%d %d\n", r, s);



	return 0;
}


Measured memory_bytes: 2064
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <functional>
#include <algorithm>
#include <cctype>
using namespace std;

typedef long long ll;

string table[6][5] = {
    {"a", "b", "c", "d", "e"} ,
    {"f", "g", "h", "i", "j"} ,
    {"k", "l", "m", "n", "o"} ,
    {"p", "q", "r", "s", "t"} ,
    {"u", "v", "w", "x", "y"} ,
    {"z", ".", "?", "!", " "}
};

int main()
{
    string str;
    while(cin >> str) {
        if(str.size() % 2 == 1) {
            cout << "NA" << endl;
            continue;
        }

        bool ok = true;
        string ret = "";
        int a, b;
        for(int i = 0; i < str.size(); i++) {
            if(!isdigit(str[i])) {
                ok = false;
                break;
            }
            if(i % 2 == 0) {
                a = str[i] - '1';
            } else {
                b = str[i] - '1';
                if(a < 0 || a >= 6 || b < 0 || b >= 5) {
                    ok = false;
                    break;
                }
                ret += table[a][b];
            }
        }
            if(ok) {
                cout << ret << endl;
            } else {
                cout << "NA" << endl;
            }
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    char c;
    cin >> c;
    while(true) {
        if(c == 'A' or c == 'a') {
            cout << c << endl;
            return 0;
        }
        c--;
    }
}

Measured memory_bytes: 3616
#include<cstdio>
char s[100],a;
int main(){
	scanf("%s",s);
	for(int i=0;i<100;i++){
		if(s[i]=='C')a=1;
		if(s[i]=='F'&&a)a=2;
	}
	return 0*printf("%s",a==2?"Yes":"No");
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
#include<map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
const int MOD = 1000000007;
int main(void) {
	int N, M, p, y, c;
	map<pair<int, int>, ll> num;
	vector<pair<int, int> > data, data2;
	scanf("%d%d", &N, &M);
	rep(i, 0, M) {
		scanf("%d%d", &p, &y);
		data.push_back(make_pair(p, y));
		data2.push_back(make_pair(p, y));
	}
	sort(all(data2));
	p = 0;
	for (auto v : data2) {
		if (v.first != p)c = 1;
		p = v.first;
		num[v] = c++ + p * 1000000LL;
	}
	for (auto v : data) {
		printf("%012lld\n", num[v]);
	}
	return 0;
}


Measured memory_bytes: 9324
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let l: usize = itr.next().unwrap().parse().unwrap();

    let mut t = Vec::new();
    for _ in 0..n {
        let s = itr.next().unwrap();
        t.push(s);
    }
    t.sort();
    let mut u = "".to_string();
    for i in 0..n {
        u += t[i];
    }
    println!("{}", u);
}


Measured memory_bytes: 2156
import math
A,B,H,M=map(int,input().split())
T=(60*H)+M
a=(6*T)%360#分針
b=(0.5*T)#時針
if a==b:
  print(abs(A-B))
  exit()

x=(A**2)+(B**2)-(2*A*B*math.cos(math.radians(abs(a-b))))
print(math.sqrt(x))

Measured memory_bytes: 9576
#include <bits/stdc++.h>
#define P pair<int, int>

using namespace std;
const int INF=1e5;

long long gcd(long long a, long long b){
  if(b==0)return a;
  return gcd(b, a%b);
}

int main(){
  long long n, k, a[100009];
  cin >> n >> k;
  for(int i=0;i<n;i++)cin >> a[i];
  long long _gcd = a[0];
  for(int i=1;i<n;i++)_gcd = gcd(_gcd, a[i]);
  for(int i=0;i<n;i++){
    if(a[i]>=k && (a[i]-k)%_gcd==0){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1024
n, k = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)

h.unshift(0)
costs = Array.new(n+1, 10000000000000)
costs[0] = 0
costs[1] = 0

2.upto(n) do |i|
  1.upto(k) do |t|
    next if i - t < 1
    cost = costs[i-t] + (h[i] - h[i-t]).abs
    costs[i] = cost if cost < costs[i]
  end
end
p costs[n]


Measured memory_bytes: 11524
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int a[4] = {1,100, 10000,1000000};
  int D, N; cin>>D>>N;
  int ans = 0;
  REP(i,N) {
    ans += a[D];
    if(ans % a[D+1] == 0) ans += a[D];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    int res = INT_MAX;
    while (n--) {
        int x;
        int cur = 0;
        scanf("%d", &x);
        while (x) {
            if (x & 1) {
                break;
            }
            else {
                cur++;
            }
            x >>= 1;
        }
        res = min(res, cur);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i,num;
  int count[26]={0};
  char ch;
  //i=0;
  while( scanf("%c",&ch)!=EOF){
    //while (i<20){
    //scanf("%c",&ch);
    for(i=0;i<26;i++){
      if(ch=='A'+i) count[i]++;
      if(ch=='a'+i) count[i]++;
    }
    //i++;
  }
  
  for(i=0;i<26;i++){
  
  printf("%c : %d\n",'a'+i,count[i]);
  }
  return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
int main(){
    string s,t;
    std::cin >> s>>t;
    if(s==t.substr(0,s.size()))std::cout << Yes << std::endl;
    else std::cout << No << std::endl;
}

Measured memory_bytes: 3632