akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	int n, m, s, g1, g2;
	while (cin >> n >> m >> s >> g1 >> g2, n)
	{
		s--; g1--; g2--;
		int d[101][101];
		REP(i, 101)REP(j, 101) d[i][j] = i == j ? 0 : INF;
		REP(i, m)
		{
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			d[a][b] = c;
		}
		REP(k, n)REP(i, n)REP(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
		int res = INF;
		REP(i, n)
		{
			chmin(res, d[s][i] + d[i][g1] + d[i][g2]);
		}
		cout << res << endl;
	}
	return 0;
}

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

vector<int>E[100];
bool used[200];
int match[200];

bool dfs(int u) {
	used[u] = true;
	for (int v : E[u]) {
		int w = match[v];
		if (w == -1 || (!used[w] && dfs(w))) {
			match[u] = v; match[v] = u;
			return true;
		}
	}
	return false;
}
int x[100], y[100], z[100], a[100], b[100];
double d[100][100];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n)scanf("%d%d%d", &x[i], &y[i], &z[i]);
		rep(i, m)scanf("%d%d", &a[i], &b[i]);
		rep(i, n)rep(j, m)d[i][j] = hypot(x[i] - a[j], y[i] - b[j]) / z[i];
		double l = 0, r = 15000;
		rep(i, 45) {
			double t = (l + r) / 2;
			rep(j, n) {
				E[j].clear();
				rep(k, m) {
					if (d[j][k] <= t)E[j].push_back(n + k);
				}
			}
			int cnt = 0;
			memset(match, -1, sizeof(match));
			rep(j, n) {
				if (match[j] == -1) {
					memset(used, 0, sizeof(used));
					cnt += dfs(j);
				}
			}
			if (cnt == m)r = t;
			else l = t;
		}
		printf("%.14lf\n", l);
	}
}

Measured memory_bytes: 3324
N = int(input())
A = [int(input()) for i in range(N)]
keys = list(set(A))
values = [0]*len(keys)
dic = {}
dic.update(zip(keys,values))
for i in A:
    dic[i] += 1
tmp = [i%2 for i in dic.values()]
print(sum(tmp))

Measured memory_bytes: 20748
a=(0..2).flat_map{gets.split.map &:to_i}
gets
$<.map{t=_1.to_i
i=a.index t
a[i]=0 if i}
f=->i,j,k{a[i]+a[j]+a[k]}
puts f[0,1,2]*f[3,4,5]*f[6,7,8]*f[0,3,6]*f[1,4,7]*f[2,5,8]*f[0,4,8]*f[2,4,6]==0 ? :Yes: :No

Measured memory_bytes: 14252
N = int(input())
data = [list(map(int, input().split())) for _ in range(N)]



for Cx in range(101):
    for Cy in range(101):
        for x, y, h in data:
            if h != 0:
                H = abs(x - Cx) + abs(y - Cy) + h
                break
        count = 0
        for x, y, h in data:
            if h != max(H-abs(x-Cx)-abs(y-Cy), 0):
                break
            count += 1
        if count == N:
            print(Cx, Cy, H)
            exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD  1000000007
#define ll long long
#define int long long
#define INF 1e18
#define ar array
#define MAX 1000004
#define wt(x) int x;cin>>x;while(x--)

typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 
}
ll power(ll a,ll b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    ll res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 

 int32_t main() {

c_p_c();

    ll a,b;
    cin>>a>>b;
    cout<<a*b<<"\n";

return 0;
 }

Measured memory_bytes: 3652
# include <iostream>
using namespace std;
 
long long N, P;
long long ans = 1;

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

    for(long long i = 2; i * i <= P; i++) {
        long long temp = 0;
        while (P % i == 0) {
            P = P / i;
            temp ++;
            if (temp % N == 0) {
                ans *= i;
            }
           
        }
    }
    if (P != 1 && N == 1) {
        ans *= P;
    }

    cout << ans << endl;
}

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

alice=[]
bob=[]

if len(cards)%2==0:
    while len(cards)>1:
        alice.append(cards[0])
        del cards[0]
        bob.append(cards[0])
        del cards[0]
else:
    while len(cards)>1:
        alice.append(cards[0])
        del cards[0]
        bob.append(cards[0])
        del cards[0]

    alice.append(cards[0])

print(sum(alice)-sum(bob))

Measured memory_bytes: 3064
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

struct Node {int parent, left, right;};
int *D;
int *C;
struct Node *T;

void setdepth(int u, int p, Node T[], int D[], int nil){
    D[u] = p;
    if(T[u].right != nil) {
        //cout<<"rrr"<<endl;
        setdepth(T[u].right, p, T, D, nil);
    }
    if(T[u].left != nil){
        //cout<<"lll"<<endl;
        setdepth(T[u].left, p+1, T, D, nil);
    }
}



