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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

//========================================================================//

int main() {
	set<int> st;
	Loop1(a, 9) {
		Loop1(b, 9) {
			st.insert(a * b);
		}
	}
	int n; cin >> n;
	if (st.find(n) == st.end()) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    t,a=parseMap(split(readline()))
    h=parseMap(split(readline()))
    ans=10^9
    ansindex=0
    for i in 1:n
        if abs(ans-a)>abs((t-h[i]*0.006)-a)
            ans=t-h[i]*0.006
            ansindex=i
        end
    end
    println(ansindex)
end
main()

Measured memory_bytes: 170712
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define Imax 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,0,n) cin>>a[i];
  asort(a);
  cout<<accumulate(a.begin(), a.end(), 0)-a[n-1]/2;
  
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]

d0 = [0]*100
d1 = [0]*100
for i in range(n):
    for j in range(61):
        if a[i] & (1<<j):
            d1[j] += 1
        else:
            d0[j] += 1

x = 1
ans = 0
mod = 10**9+7
for i in range(100):
    ans += x * d0[i] * d1[i] %mod
    x = x * 2 % mod
    ans %= mod
print(ans)

Measured memory_bytes: 123044
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
ll r,g;cin >> r >> g;
cout << 2*g-r << endl;

return 0;
}





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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    string st;
    cin >> st;
    cout << "2018/01/" << st[st.size()-2] << st[st.size()-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define sf scanf
#define pf printf
using namespace std;
#define ll long long
const int N=1e6+9;
const ll mod=1e9+7;
const ll inf=2e10;
int prime[N],vis[N];
void seive()
{
    for(int i=1;i<N;i++) prime[i]=i;
    for(int i=2;i<N;i+=2) prime[i]=2;
    for(int i=3;i*i<N;i+=2) {
        if(prime[i] == i) {
            for(int j=i*i;j<N;j+=i) {
                if(prime[j] == j) prime[j]=i;
            }
        }
    }
}
vector<int> chk(int v)
{
    vector<int>ans;
    while (v != 1)
    {
        int p=prime[v];
        ans.push_back(p);
        while (v%p==0) v/=p;
    }
    return ans;
}
void slv()
{
    seive();
    int n;
    cin >> n;
    int a[n+3],gcd=0;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        gcd=__gcd(gcd,a[i]);
    }
    bool ok=0;
    for(int i=0;i<n;i++) {
        vector<int>ans = chk(a[i]);
        for(auto x : ans)
        {
            if(vis[x]==1) ok=1;
            vis[x]=1;
        }
        if(ok) break;
    }
    if(!ok) puts("pairwise coprime");
    else {
        if(gcd == 1) puts("setwise coprime");
        else puts("not coprime");
    }
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;
    while (t--)
    {
        slv();
    }
    return 0;
}


Measured memory_bytes: 11752
import collections

n = int(input())
a = list(map(lambda x: int(x),input().split()))

ans = 0
count_dict = collections.Counter(a)
for k, v in count_dict.items():
    if k < v:
        ans = ans + abs(int(k)-int(v))
    elif k > v:
        ans = ans + int(v)

print(ans)


Measured memory_bytes: 18668
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define xx          exit(0);
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;

}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) {
    return (ll)(log(x) / log(base));
}
ll dp[1<<17], pre[1<<17];
//rec(0,notPresent,dp[mask],mask,0);
void rec(ll i, vector<ll> &notPresent,ll score_so_far,ll mask,ll group)
{
	if(i==(ll)notPresent.size())
	{
		dp[mask]=max(dp[mask],score_so_far+pre[group]);
		return ;
	}
	rec(i+1,notPresent,score_so_far,mask,group);
	rec(i+1,notPresent,score_so_far,mask^(1<<notPresent[i]),group^(1<<notPresent[i]));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll k,i,j,w,n,m,mask,N;
    	cin>>n;
    	ll a[n][n];
    	rep(i,0,n){
    		rep(j,0,n) cin>>a[i][j];
		}
    	rep(mask,0,1<<n)
    	{
    		pre[mask]=0;
    		rep(i,0,n)
    		{
    			if(mask & (1<<i))
    			{
    				rep(j,0,n)
    				{
    					if((mask^(1<<i)) & (1<<j))
    					pre[mask]+=a[i][j];
					}
				}
			}
			pre[mask]/=2;
		}
		vector<ll> notPresent;
		dp[0]=0;
    	rep(mask,0,1<<n)
    	{
    		notPresent.clear();
    		rep(i,0,n)
    		{
    			if(!(mask & (1<<i)))
    			notPresent.pb(i);
			}
			rec(0,notPresent,dp[mask],mask,0);
		}
    	cout<<dp[(1<<n)-1];
	}
	return 0;
}

