akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

char t[30];
string s;
int is[30], i, j, c;

int main() {
scanf("%s", t);
s = t;
for (i=0;i<26;i++) is[i] = 0;
for (i=0;i<s.size();i++) is[int(s[i]) - 'a'] = 1;
for (i=0;i<26;i++) if (!is[i]) {
	s += char(i + 97);
	//printf("%d\n", i);
	printf("%s\n", s.c_str());
	return 0;
}
for (i=s.size() - 1;i>=0;i--) {
	c = int(s[i]) - 'a';
	for (j=c + 1;j<26;j++) if (!is[j]) {
		s = s.substr(0, i) + char(j + 97);
		printf("%s\n", s.c_str());
		return 0;
	}
	is[c] = 0;
}
printf("-1\n");
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#include <numeric>
using namespace std;
const int sz = 1e6+5;
ll int arr[sz], arr1[sz];
//ll int arr[100][100]= {0};
bool prime[sz]= {0};
vector <ll int> pr,vec1,vec2;
//vector <pair <int,int>> vec;

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

    for (ll int i=0;i<n;i++)
        cin>>arr[i];
    for(ll int i=0;i<m;i++)
        cin>>arr1[i];

    ll int i=0,j=0,s=0,t=0;

    while(i<n)
    {
        s+=arr[i];
        i++;
        if(s>k)
        {
            i--;
            s-=arr[i];
            break;
        }

    }
    t = i;
    while(j<m)
    {
        s+=arr1[j];
        j++;
        while(s>k && i>0)
        {
            i--;
            s-=arr[i];

        }

        if(s<=k)
            t = max(i+j,t);
    }

    cout<<t<<endl;




}


Measured memory_bytes: 6728
s=int(input())
if  s<3:print(0);exit()
n=s//3
mod=10**9+7
fact=[1]*(2*s+1)
inv=[1]*(2*s+1)
for i in range(2,2*s+1):
    fact[i]=i*fact[i-1]%mod
inv[-1]=pow(fact[-1],-1,mod)
for i in range(2*s,1,-1):
    inv[i-1]=inv[i]*i%mod
def comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0
ans=0
for i in range(1,s+1):
    ans=(ans+comb(s-3*i+i-1,i-1))%mod
print(ans)