int main(){
    int n, i, j,r,m;
    scanf("%d", &n);
    int nil = n + 1;
    T = (Node*)malloc(sizeof(Node)*(n+1));
    D = (int*)malloc(sizeof(int)*(n+1));
    C = (int*)malloc(sizeof(int)*(n+1));

    

    for(i=0;i<n;i++){
        T[i].parent=-1;
        T[i].left=nil;
        T[i].right=nil;
    }
    for(i=0;i<n;i++){
        int id, k, c;
        scanf("%d %d", &id, &k);
        for(j=1;j<k+1;j++){
            scanf("%d", &C[j]);
            T[C[j]].parent = id;
            if(j==1) T[id].left = C[j];
            if(j==k) T[C[j]].right=nil;
            if(j!=1) T[C[j-1]].right= C[j];
        }
        if(k==0) T[id].left=nil;
    }

    for(i=0;i<n;i++){
        if(T[i].parent==-1){
            r=i;
            break;
        }
    }

    //cout<<T[r].parent<<endl;
    setdepth(r, 0, T, D ,nil);


    for(i=0;i<n;i++){
        cout<<"node "<<i<<": parent = "<<T[i].parent<<", depth = "<<D[i]<<", ";
        if(T[i].parent==-1) cout<<"root, [";
        else if(T[i].left==nil) cout<<"leaf, [";
        else cout<<"internal node, [";
        if(T[i].left==nil) cout<<"]"<<endl;
        else{
            m=T[i].left;
            while(m != nil){
                cout<<m;
                if(T[m].right==nil) cout<<"]"<<endl;
                else cout<<", ";
                m = T[m].right;
            }
        }


    }
    free(T);
    free(D);
    free(C);

}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



i64 n,m, k, a[202020],b[202020], d[202020];
void solve(){
	cin >> n >> m >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < m; i++){
		cin >> b[i];
		d[i+1] = d[i]+b[i];
	}
	
	i64 ma = 0;
	i64 cnt = 0;
	for(int i = 0; i <= n; i++){
		if(k-cnt < 0) break;
		chmax(ma, upper_bound(d,d+m+1, k-cnt)-d-1LL + i);
		
		if(i == n) break;
		cnt += a[i];
		
	}
	cout << ma << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 8340
s=input()
n=len(s)
mod=10**9+7
dp=[[0]*13 for _ in range(n+1)]
dp[0][0]=1
mul=1

for i in range(n):
    x=s[-(i+1)]  # 後ろから見ていく
    if x=='?':
        for k in range(10):
            for j in range(13):
                dp[i+1][(mul*k+j)%13]+=dp[i][j]
                dp[i+1][(mul*k+j)%13]%=mod
    else:
        k=int(x)
        for j in range(13):
            dp[i+1][(mul*k+j)%13]+=dp[i][j]
            dp[i+1][(mul*k+j)%13]%=mod
    mul=mul*10%13
# print(dp)
print(dp[n][5])


Measured memory_bytes: 62300
#include <iostream>

using namespace std;

int const nmax = 2e5;
char comp[1 + nmax];

int main() {

  int n, ans = 0;
  n = 0;
  char popo;
  while(cin.get(popo) && popo != '\n'){
    n++;
    comp[n] = popo;
  }
  n = 0;
  while(cin.get(popo) && popo != '\n'){
    n++;
    if(popo != comp[n]){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3784
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=100010;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
signed main()
{
	char s[10];
	scanf("%s",s);
	if(s[2]==s[3]&&s[4]==s[5]) puts("Yes");
	else puts("No");
	return 0;
}

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

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

using ll = long long;
using namespace std;

int
main ()
{
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    for (auto & e : a) {
      cin >> e;
    }

    auto sum = 0;
    for (auto e : a) {
      sum += e;
    }

    cout << (h <= sum ? "Yes" : "No") << endl;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N,ans;
  vi V,C;
  cin >> N;
  REP(i,N){
		int x;
		cin >> x;
		V.push_back(x);
	}
   REP(i,N){
		int x;
		cin >> x;
		C.push_back(x);
	}
  ans=0;
  REP(i,N){
    if(V[i]>C[i]){
      ans = ans + V[i]-C[i];
    }
  }
  cout << ans<< endl;
  return 0;
}

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

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

int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  k--;
  if (s[k] == 'A') s[k] = 'a';
  else if (s[k] == 'B') s[k] = 'b';
  else s[k] = 'c';
  cout << s << endl;
  return 0;
}

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

typedef long long int ll;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(3),dp(3,0);
    ll i,j,s=0,flag=1;
    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            ll v;
            cin>>v;
            a[j]=v;
        } 
        vector<ll> new_dp(3,0);
        ll k=0;
        for(k=0;k<3;k++){
            for(j=0;j<3;j++){
                if(k!=j){
                    new_dp[j]=max(a[j]+dp[k],new_dp[j]);
                }
            }
        }
        dp=new_dp;
    }
    for(i=0;i<3;i++)
        s=max(s,dp[i]);
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;

#define int long long

#ifdef lioraju
	#define ndbg(x) 
#else
	#define ndbg(x) x
#endif

const int mxsz = 1e3 + 5;
const int mod = 1e9 + 7;

char v[mxsz][mxsz];

int dp[mxsz][mxsz];
bool vis[mxsz][mxsz];

int d(int i, int j)
{
	if (v[i][j]=='#') return 0;
	if (!i && !j) return 1;
	if (vis[i][j]) return dp[i][j];
	
	vis[i][j] = 1;
	int sum = 0;
	if (i) sum += d(i-1, j), sum %= mod;
	if (j) sum += d(i, j-1), sum %= mod;
	
	return dp[i][j] = sum;
}