Measured memory_bytes: 4704
var
 n,k,i,j:longint;
 a:array[0..105] of longint;
begin
 readln(n);
 a[1]:=1;
 i:=1;
 k:=1;
 while k<=100 do
  begin
   k:=k*2;
   inc(i);
   a[i]:=k;
  end;
 k:=i;
 for i:=k downto 1 do
  if a[i]<=n then 
   begin 
    writeln(a[i]);
    halt;
   end;
end.

Measured memory_bytes: 128
N, P = map(int, input().split())
A = list(map(int, input().split()))
B = [a % 2 for a in A]
count_0 = B.count(0)
count_1 = B.count(1)

if count_1 == 0:
    if P == 0:
        ans = 2 ** N
    else:
        ans = 0
else:
    ans = 2 ** (N - 1)
print(ans)


Measured memory_bytes: 61928
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int64_t l0 = 2;
    int64_t l1 = 1;
    int64_t li = 0;
    if (n == 1) {
        cout << 1 << endl;
    }
    else {
        for (int i = 0; i < n-1; i++) {
            li = l0 + l1;
            l0 = l1;
            l1 = li;
        }
        cout << li << endl;
    }
}

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

int main() {
  string s; cin >> s;
  int size = s.length(), a = 0, b = 0;
  for (int i = 0; i < size; i++) {
    if (s[i] == 'S')
      a++;
    else {
      if (a>0)
        a--;
      else
        b++;
    }
  }
  cout << a+b << endl;
  return 0;
}


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

void show(vector<ll>& vc)
{
    for(auto it:vc)cout<<it<<" ";
    cout<<endl;
}
#define M 300014



/**
int marked[M/64 + 2];

#define on(x) (marked[x/64] & (1<<((x%64)/2)))
#define mark(x)  marked[x/64] |= (1<<((x%64)/2))

void bitwiseSieve() {
  for (int i = 3; i * i <=M; i += 2) {
    if (!on(i)) {
      for (int j = i * i; j <= M; j += i + i) {
        mark(j);
      }
    }
  }
}

bool isPrime(int num) {
  return num > 1 && (num == 2 || ((num & 1) && !on(num)));
}
**/


/**
vector<ll>phi(M+2);
bool p[M+2];

void euler_phi(void)
{

    for(ll i=0;i<=M;i++)phi[i]=i;
    memset(p,0,sizeof p);
    p[1]=1;
    p[0]=1;
    phi[1] = 0;

    for(ll i=2; i<=M; i++)
    {

        if(!p[i])
        {

            for(ll j=i; j<=M; j+=i)
            {
                p[j]=1;
                phi[j]/=i;
                phi[j]*=(i-1);

            }
            p[i]=0;
        }
    }


}
//**/


/**
bool p[M+2];
vector<ll>prime;
void seive(void)
{

    memset(p,0,sizeof p);
    p[1]=1;
    p[0]=1;

    for(ll i=4; i<=M; i+=2)
    {
        p[i]=1;

    }

    for(ll i=3; i*i<=M; i+=2)
    {

        if(!p[i])
        {

            for(ll j=i*i; j<=M; j+=2*i)
            {
                p[j]=1;

            }
        }
    }

    prime.push_back(2);
    for(ll i=3; i<=M; i+=2)prime.push_back(i);
}
//**/


/**
ll dx[] = {-1,-1,0,-1,1,0,1,1};
ll dy[] = {-1,0,-1,1,-1,1,0,1};
**/

/**
typedef pair<ll, ll> pii;
#define x first
#define y second


pii extendedEuclid(ll a, ll b)   // returns x, y | ax + by = gcd(a,b)
{
    if(b == 0) return pii(1, 0);
    else
    {
        pii d = extendedEuclid(b, a % b);
        return pii(d.y, d.x - d.y * (a / b));
    }
}

ll modularInverse(ll a, ll n)
{
    pii ret = extendedEuclid(a, n);
    return ((ret.x % n) + n) % n;
}
//**/


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



void solve(ll t)
{


    ll n;
    cin>>n;
    ll sum =0;
    vector<ll>vc;
    for(int i=0;i<n;i++)
    {
        ll temp;
        cin>>temp;
        vc.push_back(temp);
        sum+=temp;
    }
    ll f = sum/n;
    ll c = (sum+n-1)/n;

    ll ans1 = 0;
    ll ans2 = 0;

    for(auto it:vc)
    {

        ans1+=(it-f)*(it-f);
    }

    for(auto it:vc)
    {

        ans2+=(it-c)*(it-c);
    }

    cout<<min(ans1,ans2)<<endl;




}


