akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

void BubbleSort(char *C, int N, char *A) {
	int i, j;
	for (i = 0; i < N; i++) {
		for (j = N-1; j > i; j--) {
			if (C[j] < C[j-1]) {
				swap(C[j], C[j-1]);
				swap(A[j], A[j-1]);
			}
		}
	}
}

void SelectionSort(char *C, int N, char *A) {
	int i, j;
	int minj;
	for (i = 0; i < N; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (C[j] < C[minj])
				minj = j;
		}
		swap(C[i], C[minj]);
		swap(A[i], A[minj]);
	}
}



int main(void)
{
	char A[36];
	int N;
	char C[36];
	char Amoto[36];
	char Cmoto[36];
    cin>>N;
	int i, j;
	for (i = 0; i < N; i++) {
		cin>>A[i];
		cin>>C[i];
	}
	for (i = 0; i < N; i++) {
		Amoto[i] = A[i];
		Cmoto[i] = C[i];
	}
	int M[9][36];
	int k = 0;
	for (i = 0; i < 9; i++) {
		for (j = 0; j < N; j++) {
			if( (C[j] - '0') == (i + 1) ) {
				M[i][k] = A[j];
				k++;
			}
		}
		k = 0;
	}
	BubbleSort(C, N, A);
	for (i = 0; i < N; i++) {
		if(i > 0) {
			cout<<" ";
		}
		cout<<A[i];
		cout<<C[i];
	}
	cout<<endl;
	int flag = 1;
	for ( i = 0; i < 9; i++ ) {
		k = 0;
		for ( j = 0; j < N; j++ ) {
			if ( (C[j] - '0') == (i + 1) ) {
				if (A[j] != M[i][k]) {
					flag = 0;
					break;
					i = 9;
				} else {
					k++;
				}
			}
		}
	}
	if (flag == 0) {
		cout<<"Not stable"<<endl;
	} else {
		cout<<"Stable"<<endl;
	}			
		
	for (i = 0; i < N; i++) {
		A[i] = Amoto[i];
		C[i] = Cmoto[i];
	}
	SelectionSort(C, N, A);
	for (i = 0; i < N; i++) {
		if(i > 0) {
			cout<<" ";
		}
		cout<<A[i];
		cout<<C[i];
	}
	cout<<endl;
	flag = 1;
	for ( i = 0; i < 9; i++ ) {
		k = 0;
		for ( j = 0; j < N; j++ ) {
			if ( (C[j] - '0') == (i + 1) ) {
				if (A[j] != M[i][k]) {
					flag = 0;
					break;
					i = 9;
				} else {
					k++;
				}
			}
		}
	}
	if (flag == 0) {
		cout<<"Not stable"<<endl;
	} else {
		cout<<"Stable"<<endl;
	}
	
	
	
}

Measured memory_bytes: 3092
N, M, X = list(map(int, input().split()))
A = [a for a in list(map(int, input().split()))]

cost1 = cost2 = 0

for i in range(M):
    if A[i] < X:
        cost1 += 1
    else:
        cost2 += 1

print(min(cost1, cost2))

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

using namespace std;

char abc[3] = {'A', 'B', 'C'};

bool dfs(string s){
    if(s == "ABC") return true;
     
    int i = 0;
    string t = "";
    int cnt[3] = {0};
    bool ret_flag = true;
    while(i < int(s.length())){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            t += 'X';
            ret_flag = false;
            i += 3;
        }else{
            cnt[s[i] - 'A']++;
            t += s[i++];
        }
    }
    if(ret_flag) return false;
 
    char c[3] = {'A', 'B', 'C'};
    bool ret = false;
    for(int i=0;i<3;i++){
        if(cnt[i]) continue;
        string tt(t);
        for(int j=0;j<int(t.length());j++){
            if(t[j] == 'X') tt[j] = c[i];
        }
        ret |= dfs(tt);
    }
    return ret;
}

int main(){
    string s;
    cin >> s;
    cout << (dfs(s)?"Yes":"No") << endl;
}


Measured memory_bytes: 28148
import java.util.*;
import java.lang.String;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int point = 0;
        double probability = 0.0f;

        for (int i = 1; i <= n; i++) {
            point = i;// ポイントの初期値設定
            double tmpProbability = 1.0/n;

            if (point >= k) {
                probability += tmpProbability;
                continue;
            }

            int j = 1;
            while (point < k) {
                point *= 2;
                if (point >= k) {
                    tmpProbability *= Math.pow(0.5, (double)j);
                    probability += tmpProbability;
                    break;
                }
                j++;
            }
        }

        System.out.println(probability);
    }
}


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