signed main()
{
	ndbg( ios::sync_with_stdio(0); cin.tie(0); );
	int n, m; cin>>n>>m;
	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++)
			cin>>v[i][j];
	
	cout<<d(n-1, m-1)<<'\n';
}

Measured memory_bytes: 10112
/*
 * atcode153-c
 */

#include <stdio.h>
#include <stdlib.h>

int
comp_int(const void *p1, const void *p2)
{
  int *i1 = (int *)p1;
  int *i2 = (int *)p2;

  return (*i1 < *i2);
}

int
main(int argc, char *argv[])
{
  int *np;
  int n, k, i;
  unsigned long long sum = 0;

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

   if (k >= n) {
    printf("0\n");
    return (0);
  }
  
  np = (int *) malloc(n * sizeof (int));

  for (i = 0; i < n; i++) 
    scanf("%d", np+i);

  qsort(np, n, sizeof (int), comp_int); 

  for (i = k; i < n; ++i) {
    sum += np[i];
  }

  printf("\n%llu\n", sum);
  return (0);
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, q, a, b, s, x;
vector<ll> v(100005);
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> x;
		++v[x];
		s += x;}
	cin >> q;
	while (q--)
	{
		cin >> a >> b;
		s -= (v[a] * a);
		s += (v[a] * b);
		v[b] += v[a], v[a] = 0;
		cout << s << "\n";
	}
	return 0;
}


Measured memory_bytes: 3864
n = int(input())
h = [int(i) for i in input().split(' ')]
dp = [0 for i in range(n)]

dp[1] = abs(h[0] - h[1])

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


Measured memory_bytes: 13928
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    n %= k;

    cout << min(n, k - n) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define Graph vector<vector<ll>>
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
	int a,b,c,d;
	scanf("%1d%1d%1d%1d",&a,&b,&c,&d);

	string s="";
	for(int i=0;i<(1<<3);i++){
		int seven=a;
		for(int j=0;j<3;j++){
			if((i>>j)&1){
				if(j==0) seven+=b;
				if(j==1) seven+=c;
				if(j==2) seven+=d;

				s[j]='+';
			}else{
				if(j==0) seven-=b;
				if(j==1) seven-=c;
				if(j==2) seven-=d;

				s[j]='-';
			}
		}
		if(seven==7) break;
		else{s="";}
	}

	printf("%d%c%d%c%d%c%d=7\n",a,s[0],b,s[1],c,s[2],d);
	return 0;
}

Measured memory_bytes: 256
import  sys
N=int(input())
a = [int(input()) for _ in range(N)]
cnt=1
t=1
if a[t - 1] == 2:
    print(cnt)
    sys.exit()
for i in range(10**5):
    cnt+=1
    t=a[t-1]
    if a[t-1]==2:
        print(cnt)
        sys.exit()

print(-1)

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

int A, B, C, D, T, O;

