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

#define rep(i, n) for (Int i = 0; i < (Int)(n); i++)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

Int dp[10001][101][2];

int main() {
    string s;
    Int d;
    cin >> s >> d;
    Int n = s.size();
    dp[0][0][1] = 1;
    rep(i, n) {
        Int x = s[i] - '0';
        rep(j, d) {
            rep(k, 10) {
                dp[i + 1][(j + k) % d][0] += dp[i][j][0];
                dp[i + 1][(j + k) % d][0] %= mod;
            }
            rep(k, x) {
                dp[i + 1][(j + k) % d][0] += dp[i][j][1];
                dp[i + 1][(j + k) % d][0] %= mod;
            }
            dp[i + 1][(j + x) % d][1] += dp[i][j][1];
            dp[i + 1][(j + x) % d][1] %= mod;
        }
    }
    // rep(j, d) {
    //     rep(i, n + 1) {
    //         cout << dp[i][j][0] << " ";
    //     }
    //     cout << endl;
    // }
    // rep(j, d) {
    //     rep(i, n + 1) {
    //         cout << dp[i][j][1] << " ";
    //     }
    //     cout << endl;
    // }
    dump((dp[n][0][0] + dp[n][0][1] - 1 + mod) % mod);
    return 0;
}

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

int cnt_num(vector<int>& a, vector<int>& b, int n){
    pair<int, int> p;
    vector<pair<int, int> > vecp;
    int j = 0;
    int cnt = 1;
    for(int i = 0; i < a.size(); i++){
        if(i != a.size() - 1 &&  a[i] == a[i+1]){
            cnt++;
        }else{
            p.second = a[i];
            p.first = cnt;
            vecp.push_back(p);
            cnt = 1;
        }
    }
    vecp.push_back(make_pair(0, 0));
    sort(vecp.rbegin(), vecp.rend());

    vector<pair<int, int> > vecp2;
    cnt = 1;
    for(int i = 0; i < b.size(); i++){
        if(i != b.size() - 1 && b[i] == b[i+1]){
            cnt++;
        }else{
            p.second = b[i];
            p.first = cnt;
            vecp2.push_back(p);
            cnt = 1;
        }
    }
    vecp2.push_back(make_pair(0,0));
    sort(vecp2.rbegin(), vecp2.rend());

    if(vecp2[0].second == vecp[0].second){
        return min(n - (vecp[0].first + vecp2[1].first), n - (vecp[1].first + vecp2[0].first));
    }else{
        return (n - (vecp[0].first + vecp2[0].first));
    }
}

int main(){
    int n; cin >> n;
    vector<int> odd;
    vector<int> even;
    for(int i = 0; i < n; i++){
        int m; cin >> m;
        if(i%2 == 0)odd.push_back(m);
        else even.push_back(m);
    }
    sort(odd.begin(), odd.end());
    sort(even.begin(), even.end());

    cout << cnt_num(odd,even,n) << endl;
}

Measured memory_bytes: 1784
#include<iostream>
using namespace std;
int N,M,x,y,ans;
int main(){
    cin>>N>>M;
    int ball[N];
    bool red[N];
    for(auto &x:ball)x=1;
    for(auto &x:red)x=false;
    red[0]=true;
    for(int i=0;i<M;i++){
        cin>>x>>y;
        x--,y--;
        if(red[x]){
            if(ball[x]==1){
                red[x]=false;
                red[y]=true;
            }
            else red[y]=true;
        }
        ball[x]--;
        ball[y]++;
    }
    for(int i=0;i<N;i++)ans+=red[i];
    cout<<ans<<endl;
    return 0;
}

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

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {
            String s = Console.ReadLine();
           // String s2 = "coffee";
            if (s[2] == s[3] && s[4] == s[5]) RESULT("Yes"); else RESULT("No");


        }
      
      
        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] S2Iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
        static long[] S2Larray(String[] src)
        {
            int len = src.Length;
            long[] res = new long[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt64(src[i]);
            }
            return res;
        }
    }
}


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

int main(){
  int A[3],nana = 0,go = 0; cin >> A[0] >> A[1] >> A[2] ;

  for (int j = 0; j < 3 ; j++){
    if (A[j] == 7){
      nana += 1;
    }
    if (A[j] == 5){
      go += 1;
    }
  }
  if (nana == 1 && go == 2){
    cout << "YES" <<endl;
  }else{
    cout << "NO" <<endl;
  }
}


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

typedef struct{
	double x;
	double y;
}Point;

