akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

typedef long long llong ;

typedef struct
{
	llong size ;
	llong value ;

} Data ;

#define N_MAX 500000
Data art[ N_MAX ] ;

int cmp( const Data *a ,const Data *b )
{
	if( a->size == b->size )
	{
		return a->value - b->value ;
	}

	if( a->size < b->size )
	{
		return -1 ;
	}

	return 1 ;
}

inline llong max( llong a ,llong b )
{
	return a > b ? a : b ;
}


int main( void )
{
	int N ;
	scanf( "%d" ,&N ) ;

	int i ;
	for( i = 0 ; i < N ; ++i )
	{
		scanf( "%lld %lld" ,&art[ i ].size ,&art[ i ].value ) ;
	}

	qsort( art ,N ,sizeof( Data ) ,cmp ) ;

	llong min_size	= art[ 0 ].size		;
	llong sum_value	= art[ 0 ].value	;

	llong ans = art[ 0 ].value ;
	for( i = 1 ; i < N ; ++i )
	{
		llong value	= art[ i ].value	;
		llong size	= art[ i ].size		;

		llong tmp =  sum_value + value  - ( size -  min_size ) ;
		if( tmp < value )
		{
			ans = max( ans ,value ) ;

			sum_value	= value	;
			min_size	= size	;
		}

		else
		{
			ans = max( ans ,tmp ) ;

			sum_value += value ;
		}
	}

	printf( "%lld\n" ,ans ) ;

	return 0 ;
}


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

int main() {

  // string S; cin >> S;
  string S; cin >> S;
  vector<int> a(S.size(), 0);
  // int   a[11];
  
  for(int i = 0 ; i < S.size() ; ++i){
    char ch = S[i];
    // cout << ch << endl;
    a[i] = atoi(&ch);
    // cout << a[i] << endl;
  }

  vector<int> sum(S.size() - 2, 0);
  int min = 9999;
  for(int i = 0 ; i < S.size() - 2 ; ++i){
    sum[i] = a[i]*100 + a[i+1]*10 + a[i+2];
    min = std::min(min, abs(753 - sum[i]));
  }

  cout << min << endl;

}

Measured memory_bytes: 256
n = int(input())
s = input()

def kakunin(animal):
    for i in range(2,n):
        if s[i-1]=='o':
            if (animal[i-1]==0) and (animal[i-2]==0 ):
                animal[i]=0
            elif (animal[i-1]==1) and (animal[i-2]==0 ):
                animal[i]+=1
            elif (animal[i-1]==0) and (animal[i-2]==1 ):
                animal[i]+=1
            elif (animal[i-1]==1) and (animal[i-2]==1 ):
                animal[i]=0
        else:
            if (animal[i-1]==0) and (animal[i-2]==0 ):
                animal[i]+=1
            elif (animal[i-1]==1) and (animal[i-2]==0 ):
                animal[i]=0
            elif (animal[i-1]==0) and (animal[i-2]==1 ):
                animal[i]=0
            elif (animal[i-1]==1) and (animal[i-2]==1 ):
                animal[i]+=1
    if s[0]=='o':
        if (animal[0]==0):
            if (animal[1]==0) and (animal[-1]==0 ):
                if ((s[-1]=='o')and(animal[-2]==0))or((s[-1]=='x')and(animal[-2]==1)):
                    return True
            elif (animal[1]==1) and (animal[-1]==1):
                if ((s[-1]=='o')and(animal[-2]==1))or((s[-1]=='x')and(animal[-2]==0)):
                    return True
        else:
            if (animal[1]==1) and (animal[-1]==0 ):
                if ((s[-1]=='o')and(animal[-2]==1))or((s[-1]=='x')and(animal[-2]==0)):
                    return True
            elif (animal[1]==0) and (animal[-1]==1):
                if ((s[-1]=='o')and(animal[-2]==0))or((s[-1]=='x')and(animal[-2]==1)):
                    return True
            
            
    else:
        if (animal[0]==0):
            if (animal[1]==1) and (animal[-1]==0 ):
                if ((s[-1]=='o')and(animal[-2]==0))or((s[-1]=='x')and(animal[-2]==1)):
                    return True
            elif (animal[1]==0) and (animal[-1]==1):
                if ((s[-1]=='o')and(animal[-2]==1))or((s[-1]=='x')and(animal[-2]==0)):
                    return True
        else:
            if (animal[1]==1) and (animal[-1]==1):
                if ((s[-1]=='o')and(animal[-2]==0))or((s[-1]=='x')and(animal[-2]==1)):
                    return True
            elif (animal[1]==0) and (animal[-1]==0):
                if ((s[-1]=='o')and(animal[-2]==0))or((s[-1]=='x')and(animal[-2]==1)):
                    return True
    return False
