akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int inf = 3e18;

struct edge{
	int to, cost, dist;
	edge(int to,int cost,int dist) : to(to), cost(cost), dist(dist) {}
};

using Data=pair<pii, int>;

const int OK = 3000;

int N, M, S;
int C[55], D[55];
vector<edge> G[55];
int dist[55][3005]; // dist[i][j] := 頂点i, 残り銀貨j枚

signed main()
{
	cin >> N >> M >> S;

	rep(i, M) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		--u, --v;
		G[u].PB(v, a, b);
		G[v].PB(u, a, b);
	}

	rep(i, N) {
		cin >> C[i] >> D[i];
		G[i].PB(i, -C[i], D[i]);
	}

	S = min(S, OK);

	rep(i, N) {
		rep(j, OK+1) dist[i][j] = inf;
	}

	dist[0][S] = 0;

	priority_queue<Data, vector<Data>, greater<Data>> pq;

	pq.push(Data(pii(0, -S), 0));

	while (pq.size()) {
		Data data = pq.top(); pq.pop();
		int d = data.first.first, s = -data.first.second;
		int cur = data.second;

		 if (d > dist[cur][s]) continue;

		for (edge &e : G[cur]) {
			if (s < e.cost) continue;

			int nxt = e.to;
			int nd = d + e.dist, ns = s - e.cost;

			if (s == OK or ns >= OK) ns = OK;

			if (dist[nxt][ns] > nd) {
				dist[nxt][ns] = nd;
				pq.push(Data(pii(nd, -ns), nxt));
			}
		}
	}


	for (int i = 1; i < N; ++i) {
		int mn = inf;
		rep(j, OK+1) {
			chmin(mn, dist[i][j]);
		}
		printf("%lld\n", mn);
	}
}



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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	vi v(1005);
	v[1] = 1;
	for(int i = 2 ; i < 1005 ; ++i) v[i] = v[i - 1] + i;
	int a , b;
	cin >> a >> b;
	
	for(int i = 1 ; i < 999 ; ++i){
		for(int j = 1 ; j < v[i] ; ++j){
			if(v[i] - j == a && v[i + 1] - j == b){
				cout << j << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 384
H,W=map(int,input().split())
Grid=[input() for i in range(H)]
dp=[[0]*W for i in range(H)]
dp[0][0]=1
mod=10**9+7
for i in range(H):
  for j in range(W):
    if Grid[i][j]==".":
      if i>=1:
        dp[i][j]+=dp[i-1][j]
      if j>=1:
        dp[i][j]+=dp[i][j-1]
      dp[i][j]%=mod
print(dp[H-1][W-1])

Measured memory_bytes: 53488
import math
n,d=map(int,input().split())
arr=[]
for _ in range(n):
	arr.append(list(map(int,input().split())))
def dist2(p,q):
  ans=0
  for i,j in zip(p,q):
    ans+=(i-j)**2
  return ans

ans=0
for i in range(n-1):
  for j in range(i+1,n): 
    d2=dist2(arr[i],arr[j])
    d=int(math.sqrt(d2)+1e-15)
    if d*d==d2: ans+=1
print(ans)    


Measured memory_bytes: 3064
import functools
import operator

n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(3**n):
    p=i
    c=[]
    for j in range(n):
        p,b=p//3,p%3
        if b == 0:
            c.append(a[j]-1)
        elif b==1:
            c.append(a[j])
        else:
            c.append(a[j]+1)
    x = functools.reduce(operator.mul, c)
    if x%2 == 0:
        ans += 1
print(ans)

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

using namespace std;

typedef pair<int,int> P;

struct edge
{
    int to,cost;
    edge(int _to=0,int _cost=0)
    {
        to=_to;cost=_cost;
    }
};

int n;
vector<edge> G[10010];

int d[10010];
const int INF=1e9+7;

void dijkstra(int s)
{
    fill(d,d+n,INF);

    d[s]=0;
    priority_queue<P,vector<P>,greater<P> > q;
    q.push(P(0,s));

    while(!q.empty())
    {
        P tmp=q.top();q.pop();
        int v=tmp.second;
        if(d[v]<tmp.first) continue;
        for(int i=0;i<G[v].size();i++)
        {
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost)
            {
                d[e.to]=d[v]+e.cost;
                q.push(P(d[e.to],e.to));
            }
        }
    }
}

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    while(cin>>n)
    {
        int a,b,c,dd;
        for(int i=0;i<n;i++)
        {
            G[i].clear();
            cin>>a>>b;
            for(int j=0;j<b;j++)
            {
                cin>>c>>dd;
                G[a].push_back(edge(c,dd));
            }
        }

        dijkstra(0);

        for(int i=0;i<n;i++)
        {
            cout<<i<<" "<<d[i]<<endl;
        }
    }



    return 0;
}



Measured memory_bytes: 8096
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-9;

bool foo(vector< vector<int> >& a, int x, int y) {
	a[x][y] = 1;
	for (int u = 0; u < 26; u++)
		for (int v = 0; v < 26; v++)
			a[u][v] |= a[u][x] & a[x][v];
	for (int u = 0; u < 26; u++)
		if (a[u][u]) return false;
	return true;
}

bool bar(string& s, string& t, vector< vector<int> >& a) {
	int S = s.length(), T = t.length();
	int i;
	for (i = 0; i < S && i < T && s[i] == t[i]; i++);
	if (i == S) return true;
	if (i == T) return false;
	return foo(a, s[i] - 'a', t[i] - 'a');
}

int main() {
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		vector<string> s(n);
		for (int j = 0; j < n; j++)
			cin >> s[j];
		vector< vector<int> > a(26, vector<int>(26));
		bool flag = true;
		for (int j = 0; j + 1 < n; j++) {
			if (!bar(s[j], s[j + 1], a)) {
				flag = false;
				break;
			}
		}
		cout << (flag ? "yes" : "no") << endl;
	}
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
#define ook order_of_key
#define fbo find_by_order

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}