int main(){
    int a, b, c;
    int n=0;
    cin >> a >> b >> c;
    for(int i=a; i<=b; i++){
        if(c%i==0){
            n+=1;
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>

int main(void) {
  int num;
  int sum = 0;

   while(1) {
    while ((num = getchar()) != '\n') {
      sum += num - 48;
    }
    if (sum != 0)
      printf("%d\n", sum);
    else if (sum == 0)
      break;
    sum = 0;
    }
  


  return 0;
}



Measured memory_bytes: 2056
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		while(s.hasNext()){
			String str=s.nextLine();
			String []table=str.split(" ");
			Stack<String> stack=new Stack<String>();
			for(int i=0;i<table.length;i++){
				if(table[i].equals("+")){
					double a=Double.parseDouble(stack.pop());
					double b=Double.parseDouble(stack.pop());
					stack.push(""+(a+b));
				}
				else if(table[i].equals("-")){
					double a=Double.parseDouble(stack.pop());
					double b=Double.parseDouble(stack.pop());
					stack.push(""+(b-a));
				}
				else if(table[i].equals("*")){
					double a=Double.parseDouble(stack.pop());
					double b=Double.parseDouble(stack.pop());
					stack.push(""+(a*b));
				}
				else if(table[i].equals("/")){
					double a=Double.parseDouble(stack.pop());
					double b=Double.parseDouble(stack.pop());
					stack.push(""+(b/a));
				}else{
					stack.push(table[i]);
				}
			}
			System.out.println(stack.pop());
		}
	}
}

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

#define DEBUG(x) cerr << #x << " = " << x << endl

struct node {
    int a, b, weight;
    node(int _a, int _b, int _w) : a(_a), b(_b), weight(_w) { }
    bool operator <(const node &x) const {
        return this->a < x.a;
    }
};

ostream &operator <<(ostream &os, const node &t) {
    os << "a = " << t.a << ", b = " << t.b << ", w = " << t.weight;
    return os;
}

int main() {
    for(int N; cin >> N, N; ) {
        vector<node> vec;
        for(int i = 0; i < N; i++) {
            int a, b, w; cin >> w >> a >> b;
            vec.emplace_back(a, b, w);
        }
        sort(begin(vec), end(vec));
        int w = 0;
        bool valid = true;
        vector<node> s;
        for(node it : vec) {
            for(int i = 0; i < (int)s.size(); ++i) {
                if(s[i].b <= it.a) {
                    w -= s[i].weight;
                    s[i].weight = 0;
                }
            }
            w += it.weight;
            s.push_back(it);
            if(w > 150) {
                valid = false;
                break;
            }
        }
        cout << (valid ? "OK" : "NG") << endl;
    }
}

Measured memory_bytes: 1192
main(){double a,b,c,d,e,f,g;for(scanf("%*d");~scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f);puts(d>c+f?"0":c>d+f?"2":f>c+d?"-2":"1"))d=hypot(a-d,b-e);}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, r;
    cin >> n >> r;
    if(n<10)
        r+=100*(10-n);
    cout << r;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=310;
const int inf=2147483647;
const int mod=998244353;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int n,m,a[Maxn][Maxn],b[Maxn][Maxn],c[Maxn],cnt=0;
int Pow(int x,int y)
{
	if(!y)return 1;
	int t=Pow(x,y>>1),re=(LL)t*t%mod;
	if(y&1)re=(LL)re*x%mod;
	return re;
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	a[i][j]=read();
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)c[j]=a[i][j];
		for(int j=1;j<=m;j++)
		if(c[j])
		{
			if(!b[j][j])
			{
				for(int k=j;k<=m;k++)b[j][k]=c[k];
				cnt++;break;
			}
			else
			{
				for(int k=j;k<=m;k++)c[k]^=b[j][k];
			}
		}
	}
	printf("%lld",(LL)(Pow(2,n)-Pow(2,n-cnt)+mod)%mod*Pow(2,m-1)%mod);
}

Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
D, X = MAP()
A = []
for i in range(N):
    A.append(INT())

ate = 0

for i in range(N):
    j = 0
    while(1):
        day = A[i] * j + 1
        j += 1
        if day <= D:
            ate += 1
        else:
            break
print(X + ate)



Measured memory_bytes: 5196
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////
const int maxn=2e5+5;
vector<int>adj[maxn];
bool visited[maxn];
int compo;


void dfs(int v){
    compo++;
    visited[v]=true;

    for(auto it:adj[v]){
        if(!visited[it]){
            dfs(it);
        }
    }

}


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


    int n,m;
    cin>>n>>m;

    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);

    }

    compo=0;
    int ans=0;

    for(int i=1;i<=n;i++){
        if(!visited[i]){
            dfs(i);
        }
        ans=max(ans,compo);

        compo=0;
    }

    cout<<ans<<endl;


}