f = [False]     
for i in range(0,4):
    animal = [0]*n
    if i == 1:
        animal[0]+=1
    elif i==2:
        animal[1]+=1
    elif i==3:
        animal[0]+=1
        animal[1]+=1
    f[0]= kakunin(animal) 
    if f[0]==True:
        u = ''
        for j in range(0,n):
            if animal[j]==0:
                u = u+'S'
            else:
                u = u + 'W'
        print(u)
        break

if f[0] == False:
    print(-1)
        
              


Measured memory_bytes: 5000
from sys import stdin
data = int(stdin.readline().rstrip())

a = data % 10
if a == 2 or a ==4 or a == 5 or a == 7 or a == 9:
    print("hon")
elif a == 0 or a == 1 or a == 6 or a == 8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int mod = 1e9 + 7;
#define int long long int

int32_t main() {
    IOS ;
    int n, m ; cin >> n >> m ; 
    bool arr[n][m] ; char c ; 
    for(int i=0; i<n; i++) 
    for(int j=0; j<m; j++) { 
        cin >> c ;   
        if(c == '.') arr[i][j] = true ; 
        else arr[i][j] = false ;
    }

    bool flag = true ; int dp[n][m] ;
    for(int i=0; i<n; i++) 
    if(arr[i][0] and flag)   dp[i][0] = 1 ; 
    else dp[i][0] = 0, flag = false ;

    flag = true ;
    for(int i=1; i<m; i++) 
    if(arr[0][i] and flag)  dp[0][i] = 1;   
    else dp[0][i] = 0, flag = false ;

    for(int i=1; i<n; i++) {
        for(int j=1; j<m; j++) {
            if(arr[i][j]) dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod ; 
            else dp[i][j] = false ;
        }
    } 

    cout << dp[n-1][m-1] ;

    return 0 ;
}


Measured memory_bytes: 12384
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
dlist = []

for i in range(n):
    d = t - h[i] * 0.006 - a
    
    if d >= 0:
        dlist.append(d)
    else:
        d = -d
        dlist.append(d)
        
m = min(dlist)
        
print(dlist.index(m) + 1)
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


const ll mod = 1000000007;
ll fact[201200];
ll invfact[201200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll res = sub(pow(2LL, n), 1);

    ll x1 = 1;
    for(ll i = n; i > n-a; i--){
        x1 = mul(x1, i);
    }
    for(ll i = 1; i <= a; i++){
        x1 = mul(x1, mod_inv(i));
    }

    ll x2 = 1;
    for(ll i = n; i > n-b; i--){
        x2 = mul(x2, i);
    }
    for(ll i = 1; i <= b; i++){
        x2 = mul(x2, mod_inv(i));
    }

    cout << sub(res, add(x1, x2)) << endl;




    return 0;
}


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

using namespace std;