void koch(int n,Point a,Point b){
	if(n!=0){
		Point s,t,u;
		double th=M_PI*60.0/180.0;
		
		s.x=(2.0*a.x+1.0*b.x)/3.0;
		s.y=(2.0*a.y+1.0*b.y)/3.0;
		t.x=(1.0*a.x+2.0*b.x)/3.0;
		t.y=(1.0*a.y+2.0*b.y)/3.0;
		u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
		u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
		
		koch(n-1,a,s);
		printf("%.8f %.8f\n",s.x,s.y);
		koch(n-1,s,u);
		printf("%.8f %.8f\n",u.x,u.y);
		koch(n-1,u,t);
		printf("%.8f %.8f\n",t.x,t.y);
		koch(n-1,t,b);
	}
}

int main(void){
	Point a,b;
	int n;
	
	scanf("%d",&n);
	
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	
	return 0;
}



Measured memory_bytes: 2732
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  if (a < k) {
    ans += a;
  }
  else {
    cout << k << endl;
    return 0;
  }
  if (b+a >= k) {
    cout << ans << endl;
    return 0;
  }
  ll nokori = k - (a+b);
  ans -= nokori;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)n;++i)

const int INF = 100000000;

unsigned int stat[110][110];
unsigned int stac[110][110];
int N, M, K;

int main() {
	while(cin >> N >> M && N && M) {
		for(int i = 0; i <= 100; i++) {
			for(int j = 0; j <= 100; j++) {
				stat[i][j] = INF;
				stac[i][j] = INF;
			}
		}
		rep(i, N) {
			int a, b, time, cost;
			cin >> a >> b >> cost >> time;
			stat[a][b] = time;
			stat[b][a] = time;
			stac[a][b] = stac[b][a] = cost;
		}
		for (int k = 1; k <= M; k++)
			for (int i = 1; i <= M; i++)
				for (int j = 1; j <= M; j++) {
					stat[i][j] = min(stat[i][j], stat[i][k] + stat[k][j]);
					stac[i][j] = min(stac[i][j], stac[i][k] + stac[k][j]);
				}

		cin >> K;
		rep(i, K) {
			int p, q, r;
			cin >> p >> q >> r;
			if(r == 0) {
				cout << stac[p][q] << endl;
			} else {
				cout << stat[p][q] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 960
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define uni(x) sort(all(x)),x.resize(unique(all(x))-x.begin());
#define GETPOS(c,x) (lower_bound(all(c),x)-c.begin())
#define lown1(x,val) low(in(x),val)-x
#define lowm1(x,val) low(im(x),val)-x
#define low1(x,nums,val) low(x+1,x+nums+1,val)-x
#define mst(x,val) memset((x),val,sizeof((x)))
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define far(i,V) for(auto &i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b))/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) ((x)&(-x))
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (((x)<0)?(x)%mo_num+mo_num:(x)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define Umap unordered_map<int,int>
#define P pair<int,int>
#define SET set<int>
#define mk make_tuple
#define eps 1e-6
//Remember cancel"#define endl '\n'" in interactive questions or use "<<flush"
#define endl '\n'
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
//#define yn(key) out(key?"Yes":"No")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define ik(i,k) i+1,i+1+k
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define db double
#define ll long long
#define got(container,num) get<num-1>(container)
#define int long long
#define print(a,n) fun(i)cout<<a[i]<<(i!=n?' ':endl);
#define outcase(x) cout<<"Case #"<<(++case_of_T)<<": "<<(x)<<endl;
#define ptcase(x) printf("Case #%d: %d\n",++case_of_T,x);
#define plcase(x) printf("Case #%lld: %lld\n",++case_of_T,x);
using namespace std;
//Remember to cancel the line below and declare INT=INT_MAX/2; when you want to change long to int
const int INF=LLONG_MAX/4,SINF=0x3f3f3f3f,Lim=1<<20,MINF=LLONG_MAX;
//const int INF=INT_MAX/4,SINF=0x3f;
// use C:printf("%.16f", x);  ->  printf("%.10f", x); can accelerate the program
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//down up left right
const int maxn=1e6+1e5;
int mo_num=1e9+7;
//const int mo_num=998244353;
int n,m,t,a[maxn],b[maxn],ans,case_of_T;
bool can(int i)
{
    return i<=n-2 && a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2];
}
void solve()
{
    cin>>n;
    fun(i)cin>>a[i]>>b[i];
    fun(i)
    {
        if(can(i)){out("Yes")return;}
    }
    out("No")
    return ;
}
main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)solve();
    return 0;
}