int main()
{
//     freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);

    /**seive();        //**/
    /** euler_phi();    //**/
    /** show(phi);      //**/
    /** bitwiseSieve(); //**/





    ll t=1;
    //scanf("%lld",&t);
    ll T=t;



    while(t--)
    {


        solve(T-t);

    }
    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int h,w;
    cin >> h >> w;
    vector<string> maze(h);
    for(auto &x:maze)cin >> x;

    queue<pii> nxt;
    vector<vector<bool>> check(h,vector<bool>(w,false));
    nxt.push(make_pair(0,0));
    while(!nxt.empty()){
        int x=nxt.front().first,y=nxt.front().second;
        nxt.pop();
        if(check[y][x])continue;
        check[y][x]=true;
        if(x+1<w){
            if(!check[y][x+1])nxt.push(make_pair(x+1,y));
        }
        if(y+1<h){
            if(!check[y+1][x])nxt.push(make_pair(x,y+1));
        }
        if(maze[y][x]=='#'){
            continue;
        }
        int bomb=0;
        for(int i=-1;i<2;i++){
            if(x+i<0 || x+i>=w)continue;
            for(int j=-1;j<2;j++){
                if(i==0 && j==0)continue;
                if(y+j<0 || y+j>=h)continue;
                if(maze[y+j][x+i]=='#')bomb++;
            }
        }
        maze[y][x]=bomb+'0';
    }

    for(auto &x:maze)cout << x << endl;

    return 0;
}


Measured memory_bytes: 3644
#064_C
n = int(input())
a = list(map(int, input().split()))

color = set()
flg = 0
for ai in a:
    if ai // 400 < 8:
        color.add(ai // 400)
    else:
        flg += 1
        
if len(color) == 0:
    print(1, len(color) + flg)
else:
    print(len(color), len(color) + flg)

Measured memory_bytes: 3060
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int stack;
      	
      	a *= 100;
      	if((a/100)%2==1) a+=4;
      	b *= 100;
      
      	boolean b1 = (a+96)*100/8 < b*100/10;
      	if((a+96)%100 == 0) b1 = (a+88)*100/8 < b*100/10;
      	boolean b2 = (b+90)*100/10 < a*100/8;
      	boolean b3 = a*100/8 < b*100/10;
      
      	if(b1 || b2) System.out.println(-1);
      	else if(b3) {
          stack = b*100/10/100;
          if((int)(stack * 0.08) == a /100) System.out.println(stack);
          else System.out.println(stack + 1);
        }
        else if(!b3) {
          stack = a*100/8/100;
          if((int)(stack * 0.1) == b/100) System.out.println(stack);
          else System.out.println(stack + 1);
        }
        
	}
}


Measured memory_bytes: 35844
#include <stdbool.h>
#include <stdio.h>
#include <string.h>

#define S 100

int main(void) {
    long k;
    int n, count_forward = 0, count_backward = 0;
    char c, s[S+2]; // +2 for newline and null
    bool is_same_char;

    fgets(s, S+1, stdin);
    n = strlen(s);
    if (s[n-1] == '\n') {
        s[n-1] = '\0';
        n--;
    }

    scanf("%ld", &k);

    // Special case for s consits of a single character
    is_same_char = true;
    c = s[0];
    for (int i = 1; i < n; i++) {
        if (s[i] != c) {
            is_same_char = false;
            break;
        }
    }
    if (is_same_char) {
        printf("%ld\n", (long) k * (long) n / 2);
        return 0;
    }

    if (s[0] == s[n-1]) {
        char c = s[0];

        int i = 0;
        while (i < n && s[i] == c) {
            count_forward++;
            i++;
        }
        i = n-1;
        while (i >= 0 && s[i] == c) {
            count_backward++;
            i--;
        }
    }

    long count = 0, ch_count = 1;
    c = s[0];
    for (int i = 1; i < n; i++) {
        if (s[i] == c) {
            ch_count++;
            if (ch_count % 2 == 0) {
                count++;
            }
        } else {
            ch_count = 1;
            c = s[i];
        }
    }

    long result = count * k - \
        (k - 1) * (count_forward / 2 + count_backward / 2 - (count_forward + count_backward) / 2);

    printf("%ld\n", result);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
long long a[N], b[N], ans;
int main(int argc, char const *argv[]) {
  // freopen("../../temp/.in", "r", stdin);
  int n = read();
  for (int i = 1; i <= n; ++ i) {
    a[i] = read();
    b[i] = read();
  }
  for (int i = n; i; -- i) {
    a[i] += ans;
    ans += (b[i] - a[i] % b[i]) % b[i];
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count_ac=0;
        int count_wa=0;
        int count_tle=0;
        int count_re=0;
        
        
        for(int i=0;i<n;i++){
            String str = sc.next();
            if(str.equals("AC")){
                count_ac++;
                continue;
            }
            if(str.equals("WA")){
                count_wa++;
                continue;
            }
            if(str.equals("TLE")){
                count_tle++;
                continue;
            }
            if(str.equals("RE")){
                count_re++;
                continue;
            }
            
        }
        System.out.println("AC x " + count_ac);
        System.out.println("WA x " + count_wa);
        System.out.println("TLE x " + count_tle);
        System.out.println("RE x " + count_re);

    }
}


Measured memory_bytes: 58120
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int answer = 0;
		int max = 0;
		ArrayList<Integer> list = new ArrayList<>();
		
		for (int i = N; i > 0; i-- ){
			
			int H = scanner.nextInt();
			list.add(H);
			if (H >= max) {
				max = H;
				answer = answer + 1;
			}
		}
		//System.out.println(list);
		System.out.println(answer);
	}
}