const int shift=1000+10;
int c=0;
struct Fenwick{
     Tree<pii> tree[2*shift];
 
    int query(int i,int r){
        int sum=0;
        while(i){
           sum+=tree[i].ook({r+1,-1e18});
           i-=i&(-i);
       }  
       return sum;
    }
   
    void insert(int i,int y,int n=2000){
    	c++;	
       while(i<=n){
          tree[i].insert({y,c});
          i+=i&(-i);
       }
    }
};


int solve(){
 	int n;cin>>n;
 	vector<pii>a(n+1),b(n+1);
 	a[0]=b[0]={-1e9,-1e9};
 	Fenwick fn;
 	rep(i,1,n+1){
 		string s;cin>>s;
 		int t=0;
 		bool f=0;
 		int cnt=0;
 		for(auto i:s){
 			if(f)cnt++;
 			if(i=='.'){
 				f=1;continue;
 			}
 			t=t*10+(i-'0');
 		}
 		b[i]={cnt,cnt};
 		a[i]={-cnt,-cnt};
 		int z=t;
 		while(z%5==0){
 			z/=5;
 			a[i].x++;
 			b[i].x--;
 		}
 		while(z%2==0){
 			z/=2;
 			a[i].y++;
 			b[i].y--;
 		}
 		fn.insert(shift+b[i].x,shift+b[i].y);
 	}
 	int cnt=0;
 	for(int i=1;i<=n;i++){
 		 cnt+=fn.query(shift+a[i].x,shift+a[i].y);
 		 if(a[i].x>=b[i].x && a[i].y>=b[i].y)cnt--;
 	}cout<<cnt/2<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 59536
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long

int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n;
    cin >> n;
    int sum = 0;
    int ans = 0;
    for(int i = 1; i < inf; i++){
        sum += i;
        ans++;
        if(sum == n){
            cout << ans;
            break;
        }
        else if(sum > n){
            cout << ans;
            break;
        }
    }
}

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 R,G; cin >> R >> G;
    cout << 2*G-R << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define all(c) (c).begin(), (c).end()

//analyze testcases thoroughly before starting implementation

void solve () {
	string s;
	cin>>s;
	int n = s.length();
	if (s[n - 1] == 's') s += "es";
	else s += "s";
	cout<<s;	
}

int main() {
	fastIO;
	int t = 1; 
	//cin>>t;
	while (t--) {
		solve();
		cout<<'\n';
	}
	return 0;
}

/*
check for edge cases : n = 0, 1 etc
check for overflows and out of bounds
*/

Measured memory_bytes: 3660
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = read().rstrip().decode('utf-8')

MOD = 10**9 + 7

"""
・最後に使った数に対して、下側に残っている個数 -> 数え上げ
"""

dp = np.ones(N,np.int64) # 左端

for s in S:
    prev = dp
    if s == '<':
        # 0,1,...,nがdp[n]に遷移する
        dp = prev[:-1].cumsum()
    else:
        # n+1,n+2,...がdp[n]に遷移する
        dp = prev[1:][::-1].cumsum()[::-1]
    dp %= MOD

answer = dp[0]
print(answer)

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