Measured memory_bytes: 9284
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll A , V , B , W , T; cin >> A >> V >> B >> W >> T;
  if(V  > W){
    ll sa = abs(A - B);
    if((V - W) * T >= sa){
        cout << "YES" << endl;
        return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 3596
#include<iostream>

using namespace std;
int main(){
	
	int A[100], i, j, size, pos, n=0;
	
	while( cin >> size){
		
	for(i=0;i<size;i++){
		
	cin >> A[i];
	
	}
	for(i=0;i<size-1;i++){
		
	cout << A[i]  << " ";
	
	}	
	
	cout << A[size-1] << "\n";
	for(i=1;i<=size-1;i++)
	{
		pos = A[i];
		j = i - 1;
		
	while( j >= 0 && A[j] > pos ){
        A[j+1] = A[j];
        j--;
 		}
 		        A[j+1] = pos;
 	for(int k=0;k<size-1;k++){
	cout << A[k] << " " ;

	}
	cout << A[size-1] << "\n";

	}
	
	}
	return 0;
	}


Measured memory_bytes: 3088
from sys import stdin


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def factorization(a):
    if a < 2:
        return []
    fac = []
    lim = int(a ** 0.5)
    i = 2
    while a > 1 and i <= lim:
        n = 0
        while a % i == 0:
            a //= i
            n += 1
        if n > 0:
            fac += [(i, n)]
        i += 1
    if a > 1 or fac == []:
        fac += [(a, 1)]
    return fac


a, b = [int(x) for x in stdin.readline().split()]

print(len(factorization(gcd(a, b))) + 1)

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

int main(){
    int n, t, cnt = 0;
    cin >> n >> t;
    vector<int> cost(n),time(n);
    int minc = 10000;
    for (int i = 0; i < n; i++){
        cin >> cost.at(i) >> time.at(i);
        if (minc > cost.at(i) && t >= time.at(i))
            minc = cost.at(i);
        if(t>=time.at(i))
            cnt++;
    }
    if(cnt!=0&&minc<10000)
        cout << minc << endl;
    else
        cout << "TLE" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}



ll dp[21000];
main(){
    int h=in();
    int n=in();
    vec a,b;
    rep(i,n)a.pb(in()),b.pb(in());
    rep(i,h)dp[i]=1e13;
    dp[h]=0;
    rep3(i,h,0){
        rep(j,n){
            chmin(dp[i],dp[i+a[j]]+b[j]);
        }
    }
    cout<<dp[0]<<endl;
}


Measured memory_bytes: 384
let for_range s e step f =
  let rec loop i =
    if i <= e then begin f i;loop (i + step) end
  in loop s;;

let sieve num =
  let p = Array.make (num+1) 1 in
  let rec loop i =
    if i*i < num then
      begin
        if p.(i) = 1 then for_range (i*i) num (i*2) (fun x -> p.(x) <- 0);
        loop (i+2)
      end
  in
  p.(0) <- 0; p.(1)<-(0); for_range 4 num 2 (fun x -> p.(x) <- 0);loop 3;
  for i = 1 to num-1 do
    p.(i) <- p.(i) + p.(i-1);
  done;
  p
;;

let _ =
  let p = sieve 1000000 in
  let rec read () =
    try let n = read_int () in
        Printf.printf "%d\n" p.(n);
        read ()
    with End_of_file -> ()
  in read ()
;;

Measured memory_bytes: 10292
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
struct Edge { int to; ll cost; };
int n, m;
vector<Edge> g[100005];
ll dist[100005];
bool used[100005];

void bfs(int pos, ll cost, bool &f) {
  if(used[pos]) {
    if(dist[pos] != cost) f = false;
  } else {
    used[pos] = true;
    dist[pos] = cost;
    REP(i, g[pos].size()) {
      Edge e = g[pos][i];
      bfs(e.to, cost + e.cost, f);
    }
  }
}

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

  cin >> n >> m;

  REP(i, m) {
    int l, r, d;
    cin >> l >> r >> d;
    g[l].push_back(Edge {r, d});
    g[r].push_back(Edge {l, -d});
  }

  REP(i, n + 1) dist[i] = LLINF;

  bool f = true;
  FOR(i, 1, n + 1) {
    if(!used[i]) {
      bfs(i, 0LL, f);
    }
  }

  cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 17536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
const int N = 2*1e5 + 10;
const int oo = 3*1e5;
const int mod = 1e9 + 7;
int n, a[N], up[N];
signed main()
{
	//freopen("test.txt", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i]; 
	}	
	a[0] = -1;
	for(int i = 1; i <= n; ++i) if(a[i] > a[i - 1] + 1)	{
		cout << "-1"; return 0;
	} 
	for(int i = 1; i <= n; ++i)		{
		up[i - a[i] + 1] = a[i];
	}
	int sum = 0ll;
	for(int i = 1; i <= N; ++i) sum += up[i];
	cout << sum; 
}

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll K, X; cin>>K>>X;
    for(ll i=X-K+1; i<=X+K-1; i++){
        if(i!=X-K+1) cout << " ";
        cout << i;
    }
    cout << endl;
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

const int MOD = 998244353;

void Main(){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    
    /*
    i 行 j 列のマス目であって一番上の行に黒く塗られたマスが

    複数: dp[i][j][2] = (dp[i][j-1][2]) * i + dp[i][j-1][1]
    1個: dp[i][j][1] = (dp[i-1][j][0] + dp[i-1][j][1] + dp[i-1][j][2]) * j
    0個: dp[i][j][0] = dp[i][j-1][0] * (i-1)
    */

    ll dp[c+1][d+1][3];
    dp[a][b][2] = 0;
    dp[a][b][1] = 0;
    dp[a][b][0] = 1;
    
    for(ll i = a; i <= c; i++){
        for(ll j = b; j <= d; j++){
            if(i == a && j == b) {;}
            else if(i == a){
                dp[i][j][2] = (dp[i][j-1][2] * i) % MOD;
                dp[i][j][2] = (dp[i][j][2] + dp[i][j-1][1]) % MOD; 
                dp[i][j][1] = (dp[i][j-1][1] * (i-1)) % MOD;
                dp[i][j][1] = (dp[i][j][1] + dp[i][j-1][0]) % MOD;
                dp[i][j][0] = (dp[i][j-1][0] * (i-1)) % MOD;
            }
            else if(j == b){
                dp[i][j][2] = 0; 
                dp[i][j][1] = (((dp[i-1][j][0] + dp[i-1][j][1]) % MOD) * j) % MOD;
                dp[i][j][0] = 0;
            }else{
                if(j - 1 >= b) dp[i][j][2] = (((dp[i][j-1][2] * i) % MOD) + dp[i][j-1][1]) % MOD;
                if(i - 1 >= a) dp[i][j][1] = ( ( ( ( (dp[i-1][j][0] + dp[i-1][j][1]) % MOD) + dp[i-1][j][2]) % MOD) * j) % MOD;
                if(j - 1 >= b) dp[i][j][0] = (dp[i][j-1][0] * (i-1)) % MOD;
            }
            // cout << i << ", " << j << ": " << dp[i][j][0] << " " << dp[i][j][1] << " " << dp[i][j][2] << endl;
        }
    }
    ll ans = (dp[c][d][0] + dp[c][d][1]) % MOD;
    ans = (ans + dp[c][d][2]) % MOD;
    cout << ans << endl;
    return;
}

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

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

int main(){
  int n;
  cin >> n;
  for(int i=0; i<26; i++){
    for(int j=0; j<15; j++){
      if((4*i+7*j)==n){cout << "Yes" << endl; return 0;}
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,m,s=0;
    cin>>n;
    m=n;
    while(m){
        int a=m%10;
        s+=a;
        m/=10;
    }
    if(n%s==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;

int main(void) {
    int a, b;
    cin >> a >> b;
    ans = a*b;



  
    cout << ans << "\n";
    return 0;
}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int calc(int ab, int b, int a) {
    int ret = 0;
    if (ab) {
        ret += ab - 1;
        ab = 1;
    }

    if (ab && b) {
        b--;
        ret++;
    }

    if (ab && a) {
        a--;
        ret++;
    }

    ret += min(b, a);
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<string> s(N);

    map<int, int> mp;
    int ans = 0;
    rep(i, N) {
        string s;
        cin >> s;
        rep(i, s.size() - 1) {
            if (s[i] == 'A' && s[i + 1] == 'B') ans++;
        }
        bool beginB = s[0] == 'B';
        bool endA = s[s.size() - 1] == 'A';
        if (beginB && endA) {
            mp[0]++;
        } else if (beginB) {
            mp[1]++;
        } else if (endA) {
            mp[2]++;
        }
    }

    ans += calc(mp[0], mp[1], mp[2]);
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n;
unsigned long long x[1000];
unsigned long long gcd(unsigned long long a,unsigned long long b)
{
	if(a%b==0)return b;
	else return gcd(b,a%b);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>x[i];
	for(int i=2;i<=n;i++)
	{
		x[i]=x[i]/gcd(x[i],x[i-1])*x[i-1];
	}
	cout<<x[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
z = input().split()
a = int(z[0])
b = int(z[1])
c = int(z[2])
k = int(z[3])
if(1 <= k <= a+b+c <= 2*(10**9)):
    if(k <= a):
        print(k)
    elif(k <= a+b):
        print(a)
    else:
        print(a - (k-(a+b)))
else:
    print('err')


Measured memory_bytes: 79604
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int h , n , sum =0;
   cin >> h >> n;
   while(n--){
      int x;
      cin >> x;
      sum += x;
   }
   cout << (sum >= h ? "Yes" : "No") << "\n";
}

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

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

  vector<int> A(M);
  int Sum = 0;
  rep( i, 0, M ) {
    cin >>A.at(i);
    Sum += A.at(i);
  }

  int Ans = N-Sum;
  cout << ( 0<=Ans ? Ans : -1 ) << endl;
}


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

int main(){
	int K; cin >> K;
	int a = K%10;
	if( a == 3 ){ cout << "bon" << endl; }
	else if( a==0 || a==1 || a==6 || a==8){ cout << "pon" << endl; }
	else{ cout << "hon" << endl; }
	return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = System.Console.ReadLine().Trim().Split(' ');
            List<int> lstInp = new List<int>();
            for (int i = 0; i < sS.Length; i++) { lstInp.Add(int.Parse(sS[i])); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            for (int i = 1; i < lstInp.Count - 1; i++)
            {
                if ( ((lstInp[i - 1] < lstInp[i + 0]) || (lstInp[i + 1] < lstInp[i + 0])) &&    //  真ん中がどっちかより大きい
                    !((lstInp[i - 1] < lstInp[i + 0]) && (lstInp[i + 1] < lstInp[i + 0])))      //  但し両方より大きくてはダメ
                { iOut += 1; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    char c[n];
    int MIN=0,MAX=0,ne,po,pu=0,mai=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a>=0){c[i]='+';pu++;}
        else {c[i]='-';mai++;}
        if(MIN>=a){
            MIN=a;
            ne=i+1;
        }
        if(MAX<=a){
            MAX=a;
            po=i+1;
        }
    }
    if(abs(MIN)<=abs(MAX)){
        cout<<n+mai<<endl;
        for(int i=0;i<n;i++){
            cout<<po<<" "<<i+1<<endl;
            if(c[i]=='-')cout<<po<<" "<<i+1<<endl;
            po=i+1;
        }
    }
    else{
        cout<<n+pu<<endl;
        for(int i=n;i>0;i--){
            cout<<ne<<" "<<i<<endl;
            if(c[i-1]=='+')cout<<ne<<" "<<i<<endl;
            ne=i;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
    if(u==NIL) return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u){
    if(u==NIL) return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}

void postParse(int u){
    if(u==NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int v,l,r,root;
    cin>>n;
    REP(i,n){
        T[i].p = NIL;
    }
    REP(i,n){
        cin>>v>>l>>r;
        T[v].l = l;
        T[v].r = r;
        if(l!=NIL) T[l].p = v;
        if(r!=NIL) T[r].p = v;
    }
    REP(i,n) if(T[i].p==NIL) root = i;

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
}



Measured memory_bytes: 3228
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

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

int main() {
    int A, B;
    cin >> A >> B;
    if (A % B == 0) {
        cout << A / B << endl;
    }
    else {
        cout << A / B + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	string s, t; cin >> s >> t;
	int cnt = 0;
	for( int i = 0; i < 3; ++i ){
		if( s[i] == t[i] ) ++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
// 72 72 72 72 72 72 72 72 72 72 72
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e17;                                                                                                  
ll mpow(ll a,ll b){a=a%MOD;ll res=1;while(b>0){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b=b>>1;}return res%MOD;}             

int main()
{ 
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt", "r", stdin);
///freopen("output.txt","w",stdout);
ll n,k;
cin>>n>>k;
ll a[n];
forn(i,n) cin>>a[i];
cout<<(n-1+k-2)/(k-1);
return 0;    
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

int N;

// Primes begin
class Primes {
 public:
  int n;
  vector<int> nthp;
  vector<bool> isp;

  Primes(int n) : n(n), nthp(), isp(n+1) {
    FOR(i, 0, 1) { isp[i] = false; }
    FOR(i, 2, n) { isp[i] = true; }
    FOR(i, 2, n) {
      if (isp[i]) {
        nthp.push_back(i);
        for (int j = i+i; j <= n; j += i) { isp[j] = false; }
      }
    }
  }
};
// Primes end


signed main() {
  cin >> N;
  Primes p(55555);

  int c = 0;
  for (int i = 2; c < N; ++i) {
    if (p.isp[i] && i%5 == 1) {
      if (c != 0) { cout << " "; }
      cout << i;
      ++c;
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<int>cntS[26];
vector<int>cntT[26];
signed main() {
    string S,T;
    cin >> S >> T;
    for(int i = 0; i < S.size(); i++) {
        cntS[S[i]-'a'].push_back(i);
        cntT[T[i]-'a'].push_back(i);
    }
    bool ok = true;
    for(int i = 0; i < 26; i++) {
        if(cntS[i].size() == 0) {
            continue;
        }
        if(cntS[i].size() != cntT[T[cntS[i][0]]-'a'].size()) {
            ok = false;
        }
        else {
            for(int j = 0; j < cntS[i].size(); j++) {
                if(cntS[i][j] != cntT[T[cntS[i][0]]-'a'][j]) {
                    ok = false;
                }
            }
        }
    }
    if(ok) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 7648
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    vec(a,n);
    input(a,n);
    int ans = 0;
    REP(i,n){
        FOR(j,i+1,n){
            ans += a[i]*a[j];
        }
    }
    print(ans);
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 256
from collections import deque
import heapq

N = int(input())

gr = [None] * N
child = [0] * N
dic = {}

q = []


for i in range(N-1):

    x,y = map(int,input().split())
    x -= 1
    y -= 1

    if x not in dic:
        dic[x] = []
    if y not in dic:
        dic[y] = []

    dic[x].append(y)
    dic[y].append(x)
    child[x] += 1
    child[y] += 1

dep = [float("inf")] * N
dep[0] = 0
dq = deque([0])
while len(dq) > 0:
    n = dq.popleft()

    for i in dic[n]:
        if dep[i] > dep[n] + 1:
            dep[i] = dep[n] + 1


for i in range(N):

    if child[i] == 1:
        child[i] = 0
        gr[i] = 0
        heapq.heappush(q,[-1 * dep[i] , i])

while len(q) > 0:

    ngr = 0
    no = heapq.heappop(q)
    now = no[1]

    for i in dic[now]:
        if gr[i] != None:
            ngr ^= (gr[i] + 1)
        else:
            child[i] -= 1

            if child[i] <= 1 and gr[i] == None:
                heapq.heappush(q,[-1 * dep[i] , i])

    gr[now] = ngr

#print (gr)

if gr[0] == 0:
    print ("Bob")
else:
    print ("Alice")

Measured memory_bytes: 92760
function main()
    N, M = [parse(Int, s) for s in split.(readline())]
    edges = [Int[] for _ in 1:N]
  	for i in 1:M
        a, b = [parse(Int, s) for s in split.(readline())]
        push!(edges[a], b)
        push!(edges[b], a)
    end

    visited = falses(N)
    to_room = zeros(Int, N)
  
  	q = zeros(Int, N)
    q[1] = 1
    visited[1] = true
  	qs = 1
    qe = 2
    while qs != qe
        pos = q[qs]
        qs += 1
        for topos in edges[pos]
            visited[topos] && continue
            visited[topos] = true
            to_room[topos] = pos
            q[qe] = topos
            qe += 1
        end
    end
    if !all(visited)
        println("No")
        return
    end

    println("Yes")
    for i in 2:N
        println(to_room[i])
    end
end

main()


Measured memory_bytes: 230496
#include <cstdio>

#define ll long long

template<class T>void fr(T &a) {
    T s=0,w=1;char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=w*s;
}
template<class T>T fr() {T a;fr(a);return a;}
#define R() fr<ll>()

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

int main() {
	ll a=R(),b=R();
	return !printf("%lld\n",lcm(a,b));
}

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

int main(){


	int a, b, d, r;
	double f;

	scanf("%d %d",&a, &b);


	d = a/b;

    r = a%b;

    f = (double)a/(double)b;

	printf("%d %d %f\n", d, r, f);
fflush(stdin);

return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define PI 3.1415926535
typedef long long int ll;
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  double a,b,c,x,h;
  scanf("%lf %lf %lf",&a,&b,&x);
  if(x>a*a*b/2){
    x=a*a*b-x;
    c=x/(a*a/2);
    h=c/a;
    PRF(atan(h)*180/PI);
  }else{
    c=x/(a*b/2);
    h=b/c;
    PRF(atan(h)*180/PI);
  }
  return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
x = [0]*N

S = sum(A)
sA = 0
for i in range(1,N,2):
    sA +=A[i]
x[0] = S - 2*sA
print(x[0],end=" ")

for i in range(N-1):
    x[i+1] = 2*A[i]-x[i]
    print(x[i+1],end=" ")
print("")

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

//counterの値を親から子に伝搬させる
void dfs(int vertex, int parent, 
    vector<vector<int> >& Tree, vector<int>& counter){

  //根でないなら親のカウンターの値を足し合わせる
  if(parent != -1)counter[vertex] += counter[parent];

  //子に伝播させる
  for(const int &nxtv : Tree[vertex]){
    if(nxtv == parent)continue;
    dfs(nxtv, vertex, Tree, counter);
  }
}

int main(void){
  int N,Q;
  cin >> N >> Q;
  //木
  vector<vector<int> > Tree(N);
  //頂点のカウンター
  vector<int> counter(N,0);
  //木の構築
  for(int i = 0; i < N-1; ++i){
    int a,b;
    cin >> a >> b;
    --a;--b;
    Tree[a].push_back(b);
    Tree[b].push_back(a);
  }

  //カウンターの加算
  for(int j = 0; j < Q; ++j){
    int p,x;
    cin >> p >> x;
    --p;
    counter[p] += x;
  }

  //カウンターの伝搬
  dfs(0,-1,Tree,counter);

  //出力
  for(int i = 0; i < N; ++i){
    cout << counter[i] << " ";
  }
  cout << endl;
  return 0;
}


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

using namespace std;

void Main() {
    string s;
    cin >> s;
    string ans = "";
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) {
            ans += s.substr(i, 1);
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
string s;
int k=-1,k0=-1;
char m='R';
int a[100000];
int main()
{
	cin>>s;
	for (int i=0;;)
	{
		m='L';
		bool b=1;
		int ii=i;
		for (int j=i+1;j<s.size()&&b;j++)
		{
			if (s[j]==m) 
				k0=j,b=0; 
		}
		m='R';
		b=1;
		for (int j=k0+1;j<=s.size()&&b;j++)
		{
			if (j==s.size())
			    k=s.size();
            else			    
			if (s[j]==m) 
				k=j,b=0; 
		}
		a[k0]=(k0-i)/2+k-k0-(k-k0)/2;
		a[k0-1]=-(k0-i)/2+k0-i+(k-k0)/2;
		if (k==s.size()) 
		{
			
	      for (int j=0;j<s.size();j++)
	      {
		    printf("%d%c",a[j]," \n"[j==s.size()-1]);
	      }
	      exit(0);
		}
		i=k;
	}
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define debug(var) do{cout << #var << " : "; print(var); } while(0)
using namespace std;
typedef long long ll;
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); }
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }
const int INF = 1e9;
const int MOD = 1e9+7;

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

	string S, T; cin >> S >> T;
	int A, B; cin >> A >> B;
	string U; cin >> U;
	if (S==U) A--;
	else B--;

	cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	int h, w;

	cin >> h >> w;
	
	if(h == 1 || w == 1) return cout << 1 << '\n', 0;
	cout << (1LL * h * w + 1) / 2 << '\n';

	return 0;
}



Measured memory_bytes: 256
class Integer
  def combination(k)
    return 1 if k.zero?

    (self - k + 1..self).inject(:*) / k.factorial
  end

  def factorial
    return 1 if self.zero?

    (1..self).inject(:*)
  end
end

N, A, B = gets.split.map(&:to_i)
goods = gets.split.map(&:to_i).sort.reverse
counter = Hash.new(0)

goods.each do |g|
  counter[g] += 1
end

max_list = goods.take(A)
max_average = Rational(max_list.inject(:+), A.to_f)

pattern_count = 0

(A..B).each do |k|
  list = goods.take(k)
  val = Rational(list.take(k).inject(:+), k)
  next if max_average > val

  remain = k
  cnt = 1

  list.uniq.each do |m|
    if counter[m] > remain
      cnt *= counter[m].combination(remain)
    else
      remain -= counter[m]
    end
  end

  pattern_count += cnt
end

puts "%4.6f" % max_average
puts pattern_count


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    vector<int> v(3);
    for (int i = 0; i < 3; i++) cin >> v[i];
    int k;
    cin >> k;
    int t = 0;
    for (int i = 0; i < 2; i++) {
        while (v[i] >= v[i+1]) {
            v[i+1] *= 2;
            t++;
        }
    }
    if (t <= k) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 3624
from collections import defaultdict

n, k = [0] * 2
a = []

def format_input(filename = None):
	global n, k
	global a
	if filename == None:
		n, k = list(map(int, input().split()))
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(2, 2 * 10**5)
		k = rng(1, 10**18)
		a = [rng(1, n) for i in range(n)]
		print(n, k)
		print(' '.join(list(map(str, a))))

def get_answer():
	loop = [1]
	loop_index = defaultdict(int)
	start = -1
	while start == -1 and len(loop) < k + 1:
		node = a[loop[-1]-1]
		if loop_index[node] > 0:
			start = loop_index[node]
		elif node == 1:
			start = 0
		else:
			loop.append(node)
			loop_index[node] = len(loop) - 1

	l = len(loop)
	if k >= l:
		answer = loop[(k - l) % (l - start) + start]
	else:
		answer = loop[k]

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 33928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

vector<vector<P>> g;
bool use[100];
ll n, m, a, b, u, v, dp[51][(1LL << 20)];;

bool dfs(ll at, ll from, ll goal){
	if(goal == at){
		return true;
	}
	zep(i, 0, g[at].size()){
		if(g[at][i].first != from){
			use[g[at][i].second] = true;
			if(dfs(g[at][i].first, at, goal)){
				return true;
			}
			use[g[at][i].second] = false;
		}
	}
	return false;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	//vector<vector<P>> g;
	g.resize(n+1);
	rep(i, 1, n-1){
		cin >> a >> b;
		g[a].push_back(P(b, i));
		g[b].push_back(P(a, i));
	}
	cin >> m;
	set<ll> c[m];
	zep(i, 0, m){
		cin >> u >> v;
		memset(use, 0, sizeof(use));
		dfs(u, -1, v);
		//printa(use, 1, n-1)
		rep(j, 1, n-1){
			if(use[j]){
				c[i].insert(j);
			}
		}
	}
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	rep(i, 1, n-1){
		ll job = 0LL;
		zep(j, 0, m){
			if(c[j].find(i) != c[j].end()){
				job |= (1LL << j);
			}
		}
		//print(job)
		zep(bit, 0, (1LL << m)){
			dp[i][bit] += dp[i-1][bit];
			dp[i][bit|job] += dp[i-1][bit];
		}
		//printa(dp[i], 0, (1LL << m)-1)
	}
	//print((1LL << m)-1)
	print(dp[n-1][(1LL << m)-1])
	return 0;
}

Measured memory_bytes: 418048
#include<bits/stdc++.h>
using namespace std;
int n,a[3][101];
int main()
{
    cin>>n;
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)
            cin>>a[i][j];
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)
        	a[i][j]+=max(a[i-1][j],a[i][j-1]);
	cout<<a[2][n]<<endl;
	return 0;
}

Measured memory_bytes: 256
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
INF = 10**18

A,B,Q=rl()
s = [-INF] + rr(A) + [INF]
t = [-INF] + rr(B) + [INF]
X= rr(Q)

import bisect
for x in X:
    s_i = bisect.bisect_left(s,x)
    t_i = bisect.bisect_left(t,x)
    s_l = x-s[s_i-1]
    s_r = s[s_i]-x
    t_l = x-t[t_i-1]
    t_r = t[t_i]-x
    ans = min(
        max(s_l,t_l), s_l+t_r+min(s_l,t_r), s_r+t_l+min(s_r,t_l), max(s_r,t_r)
    )
    print(ans)

Measured memory_bytes: 16128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int m = reader.nextInt();
        int max = reader.nextInt();
        int min = reader.nextInt();
        int in;
        for (int i = 0; i < n; ++i) {
            in = reader.nextInt();
            if (in > max)
                max = in;
        }
        for (int i = 0; i < m; ++i) {
            in = reader.nextInt();
            if (in < min)
                min = in;
        }
        System.out.println(min > max ? "No War" : "War");

    }
}

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

ll cnt;

void merge(int *A, int left, int mid, int right)
{
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	int *L = new int[n1 + 1];
	int *R = new int[n2 + 1];
	for (i = 0; i < n1; i++)
		L[i] = A[left + i];
	L[i] = INT_MAX;
	for (i = 0; i < n2; i++)
		R[i] = A[mid + i];
	R[i] = INT_MAX;
	for (i = 0, j = 0, k = left;
		k < right; k++)
	{
		if (L[i] < R[j]) {
			A[k] = L[i];
			i++;
			cnt += j;
		} else {
			A[k] = R[j];
			j++;
		}
	}
	delete[] L;
	delete[] R;
}

void mergeSort(int *A, int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(void) 
{
	cnt = 0;
	int n, *A, i;
	cin >> n;
	A = new int[n];
	for (i = 0; i < n; i++) {
		cin >> A[i];
	}
	mergeSort(A, 0, n);
	cout << cnt << endl;
	delete[] A;
}


Measured memory_bytes: 4316
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a,b,c,d;
	while(sc.hasNextInt()){
	    a=sc.nextInt();
	    b=sc.nextInt();
	    c=a+b;
	    d=0;
	    while(c>0)
		{
		    c/=10;
		    d++;
		}
	    System.out.println(d);
	}
    }
}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
int main(){
    //??????
    int matrix[100][100];
    int b_vector[100];
    int c_vector[100];
    int n,m;

    
    //??\???
    cin>>n>>m;
    for (int i = 0; i < n ; ++i) {
        for (int j = 0; j < m; ++j) {
            cin>>matrix[i][j];
        }
    }
    for (int i = 0; i < m ; ++i) {
        cin>>b_vector[i];
    }

    //?????????
    for (int i = 0; i < n ; ++i) {
        int sum = 0;
        for (int j = 0; j < m; ++j) {
            sum += matrix[i][j]*b_vector[j];
        }
        c_vector[i] =  sum;
    }

    //??????
    for (int i = 0; i < n ; ++i) {
    cout<<c_vector[i]<<endl;
    }
}

Measured memory_bytes: 1200
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    N = get_ln_int_inputs()[0]
    p = get_ln_int_inputs()

    arranged_terms = set()
    for i in range(N):
        if p[i] == i + 1:
            arranged_terms.add(i)

    swaps = 0

    double_arranged = set()
    for arranged_term in arranged_terms:
        if (arranged_term + 1) in arranged_terms and (not (arranged_term - 1) in double_arranged):
            double_arranged.add(arranged_term)
    
    single_arranged = set()
    for arranged_term in arranged_terms:
        if not (arranged_term in double_arranged or (arranged_term - 1) in double_arranged):
            single_arranged.add(arranged_term)

    print(len(double_arranged) + len(single_arranged))

main()

Measured memory_bytes: 17336
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int K = in.nextInt();
			int X = in.nextInt();
			for(int i = X - K + 1; i <= X - 1; i++) {
				out.print(i + " ");
			}
			for(int i = X; i <= X + K - 1; i++) {
				out.print(i + " ");
			}
			out.println();
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 21460
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

S = si()

if S == "ABC":
    print('ARC')
else:
    print('ABC')

Measured memory_bytes: 65332