Measured memory_bytes: 3656
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def main():
    N, M = map(int, input().split())
    s = input().strip()
    t = input().strip()
    if M > N:
        tmp = s
        s = t
        t = tmp
        tmp = N
        N = M
        M = tmp
    # N >= Mと仮定して良い
    gcd_ = gcd(N, M)
    len_ = N * (M//gcd_)
    tmp1 = len_ // N
    tmp2 = len_ // M
    # print(tmp1, tmp2)
    ok = True
    for i in range(0, len_, tmp1 * (tmp2//gcd(tmp1, tmp2))):
        # print(i, s[i//tmp1], t[i//tmp2])
        if s[i//tmp1] != t[i//tmp2]:
            ok = False
            break
    if ok:
        print(len_)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;

#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(), x.end()

int const N = 100 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n, m;
  cin >> n >> m;
  int a[26] = {};
  string line;
  for(int i = 0; i < n; ++i) {
    cin >> line;
    for_each(line.begin(), line.end(), [&] (char c) {
      a[c-'a']++;
    });
  }

  int one = 0;
  int two = 0;
  int four = 0;

  for(int i = 1; i+i <= n+1; ++i) {
    for(int j = 1; j+j <= m+1; ++j) {
      int cnt = 0;
      cnt += (i != n-i+1);
      cnt += (j != m-j+1);
      if(cnt == 0)
        one++;
      else if(cnt == 1)
        two++;
      else
        four++;
    }
  }

  for(int i = 0; four && i < 26; ++i) {
    int take = min(four, a[i]>>2);
    four -= take;
    a[i] -= 4*take;
  }

  for(int i = 0; two && i < 26; ++i) {
    int take = min(two, a[i]>>1);
    two -= take;
    a[i] -= 2*take;
  }

  for(int i = 0; one && i < 26; ++i) {
    int take = min(one, a[i]);
    one -= take;
    a[i] -= take;
  }

  string w[] = {"No", "Yes"};
  cout << w[accumulate(a,a+26,0) == 0];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x=0,mon=0;
  string h;
  cin>>n>>h;
  for(int i=0;i<h.length();++i){
    if(h[i]=='I') x++;
    else x--;
    
    if(x>mon) mon=x;
  }
  cout<<mon<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,x,y,r;
  cin>>w>>h>>x>>y>>r;
  if(x-r<0 || x+r>w){
    cout<<"No"<<'\n';
  }else if(y-r<0 || y+r>h){
    cout<<"No"<<'\n';
  }else{
    cout<<"Yes"<<'\n';
  }
  return(0);
}



Measured memory_bytes: 3104
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
	int A1,A2,A3;

	scanf("%d %d %d",&A1,&A2,&A3);

	if(A1+A2+A3>21){
		printf("bust");
	}else{
		printf("win");
	}




	return 0;
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

void Main()
{
	int A,B,C,K;
	cin>>A>>B>>C>>K;
	bool flag = false;
	while(K--){
		if(B<=A)B*=2;
		else if(C<=B)C*=2;
		else{
			flag=true;break;
		}
		dout<<A<<_t<<B<<_t<<C<<_n;
	}
	if(A<B && B<C)flag=true;
	cout<<(flag?"Yes":"No");
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
    int a,b,d,r;
    double f;
    scanf("%d",&a);
    scanf("%d",&b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %f",d,r,f);
}


Measured memory_bytes: 2104
import collections as c
while 1:
 N=int(input())
 if N==0:break
 C=raw_input().split()
 for i in range(1,N+1):
  l=c.Counter(C[:i]).most_common()+[('',0)]
  if l[0][1]>l[1][1]+N-i:print l[0][0],i;break
 else:print("TIE")

Measured memory_bytes: 6708
#include <bits/stdc++.h>
#define m 1e9+7
#define lld long long int 
#define ull unsigned long long int 
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forrev(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forrand(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define endl "\n"

using namespace std;

typedef pair<lld, lld> pii;
typedef vector<lld> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef unordered_map<lld ,lld > mpii;
typedef unordered_map<char ,lld > mpci;
typedef unordered_map<lld ,char > mpic;
typedef unordered_map<string ,lld > mpsi;

//useful utility functions
bool cmp(lld a ,lld b){ return ( a>b? true : false);}
bool pair_cmp(pii a,pii b){return (a.first>b.first? true : false);}
lld mpow(lld a,lld b,lld p=m){a=a%p;lld res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
 lld count_factors(lld c){lld cnt=0; for(lld i=1; i*i<=c; i++){ if(c%i==0){if(c/i==i)cnt++;else cnt+=2; } } return cnt;}
//gcd function __gcd()
/*
It is not a disgrace if you don't reach the stars,
But a disgrace if you don't have stars to reach.
*/

lld t;

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

        lld n,k,i,j,c=0;
        cin>>n;
         double a[n],b[n],cnt;
        for0(i,n){
            cin>>a[i];
        }
        sort(a,a+n);
        cnt=a[0];
        //logic here
        for(i=1;i<n;i++){
          cnt=(cnt+a[i])/2;
        }
        // for(i=1;i<n ; i++){
        //     cnt=a[i-1];
        //     for(j=i; j<n; j++){
        //         cnt=(cnt+a[j])/2;
        //          a[j]=cnt;
        //     }
        // }
        cout<<setprecision(9)<<cnt;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
const int N = 1e5 + 5;
int n, m, k, sz[N - 1], rep[N - 1];
vector<vector<pair<int, int>>>v;
ll findu(ll u)
{
   return (rep[u] == u) ? u : rep[u] = findu(rep[u]);
}
void join(ll a, ll b)
{
   a = findu(a);
   b = findu(b);
   if(a == b)
       return;
   if(sz[a] < sz[b])
       swap(a, b);
   sz[a] += sz[b];
   rep[b] = rep[a];
}
int main()
{
    Hello
    cin >> n >> m >> k;
    fill(sz, sz + n + 1, 1);
    iota(rep, rep + n + 1, 0);
    v.resize(n + 5);
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        join(a, b);
        v[a].push_back({b, 1});
        v[b].push_back({a, 1});
    }
    for(int i = 0; i < k; i++)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back({b, 0});
        v[b].push_back({a, 0});
    }
    ///ans = size - directChildren - 1 - blockListInSameComponent
    for(int i = 1; i <= n; i++)
    {
        int parenta = findu(i);
        int ans = sz[parenta] - 1;
        int directChildren = 0, blockShip = 0;
        for(int j = 0; j < v[i].size(); j++)
        {
            if(v[i][j].second == 1)
                directChildren++;
            else if(v[i][j].second == 0)
            {
                int parentb = findu(v[i][j].first);
                if(parenta == parentb)
                    blockShip++;
            }
        }
        ans -= directChildren;
        ans -= blockShip;
        cout << ans << " ";
    }
    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  int count=0;
  for(int i=1;i<=n;++i)
  { cin>>a[i];
    if(a[i]&1 && i&1)
      count++;
  }
  cout<<count;
  return 0;
  
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
  int bingo[3][3];
  int n, a;
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> bingo[i][j];
    }
  }
  
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    cin >> a;
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (bingo[j][k] == a) {
          bingo[j][k] = 0;
        }
      }
    }
  }
  
  for (int i = 0; i < 3; i++) {
    if (bingo[i][0] == bingo[i][1] && bingo[i][1] == bingo[i][2]) {
      cout << "Yes" << endl;
      return (0);
    }
    if (bingo[0][i] == bingo[1][i] && bingo[1][i] == bingo[2][i]) {
      cout << "Yes" << endl;
      return (0);
    }
  }
  
  if (bingo[0][0] == bingo[1][1] && bingo[1][1] == bingo[2][2]) {
    cout << "Yes" << endl;
    return (0);
  }
  if (bingo[0][2] == bingo[1][1] && bingo[1][1] == bingo[2][0]) {
    cout << "Yes" << endl;
    return (0);
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="Sunny"s) cout<<"Cloudy"<<endl;
  if(s=="Cloudy"s) cout<<"Rainy"<<endl;
  if(s=="Rainy"s) cout<<"Sunny"<<endl;
  return 0;
}

