akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")   //Comment optimisations for an interatcive problem - use endl
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  2e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int qq;
ll n, a[MAXN];
ll res=INF;
ll pr[MAXN]={}, sf[MAXN]={};
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//

int main(){
	fastio;randomINIT;

	cin>>n;
	fo(i,n)cin>>a[i];
	pr[0]=a[0];
	foo(i,1,n-1)pr[i]=pr[i-1]+a[i];
	sf[n-1]=a[n-1];
	frr(i,n-2,0)sf[i]=sf[i+1]+a[i];
	fo(i,n-1)res=min(res,abs(pr[i]-sf[i+1]));
	cout<<res;
	

}

Measured memory_bytes: 11264
sflag = false
while a = gets.split.map(&:to_i)
  break if a[0] == 0
  puts if sflag
  flag = true
  i = a[0]
  while i % 4 != 0
    i += 1
  end
  loop do
    break if i > a[1]
    if i % 4 == 0 && i % 100 != 0 || i % 400 == 0
      puts i
      flag = false
    end
    i += 4
  end
  if flag
    puts "NA"
  end
  sflag = true
end

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



int main(){
	string str1,str2;
	cin>>str1>>str2;

	int n1=str1.length();
	int n2= str2.length();

	int dp[n1+1][n2+1]={{0}};
	
	string ans="";
	
	for(int i=0;i<=n1;i++){
		for(int j=0;j<=n2;j++){
          	
	          if(i==0||j==0){
	          	dp[i][j] =0;
	          }
			else if(str1[i-1] == str2[j-1]){
				dp[i][j] = dp[i-1][j-1]+1;
				
			}else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}

	
	int i=n1,j=n2;

	while(i>=1 && j>=1){
		
		if(str1[i-1]  == str2[j-1]){
			ans+=str1[i-1];
			i=i-1;
			j=j-1;
		}else{
			int temp=max(dp[i-1][j],dp[i][j-1]);
			
			if(temp == dp[i-1][j]){
				i=i-1;

			}else{
				j=j-1;
			}

		}
	}
  
  	

	reverse(ans.begin(),ans.end());
  cout << ans << endl;

/*	for(int i=0;i<=n1;i++){
		for(int j=0;j<=n2;j++){
			cout << dp[i][j]<< " ";
		}
		cout << endl;
	}*/
		
	return 0;
}

Measured memory_bytes: 35456
N=int(input())

t=[]
x=[]
y=[]

for _ in range(N):
	tt,xx,yy=map(int,input().split())
	t.append(tt)
	x.append(xx)
	y.append(yy)

t_=0
x_=0
y_=0

for i in range(N):
	tmp1=abs(x[i]-x_) + abs(y[i]-y_) 
	tmp2=t[i]-t_
	t_=t[i]
	x_=x[i]
	y_=y[i] 
	if tmp1<=tmp2 and tmp1%2==tmp2%2:
		pass
	else:
		print("No")
		break

else:
	print("Yes")
	

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

int main(){
  
  long long n,k;
  cin >>n>>k;
  
  long long ans=0;
 
  //kで割り切れるa,b,cの種類
  long long num1=n/k; 
  
  //kで割った余りがk/2になるa,b,cの種類
  long long num2=0;
  if(k%2==0){
    num2=(n+(k/2))/k;
  }
  ans=num1*num1*num1+num2*num2*num2;
  // cout <<"num1:"<<num1<<endl;
  // cout <<"num2:"<<num2<<endl;
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList[] a = new ArrayList[n];
        for(int i=0; i<n; i++){
            a[i] = new ArrayList<Integer>();
            for(int j=0; j<m; j++){
                a[i].add(sc.nextInt() - 1);                
            }
        }

        int min = n;

        for(int i=0; i<m; i++){
            int[] mnum = new int[m];
            for(int j=0; j<n; j++){
                mnum[(int)(a[j].get(0))]++;
            }
            int max = 0, maxpos = 0;
            for(int j=0; j<m; j++){
                if(mnum[j] > max){
                    max = mnum[j];
                    maxpos = j;
                }
            }
            if(max < min) min = max;
            for(int j=0; j<n; j++){
                a[j].removeAll(Arrays.asList(new Integer[]{maxpos}));
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 50328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string X;
  cin >> X;
  vector<int> dp(200001, 0);
  for (int i = 1; i <= 200000; i++){
    dp[i] = dp[i % __builtin_popcount(i)] + 1;
  }
  int pcnt = 0;
  for (int i = 0; i < N; i++){
    pcnt += X[i] - '0';
  }
  vector<int> rem_neg(N, 0);
  if (pcnt >= 2){
    rem_neg[N - 1] = 1;
    for (int i = N - 2; i >= 0; i--){
      rem_neg[i] = rem_neg[i + 1] * 2 % (pcnt - 1);
    }
  }
  vector<int> rem_pos(N, 0);
  rem_pos[N - 1] = 1;
  for (int i = N - 2; i >= 0; i--){
    rem_pos[i] = rem_pos[i + 1] * 2 % (pcnt + 1);
  }
  int X_neg = 0;
  if (pcnt >= 2){
    for (int i = 0; i < N; i++){
      if (X[i] == '1'){
        X_neg += rem_neg[i];
        X_neg %= (pcnt - 1);
      }
    }
  }
  int X_pos = 0;
  for (int i = 0; i < N; i++){
    if (X[i] == '1'){
      X_pos += rem_pos[i];
      X_pos %= (pcnt + 1);
    }
  }
  for (int i = 0; i < N; i++){
    if (X[i] == '1'){
      if (pcnt == 1){
        cout << 0 << endl;
      } else {
        int r = X_neg - rem_neg[i];
        r += pcnt - 1;
        r %= pcnt - 1;
        cout << dp[r] + 1 << endl;
      }
    } else {
      int r = X_pos + rem_pos[i];
      r %= pcnt + 1;
      cout << dp[r] + 1 << endl;
    }
  }
}

Measured memory_bytes: 6032
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

string S;
int dp[200000 + 10];
int nxt[200000 + 10][26];
char hukugen[200000 + 10];
int comefrom[200000 + 10];

int main() {
	cin >> S;

	for (int i = 0; i < 26; i++) {
		nxt[S.size()][i] = S.size();
	}
	for (int i = S.size() - 1; i >= 0; i--) {
		for (int j = 0; j < 26; j++) {
			if (j + 'a' == S[i])nxt[i][j] = i;
			else nxt[i][j] = nxt[i + 1][j];
		}
	}

	dp[S.size()] = 1;
	for (int i = S.size() - 1; i >= 0; i--) {
		int tmp = 1145141919;
		for (int j = 0; j < 26; j++) {
			if (nxt[i][j] == S.size()) {
				if (tmp > 1) {
					//辞書順対策
					tmp = 1;
					hukugen[i] = 'a' + j;
					comefrom[i] = S.size();
				}
			}
			else {
				if (tmp > dp[nxt[i][j] + 1] + 1) {
					tmp = dp[nxt[i][j] + 1] + 1;
					hukugen[i] = 'a' + j;
					comefrom[i] = nxt[i][j] + 1;
				}
			}
		}
		dp[i] = tmp;
	}
	int idx = 0;
	string ans = "";
	while (idx < S.size()) {
		ans += hukugen[idx];
		idx = comefrom[idx];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22660
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
 
#define DEBUG 0
 
#define lli long long unsigned int
#define REP(i,n) for(int i=0;i<n;i++)
 
using namespace std;

vector<lli> a,b,p;

lli calc(lli level,lli num){
	lli right = 0;
	lli left = a[level]-1;
	lli middle = (right+left)/2;
	if(DEBUG)cout<<"level="<<level<<" num= "<<num<<endl;

	if(level == 0)return 1;

	if(num == 0)return 0;
	else if(num < middle){
		return calc(level-1,num-1);
	}
	else if(num == middle){
		return p[level-1] + 1;
	}
	else if(middle < num){
		return p[level-1] + 1 + calc(level-1,num-middle-1);
	}
	else{
		return p[level];
	}
}


int main(){

	lli n,x;
	cin>>n>>x;
	a.resize(n+1);
	b.resize(n+1);
	p.resize(n+1);
	a[0] = 1;
	b[0] = 0;
	p[0] = 1;
	lli d = 2;
	for(lli i=1;i<=n;i++){
		b[i] = b[i-1] + d;
		p[i] = p[i-1] + d;
		a[i] = b[i]+p[i];
		d *= 2;
	}

	cout<<calc(n,x-1)<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define N_MAX 100000
using namespace std;

int dp[N_MAX][3];
int h[N_MAX][3];

int main(){
  int N,i,k;
  cin>>N;
  for(i=0;i<N;i++){
    cin>>h[i][0]>>h[i][1]>>h[i][2];
  }
  
  dp[0][0]=h[0][0];
  dp[0][1]=h[0][1];
  dp[0][2]=h[0][2];
  
  for(i=1;i<N;i++){
    for(k=0;k<3;k++){
      dp[i][k]=max(dp[i-1][(k+1)%3],dp[i-1][(k+2)%3])+h[i][k];
    }
  }
  cout<<max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2])<<endl;
}

Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String t = sc.next();
        String s = sc.next();

        ArrayList<Integer> list = new ArrayList<>();

        String hantei;
        for(int i = 0; i <= t.length() - s.length(); i++) {
            hantei = t.substring(i, s.length() + i);
            int c = 0;
            for(int j = 0; j < s.length(); j++)
            	if(s.charAt(j) != hantei.charAt(j)) ++c;
            list.add(c);
        }

        Collections.sort(list);
        System.out.println(list.get(0));
    }

}


Measured memory_bytes: 37072
h1, m1, h2, m2, k = map(int, input().split())
 
if h1 <= h2:
    time = h2 * 60 + m2 - h1 * 60 - m1
else:
    time = (h2+24) * 60 + m2 - h1 * 60 - m1
if k >= time:
    print(0)
else:
    print(time - k)


Measured memory_bytes: 61584
n = int(input())
a = [0]
b = [0]
c = [0]

for i in range(n):
    aa,bb,cc = map(int,input().split())
    a.append(max(b[i] + aa, c[i] + aa))
    b.append(max(a[i] + bb, c[i] + bb))
    c.append(max(a[i] + cc, b[i] + cc))
    
print(max(a[-1], b[-1], c[-1]))


Measured memory_bytes: 14980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    ll ans = 0;
    ll now = 0;
    rep(i, n)
    {
        if (now > a[i])
        {
            ans += now - a[i];
        }
        else
        {
            now = max(now, a[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cfloat>
#include <cmath>
#include <functional>
#include <forward_list>
#include <list>


#define DEBUG(x) cout << #x << "\t:" << x << endl;
#define EPS (1e-9)
#define INF (INT_MAX/3)
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REPV(it,v) for(auto it = (v).begin(); it != (v).end(); ++it)

#define ll long long
#define ull unsigned long long


using namespace std;



class Edge {
public:
	int lv;
	int rv;
	double w;
	Edge(int lv, int rv, double w) {
		this->lv = lv;
		this->rv = rv;
		this->w = w;
	}

	Edge(int r, int l) : Edge(r, l, 1) {}
};

class Graph {
public:
	vector<double> vs;
	vector<vector<Edge> > es;

	Graph(vector<double>& vs, vector<vector<Edge> >& es) {
		this->vs = vs;
		this->es = es;
	}

	Graph(int n, vector<vector<Edge> >& es) {
		this->vs = vector<double>(n, 0);
		this->es = es;
	}

	Graph(int n, vector<Edge>& es, bool isBidirectional) {
		this->vs = vector<double>(n, 0);
		this->es = vector<vector<Edge> >(n, vector<Edge>());

		for (int i = 0;i < es.size();i++) {
			this->es[es[i].lv].push_back(es[i]);
		}

		if (isBidirectional) {
			for (int i = 0;i < es.size();i++) {
				this->es[es[i].rv].push_back(Edge(es[i].rv, es[i].lv, es[i].w));
			}
		}
	}

	Graph(int n) {
		this->vs = vector<double>(n, 0);
		this->es = vector<vector<Edge> >();
	}

};

class Main {
public:
	vector<int> getAns(Graph& g) {
		vector<int> ans(g.vs.size());

		REP(i, g.vs.size()) {
			ans[i] = g.es[i].size();
		}

		return ans;
	}
};

int main(void) {
	Main main;
	int n, m;
	vector<Edge> es;

	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		es.push_back(Edge(a - 1, b - 1));
	}

	Graph g(n, es, true);

	auto ans = main.getAns(g);
	REP(i, n) {
		cout << ans[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

ll f(ll x){
    ll ret = 0;
    while(x){
        ret += (x % 10);
        x /= 10;
    }
    return ret;
}

int main(){

    ll N;
    cin >> N;
    Say(N % f(N) == 0);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mp make_pair

using namespace std;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	#ifdef PIYUSH_HOME
		I_O;
	#else
	#define print(...) 0
	#endif
	int n; cin >> n;
	if(n < 1200)
		cout << "ABC";
	else if(n < 2800)
		cout << "ARC";
	else
		cout << "AGC";
}

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

int main(){
    ll n,sum=0,summ=0,a[300005];
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n-1){
        summ+=a[n-1-i];
        summ%=mod;
        sum+=(a[n-2-i]*summ)%mod;
        sum%=mod;
    }
    cout<<sum;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for(int i=0; i<M; i++){
    cin >> L.at(i) >> R.at(i);
  }

  int l = 1;
  int r = N;
  for(int i=0; i<M; i++){
    if(L.at(i) > l){
      l = L.at(i);
    }
    if(R.at(i) < r){
      r = R.at(i);
    } 
  }
  if(r-l+1 <= 0){
    cout << 0 << endl;
  }else{
    cout << r-l+1 << endl;
  }
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
    int x, A, B;
    scanf("%d %d %d", &x, &A, &B);

    if (x, A, B >= 1 && x, A, B <= 1000) {
        if (x < A && x < B) {
            if (A - x < B - x) {
                printf("A\n");
            } else {
                printf("B\n");
            }
        } else if (x > A && x > B) {
            if (x - A < x - B) {
                printf("A\n");
            } else {
                printf("B\n");
            }
        } else {
            if (x > A && x < B) {
                if (x - A < B - x) {
                    printf("A\n");
                } else {
                printf("B\n");
                }
            } else {
                if (x - B < A - x) {
                    printf("B\n");
                } else {
                printf("A\n");
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1664
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { 
    answer();
   }
   static void answer()
   {
     Scanner sc = new Scanner(System.in);
     
     int n = sc.nextInt();
     
     int[] table = new int[n];
     
     int min = 0;
     
     int max = 0;     
     
     long sum = 0;
     
     for(int i = 0; i < n; i ++)
     {
       table[i] = sc.nextInt();
       
       if(i == 0)
       {
         min = table[i];
         
         max = table[i];
       }
       else 
       {
         if(min > table[i])
         {
           min = table[i];
         }
         if(max < table[i])
         {
           max = table[i];
         }
       }
       sum = sum + table[i];
     }
     System.out.printf("%d %d %d",min,max,sum);
     
     System.out.println();
   }
 }
    


Measured memory_bytes: 41412
n = int(input())
t, a = list(map(int, input().split()))
h_list = list(map(int, input().split()))

t_list = list(map((lambda h: t-h*0.006), h_list))
diff_list = list(map((lambda t: abs(a-t)), t_list))

idx = 1
idx_diff_list = []
for diff in list(diff_list):
    idx_diff_list.append((idx, diff))
    idx += 1

print(min(idx_diff_list, key=(lambda t: t[1]))[0])


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

int main(){
  int N, A, B;
  int tmp;
  int sum = 0;
  int result = 0;
  cin >> N >> A >> B;
  for(int i=0;i<=N;i++){
  	sum = 0;
    tmp = i;
	while(tmp){
	  sum += tmp % 10;
	  tmp /= 10;
	}
	if(A<=sum && sum<= B) result+=i;
  }
  cout << result << endl;
  return 0;
}


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

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

  int n, m;
  cin >> n >> m;
  int res = (1 << m) - 1;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    int tmp = 0;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      tmp |= 1 << (a - 1);
    }
    res &= tmp;
  }
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    cnt += res >> i & 1;
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,t;
	cin>>n>>t;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	ll mini=INF,buf=0,c=0;
	REP(i,n) {
		mini=min(mini,a[i]);
		if(a[i]-mini>buf) {
			buf=a[i]-mini;
			c=1;
		} else if(a[i]-mini==buf) {
			++c;
		}
	}
	cout<<c<<endl;
}


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

int main()
{
  int N,D,X;
  cin >> N >> D >> X;
  int A[100],T[100],sum;
  sum = X;
  for(int i = 0;i < N;i++){
    cin >> A[i];
    T[i] = 1;
    T[i] += D/A[i];
    if((D%A[i])==0) T[i] -= 1;
    sum += T[i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
//ABC097-B
#include <stdio.h>

int main(){
	int X, i, j, ans = 1;
	scanf("%d", &X);
	for(i = 2; i * i <= X; i++){
		for(j = i; j * i <= X; j *= i);
		if(j > ans){
			ans = j;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
//typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll N, x[100010], sum[100010];

ll ans;

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

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

void init()
{
	
}

void output()
{
	//cout << ans << endl;
}



void solve()
{
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
}

int main()
{
	init();
	
	solve();

	

	output();
	ll N;
	cin >> N;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <string>
#include <bitset>
#include <math.h>
#include <vector>
#include <set>

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

using namespace std;


int main(){
    int cnt = 0;
    int N, M, C;

    cin >> N >> M >> C;

    vector<int> B(M);
    for(int i = 0; i < M; i++) cin >> B.at(i);

    for(int i = 0; i < N; i++){
        vector<int> A(M);
        for(int j = 0; j < M; j++) cin >> A.at(j);

        int ans = 0;
        for(int j = 0; j < M; j++){
            ans += A.at(j) * B.at(j);
        }
        ans += C;
        //cout << ans << endl;
        if(ans > 0) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    vint cnt(N);
    REP(i,M){
        int a,b; cin>>a>>b;
        a--; b--;
        cnt[a]++; cnt[b]++;
    }
    REP(i,N) cout<<cnt[i]<<endl;
 
}


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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<ll> A;
string S, T="";

signed main(){
    cin >> S;
    for(int i=0;i<S.size();i++) {
        if(S[i]!='x') {
            T = T+S[i];
            A.push_back(tmp);
            tmp=0;
        }
        else {
            tmp++;
        }
    }
    //cout << T << endl;
    A.push_back(tmp);
    for(int i=0;i<T.size();i++) {
        if(T[i]!=T[T.size()-1-i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i=0;i<A.size();i++) {
        if(i<A.size()-1-i) ans += abs(A[i]-A[A.size()-1-i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

string N;
vector<string> tfs;

void search_tfs(string sn) {
	if (sn.length() > 2) {
		if (sn.length() > N.length()) {
			return;
		}
		bool t,f,s;
		t = f = s = false;
		for (int i = 0; i < sn.length(); ++i) {
			if (sn[i] == '3') {
				t = true;
			}
			if (sn[i] == '5') {
				f = true;
			}
			if (sn[i] == '7') {
				s = true;
			}
		}
		if (t&&f&&s) {
			tfs.push_back(sn);
		}
	}
	search_tfs(sn+"3");
	search_tfs(sn+"5");
	search_tfs(sn+"7");
	return;
}

int main(void) {
	cin >> N;
	int res = 0;
	if (N.length() > 2) {
		tfs = vector<string>();
		search_tfs("");
		int num = stoi(N);
		for (int i = 0; i < tfs.size(); ++i) {
			if (stoi(tfs[i]) <= num) {
				++res;
			}
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 1660
using System;

class Problem
{
    public static void Main(string[] args)
    {
        var line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        if (line[0] + line[1] >= line[2])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
import itertools
import sys
input = sys.stdin.readline

def prime_boolean_table(n):
    primes = [True] * (n + 1)
    primes[0] = False
    primes[1] = False
    for i in range(2, n + 1):
        if primes[i]:
            for j in range(i + i, n + 1, i):
                primes[j] = False
    return primes

def main():
    pl = prime_boolean_table(10**5)
    ql = [0]*(10**5+1)
    for i in range(1,10**5+1):
        if pl[i] and pl[(i+1)//2]:
            ql[i] += 1
    ql = list(itertools.accumulate(ql))
    q = int(input())
    for _ in range(q):
        l,r = map(int,input().split())
        print(ql[r]-ql[l-1])

if __name__=='__main__':
    main()


Measured memory_bytes: 7716
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;
  ll mul = 1;
  int cnt = 0;
  while (mul <= n) {
    mul *= k;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    double res;//deg
    double min, max;//deg
    min = 0;
    max = 90;
    while(max - min > 1e-8){
        res = (min + max)/2;
        if(a * tan(res*M_PI/180) <= b){
            if(a*a*b - a*a*a*tan(res*M_PI/180)/2 > x){
                min = res;
            }else{
                max = res;
            }
        }else{
            if(a*b*b*tan((90-res)*M_PI/180)/2 > x){
                min = res;
            }else{
                max = res;
            }
        }
        
    }
    
    printf("%.7f\n", res);
    return 0;
}

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

using namespace std;

int foot(int);

int main() {

	int n;
	vector<int>floor;

	
	cin >> n;
	while (n != 0) {
		floor.push_back(n);
		cin >> n;
	}
	floor.push_back(0);


	int i = 0;
	while (floor[i] != 0) {

		int res = 0;
		res = foot(floor[i]) / 3650;
		if( foot(floor[i]) % 3650 != 0) res++;

		cout << res << endl;
		i++;
	}

	cin >> n;


	return 0;
}

int foot(int n) {


	if (n == 1)return 1;
	if (n == 2)return 2;
	if (n == 3)return 4;
	if (n < 1)return 0;

	return foot(n - 1) + foot(n - 2) + foot(n - 3);


}

Measured memory_bytes: 1216
N, T, *TS = $stdin.read.split.map(&:to_i)
t = 0
ans = 0
start = nil
stop = 0
times = (TS + [TS.last+T]).each_cons(2).map{|t1, t2|
  [t2-t1, T].min
}
p times.inject(:+)


Measured memory_bytes: 24700
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,i,j,k;
    vector<long long int>v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>k;
        v.push_back(k);

    }
    if(n%2==0)
    {
        for(i=n-1;i>=0;i-=2)
        {
            cout<<v[i]<<" ";
        }
        for(i=0;i<n;i+=2)
        {
            cout<<v[i]<<" ";
        }
        cout<<endl;
    }
    else
    {
         for(i=n-1;i>=0;i-=2)
        {
            cout<<v[i]<<" ";
        }
        for(i=1;i<n;i+=2)
        {
            cout<<v[i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}




Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = (1<<30);

struct BIT
{
  int n;
  vector<int> tree;
  BIT(int n_)
  {
    tree = vector<int>(n_+1,0);
    n = n_;
  }
  int sum(int i)
  {
    int ret = 0;
    while( i > 0 ) {
      ret += tree[i];
      i -= i & -i;
    }
    return ret;
  }
  void add(int i, int x)
  {
    while( i <= n ) {
      tree[i] += x;
      i += i & -i;
    }
  }
};

main()
{
  int N, M;
  vector<Pii> range[100001];

  cin >> N >> M;
  Rep(i, N) {
    int l, r;
    cin >> l >> r;
    range[r-l+1].pb( Pii(l, r) );
  }

  BIT tree(M+1);
  int cnt = N; //必ず通る地点
  for(int d=1; d<=M; d++) {
    for(int i=0; i<range[d].size(); i++) {
      Pii p = range[d][i];
      tree.add( p.fr, 1 ); //高々1回しか通らない範囲に+1
      tree.add( p.sc+1, -1 ); //重複してカウントすることを防ぐ
      cnt--;
    }
    int cnt2 = 0; //たかだか１回とおる地点
    for(int i=d; i<=M; i+=d) {\
      cnt2 += tree.sum( i );
    }
    cout << cnt + cnt2 << endl;
  }

}

Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

int main() {

	set<char> s;
	string str;

	cin >> str;
	rep(i, str.size()) {
		int size = s.size();
		s.insert(str[i]);
		if (s.size() == size) {
			cout << "no" NL;
			return 0;
		}
	}

	cout << "yes" NL;

	return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    double res = 0;
    vector<double>x(n),y(n);
    rep(i,n)cin >> x[i] >> y[i];
    vector<int>id(n);
    iota(id.begin(), id.end(),0);
    do{
        rep(i,n-1){
            res += sqrt((x[id[i]]-x[id[i+1]])*(x[id[i]]-x[id[i+1]]) + (y[id[i]]-y[id[i+1]])*(y[id[i]]-y[id[i+1]]));
        }
    }while(next_permutation(id.begin(), id.end()));
    rep(i,n)res /= double(i + 1);
    printf("%.10lf\n", res);
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: i32, m: i32, x: i32,
        a: [i32; m],
    }
    
    let left = a.iter().filter(|&&c|  c < x).count();
    let ans = cmp::min(left, a.len() - left);
    println!("{}", ans);
}   


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

int main() {
    int D, G, p[11], c[11];
    cin >> D >> G;
    for (int i = 0; i < D; i++)
        cin >> p[i] >> c[i];

    int ans = 1e9;
    for (int mask = 0; mask < (1 << D); mask++) {
        int s = 0, num = 0, rest_max = -1;
        for (int i = 0; i < D; i++) {
            if (mask >> i & 1) {
                s += 100 * (i + 1) * p[i] + c[i];
                num += p[i];
            } else {
                rest_max = i;
            }
        }
        if (s < G) {
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if (need >= p[rest_max]) {
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
num = [i for i in range(1, x)]
comb = []
for k in num:
    comb.append([k, x - k])
if y % 4 == 0 and y // 4 == x:
    print("Yes")
    exit()
elif y % 2 == 0 and y // 2 == x:
    print("Yes")
    exit()
for j in comb:
    if j[0] * 4 + j[1] * 2 == y:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 9212
#include<stdio.h>
int main(){
  int n,i,j,gx,gy,ny,nx,c,b;
  int x[101][101],y[101][101];
  while(scanf("%d",&n),n){
    int f[101][101]={0};
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	scanf("%d %d",&x[i][j],&y[i][j]);
      }
    }
    for(i=c=b=0;i<n;i++){
      for(j=0;j<n;j++){
	if(f[i][j])continue;
	gy=i;
	gx=j;
	c++;
	while(f[gy][gx]==0){
	  nx=x[gy][gx];
	  ny=y[gy][gx];
	  f[gy][gx]=c;
	  gx=nx;
	  gy=ny;
	}
	if(f[gy][gx]!=c)b++;
      }
    }
    printf("%d\n",c-b);
  }
  return 0;
}

Measured memory_bytes: 724
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

#define MAX 90001

int main(void){

    long long MOD=998244353;
    int N;
    cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int sum=accumulate(a.begin(),a.end(),0);

    long long ans=1;

    for(int i=0;i<N;i++){
        ans=(ans*3)%MOD;
    }

    long long dp[MAX];

    dp[0]=1;
    for(int i=1;i<sum+1;i++){
        dp[i]=0;
    }

    for(int i=0;i<N;i++){
        for(int k=sum;k>=0;k--){
            if(k-a[i]>=0){
                dp[k]=(2*dp[k]+dp[k-a[i]])%MOD;
            }else{
                dp[k]=2*dp[k]%MOD;
            }
        }
    }

    for(int i=sum/2+sum%2;i<sum+1;i++){
        ans=(ans-3*dp[i]+3*MOD)%MOD;
    }
    
    dp[0]=1;
    for(int i=1;i<sum+1;i++){
        dp[i]=0;
    }
    for(int i=0;i<N;i++){
        for(int k=sum;k>=0;k--){
            if(k-a[i]>=0){
                dp[k]=(dp[k]+dp[k-a[i]])%MOD;
            }else{
                dp[k]=dp[k]%MOD;
            }
        }
    }


    if(sum%2==0){
       ans=(ans+3*dp[sum/2])%MOD;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 896
/*___________Bismillahir Rahmanir Rahim__________*/
//Think positive, be positive and never use negative words
#include<bits/stdc++.h>
#define ll               long long int
#define uni(a)           a.erase(unique(a.begin(),a.end()),a.end())
#define vsum(a)          accumulate(a.begin(),a.end(),0)
#define vmax(a)          *max_element(a.begin(),a.end())
#define vmin(a)          *min_element(a.begin(),a.end())
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
#define yes              cout<<"YES"<<endl
#define no               cout<<"NO"<<endl;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n;
    cin>>n;
    if(n==0) cout<<1<<endl;
    else if(n==1) cout<<0<<endl;
    return 0;
}
/*_________________Alhamdulillah_________________*/


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<T> ReadVec1(int N) {
    vector<T> vec(N);
    for(int i = 0; i < N; i++)
        vec[i] = In<T>();
    return move(vec);
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(j, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

bool check(const vector<int> &v1, const vector<int> &v2) {
    int r2 = 0;
    for(int d = 0; d < v1.size(); d++) {
        r2 += (v1[d] - v2[d]) * (v1[d] - v2[d]);
    }

    for(int r = 1; r < sqrt(r2 + 1); r++){
        if(r*r == r2)
            return true;
    }
    return false;
}

int main() {
    int N = In<int>(), D = In<int>();
    auto vec = Vec2<int>(N, D);
    for(int n = 0; n < N; n++){
        for(int d = 0; d < D; d++){
            vec[n][d] = In<int>();
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < i; j++){
            if(check(vec[i], vec[j]))
                ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {

  string s;
  cin >> s;
  int n = s.size();
  vector< vector<long long int> > dp(n+1, vector<long long int>(4, 0));
  dp[0][0] = 1;
  for(int i=0; i<n; i++){
    int c = (s[i] == '?' ? 3 : 1 );
    for(int j=0; j<4; j++){
      dp[i+1][j] += c * dp[i][j];
    }
    if( s[i] == 'A' ) dp[i+1][1] += dp[i][0];
    else if( s[i] == 'B') dp[i+1][2] += dp[i][1];
    else if( s[i] == 'C' ) dp[i+1][3] += dp[i][2];
    else {
      dp[i+1][1] += dp[i][0];
      dp[i+1][2] += dp[i][1];
      dp[i+1][3] += dp[i][2];
    }
    for(int j=0; j<4; j++){
      dp[i+1][j]%=mod;
    }
  }

  cout << dp[n][3] << endl;

  return 0;
}




//


Measured memory_bytes: 7424
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;

int tmp;

void dfs(vector<vector<int>>& adj, int u, int p, vector<bool>& vis) {
	vis[u] = true;
	tmp++;

	for(int child: adj[u]) {
		if(vis[child] == false && child != p)
			dfs(adj, child, u, vis);
	}
}


int main() {
	//fios;
	int n, m;
	cin >> n >> m;
	vector<vector<int> > adj(n);
	int a, b;
	for(int i = 0; i < m; i++) {
		cin >> a >> b, --a, --b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	} 
	vector<bool> vis(n, 0);
	int ans = 0;
	for(int i = 0; i < n; i++)
		if(vis[i] == false){
			tmp = 0;
			dfs(adj, i, -1, vis);
			ans = max(tmp, ans);
		}

	cout << ans << endl;
}

Measured memory_bytes: 29796
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);

        int N, K;
        Integer[] D;

        N = sc.nextInt();
        K = sc.nextInt();

        D = new Integer[K];
        for (int i = 0; i < K; i++) {
            D[i] = sc.nextInt();
        }

        for (int i = 1; i < 100000; i++) {
            if (N <= i) {
                if (i < 10)
                {
                    if (!Arrays.asList(D).contains(i)) {
                        out.println(i);
                        break;
                    }
                } else if (i < 100)
                {
                    if (!Arrays.asList(D).contains(i/10) && !Arrays.asList(D).contains(i%10)) {
                        out.println(i);
                        break;
                    }
                } else if (i < 1000) {
                    if (!Arrays.asList(D).contains(i/100) && !Arrays.asList(D).contains((i%100)/10) && !Arrays.asList(D).contains(i%10)) {
                        out.println(i);
                        break;
                    }
                } else if (i < 10000) {
                    if (!Arrays.asList(D).contains(i/1000) && !Arrays.asList(D).contains((i%1000)/100) && !Arrays.asList(D).contains((i%100)/10) && !Arrays.asList(D).contains(i%10)) {
                        out.println(i);
                        break;
                    }
                } else if (10000 <= i) {
                    if (!Arrays.asList(D).contains(i/10000) && !Arrays.asList(D).contains((i%10000)/1000) && !Arrays.asList(D).contains((i%1000)/100) && !Arrays.asList(D).contains((i%100)/10) && !Arrays.asList(D).contains(i%10)) {
                        out.println(i);
                        break;
                    }
                }
            }
        }
        sc.close();
    }
}

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

using namespace std;
const int maxn = 1e5 + 100;

vector<int> e[maxn];
int n, m;
int ans[maxn];
int cnt = 0;
int v[maxn], d[maxn], c[maxn];
int maxx[maxn][200];

struct node {
    int vec, d;
};

bool operator<(node a, node b) {
    return a.d < b.d;
}


queue<node> q;

void dfs(int v, int d, int c) {
    if (maxx[v][d]) return;
    if (!ans[v]) ans[v] = c;
    if (d == 0) return;
    int to = e[v].size();
    for (int i = 0; i < to; i++) {
        dfs(e[v][i], d - 1, c);
    }
    maxx[v][d] = 1;
}

int main() {
   // freopen("input.txt", "r", stdin);
    scanf("%d %d", &n, &m);
    int a, b;
    for (int i = 0; i < m; i++) {
        scanf("%d %d", &a, &b);
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int _;
    scanf("%d", &_);
    for (int i = 0; i < _; i++) {
        scanf("%d %d %d", &v[i], &d[i], &c[i]);
    }
    for (int i = _ - 1; i >= 0; i--) {
        dfs(v[i], d[i], c[i]);
    }
    for (int i = 1; i <= n; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 86264
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

#define NUM 2147483647

using namespace std;

struct Info{
	int left,right,minimum;
};

Info* info;
int* index_table;
int N;

void func(int index){
	int div = info[index].right - info[index].left;

	if(div != 0){
		if(div%2 == 1){ //????????????2?????????????????´???
			info[index*2+1].left = info[index].left;
			info[index*2+1].right = (info[index].left + info[index].right)/2;
			func(index*2+1);
			info[index*2+2].left = (info[index].left + info[index].right)/2 + 1;
			info[index*2+2].right = info[index].right;
			func(index*2+2);
		}else{
			info[index*2+1].left = info[index].left;
			info[index*2+1].right = (info[index].left + info[index].right)/2;
			func(index*2+1);
			info[index*2+2].left = (info[index].left + info[index].right)/2 + 1;
			info[index*2+2].right = info[index].right;
			func(index*2+2);
		}
	}else{
		index_table[info[index].left] = index;
	}
}

void update(int index, int new_value){
	info[index_table[index]].minimum = new_value;

	if(index_table[index] == 0)return;
	int t = (index_table[index]-1)/2;

	while(true){
		info[t].minimum = min(info[2*t+1].minimum,info[2*t+2].minimum);
		if(t == 0)break;
		t = (t-1)/2;
	}
}

int getMinimum(int index,int left,int right){
	if(info[index].left > right || info[index].right < left){
		return NUM;
	}else if(info[index].left >= left && info[index].right <= right){
		return info[index].minimum;
	}else{
		return min(getMinimum(index*2+1,left,right),getMinimum(index*2+2,left,right));
	}
}

int main(){

	int Q,type,a,b;
	scanf("%d %d",&N,&Q);

	info = (Info*)malloc(sizeof(Info)*(4*N));
	for(int i = 0; i < 4*N; i++){
		info[i].minimum = NUM;
		info[i].left = info[i].right = -1;
	}
	index_table = new int[N];

	info[0].left = 0,info[0].right = N-1;

	func(0);

	for(int loop = 0; loop < Q; loop++){
		scanf("%d %d %d",&type,&a,&b);
		if(type == 0){
			update(a,b);
		}else{
			printf("%d\n",getMinimum(0,a,b));
		}
	}
	return 0;
}

Measured memory_bytes: 7780
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans = 0
for i  in range(n-2):
    a = l[i]
    for j in range(i+1,n-1):
        b = l[j]
        k = bisect_left(l,a+b)
        ans += k-j-1
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

/*-- template --*/

int main() {
    int A, B, C; cin >> A >> B >> C;
    int maxv = max(A, max(B, C));
    A = maxv - A, B = maxv - B, C = maxv - C;
    int ans = int((A) / 2) + int((B) / 2) + int((C)/2);
    A %= 2, B %= 2, C %= 2;
    if((A + B + C) % 2) {
        cout << ans + 2 << endl;
    }else if((A + B + C) == 0){
        cout << ans << endl;
    }else {
        cout << ans + 1 << endl;
    }
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

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

ll couFactor(ll n){
    ll cou=1;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            cou++;
            while(n%i==0){
                n/=i;
            }
        }
    }
    if(n!=1)cou++;
    return cou;
}

int main(){
    ios::sync_with_stdio(false);

    ll a,b;
    cin >> a >> b;
    ll c = gcd(a,b);

    cout << couFactor(c) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, a + b + 1) + b << endl;
}


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

int main() {
    ll X;
    cin >> X;
    for (ll A = -999; A <= 999; A++) {
        for (ll B = -999; B <= 999; B++) {
            if (pow(A, 5) - pow(B, 5) == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3984
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Z, W;
    cin >> N >> Z >> W;
    int a[2010];
    rep(i, N) cin >> a[i];
    int ans = abs(W - a[N - 1]);
    if (N == 1)
        cout << ans << endl;
    else
        cout << max({ans, abs(a[N - 1] - a[N - 2])}) << endl;




    return 0;
}


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

int main(void){
    int D,G;
    cin >> D >> G;
    vector<int> p;
    vector<ll> c;
    rep(i,D){
        int t1,t2;
        cin >> t1 >> t2;
        p.push_back(t1);
        c.push_back(t2);
    }
    ll res = 1 << 29;
    for(int bit=0;bit < (1<<D); ++bit){
        ll sum = 0;
        ll num = 0;
        // 全完する問題を決め打ち
        rep(i,D){
            if(bit & (1<<i)){
                sum += c[i] + p[i] * 100 * (i+1);
                num += p[i];
            }
        }
        // 点数がGより上回っている
        if(sum >= G) res = min(res,num);
        //点数が高い順にみていく
        else{
            for(int i=D-1; i >= 0; --i){
                // 既に決め打ちされていた場合
                if(bit & (1 << i)) continue;
                for(int j=0;j < p[i]; ++j){
                    if(sum >= G) break;
                    sum += 100 * (i+1);
                    num++;
                }
            }
            res = min(res,num);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624