akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K, ans = 1;
    cin >> N >> K;
    REP(i, N) {
        ans = min(ans * 2, ans + K);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

int memo[200000];

int fac(int n){
  if(n==0)return 1;
  else return memo[n]=n*fac(n-1);
}

signed main(){
  int n;
  cin>>n;
  vector<int> a(n+1);
  rep(i,n)cin>>a[i+1];
  rep(i,n)a[i+1]+=a[i];
  map<int,int> mp;
  int ans=0;
  loop(i,1,n+1){
    mp[a[i]]++;
    if(a[i]==0)ans++;
  }

  for(auto x:mp){
    ans+=x.second*(x.second-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 14336
n, m = map(int, input().split())
matrix = []
for i in range(n) :
    col = list(map(int, input().split()))
    matrix.append(col)

vector = []
for i in range(m) :
    element = int(input())
    vector.append(element)

ans = []
for i in range(n) :
    ans_row = 0
    for j in range(m) :
        ans_row += matrix[i][j] * vector[j]
    ans.append(ans_row)

for ans_row in ans :
    print(ans_row)


Measured memory_bytes: 6012
#include <stdio.h>
#define NUM 50001

int prime[NUM];

void eratosthenes(void) {
    int i, j;
    prime[0] = 1;
    prime[1] = 1;
    for(i = 2; i < NUM; i++ ) {
        for(j = 2; j * i < NUM; j++ ) {
            prime[i*j] = 1;
        }
    }
}

int main(void) {
    int n, i, j, count;
    eratosthenes();
    while(scanf("%d",&n), n != 0) {
        count = 0;
        /*if(!prime[n]) {
            puts("0");
            continue;
        }*/
        if(!prime[n - 2]) {
            count++;
        }
        for(i = 3; i <= n / 2; i += 2 ) {
            if(!prime[i]) {
                if(!prime[n - i]) {
                    count++;
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

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

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

    rep(i,S.size()){
        if(S[i]!=T[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main() {
    string s; cin >> s;
    int w = 0;
    int b = 0;
    if(s[0]=='W') w ++;
    else b ++;
    for(int i = 1; i < s.length(); i ++) {
        if(s[i]==s[i-1]) continue;
        else {
            if(s[i]=='W') w ++;
            else b ++;
        }
    }
    int ans;
    if(w==b) ans = w+b-1;
    else ans = min(w,b) * 2;
    cout << ans << endl;
}

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

def f(N, A):
    
    if len(A) == 2:
        A.sort()
        print(A[1], A[0])
        return

    res = 0
    temp = 0
    maxA = max(A)

    for a in A:
        if a == maxA:
            continue
        
        b = min(a, maxA - a)
        if temp < b:
            temp = b
            res = a
        
    return print(maxA, res)

f(N, A)    



Measured memory_bytes: 14060
/*
* AUTHOR : Haoyang(Max) Chen
* INSTITUTION : Australian National Unversity
*/

#include <bits/stdc++.h>
using namespace std;

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

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

	string input;
	cin >> input;
	if (input[2] == input[3] && input[4] == input[5]) {
		cout << "Yes" << "\n";
	}else {
		cout << "No" << "\n";
	}


	return 0;
}


Measured memory_bytes: 3556
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, m;
    scan(n, m);
    auto x = aryread();
    // writeln(n);
    // writeln(x);
    // x.sort().writeln();
    x.sort();
    // writeln(x);
    if (x.length == 1 && m == 1)
    {
        writeln(0);
        return;
    }
    auto tmp = new long[](m - 1);

    foreach (i; 0 .. m - 1)
    {
        tmp[i] = abs(x[i + 1] - x[i]);
    }
    // writeln("差", tmp); //i番目はx[i]とx[i+1]の絶対値
    tmp.sort();
    // writeln("差をsort", tmp);
    long ans;
    foreach (i; 0 .. (m - n))
    {
        // writeln(tmp[i]);
        ans += tmp[i];
    }
    writeln(ans);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 7244
package main

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

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func check() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	capacity := make([]int, 0, 5)

	n := scanInt(sc)

	min := scanInt(sc)
	capacity = append(capacity, min)

	for i := 0; i < 5-1; i++ {
		v := scanInt(sc)
		if v < min {
			min = v
		}
		capacity = append(capacity, v)
	}

	minCount := n / min
	if n%min != 0 {
		minCount++
	}

	fmt.Printf("%d\n", minCount+4)

}

func main() {
	check()
}


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

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

const ll mod=1e9+7;
const ll inf=1ll<<60;

/*---------------------*/

ll n,k;
vector<ll> a,num[200009];

int main(){
    cin>>n>>k;
    a.resize(n);
    rep(i,n){
        cin>>a[i];
        num[a[i]].push_back(i);
    }
    ll x=0,cnt=1;
    do{
        auto itr=upper_bound(num[a[x]].begin(),num[a[x]].end(),x);
        if(itr==num[a[x]].end()){
            x=num[a[x]][0];
            cnt++;
        }else x=*itr;
        x=(x+1)%n;
    }while(x);

    k%=cnt;

    if(!k){
        cout<<endl;
        return 0;
    }
    while(k>1){
        auto itr=upper_bound(num[a[x]].begin(),num[a[x]].end(),x);
        if(itr==num[a[x]].end()){
            x=num[a[x]][0];
            k--;
        }else x=*itr;
        x=(x+1)%n;
    }

    vector<ll>ans;
    while(x<n){
        auto itr=upper_bound(num[a[x]].begin(),num[a[x]].end(),x);
        if(itr==num[a[x]].end()){
            ans.push_back(a[x]);
        }else x=*itr;
        x++;
    }

    rep(i,ans.size()){
        if(i)cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
}

Measured memory_bytes: 15732
n, m = map(int, input().split())
H = list(map(int, input().split()))
chk = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]:
        chk[b] = False
    if H[b] >= H[a]:
        chk[a] = False
cnt = 0
for j in chk:
    if j == True:
        cnt += 1
print(cnt)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define int long long

int N, K;
signed main(){
    cin >> N >> K;
    vector<int> A(200001,0);
    rep(i, N){
        int t; cin >> t;
        A[t]++;
    }
    sort(rall(A));
    
    int ans = N;
    rep(i,K){
        ans -= A[i];
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    if(n>=100 && n<=111)
        printf("111\n");
    else if(n>111 && n<=222)
        printf("222\n");
    else if(n>222 && n<=333)
        printf("333\n");
    else if(n>333 && n<=444)
        printf("444\n");
    else if(n>444 && n<=555)
        printf("555\n");
    else if(n>555 && n<=666)
        printf("666\n");
    else if(n>666 && n<=777)
        printf("777\n");
    else if(n>777 && n<=888)
        printf("888\n");
    else if(n>888 && n<=999)
        printf("999\n");
    return 0;
}


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

int N;
int A,B;
int T[1000] = {0};

int main(){
    cin >> N >> A >> B;
    for(int i=0;i<N;i++){
        cin >> T[i];
    }
    sort(T,T+N);
    int ans = 0;
    for(int i=0;i<N;i++){
        if(T[i] >= A && T[i] < B) ans++;
    }
    cout << N - ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    char lst = s[0];
    vector<int> a;
    int cnt = 1;
    for (int i = 1; i < n; i++){
        if (s[i] == lst){
            cnt++;
            if (s[i] == 'R') a.push_back(0);
        } else {
            a.push_back(cnt);
            if (s[i] == 'R'){
                for (int j = 0; j < cnt - 1; j++) a.push_back(0);
            }
            cnt = 1;
        }
        lst = s[i];
    }
    a.push_back(cnt);
    if (s[n - 1] == 'L'){
         for (int j = 0; j < cnt - 1; j++) a.push_back(0);
    }
    int sz = a.size();
    for (int i = 0; i + 1 < sz; i++){
        if (a[i] == a[i + 1] || a[i] == 0 || a[i + 1] == 0) continue;
        int sum = a[i] + a[i + 1];
        if (sum & 1){
            if ((i - a[i] + 1) & 1){
                if (i & 1){
                    a[i + 1] = sum / 2;
                    a[i] = sum - a[i + 1];
                } else {
                    a[i] = sum / 2;
                    a[i + 1] = sum - a[i];
                }
            } else {
                if (i & 1){
                    a[i] = sum / 2;
                    a[i + 1] = sum - a[i];
                } else {
                    a[i + 1] = sum / 2;
                    a[i] = sum - a[i + 1];
                }
            }
        } else {
            a[i] = sum / 2;
            a[i + 1] = sum / 2;
        }
        i++;
    }
    for (auto elem : a){
        cout << elem << " ";
    }
    return 0;
}


Measured memory_bytes: 1144
s = input()
t = input()
orz = False
for j in range(2):
  d = {}
  for i in range(len(s)):
    if s[i] in d and d[s[i]]!=t[i]:
      orz = True
      break
    d[s[i]] = t[i]
  s, t = t, s
print('No' if orz else 'Yes')

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define sc scanf
using namespace std;
const int N=3e5+5;
typedef unsigned long long ull;
template <typename it>int o(it a){cout<<a<<endl;return 0;}
int x,a;
int main(){
    cin>>x>>a;
    if(x<a)o(0);
    else o(10);
}

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

int main(){
    int a,b,i;
    string s;
    cin >> a >> b >> s;

    if(s[a] != '-'){
        cout << "No" << endl;
        return 0;
    }

    for(i = 0;i < s.size();i++){
        if(i != a && s[i] == '-'){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a % x == 0) {
		cout << b / x - a / x + 1;
	} else {
		cout << b / x - a / x;
	}
}

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


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

	// test
	solve();

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n, r;

void solve()
{
    cin >> n >> r;
    if (n>=10) {
        nout(r);
    }else {
        nout(r + (100*(10-n)));
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll N, cnt;
map<ll, map<ll, ll>> mm;

int main()
{
    /*for(int i = 0; i<=9; ++i)
        for(int j = 0; j<=9; ++j)
            mm[i][j] = 0;*/
    cin>>N;
    for(int i = 1; i<=N; ++i)
    {
        int tmp = i;
        while(tmp>=10) tmp/=10;
        mm[tmp][i%10]++;
        //cout<<i<<" "<<tmp<<" "<<i%10<<"\n";
    }

    for(auto i : mm)
    {
        for(auto j : i.second)
        {
            cnt+=j.second*mm[j.first][i.first];
        }
    }
    cout<<cnt<<"\n";
}

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

using namespace std;

int main(){
    int n,c;
    cin >> n >> c;
    vector<vector<int> > d(c,vector<int>(c));
    vector<vector<int> > t(3,vector<int>(c));

    for(int i=0;i<c;i++){
        for(int j=0;j<c;j++){
            cin >> d[i][j];
        }
    }

    int x;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> x;
            t[(i+j)%3][x-1]++;
        }
    }

    int res=1<<30;
    for(int i=0;i<c;i++){
        for(int j=0;j<c;j++){
            if(i!=j){
                for(int k=0;k<c;k++){
                    if(i!=k && j!=k){
                        int tt=0;
                        for(int l=0;l<c;l++){
                            tt+=d[l][i]*t[0][l];
                        }
                        for(int l=0;l<c;l++){
                            tt+=d[l][j]*t[1][l];
                        }
                        for(int l=0;l<c;l++){
                            tt+=d[l][k]*t[2][l];
                        }
                        if(tt<res){
                            res=tt;
                        }
                    }
                }
            }
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
N,A,B,C,*L=`dd`.split.map &:to_i
def dfs(cur, a, b, c)
	if cur==N
		return [a,b,c].min>0 ? (a-A).abs+(b-B).abs+(c-C).abs-30 : 1<<30
	end
	[
		dfs(cur+1, a, b, c),
		dfs(cur+1, a+L[cur], b, c) + 10,
		dfs(cur+1, a, b+L[cur], c) + 10,
		dfs(cur+1, a, b, c+L[cur]) + 10,
	].min
end
p dfs 0,0,0,0

Measured memory_bytes: 2044
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans_str = T.replace('r', 'a').replace('s', 'b').replace('p', 'c')
ans_str = list(ans_str.replace('a', 'p').replace('b', 'r').replace('c', 's'))

def rsp(arg):
    for x in 'rsp':
        if x not in arg: break
    return x

for i_str in range(K):
    idx = i_str
    while idx < len(ans_str):
        if idx > i_str:
            if ans_str[idx] == ans_str[idx - K]:
                if idx + K < len(ans_str):
                    ans_str[idx] = rsp((ans_str[idx - K], ans_str[idx + K]))
                else:
                    ans_str[idx] = rsp((ans_str[idx - K],))
        #
        idx += K

ans = 0
for ansi, Ti in zip(ans_str, list(T)):
    if ansi == 'r' and Ti == 's':
        ans += R
    if ansi == 's' and Ti == 'p':
        ans += S
    if ansi == 'p' and Ti == 'r':
        ans += P

print(ans)

Measured memory_bytes: 5044
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
int res[100][100];

int main(){
    int N;
    cin>>N;
    if(N==2){
        cout<<-1<<endl;
        return 0;
    }
    if(N%2==1){
        for(int i=0;i<N;i++){
            for(int j=0;j<N-1;j++){
                res[i][j]=(i+j+1)%N + 1;
            }
        }
    }else{//人の番号は 1~N
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N-1;j++){
                if(i==N){
                    if(j==N/2){
                        res[i-1][j-1]=1;
                    }else if(j==1){
                        res[i-1][j-1]=N/2;
                    }else{
                        res[i-1][j-1]=j;
                    }
                }else{
                    if(i==j){
                        res[i-1][j-1] = (i-1+N/2)%N+1;
                    }else if(i == j+N/2 || i == j-N/2){
                        res[i-1][j-1]=N;
                    }else{
                        res[i-1][j-1]=j;
                    }
                }
            }
        }
        
        
    }
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cout<<res[i][j]<<' ';
        }cout<<endl;
    }
    
    
    
    return 0;
}


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

int main(){
   int r, D, x2000;
   cin >> r >> D >> x2000;
   vector<int> x(11);
   x.at(0) = x2000;
   for (int i=1; i<=10; i++){
      x.at(i) = r*x.at(i-1) - D;
   }

   for (int i=1; i<=10; i++){
      cout << x.at(i) << endl;
   }
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;

int main()
{
    int n;
    int a,b,c,d;
    a=b=c=d=0;
    scanf("%d",&n);
    while(n--)
    {

        string s;
        cin>>s;
        if(s=="AC") a++;
        else if(s=="WA") b++;
        else if(s=="TLE") c++;
        else if(s=="RE") d++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,b,c,d);
}


Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string>
#include<set>
#include<limits.h>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<functional>
#include<stack>
#include<deque>
#include<queue>
#define int long long
using namespace std;

signed main() {
	int x, y; cin >> x >> y;
	int ans = 1;
	while (x * 2 <= y) {
		x *= 2;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
s = int(input())
def fn(n):
    if n%2 == 0:
        return n/2
    else:
        return 3*n+1
tmp = [s]
flag = 1
count = 1
while flag == 1:
    count += 1
    s = fn(s)
    tmp.append(s)
    if s in tmp[:-1]:
        break
print(count)

Measured memory_bytes: 3188
#include <stdio.h>

int main()
{
    int n, ans;
    char oc, cc;
    scanf("%d", &n);
    ans = 0; oc = 0;
    for (int i=0; i<n; i++) {
        scanf(" %c", &cc);
        if (oc != cc) {
            ans++;
        }
        oc = cc;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
n,d = map(int, input().split())

x_list = []
for i in range(n):
    tmp = list(map(int, input().split()))
    x_list.append(tmp)

ans = 0
for j in range(n):
    for k in range(1,n-j):
        tmp = 0
        for l in range(d):
            tmp += abs(x_list[j][l]-x_list[j+k][l])**2
        tmp = tmp**0.5

        if tmp.is_integer() == True:
            ans += 1

print(ans)

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

using namespace std;

int main(){
    long long a,b,x,tmp,ans;

    cin>>a>>b>>x;

    ans=b/x - a/x;
  
  if(a%x == 0){
    ans=ans+1;
  }
    

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define bitcount(b) __builtin_popcount(b)
#define all(n) n.begin(),n.end()
typedef pair<double,double> P;
#define x first
#define y second

double tri(P a,P b, P c){
	a.x -= c.x, a.y -= c.y;
	b.x -= c.x, b.y -= c.y;
	c.x -= c.x, c.y -= c.y;
	
	return fabs( b.x * a.y - a.x * b.y ) / 2.0;
}

int main(){
	vector<P> d(4);
	string line;
	while( getline(cin,line) ){
		while(~line.find(","))line[line.find(",")] = ' ';
		stringstream ss(line);
		rep(i,4)ss >> d[i].x >> d[i].y;
		
		double S = tri(d[0],d[2],d[1]) + tri(d[0],d[2],d[3]);
		
		bool flag = true;
		
		rep(i,4){
			double s = tri(d[0],d[2],d[1]) + tri(d[0],d[2],d[3]);
			if( s != S)flag = false;
			rotate(d.begin(),d.begin()+1,d.end());
		}
		cout << (flag?"YES":"NO") << endl;
	}
}

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

#define lint long long
#define P pair<int, lint>

const lint INF = 1E15;

int main() {
    int Q;
    cin >> Q;
    int u[Q],a[Q], b[Q];
    
    lint sum = 0;
    priority_queue<int> small;
    priority_queue<int, vector<int>, greater<int>> big;
    int pos;
    lint num = 0;

    for(int i = 0; i < Q; ++i){
        cin >> u[i];
        if(u[i] == 1){
            cin >> a[i] >> b[i];
        } else {
            continue;
        }
    }

    {
        pos = a[0];
        num = 0;
        sum = b[0];
    }

    for(int i = 1; i < Q; ++i){
        if(u[i] == 1){
            sum += b[i];
            if(a[i] > pos){
                big.push(a[i]);
            } else {
                small.push(a[i]);
            }
            num += (abs(a[i] - pos));

            if(small.size() > big.size()){
                big.push(pos);
                pos = small.top(); small.pop();
            }
            if(big.size() > small.size() + 1){
                small.push(pos);
                pos = big.top(); big.pop();
                
                num -= abs(pos - small.top()) * (big.size() - small.size() + 1);
            }


        } else {
            cout << pos << " " << num + sum << endl;
        }
    }


}


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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  int peaple[N] = {0};
  for(int i=0; i<Q; i++){
    int a;
    cin >> a;
    peaple[a-1]++;
  }

  for(int i=0; i<N; i++){
    if(peaple[i] > Q - K){
      cout << "Yes" << endl;
      continue;
    }
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <vector>
#include <string>
#include <bitset>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
 
typedef long long ll;
typedef long double ld;
 
const ll MOD = 1e9 + 7, INF = 1e18 + 1;
 
using namespace std;
ll n, k, even, x[1000000], y[1000000];

bool is_in (ll c_x, ll c_y, ll x, ll y, ll r)
{
	return (abs (c_x + c_y - (x + y)) <= r && abs (c_x - c_y - (x - y)) <= r);
}

string find (ll x, ll y)
{
	string s;

	ll c_x = 0, c_y = 0;

	if (even) 
	{
		s += 'U';
		c_y++;
	}

	ll sum = 0;

	for (ll i = 34; i >= 0; i--)
		sum += (1LL << i);

	for (ll i = 34; i >= 0; i--)
	{
		//cout << x << ' ' << y << ' ' << c_x << ' ' << c_y << endl;

		sum -= (1LL << i);

		if (is_in (c_x, c_y + (1LL << i), x, y, sum))
		{
			s += 'U';
			c_y += (1LL << i);
		}
		else if (is_in (c_x + (1LL << i), c_y, x, y, sum))
		{
			s += 'R';
			c_x += (1LL << i);
		}
		else if (is_in (c_x, c_y - (1LL << i), x, y, sum))
		{
			s += 'D';
			c_y -= (1LL << i);
		}
		else if (is_in (c_x - (1LL << i), c_y, x, y, sum))
		{
			s += 'L';
			c_x -= (1LL << i);
		}
	}

	return s;
}

int main ()
{
	cin >> n;

	for (ll i = 0; i < n; i++)
	{
		scanf ("%lld%lld", &x[i], &y[i]);
		if (i && abs (x[i] + y[i]) % 2 != abs (x[i-1] + y[i-1]) % 2)
		{
			cout << "-1";
			return 0;
		}
	}

	if ((x[0] + y[0]) % 2 == 0)
	{
		cout << 36 << endl;
		cout << 1 << ' ';
		even = 1;
	}
	else cout << 35 << endl;

	for (ll i = 34; i >= 0; i--)
		cout << (1LL << i) << ' ';

	for (ll i = 0; i < n; i++)
	{
		cout << find (x[i], y[i]) << endl;
	}
}


Measured memory_bytes: 2304
#include <iostream>
#include <set>
#include <vector>

using namespace std;

#define forsn(i,s,n) for(int i=(s); i<(int)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define F first
#define S second
#define contains(x, c) ((c).find(x) != (c).end())

vector<set<int> > edges;
int n, m; 

bool works() {
	forsn(i,1,n-1) {
		if (contains(0, edges[i]) && contains(n - 1, edges[i])) return true;
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	edges = vector<set<int> >(n, set<int>());
	forn(i,m) {
		int a, b; cin >> a >> b; a--, b--;
		edges[a].insert(b);
		swap(a,b);
		edges[a].insert(b);
	}
	
	cout << (works()? "POSSIBLE" : "IMPOSSIBLE") << "\n";
}


Measured memory_bytes: 28416
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(void)
{
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  for (int i=0;i<n;i++){
    cin >> h[i];
  }
  vector<int> c(n, 1);
  
  ll a, b;
  for (int j=0;j<m;j++){
    cin >> a >> b;
    if (h[a-1] > h[b-1]){
      c[b-1] = 0;
    }else if (h[a-1] == h[b-1]){
      c[a-1] = 0;
      c[b-1] = 0;
    }else {
      c[a-1] = 0;
    }
  }
  
  ll cnt = 0;
  for (int i=0;i<n;i++){
    if (c[i] == 1){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 4548
#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
using namespace std;
 
#define INF 1<<21
#define MAX 100005
#define MOD 10e9+7
 
int main(){
    string s1,s2;
    cin>>s1;
    cin>>s2;
    if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
 
    return 0;   
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = (1..13).to_a
h = (1..13).to_a
c = (1..13).to_a
d = (1..13).to_a

while line = gets
  card = line.chomp.split(' ')
  if card[0] == 'S'
    s[card[1].to_i - 1] = 0
  elsif card[0] == 'H'
    h[card[1].to_i - 1] = 0
  elsif card[0] == 'C'
    c[card[1].to_i - 1] = 0
  elsif card[0] == 'D'
    d[card[1].to_i - 1] = 0
  end
end

s.each do |x|
  if x != 0
    print "S #{x}\n"
  end
end
h.each do |x|
  if x != 0
    print "H #{x}\n"
  end
end
c.each do |x|
  if x != 0
    print "C #{x}\n"
  end
end
d.each do |x|
  if x != 0
    print "D #{x}\n"
  end
end

Measured memory_bytes: 6120
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int main(int, char *[])
{
    int N;
    vector<int> A;
    cin >> N;
    for(int i = 0; i < N; ++i)
    {
        int v;
        cin >> v;
        A.push_back(v);
    }
    sort(A.begin(), A.end(), greater<int>());
    cout << A.front();

    int min_idx = N - 1;
    for(int i = 1; i < N; ++i)
    {
        const double diff0 = std::abs(A.front() * 0.5 - A[min_idx]);
        const double diff1 = std::abs(A.front() * 0.5 - A[i]);
        if(diff0 > diff1)
            min_idx = i;
    }
    cout << ' ' << A[min_idx] << endl;

    return 0;
}


Measured memory_bytes: 892
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int r, d, x;
    cin >> r >> d >> x;
    for(int i=1;i<=10;i++){
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
 
int main()
{
	int N;
	std::cin >> N;
	std::string ans;
 
	int temp;
	int mod;
	for (int i = 0; N != 0 && N != -0; ++i) {
		temp = static_cast<int>(std::pow(-2, i));
		mod = static_cast<int>(std::fmod(N, std::pow(-2, i + 1)));
		if (mod == 0 || mod == -0)
			ans += "0";
		else {
			ans += "1";
			N -= temp;
		}
	}
 
	if (ans == "")
		std::cout << "0\n";
	else {
		std::reverse(ans.begin(), ans.end());
		std::cout << ans << '\n';
	}
 
	return 0;
}

Measured memory_bytes: 256
def mpow(x, n):
    result = 1
    while n != 0:
        if n & 1 == 1:
            result *= x
            result %= 1000000007
        x *= x
        x %= 1000000007
        n >>= 1
    return result


max_A = 1000000

N = int(input())
A = list(map(int, input().split()))

sieve = [0] * (max_A + 1)
sieve[0] = -1
sieve[1] = -1
for i in range(2, max_A + 1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    for j in range(i * i, max_A + 1, i):
        if sieve[j] == 0:
            sieve[j] = i

lcm_factors = {}
for i in range(N):
    t = []
    a = A[i]
    while a != 1:
        if len(t) == 0:
            t.append([sieve[a], 1])
        elif t[-1][0] == sieve[a]:
            t[-1][1] += 1
        else:
            t.append([sieve[a], 1])
        a //= sieve[a]
    for k, v in t:
        if k not in lcm_factors or lcm_factors[k] < v:
            lcm_factors[k] = v

lcm = 1
for k in lcm_factors:
    for i in range(lcm_factors[k]):
        lcm *= k
        lcm %= 1000000007

result = 0
for i in range(N):
    result += lcm * mpow(A[i], 1000000007-2)
    result %= 1000000007
print(result)


Measured memory_bytes: 14532
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
int seg[20000000];
int n,q;
void add(int a,int b){
    a+=n-1;
    seg[a]+=b;
    while(a>0){
        a=(a-1)/2;
        seg[a]+=b;
    }
}
int sum(int a,int b,int l,int m,int k){
    if(a<=l&&m<=b)return seg[k];
    
    if(m<a||b<l)return 0;
    
    return sum(a,b,l,(l+m-1)/2,k*2+1)+sum(a,b,(l+m+1)/2,m,k*2+2);
}
int main(void){
   cin>>n>>q;
   int n1=1;
   for(;n1<n;n1*=2);
   n=n1;
   for(int i=0;i<q;i++){
       int c,x,y;
       cin>>c>>x>>y;
       x--;
       if(c==0){
           add(x,y);
       }else{
           y--;
           cout<<sum(x,y,0,n-1,0)<<endl;
       }
   }
   
}

Measured memory_bytes: 3880
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const int MX = 500005;
const int MD = 1e9+7;
int n, a[MX], z[MX], pr[1<<20];
ll ans, d[1<<20][2];
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", a+i);
		if(i) a[i] ^= a[i-1];
	}
	if(a[n-1]){
		d[0][0] = {1};
		rep(i,n){
			if(a[i] == a[n-1]) (d[0][1] += d[0][0]) %= MD;
			else if(!a[i]) (d[0][0] += d[0][1]) %= MD;
		}
		ans = d[0][0];
	}else{
		fill(pr, pr+(1<<20), -1);
		rep(i,1<<20) d[i][0] = 1;
		rep(i,n){
			if(a[i]){
				(d[a[i]][0] += (z[i] - z[pr[a[i]]]) * d[a[i]][1]) %= MD;
				(d[a[i]][1] +=  d[a[i]][0]) %= MD;
				pr[a[i]] = i;
			}else z[i]++;
			z[i+1] += z[i];
		}
		rep(i,1<<20) (ans += d[i][1]) %= MD;
		rep(i,z[n]-1) (d[0][0] *= 2) %= MD;
		(ans += d[0][0]) %= MD;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 24576
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n;
  cin >> n;

  for (int i = 1; i <= 9; i++) {
    if (n % i == 0) {
      int x = n / i;
      if (1 <= x && x <= 9) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    int n;
    cin >> n;
    vector<int> l1(n), l2(n);
    for(int i = 0; i < n; i++){
        cin >> l1[i];
        if(i != 0){
            l1[i] += l1[i-1];
        }
    }
    for(int i = 0; i < n; i++){
        cin >> l2[i];
        if(i == 0) l2[i] += l1[i];
        else l2[i] += max(l2[i-1], l1[i]);
    }

    cout << l2[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <limits>

using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;

    vector <int> v(n), summ(n, numeric_limits <int> :: max() - 1);

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

    summ[n - 1] = 0;

    for (int i = n - 2; i >= 0; i--)
    {

        for (int j = i + 1; j <= min(n - 1, i + k); j++)
        {
            summ[i] = min(abs(v[i] - v[j]) + summ[j], summ[i]);
        }
    }

    cout << summ[0];
    return 0;
}


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

int main() {
  int H,N;
  cin >> H >> N;
  
  vector<int> A(N);
  
  for (int i = 0; i<N; i++){
    cin >> A.at(i);
  }
  
  int S;
  S = 0;
  for (int i = 0; i<N; i++){
    S = S + A.at(i);
  }
  
  if(H<=S){
    cout<< "Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}








Measured memory_bytes: 640
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("%s = %d\n", #x, x)
#define debug2(x, y) printf("%s = %d, %s = %d\n", #x, x, #y, y)
#define debug3(x, y, z) printf("%s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z)
#define debug4(x, y, z, t) printf("%s = %d, %s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z, #t, t)
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;
const ll MOD = 1000000007ll;

ll n, m, ans = 1, cnt, DP[MAXN + 30][30];

void init() {
    DP[0][0] = 1;

    for (int i = 1; i < MAXN + 30; i++) {
        DP[i][0] = 1;

        for (int j = 1; j < 30; j++) {
            DP[i][j] = (DP[i - 1][j] + DP[i - 1][j - 1]) % MOD;
        }
    }
}

int main() {
    init();

    scanf("%lld%lld", &n, &m);

    for (ll i = 2; i * i <= m; i++) {
        cnt = 0;

        while (m % i == 0) {
            cnt++;
            m = m / i;
        }
        
        ans = cnt > 0 ? (ans * DP[n + cnt - 1][cnt]) % MOD : ans;
    }

    if (m != 1) {
        ans = (ans * n) % MOD;
    }

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

    return 0;
}

Measured memory_bytes: 23680
#include<stdio.h>
int main() {
	int sx,sy,tx,ty;
	scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
	for(int i=1;i<=ty-sy;i++) {
		printf("U");
	}
	for(int i=1;i<=tx-sx;i++) {
		printf("R");
	}
	for(int i=1;i<=ty-sy;i++) {
		printf("D");
	}
	for(int i=1;i<=tx-sx;i++) {
		printf("L");
	}
	printf("L");
	for(int i=1;i<=ty-sy+1;i++) 
		printf("U");
	for(int i=1;i<=tx-sx+1;i++) 
		printf("R");
	printf("D");
	printf("R");
	for(int i=1;i<=ty-sy+1;i++) 
		printf("D");
	for(int i=1;i<=tx-sx+1;i++) 
		printf("L");
	printf("U");
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
n,c = map(int, input().split())
channels = {i:[] for i in range(1,c+1)}
table = [0 for _ in range(200004)]
for _ in range(n):
    s,t,c = map(int, input().split())
    channels[c].append([s,t])

for ch, time in channels.items():
    sub = [0 for _ in range(200004)]
    for s,t in time:
        if sub[s*2]:
            sub[s*2] = 0
        else:
            sub[s*2-1] = 1
        if sub[t*2-1]:
            sub[t*2-1] = 0
        else:
            sub[t*2] = -1
    for i in range(1,200002):
        sub[i] += sub[i-1]
        table[i] += max(0, sub[i])
ans = 0
for i in range(1,200002):
    ans = max(ans, table[i])
print(ans)


Measured memory_bytes: 119656
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m;
    cin >> m;
    ll ans = 0;
    ll sum = 0;
    REP(i,m){
        ll d,c;
        cin >> d >> c;
        ans+=c;
        sum+=d*c;
    }
    ans--;
    ans+=(sum-1)/9;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

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


    for (int i = 0; i < S.size() - 1; ++i) {
        string before = S.substr(i, 1);
        string after = S.substr(i + 1, 1);

        if (before == after) {
            cout << "Bad" << endl;
            return 0;
        }
    }

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

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<int,int> pll;
typedef pair<string,string> pss;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

struct city{
	int index;
	int year;
	string pref;
} v[N];

bool compare(city a, city b){
	return a.year < b.year;
}

//~ pair<int,string> v[N];
int cont[N];
pair<int,string> ans[N];

string fun(string s){
	
	if(sz(s) >= 6)
		return s;
	else{
		
		int x = 6-(int)sz(s);
		rep(i,1,x)
			s ="0"+s;
		
		return s;
	}
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}


string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int main(){
	clr(cont,0);
	int n, m; cin>> n >> m;
	string p; int y;
	rep(i,1,m){
		cin>> p >> y;
		v[i].year = y;
		v[i].pref = p;
		v[i].index = i;
	}
	sort(v+1,v+1+m,compare);
	
	
	rep(i,1,m){
		int x =  conv(v[i].pref);
		string s = fun(v[i].pref) + fun( conv(cont[x]+1) );
		cont[x]++;
		ans[i] = mp(v[i].index,s);
	}
	sort(ans+1,ans+1+m);
	
	rep(i,1,m){
		cout<< ans[i].s << endl;
	}
	
	return 0;
}


Measured memory_bytes: 19456
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+7;
ll sum[N], pre[N];
pair<ll, int> a[N];
int b[N], l[N], u[N];
int check(int n, int m, int k)
{
	for(int i = 1; i <= m; i++)
	{
		int p = a[i].second;
		if(sum[m+1]-sum[i]+sum[i-1]+(ll)(k-b[p])*(k >= b[p] ? u[p] : l[p])-pre[n]+pre[m+1]>=0)
		{
			return true;
		}
	}
	for(int i = m+1; i <= n; i++)
	{
		int p = a[i].second;
		if(sum[m]+(ll)(k-b[p])*(k >= b[p] ? u[p] : l[p])-pre[n]+pre[i]-pre[i-1]+pre[m]>=0)
		{
			return true;
		}
	}
	return false;
}
int main()
{
	int n, x;
	scanf("%d%d", &n, &x);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d%d%d", &b[i], &l[i], &u[i]);
		a[i] = make_pair((ll)(x-b[i])*u[i]+(ll)b[i]*l[i], i);
	}
	sort(a+1, a+1+n);
	reverse(a+1, a+1+n);
	for(int i = 1; i <= n; i++)
	{
		pre[i] = pre[i-1]+(ll)b[a[i].second]*l[a[i].second];
		sum[i] = sum[i-1]+(ll)(x-b[a[i].second])*u[a[i].second];
	}
	ll l = 0, r = (ll)n*x;
	while(l<r)
	{
		ll mid = (l+r)>>1;
		//printf("%lld %d\n", mid, check(n, mid/x, mid%x));
		if(check(n, mid/x, mid%x))
		{
			r = mid;
		}
		else
		{
			l = mid+1;
		}
	}
	printf("%lld\n", l);
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);


const int M=1000000007;

int n,ret=1,tmp=1;
int f[1000010];

main(){
    #define task "TASK"
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);

    n=in;
    forinc(i,1,n){
        f[i]=(f[i]+f[i-1])%M;
        tmp=(tmp+f[i])%M;
        f[i+3]=(f[i+3]+tmp)%M;
        ret=(ret+tmp%M*(n-1)%M*(i==n ? 1 : n)%M)%M;
    }
    cout<<ret;
}


Measured memory_bytes: 8064
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

void solve(long long a, long long b, long long c, long long d, long long e,
           long long k) {
             VI arr;
             arr.PB(a);
             arr.PB(b);
             arr.PB(c);
             arr.PB(d);
             arr.PB(e);
             for(int i=0; i < 5; i++){
               for(int j=1; j<5; j++){
                 if(arr[j]-arr[i]>k){
                   cout<<":("<<endl;
                   return;
                 }
               }
             }
             cout<<"Yay!"<<endl;
             return;
           }

int main() {
  long long a;
  scanf("%lld", &a);
  long long b;
  scanf("%lld", &b);
  long long c;
  scanf("%lld", &c);
  long long d;
  scanf("%lld", &d);
  long long e;
  scanf("%lld", &e);
  long long k;
  scanf("%lld", &k);
  solve(a, b, c, d, e, k);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
const int MAX_N = 200000;
const int MAX_M = 30;

int main() {
  int N, ans = 0; scanf("%d", &N);
  vi A, As[MAX_M], B, Bs[MAX_M];
  for (int i = 0; i < N; i++) {
    int tmp; scanf("%d", &tmp);
    A.pb(tmp);
  }
  for (int i = 0; i < N; i++) {
    int tmp; scanf("%d", &tmp);
    B.pb(tmp);
  }
  int base = 1;
  for (int i = 0; i < MAX_M; i++) {
    for (int j = 0; j < N; j++) {
      Bs[i].pb(B[j] % base);
      As[i].pb(A[j] % base);
    }
    sort(Bs[i].begin(), Bs[i].end());
    base <<= 1;
  }

  base = 1;
  for (int i = 1; i < MAX_M; i++) {
    int cnt = 0;
    for (int ind = 0; ind < N; ind++) {
      int a = As[i][ind];
      cnt += lower_bound(Bs[i].begin(), Bs[i].end(), 2*base - a) - lower_bound(Bs[i].begin(), Bs[i].end(), base - a);
      cnt += lower_bound(Bs[i].begin(), Bs[i].end(), 4*base - a) - lower_bound(Bs[i].begin(), Bs[i].end(), 3*base - a);
    }
    ans += base * (cnt&1);
    base <<= 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 51124
#include<stdio.h>

int main(void)
{
	int a[10000];
	int i, j;
	
	for (i = 0; i < 10000; i++) {
		scanf("%d", &a[i]);
		
		if (a[i] == 0) {
			break;
		}
	}
	
	for (j = 0; j < i; j++) {
		printf("Case %d: %d\n", j + 1, a[j]);
	}
	
	return (0);
}

Measured memory_bytes: 632
# -*- coding: utf-8 -*-
M, D = map(int, input().split())

ans_count = 0
if D >= 22:
    for i in range(22, D + 1):
        first_place = i % 10
        tenth_place = i // 10
        if first_place > 1 and tenth_place > 1 and first_place * tenth_place <= M:
            ans_count += 1

print(ans_count)

Measured memory_bytes: 2940