akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int K;
  cin >> K;
  ll ans = 1;
  ll num = 7;
  unordered_map<int, int> um{};
  while (true) {
    if (num % K == 0) break;
    if (um[num % K] == 1) {
      cout << -1 << endl;
      return 0;
    }
    um[num % K] = 1;
    ans++;
    num *= 10;
    num += 7;
    num %= K;
  }
  cout << ans << endl;
}

Measured memory_bytes: 42640
#include<stdio.h>

int main(){
	char b;
  
  	scanf("%c", &b);
  
  	if(b == 'A'){
    	printf("T\n");
    }else if(b == 'T'){
    	printf("A\n");
    }else if(b == 'C'){
    	printf("G\n");
    }else if(b == 'G'){
    	printf("C\n");
    }
  	return 0;
}

Measured memory_bytes: 128
##import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
mod=10**9+7
n=int(input())
res=[0]*(2*10**5+1)
d=[0]*(n+1)
c_b=0
d[0]=1
for i in range(n):
    c=int(input())
    if c_b==c:
        d[i+1]=d[i]
    else:
        d[i+1]=d[i]+res[c]
        res[c]+=d[i]
        res[c]%=mod
    d[i+1]%=mod
    c_b=c
print(d[n])

Measured memory_bytes: 83196
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n[3];
    cin >> n[0] >> n[1] >> n[2];
    sort(n, n+3);
    int o = 0;
    if (n[2] % 2 == n[0] % 2 && n[2] % 2 == n[1] % 2) o = 0;
    else if (n[2] % 2 == n[0] % 2 || n[2] % 2 == n[1] % 2) o = 2;
    else o = 1;
    cout << (n[2] - n[0]) /2 + (n[2] - n[1])/2 + o << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
   ll n;
   cin >>n;
   vector<pair<ll,ll>>a(n);
   for(ll i=0;i<n;i++){
     ll z,zz;
     cin >> z >> zz;
     a.at(i)=make_pair(zz,z);
   }
   sort(a.begin(),a.end());
   ll now=0;
   bool ans = true;
   for(ll i=0;i<n;i++){
         now+=a.at(i).second;
     if(now>a.at(i).first)ans = false;
   }
   if(ans)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
 }

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
int last=0;

vector<bool> furui_bool(int n) {
  vector<bool> fu(n + 1, 1);
  fu.at(0) = 0; fu.at(1) = 0;
  for (int i=2; i <= n/2 + 1; i++) {
    if (fu.at(i) == 1) {
      int j = 2 * i;
      while (j <= n) {
        fu.at(j) = 0;
        j += i;
      }
    }
  }
  return fu;
}

vector<ll> prime_fac(ll n, ll &max) {
  ll sq = sqrt(n);
  vector<ll> pr(sq + 2, 0);
  vector<bool> fu = furui_bool(sq + 2);
  for (int i=2; i < sq + 1; i++) {
    if (fu.at(i)) {
      while (n % i == 0) {
        n /= i;
        max = i;
        pr.at(i)++;
      }
    }
  }
  if (n > 1) {
    last++;
  }
  return pr;
}

int main(){
  ll n;
  cin >> n;
  if(n==1){cout << 0 << endl;return 0;}
  ll max = 1;
  ll ans=0;
  vector<ll> out = prime_fac(n,max);
  for (int i=2;i<=sqrt(n);i++){
    if(out[i]>=1){
      int b=1;
      while(1){
        out[i]-=b;
        if(out[i]>=0)ans++;
        else break;
        b++;
      }
    }
  }
  cout << ans+last << endl;
}


