akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;


int main(){
	int n,q;
	while(cin>>n>>q,n&&q){
		vint v(1000,0);
		int MAX=0;
		rep(i,n){
			int c;
			cin>>c;
			rep(j,c){
				int t;
				cin>>t;
				v[t]++;
				MAX=max(MAX,v[t]);
			}
		}
		if(MAX<q){
			cout<<0<<endl;
			continue;
		}
		rep(i,1000){
			if(v[i]==MAX){
				cout<<i<<endl;
				break;
			}
		}
	}
	return 0;
}
		

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pll > 
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
//#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
set <pll> adj[200002];
set <lli> adj2[200002];
lli mod=1000000007;
int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);
      lli n;
        cin>>n;
        n++;
        lli a[n],b[n];
        lli temp=0;
        for(lli i=0;i<n;i++){cin>>a[i];temp+=a[i];}
        for(lli j=1;j<n;j++)cin>>b[j];
        b[0]=0;
    	lli ans=0;
    	for(lli i=0;i<n;i++){
    		lli dcurr=min(a[i],b[i]);
    		a[i]=a[i]-dcurr;
    		b[i]=b[i]-dcurr;
    		if(i!=n-1){
    		lli dfor=min(a[i],b[i+1]);
    		a[i]=a[i]-dfor;
    		b[i+1]=b[i+1]-dfor;
    		}
    	}
    	for(lli i=0;i<n;i++){ans+=a[i];}//cout<<endl;
    	cout<<temp-ans;
        return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'
 
int main()
{
    fastio;
    lli n,k;
    cin>>n>>k;
 
    vinput(a,n);
 
    vlli fv(n,-1);
 
    int cur = 0,T = 0;
 
    while(1){
        if(k == 0){
            cout<<cur + 1<<endl;
            return 0;
        }      
 
        // cout<<"left = "<<k<<" current = "<<cur+1<<endl;
 
        if(fv[cur] == -1){
            k--;
            fv[cur] = T;
            T++;
            cur = a[cur] - 1;
        }
        else if(k > 4e5){
            lli len = (T - fv[cur]);
 
            // cout<<"cycle len = "<<len<<endl;
 
            k = (k%len) + len;
            if(k > 3e5)k -= len;
        }
        else{
            k--;
            cur = a[cur] - 1;
        }
    }
}

Measured memory_bytes: 6372
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;
VVi ks;
Vi p;
Vi v;

int dfs(int d) {
    if (d == n) {
        bool f = true;
        REP(i, m) {
            bool g = false;
            FOR(j, ks[i]) g ^= v[*j];
            f = f && !(p[i] ^ g);
        }
        return f ? 1 : 0;
    }
    v[d] = 0;
    int x = dfs(d+1);
    v[d] = 1;
    int y = dfs(d+1);
    return x + y;
}

int main() {
    cin >> n >> m;
    ks = VVi(m);
    REP(i, m) {
        int k; cin >> k;
        REP(j, k) {
            int x; cin >> x;
            ks[i].push_back(x-1);
        }
    }
    p = Vi(m);
    REP(i, m) cin >> p[i];

    v = Vi(n, 0);

    std::cout << dfs(0) << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		long N=sc.nextInt();
		long M=sc.nextInt();
		
		if(N==M) {
			p(((Nb(N)*Nb(N))%mod*2)%mod);
			
			
			
		}else if(Math.abs(M-N)==1){
			p((Nb(M)*Nb(N))%mod);
			
			
			
		}else
			p(0);
		
		}
		static long Nb(long t) {
			long r=1;
			for(long i=t;i>0;i--) {
				r*=i;
				r%=mod;
				
			}
			return (int)r;
			
		}
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int main() {
  int n;
  int ans=0;
  cin >> n;
  int p[n];
  rep(i,n)cin >> p[i];

  reps(i,n-2){
    if((p[i-1]<p[i]) && (p[i]<p[i+1]))ans++;
    else if((p[i-1]>p[i]) && (p[i]>p[i+1]))ans++;
  }
  cout << ans <<endl;
  return 0;
}

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



using namespace std;

