akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

int Mod(int a) {
	return a%mod;
}
int Mul(int a, int b) {
	return Mod(Mod(a) * Mod(b));
}
int Add(int a, int b) {
	return Mod(Mod(a) + Mod(b));
}
//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}
bool cmp(pair<pair<int,int>,pair<int,int>>a,pair<pair<int,int>,pair<int,int>>b) {
	return a.second.first < b.second.first;
}
bool cmp1(pair<pair<int,int>,pair<int,int>>a,pair<pair<int,int>,pair<int,int>>b) {
	return a.second.second < b.second.second;
}
//bool cmp1(pair<pair<int,int>,int>a,pair<pair<int,int>,int>b) {
	//return a.first.first < b.first.first;
//}
//bool cmp2(pair<pair<int,int>,int>a,pair<pair<int,int>,int>b) {
	//return a.first.second < b.first.second;
//}	
	
signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        int n;
        cin>>n;
        vector<pair<pair<int,int>,pair<int,int>>>ip;
        for(int i = 0; i < n; i++) {
			int x,y;
			cin>>x>>y;
			ip.pb(mp(mp(x,y),mp(x+y,x-y)));
		}
		sort(ip.begin(), ip.end(), cmp);
		int ans = 0;
		ans = abs(ip[n-1].first.first-ip[0].first.first) + abs(ip[n-1].first.second-ip[0].first.second);
		sort(ip.begin(), ip.end(), cmp1);
		ans = max(ans, abs(ip[n-1].first.first-ip[0].first.first) + abs(ip[n-1].first.second-ip[0].first.second));
		cout<<ans<<endl;
		//for(int i = 1; i < n; i++) {
			//ans = max(ans,(abs(ip[i].first.first-ip[0].first.first) + abs(ip[i].first.second-ip[0].first.second)));
		//}
		//sort(ip.begin(), ip.end(),cmp1);
		//for(int i = 0; i < n; i++) {
			//ans = max(ans,(abs(ip[i].first.first-ip[0].first.first) + abs(ip[i].first.second-ip[0].first.second)));
		//}
		//sort(ip.begin(), ip.end(), cmp2);
		//for(int i = 0; i < n; i++) {
			//ans = max(ans,(abs(ip[i].first.first-ip[0].first.first) + abs(ip[i].first.second-ip[0].first.second)));
		//}
		//sort(ip.begin(), ip.end(), cmp2);
		//sort(ip.begin(), ip.end(),cmp1);
		//for(int i = 0; i < n; i++) {
			//ans = max(ans,(abs(ip[i].first.first-ip[0].first.first) + abs(ip[i].first.second-ip[0].first.second)));
		//}
		//cout<<ans<<endl;
        
        
    }



return 0;
}


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