Measured memory_bytes: 11408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    int c[n-1];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        sum += k;
    }
    for(int i = 0; i < n-1; i++){
        cin >> c[i];
    }
    for(int i = 0; i < n-1; i++){
        if(a[i]+1 == a[i+1]){
            sum += c[a[i]-1];
        }
    }
    cout << sum;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  rep(i, 0, N) cin >> V[i];
  int ans = 0;
  rep(i, 0, min(N, K)+1) rep(j, 0, min(N, K)+1) {
    if(i + j > min(N, K)) continue;
    priority_queue<int,vector<int>,greater<int>> Q;
    rep(k, 0, i) Q.push(V[k]);
    rep(k, 0, j) Q.push(V[N-1-k]);
    int n = K - i - j;
    while(n-- && !Q.empty() && Q.top() < 0) Q.pop();
    int sum = 0;
    while(!Q.empty()) {
      sum += Q.top(); Q.pop();
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int main() {
	vector<int>w;
	int t;
	while (cin >> t){
		if (t == -1)
			break;
		else if (t <= 10)
			w.push_back(1150);
		else if (t <= 20)
			w.push_back(1150 + (t - 10) * 125);
		else if (t <= 30)
			w.push_back(2400 + (t - 20) * 140);
		else
			w.push_back(3800 + (t - 30) * 160);
	}
	for (int i = 0; i != w.size(); i++){
		cout << 4280 - w[i];
		cout << endl;
	}
	char c;
	cin >> c;
}

Measured memory_bytes: 3124
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
#include<queue>
#include<string.h>
#include<bitset> 
#define PI acos(-1.0)
using namespace std; 

int main()
{
	bitset<4000005> bs(1);
	int n,x,sum=0;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++)
		{
			scanf("%d",&x);
			bs|=bs<<x;
			sum+=x;
		}
	if(n==1)
	{
		printf("%d\n",sum);
		return 0;
	}
	for(int i=(double)sum/2.0+0.5;i<=sum;i++)
		{
			if(bs[i]==1)
			{
				printf("%d\n",i);
				break;
			}
		}
	return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#define N 101
int main(){
  int G[N][N],a[N],f[N];
  int n,i,j,k=1,m=0,num,sum=0;
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  a[0]=0;
  f[0]=1;
   
  for(i=1;i<n;i++) f[i]=0;
   
  while(1){
    num=2001;
     
    for(i=0;i<k;i++){
      for(j=0;j<n;j++){
    if(G[a[i]][j]<num && G[a[i]][j]!=-1 && f[j]!=1){
      num=G[a[i]][j];
      m=j;
    }
      }
    }
     
    if(k!=n){
      a[k]=m;
      f[m]=1;
      sum+=num;
      k++;
    }
    else break;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N;
    int W[100];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> W[i];
    }
    int ans = 1e+6;
    for(int i = 0; i < N; i++){
        int sum1 = 0;
        int sum2 = 0;
        for(int j = 0; j < N; j++){
            if(j <= i) sum1 += W[j];
            else sum2 += W[j];
        }
        ans = min(ans, abs(sum1-sum2));
    }
    cout << ans << endl;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

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

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

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

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

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

    map<int, ll> f;
    vector<ll> s(n+1);
    vector<int> a(n);
    for(int& i : a) cin >> i;

    s[0] = 0;
    for(int i = 1; i <= n; i++) s[i] = s[i-1] + a[i-1];
    for(int i = 1; i <= n; i++){
        s[i] = ((s[i] - i) % k + k) % k;
    }

    
    ll ans = 0;

    for(int i = 0; i <= n; i++){
        if(i >= k) f[s[i-k]]--;
        ans += f[s[i]];
        f[s[i]]++;
    }

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



Measured memory_bytes: 15104
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 1001000 
#define pb push_back 
int n,ans,pos[N],sum[N];
char s[N],p[N];
vector<int>ve[30];
vector<int>::iterator it;
int p1[N],p2[N],m;
bool check(int x)
{
	for(int i=1;i+x<=m;++i)
		if(p1[i+x]-x<p2[i])
			return false;
	return true;
}
int main()
{
	scanf("%d%s%s",&n,s+1,p+1);
	int i,last=n+1,flag=0,r;
	for(i=1;i<=n;++i) if(s[i]!=p[i]) flag=1;
	if(!flag) puts("0");
	else
	{
		flag=0;
		for(i=1;i<=n;++i) ve[s[i]-'a'].pb(i);
		for(r=i=n;i>=1;--i)
		{
			if(i==1||p[i-1]!=p[i])
			{
				last=min(last,i+1);
				it=lower_bound(ve[p[i]-'a'].begin(),ve[p[i]-'a'].end(),last);
				if(it==ve[p[i]-'a'].begin()) {flag=1; break;}
				--it;
				last=*it;
				++m;
				p1[m]=*it; p2[m]=r;
				r=i-1;
			}
		}
		if(flag) puts("-1");
		else
		{
			for(i=1;i<=m;++i) if(i<m+1-i) swap(p1[i],p1[m+1-i]),swap(p2[i],p2[m+1-i]);
			int l=0,mid; r=m;
			while(l<r)
			{
				mid=(l+r)>>1;
				if(check(mid)) r=mid;
				else l=mid+1;
			}
			printf("%d",r);
		}
	}
	return 0;
}

Measured memory_bytes: 15564
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const LL N = 1000000007;

LL n,l,r;
LL a[5005],dp[5005];

struct BIT{
	LL tr[100005];
	LL lowbit(LL x){ return (x & (-(x))); }
	void modify(LL x,LL v){ for(;x <= n + 2;x += lowbit(x)); tr[x] += v; }
	LL query(LL x){ LL ret = 0; for(;x;x -= lowbit(x)) ret += tr[x]; return ret; }
}t;

int main(){
	memset(dp,0x3f,sizeof(dp));
	cin >> n >> r >> l;
	for(LL i = 1;i <= n;i ++){
		cin >> a[i];
		a[i] ++;
	}
	a[0] = 1; dp[0] = 0; a[n + 1] = n + 2;
	for(LL i = 1;i <= n + 1;i ++){
		LL sr = 0,sl = 0;
//		dp[i] = dp[i - 1] + l;
		for(LL j = i - 1;j >= 0;j --){
			if(a[j] < a[i]) dp[i] = min(dp[i],dp[j] + r * sr + l * sl);
			if(a[j] > a[i]) sr ++; if(a[j] < a[i]) sl ++;
			t.modify(a[j],1);
//			cout << i << ' ' << j << ' ' << sr << ' ' << dp[i] << endl;
		}
		for(LL j = i - 1;j >= 0;j --) t.modify(a[j],-1);
	}
	cout << dp[n + 1] << endl;
	return 0;
}

Measured memory_bytes: 384
// Target Expert 

/*
 * Author    : raj1307 - Raj Singh
 * Institute : Jalpaiguri Government Engineering College
 * Date      : 28.07.19
 */

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <iomanip>
 #include <memory.h>
#include <assert.h>
using namespace std;

//#define DEBUG
#ifdef DEBUG
#define deb(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
#define debarr(a,n) cerr<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}

#else
#define deb(...) {}
#define debarr(a,n) {}
#define debmat(mat,row,col) {}
#define endl "\n"
#endif

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define int long long
#define pb push_back
#define sz(x) ((int)x.size())
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}

const int mod = 1000*1000*1000+7;

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


const int N = 1e5 + 5;

int n,k;

int cache[N];
int h[N];

int dp(int cur){

	if(cur>=n)
		return 1e15;

	else if(cur==n-1)
		return 0;
	else if(cache[cur]!=-1)
		return cache[cur];
	else{

		int ans=1e15;
		fr(i,1,k+1)
			ans=min(ans,abs(h[cur]-h[cur+i])+dp(cur+i));
		cache[cur]=ans;
		return ans;



	}

	



}








void solve(){


	cin>>n>>k;
	fr(i,0,n) cin>>h[i];
	

	memset(cache,-1,sizeof(cache));

	int ans=1e15;

	fr(i,1,k+1)
		ans=min(ans,abs(h[0]-h[i])+dp(i));
	
	cout<<ans;






	
	

}




signed main() {
	fio;
	
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--) {
		solve();
	}

	
	return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
int x[105050];
int N,X;
using namespace std;

int main()
{
	scanf("%d%d",&N,&X);
	for(register int i=1;i<=N;i++){
		scanf("%d",&x[i]);
		x[i]-=X;
	}
	int ans=fabs(x[1]);
	for(register int i=2;i<=N;i++)
		ans=__gcd(ans,(int)fabs(x[i]));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
N = int(input())
A = [int(s) for s in input().split(" ")]
ABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)
prev = [0]
for k, (a,i) in enumerate(ABI):
  curr = [0]*(k+2)
  for l in range(k+1):
    curr[l] = max(curr[l], prev[l]+abs(N-i-k+l)*a)
    curr[l+1] = prev[l]+abs(i-l-1)*a
    
  prev = curr
 
print(max(prev))

Measured memory_bytes: 9448
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"B":"A")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int x,a,b;
	int ans=0;
	cin >>x>>a>>b;
	cout<<solve(abs(x-a)>abs(x-b))<<endl;
}