#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define vld vector<ld>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define vvld vector<vector<ld> >
#define vpii vector<pii>
#define vpll vector<pll>
#define ld long double
#define ll long long
#define sz(a) (ll)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<ll >());
#define pii pair<int,int>
#define pll pair<long long,long long>
#define ff first
#define ss second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define endl "\n" 
#define PI acos(-1.0)
#define GCD(a,b) __gcd(a,b)
#define popcount(x) __builtin_popcountll(x)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define r1(x) cin>>x
#define r2(x,y) cin>>x>>y
#define r3(x,y,z) cin>>x>>y>>z
#define r4(a,b,c,d) cin>>a>>b>>c>>d
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define fix(f,n) fixed<<setprecision(n)<<f<<endl
#define check(ds, a) (ds.find(a)!=ds.end()?1:0)
#define mem(arr)  memset(arr,0,sizeof(arr))
const int M=(int)1e9+7;
int main(){
    ll d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d)d1("Yes");
    else d1("No");}

Measured memory_bytes: 3620
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
#include <bits/stdc++.h>
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;

Bint factorial(Bint n) {
    Bint fct = 1;
    for (int i = 2; i <= n; i++) {
        fct *= i;
    }
    return fct;
}

int main() {
    Bint n, m;
    cin >> n >> m;
    n = factorial(n) / (factorial(n - 2) * factorial(2));
    m = factorial(m) / (factorial(m - 2) * factorial(2));
    cout << n + m << endl;
}

Measured memory_bytes: 3688
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int int64_t
#define double long double
#define pii pair<int, int>
#define pdd pair<double, double>
#define F first
#define S second
#define pb push_back
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orset;

const int N = 202000;

