akhauriyash/Code-Regression huggingface dataset:
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(N);
	READV(R);
	if(N>=10)
	{
		cout<<R<<endl;
	}
	else
	{
		cout<<R+100*(10-N)<<endl;
	}
	

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


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void sort(void);
int FourCard(void);
int HullHouse(void);
int Straight(void);
int ThreeCard(void);
int TwoPair(void);
int OnePair(void);

int x[5];

int main(){
  int a,b,c,d,e;
  char c1,c2,c3,c4;

  while(scanf("%d %c %d %c %d %c %d %c %d", &a, &c1, &b, &c2, &c, &c3, &d, &c4, &e) != EOF){
    x[0] = a;
    x[1] = b;
    x[2] = c;
    x[3] = d;
    x[4] = e;

    sort();

    if(FourCard() == 1)
      printf("four card\n");
    else if(HullHouse() == 1)
      printf("full house\n");
    else if(Straight() == 1)
      printf("straight\n");
    else if(ThreeCard() == 1)
      printf("three card\n");
    else if(TwoPair() == 1)
      printf("two pair\n");
    else if(OnePair() == 1)
      printf("one pair\n");
    else
      printf("null\n");
  }

  return 0;
}

void sort(void){
  int i, j, a, b;
  for(i=1; i<5; i++){
    a = x[i];
    for(j=i; x[j-1]>a && j>0; j--){
      b = x[j-1];
      x[j-1] = x[j];
      x[j] = b;
    }
  }
}

int FourCard(void){
  int i;
  for(i=0; i<2; ++i){
    if(x[i] == x[i+1] && x[i] == x[i+2] && x[i] == x[i+3])
      return 1;
  }
  return 0;
}

int HullHouse(void){
  if((x[0] == x[1] && x[0] == x[2] && x[3] == x[4])||(x[0] == x[1] && x[2] == x[3] && x[2] == x[4]))
    return 1;
  else
    return 0;
}

int Straight(void){
  if(x[0] == x[1]-1 && x[0] == x[2]-2 && x[0] == x[3]-3 && x[0] == x[4]-4)
    return 1;
  else if(x[0] == 1 && x[1] == 10 && x[2] == 11 && x[3] == 12 && x[4] == 13)
    return 1;
  else
    return 0;
}

int ThreeCard(void){
  int i;
  for(i=0;i<3; ++i){
    if(x[i] == x[i+1] && x[i] == x[i+2])
      return 1;
  }
  return 0;
}

int TwoPair(void){
  int i;
  if((x[0] == x[1] && x[2] == x[3])||(x[0] == x[1] && x[3] == x[4])||(x[1] == x[2] && x[3] == x[4]))
    return 1;
  else return 0;
}