Measured memory_bytes: 21716
n,m=map(int,input().split())
a=[-1]+[int(input())for i in range(m)]+[n+1]
l=[1,2]+[0]*n+[1]
for i in range(n):
    l[i+2]=l[i]+l[i+1]
c=1    
for i in range(m+1):
    if a[i+1]-a[i]==1:
        c*=0
    else:
        c*=l[a[i+1]-a[i]-3]
print(c%1000000007)

Measured memory_bytes: 463984
#include <iostream>
#include <vector>
#include <algorithm>

int main(int, char**) {
  int x, y, z, K;
  std::cin >> x >> y >> z >> K;

  std::vector<long long> as(x), bs(y), cs(z);
  for(int i{}; i < x; ++i) {
    std::cin >> as[i];
  }
  for(int i{}; i < y; ++i) {
    std::cin >> bs[i];
  }
  for(int i{}; i < z; ++i) {
    std::cin >> cs[i];
  }

  std::sort(begin(as), end(as), std::greater<long long>());
  std::sort(begin(bs), end(bs), std::greater<long long>());
  std::sort(begin(cs), end(cs), std::greater<long long>());

  std::vector<long long> ans;
  for(int i{}; i < x; ++i) {
    for(int j{}; j < y; ++j) {
      for(int k{}; k < z; ++k) {
        if((i + 1) * (j + 1) * (k + 1) <= K) { ans.push_back(as[i] + bs[j] + cs[k]); }
        else { break; }
      }
    }
  }
  std::sort(begin(ans), end(ans), std::greater<long long>());
  for(int i{}; i < K; ++i) {
    std::cout << ans[i] << std::endl;
  }

  return 0;
}


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

int n;
vector<int> jutut;
int m;

bool tarkistus(int s){
	int a = 0;
	int b = jutut.size()-1;
	while(a <= b){
//		cout << a << " " << b << "\n";
		int k = (a+b)/2;
		if(jutut[k] > s) b = k-1;
		else a = k+1;
	}
	if(2*a == jutut.size()){
	return true;
	}else return false;
}
int main(){
	cin >> n;
	int maxi = 0;
	for(int i = 0; i < n; i++){
		cin >> m;
		maxi = max(m,maxi);
		jutut.push_back(m);
	}
	int counter= 0;
	sort(jutut.begin(), jutut.end());
	int a1 = 0;
	int b1 = maxi;
	for(int i = 1; i <= maxi; i++){
		if(tarkistus(i)) counter++;
	}
		/*	while(a1 <= b1){
		int k1 = (a1+a2)/2;
		if(tarkistus(k1)) b = k1-1;
		else a = k1+1;
	}
	cout << a1 << "\n";*/
	cout << counter << "\n";
}


Measured memory_bytes: 892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static boolean solve(int i, int m, int[] a) {
		if(m == 0) {
			return true;
		} else if(i >= a.length) {
			return false;
		}

		boolean result = solve(i + 1, m, a) || solve(i + 1, m - a[i], a);

		return result;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));

		int numberA = Integer.parseInt(br.readLine());

		String[] progressionA = br.readLine().split(" ");

		int[] A = new int[numberA];

		for (int i = 0; i < numberA; i++) {
            A[i] = Integer.parseInt(progressionA[i]);
		}

		int q = Integer.parseInt(br.readLine());

		String[] progressionM = br.readLine().split(" ");

		int[] m = new int[q];

		for (int i = 0; i < q; i++) {
			m[i] = Integer.parseInt(progressionM[i]);
		}

		for (int i = 0; i < m.length; i++) {
			if(solve(0, m[i], A)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}
}