int32_t main(){
   ios_base :: sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   int n, k;
   cin >> n >> k;
   n %= k;
   int ans = n;
   for(int i = 0; i < 10000; i ++){
      n = abs(n - k);
      ans = min(ans, n);
   }
   cout << ans;

}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
//Lはn,mの公倍数
//L-L/N+1まで見る
lint gcd(lint a, lint b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

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

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

    lint l = lcm(n, m);
    lint ans=l;
    string s;
    cin >> s;
    string t;
    cin >> t;
    //vector<char> c(l);
    map<lint, char> c;

    REP(i,n){
        lint x = i * (l / n) + 1;
        c[x] = s[i];
    }
    REP(i, m)
    {
        lint x = i * (l / m) + 1;
        if (c.count(x)&& c.at(x) != t[i]){
            ans = -1;
            break;
        }
    }

    cout << ans <<"\n";

    return 0;
}

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    N--;
    vector<int> C(N), S(N), F(N);
    for (int i = 0; i < N; i++) cin >> C[i] >> S[i] >> F[i];
    for (int i = 0; i <= N; i++)
    {
        cerr << "i = " << i + 1 << endl;
        int t = 0;
        for (int j = i; j < N; j++)
        {
            t = max(t, S[j]);
            t = (t + F[j] - 1) / F[j] * F[j];
            cerr << "leave " << t;
            t += C[j];
            cerr << ", arrive " << t << endl;
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<char> = s.trim().chars().collect();

    const D: [char; 5] = ['d', 'r', 'e', 'a', 'm'];
    const E: [char; 5] = ['e', 'r', 'a', 's', 'e'];
    const A: [char; 3] = ['a', 's', 'e'];
    const R: [char; 2] = ['e', 'r'];
    const W: [char; 1] = ['r'];

    let mut i = 0;
    let mut q = 0;
    loop {
        if i >= v.len() {println!("YES"); return;}
        let r = v.len() - i;
        if q == 0 {
            if r >= 5 && &v[i..i+5] == D {i += 5; q = 1;}
            else if r >= 5 && &v[i..i+5] == E {i += 5; q = 2;}
            else {println!("NO"); return;}
        }
        else if q == 1 {
            if r >= 5 && &v[i..i+5] == D {i += 5; q = 1;}
            else if r >= 2 && &v[i..i+2] == R {i += 2; q = 3;}
            else {println!("NO"); return;}
        }
        else if q == 2 {
            if r >= 5 && &v[i..i+5] == D {i += 5; q = 1;}
            else if r >= 5 && &v[i..i+5] == E {i += 5; q = 2;}
            else if r >= 1 && &v[i..i+1] == W {i += 1; q = 3;}
            else {println!("NO"); return;}
        }
        else if q == 3 {
            if r >= 5 && &v[i..i+5] == D {i += 5; q = 1;}
            else if r >= 5 && &v[i..i+5] == E {i += 5; q = 2;}
            else if r >= 3 && &v[i..i+3] == A {i += 3; q = 2;}
            else {println!("NO"); return;}
        }
    }
}



Measured memory_bytes: 4352
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ch() getchar()
#define pc(x) putchar(x)
template<typename T>inline void read(T&x){
	int f;char c;
	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;
	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;
}
template<typename T>inline void write(T x){
	static char q[64];int cnt=0;
	if(!x)pc('0');if(x<0)pc('-'),x=-x;
	while(x)q[cnt++]=x%10+'0',x/=10;
	while(cnt--)pc(q[cnt]);
}
int mx[300000*3*4];
int query(int x,int l,int r,int L,int R){
	if(L<=l&&r<=R)return mx[x];int mid=(l+r)>>1,re=0;
	if(L<=mid)re=max(re,query(x<<1,l,mid,L,R));
	if(R>mid)re=max(re,query(x<<1|1,mid+1,r,L,R));
	return re;
}
void change(int x,int l,int r,int pos,int v){
	mx[x]=max(mx[x],v);
	if(l==r)return;int mid=(l+r)>>1;
	if(pos<=mid)change(x<<1,l,mid,pos,v);
	else change(x<<1|1,mid+1,r,pos,v);
}
int main(){
	int n,k,ans=0;
	read(n),read(k);
	for(int i=1;i<=n;++i){
		int A;read(A);int tmp=0;
		ans=max(ans,tmp=query(1,-300000,600000,A-k,A+k)+1);
		change(1,-300000,600000,A,tmp);
	}
	write(ans),pc('\n');
	return 0;
}


Measured memory_bytes: 6412
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
using namespace std;

int main() {
    int k;
    cin >> k;
    if (k % 2 == 0) cout << pow(k / 2, 2) << endl;
    else cout << (k + 1) * (k - 1) / 4 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N  ;
    cin >> N;
    int ans = 0;
    if(10000 <= N ){
        if(100000 <= N){
            N = 99999;
        }
        for(int i = 10000; i <= N; i++){
            ans++;
        }
        N = 999;
    }
    if(100 <= N){
        if(1000 <= N){
            N = 999;
        }
        for (int i = 100; i<=N; i++){
            ans++;
        }
        N = 9;
    }
    if(1 <= N){
        if(10 <= N){
            N = 9;
        }
        for (int i = 1; i<=N; i++){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> button(N);
  
  int has_2 = 0;
  for (int i=0; i < N; i++) {
    cin >> button.at(i);
    if (button.at(i) == 2) has_2 = 1;
  }
  
  if (has_2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  
  vector<int> is_visited(N, 0);
  is_visited.at(0) = 1;
  int cnt = 0;
  int pos = 0;
  
  while (1) {
    cnt++;
    pos = button.at(pos) - 1;
    if (pos == 1) {
      cout << cnt << endl;
      break;
    }
    
    if (is_visited.at(pos) == 1) {
      cout << -1 << endl;
      break;
    }
    is_visited.at(pos) = 1;
  }
  return 0;
}

Measured memory_bytes: 1024
using AtCoderBeginnerContest142.Questions;
using AtCoderBeginnerContest142.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest142.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var a = inputStream.ReadIntArray();
            var dictionary = new Dictionary<int, int>();

            for (int i = 0; i < n; i++)
            {
                dictionary.Add(i + 1, a[i]);
            }

            yield return string.Join(" ", dictionary.OrderBy(p => p.Value).Select(p => p.Key));
        }
    }
}


namespace AtCoderBeginnerContest142
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest142.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest142.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

int a[6], t[6];
char c[] = {'E', 'N', 'S', 'W'};
int r[4][6] {
	{2, 1, 5, 3, 0, 4},
	{1, 5, 2, 0, 4, 3},
	{3, 0, 2, 5, 4, 1},
	{4, 1, 0, 3, 5, 2}
};

bool ch(int *t) {
	int a[3] = {t[0] + t[5], t[1] + t[3], t[2] + t[4]};
	sort(a, a + 3);
	return a[2] <= a[0] + a[1];
}

bool check(int *t) {
	if(ch(t)) return true;
	for(int i = 1; i <= 4; i ++)
		if(t[i] > 0) {
			t[i] --;
			bool f = ch(t);
			t[i] ++;
			if(f) return true;
		}
	return false;
}

int main() {
	ios :: sync_with_stdio(false);
	while(cin >> a[0]) {
		for(int i = 1; i < 6; i ++)
			cin >> a[i];
		if(!a[5]) break;
		string ans = "";
		int p[6] = {0, 1, 2, 3, 4, 5};
		do {
			/*
			if(p[1] > p[3] || p[2] > p[4])
				continue;
				*/
			for(int i = 0; i < 6; i ++)
				t[i] = a[p[i]];
			if(!check(t)) continue;
			string tmp = "";
			int sum = accumulate(t, t + 6, 0);
			while(sum --) {
				for(int k = 0; k < 4; k ++) {
					int s[6];
					for(int i = 0; i < 6; i ++)
						s[i] = t[r[k][i]];
					s[0] --;
					if(s[0] >= 0 && check(s)) {
						tmp += c[k];
						for(int i = 0; i < 6; i ++)
							t[i] = s[i];
						break;
					}
				}
			}
			if(ans == "" || tmp < ans)
				ans = tmp;
		}while(next_permutation(p, p + 6));

		{
			int p, q; cin >> p >> q;
			if(ans == "")
				cout << "impossible\n";
			else {
				for(int i = p - 1; i < q; i ++)
					cout << ans[i];
				cout << '\n';
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

ll n;

struct Info{
    ll nex;
    ll sum=0;
    ll mul=1;
};

//nの最大値が1e5の時とかは使える
const int MAX = 510000;
const int MOD = 1000000007;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
  return modpow(a, mod - 2, mod);
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int N;
vector<int> E[202020];
ll dp[202020];
int C[202020];
ll pdp[202020];
const ll mo=1000000007;


void dfs(int cur,int pre) {
  C[cur]=0;
  dp[cur]=1;
  for(auto e:E[cur]) if(e!=pre) {
    dfs(e,cur);

    dp[cur]=dp[cur]*dp[e]%mo*COM(C[cur]+C[e],C[e])%mo;
    C[cur]+=C[e];
  }
  C[cur]++;
}

void dfs2(int cur,int pre,ll pv) {
  dp[cur]=dp[cur]*pv%mo*COM(N-1,N-C[cur])%mo;
  for(auto e:E[cur]) if(e!=pre) {
    //処理を戻して、子の値を求める
    pv=dp[cur] * modinv(dp[e]*COM(N-1,C[e])%mo,mod)%mo;
    dfs2(e,cur,pv);



  }

}


void solve() {
  int i,j,k,l,r,x,y; string s;

  COMinit();

  cin>>N;
  rep(i,N-1) {
    cin>>x>>y;
    E[x-1].push_back(y-1);
    E[y-1].push_back(x-1);
  }

  dfs(0,0);
  dfs2(0,0,1);

  rep(i,N) cout<<dp[i]<<endl;
}

int main(){
  solve();
}

Measured memory_bytes: 28276
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/20/2019 2:05:47 AM
*************************************************************************/
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
#define ull unsigned long long
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#define lowbit(x) x&(-x)
#define ls(u) u<<1
#define rs(u) u<<1|1
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const double clf = 1e-8;
const int MMAX = 0x7fffffff;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
ostream& operator <<(ostream &out, pii &p){
	return out<<p.first<<" "<<p.second;
}
istream& operator >>(istream &in, pii &p){
	return in>>p.first>>p.second;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//ifstream cin("C:\\Users\\LENOVO\\Desktop\\in.txt");
	//ofstream cout("C:\\Users\\LENOVO\\Desktop\\out.txt");
	int res=0,t;
	while(cin>>t) res+=t;
	cout<<(res>=22?"bust":"win")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct Node {
  struct Node *parent;
  struct Node *left;
  struct Node *right;
  int key;
} node;
void preOrder(node *);
void inOrder(node *);
void insert(int);
node *find(int);
void delete(int);
node *getSuccessorKey(node *);
node *root;
int n;
int main() {
  int i, j, key;
  char command[7];
 
  scanf("%d", &n);
  for (i = 0; i < n; i++) {    
    scanf("%s", command);
    switch (command[0]) {
    case 'i':
      scanf("%d", &key);
      insert(key);
      break;
    case 'f':
      scanf("%d", &key);
      node *tmp = find(key);
      if (tmp != NULL) {
	printf("yes\n");
      } else {
	printf("no\n");
      }
      break;
    case 'd' :
      scanf("%d", &key);
      delete(key);
      break;
    default:
      inOrder(root);
      printf("\n");
      preOrder(root);
      printf("\n"); 
      break;
    }
  }
  return 0;
}
void inOrder(node *u) {
  if (u == NULL) {
    return ;
  }
  if (u->left != NULL) inOrder(u->left);
  printf(" %d",u->key);
  if (u->right != NULL) inOrder(u->right);
  return ;
}
void preOrder(node *u) {
  if (u == NULL) {
    return ;
  }
  printf(" %d",u->key);
  if (u->left != NULL) preOrder(u->left);
  if (u->right != NULL) preOrder(u->right);
  return ;
}
void insert(int key) {
  node *y = NULL;
  node *x = root;
  node *z;
 
  z = (node*) malloc(sizeof(node));
  z->left = NULL;
  z->right = NULL;
  z->key = key;
 
  while (x != NULL) {
    y = x;
    if (key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if ( y==NULL ) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
  return ;
}
node *find(int key) {
  node *x = root;
  while (x != NULL && x->key != key) {
    if (x->key < key) x = x->right;
    else  x = x->left;
  }
  return x;
}
node *getSeccessorKey(node *u) {
  node *p;
  if (u->right != NULL) {
    u = u->right;
    while (u->left != NULL) u = u->left;
    return u;
  } else {
    p = u->parent;
    while (p != NULL && u == p->right) {
      u = p;
      p = u->parent;
    }
    return p;
  }
}
void delete(int key) {
  node *z, *y, *x;
  z = find(key);

  if (z->left == NULL || z->right == NULL) {
    y = z;
  } else {
    y = getSeccessorKey(z);
  }

  if (y->left != NULL) x = y->left;
  else x = y->right;
 
  if (x != NULL) {
    x->parent = y->parent;
  }
  if (y->parent == NULL) {
    root = x;
  } else if (y == y->parent->left) {
    y->parent->left = x;
  } else {
    y->parent->right = x;
  }

  if (y != z) {
    z->key = y->key;
  }
  return ;
}

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

#define fast_io()                    \
    do {                             \
        ios::sync_with_stdio(false); \
        std::cin.tie(0);             \
    } while (0)
#define DBG(__need_dbg)                                              \
    do {                                                             \
        std::cout << "[" << __FUNCTION__ << ":" << __LINE__ << "] "; \
        std::cout << #__need_dbg << " = " << (__need_dbg) << endl;   \
    } while (0)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> two;

int main() {
    fast_io();

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

    bool flag{};
    if (a == b && a == c && b == c) {
        flag = true;
    }

    if (a != b && a != c && b != c) {
        flag = true;
    }

    if (flag) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sn = new Scanner(System.in);
		int K = sn.nextInt();
		sn.close();
		String[] list = {"1", "1", "1", "2", "1", "2", "1", "5", "2", "2", "1", "5", "1", "2", "1",
				"14", "1", "5", "1", "5", "2", "2", "1", "15", "2", "2", "5", "4", "1", "4", "1", "51"};

		System.out.println(list[K-1].toString());

	}

}

Measured memory_bytes: 21588
import java.awt.Point;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int M = sc.nextInt();
			if (M == 0) break;
			int[] xm = new int[M];
			int[] ym = new int[M];
			for (int i = 0; i < M; ++i) {
				xm[i] = sc.nextInt();
				ym[i] = sc.nextInt();
			}
			int N = sc.nextInt();
			int[] xn = new int[N];
			int[] yn = new int[N];
			HashSet<Point> ps = new HashSet<Point>();
			for (int i = 0; i < N; ++i) {
				xn[i] = sc.nextInt();
				yn[i] = sc.nextInt();
				ps.add(new Point(xn[i], yn[i]));
			}
			for (int i = 0; i < N; ++i) {
				int dx = xn[i] - xm[0];
				int dy = yn[i] - ym[0];
				boolean ok = true;
				for (int j = 0; j < M; ++j) {
					if (!ps.contains(new Point(xm[j] + dx, ym[j] + dy))) {
						ok = false;
						break;
					}
				}
				if (ok) {
					System.out.println(dx + " " + dy);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 13000
#include<stdio.h>
#include<string.h>
#define LEN 100000

typedef struct {
    char name[100];
    int time;
}Proces;
int head=0;tail=0;
Proces que[LEN];
void enqueue(Proces);
Proces dequeue();
int min(int,int);
void enqueue(Proces x){
    que[tail]=x;
    tail=(tail+1)%LEN;
    return;
}
Proces dequeue(){
    Proces x=que[head];
    head=(head+1)%LEN;
    return x;
}
int min(int x,int y){
    return x < y ? x : y;
}
int main(void){
    int i,n,q,c,sum=0;
    Proces a;
    scanf("%d %d",&n,&q);
    for(i=0;i<n;i++){
        scanf("%s %d",que[i].name,&que[i].time);
    }
    head=0;tail=n;
    while(head!=tail){
        a=dequeue();
        c=min(q,a.time);
        a.time-=c;
        sum+=c;
        if(a.time>0){
            enqueue(a);
        }else{
            printf("%s %d\n",a.name,sum);
        }
    }
    return 0;
}



Measured memory_bytes: 11940
#include<bits/stdc++.h>
using namespace std;
int a[100010],n,b[100010];
long long ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n+1;++i) scanf("%d",&a[i]);
	for(int i=1;i<=n;++i) scanf("%d",&b[i]);
	for(int i=1;i<=n;++i) {
		ans+=(long long)min(a[i]+a[i+1],b[i]);
		b[i]-=a[i];
		a[i+1]-=max(b[i],0);
		a[i+1]=max(a[i+1],0);
	}
	printf("%lld",ans);
	return 0;
}

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


int main(){
   int n; cin>>n;
   string s; cin>>s;
   int cnt=0;
   rep(i,n-1){
       if(s[i]!=s[i+1]) cnt++;
   }
   cout<<cnt+1<<endl;
   return 0;
}

   


Measured memory_bytes: 512
from bisect import bisect_left, bisect_right

n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))

ans = 0
for i in range(len(b)):
    ai = bisect_left(a, b[i])
    ci = bisect_right(c, b[i])
    # print(i, ai, ci)
    ans += ai * (n - ci)

print(ans)


Measured memory_bytes: 22720
#include <iostream>
#include <vector>
using namespace std;
using Int = int64_t;
const char* solve() {
    Int N, sum = 0;
    cin >> N;
    vector<Int> a(N), b(N);
    for (auto& i : a) cin >> i;
    for (auto& i : b) cin >> i;
    if (sum < 0) return "No";
    Int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] > b[i]) cnt += a[i] - b[i];
        else if (a[i] < b[i]) cnt -= (b[i] - a[i]) / 2;
    }
    return cnt <= 0 ? "Yes" : "No";
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 384
from collections import Counter

S=input()
T=input()
A=dict(Counter(list(S)))
B=dict(Counter(list(T)))

ans="Yes"
for m in A:
  for n in B:
    if A[m]==B[n]:
      del B[n]
      break
  else:
    ans="No"
    break
print(ans)

Measured memory_bytes: 5680
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  for(int i=0; i<N; i++){
    set<int> pre,suf;
    for(int j=0; j<=i; j++){
      pre.insert(S[j]-'a');
    }
    for(int j=i+1; j<N; j++){
      suf.insert(S[j]-'a');
    }
    int cnt = 0;
    for(int i=0; i<=26; i++){
      if(pre.count(i) && suf.count(i)){
        cnt++;
      }
    }
    chmax(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define oo (int)1e7
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e2 + 5, M = 1e5 + 5;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n & 1){
        puts("No");
        return 0;
    }
    string k;
    for(int i = 0 ; i < n / 2 ; ++i){
        k += s.back();
        s.pop_back();
    }
    reverse(k.begin(), k.end());
    puts(s == k ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;

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

const ll p = 1000000007;

ll N, M;
vector<ll> a;
vector<ll> ways;

int main()
{
  cin >> N >> M;
  a.resize(M);
  for (int i = 0; i < M; i++)
  {
    cin >> a[i];
  }

  ways.resize(N + 1, 0);
  ways[0] = 1;

  for (int i = 0; i < M; i++)
  {
    ways[a[i]] = -1;
  }

  for (int i = 1; i <= N; i++)
  {
    if (ways[i] == -1)
      continue;
    if (ways[i - 1] != -1)
      ways[i] = ways[i - 1];
    if (i >= 2)
    {
      if (ways[i - 2] != -1)
      {
        ways[i] += ways[i - 2];
      }
    }
    ways[i] %= p;
  }

  cout << ways[N] << endl;
}

Measured memory_bytes: 1792
N, M = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
sum_votes = sum(A)
count = 0
for i in range(N):
    if not sum_votes > A[i] * 4 * M:
        count += 1
if count >= M:
    print('Yes')
else:
    print('No')


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    int ac = 0, wa = 0, tle = 0, re = 0;
    for(int i = 0; i < n; i++) {
        cin >> s[i];
        if(s[i] == "AC") {
             ac++; 
        } else if (s[i] == "WA") {
            wa++;
        }else if(s[i]=="TLE") {
            tle++;
        } else {
            re++;
        }
    }
    
    cout <<"AC x "<<ac<<endl;
    cout <<"WA x "<<wa<<endl;
    cout <<"TLE x "<<tle<<endl;
    cout <<"RE x "<<re<<endl;
    return 0;
}

Measured memory_bytes: 6404
let [|A;B;C;X|] =
    [|1..4|]
    |> Array.map (fun _ ->
        stdin.ReadLine()
        |> int)

Array.allPairs [|0..B|] [|0..C|]
|> Array.allPairs [|0..A|]
|> Array.fold (fun state (a,(b,c)) ->
    match 500*a+100*b+50*c with
    | x when x=X -> state+1
    | _ -> state) 0
|> stdout.WriteLine

Measured memory_bytes: 33788
#include "bits/stdc++.h"

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int

#define pb push_back
#define m <i> map<int>
#define v <i> vector<int>

const int MX = 1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

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

int main()
{
  IOS;
  string s;
  cin >> s;
  if (s=="AAA"||s=="BBB")
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int maxn = max(a, max(b, c));
	int ans = 1;
	if(a != maxn)ans *= a;
	if(b != maxn)ans *= b;
	if(c != maxn)ans *= c;
	cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int j = 0; j < M; j++) cin >> A[i][j];
  }
  int minSum = 1500000;
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<int> res(M);
    int sum = 0;
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        sum += C[i];
        for (int j = 0; j < M; j++) {
          res[j] += A[i][j];
        }
      }
    }
    bool flag = true;
    for (int j = 0; j < M; j++) {
      if (res[j] < X) {
        flag = false;
      }
    }
    if (flag) chmin(minSum, sum);
  }

  if (minSum == 1500000)
    cout << -1 << endl;
  else
    cout << minSum << endl;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define LL long long
