akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>  
#include<cstring>  
#include<algorithm>  
#include<iostream>  
#include<string>  
#include<vector>  
#include<stack>  
#include<bitset>  
#include<cstdlib>  
#include<cmath>  
#include<set>  
#include<list>  
#include<deque>  
#include<map>  
#include<queue>
using namespace std;
typedef long long ll;
const ll inf=1<<29;
const ll Maxn=1e6;

ll A[Maxn],B[Maxn],C[Maxn];

int main(){
	ll a,b,c,x;
	ll q=0,w=0,e=0,mid=0;
	cin>>a>>b>>c>>x;
	for(int i=1;i<=a;i++) A[++q]=500*i;
	for(int i=1;i<=b;i++) B[++w]=100*i;
	for(int i=1;i<=c;i++) C[++e]=50*i;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(A[i]+B[j]+C[k]==x) mid++;
			}
		}
	}
	printf("%lld\n",mid);
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

ll gcd(ll x, ll y) {
    ll r = y % x;
    if (r == 0) return x;
    else return gcd(r, x);
}

int main() {
    int N;
    cin >> N;
    vector<ll> T(N);
    Rep(i, N) {
        cin >> T[i];
        if (i) T[i] = T[i] / gcd(T[i], T[i - 1]) * T[i - 1];
    }
    cout << T[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 3612
n,m=map(int,input().split())
up=float('inf')
dp=[[up]*(1<<n) for i in range(m)]

dp[0][0]=0
buy=[]
a=[]
b=[]
for cnt in range(m):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
    c=list(map(int,input().split()))
    tmp=0
    for w in c:
        tmp+=1<<(w-1)
    buy.append(tmp)

for i in range(m-1):
    for j in range(1<<n):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][j|buy[i]]=min(dp[i][j]+a[i],dp[i+1][j|buy[i]]) #i番目を買っているよ

if dp[m-1][-1]==float('inf'):
    print(-1)
else:
    print(dp[m-1][-1])

Measured memory_bytes: 129632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;

int n,m;
ll d[105][105];
bool v[105][105];

int main() {
	cin>>n>>m;
	for (int i=0;i<n;i++) for (int j=0;j<n;j++) {
		if (i==j) {
			d[i][j]=0;
			v[i][j]=1;
		}
		else d[i][j]=INF;	
	}
	for (int i=0;i<m;i++) {
		int s,t,l; cin>>s>>t>>l;
		d[s][t]=l;
		v[s][t]=1;
	}
	for (int k=0;k<n;k++)
	  for (int i=0;i<n;i++)
	  for (int j=0;j<n;j++)
	    if (v[i][k] && v[k][j]) {
	    	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	    	v[i][j]=1;
	    }
	for (int i=0;i<n;i++) 
		if (d[i][i]<0) {
			cout<<"NEGATIVE CYCLE"<<'\n';
			return 0;
		}
	for (int i=0;i<n;i++) for (int j=0;j<n;j++) {
		if (d[i][j]==INF) cout<<"INF";
		else cout<<d[i][j];
		cout<<" \n"[j+1==n];
	}
}


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

using namespace std;

typedef pair<int, int> ii;

vector<int> AB[100005];

int main(){
	int N, M;
	scanf("%d%d", &N, &M);
	
	for(int i = 0; i < N; i ++){
		int X, Y;
		scanf("%d%d", &X, &Y);
		AB[X].push_back(Y);
	}
	
	priority_queue<int> pq2;
	long long ans = 0;
	for(int i = 1; i <= M; i ++){
		for(int j: AB[i]){
			pq2.push(j);
		}
		if(!pq2.empty()){
			ans += pq2.top();
			pq2.pop();
		}
	}
	
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    char ans1;
    int ans2;
    int h,w;
    cin >> h >> w;
    string str[h][w],temp;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> temp;
            if(temp=="snuke"){
                ans1='A'+j;
                ans2=1+i;
            }
        }
    }
    cout << ans1 << ans2 << endl;
    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int n, m;
char a[10][10];
bool vis[10][10], res = true;

void dfs(int x, int y)
{
	vis[x][y] = true;
	if (a[x+1][y] == '#' && a[x][y+1] == '#')
		res = false;
	if (a[x-1][y] == '#' && !vis[x-1][y])
		res = false;
	if (a[x][y-1] == '#' && !vis[x][y-1])
		res = false;
	bool posz = false;
	if (x+1 <= n && a[x+1][y] == '#') {
		posz = true;
		dfs(x+1, y);
	}
	if (y+1 <= m && a[x][y+1] == '#') {
		posz = true;
		dfs(x, y+1);
	}
	if (!posz && (x != n || y != m))
		res = false;
}