int OnePair(void){
  int i;
  for(i=0; i<4; ++i){
    if(x[i] == x[i+1])
      return 1;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, A, B, C, D = map(int, rl().split())
    
    @lru_cache(maxsize=None)
    def calc(t):
        if t == 0:
            return 0
        if t == 1:
            return D
        
        res = min(
            D * t,
            D * abs(t - t // 5 * 5) + C + calc(t // 5),
            D * abs(t - (t + 4) // 5 * 5) + C + calc((t + 4) // 5),
            D * abs(t - t // 3 * 3) + B + calc(t // 3),
            D * abs(t - (t + 2) // 3 * 3) + B + calc((t + 2) // 3),
            D * abs(t - t // 2 * 2) + A + calc(t // 2),
            D * abs(t - (t + 1) // 2 * 2) + A + calc((t + 1) // 2)
        )
        return res
    
    return calc(N)


if __name__ == '__main__':
    T = int(rl())
    ans = []
    for _ in range(T):
        ans.append(solve())
    print(*ans, sep='\n')


Measured memory_bytes: 91764
#include<stdio.h>
#include<math.h>
int main ()
{
    int i,j,a,b,p,q;
    while(scanf("%d %d",&a,&b)==2)
    {
        int y,n=1;
        y=b;
        while(b!=0)
        {
            b=b/10;
            n=n*10;
        }
        n=n*a;
        q=n+y;
        p=sqrt(q);
        if((pow(p,2))==q)
            printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
n = gets.chomp.to_i
s = gets.chomp.split(" ").map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split(" ").map(&:to_i)

binarySearch = ->(key) {
  left = 0
  right = n
  while left < right
    mid = (left + right) / 2
    if key == s[mid] then
      return 1
    elsif key < s[mid] then
      right = mid
    elsif key > s[mid] then
      left = mid + 1
    end 
  end
  return 0
}

res = 0
t.each do |i|
  res += binarySearch.call(i)
end
puts res

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

const int N = 2e5 + 10;
typedef long long ll;
int n, fa[N], vis[N], p[N];
ll ans, f[N], sum1[N], sum0[N];
struct node {
    int x, s0, s1;
    /*bool operator > (const node& a) const {
        return 1ll * s1 * a.s0 > 1ll * s0 * a.s1;
        // return 1ll * s1 * a.s0 == 1ll * s0 * a.s1 ? s0 > a.s0 : 1ll * s1 * a.s0 > 1ll * s0 * a.s1;
    }*/
    bool operator < (const node& a) const {
        return 1ll * s0 * a.s1 == 1ll * s1 * a.s0 ? s0 < a.s0 : 1ll * s0 * a.s1 < 1ll * s1 * a.s0;
    }
};
priority_queue<node> q;

int getfa(int x) {
    return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}

void merge(int x, int y) {
    x = getfa(x), y = getfa(y);
    if (x == y) return;
    fa[x] = y;
}

int main() {
    cin >> n;
    rep(i, 1, n) fa[i] = i;
    rep(i, 2, n) scanf("%d", &p[i]);
    rep(i, 1, n) {
        int x; scanf("%d", &x);
        if (!x) {
            sum0[i] = 1;
            q.push((node){i, 1, 0});
        } else {
            sum1[i] = 1;
            q.push((node){i, 0, 1});
        }
    }
    vis[0] = 1;
    int s1 = 0;
    while (q.size()) {
        node t = q.top(); q.pop();
        if (vis[t.x] || t.s1 != sum1[t.x] || t.s0 != sum0[t.x]) continue;
        int x = t.x;
        vis[x] = 1;
        if (vis[getfa(p[x])]) {
            ans += f[x] + 1ll * s1 * sum0[x];
            s1 += sum1[x];
        } else {
            int y = getfa(p[x]);
            f[y] += f[x] + 1ll * sum1[y] * sum0[x];
            sum0[y] += sum0[x];
            sum1[y] += sum1[x];
            q.push((node){y, sum0[y], sum1[y]});
            merge(x, y);
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair < int , int >;
using vi3 = pair < int , ii >;
using vi = vector < int >;
using vii = vector < ii >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

ll W , H , x , y;

main(){
    scanf("%lld %lld %lld %lld" , &W , &H , &x , &y);

    int border = 1;

    if( (x == (W/2.0)) && (y == (H/2.0)))border = 0;

    printf("%.6f %d\n" , 1.0*(W*H)/(2*1.0) , 1-border);

    return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,mmx,avx")
#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#ifdef ONLINE_JUDGE
#define assert(...) /* nothing */
#endif
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif
int rint();char rch();long long rlong();
// mt19937 rng; rng.seed(std::chrono::high_resolution_clock::now().time_since_epoch().count());
// template<typename T> int bins(vector<T> &v, T key) {int imin=0,imax=v.size();while(imin<imax) {int imid=(imin+imax)>>1;if (v[imid]<key) imin=imid+1;else imax=imid;}return imin;}
string a[102];
int f[102][102];
int cost(char oldc, char newc) {
  if (oldc=='.'&&newc=='#') return 1;
  return 0;
}
int main() 
{
  int nr,nc; cin>>nr>>nc;
  for (int r=0;r<nr;r++) {
    cin>>a[r];
  }
  //for (int r=0;r<nr;r++) for (int c=0;c<nc;c++) a[r][c]=INF;
  f[0][0]=(a[0][0]=='#'?1:0);
  for (int r=0;r<nr;r++) for (int c=0;c<nc;c++) {
    if (r+c>0) {
      int ans=INF;
      char h=a[r][c];
      if (r-1>=0) chkmin(ans, f[r-1][c] + cost(a[r-1][c],h) );
      if (c-1>=0) chkmin(ans, f[r][c-1] + cost(a[r][c-1],h) );
      f[r][c]=ans;
    }
  }
  int final=f[nr-1][nc-1];
  printf("%d\n",final);
}


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

int main()
{
    //printf("Hello World");
    char s[4];
    cin>>s;
    if(s[0]=='M') cout<<6;
    else if((s[0]=='T') &&(s[2]=='E')) cout<<5;
    else if(s[0]=='W')  cout<<4;
    else if((s[0]=='T')&&(s[2]=='U')) cout<<3;
    else if(s[0]=='F') cout<<2;
    else if((s[0]=='S')&&(s[2]=='T')) cout<<1;
    else if((s[0]=='S')&&(s[2]=='N')) cout<<7;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var str = ReadLine();
        if (str[str.Length - 1] == '1'||str[0]=='0') { WriteLine(-1);return; }
        for (var i = 0; i < str.Length - 1; i++)
            if (str[i] != str[str.Length - i - 2])
            { WriteLine(-1); return; }
        var s = 1;
        for (var i = 0; i < str.Length; i++)
            if (str[i] == '1')
            {
                for (var j = s + 1; j <= i + 2; j++)
                    WriteLine($"{s} {j}");
                s = i + 2;
            }
    }
}

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

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int m=max(a,max(b,c));
  int tmp =m;
  for(int i=0;i<k;i++) m *=2;

  cout<< a+b+c+m-tmp<<endl;

}


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

int arr[107];
int sum[107][100007];
int dp[107][100007];

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

    for( int i=1;i<=n;i++ )
        cin>> arr[i];

    for( int i=1;i<=n;i++ )
    {
        dp[i][0]= 1;
        sum[i][0]= 1;
    }

    for( int i=0;i<=k;i++ )
        sum[0][i]= 1;

    for( int i=1;i<=n;i++ )
    {
        for( int j=1;j<=k;j++ )
        {
            int range,l,r;
            if( j-arr[i]-1>=0 )
                l=  sum[i-1][j-arr[i]-1];
            else
                l= 0;
            r= sum[i-1][j];

            dp[i][j]= ( dp[i][j]+( r-l+mod )%mod )%mod;
            sum[i][j]= ( sum[i][j-1]+dp[i][j] )%mod;
        }
    }

    cout<< dp[n][k] <<endl;
}


Measured memory_bytes: 81792
#include <stdio.h>

int H, W, dp[2][10946][2][2], bits[10946], conv[1 << 19], maxbits;

char M[20][21];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	int maxbit = 1 << (W - 1);

	for (int i = 0; i < maxbit; i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok)
		{
			conv[i] = maxbits; bits[maxbits++] = i;
		}
	}

	for (int i = 0; i < H * W - 1; i++)
	{
		int s = i % 2;
		int t = (i + 1) % 2;

		for (int j = 0; j < maxbits; j++)
		{
			dp[t][j][0][0] = 0;
			dp[t][j][0][1] = 0;
			dp[t][j][1][0] = 0;
			dp[t][j][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		for (int j = 0; j < maxbits; j++)
		{
			int nxt = (bits[j] << 1) & (maxbit - 1);

			int sum0 = dp[s][j][0][0] + dp[s][j][1][0];
			int sum1 = dp[s][j][0][1] + dp[s][j][1][1];

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[t][conv[nxt]][0][0] += sum0;
				dp[t][conv[nxt]][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[t][conv[nxt + 1]][1][0] += dp[s][j][0][0];
					dp[t][conv[nxt + 1]][1][1] += dp[s][j][0][1];

					dp[t][conv[nxt + 1]][1][0] %= 100000;
					dp[t][conv[nxt + 1]][1][1] %= 100000;

					dp[t][conv[nxt]][1][0] += dp[s][j][1][0];
					dp[t][conv[nxt]][1][1] += dp[s][j][1][1];
				}
				else
				{
					dp[t][conv[nxt]][1][0] += sum0;
					dp[t][conv[nxt]][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[t][conv[nxt]][1][1] += sum0;
				}
				else
				{
					dp[t][conv[nxt]][1][0] += sum0;
				}

				dp[t][conv[nxt]][1][1] += sum1;
			}

			dp[t][conv[nxt]][0][0] %= 100000;
			dp[t][conv[nxt]][0][1] %= 100000;
			dp[t][conv[nxt]][1][0] %= 100000;
			dp[t][conv[nxt]][1][1] %= 100000;
		}
	}

	int ret = 0;

	int last = (H * W + 1) % 2;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[last][i][0][1];
		ret += dp[last][i][1][1];

		ret %= 100000;
	}

	printf("%d\n", ret);

	return 0;
}

Measured memory_bytes: 3352
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


int main()
{
	int n;
	cin >> n;
	ll te = 1, ni = 1, ei = 1;
	ll ans;
	for (int i = 0; i < n; i++) {
		te *= 10;
		ni *= 9;
		ei *= 8;
		te %= Mod;
		ni %= Mod;
		ei %= Mod;
		ans = (te - 2 * ni + ei);
		//cout << ans << endl;
	}
	ans %= Mod;
	if (ans >= 0) cout << ans << endl;
	else cout << ll(1e9) + 7 - abs(ans) << endl;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(){

	int a,b;
	//a:Alice, b:Bob
	scanf("%d %d", &a, &b);

	if(a == b){
		printf("Draw\n");
	}
	else if(a == 1 || b == 1){
		if(a == 1) printf("Alice\n");
		else printf("Bob\n");
	}
	else if (a < b){
		printf("Bob\n");
	}
	else{
		printf("Alice\n");
	}

	return 0;

}

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

int main(){
  for (;;) {
    int m, d;
    cin >> m >> d;
    if (m == 0) break;

    vector<int> day = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int tmp = d;
    for (int i = 0; i < m - 1; i++) {
      tmp += day.at(i);
    }

    int ans = tmp % 7;
    vector<string> week = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
    cout << week.at(ans) << endl;
  }
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;

int main() {
  int q;string S;
  cin>>S>>q;
  int w,f;string c;int sum=0;
  string mae,ushiro;
  rep(i,q){
    cin>>w;
    if(w==1)sum++;
    else{cin>>f>>c;
      if(((f==1)&&(sum%2==0))||(f==2)&&(sum%2==1))mae=c+mae;
      else ushiro+=c;
    }

  }
  S=mae+S+ushiro;
  if(sum%2==1){reverse(S.begin(),S.end());}
  
  cout<<S<<endl;
}

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

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

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

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

  int ans = 0;
  for (int i = 1; i < n; i++) {
    ans += abs(a[i] - a[i-1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

int N;

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

	cin >> N;
	vector<int>a(3*N);
	rep(i, 3*N)cin >> a[i];

	sort(ALL(a));
	int ans = 0;
	rep(i, N)ans += a[3*N - 2 - i * 2];
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
const ll mod=1e9+7;


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

    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m+2;i++)
        cout<<"#";
    cout<<"\n";
    char r;
    for(ll i=0;i<n;i++){
        cout<<"#";
        for(ll j=0;j<m;j++){
            cin>>r;
            cout<<r;
        }
        cout<<"#\n";
    }
    for(ll i=0;i<m+2;i++)
        cout<<"#";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int MOD = (int)1e9+7;
const ll INF = 1e18;

int n, m , R;
int r[10];
ll d[205][205];
ll cache[205][1<<8];

ll solve(int here, int visited) {
	if(visited == ((1<<R)-1)) {
		return 0;
	}

	ll& ret = cache[here][visited];
	if(ret != -1) return ret;
	ret = INF;

	rep(i,0,R) {
		if(visited & (1 << i)) {
			continue;
		}
		int there = r[i];
		ret = min(ret, solve(there, visited | (1<<i)) + d[here][there]);
	}

	return ret;
}

int main(void) {
	//freopen("in.txt", "r", stdin);
	cin >> n >> m >> R;
	rep(i,0,R) {
		cin >> r[i];
		r[i]--;
	}
	memset(d, 0, sizeof(d));
	rep(i,0,n) rep(j,0,n) {
		d[i][j] = INF;
	}
	rep(i,0,m) {
		int a,b,c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = min(d[a][b], (ll)c);
		d[b][a] = min(d[b][a], (ll)c);
	}
	rep(i,0,n) d[i][i] = 0;
	rep(k,0,n) rep(i,0,n) rep(j,0,n) {
		d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	rep(i,0,205) rep(j,0,(1<<8)) cache[i][j] = -1;
	cout << solve(n, 0) << '\n';
	return 0;
}

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

#define MAX 100
#define BLACK 0
#define GRAY 1
#define WHITE 2
#define INF (1<<30)

int graph[MAX][MAX];
int n;

// プロトタイプ宣言
void dijkstra(int start);
// ここまで

int main(){
	for(int i=0;i<MAX;i++){
		for(int j=0;j<MAX;j++){
			graph[i][j]=INF;
		}
	}

	int from,to,k,weight;		cin>>n;
	for(int i=0;i<n;i++){
		cin>>from>>k;
		for(int j=0;j<k;j++){
			cin>>to>>weight;
			graph[from][to]=weight;
		}
		
	}

	dijkstra(0);

	return 0;
}

//  - - - - - - - - - - - - - - - - - - - --
void dijkstra(int start){
	int color[MAX];
	int d[MAX];
	int p[MAX];
	for(int i=0;i<MAX;i++){
		color[i]=WHITE;
		d[i]=INF;
		p[i]=-1;
	}

	d[start]=0;
	p[start]=-1;

	while(1){
		int from = -1;
		int minCost=INF;
		for(int i=0;i<n;i++){
			if(color[i]!=BLACK && d[i]<minCost){
				minCost=d[i];
				from=i;
			}
		}
		if(from == -1)break;
		
		color[from]=BLACK;

		for(int to=0;to<n;to++){
			if(color[to]!=BLACK && graph[from][to]!=INF){
				if(d[from]+graph[from][to] < d[to]){
					d[to] =d[from]+graph[from][to];
					p[to]=from;
					color[to]=GRAY;
				}
			}
		}
	}

	for(int i=0;i<n;i++){
		printf("%d %d\n",i,d[i]);
	}
}



Measured memory_bytes: 3184
#include <cstdio>
#define LEN 100005
using namespace std;

struct P {
  char name[100];
  int t;
};

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) {return a < b ? a : b;}

int main() {
  int elaps = 0, c;
  int q;
  P u;
  scanf("%d %d", &n, &q);

  for (int i = 1; i <= n; ++i) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;

  while (head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0)
      enqueue(u);
    else
      printf("%s %d\n", u.name, elaps);
  }

  return 0;
}

Measured memory_bytes: 12904
#include<iostream>
#include<queue>
#include<vector>
#include<utility>
using namespace std;

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

    long A,B;
    auto c = [](pair<long, long> l, pair<long, long> r) { if ( r.second < l.second ) return true; else return false; };
    priority_queue < pair<long, long>, vector< pair<long, long> >, decltype(c) > que(c);

    for(int i=0; i<N; i++){
        cin >> A >> B;
        que.push(make_pair(A,B));
    }

    long time=0;

    while(!que.empty()){
        A=que.top().first;
        B=que.top().second;
        que.pop();

        //cout << "time A B " << time << " " << A << " " << B << endl;
        time+=A;

        if( time <= B ){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 6128
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

const int INF = 1e5;

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

  int num = (int)s.size();

  int ans = INF;
  for (int i = 0; i < num - 2; i++) {
    int a = s[i] - '0';
    int b = s[i+1] - '0';
    int c = s[i+2] - '0';
    int x = 100 * a + 10 * b + c;
    ans = std::min(ans, (int)std::fabs(x-753));
  }

  std::cout << ans << std::endl;

  return 0;
}


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

int N, a, c[100009], cnt;
int main()
{
cin >> N;
for(int i = 0; i < N; i++) cin >> a, c[a]++;
for(int i = 0; i <= 100000; i++) cnt = max(cnt, c[i] + c[i +1] + c[i + 2]);
cout << cnt << endl;
return 0;
}

Measured memory_bytes: 640
def selectionSort(A, N):
    count = 0
    for i in range(N):
        min_index = i
        for j in range(i, N):
            if A[j] < A[min_index]:
                min_index = j
        if A[i] != A[min_index]:
            A[i], A[min_index] = A[min_index], A[i]
            count += 1
    return A, count


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))

    answer_list, answer_count = selectionSort(A, N)

    print(*answer_list)
    print(answer_count)



Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    ll sum = 0;
    int startsWithBAndEndsWithANum = 0;
    int startsWithBNum = 0;
    int endsWithANum = 0;
    rep(i, 0, N)
    {
        string s;
        cin >> s;
        rep(j, 0, s.length() - 1)
        {
            if (s[j] == 'A' && s[j + 1] == 'B')
            {
                ++sum;
            }
        }
        if (s.front() == 'B' && s.back() == 'A')
        {
            ++startsWithBAndEndsWithANum;
        }
        else if (s.front() == 'B')
        {
            ++startsWithBNum;
        }
        else if (s.back() == 'A')
        {
            ++endsWithANum;
        }
    }
    // cout << sum << " " << startsWithBAndEndsWithANum << " " << startsWithBNum << " " << endsWithANum << endl;
    sum += max(startsWithBAndEndsWithANum - 1, 0);
    if (startsWithBAndEndsWithANum > 0)
    {
        if (endsWithANum > 0)
        {
            ++sum;
            --endsWithANum;
        }
        if (startsWithBNum > 0)
        {
            ++sum;
            --startsWithBNum;
        }
    }
    sum += min(endsWithANum, startsWithBNum);
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> s(N);
    int ans = 0;
    rep(0, i, N)
    {
        cin >> s.at(i);
        ans += s.at(i);
    }
    sort(all(s));
    if (ans % 10 == 0)
    {
        rep(0, i, N)
        {
            if (s.at(i) % 10 != 0)
            {
                ans -= s.at(i);
                cout << ans << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;

	while (n > 0)
	{
		n /= 10;

		count++;
	}
	return count;
}
int digit(int n)
{

	int ans = 0;
	while (n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	int sum=0;
	int fore=0;
	rep(i,n){
		if(s[i]=='c')
		{
			cout<<"No"<<endl;
		}else if(s[i]=='a'){
			if(sum<a+b){
				cout<<"Yes"<<endl;
				sum++;
			}else{
				cout<<"No"<<endl;
			}
		}else{
			if(sum<a+b&&fore<b){
				fore++;
				sum++;
					cout<<"Yes"<<endl;
			}else{
				cout<<"No"<<endl;
			}
		}
	}

	
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int>L(M);
    vector<int>R(M);
    int ans = 0;
    for(int i = 0; i < M; i++) {
        cin >> L[i];
        cin >> R[i];
    }
    sort(L.begin(), L.end());
    sort(R.begin(), R.end());
    if(R[0]-L[M-1] >= 0) cout << R[0]-L[M-1]+1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 1024
use proconio;

fn main() {
    proconio::input! {
        (n, d): (u64, f64)
    };

    let mut ans = 0;
    for _ in 0..n {
        proconio::input! {
            (x, y): (f64, f64)
        };

        let diff = x.powf(2.0) + y.powf(2.0);

        if diff.sqrt() <= d {
            ans += 1;
        }
    }
        
    println!("{}", ans);
}


Measured memory_bytes: 5004
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  int r = 0;
  F0R(i, N) {
    int a;
    cin >> a;
    if ((i & 1) == 0 && (a & 1)) {
      r++;
    }
  }
  cout << r;
}
#endif


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int solve(int n){
	if(n == 0) return n;
	return solve(n/10) + n % 10;
}
int main(){
	int n;
	cin >> n;
	int ans = 100000000;
	for(int a = 1; a < n; a++){
		ans = min(ans, solve(a) + solve(n-a));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

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

  std::vector<int> A(N);
  for (int i = 0; i < N; ++i)
    std::cin >> A[i];

  std::map<int, int> mp;
  for (auto &v : A) {
    mp[v] += 1;
  }

  // for (auto kv: mp)
  //   std::cout << kv.first << ": " << kv.second << std::endl;

  long long sum = 0;
  for (auto &kv : mp) {
    long long x = kv.second;
    sum += x * (x - 1) / 2;
  }

  for (auto &v : A) {
    long long res = 0;
    // for (auto &kv : mp) {

    //   int x;
    //   if (kv.first == v) {
    //     x = kv.second - 1;
    //   } else {
    //     x = kv.second;
    //   }

    //   res += x * (x - 1) / 2;
    // }

    long long x = mp[v];

    res = sum;
    res -= x * (x - 1) / 2;

    x -= 1;

    res += x * (x - 1) / 2;

    std::cout << res << std::endl;
  }

  return 0;
}


Measured memory_bytes: 9728
def main():
    n, k = map(int, input().split())
    a_list = list(map(int, input().split()))

    dp = [0] * (k+1)
    # dp[0] == 0 ならばそのとき手番の者（先手）の負け
    for i in range(k+1):
        for a in a_list:
            if dp[i] == 0:
                idx = i + a
                if idx < k+1:
                    dp[idx] = 1

    if dp[k] == 0:
        print('Second')
    else:
        print('First')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
void A()
{
    // 入力
    string N;
    cin >> N;
    
    // 出力
    if( N.find("7") != string::npos )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
 
void B()
{
    // 入力
    int N;
    cin >> N;
    
    long long int ans = 0;
    
    // "Fizz", "Buzz", "FizzBuzz"のいずれでもない場合を合算する
    for( int i = 1; i < N+1; ++i )
        if( (i % 3 != 0) && (i % 5 != 0) )
            ans += i;
    
    // 出力
    cout << ans << endl;
}
 
long long int gcd(long long int a, long long int b)
{
    long long int ret;
     
    if( a < b ){
        long long int tmp = a;
        a = b;
        b = tmp;
    }
     
    if( b == 0 ) return a;
     
    ret = a % b;
    ret = gcd(b, ret);
     
    return ret;
}
 
void C()
{
    // 入力
    int K;
    cin >> K;
    
    int ans = 0;
    
    // 2重GCDで解ける
    for( int a = 1; a < K+1; ++a )
        for( int b = 1; b < K+1; ++b )
            for( int c = 1; c < K+1; ++c )
                ans += gcd(gcd(a, b), c);
    
    // 出力
    cout << ans << endl;
}
 
void D()
{
    // 入力
    int N;
    string S;
    cin >> N >> S;
    
    // SをR, G, Bに分割する
    unsigned long long int R = 0, G = 0, B = 0;
    for( int i = 0; i < N; ++i )
        switch( S[i] ){
            case 'R': ++R; break;
            case 'G': ++G; break;
            case 'B': ++B; break;
        }
    
    // {R, G, B}の組合せの数
    // 必ずR, G, Bそれぞれひとつずつの組合せになるが、i < j < k順に並びかえればいいので、それぞれの個数をかけた値になる
    //unsigned long long int ans = R * G * B;
    long long int ans = R * G * B;
    
    // (j − i) == (k − j)の組合せの数を引く
    // i, jが決まればkを求められる
    for( int i = 1; i < N+1; ++i )
        for( int j = i+1; j < N+1; ++j ){
            int k = 2*j - i;
            if( k < j || N < k ) continue;
            if( S[i-1] != S[j-1] && S[j-1] != S[k-1] && S[k-1] != S[i-1] )
                --ans;
        }
    
    // 出力
    cout << ans << endl;   
}
 
int main()
{
    //A();
    //B();
    //C();
    D();
    
    return 0;
}


Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
vector<int> a[N];
int deg[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n + m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    a[x].push_back(y);
    deg[y]++;
  }
  queue<int> Q;
  vector<int> ret(n);
  for (int i = 0; i < n; ++i) {
    if (deg[i] == 0) {
      Q.push(i);
      ret[i] = -1;
    }
  }
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (auto& v : a[u]) {
      if (--deg[v] == 0) {
        Q.push(v);
        ret[v] = u;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    printf("%d\n", ret[i] + 1);
  }
  return 0;
}


Measured memory_bytes: 7040
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin >> n;
	map<string,bool> S;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		if (s == "insert")
		{
			string t;
			cin >> t;
			S[t] = true;
			continue;
		}
		if (s == "find")
		{
			string t;
			cin >> t;
			//auto result = find(S.begin(), S.end(), t);
			
			//if (result != S.end())
			if (S[t] == true)
			{
				cout << "yes" << endl;
			}
			else
			{
				cout << "no" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 52440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	ll nt = 1, na = 1;
	rep(i, n){
		ll t, a;cin>>t>>a;
		ll r = max((ll)(nt+t-1)/t, (ll)(na+a-1)/a);
		nt = t*r;na = a*r;
	}
	cout << nt+na << endl;
	return 0;
}


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

typedef complex<double> P;
typedef pair<P,P> L;
const double EPS = 1e-8;

double dot(P a, P b){ return real(conj(a)*b);}
double cross(P a, P b){ return imag(conj(a)*b);}

int ccw(P a, P b, P c){
    c -= a;
    b -= a;
    if(cross(b, c) > EPS) return 1;
    if(cross(b, c) < -EPS) return -1;
    if(dot(b,c) < -EPS) return 2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

bool isIntersect(L s1, L s2){
    return ( ccw(s1.first,s1.second,s2.first) * ccw(s1.first,s1.second,s2.second) <= 0 &&
             ccw(s2.first,s2.second,s1.first) * ccw(s2.first,s2.second,s1.second) <= 0);
}

P crossPoint(L l, L m){
    double A = cross(l.second - l.first, m.second - m.first);
    double B = cross(l.second - l.first, l.second - m.first);
    if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
    else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

double area(vector<P> v){
    double sum = 0.0;
    int n = v.size();
    for(int i=0;i<n;i++) sum += (real(v[i]) - real(v[(i+1)%n])) * (imag(v[i]) + imag(v[(i+1)%n]));
    return fabs(sum / 2.0);
}

string ans(vector<P> v){
    double a = area(v);
    if(a < EPS) return "kyo";
    if(a < 100000.0) return "syo-kichi";
    if(a < 1000000.0) return "kichi";
    if(a < 1900000.0) return "chu-kichi";
    return "dai-kichi";
}

int main(){
    double x1,y1,x2,y2;
    while(cin >> x1 >> y1 >> x2 >> y2 && (x1||y1||x2||y2)){
        L v[3];
        vector<P> p;
        bool f = false;
        v[0] = L(P(x1,y1),P(x2,y2));
        for(int i=1;i<3;i++) {
            cin >> x1 >> y1 >> x2 >> y2;
            v[i] = L(P(x1,y1),P(x2,y2));
            if(!isIntersect(v[0],v[i])) f = true;
            else p.push_back(crossPoint(v[0],v[i]));
        }
        if(!isIntersect(v[1],v[2])) f = true;
        else p.push_back(crossPoint(v[1],v[2]));

        if(!f){
            for(int i=0;i<3;i++){
                for(int j=i+1;j<3;j++){
                    if(abs(p[i]-p[j]) < EPS) f = true;
                }
            }
        }

        if(f) cout << "kyo" << endl;
        else cout << ans(p) << endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<array>
#include<bitset>
#include<cmath>

using namespace std;

#define square(s) ((s)*(s))
#define scast(type,e) static_cast<type>(e)
#define rep(i,n) for(decltype(n) i = 0; i < n;i++)
#define repp(i,s,u) for(decltype(s) i = s; i < u;i++)
#define range(a) a.begin(),a.end()
#define pr(l,r) make_pair((l),(r))
#define INF (1145141919)


template<class T>
using vec = vector<T>;
template<class T, size_t S>
using arr = array<T, S>;
template<class T1, class T2>
using pr = pair<T1, T2>;

using ll = long long;
using ull = unsigned long long;

template<class T>
void chmax(T& dest, const T& target) {
	dest = max(dest, target);
}
template<class T>
void chmin(T& dest, const T& with) {
	dest = min(dest, with);
}

int main() {
	int N, M;
	cin >> N >> M;
	vec<int> as(M);
	vec<bitset<12>> bits(M);
	vec<int> bs(M);
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		as[i] = a;
		bs[i] = b;
		rep(j, b) {
			int c;
			cin >> c; c--;
			bits[i][c] = 1;
		}
	}
	
	vec<arr<int,(1 <<12)>> dp(M + 1);
	for (auto& i : dp) {
		fill(range(i), 1145141919);
		i[0] = 0;

	}

	rep(i, M) {
		rep(j, 1 << N) {
			dp[i + 1][j] = min(dp[i][j], dp[i][j & (~bits[i]).to_ulong()] + as[i]);
		}
	}
	auto res = dp[M][(1 << N) - 1];
	if (dp[M][(1 << N) - 1] == 1145141919) {
		cout << -1;
	}
	else {
		cout << dp[M][(1 << N) - 1] << endl;
	}



	return 0;
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;



int main()
{
	int N,K;
    int res=1;
    scanf("%d%d",&N,&K);
    for(int i=0;i<N;i++){
       res = min (res+K,res*2) ;
    }  
    cout << res << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
T = [1]
c = [0]*N

k = 1
st = 0
c[0] = 1
cc = 1
for i in range(N):
    k = A[k-1]
    if c[k-1] == 1:
        st = T.index(k)
        f = T[:st]
        r = T[st:]
        break

    T.append(k)
    c[k-1] += 1
    cc += 1

ff = len(f)
if K < ff:
    print(f[K])
else:
    print(r[(K-ff)%(cc-ff)])


Measured memory_bytes: 32348
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)


















int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    for(;;){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
def resolve():
    yyyy, mm, dd = list(map(int, input().split("/")))
    if yyyy < 2019 or (yyyy==2019 and mm < 4) or (yyyy==2019 and mm == 4 and dd <= 30):
        print("Heisei")
    else:
        print("TBD")

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 61848
#include <stdio.h>
 int main(void){
    int n[3],i;
   for(i=0;i<3;i++)
    scanf("%d",&n[i]);
   // printf("%d %d %d",n[0],n[1],n[2]);
   if((n[0]==n[1]&&n[1]==n[2])||(n[0]!=n[1]&&n[1]!=n[2]&&n[2]!=n[0]))
     printf("No");
   else //if(n[0]!=n[1]||n[1]!=n[2])
     printf("Yes");
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  vector<vector<int>> sub(n, vector<int>(2, 0));
  int ac = 0, wa = 0;
  for (int i = 0; i < m; i++) {
    cin >> p.at(i) >> s.at(i);
    if (sub.at(p.at(i) - 1).at(0) == 1) continue;
    if (s.at(i) == "AC") sub.at(p.at(i) - 1).at(0) = 1;
    else sub.at(p.at(i) - 1).at(1)++;
  }
  for (int i = 0; i < n; i++) {
    if (sub.at(i).at(0) == 1) {
      ac++;
      wa += sub.at(i).at(1);
    }
  }
  cout << ac << " " << wa << endl;
}

Measured memory_bytes: 11520