int main()
{
  int a, b;
  cin >> a >> b;
  string s = to_string(b);
  int n = s.size();
  for(int i = 0; i < n; i++){
    a = a * 10;
  }
  for(int i = 0; i * i <= a + b; i++){
    if(i * i == a + b){
      cout << "Yes" << endl;
      return(0);
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n;cin>>n;
    vi v(n);rep(i,n)cin>>v[i];
    sort(all(v),greater<int>());
    int a=0,b=0;
    rep(i,v.size())if(i%2==0)a+=v[i];else b+=v[i];
    cout<<a-b<<endl;
}


Measured memory_bytes: 256
///
// File:  2700.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 26 02:25:16 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int32_t main()
{
  while (true) {
    uint32_t n;
    cin >> n;
    if (n == 0) break;

    uint32_t max_len = 0;
    vector<string> codes;
    for (uint32_t i = 0; i < n; i++) {
      string str;
      cin >> str;

      string code = "";
      for (uint32_t j = 0; j < str.size(); j++) {
        if (j == 0) {
          code += str[j];
        } else {
          char prev = str[j - 1];
          if (prev == 'a' || prev == 'i' || prev == 'u' || prev == 'e' || prev == 'o') {
            code += str[j];
          }
        }
      }
      codes.push_back(code);
      max_len = max(max_len, (uint32_t)code.size());
    }

    int32_t min_k = -1;
    for (uint32_t k = 1; k <= max_len; k++) {
      vector<string> codes2;
      for (uint32_t i = 0; i < codes.size(); i++) {
        string code = codes[i];
        if (code.size() < k) {
          codes2.push_back(code);
        } else {
          codes2.push_back(code.substr(0, k));
        }
      }

      bool is_same = false;
      for (uint32_t i = 0; i < codes2.size(); i++) {
        for (uint32_t j = i + 1; j < codes2.size(); j++) {
          if (codes2[i] == codes2[j]) {
            is_same = true;
            break;
          }
        }
      }

      if (!is_same) {
        min_k = k;
        break;
      }
    }
    cout << min_k << endl;
  }
  return 0;
}

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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
    
if((A+B)>(C+D)){
	cout<<"Left"<<endl;
}
  
  else if((A+B)==(C+D)){
  	cout<<"Balanced"<<endl;
  }

  else{
  cout<<"Right"<<endl;
  }

}

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

int main(){
  int a;
  int b=0;
  cin >> a;
  for(int i=0;i<3;i++){
    if(a%10==7){
      b=1;
      break;
    }
    a/=10;
  }
  if(b==1) cout << "Yes" << endl;
  else cout << "No" << endl;
  }

Measured memory_bytes: 3632
//started 17 minute late
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=2e3+5;
const int M=1e9+7;
void solve()
{
	string s;
	cin>>s;
	int i=0;
	int n=s.size();
	int ans=0;
	int res[n+1]={0};
	for(int i=0;i<n-1;i++)
	{
		if(s[i]=='R' && s[i+1]=='L')
		{
			int j=i,r=0,l=0;
			while(j>=0 && s[j]=='R')
			{
				r++;
				j--;
			}
			j=i+1;
			while(j<n && s[j]=='L')
			{
				j++;
				l++;
			}
			res[i]+=r/2;
			res[i+1]+=r/2;
			if(r%2) res[i]++;
			res[i]+=l/2;
			res[i+1]+=l/2;
			if(l%2) res[i+1]++;
			
		}
	}
	f(i,0,n-1)
	cout<<res[i]<<" ";
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}



Measured memory_bytes: 1488
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int X, Y, Z;
	cin >> X >> Y >> Z;

	swap(X, Y);
	swap(X, Z);

	cout << X << " " << Y << " " << Z << endl;

}






Measured memory_bytes: 3584
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n;
	static boolean[] Monday_Saturday = new boolean[300001];
	public static void main(String[] args){
		make();
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		n = sc.nextInt();
		if(n == 1)return false;
		
		return true;
	}
	
	static void solve(){
		System.out.print(n+":");
		for(int i = 2; i <= n; i++){
			if(Monday_Saturday[i] && (n % i) == 0){
				System.out.print(" "+i);
			}
		}
		System.out.println();
	}
	
	static void make(){
		Arrays.fill(Monday_Saturday, true);
		Monday_Saturday[0] = false;
		Monday_Saturday[1] = false;
		for(int i = 2; i < Monday_Saturday.length; i++){
			if(i % 7 != 1 && i % 7 != 6){
				Monday_Saturday[i] = false;
				continue;
			}
			for(int j = 2*i; j < Monday_Saturday.length; j += i){
				Monday_Saturday[j] = false;
			}
		}
	}
}

Measured memory_bytes: 13000
def main():
	import math
	N = int(input())
	n = math.ceil(math.log(100000000000, 4)) # toriaezu BIG ENOUGH na number
	M = int('10' * n, 2)
	B = format(N + M, 'b')
	print(even_toggle(B))

def even_toggle(b):
	r = []
	for i in range(len(b)):
		if i % 2 == 0:
			r.insert(0, b[-i-1])
		else:
			r.insert(0, str(1 - int(b[-i-1])))
	head_zeroes = 0
	for i in range(len(r)):
		if r[i] == "0":
			head_zeroes += 1
		else:
			break
	return "".join(r[head_zeroes:]) or "0"

