akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef vector<double> vd;
typedef vector<vd> vvd;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		vector<pii> data(n);
		rep(i, n){
			scanf("%d", &data[i].second);
			
			int point = 0;
			int remain[10] = {0};
			rep(j, 10){
				int pin = 0;
				int roop = 2;
				for(int cnt=0 ; cnt<roop; ++cnt){
					int p;
					scanf("%d", &p);
					rep(k, j){
						if(remain[k]){
							--remain[k];
							point += p;
						}
					}
					pin += p;
					if(pin == 10){
						if(j < 9){
							remain[j] = 2 - cnt;
							break;
						}
						else
							roop = 3;
					}
				}

				point += pin;
			}
			data[i].first = -point;
		}
		
		sort(data.begin(), data.end());
		rep(i, n){
			printf("%d %d\n", data[i].second, -data[i].first);
		}
	}

	return 0;
}

Measured memory_bytes: 0
from collections import deque
N,E=map(int,input().split())
G=[[] for i in range(N)]
In=[0]*N
for i in range(E):
    s,t=map(int,input().split())
    G[s].append(t)
    In[t]+=1
S=deque([i for i in range(N) if In[i]==0])
res=[]
while S:
    b=S.popleft()
    for nv in G[b]:
        In[nv]-=1
        if(In[nv]==0):
            S.append(nv)
    res.append(b)
print(*res,sep='\n')


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] curtain = Console.ReadLine().Split(' ');
           
            int a= int.Parse(curtain[0]);           //A窓の横の長さ
            int b = int.Parse(curtain[1]);          //Bカーテンの長さ
            int ans = a - (b * 2);

            if (ans > 0)
            {
                Console.WriteLine(ans);

            }
            else if (ans <=0)
            {
                Console.WriteLine(0);
            }
        
            }

        }
    }


Measured memory_bytes: 13140
// Grid 1
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define times(t) int t; cin >> t; while(t--)
#define mod 1000000007

int h, w;
char arr[1003][1003];
int dp[1003][1003], vis[1003][1003];

int dfs(int r, int c) {
	if(r>=h or c>=w) return 0;
	if(arr[r][c] == '#') return 0;
	if(vis[r][c]) return dp[r][c];
	if(r==h-1 and c==w-1) return 1;
	vis[r][c] = 1;
	return dp[r][c] = (dfs(r+1, c) + dfs(r, c+1))%mod;
}

void solve() {
	cin >> h >> w;
	for(int i=0; i<h; i++) {
		for(int j=0; j<w; j++) {
			cin >> arr[i][j];
		}
	}
	cout << dfs(0, 0) << endl;
	return;
}

int main() {
	IOS;
	// #ifndef ONLINE_JUDGE
	// freopen("C:/Gen code/CompProg/input.txt", "r", stdin);
	// freopen("C:/Gen code/CompProg/output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}

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

int main(){

  int inning_num;
  char inning_data[7];
  int i,j;
  int runner[3] = {0,0,0};
  int sum = 0;
  int out_count = 0;

  scanf( "%d",&inning_num );

  for( i=0;i<inning_num;i++ ){

  for( j=0;j<3;j++ ){
    runner[j] = 0;
  }
  out_count = 0;

    while( out_count<3 ){

      scanf( "%s",inning_data );

      if( strcmp(inning_data,"HIT") == 0){

        if( runner[2] == 1 ){
          sum++;
          runner[2] = 0;
        }

        if( runner[1] == 1 ){
          runner[1] = 0;
          runner[2] = 1;
        }

        if( runner[0] == 1 ){
          runner[0] == 0;
          runner[1] = 1;
        }

        runner[0] = 1;

      }

      else if( strcmp(inning_data,"HOMERUN") == 0 ){
        sum++;
        for( j=0;j<3;j++ ){
          if( runner[j] == 1 ){
            sum++;
            runner[j] = 0;
          }
        }
      }

      else{
        out_count++;
      }

    }

    printf("%d\n",sum);
    sum = 0;

  }

  return 0;

}

Measured memory_bytes: 596
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int yon = 0;
    int ni = 0;
    for(int i = 0 ; i < n ; ++i){
      int num = sc.nextInt();
      if(num%4 == 0) yon++;
      else if(num%2 == 0) ni++;
    }
    
    if(yon >= n/2 || ni == n-2*yon) System.out.println("Yes");
    else System.out.println("No");
 
  }
}