int main(){
    int h,w;
    char ch[100][101];

    cin >> h >> w;
    for(int i = 0; i < h; i++){
        // int j = 0;
        // for(j = 0; j < w; j++){
        //     scanf("%c",&ch[i][j]);
        // }

        scanf("%s",ch[i]);
    }

    for(int i = 0; i < h; i++ ){
        cout << ch[i] << endl;
        cout << ch[i] << endl;

    }



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
char words[N];
int main(){
	int len;
	scanf("%s",words);
	len=strlen(words);
	if(words[len-1]=='s'){
		for(int i=0;i<len;i++){
			printf("%c",words[i]);
		}
		puts("es");
	} 
	else{
		for(int i=0;i<len;i++){
			printf("%c",words[i]);
		}
		puts("s");
	}
	return 0;
}

Measured memory_bytes: 3744
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    int x = min(s.size(),t.size());
    bool ans = 1;
    for(int i=0; i<x; i++){
        if(s[i]>t[i]){
            ans = 0;
            break;
        }
        if(s[i]<t[i]) break;
        else if(i==x-1 && x==t.size()){
            ans = 0;
        }
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>

using namespace std;


int x[8][2] ={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};


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

  if(n%2==0){
    for(int i = n-1;i>=0;i-=2){
      cout << a[i] << " ";
    }
    for(int i=0;i<n;i+=2){
      cout << a[i] << " ";
    }
    cout << endl;
  }
  else{
    for(int i = n-1;i>=0;i-=2){
      cout << a[i] << " ";
    }
    for(int i=1;i<n;i+=2){
      cout << a[i] << " ";
    }
    cout << endl;
  }


  return 0;

}

Measured memory_bytes: 2944
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
string S, T;

int main() {
    cin >> S >> T;
    string ans = "Yes";
    for (int i = 0; i < S.length(); i++)
    {
        if(S[i]!=T[i])ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef tuple<int,int,int> TP;
constexpr int mod = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> dp(13, 0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    vector<int> ndp(13, 0);
    for (int j = 0; j < 13; j++) {
      for (int k = 0; k < 10; k++) {
        if (s[i] == '?' || int(s[i] - '0') == k) (ndp[(j * 10 + k) % 13] += dp[j]) %= mod;
      } 
    }
    dp = move(ndp);
  }
  cout << dp[5] << endl;
  return 0; 
} 

Measured memory_bytes: 3608
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	int init;
	int year;
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int set = scan.nextInt();
			int max;
			int n;
			int type;
			double r;
			int f;
			for(int data = 0;data < set;data++){
				init = scan.nextInt();
				year = scan.nextInt();
				max = 0;
				n = scan.nextInt();
				for(int i = 0;i < n;i++){
					type = scan.nextInt();
					r = scan.nextDouble();
					f = scan.nextInt();
					if(type == 1){
						max = Math.max(max,simp(r,f));
					}else if(type == 0){
						max = Math.max(max,comp(r,f));
					}
				}
				System.out.println(max);
			}
		}
	}
	public int simp(double r,int f){
		int a;
		int i;
		for(a = init,i=0;i<year;i++){
			a += ((int)(r*a) - f);
		}
		return a;
	}
	public int comp(double r,int f){
		int a;
		int i;
		int total;
		for(a=init,i=0,total=0;i<year;i++){
			total += (int)(a*r);
			a -= f;
		}
		return a + total;
	}
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    rep(i,m) cin >> p[i] >> s[i];
    vector<bool> flag(n);
    vector<int> pn_cnt(n);
    int ac_cnt=0, pn_sum = 0;

    rep(i,m){
        if(s[i] == "AC"){
            if(flag[p[i]-1] == false){
                flag[p[i]-1] = true;
                ac_cnt++;
                pn_sum = pn_sum + pn_cnt[p[i]-1];
            }
        }else if(s[i] == "WA"){
            if(flag[p[i]-1] == false) pn_cnt[p[i]-1]++; 
        }
    }

    cout << ac_cnt << " " << pn_sum << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>
#include<string>

int main(){
	char num_in='\0';
	int sum=0;

	while(true){
		while((num_in =getchar()) !='\n'){
			sum+=num_in-'0';
		}
		if(sum==0){
			break;
		}else{
			printf("%d\n",sum);
			sum=0;
		}
	}
	return 0;

}



Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
int main(){
  int p,q,used[1000005];
  while(cin>>p>>q){
    for(int i=0;i<q;i++)used[i]=-1;
    vector<int>ans;
    int i=0,idx=-1;
    while(p){
      if(used[p]!=-1){idx=used[p];break;}
      used[p]=i;
      p*=10;
      ans.push_back(p/q);
      p%=q;
      i++;
    }
    for(int j=0;j<ans.size();j++)
      cout<<ans[j];
    cout<<endl;
    if(idx!=-1){
      for(int j=0;j<ans.size();j++){
	if(j<idx)cout<<" ";
	else cout<<"^";
      }
      cout<<endl;
    }
  }
  return 0;
}

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


def main():
    """Function."""
    w, a, b = map(int, input().split())

    if b + w < a:
        print(a - (b + w))
    elif b > a + w:
        print(b - (a + w))
    else:
        print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <cstdio>
using namespace std;

int lf(int d, int n)
{
    int t = 1;
    for (int i = 0; i < n; i++) {
        t *= d;
    }
    return t;
}

int main(void)
{
    int d, n;
    scanf("%d%d", &d, &n);

    if (n == 100) {
        switch (d) {
            case 0: printf("%d\n", 101); break;
            case 1: printf("%d\n", 10100); break;
            case 2: printf("%d\n", 1010000); break;
        }
    }
    else
        printf("%d\n", lf(100, d) * n);
    
    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String ans = "No";
    if(n%2==0){
      ans = "Yes";
      int half = n/2;
      for(int i=0; i<half; ++i){
        if(s.charAt(i) != s.charAt(i+half))
          ans = "No";
      }
    }
    System.out.println(ans);
  }
}


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

