akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;
#define out(i) cout<<(i)<<endl

int main() {
  ll N;
  cin>>N;
  vector<ll> A(N-1);
  rep0(i,N-1){cin>>A[i];}
  map<ll,ll> data;
  
  for(ll i=0;i<N-1;i++){
    data[A[i]]++;
  }
  rep1(i,N){cout<<data[i]<<endl;}
}

Measured memory_bytes: 17252
#include <bits/stdc++.h>
using namespace std;
const int MX  = 3e3+5;
long long dp[MX][MX] = {};
int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> a(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i]*1LL;
    dp[i][i] = a[i];
  }
  for (int i = n-1; i >= 0; i--) {
    for (int j = 0; j < n; j++) {
      if(i== j) {
        continue;
      }else if(j - i == 1) {
        dp[i][j] = max(a[j], a[i]);
      }else if(j - i  > 1) {
        dp[i][j] = max(min(dp[i+2][j],dp[i+1][j-1]) + a[i], min(dp[i][j-2], dp[i+1][j-1])+a[j]);
      }
    }
  }
  cout << -1*(sum - 2LL*dp[0][n-1]);
  return 0;
}




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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = y; x <= z; x++)
#define REPP(x, y, z) for(int x = y; x >= z; x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn

//structure

//declaration

//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

	string str;

	cin >> str;
	int ans = 0;

	for(int i = 0; i < str.size()/2; i++)
	{
		if(str[i] != str[str.size()-i-1])
			ans++;
	}

	printf("%d\n", ans);

	return 0;
}

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

namespace ABC066A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c, s;

			string[] word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);

			if (a > b && a > c)
				s = b + c;
			else if (b > a && b > c)
				s = a + c;
			else
				s = a + b;


			Console.WriteLine(s);

			//Console.ReadKey();
		}
	}
}


Measured memory_bytes: 27480
#include <stdio.h>
 
#define M 1000000007
 
 
unsigned long long power(int m, int n) {
    unsigned long long x;
    if (n == 0) return 1;
    if (n % 2) {
        x = power(m, n-1);
        return (x * m) % M;
    }
    else {
        x = power(m, n/2);
        return (x * x) % M;
    }
}
 
