akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
long long x[100000], s[100000];
long long const p = 1000000007;
long long prodsum(int n) {
	int i;
	for (i = 0; i < n; i++)scanf("%lld", &x[i]);
	for (i = n - 1; i > 0; i--)x[i] -= x[i - 1];
	s[0] = 0;
	for (i = 1; i <= n / 2; i++)s[i] = s[i - 1] + n - 1 - 2 * (i - 1);
	for (i = n - 1; i >= n / 2; i--)s[i] = s[n - i];
	long long sum = 0;
	for (i = 1; i < n; i++)sum += x[i] * s[i] % p;
	return sum%p;
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	printf("%lld", prodsum(n)*prodsum(m) % p);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define mp make_pair
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcd(int a,int b){return a*b / gcd(a,b);}
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  int h,a;
  cin >> h >> a;
  int res = h / a;
  if(h%a!=0)res++;
  cout << res << endl;
  return 0;
}


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

int main() {
        string s;
        cin >> s;
        if (s[0] == s[1] && s[1] == s[2]) {
                cout << "Yes" << endl;
        } else if (s[1] == s[2] && s[2] == s[3]) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<cstdio>
using namespace std;
const int maxn=100000;
const int NIL=-1;
int n;
vector<int> G[maxn];
int color[maxn];

void dfs(int r,int c){
    stack<int> S;
    S.push(r);
    color[r]=c;
    while(!S.empty()){
        int u=S.top();S.pop();
        for(int i=0;i<G[u].size();++i){
            int v=G[u][i];
            if(color[v]==NIL){
                color[v]=c;
                S.push(v);
            }
        }
    }
}

void setColor(){
    int id=1;
    for(int i=0;i<n;++i){
        color[i]=NIL;
    }
    for(int u=0;u<n;++u){
        if(color[u]==NIL) dfs(u,id++);
    }
}

int main(){
    int s,t,m,q;

    cin>>n>>m;

    for(int i=0;i<m;++i){
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    setColor();

    cin>>q;
    for(int i=0;i<q;++i){
        cin>>s>>t;
        if(color[s]==color[t]){
            puts("yes");
        }else{
            puts("no");
        }
    }

    return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n,t,a;
  cin>>n>>t>>a;
  double h[n];
  
  for(int i = 0; i < n; i++)
  {
    cin>>h[i];
    h[i] = abs(a - (t - h[i] * 0.006));
  }
  
  int mini = 0;
  for(int i = 1; i < n; i++)
  {
    if(h[mini] > h[i]) mini = i;
  }
  cout<<mini + 1<<endl;
  
  

  return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ball_ls = [0 for i in range(n)]
for i in range(n-1,-1,-1):
    if i > n / 2 - 1:
        ball_ls[i] = a_ls[i]
    else:
        ball_ls[i] = (sum(ball_ls[i::(i + 1)]) + a_ls[i]) % 2
cnt = sum(ball_ls)
ball_ls = [str(i+1) for i, ball in enumerate(ball_ls) if ball > 0]
print(cnt)
if cnt > 0:
    print(" ".join(ball_ls))

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

bool dup(char a, char b, char c) {
  if (a == b || b == c || c == a) return true;
  return false;
}

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

  ll n;
  cin >> n;
  char s[n];
  map<char, int> mp;
  rep(i, n) {
    cin >> s[i];
    mp[s[i]]++;
  }
  ll total = 1;
  int color = 0;
  for(auto m: mp) {
    total *= m.second;
    color++;
  }
  if (color < 3) {
    cout << 0 << endl;
    return 0;
  }
  rep(i, n-2) {
    for(int j = i+1; j < n-1; j++) {
      int k = j + (j-i);
      if (k >= n) break;
      //printf("i: %d, j: %d, k: %d\n", i, j, k);
      if (dup(s[i], s[j], s[k])) continue;
      total--;
    }
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys


def solve(S: str, K: int):

    for i in range(K-1):
        if(S[i] != '1'):
            print(S[i])
            exit()

    print(S[K-1])

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(S, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
for i in range(len(A)):
  if x-A[i]<0:
    print(i)
    exit()
  else:
    x-=A[i]
if x==0:print(N)
else:print(N-1)



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


int main()
{
    ll n, T;
    cin >> n >> T;
    vector<ll> t(n);

    rep(i, n){
        cin >> t[i];
    }

    ll sum = 0;
    ll pre_t = t[0];
    for (ll i = 1;i<n;i++){
        ll dt = t[i] - pre_t;
        if (dt < T){
            sum += dt;
        }else{
            sum += T;
        }
        pre_t = t[i];
    }
    sum += T;

    cout << sum << endl;

    return 0;
}


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

using namespace std;
const int maxn=2e5+20;

int main()
{
	ios::sync_with_stdio(0);	
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin >> a >> b; 
	int x=a/b;
	long long ans=pow(x,3);
	
	long long q=0;
	if(b%2 == 0)
	{
		for(int i=1;i<=a;i++)
		{
			if(i%b == b/2)
				q++;
		}
	}
	
	ans+=pow(q,3);
	cout << ans;	
	
	
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = []

for i in range(n):
    delete = max([a[j] if (j == a[j] - 1) else 0 for j in range(len(a))])
    if (delete == 0):
        print(-1)
        exit()
    else:
        ans.append(delete)
        a.pop(delete-1)

for i in reversed(ans):
    print(i)

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		String s[]=scanner.next().split("");
		String tmp[]=new String[7];
		tmp[0]=s[0];
		dfs(Integer.parseInt(s[0]),1,1,s,tmp);
		System.out.println(ans);
	}

	static String ans="";
	private static void dfs(int a, int i,int j, String[] s,String[] tmp) {
		if(i==4) {
			if(a==7) {
				ans=String.join("", tmp)+"=7";
			}
			return;
		}
		String tmp1[]=deepCopy(tmp);
		tmp1[j]="+";
		tmp1[j+1]=s[i];
		dfs(a+Integer.parseInt(s[i]),i+1,j+2,s,tmp1);
		String tmp2[]=deepCopy(tmp);
		tmp2[j]="-";
		tmp2[j+1]=s[i];
		dfs(a-Integer.parseInt(s[i]),i+1,j+2,s,tmp2);
	}
	
	private static String[] deepCopy(String[] array) {
		String[] newArray = new String[array.length];
		System.arraycopy(array, 0, newArray, 0, array.length);
		return newArray;
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <utility>
#include <queue>
#include <algorithm>
#include <climits>
#define INF (200*200*64*100000LL)

typedef long long ll;
using namespace std;

int N,M,R;
int r[8];
ll shortest_path[200][200];
ll path[200][200];

ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
	//pair<int,ll> p; //node, distance
void warshall_flroyd(){
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			shortest_path[i][j] = path[i][j];
		}
	}
	for(int k = 0; k < N; k++){
      	for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				shortest_path[i][j] = min(shortest_path[i][j], shortest_path[i][k]+shortest_path[k][j]);
			}
		}
	}
}

int main(){
	scanf("%d %d %d",&N,&M,&R);
	for(int i = 0; i < N; i++){ 
		for(int j = 0; j < N; j++){ 
			path[i][j] = (i==j)?0:INF;
		}	
	}
	int t;
	for(int i = 0; i < R; i++){
		scanf("%d",&t);
		r[i] = t-1;
	}
	int A,B;
	ll C;
	for(int i = 0; i < M; i++){
		scanf("%d %d %lld",&A,&B,&C);
		path[A-1][B-1] = path[B-1][A-1] = C;
	}
	warshall_flroyd();
	
#if 0
	for(int y = 0; y < N; y++){
		for(int x = 0; x < N; x++){
			printf("%lld,",shortest_path[x][y]);
		}puts("");
	}
#endif
	
	sort(r,r+R);
	ll mindist = INF;
	do{
		ll dist = 0;
		for(int i = 0; i < R-1; i++) dist += shortest_path[r[i]][r[i+1]];	
		//for(int i = 0; i < R-1; i++) printf("%d,",r[i]);	
		//printf("dist=%lld\n",dist);
		mindist = min(mindist,dist);
	}while(next_permutation(r,r+R));
	
	
	printf("%lld\n",mindist);
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
const ll INF=99999999999999999;
ll a,b,c,d,e,f,ans=0;
ll n,q;
string s;
char t[300000],w;
vl v;
ll hantei(ll x){
    rep(i,q){
        if(s[x]==t[i])x+=v[i];
        if(x<0)return -1;
        if(x>n-1)return 1;
    }
    return 0;
}
int main(){
    cin>>n>>q;
    cin>>s;
    rep(i,q){
        cin>>t[i]>>w;
        if(w=='L')v.push_back(-1);
        else v.push_back(1);
    }
 
    ll l_min=-1,l_max=n,r_min=-1,r_max=n,l,r;
    while(l_max-l_min>1){
      //cout<<l_max<<" "<<l_min<<endl;
        ll mid=(l_max+l_min)/2;
        if(hantei(mid)==-1){
            l_min=mid;
        }
        else l_max=mid;
    }
 
    l=l_max;
    
    while(r_max-r_min>1){
      //cout<<r_max<<" "<<r_min<<endl;
        ll mid=(r_max+r_min)/2;
        if(hantei(mid)==1){
            r_max=mid;
        }
        else r_min=mid;
    }
 
    r=r_max;
  //cout<<r<<" "<<l<<endl;
    cout<<r-l<<endl;    
}

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

struct edge{
    int to,cost;
};

vector<edge> g[100100];
vector<int> ans(100100);

void solve(int cu,int pa=-1){
    //cout << cu << endl;
    for(auto e:g[cu]){
        if(e.to==pa) continue;
        if(e.cost%2==0){
            ans[e.to]=ans[cu];
        }else{
            ans[e.to]=1-ans[cu];
        }
        solve(e.to,cu);
    }
}

int main(){
    int N; cin >> N;
    for(int i=0;i<N-1;i++){
        int u,v,w; cin >> u >> v >> w; u--;v--;
        g[u].push_back({v,w});
        g[v].push_back({u,w});
    }
    ans[0]=1;
    solve(0);
    for(int i=0;i<N;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 9216
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
S = []
N.times do |i|
  S[i] = gets.chomp
end

hash = Hash.new(0)
S.each do |s|
  hash[s.split('').sort.join] += 1
end

puts hash.values.sum { |x| (x * ( x - 1)) / 2 }


Measured memory_bytes: 38332
#include<stdio.h>
long long int as[1001][1001];
int main(void)
{
	long long int a,b,x[1001],s[1001],A=9223372036854775800,min=9223372036854775800,i,j;
	scanf("%lld %lld",&a,&b);
	for(i=1;i<=a;i++){
		scanf("%lld",&x[i]);
	}
	for(i=1;i<=b;i++){
		scanf("%lld",&s[i]);
	}
	for(i=0;i<=b;i++){
		for(j=0;j<=a;j++){
			as[i][j]=A;
		}
	}
	as[0][0]=0;
	for(i=0;i<b;i++){
		for(j=0;j<=a;j++){
			if(as[i][j]!=A){
				if(as[i+1][j]>as[i][j]){
					as[i+1][j]=as[i][j];
				}
                if(as[i+1][j+1]>as[i][j]+x[j+1]*s[i+1]){
					as[i+1][j+1]=as[i][j]+x[j+1]*s[i+1];
				}
			}
		}
	}
/*	for(i=0;i<=b;i++){
		for(j=0;j<=a;j++) printf("%d ",as[i][j]);
		printf("\n");
	}*/
	for(i=0;i<=b;i++){
		if(as[i][a]<min){
			min=as[i][a];
		}
	}
	printf("%lld\n",min);
	return 0;
}

Measured memory_bytes: 8436
from collections import deque

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

d=deque()

odd = True

for i, aa in enumerate(a):
    if odd:
        d.append(str(aa))
        odd = False
    else:
        d.appendleft(str(aa))
        odd = True

if odd == False:
    d = list(d)[::-1]
ans = ' '.join(d)
print(ans)


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

int main(void)
{
    int n, m, A[111]; scanf("%d%d", &n, &m);
    int cnt = 0;
    int sum = 0;
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &A[i]);
        sum += A[i];
    }
    for (int i = 1; i <= n; ++i)
        cnt += A[i] >= ceil(sum / (float)(4 * m));
    printf("%s\n", cnt >= m ? "Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

/*template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
*/
int main(){
    int n;cin>>n;
    long double x=0;
    long double p;
    for(int i=0;i<n;i++){
    	cin>>p;
    	x+=((double)1/p);
	}
	
	x=(double)1/x;
	cout<<setprecision(15);
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);
  string s;
  cin >> s;
  cout << 700 + 100 * count(all(s), 'o') << endl;
  return 0;
}


Measured memory_bytes: 384
S = input()
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in alphabet:
    if i not in S:
        print(S + i)
        break
else:
    output = False
    while len(S) > 0 and not output:
        last = alphabet.index(S[-1])
        for i in alphabet[last + 1:]:
            if i not in S[:-1]:
                print(S[:-1] + i)
                output = not(output)
                break
        else:
            S = S[:-1]
    if not output:
        print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    vector<string> ans;

    int nat = 0, abr = 0;
    for (auto &&i : s)
    {
        if (i == 'a' && nat + abr < a + b)
        {
            ans.push_back("Yes");
            nat++;
        }
        else if (i == 'b' && nat + abr < a + b && abr < b)
        {
            ans.push_back("Yes");
            abr++;
        }
        else ans.push_back("No");
    }
    
    for (auto &&i : ans)
    {
        cout << i << endl;
    }
    
}


Measured memory_bytes: 6260
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define EPS (1e-10)
#define MOD 1000000007
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int s[100000];
int main() {
	int n; scanf("%d", &n);
	int cnt = 0;
	for(int i=1;i<=n;i++) {
		int a; scanf("%d", &a);
		if (s[a] == i)cnt++;
		s[i] = a;
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 640
def main():
    # 内包表記でがんばるバージョン。
    n, threshould = [int(x) for x in input().split()]
    count = sum(
        sum(int(x) ** 2 for x in input().split()) <= threshould ** 2
        for _ in range(n))
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<list>


using namespace std;

#define FOR(x) for(int i = 0; i < x; i++)

stack<short> left, right;
short a[10], n, j;

bool solve(short c, bool judge){
	if(c == 10) return true;
	if(left.top() < a[c]){
		left.push(a[c]);
		if(solve(c + 1, true)) return true;
	}
	if(right.top() < a[c]){
		right.push(a[c]);
		if(solve(c + 1, false)) return true;
	}
	if(judge) left.pop();
	else right.pop();
	return false;
}

int main(){
	scanf("%d", &n);
	FOR(n){
		left.push(0);
		right.push(0);
		for(j = 0; j < 10; j++)
			scanf("%d", &a[j]);
		if(solve(0, true)) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
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 per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  int n, c, k;
  cin >> n >> c >> k;
  vi t(n);
  rep(i,n) cin >> t[i];
  sort(all(t));
  int cur = t[0] + k;
  int cnt = 1;
  int ans = 1;
  REP(i,n) {
    cnt++;
    if(cnt > c || t[i] > cur) {
      ans++;
      cur = t[i] + k;
      cnt = 1;
    }
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a;
    a.push_back(0);
    rep(i,n){
        int x;
        cin >> x;
        a.push_back(x);
    }
    a.push_back(0);
    ll sum = 0;
    rep(i, a.size()-1) sum += abs(a[i+1] - a[i]);
    for(int i = 1; i <= n; i++){
        ll ans = sum;
        ans -= abs(a[i] - a[i-1]);
        ans -= abs(a[i+1] - a[i]);
        ans += abs(a[i+1] - a[i-1]);
        cout << ans << endl;
    }
    return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1;

const ll INF = 1LL << 60;

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;}

// a^n mod を計算 再帰
ll modpow(ll a,ll n,ll &mod){
  if(!n) return 1;
  ll x = modpow(a,n/2,mod)%mod;
  x *=x;
  if(n%2==1)x*=a;
  return x%mod;
}

int main(){
  string s;cin>>s;
  if(s=="ABC")cout<<"ARC";
  else cout<<"ABC";
}


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

a, b, c, d = list(input())
a = int(a)
b = int(b)
c = int(c)
d = int(d)
if a + b + c + d == 7:
    print('{0}+{1}+{2}+{3}=7'.format(a, b, c, d))
elif a + b + c - d == 7:
    print('{0}+{1}+{2}-{3}=7'.format(a, b, c, d))
elif a + b - c + d == 7:
    print('{0}+{1}-{2}+{3}=7'.format(a, b, c, d))
elif a + b - c - d == 7:
    print('{0}+{1}-{2}-{3}=7'.format(a, b, c, d))
elif a - b + c + d == 7:
    print('{0}-{1}+{2}+{3}=7'.format(a, b, c, d))
elif a - b + c - d == 7:
    print('{0}-{1}+{2}-{3}=7'.format(a, b, c, d))
elif a - b - c + d == 7:
    print('{0}-{1}-{2}+{3}=7'.format(a, b, c, d))
elif a - b - c - d == 7:
    print('{0}-{1}-{2}-{3}=7'.format(a, b, c, d))


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

int gcd(int a,int b){
    if(b==0)
        return a;
    if(a<b)
        swap(a,b);
    return gcd(b,a%b);
}

int main(){
    int a,b;
    while(scanf("%d %d",&a, &b)!=EOF){
        int g = gcd(a,b);
        printf("%d %d\n",g,a/g*b/g*g);
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  while(s!=""){
    if(s.substr(0,5)=="dream"||s.substr(0,7)=="dreamer"||s.substr(0,5)=="erase"||s.substr(0,6)=="eraser"){
      if(s.substr(0,6)=="eraser"){
        s.erase(0,6);
        continue;
      }else{
        if(s.substr(0,5)=="erase"){
          s.erase(0,5);
          continue;
        }
      }
      if(s.substr(0,7)=="dreamer"){
        if(s.substr(7,1)=="a"){
          s.erase(0,5);
        }else{
          s.erase(0,7);
        }
        continue;
      }
      if(s.substr(0,5)=="dream"){
        s.erase(0,5);
        continue;
      }
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(N: int):

    result = 0
    for i in range(1, N + 1, 2):
        if len(make_divisors(i)) == 8:
            result += 1
    print(result)
    return


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


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


ll a[200020];

int main(){
    ll n;cin>>n;
    rep(i,0,n-1){
        ll x;
        cin>>x;
        x--;
        a[x]++;
    }
    rep(i,0,n)cout<<a[i]<<endl;
}
    









Measured memory_bytes: 5124
blood_hash = [[:A, 0],[ :B, 0], [:AB, 0], [:O, 0]].to_h
while tmp = gets
  # break if tmp == ""
  tmp = tmp.chomp.split(",")
  blood_hash[tmp[1].to_sym] +=  1
end

blood_hash.each{|k,_|
  puts blood_hash[k]
}



Measured memory_bytes: 6864
a = input().split()
h = int(a[0])
w = int(a[1])

b = []
c =[]

for i in range(h):
    s = input()
    b.append(s)

for i in range(h):
    c.append(b[i])
    c.append(b[i])

for i in range(len(c)):
    print(c[i])

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

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

struct UndirectionalCompare {
    bool operator() (const Edge& e, const Edge& f) const {
        if (min(e.src,e.dst) != min(f.src,f.dst))
            return min(e.src,e.dst) < min(f.src,f.dst);
        return max(e.src,e.dst) < max(f.src,f.dst);
    }
};
typedef set<Edge, UndirectionalCompare> Edgeset;
void visit(const Graph &g, int v, int u,
           vector<int>& art, vector<Edgeset>& bcomp,
           stack<Edge>& S, vector<int>& num, vector<int>& low, int& time) {
    low[v] = num[v] = ++time;
    for(auto &e : g[v]){
        int w = e.dst;
        if (num[w] < num[v]) S.emplace(e);              // for bcomps
        if (num[w] == 0) {
            visit(g, w, v, art, bcomp, S, num, low, time);
            low[v] = min(low[v], low[w]);
            if ((num[v] == 1 && num[w] != 2) ||         // for arts
                (num[v] != 1 && low[w] >= num[v])) art.push_back(v);
            if (low[w] >= num[v]) {                     // for bcomps
                bcomp.push_back(Edgeset());
                while (1) {
                    Edge f = S.top(); S.pop();
                    bcomp.back().insert(f);
                    if (f.src == v && f.dst == w) break;
                }
            }
        } else low[v] = min(low[v], num[w]);
    }
}
void articulationPoint(const Graph& g,
                       vector<int>& art, vector<Edgeset>& bcomp) {
    const int n = g.size();
    vector<int> low(n), num(n);
    stack<Edge> S;
    for(int u = 0; u < n; u++){
        if (num[u] == 0) {
            int time = 0;
            visit(g, u, -1, art, bcomp, S, num, low, time);
        }
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    while(cin >> n >> m){
        Graph g(n);
        rep(i,m){
            int a,b;
            cin >> a >> b;
            g[a].emplace_back(a,b,0);
            g[b].emplace_back(b,a,0);
        }
        vector<int> arts;
        vector<Edgeset> es;
        articulationPoint(g,arts,es);
        sort(all(arts));
        auto last = unique(all(arts));
        for(auto it = arts.begin(); it != last; ++it) cout << *it << '\n';
    }
}

Measured memory_bytes: 9604
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

int n, a[MAXN];

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

	cin >> n;

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

	sort(a, a + n);

	cout << a[n / 2] - a[(n / 2) - 1] << endl;
	

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 10001
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
     int n;
     cin>>n;
     int h[n],dp[n]={INF};
     for(int i=0;i<n;i++)
     {
     	cin>>h[i];
	 }
     dp[0]=0;
     dp[1]=abs(h[0]-h[1]);
     for(int i=2;i<n;i++)
     dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
     cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int a,b;
	int i,x=0;
	scanf("%d %d",&a,&b);
	if((a+b)%2==0){
		printf("%d",(a+b)/2);
	}
    else{
		printf("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 1732
x=int(input())
if x>=400 and x<=599:
	print('8')
elif x>=600 and x<=799:
	print('7')
elif x>=800 and x<=999:
	print('6')
elif x>=1000 and x<=1199:
	print('5')
elif x>=1200 and x<=1399:
	print('4')
elif x>=1400 and x<=1599:
	print('3')
elif x>=1600 and x<=1799:
	print('2')
else:
	print('1')

Measured memory_bytes: 9184
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func kaibun(s string) bool {
	a := strings.Split(s, "")
	for i := 0; i < len(a)/2; i++ {
		if a[i] != a[len(a)-1-i] {
			return false
		}
	}
	return true
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	ans := 0
	for i := a; i < b+1; i++ {
		if kaibun(strconv.Itoa(i)) {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, m, x, y;;
    pair<int, int> mark[100010];
    Fill(mark, make_pair(1, 0));
    mark[1] = make_pair(1, 1);
    cin >> n >> m;
    rep(i, m){
        cin >> x >> y;
        if(mark[x].second){
            mark[y].second = 1;
        }
        mark[y].first++;
        if(mark[x].first == 1){
            mark[x].second = 0;
        }
        mark[x].first--;
    }

    ll res = 0;
    reps(i, 1, n){
        if(mark[i].second) res++;
    }

    cout << res << endl;

    // reps(i, 1, n){
    //     cout << mark[i].first sp mark[i].second << endl;
    // }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int N,h;
	cin >> N;
	int ans = 1;
	int m;
	cin >> m;
	for (int i = 1; i < N; i++) {
		cin >> h;
		if (h >= m) {
			m = h;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

void nextCharIndex(string& str, Vvec<int>& dst)
{
    const int N = str.size();
    const int infty = 1e+9;

    for(int j=0; j<26; j++) dst[N-1][j] = infty;
    for(int i=N-2; i>=0; i--){
        for(int j=0; j<26; j++){
            char c = j + 'a';
            dst[i][j] = dst[i+1][j];
            if(str[i+1] == c) dst[i][j] = i+1;
        }
    }
}

int main()
{
    const int infty = 1e+9;

    string s, t;
    cin >> s >> t;

    Vvec<int> next(s.size(), vector<int>(26));
    nextCharIndex(s, next);

    int loop = 0;
    if(next[0][t[0]-'a'] == infty && t[0] != s[0]){cout << -1 << endl; return 0;}
    int tmp = (t[0] == s[0]) ? 0 : next[0][t[0] - 'a'];
    for(int i=1; i<t.size(); i++){
        // cout << "i = " << i << endl;
        int j = t[i] - 'a';
        if(next[tmp][j] == infty){
            if(t[i] == s[0]){loop++; tmp = 0;}
            else if(next[0][j] == infty){
                cout << -1 << endl; return 0;
            }
            else{
                loop++; tmp = next[0][j];
            }
        }
        else tmp = next[tmp][j];
        // cout << "tmp = " << tmp << endl;
    }

    cout << loop*s.size() + tmp + 1 << endl;
    // cout << loop << " " << tmp << endl;

    // for(vector<int>& vec: next){
    //     for(int& i: vec){
    //         if(i == infty) cout << "inf ";
    //         else cout << i << " ";
    //     }
    //     cout << endl;
    // }
}

Measured memory_bytes: 13824
#include <stdio.h>
#include <string.h>
#define N 2000
int main(void){
	int n,m,i,A[N][2]={0};
	char s[N],str[N],*line;

	fgets(str,sizeof(str),stdin);
	for( ;str[0]!='\n'; ){
		sscanf(str,"%d,%d",&n,&m);
		A[n][0]+=1;
		fgets(str,sizeof(str),stdin);
	}
	for( ;fgets(s,sizeof(s),stdin)!=NULL; ){
		line=strtok(s," ,");
		sscanf(line,"%d",&n);
		A[n][1]+=1;
		line=strtok(NULL," ,");
		sscanf(line,"%d",&m);
	}
	for(i=1;i<N;i++){
		if(A[i][0]>=1 && A[i][1]>=1) printf("%d %d\n",i,A[i][0]+A[i][1]);
	}			
	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a;cin >> a;
	string s;cin >> s;
	if(a >= 3200) cout << s << endl;
	else cout << "red" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

LL n;
int ans = 0;

void func(LL i, int use) {
	if (i > n) return;
	if (use == 0b111) ans++;

	func(i * 10 + 7, use | 0b001);
	func(i * 10 + 5, use | 0b010);
	func(i * 10 + 3, use | 0b100);
}

int main() {
	cin >> n;
	func(0, 0);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		int N = s.Length;
		int[]A = new int[s.Length+1];
		int[]B = new int[s.Length+1];
		int c = 0;
		for(var i=0;i<N;i++){
			if(s.Substring(i,1)=="<"){
				c++;
			} else {
				c = 0;
			}
			A[i+1] = c;
		}
		c = 0;
		for(var i=N-1;i>=0;i--){
			if(s.Substring(i,1)==">"){
				c++;
			} else {
				c = 0;
			}
			B[i] = c;
		}
		long ans = 0;
		for(var i=0;i<N+1;i++){
			ans += Math.Max(A[i],B[i]);
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 20940
#include <stdio.h>
#define MAX 40
int n, post[MAX], idx;

void solve(int pre[], int in[], int N){
  int i, p;
  for(i = 0 ; i < N ; i++){
    if(in[i] == pre[0]){
      p = i;
      break;
    }
  }
  if(p != 0){
    solve(pre+1, in, p);
  }
  if(p != N-1){
    solve(pre+p+1, in+p+1, N-p-1);
  }
  post[idx++] = pre[0]; 
}
 
int main(){
  int pre[MAX], in[MAX], i;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",pre+i);
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d",in+i); 
  }
  solve(pre, in, n);
  for(i = 0 ; i < n ; i++){
    printf("%d%c",post[i],(i != n-1 ? ' ':'\n'));
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  if(D==25){
    cout<<"Christmas";
  }
  else if(D==24){
    cout<<"Christmas Eve";
  }
  else if(D==23){
    cout<<"Christmas Eve Eve";
  }
  else if(D==22){
    cout<<"Christmas Eve Eve Eve";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
     int S,h,m,s;
     cin>>S;
     h=(S-S%3600)/3600;
     S=S%3600;
     m=(S-S%60)/60;
     s=S%60;
     cout<<h<<":"<<m<<":"<<s<<endl;
}



Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main(){
	int a , b , c , d ,l1=0,l2=0,l=0 ;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a>=c)
	l1=a;
	else 
	l1=c;
    if(b<=d)
	l2=b;
	else
	l2=d;
	l=l2-l1;
	if(l<=0)
	printf("0");
	else
	printf("%d",l);
	
}

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

int main(){
    int n;cin>>n;
    string s;cin>>s;
    int res=1;
    for(int i=0;i<n-1;i++){
        if(s.at(i)==s.at(i+1))continue;
        res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 512
N = int(input())
A = [int(input()) for _ in range(N)]

left = [0] * (N+1)
right = [0] * (N+1)
for i in range(N):
    left[i+1] = (max(left[i],A[i]))
    right[-i-2] = (max(right[-i-1],A[-(i+1)]))
for i in range(N):
    print(max(left[i],right[i+1]))

Measured memory_bytes: 15700
#include<iostream>
using namespace std;
int main(){
    int arr[3][3],i,j,m,n,h,flag=1;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            cin>>arr[i][j];
        }
    }
    for(m=0;m<2;m++){
        h=arr[m+1][0]-arr[m][0];
        for(n=1;n<3;n++){
            if(h!=arr[m+1][n]-arr[m][n]){
                flag=0;
                break;
            }
        }
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
  ll n,y;cin>>n>>y;
  y/=1000;
  int k;
  rep(i,n+1){
    rep(j,n+1-i){
      k=n-i-j;
      if(10*i+5*j+k==y){
        cout<<i<<" "<<j<<" "<<k<<endl;
        return 0;
      }
    }
  }

  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}

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

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

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3632
N = int(input())
C, S, F = [],[],[]
for i in range(N-1):
    c,s,f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)


for i in range(N):
    t = 0
    for j in range(i,N-1):
        if t < S[j]:
            t = S[j]
        elif t%F[j] != 0:
            t = t + F[j] - t%F[j]
        t += C[j]

    print(t)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int a,b,c,d;
    cin >>a >>b >> c >> d;
    int now = 0;
    while(1){
        if(now%2==0){
            c-=b;
        }
        else {
            a-=d;
        }
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        now++;
    }
}
    



Measured memory_bytes: 3592