int main()
{
    init_ios();
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
    	for (int j = 1; j <= m; ++j)
    		cin >> a[i][j];
    }
    if (a[1][1] == '.') {
    	cout<<"Impossible\n";
    	return 0;
    }
    dfs(1, 1);
    if (res)
    	cout<<"Possible\n";
    else
    	cout<<"Impossible\n";
}

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

int main(){
    long int n;
    string s;
    cin>>n>>s;
    long int count=1;
    for(long int i=1;i<n;i++){
        if(s[i]==s[i-1])count+=0;
        else count+=1;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	double v0,t;
	while(cin>>v0){
		int n=0;
		t=0;
		t=v0/9.8;
		while(5*n-5<=4.9*t*t){
			n++;
		}
		cout<<n<<endl;
	}
}

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

int main()
{
	int n;
	scanf("%d",&n);
	
	int v[n];
	
	for(int i=0;i<n;i++)
		cin>>v[i];
		
	int menor=8000;			
	int suma=0;
	
	for(int i=0;i<n;i++)
	{
		suma+=v[i];
		if(v[i]%10>0)
			menor=min(menor,v[i]);
	}	
	
	if(suma%10>0) cout<<suma;
	else if(menor<8000) cout<<suma-menor;
	else cout<<"0";
	cout<<"\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

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

int main() {
	int total_n;
	int i;
	
	cin >> total_n;
	
	vector<int> nums(total_n);
	
	for (i=0; i<total_n; i++) {
		cin >> nums[i];
	}
	
	vector<int> left(total_n);
	vector<int> right(total_n);
	left[0] = nums[0];

	for (i=1; i<total_n; i++) {
		left[i] = gcd(left[i-1], nums[i]);
	}

	right[total_n-1] = nums[total_n-1];
	for (i=total_n-2; i>=0; i--) {
		right[i] = gcd(right[i+1], nums[i]);
	}

	int ans = -1;

	for (i=1; i<total_n-1; i++) {
		ans = max(ans, gcd(left[i-1],right[i+1]));
	}
	ans = max(ans,right[1]);
	ans = max(ans,left[total_n-2]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
const int N=1e5+11;
struct Edge{
	int v;Edge *nex;
} pl[N],*cur=pl,*G[N];
void ins(int u,int v){
	cur->v=v,cur->nex=G[u],G[u]=cur++;
}
int n,f[N];
typedef priority_queue<int> heap;
void dfs(int x){
	heap H;
	Es(x,i){
		dfs(i->v);
		H.push(f[i->v]);
	}
	for(int i=1;!H.empty();i++,H.pop()){
		f[x]=max(f[x],H.top()+i);
	}
}
int main(){
	n=rd();
	rep(i,2,n){
		ins(rd(),i);
	}
	dfs(1);
	cout<<f[1]<<endl;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

/****************** 数論 ******************/
// 最大公約数
lint gcd(lint a, lint b) {
    // 引数の一方が 0 なら他方の値を返す
    return b ? gcd(b, a%b) : a;
}

int main(void) {
    int n;
    cin >> n;
    vector<int> x(n + 1);
    cin >> x[0];
    repeat (i, n) cin >> x[i+1];
    sort(x.begin(), x.end());
    if (n == 1) {
        cout << x[1] - x[0] << endl;
        return 0;
    }
    
    lint ans = gcd(x[1] - x[0], x[2] - x[1]);
    repeat (i, n) {
        ans = gcd(ans, x[i+1] - x[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


bool cmp(const P&a,const P&b){
    return a.fi+a.se > b.fi+b.se;
}


int main(void) {
    ll N;
    cin >> N;
    vector<P> vec;
    
    for(ll i=0; i<N; i++) {
        ll a, b;
        cin >> a >> b;
        vec.push_back(P(a, b));
    }
    sort(vec.begin(), vec.end(), cmp);
    
    ll ans=0;
    for(ll i=0; i<N; i++) {
        if(i&1) ans-=vec[i].se;
        else ans+=vec[i].fi;
    }
    
    pt(ans);
}






Measured memory_bytes: 2420
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let x: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();

    let mut used: Vec<bool> = vec![false; m];
    let mut cycle: Vec<usize> = vec![];

    let mut start = 0;
    let mut now = x;
    for _ in 0..n {
        used[now] = true;
        cycle.push(now);
        now = now * now % m;
        if used[now] {
            for j in 0..cycle.len() {
                if cycle[j] == now {
                    start = j;
                    break;
                }
            }
            break;
        }
    }

    let mut s1 = 0;
    let mut s2 = 0;
    let len = cycle.len() - start;
    for i in 0..start {
        s1 += cycle[i];
    }
    for i in start..cycle.len() {
        s2 += cycle[i];
    }

    let mut ans = s1 + (n - start) / len * s2;
    for _ in 0..(n - start) % len {
        ans += now;
        now = now * now % m;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2520
#include<iostream>
#include<algorithm>
using namespace std;
int a[1000000];
int haj[1000000];
int hao[1000000];
int maxn1,maxn2,temp1,temp2;
int cmp(int x,int y)
{
	return x>y;
 } 
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(i%2==1)
		haj[a[i]]++;
		else
		hao[a[i]]++;
		if(haj[a[i]]>maxn1)
		temp1=a[i],maxn1=haj[a[i]];
		if(hao[a[i]]>maxn2)
		temp2=a[i],maxn2=hao[a[i]];
	}
	sort(haj+1,haj+100001,cmp);
	sort(hao+1,hao+100001,cmp);
	if(temp1==temp2)
	{
		if(haj[2]+hao[1]>=haj[1]+hao[2])
		cout<<n-haj[2]-hao[1]<<endl;
		else
		cout<<n-haj[1]-hao[2]<<endl;
	}
	else
	cout<<n-haj[1]-hao[1]<<endl;
}

Measured memory_bytes: 8832
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;

struct list{
	int t;
	int s;
	int d;
};
struct list l[20010];
int v[20010];
int n, m, ans;


class LessAn{
public:
	bool operator()(const list& a, const list& b){
		return a.t < b.t;
	}
};
	

int main(void){
	int i;
	while( cin >> n >> m, n){
		ans = 0;
		memset(l, 0, sizeof(l));
		memset(v, 0, sizeof(v));
		for(i = 0; i < m; i++) cin >> l[i].t >> l[i].s >> l[i].d;
		sort(l, l + m, LessAn());
		v[1] = 1;
		for(i = 0; i < m; i++) if(v[l[i].s]) v[l[i].d] = 1;
		for(i = 1; i <= n; i++) if(v[i]) ans++;
		cout << ans << endl;
	}
	return 0;
}

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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int a,b;

int main(){
  cin>>a>>b;
  if(a+b==15)
    cout<<"+"<<endl;
  else if(a*b==15)
    cout<<"*"<<endl;
  else
    cout<<"x"<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-04 15:32:03 +0900
# LastModified: 2020-09-04 15:43:28 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


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


def main():
    n = int(input())
    ans = int(input())
    for _ in range(n-1):
        t = int(input())
        ans = ans*t//gcd(max(ans, t), min(ans, t))
    print(ans)




if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
n = int(input())
h = list(map(int,input().split()))

cost = [0]*(n)
cost[1] = abs(h[0]-h[1])

for i in range(2,n):
  cost[i] = min(cost[i-2]+abs(h[i]-h[i-2]),cost[i-1]+abs(h[i]-h[i-1]))
  
print(cost[-1])

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

int main(){
  int n,a,b,c,x,y[100];
  while(1){
    int count=0;
    cin>>n>>a>>b>>c>>x;
    if((n+a+b+c+x)==0)break;
    for(int i=0;i<n;i++)
      cin>>y[i];
    int j=0;    
    while(1){
      if(y[j]==x)j++;
      if(n==j)break;
      else{
	x=(a*x+b)%c;
	count++;
      }
      if(count>10000)break;
    }
    if(count<=10000)
      cout<<count<<endl;
    else
      cout<<"-1"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int h1,m1,h2,m2,k;cin >> h1 >> m1 >> h2 >> m2 >> k;
	int diff = (60*(h2-h1))+(m2-m1);
	cout << diff-k << '\n';
}


Measured memory_bytes: 3636
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	int n, k, c; cin >> n >> k >> c;
	string s; cin >> s;
	vector<int>L(k), R(k);
	for (int i = 0, cnt = 0; i < n && cnt < k;) {
		if (s[i] == 'o') {
			L[cnt] = (i+1);
			i += (c + 1);
			cnt++;
		}
		else {
			i++;
		}
	}
	reverse(s.begin(), s.end());
	for (int i = 0,cnt=0; i < n && cnt < k;) {
		if (s[i] == 'o') {
			R[k-1-cnt] = n-i;
			i += (c + 1);
			cnt++;
		}
		else {
			i++;
		}
	}
	rep(i, k) {
		if (L[i] == R[i]) {
			cout << L[i] << endl;
		}
	}

}


	


		






Measured memory_bytes: 3460
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <deque>
#include <queue>

#define pb push_back
#define mp make_pair
#define x first
#define y second
#define FOR(i, a, b) for(int i=a, loop=b; i<=loop; ++i)
#define REV(i, a, b) for(int i=a, loop=b; i>=loop; --i)
#define mize(a, b) a = min(a, b)
#define maxi(a, b) a = max(a, b)
#define shl(k) ((k) << 1)
using namespace std;

const int N = 1e5+5;
int n, m, deg[N], par[N];
vector<int> ke[N];

void dfs(int u)
{
    for(int v: ke[u]) if (--deg[v] == 0) par[v] = u;
    for(int v: ke[u]) if (par[v] == u) dfs(v);
}
int main()
{
    ios::sync_with_stdio(); cin.tie(0);

    cin >> n >> m;
    FOR(i ,1, m+n-1) {
        int u, v;
        cin >> u >> v;
        ke[u].pb(v); deg[v] += 1;
    }

    int root = 1;
    FOR(i, 2, n) if (deg[i] == 0) root = i;
    dfs(root);
    FOR(i, 1, n) cout << par[i] << '\n';
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int k; cin >> k;
    string s; cin >> s;
    if ((int)s.length() <= k) cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(vector<A> v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void(0)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int)s.size();
  vector<ll> cnt(2020);
  cnt[0] = 1;
  ll x = 0;
  ll ten = 1;
  for (int i = n - 1; ~i; i--) {
    x += (s[i] - '0') * ten % 2019;
    cnt[x % 2019]++;
    ten *= 10;
    ten %= 2019;
    debug(x);
  }
  ll ans = 0;
  for (const auto& c : cnt) {
    ans += c * (c - 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;

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

    vector<vector<ll>> table(9, vector<ll>(9, 0));

    ll num = 0;
    for (int k = 1; k <= N; k++)
    {
        string k_str = to_string(k);
        int i = k_str.at(0) - '0';
        int j = k_str.at(k_str.size() - 1) - '0';
        if (j == 0)
        {
            continue;
        }
        table[i - 1][j - 1] += 1;
    }

    ll ans = 0;
    for (int i = 1; i <= N; i++)
    {
        string i_str = to_string(i);
        int l = i_str.at(0) - '0';
        int m = i_str.at(i_str.size() - 1) - '0';

        if (m == 0)
        {
            continue;
        }

        ans += table[m - 1][l - 1];
    }

    cout << ans << endl;
}


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

int main(){
 int x,y;
 cin >> x >> y;
 while(!(x==0&&y==0)){
  if(x<y)cout << x << " " << y << endl;
  else cout << y << " " << x << endl;
  cin >> x >> y;
 }
 return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define LL long long 
#define INF 12000000000
using namespace std;
int main(){
    LL x,y,ans = INF;
   	cin>>x>>y;
    if((x*y)%3==0)
       	cout<<0;
    else
    {
        if(x < y) swap(x,y);
        ans = y;
        LL temm=0,temm_=12000000000;
        for(LL i = x/3; i <= x/3+1; i++)
            for(LL j = y/2; j <= y/2+1; j++)
            {
                temm=0,temm_=12000000000;
                temm=max(y*i, temm);
                temm=max(temm, (x-i)*j);
                temm=max(temm, (x-i)*(y-j));
                temm_=min(y*i, temm_);
                temm_=min(temm_, (x-i)*j);
                temm_=min(temm_, (x-i)*(y-j));
                ans = min(ans, temm - temm_);
            }
        for(LL i = y/3; i <= y/3+1; i++)
            for(LL j = x/2; j <= x/2+1; j++)
            {
                temm = 0, temm_ =12000000000;
                temm=max(x*i, temm);
                temm=max(temm, (y-i)*j);
                temm=max(temm, (y-i)*(x-j));
                temm_=min(x*i, temm_);
                temm_=min(temm_, (y-i)*j);
                temm_=min(temm_, (y-i)*(x-j));
                ans = min(ans, temm - temm_);
            }
       	cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
import time
input = sys.stdin.readline

def find(tree,x):
    idx = tree[x][0]
    if(idx== x):
        return x
    else:
        root_idx = find(tree,idx)
        return root_idx

def unite(tree,x,y,w):
    x_root_idx = find(tree,x)
    y_root_idx = find(tree,y)

    if not (x_root_idx == y_root_idx):
        if(tree_rank[x_root_idx] < tree_rank[y_root_idx]):
            tree[x_root_idx] = (y_root_idx,w)
        else:
            tree[y_root_idx] = (x_root_idx,w)
            if(tree_rank[x_root_idx] == tree_rank[y_root_idx]):
                tree_rank[x_root_idx] = tree_rank[x_root_idx] + 1

def same(tree,x,y):
    x_root_idx = find(tree,x)
    y_root_idx = find(tree,y)
    if(x_root_idx == y_root_idx):
        return True
    else:
        return False

v_num,e_num = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(e_num)]
union_find_tree = [(i,0) for i in range(v_num)]
tree_rank = [0]*v_num
if __name__ == "__main__":
    edges.sort(key=lambda x:x[2])
    for e in edges:
        unite(union_find_tree,e[0],e[1],e[2])
    print(sum(item[1] for item in union_find_tree))





Measured memory_bytes: 29316
#include <iostream>
#include <string>

int main()
{
    std::string a, b, c;
    std::cin >> a >> b >> c;
    int i = 0, j = 0, k = 0;
    char ch = 'a';

//    int aLen = a.length(), bLen = b.length(), cLen = c.length();
//    i++;

    while(1)
    {
        if(ch == 'a')
        {
            if(i == a.length())
            {
                std::cout << "A" << std::endl;
                break;
            }

            ch = a[i];
            i++;
        }
        else if(ch == 'b')
        {
            if(j == b.length())
            {
                std::cout << "B" << std::endl;
                break;
            }

            ch = b[j];
            j++;
        }
        else
        {
            if(k == c.length())
            {
                std::cout << "C" << std::endl;
                break;
            }

            ch = c[k];
            k++;
        }
    }

    return 0;
}


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

int main(){
    int n;
    ll k; cin >> n >> k;
    vector<int> A(n);
    for(int i=0; i<n; i++) cin >> A[i];

    int count = 0;
    int index = 0;
    vector<int> com(n);
    com[0] = 1;
    while(true){
        index = A[index] - 1;
        count++;
        if(com[index] == 1) break;
        else com[index] = 1;
    }

    int rupe = 0;
    int index2 = 0;
    while(true){
        if(index2 == index) break;
        else index2 = A[index2] - 1;
        rupe++;
    }

    if(rupe < k){
        k -= rupe;
        count -= rupe;
        k %= count;
        for(int i=0; i<k; i++){
            index = A[index] - 1;
        }

        cout << index + 1 << endl;
    }else{
        index = 0;
        for(int i=0; i<k; i++){
            index = A[index] - 1;
        }

        cout << index + 1 << endl;
    }
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int x, a, b; cin >> x >> a >> b;
  if(b <= a) cout << "delicious" << endl;
  else if(b <= a + x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}


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

int cnt = 2, seze = 5e4, A = 0, B = 1, tA, tB, A0, A1, B0, B1;
int pow2[110], wA[110], wB[110], tmp[110];

int main() {
	puts("32926");
	puts("+ 0 1 3");
	puts("+ 3 3 3");
	puts("< 1 3 3");
	pow2[0] = ++cnt;
	for (int i = 1; i <= 30; ++i) pow2[i] = ++cnt, printf("+ %d %d %d\n", pow2[i - 1], pow2[i - 1], pow2[i]);
	tA = ++cnt, tB = ++cnt;
	printf("+ %d %d %d\n", A, pow2[0], tA);
	printf("+ %d %d %d\n", B, pow2[0], tB);
	A0 = ++seze, A1 = ++seze, B0 = ++seze, B1 = ++seze;
	for (int i = 30; ~i; --i) {
		printf("+ %d %d %d\n", pow2[i], A0, A1);
		wA[i] = ++cnt;
		printf("< %d %d %d\n", A1, tA, wA[i]);
		tmp[0] = ++seze;
		printf("+ %d %d %d\n", wA[i], tmp[0], tmp[0]);
		for (int j = 1; j <= i; ++j) tmp[j] = ++seze, printf("+ %d %d %d\n", tmp[j - 1], tmp[j - 1], tmp[j]);
		printf("+ %d %d %d\n", A0, tmp[i], A0);
	}
	for (int i = 30; ~i; --i) {
		printf("+ %d %d %d\n", pow2[i], B0, B1);
		wB[i] = ++cnt;
		printf("< %d %d %d\n", B1, tB, wB[i]);
		tmp[0] = ++seze;
		printf("+ %d %d %d\n", wB[i], tmp[0], tmp[0]);
		for (int j = 1; j <= i; ++j) tmp[j] = ++seze, printf("+ %d %d %d\n", tmp[j - 1], tmp[j - 1], tmp[j]);
		printf("+ %d %d %d\n", B0, tmp[i], B0);
	}
	for (int i = 0; i <= 30; ++i)
		for (int j = 0; j <= 30; ++j) {
			tmp[0] = ++seze;
			printf("+ %d %d %d\n", wA[i], wB[j], tmp[0]);
			printf("< %d %d %d\n", pow2[0], tmp[0], tmp[0]);
			for (int k = 1; k <= i + j; ++k) tmp[k] = ++seze, printf("+ %d %d %d\n", tmp[k - 1], tmp[k - 1], tmp[k]);
			printf("+ %d %d %d\n", 2, tmp[i + j], 2);
		}
	return 0;
}

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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
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();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    string s;
    cin >> n >> k >> s;

    s[k-1] = s[k-1] - 'A' + 'a';
    ppp(s);



    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{

    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int C1 = 0;
        int C2 = 0;
        int C3 = 0;
        int C4 = 0;
        for (int i=0;i<N;i++)
        {
            string A = Console.ReadLine();

            if(A =="AC")
            {
                C1++;
            }

            if (A == "WA")
            {
                C2++;
            }

            if (A == "TLE")
            {
                C3++;
            }

            if (A == "RE")
            {
                C4++;
            }
        }
        Console.WriteLine("AC x {0}", C1);
        Console.WriteLine("WA x {0}", C2);
        Console.WriteLine("TLE x {0}", C3);
        Console.WriteLine("RE x {0}", C4);

    }

}

Measured memory_bytes: 30680
#include <stdio.h>

int main(void)
{
	int h,w;
	int i,j;
	
	while(1)
	{
		scanf("%d %d",&h,&w);
		
		if((h==0) && (w==0)) break;
		
		for(i=1;i<=h;i++)
		{
			if(i==1 || i==h)
			{
				for(j=1;j<=w;j++)
				{
					printf("#");
				}
			}
			else
			{
				for(j=1;j<=w;j++)
				{
					if(j==1 || j==w)
					{
						printf("#");
					}
					else
					{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 2056
require 'bigdecimal'
n = gets.to_i
bmi1 = 22
until n == 0
    resou = 1000.0
    id = 1001
    n.times do
        x = gets.split(" ").map{|k| k.to_f }
        height = x[1] * x[1] / 10000
        weight = x[2]
        bmi = BigDecimal(weight.to_s) / BigDecimal(height.to_s)
        bmi.to_i
        num = (bmi1 - bmi).abs
        if resou > num
            resou = num
            id = x[0]
        elsif resou < num
        elsif resou == num
            if id > x[0]
                id = x[0]
            end
        end 
    end
    puts id.to_i
    n = gets.to_i
end


Measured memory_bytes: 7100
#include <iostream>
using namespace std;
static const int MAX = 100;

int SelectionSort(int* A, int n) {
    int minj, count = 0;
    for(int i = 0; i < n ; ++i) {
        minj = i;
        for(int j = i; j < n; ++j) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        if(i != minj){
            swap(A[i], A[minj]);
            count++;
        }
    }
    return count;
}

int main(int argc, char const *argv[]) {
    int A[MAX];
    int n, count;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    count = SelectionSort(A, n);

    cout << A[0];
    for(int i = 1; i < n; ++i) {
        cout << " " << A[i] << flush;
    }
    cout << endl;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3108
#include<iostream>

#include<algorithm>

using namespace std;



int main(){
    string s;
    cin>>s;
    
    if((s=="abc")||(s=="acb")||(s=="bac")||(s=="bca")||(s=="cab")||(s=="cba")){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


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

int main()
{
    std::uint64_t N, K;
    std::cin >> N >> K;

    std::vector<std::size_t> A(N);
    for(auto& a : A)
    {
        std::cin >> a;
        a -= 1; // 0-based index
    }

    std::size_t loop = 0;
    std::size_t city = 0;
    std::vector<bool> visited(N, false);
    while(city != 0xFFFFFFFF)
    {
        if(visited[city])
        {
            loop = city;
            city = 0xFFFFFFFF;
            break;
        }
        visited[city] = true;
        city = A[city];
    }

    city = A[loop];
    std::size_t loop_size = 1;
    while(city != loop)
    {
        loop_size += 1;
        city = A[city];
    }

    city = 0;
    std::size_t loop_dist = 0;
    while(city != loop)
    {
        loop_dist += 1;
        city = A[city];
    }

    if(K < loop_dist)
    {
        city = 0;
        while(K != 0)
        {
            city = A[city];
            K -= 1;
        }
        std::cout << city + 1 << std::endl;
    }
    else
    {
        K -= loop_dist;
        city = loop;
        K %= loop_size;
        while(K != 0)
        {
            city = A[city];
            K -= 1;
        }
        std::cout << city + 1 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 4844
N,T=map(int,input().split())
t=list(map(int,input().split()))

def check(N,T,t):
    counter=0
    for i in range(N-1):
        finish=t[i]+T
        start=t[i+1]
        #print(counter)        
        if finish>start:
            counter=counter+finish-start
                 
    return counter
print(N*T-check(N,T,t))

Measured memory_bytes: 25200
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int n, m;
    scanf("%d", &n);
    char s[100][11], t[100][11];
    int i, j, k;
    for (i=0; i<n; i++)
    {
        scanf("%s", s[i]);
    }
    scanf("%d", &m);
    for (i=0; i<m; i++)
    {
        scanf("%s", t[i]);
    }
    int count_max = 0;
    for (i=0; i<n; i++)
    {
        int count = 1;
        for (j=0; j<n; j++)
        {
            if (j==i) continue;
            if (strcmp(s[i], s[j]) == 0) {
                count ++;
            }
        }
        for (k=0; k<m; k++)
        {
            if (strcmp(s[i], t[k]) == 0) {
                count --;
            }
        }
        if (count > count_max) count_max = count;
    }
    printf("%d\n", count_max);
    return 0;
}


Measured memory_bytes: 128
r,c = gets.split.map(&:to_i)
arr = Array.new()
sum = Array.new()
r.times{
    |i|
    arr[i] = gets.split.map(&:to_i)
    sum[i] = arr[i].inject(:+)
}
r.times{
    |i|
    puts "#{arr[i].join(" ")} #{sum[i]}"
}
n = arr.transpose
c.times{ |i|
print n[i].inject(:+)
print " "
}
puts "#{sum.inject(:+)}"


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A <= 5) {
    cout << 0 << endl;
  }
  else if (A <= 12) {
    cout << B/2 << endl;
  }
  else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int as[s.size()];
  rep(i,0,s.size()){
    rep(j,0,26){
      if(s.at(i)==al.at(j)){
        as[i]=j;
        break;
      }
    }
  }
  rep(i,0,s.size()){
    as[i]+=n%26;
    cout << al.at(as[i]);
  }
  cout << endl;
  return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int H, W, N;
    cin >> H >> W >> N;

    int ans = 0;
    if (H > W) {
        ans = (N + H - 1) / H;
    } else {
        ans = (N + W - 1) / W;
    }

    cout << ans << endl;
}

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

class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');

        bool[] flg = new bool[int.Parse(inp[0])];

        for(int i = 0;i < int.Parse(inp[1]);i++) {
            var inpD = Console.ReadLine().Split(' ');
            var inpA = Console.ReadLine().Split(' ');

            for(int j = 0;j < int.Parse(inpD[0]);j++) {
                flg[int.Parse(inpA[j])-1] = true;
            }
        }

        int cnt = 0;
        for(int i = 0;i < flg.Length;i++) {
            if(!flg[i]) {
                cnt++;
            }
        }

        Console.WriteLine(cnt);
    }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> cnt_A(n + 10, 0);
  rep(i, n) {
    int tmp;
    cin >> tmp;
    cnt_A[tmp]++;
  }
  
  int count = 0;
  for (int i = 1; i <= n; i++) {
    if (cnt_A[i] != 0) count++;
  }

  sort(cnt_A.begin(), cnt_A.end());

  int i = 0;
  int ans = 0;
  int s = n - count + 10;
  while (i++ < count - k) {
    ans += cnt_A[s++];
  }

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


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    string s; cin >> s;
    if(s[0]==s[1]&&s[1]==s[2]) cout << "No";
    else cout << "Yes";
}



Measured memory_bytes: 256
using System;
class Hello{
    static void Main(string[] args){
        string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
     
      if((a*b)%2==0){
          Console.WriteLine("Even");
      }else{
          Console.WriteLine("Odd");
      }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  string s;   cin >> s;
  int r = 0, l = s.length() - 1;  //戦闘と末尾を指すもの

  int ans = 0;
  while(r < l){

    if(s[r] == s[l]){
	r += 1;
	l -= 1;
    }else if(s[r] == 'x'){
	r += 1;
	ans += 1;
    }else if(s[l] == 'x'){
	l -= 1;
	ans += 1;
    }else{
	ans = -1;
	break;
    }

  }

  if(ans != -1)
    SCOUT(ans) << endl;
  else
    SCOUT(ans) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
int f[1<<21][22];
char X[1<<20];
int n,K;
int main() {
	rd(n),rd(K);
	for(int i=0;i<=n;++i) {
		scanf("%s",X);
		for(int j=0;j<(1<<i);++j)
			f[(1<<i)|j][i]=X[j]=='1';
	}
	for(int i=n;i>=0;--i)
		for(int s=0;s<(1<<i);++s)
			for(int j=i;j>=0;--j) if(f[(1<<i)|s][j]) {
				int cur=f[(1<<i)|s][j];
				int s1=s>>j;
				int s2=s&((1<<j)-1);
				if(j) f[(1<<i-j)|s1][0]+=cur;
				if(s2) {
					int p=j-1; while(!((s2>>p)&1)) p--;
					f[(1<<(i-(j-1-p)))|(s1<<p+1)|(1<<p)|(s2&((1<<p)-1))][p]+=cur;
				}
				if(((1<<j)-1)&(~s2)) {
					int p=j-1; while((s2>>p)&1) p--;
					f[(1<<(i-(j-1-p)))|(s1<<p+1)|(s2&((1<<p)-1))][p]+=cur;
				}
			}
	for(int i=n;i>=0;--i)
		for(int j=0;j<(1<<i);++j)
			if(f[(1<<i)|j][0]>=K) {
				for(int k=i-1;k>=0;--k) printf("%d",(j>>k)&1);
				return 0;
			}
	return 0;
}

Measured memory_bytes: 181632
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);

using namespace std;
const int N = 1E6+7;
const int M = 1E9+7;

long long f[N];
int n;
vector<int> a;

int main()
{
    fastIO
    cin>>n;

    for (int i = 3;i < 2001; ++i) a.push_back(i);
    
    
    f[0] = 1;
    
    for (int i = 1;i <= n;++i)
        for (int j = 0;j < (int)a.size(); ++j)
            if (i-a[j] >= 0) f[i] = (f[i] + f[i-a[j]]) % M;
    
    cout<<f[n];
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }


signed main()
{
	int S, W;
	cin >> S >> W;
	if (S <= W)
	{
		cout << "unsafe" << endl;
	}
	else
	{
		cout << "safe" << endl;
	}
}




Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
const int MAX=1e5;
int a[MAX];

int main() {
    long long n ,sum=0;
    cin>>n;
    for(int i=1;i<n;i++){
        sum+=i;
    }
    cout<<sum;
}


Measured memory_bytes: 256
//om namah shivaaay//
#include <bits/stdc++.h>
#define input int t;cin>>t;while(t--)
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout.precision(10)
 #define ll long long
 #define vi  vector<int>vec
 #define pb push_back
 #define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
 #define f(i, a, b) for (int i = 0; i < (b); i++)
 #define w(t) int t;cin>>t;while(t --)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
 const int N=1e5 +5;
 using namespace std;
 int main()
 {
    Om_namah_Shivaay; 
    char x; 
    cin >> x; 
    if (isupper(x))  
        cout << "A"<<endl; 
    else 
        cout << "a"<<endl;     
    return 0; 
} 


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ws=0;
	int t=n;
	while(t)
	{
		ws++;
		t/=10;
	}
	t=n;
	int *digit=new int[ws+1];
	digit[0]=0;
	for(int i=1;i<=ws;i++)
	{
		digit[i]=t%10;
		t/=10;
		digit[0]+=digit[i];
	}
	if(n%digit[0]!=0)
	{
		cout<<"No";
	}
	else cout<<"Yes";
	return 0;
}

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

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long n,a[200005],k,s=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n-k;i++)
	s+=a[i];
	cout<<s;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf1 INT_MAX
#define inf2 LLONG_MAX
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sbit __builtin_popcount
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define rit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define fill(a,b) memset(a,b,sizeof(a))
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define infile ifstream fin; fin.open("input.txt")
#define outfile ofstream fout; fout.open("output.txt")
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<ll,int>
#define pll pair<ll,ll>
#define p_queue priority_queue< plii,vector< plii >,greater< plii > > 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%lld",&x)
#define sst(x) scanf("%s",x)
#define pl(x) printf("%lld\n",x)
#define pi(x) printf("%d\n",x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mex 100005
vec adj[mex];
int dp[mex];

inline ll binex(ll a,ll b)
{
    ll ans=1,temp=a%mod;
    while(b!=0){
        if(b&1) ans=(ans*temp)%mod;
        temp=(temp*temp)%mod;
        b=b>>1;
    }
    return ans;
}

inline int solve(int u)
{
    if(dp[u]!=-1) return dp[u];
    int res=0;
    rep(i,0,sz(adj[u])) res=max(res,solve(adj[u][i]));
    return dp[u]=res+1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m; cin>>n>>m;
    rep(i,0,m){
        int u,v; cin>>u>>v;
        u--; v--;
        adj[u].pb(v);
    }
    fill(dp,-1);
    int ans=-1;
    rep(i,0,n){
        if(dp[i]!=-1) ans=max(ans,dp[i]);
        else ans=max(ans,solve(i));
    }
    cout<<ans-1<<endl;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int counta=0,countb=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='A')
		counta++;
		else
		countb++;
	}
	if(counta>0 && countb>0)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

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

#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
using namespace atcoder;

void Main()
{
    ll n, Q;
    cin >> n >> Q;

    vector<ll> t(Q), u(Q), v(Q);
    rep(i, Q) cin >> t[i] >> u[i] >> v[i];
    
    dsu d(n);
    rep(i, Q) {
        if (t[i] == 0) {
            d.merge(u[i], v[i]);
        }
        else {
            if (d.same(u[i], v[i])) {
                put("1");
            }
            else {
                put(0);
            }
        }
    }
    
}
signed main(){ Main();return 0;}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

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

int main(){
    ll n, m; cin >> n >> m;
    if((n == 1 && m == 2) || (n == 2 && m == 1)){
        cout << 2 << endl;
        return 0;
    }
    if((n == 2 && m == 2) || n == 2 || m == 2 ){
        cout << 0 << endl;
        return 0;
    }
    cout << max(1LL, (n-2)) * max(1LL, (m-2)) << endl;
}

Measured memory_bytes: 256