akhauriyash/Code-Regression huggingface dataset:
c = [map(int, raw_input().split()) for _ in range(3)]
a = [0]*3
b = [0]*3
b[0] = c[0][0]-a[0]
b[1] = c[0][1]-a[0]
b[2] = c[0][2]-a[0]
a[1] = c[1][0]-b[0]
a[2] = c[2][0]-b[0]
ans = "Yes"
for i in range(3):
  for j in range(3):
    if c[i][j] != a[i]+b[j]:
      ans = "No"
print ans


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define int ll
#define Endl endl

signed main(){
    int N,K;
    string S;
    cin >> N >> K;
    cin >> S;
    S[K-1]=(S[K-1]-'A'+'a');
    cout << S << endl;
    
    return 0;
}

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

#define iso ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll int
#define pll pair<ll,ll>
#define mod 1000000007

int main(){
	int n,r,ans;
	cin>>n;

	r = n%1000;
	ans = 1000-r;
	cout<<ans%1000<<endl;
}

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

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }



#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

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

  int N, K;
  cin >> N >> K;

  vector<int> a;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if(x < K) a.push_back(x);
  }

  int n = a.size();
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  auto dp = make_2d_vector(n+1, K+1, false);
  dp[0][0] = true;
  for(int i = 1; i <= n; i++) {
    for(int j = 0; j <= K; j++) {
      if( a[i-1] <= j ) {
        dp[i][j] = dp[i-1][j] || dp[i-1][j-a[i-1]];
      } else {
        dp[i][j] = dp[i-1][j];
      }
    }
  }

  // for(int i = 1; i <= n; i++) {
  //   for(int j = 0; j <= K; j++) {
  //     cout << dp[i][j];
  //   }
  //   cout << "\n";
  // }


  int last_needed = 0;
  for(int i = 1; i <= n; i++) {
    for(int j = K - a[i-1]; j < K; j++) {
      if( dp[i-1][j] ) {
        last_needed = i;
        break;
      }
    }
  }

  cout << n - last_needed << "\n";

  return 0;
}


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

