akhauriyash/Code-Regression huggingface dataset:
class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.MSB = 1 << (N.bit_length() - 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def bisect(self, w):
        bit, N = self.tree, self.size
        i = 0
        K = N.bit_length()
        for k in (1 << k for k in reversed(range(K))):
            if i + k <= N and bit[i + k] < w:
                w -= bit[i + k]
                i += k
        return i + 1

N, *A = map(int, open(0).read().split())

memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
M = len(memo)

bit = BIT(M)
for b in (memo[a] for a in A):
    s = bit.sum(b - 1)
    if s > 0:
        i = bit.bisect(s)
        bit.add(i, -1)
    bit.add(b, 1)

print(bit.sum(M))


Measured memory_bytes: 25228
#include<queue>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  unsigned i;
  unsigned a[100][100],b[100][11],c[100][11],m,n,o,u,v,x,y,z;
  priority_queue<pair<unsigned,pair<unsigned,unsigned> >,vector<pair<unsigned,pair<unsigned,unsigned> > >,greater<pair<unsigned,pair<unsigned,unsigned> > > > d;
  while(cin>>m>>n>>o>>u>>v&&m+n+o+u+v){
    u--;
    v--;
    memset(a,-1,sizeof(a));
    for(i=0;i<o;i++){
      int p,q,r;
      cin>>p>>q>>r;
      p--;
      q--;
      a[p][q]=a[q][p]=r;
    }
    memset(b,0,sizeof(b));
    memset(c,-1,sizeof(c));
    c[u][0]=0;
    while(d.empty()==0)
      d.pop();
    d.push(make_pair(0,make_pair(u,0)));
    for(;;){
      z=d.top().first;
      x=d.top().second.first;
      y=d.top().second.second;
      d.pop();
      if(x==v)
	break;
      if(b[x][y]==0){
	b[x][y]=1;
	for(i=0;i<n;i++){
	  if((int)a[x][i]!=-1){
	    d.push(make_pair(z+a[x][i],make_pair(i,y)));
	    if(y<m)
	      d.push(make_pair(z+a[x][i]/2,make_pair(i,y+1)));
	  }
	}
      }
    }
    cout<<z<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
X,K,D=map(int,input().split())
if X>=0:
    a=X//D
    b=a+1
else:
    b=X//D
    a=b+1
if abs(b)<=K:
    if b%2==K%2:
        s=abs(X-D*b)
    else:
        s=abs(X-D*a)
else:
    if X>0:
        s=abs(X-D*K)
    else:
        s=abs(X+D*K)
print(s)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 1;
string s;

void input() {
  IN(N);
  IN(K);
}

void solve() {
  ll top = 1;
  while(N / top >= K) {
    top *= K;
    ret += 1;
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import itertools
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  A=list(map(int,pin().split()))
  mod=10**9+7
  B=list(itertools.accumulate(A))
  ans=0
  for i in range(N-1):
    ans+=A[i]*(B[N-1]-B[i])
  print(ans%mod)
  return 
main()

Measured memory_bytes: 31640
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

const int N = 5e5+5;
int n,q;
int c[N];
int vis[N];
struct node{
    int l,r,id;
}qus[N];
bool cmp(const node &a,const node&b){
    return a.r<b.r; 
}
int tree [N];
void update(int x,int val){
    while(x<=n){
        tree[x]+=val;
        x+=(x&(-x));
    }
}
int query(int x)
{
    int ans = 0;
    while(x){
        ans+=tree[x];
        x-=(x&(-x));
    }
    return ans;
}
int res[N];
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>q;
    rep(i,1,n){
        cin>>c[i];
    }
    rep(i,1,q){
        cin>>qus[i].l>>qus[i].r;
        qus[i].id = i;
    }
    sort(qus+1,qus+1+q,cmp);

    rep(i,1,q){
        rep(j,qus[i-1].r+1,qus[i].r){
            if(vis[c[j]]){
                update(vis[c[j]],-1);
            }
            update(j,1); vis[c[j]] = j;    
        }
        res[qus[i].id] = (query(qus[i].r)-query(qus[i].l-1));
    }

    rep(i,1,q){
        cout<<res[i]<<'\n';
    }
}


Measured memory_bytes: 17404
MOD = 10 ** 9 + 7

import numpy as np

N, K = map(int, input().split())
A = list(map(int, input().split()))

if K == 0:
    print (1)
    exit()

dp = np.zeros((N + 1, K + 1), dtype = np.int64)
dp[N: N + 1,:] = 1
# print (dp[N]):
for i in range(N - 1, -1, -1):
    dp[i:i + 1, :A[i] + 1] = dp[i + 1:i + 2, :A[i] + 1]
    dp[i:i + 1, A[i] + 1:] = dp[i + 1:i + 2, A[i] + 1:] - dp[i + 1:i + 2, :K - A[i]]
    # print (dp[i])
    dp[i] = np.cumsum(dp[i]) % MOD
    # print (dp[i])

print ((dp[0, K] - dp[0, K - 1]) % MOD)

Measured memory_bytes: 92904
#include "iostream"
#include "cstdio"
#include "cmath"
using namespace std;
const int INF=50;
long long n;
int solve(long long num){
	int cnt=0;
	while(num){
		cnt++;
		num/=10;
	}
	return cnt;
}
int main()
{
	while(cin>>n){
		long long minx=INF;
		//cout<<solve(10000)<<endl;
		for(long long i=1;i*i<=n;i++){
			if(n%i==0){
				long long t=max(solve(i),solve(n/i));
				minx=min(minx,t);
			}
		}
		cout<<minx<<endl;
	}
}

Measured memory_bytes: 256
import sys

N = int(input())
S = input()
s_tail = S[len(S)-1]
A = []
A.append(S)
flg = 0

for i in range(N-1):
    S = input()
    s_head = S[0]
    if s_tail!=s_head:
        flg = 1
    elif not (S in A):
        A.append(S)
    else:
        flg = 1

    s_tail = S[len(S)-1]

if flg==1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3188
#include<iostream>

using namespace std;

int main (void){

	int num;
	char sign;
	int cnt = 0;
	int ans = 0;

	cin >> ans;
	for(int i=0;;i++){
		if(i%2==0){
			cin >> sign;
			if(sign=='=')break;
		}else{
			cin >> num;
			switch(sign){
				case '+':
				ans += num;
				break;
				case '-':
				ans -= num;
				break;
				case '*':
				ans *= num;
				break;
				case '/':
				ans /= num;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        left = set(['q', 'w', 'e', 'r', 't', 'a', 's', 'd', 'f', 'g', 'z', 'x', 'c', 'v', 'b'])
        while True:
            s = raw_input()
            if s == '#':
                break
            count = 0
            flg = s[0] in left
            for i in range(1, len(s)):
                if (s[i] in left) != flg:
                    flg = not flg
                    count += 1
            print count
                    
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;
    ll n;

    cin >> n;

    long double ans = (n/3.00000)*(n/3.0000)*(n/3.0000000);

    cout << setprecision(20) << ans  << endl;





    return 0;
}



Measured memory_bytes: 256
n,x = map(int,input().split())
l = list(map(int,input().split()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
#それぞれの間の距離の最大公約数
l.append(x)
l = list(set(l))
l.sort()

ans = l[1]-l[0]
for i in range(2,len(l)):
  num = l[i]-l[i-1]
  ans = gcd(ans,num)
print(ans)  
  

Measured memory_bytes: 65688
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int main(){
    string s;
    cin >> s;
    int numS=0,numT=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='S'){
            numS++;
        }else if(s[i]=='T'&&numS!=0){
            numS--;
        }else if(s[i]=='T'&&numS==0){
            numT++;
        }
    }
    cout << numS+numT << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int n,m;
struct edge{
	int to,co,p;
};

vector<edge> vs[105];

int gone[105];
int dfs(int no,int f,int gl){
	gone[no]=1;
	if(no==gl)return f;
	rep(i,vs[no].size()){
		edge& e = vs[no][i];
		if(gone[e.to])continue;
		if(e.co==0)continue;
		int tf=dfs(e.to,min(f,e.co),gl);
		if(tf!=0){
			e.co -= tf;
			vs[e.to][e.p].co += tf;
			return tf;
		}
	}
	return 0;
}

int ford(int st,int gl){
	int res=0;
	for(;;){
		memset(gone,0,sizeof(gone));
		int f=dfs(st,IINF,gl);
		if(f==0)break;
		res+=f;
	}
	return res;
}

int main(void){
	scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		edge e;
		e.co=c; e.to=b; e.p = vs[b].size();
		vs[a].push_back(e);
		e.co=0; e.to=a; e.p = vs[a].size()-1;
		vs[b].push_back(e);
	}
	
	printf("%d\n",ford(0,n-1));
	return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct Node{
	int data;
	Node* prev;
	Node* next;
};

class List{
public:
	List(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;	//円環構造を作る
		motherNode->next = motherNode;
		num_of_node = 0;
		current = 0;
	};

	void insertFromLast(int x){	//過去最大数なので末尾へ追加
		Node* tmpNode = motherNode->prev;
		if(tmpNode == motherNode){	//初めてデータを登録する場合
			motherNode->next = new Node();
			motherNode->next->data = x;
			motherNode->next->next = motherNode;
			motherNode->next->prev = motherNode;
			motherNode->prev = motherNode->next;
			current = motherNode->next;	//★currentの初期値を設定★
		}else{	//既に登録されているデータが存在する場合
			while(tmpNode != motherNode && tmpNode->data > x){
				tmpNode = tmpNode->prev;
			}
			Node* nextNode = tmpNode->next;
			tmpNode->next = new Node();
			tmpNode->next->data = x;
			tmpNode->next->next = nextNode;
			tmpNode->next->prev = tmpNode;
			nextNode->prev = tmpNode->next;
		}
		num_of_node++;
	}

	//時計回り方向にa移動し、移動先のノードを削除する関数
	void upDist(int a){
		int to_move = a%num_of_node,count = 0;

		if(to_move > num_of_node-(to_move-3)){	//反時計周りに動いた方が早いなら、そうする
			downDist(num_of_node-to_move);
			return;
		}

		Node* tmp = current;
		while(count < to_move){
			tmp = tmp->next;
			if(tmp != motherNode){
				count++;
			}
		}

		//motherNodeの時countは増えないので、count == to_moveとなった箇所がmotherNodeであることはありえない
		if(tmp->next == motherNode){
			current = motherNode->next;
		}else{
			current = tmp->next;
		}

		tmp->prev->next = tmp->next;
		tmp->next->prev = tmp->prev;
		delete tmp;
		num_of_node--;
	}

	//反時計周りにa移動し、移動先のノードを削除し、その番号を返却する関数
	void downDist(int a){

		int to_move = a%num_of_node,count = 0;

		Node* tmp = current;
		while(count < to_move){
			tmp = tmp->prev;
			if(tmp != motherNode){
				count++;
			}
		}

		//motherNodeの時countは増えないので、count == to_moveとなった箇所がmotherNodeであることはありえない
		if(tmp->next == motherNode){
			current = motherNode->next;
		}else{
			current = tmp->next;
		}

		tmp->prev->next = tmp->next;
		tmp->next->prev = tmp->prev;
		delete tmp;
		num_of_node--;
	}

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		printf("\n");
	}

private:
	Node* motherNode;
	Node* current; //バトンを持っている人のノードを保存するためのポインタ
	int num_of_node;
};

void func(int n,int k,int m){

	List list;

	for(int i=0; i < n; i++){
		list.insertFromLast(i+1); //0～n-1のノードを追加
	}

	//ノードmを消去する
	list.upDist(m-1);

	//n-2個のノードを消す
	for(int i=0; i < n-2; i++){
		list.upDist(k-1);
	}

	list.showList();
}

int main(){

	int n,k,m;
	while(true){
		scanf("%d %d %d",&n,&k,&m);
		if(n == 0 && k == 0 && m == 0)break;

		func(n,k,m);
	}
    return 0;
}



Measured memory_bytes: 3544
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
  Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int m = scanner.nextInt();
    int ans = 0;
    if(n > 1){
      ans += (n * (n -1))/2;
    }
    if(m > 1){
      ans += (m * (m - 1))/2;
    }
    System.out.println(ans);
  }
}

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

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

    if (N == 3) {
        cout << "2 5 63" << endl;
        return 0;
    }

    int MAX = 30000;

    vector<int> ans;
    ans.push_back(2);
    ans.push_back(3);
    ans.push_back(4);
    ans.push_back(9);

    int x6 = 6;
    int x2 = 8;
    int x3 = 15;

    for(int i = 4; i < N; i++) {
        if(i < N - 1 && x2 + 2 <= MAX) {
            ans.push_back(x2);
            ans.push_back(x2 + 2);
            x2 += 6;
            i++;
        }else if(i < N - 1 && x3 + 6 <= MAX) {
            ans.push_back(x3);
            ans.push_back(x3 + 6);
            x3 += 12;
            i++;
        }else{
            ans.push_back(x6);
            x6 += 6;
        }
    }

    for (int i = 0; i < ans.size(); i++)
    {
        if (ans.size() > N && ans[i] == MAX)
            continue;
        if (i == 0)
            cout << ans[i];
        else
            cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    ld a, t, r; cin >> a >> t >> r;
    print(t * r / a);

    return 0;
}


Measured memory_bytes: 3256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String tmp = "";
		int count[] = new int[26];
		char al = 'a';
		while(sc.hasNext()){
			tmp += sc.nextLine();
		}
		for(int i = 0; i < tmp.length(); i++){
			int c = tmp.charAt(i);
			if('a' <= c && c <= 'z'){
				count[c - 'a']++;
			}else if('A' <= c && c <= 'Z'){
				count[c - 'A']++;
			}
		}
		for(int i = 0; i < count.length; i++){
			System.out.println(al++ + " : " + count[i]);
		}
	}

}

Measured memory_bytes: 26200
using System;
class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var ab = int.Parse(input[0]);
        var bc = int.Parse(input[1]);
        var ca = int.Parse(input[2]);
        var area = bc * ab / 2;
        Console.WriteLine(area);
    }
}

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

