akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

ll mult(ll n,ll m){//n^m%modを求める
    if(m==0) return 1;
    if(m==1){
        return n%mod;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%mod;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%mod;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=len(s);
    if(n==1){
      cout<<3<<endl;
      return 0;
    }
    ll ans=0;
    ll cnt=1;
    FOR(i,1,n+1){
      if(s[i-1]=='1'){
        ans+=mult(2,cnt-1)*mult(3,n-i)%mod;
        ans%=mod;
      }
      if(i!=n && s[i]=='1') cnt++;
    }
    ans+=mult(2,cnt);
    ans%=mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 512
def main():
        
    import math

    N_ko, Distance = map(int, input().split())

    cnt = 0

    for i in range(N_ko):
        x, y = map(int, input().split())
        dis = math.sqrt(x * x + y * y)
        
        if (dis <= Distance):
            cnt += 1

    print(cnt)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, a[20];
map<pair<int, int>, ll> mp[20][20];

ll solve(int l, int r, int x, int y) {
	if (l + 1 == r) return 0;
	map<pair<int, int>, ll>::iterator it = mp[l][r].find(make_pair(x, y));
	if (it != mp[l][r].end()) return it -> second;
	ll ans = 1e18;
	for (int i = l + 1; i <= r - 1; ++i)
		ans = min(ans, solve(l, i, x, x + y) + solve(i, r, x + y, y) + 1ll * (x + y) * a[i]);
	return mp[l][r][make_pair(x, y)] = ans;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	printf("%lld", solve(1, n, 1, 1) + a[1] + a[n]);
}


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

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

int dim;

bool ok(double v[],int exce,int obj);

int main(){

  while(cin >> dim && dim !=0){
    double inp[dim+3];
    for(int i=0;i<dim+3;i++){
      cin >> inp[i];
    }
    double ans=-1;
   
    for(int i=0;i<(dim+3)/2+1;i++){
      if(ok(inp,i,2*i)){
	ans=2*i+1;
	break;
      }
      if(ok(inp,i,2*i+1)){
	ans=2*i;
	break;
      }
    }
    cout << ans << endl;
    
  }
}

bool ok(double v[],int exce, int obj){
  int s=2*exce;
  int t=(2*exce+1)%(dim+3);
  obj=obj%(dim+3);
  double expe=0;
  for(int i=0;i<dim+3;i++){
    if(s == i ||  i == t )continue;
    double temp=1;
    for(int j=0;j<dim+3;j++){
      if(j==i || s==j || j==t)continue;
      temp*=((double)(obj-j)/(i-j));
    }
    expe+=(double)temp*v[i];
  }
  double sa=expe-v[obj];

  if(sa<pow(10,-3) && sa > -pow(10,-3))return true;
  return false;
}
	

Measured memory_bytes: 1284
n = int(input())
h = list(map(int, input().split()))
ans = 0

while True:
#    print(h)
    if max(h) == 0:
        break
    maxV = max(h)
    count = 1
    prev = h.index(maxV)

    if prev != len(h)-1:
        for i in range(prev+1, len(h)):
            if h[i] == maxV:
                if i > prev+1:
                    count += 1
                    prev = i
                else:
                    prev = i

    ans += count
    for i in range(len(h)):
        if h[i] == maxV:
            h[i] -= 1
#    filter(lambda x: x == maxV, h)
#    h = list(map(lambda x: x - 1, filter(lambda x: x == maxV, h)))

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
int main(int argc, char** argv) {
	double ans=0;
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		double x;
		string s;
		cin >> x >> s;
		if(s[0]=='B') x*=380000;
		ans+=x;
	}
	printf("%.10lf",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


int main(void) {
  string s, t;
  cin >> s;
  cin >> t;
  ll i;
  ll cs[26]={};
  ll ct[26]={};
  
  for(i=0; i<s.size(); i++)
    cs[s[i]-'a']=1;
  for(i=0; i<t.size(); i++)
    ct[t[i]-'a']=1;
  
  for(i=0; i<26; i++)
    if(cs[i]<ct[i]) {
      pt(-1);
      return 0;
    }
  
  vector<ll> pos[26];
  
  for(i=0; i<s.size(); i++)
    pos[s[i]-'a'].pb(i);
  
  for(i=0; i<26; i++)
    pos[i].pb(INF);
  
  ll ans=0;
  ll p=-1;
  for(i=0; i<t.size(); i++) {
    auto it=upper_bound(pos[t[i]-'a'].begin(), pos[t[i]-'a'].end(), p);
    
    if(*it==INF) {
      p=-1;
      ans+=s.size();
      auto jt=upper_bound(pos[t[i]-'a'].begin(), pos[t[i]-'a'].end(), p);
      p=*jt;
      
      if(i==(ll)t.size()-1) {
        ans+=*jt+1;
        break;
      }
      
    }else {
      p=*it;
      
      if(i==(ll)t.size()-1) {
        ans+=*it+1;
        break;
      }
    }
  }
  
  pt(ans);
}


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

int main(){
  vector<string> C(2);
  cin >> C.at(0) >> C.at(1);
  int check = 0;
  for(int i = 0;i<3;i++){
    if(C.at(0).at(i) == C.at(1).at(2-i)){
      check += 1;
    }
  }
  if(check == 3){
    cout << "YES" <<endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,g[5],t[5],k,s=1;
  int i,j;
  while(scanf("%d",&n)!=EOF){
    for(i=4;i>=0;i--){
      k=n%10;
      n/=10;
      g[i]=0;
      if(k>=5){
	g[i]=1;
	k-=5;
      }
      t[i]=k;
    }
    if(s==0)printf("\n");
    s=0;
    for(j=0;j<8;j++){
      for(i=0;i<5;i++){
	if(j==0){
	  if(g[i]==1)printf(" ");
	  else       printf("*");
	}
	if(j==1){
	  if(g[i]==0)printf(" ");
	  else       printf("*");
	}
	if(j==2)printf("=");
	if(j>2){
	  if(j-3==t[i])printf(" ");
	  else         printf("*");
	}
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()) {
			int n = scan.nextInt();
			if(n == 0) break;

			int[] a = new int[n];
			int[] b = new int[n];
			int input = 0;
			int max = Integer.MIN_VALUE;

			for(int i = 0 ; i < n ; i++) {
				a[i] = scan.nextInt();
				b[i] = a[i] + input;
				input = b[i];
			}

			for(int k = 0 ; k < n ; k++) {
				if(b[k] > max) {
					max = b[k];
				}
				for(int j = 0 ; j < k ; j++) {
					if(b[k] - b[j] > max) {
						max = b[k] - b[j];
					}
				}
			}
			System.out.println(max);
		}
	}

}


Measured memory_bytes: 33628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,sum=0;
  cin>>N;
  for(int i=0;i<N;i++){
  int j=0,k=0;
  cin>>j>>k;
  sum+=k-j+1;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
//#include <utility>
#include <stack>

using namespace std;
static const int MAX_STR_LEN = 20000;

void sh_result(stack< pair<int, int> > st);
void get_result(stack< pair<int, int> > *st);

int main(){
	int i, str_len;


	stack< pair<int, char> > st_block;  // ??°??¢?¨?????????????, ??°??¢?¨????(/, _, \)
	stack< pair<int, int> > st_area;    // ?°´?????????????????´???????????????, ??¢???

	string str;

	cin >> str;
	str_len = str.size();

	for (i = 0; i < str_len; i++) {
//		printf("str i = %d\n", i);
		switch (str[i]) {
		case '\\' :
			if (i == 0)
				st_area.push( make_pair(i, 0) );
			else if (str[i - 1] != '\\')
				st_area.push( make_pair(i, 0) );
			st_block.push( make_pair(i, str[i]) );
			break;
		case '_' :
			if (i == 0) {}
			else if (str[i - 1] == '/')
				st_area.push( make_pair(i, 0) );
			// 	st_area.push( make_pair(i, 0) );
			break;
		case '/' :
			if ( !(st_block.empty()) ) {
				auto b = st_block.top(); st_block.pop();
				if ( !(st_area.empty()) ) {
					auto a = st_area.top(); st_area.pop();
					while (a.first > b.first) {
						auto c = st_area.top(); st_area.pop();
						a.first = c.first;
						a.second += c.second;
					}
					if (a.first <= b.first) {
						a.second += i - b.first;
						st_area.push( a );
					}
				}
			}
			break;
		}
//		sh_result(st_area);
	}

		get_result(&st_area);

	return 0;
}


void sh_result(stack< pair<int, int> > st) {
	int i, st_size;
	st_size = st.size();
	printf("stack size = %d\n",st_size);
	for (i = 0; i < st_size; i++) {
		cout << st.top().first << ',' << st.top().second << endl;
		st.pop();
	}

}

void get_result(stack< pair<int, int> > *st) {
	int i, st_size, num = 0, area = 0;
	int empty_flag  = 0;
	int area_each_puddle[MAX_STR_LEN / 2] = {0};

	st_size = st->size();
//	printf("st_size = %d\n", st_size);

	for (i = 0; i < st_size && empty_flag != 1; i++) {
//		printf("i = %d\n", i);

		while (st->size() > 0) {
//			printf("stack size = %lu\n", st->size());

//			printf("before second 1\n");
			if (st->top().second == 0) {
//				printf("before pop 1\n");
				st->pop();
//				printf("after pop 1\n");
				if (st->size() == 0) {
					empty_flag = 1;
					break;
				}
			}
			else {
				break;
			}
		}

		if (empty_flag == 1) {
			break;
		}
		else {
//			printf("before second 2\n");
			area_each_puddle[i] = st->top().second;
			area += area_each_puddle[i];
			num++;
//			printf("before pop 2\n");
			st->pop();
//			printf("after pop 2\n");
			if (st->size() == 0) {
				empty_flag = 1;
				break;
			}
		}
	}

	//print result
	cout << area << endl;
	if (area == 0) {
		cout << 0 << endl;
	}
	else {
		// print num of puddle
		cout << num;

		//print each area of puddles
		for (i = num - 1; i >= 0; i--)
			cout << ' ' << area_each_puddle[i];

		cout << endl;
	}
}

Measured memory_bytes: 3336
#include <iostream>

using namespace std;

int bexp(int a, int x, int p) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return a * bexp(a, x - 1, p) % p;
    }
    int t = bexp(a, x / 2, p);
    return t * t % p;
}

int inv(int a, int p) {
    return bexp(a, p - 2, p);
}

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

    int c[p][p];
    for (int i = 0; i < p; i++) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < i; j++) {
            c[i][j] = (c[i-1][j-1] + c[i-1][j]) % p;
        }
    }

    int e[p][p];
    for (int i = 0; i < p; i++) {
        for (int j = 0; j < p; j++) {
            e[i][j] = j == 0 ? 1 : e[i][j-1] * i % p;
        }
    }

    int fac[p];
    for (int i = 0; i < p; i++) {
        fac[i] = i == 0 ? 1 : i * fac[i-1] % p;
    }

    int b[p];
    for (int i = p - 1; i >= 0; i--) {
        int y = 0;
        int neg = 1;
        for (int j = i; j >= 0; j--) {
            y = ((y + a[j] * c[i][j] * neg) % p + p) % p;
            neg = -neg;
        }
        b[i] = y * inv(fac[i], p) % p;

        for (int j = 0; j < p; j++) {
            a[j] = ((a[j] - b[i] * e[j][i]) % p + p) % p;
        }
    }

    for (int i = 0; i < p; i++) {
        cout << b[i] << (i == p - 1 ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 70528
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

int main (){
    char S[3],T[3];
    for (int i=0;i<3;i++){
        cin >> S[i];
    }
    
    for (int i=0;i<3;i++){
        cin >> T[i];
    }
    int answer = 0;
    for(int i=0;i<3;i++){
        if (S[i]==T[i]){answer++;}
        
    }
    cout <<answer;
    
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll=long long;
int main(){
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s] +=1;
  }
  cout << mp.size() << endl;
  return 0;
}

Measured memory_bytes: 19080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);


		int K = sc.nextInt();
		String S = sc.next();
		int s = S.length();

		if(s<=K) {
			System.out.println(S);
		}else {
			String ss = S.substring(0,K);
			System.out.println(ss+"...");


		}

	}

}


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