Measured memory_bytes: 24648
li = [int(input()) for _ in range(5)]

ans = sum(li)

wareru = 0
sa = []
for i in li:
    tmp = i % 10
    if tmp == 0:
        pass
    else:
        tmp = 10-tmp
    sa.append(tmp)

ans += sum(sa)
ans -= max(sa)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#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 INF 1e9
// template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
// template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;
using ll = long long;

int main() { //int argc, const char * argv[]

    cin.tie(0);
    ios::sync_with_stdio(false);
 
 
    ll n, a, b, c, ans;
    cin >> n >> a >> b;
    c = a+b;
    
    if (c != 0){
        ans = (n/c) * a;
        if (n%c > a) {
            ans += a;
        } else {
            ans += n%c;
        }
    } else {
        ans = 0;
    }
    
 
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,N,X,sum=0;
  cin >> N;
  vector<int> vec(N);
  for(i=0;i<N;i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  X=(double)sum/N+0.5;
  sum = 0;
  for(i=0;i<N;i++){
    sum += (vec.at(i)-X)*(vec.at(i)-X);
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 3576
fn main() {
    let n = readln();

    let mut a: Vec<usize> = readlns(n);
    for i in 0..n {
        a[i] = a[i] - 1;
    }

    let mut rev: Vec<usize> = vec![0; n];
    for (i, &x) in a.iter().enumerate() {
        rev[x] = i;
    }

    let mut dp = vec![1; n];
    for i in (0..(n - 1)).rev() {
        let a = rev[i];
        let b = rev[i + 1];
        if a < b {
            dp[i] = dp[i + 1] + 1;
        }
    }
    println!("{}", n - dp.iter().max().unwrap());
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 10492
#include <iostream>

bool binary_search(int query, int arr[], int start_ind, int end_ind) {
    int length = end_ind - start_ind;
    if ( length == 1 ) {
        return arr[start_ind] == query;
    } else if ( length == 2 ) {
        return ( arr[start_ind] == query || arr[start_ind+1] == query );
    } else {
        int center_ind = ( start_ind + end_ind ) / 2;
        if ( arr[center_ind] == query ) {
            return true;
        } else if ( arr[center_ind] > query ) {
            return binary_search(query, arr, start_ind, center_ind);
        } else {
            return binary_search(query, arr, center_ind+1, end_ind);
        }
    }
}

int main() {
    int n, q;
    std::cin >> n;
    int s[n];
    for (int i=0; i<n; i++) {
        std::cin >> s[i];
    }
    
    std::cin >> q;
    int cnt = 0;
    for (int i=0; i<q; i++) {
        int t;
        std::cin >> t;
        if ( binary_search(t, s, 0, n) ) {
            cnt += 1;
        }
    }
    
    std::cout << cnt << std::endl;
}

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

using ll = long long;
const ll INF = 1e18;

int main() {
    int N, M, L, R, A = 0, B = 100001;
    cin >> N >> M;
    rep(i, M) {
        cin >> L >> R;
        A = max(A, L);
        B = min(B, R);
    }
    cout << max(0, B - A + 1) << "\n";
}

Measured memory_bytes: 256
n = int(input())

xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))
xyh.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        flag = True
        for k in range(1, n):
            if xyh[k][2] == 0:
                if abs(xyh[k][0] - i) + abs(xyh[k][1] - j) < h:
                    flag = False
                    break
            else:
                temp = xyh[k][2] + abs(xyh[k][0] - i) + abs(xyh[k][1] - j)
                if h != temp:
                    flag = False
                    break
        if flag == True and h >= 1:
            print(i, j, h)
            exit()


Measured memory_bytes: 9240
from functools import reduce

N = int(input())
dp = {}
result = 0

for _ in range(N):
    s = ''.join(sorted(input()))
    if s in dp:
        dp[s] += 1
    else:
        dp[s] = 1

print(reduce(lambda r, key: r + dp[key] * (dp[key] - 1) // 2, dp, 0))


Measured memory_bytes: 60504
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define sll            set<ll int>
#define msll        multiset<ll int>
#define io    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

ll h,w;
string a[1003];
ll dp[1003][1003];


ll go(ll i, ll j){

    if(i==h-1 and j==w-1) return 1;
    if(i>=h || j>=w) return 0;
    if(dp[i][j]!=-1) return dp[i][j];

    ll ans=0;
    if(a[i+1][j]=='.') ans+=go(i+1,j);
    if(a[i][j+1]=='.') ans+=go(i,j+1);

    return dp[i][j]=(ans%hell);
}

int main()
{
    io
    ll i,j;
    memset(dp,-1,sizeof dp);
    cin>>h>>w;

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

    cout<<go(0,0);

    return 0;
}

Measured memory_bytes: 9216
type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

let factorize :
  (* 素因数分解する整数 *)
  int ->
  (* 素因数と指数の組のリスト
     素因数について降順に出てくる *)
  (int * int) church_list
= fun n ->
  (* nをpで割れるだけ割って，割れた数c'にcを加えたものとn/p^c'を返す *)
  let rec iter_div p c n k =
    if 0 < n mod p
    then k c n
    else iter_div p (c + 1) (n / p) k in
  (* 素因数分解の処理の本体 *)
  let rec factorize f acc p n =
    if n <= 1
    then acc
    else if n < p * p
    then f (n, 1) acc
    else iter_div p 0 n @@ fun c ->
           factorize f (if c <= 0 then acc else f (p, c) acc) (p + 1) in
  { fold = fun f acc -> factorize f acc 2 n }

let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m 
       then upper_bound m r p
       else upper_bound l m p

let rec f n x =
  if x - n < 0 then n - 1
  else f (n + 1) (x - n)
let f = f 1

let () = Scanf.scanf "%d" @@ fun n ->
  Printf.printf "%d\n" @@
  (factorize n).fold (fun (_, n) -> ( + ) @@ f n) 0



Measured memory_bytes: 5872
#include<bits/stdc++.h>
using namespace std;
#define LL long long
char s[20];
map<LL,int>mp;
int main(){
	int n;scanf("%d",&n);
	LL ans=0;
	for(int i=0;i<n;i++){
		scanf("%s",s);
		sort(s,s+10);LL x=0;
		for(int j=0;s[j];j++){
			x=x*26+s[j]-'a';
		}
		ans+=mp[x];
		mp[x]++;
	}
	printf("%lld\n",ans);
	return 0;
}

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

vector <int> days[4];
vector <int> dp[4];
int n;

int main(){

	scanf("%d" , &n);
	for(int i = 0 ; i < n ; i++){
		int a, b, c;
		scanf("%d %d %d" , &a, &b, &c);
		days[0].push_back(a);
		days[1].push_back(b);
		days[2].push_back(c);
	}

	dp[0].push_back(days[0][0]);
	dp[1].push_back(days[1][0]);
	dp[2].push_back(days[2][0]);

	for(int i = 1 ; i < n ; i++){
		int a = days[0][i] + max(dp[1][i-1], dp[2][i-1]);
		int b = days[1][i] + max(dp[0][i-1], dp[2][i-1]);
		int c = days[2][i] + max(dp[0][i-1], dp[1][i-1]);
		dp[0].push_back(a);
		dp[1].push_back(b);
		dp[2].push_back(c);
	}

	printf("%d\n", max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1])));
	return 0;
}

Measured memory_bytes: 2924
X, K, D = map(int, input().split())
def resolve_best_i(X, K, D):
    if abs(X - int(X / D) * D) < abs(X - (int(X / D)+1)*D):
        return abs(X - int(X / D) * D), int(X /D)
    else:
        return abs(X - (int(X / D)+1)*D), int(X /D) + 1
def make_most_min(X, K, D):
    mokuhyou = X
    best = 0
    if X >= 0:
        mokuhyou, best = resolve_best_i(X, K, D)
        if best > K:
            best_posi = abs(X - K * D)
            return best_posi
        if best % 2 == K % 2:
            return abs(X - best * D)
        else:
            return min(abs(X - (best+1) * (D)), abs(X - (best-1) * (D)))
if X >= 0:
    a = make_most_min(abs(X), K, abs(D))
else:
    a = make_most_min(-X, K, abs(D))
print(a)

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

int main() {
  string S;
  cin >> S;
  int count = 0;
  int maxv = 0;
  for(int i = 0; i < S.size(); i++){
    
    if(S.at(i) == 'A' || S.at(i) == 'T' || S.at(i) == 'G' || S.at(i) == 'C' ) {
      count += 1;
    }
    else{
      count = 0;
    }
    
    maxv = max(count, maxv);
  }
    
  cout << maxv << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++) cin >> A[i];
    for (int i = 0; i < Y; i++) cin >> B[i];
    for (int i = 0; i < Z; i++) cin >> C[i];
    vector<ll> first_pair;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            first_pair.push_back(A[i] + B[j]);
        }
    }
    sort(first_pair.begin(), first_pair.end());
    reverse(first_pair.begin(), first_pair.end());
    vector<ll> AB;
    for (int i = 0; i < min(K, (int)first_pair.size()); i++) {
        AB.push_back(first_pair[i]);
    }
    vector<ll> second_pair;
    for (int i = 0; i < AB.size(); i++) {
        for (int j = 0; j < C.size(); j++) {
            second_pair.push_back(AB[i] + C[j]);
        }
    }
    sort(second_pair.begin(), second_pair.end());
    reverse(second_pair.begin(), second_pair.end());
    for (int i = 0; i < K; i++) cout << second_pair[i] << endl;
    return 0;
}

