akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>

int main() {
    int n, q;
    std::cin >> n >> q;

    std::vector<std::queue<int>> Qs(n);

    for (int i = 0; i < q; i++) {
        int op, t;
        std::cin >> op >> t;

        if (op == 0) {
            int x;
            std::cin >> x;
            Qs[t].push(x);
        } else if (op == 1) {
            if (!Qs[t].empty()) {
                std::cout << Qs[t].front() << std::endl;
            }
        } else if (op == 2) {
            if (!Qs[t].empty()) {
                Qs[t].pop();
            }
        }
    }
}



Measured memory_bytes: 4332
N, M = [int(n) for n in input().split()]
students = []
for i in range(N):
  a, b = [int(n) for n in input().split()]
  students.append((a,b))

checkpoints = []
for i in range(M):
  c, d = [int(n) for n in input().split()]
  checkpoints.append((c,d))

st_cp=[]

for a, b in students:
  min_d=10000000000
  cp = 0
  for m, (c, d) in enumerate(checkpoints):
    dist = abs(a-c) + abs(b-d)
    if dist < min_d:
      min_d = dist
      cp = m+1
  st_cp.append(cp)

for i in range(N):
  print(st_cp[i])

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

vector<vector<int> > mat(10, vector<int>(10));

inline int digit(int a, int b, int c, int d){
  return mat[mat[mat[mat[0][a]][b]][c]][d];
}

int main(){
  rep(i,10) rep(j,10) scanf("%d", &mat[i][j]);
  int res=0;
  rep(a,10)rep(b,10)rep(c,10)rep(d,10){
    int cnt=0;
    int dig = digit(a,b,c,d);

    rep(j,10) if(j!=a){
      if(mat[digit(j,b,c,d)][dig]==0) cnt++;
    }
    rep(j,10) if(j!=b){
      if(mat[digit(a,j,c,d)][dig]==0) cnt++;
    }
    rep(j,10) if(j!=c){
      if(mat[digit(a,b,j,d)][dig]==0) cnt++;
    }
    rep(j,10) if(j!=d){
      if(mat[digit(a,b,c,j)][dig]==0) cnt++;
    }
    rep(j,10) if(j!=dig){
      if(mat[dig][j]==0) cnt++;
    }
    if(a!=b && mat[digit(b,a,c,d)][dig]==0) cnt++;
    if(c!=b && mat[digit(a,c,b,d)][dig]==0) cnt++;
    if(c!=d && mat[digit(a,b,d,c)][dig]==0) cnt++;
    if(dig!=d && mat[digit(a,b,c,dig)][d]==0) cnt++;

    if(cnt>0) res++;
  }

  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n,tmp;
    cin >> n;

    vector<int> v;

    rep(i,n){
        cin >> tmp;
        v.pback(tmp);
    }

    sort(ALL(v));
    reverse(ALL(v));

    int alice = 0;
    int bob = 0;

    rep(i,n){
        if(i % 2 == 0){
            alice += v[i];
        }else{
            bob += v[i];
        }
    }

    cout << alice - bob << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<cctype>
#include<cstdio>

using namespace std;

char ToLower (char cX) { return tolower(cX); } 
int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    string s1 = s.substr(0, k-1);
    string s2 = s.substr(k-1, 1);
    transform(s2.begin(), s2.end(), s2.begin(), ToLower);
    string s3 = s.substr(k);
    cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    vector<ll> b(m);
    vector<ll> s(m + 1);
    rep(i, n) cin >> a[i];
    rep(i, m) {
        cin >> b[i];
        s[i + 1] = s[i] + b[i];
    }
    ll ans = upper_bound(all(s), k) - s.begin() - 1;
    ll count = 0;
    rep(i, n){
        k -= a[i];
        if(k < 0) break;
        count++;
        chmax(ans, (ll)(upper_bound(all(s), k) - s.begin() - 1 + count));
    }
    print(ans);

}




Measured memory_bytes: 7948
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy



vl getDegrees(ll x){
  vl degrees;
  ll i = 2;
  while(i<x+1){
    ll r = 0;
    while(x%i == 0){
      r++;
      x /= i;
    }
    degrees.pb(r);
    i++;
  }
  return degrees;
}