Measured memory_bytes: 3620
#include<iostream>

using namespace std;

struct Card { char suit, value; };

void Bubble(struct Card c1[],int N) {
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j > i; j--) {
			if (c1[j].value < c1[j - 1].value) {
				Card t = c1[j];
				c1[j] = c1[j - 1];
				c1[j - 1] = t;
			}
		}
	}
}

void Selection(struct Card c2[],int N) {
	for (int i = 0; i < N; i++) {
		int minv = i;
		for (int j = i; j < N ; j++) {
			if (c2[j].value < c2[minv].value) {
				minv = j;
			}
		}
		Card t = c2[minv];
		c2[minv] = c2[i];
		c2[i] = t;
	}
}

bool judge(struct Card c1[], struct Card c2[],int N) {
	for (int i = 0; i < N; i++) {
		if (c1[i].suit != c2[i].suit) {
			return false;

		}
	}
	return true;
}

int main() {
	Card c1[100], c2[100];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> c1[i].suit >> c1[i].value;
		c2[i] = c1[i];
	}
	Bubble(c1, N);
	Selection(c2, N);
	for (int i = 0; i < N; i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << c1[i].suit << c1[i].value;
	}
	cout << endl;
	cout << "Stable" << endl;

	for (int i = 0; i < N; i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << c2[i].suit << c2[i].value;
	}
	cout << endl;

	if (judge(c1, c2, N)) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}

}


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

#define ll              long long
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             (int)(1e18)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define rep(i,j,n)      for(int i=j;i<n;i++)
#define all(p)          p.begin(),p.end()
#define ub(a,b)         upper_bound(all(a),b)
#define lb(a,b)         lower_bound(all(a),b)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int32_t main()
{
	run();
	int n, k;
	cin >> n >> k;
	vi dp(k + 1, -1), a(n);
	rep(i, 0, n)cin >> a[i];
	dp[k] = 0;
	for (int i = k; i >= 0; i--)
	{
		if (dp[i] == -1)
		{
			for (int j = 0; j < n; j++)
			{
				if (a[j] + i <= k and dp[a[j] + i] == 0)
				{
					dp[i] = 1;
					break;
				}
			}
			if (dp[i] != 1)
			{
				dp[i] = 0;
			}
		}
	}
	// for (auto ele : dp)
	// {
	// 	cout << ele << " ";
	// }
	// cout << endl;
	if (dp[0] == 0)
	{
		cout << "Second" << endl;
	}
	else {
		cout << "First" << endl;
	}
	return 0;
}

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

