akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        boolean flag = false;
        for (int i = 0; i < s.length(); i++) {
            String tmp = t.substring(i, t.length()) + t.substring(0, i);
            if (tmp.equals(s)) {
                flag = true;
                break;
            }
        }

        if (flag) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23892
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    vi x(3*n);
    forn(i,3*n)   cin>>x[i];
    sort(rall(x));
    i64 sum=0;
    int cnt=0;
    for(int i=1;cnt<n;i+=2){
        //cout<<x[i]<<endl;
        sum+=x[i];
        cnt++;
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 4564
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;
typedef pair<int, int> pii;

int main(){

    while(1){
        int w, h;
        cin>> w>> h;
        if(!(w||h)) break;

        int maze[2*h-1][w*2-1];
        for(int i=0; i<2*h-1; i++){
            for(int j=0; j<w*2-1; j++){
                if(i%2==0&&j%2==0){
                    maze[i][j]=0;// point
                }else if((i+j)%2==0){
                    maze[i][j]=1;// intersection
                }else{

                }
            }
        }
        for(int i=0; i<2*h-1; i++){
            if(i%2==0){
                for(int j=0; j<w-1; j++){
                    int a;
                    cin>> a;
                    maze[i][2*j+1]=a;
                }
            }else{
                for(int j=0; j<w; j++){
                    int a;
                    cin>> a;
                    maze[i][2*j]=a;
                }
            }
        }

//        for(int i=0; i<2*h-1; i++){
//            for(int j=0; j<w*2-1; j++){
//                cout<< maze[i][j];
//            }cout<< endl;
//        }

        int dx[]={0, 0, -1, 1};
        int dy[]={1, -1, 0, 0};
        int d[h][w];
        const int inf=1e8;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                d[i][j]=inf;
            }
        }
        queue<pii> Q;
        Q.push(make_pair(0, 0));
        d[0][0]=0;
        while(!Q.empty()){
            pii p=Q.front(); Q.pop();
            if(p.first==2*h-2&&p.second==2*w-2){
                cout<< d[h-1][w-1]+1<< endl;
                break;
            }
            for(int i=0; i<4; i++){
                int y=p.first+dy[i];
                int x=p.second+dx[i];
                int Y=y+dy[i];
                int X=x+dx[i];
                if(!(0<=Y&&Y<2*h-1&&0<=X&&X<2*w-1)) continue;
                if(maze[y][x]) continue;
                if(d[Y/2][X/2]>d[p.first/2][p.second/2]+1){
                    d[Y/2][X/2]=d[p.first/2][p.second/2]+1;
                    Q.push(pii(Y, X));
                }
            }
        }
        
        if(d[h-1][w-1]==inf){
            cout<< 0<< endl;
        }
    }

    return 0;
}

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