int main() {
	int N; cin >> N;
	int pr;
	int a[10];

	pr = N / 1.08;
	a[0] = pr;
	a[1] = pr + 1;
	a[2] = pr - 1;
	
	if ((int)(a[0] * 1.08) == N) cout << a[0] << endl;
	else if ((int)(a[1] * 1.08) == N) cout << a[1] << endl;
	else if ((int)(a[2] * 1.08) == N) cout << a[2] << endl;
	else cout << ":(" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>



int gcd(int x, int y) {
	if (x < y)
	{
		int z = x;
		x = y;
		y = z;
	}

	while (y > 0) {
		int z = x % y;
		x = y;
		y = z;
	}

	return x;
}

int main(void) {
	int x, y;

	scanf("%d %d", &x, &y);

	printf("%d\n", gcd(x, y));

	return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int N, M, Q;//Qを追加
vi a(50), b(50), c(50), d(50);//a,b,c,dを保存しておく配列

int score(vi &A){
  int ans = 0;
  for(int i=0; i<Q; i++){
    if(A[b[i]]-A[a[i]]==c[i])ans+=d[i];
  }
  return ans;
}

int dfs(){
  //深さ優先探索して得点の最大値を返す
  int ans = 0;//得点の最大値を入れる変数
  vector<vi> uncalced;
  uncalced.push_back({});

  while(!uncalced.empty()){
    vi current = uncalced.back();//積んである最後尾の配列を読む
    uncalced.pop_back();

    if(current.size()==N){
      //N桁になってたら得点求めて最大値更新
      ans = max(ans, score(current));
    }else{
      //短かったら伸ばしたのを積む
      int last = (current.empty()? 1: current.back());
      for(int i=last; i<=M; i++){
        vi next = current;
        next.push_back(i);
        uncalced.push_back(next);
      }
    }
  }
  
  return ans;//答えを返す
}

int main(){
  //入力
  cin>>N>>M>>Q;
  for(int i=0; i<Q; i++){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--;
    b[i]--;
    //aとbはデクリメント忘れずに
  }

  int ans = dfs();

  cout<<ans<<endl;
}

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  int cnt = 0;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    if((i%2==0)&&(a%2==1)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	REP(i, 26){
		REP(j, 16){
			if(4*i+7*j==n){
				cout<<"Yes"<<'\n';
				return 0;
			}
		}
	}
	cout<<"No"<<'\n';
	return 0;
}


Measured memory_bytes: 256
using AtCoderBeginnerContest140.Questions;
using AtCoderBeginnerContest140.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest140.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var count = n - 1;
            yield return n * n * n;
        }
    }
}


namespace AtCoderBeginnerContest140
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest140.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest140.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

