akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N = int(input())
pos = []
zero = []
neg = []
for _ in range(N):
    S = input().rstrip()
    m = s = 0
    for c in S:
        if c == '(':
            s += 1
        else:
            s -= 1
            m = min(m, s)
    if s > 0:
        heappush(pos, (-m, s)) # take larger mins first
    elif s == 0:
        heappush(zero, (m, s))
    else:
        heappush(neg, (m - s, s)) # take smaller mins first
num = 0
while pos:
    m, s = heappop(pos)
    if num - m < 0:
        print('No')
        exit()
    num += s
while zero:
    m, s = heappop(zero)
    if num + m < 0:
        print('No')
        exit()
while neg:
    m, s = heappop(neg)
    m += s
    if num + m < 0:
        print('No')
        exit()
    num += s
if num == 0:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 168680
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main() {
     
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    
    string a,b;
    cin>>a;
    cin>>b;
     int l1=a.length();
     int l2=b.length();
  
    int max=(l1>=l2)?l1:l2;
    int i;
    for(i=0;i<max;++i)
    {
         if(b[i]=='\0' && a[i]!='\0')
            printf("%c",a[i]);      
      
         else
            printf("%c%c",a[i],b[i]);
    }
    
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> pr;
typedef priority_queue<pr,vector<pr >,greater<pr> > pq;
const int INF=1<<30;
int Dijkstra(int start,int goal,vector<pr> cost[101]){
	int ans[101];
	for(int i=0;i<101;i++)
		ans[i]=INF;	
	ans[start]=0;
	pq p;
	p.push(pr(0,start));
	while(!p.empty()){
		int f=p.top().first,s=p.top().second;
		p.pop();
		if(f!=ans[s]) continue;
		for(int i=0;i<cost[s].size();i++){
			int next=cost[s][i].second;
			if(ans[next]>ans[s]+cost[s][i].first){
				ans[next]=ans[s]+cost[s][i].first;
				p.push(pr(ans[next],next));
			}
		}
	}
	return ans[goal];
}
int main() {
	// your code goes here
	int m,n,a,b,c,d;
	while(cin >> n >> m && n){
	vector<pr> price[101],time[101];
	for(int i=0;i<n;i++){
		cin >> a>>b>>c>>d;
		price[a].push_back(pr(c,b));
		price[b].push_back(pr(c,a));
		time[a].push_back(pr(d,b));
		time[b].push_back(pr(d,a));
	}
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a>> b >>c;
		if(!c)
	cout << Dijkstra(a,b,price) << endl;
	else
	cout <<	Dijkstra(a,b,time) << endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1332
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int N[] = {0,1,5,3};
    int E[] = {0,4,5,2};
    int W[] = {0,2,5,4};
    int S[] = {0,3,5,1};
    int R[] = {1,2,3,4};
    int L[] = {1,4,3,2};

    int* move[256];
    move['n'] = N;
    move['e'] = E;
    move['w'] = W;
    move['s'] = S;
    move['r'] = R;
    move['l'] = L;

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int dice[] = {1,5,4,2,3,6};
        for(int i=0; i<n; ++i){
            string s;
            cin >> s;
            char c = s[0];
            int tmp = dice[move[c][0]];
            for(int i=1; i<4; ++i)
                dice[move[c][i-1]] = dice[move[c][i]];
            dice[move[c][3]] = tmp;
        }

        cout << dice[0] << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+5;
void solve(){
	ll n,m; 
	cin>>n>>m; 
	ll ans = min(n,m/2ll);
	n-=ans;
	m-=2ll*ans;
	if(m>0){
		ans+=m/4ll;
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3572
// written by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

int read() {
  int f = 0;
  char ch;
  while (!isdigit(ch = getchar()));
  do f = 10 * f + (ch ^ '0');
  while (isdigit(ch = getchar()));
  return f;
}

const int N_MAX = 200003;
int p[N_MAX], f[N_MAX], c[N_MAX][2];
int find(int x) {
  return x == f[x] ? x : f[x] = find(f[x]);
}

struct Node {
  int c0, c1, id;
  Node() {}
  Node(const int &c0, const int &c1, const int &id) : c0(c0), c1(c1), id(id) {}
  friend bool operator<(const Node &lhs, const Node &rhs) {
    return 1ll * lhs.c0 * rhs.c1 < 1ll * lhs.c1 * rhs.c0;
  }
};
std::priority_queue<Node> que;

int main() {
  int n = read();
  for (int i = 2; i <= n; ++i)
    p[i] = read();
  for (int i = 1; i <= n; ++i)
    f[i] = i, c[i][read()] = 1;
  for (int i = 2; i <= n; ++i)
    que.push(Node(c[i][0], c[i][1], i));
  
  long long ans = 0;
  // int cnt = 0;
  while (!que.empty()) {
    Node now = que.top();
    que.pop();
    // int x = find(now.id);
    int x = now.id;
    if (now.c0 == c[x][0] && now.c1 == c[x][1]) {
      // ++cnt;
      int u = find(p[x]);
      ans += 1ll * c[u][1] * now.c0;
      c[u][0] += now.c0, c[u][1] += now.c1;
      f[now.id] = u;
      if (u > 1)
        que.push(Node(c[u][0], c[u][1], u));
    }
  }
  
  printf("%lld\n", ans);
  // debug(cnt);
  return 0;
}


Measured memory_bytes: 8052
#include <iostream>

using namespace std;

int main(void){
    char s[4];
    cin >> s[0] >> s[1] >> s[2] >> s[3];
    
    int ans = 0;
    
    for(int i=0;i<4;i++){
        if(s[i]=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#define PI 3.14159265359
#define rep(i,n) for(int i=0; i<n; ++i)
#define INF 1001001001
#define MAX_N 100005
#define MAX_M 100005
#define MAX_K 100000
typedef long long ll;
using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int> > a(n, vector<int>(m));

    rep(i, n) {
        cin >>c[i];
        rep(j, m) cin >> a[i][j];
    }

    int ans = INF;
    for(int bit=0; bit < (1<<n); ++bit) {
        vector<int> s(m);
        int cost = 0;
        rep(i, n) {
            if (bit & (1<<i)) {
                cost += c[i];
                rep(j, m) s[j] += a[i][j];
            }
        }
        bool flg = true;
        rep(j, m) if (s[j] < x) flg = false;
        if (flg) ans = min(ans, cost);
    }

    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

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


int main(){
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i])
        {
            cout << "No" << endl;
            return 0;
        }
        
    }
    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    int K;
    int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cin >> K;

    cout << A[K - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
/* ex4_1
	kanon */

#include <stdio.h>
#include <math.h>

int main(void)
{

    //与えられる値を入れる数を宣言
    float num,d;

    //変数に値を入力する
    scanf("%f %f",&num,&d);
  

    //全体の長さ/(１人の人が見張れる範囲)を計算
    int ans=ceil(num/(2*d+1));

    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, v: [isize; n], c: [isize; n]);

    let mut ans = 0;
    for i in 0..n {
        if 0 < v[i] - c[i] {
            ans += v[i] - c[i];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

ll mod = 1000000007;


ll modPow(ll x, ll n){
    if (n == 0) return 1;
    if (n % 2 == 0){
        ll half =  modPow(x, n/2);
        return half * half % mod;
    }else{
        return x * modPow(x, n-1) % mod;
    }
}

ll choose(ll n, ll r){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * modPow(div, mod-2) % mod;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;;
    ll ans = modPow(2, n) - choose(n, a) - choose(n, b) - 1;
    ans %= mod;
    if (ans < 0) ans += mod;
    cout << ans << endl;
    return 0;
}

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

int main()
{
    string S;
    cin >> S;
    bool loop = true;
    string revS1 = S;
    reverse(revS1.begin(), revS1.end());
    if (S != revS1)
    {
        cout << "No" << endl;
    }
    else{
        int N = (S.length() - 1) / 2;
        string newS = S.substr(0, N);
        string revS2 = newS;
        reverse(revS2.begin(), revS2.end());
        if (newS != revS2)
        {
            cout << "No" << endl;
        }
        else{
            int N = (S.length() + 3) / 2;
            string newS2 = S.substr(N-1, S.length());
            string revS3 = newS2;
            reverse(revS3.begin(), revS3.end());
            if (newS2 != revS3)
            {
                cout << newS2 << endl;
                cout << "No" << endl;
            }
            else{
                cout << "Yes" << endl;
            }
        }
    }
}

Measured memory_bytes: 256
import sys

while True:
	h, w = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	if 0 ==h and 0 == w:
		break
	for i in range( h ):
		if 0 == i or h-1 == i:
			print( "#"*w )
		else:
			print( "#"+"."*(w -2)+"#"  )
	print( "" )

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

int main()
{
	int n;
	int a[105];
	cin >> n;
	int f=1;
	for(int i=0;i<n;i++){
		cin >> a[i] ;
		if(a[i]%2==0) {
			if(a[i]%3==0||a[i]%5==0) ;
			else f=0;
		}
	}
	if(f==0) cout <<"DENIED";
	else cout <<"APPROVED"	;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N;
    cin >> N;
    vec A(N);
    map<ll, ll> X;
    rep(i, N) cin >> A[i], ++X[A[i]], X[A[i]] %= 2;
    ll ct0 = 0, ct1 = 0;
    for(auto x : X){
        if(x.second == 0) ++ct0;
        else ++ct1;
    }

    ll ans = ct0 + ct1 - ct0 % 2;
    print(ans);

    return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		int ans = 0;
		for (int i=0;i<n;i++) {
			if (a.charAt(i) == b.charAt(i) && a.charAt(i) == c.charAt(i)) {
				
			} else if (a.charAt(i) == b.charAt(i) || a.charAt(i) == c.charAt(i) || b.charAt(i) == c.charAt(i)) {
				ans++;
			} else {
				ans+=2;
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;cin>>s;int flag=-1;
	for(int i=0;i<s.size();i++){
		if(s[i]=='7'){flag=1;break;
		}
	}
	if(flag==-1)cout<<"No"<<"\n";
	else cout<<"Yes"<<'\n';
}

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

int main(){

	int n, q;
	cin >> n;
	int* S = new int[n];
	for (int i = 0; i < n; i++) cin >> S[i];
	cin >> q;
	int* T = new int[q];
	for (int i = 0; i < q; i++) cin >> T[i];

	int count = 0;
	int min, max, mid;
	for (int i = 0; i < q; i++){
		if (T[i] > S[n - 1] || T[i] < S[0]) continue;
		min = 0;
		max = n - 1;
		do{
			mid = min + (max - min) / 2;
			if (S[mid] > T[i]){
				max = mid - 1;
			}
			else if (S[mid] < T[i]){
				min = mid + 1;
			}
			else{
				count++;
				break;
			}
		} while (min <= max);
	}

	cout << count << endl;

	delete[] S;
	delete[] T;
		
	return 0;
}


Measured memory_bytes: 3276
#include <stdio.h>

typedef struct { int m; int c; int x; int i; } MCXI;

/* 標準入力からMCXI文字列を読み込む */
void scanMCXI(MCXI *a) {
	char s[9];
	int d, i;
	/* 初期化 */
	a->m = 0; a->c = 0; a->x = 0; a->i = 0;
	/* 入力 */
	scanf("%*[^mcxi2-9]%[mcxi2-9]", s);
	/* MCXIの書式に従って解析する */
	for (d = 1, i = 0; s[i] != '\0'; i++) {
		/* mxci符号 */
		if (s[i] == 'm') a->m = d;
		else if (s[i] == 'c') a->c = d;
		else if (s[i] == 'x') a->x = d;
		else if (s[i] == 'i') a->i = d;
		/* 数字 */
		if (s[i] >= '2' && s[i] <= '9') d = s[i] - '0';
		else d = 1; /* mcxiの前に数字がない場合は1であるので1で初期化する */
	}
}

/* 標準出力へMCXI文字列を書き出す */
void printMCXI(MCXI a) {
	if (a.m > 1) printf("%d", a.m); if (a.m > 0) printf("m");
	if (a.c > 1) printf("%d", a.c); if (a.c > 0) printf("c");
	if (a.x > 1) printf("%d", a.x); if (a.x > 0) printf("x");
	if (a.i > 1) printf("%d", a.i); if (a.i > 0) printf("i");
	printf("\n");
}

/* 2つのMCXI文字列の和を返す */
MCXI addMCXI(MCXI a, MCXI b) {
	MCXI s;
	/* 各位同士と繰り上がりを足し合わせる */
	s.i = a.i + b.i;
	s.x = a.x + b.x + s.i / 10;
	s.c = a.c + b.c + s.x / 10;
	s.m = a.m + b.m + s.c / 10;
	/* 繰り上がりを取り除く */
	s.m %= 10; s.c %= 10; s.x %= 10; s.i %= 10;
	return s;
}

int main(void) {
	int n; /* 計算指示の個数 */
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		MCXI a, b;
		scanMCXI(&a);
		scanMCXI(&b);
		printMCXI(addMCXI(a, b)); /* 和を出力する */
	}
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>//大佬勿喷，C党强迫症
#include <string.h>
int main()
{
    char str[101],answer[101];//刚开始的时候的输入存在str数组里，输出存在answer数组里。
    gets(str);//输入我们的str数组
    int lens=strlen(str),i,lena=0;//lena是answer数组的长度，目前一个字符都没插，长度为0
    for(i=0;i<lens;i++)
        switch(str[i])
        {
            case '0':answer[lena]='0';lena++;break;//是0的情况，在空串的右边插入0
            case '1':answer[lena]='1';lena++;break;//同样
            case 'B':if(lena!=0) lena--;break;//是退格键的时候，先判断现在是不是空串，如果不是，就退一格
        }
    for(i=0;i<lena;i++)
        printf("%c",answer[i]);//输出
    printf("\n");//注意换行
}//完美收场23333（防伪标记）

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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

ll dp[253][253][32] = {0};

int n,c,l[10],perm[10];

int main() {
	read(n);read(c);
	ll fm = 1;
	for(int i=0;i<n;i++){
		read(l[i]);
		perm[i] = i;
		if(i)fm*=i*c;
	}
	sort(l,l+n);
	ll ans = 0;
	do{
		memset(dp,0,sizeof(dp));
		int m = (n-1);
		dp[0][m*l[m]][0] = 1;
		for(int j=0;j<m*c;j++){
			//cout<<j<<' '<<(1<<(j%m))<<endl;
			int cm = j%m;
			for(int k=1;k<m*c;k++){
				for(int cc = 0;cc<1<<m;cc++){
					if(!dp[j][k][cc])continue;
					dp[j+1][k-1][cc]+=dp[j][k][cc];
					if((cc&(1<<cm)) == 0){
						dp[j+1][max(k,m*l[perm[cm]])-1][cc|(1<<cm)]+=dp[j][k][cc];
					}
				}
			}
		}
		for(int k=0;k<m*c;k++) ans+=dp[m*c][k][(1<<m)-1];
		//return 0;
	}while(next_permutation(perm,perm+n-1));
	//cout<<ans<<' '<<fm<<endl;
	cout<<setprecision(25)<<fixed<<(double)ans/fm<<endl;
	return 0;
}


Measured memory_bytes: 16384
/*
And, when you want something, all the universe conspires in helping you to achieve it.
-The Alchemist, Paulo Coelho
*/
 
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <algorithm>
#include <math.h>
#include <map>
#include <cstdlib>
 
#define INF 1e9
 
using namespace std;
 
 
int main(){
 
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int a, b;
    cin >> a >> b;
    cout << a*b;

    return 0;
}

Measured memory_bytes: 3536
a = input()
b = input()
c = input()
now = "a"
A = []
B = []
C = []
for i in range(len(a)):
  A.append(a[i])
for i in range(len(b)):
  B.append(b[i])
for i in range(len(c)):
  C.append(c[i])
for i in range(len(A)+len(B)+len(C)):
  if now == "a":
    if len(A) == 0:
      print("A")
      break
    else:
      now = A[0]
      A.remove(A[0])
  elif now == "b":
    if len(B) == 0:
      print("B")
      break
    else:
      now = B[0]
      B.remove(B[0])
  elif now == "c":
    if len(C) == 0:
      print("C")
      break
    else:
      now = C[0]
      C.remove(C[0])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++){
        int a;cin>>a;v.push_back(a);
    }
    sort(v.rbegin(),v.rend());
    int pas1=-1,pas2=-1;
    for(int i=0;i<n-1;i++){
        int a=v[i],b=v[i+1];
        if(a==b){
            if(pas1==-1)pas1=a;
            else if(pas2==-1)pas2=a;
            i++;
        }
    }
    if(pas2==-1)cout<<"0\n";
    else cout<<(long long)pas1*pas2<<endl;
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int n;
           cin>>n;
           vin a(n);
           rep(i,0,n)cin>>a[i];
           vin b(n);
           b=a;
           sort(all(a));
           rep(i,0,n){
            if(b[i]<a[n/2]){
             cout<<a[n/2]<<endl; 
            }
             else cout<<a[n/2-1]<<endl;
           }
          }

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;

int n, k;
VVI ab;

ll chain(int cs, int par, int anc)
{

    ll rval = 1;
    //cout<<cs<<" "<<par<<" "<<anc<<" "<<rval<<endl;

    int cnt = 0;
    REPALL(i,ab[cs]) {
        //cout<<cs<<"_"<<ab[cs][i]<<endl;
        if (ab[cs][i] == par) {
            continue;
        } else {
            rval = (rval * (k - anc - cnt) % MOD) * (chain(ab[cs][i], cs, min(2, anc + 1))) % MOD;
            cnt++;
        }
    }

    return rval;
}

int main()
{
    cin>>n>>k;
    ab.resize(n+1);
    REP(i,n-1) {
        int a, b;
        cin>>a>>b;
        ab[a].push_back(b);
        ab[b].push_back(a);
    }
    ab[0].push_back(1);
    ab[1].push_back(0);

    cout<<chain(0, 0, 0)<<endl;

    return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
int cnt[2][105];

int main() {
	int n;
	cin >> n;
	vector<int>c(n), s(n), f(n);
	rep(i, n - 1) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 0;i < n;++i) {
		int ans = 0;
		for (int j = i;j < n-1;++j) {
			if (ans <= s[j])ans = s[j];
			else {
				int res = ans;
				if (ans % f[j] != 0) {
					ans = res + f[j] - (res % f[j]);
				}
			}
			ans += c[j];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef long long LL;
int sz=0;
LL IN(void)
{
  LL x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  LL N=IN();char str[12];
  while(N){N--;str[sz++]=97+N%26;N/=26;}
  for(int i=0;i<sz;i++)printf("%c",str[sz-i-1]);
}

Measured memory_bytes: 1532
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Dec 17 14:25:18 2018
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	sort.Ints(arr)

	min := 1<<31 - 1
	for i := 0; i+K-1 < len(arr); i++ {
		diff := arr[i+K-1] - arr[i]
		if diff < min {
			min = diff
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 5504
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;

int main()
{      
    long long a;
    cin >> a;
    
    cout << a*a*a + a*a + a << endl;
      
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main() {
    int H, W;
    while(true) {
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i = 1; i <= H; ++i) {
            for(int j = 1; j <= W; ++j) {
                if(i == 1 || i == H) cout << '#';
                else if(j == 1 || j == W) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;
    if((A+B)%3==0)
        cout<<"Possible\n";
    else if(A%3==0||B%3==0)
        cout<<"Possible\n";
    else
        cout<<"Impossible\n";

}


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


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

  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int Sum = 0;

  if(a + b <= 2 * c){
    Sum = a * x + b * y;
  }
  else if(x < y){
    Sum = 2 * x * c + (y - x) * min(b,2*c);
  }
  else{
    Sum = 2 * y * c + (x - y) * min(a,2*c);
  }

  cout << Sum << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vp p(n);
  cin>>p;
  map<P,int> mp;
  rep(i,n)rep(j,n) {
    if (i == j) continue;
    mp[P(p[i].fi-p[j].fi, p[i].se-p[j].se)]++;
  }
  int ans = 0;
  for (auto p : mp) maxs(ans,p.se);
  ans = n-ans;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 384
#include <bits/stdc++.h>
  
using namespace std;
 
#define endl "\n"
#define JAM(x) cout<< #x <<" = "<<x<<"\n"
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { ll a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
 
 
//Fast Reader
template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef vector<PII> VPI;
 
const int INF=2e9;
const int MX=100005;
const int MOD=1000000007;
const double PI=acos(-1.0);




long long int power(long long int a,long long int b)
{
    a %= MOD;
    long long int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
bool isprime(int n)
{
    if(n==1)
    return 0;
    int i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return false;
    }
    return true;
}



/*_______________________________________________*/





int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    long int m=(1000000007);
    long int a[n];
    long int sm=0,i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long int ans=0;
    for(i=n-1;i>=0;i--)
    {
        ans=(ans+(sm*a[i]+m)%m+m)%m;
        sm=((sm+a[i])%m)%m;
    }
    cout<<ans;
}


Measured memory_bytes: 5208
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

now = 1
count = 0
for i in range(n):
    now = a[now - 1]
    count += 1
    if now == 2:
        break

count = -1 if count == n else count
print(count)


Measured memory_bytes: 7084
#include<cstdio>
const int P=1e9+7;
int n,m;
int f[307][307][307];
void inc(int&a,int b){
	if(~a&&(a+=b)>=P)a-=P;
}
void trans(int a,int b,int c,int d){
	int x=f[a][b][c];
	if(x<=0)return;
	inc(f[d][b][c],x);
	inc(f[a][d][c],x);
	inc(f[a][b][d],x);
}
int chk(int x){return x>0?x:0;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0,l,r,x;i<m;++i){
		scanf("%d%d%d",&l,&r,&x);
		for(int a=0;a<=r;++a){
			for(int b=0;b<=r;++b){
				if((a>=l)+(b>=l)+1!=x)f[r][a][b]=f[a][r][b]=f[a][b][r]=-1;
			}
		}
	}
	inc(f[1][0][0],1);
	inc(f[0][1][0],1);
	inc(f[0][0][1],1);
	for(int t=1;t<n;++t){
		for(int a=0;a<t;++a){
			for(int b=0;b<t;++b){
				trans(t,a,b,t+1);
				trans(a,t,b,t+1);
				trans(a,b,t,t+1);
			} 
		}
	}
	long long s=0;
	for(int a=0;a<n;++a)
	for(int b=0;b<n;++b){
		s+=chk(f[n][a][b]);
		s+=chk(f[a][n][b]);
		s+=chk(f[a][b][n]);
	}
	printf("%lld\n",s%P);
	return 0;
}

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

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

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

	ll ans = 0;
	ll c = min({ a[0], a[3], a[4] });
	for(int i = 0; i <= 1; i++) {
		if(i == 1 && c == 0) break;
		ll sum = 0;
		sum += 6 * i;
		sum += (a[0] - i) / 2 * 4;
		sum += (a[3] - i) / 2 * 4;
		sum += (a[4] - i) / 2 * 4;
		ans = max(ans, sum);
	}
	ans += a[1] * 2;

	cout << ans / 2 << endl;
}

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

using namespace std;

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

  int ans = (s.size() - 1) / 2;
  char c = s[ans];

  for (int i = ans + 1; i < s.size(); i++) {
    if (s[i] == c && s[s.size() - 1 - i] == c) {
      ans = i;
    } else {
      break;
    }
  }

  cout << ans + 1 << endl;
}


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

int main(){
  int N;
  cin >>N;
  int a[N];
  int s[100010];
  for(int i=0;i<100010;i++){
    s[i]=0;
  }
  for (int i= 0;i<N;i++){
    cin >> a[i];
   }
  int cntmax=0;
  sort (a,a+N);
  for (int i=0;i<N;i++){
    s[a[i]]++;
    if(a[i]>0){
    s[a[i]-1]++;
    }
    s[a[i]+1]++;
  }
  int maxi=0;
  for(int i=0;i<100001;i++){
    maxi=max(maxi,s[i]);
  }
  cout<<maxi<<endl;
  return 0;
}

   
    
      
        
  
    

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[a.size() - 1] - a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define LOWB(x) (x & (-x))
#define UNIQUE(a) sort(ALL(a)), (a).erase(unique(ALL(a)), (a).end())
#define INF 1e9
#define INF_LL 4e18
#define rep(i,a,b) for(__typeof(b) i=a; i<(b); ++i)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
/*-----------------------------------*/
int a, b, t;

int main() {
  cin >> a >> b >> t;
  cout << t / a * b << endl;
  return 0;
}


Measured memory_bytes: 256
import collections

def search(node, elems, tree, depth):
    elems[node].append(depth)
    if elems[node][0] == -1:
        state = 'root'
    elif not tree[node]:
        state = 'leaf'
    else:
        state = 'internal node'
    elems[node].append(state)
    elems[node].append(tree[node])
    depth += 1
    for c in tree[node]:
        search(c, elems, tree, depth)
    
if __name__ == '__main__':
    n = int(input())
    tree = collections.defaultdict(list)
    elems = collections.defaultdict(list)
    #elems key:id, value: parent, depth, state, children
    parents = list()
    node_list = list()
    for _ in range(n):
        hoge = [int(x) for x in input().split()]
        node_list.append(hoge[0])
        tree[hoge[0]]
        for childs in range(hoge[1]):
            tree[hoge[0]].append(hoge[childs+2])
    
    for key, value in tree.items():
        for v in value:
            elems[v].append(key)
    for node in node_list:
        if not elems[node]:
            parents.append(node)
            elems[node].append(-1)
    
    for p in parents:
        search(p, elems, tree, 0)
        
    for key, value in sorted(elems.items()):
        print('node {0}: parent = {1[0]}, depth = {1[1]}, {1[2]}, '.format(key, value), end='')
        print (value[-1])


Measured memory_bytes: 51720
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}


signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    int x = a - b;
    cout << max((int)0, c - x) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int p[303];
int num[303];
bool off[303];
int n,m;
int a[303][303];
 
bool test(int bound)
{
	memset(p,0,sizeof(p));
	memset(num,0,sizeof(num));
	memset(off,0,sizeof(off));
	for (int i = 1; i<=n; i++)
	{
		p[i] = 1;
		num[a[i][1]]++;
	}
 
	for (int q = 0; q<m; q++)
	{
		int i;
		for (i = 1; i<=m; i++)
		{
			if (num[i]>bound)
			{
				break;
			}
		}
		if (i > m) return true;
		num[i] = 0;
		off[i] = true;
		for (int j = 1; j<=n; j++)
		{
			if (a[j][p[j]] == i)
			{
				while (off[a[j][p[j]]])
				{
					p[j]++;
					if (p[j]>m) return false;
				}
				num[a[j][p[j]]]++;
			}
		}
	}
	return true;
}
 
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i<=n; i++)
		for (int j = 1; j<=m; j++)
			scanf("%d", &a[i][j]);
	int l = 0; 
	int r = n;
	int mid;
	//printf("%d", test(2));
	while(l + 1 < r)
	{
		mid = (l+r)/2;
		if (test(mid))
		{
			r = mid;
		}
		else
		{
			l = mid;
		}
	}
	printf("%d", r);
 
}

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


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

    string n;
    cin >> n;
    if(n[0]=='9'||n[1]=='9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line1 = br.readLine();
		int n = Integer.parseInt(line1);
		int taro = 0;
		int hanako = 0;
		for (int i = 0; i<n ; i++ ) {
			String line = br.readLine();
			String[] str = line.split(" ");
			if (str[0].compareToIgnoreCase(str[1]) > 0) {
				taro = taro + 3;
			}else if (str[0].compareToIgnoreCase(str[1]) < 0){
				hanako = hanako + 3;
			}else{
				taro++;
				hanako++;
			}

		}
		System.out.println(taro + " " + hanako);
	}
}

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	int r = 1;
	for (int i = 0; i < n; i++)
	{
		r = min(r*2, r+k);
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<string>
using namespace std;
char c[105];
long long a[105];
int main() {
	long long sum = 0;
	long long res = 0;
	long long  m = 0, n;
	long long cnt = 0;
	char s;
	while (s = getchar()) {
		if (s == '\n')
			break;
		c[++m] = s;
	}
	cin >> n;
	if (m == 1) {
		cout << n / 2;
		return 0;
	}
	for (int i = 1; i < m; i++) {
		if (c[i] == c[i + 1]) {
			cnt++;
		}
		else
		{
			a[i - cnt] = cnt;
			cnt = 0;
		}
	}

	if (c[m] == c[m - 1]) {
		a[m - cnt] = cnt;
	}
	//for (int i = 1; i <= m; i++)
	//	cout << a[i] << endl;
	for (int i = 1; i <= m; i++) {
		if (a[i] != 0) {
			res += (a[i] + 1) / 2;

		}
	}
	if (a[m - cnt] + 1 == m) {
		cout << n * m / 2;
		return 0;
	}
	if (c[1] == c[m]) {
		if ((a[m - cnt] + 1) % 2 == 0) {
			cout << res * n;
			return 0;
		}
		else {
			if (a[1] % 2 == 1)
			{
				cout << res*n;
				return 0;
			}
			cout << (res + 1) * n - 1;
			return 0;
		}
	}
	cout << res * n;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int N;
	while (cin >> N)
	{
		int *a = new int[N];
		int num2 = 0;
		int num4 = 0;

		for (int i = 0; i < N; i++)
			cin >> a[i];
		for (int j = 0; j < N; j++)
			if (a[j] % 2 == 0 && a[j] % 4 != 0)
				num2++;
		for (int k = 0; k < N; k++)
			if (a[k] % 4 == 0)
				num4++;

		if (num4 == 0)
			if (num2 == N)
				cout << "Yes";
			else
				cout << "No";
		if (num4 != 0)
		{
			if (num2 != 0)
				if (num4 >= floor((N - num2 + 1) / 2.0))
					cout << "Yes";
				else
					cout << "No";
			else
				if (num4 >= floor(N / 2))
					cout << "Yes";
				else
					cout << "No";
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

constexpr int mod = 1000000007;
struct mint {
  long long x;
  constexpr mint(long long x = 0) : x((x % mod + mod) % mod) {}
  constexpr mint operator-() const { return mint(-x); }
  constexpr mint &operator+=(const mint &a) {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator-=(const mint &a) {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator*=(const mint &a) {
    (x *= a.x) %= mod;
    return *this;
  }
  constexpr mint operator+(const mint &a) const {
    mint res(*this);
    return res += a;
  }
  constexpr mint operator-(const mint &a) const {
    mint res(*this);
    return res -= a;
  }
  constexpr mint operator*(const mint &a) const {
    mint res(*this);
    return res *= a;
  }
  constexpr mint pow(long long t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  constexpr mint inv() const { return pow(mod - 2); }
  constexpr mint &operator/=(const mint &a) { return (*this) *= a.inv(); }
  constexpr mint operator/(const mint &a) const {
    mint res(*this);
    return res /= a;
  }
};
ostream &operator<<(ostream &os, const mint &m) {
  os << m.x;
  return os;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

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

  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, 0, n) cin >> a[i];
  sort(a.begin(), a.end());

  combination c(n + 5);

  mint ans = 0;
  rep(ri, 0, 2) {
    rep(i, 0, n) {
      mint now = c(i, k - 1);
      if (ri == 1)
        now = -now;
      ans += a[i] * now.x;
    }
    reverse(a.begin(), a.end());
  }

  cout << ans.x << endl;
}


Measured memory_bytes: 5252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	double ans = 0.0;
	rrep(i, n + 1) {
		int a = i;
		int cnt = 0;
		while (a < k) {
			a *= 2;
			cnt++;
		}
		ans += double(1 / pow(2, cnt));
	}
	ans /= double(n);
	cout << setprecision(12) << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 256
a = [int(input()) for _ in range(5)]
ans = 0
x = 0
for i in a:
    ans += i
    if i % 10 != 0:
        ans += 10 - ans % 10
        x = max(x, 10 - i % 10)
if x != 0:
    ans -= x
print(ans)

Measured memory_bytes: 3060
using System;
using System.Linq;
using static System.Math;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int L = int.Parse(input[1]);
        int[] apples = new int[N];
        int l = L;
        for (int i = 0; i < N; i++)
        {
            apples[i] = l;
            l++;
        }

        int eat = apples.Max();
        for(int i = 0; i < N; i++)
        {
            if(Abs(eat) > Abs(apples[i]))
            {
                eat = apples[i];
            }
        }
        int ans = 0;
        for(int i = 0; i < N; i++)
        {
            ans += apples[i];
        }
        Console.WriteLine(ans - eat);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	
	for(int i=0;i<=s.length();i+=2){
		if(s[i]=='L'){
			cout << "No"<<endl;
			return 0;
		}
	}
	for(int i=1;i<=s.length();i+=2){
		if(s[i]=='R'){
			cout << "No"<<endl;
			return 0;	
		}	
	}
	cout << "Yes"<<endl;
}

Measured memory_bytes: 384
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention

# C_Attention.py

N = int(input())
S = input()

e = [0 for i in range(N)]
w = [0 for i in range(N)]
d = [0 for i in range(N)]
#print("累積和")

for i in range(N):
    # そこからE側の人で、Wを向くべきなのにEを向いている人
    #if S[i] == "E":
    #    for j in range(0, i):
    #        e[j]+=1
    #        d[j]+=1
    # そこからW側の人で、Eを向くべきなのにWを向いている人
    if i > 0:
        w[i] += w[i-1]
    if i < N-1:
        if S[i] == "W":
            w[i+1] += 1
    if i > 0:
        e[N-1-i] += e[N-1-(i-1)]
    if i < N-1:
        if S[N-1-i] == "E":
            e[N-1-(i+1)] += 1

    #print("i:", i)
    #print("w:", w)
    #print("e:", e)
    #print("")

#w[0] = 0
#e[-1] = 0

#print("w:", w)
#print("e:", e)
min = 10 ** 6
for i in range(N):
    total = e[i] + w[i]
    if total < min:
        min = total
print(min)


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T = 1,n,m,k;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // cin >> T;
    while(T--){
        string s;
        cin >> s;
        n = s.size()-1;
        cout << s;
        if(s[n] == 's'){
            cout << "es";
        }
        else
            cout << "s";
        
    }

    return 0;
}


Measured memory_bytes: 3656
package main

import (
	"fmt"
	"strings"
)

func main() {
	var str string

	fmt.Scan(&str)

	flag := true

	idx := strings.Index(str[2:len(str)-1], "C")

	flag = flag && (str[0] == 'A')
	flag = flag && (idx != -1)

	for i := range str {
		if i == 0 || i == idx+2 {
			continue
		}

		if str[i:i+1] != strings.ToLower(str[i:i+1]) {
			flag = false
		}
	}

	if flag {
		fmt.Println("AC")
	} else {
		fmt.Println("WA")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int l;
    cin >> l;
    printf("%.15lf\n", pow(l/3.0, 3));
    return 0;
}

Measured memory_bytes: 384