Measured memory_bytes: 256
import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._

  loop()
  @tailrec def loop(): Unit = {
    val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
    if (n == 0 && m == 0) return 
    val futon = readLine.trim.split(' ').map(_.toInt)
    val demand = readLine.trim.split(' ').map(_.toInt).sorted.toList
    val memo = Array.fill(1 << n){-1}
    println(solve(0, futon, demand, memo))
    loop()
  }
  def solve(futonSet: Int, futon: Array[Int], demand: List[Int], memo: Array[Int]): Int = {
    if (memo(futonSet) >= 0) return memo(futonSet)
    if (!futon.indices.exists(i ⇒ (futonSet & (1 << i)) == 0)) {
      memo(futonSet) = demand.sum - futon.sum * demand.length
      return memo(futonSet)
    }
    val low = futon.indices.filter(i ⇒ (futonSet & (1 << i)) != 0).map(futon).sum
    var min = Int.MaxValue
    for (next ← futon.indices if (futonSet & (1 << next)) == 0) {
      demand.span(_ <= low + futon(next)) match {
        case (l, rest) ⇒
          val confirmed = l.map{d ⇒ math.min(d - low, low + futon(next) - d)}.sum
          min = math.min(min, confirmed + solve(futonSet | (1 << next), futon, rest, memo))
      }
    }
    memo(futonSet) = min
    min
  }
}


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

ll F(ll A,ll B){
    ll cntA=0,cntB=0;
    while(A!=0){
        A/=10;
        cntA++;
    }
    while(B!=0){
        B/=10;
        cntB++;
    }
    return max(cntA,cntB);
}

