akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    ll n; cin >> n;
    string s; cin >> s;

    // 全て異なる文字の場合は、それぞれのオンオフ考慮して-1なので2*n-1
    // 重複文字がある場合は重複文字に関してはその重複数通り
    map<char, ll> m;
    REP(i, n) {
        if (m.find(s[i]) == m.end()) {
            m[s[i]] = 0;
        }
        m[s[i]]++;
    }
    ll res = 1;
    for (auto e:m) {
        // 同じ文字の中からの選び方は、どれかを選ぶかどれも選ばないか
        res *= (e.second + 1);
        res %= 1000000007;
    }
    // すべての文字を選ばないことはできないので-1
    res -= 1;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define MAX 505
#define MOD 1000000007

typedef long long ll;

int main(int, char**)
{
    int k, a, b;
    cin >> k >> a >> b;

    if (a % k == 0 || b % k == 0 || a / k != b / k) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3636
N=int(input())
A=list(map(int, input().split()))
A=[0]+A+[0]
B=[abs(A[i+1]-A[i]) for i in range(N+1)]
C=[abs(A[i+2]-A[i]) for i in range(N)]
Bsum=sum(B)
D=[Bsum-B[i-1]-B[i]+C[i-1] for i in range(1, N+1)]
for i in range(N):
  print(D[i])

Measured memory_bytes: 20620
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Console.WriteLine(getFriend(a));
    }
    public static int getFriend(int[] a)
    {
        var n = a.Length;
        var chk = new bool[n];
        var ret = 0;
        for (int i = 0; i < n; i++)
        {
            if (chk[i]) continue;
            var w = a[i] - 1;
            var w2 = a[w] - 1;
            if (w2 == i) { chk[w] = true; ret++; }
        }
        return ret;
    }
}

Measured memory_bytes: 18912
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int N;
string S;
map<string,ll int> a;
cin >> N;
rep(i,N){
	cin >> S;
	a[S] += 1;
}

cout << "AC x " << a["AC"] << endl;
cout << "WA x " << a["WA"] << endl;
cout << "TLE x " << a["TLE"] << endl;
cout << "RE x " << a["RE"] << endl;










	return 0;

}



Measured memory_bytes: 3632
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll 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() {
  IOS;
  ll a,b;
  cin>>a>>b;
  cout<<LCM(a,b)<<endl;
}

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

int main() {
  std::string s;
  cin >> s;
  int max_length = 0, cur_length = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' ||
        s[i] == 'C' ||
        s[i] == 'G' ||
        s[i] == 'T') {
      cur_length++;
    } else {
      max_length = max(max_length, cur_length);
      cur_length = 0;
    }
  }
  max_length = max(max_length, cur_length);
  cout << max_length << endl;
  return 0;
}


Measured memory_bytes: 256
n,x,y = map(int,input().split())
ans = [0]*(n-1)
for i in range(1, n+1):
    for j in range(i+1, n+1):
        if i <= x and j >= y:
            ans[x-i+j-y] += 1
        else:
            if i < x and j < y:
                temp = min(j-i, x-i+1+y-j)
                ans[temp-1] += 1
            elif i > x and j > y:
                temp = min(j-i, i-x+1+j-y)
                ans[temp-1] += 1
            else:
                temp = min(j-i, i-x+1+y-j)
                ans[temp-1] += 1
for i in range(n-1):
    print(ans[i])


Measured memory_bytes: 48348
#include<bits/stdc++.h>
using namespace std;
string s;
int Bit[200003],m[200003];
vector<int>v[26];
void add(int x,int a){
	while(x<=s.size()){
		Bit[x]+=a;
		x+=x&(-x);
	}
}
int que(int x){
	int ret=0;
	while(x)ret+=Bit[x],x-=x&(-x);
	return ret;
}
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++)
		v[s[i]-'a'].push_back(i),add(i+1,1);
	int cnt=0;
	for(int i=0;i<26;i++)
	{
		cnt+=(v[i].size()&1);
		for(int j=0;j<v[i].size();j++)
			m[v[i][j]]=v[i][v[i].size()-1-j]+1;
	}
	if(cnt>1){cout<<-1;return 0;}
	long long ans=0;
	for(int i=0;i<s.size();i++){
		ans+=(que(s.size())-que(m[i]));
		add(m[i],-1);
	}
	cout<<ans/2;
}