//#define rep(i,n) for (int i=0;i<(n);i++)
#define rep(i,x,n) for (int i=x;i<(n);i++)
using namespace std;
int main(){
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	
	while(cin >> a >> b){
		
		int sum = a+b;
		string res = to_string(sum);
		
		cout << res.size() << endl;
	
	}
	return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modpow(long long a, long long b){
	long long ans = 1;
	while (b > 0){
		if (b % 2 == 1){
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return ans;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
vector<long long> mf = {1};
vector<long long> mfi = {1};
long long modfact(int n){
	if (mf.size() > n){
		return mf[n];
	} else {
		for (int i = mf.size(); i <= n; i++){
			long long next = mf.back() * i % MOD;
			mf.push_back(next);
			mfi.push_back(modinv(next));
		}
		return mf[n];
	}
}
long long modfactinv(int n){
	if (mfi.size() > n){
		return mfi[n];
	} else {
		return modinv(modfact(n));
	}
}
long long modbinom(int n, int k){
	if (n < 0 || k < 0 || k > n){
		return 0;
	} else {
		return modfact(n) * modfactinv(k) % MOD * modfactinv(n - k) % MOD;
	}
}
long long modperm(int n, int k){
  if (n < 0 || k < 0 || k > n){
    return 0;
  } else {
    return modfact(n) * modfactinv(n - k) % MOD;
  }
}
long long dfs(vector<vector<int>> &c, int K, int v = 0){
  long long ans = 1;
  if (v == 0){
    ans = modperm(K - 1, c[v].size());
  } else {
    ans = modperm(K - 2, c[v].size());
  }
  for (int w : c[v]){
    ans *= dfs(c, K, w);
    ans %= MOD;
  }
  return ans;
}
int main(){
  int N, K;
  cin >> N >> K;
  vector<vector<int>> E(N);
  for (int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  vector<int> p(N, -1);
  vector<vector<int>> c(N);
  queue<int> Q;
  Q.push(0);
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (int w : E[v]){
      if (w != p[v]){
        p[w] = v;
        c[v].push_back(w);
        Q.push(w);
      }
    }
  }
  cout << K * dfs(c, K) % MOD << endl;
}

Measured memory_bytes: 19296
#include <cstdio>
#include <unordered_map>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
const int N = 1e5 + 1;
int a[N];
long long f[N], g[N];
int L, R;
int n, q;
void get(int l, int r, int ll, int rr)
{
    if (a[r] < ll || rr < a[l]) return;
    if (ll <= a[l] && a[r] <= rr) {
        L = min(L, l), R = max(R, r);
        return;
    }
    get(l, (l + r) / 2, ll, rr);
    get((l + r) / 2 + 1, r, ll, rr);
}
int check(int mid, int r)
{
    if (mid >= a[n])
    {
        printf("%lld\n", g[n]);
        return 0;
    }
    if (mid <= a[1])
    {
        printf("%lld\n", f[n] - f[n / 2]);
        return 0;
    }
    L = n, R = 1;
    get(1, n , mid - r, mid + r);
    if (n - (R - L) == R + 1)
    {
        printf("%lld\n", g[L - 1] + f[n] - f[R]);
        return 0;
    }
    if (n - (R - L) > R + 1) {
        if (L == 1)
        {
            int rr = n - (R - L) - 1, ll = R + 1;
            printf("%lld\n", f[rr] - f[(ll + rr - 1) / 2] + f[n] - f[rr]);
            return 0;
        }
        return 1;
    }
    if (abs(a[L] - mid) <= abs(a[R] - mid))
        R --;
    else
        L ++;
    if (n - (R - L) == R + 2)
    {
        if (L - 2 >= 0)
            printf("%lld\n", f[n] - f[R] + g[L - 2]);
        else
            printf("%lld\n", f[n] - f[R]);
        return 0;
    }
    if (n - (R - L) > R + 1)
        return 1;
    if (n - (R - L) == R + 1)
    {
        printf("%lld\n", g[L - 1] + f[n] - f[R]);
        return 0;
    }
    return -1;
}
int main()
{
    scanf("%d %d", &n, &q);
    for (int i = 1; i <= n ; i ++) {
        scanf("%d", &a[i]);
        f[i] = f[i - 1] + a[i];
        if (i == 1) g[i] = a[i];
        else
            g[i] = g[i - 2] + a[i];
    }
    while (q --)
    {
        int x ;
        scanf("%d", &x);
        int l = 0, r = 1e9, mid, s;
        while (l <= r)
        {
            int sig = check(x, mid = (l + r) / 2);
            if (sig > 0)
                l = mid + 1;
            else
                if (sig < 0)
                    r = mid - 1;
                else
                    break;

        }
    }

    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int n,m;
struct node
{
    ll a;
    ll b;
}s[maxn];
bool cmp(node x,node y)
{
    if(x.a!=y.a) return x.a<y.a;
    else return x.b>y.b;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%lld%lld",&s[i].a,&s[i].b);
    sort(s,s+n,cmp);
    ll ans=0,sum=0;
    for(int i=0;i<n;i++)
    {
        ans+=s[i].b;
        if(ans<m)
        {
            sum+=s[i].b*s[i].a;
            continue;
        }
        sum+=(s[i].b-ans+m)*s[i].a;
        break;
    }
    printf("%lld\n",sum);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    a.at(i)--;
  }
  int c=-1;
  int x=a.at(0);
  for(int i=1;i<=n;i++){
    if(x==1){
      c=i;
      break;
    }
    x=a.at(x);
  }
  cout<<c<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];
int main(){
  ll ans = 1e18;
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  {
    ll tmp = 0;
    ll sum = 0;
    REP(i,n){
      sum += a[i];
      if(i%2==0){
        if(sum<=0)tmp += 1-sum, sum=1;
      }else{
        if(sum>=0)tmp += sum+1, sum=-1;
      }
    }
    CHMIN(ans,tmp);
  }
  {
    ll tmp = 0;
    ll sum = 0;
    REP(i,n){
      sum += a[i];
      if(i%2==1){
        if(sum<=0)tmp += 1-sum, sum=1;
      }else{
        if(sum>=0)tmp += sum+1, sum=-1;
      }
    }
    CHMIN(ans,tmp);
  }
  printf("%lld\n",ans);
  return 0;
}


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

int n;
long long a[200001];
int main() {
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    vector<long long> v;
    REP(i, 0, n){
        v.push_back(a[i]-(i+1));
    }
    sort(v.begin(), v.end());

    long long ans=0;
    REP(i, 0, n){
        ans+=abs(a[i]-(v[n/2]+i+1));
    }
    if(n%2==0){
        long long sum=0;
        REP(i, 0, n){
            sum+=abs(a[i]-(v[n/2 -1]+i+1));
        }
        ans=min(ans, sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3956
h, w = map(int, input().split())
cv = [input() for _ in range(h)]
for y in range(h):
    for x in range(w):
        if cv[y][x] == '#':
            if (y > 0 and cv[y - 1][x] == '#') or (y < h - 1 and cv[y + 1][x] == '#') \
                    or (x > 0 and cv[y][x - 1] == '#') or (x < w - 1 and cv[y][x + 1] == '#'):
                continue
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064