int main()
{
	int64_t k;
	cin >> k;

	vector<bool> done(k, false);

	for (int64_t i = 7 % k, j = 1; !done[i]; i = (10 * i + 7) % k, j++)
	{
		done[i] = true;
		if (i == 0)
		{
			cout << j << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3656
from collections import deque

n=int(input())
g=[[] for i in range(n)]
b=[0]*(n-1)
for i in range(n-1):
    ai,bi=map(int,input().split())
    g[ai-1].append(bi-1)
    g[bi-1].append(ai-1)
    b[i]=bi-1
    
#n=8
#g=[[1], [0, 2, 3, 4], [1], [1, 6], [1, 5], [4, 7], [3], [5]]
#b=[1, 2, 3, 4, 6, 5, 7]
#n=6
#g=[[1, 2, 3, 4, 5], [0], [0], [0], [0], [0]]

q=deque([0])

stack=[0]
parent=[-1]*n
pc=[-1]*n
parent[0]=0
dist=[-1]*n
dist[0]=0
while q:
    state = q.popleft()
    ic=0
    for v in g[state]:
        if parent[v] !=-1:
            continue
        else:
            parent[v]=state
            dist[v]=dist[state]+1
            q.append(v)
            ic+=1
            if ic==pc[state]:
                ic+=1
            pc[v]=ic

k=max(pc)
print(k)
for i in range(n-1):
    print(pc[b[i]])
    

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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*b / GCD(a,b) ;}

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

    string s;cin >> s;
    cout << (count(ALL(s),'7') ? "Yes" : "No") << endl;
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,m; cin>>n>>m;
  vpll ab(m);
  rep(i,m){
    ll a,b; cin>>a>>b; a--,b--;
    ab[i]={a,b};
  }
  
  ll ans=0;
  rep(i,m){
    UnionFind uf(n);
    rep(j,m){
      if(i==j) continue;
      ll a,b; tie(a,b)=ab[j];
      uf.connect(a,b);
    }
    rep(j,n){
      if(!uf.isSame(0,j)){
        ans++;
        break;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

four = len(list(filter(lambda x: x % 4 == 0, A)))
two = len(list(filter(lambda x: x % 2 == 0 and x % 4 != 0, A)))
odd = N - two - four

if odd == 0 and two % 2 == 0:
    print('Yes')
elif four > 0 and odd + two % 2 <= four + 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
N = int(input())
H = [int(h) for h in input().split()]

def max_heapfiy(i):
    left = 2 * i
    right = 2 * i + 1
    if left <= N and H[i - 1] < H[left - 1]:
        largest = left
    else:
        largest = i
    if right <= N and H[largest - 1] < H[right - 1]:
        largest = right
    if largest != i:
        H[i - 1], H[largest - 1] = H[largest - 1], H[i - 1]
        max_heapfiy(largest)

for i in reversed(range(1, N // 2 + 1)):
    max_heapfiy(i)

print('', *H)


Measured memory_bytes: 64036
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  while(true){
    int m, n;
    cin >> m >> n;
    if(m == 0 && n == 0) break;
    vi b(m+n);
    vector<set<int>> factor(m+n);
    for(int i = 0; i < m+n; i++){
      cin >> b.at(i);
      for(int j = 2; j*j <= b.at(i); j++){
        if(b.at(i) % j == 0){
          factor.at(i).insert(j);
          while(b.at(i) % j == 0) b.at(i) /= j;
        }
      }
      if(b.at(i) != 1) factor.at(i).insert(b.at(i));
    }
    vvi G(n+m, vi(0));
    for(int i = 0; i < m; i++){
      for(int j = 0; j < n; j++){
        set<int> se = factor.at(i);
        int num = se.size();
        for(auto ite = factor.at(m+j).begin(); ite != factor.at(m+j).end(); ite++){
          se.insert(*ite);
        }
        if(sz(se) != num + sz(factor.at(m+j))){
          G.at(i).push_back(m+j);
          G.at(m+j).push_back(i);
        }
      }
    }
    vi match(m+n, -1);
    vi flag(m+n, 0);
    /*for(int i = 0; i < m; i++){
      for(auto x: G.at(i)) cout<< i << ' ' << x << endl;
      //for(auto x: factor.at(i)) cout<< i << ' ' << x << endl;
    }*/
    function<bool(int)> dfs = [&](int v){
      flag.at(v) = 1;
      for(int i = 0; i < sz(G.at(v)); i++){
        int u = G.at(v).at(i);
        int w = match.at(u);
        if(flag.at(u)) continue;
        if(w == -1 || (!flag.at(w) && dfs(w))){
          match.at(v) = u;
          match.at(u) = v;
          return true;
        }
      }
      return false;
    };
    int ans = 0;
    for(int i = 0; i < m; i++){
      if(match.at(i) != -1) continue;
      fill(ALL(flag), 0);
      if(dfs(i)) ans++;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 4736
stack = []
res = []

area = input()

for i, terrain in enumerate(area):
    if terrain == '\\':
        stack.append(i)
    elif terrain == '/' and len(stack)>0:
        left = stack.pop()
        pond = i - left
        if len(res) == 0 or left >= res[-1][0]:
            res.append([left,pond])
        else:
            while len(res) > 0 and left < res[-1][0] :
                pond += res[-1][1]
                res.pop()
            res.append([left,pond])

total = 0
ponds = []
for i in res:
    ponds.append(i[1])
    total += i[1]

ans = [len(res)]
ans += ponds
ans_new = " ".join(map(str,ans))

print(total)
print(ans_new)



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

long calcGcd(long a, long b) {
  if (a < b) return calcGcd(b, a);
  long r;
  while (r = a % b) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  long n, m;
  std::string s, t;
  std::cin >> n >> m >> s >> t;

  long gcd = calcGcd(n, m);
  long dn = n / gcd;
  long dm = m / gcd;
  long ans = dn * m;

  for (long i = 0; i < gcd; ++i) {
    if (s[dn * i] != t[dm * i]) {
      ans = -1;
      break;
    }
  }
  std::cout << ans << std::endl;
}

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

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<int64_t> A(N);
  vector<int64_t> B(M);
  vector<int64_t> A_sum(N + 1,0);
  vector<int64_t> B_sum(M + 1,0);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < M; i++) cin >> B.at(i);
  for (int i = 1; i <= N; i++) A_sum.at(i) = A_sum.at(i-1) + A.at(i-1);
  for (int i = 1; i <= M; i++) B_sum.at(i) = B_sum.at(i-1) + B.at(i-1);
  
  int max_j = M;
  int ans = 0;
  for (int i = 0; i <= N; i++) {
    for(int j = max_j; j >= 0; j--) {
      if ((K - A_sum.at(i)) >= B_sum.at(j)) {
        max_j = j;
        ans = max(ans,i + max_j);
        break;
      }
    }
  }
  cout << ans << endl;
}
  
  

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

int main() {
	int N;
	int A;
	int* result;

	cin >> N;
	result = new int[N];

	for (int i = 0; i < N; i++) {
		result[i] = 0;
	}

	for (int i = 0; i < N - 1; i++) {
		cin >> A;
		result[A - 1] += 1;
	}

	for (int i = 0; i < N; i++) {
		cout << result[i] << '\n';
	}

	delete[] result;
	return 0;
}

Measured memory_bytes: 4008
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7
 
int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  VE wr, er;
  wr.push_back(0);
  er.push_back(0);
  REP(i, n){
    if(s[i] == 'W'){
      wr.push_back(wr[i] + 1);
      er.push_back(er[i]);
    }else{
      wr.push_back(wr[i]);
      er.push_back(er[i] + 1);
    }
  }
  int ans = mod;
  int count = 0;
  REP(i, n){
    count = 0;
    count = wr[i] + er.back() - er[i + 1];
    ans = min(ans, count);
  }
  print(ans);
}

Measured memory_bytes: 3960
input_yohou = input()
yohou = list(input_yohou)
input_tenki = input()
tenki = list(input_tenki)
num = 0
if yohou[0] == tenki[0]:
  num = num + 1
if yohou[1] == tenki[1]:
  num = num + 1
if yohou[2] == tenki[2]:
  num = num + 1
print(num)

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


int main() {
    // insert code here...
    char ch;
    while (true) {
        scanf("%c", &ch);
        if (ch=='\n') {
            cout<<endl;
            break;
        }
        if('a'<=ch&&ch<='z')ch-=32;
        else if('A'<=ch&&ch<='Z')ch+=32;
        printf("%c",ch);
        
    }

    
    return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main(void){
   int n,x=0,m=0;
   cin>>n;
   char a[n];
   for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]=='I')x++;
        else x--;
        m = max(m,x);
   }
   cout<<m;
}

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

using namespace std;

typedef long long ll;

const ll mod=1000000007;

bool prime[1001];

int main(){
        for(int i=0;i<1001;i++){
                prime[i]=true;
        }
        for(int i=2;i<1001;i++){
                if(prime[i]==true){
                        for(int j=i+i;j<1001;j+=i){
                                prime[j]=false;
                        }
                }
        }
        ll N;
        cin>>N;
        ll res=1;
        vector <ll> v;
        for(int i=2;i<1001;i++){
                int cnt=0;
                if(prime[i]){
                        for(int j=2;j<=N;j++){
                                int m=j;
                                while(m%i==0){
                                        m/=i;
                                        cnt++;
                                }
                        }
                }
                res*=(cnt+1);
                res%=mod;
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $n);

$arr = array();
for ($i = 0; $i < $n; ++$i) {
	fscanf(STDIN, '%s %s', $cmd, $str);
	if ($cmd == 'insert') {
		$arr[$str] = 1;
	} else {
		if (isset($arr[$str])) {
			echo 'yes', PHP_EOL;
		} else {
			echo 'no', PHP_EOL;
		}
	}
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

ll n, a, b, c, d, e;

ll cnt;

int main(void){
	cin>>n>>a>>b>>c>>d>>e;

	ll min_minits = min(a, min(b, min(c, min(d, e))));

	cnt = (n - 1) / min_minits + 5;

	printf("%lld\n", cnt);
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[111]={0},b[111]={0};
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    a[i]+=a[i-1];
  }
  for(int i=1;i<=n;i++){
    cin>>b[i];
    b[i]+=b[i-1];
  }
  int maxs=0;
  for(int i=1;i<=n;i++) maxs=max(maxs,a[i]+b[n]-b[i-1]);
  cout<<maxs<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e5+17;
int a[MAXN],b[MAXN];
map<int,int > mp;
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif      
    int n,ans=0;
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b, b+n);
    for (int i = 0; i < n; ++i)
    {
        mp[b[i]] = i+1;
    }
    for (int i = 0; i < n; ++i)
    {
        if(abs(i+1-mp[a[i]])&1) ans++;
    }
    cout<<ans/2+(ans&1)<<endl;
    return 0;   
}


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

using namespace std;

const int NS = (int)2e5 + 4;
int N, Q;
struct data{
    int s, e, pos;
    bool operator<(const data&r)const{
        return s < r.s;
    }
}arr[NS];
struct pqd{
    int pos, num;
    pqd(){}
    pqd(int pos, int num):pos(pos), num(num){}
    bool operator<(const pqd&r)const{
        return pos > r.pos;
    }
};
priority_queue < pqd > pq;
pqd top;

int main(){
    scanf("%d %d", &N, &Q);
    for(int i = 1; i <= N; ++i){
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        arr[i].s = max(0, a - c), arr[i].e = max(0, b - c - 1), arr[i].pos = c;
    }
    sort(arr + 1, arr + N + 1);
    int apos = 1;
    while(Q--){
        int in; scanf("%d", &in);
        while(apos <= N && arr[apos].s <= in){
            pq.push(pqd(arr[apos].pos, apos)); ++apos;
        }
        int f = 1;
        while(!pq.empty()){
            top = pq.top(); pq.pop();
            if(arr[top.num].e >= in){
                f = 0; break;
            }
        }
        if(f){
            puts("-1"); continue;
        }
        printf("%d\n", top.pos); pq.push(pqd(top.pos, top.num));
    }
    return 0;
}


Measured memory_bytes: 5232
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int N, i, Sa = 0, Sb = 0, c = 0, num = 0;
	scanf("%lld", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	int *b = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &a[i]);
		Sa += a[i];
	}
	for(i = 0; i < N; i++){
		scanf("%lld", &b[i]);
		Sb += b[i];
	}
	for(i = 0; i < N; i++){
		if(a[i] > b[i]){
			c += a[i] - b[i];
		}
	}
	for(i = 0; i < N; i++){
		if(b[i] > a[i]){
			c -= (b[i] - a[i]) / 2;
		}
	}
	if(c <= 0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))

Aset = set(A)
lst = {}
for i in Aset:
    lst[i] = 0
    
for i in range(N):
    lst[A[i]] += 1

llst = dict(lst) # llst は、valueが1のものを消したリスト
for i in lst:
    if lst[i] == 1:
        llst.pop(i)

c = dict(lst) # c は keyの値である場合の組み合わせの数。
              # c = dict(lst)で異なるオブジェクトとして等価なcを定義
              # c = lst だと、同一のオブジェクトとなってしまう？
c_all = 0
for j in llst:
    c_all += llst[j]*(llst[j]-1)//2

# print('c_all:{}'.format(c_all))
for i in lst:
#     print('i:{}'.format(i))
#     print('lst[i]:{}'.format(lst[i]))
    c[i] = c_all
    c[i] = c[i] - lst[i]*(lst[i]-1)//2 + (lst[i]-1)*(lst[i]-2)//2
        
for i in range(N):
    print(c[A[i]])

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

// 互除法で2正数x,yのgcdを返す関数
int gcd (int x, int y) {
    int p = x % y;
    while(p){
        x = y;
        y = p;
        p = x % y;
    }
    return y;
}


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

    vector<int>fromLeft(N); // 左からi+1番目までのgcdがfromLeft[i]
    vector<int>fromRight(N); // 右からi+1番目までのgcdがfromRight[i]
    // 長さN-1でいいのはそれはそう
    fromLeft[0] = A[0];
    fromRight[0] = A[N-1];
    for (int i = 1; i < N; ++i) {
        fromLeft[i] = gcd(fromLeft[i-1], A[i]);
        fromRight[i] = gcd(fromRight[i-1], A[N-1-i]);
    }

    int ans = fromRight[N-2]; // A_1を消したとき
    for (int i = 2; i < N; ++i) {
        // A_iを消したとき
        ans = max(ans, gcd(fromLeft[i-2], fromRight[N-i-1]));
    }
    // A_Nを消したとき
    ans = max(ans, fromLeft[N-2]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 1408
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();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if ((a + b) > (c + d)) {
			System.out.println("Left");
		} else if ((a + b) == (c + d)) {
			System.out.println("Balanced");
		}else if ((a + b) < (c + d)) {
			System.out.println("Right");
		}
	}
}

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

void printNo(){
	cout << "NO" << endl;
	exit(0);
}


int main() {
  string s;cin >> s;
	vector<string> ts = {"dream","dreamer","erase","eraser"};
	string pre = "";
	for(ll i=0;i<(ll)s.size();++i){
		if( s.at(i) != 'd' && s.at(i) != 'e' ){
			cout << "NO" << endl;
			return 0;
		}
		if( s.at(i) == 'd' ){
			string tmp = s.substr(i,5);
			if( tmp == "dream" ) i += 4;
			else printNo();
			pre = "dream";
		}else if( s.at(i) == 'e' ){
			string tmp = s.substr(i,6);
			if( tmp == "eraser" ){
				i+= 5;
				pre = "eraser";
			}
			else if( tmp.substr(0,5) == "erase" ){
				i+= 4;
				pre = "erase";
			}
			else if( tmp.at(1) == 'r' && pre == "dream" ){
				i++;
				pre = "dreamer";
			}
			else printNo();
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 3856
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    if N == K:
        ans = 1
        for a in A:
            ans *= a
            ans %= MOD
        print(ans)
        return

    B = []
    n_plus = 0
    for a in A:
        if a >= 0:
            B.append((a, True))
            n_plus += 1
        else:
            B.append((-a, False))

    if n_plus == 0:
        if K % 2 == 0:
            A.sort()
        else:
            A.sort(reverse=True)
        ans = 1
        for i in range(K):
            ans *= A[i]
            ans %= MOD
        print(ans)
        return

    B.sort(key=lambda x: x[0], reverse=True)
    cnt = 0
    prev_minus = None
    prev_plus = None
    for i in range(K):
        b, flag = B[i]

        if flag:
            prev_plus = b
        else:
            cnt += 1
            prev_minus = b

    if prev_plus == 0:
        print(0)
        return

    if cnt % 2 == 0:
        ans = 1
        for i in range(K):
            b, flag = B[i]
            ans *= b
            ans %= MOD
        print(ans)
        return

    next_minus = None
    next_plus = None
    for i in range(K, N):
        b, flag = B[i]
        if flag:
            if next_plus is None:
                next_plus = b
        else:
            if next_minus is None:
                next_minus = b

        if b == 0:
            if next_minus is None:
                next_minus = 0

    if next_plus is not None and prev_minus is not None:
        ans1 = 1
        ignored = False
        for i in range(K):
            b, flag = B[i]

            if ignored or prev_minus != b:
                ans1 *= b
                ans1 %= MOD
                continue

            if prev_minus == b:
                ignored = True

        ans1 *= next_plus
        ans1 %= MOD
    else:
        ans1 = -INF

    if next_minus is not None and prev_plus is not None:
        ans2 = 1
        ignored = False
        for i in range(K):
            b, flag = B[i]

            if ignored or prev_plus != b:
                ans2 *= b
                ans2 %= MOD
                continue

            if prev_plus == b:
                ignored = True

        ans2 *= next_minus
        ans2 %= MOD
    else:
        ans2 = -INF

    if ans1 == -INF:
        print(ans2)
    elif ans2 == -INF:
        print(ans1)
    else:
        if prev_minus * next_minus > prev_plus * next_plus:
            print(ans2)
        else:
            print(ans1)


if __name__ == "__main__":
    main()


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


void solve()
{
	string s, t;
	cin >> s >> t;
	if (s == t.substr(0, s.length())) cout << "Yes" << '\n';
	else cout << "No" << '\n';


}


int main() {

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using ll = long long;

ll H, W, N;

int main()
{
  std::map< std::pair<ll, ll>, ll> m;

  std::cin >> H >> W >> N;
  for (ll i = 0; i < N; i++) {
    ll a, b;
    std::cin >> a >> b;
    a--; b--;
    for (ll y = a-1; y <= a+1; y++) {
      for (ll x = b-1; x <= b+1; x++) {
	if (x-1>= 0 && y-1 >= 0 && x+1 < W && y+1 < H) {
	  m[std::make_pair(y, x)]++;
	}
      }
    }
  }

  std::vector<ll> vcnt(10, 0LL);
  vcnt[0] = (H-2) * (W-2);
  for (std::map< std::pair<ll, ll>, ll>::iterator it = m.begin(); it != m.end(); it++) {
    vcnt[it->second]++;
    vcnt[0]--;
  }
  for (ll i = 0; i < 10; i++) {
    std::cout << vcnt[i] << std::endl;
  }
  return 0;
}


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

int main(){
	int a1, a2, a3, a4;
	int b1, b2, b3, b4;
	int hit = 0;
	int blow = 0;

	while(cin >> a1 >> a2 >> a3 >> a4){
		cin >> b1 >> b2 >> b3 >> b4;

		hit = 0;
		blow = 0;


		if(a1 == b1){
			hit++;
		}
		if(a2 == b2){
			hit++;
		}
		if(a3 == b3){
			hit++;
		}
		if(a4 == b4){
			hit++;
		}
		if(a1 == b2 || a1 == b3 || a1 == b4){
			blow++;
		}
		if(a2 == b1 || a2 == b3 || a2 == b4){
			blow++;
		}
		if(a3 == b1 || a3 == b2 || a3 == b4){
			blow++;
		}
		if(a4 == b1 || a4 == b2 || a4 == b3){
			blow++;
		}

		cout << hit << " " << blow << endl;
	}

}

Measured memory_bytes: 0
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
const lnt INF = 0xffffffffffffff;
lnt d[10][10];
lnt x,y,z;
lnt used[10];
int main()
{while(1){
	lnt n;
	cin>>n;
	if(!n) return 0;
	fill(d[0],d[10]+10,INF);
	fill(used,used+10,0);
	for(lnt i=0;i<n;i++){
		cin>>x>>y>>z;
		used[x]=1;
		used[y]=1;
		d[x][y]=z;
		d[y][x]=z;
	}
	for(lnt i=0;i<10;i++){
		if(used[i]) d[i][i]=0;
	}
	for(lnt k=0;k<10;k++){
		for(lnt i=0;i<10;i++){
			for(lnt j=0;j<10;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	P ans=P(-1,INF);
	lnt sum;
	for(lnt i=0;i<10;i++){
		if(!used[i]) continue;
		sum=0;
		for(lnt j=0;j<10;j++){
			if(!used[j]) continue;
			sum+=d[i][j];
		}
		if(ans.second>sum){
			ans.first=i;
			ans.second=sum;
		}
	}
	cout<<ans.first<<' '<<ans.second<<endl;
}}

Measured memory_bytes: 1156
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define repp(a, b, n) for (int i = a; i < b; ++i)
#define vint vector<int>

int main() {
	int N;
	cin >> N;
	vint X(N);
	rep(i, N) cin >> X[i];

	int sum = 0;
	rep(i, N) sum += X[i];

	int val1, val2;
	val1 = sum / N;
	val2 = val1 + 1;

	int sumsq = 0;
	rep(i, N) sumsq += X[i] * X[i];

	int ans1, ans2;
	ans1 = sumsq - 2 * val1 * sum + val1 * val1 * N;
	ans2 = sumsq - 2 * val2 * sum + val2 * val2 * N;

	cout << min(ans1, ans2) << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

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

int main() {
  int N;
  cin >> N;
  cout << (N+1) / 2 << endl;
};


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()
	ac := make([]bool, N)
	wa := make([]int, N)
	for i := 0; i < M; i++ {
		p := sc.nextInt() - 1
		res := sc.nextStr()
		if !ac[p] {
			if res == "AC" {
				ac[p] = true
			} else {
				wa[p]++
			}
		}
	}
	acNum := 0
	for _, r := range ac {
		if r {
			acNum++
		}
	}
	waSum := 0
	for i, s := range wa {
		if ac[i] {
			waSum += s
		}
	}

	fmt.Fprintln(wtr, acNum, waSum)
	wtr.Flush()
}


Measured memory_bytes: 2304
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    public static long[] steps;

    public static void Main()
    {
        var W = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int rows = W[0];
        int columns = W[1];
        string[] field = new string[rows];
        int[][] yoko = new int[rows][];
        int[][] tate = new int[rows][];
        for (int i = 0; i < rows; i++)
        {
            yoko[i] = new int[columns];
            tate[i] = new int[columns];
        }

        for (int i = 0; i < rows; i++)
        {
            field[i] = Console.ReadLine();
        }

        //
        for (int ri = 0; ri < rows; ri++)
        {
            int space_continuous = 0;
            for (int cj = 0; cj < columns; cj++)
            {
                if (field[ri][cj] == '#')
                {
                    for (int i = 0; i < space_continuous; i++)
                    {
                        yoko[ri][cj - i - 1] = space_continuous;

                    }
                    yoko[ri][cj] = 0;
                    space_continuous = 0;


                }
                else
                {
                    space_continuous++;
                }

            }
            for (int i = 0; i < space_continuous; i++)
            {
                yoko[ri][columns - i - 1] = space_continuous;

            }

        }


        for (int cj = 0; cj < columns; cj++)
        {
            int space_continuous = 0;
            for (int ri = 0; ri < rows; ri++)
            {
                if (field[ri][cj] == '#')
                {
                    for (int i = 0; i < space_continuous; i++)
                    {
                        tate[ri - i - 1][cj] = space_continuous;

                    }
                    tate[ri][cj] = 0;
                    space_continuous = 0;


                }
                else
                {
                    space_continuous++;
                }

            }
            for (int i = 0; i < space_continuous; i++)
            {
                tate[rows - i - 1][cj] = space_continuous;

            }

        }






        int Maxvalue = 0;
        for (int ri = 0; ri < rows; ri++)
        {
            for (int cj = 0; cj < columns; cj++)
            {
                int score = yoko[ri][cj] + tate[ri][cj];
                if (Maxvalue < score) Maxvalue = score;
            }
        }

        Console.WriteLine(Maxvalue - 1);
    }




}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
// typedef tuple<int, int, int> T;
#define FOR(i, s, x) for (int i = s; i < (int)(x); i++)
#define REP(i, x) FOR(i, 0, x)
#define ALL(c) c.begin(), c.end()
#define DUMP(x) cerr << #x << " = " << (x) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int N;
ll dp[1 << 16], A[16][16];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> N;
  REP(i, N) REP(j, N) cin >> A[i][j];
  REP(state, 1 << N) {
    REP(i, N) FOR(j, i + 1, N) {
      if ((state >> i & 1) and (state >> j & 1)) dp[state] += A[i][j];
      // dp[state] += A[i][j] * (state >> i & 1) * (state >> j & 1);
    }

    for (int sub = state & (state - 1); sub > 0; sub = state & (sub - 1)) {
      int not_sub = state & ~sub;
      if (sub < not_sub) break;
      dp[state] = max(dp[state], dp[sub] + dp[not_sub]);
    }
  }
  cout << dp[(1 << N) - 1] << endl;
  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

ll dfs(const vector<ll>& a, int c, ll t) {
  if(t == 1) return 1;
  ll ans = 0;
  for(auto& d : {3, 5, 15, 25, 75}) {
    if(t % d == 0) {
      REP_FROM(i, c, a.size()) {
        if(d-1 <= a[i]) {
          ans += dfs(a, i+1, t / d);
        }
      }
    }
  }
  return ans;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  REP_FROM(i, 1, n+1) {
    ll tmp = i;
    REP_FROM(j, 2, n+1) {
      while(tmp % j == 0) {
        a[j]++;
        tmp /= j;
      }
    }
  }
  ll ans = dfs(a, 0, 75);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 E, T;
i64 X[101010];
i64 dp[101010];
i64 adp[101010];
int main()
{
	scanf("%d%lld%lld", &N, &E, &T);
	for (int i = 1; i <= N; ++i) scanf("%lld", X + i);

	i64 ret = 0;
	dp[0] = adp[0] = -2 * X[1];
	for (int i = 1; i <= N; ++i) {
		dp[i] = 1LL << 60LL;

		int left = 1, right = i;
		while (left < right) {
			int mid = (left + right) / 2;
			if (2 * (X[i] - X[mid]) > T) {
				left = mid + 1;
			} else {
				right = mid;
			}
		}

		dp[i] = min(dp[i], dp[left - 1] + 2 * X[left] + T);
		if (left - 2 >= 0) dp[i] = min(dp[i], 2 * X[i] + adp[left - 2]);

	//	printf("%d: %lld\n", i, dp[i]);
		if (i != N) {
			dp[i] -= 2 * X[i + 1];
		}
		adp[i] = min(adp[i - 1], dp[i]);
	}

	ret = dp[N];
	ret += E;
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 999999999999 //10^13-1
#define P pair<int,int>
#define prique priority_queue
int n,m;
int a[400000],b[400000];
vector<int>x,y;
set<int>st;
signed main(){
	cin>>n>>m;
	rep(i,m){
		cin>>a[i]>>b[i];
		if(a[i]==1)x.push_back(b[i]);
		if(b[i]==n)y.push_back(a[i]);
	}
	int l=y.size(),r=x.size();
	rep(i,r)st.insert(x[i]);
	rep(i,l)st.insert(y[i]);
	int le=st.size();
	if(le==l+r||l*r==0)puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}


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

int main(){
  char blood[2];
  int n,type_num[4];
  string type[5] = {"A","B","AB","O"}; 

  for(int i = 0 ; i < 4 ; i++)type_num[i] = 0;

  while(~scanf("%d,%s ",&n,blood)){
    for(int i = 0; i < 4 ; i++ ){
      if(blood == type[i])type_num[i]++; 
    }
  }
  for(int i = 0; i < 4 ; i++ ){
    cout << type_num[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
extern crate proconio;
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut p: [usize; n],
        c: [i64; n],
    }
    let p = p.iter().map(|x| x - 1).collect::<Vec<_>>();
    let mut ans = std::i64::MIN;
    for i in 0..n {
        let mut cur = i;
        let mut s = 0;
        let mut cycle = false;
        let mut len: usize = 0;
        for _ in 0..k {
            cur = p[cur];
            s += c[cur];
            ans = std::cmp::max(ans, s);
            len += 1;
            if cur == i {
                cycle = true;
                break;
            }
        }
        if cycle && s > 0 {
            let mut u = k % len;
            if u == 0 {
                u = len;
                s = s * (k / len - 1) as i64;
            } else {
                s = s * (k / len) as i64;
            }
            cur = i;
            let mut t = 0;
            for _ in 0..u {
                cur = p[cur];
                t += c[cur];
                ans = std::cmp::max(ans, s + t);
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2384
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	string s;
  	cin >> s;
  
 	rep(i,0,s.size()){
      if(s[i] == '1'){
        cout << 9;
      }
      else{
        cout << 1;
      }
    }
  
  	cout << endl;
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

ll mod=1e9+7;

long long powm(long long a, long long b, long long mod=1000000007){
    if(b<0) b+=mod-1;
    if(b>0){
        if(b%2==1) return a*powm(a*a%mod,b/2)%mod;
        else return powm(a*a%mod,b/2)%mod;
    }else{
        return 1;
    }
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}


int main(){
    ll k,l;
    string s;
    cin>>k>>s;
    l=s.size();
    vector<ll> x25(l+k+2,1),x26(l+k+2,1),con(l+k+2,1);
    rept(i,1,l+k+2){
        x25[i]=x25[i-1]*25%mod;
        x26[i]=x26[i-1]*26%mod;
    }
    rept(i,l-1,l+k+2){
        con[i+1]=((con[i]*(i+1))%mod)*modinv(i+2-l,mod)%mod;
    }
    ll sum=0;
    rept(i,l,l+k+1){
        sum+=con[i-1]*x25[i-l]%mod*x26[l+k-i]%mod;
        sum%=mod;
    }
    cout<<sum<<endl;
   // cout<<x25<<x26<<con<<endl;
    return 0;
}

Measured memory_bytes: 51096
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, C, K):
    ans = 0
    na = min(A, K)
    K -= na
    ans += na
    nb = min(B, K)
    K -= nb
    nc = min(C, K)
    ans -= nc

    return ans


def main():
    A, B, C, K = read_int_n()
    print(slv(A, B, C, K))


if __name__ == '__main__':
    main()


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

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  RULL(A, B);
  if (B % A == 0) { PULL(A + B) }
  else { PULL(B - A) }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
using namespace std;
typedef long long ll;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"in%s.txt",s);
	freopen(str,"r",stdin);
//	sprintf(str,"out%s.txt",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int Max=3500;
ll N;

int main()
{
	N=rd();
	fo(n,1,Max)fo(h,1,Max){
		ll A=N*n*h;
		ll B=4ll*h*n-N*n-N*h;
		if(A<B||B<=0||A%B!=0)continue;
		return printf("%lld %lld %lld\n",(ll)n,(ll)h,A/B),0;
	}
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256