akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    int sum=0;
    rep(i,n){
        sum+=a[i];
    }
    vec x;
    for(int i=1;i*i<=sum;i++){
        if(sum%i==0){
            x.pb(i);
            x.pb(sum/i);
        }
    }
    int s=x.size();
    ll ans=0;
    rep(i,s){
        int nd=0;
        vec y(n);
        rep(j,n){
            y[j]=a[j]%x[i];
        }
        sort(all(y));
        int ta=0;
        int tb=n-1;
        while(ta!=tb){
            int tmp=min(y[ta],x[i]-y[tb]);
            y[ta]-=tmp;
            y[tb]+=tmp;
            nd+=tmp;
            if(y[ta]==0){
                ta++;
            }
            else{
                tb--;
            }
        }
        if(nd>k) continue;
        chmax(ans,x[i]);

    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll mod=1e9+7;
 
ll mpow(ll a,ll b) {
    ll c=1;
    while (b) {
        if (b&1) c=c*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return c;
}
 
ll C(ll a,ll b) {
    ll f=1;
    for (ll i=a;i>a-b;i--)
        f=f*i%mod;
    ll f2=1;
    for (ll i=2;i<=b;i++)
        f2=f2*i%mod;
    return f*mpow(f2,mod-2)%mod;
}
 
int main() {
    ll n,a,b;cin>>n>>a>>b;
    cout<<((mpow(2,n)-1-C(n,a)-C(n,b))%mod+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	m := make(map[int]int)
	for _, ai := range A {
		m[ai]++
	}
	c := 0
	for _, v := range m {
		c += v * (v - 1) / 2
	}
	for _, ai := range A {
		fmt.Println(c - m[ai] + 1)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 14628
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        while(true) {
            string inpt = Reader.ReadLine();
            if(inpt == null) {
                break;
            }
            decimal[] ret = GetAns(inpt.Split(' ').Select(a => decimal.Parse(a)).ToArray());
            ans.AppendLine(ret[0] + " " + ret[1]);
        }
        Console.Write(ans.ToString());
        
    }

    private decimal[] GetAns(decimal[] inpt) {
        decimal[] ret = new decimal[2];
        decimal x = GetX(inpt, -5000, 5000);
        decimal y = GetY(inpt, x);

        ret[0] = Math.Round(x, 3, MidpointRounding.AwayFromZero);
        ret[1] = Math.Round(y, 3, MidpointRounding.AwayFromZero);
        return ret;
    }

    private decimal GetX(decimal[] list, decimal min, decimal max) {
        if(max - min < 0.0000001m) {
            return Math.Round(min, 6, MidpointRounding.ToEven);
        }

        decimal md1 = min + (max - min) / 3;
        decimal md2 = min + (max - min) / 3 * 2;

        decimal[] vals = new decimal[4];
        vals[0] = GetYDiff(list, min);
        vals[1] = GetYDiff(list, md1);
        vals[2] = GetYDiff(list, md2);
        vals[3] = GetYDiff(list, max);

        decimal valMin = vals.Min();
        if(valMin == vals[0]) {
            return GetX(list, min, md1);
        } else if(valMin == vals[1]) {
            return GetX(list, min, md2);
        } else if(valMin == vals[2]) {
            return GetX(list, md1, max);
        } else {
            return GetX(list, md2, max);
        }
    }

    private decimal GetY(decimal[] list, decimal x) {
		decimal y = (list[2] - x * list[0]) / list[1];
        return y;
	}

    private decimal GetYDiff(decimal[] list, decimal x) {
        decimal y = GetY(list, x);
        decimal tmp = Math.Abs((x * list[3] + y * list[4]) - list[5]);
        return tmp;
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


1 2 3 4 5 6
2 -1 -2 -1 -1 -5



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9944
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

ll md = (ll)1e9 + 7;

int main()
{
	ll N;
	cin >> N;
	int width = (int)1e6;

	ll ans = (ll)1e12+100;
	for (int i = 1; i <= width; ++i) {
		if (N % i == 0) {
			ll cnt = i + (N / i) - 2;
			ans = min(ans, cnt);
		}
	}

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


Measured memory_bytes: 3604
/*input
red
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const int maxn=1e5+5;
int main(){
	string a;
	cin>>a;
	REP(i,sz(a)) cout<<'x';
}

Measured memory_bytes: 256
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-
"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = input().split()
    t = input().split()
    a = 0
    for i in range(int(s[1])):
        a += int(t[i])
    b = int(s[0])
    if b <= a:
        print('Yes')
    else:
        print('No')

    return 0

if __name__ == '__main__':
    #上記のifの記述によってこのスクリプトファイルが起動された時だけ実行する部分になる。
    #ちなみにスクリプトが "モジュールとして"インポートされた時には実行されない、

    #単体テスト:モジュールのdocstring(ドキュメンテーション文字列)に記載された全ての対話実行例が書かれている通りに動作するかを確認
    #python ファイル名 -v
    import doctest
    doctest.testmod()

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Measured memory_bytes: 15012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;
    s[K-1] += 0x20;
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX/4;

void update(int& a, int b){
    a = min(a, b);
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> t0(n); // ツ堕閉氾オツ鳴ウ
        vector<vector<int> > t(n, vector<int>(n));
        for(int i=0; i<n; ++i){
            cin >> t0[i];
            for(int j=0; j<n; ++j)
                cin >> t[i][j];
        }

        vector<int> dp(1<<n, INF);
        dp[0] = 0;
        for(int i=0; i<(1<<n); ++i){
            bitset<16> bs(i);
            for(int j=0; j<n; ++j){ // ツ攻ツ猟ェツつキツづゥツスツテツーツジ
                if(bs[j])
                    continue;
                bitset<16> bs2 = bs;
                bs2[j] = true;
                update(dp[bs2.to_ulong()], dp[bs.to_ulong()] + t0[j]); 
                for(int k=0; k<n; ++k){ // ツ使ツつ、ツ堕閉氾オ
                    if(bs[k])
                        update(dp[bs2.to_ulong()], dp[bs.to_ulong()] + t[j][k]);
                }
            }
        }

        cout << dp[(1<<n)-1] << endl;
    }
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define preeti ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f first
#define s second
#define SIZE 26 
const long double PI = 3.141592653589793238L;
int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

int main()
{
  preeti;
  int t;
  cin>>t;
  int ac=0,wa=0,tle=0,re=0;
  while(t--)
  {
 string s;
 cin>>s;
 if(s=="AC")
 ac++;
 else if(s=="WA")
 wa++;
 else if(s=="TLE")
 tle++;
 else 
 re++;
  }
  cout<<"AC"<<" "<<"x"<<" "<<ac<<"\n";
  cout<<"WA"<<" "<<"x"<<" "<<wa<<"\n";
  cout<<"TLE"<<" "<<"x"<<" "<<tle<<"\n";
  cout<<"RE"<<" "<<"x"<<" "<<re<<"\n";
 
return 0;
}


Measured memory_bytes: 3648
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

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

int h, w, d, q, l, r, cnt, mem, sum[90000];
unordered_map<int, pair<int, int>>mp;

int main(){
	cin >> h >> w >> d;
	lp(h) {
		LP(w, j) {
			cin >> mem;
			mp[mem - 1] = make_pair(i, j);
		}
	}
	lp(d)sum[i] = 0;
	for (int i = d; i < h*w; i++) {
		sum[i] = sum[i - d] + abs(mp[i].first - mp[i - d].first) + abs(mp[i].second - mp[i - d].second);
	}
	cin >> q;
	lp(q) {
		cin >> l >> r;
		cout << sum[r - 1] - sum[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 5284
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int nax=5e5+1;
vector<int> cnt(nax);
int blk=707;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   int n,q;
   cin>>n>>q;
   vector<int> a(n);
   for(int i=0;i<n;i++) cin>>a[i];
   vector<pair<pair<int,int>,int>> vec(q);
   for(int i=0;i<q;i++)
   {
       cin>> vec[i].first.first>>vec[i].first.second;
       vec[i].first.first--;
       vec[i].first.second--;
       vec[i].second=i;

   }
   
   sort(vec.begin(),vec.end(),[&](pair<pair<int,int>,int> x,pair<pair<int,int>,int> y){
      
       if((x.first.first/blk)!=(y.first.first/blk)) return (x.first.first/blk)<(y.first.first/blk);
       else return x.first.second<y.first.second;
       
   });
   int l=0,r=-1;
   vector<int> an(q);
   int ans=0;
   auto add=[&](int id){
       cnt[a[id]]++;
       if(cnt[a[id]]==1) ans++;
   };

   auto sub=[&](int id){
       cnt[a[id]]--;
       if(cnt[a[id]]==0) ans--;
   };

   for(int i=0;i<q;i++)
   {
       while(r<vec[i].first.second)
       {
           r++;
           add(r);
       }
        while(l<vec[i].first.first)
       {
           
           sub(l);
           l++;

       }
       while(r>vec[i].first.second)
       {
           sub(r);
           r--;
       }
      
       while(l>vec[i].first.first)
       {
           l--;
           add(l);
           

       }
      //if(l==r) ans--;
      an[vec[i].second]=ans;
       //cout<<ans<<endl;

   }
   for(auto it : an) cout<<it<<"\n";
}


Measured memory_bytes: 15520
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cassert>
#include <algorithm>
using namespace std;

static const int N = 4;
static const int N2 = N*N;
static const int LIMIT = 100;

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle{
  int f[N2];
  int space;
  int MD;
};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz){
  int sum=0;
  for(int i=0; i<N2; i++){
    if(pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i]-1];
  }
  return sum;
}

bool dfs(int depth, int prev){
  if(state.MD == 0) return true;
  //現在の深さにヒューリスティック距離を足して制限を超えたら枝をかる
  if(depth + state.MD > limit) return false;

  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;

  for(int r=0; r<4; r++){
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if(tx<0 || ty<0 || tx>=N || ty>=N) continue;
    if(max(prev, r) - min(prev, r) == 2) continue;
    tmp = state;

    state.MD -= MDT[tx*N + ty][state.f[tx*N + ty]-1];
    state.MD += MDT[sx*N + sy][state.f[tx*N + ty]-1];
    swap(state.f[tx*N + ty], state.f[sx*N + sy]);
    state.space = tx*N + ty;
    if(dfs(depth + 1, r)) {
      path[depth] = r;
      return true;
    }
    state = tmp;
  }

  return false;
}

string iterative_deeping(Puzzle in){
  in.MD = getAllMD(in);

  for(limit = in.MD; limit <= LIMIT; limit++){
    state = in;
    if(dfs(0, -100)){
      string ans = "";
      for(int i=0; i < limit; i++){
        ans += dir[path[i]];
      }
      return ans;
    }
  }

  return "unsolvable";
}

int main(){
  for(int i=0; i<N2; i++){
    for(int j=0; j<N2; j++){
      MDT[i][j] = abs(i/N - j/N) + abs(i%N - j%N);
    }
  }

  Puzzle in;

  for(int i=0; i<N2; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }

  string ans = iterative_deeping(in);
  cout << ans.size() << endl;

  return 0;
}



Measured memory_bytes: 3180
#include <cstdio>
constexpr int MOD = 1e9+7;
int K, M, N;

constexpr int fpm(int base, int index) {
    int power = 1;
    while (index) {
        if (index & 1) {
            power = 1LL * base * power % MOD;
        }
        base = 1LL * base * base % MOD;
        index >>= 1;
    }
    return power;
}
constexpr int inv2 = fpm(2, MOD-2);

int ncr(int r) {
    // (N x M - 2) choose (K - 2)
    int n = (1LL * N * M % MOD + MOD - 2) % MOD;
    int c = 1;
    for (int i = 1; i <= r; ++i) {
        c = 1LL * c * (n - (i - 1)) % MOD * fpm(i, MOD-2) % MOD;
    }
    return c;
}

int sum(int n) { return 1LL * n * (n + 1) % MOD * inv2 % MOD; }

int main() {
    scanf(" %d%d%d", &N, &M, &K);
    int ret = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            int b = N-i;
            ret = (1LL * sum(M-j-1) * b % MOD + ret) % MOD; // Forwards (>= i)
            ret = (1LL * sum(j) * (b-1) % MOD + ret) % MOD; // Backwards (> i)
            ret = (1LL * sum(b - 1) * M % MOD + ret) % MOD; // Downwards (all)
        }
    }
    ret = 1LL * ret * ncr(K-2) % MOD;
    printf("%d\n", ret);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int n,m,i,sum,tm=0,stm;
    int t[100001],p,x;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&t[i]);
        tm+=t[i];
    }
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%d %d",&p,&x);
        stm=tm-(t[p-1]-x);
        printf("%d\n",stm);
    }
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 101000
using namespace std;
vector<int>E[N_], TP;
vector<int>V;
vector<vector<int> >U;
int n, m, v[N_], w[N_];
void DFS(int a) {
	v[a] = 1;
	TP.push_back(w[a]);
	int i;
	for (i = 0; i < E[a].size(); i++)if (!v[E[a][i]])DFS(E[a][i]);
}
int main() {
	int i, a, b, j;
	scanf("%d%d", &n,&m);
	if (m == n - 1) {
		printf("0\n");
		return 0;
	}
	for (i = 1; i <= n; i++)scanf("%d", &w[i]);
	for (i = 1; i <= m; i++) {
		scanf("%d%d", &a, &b);
		a++, b++;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	int S = 0, Com = 0;
	for (i = 1; i <= n; i ++) {
		if (!v[i]) {
			TP.clear();
			DFS(i);
			sort(TP.begin(), TP.end());
			Com++;
			U.push_back(TP);
		}
	}
	long long res = 0;
	for (i = 0; i < U.size(); i++) {
		res += U[i][0];
		for (j = 1; j < min((int)U[i].size(), Com - 1); j++) {
			V.push_back(U[i][j]);
		}
	}
	if (Com * 2 - 2 > (int)V.size() + Com) {
		printf("Impossible\n");
	}
	else {
		sort(V.begin(), V.end());
		for (j = 0; j < Com * 2 - 2 - Com; j++) {
			res += V[j];
		}
		printf("%lld\n", res);
	}
}

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

int main(){
  int N,T;
  cin >> N >> T;
  int ans=1001;
  for(int i = 0; i< N ; i++){
    int c,t;
    cin >> c >> t;
    if(t <= T && c < ans)ans = c;
  }
  
  if(ans <= 1000)cout << ans << endl;
  else cout << "TLE" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      cin >> N;
      int count=0;
      int min=30;
      int k=0;
      
      // ここにプログラムを追記
      for(int i=0;i<N;i++){
        cin >> k ;
        count=0;
        while(k%2==0){
          k/=2;
          count++;
        }
        if(count<min){
          min=count;
        }
      }
      cout << min << endl;
      
    }

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(b == 1) {
        cout << 0;
        return 0;
    }
    int num = 0, i = 0;
    while(num < b) {
        i += 1;
        num = ((i - 1) * (a - 1)) + a;
    }
    cout << i;
}



Measured memory_bytes: 3576
tmp = list(map(int, input().split()))
n = tmp[0]
m = tmp[1]

maxl = 1
minr = n
for i in range(m):
  tmp = list(map(int, input().split()))
  l = tmp[0]
  r = tmp[1]
  if l > maxl:
    maxl = l
  if r < minr:
    minr = r

if maxl <= minr:
  print(minr - maxl + 1)
else:
  print('0')

Measured memory_bytes: 44136
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define MaxN 100003

int N;
int fa[MaxN];
long long ans, cnty[MaxN], cntx[MaxN];
map<int, bool> bk[MaxN];
struct Nd {
	int x, y;
}a[MaxN];

inline int Rd() {
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}
inline int Find(int d) {
	if(fa[d] == d) return d;
	else return fa[d] = Find(fa[d]);
} 
inline bool cmp(Nd aa, Nd bb) {
	return aa.x < bb.x;
}

int main() {
	N = Rd();
	for(reg int i = 1; i <= 100000; ++i)
		fa[i] = i;
	for(reg int i = 1; i <= N; ++i)
		a[i].x = Rd(), a[i].y = Rd();
	sort(a + 1, a + 1 + N, cmp);
	for(reg int i = 1; i < N; ++i)
		if(a[i].x == a[i + 1].x)
			fa[Find(a[i].y)] = Find(a[i + 1].y);
	for(reg int i = 1; i <= 100000; ++i)
		++cnty[Find(i)];
	for(reg int i = 1; i <= N; ++i)
		if(!bk[Find(a[i].y)][a[i].x]) {
			++cntx[Find(a[i].y)];
			bk[Find(a[i].y)][a[i].x] = true;
		}
	for(reg int i = 1; i <= 100000; ++i)
		ans += cnty[i] * cntx[i];
	cout << ans - N << endl;
	return 0;
}

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

void check(char str[])
{
    if(str[2]==str[3] && str[4]==str[5])
        cout << "Yes";
    else
        cout << "No";
}

int main()
{
    char str[6];
    cin >> str;
    check(str);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a,b,sum=30;
  cin >> N;
  
  for(int i=0;i<N;i++){
    cin>> a;
    b=0;
    for(int j= 0;a%2==0;j++){
      a/=2;
      b++;
    }
    if(b<sum)
      sum=b;
    
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<string>
using namespace std;
int cnt=0;
int main(void){
    int k,s;
    cin>>k>>s;
    int cnt=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(s-(i+j)>=0 && s-(i+j)<=k) cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;   
}


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

int main()
{
    char f[1024] = "";
    scanf("%s", f);
    bool a[256] = {};
    for (int i = 0; f[i]; i++) a[f[i]] = true;
    puts((a['S'] ^ a['N']) || (a['W'] ^ a['E']) ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 256
from numpy import*
a,b=loadtxt(open(0),'i',skiprows=1)
c=0
l=1<<29
while l:u=l;l>>=1;c+=sum(diff(searchsorted(sort(r_[b%u-u,b%u]),([u],[l])-a%u).T))%2*l
print(c)

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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const ll N = 123456;

vector < int > a[N];

const ll mod = 1e9 + 7;

int deg[N];
int par[N];
int child[N];
bool flag = -1;

void dfs(int s , int p) {
    par[s] = p;

    for(auto child : a[s]) {
        if(child == p) continue;
        dfs(child , s);
    }

    //cout << s << "  sad " << deg[s] << endl;

    if(deg[s] == 1 && s != 1) {
        child[s] = 0;
        return ;
    }

    int total = 0;

    for(auto child : a[s]) {
        if(child == p) continue ;
        else total++;
    }

    child[s] = total;
    return;
}

ll npr(ll n , ll r) {
    if(r > n) return 0;
    ll total = 1;

    rep(i , n - r + 1 , n) {
        total = total * i;
        total %= mod;
    }

    return total;
}

ll nways(ll n , ll k) {
    dfs(1 , -1);

    ll ways = 0;

    rep(i , 1 , n) {
        if(i == 1) {
            ways = ways + k * npr(k - 1 , child[1]);

         //   cout << i << " " << ways << endl;
        }
        else {
            if(deg[i] == 1) continue;
            ways = ways * npr(k - 2 , child[i]);
           // cout << i << " " << npr(k - 2 , child[i]) << " " << child[i] << endl;
        }

        ways %= mod;
    }

    return ways % mod;
}

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

    ll n , k;

    cin >> n >> k;

    rep(i , 1 , n - 1) {

        int x , y;

        cin >> x >> y;

        deg[x]++;
        deg[y]++;

        a[x].push_back(y);
        a[y].push_back(x);
    }

    cout << nways(n , k) << endl;

    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)
#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX = 1e6 + 5, MOD = 1e9 + 7 , MAXLG = log2(MAX)+1;
const ll inf = 1e18 + 5;

int arr[MAX];
int main(){

    fastio;
    ll n;
    cin>>n;
    cout<<(ll)(n/2 + n%2)<<"\n";
}


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

using namespace std;

int main() {
  int n, a;
  cin >> n;
  vector<int> v;
  for(int i = 0; i < n; i++) {
    cin >> a;
    v.emplace_back(a);
  }
  int x = __gcd(v[0], v[1]);
  for(int i = 2; i < n; i++) {
    x = __gcd(x, v[i]);
  }

  cout << x << endl;
}


Measured memory_bytes: 892
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int a, b, c;
    cin >> a >> b >> c;

    if (a + b + c >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n<1200){
		cout<<"ABC"<<endl;
	}else if(n<2800&&n>=1200){
		cout<<"ARC"<<endl;
	}else{
		cout<<"AGC"<<endl;
	}
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

Int x, y;
int main(){
	cin >> x >> y;
	if(x % y == 0) cout << "-1" << endl;
	else cout << x << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    lli n;
    cin >> n;
    if(n%1000!=0)
    cout << 1000 - n % 1000;
    else
        cout << "0";
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int k;
int h, w;
int inf = 100000000;
char s[10][1000];
char cut[9];
int DFS(int m);
int main() {

	cin >> h >> w;
	cin >> k;
	int i, j;
	for (i = 0; i < h; i++) {
		//if (i < h - 1) {
		//	cut[i] = 0;
		//}
		for (j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	cout << DFS(0) << endl;
	return 0;
}
int DFS(int m) {
	int a, b;
	int area[10];
	int cutnum, areanum, prevcut, cutcounter, lflag;
	int i, j,l;
	if (m < h - 1) {
		cut[m] = 0;
		a = DFS(m+1);
		cut[m] = 1;
		b = DFS(m+1);
		if (a < b) {
			//cout << a;
			return a;
		}
		else {
			//cout << b;
			return b;
		}
	}
	else {
		cutnum = 0;
		for (i = 0; i < h - 1; i++) {
			if (cut[i] == 1) {
				cutnum++;
			}
		}
		cutcounter = cutnum;
		//cout << cutnum << endl;

		prevcut = -1;
		for (i = 0; i <= cutnum; i++) {
			area[i] = 0;
		}
		for (j = 0; j < w; j++) {
			lflag = 0;
			
			areanum = 0;
			for (i = 0; i < h; i++) {
				if (i > 0) {
					if (cut[i - 1] == 1)areanum++;
				}
				if (s[i][j] == '1') {
					area[areanum]++;
					//if (cut[0] == 0)cout << area[areanum] << endl;
					if (area[areanum] > k) {
						if (j - prevcut == 1) {
							//cout << inf;
							return inf;

						}else{
							for (l = 0; l <= cutnum; l++) {
								area[l] = 0;
							}
							prevcut = j - 1;
							j--;
							lflag = 1;
							cutcounter++;
						}
					}
				}
				if (lflag == 1)break;
			}
		}
		return cutcounter;

		 
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using std::swap;
int a[1123];
int main(){
	int n; scanf("%d", &n);
	int x = 0;
	for(int i(1), t; i <= n; ++i){
		scanf("%d", &t);
		if(t != i) ++x;
	}
	printf("%s\n", x <= 2 ? "YES" : "NO");
	return 0;	
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
	long box[10001];
	int i = 0;

	while(1) {
		cin >> box[i];
		if (box[i] == 0) {
			break;
		}
		i++;
	}

	for (int j = 0;j < i;j++) {
		cout << "Case" << " " << j + 1 << ":" << " " << box[j] << endl;
	}

	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=2e5+10;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()


#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
} 
int binomialCoeff(int n, int k)  
{
    if (k == 0 || k == n)  
        return 1;  

    return binomialCoeff(n - 1, k - 1) +  
                binomialCoeff(n - 1, k);  
}  
long long power(ll a, ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%MOD;
        b/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

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

vector<int>v[N];
ll sum[N];

void dfs(int n,int vis)
{
    for(int i=0;i<v[n].size();i++)
    {
        if(v[n][i]!=vis)
        {
            sum[v[n][i]]+=sum[n];
            dfs(v[n][i],n);
        }
    }
}


int main()
{
    IOS;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int mx=0;
    int c=0;
    for(int i=0;i<n;i++)
    {
        int c=0;
        while(i<n-1 && a[i]>=a[i+1])
        {
            c++;
            i++;
        }
        mx=max(c,mx);
    }
    cout<<mx<<endl;


}

Measured memory_bytes: 5376
while input = gets

    n, x = input.chomp.split(" ").map(&:to_i)
    
    if n == 0 && x == 0
        exit
    end
    
    ways = 0
    
    for i in 1..n - 2
    
        if i * 3 + 3 > x
            break
        end
    
        for j in i + 1..n - 1
        
            if i + j * 2 + 1 > x
                break
            end
        
            for k in j + 1..n
            
                if i + j + k > x
                    break
                elsif i + j + k == x
                    ways += 1
                end
            end
        end
    end
    
    puts ways
end


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

int main(){
	int A,B,K,i,count=0;
	cin>>A>>B>>K;
	for(i=100;i>=1;i--){
		if(A%i==0){
			if(B%i==0){count++;}
		}
		if(count==K){break;}
	}
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 101

int main(void){

  int A[N][N]={};
  int i,j,n,u,v[N],k;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v[j]);
      A[u-1][v[j]-1] = 1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j==n-1){
	printf("%d",A[i][j]);
	continue; 
      }
      printf("%d ",A[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n; cin >>n;
  vector<int> cnt(2e5,0);
  rep(i,n){
    int a; cin >>a;
    cnt[a]++;
  }
  int ans=0;
  repa(i,1,2e5-1){
    int c=cnt[i]+cnt[i-1]+cnt[i+1];
    chmax(ans,c);
  }
  print(ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



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

  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;

  rep(i, n + 1) {
    if (s.substr(i) == t.substr(0, n - i)) {
      cout << n + i << '\n';
      return 0;
    }
  }




  
  return 0;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

#define P 1000000007
#define N 2010
string a[N], ca[N];
int n, m; ll k;

int pow(int x, ll y) {
	int s = 1, t = x;
	while (y) {
		if (y&1) {
			s = (ll)s*t%P;
		}
		t = (ll)t*t%P;
		y /= 2;
	}
	return s;
}

int main () {
	cin >> n >> m >> k;
	if (k == 0 || k == 1) {
		puts ("1");
		return 0;
	}
	k --;
	for (int i = 0; i < n; i ++) cin >> a[i];
	bool cu = 0, cl = 0;
	for (int i = 0; i < m; i ++) 
		if (a[0][i] == '#' && a[n-1][i] == '#') cu = 1;
	for (int i = 0; i < n; i ++)
		if (a[i][0] == '#' && a[i][m-1] == '#') cl = 1;
	if (cu && cl) {
		puts ("1");
	} else 
	if (!cu && !cl) {
		int S = 0;
		for (int i = 0; i < n; i ++)
			for (int j = 0; j < m; j ++)
				if (a[i][j] == '#') S ++;
		cout << pow(S, k) << endl;
	} else {
		if (cu) {
			for (int i = 0; i < m; i ++) {
				for (int j = 0; j < n; j ++) {
					ca[i] += a[j][i];
				}
			}
			for (int i = 0; i < m; i ++) a[i] = ca[i];
			swap(n, m);
		}
		int py = 0, pz = 0, ps = 0;
		for (int i = 0; i < n; i ++) {
			if (a[i][0] == '#' && a[i][m-1] == '#') ps ++;
			for (int j = 0; j < m; j ++) {
				if (a[i][j] == '#') {
					pz ++;
					if (j < m-1 && a[i][j+1] == '#') py ++;
				}
			}
		}
		int add = 1, ads = 0, asd = 0, ass = 1;
		int bdd = pz, bds = 0, bsd = (P-py)%P, bss = ps;
		while (k) {
			if (k&1) {
				int ndd = ((ll)add*bdd+(ll)ads*bsd)%P;
				int nds = ((ll)add*bds+(ll)ads*bss)%P;
				int nsd = ((ll)asd*bdd+(ll)ass*bsd)%P;
				int nss = ((ll)asd*bds+(ll)ass*bss)%P;
				add = ndd;
				ads = nds;
				asd = nsd;
				ass = nss;
			}
			int ndd = ((ll)bdd*bdd+(ll)bds*bsd)%P;
			int nds = ((ll)bdd*bds+(ll)bds*bss)%P;
			int nsd = ((ll)bsd*bdd+(ll)bss*bsd)%P;
			int nss = ((ll)bsd*bds+(ll)bss*bss)%P;
			bdd = ndd;
			bds = nds;
			bsd = nsd;
			bss = nss;
			k /= 2;
		}
		int ad = 1, as = 1;
		int S = ((ll)ad*add+(ll)as*asd)%P;
		cout << S << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;

long long const inf = 2e18, linf = 2e9, mod = 1e9+7;
int const mxn = 1e6 + 10 ;  ; 

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

long long ans ;
int main(){
	int k ; 
	cin>>k ;
	for (int i = 1 ; i <= k ; i++){
		for (int j = 1 ; j <=k ; j++){
			for (int z = 1  ; z <=k ; z++){
				ans+=(__gcd(i, __gcd(j, z))) ; 
			}
		}
	}
	cout<<ans ; 

}

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll a;
    cin>>a;
	string N;
	cin>>N;
    ll r=0,g=0,b=0;
    rep(i,N.size()){
        if(N[i]=='R'){
            ++r;
        }else if(N[i]=='G'){
            ++g;
        }else{
            ++b;
        }
    }
    ll ans = 0;

    ans += r*g*b;
    ll d;
    rep(i,N.size()/2){
        d = i+1;
        rep(j,N.size()){
            if(j+d*2>=N.size()){
                continue;
            }
            if(N[j]!=N[j+d] &&N[j]!=N[j+2*d]&&N[j+d]!=N[j+2*d]){
                --ans;
                // cout<<j<<d<<"\n";
            }
        }
    }
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3656
function main() {
  console.log(require('util').format('%s:%s:%s',
                                     Math.floor(Math.floor(input[0] / 60 / 60 % 60)),
                                     Math.floor(input[0] / 60 % 60),
                                     Math.floor(input[0] % 60)));
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 7648
S = input() 
is_yymm = 1 <= int(S[2:4]) <= 12
is_mmyy = 1 <= int(S[0:2]) <= 12

if is_mmyy and is_yymm:
    print('AMBIGUOUS') 
elif is_yymm:
    print('YYMM')
elif is_mmyy:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int keta = 1;
		while(b / (int) Math.pow(10, keta) != 0)
			keta++;
		int wa = (int) (a * Math.pow(10, keta) + b);
		double ans = (int) Math.sqrt(wa);
		if(ans == Math.sqrt(wa)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


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

#define MAX_N 100010

struct point {int id, x, y;};
struct edge {int u, v, w;};

int n;
point p[MAX_N];
edge edgeset[2 * MAX_N];

int pa[MAX_N];
int rnk[MAX_N];

void init(void)
{
    memset(pa, 0, sizeof(pa));
    memset(rnk, 0, sizeof(rnk));
    for (int i = 0; i < n; i++) {
        pa[i] = i;
        rnk[i] = 0;
    }
}

int find(int x)
{
    if (pa[x] == x) return x;
    else return pa[x] = find(pa[x]);
}

void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rnk[x] < rnk[y]) pa[x] = y;
    else {
        pa[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x, int y)
{
    return (find(x) == find(y));
}

int abs(int a)
{
    return a >= 0? a: -a;
}

bool cmp_x(point a, point b)
{
    return a.x < b.x;
}

bool cmp_y(point a, point b)
{
    return a.y < b.y;
}

bool cmp_edge(edge a, edge b)
{
    return a.w < b.w;
}

int mst(void)
{
    init();
    int res = 0;
    for (int i = 0; i < 2 * (n - 1); i++) {
        edge e = edgeset[i];
        if (!same(e.u, e.v)) {
            unite(e.u ,e.v);
            res += e.w;
        }
    }
    return res;
}

int main(void)
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &p[i].x, &p[i].y);
        p[i].id = i;
    }
    sort(p, p + n, cmp_x);
    for (int i = 0; i < n - 1; i++) {
        edgeset[i].u = p[i].id;
        edgeset[i].v = p[i + 1].id;
        edgeset[i].w = abs(p[i + 1].x - p[i].x);
    }
    sort(p, p + n, cmp_y);
    for (int i = 0; i < n - 1; i++) {
        edgeset[i + n - 1].u = p[i].id;
        edgeset[i + n - 1].v = p[i + 1].id;
        edgeset[i + n - 1].w = abs(p[i + 1].y - p[i].y);
    }
    sort(edgeset, edgeset + 2 * (n - 1), cmp_edge);
    printf("%d\n", mst());
    return 0;
}


Measured memory_bytes: 4480
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

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

        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            if ((m | n) == 0)
                break;
            final int[] p = new int[m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    p[j] += sc.nextInt();
                }
            }
            Integer[] ord = new Integer[m];
            for (int i = 0; i < m; i++) {
                ord[i] = i;
            }
            Arrays.sort(ord, new Comparator<Integer>() {
                public int compare(Integer a, Integer b) {
                    if (p[a] != p[b])
                        return p[b] - p[a];
                    return a - b;
                }
            });
            boolean f = true;
            for (int i = 0; i < m; i++) {
                if (f)
                    f = false;
                else
                    System.out.print(" ");
                System.out.print(ord[i] + 1);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch HopscotchAddict | diff HopscotchAddict.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address HopscotchAddict.cpp && ./a.out

/*
 
 6/29/2019
 
 5:45-
 
 */

const int MAX_N=1e5+1;
VI G[MAX_N];
int N,M,S,T;

const LL Inf=1e10;
LL D[MAX_N][3];
void solve() {
  REP(i,N)REP(j,3)D[i][j]=Inf;
  queue<tuple<long long,int,int>> Q; Q.emplace(0,S,0); D[S][0]=0;
  while(Q.size()>0) {
    auto tu=Q.front(); Q.pop();
    int u,step; long long d;
    tie(d,u,step)=tu;
    for(auto v : G[u]) {
      int step2=(step+1)%3;
      if(d+1<D[v][step2]) {
        D[v][step2]=d+1;
//        dump(v,step2,d+1);
        Q.emplace(d+1,v,step2);
      }
    }
  }
  LL res;
//  dump(D[T][0]);
  if(D[T][0]>=Inf) res=-1;
  else if(D[T][0]%3==0) res=D[T][0]/3;
  else res=Inf;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,M) {
    int u,v; cin>>u>>v;
    --u,--v;
    G[u].push_back(v);
  }
  cin>>S>>T;
  --S,--T;
  solve();
  
  return 0;
}


Measured memory_bytes: 8064