int main() {
    int m, n, i;
    unsigned long long x;
 
    scanf("%d %d", &m, &n);
 
    printf("%llu\n", power(m, n));
 
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;
#define int long long
int mas[100000];
signed main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	int ss = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> mas[i];
		ss += mas[i];
	}
	sort(mas + 1, mas + n + 1);
	if (ss % 10 != 0) {
		cout << ss << endl;
		return 0;
	}
	for (int i = 1; i <= n; ++i) {
		if (mas[i] % 10 != 0) {
			cout << ss - mas[i] << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
x = list(map(int,input().split()))
n5=0
n7=0
for i in range(len(x)):
    if(x[i]==5):n5=n5+1
    if(x[i]==7):n7=n7+1
if(n5==2 and n7==1):print("YES")
else:print("NO")


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e16;

lint N, K, A, B;
vector<lint> to[100000];
lint dp_min[100000], dp_max[100000];
lint dp[100000];
int main() {
	cin >> N;
	REP(i, N - 1) {
		cin >> A >> B; A--; B--;
		to[A].push_back(B);
		to[B].push_back(A);
	}
	REP(i, N) {
		dp_min[i] = INF;
		dp_max[i] = INF;
		dp[i] = INF;
	}
	cin >> K;
	queue<lint> que;
	lint st;
	REP(i, K) {
		cin >> A >> B; A--;
		dp_min[A] = B;
		dp_max[A] = B;
		que.push(A);
		st = A;
	}

	while (!que.empty()) {
		lint curr = que.front(); que.pop();
		REP(i, SZ(to[curr])) {
			lint next = to[curr][i];
			if (dp_max[next] == INF) {
				dp_max[next] = dp_max[curr] + 1;
				dp_min[next] = dp_min[curr] - 1;
				que.push(next);
			}
			else {
				if (dp_max[next] % 2 == dp_max[curr] % 2) {
					cout << "No" << endl;
					return 0;
				}
				if (dp_max[next] < dp_min[curr] - 1 || dp_max[curr] + 1 < dp_min[next]) {
					cout << "No" << endl;
					return 0;
				}
				else {
					lint prev_max = dp_max[next], prev_min = dp_min[next];
					dp_max[next] = min(dp_max[curr] + 1, dp_max[next]);
					dp_min[next] = max(dp_min[curr] - 1, dp_min[next]);
					if(dp_max[next] != prev_max || dp_min[next] != prev_min) que.push(next);
				}
			}
		}
	}

	que.push(st);
	dp[st] = dp_max[st];
	while (!que.empty()) {
		lint curr = que.front(); que.pop();
		REP(i, SZ(to[curr])) {
			lint next = to[curr][i];
			if (dp[next] != INF) continue;
			if (dp_min[next] <= dp[curr] - 1) dp[next] = dp[curr] - 1;
			else dp[next] = dp[curr] + 1;
			que.push(next);
		}
	}
	cout << "Yes" << endl;
	REP(i, N) {
		cout << dp[i] << endl;
	}
}


Measured memory_bytes: 12676
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

int n, m;
int a[55], b[55];
vector<pair<int, int>> g[55];
int u[25], v[25];

void dfs(ll *eid, int u, int p = -1) {
  for (pair<int, int> c : g[u]) {
    int t, id; tie(t, id) = c;
    if (t != p) {
      eid[t] = id;
      dfs(eid, t, u);
    }
  }
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  read(n);
  rep(i, 1, n) {
    read(a[i], b[i]);
    g[a[i]].push_back({ b[i], i });
    g[b[i]].push_back({ a[i], i });
  }
  read(m);
  rep(i, 0, m) read(u[i], v[i]);

  ll sum = 0;
  rep(i, 1, 1 << m) {
    ll sgn = __builtin_popcountll(i) % 2 ? 1 : -1;
    ll ban[55]; fill(ban, ban + 55, 0);
    int cnt = n - 1;
    rep(j, 0, m) if (i & (1 << j)) {
      ll eid[55]; fill(eid, eid + 55, 0);
      dfs(eid, u[j]);
      int t = v[j];
      while (eid[t]) {
        ban[eid[t]] = 1;
        t = a[eid[t]] != t ? a[eid[t]] : b[eid[t]];
      }
    }
    rep(j, 1, n) if (ban[j]) cnt--;
    sum += sgn * (1ll << cnt);
  }

  ll ans = (1ll << (n - 1)) - sum;
  write(ans);
}



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

using namespace std;
typedef long long ll;

int main() {
    ll n, q;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    map<ll, ll> m;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
        m[a[i]]++;
    }
    cin >> q;
    for (ll i = 0; i < q; i++) {
        ll b, c;
        cin >> b >> c;
        ll cnt = m[b];
        sum += cnt * (c - b);
        m[b] -= cnt;
        m[c] += cnt;
        cout << sum << endl;
    }
    // for (ll i = 0; i < q; i++) {
    //     ll sum = 0;
    //     ll b, c;
    //     cin >> b >> c;
    //     for (ll i = 0; i < n; i++) {
    //         if (a[i] == b) {
    //             a[i] = c;
    //         }
    //         sum += a[i];
    //     }
    //     cout << sum << endl;
    // }
    return 0;
}


Measured memory_bytes: 9912
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する

bool cmp(pair<ll,ll> a, pair<ll,ll> b){
    if(a.second == b.second){
        return a.first > b.first;
    }else{
        return a.second > b.second;
    }
}

bool cmp2(pair<ll,ll> a, pair<ll,ll> b){
    if(a.first == b.first){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {
    ll n;
    cin >> n;
    vector<pair<ll,ll>> red(n);
    vector<pair<ll,ll>> blue(n);

    rep(i,n){
        ll x, y;
        cin >> x >> y;
        red.at(i) = make_pair(x, y);
    }
    rep(i,n){
        ll x, y;
        cin >> x >> y;
        blue.at(i) = make_pair(x, y);
    }

    sort(all(red), cmp);
    sort(all(blue));
    
    
    ll ans = 0;
    vector<ll> res_r(n, 0);
    vector<ll> res_b(n, 0);
    rep(j ,blue.size()){
        rep(i, red.size()){
            if(res_r[i] == 1){
                continue;
            }
            if(res_b[j] == 1){
                break;
            }
            if(red.at(i).first < blue.at(j).first && red.at(i).second < blue.at(j).second){
                ans++;
                res_r[i] = 1;
                res_b[j] = 1;
            }
        }
    }

    cout << ans << endl;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n, k;
  cin>>n>>k;
  int64_t count = 0;
  if (k == 0) {
    cout << (int64_t)n * n << endl;
    return 0;
  }
  FOR(i,k,n+1) {
    count += (n/i) * (i-k);
    count += max(0, n%i+1 - k);
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (max, mid, min) = readLine()!!.split(" ").map { it.toInt() }.sortedDescending()

    var count = 0
    while (max != mid) {
        mid++
        min++
        count++
    }


    while (2 <= max - min) {
        min += 2
        count++
    }

    when {
        max - min == 0 -> println(count)
        max - min == 1 -> println(count + 2)
        max - min == -1 -> println(count + 1)
    }
}

Measured memory_bytes: 37748
#include <iostream>
#include <vector>
#include <set>
#include <utility>
using namespace std;

int main(){
    while(true){
        int n, w, d;
        int p, s;
        vector<pair<int, int> > pieces;
        multiset<int> area;
        cin >> n >> w >> d;
        if(!(n||w||d)) break;
        pieces.push_back(make_pair(w,d));
        for(int i=0;i<n;++i){
            int pw, pd;
            pair<int, int> piece1, piece2;
            cin >> p >> s;
            pw = pieces[p-1].first; pd = pieces[p-1].second;
            pieces.erase(pieces.begin() + p-1);
            s = s%(pw+pd);
            if(s<pw){
                piece1.first = s; piece1.second = pd;
                piece2.first = pw-s; piece2.second = pd;
            }else{
                s-=pw;
                piece1.first = pw; piece1.second = s;
                piece2.first = pw; piece2.second = pd-s;
            }
            if(piece1.first*piece1.second < piece2.first*piece2.second){
                pieces.push_back(piece1);
                pieces.push_back(piece2);
            }else{
                pieces.push_back(piece2);
                pieces.push_back(piece1);
            }
        }
        for(int i=0;i<n+1;++i){
            area.insert(pieces[i].first*pieces[i].second);
        }
        cout << *(area.begin());
        for(multiset<int>::iterator it=++area.begin();it!=area.end();++it){
            cout <<  ' ';
            cout << *it;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1204
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */


int n;
vector<vector<pair<int, int>>> graph;
vector<int> res;
void dfs(int v, int p, int color){
    res[v] = color;
   for(auto e : graph[v]){
       if(e.first == p) continue;
       if(e.second%2)dfs(e.first, v, 1 - color);
       else dfs(e.first, v, color);
   }
}
int main() {
    cin >> n;
    int u, v, w;
    graph.assign(n,vector<pair<int,int>>());
    res.assign(n, 0);
    rep(i, n - 1){
        cin >> u >> v >> w;
        u--;v--;
        graph[u].push_back(make_pair(v, w));
        graph[v].push_back(make_pair(u, w));
    }
    dfs(0, -1, 1);
    for(auto e: res) cout << e << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back

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

  int a, b;
  cin >> a >> b;

  if(a + b == 15) {
    cout << '+' << endl;
  } else if(a * b == 15) {
    cout << '*' << endl;
  } else {
    cout << 'x' << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <stack>
using namespace std;
void startstack(stack<int> &st){
  st.empty();
  st.push(0);
}
void clear(string &tmp){
  int j;
  do{
    for(j=0;tmp[j];j++);
    if(tmp[--j]=='.') break;
  }while(getline(cin,tmp));
}
int main(){
  int i,j;
  stack<int> st;
  string tmp;
  startstack(st);
  getline(cin,tmp);
  while(tmp!="."){
    for(i=0;tmp[i];i++){
      if(tmp[i]=='('||tmp[i]=='['){
	st.push(tmp[i]);
      }
      if(tmp[i]==']'){
	if(st.top()=='[') st.pop();
	else {startstack(st);
	  cout <<"no\n";
	  clear(tmp);
	  break;}
      }
      if(tmp[i]==')'){
	if(st.top()=='(') st.pop();
	else {startstack(st);
	  clear(tmp);
	  cout <<"no\n";
	  break;
	}
      }
      if(tmp[i]=='.'){
	if(st.top()==0) {cout <<"yes\n";
	  startstack(st);}
	else {
	  cout <<"no\n";
	  startstack(st);
	  break;}
      }
    }
    getline(cin,tmp);
  }
      return 0;
}

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

int main(){
    int N;
    string A;
    cin >> N >> A;
    int count = 0;
    for (int i = 0; i < N - 2; i++)
    {
        if (A.at(i) == 'A')
        {
            if (A.at(i + 1) == 'B')
            {
                if (A.at(i + 2) == 'C')
                {
                    count++;
                }
                else
                    continue;
            }
            else
                continue;
        }
        else
            continue;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
ans = 10000
for i in range(len(s) - len(t) + 1):
    l = s[i:i + len(t)]
    cnt = 0
    for j in range(len(t)):
        if t[j] != l[j]:
            cnt += 1
    ans = min(ans,cnt)
print(ans)













Measured memory_bytes: 9004
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

    ll ans = -1;
    REP(i, 8) {
        ll t = s[0] - '0';
        FOR(j, 1, 4) {
            if ((i >> (j-1)) & 1) t += s[j] - '0';
            else t -= s[j] - '0';
        }

        if (t == 7) {
            ans = i; break;
        }
    }

    cout << s[0];
    FOR(j, 1, 4) {
        if ((ans >> (j-1)) & 1) cout << '+';
        else cout << '-';
        cout << s[j];
    }
    cout << "=7" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,x,y,z;
	cin>>n;
	ll arr[n];
	map<ll,ll> mp,mp1;
	for(int a=0;a<n;a++)
	{
		cin>>x;
		arr[a]=x;
		mp[x]++;
		mp1[x]=-1;	
	}
	y=0;
	z=0;
	map<ll,ll>::iterator it,it1;
	ll ans=0;
	for(it=mp.begin();it!=mp.end();it++)
	{
		ans+=((it->second)*(it->second-1))/2;
	}
	for(int a=0;a<n;a++)
	{
		z=ans-((mp[arr[a]])*(mp[arr[a]]-1))/2+((mp[arr[a]]-1)*(mp[arr[a]]-2))/2;
		cout<<z<<endl;
	}
	return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, M;
    vector<int> A(N);
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum = sum + A.at(i);
    }
    int Ave;
    if (sum % (4 * M) == 0) {
        Ave = sum / (4 * M);
    }
    else {
        Ave = sum / (4 * M) + 1;
    }
    int count;
    for (int i = 0; i < N; i++){
        if (A.at(i) >= Ave) {
            count++;
        }
        else {
            count = count;
        }
    }
    if (count >= M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }


}


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

int main() {
  int n;
  string s;
  int countAC = 0;
  int countWA = 0;
  int countTLE = 0;
  int countRE = 0;

  cin >> n;

  for (int i = 0; i < n; ++i){
    cin >> s;
    if (s == "AC") 
     countAC++;
    if (s == "WA") 
     countWA++;
    if (s == "TLE") 
     countTLE++;
    if (s == "RE") 
     countRE++;
  }
  cout << "AC x " << countAC << endl;
  cout << "WA x " << countWA << endl;
  cout << "TLE x " << countTLE << endl;
  cout << "RE x " << countRE << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);

	if(a<c)
		a=c;
	if(b>d)
		b=d;
	printf("%d\n",(b-a)<1 ? 0 : b-a);

	return 0;
}

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

int main () {
  int N, K;
  cin >> N >> K;
  int sum = 1;
  int x, y;
  for (int i = 0; i < N; i++){
    x = sum * 2;
    y = sum + K;
    
    if (x <= y){
      sum *= 2;
    }
    if (x > y){
      sum += K;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * 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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	vector<bool>v(40, false);
	rep(i, N) {
		int num = a[i];
		for (int j = 0; j < 40; j++) {
			if (num % 2)v[j] = !v[j];
			num /= 2;
		}
	}
	rep(i, N) {
		vector<bool>tmp(40);
		tmp = v;
		int num = a[i];
		int res = 0;
		int mul = 1;
		for (int j = 0; j < 40; j++) {
			if (num % 2)tmp[j] = !tmp[j];
			if (tmp[j])res += mul;
			mul *= 2;
			num /= 2;
		}
		cout << res << " ";
	}
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i, n)cin >> h[i];
    sort(h.begin(), h.end(), greater<int>());

    ll l = 0; ll r = h[0];
    while(l + 1 < r){
        ll x = (l + r) / 2;
        int cnt = 0;
        rep(i, n){
            ll y = h[i] - b * x;
            if(y <= 0)break;
            cnt += (y + (a-b) - 1) / (a-b);
            if(cnt > x)break;
        }
        if(cnt <= x)r = x;
        else l = x;
    }
    cout << r << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#define MAX 10

using namespace std;

int num[MAX];

int bubble_sort(int n){

  int cnt = 0;

  for( int i = 0 ; i < n - 1 ; i++ ){
    for( int j = n - 1 ; j > i ; j-- ){

      if( num[j - 1] > num[j] ){

	int temp = num[j - 1];
	num[j - 1] = num[j];
	num[j] = temp;

	cnt++;

      }
    }
  }
  return cnt;
}


int main(void){

  int n;
  while( cin >> n , n ){

    for( int i = 0 ; i < MAX ; i++ ) num[i] = 0;

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

    cout << bubble_sort(n) << endl;
  }
  return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool isp[1000000]={};


void makeEra(){
    for(int i=2;i<=1000;i++){
        if( isp[i] ){
            for(int j=2;j<=1000000/i;j++){
                isp[i*j]=false;
            }
        }
    }
}


int main(){
    rep(i,1000000)isp[i]=true;
    isp[0]=isp[1]=false;
    makeEra();
    
    int n;
    while(cin>>n){
        for(int i=n-1;;i--){
            if(isp[i]){
                cout<<i;
                break;
            }
        }
        cout<<" ";
        for(int i=n+1;;i++){
            if(isp[i]){
                cout<<i;
                break;
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 2136
<?php
    
    fscanf(STDIN, "%s %s", $l1, $r1);
    fscanf(STDIN, "%d %d", $l2, $r2);
    fscanf(STDIN, "%s", $c);
    if ($c == $l1) {
        echo --$l2 . " {$r2}";
    } else {
        echo "{$l2} ". --$r2;
    }
   

Measured memory_bytes: 4728
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        a:i64,
        mut p:i64,
    }
    p += a * 3;
    println!("{}", p / 2);
}


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

int main()
{

	bool b1, b2, b3;

	cin >> b1 >> b2 >> b3;

	if( b1 ) {
		if( !b2 ) cout << "Close" << endl;
		else cout << "Open" << endl;
	}
	else if( b3 ) cout << "Open" << endl;
	else cout << "Close" << endl;

	return 0;

}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int N;cin>>N;
    int a[110];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a,a+N,greater<int>());
        
    int Alice=0;
    int Bob=0;
    for(int j=0;j<N;j++){
        if(j%2==0){
            Alice=Alice+a[j];
        }else{
            Bob=Bob+a[j];
        }
    }
    
    cout<<Alice-Bob<<endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <set>

using namespace std;

int main(){
    map<int, int> m;
    int N;
    long long K;

    cin >> N >> K;

    m[0] =1;
    for(int i=0; i<N; ++i){
        int dest;
        cin >> dest;
        m[i+1] = dest;
    }

    queue<long long> hist; // 訪問履歴
    set<long long> cycle; // cycle detection
    long long cycle_start = -1;


    hist.push(1);
    cycle.insert(1);
    long long ans = m[1];

    while(true){
        if( cycle.count(ans) > 0){
            cycle_start = ans;
            break;
        }
        // if no cycle case
        if(ans == 0){
            break;
        }
        hist.push(ans);
        cycle.insert(ans);
        ans = m[ans];
    }

    long long count = 0;
    while(cycle_start > 0){
        long long num = hist.front();
        if(num != cycle_start){
            count++;
            hist.pop(); 
            ans = m[num];
        }else{
            break;
        }
    }

    if( cycle_start > 0){
        if( K < count ){
            ans = m[0];
            for(int i=0; i<K; ++i){
                ans = m[ans];
            }

        }else{
            //cycle mod calculation
            K = K - count;
            long long cycle_size = hist.size();
            long long idx = K%cycle_size;
            for(long long i=0; i<idx; ++i){
                ans = m[ans];
        }

        }
    }else{
        for(int i=0; i<=K; ++i){
            ans = m[ans];
        }    
    }

// 5 5
// 2 3 4 5 6


    cout << ans << endl;
}

Measured memory_bytes: 23684
n, k = map(int, input().split())
a_list = [int(i) for i in input().split()]
f_list = [int(i) for i in input().split()]
a_list.sort(reverse=True)
f_list.sort()

if k >= sum(a_list):
    print(0)
    exit()

point = []
for i in range(n):
    point.append(a_list[i] * f_list[i])

import math
def binary_search(point, k):
    left = 0
    right = 10 ** 12
    while left + 1< right:
        ans = 0
        center = (left + right) // 2
        for i in range(n):
            if point[i] > center:
                ans += a_list[i] - (center // f_list[i])
        if ans <= k:
            right = center
        else:
            left = center
    return right    
    
value = binary_search(point, k)
print(value)

Measured memory_bytes: 122508
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        int K = cin.nextint;
        var A = cin.scanint;
        var dp = new int[N];
        for (int i = 0; i < N; i++)
        {
            dp[i] = int.MaxValue;
        }
        dp[0] = 0;
        for (int i = 1; i < N; i++)
        {
            for (int j = 1; j <= K; j++)
            {
                if (i - j >= 0)
                {
                    chmin(ref dp[i], dp[i - j] + Math.Abs(A[i] - A[i - j]));
                }
            }
        }
        WriteLine(dp[N - 1]);
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 18912
#include<bits/stdc++.h>
using namespace std; //std::の省略のため
using ll = long long;

int main(){

    int n;

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

    int count = 0;

    for(int i=0; i<n; i++){
        if((i+1)%2 != 0 && a[i]%2 != 0) count++;
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            var n = ReadInt();
            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                var str = Read();
                str = str + str;
                if (str.Contains(S))
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

int main(){
    int n,k;
    cin >> n;
    int N[2*(n+1)];
    int C[201];
    
    for(int i=1; i<=2*n; i++){
        N[i] = i;
    }
    int m;
    cin >> m;
    for(int i=0; i<m; i++){
        for(int f=1; f<=2*n; f++){
            C[f] = N[f];
        }
        int t=0,s=0;
        cin >> k;
        if(k==0){
            for(int j=1; j<=2*n; j++){
                if(j%2==1){
                    t++;
                    N[j] = C[t];
                }else{
                    s++;
                    N[j] = C[n+s];
                }
            }
        }else{
            for(int j=1; j<=2*n; j++){
                if(j<=2*n-k) {
                    C[j] = N[j];
                    N[j] = N[k+j];
                }
                else{
                    N[j] = C[j-2*n+k];
                }
            }
        }
    }
    for(int i=1; i<=2*n; i++){
        cout << N[i] << endl;
    }
}

Measured memory_bytes: 3100
#include<iostream>
#include<cstring>
using namespace std;
const int MAX=100005;
int cnt[MAX];
int main(){
	int n;
	cin >> n;
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		cnt[a]++;
	}
	int ans=0;
	ans=cnt[0]+cnt[1];
	for(int i=1;i<MAX;i++){
		if(cnt[i]+cnt[i-1]+cnt[i+1]>ans) ans=cnt[i]+cnt[i-1]+cnt[i+1];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3956
#include<iostream>
#include<string.h>

using namespace std;

long long a[210000];
long long b[210000];

int main(){
    long long n, sum;
    while(cin>>n){
        memset(b, 0, sizeof(b));
        for (int i = 1; i <= n;i++){
            cin >> a[i];
            b[a[i]]++;
        }
        long long s=0;
        for (int i = 1; i <= n;i++){
            if(b[i]>1)
            s+=((b[i] - 1) * b[i] / 2);
        }
        for (int i = 1; i <= n; i++)
            {
                if(b[a[i]]>1){
                    sum=s-((b[a[i]] - 1) * b[a[i]] / 2)+((b[a[i]] - 2) * (b[a[i]]-1) / 2);
                }
                else
                    sum = s;
                cout << sum << endl;
            }
    }
    return 0;
}

Measured memory_bytes: 5760
n, z, w = map(int, input().split())
a = list(map(int, input().split()))
INF = 10 ** 10

coef = [-1, 1]
initial = [w, z]
func = [max, min]
turn = [0, 1]

dp = [[None] * 2 for _ in range(n)]
for i in range(n - 1, -1, -1):
    for c, ini, f, t in zip(coef, initial, func, turn):
        dp[i][t] = c * INF
        opo_card = a[i-1] if i else ini
        dp[i][t] = f(dp[i][t], abs(a[-1] - opo_card))
        opo_t = (t + 1) % 2
        for j in range(i + 1, n):
            dp[i][t] = f(dp[i][t], dp[j][opo_t])

ans = dp[0][0]
print(ans)


Measured memory_bytes: 3368
N , Ma, Mb = map(int, input().split())

# 入力値の受け取り方を変える

arr=[list(map(int,input().split())) for _ in range(N)]

#a = [0] * N
#b = [0] * N
#c = [0] * N

#for i in range(N):
#    a[i], b[i], c[i] = map(int, input().split())



# TLEになってしまうためinfを5000とかで設定する
INF = 5000
# さらに計算量を落とすため10 * N + 1などを定数で設定する →　関係なかったため戻す

# 最小値を求める問題なのでinfで初期化
# dp[i][sun_a][sum_b]で考えていく
dp = [[[INF] * (10 * N + 1) for _ in range(10 * N + 1)] for _ in range(N+1)]

# 初期選択状態を0とする

dp[0][0][0] = 0
for i in range(N):
    a,b,c=arr[i]
    for j in range(10*N+1):
        for k in range(10*N+1):
            if dp[i][j][k] == INF:
                continue
            
            # 選ばなかった場合
            dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
            # 選んだ場合
            dp[i+1][j+a][k+b] = min(dp[i+1][j+a][k+b], dp[i][j][k] + c)


ans = INF
# 0スタートは何を選んでいない状態となり最小値が0になってしまうため1から開始する

# TLEになったため変更
#for i in range(1,10 * N + 1):
#    for j in range(1,10 * N + 1):
#        if i * Mb != j * Ma:
#            continue
#        ans = min(ans, dp[N][i][j])
#

for i in range(1, 10*N+1):
        if i*Ma>10*N or i*Mb>10*N:
            break
        ans = min(ans, dp[N][i*Ma][i*Mb])

if ans == INF:
    print(-1)
else:
    print(ans)

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

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    
    if(b-a >= 3 && k > a-1){
        long long int ans = a;
        ans += (long long int)(b-a)*((long long int)(k-a+1)/2);
        if((k-a+1) % 2) ans++;
        cout << ans << endl;
    }else{
        cout << k+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();

    if s[0] == 'R' && s[0] == s[1] && s[1] == s[2] {
        return "3".to_string();
    }

    if s[0] == 'R' && s[0] == s[1] || s[1] == 'R' && s[1] == s[2] {
        return "2".to_string();
    }

    if s[0] == 'R' || s[1] == 'R' || s[2] == 'R' {
        return "1".to_string();
    }
    "0".to_string()
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll N;
  cin >> N;
  vector<P> v;
  rep(i, N) {
    ll A, B;
    cin >> A >> B;
    v.pb({B, A});  // firstが締め切り時間
  }

  SORT(v);
  ll keika = 0;
  rep(i, N) {
    keika += v[i].second;
    if (keika > v[i].first) {
      COUT("No");
      return 0;
    }
  }
  COUT("Yes");
  return 0;
}

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

const ll INF = 1LL << 60;

ll N, M;
vector<ll> A;
int main() {
    cin >> N >> M;
    A.resize(M);
    rep(i, M) cin >> A[i]; 

    ll total = accumulate(A.begin(), A.end(), 0LL);
    if (total <= N) {
        cout << N - total << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

char s[100030];
int cnt[26];

int ans=1;
const int mod = 1e9+7;

int32_t main(){
	int n;
	cin>>n;
	cin>>s+1;
	for(int i=1;i<=n;i++){
		cnt[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		ans *= (cnt[i]+1);
		ans %= mod;
	}
	cout<<(ans+mod-1)%mod;
}


Measured memory_bytes: 384
# coding:utf-8

N = int(input())
act = []
for i in range(N):
	act.append([int(x) for x in input().split()])

dp = [[0 for x in range(3)] for y in range(N)]

dp[0][0] = act[0][0]
dp[0][1] = act[0][1]
dp[0][2] = act[0][2]

for i in range(1, N):
	for j in range(3):
		for k in range(3):
			if j != k:
				dp[i][j] = max(dp[i][j], dp[i-1][k] + act[i][j])

m = 0
for i in range(3):
	m = max(m, dp[N-1][i])

print(m)

Measured memory_bytes: 74840
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,x,ara[100005];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        ara[x]=i;
    }
    for(i=1;i<=n;i++)
    {
        printf("%d ",ara[i]);
    }
    return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::array<i64, 4> degrees({0});
  for (i64 i = 0; i < 6; ++i) {
    i64 city;
    std::cin >> city;
    --city;
    ++degrees[city];
  }

  const i64 odd_degree = std::count_if(degrees.begin(), degrees.end(), [](const i64& degree) { return degree % 2 == 1; });

  std::cout << (odd_degree == 0 || odd_degree == 2 ? "YES" : "NO") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int i,k,n,t[100],a,b,c,d,l,j,m,T[100];

  scanf("%d",&k);
  for(i=0;i<=k-1;i++)
    {
      t[i]=0;
    }
  for(i=0;i<(k*(k-1))/2;i++)
    {
      scanf("%d%d%d%d",&a,&b,&c,&d);
      if(c<d) t[b-1]+=3;
      else if(c>d) t[a-1]+=3;
      else
	{
	  t[a-1]++;
	  t[b-1]++;
	}
    }
  l=1;
  for(i=3*(k-1);i>=0;i--)
    {
      m=0;
      for(j=0;j<=k-1;j++)
	{
	  if(t[j]==i)
	    {
	      T[j]=l;
	      m++;
	    }
	}
      l+=m;
    }
  for(i=0;i<=k-1;i++)
    {
      printf("%d\n",T[i]);
    }
  return 0;
}

Measured memory_bytes: 600
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
// Time Complexity: O(V^3)
// init_d should be {INF(if i!=j), 0 (if i==j)}
template <typename T>
void WarshallFloyd(vector<vector<T>>& d, T INFD){
    int v = d.size();
    for(int k = 0; k < v; k++){
        for(int i = 0; i < v; i++){
            for(int j = 0; j < v; j++){
                if(d[i][k] == INFD || d[k][j] == INFD) continue;
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}
#pragma endregion library

int main(){
    int h,w; cin >> h >> w;
    vv<int> mat(10,vi(10));
    rep(i,10)rep(j,10) cin >> mat[i][j];
    WarshallFloyd(mat, INF);
    int ans = 0;
    rep(i,w)rep(j,h){
        int a; cin >> a;
        if(a!=-1) ans+=mat[a][1];
    }
    cout << ans << '\n';
    
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
	int r, g, b;

	cin >> r >> g >> b;

	int n = 100 * r + 10 * g + b;

	if (n % 4 == 0) 
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;

	return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  if(S.size() < T.size() && S == T.substr(0, T.size() - 1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
long INF=10000000000;

//関数
bool cmp0(const vector<long> &a,const vector<long> &b){
    return (a.at(0)<b.at(0));
}
bool cmp1(const vector<long> &a,const vector<long> &b){
    return (a.at(1)<b.at(1));
}
bool cmp2(const vector<long> &a,const vector<long> &b){
    return (a.at(2)<b.at(2));
}



//main関数
int main() {
    
    
    //入力
    long N,M;
    cin>>N>>M;
    vector<vector<long>> data(M,vector<long>(4));
    //0:pref  1:year  2:index  3:ans;
    for(int i=0;i<M;i++){
        cin>>data.at(i).at(0)>>data.at(i).at(1);
        data.at(i).at(2)=i;
    }
    
    //計算
    sort(data.begin(),data.end(),cmp1);
    stable_sort(data.begin(),data.end(),cmp0);
    
    long pre=0;
    long count=0;
    for(int i=0;i<M;i++){
        if(data.at(i).at(0)==pre){
            count++;
        }else{
            pre=data.at(i).at(0);
            count=1;
        }
        data.at(i).at(3)=pre*1000000+count;
    }
    sort(data.begin(),data.end(),cmp2);
    
 
    //出力
    for(int i=0;i<M;i++){
        for(int j=11;j>=0;j--){
            cout<<(data.at(i).at(3)/(long)pow(10,j))%10;
        }
        cout<<endl;
    }
}

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

d = [1] * (N+1)
d[0] -= A[0]
for i in range(N):
    d[i+1] = d[i] * 2 - A[i+1]
if d[-1] < 0:
    print(-1)
    exit()

d[-1] = A[-1]
for i in range(N, 0, -1):
    d[i-1] = min(d[i]+A[i-1], d[i-1]+A[i-1])
print(sum(d))


Measured memory_bytes: 668576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  int N,K;
  scanf("%d%d", &N,&K);
  string s;
  cin >> s;

  vector<int> v;

  int cnt = 0;
  int ref = 0;

  while(ref<N){
    while(s[ref]=='1'){
      ++cnt;
      ++ref;
      if(ref>=N) break;
    }
    v.PB(cnt);
    cnt = 0;
    

    while(s[ref]=='0'){
      ++cnt;
      ++ref;
      if(ref>=N) break;
    }
    v.PB(cnt);
    cnt = 0;

    if(ref>=N) {
        v.PB(0);
        break;
    }
  }

  int num = SZ(v);
//   FOR(i,0,num-1) cout << v[i];
//   cout << endl;

  if(v[num-1]==0 && v[num-2]==0){
      v.erase(v.begin()+num-1);
      v.erase(v.begin()+num-2);
  }

  num = SZ(v);

//   FOR(i,0,num-1) cout << v[i];
//   cout << endl;

  int ans = 0;
  int fivesum = 0;
  ref = 0;

  while((ref+2*K)<num){
    fivesum = 0;
    FOR(i,0,2*K) fivesum += v[ref+i];
    chmax(ans,fivesum);
    ref += 2;
  }

//   if(num-1-2*K>=0){
//   fivesum = 0;
//   FORD(i,num-1,num-2*K) fivesum += v[ref+1];
//   chmax(ans,fivesum);
//   }

  if(ans==0) ans = N;

  cout << ans << endl;

}


Measured memory_bytes: 1020
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	bool ans = true;
	if (y % 2 == 1)ans = false;
	if (y < 2 * x || 4 * x < y)ans = false;
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3556
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    times = []
    for _ in range(n - 1):
        times.append(input_int_list())

    for i in range(n - 1):
        cur = 0
        for j in range(i, n - 1):
            c, s, f = times[j]
            # 次の電車の出発時間を探索する
            time = s
            while time < cur:
                time += f
            cur = time + c
        print(cur)
    # はじめからゴールにいるケースを出力
    print(0)
    return


if __name__ == "__main__":
    main()


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S; cin >> S;
    if (S[0]== S[1] && S[1] == S[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256