akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





















int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
        a[i]--;
    }
    vector<ll> t;
    vector<bool> used(n);
    for(ll now = 0; ; now = a[now]){
        if(used[now]){
            ll s = -1;
            REP(i, t.size()){
                if(t[i] == now){
                    s = i;
                    break;
                }
            }
            ll loop = (ll)t.size() - s;
            if(k < t.size()){
                cout << t[k] + 1 << endl;
            }
            else{
                cout << t[s + ((k - s) % loop)] + 1 << endl;
            }
            return 0;
        }
        else{
            used[now] = true;
            t.push_back(now);
        }
    }
}


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

using namespace std;

int main() {
  int A, B, C, ans = 0x7FFFFFFF;
  
  cin >> A >> B >> C;
  
  ans = min(ans, A + B);
  ans = min(ans, C + B);
  ans = min(ans, A + C);
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int i;
	int n;
	
	scanf("%d %d %d", &a, &b, &c);
	
	n = 0;
	for (i = a; i <= b; i++){
		if (c % i == 0){
			n++;
		}
	}
	
	printf("%d\n", n);
	
	return (0);
}

Measured memory_bytes: 596
N=int(input())
ls=[int(s) for s in input().split()]
dic={}
for k in ls:
  if k in dic:
    dic[k]+=1
  else:
    dic[k]=1
#print(dic)
_sum=0
for k,v in dic.items():
  _sum+=k*v
#print(_sum)
K=int(input())
for _ in range(K):
  b,c=[int(s) for s in input().split()]
  if b in dic:
    _sum+=(c-b)*dic[b]
    if c in dic:
      dic[c]+=dic[b]
    else:
      dic[c]=dic[b]
    dic[b]=0
  print(_sum)

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int MIN_SUM = 100000;

int sumdigits(int x){
    int sum = 0;
    while(x > 0){
        sum += (x % 10);
        x /= 10;
    }
    return sum;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int minsum = MIN_SUM;
    for(int i=1;i<n;i++){
        minsum = min(minsum, sumdigits(i) + sumdigits(n - i));
    }
    cout << minsum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	long long P, C[500000];

	int N, Q;

	scanf("%d", &N);

	scanf("%lld", &P);

	scanf("%d", &Q);

	long long zenbugaishoku = 0;

	for (int i = 0; i < N; i++)
	{
		scanf("%lld", &C[i]);

		zenbugaishoku += C[i];

		C[i] = C[i] - (Q - i) * P;
	}

	long long *E = C + N;

	sort(C, E);

	long long Answer = zenbugaishoku;

	long long sum = zenbugaishoku;

	long long V = 2 * P;

	for (int i = 0; i < N; i++)
	{
		sum += V * i - C[i];

		Answer = max(sum, Answer);
	}

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

	return 0;
}

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