Measured memory_bytes: 21020
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

int N,M,K;
string S;
signed main(){
  cin>>N;
  int sum_=0;
  REP(i,1,N+1){
    if((i%3!=0)&&(i%5!=0)){
      sum_+=i;
    }
  }
  print(sum_)

}


Measured memory_bytes: 3608
# -*- coding: utf-8 -*-

def main(N,M,A,B):
    ct = [0]*N
    for i in range(M):
        ct[A[i]-1] += 1
        ct[B[i]-1] += 1
    for i in range(N):
        print(ct[i])
    
if __name__ == '__main__':
    N, M = map(int, input().split())
    A, B = [], []
    for i in range(M):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    
    main(N,M,A,B)

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

const int N = 1e5+5;

struct node{
    int aa,bb;
};

int main()
{
    int n,m,i,j,k;
    cin>>n>>m;
    int p[m+2],y[m+2];
    //priority_queue < pair<int,int> > pq;
    //map < node ,int> mp;
    map < pair<int,int> ,int> mp;
    map < int, vector<int> > v;
    set <int> st;
    //node pp;
    pair <int,int> pp;

    for(i=0; i<m; i++)
    {
        cin>>p[i]>>y[i];
        v[p[i]].push_back(y[i]);
        st.insert(p[i]);
    }

    for(auto ii: st)
    {
        sort(v[ii].begin(),v[ii].end());
        for(i=0; i<v[ii].size(); i++)
        {
            //pp.aa=ii;
            //pp.bb=v[ii][i];
            pp= make_pair(ii,v[ii][i]);
            mp[pp]=i+1;
        }
    }


    string s;

    for(i=0; i<m; i++)
    {
        s="000000000000";

        k=p[i];
        j=5;
        while(k)
        {
            s[j--]=(char) (k%10)+'0';
            k/=10;
        }
        ///////////////
        pp= make_pair(p[i],y[i]);
        //pp.aa=p[i];
        //pp.bb=y[i];
        k=mp[pp];
        j=11;
        while(k)
        {
            s[j--]=(char) (k%10)+'0';
            k/=10;
        }

        cout<<s<<endl;
    }


    return 0;
}


Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
#define IN_OUT(n) ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) , cout << fixed << setprecision(n)
#define F first
#define S second
typedef pair<int,int> pii;
typedef pair<pii,int> tpi;
typedef pair<pii,pii> qpi;
typedef long long ll;
const int MOD = 1e9 + 7;
const int MAX = 1e5;
const int INF = 2e9;
int MA = -INF , MI = INF;