main()

Measured memory_bytes: 9216
n, q = list(map(int, input().split()))
ss = []
for i in range(n):
    ss.append([])
    
for i in range(q):
    a = list(map(int, input().split()))
    k = a[0]
    if k == 0:
        ss[a[1]].append(a[2]) 
    if k == 1:
        if len(ss[a[1]]) != 0:
            print(ss[a[1]][-1])
        else:
            continue
    if k == 2:
        if len(ss[a[1]]) != 0:
            ss[a[1]].pop(-1)
        else:
            continue



Measured memory_bytes: 13700
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

int flag_dpl = 0;
int prevval;
int d[101];
int ds[500];
int x,n;
int ans = 1000;
int flag = 0;

int main(){
    cin >> x >> n;
    for(int i=0;i<n;i++){
        cin >> d[i] ;
    }
    if(n == 0){
        cout << x << endl;
        return 0;
    }
    int cnt = 0;
    for(int i=-100;i<=200;i++){
        flag = 0;
        for(int j=0;j<n;j++){
            if(d[j] == i) flag = 1;
        }
        if(flag == 0) ds[cnt++] = i;
        //cout << ds[cnt-1] << " " ;
    }
    int d=1000;
    int e,f;


    for(int i=0;i<cnt;i++){
        
        e = x - ds[i];
        if(e<0) e = -e;
        if(d > e) {
            d = e;
            ans = ds[i];
        }
    }
    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 3632
N,M = map(int,input().split())
wa_list= [0]*(N+2)
ac_list=[-1]*(N+2)
for i in range(M):
  p,a = map(str,input().split())
  p = int(p)
  if a =='WA':
    wa_list[p]+=1
  if a =='AC' and ac_list[p] == -1:
    ac_list[p]+=(wa_list[p]+1)
    

#print(ac_list)    
count = 0
count2 = 0
for i in ac_list:
  if i>=0:
    count+=1
    count2+=i
print(count,count2)
    

Measured memory_bytes: 10316
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 200010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
int n;
vector<int> A;
vector<char> op;
int f[2] = {1,-1};

int used[N][2][2],mem[N][2][2];

int dfs(int idx,int sgn,int open){
  if(idx == n) return 0;
  if(used[idx][sgn][open]++) return mem[idx][sgn][open];
  
  char ch = op[idx-1];
  int res = 0;
  int nsgn = ch == '-'? !sgn:sgn;
  int nopen = open || ch == '-';
  int val = f[nsgn] * A[idx];
  if(nopen == 1) Max(res,val + dfs(idx+1,!nsgn,!nopen));
  Max(res,val + dfs(idx+1,nsgn,nopen));
  return mem[idx][sgn][open] = res;
}


signed main(){
  cin>>n;
  A.resize(n);
  op.resize(n);
  for(int i=0;i<n;i++) {
    cin>>A[i];
    if(i!=n-1) cin>>op[i];
  }
  
  cout<<A[0] + dfs(1,0,0)<<endl;
  
  return 0;
}


Measured memory_bytes: 17152
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s,t;
    cin>>s>>t;

    int n=s.length();
    int m=t.length();

    vector<vector<int>> dp(n+1,vector<int>(m+1,0));

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j-1],max(dp[i-1][j],dp[i][j-1]));
            }
        }
    }

    string ans="";

    int i=n;
    int j=m;

    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]==dp[i][j])
            {
                i--;
            }   
            else if(dp[i][j-1]==dp[i][j])
            {
                j--;
            }
            else
            {
                i--;
                j--;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 38520
import java.util.Scanner;

public class Main {

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

        int a = sc.nextInt();
        int p = sc.nextInt() + a * 3;

        //        for (int i = 0; i < m; i++) {
        //
        //        }

        sc.close();

        System.out.println(p / 2);

    }
}