int main(){

    while(1){
        int N, K, S; cin >> N >> K >> S;
        if(!N) break;

        int dp[22][22][160] = {};      //dp[n][k][s] :=   n以下の数字をk個使ってsを作る組み合わせ
        dp[0][0][0] = 1;
        for(int n = 1; n <= N; n++){
            for(int k = 0; k <= K; k++){
                for(int s = 0; s <= S; s++){
                    if(s - n >= 0 && k != 0) dp[n][k][s] += dp[n - 1][k - 1][s - n];

                    dp[n][k][s] += dp[n - 1][k][s];
                }
            }
        }
        cout << dp[N][K][S] << endl;
    }

    return 0;
}


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

ll n,w;
ll dp[105][100005];

int main(){
    cin >> n >> w;
    for(ll i=1;i<=n;i++){
        ll ww,vv;
        cin >> ww >> vv;
        for(ll j=0;j<=w;j++){
            if(j-ww>=0) dp[i][j]=max(dp[i-1][j],dp[i-1][j-ww]+vv);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout << dp[n][w] << endl;
}


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

typedef long long ll;

constexpr ll MAX = 5000000;
constexpr ll MOD = 1000000007;
ll fac[MAX + 1], facinv[MAX + 1];
// fac[i] = i!;
// facinv[i] = (i!)^-1 (mod MOD)

constexpr ll extgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  // ll d = extgcd(b, a % b, x, y);
  // ll temp = x;
  // x = y;
  // y = temp - (a / b) * x;
  ll d = extgcd(b, a % b, y, x);
  y -= (a / b) * x;
  return d;
}

constexpr ll modinv(ll a, ll m) {
  // Need: gcd(a, m) = 1;
  // a^-1(mod. m)は
  // ax+my=gcd(a, m)=1;
  // を満たすxである。(それはそう,両辺をmodを法としてmodを考えてみよう)
  ll x = 0, y = 0;
  extgcd(a, m, x, y);
  return (x % m + m) % m;
}

constexpr void COMInit(ll *fac, ll *facinv) {
  // O(MAX log MOD)
  fac[0] = 1;
  for (int i = 1; i <= MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
  }
  facinv[MAX] = modinv(fac[MAX], MOD);
  for (int i = MAX; i >= 0; i--) {
    facinv[i - 1] = facinv[i] * (i) % MOD;
  }
}

ll comb(ll n, ll r) {
  //           n!
  // nCr = -----------
  //        r!*(n-r)!
  return (fac[n] * facinv[r]) % MOD * facinv[n - r] % MOD;
}

int main() {
  COMInit(fac, facinv);
  ll x, y;
  cin >> x >> y;
  if ((2 * x - y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if ((2 * y - x) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll a = (2 * x - y) / 3;
  ll b = (2 * y - x) / 3;
  if (a < 0 || b < 0) {
    cout << 0 << endl;
    return 0;
  }
  a %= MOD;
  b %= MOD;
  cout << comb((a + b) % MOD, a) << endl;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
#define all(x) x.begin(),x.end()
#define mx 32
using namespace std;

void masterstroke(){
	ll n;
	cin>>n;
	ll a[n];
	ll un=1;
	vector <ll> ans;
	for(ll i=0;i<n;i++)
	cin>>a[i];
	
	ll c[n+1]={0};
	ll t=0;

	for(ll i=n-1;i>=0;i--){
		ll f=i+1;
	    ll t=0;
		for(ll j=2*f;j<=n;j+=f){
		t+=c[j];
		}
		if(a[i]%2!=t%2){c[f]=1;ans.PB(f);}
		
		
		}
	
	ll ze=ans.size();
	cout<<ze<<endl;
	for(ll i=0;i<ze;i++){
	cout<<ans[i]<<" ";
	}

	
    

}


int main() {
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke();
	
	// your code goes here
	return 0;
}


Measured memory_bytes: 4980
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);


    let (n, x): (i64, i64) = (sc.input(), sc.input());
    let mut a: Vec<i64> = (0..n)
        .map(|_| sc.input())
        .collect();


    let mut index = 0;
    let mut ans = 0;
    while index + 1 < a.len() {
        let cur = a[index];
        let next = a[index + 1];

        if cur + next > x {
            let diff = cur + next - x;
            if diff <= next {
                a[index + 1] = next - diff;
            } else {
                a[index] -= diff - next;
                a[index + 1] = 0;
            }
            ans += diff;

        }

        index += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, S; cin >> N >> S;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	int sum(0), l(0), r(0), ans(INF);
	while (r < N) {
		while (r < N&&sum < S)sum += a[r++];
		if (sum >= S)chmin(ans, r - l);
		while (l < r&&sum >= S) {
			chmin(ans, r - l);
			sum -= a[l++];
		}
	}
	cout << (ans == INF ? 0 : ans) << endl;
	return 0;
}

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

int main() {
    double pi = 3.141592653589;
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double kaku = min(30*H-5.5*M, 360-30*H+5.5*M);
    double kyori2 = A*A + B*B - 2*A*B* cos(kaku*pi/180);

    cout << fixed << setprecision(15) << sqrt(kyori2) << endl;
}

Measured memory_bytes: 4196
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n); std::vector<int> p(n);
	for(int i = 0; i < n; i++) scanf("%d", &p[i]); sort(begin(p), end(p));
	
	int sum = 0;
	for(auto v : p) sum += v;
	cout << sum - p.back() / 2 << endl;
	return 0;
}


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

ll maxxx(pair<ll, ll> a) {
  int x = to_string(a.first).size();
  int y = to_string(a.second).size();
  return max(x, y);
}

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

  vector<pair<ll, ll> > ans;

  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) ans.push_back(make_pair(i, n / i));
  }
  ll num = 1 << 17;
  for (int i = 0; i < ans.size(); i++) {
    num = min(num, maxxx(ans[i]));
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<int> A;
  A.push_back(0);
  for (int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  A.push_back(0);
  ll cost = 0;
  for (int i = 0; i <= N+1; i++) {
    cost += abs(A[i] - A[i-1]);
  }

  for (int i = 1; i <= N; i++) {
    ll res = cost;
    if (A[i-1] > A[i] && A[i+1] > A[i]) {
      res -= abs(A[i] - min(A[i-1],A[i+1])) * 2;
    } else if (A[i-1] < A[i] && A[i+1] < A[i]) {
      res -= abs(max(A[i-1],A[i+1]) - A[i]) * 2;
    } else {
      res -= 0;
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std ;
#define P pair<int,int>
#define pb push_back

main(){
	
	int N,M,s,t,e,L ;
	int b[10010] ;
	vector<int> V[10010] ;
	map<P,int> E ;
	
	cin >> N >> M ;
	while( cin >> s >> t >> e , s ){
		V[s].pb(t) ;
		E[P(s,t)] = e ;
	}
	
	cin >> L ;
	for( int i=0 ; i<L ; i++ ){
		int c[10010] = {} ;
		for( int j=1 ; j<=M ; j++ ) cin >> b[j] ;
		for( int j=1 ; j<=N ; j++ )
			for( int k=0 ; k<V[j].size() ; k++ )
				c[j] += b[V[j][k]] * E[P(j,V[j][k])] ;
		for( int j=1 ; j<=N ; j++ ){
			cout << c[j] ;
			if( j != N ) cout << ' ' ;
			else cout << endl ;
		}
			
	}
}

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

#define N 1000000

int main() {
    
    int n, q, b, count = 0, l, r, m;
    cin>>n; //入力

    int a[N];
    for(int i = 0; i < n; i++) cin>>a[i];
    
    cin>>q; //入力
    /* 二分探索 */
    for(int j = 0; j < q; j++) {
        cin>>b; //入力
        
        l = 0;
        r = n;
        while(r > l) {
            m = (l+r) / 2;
            if(a[m] == b) {
                count++;
                break;
            }
            else if(a[m] > b) {
                r = m;
                continue;
            }
            else if(a[m] < b) {
                l = m + 1;
                continue;
            }
        }
    }
    
    cout<<count<<endl; //出力
    return 0;
}



Measured memory_bytes: 3412
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int H,W;cin >> H >> W;
    vector<vector<int> > a(H,vector<int>(W));
    rep(i,H)rep(j,W){
        cin >> a[i][j];
        a[i][j]%=2;
    }
    vector<pii> res;
    int carry = 0;
    rep(i,H){
        if(i%2==0){
            rep(j,W){
                if(a[i][j]==1||carry==1){
                    res.push_back(make_pair(i,j));
                    if(carry&&!a[i][j])res.push_back(make_pair(i,j));
                    if(a[i][j]==1)carry = 1-carry;
                }
            }
        }
        else if(i%2==1){
            rep(j,W){
                if(a[i][W-j-1]==1||carry==1){
                    res.push_back(make_pair(i,W-j-1));
                    if(carry&&!a[i][W-j-1])res.push_back(make_pair(i,W-j-1));
                    if(a[i][W-j-1]==1)carry = 1-carry;
                }
            }
        } 
    }
    int N = res.size()/2;
    cout << N << endl;
    for(int i=0;i<=N*2-1;i+=2){
        cout << res[i].first+1 << " " << res[i].second+1 << " ";
        cout << res[i+1].first+1 << " " << res[i+1].second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; ll M; cin >>N >>M;
  vector<ll> A(N); rep(i, N) cin >>A[i];
  // 任意のA_iに対して以下の条件を満たす正の整数xの個数を求めよ。
  // X = A_i * (p + 0.5) を満たす負でない整数pが存在する
  rep(i, N) A[i] /= 2;
  // 任意のA_iに対して以下の条件を満たす正の整数xの個数を求めよ。
  // X = A_i * (2p + 1) を満たす負でない整数pが存在する
  // X = A_i * P を満たす正の奇数Pが存在する

  // X は A_iの公倍数であり、かつA_i * 奇数 で表される

  // まず最小公倍数を求めれば良さそう
  ll l = 1;
  rep(i, N){
    l = lcm(l, A[i]);
    if (l > M){
      // 最小公倍数がMを超えたとするとM以下の公倍数は存在しない
      cout <<0 <<endl; return 0;
    }
  }
  // 最小公倍数がl
  // 全てのA_iの奇数倍数であることを確認する。そうでなければ0
  rep(i, N){
    if ((l/A[i])%2 == 0){
      cout <<0 <<endl; return 0;
    }
  }
  // 条件を満たしていれば、M以下のlの倍数のうちl * 奇数 の形で示されるものの個数が答え
  ll res = (M/l + 1) / 2;
  cout <<res <<endl;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  var t: Long = 1
  var a: Long = 1
  for(i in 1..N){
    val (T,A) = readLine()!!.split(" ").map(String::toInt)
    val k = max((t+T-1)/T, (a+A-1)/A)
    t = T*k
    a = A*k
  }
  println(t+a)
}
fun <T: Comparable<T>>max(x: T, y: T): T{
  return if(x>=y) x else y
}

Measured memory_bytes: 37804
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");

	char str[MAX_N];
	scanf("%s", str);
	int len = strlen(str);
	for (int i = 0; i < len; i += 2)
		putchar(str[i]);
	puts("");
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  ll p;
  cin >> n >> m >> l >> p;
  if(n * m >= l * p)print(n*m);
  else print(l*p);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int A,B;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> A >> B;
  cout << max({A+B,A-B,A*B}) << endl;

  return 0;
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
// #define cerr if(false)cerr
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;

inline void solve()
{
    int n;
    cin >> n;
    vll arr(4, 0);
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s.compare("AC") == 0){
            arr[0]++;
        }
        else if (s.compare("WA")==0){
            arr[1]++;
        }
        else if(s.compare("TLE")==0)
            arr[2]++;
        else if (s.compare("RE")==0)
            arr[3]++;
    }
    cout << "AC x " << arr[0] << "\nWA x " << arr[1] << "\nTLE x " << arr[2] << "\nRE x " << arr[3];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3652
n, x = map(int, input().split())
a = list(map(int, input().split()))

ans = max(a[0] - x, 0)
a[0] = min(a[0], x)
for i in range(1, n):
    ans += max(a[i - 1] + a[i] - x, 0)
    a[i] = min(x - a[i - 1], a[i])

print(ans)


Measured memory_bytes: 14132
#include<stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if((a+b) > (c+d)) printf("Left\n");
    else if((a+b) == (c+d)) printf("Balanced\n");
    else printf("Right\n");
    
    return 0;
}

Measured memory_bytes: 128
N = int(input())
K = int(input())
x = map(int, input().split())
x = list(x)
ans = 0
for i in range(N):
    s = K - x[i]
    if(x[i] > s):
        ans += s
    else:
        ans += x[i]
    
print(ans * 2)


Measured memory_bytes: 3060
program ABC140B
    implicit none
    integer::N,i,ans=0
    integer,allocatable::A(:),B(:),C(:)
    read*,N
    allocate(A(N))
    allocate(B(N))
    allocate(C(N-1))
    read*,A,B,C
    do i=1,N
        ans=ans+B(A(i))
        if(i>=2.and.A(i)-A(i-1)==1)ans=ans+C(A(i-1))
    end do
    print'(i0)',ans
end program ABC140B

Measured memory_bytes: 2804
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

template <typename T>
T gcd(T n1, T n2) {
	return n1 ? gcd(n2 % n1, n1) : n2;
}
template <typename T>
T lcm(T n1, T n2) {
	return n1 * n2 / gcd(n1, n2);
}

int main()
{
	i64 N;
	cin >> N;
	i64 ans = lcm<i64>((i64)2, N);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0;i<n;++i)
	{
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	cout<<v[n/2]-v[n/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#define mod 1000000007
using namespace std; 

int main(){
	int n,k; cin >> n >> k;
	map<int,int> A;
	for (int i=0;i<k;i++){
		int a; cin >> a;
		for (int j=0;j<a;j++){
			int s; cin >> s;
			A[s]++;
		}
	}
	cout << n-A.size() << "\n";
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//------------------------------------------------

int w, h;
int fld[100][100];
int dx[2][6] = {{0, 1, 1, 1, 0, -1}, {-1, 0, 1, 0, -1, -1}};
int dy[2][6] = {{-1, -1, 0, 1, 1, 0}, {-1, -1, 0, 1, 1, 0}};


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

	cin >> w >> h;
	REP(i, h) REP(j, w) cin >> fld[i][j];

	queue<P> Q;
	REP(i, h) {
		if (fld[i][0] == 0) {
			fld[i][0] = -1;
			Q.push(P(i, 0));
		}
		if (fld[i][w - 1] == 0) {
			fld[i][w - 1] = -1;
			Q.push(P(i, w - 1));
		}
	}
	REP(j, w) {
		if (fld[0][j] == 0) {
			fld[0][j] = -1;
			Q.push(P(0, j));
		}
		if (fld[h - 1][j] == 0) {
			fld[h - 1][j] = -1;
			Q.push(P(h - 1, j));
		}
	}

	while(Q.size()) {
		P p = Q.front(); Q.pop();
		REP(i, 6) {
			int nx = p.se + dx[p.fi & 1][i], ny = p.fi + dy[p.fi & 1][i];
			if (nx < 0 || nx >= w || ny < 0 || ny >= h || fld[ny][nx] != 0) continue;
			fld[ny][nx] = -1;
			Q.push(P(ny, nx));
		}
	}

    int ans = 0;
	REP(i, h) {
		REP(j, w) {
			if (fld[i][j] != 1) continue;
			REP(k, 6) {
				int nx = j + dx[i & 1][k], ny = i + dy[i & 1][k];
				if (nx < 0 || nx >= w || ny < 0 || ny >= h || fld[ny][nx] == -1) ans++;
			}
		}
	}
    cout << ans << endl;

	return 0;
}




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

ll N, M;
const ll MAX_N = 1.0e5 + 100;
ll p[MAX_N];
string S[MAX_N];

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> p[i] >> S[i];
    }

    pair<bool, ll> ans[N+1];
    for (int i = 1; i <= N; i++) {
        ans[i] = make_pair(false, 0);
    }

    for (int i = 0; i < M; i++) {
        if (S[i] == "AC") {
            ans[p[i]].first = true;
        }
        else {
            if (!ans[p[i]].first) {
                ans[p[i]].second++;
            }
        }
    }

    ll ac = 0;
    ll wa = 0;
    for (int i = 1; i <= N; i++) {
        if (ans[i].first) {
            ac++;
            wa += ans[i].second;
        }
    }

    cout << ac << " " << wa << endl;

    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,Y;
    cin>>N>>Y;
    Y/=1000;
    for(int i=0; i<=N; i++) {
        for(int j=0; j<=N; j++) {
            if(i+j<=N&&i+5*j+(N-i-j)*10==Y) {
                cout<<N-i-j<<" "<<j<<" "<<i<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

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

int main () {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n), c(m), d(m);
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,m) cin >> c[i] >> d[i];
  rep(i,n) {
    int k = 0, mind = 1e9;
    rep(j,m) {
      int md = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(md < mind) {
        mind = md;
        k = j;
      }
    }
    cout << k + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=100005;
i64 a[maxn];
int n;
int prime[maxn],tot;
bool flag[maxn];
inline void solve(int n){
	memset(flag,1,sizeof(flag));
	rep(i,2,n){
		if(flag[i])prime[++tot]=i;
		rep(j,1,tot){
			if(i*prime[j]>n)break;
			flag[i*prime[j]]=0;
			if(i%prime[j]==0)break;
		}
	}
}
map<i64,int> cnt;
map<i64,i64> op;
set<i64> used;
inline i64 calc(i64 x){
	i64 res=1;
	rep(j,1,tot)if(x%prime[j]==0){
		if(x%(prime[j]*prime[j])==0)res*=prime[j];
		else res*=prime[j]*prime[j];
		while(x%prime[j]==0)x/=prime[j];
	}
	if(x!=1){
		i64 tmp=sqrt(x);
		while((tmp+1)*(tmp+1)<=x)tmp++;
		while(tmp*tmp>x)tmp--;
		if(tmp*tmp==x){
			res*=tmp;
		}else
			res*=x*x;
	}return res;
}
int main(){
	read(n);
	rep(i,1,n)scanf("%lld",&a[i]);
	solve(3000);
	rep(j,1,tot){
		i64 v=1ll*prime[j]*prime[j]*prime[j];
		rep(i,1,n)while(a[i]%v==0)a[i]/=v;
	}
	int ans=0;
	rep(i,1,n){
		if(a[i]==1){
			ans=1;continue;
		}
		cnt[a[i]]++;
		op[a[i]]=calc(a[i]);
	}
	for(auto x:cnt){
		i64 v1=x.w1;
		i64 v2=op[v1];
		if(used.count(v1))continue;
		if(v2==0){
			ans+=x.w2;
		}else{
			ans+=max(cnt[v1],cnt[v2]);
			used.insert(v2);
		}
	}cout<<ans;
    return 0;
}


Measured memory_bytes: 29312