Measured memory_bytes: 43144
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
#define LIM 100001

class Solve {
public:
    string S;
    ll dp[LIM][2][13];

    ll func(int k = 0, int tight = 1, int m = 0) {
        if (dp[k][tight][m] != -1) {
            return dp[k][tight][m];
        }
        if (k == S.size()) {
            return (m % 13 == 5);
        }

        ll ret = 0ll;
        if (S[k] == '?') {
            for (int i = 0; i <= 9; ++i) {
                ll tmp = func(k + 1, tight, ((m * 10 + i)) % 13);
                ret += tmp;
                ret %= MOD;
            }
        } else {
            int i = (S[k] - '0');
            ll tmp = func(k + 1, tight, ((m * 10 + i)) % 13);
            ret += tmp;
            ret %= MOD;
        }
        return dp[k][tight][m] = ret;
    }

    void solve() {
        cin >> S;
        memset(dp, -1, sizeof(dp));
        ll ans = func();

        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 27904
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;


int main(){
  int q;
  cin >> q;
  rep(i,q){
    ll a,b;
    cin >> a >> b;
    ll f=min(a,b);
    ll g=max(a,b);
    ll ans=f-1;
    ll l=f+1,r=g+10;
    while(l!=r){
      ll mid=(l+r)/2;
      ll c=(f*g-1)/(mid);
      if (c<=mid) r=mid;
      else l=mid+1;
    }
    ans+=l-1-f;
    ans+=(f*g-1)/l;
    cout << ans << endl;
  }
}


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

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

    vector<int> A(N);
    vector<int> res(N);
    

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

    for(int i=0;i<N;i++){
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <string>

using namespace std;


int main(){
	int n;
	string s,t;
	cin >> n;
	cin >> s >> t;
	int p;
	
	for(p=n;p>0;p--){
		int i;
		for(i=0;i<p;i++){
			if(s[n-p+i] != t[i]){
				break;
			}
		}
		if(i == p){
			cout << (2*n - p) << endl;
			return 0;
		}
	}
		
	cout << 2*n << endl;
	return 0;
}



Measured memory_bytes: 256
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv) {
  int a[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int b;
    scanf("%d", &b);
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (b == a[i][j])
          a[i][j] = -1;
      }
    }
  }