Measured memory_bytes: 22356
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n, k;
	cin >> n >> k;
	int ans = 0;
	REP(i, n)
	{
		int x;
		cin >> x;
		ans += min(abs(x), abs(x - k)) * 2;
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

int main() {
  int n;
  cin >> n;
  n = n % 10;
  string ans = "";
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    ans = "hon";
  } else if (n == 3) {
    ans = "bon";
  } else {
    ans = "pon";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
using ll = long long;

ll MOD = 1e9 + 7;

template <class T> inline ll powmod(T x, T n, T mod) {
  if(n == 0) {
    return 1;
  }
  if(n == 1) {
    return x;
  }
  if(n % 2 == 0) {
    auto xx = powmod(x, n / 2, mod);
    return ((xx % mod) * (xx % mod)) % mod;
  } else {
    auto xx = powmod(x, n - 1, mod);
    return ((xx % mod) * (x % mod)) % mod;
  }
}

ll combi(ll m, ll n, ll mod) {
  ll x = 1;
  ll y = 1;
  for(ll i = 0; i < n; ++i) {
    x = (x * (m - i)) % MOD;
    y = (y * (i + 1)) % MOD;
  }
  return (x * powmod(y, MOD - 2, MOD)) % MOD;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll all = (powmod(2LL, n, MOD) + MOD - 1) % MOD;
  all = (all - combi(n, a, MOD) + MOD) % MOD;
  all = (all - combi(n, b, MOD) + MOD) % MOD;
  cout << all << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import collections
import heapq

pi = 3.14159265359

a, b, h, m = list(map(int, input().split()))

hun = h*60+m

long_deg = ((360/60)*hun) % 360
short_deg = ((360/(12*60))*hun) % 360
diff = min(abs(long_deg - short_deg), 360-abs(long_deg - short_deg))
diff = np.deg2rad(diff)
ans = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(diff))
# (diff/360)
print(ans)


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

ans=[]
while(1):
    if N==0:
        break
    tmp=N%26
    if tmp==0:
        ans.append(26)
        N=N//26-1
    else:
        N//=26
        ans.append(tmp)
        
new_ans = list(reversed(ans))
ANS=""

for i in new_ans:
    ANS+=chr(96+int(i))
print(ANS)

Measured memory_bytes: 9128
#include<stdio.h>
#include<math.h>

int main() {
	unsigned int x;
	int a[33] = {0},b[33] = { 0 }, c[33] = { 0 }, i;

	scanf("%d", &x);

	for (i =0; x>0; i++) {
		a[i] = x % 2;
		x = x / 2;
	}

	for (i = 31; i >= 0; i--)printf("%d",a[i]);
	printf("\n");


	for(i = 31; i >= 0; i--) {
		if (a[i]==0)printf("1");
		else printf("0");
	}
	printf("\n");


	for (i = 31; i >= 0; i--) {
		b[i+1] = a[i];
	}
	for (i = 31; i >= 0; i--)printf("%d", b[i]);
	
	printf("\n");


	for (i = 31; i >= 0; i--) {
		c[i] = a[i+1];
	}
	for (i = 31; i >= 0; i--)printf("%d",c[i]);
	printf("\n");


	return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>
#include <math.h>

#define EPS 1e-8

int N;
int x[64], y[64];

double kyori(int i1, int i2) {
	return sqrt((x[i1] - x[i2]) * (double)(x[i1] - x[i2]) + (y[i1] - y[i2]) * (double)(y[i1] - y[i2]));
}

int asumikana(double cx, double cy, double r) {
	int i;
	for (i = 0; i < N; i++) {
		double d = (x[i] - cx) * (x[i] - cx) + (y[i] - cy) * (y[i] - cy);
		if (d > r * r + EPS) return 0;
	}
	return 1;
}

int main(void) {
	int i, j, k;
	double mimorinn = 1e+100;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &x[i], &y[i]) != 2) return 1;
	}
	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			double cx, cy, r;
			cx = (x[i] + x[j]) / 2.0;
			cy = (y[i] + y[j]) / 2.0;
			r = kyori(i, j) / 2.0;
			if (asumikana(cx, cy, r) && r < mimorinn) mimorinn = r;
			for (k = j + 1; k < N; k++) {
				double a = 2.0*x[i] - 2.0*x[j];
				double b = 2.0*y[i] - 2.0*y[j];
				double c = 2.0*x[j] - 2.0*x[k];
				double d = 2.0*y[j] - 2.0*y[k];
				double e = (double)x[i]*x[i] + (double)y[i]*y[i] - ((double)x[j]*x[j] + (double)y[j]*y[j]);
				double f = (double)x[j]*x[j] + (double)y[j]*y[j] - ((double)x[k]*x[k] + (double)y[k]*y[k]);
				double det = a*d - b*c;
				if (fabs(det) > EPS) {
					double cx = (d*e - b*f) / det;
					double cy = (-c*e + a*f) / det;
					double r = sqrt((x[i] - cx) * (x[i] - cx) + (y[i] - cy) * (y[i] - cy));
					if (asumikana(cx, cy, r) && r < mimorinn) mimorinn = r;
				}
			}
		}
	}
	printf("%.15f\n", mimorinn);
	return 0;
}