int main(){
    ll N,A,B;
    cin>>N;
    ll minF=12;
    for(int i=1;i<=sqrt(N);i++){
        if(N%i==0){
            A=i;
            B=N/i;
        }
        else{
            continue;
        }
        minF=min(minF,F(A,B));
    }
    cout<<minF<<endl;
       
    }
    
    
  
 
 




Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<numeric>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

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

	vi L(2 * N);
	REP(i, 2 * N) {
		cin >> L[i];
	}

	sort(L.begin(), L.end());

	int sum = 0;
	REP(i, N) {
		sum += L[i * 2];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX_NUM = 50;

class student{
public:
  int m, f, r;
  char grade;
}s[MAX_NUM];

int main(){
  int n;
  for(int i=0; i<MAX_NUM; i++){
    cin >> s[i].m >> s[i].f >> s[i].r;
    if(s[i].m == -1 && s[i].f == -1 && s[i].r == -1){
      n = i;
      break;
    }
    if(s[i].m == -1 || s[i].f == -1) s[i].grade = 'F';
    else if(s[i].m + s[i].f >= 80) s[i].grade = 'A';
    else if(s[i].m + s[i].f >= 65) s[i].grade = 'B';
    else if(s[i].m + s[i].f >= 50) s[i].grade = 'C';
    else if(s[i].m + s[i].f >= 30){
      s[i].grade = 'D';
      if(s[i].r >= 50) s[i].grade = 'C';
    }else s[i].grade = 'F';
  }

  for(int i=0; i<n; i++){
    cout << s[i].grade << endl;
  }
  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
const int maxn = int(2e5) + 7;
int n, m, flag[maxn][2], type[maxn];
bool vis[maxn];
char str[maxn];
std::vector<int> edge[maxn];
void addedge(int u, int v) {
	edge[u].push_back(v);
	flag[u][type[v]]++;
}
std::queue<int> que;
int main() {
	scanf("%d%d %s", &n, &m, str + 1);
	for (int i = 1; i <= n; i++) type[i] = str[i] - 'A';
	for (int i = 1, u, v; i <= m; i++) {
		scanf("%d%d", &u, &v);
		addedge(u, v);
		addedge(v, u);
	}
	int cnt = n;
	for (int i = 1; i <= n; i++) if (flag[i][0] == 0 || flag[i][1] == 0) vis[i] = true, que.push(i);
	while (!que.empty()) {
		assert(que.size() < maxn);
		cnt--;
		int u = que.front();
		que.pop();
		for (int v : edge[u]) {
			if (vis[v]) continue;
			if (--flag[v][type[u]] == 0) que.push(v), vis[v] = true;
		}
	}
	printf("%s\n", cnt ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 13312
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

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;
}

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


int N;
double X[101], Y[101];
double dist(double x, double y) {
	return sqrt(x*x + y * y);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	REP(i, N) {
		cin >> X[i] >> Y[i];
	}
	double theta = 0;
	double ans = 0;
	while (theta <= 2 * pi) {
		double x = 0, y = 0;
		REP(i, N) {
			if (cos(theta)*X[i] + sin(theta)*Y[i] > 0) {
				x += X[i];
				y += Y[i];
			}
		}
		ans = max(ans, dist(x, y));
		theta += pi / 100000.0;
	}
	cout << setprecision(12) << ans << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
*/
bool func(int i, int m, const vector<int> &A,vector<vector<int>> &dp) {
  //Aの最初のi個から何個か選んでmにできるかを返す
  if(i == 0){
    if(m == 0) return true;
    else return false;
  }
  if (m < 0) return false;
  //メモをチェック
  if(dp[i][m] != -1) return dp[i][m];

  //A[i-1]を選ばない場合
  if(func(i-1,m,A,dp)) return dp[i][m] = 1;//trueをメモしつつリターン

  //A[i-1]を選ぶ場合
  if(func(i-1,m-A[i-1],A,dp)) return dp[i][m] = 1;;

  return dp[i][m] = 0;//falseをメモしながらリターン
}

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i,n){
    cin >> A[i];
  }
  int q;
  cin >> q;
  vector<int> m(q);
  rep(i,q){
    cin >> m[i];
  }

  const int MAX = 50000;
  vector<vector<int>> dp(n+1, vector<int>(MAX+1, -1)); // -1 は未確定を表す

  rep(i,q){
    if(func(n,m[i],A,dp)) cout << "yes" << endl;
    else cout << "no" << endl;
  }

}


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


using namespace std;
const int N=1e5+55;
int a[N];
int dp[N];

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	dp[0]=0;
	for(int i=1;i<n;i++)
	{
		dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		if(i>1)
			dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1]<<endl;
	
	
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
ans = ''
for i in range(1, 12):
    if n <= 26 ** i:
        n -= 1
        for _ in range(i):
            ans += alphabet[n % 26]
            n //= 26
        break
    else:
        n -= 26 ** i
print(ans[::-1])

Measured memory_bytes: 9080
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

void solve()
{
	list<char> s;
	{
		string t; getline(cin,t);
		rep(i,t.size())
			s.push_back(t[i]);
	}
	
	iter(s) it=s.begin();
	int n; cin>>n; cin.get();
	while(n--){
		string cmd; getline(cin,cmd);
		if(cmd=="forward char")
			if(it!=s.end())
				++it;
		if(cmd=="forward word"){
			while(it!=s.end() && *it==' ')
				++it;
			while(it!=s.end() && *it!=' ')
				++it;
		}
		if(cmd=="backward char")
			if(it!=s.begin())
				--it;
		if(cmd=="backward word"){
			while(it!=s.begin() && *--it==' ')
				;
			while(it!=s.begin()){
				--it;
				if(*it==' '){
					++it;
					break;
				}
			}
		}
		if(cmd.substr(0,6)=="insert"){
			int i=cmd.find('"')+1,j=cmd.find('"',i);
			s.insert(it,cmd.begin()+i,cmd.begin()+j);
		}
		if(cmd=="delete char")
			if(it!=s.end())
				it=s.erase(it);
		if(cmd=="delete word"){
			iter(s) it2=it;
			while(it2!=s.end() && *it2==' ')
				++it2;
			if(it2==s.end())
				continue;
			while(it2!=s.end() && *it2!=' ')
				++it2;
			it=s.erase(it,it2);
		}
	}
	for(iter(s) i=s.begin();;++i){
		if(i==it)
			cout<<'^';
		if(i==s.end())
			break;
		cout<<*i;
	}
	cout<<endl;
}

int main()
{
	int t; cin>>t; cin.get();
	while(t--)
		solve();
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  int A,B;cin >> A >> B;
  int count[3];
  count[0] = count[1] = count[2] = 0;
  rep(i,N){
    int p;cin >> p;
    if(p<=A) ++count[0];
    else if(p<=B) ++count[1];
    else ++count[2];
  }
  cout << min({count[0],count[1],count[2]}) << endl;
  return 0;
}


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

#define MAX2 (x,y) (((x) < (y)) ? (y) : (x))
#define MAX3 (x,y,z) (MAX2(x, MAX2(y, z)))

int main(void)
{
    uint32_t ame[3];
    // uint32_t a, b, c;
    uint32_t maxVal = 0;
    uint32_t i, maxIdx;
    uint32_t tmp = 0;
    scanf("%u %u %u", &ame[0], &ame[1], &ame[2]);
    for (i = 0; i < 3; i++) {
        if (maxVal < ame[i]) {
            maxVal = ame[i];
            maxIdx = i;
        }
    }
    for (i = 0; i < 3; i++) {
        if (maxIdx == i) continue;
        tmp += ame[i];
    }
    if (tmp == maxVal) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


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

int main(){
    int a[5];
    for(int i=0; i<5; i++){
        cin >> a[i];
    }
    for(int i=0; i<5; i++){
        if(a[i]==0){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long

int main()
{
	int a[3];
  map<int,int>mp;
  for(int i=0;i<3;i++)
  {
    cin>>a[i];
    mp[a[i]]++;
  }
  cout<<mp.size();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef struct Node{
    int data;
    struct Node *parent, *left, *right;
}Node;
Node *root;
void insert(int x){
    Node *t = (Node *)malloc(sizeof(Node));
    t->data = x;
    t->left = t->right = t->parent = NULL;

    Node *child = root;
    Node *parent = NULL;
    while(child != NULL){
        parent = child;
        if(x < child->data){
            child = child->left;
        }
        else{
            child = child->right;
        }
    }
    if(root == NULL){
        root = t;
    }
    else{
        t->parent = parent;
        if(x < parent->data){
            parent->left = t;
        }
        else{
            parent->right = t;
        }
    }
}
void Preorder(Node *t){
    if(t == NULL) return ;
    printf(" %d", t->data);
    Preorder(t->left);
    Preorder(t->right);
}
void Inorder(Node *t){
    if(t == NULL) return ;
    Inorder(t->left);
    printf(" %d", t->data);
    Inorder(t->right);
}
int main(){
    root = NULL;
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        char a[10]; int b;
        scanf("%s", a);
        if(a[0] == 'i'){
            scanf("%d", &b);
            insert(b);
        }
        else{
            Inorder(root);
            printf("\n");
            Preorder(root);
            printf("\n");
        }
    }
    return 0;
}


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

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 998244353;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}


int main()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (fat[i-1] * i) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }

  ios::sync_with_stdio(0);
  ll n,m,k;

  cin >> n >> m >> k;
  
  ll ans = 0;
  
  for(int i = 0; i <= k; i++)
  {
    ll a = C(n - 1, i);
    ll b = exp(m - 1, n - i - 1);
    // debug(a);
    // debug(b);
    // debug(m);
    a = (a * b) % mod;
    ans += (a * m) % mod;
    ans %= mod;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 6788
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF=1e9+7;
const int maxn=100001;
const double pi = acos(-1.0);
const int mod=1e9+7;
using lb=long double;
int n;
int a[105][105];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h,w,n;
    cin>>h>>w>>n;
    int temp;
    int x=1,y=1,dir=1;
    for(int i=1;i<=n;i++)
    {
        cin>>temp;
        while(temp--)
        {
            a[x][y]=i;
            y+=dir;
            if(y==w+1)
            {
                x++;
                y=w;
                dir=-1;
            }
            else if(y==0)
            {
                x++;
                y=1;
                dir=1;
            }
        }
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<'\n';
    }
    return 0;
}


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

using namespace std;

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

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

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

int N, M;

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

  cin >> N >> M;
  vector< ll > x(N);
  vector< ll > y(N);
  vector< ll > z(N);
  REP(i, N) {
    cin >> x[i] >> y[i] >> z[i];
  }

  ll ans = 0ll;
  REP(bit, (1 << 3)) {
    vector< ll > d(N);
    REP(i, N) {
      d[i] += (bit & (1 << 0)) ? x[i] : -x[i];
      d[i] += (bit & (1 << 1)) ? y[i] : -y[i];
      d[i] += (bit & (1 << 2)) ? z[i] : -z[i];
    }
    sort(ALL(d));
    reverse(ALL(d));

    ll tmp = 0ll;
    REP(i, M) {
      tmp += d[i];
    }
    ans = max(ans, tmp);
  }

  cout << ans << endl;
  
  

  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    print(N+N**2+N**3)


# oj t -c "pypy3 main.py"
# acc s main.py -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 61872
#include "bits/stdc++.h"
using namespace std;
static const int MAX=10000;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n;
//????????????????????°???????????£??\???????????¨???
vector<pair<int,int> >adj[MAX];

void dijkstra(){
	priority_queue<pair<int,int> > PQ;
	int color[MAX];
	int d[MAX];
	for (int i = 0; i < n; ++i) {
		d[i]=INFTY;
		color[i]=WHITE;
	}
	d[0]=0;
	PQ.push(make_pair(0,0));
	color[0]=GRAY;
	while(!PQ.empty()){
		pair<int,int> f=PQ.top();PQ.pop();
		int u=f.second;
		color[u]=BLACK;
		//????°???????????????????????????????????????§???????????°??????
		if(d[u]<f.first *(-1))continue;

		for (int j = 0; j < adj[u].size(); ++j) {
			int v=adj[u][j].first;
			if(color[v]==BLACK)continue;
			if(d[v]>d[u]+adj[u][j].second){
				d[v]=d[u]+adj[u][j].second;
				//priority_queue????????????????????§??§??????????????????????????????-1????????????
				PQ.push(make_pair(d[v]*(-1),v));
				color[v]=GRAY;
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		cout<<i<< " "<<(d[i]==INFTY?-1:d[i])<<endl;
   }
}


int main(){
	cin>>n;
	int k,c,u,v;
	for (int i = 0; i < n; ++i) {
		cin>>u>>k;
		for (int j = 0; j < k; ++j) {
			cin>>v>>c;
			adj[u].push_back(make_pair(v,c));
		}
	}
	dijkstra();
	return 0;
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
ll sizes[100001];
ll arr[100001];
ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
bool prime[10000];
void era(){
    memset(prime,true,sizeof prime);
    for(ll p=2;p*p<=10000;p++){
        if(prime[p]){
            for(ll q=p*p;q<=10000;q+=p){
                prime[q]=false;
            }
        }
    }

    return;
}
ll fac[200001],finv[200001];
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=(ans*a)%MAX;
        b/=2;
        a=(a*a)%MAX;
    }
    return(ans%MAX);
}
ll inverse(ll a){
    return((power(a,MAX-2))%MAX);
}
ll ncr(ll n, ll r){
    ll p1=finv[n-r];
    ll p2=finv[r];

    return((((fac[n]*p1)%MAX)*p2)%MAX);


}
int main(){
    IO

    ll H,W,D;
    cin>>H>>W>>D;
    ll x[H*W+1],y[H*W+1];
    ll z;
    for(ll i=1;i<=H;i++){
        for(ll j=1;j<=W;j++){
            cin>>z;
            y[z]=i;
            x[z]=j;
        }
    }
    ll Q;
    cin>>Q;
    ll cum[H*W+1];
    ll N=H*W;
    memset(cum,0,sizeof cum);
    for(ll i=1;i<=N;i++){
        if(cum[i]==0){
            for(ll j=i+D;j<=N;j+=D) cum[j]=cum[j-D]+abs(x[j]-x[j-D])+abs(y[j]-y[j-D]);
        }
    }

    while(Q--){
        ll L,R;
        cin>>L>>R;
        cout<<cum[R]-cum[L]<<"\n";
    }
    return(0);
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N, Y;
const int thou = 1000;
const int five_thou = thou*5;
const int ten_thou = thou*10;

void Aohashi_is_a_liar(){
  cout << "-1 -1 -1\n";
}
void Aohashi_is_a_truth_teller(const int x, const int y, const int z){
  cout << x << " " << y << " " << z << "\n";
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> Y;
  int y = 0, z = 0, flag = 0;
  for(int i=0; i<=ten_thou; ++i){
    for(int j=0; j<=ten_thou; ++j){
       if((i*five_thou + j*(ten_thou - thou)) > ten_thou*N - Y){
         break;
       }
       if((i*five_thou + j*(ten_thou - thou)) == ten_thou*N - Y){
         y = i;
         z = j;
         flag = -1;
         break;
       }  
    }
    if(flag == -1){
       flag = 0;
       break;
    }
    if(i*five_thou > ten_thou*N - Y){
       flag = 1;
       break;
    }
  }
  if(flag == 0 && N - (y+z) >= 0)
    Aohashi_is_a_truth_teller(N-(y+z), y, z);
  else 
    Aohashi_is_a_liar();
  return 0;  
}



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


using namespace std;

int n, k, x;
vector <int> vec;
int tab[1000];
int dp[1000000];
int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin >> n >> k;
    
    for(int i = 0; i < n; i++){
        cin >> x;
        vec.push_back(x);
    }
    
    for(int stones = 0; stones <= k; stones++){
        for(auto x : vec){
            if(stones >= x && !dp[stones - x])
                dp[stones] = 1;
            
        }
    }
    cout << (dp[k] ? "First" : "Second");
}



Measured memory_bytes: 640
N,M=list(map(int,input().split()))
ks=[]
for m in range(M):
    k,*s=list(map(int,input().split()))
    ks.append(s)
pm=list(map(int,input().split()))
ct=0
for i in range(2**N):
    bf="{:010b}".format(i)[::-1]
    allok=True
    for m in range(M):
        if not allok:break
        sm=0
        for s in ks[m]:
            sm+=int(bf[s-1])
        if sm%2!=pm[m]:
            allok=False
            break
    if allok:
        ct+=1
print(ct)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
 
int main(void) {
 
    int result = 0;
    char s[256];
    int a=0;
    char t[256];
    int b=0;
    char u[256];
 
    scanf("%s", s);
    scanf("%s", t);
    //個数
    scanf("%d", &a);
    scanf("%d", &b);
    //
    scanf("%s", u);
    //比較
    if (strcmp(s, u) == 0) {
        a -= 1;
    }
    else {
        b -= 1;
    }
    printf("%d %d\n", a, b);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		long[] A = new long[N];
		for(int i = 0; i < N; i++)
			A[i] = GetLong();

		long ans = 0;
		int right = 1;
		long s = A[0];
		for(int left = 0; left < N; left++)
		{
			for(; right < N; right++)
			{
				if((s & A[right]) != 0)
					break;

				s |= A[right];
			}
			ans += (long)(right - left);
			s ^= A[left];
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

int main() {
	int K,X;
	cin>>K>>X;
	vector<int>A();
	int count=0;
	for(int i=-1000000;i<1000001;i++){
		if(X-K<i&&i<X+K){
			cout<<i<<" ";
		}
	}
cout<<endl;
	return 0;
}

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

using namespace std;

vector <int> a, b;
int N, M;
bool used[100];

void rec(int v, int m){
        used[v]=true;
        for(int i=0;i<M;i++){
                if(i==m){
                        continue;
                }
                if(!used[a[i]]&&b[i]==v){
                        rec(a[i], m);
                }
                else if(!used[b[i]]&&a[i]==v){
                        rec(b[i], m);
                }
        }
}

int main(){
        cin>>N>>M;
        for(int i=0;i<M;i++){
                int aa, bb;
                cin>>aa>>bb;
                a.push_back(aa);
                b.push_back(bb);
        }
        int res=0;
        for(int i=0;i<M;i++){
                for(int j=0;j<=N+1;j++){
                        used[j]=false;
                }
                rec(1, i);
                bool flag=true;
                for(int j=1;j<=N;j++){
                        if(!used[j]){
                                flag=false;
                                break;
                        }
                }
                if(!flag){
                        res++;
                }
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 256