int main(){
  ll n;
  cin >> n;
  ll t0, x0, y0;
  cin >> t0 >> x0 >> y0;
  ll count = 0;
  ll check = 0;
  if (n == 1){
    if (abs(x0) + abs(y0) != 1) check = 1;
  }
  else{
    
    while(count < n - 1 && check == 0){
      ll t, x, y;
      cin >> t >> x >> y;
      ll time = t - t0;
      ll kyori = abs(x - x0) + abs(y - y0);
      if(time % 2 == 0 && kyori % 2 == 0 && kyori <= time){
        count++;
        x0 = x;
        y0 = y;
        t0 = t;
      }
      else if(time % 2 == 1 && kyori % 2 == 1 && kyori <= time){
        count++;
        x0 = x;
        y0 = y;
        t0 = t;
      }
      else {
        check = 1;
      }
    }
  }
    if(check == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 5;
ll n;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    cout<<n * n;
    return 0;
} 

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

bool sol(long long int n)
{
    long long int ans=0;
    while(n>0)
    {
        n/=10;
        ans++;
    }

    return ans%2!=0;

}

int main()
{
    long long int n,i;
    cin>>n;
    long long int ans=0;
    for(i=1;i<=n;i++)
        if(sol(i))
            ans++;
    cout<<ans;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	void A() {
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println(Math.max(0,(H-h)*(W-w)));
	}
	void B() {
		
	}
	void C() {
		
	}
	void D() {
		
	}
	void doIt() {
		A();
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}


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

int main() {
    string s;
    string t;
    cin >> s;
    cin >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));

    if (s < t)cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
n=int(input())
XL=[]
for i in range(n):
  x,l=map(int,input().split())
  XL.append([x-l,x,x+l])
ans=0
cur=-float("inf")
XL.sort(key=lambda x:x[2])
for x1,x2,x3 in XL:
  if x1>=cur:
    cur=x3
    ans+=1
  else:
    continue
print(ans)



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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	int arr[n][m];
	int u[n][m],l[n][m],r[n][m],d[n][m];
	for(int i=0; i<n; ++i){
		string s;
		cin>>s;
		for(int j=0; j<m; ++j){
			if( s[j] == '#'){ arr[i][j] = 1; }
			else{ arr[i][j] = 0; }
		}
	}
	// left
	for(int i=0; i<n; ++i){
		l[i][0] = !arr[i][0];
		for(int j=1; j<m; ++j){
			if( arr[i][j] == 0 ){ l[i][j] = l[i][j-1] + 1; }
			else{ l[i][j] = 0; }
		}
	}
	// right:
	for(int i=0; i<n; ++i){
		r[i][m-1] = !arr[i][m-1];
		for(int j=m-2; j>=0; --j){
			if( arr[i][j] == 0 ){ r[i][j] = r[i][j+1] + 1; }
			else{ r[i][j] = 0; }
		}
	}
	// up:
	for(int j=0; j<m; ++j){
		u[0][j] = !arr[0][j];
		for(int i=1; i<n; ++i){
			if( arr[i][j] == 0 ){ u[i][j] = u[i-1][j] + 1;}
			else{ u[i][j] = 0;}
		}
	}
	// down :
	for(int j=0; j<m; ++j){
		d[n-1][j] = !arr[n-1][j];
		for(int i=n-2; i>=0; --i){
			if( arr[i][j] == 0 ){ d[i][j] = d[i+1][j] + 1; }
			else{ d[i][j] = 0; }
		}
	}
	int max_ans = 0;
	for(int i=0; i<n; ++i){
		for(int j=0; j<m; ++j){
			max_ans = max( max_ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3);
		}
	}
	cout<<max_ans<<'\n';
	return 0;
}


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

using namespace std;
using ll = long long;

const int MAXN = 200000;

vector<int> f(MAXN, 0);