/*

(x - cx)^2 + (y - cy)^2 = r^2

x*x - 2*cx*x + cx*cx + y*y - 2*cy*y + cy*cy = r*r

2*x*cx + 2*y*cy + r*r = x*x + y*y + cx*cx + cy*cy

*/


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <cmath>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int n;
    cin >> n;
    vector<int> D(13, 0);
    REP(i, 0, n) {
        int d;
        cin >> d;
        D[d]++;
    }
    D[0]++;
    if (D[0] >= 2 || D[12] >= 2) {
        cout << 0 << endl;
        return 0;
    }
    REP(i, 1, 12) {
        if (D[i] >= 3) {
            cout << 0 << endl;
            return 0;
        }
    }
    vector<int> tm(24, 0);
    int ans = 0;
    function<void(int)> rec = [&](int pos) {
        if (pos == 13) {
            vector<int> tmp;
            REP(i, 0, 24) {
                REP(j, 0, tm[i]) {
                    tmp.push_back(i);
                }
            }
            sort(begin(tmp), end(tmp));
            int sz = tmp.size();
            int mn = 100;
            REP(i, 0, sz) {
                mn = min({mn, (tmp[(i + 1) % sz] + 24 - tmp[i]) % 24});
            }
            /*
            dump(mn);
            REP(l, 0, sz) {
                cout << tmp[l] << " \n"[l == sz - 1];
            }
            //*/
            ans = max(ans, mn);
            return;
        }
        if (D[pos] == 2) {
            tm[pos]++;
            tm[(24 - pos) % 24]++;
            rec(pos + 1);
            tm[pos]--;
            tm[(24 - pos) % 24]--;
        } else if (D[pos] == 1) {
            tm[pos]++;
            rec(pos + 1);
            tm[pos]--;
            tm[(24 - pos) % 24]++;
            rec(pos + 1);
            tm[(24 - pos) % 24]--;
        } else {
            rec(pos + 1);
        }
    };
    rec(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct UnionFind
{
  vector<int> Parent;
  UnionFind(int n):Parent(n,-1){}
  int Root(int y){return Parent.at(y)<0?y:Parent.at(y)=Root(Parent.at(y));}
  bool Unite(int x,int y)
  {
    if((x=Root(x))==(y=Root(y)))return true;
    else
    {
      if(-Parent.at(x)<-Parent.at(y))swap(x,y);
      Parent.at(x)+=Parent.at(y);
      Parent.at(y)=x;
      return false;
    }
  }
  int Size(int y){return -Parent.at(Root(y));}
};
int main()
{
  int a,b,c,d,N,M,K;
  cin>>N>>M>>K;
  UnionFind uf(N);
  vector<int> relation(N);
  for(int i=0;i<M;i++)
  {
    cin>>a>>b;
    a--,b--;
    uf.Unite(a,b);
    relation.at(a)++,relation.at(b)++;
  }
  for(int j=0;j<K;j++) 
  {
    cin>>c>>d;
    c--,d--;
    if(uf.Root(c)==uf.Root(d))relation.at(c)++,relation.at(d)++;
  }
  for(int i=0;i<N;i++)cout<<(uf.Size(i)-relation.at(i)-1)<<" ";
  return cout<<endl,0;
}

Measured memory_bytes: 1664
#高速に素因数分解するコード（
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
N = int(input())
L = factorization(N) 
#print(L)
counter = 0
for i in L:
    if i[0] != 1:
        counter += (-1+(1+8*i[1])**0.5)//2
print(int(counter))

Measured memory_bytes: 9484
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
	cout<<-(a*60+b)+(c*60+d)-e<<endl;
}


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

  int N ;
  cin >> N ;
  string S ;
  cin >> S ;
  int count = 0 ;
  rep(i,N-2){
   if(S[i]== 'A' && S[i+1]== 'B' && S[i+2]== 'C' ) count++ ;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    vector<int64_t> v(S.size()+1,0);
    rep(i,1,S.size()+1){    //i=1,2,3,...,S.size()
        char s=S.at(i-1);
        if(s=='<') v.at(i)=max(v.at(i),v.at(i-1)+1);
    }

    _rep(i,S.size()-1,0){   //i=S.size()-1,S.size()-2,...,2,1,0
        char s=S.at(i);
        if(s=='>') v.at(i)=max(v.at(i),v.at(i+1)+1);
    }

    int64_t ans=0;
    rep(i,0,v.size()) ans+=v.at(i);
    cout<<ans<<endl;
}

Measured memory_bytes: 4740
N = int(input())
L =[]
count = 0
for i in range(N):
    Str = str(input())
    L.append(Str)

for i in range(N):
    for k in range(N):
        if L[i] == L[k] and i != k:
            count += 1
            break

for i in range(N):
        if i < N-1:
            if L[i][len(L[i])-1] != L[i+1][0]:
                count += 1


if count > 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp89 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int M = st[1];

            var X = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Array.Sort(X);

            //Console.WriteLine(string.Join(" ", X));

            //隣の座標との差
            var D = new int[M - 1];
            for (int i = 0; i + 1 < M; i++) {
                D[i] = X[i + 1] - X[i];
            }

            int maxValue = X[M - 1] - X[0];

            //Console.WriteLine(maxValue);

            Console.WriteLine(maxValue - D.OrderByDescending(x => x).Take(N - 1).Sum());



        }

    }
}