int main(){
    long long int ans = 0;
    long long int ans_A = 0;
    long long int ans_C = 0;
    int num = 0;
    int count_B = 0;
    int count_C = 0;
    cin >> num;
    vector<int> A(num, 0);
    vector<int> B(num, 0);
    vector<int> C(num, 0);

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

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

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

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    
    for(int i= 0; i < num; i++){
        auto it = lower_bound(A.begin(),A.end(), B[i]);

        ans_A = (it - A.begin()) ;

        auto it2 = upper_bound(C.begin(),C.end(), B[i]);

        ans_C = C.end() - it2;

        ans += ans_A * ans_C;

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){a%=mod;b%=mod;return a*b%mod;}
inline int power(int a,int b,int MOD){a%=mod;int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     int n;
     cin>>n;
     string s;
     cin>>s;
     int res=1;
     int j=0;
     for(int i=0;i<n;i++)
     {
     	   while(j<n&&s[i]==s[j])
     	   	j++;
     	   if(j==n)
     	   	break;
     	   res++;
     	   i=j-1;
     }
     cout<<res<<endl;
     time();
     return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  if(x < 1200)
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
st = []
for i in range(n):
    st.append([str(i) for i in input().split()])
x = str(input())

tmp = 0
i = 0
while True:
    if st[i][0] == x:
        tmp += int(st[i][1])
        break
    else:
        tmp += int(st[i][1])
        i += 1
sum_t = 0
for i in range(n):
    sum_t += int(st[i][1])
print(sum_t - tmp)


Measured memory_bytes: 3064
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
#define MAX_N 52
#define INF 1e18
ll d[MAX_N][MAX_N*MAX_N];
struct edge{ll to,cost,coin;};
vector<edge> G[MAX_N];
vector<ll> c(MAX_N),di(MAX_N);
void dij(ll s){
  priority_queue<TP,vector<TP>,greater<TP>> que;
  fill(d[0],d[MAX_N],INF);
  s = min(s,MAX_N*MAX_N-1ll);
  d[0][s] = 0;
  que.push(TP(0,s,0));
  while(!que.empty()){
    auto [dis,coin,v]=que.top();
    que.pop();
    coin = min(coin,MAX_N*(MAX_N-1ll));
    if(d[v][coin]<dis) continue;
    ll n_d = dis + di[v];
    ll n_coin = min(coin+c[v],MAX_N*(MAX_N-1ll));
    if(d[v][n_coin]>n_d){
      que.push(TP(n_d,n_coin,v));
      d[v][n_coin] = n_d;
    }
    for(ll i=0;i<(ll)G[v].size();i++){
      edge e=G[v][i];
      n_coin = coin - e.coin;
      if(n_coin>=0 && d[e.to][n_coin]>dis+e.cost){
        d[e.to][n_coin] = dis+e.cost;
        que.push(TP(d[e.to][n_coin],n_coin,e.to));
      }
    }
  }
}
ll min_d[MAX_N][MAX_N];
signed main(){
  init_io();
  ll n,m,s;
  cin >> n >> m >> s;
  vector<ll> u(m),v(m),a(m),b(m);
  for(int i=0;i<m;i++){
    cin >> u[i] >> v[i] >> a[i] >> b[i];
    u[i]--;
    v[i]--;
    G[u[i]].push_back({v[i],b[i],a[i]});
    G[v[i]].push_back({u[i],b[i],a[i]});
  }
  for(int i=0;i<n;i++){
    cin >>c[i] >> di[i];
  }
  for(int i=0;i<n;i++){
    dij(s);
  }
  for(int i=1;i<n;i++){
    ll ans = INF;
    for(int j=0;j<MAX_N*MAX_N;j++){
      ans = min(d[i][j],ans);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 9244
n = int(input())
a = list(map(int, input().split()))

sum = abs(a[0]) + abs(a[n-1])

for i in range(n-1):
    sum += abs(a[i] - a[i+1])
s = sum

for i in range(n):
    if i == 0:
        sum += abs(a[1]) - abs(a[0]) - abs(a[0] - a[1])
    elif i > 0 and i < n-1:
        sum += abs(a[i - 1] - a[i + 1]) - abs(a[i-1] - a[i]) -abs(a[i] - a[i+1])
    else:
        sum += abs(a[n-2]) - abs(a[n-1]) - abs(a[n-1] - a[n-2])
    print(sum)
    sum = s

Measured memory_bytes: 14048
#include <stdio.h>

int main(void) {
  int A, B;
  if (scanf("%d%d",&A,&B) && A >= 13) {
    printf("%d",B);
  } else if (A >= 6 && A <= 12) {
    printf("%d",B/2);
  } else {
    printf("%d",0);
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int MOD = 1e9 + 7 ;
const int MXN = 3000 ;
long double dp[MXN+1][MXN+1];
int n;

int32_t main()
{
   IOS
   memset(dp,0,sizeof(dp));
   cin >> n ;
   dp[0][0]=1;
   for(int i=1;i<=n;i++)
   {
	   long double p;cin>>p;
	   for(int j=0;j<i;j++)
	   {
		   dp[j+1][i-j-1]+=dp[j][i-j-1]*p;
		   dp[j][i-j-1+1]+=dp[j][i-j-1]*(1-p);
	   }
   }
   long double ans=0;
   for(int i=0,j=n;i<=n;i++,j--)
   {
	  if(i>j)ans+=dp[i][j];
   }
   cout << fixed << setprecision(10) << ans <<endl;
		   
   
   
	  
}


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

using namespace std;

const long long inf = (long long) 1e18;

const int N = 5010;

long long L[N], R[N], new_L[N], new_R[N];
int id[N];
long long f[N][N];
long long g[2][N][3];

inline bool cmp(int i, int j) {
  return (L[i] + R[i] < L[j] + R[j]);
}

inline void upd(long long &a, long long b) {
  if (b < a) {
    a = b;
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int foo, bar;
    scanf("%d %d", &foo, &bar);
    L[i] = foo;
    R[i] = bar;
    id[i] = i;
  }
  sort(id, id + n, cmp);
  for (int i = 0; i < n; i++) {
    new_L[i] = L[id[i]];
    new_R[i] = R[id[i]];
  }
  for (int i = 0; i < n; i++) {
    L[i] = new_L[i];
    R[i] = new_R[i];
  }
  long long ans = inf;
  {
    for (int a = 0; a <= n; a++) {
      for (int b = 0; a + b <= n; b++) {
        f[a][b] = inf;
      }
    }
    f[0][0] = 0;
    for (int a = 0; a < n; a++) {
      for (int b = 0; a + b < n; b++) {
        long long ft = f[a][b];
        int i = n - 1 - a - b;
        upd(f[a + 1][b], ft + R[i] + (L[i] + R[i]) * a);
        upd(f[a][b + 1], ft + L[i] + (L[i] + R[i]) * b);
      }
    }
    for (int a = 0; a <= n; a++) {
      ans = min(ans, f[a][n - a]);
    }
  }
  if (n % 2 == 1) {
    for (int b = 0; 0 + b <= n; b++) {
      for (int c = 0; c <= 1 && 0 + b + c <= n; c++) {
        g[0][b][c] = inf;
      }
    }
    g[0][0][0] = 0;
    int half = (n - 1) / 2;
    for (int a = 0; a < n; a++) {
      for (int b = 0; (a + 1) + b <= n; b++) {
        for (int c = 0; c <= 1 && (a + 1) + b + c <= n; c++) {
          g[1][b][c] = inf;
        }
      }
      for (int b = 0; a + b <= n; b++) {
        for (int c = 0; c <= 1 && a + b + c <= n; c++) {
          long long ft = g[0][b][c];
          if (a + b + c == n) {
            ans = min(ans, ft);
            continue;
          }
          int i = n - 1 - a - b - c;
          upd(g[1][b][c], ft + R[i] + (L[i] + R[i]) * a);
          upd(g[0][b + 1][c], ft + L[i] + (L[i] + R[i]) * b);
          if (c == 0) {
            upd(g[0][b][c + 1], ft + (L[i] + R[i]) * half);
          }
        }
      }
      for (int b = 0; (a + 1) + b <= n; b++) {
        for (int c = 0; c <= 1 && (a + 1) + b + c <= n; c++) {
          g[0][b][c] = g[1][b][c];
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 117248
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

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

    int N,M;cin >> N >> M;
    //vector<pair<pair<int,int>,int>> pq;
    vector<pair<LL,LL>> world;
    for(int a = 0;a < N;a++){
        int b,c,d;cin >> b >> c >> d;
        world.push_back(make_pair(d-b,d));
        world.push_back(make_pair(d-c,d));
    }
    for(int a = 0;a < M;a++){
        int b;cin >> b;
        world.push_back(make_pair(-b,-1));
    }
    sort(world.begin(),world.end());
    set<LL> se;
    for(int a = world.size()-1;a >= 0;a--){
        pair<LL,LL> pa = world.at(a);
        if(pa.second == -1){
            if(se.empty()){
                cout<<-1<<endl;
            }else{
                cout<<*se.begin()<<endl;;
            }
        }else{
            if(se.find(pa.second) == se.end()){
                se.insert(pa.second);
            }else{
                se.erase(pa.second);
            }
        }
    }
}


Measured memory_bytes: 20836
N = int(input())
S = input()

E = [0]*(N)
W = [0]*(N)

# 反対方向の人を数え上げ
for i in range(N):
  if S[i] == "E":
    E[i] = 1
  else:
    W[i] = 1
    
# リーダーより前を累積和していく
for i in range(1, N):
  W[i] += W[i-1]
  E[i] += E[i-1]

ans = float("inf")  
for i in range(N):
  sm = 0
  if 0 < i:
    sm += W[i-1]
  sm += E[N-1] - E[i]
  ans = min(ans, sm)
    
print(ans)    

Measured memory_bytes: 27036
//
// Created by bytedance on 2020/4/10.
//


#include <bits/stdc++.h>

using namespace std;

int main() {
    int k;
    scanf("%d", &k);
    unordered_set<int> s;
    int now = 7 % k;
    int cnt = 1;
    while (true) {
        if (now == 0) {
            printf("%d\n", cnt);
            return 0;
        }
        now = now * 10 + 7;
        now = now % k;
        cnt = cnt + 1;
        if (s.count(now)) break;
        s.insert(now);
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 42592
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int w,h,n;
  cin>>w>>h>>n;
  int right=w,left=0,up=h,down=0;
  int x,y,z;
  for(int i=0;i<n;i++){
    cin>>x>>y>>z;
    if(z==1&&left>=x) continue;
    if(z==2&&right<=x) continue;
    if(z==3&&down>=y) continue;
    if(z==4&&up<=y) continue;
    if(z==1){
      left=x;
    }else if(z==2){
      right=x;
    }else if(z==3){
      down=y;
    }else if(z==4){
      up=y;
    }
  }
  int ans_h=right-left;
  int ans_w=up-down;
  if(ans_h<=0||ans_w<=0){
    cout<<0<<endl;
  }else{
    cout<<ans_h*ans_w<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1142&lang=jp
// set?????????
#include <bits/stdc++.h>
using namespace std;
int m;
string s, l, r, l2, r2;
int main() {
    scanf("%d", &m);
    for (int c=0; c<m; c++) {
        cin >> s;
        set<string> train;
        train.insert(s);
        for (int i=1; i<s.length(); i++) {
            l = s.substr(0, i); r = s.substr(i);
            l2 = l; r2 = r;
            reverse(l.begin(), l.end()); reverse(r.begin(), r.end());
            train.insert(l+r); train.insert(r+l); train.insert(l2+r); train.insert(r+l2);
            train.insert(l+r2); train.insert(r2+l); train.insert(l2+r2); train.insert(r2+l2);
        }
        printf("%d\n",train.size());
    }
}

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

int main(void){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
        
    for (int j = 0; j < K; j++) {
        vector<ll> imos(N+1, 0);
        for (int i = 0; i < N; i++) {
            imos[max(0, i-A[i])]++;
            imos[min(N, i+A[i]+1)]--;
        }
        
        A[0] = imos[0];
        bool flag = false;
        if (A[0] == N)
            flag = true;
        for (int i = 1; i < N; i++) {
            imos[i] += imos[i-1];
            A[i] = imos[i];
            if (A[i] != N)
                flag = false;
        }
        if (flag)
            break;
    }
    for (int i = 0; i < N; i++)
        cout << A[i] << " ";
}

Measured memory_bytes: 5620
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define li long long
using namespace std;
int n,tot;
int hd[100009],eg[200009],nxt[200009],len[200009];
int cl[100009];
void ins(int a,int b,int c)
{
	eg[++tot]=b;
	len[tot]=c;
	nxt[tot]=hd[a];
	hd[a]=tot;
}
void dfs(int x,int fa,li dis)
{
	if(dis&1)
		cl[x]=1;
	else
		cl[x]=0;
	for(int i=hd[x];i;i=nxt[i])
		if(eg[i]!=fa)
			dfs(eg[i],x,dis+len[i]);
}
int main()
{
	scanf("%d",&n);
	for(int i=1,a,b,c;i<=n-1;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		ins(a,b,c);
		ins(b,a,c);
	}
	dfs(1,0,0);
	for(int i=1;i<=n;i++)
		printf("%d\n",cl[i]);
	return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  
  string s;
  cin>>s;
  int cnt=0;
  rep(i,s.size()){
    if(s[i]=='1') cnt++;
  }
  cout<<cnt<<endl;
  
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

/*

g++ -std=c++1z code.cpp
./a.out

*/


Measured memory_bytes: 7780
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int N,M;
int A[2010];
int B[2010];

vector < int > dfs (int from, int to, int unused_idx)
{
    vector < int > G[1010];
    REP(i,M) {
        if (i == unused_idx) continue;
        G[A[i]].push_back(B[i]);
    }
    stack < vector < int > > sta;
    sta.push({from});
    bool used[1010] = {};
    while (!sta.empty()) {
        vector < int > t = sta.top();
        sta.pop();
        int v = t.back();
        used[v] = true;
        REP(i,G[v].size()) {
            vector < int > tt = t;
            tt.push_back(G[v][i]);
            if (to == G[v][i]) {
                return tt;
            }
            if (used[G[v][i]]) {
                continue;
            } else {
                sta.push(tt);
            }
        }
    }
    return {};
}

int main ()
{
    cin >> N >> M;
    REP(i,M) cin >> A[i] >> B[i];

    int cost = 1e9;
    vector < int > cycle;
    REP(i,M) {
        vector < int > ct = dfs(B[i], A[i], i);
        if (ct.size() > 0) {
            if (cost > ct.size()) {
                cost = (int)ct.size();
                cycle = ct;
            }
        }
    }

    if (cost == 1e9) {
        cout << -1 << endl;
    } else {
        cout << cycle.size() << endl;
        for (auto x : cycle) cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 620
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
char s[N];
 
int main()
{
	scanf("%s",s);
	int len = strlen(s);
	int cnt = len - 2;
	if (s[0] == s[len - 1])
	{
		if (cnt % 2) puts("Second");
		else puts("First");
	}
	else
	{
		if (cnt % 2 == 0) puts("Second");
		else puts("First");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    auto b = a;
    sort(a.begin(), a.end());
    int mid = n / 2;
    int minv = a[mid-1];
    int maxv = a[mid];
    rep(i, n) {
        if (maxv > b[i]) {
            cout << maxv << endl;
        }
        else {
            cout << minv << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

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

    int64_t k;
    cin >> k;
    if (k == 0) {
        cout << 2 << endl;
        cout << 1 << " " << 1 << endl;
        return 0;
    } else if (k < 50) {

        cout << k + 1 << endl;
        for (int i = 0; i < k; i++) {
            cout << 0 << " ";
        }
        cout << (k + 1) * k << endl;
        return 0;
    } else {
        int remain = k % 50;
        std::vector<int64_t> num(50, 50 - remain + (k / 50) - 1);
        for (int i = 50 - remain; i < 50; i++) {
            num[i] += 51;
        }

        cout << 50 << endl;
        for (int i = 0; i < 49; i++) {
            cout << num[i] << " ";
        }
        cout << num[49] << endl;
    }

    return 0;
}


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

int main()
{
    int seven=0,five=0,current;
    for(int i=0;i<3;i++){
        cin >> current;
        if(current == 5){
            five ++;
        }else if(current == 7){
            seven ++;
        }
    }

    if((five==2)&&(seven==1)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int ans = 0;

  while (true) {
    if (x == 0 && y == 0)
      break;
    int tmp = min(x, y);
    if (x > 0 && y > 0) {
      if (ans + 2 * c > ans + a + b) {
        ans += tmp * (a + b);
        x -= tmp;
        y -= tmp;
      } else {
        ans += tmp * 2 * c;
        x -= tmp;
        y -= tmp;
      }
    } else if (x == 0 && y > 0) {
      if (ans + 2 * c > ans + b) {
        ans += y * b;
        y -= y;
      } else {
        ans += y * 2 * c;
        y -= y;
      }
    } else if (y == 0 && x > 0) {
      if (ans + 2 * c > ans + a) {
        ans += x * a;
        x -= x;
      } else {
        ans += x * 2 * c;
        x -= x;
      }
    }
  }

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


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

int main(){
    int n;
    cin >> n;
    vector<string> v(n);
    rep(i,n) {
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());
    int sum =1;
    rep(i,n-1){
        if(v.at(i)!=v.at(i+1)){
            sum++;
        }
    }
    cout << sum <<endl;
}

Measured memory_bytes: 9600
module Main (main) where

import Control.Monad
import Control.Monad.Trans.State
import qualified Data.ByteString.Unsafe as B
import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Char
import Data.List
import Data.Maybe

main :: IO ()
main =
  replicateM 2 readPair >>= print . showAnswer . solve

type Input  = [(Int, Int)]
type Output = Int

solve :: Input -> Output
solve [(h1,w1),(h2,w2)] = (h1-h2) * (w1-w2)

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

readPair :: IO (Int, Int)
readPair = head . unfoldr readT <$> C8.getLine
  where
    readT = runStateT $
      (,) <$> StateT (C8.readInt . C8.dropWhile isSpace)
          <*> StateT (C8.readInt . B.unsafeTail)

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  char A,B,C;
  A=a[0]-32;
  B=b[0]-32;
  C=c[0]-32;
  cout<<A<<B<<C<<endl;
  return 0;
}



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

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double min = 60*H + M;//何分後か
  double kaku = 5.5 * min;//今何度差があるか
  double answer2;
  answer2 = A * A + B * B - 2 * A * B * cos(2*M_PI/360*kaku);
  cout << fixed << setprecision(15);
  cout << sqrt(double(answer2)) << endl;
  return 0;
}

Measured memory_bytes: 4188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  vector <vector<int>> vec(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> vec[i][j];
    }
  }
  int b1, b2, b3, a2, a3;
  for(int i=0;i<10000000;i++){
    b1=vec[0][0]-i;
    b2=vec[0][1]-i;
    b3=vec[0][2]-i;
    a2=vec[1][1]-b2;
    a3=vec[2][2]-b3;
    if(a2+b1==vec[1][0]  && a3+b1==vec[2][0] && a3+b2==vec[2][1] && a2+b3==vec[1][2]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout <<  "No" << endl;
  return 0;
}


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

int main()
{
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  int ans;
  if (N <= K) ans = X * N;
  else ans = X * K + Y * (N - K);
  
  cout << ans << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> table(101000,0);
    int index = 1;
    int d = 2;
    while (index<=100000){
        table[index] = d;
        index += d;
        d++;
    }

    if(table[N] > 0){
        int h = table[N];
        cout << "Yes" << endl;
        vector<vector<int>> ans(h);

        REP(i,h){
            ans[i].push_back(h-1);
        }

        int n = 1;
        FOR(i,0,h-1){
            FOR(j,i+1,h){
                ans[i].push_back(n);
                ans[j].push_back(n);
                n++;
            }
        }

        cout << h << endl;
        REP(i,h){
            REP(j, h){
                cout << ans[i][j] << " ";
            }
            cout << endl;
        }

     }else{
         cout << "No" << endl;
     }
    return 0;
}

Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  string ans = "No";
  for(int i=0; i<S.size()-1; i++){
    if(S.at(i) == 'A' && S.at(i+1) == 'C'){
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from math import ceil, floor, factorial
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def comb(n, r):
    if n-r < 0:
        return 0
    return factorial(n) // (factorial(n - r) * factorial(r))


def main():
    n,m = map(int, input().split())
    print((comb(n,2)) + (comb(m,2)))
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5204