int main() {
  int a1,a2,a3;
  cin >> a1 >> a2 >> a3;
  if(a1+a2+a3 >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
    
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	/*auto cnt = new long[][](N, 26);
	foreach (i; 0..N)
	{
		auto S = RD!string;
		foreach (c; S)
		{
			++cnt[i][c-'a'];
		}
	}*/
	long[string] set;
	foreach (i; 0..N)
	{
		auto S = RD!string;
		string[] T;
		foreach (c; S)
			T ~= [c];
		T.sort();
		++set[T.join()];
	}

	long ans;
	foreach (key; set.keys)
	{
		ans += set[key] * (set[key]-1) / 2;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 25596
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l,m,flag=0;
 
	string s;
	
		cin>>s;
		l=s.length();
		if((l%2)!=1)
          flag=1;
		 m=l/2;
		for(int j=0;j<m;j++)
		{
			if(s[j]!=s[l-j-1])
				flag=1;
		}
		int x,y,q,r;
      x=(l-1)/2;
      q=x/2;
      for(int j=0;j<q;j++)
		{
			if(s[j]!=s[x-j-1])
				flag=1;
		}
      y=(l+3)/2;
      r=y/2;
      for(int j=r-1;j<l;j++)
		{
			if(s[j]!=s[l-j-1])
				flag=1;
		}
      if(flag==1)
        cout<<"No";
  else
    cout<<"Yes";
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
total = 0
def Sum(N):
    sum = 0
    while(N > 0):
        sum += int(N % 10)
        N /= 10
    return sum

for N in range(1,n+1):
    result = Sum(N)
    if result >= a and result <= b:
        total += N

print(total)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define INF 1<<30
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n;
	while(cin >> n && n) {
		vector<string> v(n);
		rep(i, n) cin >> v[i];

		int a[5] = {5, 7, 5, 7, 7};

		rep(i, n) {
			int j = i;
			bool flag = true;
			rep(k, 5) {
				string  s = "";
				while(s.size() < a[k]) {
					s += v[j];
					j++;
				}
				if(s.size() == a[k]) continue;
				flag = false;
				break;
			}
			if(flag) {
				cout << i + 1 << endl;
				break;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(void)
{
    int n,t,m=INT_MAX,i;
    scanf("%d",&n);
    char *s=calloc(n+1,sizeof(char));
    int *te=calloc(n,sizeof(int)),*tw=calloc(n,sizeof(int));
    scanf("%s",s);
    if(s[0]=='E')te[0]++;
    else tw[0]++;
    for(i=1;i<n;i++){
        if(s[i]=='E'){
            te[i]=te[i-1]+1;
            tw[i]=tw[i-1];
        }
        else{
            te[i]=te[i-1];
            tw[i]=tw[i-1]+1;
        }
    }
    free(s);
    for(i=0;i<n;i++){
        if(1>i)t=te[n-1]-te[i];
        if(i>n-2)t=tw[i-1];
        else{
            t=te[n-1]-te[i];
            t+=tw[i-1];
        }
        if(m>t)m=t;
    }
    free(te);
    free(tw);
    printf("%d",m);
    return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
const int MAX=1e5+5;

vi nb[MAX];
int dp[MAX];

void dfs(int v){
	if(dp[v]) return;
	for(auto u:nb[v]){
		dfs(u);
		dp[v]=max(dp[v],dp[u]+1);
	}
}

int main(){
	int N,M;
	cin>>N>>M;
	rep(i,M){
		int x,y;
      	cin>>x>>y;
		x--;y--;
		nb[x].push_back(y);
	}
	rep(i,N)dfs(i);
	int ans=0;
	rep(i,N)ans=max(ans,dp[i]);
	cout<<ans;
}

Measured memory_bytes: 8192
import sys
if sys.version_info[0]>=3: raw_input=input

cross=lambda a,b: (a.conjugate()*b).imag
dot=lambda a,b: (a.conjugate()*b).real

def solve(poly, p):
	f=False
	for i in range(len(poly)):
		a=poly[i]-p
		b=poly[(i+1)%len(poly)]-p
		if a.imag>b.imag: a,b=b,a
		if a.imag<=0 and 0<b.imag and cross(a,b)<0: f=not f
		if cross(a,b)==0 and dot(a,b)<=0: return 1
	return 2 if f else 0

checkio=lambda data: solve([complex(*e) for e in data[0]],complex(*data[1]))

n=int(raw_input())
poly=[[float(e) for e in raw_input().split()] for i in range(n)]
n=int(raw_input())
try:
	for i in range(n):
		print(checkio([poly,[float(e) for e in raw_input().split()]]))
except EOFError:
	pass

Measured memory_bytes: 6784
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string a,b,c;

  cin >> a >> b >> c;

  if((a[sz(a) - 1] == b[0]) && (b[sz(b) - 1] == c[0]))
    cout << "YES" << endl;
  else
  {
    cout <<"NO" << endl;
  }
  



  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 10000000007; //10^9+7

int k,n;
VE a;
int cnt[200002];

int main(){
  cin>>n>>k;
  int temp;
  int max_=0;
  REP(i,n){
    cin>>temp;
    a.push_back(temp);
    max_=max(max_,temp);
  }
  REP(i,a.size()){
    cnt[a[i]]++;
  }
  //REP(i,max_+1)print(cnt[i]);///
  sort(cnt,cnt+max_+1,std::greater<int>());
  int K=0;
  int ans;
  REP(i,max_+1){
    if(cnt[i]!=0){
      if(K>=k){
        //print("i "<<i<<" "<<cnt[i]);///
        ans+=cnt[i];
      }else{
        K++;
      }
    }
  }
  print(ans);
}

Measured memory_bytes: 1908
# 一列に並んだ N 本の林檎の木のうちいずれかに黄金の林檎が実ると言われています。
# そこで、何人かの監視員を配置してどの林檎の木もいずれかの監視員に監視された状態にしたいです。
# それぞれの監視員は N 本の木のうちいずれかに配置します。
# 便宜上、これらの木に 1 から N までの番号をつけます。
# 番号 i の木に配置された監視員は、番号が i−D 以上 i+D 以下のすべての林檎の木を監視します。
# 条件を満たすために少なくとも何人の監視員を配置する必要があるか求めてください。

input = gets.chomp.split
n = input[0].to_i
d = input[1].to_i

watchman = n / ((2 * d) + 1)

if n % ((2 * d) + 1) != 0
    watchman += 1
end

puts watchman

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
  string S; cin >> S;
  long long K; cin >> K;
  int i;
  int one = 0;
  for (i = 0; i < S.size(); i++) {
    if (S[i] == '1') one++;
    else break;
  }
  if (K > one) {
    cout << S[i] << endl;
  } else {
    cout << 1 << endl;
  }
    
	return 0;
}



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

inline u_long lcm(const u_long a, const u_long b) {
    return a * b / std::__gcd(a, b);
}

int main(void) {
    u_long a, b;

    while (std::cin >> a >> b) {
        std::cout << std::__gcd(a, b) << " " << lcm(a,b) << std::endl;
    }

    return 0;
}

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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int j = 0,r = 0;
    rep(i,n){
        if(s[i] == 'a'){
            if(a+b > r){
                cout << "Yes" << endl;
                r++;
                continue;
            }
        }
        if(s[i] == 'b'){
            if(a+b > r && b > j){
                cout << "Yes" << endl;
                r++; j++;
                continue;
            }
        }
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
	int N = inputValue();
	int H[100000];
	int f[100000];
	inputArray(H, N);
	
	REP(i, N){
		f[i] = 0;
	}
	string ans = "Yes";
	REP(i, N-1){
		if(H[i]>H[i+1]){
			H[i]--;
			f[i] = 1;
            if(H[i]>H[i+1]){
                ans = "No";
                break;
            }
            int c = i-1;
            while(c >= 0){
                if(H[c]>H[c+1]){
                    if(f[c] == 1){
                        ans = "No";
                        break;
                    }
                    H[c]--;
                    f[c] = 1;
                }
                c--;
            }
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main(void) {
  int n;
  scanf("%d", &n);
  double ans = 0;
  for( int i = 0; i < n; i++ ) {
    double x; string u; cin >> x >> u;
    if(u == "JPY") ans += x;
    else ans += (x*380000.0);
  }
  printf("%.6lf\n", ans);
  return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int input;

int main() {
    int result = 0;
    int rem_min = 10;
    REP(i, 5) {
        cin >> input;
        int rem = input % 10;
        if (rem_min > rem && rem != 0) {
            rem_min = rem;
        }
        if (rem != 0) {
            input += (10 - rem);
        }
        result += input;
    }
    result -= (10 - rem_min);
    cout << result  << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int t, n, s, f;
	while (1) {
		scanf("%d", &t);
		if (!t)
			break;
		scanf("%d", &n);
		while (n--) {
			scanf("%d %d", &s, &f);
			t -= s < f ? f - s : s - f;
		}
		if (t > 0)
			printf("%d\n", t);
		else
			printf("OK\n");
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;

int main()
{
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	double ans = (double)w * h / 2;
	int num = (w == x * 2 and h == y * 2) ?  1 : 0;
	cout << fixed << setprecision(9) << ans;
	cout << " " << num;
}


Measured memory_bytes: 3788
n = gets.chomp.to_i
a1 = gets.chomp.split(" ").map(&:to_i)
a2 = gets.chomp.split(" ").map(&:to_i)

max = 0
for i in 0..(n-1) do
  sum = 0
  for j in 0..(n-1) do
    if j < i then
      sum = sum + a1[j]
    elsif j > i then
      sum = sum + a2[j]
    else
      sum = sum + a1[j] + a2[j]
    end
  end 
  if sum > max then
    max = sum
  end
end

puts max


Measured memory_bytes: 1788
N = int(input())

INF = 105 * 10 ** 7
dp = [INF] * 100010
dp[0] = 0

for i in range(1, N+1):
    k = 1
    while k <= i:
        dp[i] = min(dp[i], dp[i-k] + 1)
        k *= 6
    k = 9
    while k <= i:
        dp[i] = min(dp[i], dp[i-k] + 1)
        k *= 9

print(dp[N])


Measured memory_bytes: 3828
def solve(s):
    mod = 10 ** 9 + 7
    if s <= 2:
        return 0
    elif s <= 5:
        return 1
    res = [0] * (s + 1)
    res_3 = 0
    for i in range(3, s + 1):
        res[i] = 1 + res_3
        res_3 += res[i - 2]
        res_3 %= mod
    return res[s] % mod


def main():
    s = int(input())
    res = solve(s)
    print(res)


def test():
    assert solve(7) == 3
    assert solve(2) == 0
    assert solve(1729) == 294867501


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

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

    ll N, K;
    cin >> N >> K;

    vector <ll> a;

    for(ll i=0; i<N; i++)
    {
        ll x;
        cin >> x;

        a.pb(x);
    }

    sort(all(a));

    if(K >= N)
    {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;

    for(ll i=0; i<N-K; i++)
    {
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n,q;
    while(cin>>n>>q){
        string process;
        int ptime;
        queue< pair<string,int> > que;
        for(int i=1;i<=n;i++){
            cin>>process>>ptime;
            que.push(make_pair(process,ptime));
        }

        int total_time=0;
        while(!que.empty()){
            pair<string,int> mp = que.front();
            que.pop();
            if(mp.second>q){
                total_time+=q;
                mp.second-=q;
                que.push(mp);
            }
            else{
                total_time+=mp.second;
                cout<<mp.first<<" "<<total_time<<endl;
            }
        }
    }
}


Measured memory_bytes: 6328
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[100001] = {};
int main() {
	ll n, x; cin >> n >> x;
	rep(i, 0, n)cin >> a[i];

	ll ans = 0;
	if (a[0] > x) {
		ans += a[0] - x;
		a[0] -= ans;
	}

	rep(i, 1, n) {
		ll diff = (a[i - 1] + a[i]) - x;
		if (diff > 0) {
			ans += (a[i - 1] + a[i]) - x;
			a[i] -= diff;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        for j in range(w):
            if (i+j)%2 == 0 :
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()


Measured memory_bytes: 7000
#include<iostream>
#include<cstring>

using namespace std;

const int M=2011;
int inv[M+1];
char g[20][82];
int cur;

int expr(int,int,int,int);

char gcic(int c,int t,int b=99){
  for(;t<b;t++){
    if(g[t][c]!='.')return g[t][c];
  }
  return '.';
}

int sexpr(int t,int l,int b,int r){
  while(gcic(l,t,b)=='.'){
    l++;
  }
  cur=l;
  while(gcic(r-1,t,b)=='.'){
    r--;
  }
  return expr(t,l,b,r);
}

int factor(int t,int l,int b,int r){
  if(gcic(l,t)=='-'){
    if(gcic(l+1,t,b)=='.'){
      return (M-factor(t,l+2,b,r))%M;
    }else{
      int v;
      for(v=t;g[v][l]!='-';v++);
      int vr;
      for(vr=l;g[v][vr]=='-';vr++);
      int rv=(sexpr(t,l,v,vr)*inv[sexpr(v+1,l,b,vr)])%M;
      cur=vr;
      return rv;
    }
  }else{
    char c=gcic(l,t);
    int prm;
    if(c=='('){
      prm=expr(t,l+2,b,r-2);
      cur+=2;
    }else{
      prm=c-'0';
      cur=l+1;
    }
    char pc=gcic(cur,t,b);
    if(pc=='.'){
      return prm;
    }else{
      int rv=1;
      int p=pc-'0';
      cur++;
      while(p--){
	rv=rv*prm%M;
      }
      return rv;
    }
  }
}

int term(int t,int l,int b,int r){
  int rv=factor(t,l,b,r);
  while(gcic(cur+1,t,b)=='*'){
    rv=(rv*factor(t,cur+3,b,r))%M;
  }
  return rv;
}

int expr(int t,int l,int b,int r){
  int rv=term(t,l,b,r);
  for(;;){
    char op=gcic(cur+1,t,b);
    if(op!='+'&&op!='-')break;
    int f=(op=='+')?1:-1;
    rv=(rv+f*term(t,cur+3,b,r)+M)%M;
  }
  return rv;
}

int main(){
  for(int i=1;i<=M;i++){
    for(int j=0;j<=M;j++){
      if(i*j%M==1){
	inv[i]=j;
      }
    }
  }
  int len;
  for(int n;cin>>n,n;){
    for(int i=0;i<n;i++){
      cin>>g[i];
      len=strlen(g[i]);
      for(int j=len;j<82;j++){
	g[i][j]='.';
      }
    }
    cur=0;
    cout<<expr(0,0,n,len)<<endl;
  }
}

Measured memory_bytes: 1180
import sys
import math
import bisect


def main():
    d = dict()
    for _ in range(int(input())):
        s = input()
        if s not in d:
            d[s] = 0
        d[s] += 1
    max_val = max(list(d.values()))
    '''
    print(d)
    print(max_val)
    '''
    A = []
    for a in d:
        if d[a] == max_val:
            A.append(a)
    A.sort()
    for a in A:
        print(a)

if __name__ == "__main__":
    main()


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	int cur = -1, cnt = 0;
	rep (i, n) {
	  int a;
	  cin >> a;
	  if (cur == -1 && a == 1) {
		cur = 2;
		cnt++;
	  }
	  if (cur == a) {
		cur++;
		cnt++;
	  }
	}
	cout << (cur == -1 ? -1 : n - cnt) << endl;
    
    return 0;
}



Measured memory_bytes: 3656
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n, m, x, y;
    cin >> n >> m;
    set < ll > s;
    while(n--){
        cin >> x >> y;
        if(y <= m){
            s.ins(x);
        }
    }
    if(sz(s) == 0){
        cout << "TLE\n";
        return 0;
    }
    auto it = s.begin();
    cout << *it << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N;
    cin >> N;
    vector<ll> A(N);
    cin >> A;

    ll x = 0;
    REP(i, N) {
        if (i % 2 == 0)
            x += A[i];
        else
            x -= A[i];
    }

    vector<ll> ans(N);
    ans[0] = x;
    FOR(i, 1, N) {
        ans[i] = (A[i - 1] - ans[i - 1] / 2) * 2;
    }

    REP(i, N) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int gcd(int a, int b) {
    return !b ? a : gcd(b, a % b);    
}

int n;
int main () {
    while (scanf("%d", &n) == 1) {
        int gd = gcd(360, n);
        int res = 360 / gd;
        printf("%d\n", res);
    }
}


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

void Nor(int* di){
    int j;
    j=di[0];
    di[0]=di[1];
    di[1]=di[5];
    di[5]=di[4];
    di[4]=j;
}
void Eas(int* di){
    int j;
    j=di[0];
    di[0]=di[3];
    di[3]=di[5];
    di[5]=di[2];
    di[2]=j;
}

void Rol(int* di){
    int j;
    j=di[1];
    di[1]=di[3];
    di[3]=di[4];
    di[4]=di[2];
    di[2]=j;
}
int serdi(int* di1,int* di2){
    int i=0;
    int k=0;
    int l;
    while(true){
        if(di1[0]==di2[0]){
            for(l=0;l<5;l++){
                if(di1[1]==di2[1]){
                    if(di1[2]==di2[2] and di1[3]==di2[3] and di1[4]==di2[4] and di1[5]==di2[5]){
                        k=1;
                        return true;
                    }else{
                     
                        break;
                    }
                    
                }
                if(l==4){
                    break;
                }
                Rol(di2);
            }
        }
        if(i==4){
            Rol(di2);
        }
        i+=1;
        if(i==9){
            break;
        }
        Nor(di2);
    }
    return false;
}


int main(){
    int t;
    int p;
    int n;
    int m;
    int f;
    int d=0;
    int di[100][100],di1[6],di2[6];
    cin>>n;
    for(t=0;t<n;t++){
        for(m=0;m<6;m++){
            cin>>di[t][m];
        }
    }
    for(f=0;f<n-1;f++){
        for(p=0;p<6;p++){
            di1[p]=di[f][p];
        }
        for(m=f+1;m<n;m++){
            for(p=0;p<6;p++){
                di2[p]=di[m][p];
            }
            if(serdi(di1,di2)){
                d+=1;
            }
        }
    }
    if(d>=1){
        cout<<"No"<<endl;
    }else {
        cout<<"Yes"<<endl;
    }
    return 0;
}




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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  for (int i = 0; i < N; i ++) {
    cin >> mochi.at(i);
  }
  
  sort(mochi.begin(), mochi.end());
  
  int j = 0;
  int height = 1;
  while (j < N - 1) {
    if (mochi.at(j) < mochi.at(j + 1)) {
      height ++;
    }
    j ++;
  }
  
  cout << height << endl;
}

Measured memory_bytes: 256
import functools

n, a, b = map(int, input().split(" "))
m = 10**9 + 7

total = pow(2, n, m) -1

def f(n, a, m):
    X = functools.reduce(lambda x,y : (x * y) % m, range(n, n-a, -1))
    Y = functools.reduce(lambda x,y : (x * y) % m, range(1, a+1))
    return  (X * pow(Y, m - 2, m)) % m

# nCa
print((total - f(n, a, m) - f(n, b, m)) % m)

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 998244353
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll b[100009];
void solve()
{
    ll n,m,x;
    cin>>n>>x>>m;ll ans=0;
    ll i=1;
    for(;i<=n;i++)
    {
    	ans+=x;
    	b[x]=1;
    	x*=x;
    	x%=m;
    	if(b[x]==1)
    		break;
    	if(x==0)
    	{
    		cout<<ans;
    		return;
    	}
    }
    ll ans1=0;
    if(i<n)
    {
    	ll z=x;
    	for(ll j=0;j<=100000;j++)
    	{
    		b[j]=0;
    	}
    	ll c=1,cnt=n-i;
    	for(;c<=cnt;c++)
    	{
    		ans1+=x;
    		b[x]=1;
    		x*=x;
    		x%=m;
    		if(b[x]==1)
    			break;
    		if(x==0)
    		{
    			cout<<ans+ans1;
    			return;
    		}
    	}
    	if(c>=cnt)
    	{
    		cout<<ans+ans1;
    		return;
    	}
    	ll d=cnt/c;
    	ans1*=d;
    	d*=c;
    	d=cnt-d;
    	for(ll j=0;j<d;j++)
    	{
    		ans1+=x;
    		x*=x;
    		x%=m;
    	}
    }
    cout<<ans+ans1;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 4300
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) {return (n==0)?1:10*TEN(n-1);}

/**
 * Fenwick Tree 
 *
 * 0-indexed
 */
template<class T>
struct Fenwick {
    int N;
    vector<T> seg;
    Fenwick(int N) : N(N) {
        seg.resize(N+1);
        fill_n(begin(seg), N+1, 0);
    }
    /// i番目の要素にxを追加する
    void add(int i, T x) {
        i++;
        while (i <= N) {
            seg[i] += x;
            i += i & -i;
        }
    }
    /// [0, i)のsum
    T sum(int i) {
        T s{0};
        while (i > 0) {
            s += seg[i];
            i -= i & -i;
        }
        return s;
    }
    /// [a, b)のsum
    T sum(int a, int b) {
        return sum(b) - sum(a);
    }
};


int main() {
    int n;
    cin >> n;
    int a[n];
    set<int> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i % 2 == 0) {
            s.insert(a[i]);
        }
    }
    sort(a, a+n);
    int ans = 0;
    for (int i = 0; i < n; i += 2) {
        if (!s.count(a[i])) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int s=100*(n-m)+1900*m;
  int p=1;
  for(int i=0;i<m;i++){
    p*=2;
  }
  
  cout<<s*p;
}

Measured memory_bytes: 256
/**
 * Created by hiramekun at 20:52 on 2019-10-19.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl l(n);
    cin >> l;
    sort(all(l));
    ll ans = 0;
    rep(i, n - 1) {
        for (ll j = i + 1; j < n; ++j) {
            ll a = l[i], b = l[j];
            auto itr = lower_bound(all(l), a + b);
            ll num = itr - l.begin();
            ll tmp = num - j - 1;
            if (tmp > 0) ans += tmp;
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256