akhauriyash/Code-Regression huggingface dataset:
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull unsigned lon long
///////////////////////////////////////////////////////////
int absolute(int n); double absolute(double n);
void input(vector<int>& vec);
void print(vector<int> vec); void print(vector<double> vec);
int sum(vector<int> vec); double sum(vector<double> vec);
void upsort(vector<int>& vec);
void downsort(vector<int>& vec);
int maxvec(vector<int> vec);
int minvec(vector<int> vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main()
{
    int m,d;
    cin>>m>>d;
    if(d<22){
        cout<<0<<endl;
        return 0;
    }
    int count=0;
    for(int i=1;i<=m;++i){
        for(int j=22;j<=d;++j){
            int j1=j%10;
            int j10=j/10;
            if(j1>=2&&j10>=2&&j1*j10==i){
                ++count;
            }
        }
    }
    cout << count << endl;
    return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int absolute(int n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

double absolute(double n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

void input(vector<int>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

void print(vector<int> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

void print(vector<double> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

int sum(vector<int> vec)
{
    int s = accumulate(vec.begin(), vec.end(), 0);
    return s;
}

double sum(vector<double> vec)
{
    double s = accumulate(vec.begin(), vec.end(), 0.0);
    return s;
}

void upsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end());
}

void downsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end(), greater<int>());
}

int maxvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = max(m, vec.at(i));
    }
    return m;
}

int minvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = min(m, vec.at(i));
    }
    return m;
}
///////////////////////////////////////////////////////////

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K, H, W, L, R, l, r, u, d, sum, Q;
LL ans;
LL no;
bool b, bb[100001];
string s, t;