Measured memory_bytes: 21216
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

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

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

    int c[3][3];

    FOR(i, 0, 3){
        FOR(j, 0, 3){
            cin >> c[i][j];
        }
    }

    int a1 = 0;
    
    int b1 = c[0][0] - a1;
    int b2 = c[1][0] - a1;
    int b3 = c[2][0] - a1;
    
    int a2 = c[0][1] - b1;
    int a3 = c[0][2] - b1;

    // check
    bool isRight = true;
    
    if(c[0][0] != a1 + b1) isRight = false;
    if(c[0][1] != a2 + b1) isRight = false;
    if(c[0][2] != a3 + b1) isRight = false;
    
    if(c[1][0] != a1 + b2) isRight = false;
    if(c[1][1] != a2 + b2) isRight = false;
    if(c[1][2] != a3 + b2) isRight = false;
    
    if(c[2][0] != a1 + b3) isRight = false;
    if(c[2][1] != a2 + b3) isRight = false;
    if(c[2][2] != a3 + b3) isRight = false;

    if(isRight){
        p("Yes");
    }else{
        p("No");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int c = max(a, b);
  if(abs(a-b) >= 2) cout << c + (c-1) << endl;
  else cout << a + b << endl;
}

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

using namespace std;

char str[N];
bool ok;

int main()
{
    scanf("%s",str);
    int len=strlen(str);
    int i;
    ok=true;
    for(i=0;i<len-2;i++)
    {
        if(str[i]!=str[i+2])ok=false;
    }
    if(!ok)
    {
        if(str[0]==str[len-1])--len;
        if(len%2==1)ok=false;
        else ok=true;
    }
    if(!ok)printf("First\n");
    else printf("Second\n");
}


Measured memory_bytes: 384
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    N = len(S)
    for i in range(N // 2):
        if S[i] != S[N - i - 1]:
            print(NO)
            return NO
    m = N // 2
    for i in range(m // 2):
        if S[i] != S[m - i - 1]:
            print(NO)
            return NO

    print(YES)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<iostream>

int main(){
	int p[8], c[8] = {012121414, 014121214,
										012141412, 014141212,
										021214141, 041212141,
										021414121, 041412121};
	while(std::cin >> p[0], !std::cin.eof()){
		for(int i=1;i<8;i++){
			std::cin >> p[i];
		}

		int pos = 0, max_n = 0;
		for(int i=0;i<8;i++){
			int _n = 0;
			for(int j=0;j<8;j++){
				_n += (p[j]>(c[i]>>3*j&07))?(c[i]>>3*j&07):p[j];
			}
			if(_n >= max_n){
				pos = i;
				max_n = _n;
			}
		}

		for(int i=0;i<8;i++){
			std::cout << (c[pos]>>3*i&07);
			if(i < 7)std::cout << " ";
		}
		std::cout << "\n";
	}
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

string s;

int main(){
	cin >> s;
	int c = 0, ans = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'T'){
			c++;
		}
		else c--;
		ans = max(ans, c);
	}
	cout << 2 * ans << endl;
	
	return 0;
}

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

int main() {
	string s, p;
	cin >> s >> p;
	s += s;
	if (s.find(p) != -1) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,str;
    cin>>s>>str;
    int n=s.size();
    int f=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=str[i])
        {
            f=1;
            break;
        }
    }
    if(f==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3620
N,M=map(int,input().split())
P=[]
for i in range(M):
  P.append(list(map(int,input().split())))
  P[i].append(i)
S_P = sorted(
  P,
  key = lambda x: (x[0], x[1])
)
T=0
BT=S_P[0][0]
ANS=[]
for p in S_P:
  if BT != p[0]:
    BT=p[0]
    T=1
  else:
    T+=1
  ANS.append([p[2], '{:0=6}{:0=6}'.format(BT,T)])
  
A = sorted(
  ANS,
  key = lambda x: x[0]
)
for ans in A:
  print(ans[1])
       

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

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        cin>>H[i];
    }
    int Max_h=-1;
    int count=0;
    for(int i=0;i<N;i++){
        if(Max_h<=H[i]){
            count++;
            Max_h=H[i];
        }
    }
    cout<<count<<endl;
    return 0;
}


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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

  ll n;
  string s;
  cin >> n >> s;

  vll v(n + 1);
  rep(i, n) {
    v[i + 1] = v[i];
    if (s[i] == '(') {
      v[i + 1]++;
    } else {
      v[i + 1]--;
    }
  }

  ll shortage = abs(*min_element(all(v)));
  rep(i, shortage) {
    cout << "(";
  }
  cout << s;
  rep(i, v[n] + shortage) {
    cout << ")";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

int main()
{
    ll n;
    int cnt;
    map<string, int> m;
    cin >> n;
    string str;
    vector<string> s;
    for (ll i = 0; i < n; i++)
    {
        cnt = 0;
        cin >> str;
        m[str] = 1;
    }

    cout << m.size() << endl;
    return 0;
}


Measured memory_bytes: 19200
#揃える長さを決め打って二分探索
import sys
import math
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))
lst1.sort(reverse=True)
def func(mid): #ここが関数部分
    res = 0
    for i in range(n):
        if mid >= lst1[i]:
            continue
        res += math.ceil(lst1[i]/mid)-1
        if res > k:
            return False
    return True