int main()
{
    int x;
    rep(i, 5) {
        cin >> x;
        if(x == 0) {
            cout << i+1 << endl;
            break;
        } else {
            continue;
        }
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
int a[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	int x=a[0];
	for(int i=1;i<n;i++)
		x=x^a[i];
	if(x==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
# 2次元配列を作る
array = [[0] * N] * 2
array[0] = list(map(int, input().split()))
array[1] = list(map(int, input().split()))
# 全探索する
# N回移動できる
# どのタイミングで下に移動するかがキーポイント
# 下に移動するタイミングはN通りある
max_candy = 0
for n in range(N):
    # n列目で下に移動したときのキャンディの個数をチェック
    total = sum(array[0][: n + 1]) + sum(array[1][n:])
    # 記録更新なら上書き
    if max_candy < total:
        max_candy = total
print(max_candy)


Measured memory_bytes: 3060
#include<stdio.h>

int main() {
	char str[128];
	bool c = false;
	
	scanf("%s",str);
	
	for(int i=0;str[i];i++) {
		if(!c) {
			if(str[i] == 'C') {
				c = true;
			}
		}
		else if(str[i] == 'F') {
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <bitset>
#include <random>
#include <stack>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <ctime>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sc second
#define fs first
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<class T> T sqr(T x) { return x*x; }
ld pi = 3.1415926535897932384626433832795;
ll mod = 1e9 + 7;
const int N = 1e5 + 10;

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

ll a[N];



int main() {
	a[1] = 1;
	for (int i = 2; i < N; i++)
		a[i] = (a[i - 1] * i) % mod;
	a[0] = 1;
	int n, m;
	cin >> n >> m;
	if (abs(n - m) > 1)
		cout << 0;
	else {
		ll ans = 1;
		if (n - m == 0)
			ans *= 2;
		ans = (ans*a[n]) % mod;
		ans = (ans*a[m]) % mod;
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main()
{
    char a[11],b[11],c[11];
    int a1,b1,c1;
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    a1=strlen(a)-1;
    b1=strlen(b)-1;
    c1=strlen(c)-1;
    if(a[a1]==b[0] && b[b1]==c[0])
        printf("YES");
    else
        printf("NO");

    return 0;

}


Measured memory_bytes: 128
N,K = map(int,input().split())
p = list(map(int,input().split()))
R = [0]*(N+1)
ans = 0
for i in range(1,N+1):
    X = p[i-1]
    R[i] = R[i-1] + (X*(X+1))/2/X
    if i+1 >= K:
        ans = max(ans,R[i]-R[i-K])

print(ans)


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

int main(){
    while (1 > 0){
        int w,h;
        cin >> w >> h;
        if (w == 0 && h == 0){
          break;
        }
        for ( int i = 0; i < w; i++){
            for (int j = 0; j < h; j++){
                if (0 < i && i < w - 1 && 0 < j && j < h - 1){
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

int main(){
    int N;
    cin >> N;
    map<string, int> bucket;
    int64_t ans = 0;
    for(int i = 0;i < N;i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        ans += bucket[s];
        bucket[s] ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, x, i, t, dist=0, cont=0;;
    scanf("%d%d", &n, &x);
    if(dist<=x){
        cont++;
    }
    for(i=0; i<n; i++){
        scanf("%d", &t);
        dist+=t;
        if(dist<=x){
            cont++;
        }
    }
    printf("%d\n", cont);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1e18;

long long Bellman_Ford(const vector<vector<pair<long long,int>>> &G){
  int N = G.size();
  vector<long long> D(N,-INF);
  D[0] = 0;
  int t = N+1;
  bool f = false;
  while(t--){
    long long prev_d = D[N-1];
    f = false;
    for(int i = 0; i < N; ++i){
      for(size_t j = 0; j < G[i].size(); ++j){
        int v = G[i][j].second;
        long long c = D[i] + G[i][j].first;
        D[v] = max(D[v],c);
      }
    }
    f = (prev_d != D[N-1]);
  }
  if(f) return INF;
  return D[N-1];
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<pair<long long,int>>> G(N);
  for(int i = 0; i < M; ++i){
    int u, v, w;
    cin >> u >> v >> w;
    G[u-1].emplace_back(w,v-1);
  }
  long long ans = Bellman_Ford(G);
  if(ans == INF) cout << "inf" << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int t=0,ao=0;
    if(c%b!=0)t++;
    if(a%d!=0)ao++;
    t+=c/b;
    ao+=a/d;
    if(t<=ao)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

inline ll mypwn(ll x, ll n) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return mypwn(x * x % mod, n / 2);
  else
    return x * mypwn(x, n - 1) % mod;
}

inline int madd(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline int msub(int x, int y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
inline int mmul(int x, int y) { return 1ll * x * y % mod; }

const int MAX = 2 * 1e5 + 5;
ll finv[MAX], inv[MAX];

void initComb() {
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  srep(i, 2, MAX) {
    inv[i] = mod - inv[mod%i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
ll comb(ll n, ll k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  ll ret = 1;
  rep(i, k) ret = mmul(ret, n-i);
  return mmul(ret, finv[k]);
}

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

  int n, a, b; std::cin >> n >> a >> b;
  if (n == 2) {
    std::cout << '0' << "\n";
    return 0;
  }
  ll ans = mypwn(2, n) - 1;
  initComb();
  ans = msub(ans, comb(n, a));
  ans = msub(ans, comb(n, b));
  std::cout << ans << "\n";
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int n,i,j,e;
long long c;
int main(){
  cin>>n;
  vector<int> a(n+1);
  vector<int> b(n);
  for(;i<n+1;i++)cin>>a[i];
  for(i=0;i<n;i++)cin>>b[i];
  for(i=0;i<n;i++){
    int r=min(a[i],b[i]);
    c+=r;
    a[i]-=r;
    b[i]-=r;

    int l=min(a[i+1],b[i]);
    a[i+1]-=l;
    b[i]-=l;
    c+=l;
  }
  cout<<c;
}

Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String S =sc.next();
      int s =S.length();
      int b =0;
       
      for(int i=0; i<s/2; i++){
        if(S.charAt(i)!=S.charAt(s-i-1)){
        b++;
      }
      }
      System.out.print(b);
    }
}

Measured memory_bytes: 23892
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    double l;
    cin >> l;

    printf("%.10f\n", pow((l / 3.0), 3.0));

    return 0;
}


Measured memory_bytes: 3548
#include<stdio.h>

int kuku(int i, int j){
	int answer;
	answer = i * j;
	return answer;
}

int main(){
	int i, j, answer;
	for(i = 1; i <= 9; i++){
		for(j = 1; j <= 9; j++){
			answer = kuku(i, j);
			printf("%dx%d=%d\n", i, j, answer);
		}
	}
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string n,s;
	cin>>n>>s;
	for(int i=0;i<n.size();i++)
	{
		if(n[i]!=s[i])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3608
n=int(input())
a = [int(input()) for _ in range(n)]
a_max=max(a)
a_max2=sorted(a)[-2]
if a_max!=a_max2:
  for i in range(n):
    if a[i]!=a_max:
      print(a_max)
    else:
      print(a_max2)
else:
  for i in range(n):
    print(a_max)

Measured memory_bytes: 13404
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = sc.nextInt();
		if (A <= X && A + B >= X) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int n;
pair<int,int>p[233333];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int a;scanf("%d",&a);
        p[i]=make_pair(a,i);
    }
    sort(p+1,p+n+1);
    for(int i=1;i<=n;i++)printf("%d ",p[i].second);
}

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


int main(){

  int n;
  cin>>n;
  string s1,s2;
  cin>>s1>>s2;
  bool b[n];
  REP(i,n){
    if(s1[i]==s2[i]){
      b[i] = false;
    }else{
      b[i] = true;
    }
  }
  ll ans = 1;
  
  int i = 0;
  while(i<n){
    if(i==0){
      if(b[i] ==false){
        ans = ans*3%MOD;
        i++;
      }else{
        ans = ans*3*2%MOD;
        i += 2;
      }
    }else{
      if(b[i] == false){
        if(b[i-1] == false){
          ans = ans*2%MOD;
        }
        i++;
      }else{
        if(b[i-1] == false){
          ans = ans*2%MOD;
        }else{
          ans = ans*3%MOD;
        }
        i += 2;
      }
    }
  }
  cout<<ans<<endl;
  
  
  return 0;
}

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

char M[110][110];
bool hangok[110]={0},lieok[110]={0};

int main()
{
    int m,n;cin>>m>>n;
    rep(i,0,m)
    {
        cin>>M[i];
        rep(j,0,n)
        {
            if(M[i][j]=='#')
            {
                hangok[i]=1;lieok[j]=1;
            }
        }
    }
    rep(i,0,m)
    {
        if(!hangok[i]) continue;
        rep(j,0,n)
        {
            if(lieok[j])printf("%c",M[i][j]);
        }
        printf("\n");
    }
    return 0;
}


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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a[2];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	if(a[0]==a[1] && a[0]==5 && a[2]==7) cout << "YES";
	else cout << "NO";
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int ans=0;
	for(int i=a;i<=b;i++) {
		int x=i;
		int c=x%10;
		x/=10;
		int d=x%10;
		x/=10;
		x/=10;
		int f=x%10;
		x/=10;
		int g=x%10;
		if(c==g&&d==f) {
			ans++;
		}
	}
	System.out.println(ans);
	scan.close();
}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int a,b;
  cin>>a>>b;
  string ans="No";
  if(a*b%2==1)ans="Yes";
  cout(ans);

  return 0;
}

Measured memory_bytes: 125568
#include <stdio.h>
#include <string.h>


int main(void){
    int year, month, day;
    scanf("%d/%d/%d", &year, &month, &day);
    if(year < 2019){
        printf("Heisei\n");
    }
    else if(year == 2019){
        if(month <= 4){
            printf("Heisei\n");
        }
        else{
            printf("TBD\n");
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lim 100005
#define pb push_back
#define S second
#define pb push_back
#define mp make_pair
#define INF LLONG_MAX
#define fr(i,j,k) for(ll i=j;i<=k;i++)
#define frd(i,j,k) for(ll i=j;i>=k;i--)
#define F first
#define sd(n) scanf("%lld",&n)
#define pd(n) printf("%lld\n",n)
#define db double
#define pii pair<ll,ll>
#define mod 1000000007
int main()
{
	ll x;
	cin>>x;
	if(x<1200)
		cout<<"ABC"<<endl;
	else cout<<"ARC"<<endl;
}

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

int main()
{
	long long a,b,c,ans;
	cin>>a>>b>>c;
	if(a%2==0 || b%2==0 || c%2==0)
		cout<<0<<endl;
	else
	{
		ans=min(min(a*b,a*c),b*c);
		cout<<ans<<endl;
	}
}

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

using ll = long long;

int colors[200000];

vector<vector<int>> frnd;
vector<vector<int>> blckd;

void dfs(int u, int col)
{
    if(colors[u]) return;
    colors[u] = col;
    for(int to : frnd[u]) {
        dfs(to, col);
    }
}

int main()
{   
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    frnd = vector<vector<int>> (n+1);
    blckd = vector<vector<int>> (n+1);
    for(int i = 0; i < m; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        frnd[x].push_back(y);
        frnd[y].push_back(x);
    }
    for(int i = 0; i < k; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        blckd[x].push_back(y);
        blckd[y].push_back(x);
    }
    for(int i = 1; i <= n; i++) {
        dfs(i, i);
    }
    int cnt[200000];
    memset(cnt, 0, sizeof(cnt));
    for(int i = 1; i <= n; i++) cnt[colors[i]]++;
    for(int i = 1; i <= n; i++) {
        int c = cnt[colors[i]];
        c -= frnd[i].size();
        for(int to : blckd[i]) {
            if(colors[to] == colors[i]) c--;
        }
        printf("%d ", c-1);
    }
    puts("");
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/


int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if (A > K) {
        cout << K << endl;
    }
    else {
        K -= A;
        if (K > 0) K -= B;
        if (K > 0) A -= min(K, C);

        cout << A << endl;
    }

    return 0;
}


Measured memory_bytes: 3616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class arc81C {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<long long> A(N);
        map<long long, int> cnt;
        for (int i = 0; i < N; ++i) {
            in >> A[i];
            ++cnt[A[i]];
        }
        sort(A.begin(), A.end(), greater<long long>());
        A.erase(unique(A.begin(), A.end()), A.end());
        long long res = 0;
        long long a = -1;
        for (int i = 0; i < N; ++i) {
            if (a == -1 && cnt[A[i]] >= 4) {
                out << A[i] * A[i] << "\n";
                return;
            } else if (cnt[A[i]] >= 2) {
                if (a == -1) {
                    a = A[i];
                } else {
                    out << a * A[i] << "\n";
                    return;
                }
            }
        }
        out << res << "\n";
    }
};


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

	arc81C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <string>
using namespace std;
int main() {
    int n;
    int l[1001],r[1001];
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>l[i];
        cin>>r[i];
    }
    
    int sum=0;
    for(int i=0;i<n;++i){
        sum+=r[i]-l[i]+1;
    }
    
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import groupby
def main():
    n=int(input())
    ss=[]
    for _ in range(n):
        ss.append(input())
    ss=sorted(ss)
    c=0
    for k,g in groupby(ss):
        lg=len(list(g))
        if lg>c:
            c=lg
            zz=[k]
        elif lg==c:
            zz.append(k)
    for k in sorted(zz):
        print(k)
main()

Measured memory_bytes: 22972
N, X = map(int, input().split())
q = [1]*(N+1)
p = [1]*(N+1)
for i in range(1, N+1):
    q[i] = 2*q[i-1]+3
    p[i] = 2*p[i-1]+1

ans = 0
s = [(X, N)]
while s:
    x, n = s.pop()
    if n==0:
        ans += x!=0
    if x:
        a = q[n-1] + 2
        b = p[n-1] + 1

        if x >= a:
            ans += b
            s += [(x-a, n-1)]
        else:
            s += [(x-1, n-1)]

print(ans)

Measured memory_bytes: 3064
@queue = [[0,0,1]]

@s = []

def retrieve(y, x)
    while !@queue.empty?
        point = @queue.shift
        if point[0, 2] == [x - 1, y - 1]
            @s[point[1]][point[0]] = "*"
            @queue.push point
            return
        end
        if @s[point[1]][point[0] + 1] == "."
            @s[point[1]][point[0] + 1] = "*"
            @queue.push [point[0] + 1, point[1], point[2] + 1]
        end
        if @s[point[1] + 1][point[0]] == "."
            @s[point[1] + 1][point[0]] = "*"
            @queue.push [point[0], point[1] + 1, point[2] + 1]
        end
        if @s[point[1] - 1][point[0]] == "."
            @s[point[1] - 1][point[0]] = "*"
            @queue.push [point[0], point[1] - 1, point[2] + 1]
        end
        if @s[point[1]][point[0] - 1] == "."
            @s[point[1]][point[0] - 1] = "*"
            @queue.push [point[0] - 1, point[1], point[2] + 1]
        end
    end

end


h,w = gets.split.map(&:to_i)
whites = 0

h.times do |i|
    @s[i] = gets
    whites += @s[i].count(".")
end

@s[h] = "#" * w.next
@s[0][0] = "*"

retrieve(h, w)

if @queue[0].nil?
    puts -1
else
    puts whites - @queue[-1][2]
end


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
"""
D - Digits Parade
https://atcoder.jp/contests/abc135/tasks/abc135_d

"""
import sys


def solve(S):
    dp = [[0] * 13 for _ in range(len(S)+1)]
    dp[0][0] = 1
    for i, ch in enumerate(S):
        c = -1 if ch == '?' else int(ch)
        for j in range(10):
            if (c != -1 and c != j):
                continue
            for ki in range(13):
                dp[i+1][(ki*10 + j) % 13] += dp[i][ki]
        for j in range(13):
            dp[i+1][j] %= (10**9 + 7)
    return dp[len(S)][5]


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 62044
#include<bits/stdc++.h>
using namespace std;
vector<int> primes;
int A[1005];

void f(int a) {
    for(int i = 2; i * i <= a; i++) {
        if(a % i != 0) continue;
        primes.push_back(i);
        while(a % i == 0) a /= i;
    }
    if(a != 1) primes.push_back(a);
}

int main() {
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        f(A[i]);
    }
    long long ans = 0;
    for(auto val : primes) {
        long long  now = 0;
        for(int i = 1; i <= N; i++) {
            if(A[i] % val == 0) now += A[i];
        }
        ans = max(ans, now);
    }
    cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int prev2 = 0;
  int prev = 0;
  int now = 0;
  int D1, D2;
  for(int i = 0; i < N; i++){
    prev2 = prev;
    prev = now;
    
    
    cin >> D1 >> D2;
    if(D1 == D2){
      now = 1;
    }else{
      now = 0;
    }
    if(now == 1 && prev == 1 && prev2 == 1){
      cout << "Yes" << endl;
      return 0;      
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 3632
N,W = map(int, input().split())
WV = [[int(i) for i in input().split()] for _ in range(N)]

MINW = WV[0][0]

W0,W1,W2,W3 = [],[],[],[]
for w,v in WV:
    if w == MINW: W0.append(v)
    elif w == MINW + 1: W1.append(v)
    elif w == MINW + 2: W2.append(v)
    elif w == MINW + 3: W3.append(v)

W0.sort(reverse=True)
W1.sort(reverse=True)
W2.sort(reverse=True)
W3.sort(reverse=True)

W0 = [0] + W0
W1 = [0] + W1
W2 = [0] + W2
W3 = [0] + W3

from itertools import accumulate

W0 = list(accumulate(W0))
W1 = list(accumulate(W1))
W2 = list(accumulate(W2))
W3 = list(accumulate(W3))

ans = 0
for cnt0 in range(len(W0)):
    for cnt1 in range(len(W1)):
        for cnt2 in range(len(W2)):
            for cnt3 in range(len(W3)):
                SUMW = cnt0 * MINW
                SUMW += cnt1 * (MINW + 1)
                SUMW += cnt2 * (MINW + 2)
                SUMW += cnt3 * (MINW + 3)

                if SUMW <= W:
                    SUMV = W0[cnt0]
                    SUMV += W1[cnt1]
                    SUMV += W2[cnt2]
                    SUMV += W3[cnt3]
                    ans = max(ans, SUMV)

print(ans)

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

#define M1 1000000007
#define M2 1000000009
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define f0(i, n) for (int i = 0; i < (int)(n); ++i)
#define f1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fc0(i,l,r) for(int i = (int)(l); i<(int)(r); ++i)
#define fc1(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define fr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
 
void init()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
      freopen("error.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
}

int c(char m)
{
  return (m-'a');
}
 
signed main()
{
    init();

    int k=0;
    string s,t;
    cin>>s;
    cin>>t;
    f0(i,s.size()){if(s[i]!=t[i])k++;}
    cout<<k<<endl;
    cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}

Measured memory_bytes: 3908
def resolve():
    from fractions import gcd
    a, b, c, d = map(int, input().split())
    e = c*d//gcd(c,d)
    db = b - b//c - b//d + b//e
    da = a-1 - (a-1)//c - (a-1)//d + (a-1)//e
    print(int(db-da))
resolve()

Measured memory_bytes: 5048
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int child=sc.nextInt();
        int candy=sc.nextInt();
        ArrayList<Integer> distribution= new ArrayList<>(child);
        for(int i=1;i<=child;++i){
            distribution.add(sc.nextInt());
        }
        distribution.sort(Integer::compareTo);
        int max=0;
        int count=0;
        for(int i=0;i<child;++i){
            if (max<candy){
                max+=distribution.get(i);
                ++count;
            }
            else{
                break;
            }
        }
        if(max==candy){
            System.out.println(count);
        }
        else {
            System.out.println(count-1);
        }
    }
}


Measured memory_bytes: 28628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int m=scn.nextInt();
		int c=scn.nextInt();
		int []b=new int[m];
		for(int i=0;i<m;i++) {
			b[i]=scn.nextInt();
		}
		int cnt=0;
		for(int j=0;j<n;j++) {
			long temp=c;
			for(int i=0;i<m;i++) {
				temp+=scn.nextInt()*b[i];
			}
			if(temp>0) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 23764
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String[] S = new String[N];
		Set<String> list = new LinkedHashSet<String>();
		for(int i = 0; i < N; i++) {
			 S[i] = sc.next();
		}
		sc.close();
		
		for(int i = 0; i < N; i++) {
			 list.add(S[i]);
		}
		
		System.out.println(list.size());
		
	}

}

Measured memory_bytes: 73916
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,k;
    cin>>n>>k;
    long long a[n+1];
    for(long long int i=1;i<=n;i++)
    cin>>a[i];
    long long dp[n+1];
    //for(long long int i=0;i<=k;i++)
    dp[1]=0;
    //dp[2][1]=abs(a[2]-a[1]);
    for(long long int i=2;i<=n;i++){
        long long int iu =1;
        long long int jh = max(iu,i-k);
            dp[i] = dp[jh]+abs(a[i]-a[jh]);
        for(long long int j=jh;j<i;j++){
            dp[i] = min(dp[j]+abs(a[i]-a[j]),dp[i]);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

struct node{
    int self;
    int parent;
    vector<int> child;
};

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

    vector<vector<int>> adj(N+1);
    int a,b;
    REP(i,0,N-1){
        cin >> a;
        cin >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<ll> ans(N+1,0);
    REP(i,0,Q){
        cin >> a;
        cin >> b;
        ans[a]+=b;
    }

    queue<int> que;
    ll self,parent,par_value=0;
    vector<int> visited(N+1);
    que.push(1);
    visited[1]=1;
    while(!que.empty()){
        self=que.front();
        que.pop();
        for(auto child : adj[self]){
            if(visited[child]==1)continue;
            visited[child]=1;
            ans[child]+=ans[self];
            que.push(child);
        }
    }

    cout << ans[1];
    REP(i,2,N+1){
        cout << " " <<ans[i];
    }
    cout << endl;
    
}

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

#if 0
所用時間:0.5h

感想:

#endif

int solve(string X, string Y){
  int rows = Y.size();
  int cols = X.size();
  int L[1001][1001] = {}; //L[y][x]の初期化

  //テーブルLの更新
  for(int r = 1; r <= rows; ++r){
    for(int c = 1; c <= cols; ++c){
      if(X[c-1] == Y[r-1]) L[r][c] = 1 + L[r-1][c-1];
      else L[r][c] = max(L[r][c-1], L[r-1][c]);
    }
  }

  // //テーブルの表示
  // cout << "Ltable:" << endl;
  // for(int row=0; row <= rows; ++row){
  //   for(int col = 0; col <= cols; ++col){
  //     cout << L[row][col];
  //   }
  //   cout << endl;
  // }

  return L[rows][cols];
}

int main(){
  int q;
  string X, Y;
  cin >> q;

  for(int i = 0; i < q; ++i){
    cin >> X >> Y;

    int ans = solve(X, Y);

    cout << ans << endl;
  }
}



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

int main(void){
    // Your code here!
    long long N;
    long long num[5] = {0};
    cin >> N;

    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        if(s[0] == 'M')
            num[0] += 1;
        if(s[0] == 'A')
            num[1] += 1;
        if(s[0] == 'R')
            num[2] += 1;
        if(s[0] == 'C')
            num[3] += 1;
        if(s[0] == 'H')
            num[4] += 1;
    }
    
    long long count = 0;
    for(int i = 0; i < 5; i++){
        for(int j = i; j < 5; j++){
            if(i != j){
                long long temp = 1;
                for(int k = 0; k < 5; k++){
                    if(i != k && j != k)
                        temp *= num[k];
                }
                count += temp;
            }
        }
    }
    
    cout << count;
    
}


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

int main()
{
  while(1){
    int h, w;
    cin >> h >> w;
    if(h == 0 && w == 0) break;
    int x = h*h + w*w;
    pair<int,int> ans;
    ans.first = ans.second = 150;
    int y = ans.first*ans.first + ans.second*ans.second;
    for(int i = 1; i <= 150; i++){
      for(int j = i + 1; j <= 150; j++){
        int z = i*i + j*j;
        if((x == z && h < i) || x < z){
          if(z < y || (z == y && i < ans.first)){
            ans.first = i;
            ans.second = j;
            y = ans.first*ans.first + ans.second*ans.second;
          }
        }
      }
    }
    cout << ans.first << " " << ans.second << endl;
  }
}

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

typedef struct Work_ {
    long long   duration;   /* 所要時間 */
    long long   deadline;   /* 締め切り時間 */
} Work;

int work_cmp ( const void *a, const void *b ) {
    Work *a_ = (Work*)a;
    Work *b_ = (Work*)b;
    return a_->deadline - b_->deadline;
}

int main (void) {
    int n, i;
    long long cur_time=0;
    scanf("%d", &n);
    Work w[n];
    for ( i=0; i<n; i++ ) {
        scanf("%lld%lld", &w[i].duration, &w[i].deadline);    
    }
    qsort(w, n, sizeof(Work), work_cmp);

    for ( i=0; i<n; i++ ) {
        cur_time += w[i].duration;
        if ( cur_time > w[i].deadline ) {    
            printf("No\n");
            return EXIT_SUCCESS;
        }
    }
    printf("Yes\n");
    return EXIT_SUCCESS;
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define maxn 500005
using namespace std;

const int K=800;

int ans[maxn];
int n,m;
int a[maxn];

struct query{
	int l,r,id;
}q[maxn];

int cnt[maxn];

bool cmp(query x,query y){
	if(x.l/K!=y.l/K)return x.l<y.l;
	return x.r<y.r;
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=m;i++){
		cin>>q[i].l>>q[i].r;
		q[i].id=i;
	}
	sort(q+1,q+m+1,cmp);
	int L,R;
	L=R=0;
	int res=0;
	for(int i=1;i<=m;i++){
		while(R<q[i].r){
			R++;
			cnt[a[R]]++;
			if(cnt[a[R]]==1)res++;
		}
		while(R>q[i].r){
			cnt[a[R]]--;
			if(cnt[a[R]]==0)res--;
			R--;
		}
		while(L>q[i].l){
			L--;
			cnt[a[L]]++;
			if(cnt[a[L]]==1)res++;
		}
		while(L<q[i].l){
			cnt[a[L]]--;
			if(cnt[a[L]]==0)res--;
			L++;
		}
		ans[q[i].id]=res;
	}
	for(int i=1;i<=m;i++)cout<<ans[i]<<endl;
	
}

Measured memory_bytes: 15400
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
typedef long long LL;
const LL O = 1000000007;
const int maxN = 2007;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m;
int f[maxN][maxN];

LL pwr(LL x, LL tms) {
	LL res = 1;
	for (; tms > 0; tms >>= 1, x = (x * x) % O)
		if (tms & 1) res = (res * x) % O;
	return res;
}

int main() {

	n = ri(), m = ri();
	f[0][0] = 1;
	For (i, 1, n) {
		rep (j, 0, i-1) f[i][j] = f[i-1][j];
		per (j, i-1, 0) (f[i][j] +=  f[i][j+1]) %= O;
		rep (j, 1, i) (f[i][j] += f[i-1][j-1]) %= O;
	}
	printf("%lld\n", (f[n-1][n-m] * pwr(2, n-m-1) % O));

	return 0;
}


Measured memory_bytes: 14976
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

X  = list(map(int,input().split()))
for i,xi in enumerate(X):
  if xi == 0:
    print(i+1)
    break

Measured memory_bytes: 65472
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	ll x;
	cin >> x;
	ll now = 100;
	ll ans = 0;
	while(now < x){
		now = 1.01 * now;
		ans++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3252
#include<stdio.h>
int main()
{
	long long i,a,b,c=0,x,y;
	scanf("%lld %lld",&a,&b);
	for(i=0;i<a;i++){
		scanf("%lld %lld",&x,&y);
		if(x*x+y*y<=b*b){
			c++;
		}
	}
	printf("%lld\n",c);
	return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

int w,h;
vvi field;
void dfs(int y, int x)
{
  field[y][x]=0;
  rep(i,8)
  {
    int nx=x+dx[i], ny=y+dy[i];
    if(nx<w&&0<=nx&&ny<h&&0<=ny&&field[ny][nx]==1)
    {
      dfs(ny,nx);
    }
  }
}

signed main() 
{
  while(cin>>w>>h, w||h)
  {
    field=vvi(100,vi(100,-1));
    int n;
    rep(y,h) rep(x,w)
    {
      cin>>n;
      field[y][x]=n;
    }
    int x,y;
    int cnt=0;
    rep(y,h) rep(x,w)
    {
      if(field[y][x]==1) 
      {
        dfs(y,x);
        cnt++;
      }
    }
    print(cnt);
  }

  return 0;
}


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

int main()
{
    ll n, res = 0, x;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        while(x % 2 == 0)
        {
            x /= 2;
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	string s; cin >> s;
	ll len = s.size();
	ll cnt = 0,bl = 0;
	for (int i = 0; i < len; i++) {
		if (s[i] == 'B')bl++;
		if (s[i] == 'W')cnt += bl;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3756
#include<stdio.h>

int fib(int);

int F[50];

int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<=n;i++)F[i]=-1;
	printf("%d\n",fib(n));
}

int fib(int n)
{
	if(n==0||n==1) return F[n]=1;
	
    else 
    
    if(F[n]!=-1) return F[n];
    else return F[n]=fib(n-2)+fib(n-1);
}



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

int main() {
  int K;
  cin >> K;
  string S;
  cin >> S;
  size_t size = S.size();
  if(K >= size){
    cout << S << endl;
  }
  else{
    cout << S.substr(0,K) << "..." << endl;
  }
return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
vector<int> memo(1e5+5, -1);
int dfs(vector<vector<int>> &g, int i){
	if(memo[i] != -1)
		return memo[i];
	memo[i] = 0;
	for(int e : g[i]){
		memo[i]= max(memo[i], 1 + dfs(g, e));
	}
	return memo[i];
}

signed main() { 
	cin.tie(0);
	cin.sync_with_stdio();
	int n,m; 
	cin>>n>>m;
	vector<vector<int>> g(n);
	for(int i = 0; i< m; i++){
		int u, v;
		cin>>u>>v;
		u--;
		v--;
		g[u].push_back(v);
	}
	int ma = 0;
	for(int i = 0; i< n; i++){
		if(memo[i] == -1)
			ma = max(ma, dfs(g, i));
	}
	cout<<ma;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a>>b;
  if(abs(a-b)%2==1){
    cout <<"IMPOSSIBLE";
    return 0;
  }
  cout <<(a+b)/2;
}

Measured memory_bytes: 3584
n, p = map(int, input().split())
A  = list(map(int, input().split()))

N = 10**3
C = [[0]*(N+1) for i in range(N+1)] #C[n][k] > nCk

for i in range(N+1):
    for j in range(i+1):
        if j == 0 or j == i:
            C[i][j] = 1
        else:
            C[i][j] = C[i-1][j-1]+C[i-1][j]

def cmb3(n, k):
    return C[n][k]

e = 0
o = 0
for a in A:
    if a%2 == 0:
        e += 1
    else:
        o += 1

if p == 0:
    ans = 0
    for i in range(o+1):
        if i%2 == 1:
            continue
        else:
            ans += cmb3(o, i)
    ans *= 2**e
    print(ans)
else:
    ans = 0
    for i in range(o+1):
        if i%2 == 0:
            continue
        else:
            ans += cmb3(o, i)
    ans *= 2**e
    print(ans)


Measured memory_bytes: 126428