Measured memory_bytes: 58860
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
vector<int>v;
char in[110000];
int ans[110000];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	for(int i=0;i<n-1;i++){
		if(in[i]=='R'&&in[i+1]=='L'){
			v.push_back(i+1);
		}
	}
	for(int i=0;i<n;i++){
		if(in[i]=='R'){
			int at=v[lower_bound(v.begin(),v.end(),i)-v.begin()];
			int to=at;
			if((at-i)%2==1)to=at-1;
			ans[to]++;
		}else{
			int at=v[upper_bound(v.begin(),v.end(),i)-1-v.begin()];
			int to=at-1;
			if((i-at+1)%2==1)to=at;
			ans[to]++;
		}
	}
	for(int i=0;i<n;i++){
		if(i)printf(" ");printf("%d",ans[i]);
	}printf("\n");
}


Measured memory_bytes: 1276
N,K=map(int,input().split())
ans=0
B=[]
for i in range(N):
  k=i+1
  c=0
  while k<K:
    k*=2
    c+=1
  B.append(N*(2**c))
for i in range(len(B)):
  ans+=1/B[i]
print(ans)

Measured memory_bytes: 7064
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  // ll n, t, a, h;
  double n, t, a, h;
  double maybe = INF;
  int ans, i;
  scanf("%lf%lf%lf", &n, &t, &a);

  for (i = 0; i < n; i++)
  {
    scanf("%lf", &h);
    h = t - h * 0.006;
    if (maybe > fabs(a - h))
    {
      maybe = fabs(a - h);
      ans = i + 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
/*input

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
  	int a,b;cin >> a >> b;
  	cout << a*b;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define LiangJiaJun main
#define ll long long
#define INF 1999122700
using namespace std;
int ne,h[100004],n,m;
struct edge{
    int to,nt;
}e[200004];
void add(int u,int v){
     e[++ne].to=v;e[ne].nt=h[u];
     h[u]=ne;
}
int dis[100004];
int dfs(int x){
    if(dis[x])return dis[x];
    for(int i=h[x];i;i=e[i].nt){
        dis[x]=max(dis[x],dfs(e[i].to)+1);
    }
    return dis[x];
}
int w33ha(){
    ne=0;
    memset(h,0,sizeof(h));
    memset(dis,0,sizeof(dis));
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
    }
    int ans=0;
    for(int i=1;i<=n;i++)ans=max(ans,dfs(i));
    printf("%d\n",ans);
    return 0;
}
int LiangJiaJun(){
    while(scanf("%d%d",&n,&m)!=EOF)w33ha();
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=998244353;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,m;cin>>n>>m;
    string s;cin>>s;
    vb done(n,false);
    vvi g(n);
    vp c(n);
    rep(i,m){
        ll a,b;cin>>a>>b;a--;b--;
        g[a].pb(b);
        g[b].pb(a);
        if(s[a]!=s[b]){
            c[a].fi++;c[b].fi++;
        }
        else{
            c[a].se++;c[b].se++;
        }
    }
    queue<ll> q;
    rep(i,n)if(!(c[i].fi&&c[i].se)){
        done[i]=true;
        q.push(i);
    }
    while(!q.empty()){
        auto t=q.front();q.pop();
        for(auto x:g[t]){
            if(done[x])continue;
            if(s[t]!=s[x])c[x].fi--;
            else c[x].se--;
            if(!(c[x].fi&&c[x].se)){
                done[x]=true;
                q.push(x);
            }
        }
    }
    rep(i,n)if(!done[i])dame("Yes");
    out("No");
}

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

#define ll long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

int main()
{
	ios::sync_with_stdio(0);
	int i, j, k, n;

	ll a, b_dash;
	long double b;
	cin >> a >> b;
	b_dash = b * 100.0 + 0.5;

	cout << ((a * b_dash) / 100) << "\n";

	return 0;
}

Measured memory_bytes: 3660
H,W,A,B = map(int,input().split())
C = [["0" for _ in range(W)] for _ in range(H)]
for i in range(H-B):
    for j in range(A,W):
        C[i][j] = "1"
for i in range(H-B,H):
    for j in range(A):
        C[i][j] = "1"
for i in range(H):
    print("".join(C[i]))

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

int main(){
	int n,a[100];
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int j=n-1;j>0;j--) cout<<a[j]<<' ';
	cout<<a[0]<<endl;
	return 0;
}

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

double jijo(double a){
	return a*a;
}
int main(){
	int n;
	double x1, y1, x2, y2, x3, y3;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
		double a1, a2, b1, b2;
		if(y1==y2){y1+=0.0000001;}
		a1 = (x2-x1)/(y1-y2);
		b1 = (y1+y2)/2.0 - a1*(x1+x2)/2.0;
		if(y1==y3){y1+=0.0000001;}
		a2 = (x3-x1)/(y1-y3);
		b2 = (y1+y3)/2.0 - a2*(x1+x3)/2.0;
		double x, y, d;
		x = (b2-b1)/(a1-a2);
		y = a1*x + b1;
		d = sqrt(jijo(x1-x) + jijo(y1-y));
		printf("%.3lf %.3lf %.3lf\n", x, y, d);
	}
	return 0;
}

Measured memory_bytes: 1092
s = input()
option_1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option_2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 += 1
print(min(ans_1, ans_2))

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n;
  cin>>n;
  int r=0,b=0;
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    if(c=='R')r++;
    else b++;
  }
  if(r>b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

int a[100005],ma;

int main()
{
    int n;
    cin>>n;
    for (int i=1;i<=n;i++)
        {
            cin>>a[i];
            if (a[i]>ma)
                ma=a[i];
        }
    int ha=ma/2;
    int curr=0;
    for (int i=1;i<=n;i++)
    {
        if (abs(ha-a[i])<abs(ha-curr))
        curr=a[i];
    }
    cout<<ma<<" "<<curr;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

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

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

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

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

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


int main() {
    int par_road[200010];
    int par_rail[200010];
    int sz_road[200010], sz_rail[200010];

    int N, K, L;
    cin >> N >> K >> L;
    init(par_road, sz_road, N);
    init(par_rail, sz_rail, N);

    int *p = new int[K], *q = new int[K], *r = new int[L], *s = new int[L];
    for (int i = 0; i < K; i++)
        cin >> p[i] >> q[i];
    for (int i = 0; i < L; i++)
        cin >> r[i] >> s[i];

    for (int i = 0; i < K; i++)
        unite(par_road, sz_road, p[i]-1, q[i]-1);
    for (int i = 0; i < L; i++)
        unite(par_rail, sz_rail, r[i]-1, s[i]-1);
    
    int *ans = new int[N];
    vector<pair<pair<int,int>,int> > tmp(N);
    for (int i = 0; i < N; i++) {
        tmp[i].first.first = find(par_road, i);
        tmp[i].first.second = find(par_rail, i);
        tmp[i].second = i;
    }
    sort(tmp.begin(), tmp.end());

    for (int i = 0; i < N;) {
        int j = i;
        while (j < N && tmp[i].first.first == tmp[j].first.first && tmp[i].first.second == tmp[j].first.second)
            j++;
        for (int k = i; k < j; k++) {
            ans[tmp[k].second] = j-i;
        }
        i = j;
    }

    for (int i = 0; i < N; i++)
        cout << ans[i] << " ";
    cout << endl;

    return 0;

}

Measured memory_bytes: 8448
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

int find_(int x,vector<int> &v){
    if(v[x]<0) return x;
    v[x]=find_(v[x],v);
    return v[x];
}

int same_(int a,int b,vector<int> &v){
    if(find_(a,v)==find_(b,v)) return 1;
    return 0;
}

void union_(int a,int b,vector<int> &v){
    if(same_(a,b,v)) return;
    int a_p=find_(a,v),b_p=find_(b,v);
    if(a_p>b_p) swap(a_p,b_p);
    v[a_p]+=v[b_p]; v[b_p]=a_p;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,m; cin>>n>>m;
    vector<int> p(n,0);
    vector<int> v(n,-1);
    rep(i,n){
        int q; cin>>q;
        p[i]=q-1;
    }
    rep(i,m){
        int x,y; cin>>x>>y;
        x--; y--;
        union_(x,y,v);
    }
    int ans=0;
    rep(i,n){
        if(same_(p[i],i,v)) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector <int> s(m,0);
    vector <int> c(m,0);
    for(int i = 0; i < m; i++){
        cin >> s[i] >> c[i];
    }
    #if 0
    cout << n << " " << m << endl;
    for(int i = 0; i < m; i++){
        cout << s[i] << " " << c[i] << endl;
    }
    #endif

    vector <int> digit(n,-1);
    for(int j = 0; j < n; j++){
        int oldDigit = -1;
        for( int i = 0; i <m; i++){
            if(s[i]==(j+1)){
                if (oldDigit==-1){
                    oldDigit=c[i];
                    digit[n-1-j]=c[i];
                }else{
                    if(oldDigit==c[i]){
                    }else{
                        cout << -1 << endl;
                        return 0;
                    }
                }
            }
        }
    }
    #if 0
    for(int i = 0; i< digit.size(); i++){
        cout << digit[i] << " ";
    }
    cout << endl;
    #endif
    int value = 0;
    if(digit[n-1]==0){
        if(n==1){
            cout << 0 <<endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(digit[n-1]==-1){
        if(n==1){
            digit[n-1]=0;
        }else{
            digit[n-1]=1;
        }
    }
    for(int i = 0; i < n ; i++){
        if(digit[i]!=-1){
            value += digit[i]*pow(10,i);
            // cout << "i "<< i << " ";
            // cout << digit[i] << endl;
        }
    }
    //cout << value << endl;
    //cout << pow(10,n-1) << endl;
    // if(value<pow(10,n-1)){
    //     cout << -1 << endl;
    //     return 0;
    // }
    cout << value << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
int const MAXN = 2e5+5;
vector<int> adj[MAXN];
bool visited[MAXN];
ll cnt[MAXN],ans[MAXN];

void dfs(int u,ll sum){
	if(visited[u]) return;
	visited[u] = true;
	ans[u] = sum + cnt[u];
	for(auto v : adj[u]){
		dfs(v,ans[u]);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	memset(visited,false,sizeof(visited));
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<q;i++){
		int p,x;
		cin>>p>>x;
		cnt[p]+=x;
	}
	dfs(1,0ll);
	for(int i=1;i<=n;i++){
		cout<<ans[i];
		if(i < n) cout<<" ";
		else cout<<"\n";
	}
	return 0;
}

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

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

    bool isSeven = false;

    for (int i=0; i < 3; ++i) {
        if (s.at(i) == '7') {
            isSeven = true;
        }
    }

    if (isSeven) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main()
{
	int n, m;
	int a, b;
	int l=0, r;

	scanf("%d %d", &n, &m);
	r = n;

	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a, &b);
		if (l < a)
			l = a;
		if (r > b)
			r = b;
	}

	if (l > r) {
		l = 1;
		r = 0;
	}

	l--;

	printf("%d\n", r - l);

	return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string X;
  cin >> X;
  int N = X.size();
  
  int ans = N;
  int S = 0, T = 0;
  for (int i = 0; i < N; i++)
  {
    if (X.at(i) == 'S') S++;
    else 
    {
      T++;
      if (S >= 1) {S--; T--; ans -= 2;}
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define S second
#define F first
#define ld I64d
#include <cstdio>
#ifdef DEBUG
    #define D(X) X
#else
    #define D(X)
#endif
#define mehh ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(v) (int)v.size()
#define loop(i, v) for (int i = 0; i < sz(v); ++i)
#define PrimeRange(n) (n / log(n))
#define NumOfDigits(n) 1 + (int)log10(n)

using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int N = 2e4, M = 1e6+6, OO = 0x3f3f3f3f;
using namespace std ;

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

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

int main(){
    mehh
    ll n;
    cin >> n;
    ll monsters[n + 1], heros[n];
    for (int i = 0; i <= n; ++i) cin >> monsters[i];
    for (int i = 0; i < n; ++i) cin >> heros[i];
    ll defeat = 0;
    for (int i = 0; i < n; ++i){
        defeat += min(heros[i], monsters[i]);
        heros[i] -= min(heros[i], monsters[i]);
        defeat += min(heros[i], monsters[i + 1]);
        monsters[i + 1] -= min(heros[i], monsters[i + 1]);
    }
    cout << defeat;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N; cin>>N;
	int sum = 0;
	int nax = 0;
	REP(i,N){
		sum += i;
		if(sum>=N){nax = i; break;}
	}
	int ex = sum-N;
	REP(i,nax){
		if(i==ex)continue;
		cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    for(int i = 0; i < M; ++i){
        int s, t;
        cin >> s >> t;
        --s, --t;
        graph[s].emplace_back(t);
    }

    vector<double> dp(N, -1);
    dp[N - 1] = 0;
    auto MemoRec = [&](auto&& self, int from = 0) -> double {
        if(dp[from] != -1)  return dp[from];
        double res = 0;
        int cnt = 0;
        for(int to : graph[from]){
            ++cnt;
            res += self(self, to);
        }
        return dp[from] = res / cnt + 1;
    };
    double ans = MemoRec(MemoRec);

    for(int u = 0; u < N - 1; ++u){
        if(graph[u].size() == 1)    continue;
        double max_val = 0;
        int ban = -1;
        for(int v : graph[u]){
            if(chmax(max_val, dp[v]))   ban = v;
        }
        vector<double> dp2(N, -1);
        dp2[N - 1] = 0;
        auto MemoRec2 = [&](auto&& self, int from = 0) -> double {
            if(dp2[from] != -1) return dp2[from];
            double res = 0;
            int cnt = 0;
            for(int to : graph[from]){
                if(from == u && to == ban)  continue;
                ++cnt;
                res += self(self, to);
            }
            return dp2[from] = res / cnt + 1;
        };
        chmin(ans, MemoRec2(MemoRec2));
    }

    cout << fixed << setprecision(15);
    cout << ans << endl;
}

Measured memory_bytes: 4716
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <iomanip>
#include <queue>
#include <deque>
#include <sstream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <map>
#include <utility>
using namespace std;

#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",&n)
#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795


int main() {
	int n;
	cin >> n;
	int min = 10000;
	int max = 0;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if(x < min) {
			min = x;
		}
		if(x > max) {
			max = x;
		}
	}
	cout << max-min;
	return 0;
}



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

int main() {
    int ans = 0;
    string s;
    cin >> s;
    vector<char> data(s.size());
    for (int i = 0; i < s.size(); i++) {
        data.at(i) = s.at(i);
    }
    bool finished = false;
    for (int now = 0; now < s.size(); now++) {
        for (int i = 0; i < s.size(); i++) {
            if (now == i) {
                continue;
            }
            if (data.at(now) == data.at(i)) {
                ans = 1;
                finished = true;
                break;    
            }
        }
        if (finished) {
            break;
        }
    }
    if (ans == 1) {
        cout << "no" << endl;
    }
    else {
        cout << "yes" << endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (c - (a - b) <= 0) {
    cout << 0;
  } else {
    cout << c - (a - b);
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
    int N;
    cin >> N;
    int ans=0;
    for(int i=1; i<=N; i=i+2){
        int cnt=0;
        for(int j=1; j<=i; j++){
            if(0 == i%j)cnt++;
        }
        if(8 == cnt)ans++;
    }
    cout << ans << endl;

}

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

string inttostr(int in){
	string output="";
	char a;
	do{
		a=in%10+'0';
		output=a+output;
		in=in/10;
	}while(in>=1);
	return output;
}
		

string cvt(string data){
	string output="";
	char read,before;
	int c=1,leng=data.length();
	before=data[0];
	for(int i=1;i<leng;i++){
		read=data[i];
		if(read==before){
			c++;
		}else{
			output=output+inttostr(c)+before;
			before=read;
			c=1;
		}
	}
	output=output+inttostr(c)+before;
	return output;
}

int main(){
	int n;
	string data;
	while(1){
		cin>>n;
		if(n==0)break;
		cin>>data;
		for(int i=0;i<n;i++)data=cvt(data);
		cout<<data<<endl;
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    
    if (s.size() == 2)
        cout << s << endl;
    else
        cout << s.at(2) << s.at(1) << s.at(0) << endl;
}

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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((ll)(x).size())

const ll inf = 1 << 25;
const ll mod = 1e9 + 7;

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

int main() {
    ll X;
    cin >> X;
    
    ll l = 0;
    ll r = X;
    while (l + 1 < r) {
        ll m = (l + r) / 2;
        
        ll sum = 0;
        rep(i, m) sum += i + 1;
        
        if (sum >= X) r = m;
        else l = m;
    }
    cout << r << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


	public class Main {
		
		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			long x = sc.nextLong();
			long div = x/11L;
			long rem = x%11L;
			
			if(7<=rem&&rem<=10) {
				System.out.println(div*2+2);
			}else if(1<=rem&&rem<=6) {
				System.out.println(div*2+1);
			}else if(rem==0) {
				System.out.println(div*2);
			}
			
			
	    }
		
	}
	


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

int main(){
  int N, M;
  cin >> N >> M;
  
  int food[M];
  for(int i=0;i<M;i++){
    food[i]=0;
  }
  for(int i=0;i<N;i++){
    int K;
    cin >> K;
    for(int j=0;j<K;j++){
      int A;
      cin >> A;
      food[A-1]++;
    }
  }
  
  int ans=0;
  for(int i=0;i<M;i++){
    if(food[i]==N){ans++;}
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let ans = (n + m) * (n + m - 1) / 2 - n * m;
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        System.out.println("100 100");

        int[][] map = new int[100][100];
        for(int i=50; i<100; i++){
            for(int j=0; j<100; j++){
                map[i][j] = 1;
            }
        }

        int cw = 1, cb = 1;

        while(cw < a){
            int ti = cw / 50;
            int tj = cw % 50;
            if(ti % 2 == 0){
                map[ti*2][tj*2] = 1;
            }else{
                map[ti*2][tj*2+1] = 1;
            }
            cw++;
        }

        while(cb < b){
            int ti = cb / 50;
            int tj = cb % 50;
            if(ti % 2 == 0){
                map[99-ti*2][tj*2] = 0;
            }else{
                map[99-ti*2][tj*2+1] = 0;
            }
            cb++;
        }

        for(int i=0; i<100; i++){
            String ans = "";
            for(int j=0; j<100; j++){
                if(map[i][j] == 0){
                    ans += "#";
                }else{
                    ans += ".";
                }
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 28884
# AOJ ITP2_1_B: Deque
# Python3 2018.6.24 bal4u

from collections import deque
Q = deque()
q = int(input())
for i in range(q):
	a = input()
	if   a[0] == '0': # pushBack
		if a[2] == '0': Q.appendleft(a[4:])
		else          : Q.append(a[4:])
	elif a[0] == '1': print(Q[int(a[2:])]) # randomAccess
	else: # popBack
		if a[2] == '0': Q.popleft()
		else:           Q.pop()



Measured memory_bytes: 34580
#include <iostream>
using namespace std;
int main(){
    unsigned long int H, W;
    unsigned long long int ans;
    cin >> H >> W;
    if (H != 1 && W !=1){
        if (H%2==1 && W%2==1 ) ans = H * W / 2 + 1;
        else ans = H * W /2;
    }
    else ans = 1;
    cout << ans << endl;
    return 0;
}

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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

using Graph = vector<vector<int>>;

typedef pair<int, int> P;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n, INF_32);
    rep(i, n - 1)
    {
        int b;
        cin >> b;
        a.at(i) = min(a.at(i), b);
        a.at(i + 1) = min(a.at(i + 1), b);
    }

    int sum = 0;
    rep(i, n)
    {
        sum += a.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//
int N, A[200010] = {};
int seen[200010] = {};

int main() {

	ll K; cin >> N >> K;

	rep(i, N) {
		cin >> A[i];
		A[i]--;
	}

	int newi = 0, i, ct = 2;
	bool flag = 0;
	seen[0] = 0;
	while (1) {
		newi = A[newi];
		if (seen[newi] > 0)break;
		seen[newi] = ct;
		ct++;
	}

	int res;
	if (K > (ll)seen[newi]) res = (K - (ll)seen[newi] + 1) % (ll)(ct - seen[newi]);
	else {
		newi = 0;
		res = K;
	}
	rep(i, res)newi = A[newi];

	cout << newi + 1 << endl;

	return 0;
}


Measured memory_bytes: 5196
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int sum;
  if(N <= K) sum = N*X;
  else sum = K*X + (N-K)*Y;
  print(sum);

}


Measured memory_bytes: 888
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<map>
using namespace std;

int ichirou,zirou,ningyo[1010][1010],dp[1010][1010];


int main(){
  while(true){
    for(int i=0;i<1010;i++){
      for(int j=0;j<1010;j++){
	ningyo[i][j]=dp[i][j]=0;
      }
    }

    cin>>ichirou;
    if(ichirou==0){break;}
    for(int i=0;i<ichirou;i++){
      int a,b; 
      cin>>a;
      cin>>b;
      ningyo[a][b]=1;
    }
    cin>>zirou;
    for(int i=0;i<zirou;i++){
      int a,b; 
      cin>>a;
      cin>>b;
      ningyo[a][b]=1;
    }

    int a,b;
    for(b=1;b<1001;b++){
      for(a=1;a<1001;a++){
	if(ningyo[a][b]==1){
	  dp[a][b]=dp[a-1][b-1]+1;
	}
	else{
	  dp[a][b]=max(dp[a-1][b],dp[a][b-1]);
	}
      }
    }
    cout<<dp[1000][1000]<<endl;
  }
}

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

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

Measured memory_bytes: 256
def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A

W, H, x, y = InputToInt()

if W == 2*x and H == 2*y:
    print('{:f} {:d}'.format(H*W/2, 1))
else:
    print('{:f} {:d}'.format(H*W/2, 0))
    


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <list>
#include <map> //連想配列
#include <queue>
#include <set> //
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector> //動的配列

using namespace std;

int main() {
  int i, j;
  cin >> i >> j;
  cout << (i - 1) * (j - 1) << endl;
  return 0;
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

//========================================================================//

void failed() {
	cout << "No" << endl;
	exit(0);
}

int main() {
	map<char, int> mp;
	string s; cin >> s;
	Loop(i, 4) {
		mp[s[i]]++;
	}
	if (mp.size() != 2) failed();
	Loopitr(itr, mp) {
		if (itr->snd != 2) {
			failed();
		}
	}
	cout << "Yes" << endl;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> cnt(h, vector<int>(w));
    rep(i, h) {
        vector<int> done(w);
        rep(j, w) {
            if ( s[i][j] == '#' ) continue;
            if ( done[j] ) continue;
            int l = 0;
            while ( j + l < w ) {
                if ( s[i][j+l] =='#' ) break;
                ++l;
            }
            rep(k, l) {
                cnt[i][j+k] += l;
                done[j+k] = 1;
            }
        }
    }
    rep(j, w) {
        vector<int> done(h);
        rep(i, h) {
            if ( s[i][j] == '#' ) continue;
            if ( done[i] ) continue;
            int l = 0;
            while ( i + l < h ) {
                if ( s[i+l][j] =='#' ) break;
                ++l;
            }
            rep(k, l) {
                cnt[i+k][j] += l;
                done[i+k] = 1;
            }
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) ans = max(ans, cnt[i][j]-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20096
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();i++){
        sum+=s[i]-'0';
    }
    if(sum%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
ll n,c=0;
string s;
cin>>n;
cin>>s;
for(int i=0;i<n-2;i++)
{
  if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
  {
    c++;
  }
}
cout<<c<<endl;
  
  


return 0;
}

Measured memory_bytes: 256
loop do
  h1, m1, s1 = gets.split.map(&:to_i)
  
  break if h1 == -1
  
  tmp = 7200 - (h1 * 3600 + m1 * 60 + s1)
  
  q, s2 = tmp.divmod(60)
  h2, m2 = q.divmod(60)
  puts "%02d:%02d:%02d" % [h2, m2, s2]
  
  q, s2 = (tmp * 3).divmod(60)
  h2, m2 = q.divmod(60)
  puts "%02d:%02d:%02d" % [h2, m2, s2]
end

Measured memory_bytes: 8652
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359
int sum(int n){
	string s = to_string(n);
	int ans = 0;
	for(int i=0; i<s.size(); i++) ans += s[i]-'0';
	return ans;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	int ans = INT_MAX;
	for(int i=1; i<N; i++){
		ans = min(ans, sum(i)+sum(N-i));
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ve<ll> c(n+1,0);
    ll ans = 0;
    for(ll i = 1; i < n+1; i++){
        ans += (c[i]+1) * i;
        for(ll j = i*2; j < n+1; j += i){
            c[j]++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81400
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;
//外積！！
//三角形じゃなくて長方形考えると外積での面積は(1/2すると三角形の面積)
//x1y2 - x2y1 = S
//x1とx2を10^9と1で固定して考える

int main() {

    ll N;
    cin >> N;
    
    ll x1 = 1000000000;
    ll x2 = 1;

    if(N <= x1){
        cout << 0 << " " << 0 << " ";
        cout << N << " " << 0 << " ";
        cout << 0 << " " << 1 << endl;
    }else{
        //10^9 * y2 - 1 * y1 = S
        //S/10^9してy2を求める．そのあと-y1してSになるようにするにはどうすればよいか？
        //y2をちょびっと大きめ(切り上げ)にとって，余分をy1で引く！
        //y1=10^9に固定しているので制約を超えない
        ll y2 = N / x1;
        if(N % x1 > 0) y2++;
        ll y1 = x1 * y2 - N;

        cout << 0   << " " << 0 << " ";
        cout << x1 << " " << y1 << " ";
        cout << x2 << " " << y2 << endl;
    }

}

Measured memory_bytes: 256