int main() {
    long long n, k, x, y, ans;
    cin >> n >> k >> x >> y;
    for (long long i=1; i<n+1; i++) {
        if (i<=k) ans += x;
        else ans += y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n;
string s;

bool ok(string hoge){
  int cnt=0;
  rep(i,n)if(hoge[cnt]==s[i])cnt++;
  return cnt==3;
}
int main(){
  cin>>n>>s;
  int ans=0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        string tmp="";
        tmp+=(char)(i+'0');
        tmp+=(char)(j+'0');
        tmp+=(char)(k+'0');
        if(ok(tmp))ans++;
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;

int main(){
  int n,m,k;
  cin >> n >> m >> k;

  for(int i = 0;i <= n;i++){
    for(int j = 0;j <= m;j++){
      int now_cnt = i * m - j * i + j * (n - i); 
      if(now_cnt == k){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    vector<pair<int, int>> t(0), u(0);
    for (int i = 0; i < n; i++) {
        int a = 0, b = 0;

        for (int j = 0; j < static_cast<int>(s[i].size()); j++) {
            if (s[i][j] == '(') {
                b++;
            } else if (s[i][j] == ')' && b > 0) {
                b--;
            } else {
                a++;
            }
        }

        if (b - a >= 0) {
            t.push_back(make_pair(a, i));
        } else {
            u.push_back(make_pair(b, i));
        }
    }

    sort(t.begin(), t.end());
    sort(u.begin(), u.end(), greater<pair<int, int>>());

    bool res = true;
    for (int i = 0, j = 0; i < n; i++) {
        int v = (i < static_cast<int>(t.size()) ? t[i].second : u[i - t.size()].second);

        for (int k = 0; k < static_cast<int>(s[v].size()); k++) {
            if (s[v][k] == '(') {
                j++;
            } else {
                j--;
            }
            res = res && j >= 0;
        }
        res = res && (i < n - 1 || j == 0);
    }

    cout << (res ? "Yes" : "No") << endl;
}


Measured memory_bytes: 42484
#include <iostream>
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<numeric>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>

#define FOR(i, a, b) for(int i=a; i<b; i++)
#define COUT(a) cout << a << endl;

using namespace std;
using Int = long long;
using P = pair<Int, Int>;

int main() {
    Int N,M;
    Int X,Y;
    Int Xmax,Ymin;
    int flg = 0;

    Xmax = Ymin = 0;

    cin >> N >> M >> X >> Y;

    Int x,y,xold,yold;
    xold = yold = 999;

    FOR(i,0,N){
        cin >> x;
        if ((Xmax <= x) || (xold == 999)){
            Xmax = x;
        }
        xold = x;
    }

    FOR(j,0,M){
        cin >> y;
        if ((Ymin >= y) || (yold == 999)){
            Ymin = y;
        }
        yold = y;
    }

    if (Xmax < Ymin){

        if ( ((X < (Xmax + 1)) && ((Xmax + 1) <= Y)) ||
             ((X < (Ymin - 1)) && ((Ymin) <= Y)) ){
            flg = 1;
        }

    }

    if (flg == 1){
        cout << "No War" << endl;
    }
    else {
        cout << "War" << endl;
    }


    return 0;
}

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

int main(){
  string N;
  int sum = 0;
  
  cin >> N;
  
  for(size_t i=0; i < N.size(); ++i){
 	sum += N[i] - '0';
  }
    
  cout << ((sum % 9 == 0)? "Yes": "No") << endl;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define ub  upper_bound
#define lb  lower_bound
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) cout << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " << endl

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;


int main(){
  fastio;

  ll n;
  cin >> n;
  ll x,m;
  cin >> x >> m;
  ll ans = 0;
  set <ll> conj;
  vll nums;
  int times = 0;

  while(true){
    if(conj.count(x))
      break;
    nums.pb(x);
    conj.insert(x);
    ans += x;
    x = (x*x)%m;
    times++;
    if(times == n){
      cout << ans << endl;
      return 0;
    } 
  }
  
  int p = 0;
  while(nums[p] != x)
    p++;

  ll sum = 0;
  for(int i=p;i<sz(nums);i++){
    ans += nums[i];
    sum += nums[i];
    times++;
    if(times == n){
      cout << ans << endl;
      return 0;
    }
  }
  int per = sz(nums)-p;
  ll dif = n-times;

  ans += sum*(dif/per);

  int rest = dif%per;
  while(rest--){
    ans += nums[p];
    p++;
  }

  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 5848
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <random>
#include <map>

using namespace std;

int fibArray[50];

void makeFibArray() {
    for (int i = 2; i <= 46; i++) {
	fibArray[i] = fibArray[i - 1] + fibArray[i - 2];
    }
}

int main() {

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

    int n; scanf("%d", &n);
    fibArray[0] = 1;
    fibArray[1] = 1;
    makeFibArray();
    printf("%d\n", fibArray[n]);


    return 0;

}




Measured memory_bytes: 3212
import bisect
N, M = map(int, input().split())
if N == 1:
    print(1)
    exit()

a = [int(input()) for i in range(M)]
broken = [0]*(N+1)
for i in range(M):
    broken[a[i]] = 1
if M == 0:  a.append(0)
ans = [0] * (N+1)
ans[0] = 1
if a[0] != 1:   ans[1] = 1
else:   pass
for i in range(2, N+1):
    if broken[i] == 1:
        ans[i] = 0
    else:
        ans[i] = (ans[i-1] + ans[i-2]) % (10**9+7)
print(ans[N])

Measured memory_bytes: 8616
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <string>
#define rep(i, N) for(int i = 0; i < N; ++i)

typedef long long ll;
using namespace std;

int main()
{
    ll k;
    cin >> k;

    set<ll> runrun;
    queue<ll> que;

    for (int i = 1; i < 10; i++)
    {
        que.push(i);
        runrun.insert(i);
    }

    while(true)
    {
        if (runrun.size() > 100000)
        {
            break; 
        }
        auto val = que.front();
        //cout << val << endl;
        que.pop();
        // 末尾の数字
        auto tail = val % 10;
        auto plus = tail + 1;
        auto stay = tail;
        auto minus = tail - 1;
        auto str = to_string(val);
        if (minus >= 0)
        {
            auto str_minus = str + to_string(minus);
            auto minusVal = stoll(str_minus);
            que.push(minusVal);
            runrun.insert(minusVal);
        }
        auto str_stay = str + to_string(stay);
        auto stayVal = stoll(str_stay);
        que.push(stayVal);
        runrun.insert(stayVal);
        if (plus <= 9)
        {
            auto str_plus = str + to_string(plus);
            auto plusVal = stoll(str_plus);
            que.push(plusVal);
            runrun.insert(plusVal);
        }
    }

    auto iterator = runrun.begin();
    int counter = 0;
    ll ans = 0;
    while (iterator != runrun.end())
    {
        counter++;
        if (counter == k)
        {
            ans = *iterator;
            break;
        }
        iterator++;
    }
    
    cout << ans << endl;
    
    return 0;
}


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

namespace AtTest.ABC_119
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nabc = ReadInts();
            int n = nabc[0];
            int[] tar = new int[3] { nabc[1], nabc[2], nabc[3] };
            int[] ls = new int[n];
            for(int i = 0; i < n; i++)
            {
                ls[i] = ReadInt();
            }
            int allPat = (int)Pow(4, n);
            int res = int.MaxValue;
            for(int i = 0; i < allPat; i++)
            {
                int[] vals = new int[3];
                int ii = i;
                int mp = 0;
                for(int j = 0; j < n; j++)
                {
                    if (ii % 4 < 3)
                    {
                        if (vals[ii % 4] > 0) mp += 10;
                        vals[ii % 4] += ls[j];
                    }
                    ii /= 4;
                }
                if (vals[0] == 0 || vals[1] == 0 || vals[2] == 0) continue;
                mp += Abs(tar[0] - vals[0]);
                mp += Abs(tar[1] - vals[1]);
                mp += Abs(tar[2] - vals[2]);
                res = Min(res, mp);
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 15188
#include<stdio.h>
int main(void){
	int a,b,c,y,v,i,j;
	char k;
	while(scanf("%d %d",&a,&b)!=EOF){
		k=a;
		j=k;
		if(j==10){
			break;
		}
		if(a>b){
			c=a;
			a=b;
			b=c;
		}
		c=a;
		if(b%a==0){
			y=a;
		}
		else{
			while(1){
				c--;
				if(b%c==0 && a%c==0){
					y=c;
					break;
				}
			}
		}
		v=(a/y)*(b/y)*y;
		printf("%d %d\n",y,v);
	}
	return 0;
}


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

int main(){
  string s; cin >> s;
  int a,z;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='A'){a=i; break;}
  }
  for(int i=s.size()-1; i>=0; i--){
    if(s[i]=='Z'){z=i; break;}
  }
  cout << z-a+1 << endl;
}

Measured memory_bytes: 640
S = list(input())

if S[0] == S[1] == S[2] == 'R':
    print(3)
elif S[0] == S[1] == 'R' or S[1] == S[2] == 'R':
    print(2) 
elif (S[0] == 'R' or S[2] == 'R') and S[1] == 'S':
    print(1)
elif (S[0] == 'S' and S[2] == 'S') and S[1] == 'R':
    print(1)
elif S[0] == S[1] == S[2] == 'S':
    print(0)



Measured memory_bytes: 9132
from math import hypot

N = int(input())
engines = [tuple(map(int, input().split())) for _ in range(N)]

def dot(x1, y1, x2, y2):
    return x1*x2 + y1*y2
def cross(x1, y1, x2, y2):
    return x1*y2 - y1*x2

def getDistMax(xBase, yBase):
    x1s, y1s, x2s, y2s = [], [], [], []
    x, y = 0, 0
    for dx, dy in engines:
        d = dot(xBase, yBase, dx, dy)
        if d > 0:
            x, y = x+dx, y+dy
        elif d == 0:
            c = cross(xBase, yBase, dx, dy)
            if c > 0:
                x1s.append(dx)
                y1s.append(dy)
            else:
                x2s.append(dx)
                y2s.append(dy)
    ans = max(hypot(x, y), hypot(x+sum(x1s), y+sum(y1s)), hypot(x+sum(x2s), y+sum(y2s)))
    return ans

ans = 0
for x, y in engines:
    ds = []
    ds.append(getDistMax( x,  y))
    ds.append(getDistMax(-y,  x))
    ds.append(getDistMax(-x, -y))
    ds.append(getDistMax( y, -x))
    ans = max(ans, max(ds))

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

signed main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> a(N);
    FOR(i,0,N)cin >> a[i];
    bool DP[K+1][2];
    DP[0][0] = 1;
    DP[0][1] = 0;
    FOR(i,0,K+1)FOR(j,0,2){
        DP[i][j] = 1^j;
        FOR(k,0,a.size()){
            if(a[k] <= i){
                if(DP[i-a[k]][j^1] == j){
                    DP[i][j] = j;
                    break;
                }
            }
        }
    }
    cout << (DP[K][1] ? "First" : "Second") << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


bool ispal(string s)
{
    ll n=s.length();
    
    ll l=0,r=n-1;
    while(l<=r)
    {
        if(s[l]!=s[r])
        {
            return false;
        }
        l++,r--;
    }

    return true;

}


void solve()
{
    string s;
    cin>>s;
    ll n=s.length();
    if(!ispal(s))
    {
        cout<<"No\n";
        return;
    }
    string s1=s.substr(0,(n-1)/2);
    string s2=s.substr(((n+3)/2)-1);
    // cout<<s1<<" "<<s2<<"\n";
    if(!ispal(s1))
    {
        cout<<"No\n";
        return;
    }

    if(!ispal(s2))
    {
        cout<<"No\n";
        return;
    }
    cout<<"Yes\n";


}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int ans = -n; REP(i,n){int a; cin >> a; ans+=a;}
    out(ans);

    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] split = in.readLine().split(" ");
        int A = Integer.parseInt(split[0]);
        long B = Long.parseLong(split[1]);
        long N = Long.parseLong(split[2]);
        long X = -1;
        if(N < B) {
            X = N;
        } else {
            X = B - 1;
        }
        System.out.println((long)(Math.floor((A * X) / B) - A * Math.floor(X / B)));
    }
}

Measured memory_bytes: 25364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
	int n, m;
	string s;
	cin >> n;
	m = 0;
	map<string, int> mp;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (mp.count(s) == 0) {
			mp[s] = 0;
		}
		else {
			mp[s]++;
			if (m < mp[s])	m = mp[s];
		}
	}
	for (auto i = mp.begin(); i != mp.end(); ++i) {
		if (i->second == m)	cout << i->first << endl;
	}
	return 0;
}

Measured memory_bytes: 25216
import sys
input = sys.stdin.readline

k = int(input())
a, b = map(int, input().replace("\n","").split())

if a == b:
    if a % k == 0:
        print("OK")
        exit()

for i in range(a,b+1):
    if i % k == 0:
        print("OK")
        exit()

print("NG")

Measured memory_bytes: 61636
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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 COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	string ans;
	while (n) {
		n--;
		ans += 'a' + n % 26;
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const int N=1000;
const int M=1e6;
const int mo=1e9+7;
int n,m,d[N+10],f[M+10],bitcnt[M+10];
struct edges {
    int u,v;
}e[N+10];
int Sum(int x,int y) {
    x+=y;
    return (x>=mo)?x-mo:x;
}
int Mul(int x,int y) {
    return (long long)x*y%mo;
}
int main() {
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        d[u]|=(1<<(v-1));
    }
    for (int i=0;i<(1<<n);i++) {
        bitcnt[i]=0;
        for (int j=0;j<n;j++)
            if (i&(1<<j)) bitcnt[i]++;
    }
    f[0]=1;
    for (int i=0;i<(1<<n)-1;i++) {
        int nx=((1<<n)-1)^i;
        for (int j=nx;j>0;j=(j-1)&nx) {
            if ((j&1)&&(j&2)) continue;
            int va=1;
            for (int k=1;k<=n;k++)
                if (!(j&(1<<(k-1)))&&!(i&(1<<(k-1)))) {
                    int cnt=bitcnt[d[k]&j];
                    va=Mul(va,(1<<cnt)-1);
                }
                else if (j&(1<<(k-1))) {
                    int cnt=bitcnt[d[k]&(((1<<n)-1)^i^j)];
                    va=Mul(va,(1<<cnt));
                }
            f[i|j]=Sum(f[i|j],Mul(f[i],va));
        }
    }
    printf("%d\n",f[(1<<n)-1]);
    return 0;
}


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

namespace PCK2015
{
	class Quetion04
	{
		static void Main()
		{
			List<int> buff1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
			List<int> buff2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

			int N = buff1[0];
			int M = buff2[0];

			buff1.RemoveAt(0);
			buff2.RemoveAt(0);

			HashSet<int> datas1 = new HashSet<int>();
			HashSet<int> datas2 = new HashSet<int>();
			for(int i = 0; i < N * 2; i += 2)
			{
				datas1.Add(buff1[i] * 60 + buff1[i + 1]);
			}
			for (int i = 0; i < M * 2; i += 2)
			{
				datas2.Add(buff2[i] * 60 + buff2[i + 1]);
			}

			List<int> datas = datas1.Union(datas2).ToList();
			datas.Sort();

			string str = "";
			foreach(int data in datas)
			{
				int h = data / 60;
				int m = data - h * 60;
				str += h.ToString() + ":" + m.ToString("00") + " ";
			}
			Console.WriteLine(str.Trim());
		}
	}
}

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

//関数
//main関数
int main() {
    
    
    //入力
    long R,G,B,N;
    cin>>R>>G>>B>>N;
    //計算
    long ans=0;
    for(int i=0;i<=N/R;i++){//R
        for(int j=0;j<=(N-R*i)/G;j++){
            if((N-R*i-G*j)%B==0) ans++;
        }
    }

    //出力
    cout<<ans<<endl;
}





Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

inline int readin(){
	int x=0,c;
	for (;(c=getchar())<'0'||c>'9';);
	for (;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+c-48;
	return x;
}

int a[233];

int main(){
	int n=readin(),k=readin();
	for (int i=1;i<=n;i++) a[i]=readin();
	std::sort(a+1,a+1+n);
	int i=1;
	while (i<=n&&k-a[i]>=0) k-=a[i++];
	if (i>n&&k>0) i--;
	printf("%d",i-1);
}

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val A = sc.nextInt()
    val B = sc.nextInt()
    val Q = sc.nextInt()

    val S = LongArray(A+2)
    val T = LongArray(B+2)
    S[0] = -10000000000L
    S[A+1] =90000000000L
    T[0] = -10000000000L
    T[B+1] =90000000000L
    for (i in 1..A) {
        S[i] = sc.nextLong()
    }
    for (i in 1..B) {
        T[i]  = sc.nextLong()
    }
//    S.forEach {println(it)}
//    println()
//    T.forEach {println(it)}
//    println()


    fun calc(x:Long,s:Pair<Long,Long>,t:Pair<Long,Long>) :Long{
        val (s0,s1) = s
        val (t0,t1) = t
        val res = listOf(x-Math.min(s0,t0), Math.max(s1,t1)-x, 2*Math.min(x-s0, s1-x)+Math.min(x-t0, t1-x),Math.min(x-s0, s1-x)+2*Math.min(x-t0, t1-x))
        return res.min()!!
    }


    fun search(x:Long,X:LongArray) :Pair<Long,Long>{
        var up = X.size-1
        var down = 0
        var x0 = X[down]
        var x1 = X[up]
        while (up-down > 1) {
            val mid = (down+up)/2
            if (x <= X[mid]) up = mid
            else down = mid
            x0 = X[down]
            x1 = X[up]
        }
        return x0 to x1
    }

    for (i in 0 until Q) {
        val x  = sc.nextLong()
        val s = search(x,S)
        val t = search(x,T)

        println(calc(x,s,t))

    }
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(2e6+5);

void pre() {

}

void solve() {
  int n;  cin>>n;
  vector<int> a(n);
  rep(i,n)  cin>>a[i];

  sort(all(a));

  ll ans = 0;

  //rep(i,n)  cout<<a[i]<<' ';  cout<<'\n';

  rep(i,n) {
    repi(j,i+1,n-1) {
      int k = (int)(lower_bound(all(a),a[i]+a[j]) - 1 - a.begin()) - j;
      ans += k;
  //    cout<<i<<' '<<j<<' '<<k<<'\n';
    }
  }
  cout<<ans;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  #endif
  int t = 1;
  pre();
//  cin>>t;
  rep(i,t)  {
    //cout<<"\nCase #"<<(i+1)<<"\n";
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3640
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
ll N;
int getIntSubstr(string s,int start_index,int length){
    return atoi(s.substr(start_index,length).c_str());
}
ll A[3000]={};
ll cnt=0;
int main(){

    string S;
    
    cin >> S;
    N = S.size();
    A[0]++;
    ll ans;
    ll val;
    ll target=0;
    ll base = 1;
    for( int ni = N-1 ; ni>=0 ; ni-- ){
        val = getIntSubstr(S,ni,1);
        target = (target + val * base)%2019;
        cnt+=A[target];
        A[target]++;
        base = (base * 10 ) % 2019;
    }
    cout << cnt << endl;
    

    

}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(ll i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

bool check(string a,string b)
{
	FOR(i,0,a.size())
	{
		if(a[i] == b[i])continue;
		else if(a[i]!=b[i]&&a[i] == '?')continue;
		else return false;
	}
	return true;
}
int main()
{
	string s,t;
	cin>>s>>t;
	string ans = "";
	for(int i=0;i+t.size()-1<s.size();i++)
	{
		string tmp = s.substr(i,t.size());
		bool isok = check(tmp,t);
		if(!isok)continue;
		string ma = s;
		for(int j = i;j<=i+t.size()-1;j++)ma[j] = t[j-i];
		for(int j=0;j<ma.size();j++)
		{
			if(!isalpha(ma[j]))ma[j] = 'a';
		}
		if(ans == ""||ans>ma)ans = ma;
	 } 
	if(ans == "")cout<<"UNRESTORABLE"<<Endl;
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int h,w,k; cin >> h >> w >> k;
    vector<string> mas(h);
    rep(i,h){
        cin >> mas[i];
    }

    int gyou=(int)pow(2,h);
    int retu=(int)pow(2,w);
    int ans=0;

    vector<int> tmpg(h,0);
    vector<int> glist(h,0);
    vector<int> tmpr(w,0);
    vector<int> rlist(w,0);

    rep(i,gyou){
        int a;
        glist=tmpg;
        int nowgyou=i;
        rep(p,h){
            if(nowgyou%2==0) glist[p]++;
            nowgyou/=2;
        }
        rep(j,retu){
            a=j;
            rlist=tmpr;
            int nowretu=j;
            rep(p,w){
            if(nowretu%2==0) rlist[p]++;
            nowretu/=2;
            }
            int count=0;
            rep(p,h)rep(q,w){
            if(glist[p]!=0 || rlist[q]!=0){
                continue;
            }
            if(mas[p][q]=='#') count++;
        }
        //cout << i << a << ' ' << count << endl;
        if(count==k) ans++;
        }
    }

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


Measured memory_bytes: 4064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cout<<pow(n,3)<<endl;
}


Measured memory_bytes: 384
N = int(input())
S = input()
answer = 1
if N % 2 == 0:
    for i in range(N // 2):
        if S[i] != S[i + N // 2]:
            answer = 0
else:
    answer = 0
if answer == 0:
    print("No")
else:
    print("Yes")





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

using namespace std;

bool Judge()
{
  int N;
  cin >> N;

  int sum = 0;
  while(N--) {
    string S;
    cin >> S;
    if(S == "A") ++sum;
    else --sum;
    if(sum < 0) return (false);
  }
  return (sum == 0);
}

int main()
{
  if(Judge()) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3160
import re

N = int(input())
S = [int(c) for c in input().strip()]
length = len(S)

count = 0
for c1 in range(10):
	index1 = 0
	while index1 < length:
		if S[index1] == c1:
			index1 += 1
			break
		index1 += 1
	if index1 < length:
		for c2 in range(10):
			index2 = index1
			while index2 < length:
				if S[index2] == c2:
					index2 += 1
					break
				index2 += 1
			if index2 < length:
				for c3 in range(10):
					index3 = index2
					while index3 < length:
						if S[index3] == c3:
							count += 1
							break
						index3 += 1
print(count)



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define all(vi) vi.begin(),vi.end()
using namespace std;
int main()
{
	long long rc,gc,n,b,no;
	cin>>rc>>gc>>n>>b>>no;
	vector<long long> vi,vi1,vi2;
	for(long long i=0;i<n;i++)
	{
		long long a;cin>>a;vi.push_back(a);
	}
	for(long long i=0;i<b;i++)
	{
		long long a;
		cin>>a;
		vi1.push_back(a);
	}
	for(long long i=0;i<no;i++)
	{
		long long a;
		cin>>a;
		vi2.push_back(a);
	}
	sort(all(vi)) , sort(all(vi1));
	long long a = rc;
	long long pos = vi.size()-1;
	while(a--)
		vi2.push_back(vi[pos--]);
	pos = vi1.size()-1;
	a = gc;
	while(a--)
		vi2.push_back(vi1[pos--]);
	sort(all(vi2));
	long long k = rc+gc;
	long long pos1 = vi2.size()-1;
	long long sum = 0;
	while(k--)
	{
		sum+=vi2[pos1--];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 8048
fun main(args: Array<String>) {
    fun isPrimeFast(num: Long): Boolean {
        if (num < 2)
            return false
        else if (num == 2L)
            return true
        else if (num % 2L == 0L)
            return false
        val sqrtNum = Math.sqrt(num.toDouble())
        var i = 3
        while (i <= sqrtNum) {
            if (num % i == 0L) {
                return false
            }
            i += 2
        }
        return true
    }

    val x = readLine()!!.toLong()
    if(x<=2){
        println(2)
        return
    }
    var i = x + if (x % 2 == 0L) 1 else 0
    while(true){
        if(isPrimeFast(i)){
            println(i)
            return
        }
        i++
    }
}

Measured memory_bytes: 32116
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <atcoder/all>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M;

int main() {
  std::cin >> N >> M;

  std::vector<ll> a(N), b(M);

  for( auto &x : a )
    std::cin >> x;
  for( auto &x : b )
    std::cin >> x;

  auto c = atcoder::convolution( a, b );

  rep( i, N-1+M )
    std::cout << c[i] << (i==N-1+M-1?'\n':' ');

  return 0;
}

Measured memory_bytes: 27212
#include <stdio.h>
#include <math.h>
int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A < B){
      if(A < C && C < B){
        printf("Yes");
      }else{
        printf("No");
      }
    }else{
      if(B < C && C < A){
        printf("Yes");
      }else{
        printf("No");
      }
    }
    return 0;
}

Measured memory_bytes: 128
N_list = [int (i) for i in list(input())]
digit = 0
dflag = False
max = 0
for i in N_list:
    max += i

for i in N_list:
    if i == 9:
        dflag = True
    else:
        break

    digit += 1

if dflag:
    N_list[digit-1] -=1
    for i in range(digit, len(N_list)):
        N_list[i] = 9

else:
    N_list[digit] -=1
    for i in range(digit+1, len(N_list)):
        N_list[i] = 9

sum = 0

for i in N_list:
    sum += i

if sum > max:
    max = sum
print (max)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n;i++)
using namespace std;
using ll = long long;
#define int ll
int INF = -LONG_MAX/100;
signed main(){
    using pii = pair<int,int>;
    using piii  = pair<pii,int>;
    vector<piii>edge;
    int n,m; cin>>n>>m;
    rep(i,m){
        piii hoge; cin>>hoge.first.first>>hoge.first.second>>hoge.second;
        edge.push_back(hoge);
    }
    vector<int>d(n,INF);
    d[0]=0;
    for(int v=0; v<n*3;v++){
        bool update=false;
        rep(i,edge.size()){
            int from=edge[i].first.first-1;
            int to=edge[i].first.second-1;
            int cost=edge[i].second;
            if(d[from]==INF)continue;
            if(d[to]<d[from]+cost){
                d[to]=d[from]+cost;
                if(to==n-1)update=true;
            }
        }
        if(update&&v>2*n)return puts("inf")*0;
    }
    cout<<d[n-1]<<endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

//#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int buf[100001];
int N;

signed main()
{
	cin >> N;
	REP(i, N)
	{
		int a;
		cin >> a;
		for (int j = -1; j <= 1; j++)
		{
			int n = a + j;
			if (0 <= n && n <= 100000)
			{
				buf[n]++;
			}
		}
	}

	int max = 0;
	for (int i = 0; i <= 100000; i++)
	{
		max = MAX(max, buf[i]);
	}

	cout << max << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 550;
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> pii;
#define INF 0x3f3f3f3f
int mod = 1000000007;
int s[N], f[N], c[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	while (~scanf("%d", &n))
	{
		int cur = 0;
		for (int i = 0; i < n-1; i++)
		{
			scanf("%d%d%d", c + i, s + i, f + i);
		}
		for (int i = 0; i < n-1; i++)
		{
			int cur = s[i] + c[i];
			for (int j = i+1; j < n - 1; j++)
			{
				if (s[j] >= cur)
				{
					cur += s[j] - cur;
				}else
				{
					int tmp = (cur - s[j])%f[j];
					if (tmp != 0)
						tmp = f[j] - tmp;
					cur += 	tmp;
				}
				cur += c[j];
			}
			printf("%d\n", cur);
		}
		puts("0");
	}
   	return 0;
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defvar n (read))
(defvar k (read))
(defvar h (coerce (loop repeat n collect (read)) 'vector))

(defun cul-cost (from to)
  (labels ((height (x)
             (if (>= x n) (expt 10 10)
                 (aref h x))))
    (abs (- (height from) (height to)))))

(dp func (x) '(110000)
    (if (>= x (1- n)) 0
        (apply #'min
               (loop for i from 1 to k
                     collect (+ (cul-cost x (+ x i)) (func (+ x i)))))))

(princ (func 0))



Measured memory_bytes: 232508
#!/usr/bin/env python
# coding: utf-8

import sys


def board_to_string(board):
    return "\n".join(["".join([str(i) for i in row]) for row in board])


def get_answer(board, positions):
    x, y = positions.pop(0)
    board[y][x] = 0
    explode_range = []

    for i in [j for j in xrange(-3, 4) if j]:
        if (0 <= (x + i) <= 7):
            explode_range.append((x + i, y))
        if (0 <= (y + i) <= 7):
            explode_range.append((x, y + i))

    for explode_pos in explode_range:
        x, y = explode_pos
        if board[y][x] == 1:
            board[y][x] = 0
            positions.append((x, y))
    if positions:
        return get_answer(board, positions)
    else:
        return board


def main():
    s = sys.stdin.read()
    params = [param.rstrip() for param in s.split("\n\n")][1:]

    for i, param in enumerate(params):
        print "Data %d:" % (i + 1)

        lines = param.split("\n")
        board = [map(int, line) for line in lines[:-2]]
        x, y = map(int, lines[-2:])
        x -= 1
        y -= 1
        positions = []
        positions.append((x, y))

        ans_board = get_answer(board, positions)
        print board_to_string(ans_board)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4288
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 100000
#define LL long long
struct dish
{
    int val,id,pval;
}A[MAXN+5],B[MAXN+5];
int n;
int vis[MAXN+5],p1=1,p2=1,cnt;
LL ans;
bool cmp(dish s1,dish s2)
{
    if(s1.pval!=s2.pval)return s1.pval>s2.pval;
    return s1.val>s2.val;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&A[i].val,&B[i].val);
        A[i].pval=A[i].val+B[i].val;
        B[i].pval=B[i].val+A[i].val;
        A[i].id=B[i].id=i;
    }
    sort(A+1,A+n+1,cmp);
    sort(B+1,B+n+1,cmp);
    while(cnt<=n)
    {
        while(vis[A[p1].id])p1++;
        ans+=A[p1].val;vis[A[p1].id]=1;cnt++;
        if(cnt>n)break;
        while(vis[B[p2].id])p2++;
        ans-=B[p2].val;vis[B[p2].id]=1;cnt++;
    }
    printf("%lld",ans);
}

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

long long h, w, ans = 1LL << 60;

int main() {
    cin >> h >> w;

    long long Smax, Smin;

    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i < h; ++i) {
      long long h1 = h - i, s1 = i * w, s2 = h1 * (w / 2), s3 = h * w - s1 - s2, w1;
        //cout << s1 << " " << s2 << " " << s3 << endl;
        Smax = max({s1, s2, s3});
        Smin = min({s1, s2, s3});
        ans = min(ans, Smax - Smin);

	s1 = i * w, s2 = (h1 / 2) * w, s3 = h * w - s1 - s2;
	
        Smax = max({s1, s2, s3});
        Smin = min({s1, s2, s3});
        ans = min(ans, Smax - Smin);
    }
    for (int i = 1; i < w; ++i) {
        long long w1 = w - i, s1 = i * h, s2 = w1 * (h / 2), s3 = h * w - s1 - s2;
        //cout << s1 << " " << s2 << " " << s3 << endl;
        Smax = max({s1, s2, s3});
        Smin = min({s1, s2, s3});
        ans = min(ans, Smax - Smin);

	s1 = i * h, s2 = (w1 / 2) * h, s3 = h * w - s1 - s2;

        Smax = max({s1, s2, s3});
        Smin = min({s1, s2, s3});
        ans = min(ans, Smax - Smin);
    }

    cout << ans << endl;

    return 0;
}


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

using std::cin;
using std::cout;



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

  using ll = long long;

  ll N, P;
  cin >> N >> P;

  if (N == 1)
  {
    cout << P << "\n";
    return 0;
  }

  ll res = 1;
  ll x = P;
  for (ll i = 2; i*i <= P; ++i)
  {
    if (P % i) continue;

    int cnt = 0;
    while ((x % i) == 0)
    {
      x /= i;
      ++cnt;
    }

    cnt /= N;
    ll pp = i;
    while (cnt)
    {
      if (cnt & 1) res *= pp;
      cnt >>= 1;
      pp *= pp;
    }
  }

  cout << res << "\n";

  return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

//! 0~nの排他的論理和
ll calc(ll n) {
    ll m = n;
    ll b = 0;
    while (n > 0) {
        ll p = 1LL;
        while (p * 2LL <= n) {
            p <<= 1LL;
        }
        n = n & (~p);
        if (n % 2 == 0)
            b |= p;
    }
    if ((m - 2) > 0 && (m - 2) % 4 == 0)
        b++;
    if ((m + 1) % 4 == 0)
        b--;
    return b;
}

int main() {
    ll A, B;
    cin >> A >> B;
    if (A == 0)
        cout << calc(B) << endl;
    else
        cout << (calc(B) ^ calc(A - 1)) << endl;
    return 0;
}

Measured memory_bytes: 256