inline void precalc() {
	for (int i = 1; i < MAXN; i++) {
		f[i] = 1 + f[i % __builtin_popcount(i)];
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	precalc();
	int n;
	string s;
	cin >> n >> s;
	int cnt = count(s.begin(), s.end(), '1');
	array<int, 2> mods = {cnt + 1, cnt - 1};
	for (auto &el : mods) {
		el = (el == 0 ? 1 : el);
	}
	vector<array<int, 2>> p2(n, {1, 1});
	for (int i = 1; i < n; i++) {
		p2[i][0] = (p2[i - 1][0] * 2) % mods[0];
		p2[i][1] = (p2[i - 1][1] * 2) % mods[1];
	}
	array<int, 2> res = {0, 0};
	for (int i = 0; i < n; i++) {
		res[0] += (p2[n - 1 - i][0] * (s[i] - '0')) % mods[0];
		res[0] %= mods[0];
		res[1] += (p2[n - 1 - i][1] * (s[i] - '0')) % mods[1];
		res[1] %= mods[1];
	}
	for (int i = 0; i < n; i++) {
		if (cnt == 1 && s[i] == '1') {
			cout << "0\n";
			continue;
		}
		cout << f[(res[s[i] - '0'] - (p2[n - 1 - i][s[i] - '0'] * (s[i] - '0')) % mods[s[i] - '0'] + ((p2[n - 1 - i][s[i] - '0'] * ((s[i] - '0') ^ 1))) % mods[s[i] - '0'] + mods[s[i] - '0']) % mods[s[i] - '0']] + 1 << '\n';
	}
}


Measured memory_bytes: 5944
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

long long int f(const long long int x){
    const long long int m = log2(x)+1;
    long long int res = 0;
    for(int i = 1; i <= m; ++i){
        long long int n = 1LL<<i;
        long long int c = ((x+1)/n)*(n/2);
        c += max(0LL, ((x+1)%n)-(n/2));

        if(c & 1) res += n>>1;
    }

    return res;
}

int main(){
    long long int A, B;
    cin >> A >> B;

    long long int ans = f(A-1)^f(B);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (void) {
    int N;
    int M;

    cin >> N >> M;
    int box[N] = {0};
    bool red[N];
    for (int i = 0; i < N; i++) {
        box[i] = 1;
        red[i] = false;
    }
    red[0] = true;
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        box[x]--;
        box[y]++;
        if (red[x]) {
            red[y] = true;
            if (box[x] == 0) {
                red[x] = false;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (red[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int main(){
	int n; cin>>n;
	long long a[n],b[n]; for(int i=0;i<n;i++)cin>>a[i]>>b[i];

	long long ans=0;

	for(int i=n-1; i>=0; i--){
		if((a[i]+ans)%b[i]!=0){
			ans += b[i]-((a[i]+ans)%b[i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  string S;
  cin >> S;
  int N = (int)S.size();
  
  vector<int> A(N, 0);
  for( int i = 1; i < N; i++ ){
    if( S.at(i-1) == 'R' && S.at(i) == 'L' ){
      A.at(i-1) = 1;
      A.at(i) = 1;
    }
  }
  
  int basyo = -1;
  int rcnt = 0;
  int lcnt = 0;
  for( int i = 0; i < N; i++ ){
    if( A.at(i) > 0 && S.at(i) == 'R' ){
      if( basyo != -1 ){
        A.at(basyo) += lcnt/2 + lcnt%2;
        A.at(basyo+1) += lcnt/2;
        lcnt = 0;
      }
      A.at(i) += rcnt/2;
      A.at(i+1) += rcnt/2 + rcnt%2;
      rcnt = 0;
      basyo = i;
    }else if( A.at(i) == 0 ){
      if( S.at(i) == 'R' ) rcnt++;
      else lcnt++;
    }
  }
  A.at(basyo) += lcnt/2 + lcnt%2;
  A.at(basyo+1) += lcnt/2;
  
  for( int i = 0; i < N; i++ ) cout << A.at(i) << " ";
  cout << endl;
    
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    ll n;
    cin >> n;
    int count= 0;
    for(ll i=1; i < n; i*=3, count++);
    cout << count << endl;
}

Measured memory_bytes: 1164
n = int(input())
ans = []
num = [26**i for i in range(15)]
for i in range(14):
    num[i+1] += num[i]

for i in range(14):
    if n < num[i]:
        ans = [0]*i
        n -= num[i-1]
        break

num = [26**i for i in range(len(ans))]
num.reverse()

for i in range(len(num)):
    count = 0
    while n >= num[i]:
        n -= num[i]
        count += 1
    ans[i] += count

ans = [chr(i+97) for i in ans]
print(*ans, sep = "")


Measured memory_bytes: 62004
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll mod = 998244353;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  mint ans = 0;
  mint color = 1;
  for (int i = n - 1; i >= 0; --i) {
    mint now = m;
    if (i != n - 1) color *= m - 1;
    now *= color;
    if (i <= k) ans += c(n - 1, i) * now;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9) {
        cout << a * b;
    } else {
        cout << -1;
    }
    return 0;
}


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

int main()
{
    string s;cin>>s;
    if(s == "hi"||s == "hihi"||s == "hihihi"||s == "hihihihi"||s == "hihihihihi")cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long m,n,k,i;
    scanf("%lld%lld%lld",&m,&n,&k);
    if((n-m)>=k*2)
    {
        for(i=0;i<k;i++)
        {
            printf("%lld\n",m+i);
        }
        for(i=k-1;i>=0;i--)
        {
            printf("%lld\n",n-i);
        }
    }
    else
    {
        for(i=m;i<=n;i++)
            printf("%lld\n",i);
    }
    return 0;
}

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

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

  vector<bitset<10>> a(n);
  for(int i=0;i<n;i++) {
    for(int j=0;j<10;j++) {
      int input;
      cin >> input;
      if(input == 1) a[i].set(j);
    }
  }

  vector<vector<int>> b(n, vector<int>(11));
  for(int i=0;i<n;i++) {
    for(int j=0;j<11;j++) {
      cin >> b[i][j];
    }
  }

  long long int ans = LLONG_MIN;

  for(int i=0;i<pow(2, 10);i++) {
    if(i == 0) continue;
    bitset<10> me(i);
    long long int profit = 0;
    for(int j=0;j<n;j++) {
      int c = 0;
      for(int k=0;k<10;k++) {
        if(a[j].test(k) && me.test(k)) c++;
      }
      profit += b[j][c];
    }

    if(profit > ans) ans = profit;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int x[131072];
long long p[131072];
long long ans[131072];
int n,s;
long long sol(int l,int r)
{
	if(s>x[r])
	{
		for(int i=l;i<=r;i++)
		{
			ans[i]=s-x[i];
		}
		return ans[l];
	}
	if(s<x[l])
	{
		for(int i=l;i<=r;i++)
		{
			ans[i]=x[i]-s;
		}
		return ans[r];
	}
	if(p[l]>=p[r])
	{
		p[l]+=p[r];
		sol(l,r-1);
		ans[r]=ans[l]+x[r]-x[l];
		return ans[r];
	}
	p[r]+=p[l];
	sol(l+1,r);
	ans[l]=ans[r]+x[r]-x[l];
	return ans[l];
}
int main()
{
	scanf("%d%d",&n,&s);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%lld",&x[i],&p[i]);
	}
	printf("%lld\n",sol(1,n));
	return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>
int main(){
    int total,tax,first,i;
    int before=0,after=0;
    scanf("%d %d %d",&total,&tax,&first);

    while(tax){
      scanf("%d",&i);
      if(i<first) before++;
      else if(i>first) after++;
      tax--;
    }
     if(before<=after) printf("%d\n",before);
     else printf("%d\n",after);
     return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>  // setw
#include <algorithm> // sort next_permutation count __gcd reverse etc.
#include <set>
#include <list>
#include <map>
#include <memory>
#include <numeric> // accumulate
#include <complex>
#include <functional>
#include <utility>
#include <iterator>
#include <vector>
#include <limits>
#include <stack>
#include <queue>
#include <deque>
#include <typeinfo>
#include <fstream> // freopen
#include <cstdio> // scanf printf
#include <cstdlib> // abs exit atof atoi
#include <string> // memset
#include <cstring>
#include <cfloat>
#include <cassert>
#include <cmath> // fabs
#include <cctype> // tolower toupper
#include <ctime> // srand
#include <sstream> // stringstream
#include <bitset>

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

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


int main(int argc, char *argv[])
{
    int array[32] = {
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };
    int a;

    cin >> a;
    cout << array[a-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  char a, b;
  cin >> a >> b;
  if(a=='H'){
    print(b);
  }
  else{
    if(b=='H'){
      print('D');
    }
    else{
      print('H');
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	long long x,a,b;
	cin>>x>>a>>b;
	if(b<=a)cout<<"delicious"<<endl;
	else if(b-a<=x) cout<<"safe"<<endl;
	else cout<<"dangerous"<<endl;
	return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce


def MinB(x, y):
    return (x * y) // fractions.gcd(x, y)

def MinB_list(numbers):
    return reduce(MinB, numbers, 1)

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

tmp = MinB_list(AList)
result = 0
for i in range(0, N):
    result += tmp // AList[i]
    
print(result % (10 ** 9 + 7))

Measured memory_bytes: 6140
#include <cstdio>
#include <algorithm>
int doing(int n) {
	
}
int main() {
	int n;
	scanf("%d",&n);
	int cnt=0;
	for(int i=1;i<=n;++i) {
		for(int j=i+1;j<=n;++j) {
			if(j!=n-i+(n+1)%2) {
				++cnt;
			}
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=n;++i) {
		for(int j=i+1;j<=n;++j) {
			if(j!=n-i+(n+1)%2) {
				printf("%d %d\n",i,j);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1672
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
  for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
const int mod = 1e9;
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;} 
const int N = 2e5 + 100;

ll A[N];

int main(){
  fio; cout<<fixed<<setprecision(25);	
  int n, k; cin >> n >> k;
  ll mx = 0;
  for(int i = 1;i <= n; ++i){
    cin >> A[i];
    mx = max(mx , A[i]);
  }
  vector<int> v;
  v.pb(1);
  for(int i = 0; i < 30 ; ++i) v.pb(2*v.back());
  //cout << v << endl;

  ll lo = 1, hi = mx , ans = mx; 
  while(lo <= hi){
    ll m = (lo+hi)>>1;
    ll res = 0;
    //cout << m << endl;
    for(int i =1 ;i <= n ; ++i){
      //(m-1,m] range of log
      ll lft = (A[i]+m-1)/m;
      res += lft-1;
      //res += lower_bound(all(v) , lft) - v.begin();
      //cout << lft <<  endl;
    }

    if(res <= k){
      ans = m;
      hi = m-1;
    }
    else{
      lo =m+1;
    }
  }
  cout << ans << endl;






  return 0;
}


Measured memory_bytes: 5140
#include<bits/stdc++.h>
#define ll long long int
#define CON 100010
//#define MOD 1e9+7
const long long mod=1e9+7;
const int INF=1001001001;
using namespace std;
int a[12][12];
int main() 
{
	int N,M,X;
	cin>>N>>M>>X;
	vector<int> algo(N);
	for(int i=0;i<N;i++)
	{
		cin>>algo[i];
		for(int j=0;j<M;j++)
		{
			cin>>a[i][j];
		}
	}
	int ans=INF;
	//bit全探索
	for(int bit=0;bit<(1<<N);bit++)
	{
		int cost=0;
		//選んでいる本の理解度の合計を格納する配列
		vector<int> un(M);
		for(int i=0;i<N;i++)
		{
			//ビットのi桁目と1でANDをとる
			if(bit>>i&1)
			{
				//選んでいる本なら買う
				cost+=algo[i];
				for(int j=0;j<M;j++)
				{
					un[j]+=a[i][j];
				} 
			}
			//チェック用変数
			bool check=true;
			//各理解度を比較しX以上でないものが出たら解ではない
			for(int j=0;j<M;j++)
			{
				if(un[j]<X)
				{
					check=false;
				}
			}
			//条件を満たしたとき最小コストであれば解を更新
			if(check)
			{
				ans=min(ans,cost);
			}
		}
	}
	if(ans==INF) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<LL> vl;
typedef vector<vector<LL>> vvl;
typedef vector<vector<vector<LL>>> vvvl;


const int inf = 1e9+7;
const LL INF = 1e18+5;
const int mod = 1e9+7;
const int mxN = 1e5+5;
const int mxM = 1e5+5;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("E:\\Coding\\Programming\\input.txt", "r", stdin);
    freopen("E:\\Coding\\Programming\\output.txt", "w", stdout);
    #endif
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    int ans = inf;
    for(int i=0;i<=n-m;i++){
        int c = 0;
        for(int j=0;j<m;j++){
            if(s[i+j]!=t[j]){
                c++;
            }
        }
        ans = min(ans,c);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<double> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    
    sort(v.begin(),v.end());
    double ans = (v[0] + v[1]) / 2;
   // double ans = 0;
    if(n == 2){
        cout << ans;
    } else{
        for(int i = 2; i < n; i++){
            ans = (ans + v[i]) / 2 ;
        }
        cout << ans;
    }
}


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

int main(){
    int K;
    string S;
    string ans;
    cin >> K >> S;
    if(S.size() <= K){
        ans = S;
    }
    else{
        ans = S.substr(0, K) + "...";
    }

    cout << ans << endl;
}

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  int a, b; cin >> a >> b;
  if (a < b) for (int i = 0; i < b; ++i) cout << a;
  else for (int i = 0; i < a; ++i) cout << b;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x, y;
		x = sc.next();
		y = sc.next();
		sc.close();
		int tmp = x.compareTo(y);
		if(tmp < 0)System.out.println("<");
		else if(tmp == 0)System.out.println("=");
		else System.out.println(">");
	}

}


Measured memory_bytes: 22868
import bisect

n, m = [int(i) for i in input().split()]

table = [[] for _ in range(n)]
p = []
y = []
for i in range(m):
    a, b = [int(i) for i in input().split()]
    p.append(a)
    y.append(b)
    table[a-1].append(b)

vals = [[] for _ in range(n)]

for i in range(n):
    vals[i] = sorted(table[i])


for i in range(m):
    a = str(p[i]).zfill(6)
    b = str(bisect.bisect(vals[p[i]-1], y[i])).zfill(6)
    print(a+b)

Measured memory_bytes: 108720
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main() {
  int n,cnt = 0;
  string s,t;
  cin >> s >> t;
  n = s.size();
  for (int i = 0; i < n; i++){
    if (s[i] != t[i]){
      cnt++;
    }
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3920
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    vector<vector<int>> c(3, vector<int>(3));
    for(int i = 0; i < 9; i++)
    {
        cin >> c[i/3][i%3];
    }
    double x=0,y=0,z=0;
    for(int i = 0; i < 3; i++)
    {
        x+=c[i][i];
        y+=c[2-i][i];
    }
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            z+=c[i][j];   
        }
    }
    if (x==y && y==z/3.0) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> il(100, 0);
    for (int i = 2; i <= n; ++i)
    {
        int t = i;
        for (int j = 2; j <= i; ++j)
        {
            while (t % j == 0)
            {
                t /= j;
                ++il[j];
            }
        }
    }
    int odp = 0, o = 0;
    for (int i = 0; i < 100; ++i)
    {
        if (il[i] >= 74)
            ++odp;
        for (int j = 0; j < 100; ++j)
        {
            if (i != j && il[i] >= 2 && il[j] >= 24)
                ++odp;
            if (i != j && il[i] >= 14 && il[j] >= 4)
                ++odp;
            for (int k = 0; k < 100; ++k)
                if (i != j && j != k && i != k && il[i] >= 2 && il[j] >= 4 && il[k] >= 4)
                    ++o;
        }
    }
    odp += o / 2;
    cout << odp;
    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(){
  string str;
  cin >> str;
  
  if(str == "Sunny") cout << "Cloudy" << endl;
  if(str == "Rainy") cout << "Sunny" << endl;
  if (str == "Cloudy") cout << "Rainy" << endl;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;


public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;
    
    public static void main(String[] args) {
        long r = ni();
        long D = ni();
        long x = ni();
        
        for (int i = 0; i < 10; i++) {
            x = r*x - D;
            so.println(x);
        }
    }
    
    private static int ni() {
        return sc.nextInt();
    }

    private static long nl() {
        return sc.nextLong();
    }

    private static String ns() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static int[] nints(int n) {
        return nints(n, 0);
    }

    private static int[] nints(int n, int padding) {
        int[] a = new int[padding + n];
        for (int i = 0; i < n; i++)
            a[padding + i] = ni();
        return a;
    }
}


Measured memory_bytes: 22996
#include<stdio.h>
    
int main(){
    
int h1,h2,tai,tcnt,hcnt;

tcnt =0;
hcnt=0;
  
while(scanf("%d,%d,%d",&h1,&h2,&tai)!=EOF){
  if((h1*h1)+(h2*h2)==(tai*tai)){tcnt=tcnt+1;}
  else if(h1==h2){hcnt=hcnt+1;}
  
}
printf("%d\n",tcnt);
printf("%d\n",hcnt);       
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;


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

			while(true) {

				int m = sc.nextInt();
				int f = sc.nextInt();
				int r = sc.nextInt();

				if((m == -1) && (f == -1) && (r == -1)) {
					break;
				}

				if((m == -1) || (f == -1)) {

					System.out.println("F");

				} else if(m + f >= 80) {

					System.out.println("A");

				} else if(m + f >= 65) {

					System.out.println("B");

				} else if(m + f >= 50) {

					System.out.println("C");

				} else if(m + f >= 30) {

					if(r >= 50) {

						System.out.println("C");

					} else {

						System.out.println("D");

					}

				} else {

					System.out.println("F");

				}

			}
	}
}

Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    string s;
    int K;
    cin >> s >> K;
    int l = s.size();

    vi S(l);
    rep(i, l) {
        S[i] = s[i]-'a';
    }

    rep(i, l) {
        if(S[i]==0) {
            if(i!=l-1) continue;
            else S[i] = (S[i]+(K%26))%26;
        } else if(26-S[i] <= K) {
            if(i!=l-1) {
                K -= 26-S[i];
                S[i] = 0;
            } else S[i] = (S[i]+(K%26))%26;
        } else {
            if(i!=l-1) continue;
            else S[i] = (S[i]+(K%26))%26;
        }
    }

    rep(i, l) {
        cout << char(S[i]+'a');
    } cout << endl;

    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    if(A==B){
      System.out.println(C);
    }else if(A==C){
      System.out.println(B);
    }else{
      System.out.println(A);
    }
  }
}

Measured memory_bytes: 23124
n,a,b=map(int,input().split())

mod=10**9+7

def pow_cal(x,n,mod):
    if n==0:
        return 1
    elif n==1:
        return x%mod
    elif n>=2:
        if n%2==0:
            return (pow_cal(x,n//2,mod)**2)%mod
        else:
            return (x*pow_cal(x,n//2,mod)**2)%mod

def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist

def find_inv_power(n,mod):
    #0!からn!までの逆元を素数modで割ったあまりリストを作る関数
    c=1
    uselist=[0 for i in range(n+1)]
    for i in range(1,n+1):
        c*=i
        c%=mod
    first=pow_cal(c,mod-2,mod)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist
A=find_power(2*10**5,mod)
B=find_inv_power(2*10**5,mod)

d=pow_cal(2,n,mod)-1
p=1
q=1

for i in range(1,a+1):
    p*=(n+1-i)
    p%=mod

p=p*B[a]%mod

for j in range(1,b+1):
    q*=(n+1-j)
    q%=mod

q=q*B[b]%mod

print((d-p-q)%mod)


Measured memory_bytes: 63180
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define M 1046527
#define NIL (-1)
#define L 14


char H[M][L];

// ??????????????°????????????
int getChar( char ch ){
	if( ch=='A' ) return 1;
	else if( ch=='C' ) return 2;
	else if( ch=='G' ) return 3;
	else if( ch=='T' ) return 4;
	else return 0;
}

// ?????????????????°??????????????????key???????????????
long long getKey( char str[] ){
	long long sum=0,p=1;
	for(int i=0; i<strlen(str); i++){
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + ( key % (M-1) );}

int find(char str[]){
	long long key,h;
	key = getKey(str); // ??????????????°????????????
	for(int i=0;; i++){
		h = (h1(key)+i*h2(key))%M; // ????????????????????\?????¨????????????????????¢?????¬??????
		if( strcmp(H[h],str)==0 ) return 1;
		else if(strlen(H[h])==0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key,h;
	key = getKey(str); // ??????????????°????????????
	for(int i=0;; i++){
		h = (h1(key)+i*h2(key)) % M;
		if( strcmp(H[h],str)==0 ) return 1;
		else if( strlen(H[h])==0 ){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int n,h;
	char str[L],com[9];
	for(int i=0; i<M; i++) H[i][0]='\0';
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%s %s",com,str);

		if( com[0]=='i' ){
			insert(str);
		}else{
			if( find(str) ){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 17420
#include<cstdio>

int main(){
  int x,y,z;
  while(1){
    scanf("%d %d",&x,&y);
    if(x>y){
      z=x;
      x=y;
      y=z;
    }
    else if(x==y && x==0)
      break;
    printf("%d %d\n",x,y);
  } 
  return 0;
}

Measured memory_bytes: 1028
from operator import itemgetter

n, m = map(int, input().split())
ans = []

for i in range(m):
    p, y = map(int, input().split())
    ans.append((i, p, y))

ans = sorted(ans, key=itemgetter(1, 2))

_city = -1
for i in range(len(ans)):
    if _city != ans[i][1]:
        cnt_city = 1
        _city = ans[i][1]
    else:
        cnt_city += 1
    ans[i] += (cnt_city,)

ans.sort()

for _ans in ans:
    print(str(_ans[1]).zfill(6)+str(_ans[3]).zfill(6))


Measured memory_bytes: 85336
import java.util.Scanner;
 public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        String s = scanner.next();
      
        int a =s.length();
      
        if(a<=k){
        System.out.println(s);
        }
      else if(a>k){
      System.out.println(s.substring(0,k)+"...");
      }
    }
 }

Measured memory_bytes: 38568
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		
		long[] vs = new long[N];
		for(int i = 0; i < N; i++){
			final long v = sc.nextLong();
			vs[i] = v;
		}
		
		TreeMap<Long, Integer> counts = new TreeMap<Long, Integer>(Collections.reverseOrder());
		for(final long v : vs){
			if(!counts.containsKey(v)){
				counts.put(v, 0);
			}
			counts.put(v, counts.get(v) + 1);
		}
		
		long[][] comp = new long[N + 1][N + 1];
		comp[0][0] = 1;
		for(int i = 0; i < N; i++){
			for(int j = 0; j <= i; j++){
				comp[i + 1][j] += comp[i][j];
				comp[i + 1][j + 1] += comp[i][j];
			}
		}
		
		int rest_A = A;
		int rest_B = B;
		long sum = 0;
		for(final long v : counts.keySet()){
			final int count = counts.get(v);
			
			if(count <= rest_A){
				sum += v * count;
				rest_A -= count;
				rest_B -= count;
			}else{
				if(sum == 0){
					System.out.println(v);
					long opt = 0;
					
					for(int i = rest_A; i <= Math.min(rest_B, count); i++){
						opt += comp[count][i];
					}
					
					System.out.println(opt);
					return;
				}else{
					sum += v * rest_A;
					System.out.printf("%.08f\n", sum / (double)(A));
					System.out.println(comp[count][rest_A]);
					return;
				}
			}
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21588
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <utility>
#include <climits>
 
#include <cstdio>
  
using namespace std;
 
#define REP(var, count) for(int var=0; var<count; var++)


const int NMAX = 200010;

int data[NMAX];

int main(void) {
	int N, K;
	cin >> N >> K;
	REP(i, N) {
		int x;
		cin >> x;
		data[x]++;
	}
	
	sort(data, data+NMAX, greater<int>());
	int ret = 0;
	REP(i, NMAX) {
		if ( data[i] == 0 ) { break; }
		if ( i+1 > K ) {
			ret += data[i];
		}
	}
	
	cout << ret << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MAX_N=200009;
int N,M;

struct unionfind{
  int par[MAX_N];
  int myrank[MAX_N];
  int size[MAX_N];
  void init(int n){
    for(int i=1;i<=n;i++){par[i]=i; myrank[i]=0; size[i]=1;}
  }
  int find(int x){
    if(par[x]==x){return x;}
    else{return par[x]=find(par[x]);}
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y){return;}
    if(myrank[x]<myrank[y]){par[x]=y; size[y]+=size[x];}
    else{par[y]=x; size[x]+=size[y];}
    if(myrank[x]==myrank[y]){myrank[x]++;}
  }
  bool same(int x, int y){return find(x)==find(y);}
};

int main(){
  cin >> N >> M;
  unionfind T;
  T.init(N+M);
  for(int i=1;i<=N;i++){
    int K; cin >> K;
    for(int j=0;j<K;j++){
      int L; cin >> L;
      T.unite(i,N+L);
    }
  }
  string ans="YES";
  int memo=T.find(1);
  for(int i=2;i<=N;i++){
    if(memo!=T.find(i))ans="NO";
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long ll;
const int maxn=1e5+10;

int n,x;
int a[maxn];
int main(){
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;i++){
        scanf("%d",a+i);
    }
    a[0]=0;
    a[n+1]=0;
    ll ans=0;
    for(int i=1;i<=n;++i){
        if(a[i]==0) continue;
        if(a[i]+a[i-1]>x){
            ans+=a[i]+a[i-1]-x;
            a[i]-=(a[i]+a[i-1]-x);
        }
    }
    printf("%lld\n",ans);
    //getchar();
    //getchar();

    return 0;
}

Measured memory_bytes: 640
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,k,a[5555],sum,ans;
bool vis[5555];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	if(sum<k)
	{
		cout<<n<<endl;
		return 0;
	}
	vis[0]=true;
	for(int i=n-1;i>=0;i--)
	{
		for(int j=max(0ll,k-a[i]);j<k;j++)
		{
			if(vis[j])
			{
				ans=i;
				break;
			}
		}
		for(int j=k-a[i]-1;j>=0;j--)
		{
			vis[j+a[i]]|=vis[j];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if(a.back() == b[0] && b.back() == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


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

using namespace std;

int n,m;
int ans;
int blo[100][100];

void ice(int x,int y,int num){
	blo[x][y] = 0;
	if(num > ans)ans = num;
	int ix[4] = {1,-1,0,0};
	int iy[4] = {0,0,1,-1};
	
	for(int i = 0; i < 4; i++){
		if(blo[x+ix[i]][y+iy[i]] && x+ix[i] > -1 && y+iy[i] > -1 && x+ix[i] < n && y+iy[i] < m){
			ice(x+ix[i],y+iy[i],num+1);
		}
	}
	blo[x][y] = 1;
}

int main(){
	while(scanf("%d%d",&m, &n) && n && m){
		ans = 0;
		for(int i = 0 ; i < n; i++){
			for(int j = 0; j < m; j++){
				scanf("%d", &blo[i][j]);
			}
		}
		for(int i = 0 ; i < n; i++){
			for(int j = 0; j < m; j++){
				if(blo[i][j])ice(i,j,1);
			}
		}
		printf("%d\n",ans);
		for(int i = 0 ; i < n; i++){
			for(int j = 0; j < m; j++){
				blo[i][j] = 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0