ll divisorNumber(ll x){
  vl divdegrees = getDegrees(x);
  ll ans = 1;
  F0R(i,divdegrees.size()){
    ans *= (divdegrees[i]+1);
  }
  return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll firstNonOne = -1;
    F0R(i,s.length()) {
      if(s[i] != '1') {firstNonOne = i; break;}
    }
    firstNonOne;
    if(firstNonOne == -1) {
      cout << '1'<<endl;
    }
    else {
      if(firstNonOne >= k)
        cout << '1' << endl;
      else {
        cout << s[firstNonOne]<<endl;
      }
    }
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

using namespace std;

struct T{
  int v,r;
};

struct S{
  int v,c;
  bool operator<(S s)const{
    return c>s.c;
  }
};

int N,K;
int C[5001],R[5001];
vector<int> G[5001];
vector<int> H[5001];

int main(){
  cin>>N>>K;
  for(int i=1;i<=N;i++){
    cin>>C[i]>>R[i];
  }
  while(K--){
    int A,B;
    cin>>A>>B;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  for(int i=1;i<=N;i++){
    queue<T> que;
    que.push({i,R[i]});
    bool mem[5001]={};
    while(!que.empty()){
      T cs=que.front();
      que.pop();
      if(mem[cs.v]++)continue;
      H[i].push_back(cs.v);
      if(cs.r){
	for(auto e:G[cs.v]){
	  que.push({e,cs.r-1});
	}
      }
    }
  }
  priority_queue<S> que;
  que.push({1,0});
  bool mem[5001]={};
  for(;;){
    S cs=que.top();
    if(cs.v==N)break;
    que.pop();
    if(mem[cs.v]++)continue;
    for(auto e:H[cs.v]){
      que.push({e,cs.c+C[cs.v]});
    }
  }
  cout<<que.top().c<<endl;
}

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

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

int main() {
    int n;
    cin >>n;
    vector<vector<int>> Node(n);
    vector<int> Parent(n, -1);
    vector<bool> Child(n, false);
    Rep0(i, n) {
        int id, k;
        cin >>id >>k;
        if (k>0) {
            Child.at(id)=true;
            Rep0(j, k) {
                int C=0;
                cin >>C;
                Node.at(id).push_back(C);
                Parent.at(C)=id;
            }
        }
    }
    vector<int> Depth(n, -1);
    list<int> q;
    Rep0(i, n)
        if (-1==Parent.at(i)) {
            q.push_back(i);
            Depth.at(i)=0;
        }
    while(!q.empty()) {
        int ix=q.front();
        q.pop_front();
        Rep0(i, Node.at(ix).size()) {
            int c=Node.at(ix).at(i);
            Depth.at(c)=Depth.at(ix)+1;
            q.push_back(c);
        }
    }
    Rep0(i, n) {
        cout <<"node " <<i
            <<": parent = " <<Parent.at(i)
            <<", depth = " <<Depth.at(i)
            <<", ";
        if (-1==Parent.at(i))
            cout <<"root";
        else if (0==Node.at(i).size())
            cout <<"leaf";
        else
            cout <<"internal node";
        cout <<", [";
        Rep0(j, Node.at(i).size()) {
            if (0==j)
                cout <<Node.at(i).at(j);
            else
                cout <<", " <<Node.at(i).at(j);
        }
        cout <<"]" <<endl;
    }
    return 0;
}


Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<ll,ll>;

pi READ(string s, ll mul){
    bool x = false;
    for(char c:s)if(c=='x') x = true;

    if(!x) return {mul*stoi(s), 0};

    int S = s.size();
    int xidx = 0;
    while(s[xidx]!='x') ++xidx;

    ll a = 1, n = 1;
    if(xidx != 0) a = stoi(s.substr(0,xidx));
    if(xidx != S-1) n = stoi(s.substr(xidx+2));
    return {mul*a, n};
}

ll f(const vector<pi> &v, ll x){
    ll ret = 0;
    for(pi p:v){
        ll add = p.fi;
        rep(_,p.se) add *= x;
        ret += add;
    }
    return ret;
}

string cv(int x){
    if(x==0) return "x";

    string ret = "(x";

    x = -x;
    if(x>0) ret += "+";

    ret += to_string(x) + ")";
    return ret;
}

int main(){
    string s;
    cin >>s;
    int S = s.size();

    int idx = 0;
    int m = 1;
    vector<pi> v;
    while(idx<S){
        int nx = idx;
        while(nx<S && (s[nx]!='+' && s[nx]!='-')) ++nx;

        v.pb(READ(s.substr(idx, nx-idx), m));

        if(nx<S){
            if(s[nx] == '+') m = 1;
            else m = -1;
            ++nx;
        }
        idx = nx;
    }

    // dbg(v);
    int n = v[0].se;

    string ans = "";

    const int N = 2000;
    for(int i=N; i>=-N; --i){
        if(f(v,i) == 0) ans += cv(i);
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3272
/*
** Connected Components
*/

# include <cstdio>
# include <vector>
# include <queue>
using namespace std;

const int MAX = 100000;

int n, m, q, c[MAX];
vector<int> g[MAX];

void init() {
    scanf("%d%d", &n, &m);
    int u, v;
    while (m--) {
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

void bfs(int u, int mark) {
    queue<int> que;
    que.push(u);
    c[u] = mark;

    while (!que.empty()) {
        int t = que.front();
        que.pop();
        for (int i = 0; i < g[t].size(); i++) {
            if (c[g[t][i]] == 0) {
                c[g[t][i]] = mark;
                que.push(g[t][i]);
            }
        }
    }
}

void set_c() {
    int mark = 1;
    for (int i = 0; i < n; i++) {
        c[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        if (c[i] == 0) {
            bfs(i, mark++);
        }
    }
}

void solve() {
    init();
    scanf("%d", &q);
    set_c();
    int u, v;
    while (q--) {
        scanf("%d%d", &u, &v);
        if (c[u] == c[v]) {
            printf("yes\n");
        }
        else
        {
            printf("no\n");
        }
    }
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 8500
import numpy as np


def run(p1, p4):
    v = p4 - p1
    A = np.array([[v[0], v[1]], [v[1], -v[0]]])
    b = np.array([0, np.dot(v, v)])
    x = np.dot(np.linalg.inv(A), b)
    return x + p1


l = list(map(int, input().split()))
p1 = np.array([l[0], l[1]])
p2 = np.array([l[2], l[3]])

p3 = run(p2, p1).astype(np.int64)
p4 = run(p3, p2).astype(np.int64)

print("{} {} {} {}".format(p3[0], p3[1], p4[0], p4[1]))


Measured memory_bytes: 26900
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      myout((nextInt() < 1200) ? "ABC" : "ARC");
	}
	//Method addition frame start


  
	//Method addition frame end
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll C[2001][2001];

int main() {
  int n, k;
  cin >> n >> k;
  REP(i, 2001) REP(j, 2001) {
    if (i == 0 || j == 0 || i == j) {
      C[i][j] = 1;
    } else {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
    }
  }
  REP1(i, k) {
    if (n - k + 1 >= i) {
      cout << C[n - k + 1][i] * C[k - 1][i - 1] % MOD << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}

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

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

    ll ans;
    cin >> ans;
    rep(i, n - 1) {
        ll t;
        cin >> t;
        ans = ans / __gcd(ans, t) * t;
    }

    cout << ans << endl;
    return 0;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N,K;
    cin >> N >> K;
    map<int,int> count;
    rep(i,0,N){
        int Ai;
        cin >> Ai;
        ++count[Ai];
    }
    
    vector<int> nums;
    for(auto &p:count) nums.push_back(p.second);
    sort(nums.begin(),nums.end());

    int ans=0;
    rep(i,0,nums.size()-K) ans+=nums[i];

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main() {
    int A,B ; cin >> A >> B ;
    int ans ;
    int tmp ;
    for (int i = 1; i <= B ; i=i+1){
       tmp = A * i ;
       if (B == tmp){
           ans = A + B ;
           break ;
       }
       else {
           ans = B - A ;
       }
    }   
    cout << ans << endl ; 
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	int X, Y; cin >> X >> Y;
	rep( i, 0, X + 1 ){
		if (4 * X - 2 * i == Y){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 3644
c1 = [""] * 3
c2 = [""] * 3
c3 = [""] * 3
for i in range(3):
  c1[i],c2[i],c3[i] = list(str(input()))
ans = ""
ans += c1[0]
ans += c2[1]
ans += c3[2]
print(ans)

Measured memory_bytes: 3064
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[m],b[m];
    for(int i=0;i<m;i++)
    {
        cin>>a[i]>>b[i];
    }
    vector<vector<ll> >v(n+1);
    for(int i=0;i<m;i++)
    {
        v[a[i]].push_back(b[i]);
    }
   /* for(int i=1;i<=n;i++)
    {
        for(int j=0;j<v[i].size();j++)
        {
            cout<<v[i][j]<<" ";
        }
        cout<<endl;
    }*/
    bool f=0;
    //cout<<v[1].size();
    for(int i=0;i<v[1].size();i++)
    {
        if(count(v[v[1][i]].begin(),v[v[1][i]].end(),n))
        {
            f=1;break;
        }
    }
    if(f==1)
        cout<<"POSSIBLE"<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

char grid[401][401];
bitset<401> vis[401];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int h, w; cin >> h >> w;

    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            cin >> grid[i][j];

    long long ans = 0;

    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(vis[i][j]) continue;

            queue<pair<int, int>> q;
            q.push(make_pair(i, j));
            vis[i][j] = 1;

            long long whi = 0, bla = 0;

            while(!q.empty()){
                int x = q.front().first, y = q.front().second;
                q.pop();

                if(grid[x][y] == '.')
                    ++whi;
                else
                    ++bla;

                for(int dx = -1; dx < 2; ++dx){
                    for(int dy = -1; dy < 2; ++dy){
                        if(dx == 0 && dy == 0) continue;
                        if(dx != 0 && dy != 0) continue;
                        if(x + dx < 0 || x + dx == h) continue;
                        if(y + dy < 0 || y + dy == w) continue;
                        if(vis[x + dx][y + dy]) continue;
                        if(grid[x + dx][y + dy] == grid[x][y]) continue;
                        vis[x + dx][y + dy] = 1;
                        q.push(make_pair(x + dx, y + dy));
                    }
                }

            }

            ans += whi * bla;

            //cout << whi << " " << bla << endl;

        }
    }

    cout << ans << "\n";

    return 0;

}


Measured memory_bytes: 384
# by size
# 0-indexed
class UnionFind:
  N=0
  parent=None
  size=None
  def __init__(self,N):
    self.N=N
    self.parent=[i for i in range(self.N)]
    self.size=[1]*self.N
    
  def root(self,x):
    while x!=self.parent[x]:
      self.parent[x]=self.parent[self.parent[x]]
      x=self.parent[x]
    return x
  
  def same(self,x,y):
    return self.root(x)==self.root(y)
  
  def unite(self,x,y):
    x=self.root(x)
    y=self.root(y)
    if x==y:
      return
    if self.size[x]>self.size[y]:
      # 大きい方にくっつける
      self.parent[y]=x
      self.size[x]+=self.size[y]
    else:
      self.parent[x]=y
      self.size[y]+=self.size[x]
      
  def get_group_size(self,x):
    return self.size[self.root(x)]
  
  def get_roots(self):
    r=set()
    for i in range(self.N):
      r.add(self.root(i))
    return r
  
  def show_parent(self):
    print(self.parent)
    
  def show_size(self):
    print(self.size)
    
import sys
readline = sys.stdin.readline

N,Q = map(int,readline().split())
UF = UnionFind(N)
for i in range(Q):
  t,u,v = map(int,readline().split())
  u -= 1
  v -= 1
  if t == 0:
    UF.unite(u,v)
  else:
    print(int(UF.same(u,v)))


Measured memory_bytes: 18444
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

int main()
{
    int s;
    cin>>s;
    ll prev=s;
    map<ll,int> a;
    ll ans=1;
    ll towans=0;
    a[s]++;
    while(1)
    {
        ans++;
        ll tempa=0;
        if(prev%2==0)
        {
            tempa=prev/2;
        }
        else
        {
            tempa=3*prev+1;
        }
        if(a[tempa]==0)
        {
            a[tempa]++;
        }
        else
        {
            break;
        }
        prev=tempa;
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

    final int M = 1_000_000_007;
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
    }
    Arrays.sort(a);

    long[] chooseForK1 = new long[N + 1];
    chooseForK1[K - 1] = 1;
    for (int i = K; i <= N; i++) {
      chooseForK1[i] = chooseForK1[i - 1];
      chooseForK1[i] *= i;
      chooseForK1[i] %= M;
      chooseForK1[i] *= inverse(i - K + 1, M);
      chooseForK1[i] %= M;
    }

    long smax = 0;
    long smin = 0;
    for (int i = 0; i < N; i++) {
      long max = a[i] * chooseForK1[i];
      max %= M;
      smax += max;
      smax %= M;
      long min = a[i] * chooseForK1[N - i - 1];
      min %= M;
      smin += min;
      smin %= M;
    }
    long res = smax - smin;
    if (res >= M) res -= M;
    if (res < 0) res += M;
    System.out.println(res);
  }

  public static long choose(long n, long k, long mod) {
    if (k > n) return 0;
    if (k > n - k) return choose(n, n - k, mod);
    long res = 1;
    for (int i = 0; i < k; i++) {
      res = (res * (n - i)) % mod;
    }
    for (int i = 1; i <= k; i++) {
      res = (res * inverse(i, mod)) % mod;
    }
    return res % mod;
  }

  private static long inverse(long a, long mod) {
    return modpow(a, mod - 2, mod);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }
}


Measured memory_bytes: 51296
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<vector<ll>> abc(N, vector<ll>(3));
  for (ll i = 0; i < N; ++i) {
    cin >> abc.at(i).at(0) >> abc.at(i).at(1) >> abc.at(i).at(2);
  }
  vector<vector<ll>> dp(N + 1, vector<ll>(3, 0));
  for (ll i = 0; i < N; ++i) {
    for (ll j = 0; j < 3; ++j) {
      for (ll k = 0; k < 3; ++k) {
        if (j == k) {
          continue;
        }
        dp.at(i + 1).at(j) = max(dp.at(i + 1).at(j), dp.at(i).at(k) + abc.at(i).at(j));
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < 3; ++i) {
    ans = max(ans, dp.at(N).at(i));
  }
  cout << ans << "\n";
}


Measured memory_bytes: 14248
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;
  cin >> S;
  for(int i = 0; i < S.size(); i++){
    if((i % 2 == 0 && S[i] == 'L') || (i % 2 == 1 && S[i] == 'R')){
      cout << "No" << endl;
      return 0;
    }
  } 
  cout << "Yes" << endl;
}

Measured memory_bytes: 3620
import sys
x, n = map(int, input().split())

if n == 0:
  print(x)
  sys.exit()
p = list(map(int, input().split()))
p.sort()

okList = [-1]*(300)
for i in range(len(okList)):
  okList[i] = i-150
for i in range(len(p)):
  okList[p[i]+150] = -1000

ans = 0
ans2 = 10000
for i in range(len(okList)):
  if okList[i] != -1000:
    if ans2 > abs(okList[i]-x):
      ans2 = abs(okList[i]-x)
      ans = okList[i]
print(ans)

Measured memory_bytes: 9156
#include <cstdio>

int main(){
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    for(int i = 1;; i++){
        if(y * i + z * (i + 1) > x){
            printf("%d\n",i - 1);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	rep2(i, 1, n + 1) {
		if (i % 3 == 0)
			cout << " " << i;
		else {
			int x = i;
			while (x) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}



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

int main() {
  string s;
  cin >> s;

  int a = (s[0]-'0')*10 + s[1]-'0';
  int b = (s[2]-'0')*10 + s[3]-'0';

  if (0 < a && a <= 12 && 0 < b && b <= 12)
  cout << "AMBIGUOUS" << endl;
  else if (0 < a && a <= 12)
  cout << "MMYY" << endl;
  else if (0 < b && b <= 12)
  cout << "YYMM" << endl;
  else
  cout << "NA" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FastIO
{
	static char c;
	template<typename T>
	inline void read(T& x)
	{
		x=0,c=getchar();
		while(!isdigit(c))c=getchar();
		while(isdigit(c))x=x*10+c-'0',c=getchar();
	}
}
using FastIO::read;
typedef long long LL;
const int maxn=100005;

struct edge{int to,next;}e[maxn<<1];
int n,A[maxn],tot,head[maxn],deg[maxn];

inline void add(int u,int v)
{
	deg[u]++,deg[v]++;
	e[++tot]=(edge){v,head[u]},head[u]=tot;
	e[++tot]=(edge){u,head[v]},head[v]=tot;
}
inline int dfs(int u,int fa)
{
	int sum=0,w;
	for(int i=head[u];i;i=e[i].next)if(fa!=e[i].to)
	{
		w=dfs(e[i].to,u),sum+=w;
		if(w>A[u])exit((puts("NO"),0));
	}
	if(deg[u]==1)return A[u]-sum;
	if(sum<A[u])exit((puts("NO"),0));
	A[u]<<=1;
	if(A[u]<sum)exit((puts("NO"),0));
	return A[u]-sum;
}

int main()
{
	read(n);
	for(int i=1;i<=n;i++)read(A[i]);
	for(int i=1,u,v;i<n;i++)read(u),read(v),add(u,v);
	if(dfs(1,-1)>0)return puts("NO"),0;
	return puts("YES"),0;
}

Measured memory_bytes: 5376
n, k, q = map(int, input().split())

li_a = list()
d_seikai = dict()
for i in range(q):
    in_a = int(input())
    li_a.append(in_a)
    d_seikai[in_a] = d_seikai.get(in_a, 0) + 1

for m in range(1, n + 1):
    seikai = d_seikai.get(m, 0)
    machigai = q - seikai

    if k <= machigai:
        print("No")
    else:
        print("Yes")



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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string S[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
    }
    sort(S, S + N);
    ll ans = 0;
    ll index = 0;
    REP(i, N) {
        if (S[i] != S[index]) {
            ll n = i - index;
            ans += n * (n - 1) / 2;
            index = i;
        }

        if (i == N - 1) {
            ll n = i - index + 1;
            ans += n * (n - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

//#define INF 100000000
//#define MOD (int) (1e9+7)
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

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

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

    vector<int> a(n);
    map<int, int> m;

    int i;
    for(i = 0; i < n; i++){
        cin >> a[i];
        m[a[i]]++;
    }

    long long int ans = 0;
    auto begin = m.begin(), end = m.end();
    for (auto iter = begin; iter != end; iter++) {
        // first: key, second: value
        long long int p = iter->second;
        ans += p*(p-1)/2;
    }

    for(i = 0; i < n; i++){
        long long int p = m[a[i]];
        cout << ans - (p*(p-1)/2 - (p-1)*(p-2)/2) << endl;
    }

}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long A, B, K;
    cin >> A >> B >> K;
    if(A+B<=K){
        cout << 0 << ' ' << 0;
    }
    else{
        if(A>=K){
        cout << A-K << ' '<<B;
        
    } else {
        cout << 0 << ' '<< B - (K-A);
    }
        
    }
    
    
    
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;	
	int ans = 0;
	for(int i=1;i<n;i++){
		int cnt=0;		
		for(char c = 'a';c <= 'z';c++){
			bool left=false,right=false;
			for(int j=0;j<i;j++)
				if(s[j]==c)
					left=true;
			for(int j=i;j<n;j++)
				if(s[j]==c)
					right=true;
			if(left&&right)
				cnt++;
		}
		if(ans < cnt)
			ans = cnt;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
listA = list(map(int, input().split()))
listA.sort()

remCount=0
beforeN =0
index=0
count=0
while index < len(listA):
    if index==0:
        beforeN = listA[index]
        count+=1
    elif beforeN == listA[index]:
        count+=1
    else:
        if count == beforeN:
            pass
        elif count > beforeN:
            remCount+=(count-beforeN)
        else:
            remCount+=count
        beforeN = listA[index]
        count=1
    index+=1
if count == beforeN:
    pass
elif count > beforeN:
    remCount+=(count-beforeN)
else:
    remCount+=count
            
print(remCount)

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

#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax_v(ary) *max_element(all(ary))
#define vmin_v(ary) *min_element(all(ary))
#define vmax_id(ary) distance((ary).begin(),max_element(all(ary)))
#define vmin_id(ary) distance((ary).begin(),min_element(all(ary)))

using ll = int64_t;
using pll = pair<ll,ll>;
using vl = vector<ll>;

const ll INF=INT64_MAX;
const double EPS=1e-10;
const double PI=acos(-1.0);

void init(){cin.tie(0);ios::sync_with_stdio(false);}
//----------------------------------------------------

int main(){
    init();

    ll n;
    while(cin>>n,!cin.eof()){
      ll ct=0;
      for(int a=0;a<=9;a++){
        for(int b=0;b<=9;b++){
          for(int c=0;c<=9;c++){
            for(int d=0;d<=9;d++){
              if(a+b+c+d==n){
                ct++;
              }
            }
          }
        }
      }
      cout << ct << endl;
    }
    return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll N,A,B;
vector<ll> h;

bool f(ll K){
	ll tmp=0;
	for(int i=0;i<N;i++){
		ll rem=h[i]-B*K;
		if(rem>0) tmp+=(rem+(A-B-1))/(A-B);
	}
	return (tmp<=K);
}

ll binary_search(ll ok,ll ng){
	while(abs(ok-ng)>1){
		ll mid=(ok+ng)/2;
		if(f(mid)) ok=mid;
		else ng=mid;
	}
	return ok;
}

int main(){
	cin>>N>>A>>B;
	h=vector<ll>(N);
	rep(i,N) cin>>h[i];
	cout<<binary_search(INF,0)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b;
	long long ans;
	cin>>a>>b;
	long long tmp=a;
	a=max(a,b);
	b=min(tmp,b);
	for(int i=1;i<=b;i++){
		if((a*i)%b==0){
			ans=a*i;
			break;
		} 
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int MOD=1e9+7;

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

  int n;cin>>n;
  std::vector<ll> a(n+1);
  for(int i=0;i<n;i++) cin>>a[i];
  a[n]=0;
  ll res=0;
  for(int i=0;i<n;i++){
      res+=(a[i]/2);
      a[i]%=2;
      if(a[i+1]&&a[i]){
          a[i]--;a[i+1]--;
          res++;
      }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define SANKOU(n, a, b) cout << ((n) ? (#a) : (#b)) << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>

void solve()
{
}

signed main()
{
    int a, b;
    cin >> a >> b;
    cout << a - b + 1ll << endl;
    solve();
    return 0;
}


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

int main(){
  while(1){
    int H,W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(i == 0 || i == H - 1 || j == 0 || j == W - 1) cout<<"#";
	else cout<<".";
      }
      cout<<endl;
    }

    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3104
/**
 *   Author   :  Alastor
 *   Created  :  10.07.2020 07:16:29
**/
#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; it++)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


const int N = (int) 4e2 + 5;
      long long INF = (1e18) + 5;

long long dp[N][N];

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	auto Calc = [&](int L, int R) {
		long long sum = 0;
		for (int i = L; i <= R; i++) {
			sum += a[i];
		}
		return sum;
	};
	for (int L = n - 1; L >= 0; L--) {
    for (int R = L; R < n; R++) {
      if (L == R) {
        dp[L][R] = 0;
      } else {
        dp[L][R] = INF;
        long long sum = Calc(L, R);
        for (int i = L; i <= R - 1; i++) {
          dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + sum);
        }
      }
    }
  }  
  printf("%lld\n", dp[0][n-1]);
  return 0;
}


Measured memory_bytes: 5012
#include<stdio.h>
 
int search(int A[], int n,int key){
 int i = 0;
 int c = 0;
 A[n] = key;
 while ( A[i] != key )
       i++;
  
 if( i != n ) 
    c = 1;
 
 return c;
}
 
int main(){
 
 int  i, n, A[10000+1], q, key, sum = 0;
 scanf("%d", &n);
 for(i=0;i<n;i++)
    scanf("%d", &A[i]);
 scanf("%d", &q);
 for( i = 0; i < q; i++){
   scanf("%d", &key);
   if(search(A, n, key))
     sum++;
 }
 printf("%d\n", sum);
 
 return 0;
}

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

int main() {
  
  int A,B;
  string op;
  cin >> A >> op >> B;

  // ここにプログラムを追記
  
  if(op=="+")
    cout << A+B << endl;
  else
        cout << A-B << endl;
}




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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin();
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin();
#define ct(i) cout<< i << "\n";
#define sv(v) sort(v.begin(),v.end());
#define mod 1000000007
#define M 100005
#define endl "\n"

// std::vector<int> ad[100005];

// int vis[100005]={},intime[100005],low[100005],timer=0;
// int flag=0;
// vector<pair<int,int>> ans;

// void dfs(int node, int par){
//     vis[node]=1;
//     intime[node]=low[node]=timer++;
//     for(auto child:ad[node]){
//         if(child==par) continue;
//         if(vis[child]){
//             low[node] = min(low[node],low[child]);
//             if(intime[child]<intime[node]) ans.pb({node,child});
//         }
//         else{
//             dfs(child,node);
//             if(low[child]>intime[node]){
//                 flag=1;
//                 return;
//             }
//             low[node] = min(low[child],low[node]);
//             ans.pb({node,child});
//         }
//     }
// }

void answer(){
    ll n,m,x,y,ans=0;
    cin>>n>>m;
    int a[n+1],b[n+1];
    for(int i=0;i<=n;i++) a[i]=0,b[i]=1;
    a[1]=1;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        if(a[x]==1){
            a[y]=1;
        }
        b[x]--;
        b[y]++;
        if (b[x]==0){
            a[x]=0;
        }
    }
    
    for(int i=1;i<=n;i++){
        ans+=a[i];
    }
    cout<<ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();

    return 0;
}



Measured memory_bytes: 1024
function Judge(input) {
  input = input.split(" ");
  a = parseInt(input[0], 10);
  b = parseInt(input[1], 10);
  ans = a * b;
  if (ans % 2 === 0) {
    console.log("Even");
  } else {
    console.log("Odd");
  }
}
 
Judge(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7496
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    int p,q,r;
    cin>>p>>q>>r;

    int sum = INT_MAX;
    sum = min(p+q,sum);
    sum = min(p+r,sum);
    sum = min(q+r,sum);

    cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main()
{
	int c = 0;
	int a[3000];

	while (1){

		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;

		if (x > y){
			cout << y << " " << x << endl;
		}
		else{
			cout << x << " " << y << endl;
		}
		//c++;
	}
	

	return 0;
}


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

int main()
{
    bool a = true;
    vector<bool> num(102, true);
    int x, n;
    cin >> x >> n;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        num[tmp] = false;
    }
    
    int l = 0;
    
    while(a){
        if(num[x - l] == true && x - l >= 0){
            cout << x - l << endl;
            a = false;
            break;
        }else if(num[x + l] == true && x + l <= 101){
            cout << x + l << endl;
            a = false;
            break;
        }else{
            l++;
        }
    }
}

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

int main()
{
  int n; cin >> n;
  string s; cin >> s;
  
  int total = 0;
  for (int i = 0; i < 1000; ++i)
  {
    int dig[3] = { '0' + i / 100, '0' + i % 100 / 10, '0' + i % 10 };
    for (int j = 0, d = 0; j < n; ++j)
    {
      if (s[j] == dig[d])
      {
        ++d;
        if (d == 3)
        {
          ++total;
          break;
        }
      }
    }
  }
  
  cout << total << endl;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))

cumsum_t = [0]*(n+1)
for i in range(n):
    cumsum_t[i+1] = cumsum_t[i] + t[i]

v_max = [0]*(2*sum(t) + 1)
for i in range(len(cumsum_t) - 1):
    for j in range(2*cumsum_t[i], 2*cumsum_t[i+1]):
        v_max[j] = v[i]
for i in range(len(cumsum_t) - 1):
    v_max[cumsum_t[i+1]*2] = min(v_max[cumsum_t[i+1]*2], v[i])

speed = [101]*(2*sum(t) + 1)
speed[0] = 0
speed[-1] = 0
for i in range(len(speed) - 1):
    speed[i+1] = min(speed[i+1], speed[i] + 0.5, v_max[i+1])
for i in range(len(speed) - 1)[::-1]:
    speed[i] = min(speed[i], speed[i+1] + 0.5, v_max[i])

print(sum(speed)/2)

Measured memory_bytes: 3700
inputs  = list(map(int, input().strip().split(' ')))
l1 = set(range(inputs[0],min(inputs[0]+inputs[2],inputs[1]+1)))
l2 = set(range(max(inputs[1]-inputs[2]+1,inputs[0]),inputs[1]+1))
returnList = sorted(list(set().union(l1,l2)))
for l in returnList :
    print(l)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

string s;
vector<char> ta = {}, mu = {};

signed main() {
	cin >> s;
	int wa = s.size() - 7;
	for (int i = 0; i < s.size(); i++) {
		ta.push_back(s[i]);
		mu.push_back(s[i]);
	}
	for (int i = 0; i < s.size() - wa; i++) {
		ta.erase(ta.begin() + i, ta.begin() + i + wa);
		string rin(ta.begin(), ta.end());
		if (rin == "keyence") {
			cout << "YES" << endl;
			return 0;
		}
		ta = mu;
	}
	cout << "NO" << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
s=input()
x,y=map(int, input().split())
cx=[]
cy=[]
dirx=1
l=0
ini=1
for i in range(len(s)):
  if s[i] == "F":
    l += 1
  else:
    if ini:
      x -= l
      ini = 0
    else:
      if dirx:
        cx.append(l)
      else:
        cy.append(l)
    l = 0
    dirx = not dirx

if ini == 0:
  if dirx:
    cx.append(l)
  else:
    cy.append(l)
else:
  x -= l

#print(cx)
#print(cy)


ng = 0
dp = {0}
for i in range( len(cx) ):
  dpn = set()
  for d in dp:
    dpn.add(d+cx[i])
    dpn.add(d-cx[i])
#  print(dpn)
  dpn, dp = dp, dpn
  
if not x in dp:
  ng = 1
#  print("x", x)
  
dp = {0}
for i in range( len(cy) ):
  dpn = set()
  for d in dp:
    dpn.add(d+cy[i])
    dpn.add(d-cy[i])
#  print(dpn)
  dpn, dp = dp, dpn
  
if not y in dp:
  ng = 1
#  print("y", y)

if ng==0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9600