Measured memory_bytes: 3068
using System;

class Program
{
	static int[] a;
	static int count;

	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] input = Console.ReadLine().Split(' ');

		a = new int[n];
		for (int i = 0; i < a.Length; i++)
		{
			a[i] = int.Parse(input[i]);
		}

		BubbleSort();

		for (int i = 0; i < a.Length; i++)
		{
			Console.Write((i > 0 ? " " : "") + a[i]);
		}
		Console.WriteLine("\n" + count);
	}

	static void BubbleSort()
	{
		bool flag = true;

		while (flag)
		{
			flag = false;
			for (int i = a.Length-1; i > 0; i--)
			{
				if(a[i] < a[i-1])
				{
					int buf = a[i];
					a[i] = a[i - 1];
					a[i - 1] = buf;

					count++;
					flag = true;
				}
			}
		}
	}
}

Measured memory_bytes: 9216
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/


#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int n, aa, count = 0;
	bool a[101] = {};
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d", &aa);
		if (!a[aa]) {
			++count;
			a[aa] = true;
		}
	}
	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const ll N = 105;
const ll W = 10005;
ll dp[W];

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, w;
  cin >> n >> w;
  vector<P> p(n);
  rep(i,n) {
    ll vi, wi;
    cin >> vi >> wi;
    p[i] = { vi, wi };
  }

  rep(i,n) {
    ll vi, wi;
    tie(vi,wi) = p[i];
    for (ll j = w; j >= 0; --j) {
      if (j-wi >= 0) {
        chmax(dp[j], dp[j-wi] + vi);
      }
    }
  }

  cout << dp[w] << endl;
}



Measured memory_bytes: 3228
#include<stdio.h>

int main(void)
{
	
	int a, b, c;
	
    scanf("%d %d %d",&a, &b, &c);
    
    if(a < b && b < c){
    	printf("Yes\n");
    }
    else{
    	printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<60;
int MOD = 1e9 + 7;

int N,Q;
vector<vector<ll> > G(200010);
vector<ll> cost(200010);
vector<bool> visited(200010,false);

void bfs(int s){
    queue<int> que; que.push(s);
    visited[s] = true;
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(auto nv: G[v]){
            if(visited[nv] == false){
                que.push(nv);
                cost[nv] += cost[v];
                visited[nv] = true;
            }
        }
    }
}

int main(){
    cin >> N >> Q;
    
    rep(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b); G[b].push_back(a);
    }
    
    rep(i,Q){
        int a,b; cin >> a >> b;
        a--;
        cost[a] += b;
    }

    bfs(0);
    rep(i,N-1) cout << cost[i] << " ";
    cout << cost[N-1] << endl;
}

Measured memory_bytes: 17136
A, B = map(int, input().split())
parind = [0]*(B+1)
for i in range(1,B+1):
  parind[i] = parind[i-1]
  if str(i) == str(i)[::-1]:
    parind[i] += 1

ans = parind[B]-parind[A-1]
print(ans)

#print(*ans, sep='\n')


Measured memory_bytes: 3828
a,b=map(int,input().split())
def gcd(a,b):
  while b:a,b=b,a%b
  return a
c=gcd(a,b)
def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
def is_prime(n):
  if n==1:return True#特例
  for i in range(2,int(n**0.5)+1):
    if n%i==0:return False
  return True
d=sorted(divisor(c))
x=0
for i in d:
  if is_prime(i):x+=1
print(x)

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