using namespace std;

int calc( int x[4], int op[3]){
    int n=x[0];    
    for(int i=0; i<3; i++){
        if( op[i]==0 ) n -= x[i+1];
        else n += x[i+1];
    }
    return n;
}
int search( int x[4], int op[3], int n){
    for(int i=0; i<2; i++)    
        for(int j=0; j<2; j++)    
            for(int k=0; k<2; k++){
                op[0]=i, op[1]=j, op[2]=k;
                if( calc(x,op)==7 ) return 0;;
            }

    return 1;
}
int main(){
    string s;
    cin >> s;

    int x[4];
    int op[3];
    for(int i=0; i<4; i++){
        x[i] = stoi(s.substr(i,1));
    }

    int result = search(x,op,0);
    if( result==1 ) cerr << "err" << endl;

    cout << x[0];
    for(int i=0; i<3; i++){
        if( op[i]==0) cout << '-';
        else cout << '+';
        cout << x[i+1];
    }
    cout << "=7"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int mp[105][105];

int main() {
  int w, h, n;  // w -> x ,h -> y
  cin >> w >> h >> n;
  rep(i, h) {
    rep(j, w) { mp[i][j] = 1; }
  }

  rep(k, n) {
    int x, y, a;
    cin >> x >> y >> a;

    if (a == 1) {
      rep(i, h) {
        rep(j, x) {
          mp[i][j] = 0;
          // cout << "a";
        }
      }
    } else if (a == 2) {
      rep(i, h) {
        for (int j = x; j < w; j++) {
          mp[i][j] = 0;
          // cout << "b";
        }
      }
    } else if (a == 3) {
      rep(i, y) {
        rep(j, w) {
          mp[i][j] = 0;
          // cout << "c";
        }
      }
    } else {
      for (int i = y; i < h; i++) {
        rep(j, w) {
          mp[i][j] = 0;
          // cout << " d";
        }
      }
    }
  }

  int ans = w * h;
  rep(i, h) {
    rep(j, w) {
      if (!mp[i][j]) ans--;
    }
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 3640
from itertools import permutations

N, C = map(int, input().split())

D = [None] * C
for i in range(C):
    D[i] = list(map(int, input().split()))

c = [None] * N
for i in range(N):
    c[i] = list(map(int, input().split()))

# (i+j)%3 = 0,1,2 のそれぞれで初期マスの色をカウント
t = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        t[(i+j)%3][c[i][j]-1] += 1

ans = 10**12

# 塗り分けの順列総数
for p in permutations(range(C),3):
    tmp = 0
    for i in range(C):
        tmp += D[i][p[0]] * t[0][i]
        tmp += D[i][p[1]] * t[1][i]
        tmp += D[i][p[2]] * t[2][i]
    ans = min(ans,tmp)

print(ans)

Measured memory_bytes: 76124
qname=[]
qt=[]
cnt=0
name=[]
t=[]
n,q=list(map(int,input().split()))
for i in range(n):
    a=input().split()
    name.append(a[0])
    t.append(int(a[1]))
while(len(t)!=0):
    tmp=t.pop(0)-q
    cnt+=q
    if tmp==0:
        qname.append(name.pop(0))
        qt.append(cnt)
    elif tmp<0:
        qname.append(name.pop(0))
        cnt+=tmp
        qt.append(cnt)
    else:
        t.append(tmp)
        name.append(name.pop(0))
for i in range(n):
    print(qname[i],qt[i])


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


Measured memory_bytes: 61928
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;
#define INF 1e+18
//#define int long long

signed main() {
	LL T, D, L;
	while (cin >> T >> D >> L, T) {
		int tim = 0;
		int ans = 0;
		for (int i = 0; i < T - 1; ++i) {
			int x;
			cin >> x;
			if (x >= L) {
				tim = D;
			}
			else {
				tim = max(0, tim - 1);
			}
			if (tim) {
				++ans;
			}
		}
		int d;
		cin >> d;
		cout << ans << endl;
	}

}


Measured memory_bytes: 3092
N, H, W = map(int, input().split())

A = []

for i in range(N):
    l = [c for c in map(int,input().split())]
    A.append(l)
li = [l for l in filter(lambda x:x[0] >= H, A)]
li = [l for l in filter(lambda x:x[1] >= W, li)]

print(len(li))



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

#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

using Weight = int;
class Edge {
public:
	int s; //source
	int d; //destination
	Weight w; //weight
	Edge(int s = 0, int d = 0, Weight w = INF) : s(s), d(d), w(w) {};
	bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

//?????¢?´¢, ??¢?´¢???, ??¢?´¢???
enum { WHITE, GRAY, BLACK };
//???????§?????????????(???????????????) Single Source Shortest Path
//Dijkstra O( |E|log|V| )
//dist: ?§????????????????????????§??????????????¢
//?????????: ???????????¨????????????(??????-1)
vector<int> dijkstra(const Graph &g, int s, vector<Weight> &dist) {
	typedef tuple<Weight, int, int> State; //?§?????????????????°?????????? ??? ???
	priority_queue<State, vector<State>, greater<State> >PQ;
	int n = g.size();
	vector<int> color(n, WHITE);
	vector<int> prev(n, -1);
	dist.assign(n, INF); //distance
	dist[s] = 0; PQ.emplace(0, s, -1); color[s] = GRAY; //?§????
	while (!PQ.empty()) {
		Weight d; int v; int u;
		tie(d, v, u) = PQ.top(); PQ.pop(); //dist???????°??????¨??????????´????????????????
		if (dist[v] < d) continue; //?????§???????????§???????????°??????
		color[v] = BLACK;
		prev[v] = u;
		for (auto &e : g[v]) { //??£??\????????????????????¨????????????		
			if (color[e.d] == BLACK)continue; //??¢?´¢????????????
			if (dist[e.d] > dist[v] + e.w) {
				dist[e.d] = dist[v] + e.w;
				PQ.emplace(dist[e.d], e.d, v);
				color[e.d] = GRAY;
			}
		}
	}
	return prev;
}

signed main() {
	int N, M, s, t; cin >> N >> M >> s >> t; s--, t--;
	Graph G(N);
	rep(i, 0, M) {
		int x, y; cin >> x >> y; x--, y--;
		G[x].emplace_back(x, y, 1);
		G[y].emplace_back(y, x, 1);
	}
	vector<int> dist;
	dijkstra(G, s, dist);
	dumpc(dist);
	int mi = dist[t];

	vector<int> cnt(N, 0);
	for (auto &d : dist)if (d < N)cnt[d]++;

	dumpc(cnt);
	vector<int> dist2;
	dijkstra(G, t, dist2);
	dumpc(dist2);
	vector<int> cnt2(N, 0);
	for (auto &d : dist2)if (d < N)cnt2[d]++;
	dumpc(cnt2);

	int ans = 0;
	rep(i, 0, mi - 1) {
		ans += cnt[i] * cnt2[mi - 1 - i - 1];
		dump(ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23000
# -*- coding: utf-8 -*-

import itertools

n = int(input())
s = [[] for _ in range(n)]
for i in range(n):
    s[i] = list(input())

delete = []

for i in range(n):
    if s[i][0] == "M" or s[i][0] == "A" or s[i][0] == "R" or s[i][0] == "C" or s[i][0] == "H":
        pass
    else:
        delete.append(i)

diff = 0
for i in range(len(delete)):
    del s[delete[i] - diff]
    diff += 1

cand = [0,0,0,0,0]
for i in range(len(s)):
    if s[i][0] == "M":
        cand[0] += 1
    if s[i][0] == "A":
        cand[1] += 1
    if s[i][0] == "R":
        cand[2] += 1
    if s[i][0] == "C":
        cand[3] += 1
    if s[i][0] == "H":
        cand[4] += 1

ans = 0

for i in range(5):
    for j in range(5):
        if i == j:
            break
        for k in range(5):
            if i == k:
                break
            if j == k:
                break
            ans += int(cand[i] * cand[j] * cand[k])

print(ans)

Measured memory_bytes: 23876
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}



int main(){
    int n;
    cin >> n;
    vint a(n,0);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int ans = 0;
    vint flag(1000010, 1);
    rep(i,n){
        int num = a[i];
        bool dup_flag=0;
        if(i != n-1 && a[i] == a[i+1]){
            dup_flag = 1;
        }
        if(flag[num]){
            ans++;
            int count=1;
            while(num*count < 1000010){
                flag[num*count] = 0;
                count++;
            }
            if(dup_flag) ans--;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 8020
#include <bits/stdc++.h>
using namespace std;
long long Q(long long X){
  if (X<5) return X;
  return X+Q(X/5);
}
int main(){
  long long N;
  cin >> N;
  if (N%2==1){
    cout << 0;
  } else {
    N/=10;
    cout << Q(N);
  }
}

Measured memory_bytes: 256
import scala.collection.mutable.Queue
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val K = in.nextInt
  val q = Queue((1L to 9L): _*)

  def next(): Long = {
    val i = q.dequeue
    val lastDigit = i % 10
    val m = i * 10 + lastDigit
    if (lastDigit != 0) q.enqueue(m - 1)
    q.enqueue(m)
    if (lastDigit != 9) q.enqueue(m + 1)
    i
  }

  (1 until K).foreach(_ => next())
  println(next())
}

Measured memory_bytes: 51716
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

ll a[100000];

int main()
{
	int n;
	ll ans=1e17-1;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll cnt=0;//操作回数
	ll sum=0;//合計
	//最初が+の場合
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
		if((i&1)==0)
		{
			if(sum<=0)
			{
				cnt+=(1-sum);
				sum=1;
			}
		}else{
			if(sum>=0)
			{
				cnt+=(sum+1);
				sum=-1;
			}
		}
	}
	ans=min(cnt,ans);
	cnt=0;
	sum=0;
	//最初が-の場合
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
		if((i&1)==1)
		{
			if(sum<=0)
			{
				cnt+=(1-sum);
				sum=1;
			}
		}else{
			if(sum>=0)
			{
				cnt+=(sum+1);
				sum=-1;
			}
		}
	}
	ans=min(ans,cnt);
	cout<<ans<<endl;
	return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll n;
    string ss;
    cin >> ss;
    n = ss.size();
    ll i=2;
    while(1)
    {

        if(i==n) break;
        string a,b;
        ll nn = n-i;
        for(ll j = 0; j < nn/2; j++) a.pb(ss[j]);
        for(ll j = nn/2; j < n-i; j++) b.pb(ss[j]);
        if(a==b)
        {

            cout << n-i;
            return 0;
        }
        i+=2;
    }
    cout << 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
L = [0] * (10 ** 5 + 4)
for a in A:
  L[a] += 1
  L[a + 3] -= 1

s = 0
for i, l in enumerate(L):
  s += l
  L[i] = s
  
print(max(L))

Measured memory_bytes: 13964
#include <stdio.h>
#include <stdlib.h>

using namespace std;

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

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    int x;
    if (a>=b) x = gcd(a, b);
    else x = gcd(b, a);

    printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 2704
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const int N = 1e5 + 7;
vector <int> g[N];

int used[N];
int cmp_sz = 0;
bool bad = false;

void dfs(int u) {
  ++cmp_sz;
  for (auto v : g[u]) {
    if (used[v] == -1) {
      used[v] = used[u] ^ 1;
      dfs(v);
    } else if (used[v] != (used[u] ^ 1)) {
      bad = true;
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  fill(used, used + n, -1);
  int cnt1 = 0, cnt2 = 0, cnt3 = 0;
  for (int i = 0; i < n; ++i) {
    if (used[i] == -1) {
      used[i] = 0;
      cmp_sz = 0;
      bad = false;
      dfs(i);
      if (cmp_sz == 1) ++cnt1;
      else if (!bad) ++cnt2;
      else ++cnt3;
    }
  }
  ll ans = 2LL * cnt1 * n - (ll)cnt1 * cnt1 + 2LL * cnt2 * cnt2 + 2LL * cnt3 * cnt2 + (ll)cnt3 * cnt3;
  cout << ans << '\n';
}



Measured memory_bytes: 10240
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#define ll long long
#define MAX 1000003
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define vi vector<int>
#define ull unsigned ll
using namespace std;

int main(){
	IOS;
	int a,b;
	cin>>a>>b;
	int sum=a+b;
	if(sum&1){
		cout<<"IMPOSSIBLE";
		cout<<endl;
	}
	else {
		cout<<sum/2;
		cout<<endl;
	}
return 0;
}

Measured memory_bytes: 256
n,m=map(int, input().split())
a=[[int(i) for i in input().split()] for n in range(n)]
al=[]
for i in a:
    i=i[1:]
    al.append(i)
cnt=0
for i in range(m):
    if all(i+1 in j for j in al):
        cnt+=1
print(cnt)

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

ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(a % b, b);
}
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main(void) {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  // A以上B以下の整数のうち、CでもDでも割り切れないものの個数
  // 1<=A<=B<=1e18なのでひとつづつ調べると時間がかかる
  // BからCで割り切れる個数を引く、同じくDで割り切れる個数を引く
  // BからCとDの最小公倍数で割り切れる個数を足す、引きすぎたのを戻す
  // Aも同じようにしてそれぞれを引く
  ll B2 = B - (B/C) - (B/D) + (B/lcm(C, D));

  A--;
  ll A2 = A - (A/C) - (A/D) + (A/lcm(C, D));

  cout << B2 - A2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <functional>
#include <algorithm>
#define MAX_V 100
#define INF 10000000
using namespace std;

struct edge{
  int to,cost;
};

typedef pair<int,int> P; //firstは最短経路,secondは頂点番号

vector<edge> G[MAX_V];
int vertexes,edges;
int d[MAX_V][MAX_V];

void dijkstra(int start,int tickets){
  priority_queue<P,vector<P>,greater<P> > que;
  for(int i=0;i<vertexes;i++) d[tickets][i] = INF;
  d[tickets][start] = 0;
  que.push(P(0,start));

  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second; 
    if(d[tickets][v] < p.first) continue; //異なる2経路のコストで高い方は無視
    for(int i=0;i<G[v].size();i++){
      edge e = G[v][i];
      int minimum = (tickets==0 ? d[tickets][v] + e.cost: min(d[tickets][v] + e.cost, d[tickets-1][v] + e.cost/2));
      if(d[tickets][e.to] > minimum){
        d[tickets][e.to] = minimum;
        que.push( P(d[tickets][e.to],e.to) );
      }
    }
  }
}

int main(){
  int discounts,start,destination;
  while(cin >> discounts >> vertexes >> edges >> start >> destination){
    if(!discounts && !vertexes && !edges && !start && !destination) break;
    for(int i=0;i<edges;i++){
      int a,b,fee;
      cin >> a >> b >> fee;
      a--; b--;

      edge E;
      E.to = b;
      E.cost = fee;
      G[a].push_back(E);

      E.to = a;
      G[b].push_back(E);
    }
    start--; destination--;
    for(int i=0;i<=discounts;i++) dijkstra(start,i);
    cout << d[discounts][destination] << endl;
    for(int i=0;i<MAX_V;i++) G[i].clear();
  }
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[N];
    vector<pair<int,int>> P;
    REP(i,N){
        cin >> A[i];
        P.pb({A[i],i+1});
    }
    sort ALL(P);
    REP(i,N){
        cout << P[i].second << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 2164
//killer_R@$tog!
#include<bits/stdc++.h>
using namespace std;
#define hell 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define mp make_pair
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define ll long long int
#define N 100009
#define all(b) b.begin(),b.end()
#define sz sizeof
#define shuru(h) memset(h,0,sz(h))
//int pr[N];
//int seg[N];
/*int query(int l,int r,int sl,int sr,int p)
{
    if(r<sl || l>sr)
        return 0;
    if(sr<=r && sl>=l)
        return seg[p];
    int m=sl+(sr-sl)/2;
    return (__gcd(query(l,r,sl,m,2*p+1),query(l,r,m+1,sr,2*p+2)));
}

int build(int l,int r,int p,int arr[])
{
    if(l==r)
    {
        seg[p]=arr[l];
        return seg[p];
    }
    int m=l+(r-l)/2;
    seg[p]=__gcd(build(l,m,2*p+1,arr),build(m+1,r,2*p+2,arr));
    return seg[p];
}
void isprime()
{
    memset(pr,1,sizeof(pr));
    pr[1]=0;
    for(int i=2;i*i<=N;i++)
    {
        if(pr[i])
        {
            for(j=i*i;j<=N;j+=i)
            {
                pr[j]=0;
            }
        }
    }
}*/
void killer()
{
    int n,k;cin>>n>>k;int a[n+1],dp[k+1];shuru(dp);
  rep(i,1,n+1)
  {
    cin>>a[i];dp[a[i]]=1;
  }
  rep(i,1,k+1)
  {
    rep(j,1,n+1)
    {
        //cout<<i<<endl;
      if(dp[i])continue;
      if(a[j]>=i)break;
      int t=i-a[j];
      if(!dp[t]){dp[i]=1;break;}
    }
  }  
    if(dp[k])cout<<"First";
    else
      cout<<"Second";
    return;
}
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    //int h=(int)ceil(log2(n));
    //h=2*(int)pow(2,h)-1;
    //build(0,n-1,0,a);

    ll t;
    t=1;
    while(t--)
        killer();

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <stdio.h>

using namespace std;

int main() {
	int N;
	string S, T;
	string result = "";
	cin >> N;
	cin >> S >> T;
	for (int i = 0; i < N; i++) {
		result += S[i];
		result += T[i];

	}
	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, p;
    cin >> a >> p;
    p += a * 3;
    cout << p / 2 << endl;
    return 0;
}

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

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

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int value[];
		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			value = new int[n];
			int sum = 0;
			int max = 0;
			int min = 1000;
			for (int i = 0; i < value.length; i++) {
				value[i] = sc.nextInt();
				sum += value[i];
				if (max < value[i]) {
					max = value[i];
				}
				if (min > value[i]) {
					min = value[i];
				}
			}
			sum = sum - max - min;
			int average = 0;
			average = sum / (n - 2);
			System.out.println(average);
		}
	}
}

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

int main() {
  string S,T;
  cin >> S >> T;
  bool ans = true;
  
  for (int i = 0; i < S.size() ;i++){
    if (S.at(i) != T.at(i)){
      ans = false;
    }
  }
  
  if (ans){
    if (S.size() + 1 == T.size()){
      cout << "Yes" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
      
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE
//ABS, task 09, 2020/04/11
//ms, tle
/*
*/

int main(void){
  int N;
  string S;
  int64_t r=0;
  int64_t g=0;
  int64_t b=0;
  int64_t ans;

  cin >>N;
  cin >>S;

  for(int i=0;i<N;i++){
    if(S.at(i)=='R') r++;
    if(S.at(i)=='G') g++;
    if(S.at(i)=='B') b++;
  }

  ans = r*g*b;
  //cout <<"r:" <<r <<" g:"<<g <<" b:" <<b <<endl;


  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(S.at(i) != S.at(j) && 2*j-i<N){
        if(S.at(i) != S.at(2*j-i)
         &&S.at(j) != S.at(2*j-i)) ans--;
      }
    }
  }
/*
  for(int i=0;i<N;i++) {
   for(int j=i+1;i+1<N;j++) {
     int k = 2*j - i;
     if (k >= N) break;
     if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ans--;
   }
 }
*/

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

/*
rgbrgb
8
,,,,,,
,,
*/


Measured memory_bytes: 3632
import sys
# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
# from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
# from itertools import permutations, combinations, product, accumulate, groupby
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
# inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []; mod = 10 ** 9 + 7
# dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n = i()
a = wi()
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b)

l_gcd = [a[0]]#左から
r_gcd = [a[-1]]#右から
kl = a[0]
kr = a[-1]
for i in range(n - 2):
    kl = gcd(kl, a[i + 1])
    l_gcd.append(kl)
    kr = gcd(kr, a[-(i + 2)])
    r_gcd.append(kr)

ansli = []
for i in range(n):
    if i == 0:
        ansli.append(r_gcd[-1])
    elif i == n - 1:
        ansli.append(l_gcd[-1])
    else:
        ansli.append(gcd(l_gcd[i - 1], r_gcd[-(i + 1)]))

print(max(ansli))

Measured memory_bytes: 14140
import numpy as np
import math as m

def main(**kwargs):
    mod = 10 ** 9 + 7
    r = repeatSquare(2, n, mod) - 1
    r -= factMod(n, n - a + 1, mod) * repeatSquare(factMod(a, 1, mod), mod - 2, mod)
    r -= factMod(n, n - b + 1, mod) * repeatSquare(factMod(b, 1, mod), mod - 2, mod)
    r %= mod
    return r

def repeatSquare(n, p, m):
    if p == 0:
        return 1

    if p % 2 == 0:
        tmp = repeatSquare(n, p/2, m) % m
        return tmp * tmp % m

    return n * repeatSquare(n, p-1, m) % m

def factMod(n, r, m):
    res = n

    while n > r:
        n -= 1
        res *= n
        res %= m

    return res

if __name__ == "__main__":
    
    cin = np.array(input().split(" ")).astype("int")
    n, a, b = cin

    cout = main(n=n, a=a, b=b)
    print(cout)
    

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

int main(void){
    string s;
    cin >> s;
    int check;
    int ans = 1000;
    for(int i = 0; i <= s.length()-3; i++){
        check = (s[i]-48)*100+(s[i+1]-48)*10+(s[i+2]-48);
        ans = min(ans, abs(753-check));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
const int maxn=1e5+10;
int arr[maxn],n,m;
const int mod=1e9+7;
int main()
{
    cin>>n>>m;
    while(m--)
    {
        int tmp;
        cin>>tmp;
        arr[tmp]=-1;
    }
    arr[0]=1;
    for(int i=1; i<=n; ++i)
    {
        if(arr[i]==-1)
        {
            arr[i]=0;
            continue;
        }
        else arr[i]=(i>=2?arr[i-2]:0)%mod+arr[i-1]%mod;
        arr[i]%=mod;
    }
    cout<<arr[n]<<endl;
    return 0;
}


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

using namespace std;

bool check(string s) {
  return s.size() % 2 == 0 && s.substr(0, s.size() / 2) == s.substr(s.size() / 2);
}

int main() {
  string s;
  cin >> s;
  do {
    s.pop_back();
  } while (!check(s));
  cout << s.size() << endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
T=[0]
X=[0]
Y=[0]
cnt=0

N=int(input())
for i in range(N):
	t_,x_,y_=[int(i) for i in input().split()]
	T.append(t_)
	X.append(x_)
	Y.append(y_)

def delta_p(l):
	return abs(X[l]-X[l-1])+abs(Y[l]-Y[l-1])
def delta_t(l):
	return T[l]-T[l-1]
	
for t in range(1,N+1):

	if cnt !=0:
		break
	if delta_p(t)>delta_t(t) or delta_p(t)%2!=delta_t(t)%2:
			cnt+=1
	else:
		continue

print('Yes' if cnt==0 else'No')

Measured memory_bytes: 11744
#include <cstdio>
#include <cstring>
const int M=100000+10;
char s[M];
int main()
{
    while(scanf("%s",s)!=EOF)
    {
        int n=strlen(s),f=1;
        for(int i=0;i<n;)
        {

            char a[8];
            for(int z=0;z<7;z++)
            a[z]='\0';
            int k=0;

            for(int j=i;j<i+7;j++)
                if(j<n)  a[k++]=s[j];
                else
                {
                    a[k++]='k';
                }
                a[k]='\0';

            if(strcmp(a,"dreamer")==0)
            {
                if(s[i+7]=='a'&&s[i+8]=='s'&&s[i+9]=='e') i+=5;
                else i+=7;
               // printf("i=%d,a=%s\n",i,a);
                continue;

            }
            a[6]='\0';
            if(strcmp(a,"eraser")==0)
            {
                i+=6;
                continue;
            }
            a[5]='\0';
            if(strcmp(a,"dream")==0||strcmp(a,"erase")==0)
            {
                i+=5;
                //printf("a=%s\n",a);
                continue;
            }
            f=0;
            if(f==0) break;
        }
        printf("%s\n",f==1?"YES":"NO");
    }
    return 0;
}


Measured memory_bytes: 256
import fractions
import math

[a,b] = [int(i) for i in input().split()]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

c = fractions.gcd(a,b)
ls = make_divisors(c)

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

cnt = 1

for i in range(len(ls)):
    if is_prime(ls[i]):
        cnt += 1
print(cnt)


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

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

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d.at(i);
    }

    set<int> values;
    for (int i = 0; i < N; i++) {
        values.insert(d.at(i));
    }

    cout << values.size() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;
    int N, K, Q = 0;
    cin >> N >> K >> Q;
    vector<int> pp(N, K - Q);
    int tmp = 0;
    for (int i = 0; i < Q; i++)
    {
        cin >> tmp;
        pp[tmp - 1] += 1;
    }
    for (int i = 0; i < N; i++)
    {
        if (pp[i] > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1024