akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

struct Edge{
    int to ,id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int x ,int color = -1 ,int parent = -1){//頂点番号、親の色、親番号
    int k = 1;//色番号
    for(int i=0;i<g[x].size();i++){//n番の頂点について調べる
        int nextn = g[x][i].to ,num = g[x][i].id;
        if(nextn == parent) continue;//来た辺は除く
        if(k == color) k++;
        ans[num] = k;k++;
        dfs(nextn ,ans[num] ,x);
    }
}

int main(){
    int n;
    cin >> n;
    g.resize(n);
    ans = vector<int> (n-1);
    for(int i=0;i<(n-1);i++) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        g[b].push_back((Edge){a ,i});
        g[a].push_back((Edge){b ,i});
    }
    dfs(0);

    int max_color = 0;
    for(int i=0;i<(n-1);i++) max_color = max(max_color ,ans[i]);

    cout << max_color << endl;

    for(int i=0;i<(n-1);i++) cout << ans[i] << endl;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>

void print(vector<int> arr){for(auto i:arr){printf("%d ",i);}cout<<endl;}

int main()
{
    int n,m;scanf("%d %d",&n,&m);
    vector<vector<string>> arr(n+1);
    while(m--){
        int x;cin>>x;
        string s;cin>>s;
        arr[x].push_back(s);
    }
    int cnans=0;
    for(auto i:arr){
        bool yes=false;
        for(auto j:i){
            if(j=="AC"){yes=true;break;}
        }
        if(yes)cnans++;
    }
    // if(arr.size()==cnans){
    cout<<cnans<<" ";
    // }
    // else {exit(1);}
    int cnpen=0;
    for(auto i:arr){
        int cnt=0;
        for(auto j:i){
            if(j=="WA")cnt++;
            else if(j=="AC"){
                cnpen+=cnt;
                break;
            }
        }
    }
    cout<<cnpen;
    
    return 0;
}

Measured memory_bytes: 10368
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc144_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetLong();
            var rm = long.MaxValue;

            for (var i = 1; i <= Math.Sqrt(N); i++)
                if (N % i == 0)
                    rm = Math.Min(rm, (i - 1) + ((N / i) - 1));

            Console.WriteLine(rm);
        }

        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();

    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S,T;
//const ll MOD = 998244353;
typedef pair<ll,ll> P;