int main()
{
    int n;
    cin>>n;
    ll a[n];
    ll sum=0;
    map<ll,ll>mp;
    for(int i=0;i<n;i++){
      cin>>a[i];
      sum+=a[i];
      mp[a[i]]++;
    }
    int q;
    cin>>q;
    while(q--){
      ll x,y;
      cin>>x>>y;
      cout<<sum-mp[x]*x+mp[x]*y<<endl;
      sum=sum-mp[x]*x+mp[x]*y;
      mp[y]+=mp[x];
      mp[x]=0;

    }


}


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

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    
    vector<int> a(q);
    
    rep(i,q) cin >> a[i];
    
    vector<int> ans(n);
    rep(i,n) ans[i] = k-q;
    
    for(int i = 0; i < q; i++){
        ans[a[i]-1]++;
    }
    
    for(int i = 0; i < n; i++){
        if(ans[i]>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        cout << 'x';
    }
    cout << endl;
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/03  Problem: ABC 046 A / Link: http://abc046.contest.atcoder.jp/tasks/abc046_a  ----- */


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

	LL A, B, C; cin >> A >> B >> C;
	set<LL>se({ A,B,C });
	
	LL ans = SZ(se);
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define REP1(i,n1,n2) for (i=n1; i<n2; i++)
string M[14];
int bomb(int x,int y){
	string s=M[y];
	if (s[x]=='0') return 0;
	M[y]=s.substr(0,x)+"0"+s.substr(x+1);
	int i;
	REP1(i,1,4){
		bomb(x+i,y);
		bomb(x-i,y);
		bomb(x,y+i);
		bomb(x,y-i);
	}
	return 0;
}

int main(){
	int i,j,n;
	string s;
	REP1(i,0,14) M[i]="00000000000000";
	cin>>n;
	REP1(i,0,n){
		getline(cin,s);
		getline(cin,s);
		REP1(j,3,11){
			getline(cin,s);
			M[j]="000"+s+"000";
		}
		int x,y;
		cin>>x>>y;
		x+=2;
		y+=2;
		bomb(x,y);
		cout<<"Data "<<i+1<<":\n";
		REP1(j,3,11) cout<<M[j].substr(3,8)<<"\n";
	}
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        int [] t = new int[n];
        for (int i = 0 ; i < n ; i++) {
            s[i] = sc.next();
            t[i] = sc.nextInt();
        }
        String x = sc.next();

        boolean flg = false;
        int sum = 0;
        for (int i = 0 ; i < n ; i++) {
            if (flg) {
                sum += t[i];
            }
            if (s[i].equals(x)) {
                flg = true;
            }

        }

        System.out.println(sum);

    }

}

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

