akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

#define MAX 2000000
#define CNTMAX 10000

int n, C[CNTMAX + 10];

void countingSort(int A[], int B[], int k){
    for(int i = 0; i < k; i++){
        C[i] = 0;
    }
    //count number of i
    for(int i = 0; i < n; i++){
        C[A[i]]++;
    }
    //count number less than i
    for(int i = 1; i < k; i++){
        C[i]  += C[i-1];
    }
    //sort
    for(int i = n - 1; i >= 0; i--){
        B[C[A[i]] - 1] = A[i];
        C[A[i]]--;
    }
}

int main(){
    int A[MAX], B[MAX];

    scanf("%d", &n);
    rep(i, n) scanf("%d", &A[i]);

    countingSort(A,B,CNTMAX);

    rep(i,n){
        if(i) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 18840
#include <bits/stdc++.h>
#define REP(a,b,c) for(int a=b; a<(int)c; a++)
#define REPD(a,b,c) for(int a=b; a>(int)c; a--)
#define rep(a,b) REP(a,0,b)
#define repd(a,b) REPD(a,b,0)
typedef long long int ll;
using namespace std;

int main(){
  int r, c;
  cin >> r >> c;
  vector< vector<int> > A(r, vector<int>(c));
  rep(i,r) rep(j,c) cin >> A[i][j];
  rep(i,r){
    int sum = 0;
    rep(j,c){
      sum += A[i][j];
      cout << A[i][j] << " ";
    }
    A[i].push_back(sum);
    cout << sum << endl;
  }
  rep(i, c+1){
    int sum = 0;
    rep(j, r){
      sum += A[j][i];
    }
    if(i != c)
      cout << sum << " ";
    else
      cout << sum;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 


int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll A,B;
	cin>>A>>B;
	
	cout<<(A*B)/(__gcd(A,B));
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

const int MAX = 510000; //nCrのr
//const ll INF = (ll)1e18 + 1;

#include <cassert>
long long fac[MAX], finv[MAX], inv[MAX], facn[MAX];
class mint {
public:
    long long x;
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    //mint operator-() const{ return mint(-x);}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

};

struct combination {
    vector<mint> fact, ifact;
    combination(long long n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(long long n, long long k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};


int main(){
  int N, K; cin >> N >> K;
  combination C(100000);
  for (int i = 1; i <= K; ++i){
    mint ans = C(N - K + 1, i) * C(K - 1, i - 1);
    cout << ans.x << endl;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
  while (true) {
    int a, b;
    int res;
    string c;
    cin >> a >> c >> b;

    if (c == "?") break;

    if (c == "+") {
      res = a + b;
    } else if (c == "-") {
      res = a - b;
    } else if (c == "*") {
      res = a * b;
    } else if (c == "/") {
      res = a / b;
    } else if (c == "%") {
      res = a % b;
    }

    cout << res << "\n";
  }
}


Measured memory_bytes: 3128
import bisect
n = int(input())
l = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        up = l[j] + l[i]
        #l[k] = up となるようなkのうち最小のものを見つけろ
        k = bisect.bisect_left(l, up)
        cnt += k - j - 1
print(cnt)


Measured memory_bytes: 45192
N, M, Q = map(int, input().split())
tmp = [list(map(int, input().split())) for i in range(Q)]


#最初に全てのAペアを作ればいいだけだった
#1stepで何するか
#終了条件
ans = [0]
def dfs(A):
    # print(A)
    if len(A) == N:
        tmp_ans = 0
        for ele in tmp:
            if A[ele[1]-1] - A[ele[0]-1] == ele[2]:
                tmp_ans += ele[-1]
        ans[0] = max(tmp_ans,ans[0])

        return
    
    A_min = A[-1]
    while(1):
        if A_min > M:
            break
        A.append(A_min)
        dfs(A)
        A.pop()
        A_min += 1

for i in range(M):
    dfs([i+1])

print(ans[0])



Measured memory_bytes: 8968
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#define N 100000
using namespace std;
int main()
{
	int n,k,s=0,i,j,t;
	scanf("%d %d",&n,&k);
	int a[n];
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=1;i<n;i++)
	for(j=0;j<n-i;j++){
		if(a[j]<a[j+1]){
			t=a[j];
			a[j]=a[j+1];
			a[j+1]=t;
		}
	}
	for(i=0;i<k;i++)
	s=s+a[i];
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Reflection.PortableExecutable;
    using System.Runtime.CompilerServices;
    using System.Text;
    using System.Xml.Serialization;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var n = Console.ReadLine();
            char c = n[0];
            if (Char.IsUpper(c))
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("a");
            }
            
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 25888
/******************************************
/@Author: LeafBelief
/@Date: 2020-04-04
/@Remark:    
/@FileName: swapbox
******************************************/
#include <bits/stdc++.h>
#define CSE(x,y) memset(x,y,sizeof(x))
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

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

const int maxn = 111111;

int main()
{
    //FAST;
    int a, b, c;
    while(cin >> a >> b >> c)
    {
        cout << c << " " << a << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

vector<int> h;

int main()
{
    int res = 0, n;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        h.push_back(tmp);

        bool flag = true;
        for (int j = 0; j < i; j++)
        {
            if (h[j] > h[i])
            {
                flag = false;
                break;
            }
        }

        if (flag)
        {
            res++;
        }
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 256
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

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

void solve(){
    int N,M,K;
    cin >> N >> M >> K;

    rep(p, N+1) rep(q, M+1) {
        if (M * p + N * q - 2 * p * q == K) {
            cout << "Yes" << endl;
            return;
        }
    }

    cout << "No" << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    string k = "keyence";
    string str1, str2;
    int find1, find2, find3;
    for (int i = 1; i <= 6; i++)
    {
        str1 = k.substr(0, i);
        str2 = k.substr(i, 7 - i);
        find1 = S.find(str1);
        find2 = S.rfind(str2);
        find3 = S.find(k);
        if ((find1 != string::npos && find2 != string::npos) && (find1 < find2) && (0 == find1) && (S.size() - (7 - i) == find2))
        {
            cout << "YES" << endl;
            return 0;
        }
        if (find3 != string::npos)
        {
            cout << "YES" << endl;
            return 0;
        }

    }

    cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string.h>
#include<cmath>
using namespace std;
int a[50];
int main()
{
    memset(a,0,sizeof(a));
    int n,m,s,b,t=0;cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        while(s--)
        {
            cin>>b;a[b]++;
        }
    }
    for(int i=1;i<=30;i++)
        if(a[i]==n)t++;
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
  long long int num, i, square = 0;
  
  while(scanf("%lld", &num) != EOF){
    square = 0;
    for(i = num; i <= 600-num; i += num){
      square += pow(i,2) * num;
    }
    printf("%lld\n", square);
  }
  return 0;
}

Measured memory_bytes: 592
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
int A, B;
int main(){
	cin >> A >> B;
	if(A <= 5) cout << 0 << endl;
	else if(A <= 12) cout << B/2 << endl;
	else cout << B << endl;
}

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

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

  vector<ll> C(N);
  rep(i, N) cin >> C.at(i);
  sort(C.begin(), C.end());

  ll ans = 0;
  rep(i, N) {
    ans += C.at(i) * (N - i + 1) % mod;
  }
  for (int i = 1; i < N; i++) {
    ans = ans * 4 % mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    ll rec = 100, sum = 0, a, b;
    REP(i, 5){
        cin >> a;
        b = a % 10 ? a % 10 : 10;
        if(b < rec) rec = b;
        sum += (a + 10 - b);
    }
    cout << sum - 10 + rec << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  string A, B, C;
  cin >> A >> B >> C;

  if(A[A.length()-1] == B[0]){
    if(B[B.length()-1] == C[0])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  else
    cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	int a, b;
	cin >> a >> s >> b;
	if (s == "+") {
		cout << a + b << endl;
	} else {
		cout << a - b << endl;
	}
}

Measured memory_bytes: 3620
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = int64_t;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
 string s;
 cin>>s;
 vector<bool>vec(26);
 rep(i,s.size()){
   vec.at((int)(s.at(i))-97)=1;
 }
 rep(i,26){
   if(!vec.at(i)){
     cout<<(char)(i+97)<<endl;
     return 0;
   }
 }
 cout<<"None"<<endl;

}




Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
long long n,k,m=1e9+7,ans,i,q,a[100000009],ans1,ans3,s;
long long axar(long long p,long long q)
{
	if(q==1) return p;
	long long w=axar(p,q/2);
	if(q%2==1)
	{
		return ((w*w)%m*p)%m;
	}
	if(q%2==0)
	{
		return (w*w)%m;
	}
}
int main()
{
	cin>>n>>k;
	for(i=k;i>=1;i--)
	{
		q=i;
		
		while(q<=k)
		{
			ans1+=a[q]%m;
			q+=i;
			ans1=(ans1+m)%m;
		}
		a[i]=(axar(k/i,n)-ans1)%m;
		ans1=0;
		a[i]=(a[i]+m)%m;
	}
	for(i=1;i<=k;i++)
	{
		ans3+=i*a[i]%m;
		ans3=(ans3+m)%m;
	}
	cout<<ans3;
}

Measured memory_bytes: 4380
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A, B, C = [int(x) for x in input().split()]

if B >= C-1:
    answer = C + B
elif (B+A) >= C-1:
    answer = B + C
else:
    answer = 2*B + A+1

print(answer)

Measured memory_bytes: 2940
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
int n, m, mat[15];
char ss[15][15];

inline bool g(int x, int y) {
    for (int i = 1; i <= n; i++)
        if (ss[i][x] != ss[mat[i]][y]) return 0;
    return 1;
}

bool used[15];
inline void check() {
    memset(used, 0, sizeof(used));
    used[0] = m & 1;
    for (int i = 1; i <= m; i++) {
        if (used[i]) continue;
        for (int j = i + 1; j <= m; j++) {
            if (g(i, j)) {
                used[i] = used[j] = 1;
                goto succ;
            }
        }
        if (!used[i] && used[0] && g(i, i)) {
            used[i] = 1;
            used[0] = 0;
            goto succ;
        }
        return;
    succ:;
    }
    puts("YES");
    exit(0);
}

void dfs(int x, bool y) {
    if (x > n) return check();
    if (mat[x]) return dfs(x + 1, y);
    if (y) mat[x] = x, dfs(x + 1, 0), mat[x] = 0;
    int z = x;
    while (++z <= n) {
        if (mat[z]) continue;
        mat[z] = x;
        mat[x] = z;
        dfs(x + 1, y);
        mat[z] = 0;
        mat[x] = 0;
    }
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%s", ss[i] + 1);
    dfs(1, n & 1);
    puts("NO");
    return 0;
}

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

int main()
{
	int64_t t;
	cin >> t;
	vector<int64_t> ns(t), ms(t), as(t), bs(t);
	for (int64_t i = 0; i < t; i++)
	{
		cin >> ns[i] >> ms[i] >> as[i] >> bs[i];
	}

	for (int64_t i = 0; i < t; i++)
	{
		cout << floor_sum(ns[i], ms[i], as[i], bs[i]) << endl;
	}

	return 0;
}

Measured memory_bytes: 5332
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def assign_color():
    _id = 1
    for m in range(vertices_num):
        if vertices_status_list[m] == -1:
            graph_dfs(m, _id)
            _id += 1
    return None


def graph_dfs(vertex, color):
    vertices_stack = list()
    vertices_stack.append(vertex)
    vertices_status_list[vertex] = color
    while vertices_stack:
        current_vertex = vertices_stack[-1]
        vertices_stack.pop()
        for v in adj_list[current_vertex]:
            if vertices_status_list[v] == -1:
                vertices_status_list[v] = color
                vertices_stack.append(v)
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num, relation_num = map(int, _input[0].split())

    relation_info = _input[1:relation_num + 1]

    question_num = int(_input[relation_num + 1])
    question_list = _input[relation_num + 2:]

    adj_list = [[] for _ in range(vertices_num)]
    vertices_status_list = [-1] * vertices_num

    for relation in relation_info:
        key, value = map(int, relation.split())
        adj_list[key].append(value)
        adj_list[value].append(key)

    assign_color()

    # print(adj_list)
    for question in question_list:
        start, target = map(int, question.split())
        if vertices_status_list[start] == vertices_status_list[target]:
            print("yes")
        else:
            print("no")

Measured memory_bytes: 35732
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

lint calc(vector<lint> &p,vector<lint> &n, int d,lint K,lint N){
  if(d>=p.size()){
    // cerr<<K<<endl;
    if(K==1)return 0;
    while(N%K==0)N/=K;
    if(N%K==1)return 1;
    else return 0;
  }else{
    lint ret=0;
    REP(i,n[d]+1){
      ret+=calc(p,n,d+1,K,N);
      // cerr<<p.size()<<":"<<d<<" "<<K<<endl;
      K*=p[d];
    }
    return ret;
  }
}

int main(){
  lint N;
  cin>>N;
  map<lint,int> m,m1;
  lint NC=N;
  FOR(i,2,sqrt(N)+2){
    while(NC%i==0){
      NC/=i;
      m[i]++;
    }
  }
  if(NC!=1)m[NC]++;
  NC=N-1;
  FOR(i,2,sqrt(N-1)+2){
    while(NC%i==0){
      NC/=i;
      m1[i]++;
    }
  }
  if(NC!=1)m1[NC]++;
  lint ans=0;
  // for(auto e:m)cerr<<e.first<<":"<<e.second<<endl;
  // for(auto e:m1)cerr<<e.first<<":"<<e.second<<endl;
  vector<lint>p,n;
  for(auto e:m){
    p.push_back(e.first);
    n.push_back(e.second);
  }
  ans+=calc(p,n,0,1,N);
  lint temp=1;
  for(auto e:m1)temp*=e.second+1;
  temp--;
  ans+=temp;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long

void test_case()
{
    ll n,w;
    cin>>n>>w;
    ll wt[n],i,j,val[n],INF=-2e8;
    for(i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    ll dp[n+1][w+1]={};
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=w;j++)
        {
            if(j==0)
                dp[i][j]=0;
            else if(i==0)
                dp[i][j]=0;
            else
            {
                if(j>=wt[i-1])
                {
                    dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-wt[i-1]]);
                }
                else
                    dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w];
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 79232
#include <iostream>
using namespace std;
#define ll long long int
int main() {
	ll k,a,b;
	cin>>k;
	cin>>a>>b;
	for(ll i=a;i<=b;i++){
	    if(i%k == 0){
	        cout<<"OK"<<endl;
	        return 0;
	    }
	}
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

class hopcroft_karp{
public:
	vector<vector<int> > graph; //linked list
	vector<int> dist,match;
	vector<bool> used,vv;

	hopcroft_karp(int n,int m) : graph(n),match(m,-1),used(n) {}

	void add_edge(int u,int v){
		graph[u].push_back(v);
	}

	//層グラフ作り
	void bfs(){
		dist.assign(graph.size(),-1);
		queue<int> que;
		for(int i = 0; i < graph.size(); i++){
			if (!used[i]){
				que.push(i);
				dist[i] = 0;
			}
		}

		while(!que.empty()){
			int a = que.front();
			que.pop();
			for(int i = 0 ; i < graph[a].size(); i++){
				int b = graph[a][i];
				int c = match[b];
				if(c >= 0 && dist[c] == -1){
					dist[c] = dist[a]+1;
					que.push(c);
				}
			}
		}
	}

	bool dfs(int a){
		vv[a] = true;
		for(int i = 0; i < graph[a].size(); i++){
			int b = graph[a][i];
			int c = match[b];
			if(c < 0 || (!vv[c] && dist[c] == dist[a]+1 && dfs(c))){
				match[b] = a;
				used[a] = true;
				return true;
			}
		}
		return false;
	}

	int bipartite_matching(){
		int ret = 0;
		while(1){
			bfs();
			vv.assign(graph.size(),false);
			int flow = 0;
			for(int i = 0; i < graph.size(); i++){
				if(!used[i] && dfs(i)) flow++;
			}
			if(flow == 0) return ret;
			ret += flow;
		}
	}

	void output(){
		for(int i = 0; i < match.size(); i++){
			if (~match[i]){
				cout << match[i] << " " << i << endl;
			}
		}
	}
};

int main()  //AOJ_ GRL_7_A
{
	int n;
	cin>>n;
	vector<P> red(n),blue(n);
	rep(i,n){
		int a,b;
		cin>>a>>b;
		// a--,b--;
		red[i] = P(a,b);
	}
	rep(i,n){
		int a,b;
		cin>>a>>b;
		// a--,b--;
		blue[i] = P(a,b);
	}

	hopcroft_karp g(n,n);

	rep(i,n){
		rep(j,n){
			if(red[i].first < blue[j].first && red[i].second<blue[j].second) g.add_edge(i,j);
		}
	}

	cout << g.bipartite_matching() << endl;

	return 0;
}



Measured memory_bytes: 256
long long a,b,c,z,strtoll();i,j;main(m,p){for(;scanf("%d%s",&m,p)*m;printf("%lld\n",z))for(z=9e18,i=2,a=strtoll(p,0,m);m>1;++i)if(m%i<1){for(c=j=0;m%i<1;++j)m/=i;for(b=a;b;)c+=b/=i;z>c/j?z=c/j:0;}}

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

int main() 
{
	string S,T;
	cin >> S>>T;

	int Tenki = 0;

	if (S[0] == T[0])
	{
		Tenki++;
	}
	
	if (S[1] == T[1])
	{
		Tenki++;
	}

	if (S[2] == T[2])
	{
		Tenki++;
	}

	cout << Tenki;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c,d;
	cin>>a>>b>>c;
	a=a[0];
	b=b[0];
	c=c[0];
	d=a+b+c;
	transform(d.begin(),d.end(),d.begin(),::toupper);
	cout<<d;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;
}


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

using namespace std;

int N, i;
char buff[10];
long m, a, r, c, h;

int main() {
  scanf("%d", &N);
  for(i = 0; i < N; i++) {
    scanf("%s", buff);
    switch(buff[0]) {
      case 'M':
        m++;
        break;
      case 'A':
        a++;
        break;
      case 'R':
        r++;
        break;
      case 'C':
        c++;
        break;
      case 'H':
        h++;
        break;
      default:
        break;
    }
  }
  long result = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
  printf("%ld", result);
  return 0;
}

Measured memory_bytes: 128
// #pragma GCC optimize "Ofast"
#include<bits/stdc++.h>
using namespace std;
typedef int  ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define INF 100001

bitset<100001> visitado[3];


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
	ll v,x,y,e,s,tt,in=0;
	// pll h;
	cin>>v>>e;
	vector<vl> grafo(v,vl(0));
	for(int i=0;i<e;i++)
    {
        cin>>x>>y;
        grafo[x-1].push_back(y-1);
    }
    cin>>s>>tt;
    s--;tt--;

	// vector<bool> visitado(v,false);
    vl dist(v,INF);
    dist[s]=0;
    deque<int> q;
    q.push_back(s); q.push_back(-1);
    int p=0, t;
    //pll & pairrr;
    while(true){
        t = q.front();

        // ll t=pairrr.first,p=pairrr.second ;
        q.pop_front();
        // cout<<t<<' '<<p<<'\n';
        if (-1 == t)
        {
            if (q.empty()) break;
            p++; q.push_back(-1);
            continue;
        }
        if(!(p%3))
        {
            dist[t]=p/3;
            if(t==tt) break;
        }
        for(int i : grafo[t]){
            if(visitado[(p+1)%3][i])continue;
            //dist[grafo[t][i]]=dist[t]+1;
            visitado[(p+1)%3].set(i);
            q.push_back(i);
        }
    }

	if(dist[tt]!=INF)cout<<dist[tt]<<"\n";
	else cout<<"-1\n";

	return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
long long N,M,K,H,W,L,R; 
int main(){
	cin >>N;
	string s;
	cin >>s;
	vector<int>r;
	vector<int>w;
	for(int i=0;i<N;i++)
		if(s[i]=='W')
			w.push_back(i);
	for(int i=N-1;i>=0;i--)
		if(s[i]=='R')
			r.push_back(i);
	int ans=0;
	M=min(r.size(),w.size());
	for(int i=0;i<M;i++)
		if(w[i]<r[i])
			ans++;
	cout <<ans <<endl;
	return 0;
}


Measured memory_bytes: 4544
#include<iostream>
#include<string>
#include<map>
#include<algorithm>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	map<string, int>mp;
	for (int i = 0; i < N; i++){
		string s;
		cin >> s;
		mp[s]++;
	}

	int max_cnt = 0;
	for (auto i:mp){
		max_cnt = max(max_cnt, i.second);
	}
	for (auto i : mp) {
		if (max_cnt != i.second) {
			continue;
		}
		cout << i.first << endl;
	}

	return 0;
}

Measured memory_bytes: 24960
import numpy as np
N, M, C = map(int, input().split())
B_line = np.array(list(map(int, input().split())))
count = 0
for i in range(N):
    A_line = np.array(list(map(int, input().split())))
    if np.sum(A_line * B_line) + C > 0:
        count += 1
print(count)

Measured memory_bytes: 13088
#include<stdio.h>
#include<string.h>
typedef struct{
	char w[33];
	int num;
}LIST;
int main(){
	LIST set[1000];
	char word[33],reset[33]={0};
	int a,b,f=0,n=0,max[2][2]={0};
	for(a=0;;a++){
		scanf("%c",&word[a]);
		if(word[a] == 32 || word[a] == 10){
			if(word[a] == 10){f = 1;}
			word[a] = 0;
			for(b=0;b<n;b++){
				if(strcmp(word,set[b].w) == 0){
				set[b].num++;
				break;
				}
			}
			if(b == n){
				strcpy(set[n].w,word);
				set[n].num = 1;
				n++;
			}
			if(f == 1){break;}
			a = -1;
			strcpy(word,reset);
		}
	}
	for(a=0;a<n;a++){
		int t = strlen(set[a].w);
		if(max[0][0] < set[a].num){max[0][1] = a;max[0][0] = set[a].num;}
		if(max[1][0] < t){max[1][1] = a;max[1][0] = t;}
	}
	printf("%s %s\n",set[max[0][1]].w,set[max[1][1]].w);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n, k, ans;
    cin >> n >> k;
    
    ans = 0;
    vector<int> a(n);
    
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }
    
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    for(int i = 0; i < k; ++i){
        ans += a.at(i);
    }
    
    cout << ans << endl;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n,m;
    cin>>n>>m;
    if(n==m) cout<< "Yes";
    else cout<< "No";


    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <utility>
#include <vector>
#include <stdio.h>

using namespace std;

int main() {
	vector<pair<int, int> > times;
	int N, M, h, m;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &h, &m);
		times.push_back(make_pair(h, m));
	}
	scanf("%d", &M);
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &h, &m);
		times.push_back(make_pair(h, m));
	}
	sort(times.begin(), times.end());
	times.erase(unique(times.begin(), times.end()), times.end());

	for (int i = 0; i < times.size(); i++) {
		printf("%d:%02d", times[i].first, times[i].second);
		printf("%c", " \n"[times.size() - 1 == i]);
	}
	return 0;
}

Measured memory_bytes: 2732
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Word
import qualified Data.ByteString as BSW
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U

-- Input: s t
-- Output: arr
--   arr ! (i,j) == length of lcs of (drop i s, drop j t)
--   (arr ! i) ! j == length of lcs of (drop i s, drop j t)
lcsTableV :: BS.ByteString -> BS.ByteString -> V.Vector (U.Vector Word16)
lcsTableV s t = V.scanr' (\ !x !v ->
                            U.scanr (\(!j,(!w,!u)) !l -> if x == BSW.index t j
                                                         then u + 1
                                                         else max w l
                                     ) 0 (U.indexed (U.zip (U.init v) (U.tail v)))
                         ) (U.replicate (n+1) 0) (V.fromListN m $ BSW.unpack s)
  where !m = BS.length s
        !n = BS.length t

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  let !table = lcsTableV s t
      !m = BS.length s
      !n = BS.length t
  let recon !i !j | i >= m || j >= n = Nothing
                  | x == y = let !i' = i+1 ; !j' = j+1
                             in Just (x, (i', j'))
                  | (table V.! (i+1)) U.! j >= (table V.! i) U.! (j+1) = recon (i+1) j
                  | otherwise = recon i (j+1)
        where x = BSW.index s i
              y = BSW.index t j
      (result, _) = BSW.unfoldrN (fromIntegral $ (table V.! 0) U.! 0) (\(!i,!j) -> recon i j) (0,0)
  BS.putStrLn result


Measured memory_bytes: 25980
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  string line;
  while(cin>>line){
    int c[9]={0};
    REP(i,13){
      c[line[i]-'1']++;
    }
    bool out[9]={false};
    REP(i,9){
      if(c[i]>=4) continue;
      int tmp[9];
      REP(j,9){
        REP(k,9) tmp[k] = c[k];
        tmp[i]++;
        if(tmp[j]<2) continue;
        tmp[j]-=2;
        REP(k,7){
          while(tmp[k]%3!=0){
            tmp[k]--;
            tmp[k+1]--;
            tmp[k+2]--;
          }
        }
        bool outp=true;
        REP(k,9) if(tmp[k]%3!=0||tmp[k]<0) outp = false;
        if(outp){
          out[i]=true;
          break;
        }
      }
    }

    bool f=false;
    REP(i,9)if(out[i]){
      if(f) cout<<" ";
      f = true;
      cout<<i+1;
    }
    if(!f) cout<<0;
    cout<<endl;
  }
  return 0;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define IF_DEBUG 0
typedef long long ll;
typedef double db;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}
string str;
ll ans, has[26];

int main()
{
	cin >> str;
	ans = 1ll*SZ(str)*(SZ(str)+1)/2;
	fo(i,0,SZ(str)-1) has[str[i]-'a'] ++;
	fo(i,0,25) ans -= 1ll*has[i]*(has[i]+1)/2;
	cout << ans+1;
	return 0;
}

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

typedef pair<int,int> PAIR;
const int INF=100000000;
 
int main() {
    string s;
    long long k;
    cin>>s>>k;

    for (int i = 0; i < k; i++){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }

    cout<<1<<endl;

}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad

import qualified Data.IntMap as M
import qualified Data.Sequence as S

import Data.Foldable(toList)
import Data.Maybe(fromMaybe)


r :: IO [Int]
r  = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine
    where toTup [a,b] = (a,b)


main :: IO ()
main = do
    [n,q] <- r :: IO [Int]

    ab <- replicateM (n-1) $ do
        [a,b] <- r
        return (a, S.singleton b)
    let treeMp = M.fromListWith (S.><) ab :: M.IntMap (S.Seq Int)

    px <- replicateM q rp
    let modifMp = M.fromListWith (+) px :: M.IntMap Int

    let res = solve 1 0 treeMp modifMp
    putStrLn $ intercalate " " $ map (show . snd) (sortOn fst $ toList res)


solve :: Int -> Int -> M.IntMap (S.Seq Int) -> M.IntMap Int -> S.Seq (Int,Int)
solve pos vac treeMp modifMp =
    let children    = fromMaybe S.empty (M.lookup pos treeMp)
        curVal      = fromMaybe 0 (M.lookup pos modifMp)
        newVal      = curVal + vac
        resElm      = (pos, newVal)
    in  resElm S.<| (do nPos <- children
                        solve nPos newVal treeMp modifMp)

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

int N;

class Q {
    public:
    long long a,b;
    Q (long long a,long long b) :
        a(a),b(b) {
        };

    bool operator <(const Q &q) const {
        return a*q.b < b*q.a;
    }
    bool operator >(const Q &q) const {
        return a*q.b > b*q.a;
    }
    bool operator ==(const Q &q) const {
        return a*q.b == b*q.a;
    }


};
bool comp(const pair<Q,string> &arg1,const pair<Q,string> &arg2) {
    if(arg1.first.a*arg2.first.b == arg1.first.b*arg2.first.a)
       return arg1.second < arg2.second;
    return arg1.first.a*arg2.first.b > arg1.first.b*arg2.first.a;

}

void solve() {
    vector<string> L(N);
    vector<pair<Q,string> > ans;
    rep(i,N) {
        string ss;
        long long p,a,b,c,d,e,f,s,m;
        cin>>ss>>p>>a>>b>>c>>d>>e>>f>>s>>m;
        long long mm = a+b+c;
        mm += (d+e)*m;
        long long pp = f*s;
        pp = pp*m-p;
        Q q(pp,mm);
        ans.push_back(make_pair(q, ss));
    }
    sort(ans.begin(), ans.end(), comp);
    rep(i,ans.size()) {
        cout<<ans[i].second<<endl;
    }
}
int main() {
    while(cin>>N) {
        if(!N) return 0;
        solve();
        cout<<"#"<<endl;
    }

    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

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

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    static int a[101][101];
    int r,c,i,j;
    scanf("%d%d",&r,&c);
    for (i=0 ; i<=r ;i++){
        for (j=0; j<c ;j++){
            scanf("%d",&a[i][j]);
            printf("%d ",a[i][j]);
            a[i][c]+=a[i][j];
            a[r][j]+=a[i][j];
        }printf("%d\n",a[i][c]);
    }





return 0;}



Measured memory_bytes: 2052
N, A, B, C = map(int, input().split())
dic = {'A':A,'B':B,'C':C}
S = [input() for _ in range(N)]

def solve(N,dic,S):
    ans = ['Yes']
    for i in range(N):
        if dic[S[i][0]]>dic[S[i][1]]:
            dic[S[i][0]]-=1
            dic[S[i][1]]+=1
            ans.append(S[i][1])
        elif dic[S[i][0]]<dic[S[i][1]] or dic[S[i][0]]>1:
            dic[S[i][1]]-=1
            dic[S[i][0]]+=1
            ans.append(S[i][0])
        elif dic[S[i][0]]==0:
            return ['No']
        elif i==N-1:
            dic[S[i][0]]+=1
            dic[S[i][1]]-=1
            ans.append(S[i][0])
        else:
            if S[i][0] in S[i+1]:
                dic[S[i][0]]+=1
                dic[S[i][1]]-=1
                ans.append(S[i][0])
            else:
                dic[S[i][1]]+=1
                dic[S[i][0]]-=1
                ans.append(S[i][1])
    return ans
print(*solve(N,dic,S),sep='\n')


Measured memory_bytes: 95392
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>

using namespace std;
int a[1000],b[1000];
int main()
{
    int A,B;
    cin>>A>>B;
    for(int i=1;i<=999;i++){
        a[i]=i+a[i-1];
    }
    for(int i=1;i<999;i++){
        if(abs(A-B)==a[i+1]-a[i]){
            cout<<a[i]-A<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,char>> sc(m);
    for(int i=0; i<m; i++){
        int s;
        char c;
        cin>>s>>c;
        sc[i]=make_pair(s,c);
    }
    if(n==1&&m==0){
        cout<<0<<endl;
        return 0;
    }
    sort(sc.begin(),sc.end());
    string ans="";
    for(int i=0; i<n; i++) ans+="r";

    for(int i=0; i<m; i++){
        for(int j=0; j<n; j++){
            if(j==sc[i].first-1 && ans[j]=='r'){
                ans[j]=sc[i].second;
                break;
            }else if( (j==sc[i].first-1) && (ans[j]!=sc[i].second) ){
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    if(n>1&&ans[0]=='0'){
        cout<<"-1"<<endl;
        return 0;
    }
    for(int i=0; i<n; i++){
        if(i>0&&ans[i]=='r') ans[i]='0';
        if(i==0&&ans[i]=='r') ans[i]='1';
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		//
		Scanner sc = new Scanner(System.in);
		// 最初の座標
		double firstX = 0;
		double firstY = 0;

		// 二つ目の座標
		double secondX = 0;
		double secondY = 0;

		while (sc.hasNext()) {
			// 最初の座標
			firstX = sc.nextDouble();
			firstY = sc.nextDouble();

			// 二つ目の座標
			secondX = sc.nextDouble();
			secondY = sc.nextDouble();

			break;
		}
		// 二つの座標の距離
		double answer;
		answer = Math.sqrt(((secondX - firstX) * (secondX - firstX))
				+ ((secondY - firstY) * (secondY - firstY)));

		System.out.println(answer);
	}
}

Measured memory_bytes: 18348
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n;
    scanf("%d",&n);
    int A[n];
 
    for(int i = 0; i < n; i++) scanf("%d",&A[i]);
 
    for(int i = n-1; i > 0; i--) printf("%d ",A[i]);
    printf("%d\n",A[0]);
}


Measured memory_bytes: 2664
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    char a;
    cin >> a;
    int num = (int)(a-'a');
if(num >= 0 && num <= 25) { 
    cout << 'a'<< endl;
}
else {
    cout << 'A' << endl;
}
}

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

using namespace std;

#define ll             long long int
#define eb             emplace_back

static const int maxn = 1e5 + 5;
static const ll mod = 1e9 + 7;

struct Info
{
      int days, rewards;
      Info(int days = 0, int rewards = 0) : days(days), rewards(rewards) {}

      friend bool operator < (Info A, Info B)
      {
            return A.rewards > B.rewards;
      }
};

int Tree[maxn];
int N = 100000 + 1;

void update(int pos)
{
      while (pos <= N)
      {
            Tree[pos] += 1;
            pos += (pos & -pos);
      }
}

int read(int pos)
{
      int sum = 0;
      while (pos > 0)
      {
            sum += Tree[pos];
            pos -= (pos & -pos);
      }
      return sum;
}

int query(int l, int r)
{
      return read(r) - read(l-1);
}

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);
      cout << fixed << setprecision(12);


      int n, m;
      cin >> n >> m;
      vector <Info> vec;
      for (int i = 0; i < n; i++)
      {
            int days, rewards;
            cin >> days >> rewards;
            if (days <= m) vec.eb(days, rewards);
      }
      sort(vec.begin(), vec.end());
      ll ans = 0;
      set <int> positions;
      for (int i = 1; i <= m; i++) positions.insert(i);
//      for (auto x : vec)
//      {
//            cerr << x.days << " --- " << x.rewards << endl;
//      }
      for (int i = 0; i < vec.size(); i++)
      {
            if (positions.empty()) break;
            int d = vec[i].days;
            int r = vec[i].rewards;
            int st = m - d + 1;
            auto lb = positions.lower_bound(st);
            if (lb == positions.begin())
            {
                  if (*lb <= st)
                  {
                        ans += r;
                        positions.erase(lb);
                  }
            }
            else
            {
                  if (lb == positions.end() or *lb > st) --lb;
                  if (*lb <= st)
                  {
                        ans += r;
                        positions.erase(lb);
                  }
            }
//            cerr << i << " " << ans << endl;
      }
      cout << ans << endl;
}


Measured memory_bytes: 5748
import sys
from math import log 

def solve(X: int):

    n = 100
    k = 0

    while n < X:
       n = int(n * 1.01)
       k += 1

    print(k)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9120