  bool bng = false;
  for (int i = 0; i < 3; i++) {
    bng = bng || (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1);
    bng = bng || (a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1);
  }
  bng = bng || (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1);
  bng = bng || (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1);
  printf(bng ? "Yes\n" : "No\n");
  return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int k; cin >> k;
  string s; cin >> s;
  if (s.size() <= k)
    cout << s << '\n';
  else
    cout << s.substr(0, k) << "...\n";
}

Measured memory_bytes: 3632
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	int n;
	cin>>n;
	cout<<((1000 - n%1000))%1000<<endl;


	

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
int inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n;
string s;

//inputします
void input() {
    cin >> n >> s;
}

//ライブラリ置き場

//main
int main() {
    input();
    int ans = 0;
    ff(i, 0, n - 2) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }
    cout << ans << endl;
	return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{

  int i,j,N,A[100],tmp,count=0;

  scanf("%d",&N);

  for(i=0;i<N;i++){

    scanf("%d",&A[i]);
  }

  for(i=0;i<N-1;i++){

    for(j=N-1;j>i;j--){

      if(A[j]<A[j-1]){

	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;

	count++;
      }
    }
  }

  for(i=0;i<N;i++){

    printf("%d",A[i]);

    if(i<N-1)printf(" ");

      }

  printf("\n");

  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
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;
}

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

    int N;
    cin >> N;

    vector<int> v(N);
    v[0] = 1;
    int a, b, c;
    FOR(i, 1, N) {
        v[i] += v[i - 1] + i + 1;
        if (N == v[i]) {
            a = i;
            b = 0;
            break;
        }
        if (N < v[i]) {
            a = i;
            b = v[i] - N;
            break;
        }
    }

    REP(i, a + 1) {
        if (i + 1 != b) {
            std::cout << i + 1 << '\n';
        }
    }

    return 0;
}

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

#define MAX 1000

int top,bottom;