int main() {
  cin >> A >> B >> C >> D;
  if(A%D > 0){
    T = A/D + 1;
  }else{
    T = A/D;
  }
  if(C%B > 0){
    O = C/B +1;
  }else{
    O = C/B;
  }

  if(T>=O){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;
int n;
vector<int> pre;
vector<int> in;
vector<int> post;
vector<int> child[42];
int tree[42]; //store parent
void postorder(int i, vector<int> child[]){
	if(i==-1) return;
	if(child[i].size()==0){
		post.push_back(i);return;
	} 
	vector<int> temp = child[i];
	postorder(temp.at(0),child);
	postorder(temp.at(1),child);
	post.push_back(i);
}
void inorder(int i, vector<int> child[]){
	if(i==-1) return;
	//if(child[i]==NULL) return;
	vector<int> temp = child[i];
	inorder(temp.at(0),child);
	in.push_back(i);
	inorder(temp.at(1),child);
}
void preorder(int i, vector<int> child[]){
	if(i==-1) return;
	pre.push_back(i);
	vector<int> temp = child[i];
	preorder(temp.at(0),child);
	preorder(temp.at(1),child);
}
int reconstruct(int pre[], int in[], int lp,int rp, int li,int ri){
	//printf("%d %d %d %d\n",lp,rp,li,ri);
	if(li==ri){
		 lp++;
		 return in[li];
	}
	if(li>ri) return -1;
	//printf("%d ",lp);
	int p = pre[lp++];
	int index = 0;
	for(int i = li; i<=ri; i++){
		if(in[i] == p){
			index = i; break;
		}
	}
	
	
	for(int i = li; i<=ri; i++){
		if(i!=index)
		tree[in[i]] = p;
	}
	/*for(int i = lp; i<=rp; i++){
		tree[pre[i]] = p;
	}*/
	
	//inifitivve loop
	child[p].push_back(reconstruct(pre,in,lp,rp,li,index-1));
	child[p].push_back(reconstruct(pre,in,lp+(index-li),rp,index+1,ri));
	return p;
}

int main(){
	scanf("%d",&n);
	for(int i = 0; i<n; i++){
		tree[i] = -1;
	}
	int pre[n];
	int in[n];
	for(int i = 0; i<n; i++) {
		scanf("%d",&pre[i]);
		pre[i]-=1;
	}
	for(int i = 0; i<n; i++) {
		scanf("%d",&in[i]);
		in[i]-=1;	
	}
	
	reconstruct(pre,in,0,n-1,0,n-1);
	//printf("%d %d\n",child[4].at(0),child[4].at(1));
	
	/*for(int i = 0; i<n; i++){
		printf("%d ",tree[i]);
	}printf("\n");*/
	//printf("%d",child[4].size());
	/*printf("Preorder\n");
	preorder(root,child);
	for(int i = 0; i<pre.size(); i++){
		if(i==pre.size()-1)
		printf(" %d\n",pre.at(i));
		else printf(" %d",pre.at(i));
	}
	printf("Inorder\n");
	inorder(root,child);
	for(int i = 0; i<in.size(); i++){
		if(i==in.size()-1)
		printf(" %d\n",in.at(i));
		else printf(" %d",in.at(i));
	}*/
	//printf("Postorder\n");
	postorder(pre[0],child);
	for(int i = 0; i<post.size(); i++){
		if(i==post.size()-1)
		printf("%d\n",post.at(i)+1);
		else printf("%d ",post.at(i)+1);
	}
	
	return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e2 + 5;
const int mod = 1e9 + 7;
//head
const char s[] = "ATGC";
const int maxsta = 64;
int n, dp[maxn][maxsta];
bool Check(int i, int j, int k) {
    string str{s[i], s[j], s[k]};
    if(str == "AGC" || str == "GAC" || str == "ACG") return false;
    return true;
}
int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    for(int sta = 0; sta < maxsta; ++sta) {
        int i = sta % 4, j = (sta/4) % 4, k = sta/16;
        dp[3][sta] = (int)Check(i, j, k);
    }
    for(int len = 4; len <= n; ++len) {
        for(int sta = 0; sta < maxsta; ++sta) {
            int i = sta % 4, j = (sta/4) % 4, k = sta/16;
            for(int ch = 0; ch < 4; ++ch) {
                int nsta = j + k*4 + ch*16;
                dp[len][nsta] = (dp[len][nsta] + dp[len-1][sta]) % mod;
                if(!Check(j, k, ch)) dp[len][nsta] = 0;
                if(ch == 3) {
                    if(i == 0 && k == 2) dp[len][nsta] = 0;
                    if(i == 0 && j == 2) dp[len][nsta] = 0;
                }
            }
        }
    }
    int ans = 0;
    for(int sta = 0; sta < maxsta; ++sta) {
        ans = (ans + dp[n][sta]) % mod;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n;
  int y,m,d;
  const int rest = 1000;
  
  cin >> n;

  for(int i=0;i < n;i++){
    cin >> y >> m >> d;

    int cnt = 1;
    int restm = m;

    for(int i=y;i < rest;i++){
      
      if(i % 3 == 0){
	for(int j=restm;j <= 10;j++){
	  cnt += 20;
	}
      }
      else{
	for(int j=restm;j <= 10;j++){
	  if(j % 2 == 0){
	    cnt += 19;
	  }
	  else{
	    cnt += 20;
	  }
	}
      }
      restm = 1;
    }
    cout << cnt-d << endl;
  }
  return 0;
}



Measured memory_bytes: 3068
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int64_t *a1, int *a2) {
  scanf("%lld %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int64_t *a2, int *a3) {
  scanf("%d %lld %d", a1, a2, a3);
  return 0;
}

struct monster {
    int64_t pos;
    int hp;
};

int asc_by_pos(const void *a1, const void *a2) {
    struct monster *ma1 = (struct monster*)a1;
    struct monster *ma2 = (struct monster*)a2;
    return ma1->pos - ma2->pos;
}

#define NUM_MAX 200000
#define NUM2_MAX (1<<18)
#define ROOT_NODE 1
#define INF ((int64_t)(3e+9)+1)

int main(void) {
    int num, attack;
    int64_t range;
    static struct monster mons[NUM_MAX+1];
    get_int3(&num, &range, &attack);
    range *= 2;
    int num2 = 1;
    while(num > num2) num2 *= 2;

    int i;
    for(i = 0; i < num; i++) {
        get_int2(&mons[i].pos, &mons[i].hp);
    }
    mons[num] = (struct monster){INF, 0}; // guard
    qsort(mons, num, sizeof(struct monster), asc_by_pos);

    int left;
    int right = 0;
    int64_t ans = 0;
    static int64_t diff[NUM_MAX+1];
    static int64_t cum = 0;

    for(left = 0; left < num+1; left++) {
        cum += diff[left];
        if(left == right) { right++; }
        int64_t hp = mons[left].hp - cum * attack;
        if(hp <= 0) continue; // if no hit point, break;
        // ensure that mons[left] should be attacked
        for(;right < num+1; right++) {
            if(mons[left].pos + range < mons[right].pos) break;
        }
#ifdef DEBUG
        printf("[%d, %d)\n", left, right);
#endif
        // attack
        int64_t cnt = (hp-1)/attack + 1;

        // left has already searched
        diff[left+1] += cnt;
        diff[right] -= cnt;
        ans += cnt;
    }
    printf("%lld\n", ans);

    return 0;
}

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

int main() {
  int N, l, r, S = 0;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> l >> r;
    S += r - l + 1;
  }
  cout << S << endl;
}
 

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

int main() {
 int a,b,k;
 cin >> a >> b >>k ;
 for(int i = a; i <= b; i++){
   if(i <= a+k-1 || i >= b - k + 1) cout << i << endl;
 }
 } 

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;
 
int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i,n) {
        ans += s[i] - '0';
    }
    string res = (ans%9==0) ? "Yes" : "No";
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3732
#include <stdio.h>
#define N 10000
int main()
{
    int na, nb, a[N], b[N], i, j, k = 0;
    scanf("%d", &na);

    for(i = 0; i < na; i++) {
        scanf("%d", &a[i]);
    }
    scanf("%d", &nb);

    for(i = 0; i < nb; i++) {
        scanf("%d", &b[i]);
    }
    
    for(j = 0; j < nb; j++) {
        for(i = 0; i < na; i++) {
            if(a[i] == b[j]) {
                k++; break;
            }
        }
    }
    printf("%d\n", k);
    return 0;
}

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


int main(){
    int K;
    char S[101];
    scanf("%d %s",&K,S);
    for (int i=0; S[i]!='\0' ; i++) {
        if (K==i) {
            printf("...\n");
            return 0;
        }
        else{
            printf("%c",S[i]);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1660
using System;

namespace sample
{
    class Program
    {
        static void Main(string[] args)
        {
            int [] heigth = new int [10];
            string h;
            for(int i=0; i<10; i++)
            {
                h = Console.ReadLine();
                heigth[i]= int.Parse(h);
            }
            Array.Sort(heigth);
            Array.Reverse(heigth);
            for(int i=0; i<3; i++)
            {
                Console.WriteLine(heigth[i]);
            }
        }
    }
}


Measured memory_bytes: 17960
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


a, b, h, m = LI()
i = (h / 12  + m / 720) * 2 * pi
j = m / 60 * 2 * pi
print((a ** 2 + b ** 2 - 2 * a * b * cos(i - j)) ** 0.5)

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	string s;
	cin >> s;

	bool ans = true;
	if(s[0] != 'A') ans = false;
	if(s.substr(2,s.length()-3).find('C')==string::npos)
		ans = false;
	int cnt = 0;
	rep(i, s.length()){
		if(s[i] >= 'a' && s[i] <= 'z') cnt++;
	}
	if(s.length()-2 != cnt) ans = false;
	
	cout << (ans ? "AC" : "WA") << endl;
	return 0;
}

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

const int N = 2e6;

int b[N];

main() {
	clog << "Ready\n";
	
	int n, m, c;
	cin >> n >> m >> c;

	for (int i = 1; i <= m; ++ i)
		cin >> b[i];
	int cnt = 0;
	for (int i = 1; i <= n; ++ i) {
		int res = c;
		for (int j = 1; j <= m; ++ j) {
			int x;
			cin >> x;
			res += b[j] * x;
		}
		if (res > 0)
			++cnt;
	}
	cout << cnt;
	
	cerr << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main()
{
	int S,h,m,s;
    cin>>S;
    h=(S-S%3600)/3600;
    S=S%3600;
    m=(S-S%60)/60;
    s=S%60;
    cout<<h<<":"<<m<<":"<<s<<endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  cout << (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
c2=10**a
if(a==1):c1=0
else:c1=c2//10
v = [-1]*b
for i in range(b):
  n,m=map(int,input().split())
  v[i] = [n,m]
#print(v) 

for i in range(c1,c2):
  p =str(i)
  t=True
  for j in v:
    
    if(int(p[j[0]-1]) != j[1]):
      t=False
      break
  
  if(t):print(i);exit()
  
print(-1)

Measured memory_bytes: 62448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,m;
    cin>>n>>m;
    cout<<(n-1)*(n)/2+(m-1)*(m)/2<<endl;
}

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

int main(){
  int N,K,X,Y,sum=0;
  cin >> N >> K >> X >> Y;
  if(K<N){
    for(int i=1;i<=K;i++){
      sum+=X;
    }
    for(int i=K+1;i<=N;i++){
      sum+=Y;
    }
  }
  else{
    sum=X*N;
  }
  cout << sum << endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#define N 16'001
#define O 8'000

using namespace std;

bool X[2][N]{};
bool Y[2][N]{};

int main() {
  string s;
  int x, y;
  cin >> s;
  cin >> x >> y;

  int i = 0;
  int M = s.size();
  int d = 0;
  while (i < M && s[i++] == 'F') {
    ++d;
  }
  X[0][d + O] = true;
  d = 0;
  while (i < M && s[i++] == 'F') {
    ++d;
  }
  Y[0][d + O] = true;
  Y[0][-d + O] = true;

  int j = 1;
  while (i < M) {
    d = 0;
    while (i < M && s[i++] == 'F') {
      ++d;
    }
    for (int k = 0; k <= 2 * M; ++k) {
      if ((k - d) >= 0 && (k + d) <= 2 * M) {
        X[j % 2][k - M + O] = X[(j - 1) % 2][k - M + O - d] || X[(j - 1) % 2][k - M + O + d];
      } else if ((k - d) >= 0) {
        X[j % 2][k - M + O] = X[(j - 1) % 2][k - M + O - d];
      } else if ((k + d) <= 2 * M) {
        X[j % 2][k - M + O] = X[(j - 1) % 2][k - M + O + d];
      }
    }

    d = 0;
    while (i < M && s[i++] == 'F') {
      ++d;
    }
    for (int k = 0; k <= 2 * M; ++k) {
      if ((k - d) >= 0 && (k + d) < N) {
        Y[j % 2][k - M + O] = Y[(j - 1) % 2][k - M + O - d] || Y[(j - 1) % 2][k - M + O + d];
      } else if ((k - d) >= 0) {
        Y[j % 2][k - M + O] = Y[(j - 1) % 2][k - M + O - d];
      } else if ((k + d) <= 2 * M) {
        Y[j % 2][k - M + O] = Y[(j - 1) % 2][k - M + O + d];
      }
    }
    ++j;
  }
  bool res = X[(j - 1) % 2][x + O] && Y[(j - 1) % 2][y + O];
  if (res) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

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

int main()
{
	
	string s;
	cin>>s;
	int f1=0,f2=0;
	if((s[2]=='1'&&s[3]<=50)||(s[2]=='0'))
{
	if(s[2]=='0'&&s[3]=='0')
	f1=0;
	else 
		f1=1;
	

}	
if((s[0]=='1'&&s[1]<=50)||s[0]=='0')
	{
		if(s[0]=='0'&&s[1]=='0')
		f2=0;

else
f2=1;		
}
	if(f1==1&&f2==1)
	cout<<"AMBIGUOUS"<<"\n";
	else if(f1==1)
		cout<<"YYMM"<<"\n";
	else if(f2==1)
		cout<<"MMYY"<<"\n";
	else if(f1==0&&f2==0)
	cout<<"NA"<<"\n";
}

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

using namespace std;

int main(){

  long long A,B,K;
  cin >> A >> B >> K;

  if(A >= K){
    cout << A - K <<' ' << B <<endl;
  }else if(K <= A+B){
    cout << 0 <<' '<< B - (K - A) <<endl;
  }else{
    cout << 0 <<' '<< 0 <<endl;
  }
 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    vector<vector<int>> a(3,vector<int> (3));
    rep(i,3){
        rep(j,3){
            cin >> a[i][j]; 
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    bool c[3][3];
    rep(i,3){
        rep(j,3){
            c[i][j]=false;
        }
    }
    rep(i,n) cin >> b[i];
    rep(i,3){
        rep(j,3){
            rep(k,n){
                if(a[i][j]==b[k]){
                    c[i][j]=true;
                }
            }
        }
    }
    if(
    (c[0][0]==true and c[0][1]==true and c[0][2]==true) or
    (c[1][0]==true and c[1][1]==true and c[1][2]==true) or
    (c[2][0]==true and c[2][1]==true and c[2][2]==true) or
    (c[0][0]==true and c[1][1]==true and c[2][2]==true) or
    (c[0][2]==true and c[1][1]==true and c[2][0]==true) or
    (c[0][0]==true and c[1][0]==true and c[2][0]==true) or
    (c[0][1]==true and c[1][1]==true and c[2][1]==true) or
    (c[0][2]==true and c[1][2]==true and c[2][2]==true) 
    ){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
/*
    rep(i,3){
        rep(j,3){
            cout << c[i][j] << " ";
        }cout << endl;
        }*/
}

Measured memory_bytes: 3580
import sys
import math
import itertools
import collections

# H1,M1,H2,M2,K = map(int,input().split())
# H2 -= K//60
# M2 -= K % 60

# print((H2 - H1) * 60 + (M2 - M1))

N = int(input())
A = list(map(int,input().split()))
if(0 in A):
    print(0)
    sys.exit()
ans = 1
hantei = 10 ** 18
for a in A:
    ans *= a
    if(ans > hantei):
        print(-1)
        sys.exit()
    
print(ans)

Measured memory_bytes: 84096
#include <iostream>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
    }
    return a;
}

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

int main() {
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    if (n > m) {
        swap(n, m);
        swap(s, t);
    }

    if (s[0] != t[0]) {
        cout << -1 << endl;
        return 0;
    }


    ll x, y, l;
    l = lcm(n, m);
    x = l / n;
    y = l / m;


    for (int i = 0; i < n; ++i) {
        if (i * x % y == 0 && s[i] != t[i * x / y]) {

            cout << -1 << endl;
            return 0;

        }
    }
    cout << l << endl;


    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N;

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) {
    res[n]++;
  }
  return res;
}

int main() {
  cin >> N;
  int ans = 0;
  for (int i = 3; i <= N; i += 2) {
    auto mp = prime_factor(i);
    int num = 1;
    for (auto e : mp) {
      num *= (e.second + 1);
    }
    if (num == 8) {
      ++ans;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
int N;
int a[200005];
int C[200005];

vector<int> V;

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	for (int i = N; i >= 1; i--) {

		if (C[i] % 2 == a[i]) {  }
		else {
			V.push_back(i);
			for (int k = 1; k*k <= i; k++) {
				if (i%k == 0) { 
					if (k != i / k) { C[k]++; C[i / k]++; }
					else { C[k]++; }
					 }
			}
		}

		/*if (i == 3) {
			for (int i = 1; i <= N; i++) { cout << "C[" << i << "]= " << C[i] << endl; }
		}*/

	}


	cout << V.size() << endl;

	for (int i = 0; i < (int)V.size(); i++) {
		if (i != 0) { cout << " "; }
		cout << V[i];
	}
	if (V.size()) { cout << endl; }

	return 0;
}

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		 int a = scanner.nextInt();
		 int b = scanner.nextInt();
		 int c = scanner.nextInt();

		 int count = 0;

		 /*
		 if(a == b){
			 if(b == c){
				 count++;
			 }
		 }
		 */

		 while(a<=b){
			 if(0 == (c % a)){
				 count++;
				 a++;
			 }else{
				 a++;
			 }
		 }

		 System.out.println(count);
	}
}

Measured memory_bytes: 17324
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

const Inf = 1 << 60

func main() {
	A, B, Q := ReadInt(), ReadInt(), ReadInt()
	s := ReadInts(A)
	t := ReadInts(B)
	sort.Ints(s)
	sort.Ints(t)
	for q := 0; q < Q; q++ {
		x := ReadInt()

		rsIdx := sort.Search(len(s), func(i int) bool {
			return x <= s[i]
		})
		rs, ls := Inf, -Inf
		if rsIdx < len(s) {
			rs = s[rsIdx]
		}
		if rsIdx > 0 {
			ls = s[rsIdx-1]
		}

		rtIdx := sort.Search(len(t), func(i int) bool {
			return x <= t[i]
		})
		rt, lt := Inf, -Inf
		if rtIdx < len(t) {
			rt = t[rtIdx]
		}
		if rtIdx > 0 {
			lt = t[rtIdx-1]
		}
		ans := Min(
			Max(rt-x, rs-x),
			Max(x-ls, x-lt),
			x-ls+rt-ls,
			x-lt+rs-lt,
			rt-x+rt-ls,
			rs-x+rs-lt,
		)
		fmt.Println(ans)
	}
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 6340
N,A,B=[int(x) for x in str(input()).split()]
C=[int(s) for s in str(input()).split()]
j=C
v=C
v.sort()
ma=[]
mi=[]
for i in range(B):
  ma.append(v[-1])
  v=v[:len(v)-1]

for i in range(A):
  mi.append(j[-1])
  j=j[:len(j)-1]

mi.sort()
ma.sort()
ava=0
for i in ma:
  ava+=i

ava/=len(ma)


count=B
while count>A and ma[0]<ava:

  ava=(len(ma)*ava-ma[0])/(len(ma)-1)
  ma=ma[1:]
  count-=1


C1=0
for i in C:
  if i==ma[0]:
    C1+=1
mi1=0
for i in mi:
  if i==ma[0]:
    mi1+=1
ma1=0
for i in ma:
  if i==ma[0]:
    ma1+=1


factorial=[1]
p=1
for i in range(1,51):
  p*=i
  factorial.append(p)  


ans=0
for i in range(mi1,ma1+1):
  ans+=factorial[C1]//factorial[C1-i]//factorial[i]
print(ava)
print(ans)




Measured memory_bytes: 3064
using System;

namespace ProblemA
{
    class Program
    {
        static void Main()
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            if(T.Remove(T.Length - 1) == S)
            {
                Console.WriteLine("Yes");
                return;
            }
            else
            {
                Console.WriteLine("No");
                return;
            }
        }
    }
}


Measured memory_bytes: 25820
N = int(input())
W = list(map(int, input().split()))
S1 = 0
S2 = sum(W)
ans = S2
for i in range(N - 1):
	S1 += W[i]
	S2 -= W[i]
	ans = min(ans, abs(S2 - S1))
print(ans)	


Measured memory_bytes: 9172
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	int i, j, k, l, m,A,B, sum, cntA,cntB;
	cntA = 1;
	cntB = 1;
	cin >> A >> B;
	char grid[100][100];
	for (i = 0; i < 100; i++) {
		for (j = 0; j < 100; j++) {
			if (i < 50)
				grid[i][j] = '.';
			else
				grid[i][j] = '#';
		}
	}
	
	cout << "100 " << "100" << endl;
	for (i = 0; cntB < B; i+=2) {
		for (j = 0; j<100; j += 2) {
			if (cntB < B) {
				grid[i][j] = '#';
				cntB++;
			}
			else break;
		}
	}
	for (i = 51; cntA < A; i += 2) {
		for (j = 0; j<100; j += 2) {
			if (cntA < A) {
				grid[i][j] = '.';
				cntA++;
			}
			else break;
		}
	}
	for (i = 0; i < 100; i++) {
		for (j = 0; j < 100; j++) {
			cout << grid[i][j];
		}
		cout<<endl;
	}
    return 0;
}



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

using namespace std;
int dp[100009];
int gg[109],n;
bool bt(int k)
{
    if(dp[k]!=-1)
        return dp[k];
    for(int i=0;i<n;i++)
    {
        if(k-gg[i]<0)break;
        if(!dp[k-gg[i]])return 1;
    }
    return 0;
}
int k;
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>gg[i];
    }
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<gg[0];i++)
    {
        dp[i]=0;
    }
    for(int i=0;i<k;i++)
    {
        dp[i]=bt(i);
    }
    /*for(int i=0;i<k;i++)
    {
        cout<<i<<" "<<dp[i]<<"\n";
    }*/
    bool g=0;
    for(int i=0;i<n;i++)
    {
        if(dp[k-gg[i]])g=1;
        else{
            g=0;
            break;
        }
    }
    if(g)cout<<"Second";
    else cout<<"First";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
string arr;
int mod = 1e9+7;
vector<vector<int>>dp;
long long getsum(int n,long long sum,int ind)
{
	if(ind>n)return (sum==5);

	if(dp[ind][sum]!=-1)return dp[ind][sum];
	long long res=0;
	
		if(arr[ind]=='?')
		{
			for(int i=0;i<=9;i++)
			{
		     	res = (res+getsum(n,((sum*10)%13+i)%13,ind+1)%mod)%mod;
			}
		}
			else res = (res+getsum(n,((sum*10)%13+arr[ind]-'0')%13,ind+1)%mod)%mod;
	
	return dp[ind][sum]=res;
}
int main() {
	// your code goes here
	cin.tie(NULL);
	cout.tie(NULL);
        cin>>arr;
		int k=arr.size();
		dp = vector<vector<int>>(100005,vector<int>(200,-1));
		// memset(dp,-1,sizeof(dp));
		long res = (getsum(k-1,0,0))%mod;
		cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 93200
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
	int a,b,n;
	cin>>n>>a>>b;

	int ans = max(a,b)-1;
	if(a==b)ans=0;
	ans = min(ans , max(n-a,n-b));
	if(abs(a-b)%2==0) ans = min(ans,(max(a,b)-min(a,b))/2);

	ans = min( ans , (a-1) + ((b-a+1)/2) );
	ans = min( ans , (n-b) + ((b-a+1)/2) );

	cout<< ans <<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
  int mountains;
  cin >> mountains;

  int heights[mountains];
  for (int i = 0; i < mountains; i ++) {
    cin >> heights[i];
  }

  int viewable = 1;
  int max_height = heights[0];

  for (int i = 1; i < mountains; i++) {
    if (heights[i] >= max_height) {
      viewable++;
      max_height = heights[i];
    }
  }

  cout << viewable << '\n';

  return 0;

}

Measured memory_bytes: 256
s = input()
k = input()
 
for i in range(len(s)) :
    if s[i] != '1' :
        if int(k) <= i :
            print('1')
            break
        else :
            print(s[i])
            break
    else :
        if i == len(s) - 1 :
            print('1')

Measured memory_bytes: 9056
#include <stdio.h>

int main() {
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d = a / b;
    r = a % b;
    f = (double)a / b;
    printf("%d %d %f\n", d, r, f);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  cin >> A;
  A.push_back(A.front() + K);
  int d = 0;
  for (int i = 0; i < N; i++) { chmax(d, A[i + 1] - A[i]); }
  cout << K - d << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 1792
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

bool used[30];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin >> s;

  vector<string> st;
  REP(i, s.size()) {
    REP(j, 26) {
      if(!used[j] && s[i]-'a' < j) {
        string t = s.substr(0, i) + (char)('a'+j);
        st.PB(t);
        break;
      }
    }
    used[s[i]-'a'] = true;
  }
  REP(j, 26) {
    if(!used[j]) {
      string t = s + (char)('a'+j);
      st.PB(t);
      break;
    }
  }

  sort(ALL(st));
  // cout << st << endl;
  if(st.size() == 0) cout << -1 << endl;
  else cout << st[0] << endl;

  return 0;
}


Measured memory_bytes: 256
require 'bigdecimal'
N, K = gets.chomp.split.map(&:to_i)
logs = (1..N).map do |i|
  if i >= K
    BigDecimal("1")
  else
    BigDecimal("1").div( (2 ** (Math.log2(K.to_f / i).ceil)), 10 )
  end
end
puts logs.reduce(:+) / N

Measured memory_bytes: 17916
n = int(input())
*a, = map(int,input().split())
b = sorted(a)
#print(a)
#print(b)
cnt = 0
for i in range(n):
  if a[i] != b[i]:
    cnt += 1
  if cnt > 2:
    print('NO')
    exit()
print('YES')    


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

char S[11];

ll dfs(int i, ll sum, ll next) {
  if (S[i] == '\0') return sum + next;
  ll n = S[i]-'0';
  return dfs(i+1, sum+next, n) + dfs(i+1, sum, next*10 + n);
}

void _main() {
  cin >> S;
  ll ans = dfs(1, 0, S[0]-'0');
  cout << ans << "\n";
}

Measured memory_bytes: 256
n = int(input())
a =[int(x) for x in input().split()]

s = 0
for i in range(n):
	s = s ^ a[i]
	
for i in range(n):
	x = s ^ a[i]
	print(x, end='')
	if i == n - 1:
		print('')
	else:
		print(' ', end='')

Measured memory_bytes: 31624
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

short dp[4000][4000];
char s[4004], t[4004];

int main() {
    while (cin >> s >> t) {
        for (int j = 0; j < 4000; ++j) {
            fill(dp[j], dp[j] + 4000, 0);
        }

        int sLen = strlen(s);
        int tLen = strlen(t);

        short ret = 0;

        for (int j = 0; j < sLen; ++j) {
            for (int k = 0; k < tLen; ++k) {
                if (s[j] != t[k]) {
                    dp[j][k] = 0;
                } else if (j == 0 || k == 0) {
                    dp[j][k] = 1;
                } else {
                    dp[j][k] = dp[j-1][k-1] + 1;
                }

                ret = max(ret, dp[j][k]);
            }
        }

        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 34348