int main() {
	// your code goes here
	int n,x,l[1000],i,ans=1,sum=0;
	cin >> n >> x;
	for(i=1;i<=n;i++) cin >> l[i];
	l[0]=0;
	sum=0;
	for(i=1;i<=n;i++){
		sum=sum+l[i];
		if(sum<=x) ans++;
		else break;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int X;
    cin >> X;
    vector<int> x(100200,0);
    x[0] = 1;
    rep(i,X+1){
        if(x[i] == 1){
            x[i+100] = 1;
            x[i+101] = 1;
            x[i+102] = 1;
            x[i+103] = 1;
            x[i+104] = 1;
            x[i+105] = 1;
        }
    }
    cout << (x[X]?"1":"0") << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

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

int N;
ll K;
vector<pii> A;

int main(void) {
	cin >> N >> K;
	A.resize(N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		A[i] = make_pair(a, b);
	}
	sort(A.begin(), A.end());

	int ans;
	ll sum = 0;
	for (int i = 0; i < N; ++i) {
		sum += A[i].second;
		if (sum >= K) {
			ans = A[i].first;
			break;
		}
	}

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


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string a;
	cin>>a;
	int len=a.length();
	for(int i=1;i<=len;i++){
		cout<<"x";
		
	}
	cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

const int MAX_C = 1000;
long long Com[MAX_C][MAX_C];
 
void calc_com() {
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_C; ++i) {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_C; ++j) {
            Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]);
        }
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    calc_com();
    ll n,p;cin>>n>>p;
    ll e=0,o=0;
    rep(i,n){
        ll t;cin>>t;
        if(t%2==0)  e++;
        else        o++;
    }
    ll a=1,b=0;
    rep(i,e) a*=2;
    for(ll i=p;i<=o;i+=2){
        b+=Com[o][i];
    }
    cout<<a*b<<endl;
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define long long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= 5e5+10;
int n;
long L, res= 0;
int all= 0;
struct trie
{
    int Link[2], red;
}t[N];
string s;

void add()
{
    int cur= 0;
    up(i,0,(int)s.size()-1)
    {
        int c= (int)(s[i]- '0');
        if (t[cur].Link[c]== 0) t[cur].Link[c]= ++all;
        cur= t[cur].Link[c];
    }
    t[cur].red= 1;
}
long sg(long a)
{
    long res= 1;
    while (a!=0 and a%2== 0) a/= 2, res*= 2;
    return res;
}
void dfs(int cur, int h)
{
	if (t[cur].red) return;
    up(c,0,1)
     if (t[cur].Link[c]) dfs(t[cur].Link[c], h+1);
     else res^= sg(L- h);
}
void input()
{
    cin>>n>>L;
    up(i,1,n)
    {
        cin>>s; add();
    }
}
void solve()
{
    dfs(0, 0);
    if (res) cout<<"Alice"; else cout<<"Bob";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
	  #endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 6352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int a, b;

// index が条件を満たすかどうか
bool isOK(int x) {
    return x * 0.08 >= a && x * 0.1 >= b;
}

int main() {
    cin >> a >> b;
    int l = -1, r = 1000;
    while (r - l > 1) {
        int mid = l + (r - l) / 2;
        if (isOK(mid)) r = mid;
        else l = mid;
    }
    int xa = r * 0.08;
    int xb = r * 0.1;
    if (xa == a && xb == b)
        cout << r << endl;
    else
        cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
n = N
cnt = 0
while n>0:
  n = n//10
  cnt += 1

if cnt==1:
  print(N)
else:
  tmp = "90"*(cnt//2)
  tmp = int(tmp[:-1])

  if cnt%2!=0:
    tmp += N-int("9"*(cnt-1))

  print(tmp)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <map>
#include <string>

using namespace std;

int ID(string str){
	int num = 0;
	for(int i = 0; i < 500; i++){
		if(str[i] == ','){
			break;
		}
		num *= 10;
		num += (str[i] - '0');
	}
	return num;
}

// ??????????????§??????????????¢?´¢?????????????????????

int main(){
	
	map<int, int> m;
	map<int, int>::iterator ite;
	
	string str;
	int id;
	
	while(true){
		getline(cin, str);
		if(str.size() == 0){
			break;
		}
		id = ID(str);
		ite = m.find(id);
		if(ite != m.end()){
			ite -> second++;
		}else{
			m.insert(make_pair(id, 1));
		}
	}
	
	while(true){
		cin >> str;
		if(cin.eof()){
			break;
		}
		id = ID(str);
		ite = m.find(id);
		if(ite != m.end()){
			if(ite -> second < 10000){
				ite -> second += 10000;
			}
			ite -> second++;
		}
	}
	
	for(ite = m.begin(); ite != m.end(); ite++){
		if(ite -> second > 10000){
			cout << ite -> first << " " << ite -> second - 10000 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>


int f(int a, int b,int c)
{
	if (a * a == b * b + c * c) {
		return 1;
	} else if (b * b == c * c + a * a) {
		return 1;
	} else if (c * c == a * a + b * b) {
		return 1;
	} else {
		return 0;
	}
}
int main()
{
	int N;
	std::cin >> N;
	for (int i = 0; i < N; i++) {
	    int a;
	    int b;
	    int c;
	    std::cin >> a >> b >> c;
	    if (f(a, b, c) == 1) {
		    std::cout << "YES" << std::endl;
	    } else {
		    std::cout << "NO" << std::endl;
		}
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  set<string> x;
  rep(i,s.size()) rep(j, k+1) {
      string p = s.substr(i,j);
      x.insert(p);
  }
  auto itr = x.begin();
  rep(i,k) itr++;
  cout << *itr << endl;
  return 0;
}

Measured memory_bytes: 4792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N,a,r[10]={0},res=0;
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d",&a);
		if(a>=3200)
		{
			r[8]++;
			continue;
		}
		int o=0;
		for(int p=399;p<=3199&&p<a;p+=400)o++;
		r[o]++;
	}
	for(int i=0;i<8;i++)res+=r[i]>0?1:0;
	printf("%d %d\n",max(1,res),res+r[8]);
	return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int n , k ;
    cin >> n >> k ;

    vi v ( n ) ;
    for ( int i=0 ; i < n ; i ++ )
        cin >> v[i] ;

    const int inf = 1e9 + 1e3 ;
    vi dp ( n , inf ) ;

    dp[0] = 0 ;

    for ( int i=0 ; i < n ; i ++ )
    {
        for ( int j = 1 ; j <= k ; j ++ )
        {
            int indx = i + j ;
            if ( indx == n ) break ;

            dp[indx] = min ( dp[indx] , dp[i] + abs ( v[i] - v[indx] ) ) ;
        }
    }

    cout << dp[n - 1] ;
    line
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

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

  if(s == "Sunny") {
    cout << "Cloudy" << '\n';
  }
  else if(s == "Cloudy") {
    cout << "Rainy" << '\n';
  }
  else if(s == "Rainy") {
    cout << "Sunny" << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int a,b,c,e;
   cin>>a>>b;
   vector<int> d(a);
   c=0;
   rep(i,a){
     cin>>d.at(i);
     c+=d.at(i);
   }
   sort(d.begin(),d.end());
   reverse(d.begin(),d.end());
   e=0;
    rep(i,b){
     if(d.at(i)<(double)c/(4*b)){
       e++;
       break;
     }
    }
   if(e==0){
     cout<<"Yes"<<endl;
   }
   else{
     cout<<"No"<<endl;
   }

}


Measured memory_bytes: 256
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  let [nums, dirs] = content.trim().split('\n');
  nums = nums.split(' ').map(n => parseInt(n, 10));
  dirs = dirs.split('');

  const dice = {
    top: [1, 5, 6, 2].map(n => nums[n - 1]),
    right: [1, 3, 6, 4].map(n => nums[n - 1]),
  };
  const result = dirs.reduce((dice, dir) => roll(dice, dir), dice);
  console.log(result.top[0]);
});

const roll = (dice, dir) => {
  switch (dir) {
    case 'W': {
      return Object.assign({}, dice, {
        top: [
          dice.right[1],
          dice.top[1],
          dice.right[3],
          dice.top[3],
        ],
        right: dice.right.slice(1).concat([dice.right[0]]),
      });
    }
    case 'E': {
      return Object.assign({}, dice, {
        top: [
          dice.right[dice.right.length - 1],
          dice.top[1],
          dice.right[1],
          dice.top[3],
        ],
        right: [dice.right[3]].concat(dice.right.slice(0, -1)),
      });
    }
    case 'S': {
      return Object.assign({}, dice, {
        top: dice.top.slice(1).concat([dice.top[0]]),
        right: [dice.top[1], dice.right[1], dice.top[3], dice.right[3]],
      });
    }
    case 'N': {
      return Object.assign({}, dice, {
        top: [dice.top[3]].concat(dice.top.slice(0, -1)),
        right: [dice.top[3], dice.right[1], dice.top[1], dice.right[3]],
      });
    }
  }
};


Measured memory_bytes: 18120
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout<<"OK";
            return 0;
        }
    }   
    cout<<"NG";

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define MOD 1000000007
#define pb push_back
#define ll long long int

using namespace std;

int main(void) {
    fast;
    int a; cin >> a;
    cout << a + a*a + a*a*a;
}



Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> a(n*2,0);
	if(s[0]!='B'||s[2*n-1]!='B'){
		cout<<0<<endl;
		return 0;
	}
	FOR(i,0,n*2){
		if(s[i]=='B'){
			a[i]=1;
		}
	}
	int nw=0,cnt=0;
	LL ans=1;
	FOR(i,0,2*n){
		if((cnt&1)!=a[i]){
			cnt++;
			//ans=mul(ans,cnt);
		}else{
			ans=mul(ans,cnt);
			cnt--;
		}
	}
	if(cnt!=0){
		cout<<0<<endl;
		return 0;
	}
	FOR(i,1,n+1){
		ans=mul(ans,i);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1412
#include <iostream>
#include <fstream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


ll N,C;
int main() {
    cin >> N >> C;
    //メートル
    vector <ll> x(N);
    //カロリー
    vector <ll> c(N);
    ll sum = 0;
    REP(i,N)
    {
        cin >> x[i] >> c[i];
        sum += c[i];
    }


    //最大値のとりかたは、区間になるはず
    //(1~10)とか (9~2->{9,10,1,2})とか
    //小さい方を2倍のカロリーでとればよい
    //Cの最大値が10^14なので、区間は(N)でとる

    ll res = 0;
    
    //左から(時計回り)舐めたときの値と、(区間:0~i)の値
    vector <pair<ll, ll> > l(N+2);
    //時計回りに往復する
    //->反時計周りの方は、独立して考えられる
    //1回しか移動しないときの最大のAを求めておく
    vector <ll> fl(N+2);
    fl[0] = 0;

    l[0].first = 0;
    l[0].second = 0;
    for(ll i = 0; i < N; ++i)
    {
        l[i+1].first = x[i];
        l[i+1].second = l[i].second + c[i];

        res = max(res, l[i+1].second - l[i+1].first);
        fl[i+1] = max(fl[i], l[i+1].second - l[i+1].first);
    }
    l[N+1].first = C;
    l[N+1].second = sum;
    fl[N+1] = fl[N];

    //右から舐めたときの値をそれぞれとる(区間:i~N-1)の値
    vector <pair<ll, ll> > r(N+2);

    vector <ll> fr(N+2);

    fr[0] = 0;
    r[0].first = C;
    r[0].second = 0;
    for(ll i = 0; i < N; ++i)
    {
        r[i+1].first = x[N-1-i];
        r[i+1].second = r[i].second + c[N-1-i];

        res = max(res, r[i+1].second - (C - r[i+1].first));
        fr[i+1] = max(fr[i], r[i+1].second - (C - r[i+1].first));
    }
    r[N+1].first = 0;
    r[N+1].second = sum;
    fr[N+1] = fr[N];

    //時計回りから
    for(ll i = 0; i < N + 1; ++i)
    {
        ll tmp;
        tmp = l[i].second - 2 * l[i].first + fr[N - i];
        res = max(res, tmp);
    }
    //反時計回り
    for(ll i = 0; i < N + 1; ++i)
    {
        ll tmp;
        tmp = r[i].second - 2 * (C - r[i].first) + fl[N - i];
        res = max(res, tmp);
    }




//    for(ll i = 0; i < N + 2; ++i)
//    {
//        for(ll j = 0; j < N + 2; ++j)
//        {
//            //交差するようなら終了
//            if(l[i].first >= r[j].first)break;
//
//            //消費カロリー
//            ll syohi = l[i].first + C - r[j].first + min(l[i].first, C - r[j].first);
//            //摂取カロリー
//            ll sessyu = l[i].second + r[j].second;
//
//            res = max(res,sessyu - syohi);
//        }
//    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC051_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var time = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).ToList();
            var m = int.Parse(Console.ReadLine());
            var ans = new List<int>();
            for(var i=0;i<m;i++)
            {
                var drink = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var dis = time[drink[0] - 1] - drink[1];
                ans.Add(time.Sum() - dis);
            }
            foreach(var ch in ans)
            {
                Console.WriteLine(ch);
            }
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  int to;
  rep(i,10000){
    if(i*(i+1)/2>=n){
      to=i;
      break;
    }
  }
  for (int i =to; i >0; i--){
    if(n>0&&n-i>=0){
      cout<<i<<endl;
      n-=i;
    }
  }
  
}

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

const int inf=1e9+7;

int main()
{
#ifdef LOCAL
	assert(freopen("in.in","r",stdin));
#endif
	int n;cin>>n;
	vector<vector<int>> arr(n,vector<int>(3));
	for(auto& i:arr) cin>>i[0]>>i[1]>>i[2];
	vector<vector<int>> dp(n,vector<int>(3,0));
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	for(auto i=1;i<n;i++){
	dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
	dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
	dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];	
	}      
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
 
int main()
{
    arena
    ll n;
    cin>>n;
    ll arr[n];
    unordered_map<ll,ll> um;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        um[arr[i]]++;
    }
    
    ll sum=0;
    for(auto it:um)
    {
        ll x=it.second;
        sum=sum+(x*(x-1))/2;
    }
    
    for(ll i=0;i<n;i++)
    {
        ll x=sum;
        x=x-(um[arr[i]]-1);
        cout<<x<<'\n';
    }
    
}

Measured memory_bytes: 9160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main()
{
	int i;
	int n, m;
	int num_toi;
	int num_ok = 0;
	int num_pen = 0;
	char aw[5];

	scanf("%d %d", &n, &m);

	int toi[n];
	int wa[n];

	for (i = 0; i < n; i++)
	{
		toi[i] = 0;
		wa[i] = 0;
	}
	

	for (i = 0; i < m; i++)
	{
		scanf("%d", &num_toi);
		scanf("%s", aw);

		if (1 <= num_toi && num_toi <= n)
		{

			if (strcmp(aw, "AC") == 0)
			{
				if (toi[num_toi - 1] != 1)
				{
					toi[num_toi - 1] = 1;
					num_ok++;
					num_pen += wa[num_toi-1];
				}
			}
			else if (strcmp(aw, "WA") == 0)
			{
				if (toi[num_toi - 1] != 1)
				{
					wa[num_toi - 1]++;
				}
			}
		}

	}

	printf("%d %d", num_ok, num_pen);

	
	return 0;

}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{   
    long long N;
    long long A[5];
    cin >>N>> A[0] >> A[1] >> A[2] >> A[3] >> A[4];

    long long aa[5];
    long long max =0;
    for (long long i = 0; i < 5; i++)
    {
        aa[i] =(N+(A[i]-1))/A[i];
        if(aa[i]>max){
            max=aa[i];
        }
    }

    cout<<max+4<<endl;

}

Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun h w ->
    let c = Array.init 10 (fun _ ->
        Array.init 10 (fun _ -> Scanf.scanf " %d" (fun c -> c)))
    in
    let d = Array.make 10 0 in
    for i = 1 to h do
        for j = 1 to w do
            Scanf.scanf " %d" (fun a ->
                if a >= 0 then d.(a) <- d.(a) + 1
            )
        done
    done;
    for k = 0 to 9 do
        for i = 0 to 9 do
            for j = 0 to 9 do
                c.(i).(j) <- min c.(i).(j) (c.(i).(k) + c.(k).(j))
            done
        done
    done;
    let rec loop i acc =
        if i = 10 then acc else loop (i + 1) (acc + d.(i) * c.(i).(1))
    in
    loop 0 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 5932
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

    vector<int> B(M);
    for(int i=0;i<M;i++)    cin >> B[i];

    vector< vector<int> > A(N, vector<int>(M));
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++)    cin >> A[i][j];
    }

    int ans=0;
    for(int i=0;i<N;i++){
        int sum=0;
        for(int j=0;j<M;j++)    sum += A[i][j]*B[j];
        if( sum+C > 0)  ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
-- 1_1_D
main = do t <- getLine
          let t' = read t :: Int
          let h = t' `div` 3600
          let m = t' `mod` 3600 `div` 60
          let s = t' `mod` 60
          putStrLn $ show h ++ ":" ++ show m ++ ":" ++ show s

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

#define int long long

constexpr int INF = 1LL << 60;

pair<vector<vector<int>>, bool> warshallFloyd(const int V, vector<vector<int>> G) {
    for (int v = 0; v < V; v++) {
        G[v][v] = 0;
    }
    for(int k = 0; k < V; k++) {
        for(int i = 0; i < V; i++) {
            for(int j = 0; j < V; j++) {
                if(G[i][k] >= INF || G[k][j] >= INF)
                    continue;
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    bool negativeLoop = false;
    for (int v = 0; v < V; v++) {
        if (G[v][v] < 0) {
            negativeLoop = true; 
            break;
        }
    }
    return {G, negativeLoop};
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int V, E;
    cin >> V >> E;
    vector<vector<int>> G(V, vector<int>(V, INF));
    for (int i = 0; i < E; i++) {
        int from, to, cost;
        cin >> from >> to >> cost;
        G[from][to] = cost;
    }
    vector<vector<int>> d; bool negLoop;
    tie(d, negLoop) = warshallFloyd(V, G);
    if (negLoop) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            if (d[i][j] >= INF) cout << "INF";
            else cout << d[i][j];
            if (j != V - 1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3344
#include<stdio.h>
int main(void){
  int N;
  scanf("%d",&N);
  if(N%10==0){printf("pon");}
  else if((N-1)%5==0){printf("pon");}
  else if((N-2)%5==0){printf("hon");}
  else if((N-3)%5==0 && N%2==0){printf("pon");}
  else if((N-4)%5==0){printf("hon");}
  else if(N%5==0){printf("hon");}
  else {printf("bon");}
  return 0;
}

Measured memory_bytes: 1728
s = gets.chomp
t = gets.chomp
x = []
(0..s.size - t.size).each do |i|
  start = i
  finish = i + t.size - 1
  u = s[start..finish]
  is_sub_string = true
  t.size.times do |j|
    next if t[j] == u[j] || u[j] == '?'

    is_sub_string = false
    break
  end

  next unless is_sub_string

  if i == 0
    s_pre = ''
  else
    s_pre = s[0...i]
  end
  if i == s.size - t.size
    s_post = ''
  else
    s_post = s[finish+1..-1]
  end

  x << "#{s_pre}#{t}#{s_post}".gsub('?', 'a')

end

if x.empty?
  puts 'UNRESTORABLE'
else
  puts x.sort.first
end

Measured memory_bytes: 14380
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 998244353
#define NUM 100001

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){
  if(*(LL*)a>*(LL*)b)return 1;
  if(*(LL*)a<*(LL*)b)return -1;
  return 0;
}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}


int main(){
  LL N,i,ans=0;
  scanf("%lld",&N);
  LL D[N],A[N];
  FOR(i,0,N)scanf("%lld",&D[i]);
  if(D[0]==0){
    ans=1;
    A[0]=1;
    FOR(i,1,N)A[i]=0;
    FOR(i,1,N)A[D[i]]++;
    FOR(i,1,N)ans=(ans*A[D[i]-1])%MOD;
    if(A[0]>1)ans=0;
    /*ans=1;
    FOR(i,1,N){
      if(D[i]==n)a++,ans=(ans*b)%MOD;
      else{
        if(D[i]!=n+1)ans=0;
        else b=a,ans=(ans*b)%MOD,n++,a=1;
      }
    }*/
  }

  printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

int r[100001];

int main(){
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0), cin.tie(0);
    int x, k;
    cin >> x >> k;
    for (int i = 1; i <= k; i++){
        cin >> r[i];
    }
    int q;
    cin >> q;
    int j = 0;
    int d = 0;
    int mn = 0;
    int mx = x;
    int valmn = 0;
    int valmx = x;
    for (int i = 0; i < q; i++){
        int t1, a1;
        cin >> t1 >> a1;
        while (j + 1 <= k && t1 >= r[j + 1]){
            int ch = r[j + 1] - r[j];
            if (j & 1){
                mx = min(mx, mx + (x - valmx - ch));
                valmn = min(valmn + ch, x);
                valmx = min(valmx + ch, x);
            } else {
                mn = max(mn, mn + ch - valmn);
                valmn = max(valmn - ch, 0);
                valmx = max(valmx - ch, 0);
            }
            j++;
        }
        int ans;
        if (a1 <= mn){
            ans = valmn;
        } else if (a1 >= mx){
            ans = valmx;
        } else {
            ans = valmn + (a1 - mn);
        }
        if (j & 1) {
            ans = min(ans + (t1 - r[j]), x);
        } else {
            ans = max(ans - (t1 - r[j]), 0);
        }
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 1664