typedef struct{
	int x;
	int y;
	int cost;
}queue;
queue q[500000];
char map[MAX+2][MAX+2];
int visited[MAX+2][MAX+2];

void init(){
	int i,j;
	for(i=0;i<MAX+2;i++){
		for(j=0;j<MAX+2;j++){
			visited[i][j]=0;
		}
	}
}
void push(int x,int y,int cost){
	q[top].x=x;
	q[top].y=y;
	q[top].cost=cost;
	top++;
}
queue* pop(void){
	if(top==bottom){return NULL;}
	return &q[bottom++];
}

int main(){
	int h,w,n;
	int i;
	int ans=0;
	int list[10][2];//探索リスト
	int vector[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
	scanf("%d %d %d",&h,&w,&n);
	for(i=0;i<h+2;i++){
		if(i==0||i==h+1){
			memset(map[i],'X',w+2);
		}else{
			int j;
			scanf("%s",&map[i][1]);
			map[i][0]='X';
			map[i][w+1]='X';
			if(strchr(map[i],'S')!=NULL){
				list[0][0]=i;
				list[0][1]=(strchr(map[i],'S')-map[i]);
			}
			for(j=0;j<w+2;j++){
				char* p=(strchr(map[i],'0'+j));
				if(p!=NULL){
					list[j][0]=i;
					list[j][1]=p-map[i];
				}
			}
		}
	}
	for(i=0;i<n;i++){
		init();
		top=0;bottom=0;
		push(list[i][0],list[i][1],0);//スタート地点
		while(1){
			int j;
			queue* now;
			now=pop();
			if(now->x==list[i+1][0]&&now->y==list[i+1][1]){//到達したか否か
				ans+=now->cost;				
				break;
			}
			for(j=0;j<4;j++){
				int next_x=now->x+vector[j][0];
				int next_y=now->y+vector[j][1];
				if(map[next_x][next_y]!='X'&&visited[next_x][next_y]!=1){
					visited[next_x][next_y]=1;
					push(next_x,next_y,now->cost+1);
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10852
import math

a, b, h, m = map(int, input().split())

ang_a = 30 * h + m / 2
ang_b = 6 * m
ang_c = max(ang_a, ang_b) - min(ang_a, ang_b)
if ang_c > 180: ang_c = 360 - ang_c
ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(ang_c)))
print(ans)


Measured memory_bytes: 9500
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll a,b;
    cin>>a>>b;
    b -=a;
    ll sum = 0;
    rep(i,1,b){
        sum += i;
    }
    cout<<sum-a;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int n;
	scanf("%d\n",&n);
	
	int *a;
	a = (int *)malloc(n * sizeof(int));
	for(int i=0; i<n; i++) scanf("%d\n",&a[i]);
	
	int cnt = 0;
	int cur = 1;
	while (true){
		if (cur == 2) {
			printf("%d\n",cnt);
			break;
		}
		else if (cnt >= n){
			printf("-1\n");
			break;
		}
		else {
			cur = a[cur-1];
			++cnt;
		}
	}
	
	return 0;
}

Measured memory_bytes: 640
N = int(input())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
for i in range(N):
    t[i+1], x[i+1], y[i+1] = map(int, input().split())

f = True
for i in range(N):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    if dt < dist:
        f = False
    if dist%2 != dt%2:
        f = False

print('Yes' if f else 'No')

Measured memory_bytes: 17436
#include <iostream>
#include <cstring>
#include <limits.h>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int n, m, x[100020];
    cin >> n >> m;
    fill(x, x + n, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        x[a]++;  x[b]++;
    }
    
    for (int i = 0; i < n; i++) {
        if (x[i] % 2 != 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    
    
}


Measured memory_bytes: 640
{-# LANGUAGE TypeApplications #-}

import Data.List

main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  let [x, n] = map (read @Int) $ words l1
      ps = map (read @Int) $ words l2
  print $ f x ps

f x ps
  | not $ null eq = x
  | null lt = y2
  | null gt = y1
  | abs (y1 - x) <= abs (y2 - x) = y1
  | otherwise = y2
  where
    (lt, ge) = span (<x) $ filter (`notElem` ps) $ sort [0..101]
    (eq, gt) = span (==x) ge
    y1 = last lt
    y2 = head gt


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int dp[3007];
int main(){
    int a[4],x;cin>>a[1]>>a[2]>>a[3]>>x;
    for(int i=0;i<=x;i++) for(int k=0;k<=i;k+=a[1]) if(!((i-k)%a[2])) dp[i]++;
    int ans=0;
    for(int i=0;i<=x;i++){if(!((x-i)%a[3])) ans+=dp[i];}
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256