int main() {

	cin >> N;
	vector<LL> v(N),con(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		v[i]--;
		con[v[i]]++;
	}
	sum = 0;
	for (int i = 0; i < N; i++) {
		sum += con[i] * (con[i] - 1) / 2;
	}
	for (int i = 0; i < N; i++) {
		ans = sum;
		ans -= (con[v[i]] * (con[v[i]] - 1) / 2);
		ans += (con[v[i]]-1) * (con[v[i]] - 2) / 2;
		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 5760
N = int(input())
l = []
for i in range(N):
  a,b = input().split()
  l.append([a, int(b), i + 1])
l.sort(key=lambda x: x[1], reverse=True)
l.sort(key=lambda x: x[0])
for i,j,k in l:
  print(k)

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

const int maxA = 100000;

int main() {
    int N;
    cin >> N;
    vector<int> freq(maxA + 1, 0);
    for (int i = 0; i != N; ++i) {
        int a;
        cin >> a;
        freq[a] += 1;
    }
    int odd = 0;
    int even = 0;
    for (auto f : freq){
        if (f == 0) continue;
        if (f % 2) {
            ++odd;
        }else{
            ++even;
        }
    }
    if (even % 2){
        cout << odd + even - 1 << endl;
    }else{
        cout << odd + even << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
using namespace std;
//typedef long double triple;
const int maxn=111111;
int f[maxn],g[111];
int main()
{
	g[0]=1;
	for(int i=1;i<=20;++i) g[i]=g[i-1]<<1;
	int n,m;scanf("%d%d",&n,&m);f[n+1]=0;
	for(int i=n;i;--i)
	{
		for(int j=f[i+1];!f[i];++j)if(g[j]*i>=m)
		{
			f[i]=j;break;
		}
	}
	double ans=0;
	for(int i=1;i<=n;++i)
	{
		ans+=(1.0/(1<<f[i]));
	}
 	printf("%.12f",ans/n);
	return 0;
}

Measured memory_bytes: 640
/*
uchiyan ni gallan
*/

#include<bits/stdc++.h>
#define mod 1000000007
#define pp pair<long long,long long>
#define ll long long
#define ff first
#define ss second
#define horse_power ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
ll n,w;

void solve(){
   cin>>n>>w;
   ll r[n+1][2];
   for(int i=1;i<=n;i++){
     cin>>r[i][0]>>r[i][1];
   }
   vector<ll> dp(1000*n+1,1e12);
   dp[0]=0;
   for(int i=1;i<=n;i++){
      for(int j=1000*n;j>=r[i][1];j--){
      dp[j]=min(dp[j],r[i][0]+dp[j-r[i][1]]);
      }
   }

   ll ans=0;
   for(int i=0;i<=1000*n;i++){
      if(dp[i]<=w)
   ans=max(ans,(ll)i);
   }
   cout<<ans<<"\n";


}

int main(){
horse_power
int t=1;
//cin>>t;
while(t--){
solve();
}


}


Measured memory_bytes: 1024
n, a, b = map(int, input().split())
s = [0] + list(input())

num_pass = 0
num_pass_foreign = 0

for i in range(1, n + 1):
	if s[i] == 'c':
		print('No')
	elif s[i] == 'a':
		if num_pass < a + b:
			print('Yes')
			num_pass += 1
		else:
			print('No')
	elif s[i] == 'b':
		if num_pass < a + b and num_pass_foreign < b:
			print('Yes')
			num_pass += 1
			num_pass_foreign += 1
		else:
			print('No')

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

int main() {
long long a,b,c,A,B,C,T,x,y,z,n,p,ans;
a=b=c=A=B=C=T=n=x = y = z = p = ans=  0;
cin >> A >> B >> T;
x = T / A;
ans = x * B;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void C_task();

int main()
{
	C_task();
	fflush(stdout);
	return 0;
}

static void C_task()
{
	int N;
	get1int(N);

	auto slm = new char[N + 1];
	getstring(slm);

	int unite = 0;
	for (int i = 1; i < N; i++) {
		if (slm[i] == slm[i - 1]) {
			unite++;
		}
	}
	
	printf("%d\n", N - unite);

	delete[] slm;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int s,x=0,m=0;cin>>s;
  if(s<3)m=4;
  else{
    while(x<2){
      m++;
      if(s==4)x++;
      if(s%2==0)s/=2;
      else s=3*s+1;
    }
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<set>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
#define ms(f,x) memset(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);
		putchar('\n');
		return;
    }
}
using IO::read;
using IO::write;
using namespace std;
#define gi(x) read(x)
typedef long long ll;
inline ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll a,b,ans;
int main(){
    cin>>a>>b;
    ans=3ll*(a-gcd(a,b));
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

  long mi = 10000000000;
  long an;
  for(string a = "1"; stoi(a) <= sqrt(n); an++,
  a = to_string(an)) {
    an = stoi(a);
    long bn = n/an;
    string b = to_string(bn);
    if(bn != double(n)/an) continue;
    long f = max(a.size(),b.size());
    mi = min(mi,f);
    
  }
  
  cout << mi << endl;
  return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{  
    string s, t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>> dp(n+1, vector<int>(m+1,0));
    for(int i = 1 ; i <=  n  ;i++)
    {
        for(int j = 1 ; j <= m ; j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]) ;
        }
    }
//    cout<<dp[n][m]<<endl;
    int i = n; 
    int j = m;
    string ans = "";
    while(i>0 && j>0)
    {   
       // cout<<i<<" "<<j<<endl;
        if(s[i-1] == t[j-1]){ ans += s[i-1]; i--;j--;}
        else if(dp[i][j-1] > dp[i-1][j]){ j--;}
        else {i--;}
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
        
}



Measured memory_bytes: 35584
def cumsum(l):
    c = [0] * len(l)
    for i in range(len(l)):
        c[i] = c[i-1] + l[i]
    return c

N, K = map(int, input().split())
a = [int(i) for i in input().split()]
c = [0] + cumsum(a)

s = [bin(c[j+i] - c[j]).replace('0b','').zfill(40) for i in range(1, N+1) for j in range(N-i+1)]

ans = 0

for i in range(40):
    t = [j for j in s if j[i] == '1']
    if len(t) >= K:
        ans += 2**(39-i)
        s = t

print(ans)

Measured memory_bytes: 55720
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
ve <ll> facs;
void printDivisors(int n) 
{ 
    // Note that this loop runs till square root 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i) 
                facs.pb(i);
  
            else // Otherwise print both 
               {
                   facs.pb(i);
                   facs.pb(n/i);
               }
        } 
    } 
} 
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll x;
    cin>>x;
    ll val=sqrt(x)+1;
    ll a=0,b=0;
    rep (i,-2e3,2e3)
    {
        rep (j,-2e3,2e3)
        {
            ll val1=pow(i,5);
            ll val2=pow(j,5);
            if (val1-val2==x)
            {
                // cout<<"val1.. "<<val1<<"\n";
                // cout<<"val2.. "<<val2<<"\n";
                cout<<i<<" "<<j<<"\n";
                return 0;
            }
        }
    }
}


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

void solve(long long N, std::vector<long long> A, std::vector<long long> B)
{
    sort(begin(A), end(A));
    sort(begin(B), end(B));
    if (N % 2 == 1) {
        cout << B[(N + 1) / 2 - 1] - A[(N + 1) / 2 - 1] + 1 << endl;
    } else {
        cout << (B[N / 2 - 1] + B[N / 2 + 1 - 1]) - (A[N / 2 - 1] + A[N / 2 + 1 - 1]) + 1 << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 6448
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

int N;
int ga, sa, ba, gb, sb, bb;
vector<ll>dp1, dp2;
int main() {
	cin >> N >>ga >> sa >> ba >> gb >> sb >> bb;

	dp1.pb(0);
	for (ll i = 1; i <= N; i++) {
		ll dg = 0, ds = 0, db = 0;
		if(i >= ga)dg = dp1[i-ga] + gb;
		if(i >= sa)ds = dp1[i-sa] + sb;
		if(i >= ba)db = dp1[i-ba] + bb;
		dp1.pb(max(max(dg,ds),max(i,db)));
	}
	dp2.pb(0);
	for (ll i = 1; i <= dp1[N]; i++) {
		ll dg = 0, ds = 0, db = 0;
		if (i >= gb)dg = dp2[i - gb] + ga;
		if (i >= sb)ds = dp2[i - sb] + sa;
		if (i >= bb)db = dp2[i - bb] + ba;
		dp2.pb(max(max(dg, ds), max(i, db)));
	}
	cout << dp2[dp1[N]] << endl;
	
	return 0;
}


Measured memory_bytes: 264604
using System;

class Program
{
    static int Main()
    {
        int[] s1, s2=new int[4], s3 = new int[3], s4 = new int[2],kai=new int[5];
        int offs = 0, time_min = int.MaxValue;
        s1 = new int[5] { 4, 3, 2, 1, 0 };
        int[] t = new int[5];
        for (var i = 0; i < 5; i++)
        {
            t[i] = int.Parse(Console.ReadLine());
        }
        for (var i = 0; i < 5; i++)
        {
            kai[4] = s1[i];
            offs = 0;
            for (var j = 0; j < 4; j++)
            {
                if (j == i)
                    offs = 1;
                s2[j] = s1[j + offs];
            }
            for (var j = 0; j < 4; j++)
            {
                kai[3] = s2[j];
                offs = 0;
                for (var k = 0; k < 3; k++)
                {
                    if (k == j)
                        offs = 1;
                    s3[k] = s2[k + offs];
                }
                for (var k = 0; k < 3; k++)
                {
                    kai[2] = s3[k];
                    offs = 0;
                    for (var l = 0; l < 2; l++)
                    {
                        if (l == k)
                            offs = 1;
                        s4[l] = s3[l + offs];
                    }
                    for (var l = 0; l < 2; l++)
                    {
                        kai[1] = s4[l];
                        kai[0] = s4[1 - l];
                        int time = 0;
                        for (int m = 0; m < 5; m++)
                        {
                            time += t[kai[m]];
                            if (time % 10 != 0 && m != 4)
                            {
                                time += 10 - time % 10;
                            }
                        }
                        if (time_min > time)
                        {
                            //for (var x = 0; x < 5; x++)
                            //{
                            //    Console.Write(kai[x].ToString("d"));
                            //}
                            //Console.Write("\n");
                            time_min = time;
                        }
                    }
                }
            }
        }
        Console.WriteLine(time_min.ToString("d"));
        return 0;
    }
}

Measured memory_bytes: 11092
import copy
N=int(input())
ab=list(list(map(int,input().split())) for _ in range(N))
cd=list(list(map(int,input().split())) for _ in range(N))
ab.sort(key=lambda x :x[1],reverse=True)#abをy座標で逆ソート
#ab.sort(key=lambda x :x[0])#abをx座標でソート
cd.sort(key=lambda x :x[0])#cdをx座標でソート
ans=0
for c,d in cd:#あるc,dに対して、適切なabを探しともに消去する
    for a,b in ab:#
        if b<d and a<c:
            ab[ab.index([a,b])]=[1000,1000] #abは糞でかく、cdはクソ小さくする
            cd[cd.index([c,d])]=[-1000,-1000]
            ans+=1
            break#次のc,dを見に行く
print(ans)

Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 1000100
const int mod=1e6+3;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int a[N],fac[N],finv[N],Q;
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	finv[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i){
		finv[i]=1LL*finv[i+1]*(i+1)%mod;
	}
}
int Solve(int x,int d,int n){
	if(!x)return 0;
	if(!d)return qpow(x,n);
	x=1LL*x*qpow(d,mod-2)%mod;
	if(x+n-1>=mod)return 0;
	int ans=1LL*finv[x-1]*fac[x+n-1]%mod*qpow(d,n)%mod;
	return ans;
}
int main(){
	Q=read();
	init(mod-1);
	while(Q--){
		int x=read(),d=read(),n=read();
		printf("%d\n",Solve(x,d,n));
	}
	return 0;
}



Measured memory_bytes: 11564
#include <bits/stdc++.h>
using namespace std;
deque < long long > a;
deque < long long > b;
int main()
{
	int n,a2,b2;
	cin>>n;
	for(long long i=0;i<n;i++)
	{
		cin>>a2;
		a.push_back(a2);
	}
	for(long long i=0;i<n;i++)
	{
		cin>>b2;
		b.push_back(b2);
	}
	long long k=0,k2=0;
	for(long long i=0;i<n;i++)
		k+=b[i]-a[i];
	for(long long i=0;i<n;i++)
		if(b[i]-a[i]>0)
			k2+=(b[i]-a[i]+1)/2;
	if(k2>k)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(M), c(N);
    rep(i, M) {
        cin >> s[i] >> c[i];
        s[i]--;
    }

    vector<int> num(N, -1);

    rep(i, M) {
        if(num[s[i]] == -1 || num[s[i]] == c[i]) {
            num[s[i]] = c[i];
        } else {
            cout << "-1" << endl;
            return 0;
        }
    }
    //２桁以上で先頭が0の場合
    if(num[0] == 0 && N != 1) {
        cout << "-1" << endl;
        return 0;
    } else if(num[0] == 0) { // 1桁で先頭が0の場合
        cout << "0" << endl;
        return 0;
    }

    if(num[0] == -1 && N == 1) {
        cout << "0" << endl;
        return 0;
    } else if(num[0] == -1 && N != 1) {
        num[0] = 1;
    }
    //２桁目以降の空いている場所は0で補填
    rep(i, N) {
        if(num[i] == -1) {
            num[i] = 0;
        }
        cout << num[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int n[100]  = { 0 }, x[100] = { 0 },h, i, j, k, count, cycle = 0;
    while (1) {
        scanf("%d %d", &n[cycle], &x[cycle]);
        if (n[cycle] == 0 && x[cycle] == 0) {
            break;
        }
        cycle++;
    }

    
    for (h = 0; h < cycle; h++) {
        count = 0;
        for (i = 1; i <= n[h] - 2; i++) {
            for (j = i + 1; j <= n[h] - 1; j++) {
                for (k = j + 1; k <= n[h]; k++) {
                    if (i + j + k == x[h]) {
                        count++;
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    
    return 0;
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e17
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
  while(1){
    int n,m;
    int mxhp=0;
    cin>>n;
    if(n==0) break;
    int a[n];
    rep(i,n){cin>>a[i];mxhp=max(mxhp,a[i]);}
    cin>>m;
    string s[m];
    int mana[m],damage[m];
    rep(i,m){
      cin>>s[i]>>mana[i]>>s[i]>>damage[i];
      if(damage[i]>100009) damage[i]=100009;
    }
    int dps[100010],dpm[100010];
    rep(i,100010) dps[i]=dpm[i]=INF;
    dps[0]=0;dpm[0]=0;
    rep(i,100010){
      rep(j,m){
	if(i+damage[j]<100010){
	  if(s[j]=="Single" && dps[i]!=INF){
	    dps[i+damage[j]]=min(dps[i+damage[j]],dps[i]+mana[j]);
	  }else if(s[j]=="All" && dpm[i]!=INF){
	    dpm[i+damage[j]]=min(dpm[i+damage[j]],dpm[i]+mana[j]);
	  }
	}else{
	  if(s[j]=="Single" && dps[i]!=INF){
	    dps[100009]=min(dps[100009],dps[i]+mana[j]);
	  }else if(s[j]=="All" && dpm[i]!=INF){
	    dpm[100009]=min(dpm[100009],dpm[i]+mana[j]);
	  }
	}
      }
    }
    
    repn(i,100008){
      dps[i]=min(dps[i],dps[i+1]);
      dpm[i]=min(dpm[i],dpm[i+1]);
      
    }
    
    int ans=INF;
    rep(i,mxhp+1){
      int cnt=0;
      cnt+=dpm[i];
      rep(j,n){
	cnt+=dps[max((int)0,a[j]-i)];
      }
      ans=min(cnt,ans);
    }
    cout<<ans<<endl;
  }
      

  return 0;
}



Measured memory_bytes: 4724
fun main(args: Array<String>) = println(run {
    val (n,k,q)= readLine()!!.split(" ").map { it.toInt() }
    val a = (1..q).map { readLine()!!.toInt() }
    val c = a.counting()
    (1..n).joinToString("\n") { if (k - q + c.getOrElse(it) { 0 } > 0) "Yes" else "No" }

})

fun <T> List<T>.counting() = this.groupBy { it }.mapValues { it.value.size }


Measured memory_bytes: 52348
import math 

al = []
for _ in range(5):
    al.append(int(input()))
    

tmp = 11
log = -1
for idx,a in enumerate(al):
    point = a % 10
    if point == 0:
        point = 10
    if tmp > point:
        tmp = point
        log = idx

ans = 0
for idx, a in enumerate(al):
    if idx != log:
        ans += math.ceil(a / 10) * 10
    else:
        ans += a
    
print(ans)

Measured memory_bytes: 38384
W, H, N = map(int, input().split())
u, U, v, V = 0, W, 0, H
for _ in range(N):
    x, y, a = map(int,input().split())
    if a == 1:
        u = max(u,x)
    if a == 2:
        U = min(U,x)
    if a == 3:
        v = max(v,y)
    if a == 4:
        V = min(V,y)
f = lambda x:x if x > 0 else 0
print(f(U-u)*f(V-v))

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

using namespace std;

long long a,b,c;

int main(){
    scanf("%lld%lld%lld",&a,&b,&c);
    long long t=(c-a-b);
    if(4*a*b<t*t&&t>0){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int N, M, sum = 0;
    cin >>N;
    vector<int>T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        sum += T[i];
    }
    cin >> M;
    vector<int>P(M), X(M);
    for (int i = 0; i < M; i++)cin >> P[i] >> X[i];

    for (int i = 0; i < M; i++) {
        cout << sum - T[P[i]-1] + X[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int F[44];

int main()
{
  int n,i;
  scanf("%d",&n);
  F[0]=1;
  F[1]=1;
  for(i=2;i<=n;i++){
  F[i]=F[i-2]+F[i-1];
  }

  printf("%d\n",F[n]);
  return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    vector<int>A(N);
    int ans = 0;
    rep(i, N) {
        cin >> A[i];
        ans += A[i];
    }
    sort(A.begin(), A.end());
    cout << (ans - A[N-1] > A[N-1] ? "Yes" : "No") << endl;
}

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

int counter(int x){
    if(x==0) return 0;
    return counter(x>>1)+(x&1);
}

int main(){
    int n;
    cin>>n;
    int a[n];
    int x[n][n],y[n][n];

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

    int ans=0;

    for(int bits=1;bits<(1<<n);bits++){
        bool ok=true;
        for(int i=0;i<n;i++){
            if(!(bits&(1<<i))) continue;
            for(int j=0;j<a[i];j++){
                if(((bits>>(x[i][j]-1))&1)^y[i][j]) ok=false;
            }
        }
        if(ok) ans=max(ans,counter(bits));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << (n + 1)/2;
}

Measured memory_bytes: 256
// C.

#include <iostream>
#include <sstream>
#include <cmath>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL n, p, ans = 1;
	cin >> n >> p;
	if (n == 1) {
		ans = p;
	} else if (n >= 64) {
		;
	} else if (n >= 4) {
		LL sq = (LL)sqrt(p);
		LL m = (LL)sqrt(sq);
		for (LL a = m; a > 1; --a) {
			LL x = 1;
			for (LL b = 0; b < n; ++b) {
				x *= a;
				if (x > p) {
					break;
				}
			}
			if (p >= x && (p % x) == 0) {
				ans = a;
				break;
			}
		}
	} else {
		LL sq = (LL)sqrt(p);
		for (LL a = sq; a > 1; --a) {
			LL x = 1;
			for (LL b = 0; b < n; ++b) {
				x *= a;
				if (x > p) {
					break;
				}
			}
			if (p >= x && (p % x) == 0) {
				ans = a;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def dfs(index):
    global count
    d[index] = count
    count += 1
    for i in field[index]:
        if d[i]:
            continue
        count = dfs(i)
    f[index] = count
    return count + 1

n = int(input())
field = [[0,0]]
for _ in range(n):
    u, k, *v = map(int, input().split())
    field.append(v)
d = [0 for _ in range(n + 1)]
f = [0 for _ in range(n + 1)]

count = 1
for i in range(1, n + 1):
    if d[i]:
        continue
    count = dfs(i)
for i in range(1, n + 1):
    print(i, d[i], f[i])


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a<b && b<c) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
N = int(input())
P = list(map(float,input().split()))
ans = 0
dp = [[0 for _ in range(N+1)] for __ in range(N+1)]
dp[0][0]=1
for i in range(1,N+1):
    for j in range(i+1):
        if j==0:
            dp[i][j]=dp[i-1][j]*(1-P[i-1])
        else:
            dp[i][j]=dp[i-1][j-1]*P[i-1] + dp[i-1][j]*(1-P[i-1])

for i in range(N+1):
    if i>N/2:
        ans += dp[N][i]
print(ans)

Measured memory_bytes: 261640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string b="CODEFESTIVAL2016",s;
  int i,ans=0;
  cin>>s;
  for(i=0;i<16;i++) if(b[i]!=s[i]) ans++;
  cout << ans << endl;
  return 0;
}


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

int main(){
    int x, y; cin >> x >> y;
    if( (4*x - y) >= 0 && ((-2)*x + y) >= 0 ){
        if ((4*x-y)%2 == 0 && ((-2)*x+y)%2 == 0){
            cout << "Yes" << endl;
            return 0;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    else {
        cout << "No" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3600
import java.util.*

fun main(args : Array<String>) {
    println(inOutExec(Scanner(System.`in`)))
}

class CityInfo(val pref: Int, val year: Int, var index: Int = 0)

fun inOutExec(scanner: Scanner): String {
    val numOfPref = scanner.nextInt()
    val numOfCity = scanner.nextInt()

    val citiesIn2 = ArrayList<CityInfo>(numOfCity)
    repeat(numOfCity) {
        citiesIn2.add(CityInfo(scanner.nextInt(), scanner.nextInt()))
    }

    val cityCounter = Array(numOfPref) {0}
    val sortedCities = citiesIn2.sortedBy { it.year }
    for (city in sortedCities) {
        cityCounter[city.pref-1]++
        city.index = cityCounter[city.pref-1]
    }

    val sb = StringBuilder()
    for (city in citiesIn2) {
        sb.append(city.pref.toString().padStart(6, '0'))
                .append(city.index.toString().padStart(6, '0'))
                .append("\n")
    }
    return sb.toString()
}


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

using namespace std;

const int N = 100005;
int pre[N];     //存??点之?的?系
int marked[N];  //存?是否被??以及??的?序

int operation_order[N];     //按?序存??入的Q操作
int operation_node_index[N];//存?Q操作??的?点下?

long long sum;
int process_time;

int find_ance(int index) {
    if (marked[index] < process_time) {
        return index;
    }
    else {
        pre[index] = find_ance(pre[index]);
        return pre[index];
    }
}

int main() {
    int n, q;
    char op;
    int index;

    while (cin >> n >> q, n) {
        sum = 0;
        pre[1] = 1;
        marked[1] = 0;
        for (int i = 2; i <= n; ++i) {
            cin >> pre[i];
            marked[i] = q + 1;
        }
        int Q_operation_num = 0;
        for (int i = 1; i <= q; ++i) {
            cin >> op >> index;
            if (op == 'Q') {
                operation_order[Q_operation_num] = i;
                operation_node_index[Q_operation_num++] = index;
            }
            else {
                marked[index] = min(marked[index], i);
            }
        }

        while (Q_operation_num--) {
            process_time = operation_order[Q_operation_num];
            sum += find_ance(operation_node_index[Q_operation_num]);
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 4292
//created by sfailsthy 2016/11/27 13:21
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

const int maxn =10000+10;
int X[maxn];
int Y[maxn];
struct edge{
    int u,v;
    double cost;
};
edge es[maxn*maxn];

bool cmp(const edge& e1,const edge& e2){
    return e1.cost>e2.cost;
}

int V,E;

int par[maxn];
int rank[maxn];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        rank[i]=0;
    }
}

int find(int x){
    if(par[x]==x){
        return x;
    }
    else{
        return par[x]=find(par[x]);
    }
}

void unite(int x,int y){
    x=find(x);
    y=find(y);

    if(x==y) return;

    if(rank[x]<rank[y]){
        par[x]=y;
    }
    else{
        par[y]=x;
        if(rank[x]==rank[y]){
            rank[x]++;
        }
    }
}

bool same(int x,int y){
    return find(x)==find(y);
}

double kruscal(){
    sort(es,es+E,cmp);
    init(V);

    double res=0;
    for(int i=0;i<E;i++){
        edge e=es[i];
        if(!same(e.u,e.v)){
            unite(e.u,e.v);
            res+=e.cost;
        }
    }

    return res;
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin>>V>>E){
        for(int i=0;i<V;i++){
            cin>>X[i]>>Y[i];
        }
        double sum=0;
        for(int i=0;i<E;i++){
            int p,q;
            cin>>p>>q;
            p--;
            q--;
            int dx=X[p]-X[q];
            int dy=Y[p]-Y[q];
            double cost=sqrt(dx*dx+dy*dy);
            sum+=cost;
            es[i]=(edge){p,q,cost};
        }

        printf("%.3f\n", sum-kruscal());
    }
    return 0;
}

Measured memory_bytes: 3856
// template {{{
#include <bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define sz(c) (static_cast<int>(c.size()))
#define endl "\n"

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

inline ll addm(ll __a, ll __b, ll __m);
inline ll subm(ll __a, ll __b, ll __m);
inline ll mulm(ll __a, ll __b, ll __m);
ll powm(ll __a, ll __b, ll __m);
ll inv(ll __x, ll __m);
// }}}

const ll INFL = numeric_limits<ll>::max() / 2;
const ll INF = numeric_limits<int>::max() / 2;
const ll MOD = 1e9+7;

const int N = 200500;
int a[N], v[N];
struct BIT {
    ll f[N];
    BIT() {
        for (int i = 0; i < N; i++)
            f[i] = 0;
    }
    void update(int x, ll c)
    {
        for (; x < N; x+=x&(-x))
            f[x] = max(f[x] ,c);
    }

    ll query(int x)
    {
        ll ret = 0;
        for (; x; x-=x&(-x))
            ret = max(ret, f[x]);
        return ret;
    }
};
void solve()
{
    int n; cin >> n;
    ll ans = 0;
    BIT bit;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int i = 0; i < n; i++) {
        ll q = bit.query(a[i]) + v[i];
        ans = max(ans, q);
        bit.update(a[i], q);
    }
    cout << ans << endl;
}

// main {{{
int main()
{
    cin.sync_with_stdio(0); cin.tie(NULL);
    solve();
    return 0;
}

inline ll addm(ll __a, ll __b, ll __m = MOD) {
    return ((__a+__b)%__m);
}
inline ll subm(ll __a, ll __b, ll __m = MOD) {
    return (((__a-__b)%__m+__m)%__m);
}
inline ll mulm(ll __a, ll __b, ll __m = MOD) {
    return ((__a*__b)%__m);
}
ll powm(ll __a, ll __b, ll __m = MOD) {
    ll ret = (!__b) ? 1 : powm(__a, __b/2, __m);
    return (!__b) ? 1 : mulm(mulm(ret, ret, __m), (__b%2) ? __a : 1, __m);
}
ll inv(ll __x, ll __m = MOD) {
    return powm(__x, __m-2, __m);
}
// }}}


Measured memory_bytes: 3456
def arrayF(n): 
    F=[0]*(n+1) 
    i=2 
    while i*i<=n:
        if F[i] == 0: 
            k=i*i
            while k <= n:
                if F[k] == 0:
                    F[k] = i
                k += i
        i += 1 
    return F


def factorization(x, F): 
    primeFactors = []
    while F[x] > 0:
        primeFactors.append(F[x])
        x //= F[x] 
    if x != 1:
        primeFactors.append(x)
    return set(primeFactors)

n = int(input())
A = list(map(int, input().split()))

amax = max(A)
F  = arrayF(amax)

P = [0] *  (amax+1)
for a in A:
    for p in factorization(a,  F):
        P[p] += 1
p_max = max(P)
if  p_max <= 1:
    print('pairwise coprime')
elif  p_max <  n:
    print('setwise coprime')
else:
    print('not coprime')



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

int main() {
    int N, W[100];
    cin >> N;
    rep(i, N) cin >> W[i];
    int S1 = 0, S2 = accumulate(W, W + N, 0), ans = 1e9;
    rep(i, N-1) {
        S1 += W[i];
        S2 -= W[i];
        ans = min(ans, abs(S1 - S2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;
    LL t,a;
    cin >> t >> a;

    double dist = 13333333333333333;
    LL ans = -1;
    for(int i = 0; i < n; i++){
        LL in;
        cin >> in;
        if(dist > abs((double)a - ((double)t-(double)in*0.006))){
            ans = i+1;
            dist = abs(a-((double)t-(double)in*0.006));
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>
#define INF 100000000
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    
    int color[9]={};
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        
        a/=400;
        if(a>=8){
            color[8]++;
        }else{
            color[a]=1;
        }
    }
    
    int ans_M=0, ans_m=0;
    for(int i=0; i<8; i++){
        ans_M+=color[i];
        ans_m+=color[i];
    }
    
    if(ans_M>0 && color[8]>0){
        ans_m+=0;
    }else if(ans_M==0 && color[8]>0){
        ans_m+=1;
    }
    
    ans_M+=color[8];

    cout<<ans_m << " " << ans_M<<endl;
    return 0;
}


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

long long k;
string s;

long long solve();

int main() {
  cin >> s >> k;
  cout << solve() << endl;
  return 0;
}
long long solve() {
  long long ans = 0, ssize = s.size();
  vector<long long> v;
  if(ssize == 1) return k / 2;
  for(int i = 0; i < ssize;) {
    char now = s[i], cnt = 0;
    while(i < ssize && now == s[i]) ++cnt, ++i;
    v.push_back(cnt);
  }
  if(v.size() == 1) return (k * v[0]) / 2;
  for(int i = 0; i < v.size(); ++i) {
    ans += k * (v[i] / 2);
  }
  if(v.size() != 1 && s[0] == s[ssize - 1]) {
    ans -= (k - 1) * (v[0] / 2);
    ans -= (k - 1) * (v[v.size() - 1] / 2);
    ans += (k - 1) * ((v[0] + v[v.size() - 1]) / 2);
  }
  return ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  vector<int> c(3,0);
  ll sum=1;
  for(int i=0; i<N; i++){
    int count=0;
    int id = -1;
    if(A[i] == c[0]){
      count++;
      id = 0;
    }
    if(A[i] == c[1]){
      count++;
      id = 1;
    }
    if(A[i] == c[2]){
      count++;
      id = 2;
    }
    if(id == -1){
      cout << "0" << endl;
      return 0;
    }
    sum *= count;
    sum %= INFI;
    c[id]++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i,j;
  int ans = 0;
  for(i=0;i<s.length();i++){
    j=0;
    while((s[i+j]=='A' || s[i+j]=='T' || s[i+j]=='G'||s[i+j]=='C')&&i+j<s.length()){
      j++;
    }
    if(j>ans)ans=j;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h), t(w, string(h, ' '));
    for(int y=0; y<h; ++y){
        cin >> s[y];
        for(int x=0; x<w; ++x)
            t[x][y] = s[y][x];
    }

    vector<vector<vector<int> > > dp1(h, vector<vector<int> >(h, vector<int>(w, 0)));
    vector<vector<vector<int> > > dp2(w, vector<vector<int> >(w, vector<int>(h, 0)));
    for(int k=0; k<2; ++k){
        for(int y=0; y<h; ++y){
            for(int x=w-1; x>=0; --x){
                if(x < w - 1 && s[y][x] == s[y][x+1])
                    dp1[y][y][x] = dp1[y][y][x+1] + 1;
                else
                    dp1[y][y][x] = 1;
            }
        }
        for(int x=0; x<w; ++x){
            for(int y1=0; y1<h; ++y1){
                for(int y2=y1+1; y2<h; ++y2){
                    if(s[y1][x] != s[y2][x])
                        break;
                    dp1[y1][y2][x] = min(dp1[y1][y2-1][x], dp1[y2][y2][x]);
                }
            }
        }
        swap(h, w);
        s.swap(t);
        dp1.swap(dp2);
    }

    for(int ans=0; ; ++ans){
        if(dp1[0][h-1][0] == w){
            cout << ans << endl;
            return 0;
        }

        vector<vector<vector<int> > > nextDp1(h, vector<vector<int> >(h, vector<int>(w, 0)));
        vector<vector<vector<int> > > nextDp2(w, vector<vector<int> >(w, vector<int>(h, 0)));
        for(int k=0; k<2; ++k){
            for(int y1=0; y1<h; ++y1){
                for(int y2=y1; y2<h; ++y2){
                    for(int x=0; x<w; ++x){
                        int len = dp1[y1][y2][x];
                        if(x + len < w)
                            len += dp1[y1][y2][x+len];
                        nextDp1[y1][y2][x] = len;
                    }

                    int x2 = w - 1;
                    for(int x1=w-1; x1>=0; --x1){
                        while(x1 <= x2){
                            int len = dp2[x1][x2][y1];
                            if(y1 + len < h)
                                len += dp2[x1][x2][y1+len];
                            if(y2 < y1 + len){
                                nextDp1[y1][y2][x1] = max(nextDp1[y1][y2][x1], x2 - x1 + 1);
                                break;
                            }
                            -- x2;
                        }
                    }
                }
            }

            swap(h, w);
            s.swap(t);
            dp1.swap(dp2);
            nextDp1.swap(nextDp2);
        }
        dp1 = move(nextDp1);
        dp2 = move(nextDp2);
    }
}


Measured memory_bytes: 106324
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    b:String,
    c:String,
    }
    let a=a.chars().collect_vec();
    let b=b.chars().collect_vec();
    let c=c.chars().collect_vec();
    println!("{}",if a[a.len()-1]==b[0]&&b[b.len()-1]==c[0]{"YES"}else{"NO"})
}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	int N,ans=0;
	cin >> N;
	vector<int> L(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> L.at(i);
	}
	sort(L.begin(), L.end());
	for (size_t i = 0; i < N-2; i++)
	{
		for (size_t j = i+1; j < N-1; j++)
		{
			auto it=lower_bound(L.begin(), L.end(), L.at(i) + L.at(j));
			if (it != L.end()) {
				ans += max(int(distance(L.begin(), it) - j)-1, 0);
				//cout << L.at(i)<<endl << L.at(j) <<endl<< L.at(distance(L.begin(), it))<<endl;
			}
			else {
				ans += N - j - 1;
			}
		}
	}
	cout << ans;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back


typedef long long ll;
typedef long double ld;


const ll inf = 2e9;
const ll base = 998244353;
ll mod = 1e9 + 7;



void yes() {
    cout << "Yes" << endl;
}


void no() {
    cout << "No" << endl;
}




ll binpow(ll a, ll n) {
    if (!n) return 1;
    if (n & 1) return a * binpow(a, n - 1) % mod;
    return binpow((a * a) % mod, n / 2) % mod;
}

ll rev(ll a) {
    return binpow(a, mod - 2);
}

int main() {
//    srand(time(NULL));
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
//    std::random_device rd;
//    std::mt19937 g(rd());

    auto start = clock();

    ll x, y; cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll a = x - (x + y) / 3;
    ll b = y - (x + y) / 3;
    if (a < 0 || b < 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for (ll i = 1; i <= a + b; ++i) {
        ans *= i;
        ans %= mod;
    }
    for (int i = 1; i <= a; ++i) {
        ans *= rev(i);
        ans %= mod;
    }
    for (int i = 1; i <= b; ++i) {
        ans *= rev(i);
        ans %= mod;
    }
    cout << ans;



    std::cerr << double(clock() - start) / CLOCKS_PER_SEC << std::endl;
    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    a, b, c = map(int, input().split())
    ans = "No"
    if a == b + c:
        ans = "Yes"
    if b == c + a:
        ans = "Yes"
    if c == a + b:
        ans = "Yes"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 1;
    while(n--) {
        ans = min(ans*2, ans+k);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256