int main() {
    cin>>S>>T;
    ll s = S.size(), t = T.size();
    ll ans = 0;
    vector<P> table(s);
    rep(i,s){
        table[i] = {S[i] - 'a',i};
    }
    sort(table.begin(),table.end());
    ll last = -1;
    rep(i,t){
        P now = {T[i] - 'a', ans%s};
        /*bool news;
        news = (ans == 0 ? false : ans % s == 0);*/
        ll index = lower_bound(table.begin(), table.end(), now) - table.begin();
        P temp = {T[i] - 'a', 0};
        if(index == s){
            //news = true;
            index = lower_bound(table.begin(), table.end(), temp) - table.begin();
            if(index == s){
                cout<<-1<<endl;
                return 0;
            }
        }
        if(table[index].fi != (T[i] - 'a')){
            //news = true;
            index = lower_bound(table.begin(), table.end(), temp) - table.begin();
        }
        if(table[index].fi != (T[i] - 'a')){
            cout<<-1<<endl;
            return 0;
        }
        ans += (s-1+table[index].se-last)%s + 1;
        //cout<<ans<<' '<<table[index].se<<endl;
        last = table[index].se;
        //ans = (ans/s + news)*s + table[index].se + 1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

#define N 100005
ll n;
vector<ll>v[N];
ll dp[N][2];

void dfs(ll id,ll par){
    dp[id][0]=1;
    dp[id][1]=1;
    for(auto x:v[id]){
        if(x==par)continue;
        dfs(x,id);
        dp[id][0]=mod(dp[id][0]*(dp[x][0]+dp[x][1]));
        dp[id][1]=mod(dp[id][1]*dp[x][0]);
    }
    
}

int main(){fastio
    cin>>n;
    rep(i,1,n-1){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(1,-1);
    ll ans=0;rep(i,0,1)Add(ans,dp[1][i]);
    //rep(i,1,n){rep(j,0,1)cout<<dp[i][j]<<" ";cout<<endl;}
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main()
{
    int n,i,j,k,sum,tmp,x,y,z;
    int h,c,d,e;
    cin>>n>>h;
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
    }
    sort(a,a+n);
    sort(b,b+n);
    for(i=n-1,sum=0;i>=0;i--){
        if(b[i]<a[n-1]){
            break;
        }
        if(h<=0){
            break;
        }
        h-=b[i];
        sum++;
    }
    if(h>0){
        //cout<<"sum="<<sum<<endl;
        tmp=h/a[n-1];
        if(h%a[n-1]!=0)
            tmp++;
        sum+=tmp;
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 1152
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 for _ in range(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: 60012
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
#include <vector>

#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))

using namespace std;

const long MOD = 1000000007;

int main(int argc, char* argv[])
{
    long h, w;
    scanf("%ld %ld", &h, &w);

    long long gp[1005]={0};
    long i, j;
    for(i=1; i<=h; i++) {
        char str[1005] = {0};
        scanf("%s", str);
        for(j=0; j<w; j++) {
            if(i==1 && j==0) {
                gp[j+1] = 1;
            }
            else if(str[j]=='#') {
                gp[j+1] = 0;
            }
            else {
                gp[j+1] = (gp[j] + gp[j+1]) % MOD;
            }
        }
    }

    printf("%lld\n", gp[w]);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(int argc,char** argv) {
	int n;
	cin >> n;
	int *a = new int[n];
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int j = 0;j < n - 1;j++) cout << a[j] << " ";
	cout << a[n-1] << endl;
	for(int i = 1;i < n;i++) {
		int v = a[i];
		int j = i - 1;
		while(j >= 0 && a[j] > v){ a[j+1] = a[j]; j--;}
		a[j+1] = v;
		for(int j = 0;j < n - 1;j++) cout << a[j] << " ";
		cout << a[n-1];
		if(i != n) cout << endl;
	}
	delete a;
}



Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main()
{
    char A,C,G,T;
    char x;
    cin>>x;
    if(x=='A')
    {
        cout<<'T';
    }
    else if(x=='C')
    {
    cout<<'G';
    }
    else if(x=='G')
    {
    cout<<'C';
    }
    else if(x=='T')
    {
    cout<<'A';
    }






    return 0;
}


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

int N, M, h, a, b;
int res = 0;
vector<int> H(200010, 0);
vector<vector<int>> R(200010);
vector<bool> GH(200010, true);

int main(){
  cin >> N >> M;

  for(int i = 1; i <= N; i++) cin >> H[i];
  for(int i = 0; i < M; i++){ cin >> a >> b; R[a].push_back(b); R[b].push_back(a); }

  for(int i = 1; i <= N; i++){
    for(int j = 0; j < R[i].size(); j++){
      if(H[i] <= H[R[i][j]]) GH[i] = false;
    }
  }

  for(int i = 1; i <= N; i++){ if(GH[i]) ++res; }
  cout << res << endl;
    
  return 0;
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] ta = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int T = ta[0];
        int A = ta[1];

        var cands = Console.ReadLine().Split(' ').Select((s, idx) => new { h = int.Parse(s), i = idx + 1 } ).ToArray();

        var ans = cands.OrderBy(itm => Math.Abs(T - itm.h * 0.006 - A)).First().i;

        Console.WriteLine(ans);

    }
    
}

Measured memory_bytes: 13584
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    if(n == 1) {
        cout << 1 << endl << 0 << endl;
        return;
    }
    if(n == 2) {
        cout << 2 << endl << 0 << endl << 11 << endl;
        return;
    }
    cout << n - 1 << endl;
    rep(i, n - 1) {
        cout << 1;
        rep(j, i) {
            cout << 0;
        }
        cout << 1 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 3220
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {

	int n, num = 0;

	cin >> n;

	for (int i = 1; i <= n; i+=2)
	{
		int tmp = 0;

		for (int l = 1; l <= i; l++)
		{
			if (i%l == 0)tmp++;
		}
		if (tmp == 8)num++;
	}

	cout << num << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cctype>
using namespace std;
string str2;
int main(){
	int x[8],i,ans1=0,ans2=0;
	for(i=0;i<8;i++){
		cin>>x[i];
	}
	for(i=0;i<8;i++){
		if(i==0||i==1||i==2||i==3){
			ans1+=x[i];
		}else{
			ans2+=x[i];
		}
	}
	if(ans1<ans2){
		cout<<ans2<<endl;
	}else{
		cout<<ans1<<endl;
	}
	return 0;

}

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

int main()
{
  string s;
  char ss;
  int Q;
  int T;
  int F;
  bool isReverse = false;
  cin >> s >> Q;
  deque <char> d;
  for(char c: s){
    d.push_back(c);
  }
  for(int i = 1 ; i <= Q;i++){
    cin >> T;
    if(T == 1){
        isReverse = !isReverse;
    }
    else{
      cin >> F >> ss;
      if(F == 1){
        if(isReverse) d.push_back(ss);
        else d.push_front(ss);
      }
      else{
        if(isReverse) d.push_front(ss);
        else d.push_back(ss);
      }
    }
  }

  if(!isReverse){
    while(!d.empty()){
        cout << d.front();
        d.pop_front();
    }
  }
  else{
    while(!d.empty()){
        cout << d.back();
        d.pop_back();
    }
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 896
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Wed Jun 13 23:37:46 2018
//
package main

import (
	"fmt"
	"sort"
)

var W, H int64
var p, q []int

func main() {
	fmt.Scan(&W, &H)

	p = make([]int, W)
	q = make([]int, H)

	for i := range p {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)

	for i := range q {
		fmt.Scan(&q[i])
	}
	sort.Ints(q)

	var h, w int64
	ans := int64(0)
	n := int64(W+1)*int64(H+1) - 1
	for n > 0 {
		if (h >= int64(len(q))) || (w < int64(len(p)) && p[w] < q[h]) {
			ans += int64(H+1-h) * int64(p[w])
			n -= H + 1 - h
			w++
		} else {
			ans += int64(W+1-w) * int64(q[h])
			n -= W + 1 - w
			h++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, y;
    cin >> n >> y;
    //get min
    if (y % 1000 != 0) {
        cout << "-1 -1 -1";
        return 0;
    }
    int nx = y / 10000;
    y = y % 10000;
    int ny = y / 5000;
    y = y % 5000;
    int nz = y / 1000;
    int diff = n - nx - ny - nz;
    if (diff < 0) {
        cout << "-1 -1 -1";
        return 0;
    } else if (diff == 0) {
        cout << nx << " " << ny << " " << nz;
        return 0;
    }
    //1 nx -> 2 ny -> 10 nz, 1 ny -> 5 nz
    while (diff > 0 && nx > 0) {
        diff--;
        ny += 2;
        nx--;
        if (diff % 4 == 0 && ny >= diff / 4) {
            //conv diff ny to nz.
            cout << nx << " " << ny - diff / 4 << " " << nz + diff / 4 * 5;
            return 0;
        }
    }
    cout << "-1 -1 -1";
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a<c) {
        if(b<c) {
            cout << 0 << endl;
        }
        else {
            if(b<d) {
                cout << b-c << endl;
            }
            else {
                cout << d-c << endl;
            }
        }
    }
    else {//c<=a
        if(a<d) {
            if(b<d) {
                cout << b-a << endl;
            }
            else {
                cout << d-a << endl;
            }
        }
        else {
            cout << 0 << endl;
        }
    }
    return 0;
}

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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  string s, t;
  cin >> s >> t;
  int sl = s.size(), tl = t.size();
  int res = INT32_MAX;
  rep(i, sl - tl + 1) {
    int c = 0;
    rep(j, tl) if (s[j + i] != t[j])++ c;
    updatemin(res, c);
  }
  cout << res << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
    int sw[21];
    int N, A[21], B[21], C[20];
    int total=0;
    cin>>N;
    memset(sw,0,sizeof(sw));
    memset(A,0,sizeof(A));
    memset(B,0,sizeof(B));
    memset(C,0,sizeof(C));
    for(int i=1; i<=N;i++)
        cin>>A[i];
    for(int i=1; i<=N;i++)
        cin>>B[i];
    for(int i=1; i<=N-1;i++)
        cin>>C[i];

    for(int i=1; i<=N; i++){
        total += B[A[i]];
        if(A[i-1]==A[i]-1){
            total+=C[A[i]-1];
        }
    }
    printf("%d\n",total);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int M=1e9;
int main()
{
    int n;
    int a[110];
    int minx,maxn;
    int ans;
    while(~scanf("%d",&n))
    {
        minx=M;
        maxn=0;
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
            minx=min(minx,a[i]);
            maxn=max(maxn,a[i]);
        }
        ans=maxn-minx;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long int;
#define rep(i, n) for (ll i = 0; i < n; i++) 

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

	ll n;
	string s;
	cin >> n >> s;
	ll white_num=0, black_num=0;
	rep(i, n) {
		if (s[i] == '.')
			white_num++;
	}

	ll ret = white_num;
	rep(i, n) {
		if (s[i] == '.') {
			white_num--;
		}
		if (s[i] == '#') {
			black_num++;
		}
		ret = min(ret, white_num + black_num);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18

        bool compare(pair<int,int> a,pair<int,int> b){
            if(a.first==b.first)
                return a.second<b.second;
            return a.first<b.first;
        }

        signed main() {
 
    
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n,a,b;
        cin>>n>>a>>b;
        int fl=0;
        for(int i=a;i<=b;i++){
            if(i%n==0){
                fl=1;
            }
        }
        if(fl)
            cout<<"OK";
        else
            cout<<"NG";

        return 0;
    }

Measured memory_bytes: 3648
#include <iostream>
#include <string>

using namespace std;

// string型にfindとrepraceがある。
// これを用いて、

const string mis("Hoshino"), rep("Hoshina");

int main() {

	int N;
	cin >> N;
	cin.ignore();

	for (int i = 0; i < N; ++i) {
		string line;
		getline(cin, line);
		int pos = 0;
		while ((pos = line.find(mis, pos)) != string::npos) {
			line.replace(pos, mis.size(), rep);
		}
		cout << line << endl;
	}


	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef pair<int, int> ii;

int main () {
    vector<ii> ts;
    int id, solve;
    while (scanf("%d,%d", &id, &solve), id|solve) {
        ts.push_back(make_pair(solve, id));
    }
    sort(ts.begin(), ts.end(), greater<ii>());
    map<int, int> rs;
    int rank = 0;
    int pre = -1;
    for (vector<pair<int, int> >::iterator it = ts.begin(); it != ts.end(); it++) {
        if (it->first == pre) {
            rs[it->second] = rank;
        } else {
            rs[it->second] = ++rank;
            pre = it->first;
        }
    }
    while (cin >> id) {
        cout << rs[id] << endl;
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

    if(A1*T1+A2*T2 == B1*T1+B2*T2){
    	cout << "infinity" << endl;
    }else{
    	if(A1*T1+A2*T2>B1*T1+B2*T2){
    		swap(A1, B1);
    		swap(A2, B2);
    	}
    	ll C = B1*T1+B2*T2 - (A1*T1+A2*T2);

    	ll right = 0;
    	ll left = 0;

    	ll P = A1*T1;
    	ll Q = B1*T1;
    	ll R = A1*T1 + A2*T2;
    	ll S = B1*T1 + B2*T2;
    	//dump(P)
    	//dump(Q)

    	if(P<=Q){
    		left = 0;
    	}else{
    		//dump(P-Q)
    		//dump(C)
    		left += (P-Q+(C-1))/C-1;
    	}

    	if(Q>P){
    		right = 0;
    	}else{
    		right += (P-Q)/C;
    		right += 1;
    	}

    	//dump(left)
    	//dump(right)

    	cout << right+left << endl;
    }
    return 0;
}

Measured memory_bytes: 384
using System;

class IfSample
{
    static void Main()
    {
        // 整数を入力してもらう
        int x,y,n;
       
        n = int.Parse(Console.ReadLine());
        x = n * 800;
        y = n / 15 * 200;
            n = x - y;
        Console.WriteLine("{0}", n);
        

        
        }
    }

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

ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res % mod;
}

ll a[300005];
ll mod = pow(10, 9) + 7;
ll bits[70];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n;cin>>n;
  ll mx_bit = 0;
  for(ll i=0;i<n;i++){
    cin>>a[i];
    for(ll j=0;j<60;j++){
      if(a[i] & (1ll<<j)){
        bits[j]++;
      }
    }
  }
  ll res = 0;
  for(ll j=0;j<60;j++){
    ll mp = ((n - bits[j]) * bits[j]) % mod;
    res += modpow(2, j, mod) * mp;
    res %= mod;
  }
  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 2560
fn main() {
    let (n, k): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut s: HashSet<usize> = HashSet::new();
    for _ in 0..k {
        let d: usize = read();
        for __ in 0..d {
            s.insert(read());
        }
    }
    println!("{}", n - s.len());
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2152
#include <stdio.h>
int main(void){
int n,k,x,y,sum=0;

scanf("%d",&n);
scanf("%d",&k);
scanf("%d",&x);
scanf("%d",&y);

for(int i=0; i<n; i++){
if(i<k){
sum+=x;
}else{
sum+=y;
}
}
printf("%d",sum);

return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
int n,m;
int x,y;
int main()
{
	cin>>n>>m;
	x=n+m;
	y=x%2;
	cout<<x/2+y;
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main(void){ 
    int N;
    int T,A;
    cin>>N;
    cin>>T>>A;
    vector<int> a(N,0);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    vector <double> t(N,0);
    double ans=10000.0;
    int count=1;
    for(int j=0;j<N;j++){
        t[j]=(double)T-(double)a[j]*0.006;
        if(abs(t[j]-(double)A)<abs(ans-(double)A)){
            ans=t[j];

            count=j+1;
           
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int ans = 0;
	for(int i = 0; (i <= a && i*500 <= x) ; ++i){
		for(int j = 0; (j <= b && i*500 + j*100 <= x) ; ++j){
			for(int k = 0; (k <= c && i*500 + j*100 + k*50 <= x) ; ++k){
				if(500*i + 100*j + 50*k == x) ans += 1;
			}
		}
	}
	cout << ans << endl;
}

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



int lcs(string x, string y){

  int m = x.length();
  int n = y.length();

  int c[m + 1][n + 1];

  for(int i = 0; i <= m; i++){
    c[i][0] = 0;
  }
  for(int i = 1; i <= n; i++){
    c[0][i] = 0;
  }

  for(int i = 1; i <= m; i++){
    for(int j = 1; j <= n; j++){
      if(x[i - 1] == y[j - 1]){
        c[i][j] = c[i - 1][j - 1] + 1;
      }
      else if(c[i - 1][j] > c[i][j - 1]){
        c[i][j] = c[i - 1][j];
      }
      else{
        c[i][j] = c[i][j - 1];
      }
  //    cout << "c" << i << j << c[i][j] << endl;
    }

  }

  return c[m][n];
}

int main(){

  int q;

  string x, y;

  cin >> q;

  for(int i = 0; i < q; i++){
    cin >> x;
    cin >> y;
    cout << lcs(x, y) << endl;
  }



  return 0;
}



Measured memory_bytes: 7052
import sys
N = int(input())
t, x, y = 0, 0, 0
for i in range(N):
    in_t, in_x, in_y = map(int, input().split())
    t = in_t - t
    x = abs(in_x - x)
    y = abs(in_y - y)
    if (t >= x + y) & ((t - (x + y)) % 2 == 0):
        continue
    print('No')
    sys.exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1<<20
using namespace std;
int a[10];
void read(int &x)
{
	char c=getchar();
	int f=1;
	while (c=='-') {
		  f*=-1;
		  c=getchar();
	}
	int ans=0;
	while (c>='0' && c<='9')
	{
		ans=ans*10+c-'0';
		c=getchar();
	}
	x=f*ans;
	return ;
}
int main()
{
	int n,k;
	read(n);
	read(k);
	for (int i=0;i<=9;i++) a[i]=0;
	for (int i=1;i<=k;i++) {
		int x;
		read(x);
		a[x]=1;
	}
	for (int i=n;i<=INF;i++)
	{
		int x=i;
		bool flag=true;
		while (x!=0)
		{
			int d=x%10;
			x=x/10;
			if (a[d]==1) {
				flag=false;break;
			}
		}
		if (!flag) continue;
		else {
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define vl vector
using namespace std;
int main()
{
    ll n,a,b,i,j;
    cin>>a>>b;
    for(i=1;i<=1000000;i++)
    {
        long double x,y;
        x=i*0.08;
        y=i*0.1;
        ll c,d;
        c=floor(x);
        d=floor(y);
        if(c==a && d==b) 
        {
            cout<<i;
            return 0;
        }
    }
    cout<<"-1";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A = vector<int>(N);
  for(int i = 0; i < N-1; i++){
    int a;
    cin >> a;
    A[a-1] += 1 ;
  }
  for(int i = 0; i < N; i++){
    cout << A[i] << endl;
  }
}

Measured memory_bytes: 4052
#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

template <class T>
struct Edge{
    int src;
    int to;
    T cost;
    Edge(int t,T c) : to(t),cost(c) {}
    Edge(int src, int t,T c) : src(src),to(t),cost(c) {}
};
template<class T> using WeightedGraph = vector<vector<Edge<T>>>;

// Complexity: O(E*V)
// Dependency: Graph Template
template <typename T>
vector<T> BellmanFord(vector<Edge<T>>& es, int v, int s){
    const auto INFD = LINF;
    vector<T> dist(v,INFD);
    dist[s]=0;
    for (int i = 0; i < 2*v; ++i){
        for(auto e: es){
            if(dist[e.src]==INFD) continue;
            if(dist[e.to]>dist[e.src]+e.cost){
                dist[e.to]=dist[e.src]+e.cost;
                if (i==v-1) dist[e.to]=-INFD;
            }
        }
    }
    if(dist[v-1]<=-INFD/2) return vll();
    return dist;
}
#pragma endregion library

int main(){
    int n,m; cin >> n >> m;
    vector<Edge<ll>> es;
    rep(i,m){
        int a,b;ll c; cin >> a >> b >> c;
        a--;b--;
        es.emplace_back(a,b,-c);
    }
    vll d = BellmanFord(es,n,0);
    if(d.empty()) cout << "inf" << '\n';
    else cout << -d[n-1] << '\n';
    
}

Measured memory_bytes: 384
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 998244353;

        public static void Main()
        {

            var num = int.Parse(Console.ReadLine());
            var args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var ans = new int[num];

            ans[0] = 0;

            for (int i = 1; i < num; i++)
                ans[0] ^= args[i];

            for (int i = 1; i < num; i++)
                ans[i] = ans[i - 1] ^ args[i] ^ args[i - 1];

            Console.WriteLine(String.Join(" ", ans.Select(x => x.ToString()).ToArray()));

        }

    }

}

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

long double n;
int num;

int main() {
  std::cin >> n;
  int ans = 0;
  for (long double k = n; k >= 1; k--) {
    long double w = k;
    int t = 0;
    while (true) {
      w /= 2;
      if (w == (int)w) {
        t++;
      }
      else {
        break;
      }
    }
    if (t > ans) {
      ans = t;
      num = k;
    }
  }
  if (num == 0) {
    	num = 1;
  }
  std::cout << num << std::endl;
}

Measured memory_bytes: 256
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
signed main()
{
    fasino
    ll n;
    cin>>n;
    vector<ll> A(n);
    input(A,n);
    ll xi = 0;
    for(auto i:A) xi^=i;
    for(auto i:A){
        cout<<(xi^i)<<' ';
    }
    return 0;
}

Measured memory_bytes: 4728
using System;
using System.Runtime.Remoting.Metadata.W3cXsd2001;

namespace EmptyProject
{
    public class Program
    {
        public static void Main(String[] args)
        {
            int n = nextInt();
            int res = 0;
            for (int i = 1; i <= n; i++)
            {
                res += i;
            }

            Console.WriteLine(res);
        }

        static int nextInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }
}

Measured memory_bytes: 2776
#include<stdio.h>

unsigned short room[22][22];

void DFS(unsigned short x, unsigned short y);

int main(void) {

	unsigned short W, H, manx, many;
	unsigned short i, j, count = 0;
	char c[32];
	while(1){
		count=0;
		scanf("%hu%hu%*c", &W, &H);
		if(W==0 && H==0) break;
		for(i = 0; i < H + 2; i++) {
			if(i>0 && i<H+1) scanf("%s",c);
			for(j = 0; j < W + 2; j++) {
				if(i == 0 || j == 0 || i == H + 1 || j == W + 1) room[i][j] = 0;
				else{
					//putchar(c[j-1]);
					if(c[j-1]=='#') room[i][j]=0;
					else if(c[j-1]=='.') room[i][j]=1;
					else room[i][j]=2;
				}

				if(room[i][j] == 2) {
					manx = i;
					many = j;
					room[i][j] = 1;
				}
			}
		}
		DFS(manx, many);

		for(i = 1; i < H + 1; i++) for(j = 1; j < W + 1; j++) count += (room[i][j] == 2);

		printf("%hd\n", count);
	}
	return 0;
}

void DFS(unsigned short x, unsigned short y) {
	if(room[x][y] != 1) return;
	room[x][y] = 2;
	DFS(x - 1, y);
	DFS(x + 1, y);
	DFS(x, y - 1);
	DFS(x, y + 1);
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 500;
const double eps = 0.0000001;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

const int  MEIJI_Y = 1868,  MEIJI_M =  9,  MEIJI_D =  8;
const int TAISHO_Y = 1912, TAISHO_M =  7, TAISHO_D = 30;
const int  SHOWA_Y = 1926,  SHOWA_M = 12,  SHOWA_D = 25;
const int HEISEI_Y = 1989, HEISEI_M =  1, HEISEI_D =  8;

int main()
{
	int y, m, d;
	while( cin >> y >> m >> d ){
		if( cin.eof() ) break;
		
		if( y < 1868 )
			{ cout << "pre-meiji" << endl; continue; }
		
		if( y == 1868 && m < 9 )
			{ cout << "pre-meiji" << endl; continue; }
		
		if( y == 1868 && m == 9 && d < 8 )
			{ cout << "pre-meiji" << endl; continue; }
		
		if( MEIJI_Y <= y && y <= TAISHO_Y ){
			if( y == TAISHO_Y ){
				//ギリ大正.
				if( m > TAISHO_M ){
					printf("taisho 1 %d %d\n", m, d); continue;
				}
				if( m == TAISHO_M && d >= TAISHO_D ){
					printf("taisho 1 %d %d\n", m, d); continue;
				}
			}
			//明治.
			printf("meiji %d %d %d\n", y - MEIJI_Y + 1, m, d); continue;
		}

		if( TAISHO_Y < y && y <= SHOWA_Y ){
			if( y == SHOWA_Y ){
				//ギリ昭和.
				if( m > SHOWA_M ){
					printf("showa 1 %d %d\n", m, d); continue;
				}
				if( m == SHOWA_M && d >= SHOWA_D ){
					printf("showa 1 %d %d\n", m, d); continue;
				}
			}
			//大正.
			printf("taisho %d %d %d\n", y - TAISHO_Y + 1, m, d); continue;
		}

		if( SHOWA_Y < y && y <= HEISEI_Y ){
			if( y == HEISEI_Y ){
				//ギリ平成.
				if( m > HEISEI_M ){
					printf("heisei 1 %d %d\n", m, d); continue;
				}
				if( m == HEISEI_M && d >= HEISEI_D ){
					printf("heisei 1 %d %d\n", m, d); continue;
				}
			}
			//昭和.
			printf("showa %d %d %d\n", y - SHOWA_Y + 1, m, d); continue;
		}

		if( HEISEI_Y < y ){
			//平成.
			printf("heisei %d %d %d\n", y - HEISEI_Y + 1, m, d); continue;
		}
		
	}
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define N 200005
ll mod=998244353;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll sz[N];
ll id[N];
void pre(ll n)
{
    for(int i=0;i<=n;i++)
    {
        sz[i]=1;
        id[i]=i;
    }
}
ll root1(ll x)
{
    while(id[x]!=x)
    {
        x=id[x];
    }
    return x;
}
void union1(ll x,ll y)
{
    if(sz[x]>=sz[y])
    {
        id[y]=x;
        sz[x]+=sz[y];
    }
    else
    {
        id[x]=y;
        sz[y]+=sz[x];
    }
}
int main()
{
    fast;   
    ll n,m;
    cin>>n>>m;
    pre(n);
    ll x[m],y[m];
    vector<ll> v;
    for(int i=0;i<m;i++)
    {
        cin>>x[i]>>y[i];
    }
    ll x2=(n*(n-1))/2;
    v.pb(x2);
    for(int i=m-1;i>=0;i--)
    {
        ll p1=root1(x[i]);
        ll p2=root1(y[i]);
        if(p1==p2)
        {
            v.pb(x2);
        }
        else
        {
            ll q1=sz[p1];
            ll q2=sz[p2];
            x2-=q1*q2;
            v.pb(x2);
            union1(p1,p2);
        }
    }
    reverse(v.begin(),v.end());
    for(int i=1;i<v.size();i++)
    {
        cout<<v[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5364
N, K = map(int, raw_input().split())
a = []
b = []
for i in range(N):
    temp0, temp1 = map(int, raw_input().split())
    a.append(temp0)
    b.append(temp1)

index = sorted(range(N), key=a.__getitem__)

for i in range(N):
    K -= b[index[i]]
    if K <= 0:
        print(a[index[i]])
        break

Measured memory_bytes: 16420
#include <iostream>
#include <stdio.h>

using namespace std;

int Partition(int *arr, int startIndex, int thresholdIndex) {
	int thresholdValue, iteratorIndex;
	thresholdValue = arr[thresholdIndex];
	iteratorIndex = startIndex;

	for (int i = startIndex; i < thresholdIndex; i++) {
		if (arr[i] <= thresholdValue) {
			
			swap(arr[i] , arr[iteratorIndex]);
			iteratorIndex++;
		}
	}

	//since i == thresholdIndex, arr[i] <= thresholdValue
	swap(arr[iteratorIndex], arr[thresholdIndex]);

	return iteratorIndex;
}
int main() {

	int n, *arr;

	scanf("%d", &n);

	arr = new int[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}

	int q;

	q = Partition(arr, 0, n - 1);

	for (int i = 0; i < n; i++) {
		if (i) printf(" ");
		if (i == q) printf("[");
		printf("%d", arr[i]);
		if (i == q) printf("]");
	}


	cout << endl;

	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  int n,m;
  cin >> n >> m;
  vector<bool> a(n,false);
  vector<int> w(n);
  int ac;
  int wa=0;
  rep(i,m){
    int x; 
    string y;
    cin >> x >> y;
    if(a.at(x-1)){
    
    }else if(y=="AC"){
      ac++;
      wa+=w.at(x-1);
      a.at(x-1)=true;
    }else if(y=="WA"){
      w.at(x-1)++;
    }
  }
  cout << ac << " " << wa << endl;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int N; cin >> N;
    vector<string> S(N); REP(i, 0, N) cin >> S[i];

    // vector<string> data(N);
    // int data_num = 0;
    // int same_cnt = 0;
    // REP(i, 0, N){
    //     if (data_num == 0){
    //         data[0] = S[i];
    //         ++data_num;
    //     } else{
    //         REP(j, 0, data_num){
    //             if (S[i] == data[j]){
    //                 ++same_cnt;
    //                 break;
    //             }
    //         }
    //         if (same_cnt == 0){
    //             data[data_num] = S[i];
    //             ++data_num;
    //         }
    //         same_cnt = 0;
    //     }
    // }
    // cout << data_num << endl;

    set<string> st;
    REP(i, 0, N){
        st.insert(S[i]);
    }
    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 25076
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<ll> v(n);
    ll mn = 1LL << 60;
    ll mx = (1LL << 60) * -1;
    int mni,mxi;
    REP(i,n) {
        cin >> v[i];
        if (mx < v[i]) {
            mx = v[i];
            mxi = i;
        }
        if (mn > v[i]) {
            mn = v[i];
            mni = i;
        }
    }

    vector<pair<int,int>> p;
    
    if (mx < 0 || (abs(mx) < abs(mn))) {
        for (auto i = n-1; i > 0 ; i--) {
            while(v[i] < v[i-1]) {
                v[i-1] += mn;
                p.emplace_back(make_pair(mni+1,i));
                if (mn > v[i-1]) {
                    mn = v[i-1];
                    mni = i-1;
                }
            }
        }
    } else {
        for (auto i = 0; i < n-1 ; i++) {
            while(v[i] > v[i+1]) {
                v[i+1] += mx;
                p.emplace_back(make_pair(mxi+1,i+2));
                if (mx < v[i+1]) {
                    mx = v[i+1];
                    mxi = i+1;
                }
            }
        }
    }

    cout << p.size() << endl;
    for(auto x:p) {
        cout << x.first << " " << x.second << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i += 2) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)
#define pb(x) push_back(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int w, h;
vec<pi> edges;
void in(){
    cin >> w >> h;
    rep(i,0,w) edges.pb(pi(input(), 0));
    rep(i,0,h) edges.pb(pi(input(), 1));
}    

void solve(){
    
    sort(all(edges));
    int ans = 0;
    int hei = 0;
    int wid = 0;
    
    rep(i,0,w + h){
        int cost;
        if(edges[i].second == 0){//horizonal
            wid++;
            cost = (h + 1 - hei) * edges[i].first;
            ans += cost;
        }else{
            hei++;
            cost = (w + 1 - wid) * edges[i].first;
            ans += cost;
        }

    }
    print(ans);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

// 500 Yen Coins
int main(void) {

    int k, x;
    cin >> k >> x;

    if (500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3596