def binary_search(): #2分探索
    ok = 10**9
    ng = 0
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if func(mid):
            ok = mid
        else:
            ng = mid

    return ok

print(binary_search())

Measured memory_bytes: 92696
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector <int> A(100000);
  vector <int> B(100000);
  for(int i = 1;i<N+1;i++){
    cin >> A[i];
    B[A[i]] = i; 
  }
  for(int j = 1;j<N+1;j++){
    cout << B[j] << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
n = int(input())
s = input()
ans = 0
for i in range(1000):
  a = [i//100, (i//10)%10, i%10]
  cnt = 0
  for j in range(n):
    if cnt <= 2 and a[cnt] == int(s[j]): cnt+=1
  if cnt == 3: ans += 1
print(ans)

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

bool is_prime(int x){
    if(x<=1) return false;
    for(int i=2;i*i<=x;i++){
        if(x%i==0) return false;
    }
    return true;
}

int main(){
    int x;cin>>x;
    int p=x;
    while(!is_prime(p)) p++;

    cout<<p<<endl;
    return 0;
}

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

int main(){
  int n,k;
  cin >>n >>k;
  vector<int> h(n);
  rep(i,n) cin >>h[i];
  int ans = 10000000100;
  sort(h.begin(), h.end());
  for(int i = 0; i<n-k+1; i++){
    int curans = h[i+k-1]-h[i];
    ans = min(ans, curans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
/**
     **author : _KMS_
     **created : 14-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+100,MOD=2e9;
typedef long long ll;
int arr[M];
ll way;
int main() 
{ 
      
 ios::sync_with_stdio(false);
 cin.tie(0);
 int n,m;
 cin>>n;
 for(int i=0;i<n;i++)cin>>arr[i];
 sort(arr,arr+n);
 for(int i=n-1;i>=1;i--)
 {
       int l=0,r=i-1;
       while(l<r)
       {
             if(arr[i]<arr[l]+arr[r])
             {
                   way+=(ll)(r-l);
                   r--;
             }
             else
             l++;
       }
 }
 cout<<way<<"\n";

 
	return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
int n;
int a[1000],b[1000],c[1000],x[1000];
int main(){
    cin>>n;ll sum=0;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int j=1;j<=n;j++)
        {cin>>b[j];sum+=b[j];}
    for(int i=1;i<n;i++)
    {
        cin>>c[i];
    }
    
    for(int i=1;i<=n;i++){
        if(a[i]==a[i-1]+1)
            sum+=c[a[i]-1];
    }
    cout<<sum;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int grid[5][105],cum[5][105] = {0};

int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=2; i++){
        for(int j=1; j<=n; j++){
            cin>>grid[i][j];
            cum[i][j] = cum[i][j-1] + grid[i][j];
        }
    }
    int ans = 0;
    for(int i=1; i<=n; i++){
        int tem = cum[1][i] + (cum[2][n]-cum[2][i-1]);
        ans = max(ans,tem);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<vi> vii;
const int mxN=2e5+5,M=1e9+7;
const int LINF = 0x3f3f3f3f3f3f3f3f;
//did u check when n=1?
//is mxN correct?

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        if(x%2==0){
            if(x%3!=0 && x%5!=0){
                cout<<"DENIED";
                return 0;
            }
        }
    }
    cout<<"APPROVED";
    
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}

bool equal(string s){
	if(s.length()==0){
		return false;
	}
	for(int i=1;i<s.length();i++){
		if(s[i]!=s[i-1]){
			return false;
		}
	}
	return true;
}
int main(){
  fastIO();
  string s;
  cin>>s;
  int best = INT_MAX;
  if(equal(s)){
  	cout<<0<<endl;
  	return 0;
  }
  for(int i=1;i<s.length();i++){
  	string temp = s;
  	string temp2 = "";
  	int ope = 0;
  	while(!equal(temp2)){
  		temp2="";
  		for(int j=1;j<temp.length();j++){
  			if(temp[j-1]==s[i]){
  				temp2+=temp[j-1];
  			}else if(temp[j]==s[i]){
  				temp2+=temp[j];
  			}else{
  				temp2+=temp[j];
  			}
  		}
  		ope++;
  		temp=temp2;
  		if(ope>=1e4){
  			break;
  		}
  	}
  	best=min(best,ope);
  }
  cout<<best<<endl;
}  


Measured memory_bytes: 256