int32_t main()
{
	IN_OUT(10);
	string s;
	cin>>s;

	for(int msk = 0 ; msk < 8 ; msk++)
	{
		int tmp = s[0]-'0';
		for(int i=0 ; i<3 ; i++)
		{
			if( (msk >> i) & 1 )
				tmp += s[i+1]-'0';
			else
				tmp -= s[i+1]-'0';
		}
		if( tmp == 7 )
		{
			cout << s[0];
			for(int i=0 ; i<3 ; i++)
			{
				if( ( msk >> i ) & 1 )
					cout << "+";
				else
					cout << "-";
				cout << s[i+1];
			}
			cout<<"=7";
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

#define ll long long

//iostream::sync_with_stdio(false);

const int maxn = 2e6+5;

int main()
{
    int n;
    cin >> n;
    if(n % 1000 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1000 - n % 1000 << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(a) ((int)(a).size())

const int INF = 1e9;

struct UFnode
{
  string value_;
  int rank_, p_, index_, size_;
  UFnode(string value) : value_(value), rank_(0), p_(-1), size_(1) {}
  int size() const { return size_; }
};

struct UF
{
  vector<UFnode> ufnodes_;
  // mapping a value to its index in vector
  map<string, int> value_to_index_;
  // the number of components
  int size_;

  UF() : size_(0) {}
  int size() const { return size_; }
  // Returns the number of nodes in the tree in which value resides
  int tree_size(string value)
  {
    if (value_to_index_.count(value) == 0) { return 0; }
    int pix = ufnodes_[value_to_index_[value]].p_;
    return ufnodes_[pix].size();
  }

  void make_set(string value)
  {
    UFnode node(value);
    ufnodes_.push_back(node);
    int ix = ufnodes_.size() - 1;
    ufnodes_[ix].index_ = ufnodes_[ix].p_ = value_to_index_[value] = ix;
    ++size_;
  }

  // Return index of the root of the tree to which value belongs.
  int find_set(string value, int index = -1)
  {
    if (index == -1) {
      if (value_to_index_.count(value) == 0) { return -1; }
      index = value_to_index_[value];
    }
    if (ufnodes_[index].p_ != index) {
      ufnodes_[index].p_ = find_set(ufnodes_[ufnodes_[index].p_].value_, ufnodes_[index].p_);
    }
    return ufnodes_[index].p_;
  }

  void unite(string x, string y)
  {
    int s1 = find_set(x), s2 = find_set(y);
    if ((s1 == s2) || (s1 == -1) || (s2 == -1)) { return; }
    if (ufnodes_[s1].rank_ > ufnodes_[s2].rank_) {
      // connect ufnodes_[s2] to ufnodes_[s1]
      ufnodes_[s2].p_ = s1;
      ufnodes_[s1].size_ += ufnodes_[s2].size_;
    }
    else {
      // connect ufnodes_[s1] to ufnodes_[s2]
      ufnodes_[s1].p_ = s2;
      ufnodes_[s2].size_ += ufnodes_[s1].size_;
      if (ufnodes_[s1].rank_ == ufnodes_[s2].rank_) { ++ufnodes_[s2].rank_; }
    }
    --size_;
  }

  bool is_connected(string x, string y) { return find_set(x) == find_set(y); }
};

int main()
{
  vector<string> stuff;
  map<string, int> prices;
  int n = 0;
  UF uf;
  fscanf(stdin, "%d", &n);
  for (int i = 0; i < n; ++i) {
    string s;
    int p;
    cin >> s >> p;
    prices[s] = p;
    stuff.push_back(s);
    uf.make_set(s);
  }
  int m = 0;
  fscanf(stdin, "%d", &m);
  for (int i = 0; i < m; ++i) {
    string s, t;
    cin >> s >> t;
    uf.unite(s, t);
  }
  map<int, int> min_prices;
  for (int i = 0; i < sz(stuff); ++i) {
    int r = uf.find_set(stuff[i]);
    if (min_prices.count(r) == 0) {
      min_prices[r] = prices[stuff[i]];
    }
    else {
      min_prices[r] = min(min_prices[r], prices[stuff[i]]);
    }
  }
  int ans = 0;
  for (int i = 0; i < sz(stuff); ++i) {
    int r = uf.find_set(stuff[i]);
    ans += min_prices[r];
  }
  fprintf(stdout, "%d\n", ans);
  return 0;
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int, int> PII;

int main(){
    FIO;
    ll n;
    cin >> n;
    ll arr[n];
    map<ll, ll> m;
    for(ll i = 0 ; i < n ; i++){
        cin >> arr[i];
        m[arr[i]]++;
    }
    if(m.size() > 3){
        cout << "No" << endl;
        return 0;
    }
    vector<ll> ans;
    if(m.size() == 1){
        if(!m.count((ll)0)){
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        return 0;
    }
    if(n%3 != 0){
        cout << "No" << endl;
        return 0;
    }
    if(m.size() == 2){
        if(!m.count(0)){
            cout << "No" << endl;
            return 0;
        }
        ll cnt1 = m[(ll)0];
        m.erase((ll)0);
        ll cnt2 = m[m.begin()->first];
        if(cnt2 != cnt1 * 2){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
        return 0;
    }
    ll cnt1 = m[m.begin()->first], p1 = m.begin()->first;
    m.erase(m.begin()->first);
    ll cnt2 = m.begin()->second, p2 = m.begin()->first;    m.erase(m.begin()->first);
    ll cnt3 = m.begin()->second, p3 = m.begin()->first;    m.erase(m.begin()->first);
    if((p1 ^ p2) != p3){
        if((p1^p3) != p2){
            cout << "No" << endl;
            return 0;
        }
    }
    if(cnt1 != cnt2 && cnt1 != cnt3){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

vector <char> MOJI = {'A', 'C', 'G', 'T'};

int main(){
  int n, q; cin >> n >> q;
  string s; cin >> s;
  vector <int> cnt(n, 0);
  
  for(int i = 1; i < n; i++){
    cnt.at(i) = cnt.at(i - 1);
    if(s.at(i - 1) == 'A' && s.at(i) == 'C'){
      cnt.at(i)++;
    }
  }
  
  
  for(int i = 0; i < q; i++){
    int b, e;
    cin >> b >> e;
    b--; e--;
    
    cout << cnt.at(e) - cnt.at(b) << endl;
  }
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var ans = GetInt() > 999 ? "ABD" : "ABC";

            Console.WriteLine(ans); 
        }


        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	string A, B;
	cin >> A >> B;
	if (A == B)cout << "EQUAL";
	else {
		int a = A.size();
		int b = B.size();
		if (a > b)cout << "GREATER";
		else if (a < b)cout << "LESS";
		else {
			rep(i, a) {
				if (A[i] > B[i]) {
					cout << "GREATER";
					return 0;
				}
				else if (A[i] < B[i]) {
					cout << "LESS";
					return 0;
				}
			}
		}
	}
}

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

int main(){
    int n, m;
    cin >> n >> m;
    
    vector<bool> flag(m), b(m);
    vector<int> k(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n){
        cin >> k.at(i);
        rep(j, k.at(i)){
            cin >> a.at(i).at(j);
            b.at(a.at(i).at(j)-1) = true;
        }
        rep(j, m){
            if(!b.at(j)) flag.at(j) = true;
            b.at(j) = false;
        }
    }
    
    int ans = 0;
    rep(i, m){
        if(!flag.at(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1e18;
const int MX = 1000001;


long long facs [MX];
long long facInvs [MX];
long long modExp(long long base, long long power) {
    if (power == 0) {
        return 1;
    } else {
        long long cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
long long mul(long long A, long long B) {
	return (A*B)%MOD;
}
long long inv(long long base) {
	return modExp(base, MOD-2);
}
long long choose(long long a, long long b) {
	if (b > a) return 0;
	if (a < 0) return 0;
	if (b < 0) return 0;
    long long cur = facs[a];
    cur = mul(cur, facInvs[b]);
    cur = mul(cur, facInvs[a-b]);
    return cur;
}
void initFacs() {
	facs[0] = 1;
	facInvs[0] = 1;
	for(int i=1;i< MX;i++) {
		facs[i] = (facs[i-1] * i) % MOD;
		facInvs[i] = inv(facs[i]);
	}
}
int main() {
 initFacs();
	
    long long X, Y; cin >> X >> Y;
    if ((X+Y)%3 != 0) {
        cout << 0 << endl; return 0;
    }
 
    if (max(X, Y) > 2*min(X, Y)) {
        cout << 0 << endl; return 0;
    }
    int K=(X+Y)/3;
    X -= (X+Y)/3; Y -= K;
    
    cout << choose(X+Y, X) << endl;

	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int a,b,c,d;

int main(){

    cin >> a >> b >> c >> d;

    if (abs(c-a) <= d || (abs(c-b)<=d && abs(b-a)<=d)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
const int MAXN = 200010, MAXM = 10;
int n, m, k;
long long a[MAXN][MAXM], ans;

struct Node {
    int id;
    long long sum;

    bool operator < (const Node &ano) const {
        return sum > ano.sum;
    }
} b[MAXN];

inline void cmax(register long long &a, register long long b) {
    a < b && (a = b);
}

int main() {
    //scanf("%d%d%d", &n, &m, &k);
    scanf("%d%d", &n, &k); m = 3;
    for (register int i = 1; i <= n; ++i)
        for (register int j = 1; j <= m; ++j)
            scanf("%lld", &a[i][j]);
    for (register int s = 0, s_max = 1 << m; s < s_max; ++s) {
        for (register int i = 1; i <= n; ++i) {
            b[i].id = i; b[i].sum = 0;
            for (register int j = 1; j <= m; ++j)
                b[i].sum += (s & (1 << (j - 1))) ? a[i][j] : -a[i][j];
        }
        sort(b + 1, b + n + 1);
        register long long cur = 0;
        for (register int i = 1; i <= k; ++i)
            cur += b[i].sum;
        cmax(ans, cur);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <ctime>
#include <numeric>


#ifndef M_PI
#define M_PI 3.141592653589
#endif
#define int long long
#define double long double

#ifdef TIME
#define start cin.tie(NULL); cout.tie(NULL); cout.setf(ios::fixed); cout.precision(10); ios_base::sync_with_stdio(false);int32_t START = clock()
#define finish cout << "\ntime: " << (clock() - START) / (CLOCKS_PER_SEC * 1.0); return 0
#endif

#ifndef TIME
#define start cin.tie(NULL); cout.tie(NULL); cout.setf(ios::fixed); cout.precision(10); ios_base::sync_with_stdio(false)
#define finish return 0
#endif

using namespace std;


//vector input
template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &i : vec) {
        cin >> i;
    }
    return is;
}

//pair output
template<typename E>
ostream &operator<<(ostream &os, pair<E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//"map" pair output
template<typename E>
ostream &operator<<(ostream &os, pair<const E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//vector output
template<typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
    for (T i : vec) {
        os << i << ' ';
    }
    return os;
}

//2 dimensional vector output
template<typename T>
ostream &operator<<(ostream &os, vector<vector<T> > &vec) {
    for (vector<T> i : vec) {
        os << i << '\n';
    }
    return os;
}


int32_t main() {
    start;

    int n;
    cin >> n;
    if (n >= 30) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }

    finish;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <unordered_map>
  
using namespace std;

class UF{
public:
    int par[5000],rank[5000];
  
    inline UF(int n){
        while(n--){
            par[n]=n;
            rank[n]=0;
        }
    }
  
    inline int find(int x){
        if(par[x]==x)
            return x;
        else
            return par[x]=find(par[x]);
    }
  
    inline void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
  
        if(rank[x]<rank[y])
            par[x]=y;
        else{
            par[y]=x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
  
    inline bool same(int x, int y){
        return find(x)==find(y);
    }
  
};

int main(){
	int n;
	scanf("%d",&n);
	UF uf(n);	
	unordered_map<string,int> id;
	
	char s[10],s2[10];
	int x,cost[5000];
	for(int i=0;i<n;++i){
		scanf("%s %d",s,&x);
		cost[id[s]=i]=x;
	}
	
	int q;
	cin>>q;
	while(q--){
		scanf("%s %s",s,s2);
		uf.unite(id[s],id[s2]);
	}
	
	for(int i=0;i<n;++i){
		x=uf.find(i);
		cost[x]=min(cost[x],cost[i]);
	}

	int ans=0;
	for(int i=0;i<n;++i){
		ans+=cost[uf.find(i)];
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 3900
# https://atcoder.jp/contests/abc138/tasks/abc138_e

from collections import defaultdict
from bisect import bisect_right

S = input()
T = input()

# Sの中での位置
iS = defaultdict(list)
for (idx, ch) in enumerate(S):
    iS[ch].append(idx)

# Tの文字はSに出ていないといけない
for v in T:
    if v not in iS:
        print(-1)
        exit()

# 探索
cnt = 0
cur = -1
for v in T:
    i = bisect_right(iS[v], cur)
    if i == len(iS[v]):
        j = iS[v][0]
    else:
        j = iS[v][i]

    if cur >= j:
        cnt += 1
    cur = j

print(cnt * len(S) + cur + 1)

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

import sys
from math import ceil

def main():
    n, h = map(int, sys.stdin.readline().split())
    k = tuple(tuple(map(int, line.split())) for line in sys.stdin.readlines())

    max_a = max(x[0] for x in k)
    b = tuple(sorted((x[1] for x in k if x[1] > max_a), reverse=True))

    cnt = 0
    for bi in b:
        h -= bi
        cnt += 1
        if h <= 0:
            break
    else:
        cnt += ceil(h / max_a)

    print(cnt)

if __name__ == '__main__':
    main()


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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
    ll n, w; cin >> n >> w;
    vector<vector<ll> > dp(n+1, vector<ll>(2e5, 1e10));
    REP(i, 0, n+1){dp[i][0] = 0;}
    REP(i, 0, n){
        ll a, b; cin >> a >> b;
        REP(k, 0, b){
            dp[i+1][k] = min(dp[i+1][k], dp[i][k]);
        }
        REP(l, 0, 1e5+1e4){
            dp[i+1][l+b] = min({dp[i+1][l+b], dp[i][l+b], dp[i][l] + a});
        }
    }
    ll ans = 0;
    REP(i, 0, 2e5){
        if(dp[n][i]<=w && dp[n][i] != 1e10){
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 159744
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int a[4];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	a[0] = s[0] - '0'; a[1] = s[1] - '0'; a[2] = s[2] - '0'; a[3] = s[3] - '0';
	if (a[0] + a[1] + a[2] + a[3] == 7)cout << a[0] << "+" << a[1] << "+" << a[2] << "+" << a[3] << "=7" << endl;
	else if (a[0] + a[1] + a[2] - a[3] == 7)cout << a[0] << "+" << a[1] << "+" << a[2] << "-" << a[3] << "=7" << endl;
	else if (a[0] + a[1] - a[2] + a[3] == 7)cout << a[0] << "+" << a[1] << "-" << a[2] << "+" << a[3] << "=7" << endl;
	else if (a[0] - a[1] + a[2] + a[3] == 7)cout << a[0] << "-" << a[1] << "+" << a[2] << "+" << a[3] << "=7" << endl;
	else if (a[0] + a[1] - a[2] - a[3] == 7)cout << a[0] << "+" << a[1] << "-" << a[2] << "-" << a[3] << "=7" << endl;
	else if (a[0] - a[1] - a[2] + a[3] == 7)cout << a[0] << "-" << a[1] << "-" << a[2] << "+" << a[3] << "=7" << endl;
	else if (a[0] - a[1] + a[2] - a[3] == 7)cout << a[0] << "-" << a[1] << "+" << a[2] << "-" << a[3] << "=7" << endl;
	else cout << a[0] << "-" << a[1] << "-" << a[2] << "-" << a[3] << "=7" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

vector<ll> dist;
void dfs(const vector<vector<pair<int,ll>>> &G, int v) {

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (dist[next_v.F]>=0) continue; // next_v が探索済だったらスルー
        dist[next_v.F] = dist[v] + next_v.S;
        dfs(G, next_v.F); // 再帰的に探索
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    int N;
    cin >> N;
    vector<vector<pair<int,ll>>> G(N,vector<pair<int,ll>>(0));
    REP(i,N-1){
        ll a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].pb(mp(b,c));
        G[b].pb(mp(a,c));
    }
    int Q,K;
    cin >> Q >> K;
    K--;
    dist.assign(N,-1);
    dist[K] = 0;
    dfs(G,K);
    REP(i,Q){
        int s,e;
        cin >> s >> e;
        s--;e--;
        cout << dist[s] + dist[e] << "\n";
    }
}

Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    for(int i=0;i<a;i++){
        if(s[i]>='0'&&s[i]<='9')continue;
        else{
            cout<<"No";
            return 0;
        }
    }
    if(s[a]!='-'){
            cout<<"No";
            return 0;
    }
    for(int i=a+1;i<a+b+1;i++){
        if(s[i]>='0'&&s[i]<='9')continue;
        else{
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}



Measured memory_bytes: 3632
def main():
    a, b, c = list(map(int, input().split()))
    print(min(c, b//a))

"""def main():
    a, b, k = list(map(int, input().split()))
    lst = []
    for i in range(1, 101):
        if a % i == 0 and b % i == 0:
            lst.append(i)
    print(sorted(lst, reverse=True)[k-1])"""

main()


Measured memory_bytes: 2940
/**
 * @file B-Polygon.cpp
 * @author murnana
 * @brief B - Polygon
 *     https://atcoder.jp/contests/abc117/tasks/abc117_b
 *     
 * @date 2019-02-03
 * 
 * @copyright Copyright (c) 2019
 * 
 */

#include <iostream>
using namespace std;

/**
 * @brief Entry point
 * 
 * @return int 
 */
int main()
{
    // N角形を取得
    int N;
    cin >> N;

    // Lを取得しつつ
    // 定理より、一番長い辺と
    // その他短い辺の合計の値を作る
    unsigned int maxL = 0;
    unsigned int minSum = 0;
    for (int i = 0; i < N; ++i)
    {
        unsigned int L;
        cin >> L;
        if (maxL < L)
        {
            minSum += maxL;
            maxL = L;
        }
        else
        {
            minSum += L;
        }

        // cerr << "loop: " << i << endl;
        // cerr << "\tL: " << L << endl;
        // cerr << "\tmaxL: " << maxL << endl;
        // cerr << "\tminSum: " << minSum << endl;
    }

    // 答え
    cout << (maxL < minSum ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int x,y,z,tmp,ans;
	scanf("%d%d%d",&x,&y,&z);
	if(x>y)
		swap(x,y);
	if(x>z)
		swap(x,z);
	if(y>z)
		swap(y,z);
	tmp=x+y+z;
	tmp=z*3-tmp;
	if(tmp%2==0)
		ans=tmp/2;
	else
		ans=tmp/2+2;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
import bisect as bi
n = int(input())
kariA = list(map(int,input().split()))
kariB = list(map(int,input().split()))
kariC = list(map(int,input().split()))
A = sorted(kariA)
B = sorted(kariB)
C = sorted(kariC)
count = 0
Clength = len(C)
for b in B:
    count += bi.bisect_left(A,b)*(Clength - bi.bisect_right(C,b))
print(count)

Measured memory_bytes: 23232
import java.util.Scanner;

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

		int c[][] = new int[4][4];
for(int i=1;i<=3;i++){
	for(int k=1;k<=3;k++){
		c[i][k]=sc.nextInt();
	}

}
boolean ans=true;
if(c[1][1]-c[1][2]!=c[2][1]-c[2][2]||c[1][1]-c[1][2]!=c[3][1]-c[3][2]||c[1][2]-c[1][3]!=c[2][2]-c[2][3]||c[1][2]-c[1][3]!=c[3][2]-c[3][3]){
	ans=false;
}

if(c[1][1]-c[2][1]!=c[1][2]-c[2][2]||c[1][1]-c[2][1]!=c[1][3]-c[2][3]||c[2][1]-c[3][1]!=c[2][2]-c[3][2]||c[2][1]-c[3][1]!=c[2][3]-c[3][3]){
	ans=false;
}

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

	}}

Measured memory_bytes: 23508
#include<stdio.h>

int main(void)
{
    int i, j, n, r[200000];
    int min,max;

    scanf("%d", &n);

    for(i = 0; i < n; i++){

        scanf("%d", &r[i]);

    }

    min = r[0];
    max = r[1] - r[0];

    for(i = 1; i < n; i++){

    if(max < r[i] - min)

        max = r[i] - min;

    if(min > r[i])

        min = r[i];
    }
    printf("%d\n",max);

    return 0;
}


Measured memory_bytes: 2560
N, Y = map(int, input().split())

Y //= 1000

for y in range(9):
  Yt = Y - 5*y
  Nt = N - y
  if Nt <= Yt <= 10*Nt:
    x = (Yt - Nt)//9
    z = (10*Nt - Yt)//9
    if x + z == Nt:
      print(x, y, z)
      exit()

print(-1, -1, -1)

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

int main() {

  int64_t n;
  cin>>n;

  vector<int64_t> X(n);
  for(int i=0;i<n;i++){
    cin>>X.at(i);
  }

  vector<int64_t> X_org=X;

  sort(X.begin(),X.end());

  for(int i=0;i<n;i++){
    int wk=X_org.at(i);

    if(wk<=X.at(n/2-1))
      cout<<X.at(n/2)<<endl;
    else
      cout<<X.at(n/2-1)<<endl;
  }

  return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    double n,t,a,min=10000,ans;
    cin>>n>>t>>a;

    rep(i,n){
        double h;
        cin>>h;
        if(abs(a-(t-h*0.006))<min){
            min=abs(a-(t-h*0.006));
            ans=i+1;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

struct union_find
{
private:
    int n;
    vector<int> parent, tree_size;

public:
    union_find(int size) : n(size), parent(), tree_size(size, 1)
    {
        parent.reserve(size);
        rep(i, size)
        {
            parent.push_back(i);
        }
    }

    int size()
    {
        return n;
    }

    int root(int u)
    {
        if (u == parent[u])
        {
            return u;
        }
        return parent[u] = root(parent[u]);
    }

    void unite(int u, int v)
    {
        u = root(u);
        v = root(v);
        if (u == v)
        {
            return;
        }
        if (tree_size[u] < tree_size[v])
        {
            swap(u, v);
        }
        parent[v] = u;
        tree_size[u] += tree_size[v];
    }

    bool same(int u, int v)
    {
        return root(u) == root(v);
    }

    int component_size(int u)
    {
        u = root(u);
        return tree_size[u];
    }
};

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

    int n, m;
    cin >> n >> m;
    union_find g(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g.unite(a, b);
    }
    int ans = 0;
    rep(i, n)
    {
        chmax(ans, g.component_size(i));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n;
long long ans;
long long gcd(long long x,long long y)
{
	if(x%y==0)
		return y;
	return gcd(y,x%y);
}
long long g(long long a,long long b,long long c)
{
	return gcd(a,gcd(b,c));
}
long long c(int a,int b,int c)
{
	if(a==b&&b==c)
		return 1;
	if(a==b||b==c||a==c)
		return 3;
	return 6;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			for(int k=j;k<=n;k++)
				ans+=c(i,j,k)*g(i,j,k);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Task{
		public void solve(int numTest, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			String[] inputString = new String[n];
			for(int testcase = -1; ++ testcase < n;) {
				inputString[testcase] = sortString(in.next().toCharArray());
			}
			Arrays.sort(inputString);
			 
			long res = 0, count = 1;
			for(int i = 0; ++i < n;) {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			}
			
			out.print(res+count*(count-1)/2);
		}

		private String sortString(char[] charArray) {
			Arrays.sort(charArray);
			return String.copyValueOf(charArray);
		}
	}
	
	
/*
5
4 5
2 1
3 2
2 5

*/				
	
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
	}
		
}

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

using namespace std;

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

  vector<int> A, B;
  if (N & 1) {
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (i + j != N) {
          A.push_back(i);
          B.push_back(j);
        }
      }
    }
  } else {
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (i + j != N + 1) {
          A.push_back(i);
          B.push_back(j);
        }
      }
    }
  }
  cout << A.size() << "\n";
  for (int i = 0; i < A.size(); i++) {
    cout << A[i] << " " << B[i] << "\n";
  }

  return 0;
}

Measured memory_bytes: 3720