akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    int m = (n + x - 1) / x;
    cout << m * t << endl;

    return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            char[] C = cin.next().ToCharArray();
            
            Console.WriteLine((char)(C[0] + 1));
        }
    }
}


Measured memory_bytes: 13268
import math

a, b, h, m = map(int, input().split())

tmi = h * 60 + m

a_dig = tmi*((360) / (12 * 60))
b_dig = tmi*((360) / (60))

diff = a_dig - b_dig

# print(diff)
r = math.radians(diff)


s = b * math.sin(r)
c = b * math.cos(r)

dist = math.sqrt((a - c) ** 2 + s ** 2)
print(dist)


Measured memory_bytes: 9516
#include <algorithm>
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<tuple<string,int,int>> V;
  for(int i = 0; i < N; ++i){
    string s;
    int p;
    cin >> s >> p;
    V.emplace_back(s,-p,i+1);
  }
  sort(V.begin(), V.end());
  for(auto e : V){
    cout << get<2>(e) << endl;
  }
}


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

int main() {
  string s,t;
  cin >> s >> t;
  
  cout << t << s << endl;
}

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

int main()
{
    int N;
    int i;
    vector<long> x, y, h;
    long cx, cy;
    bool ok;
    long H, candidate;

    cin >> N;
    x = vector<long>(N);
    y = vector<long>(N);
    h = vector<long>(N);
    for(i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];
    }

    for(cx = 0; cx <= 100; ++cx) {
        for(cy = 0; cy <= 100; ++cy) {
            ok = true;
            H = -1;
            // Check Height
            for(i = 0; i < N; ++i) {
                if(h[i] == 0) continue;
                candidate = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
                if(H == -1) H = candidate;
                if(H != candidate) {
                    ok = false;
                    break;
                }
            }
            if(H == -1 || !ok) continue;
            for(i = 0; i < N; ++i) {
                if(h[i] != 0) continue;
                if(H - abs(x[i] - cx) - abs(y[i] - cy) > 0){
                    ok = false;
                    break;
                }
            }
            if(!ok) continue;
            printf("%d %d %ld", cx, cy, H);
            return 0;
        }
    }
    return 1;
}

Measured memory_bytes: 256
import bisect
N = int(input())
L_list =  sorted(list(map(int,input().split())))
#print(L_list)
result =0

for i in range(N):
    for j in range(i+1,N):
        a = L_list[i] + L_list[j]
        idx = bisect.bisect_left(L_list,a)
        result += max(0,idx-j-1)
print(result)

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

using namespace std;

#define int long long 
#define INF 21000000000

signed main(){
		int a,b,c,n,m;
		cin >> a >> b >> c >> n >> m;
		int ans;
		if(a + b > c * 2){
				if(n > m) ans = c * m * 2 + a * (n - m);
				else ans = c * n * 2 + b * (m - n);
		}else{
				ans = a * n + b * m;
		}
		if(n > m){
				if(ans > c * n * 2) ans = c * n * 2;
		}else{
				if(ans > c * m * 2) ans = c * m * 2;
		}
		cout << ans << endl;
}



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

int main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> a(n);
  vector<int> b(m);
  
  for(int i = 0; i< n; i++){
    cin >> a[i];
  }
  for(int i = 0; i< m; i++){
    cin >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  
  for(int i = x+1; i <= y; i++){
    if(i > a[n-1] && i <= b[0]){
      cout << "No War" << endl;
      return 0;
    }
  }
  
  cout << "War" << endl;
  
  return 0;
}

Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {


	char str[51][51];
	int h, w;
	int dx[] = { 1,0,-1 };
	int dy[] = { 1,0,-1 };
	int ans[51][51] = { 0 };


	cin >> h >> w;

	rep(i, 0, h) {
		rep(j, 0, w) {
			cin >> str[i][j];
		}
	}


	rep(i, 0, h) {
		rep(j, 0, w) {
			if (str[i][j] == '#') {
				ans[i][j] = -1;
				rep(x, 0, 3) {
					rep(y, 0, 3) {
						if (str[i + dy[y]][j + dx[x]] == '.'&&ans[i + dy[y]][j + dx[x]] != -1) {
							ans[i + dy[y]][j + dx[x]]++;
						}
					}
				}
			}
		}
	}

	rep(i, 0, h) {
		rep(j, 0, w) {
			if (ans[i][j] != -1) {
				cout << ans[i][j];
			}
			else {
				cout << '#';
			}
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}



int main(){
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

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

	//2分探索
	ll left = 0, right = 1e9+1;
	while(right - left > 1){
		vector<ll> B = A;
		ll mid = (left+right) /2;
		ll num_cut = 0;
		for(int i=0; i<N; i++){
			// while(B[i] > mid){
			// 	//B[i] = B[i] - mid;//B[i]をmidとA[i]-midに切り分ける
			// 	//num_cut++;
			// 	num_cut += B[i] / mid;
			// 	if(num_cut>K) break;
			// }
			// num_cut += (B[i]+mid-1) / mid;
			if(B[i] > mid) num_cut += B[i] / mid;
			// num_cut += B[i] / mid - 1;
			if(num_cut>K) break;
		}

		if(num_cut>K) left = mid;
		else right = mid;
		// cout << " left: " << left << "  mid: " << mid << " right: " << right << " num_cut: " << num_cut << endl;
		// cout << " B: "; print_vec(B);
	}

	cout << right << endl;


	// sort(A.begin(), A.end());
	// for(int i=0; i<K; i++){
	// 	ll tmp = A.back();
	// 	A.pop_back();
	// 	if(tmp % 2 == 1){
	// 		A.push_back(tmp/2);
	// 		A.push_back(tmp/2+1);
	// 	}
	// 	else{
	// 		A.push_back(tmp/2);
	// 		A.push_back(tmp/2);
	// 	}
	// 	sort(A.begin(), A.end());

	// }

	// cout << A.back() << endl;

	return 0;
}



Measured memory_bytes: 6340
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
const int N=1e5;
int main(){
	char ch;
	cin>>ch;
	ch+=1;
	cout<<ch<<endl;
}
/*
Small :- 
Medium :- 
Large :- 
*/


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

int main()
{
  string answer;
  int N;
  int kake;
  int amari;
  cin >> N;
  for(int i = 1 ; i < 10 ; i++){
    kake = N / i;
    amari = N % i;
    if(amari == 0){
      if( kake < 10 ){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){

	char c;
	cin >> c;
	cout << char(c+1 ) << endl;

	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc151.contest.atcoder.jp/tasks/abc151_b

Measured memory_bytes: 256
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(i => Convert.ToInt32(i)).ToArray();
            int evenNum = 0;
            for (var i = 0; i < N; i++)
            {
                while (A[i] % 2 == 0)
                {
                    evenNum++;
                    A[i] /= 2;
                }
            }
            Console.WriteLine(evenNum);
        }
    }
}


Measured memory_bytes: 14176
#include <vector>
using namespace std;

class UnionFind
{
public:
    vector<int> parent;
    vector<int> sz;
    
    UnionFind(int n): parent(n), sz(n)
    {
        for(int i=0;i<n;i++)
        {
            parent[i] = i;
            sz[i] = 1;
        }
    }

    int root(int x)
    {
        return parent[x]==x ? x : parent[x] = root(parent[x]);
    }

    bool same(int x, int y)
    {
        return root(x)==root(y);
    }

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (sz[x] < sz[y])
            {
                parent[x] = y;
                sz[y] += sz[x];
            }
            else
            {
                parent[y] = x;
                sz[x] += sz[y];
            }
        }
    }

    int size(int x)
    {
        return sz[root(x)];
    }
};

#include <iostream>
#include <algorithm>
#include <utility>

int main()
{
    int N;
    cin>>N;
    vector<long long> x(N), y(N);
    for (int i=0; i<N; i++)
        cin>>x[i]>>y[i];

    vector<pair<long long, int>> vx(N), vy(N);
    for (int i=0; i<N; i++)
    {
        vx[i] = make_pair(x[i], i);
        vy[i] = make_pair(y[i], i);
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());

    vector<pair<long long, pair<int, int>>> E;
    for (int i=0; i<(int)vx.size()-1; i++)
        E.push_back(make_pair(vx[i+1].first-vx[i].first, make_pair(vx[i].second, vx[i+1].second)));
    for (int i=0; i<(int)vy.size()-1; i++)
        E.push_back(make_pair(vy[i+1].first-vy[i].first, make_pair(vy[i].second, vy[i+1].second)));
    sort(E.begin(), E.end());

    long long ans = 0;
    UnionFind UF(N);
    for (auto e: E)
        if (!UF.same(e.second.first, e.second.second))
        {
            ans += e.first;
            UF.unite(e.second.first, e.second.second);
        }
    cout<<ans<<endl;
}


Measured memory_bytes: 11248
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 9223372036854775807
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  double n,m,d;
  cin >> n >> m >> d;
  
  double cnt = max((double)0,n-d)*2;
  if(d == 0) cnt = n;
  double ans =  cnt*(m-1)/n/n;
  cout << fixed << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int K = int.Parse(s[1]);
        string upper = Console.ReadLine();
        string lower = upper.ToLower();
        string ans = "";
        for (int i = 0; i < upper.Length; i++)
        {
            ans += i != K - 1 ? upper[i] : lower[i];
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1e+7
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

int main(){
  double L;
  cin >> L;
  ////PPPPPPPPPPPPPPPRIIIIIIIIIIIINNNNNNNNNNNNNNTTTTTTTTTTTTFFFFFF
  printf("%lf\n",(L*L*L) / 27 );
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 
#include <atcoder/all>

typedef long long ll;
typedef unsigned long long ull;
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;
using namespace atcoder;

int n;
vector<int> vv, vv1;

struct F {
    int b;
};

struct S {
    ll  a;
    int size;
};

S op(S l, S r) {
    return S{ ((ll)l.a * vv[r.size] + r.a) % MOD, l.size + r.size };
}

S e() {
    return S{ 0, 0 };
}

S mapping(F f, S x) {
    //return S{ ((ll)f.b*x.a + (ll)f.c*x.size) % MOD, x.size };
    if (f.b < 0) {
        return x;
    }
    else {
        int tmp = ((ll)f.b*vv1[x.size-1]) % MOD;
        return S{ tmp, x.size };
    }
}

F composition(F l, F r) {
    if (l.b < 0) {
        return r;
    }
    else if (r.b < 0) {
        return l;
    }
    else {
        return l;
    }
}

F id() {
    return F{ -1 };
}

void solve()
{
    int Q;
    scanf("%d%d", &n, &Q);


    vv.resize(n*2+100); vv1.resize(n*2+100);
    int i;
    for (i = 0; i < n*2+100; i++) {
        if (i == 0) {
            vv[i] = 1;
            vv1[i] = 1;
        }
        else {
            vv[i] = (ll)vv[i - 1] * 10 % MOD;
            vv1[i] = ((ll)vv1[i - 1] * 10 + 1)% MOD;
        }
    }

    vector<S> vvv(n, S{ 1,1 });
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vvv);

    for (i = 0; i < Q; i++) {
#if 0
//#ifdef _DEBUG
        printf("(%d) ", i);
        int k;
        for (k = 0; k < n; k++) {
            printf("[%d]%lld,", k, seg.get(k).a);
        }
        printf("\n");
#endif
        {
            int l, r, b;
            scanf("%d%d%d", &l, &r, &b); l--; r--;
            seg.apply(l, r+1, F{ b });
        }
        {
            printf("%lld\n", seg.prod(0, n).a);
#if 0
            int k;
            for (k = 0; k <= n; k++) {
                printf("%d %lld\n", k, seg.prod(0, k).a);
            }
#endif
        }
    }
#if 0
//#ifdef _DEBUG
    printf("(%d) ", i);
    int k;
    for (k = 0; k < n; k++) {
        printf("[%d]%lld,", k, seg.get(k).a);
    }
    printf("\n");
#endif
    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 18820
#include<stdio.h>

int search(int *, int , int );

int main() {
  int i, n, A[10000+1], q, key, sum = 0;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);

  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &key);
    if ( search(A, n, key) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while ( A[i] != key ) i++;
  return i != n;
}


Measured memory_bytes: 2108
using System;

public class my
{
	public static void Main()
	{
		var n = my.GetLong();
		
		var A = new long[n];
		for(int i = 0; i < n; i++) {
			A[i] = my.GetLong();
		}
		
		my.ShellSort(A);
	}
	
	private static void ShellSort(long[] A)
	{
		long cnt = 0;
		int m;
		if(A.Length <= 4)			m = 1;
		else if(A.Length < 16)		m = 2;
		else if(A.Length < 64)		m = 3;
		else if(A.Length < 256)		m = 4;
		else if(A.Length < 512)		m = 5;
		else if(A.Length < 1024)	m = 6;
		else if(A.Length < 2048)	m = 7;
		else if(A.Length < 4096)	m = 8;
		else if(A.Length < 16384)	m = 9;
		else if(A.Length < 65536)	m = 10;
		else						m = 11;
		
		var G = new long[m];
		for(int i = 0; i < m; i++) {
			if(i == 0) {
				G[i] = 1;
			} else {
				G[i] = G[i - 1] + (long)Math.Pow(3, i);
			}
		}
		Array.Reverse(G);
		
		for(int i = 0; i < m; i++) {
			cnt += my.InsertionSort(A, G[i]);
		}
		
		// display
		Console.WriteLine(m);
		my.WriteArray(G);
		Console.WriteLine(cnt);
		foreach(var a in A) {
			Console.WriteLine(a);
		}
	}
	
	// Insertion sort has interval g.
	private static long InsertionSort(long[] A, long g)
	{
		long cnt = 0;
		
		for(long i = g ; i < A.Length; i++ ) {
			var v = A[i];
			long j = i-g;
			while(j>=0 && A[j] > v) {
				A[j + g] = A[j];
				j -= g;
				cnt++;
			}
			A[j+g] = v;
		}
		
		return cnt;
	}
	
	private static void Swap(ref string a, ref string b) 
	{
		string tmp = a;
		a = b;
		b = tmp;
	}
	
	private static void Swap(ref int a, ref int b) 
	{
		int tmp = a;
		a = b;
		b = tmp;
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static long GetLong()
	{
		return long.Parse(Console.ReadLine());
	}
}

Measured memory_bytes: 23632
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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



int main() {

	int n, k, x;
	int ans = 0;

	cin >> n >> k;
	rep(i, 0, n) {
		cin >> x;
		if (x <= k - x)ans += 2 * x;
		else ans += 2 * (k - x);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<iostream>
#include<queue>

using namespace std;
typedef long long ll;

inline int input(){
	char c;
	for(c = getchar();c<'0' || c>'9';c = getchar());
	int res = c - '0';
	for(c = getchar();c>='0' && c<='9';c = getchar()) res = res * 10 + (c - '0');
	return res;
}
inline char letter(){
	char c;
	for(c = getchar();c != 'M' && c != 'Q';c = getchar());
	return c;
}
int n,q,p[100005],par[100005];
int mark[100005];
char c[100005];
int v[100005];
inline void ini(int x){
	for(int i=1;i<=x;i++){
		if(mark[i]) par[i] = i;
		else par[i] = p[i];
	}
}
int find_(int x){
	if(par[x] == x) return x;
	return par[x] = find_(par[x]);
}
int main(){
//	ios::sync_with_stdio(false);
	while(true){
		ll ans = 0;
		n = input();
		q = input();
		if(n == 0 && q == 0) break;
		p[1] = 1;
		mark[1] = 1;
		for(int i=2;i<=n;i++){
			p[i] = input();
		}
		for(int i=1;i<=q;i++){
			c[i] = letter();
			v[i] = input();
			if(c[i] == 'M') mark[v[i]]++;
		}
		ini(n);
		for(int i=q;i>=1;i--){
			if(c[i] == 'Q') ans += find_(v[i]);
			else{
				mark[v[i]]--;
				if(!mark[v[i]]) par[v[i]] = p[v[i]];
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 5028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int ans = 0;
		for(int i = 0 ; i < n ; i++) {
			if(s.charAt(i) == '1') {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int a, b;
  cin >> a >> b;

  if (a > b)
    swap(a, b);

  rep(i, b) {
    cout << a;
  }
  cout << "\n";
}

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

int n, r;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> n >> r;
		if(n == 0 && r == 0) return 0;
		int a[n] = {};
		for(int i=0; i<n; ++i)
			a[i] = n-i;
//		for(int i=0; i<n; ++i)
//			cout << a[i] << (i==n-1?"\n":" ");
		for(int i=0; i<r; ++i){
			int p, c;
			cin >> p >> c;
			int b[c] = {};
			for(int i=0; i<c; ++i)
				b[i] = a[p+i-1];
			for(int i=p-2; i>=0; --i)
				a[c+i] = a[i];
//			for(int i=0; i<n; ++i)
//				cout << a[i] << (i==n-1?"\n":" ");
			for(int i=0; i<c; ++i)
				a[i] = b[i];
//			for(int i=0; i<n; ++i)
//				cout << a[i] << (i==n-1?"\n":" ");
		}
		cout << a[0] << "\n";
	}
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//---------------------------------------------------------------------------//
int a[3];
int main(){
        cin>>a[0]>>a[1]>>a[2];
        sort(a,3);
        if(a[0]==5 && a[1]==5 && a[2]==7) {
                cout<<"YES"<<endl;
        }else{
                cout<<"NO"<<endl;
        }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    ll k;
    cin >> k;
    int n = 50;
    vector<ll> ans(n, n - 1);
    if(k <= (ll)n){
        for(int i = 0; i < k; ++i)  ans[i] += n - k + 1;
        for(int i = k; i < n; ++i)  ans[i] -= k;
    }
    else{
        ll foo = k / n;
        k %= n;
        for(int i = 0; i < k; ++i){
            ans[i] += foo;
            ans[i] += n - k + 1;
        }
        for(int i = k; i < n; ++i){
            ans[i] += foo;
            ans[i] -= k;
        }
    }
    cout << n << endl;
    for(int i = 0; i < n; ++i){
        cout << ans[i] << ((i == n - 1) ? "\n" : " ");
    }
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const 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 true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vector<pii> AV;
	int V;
	rep(i, 0, A)
	{
		cin >> V;
		AV.push_back(mp(V, 0));
	}
	rep(i, 0, B)
	{
		cin >> V;
		AV.push_back(mp(V, 1));
	}
	rep(i, 0, C)
	{
		cin >> V;
		AV.push_back(mp(V, 2));
	}

	sort(all(AV), greater<pii>());

	int ai = 0, bi = 0;
	priority_queue<int> pq;
	int csum = 0;
	int absum = 0;
	int ans = 0;

	for (auto p : AV)
	{
		if (p.second == 0)
		{
			if (ai == X)continue;
			absum += p.first;
			ai++;
		}
		else if (p.second == 1)
		{
			if (bi == Y)continue;
			absum += p.first;
			bi++;
		}
		else
		{
			csum += p.first;
			pq.push(p.first);
		}
		if (ai + bi + SZ(pq) > X + Y)
		{
			int c = pq.top();
			pq.pop();
			csum -= c;
		}
		chmax(ans, absum + csum);
		if (ai == X && bi == Y)
		{
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10476
#教室内の位置は右*中央
#問題は「Eleven Lover」(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2182&lang=jp)
#本当は問題「Planning Rolling Blackouts」(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1176&lang=jp)
#を解こうとしたのですが、小区間での分割をひたすら統合する解法までは立ったものの実装力がなかったので一旦やめました
while(True):
    #今回はinputの数字を文字列として一桁ずつ扱った方が嬉しいのでint()しません
    s = input()
    m = len(s)
    #0を弾くやつ
    if s == "0":
        quit()
    #pdfに書いていた方針と全く同じやり方をします
    #配列dpをA_i,jとしてとります
    dp = [[0 for j in range(11)] for i in range(m)]
    for i in range(m):
        n = int(s[i])
        #ここで、どこかの桁が0になってる時に注意します
        #というのも、問題文中に「0から始まる数は11の倍数に含めない」としてあるからです
        #したがって0が出た時はそこまでの数字を10倍する効果しか持たないことになります
        if n == 0:
            tmp = dp[i-1][1:]
            tmp.reverse()
            #dp[i][0]=dp[i-1][0]
            #dp[i][k]=dp[i-1][11-k] (if k >= 1)となります(これがtmp.reverse()の意図)
            dp[i] = [dp[i-1][0]]+tmp
        else:
            #やるだけ
            tmp = dp[i-1][1:]
            tmp.reverse()
            #10倍なのでA[i][k] (k>=1)をリバース(上と同じ)
            tmp = [dp[i-1][0]]+tmp
            #i桁目の数字を見てその分A_i,jをずらします
            #添字に注意
            dp[i] = tmp[-n:]+tmp[:-n]
            dp[i][n] += 1 #インクリメントも忘れずに
    #あとはdp[k][0]を足すだけ
    print(sum([i[0] for i in dp]))



Measured memory_bytes: 37200
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int a = in(), b = in(), c = in();
  rep(t, 60) {
    if ((t * 60 + c) % (a + b) <= a) {
      pr(t * 60 + c);
      return 0;
    }
  }
  pr(-1);
  return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<set>
#include<string>
#include<algorithm>

using namespace std;

int solve(string str)
{
    int size = str.size();

    set<string> ans{};
    for(int i = 1; i < size; i++)
    {
        string front = str.substr(0, i);
        string back = str.substr(i);

        string r_front = front;

        string r_back = back;

        ans.insert(front + back);
        ans.insert(back + front);

        if(i != size - 1)
        {
            reverse(r_back.begin(), r_back.end());
            ans.insert(front + r_back);
            ans.insert(r_back + front);
        }

        if(i != 1)
        {
            reverse(r_front.begin(), r_front.end());

            ans.insert(r_front + back);
            ans.insert(back + r_front);
        }        
        ans.insert(r_front + r_back);
        ans.insert(r_back + r_front);
    }
    return ans.size();
}

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

    for(int i = 0; i < n; i++)
    {
        string str{ "" };
        cin >> str;
        cout << solve(str) << endl;
    }

    return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int H, W; cin >> H >> W;
	int h, w; cin >> h >> w;
	printf("%d\n", (H - h) * (W - w));
	return 0;
}

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

using ll=long long; 

void solve(){
	int a,b,k;
	int cnt=0;
	cin>>a>>b>>k;
	int minv=min(a,b);
	for(int i=minv; i>=0; i--){
		if(a%i==0&&b%i==0){
			cnt++;
			if(k==cnt){
				cout<<i<<endl;
				return;
			}
		}
	}
}

signed main(){
	//while(1)
	solve();
}

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

int main() {
    int64_t n, k;
    cin >> n >> k;

    int64_t ans;
    int64_t x = n % k;
    int64_t a, b;
    a = abs(x - k);
    b = x;
    ans = min(a, b);
    cout << ans << endl;

    return 0;
}

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

int main()
{
	string str, com, p;
	int q, a, b;

	cin >> str >> q;
	for (int t = 0; t < q; t++) {
		cin >> com >> a >> b;
		if (com == "print") {
			cout << str.substr(a, b - a + 1) << endl;
		}
		else if (com == "reverse") {
			string tmp = str.substr(a, b - a + 1);
			int n = tmp.size();
			for (int i = 0; i < n; i++) str[i + a] = tmp[n - i - 1];
		}
		else if (com == "replace") {
			cin >> p;
			str = str.replace(a, b - a + 1, p);
		}
	}
	return 0;
}

Measured memory_bytes: 3204
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

bool dpx[8010][16010];
bool dpy[8010][16010];
int main(void){
    string s;
    int x,y;
    cin>>s;
    cin>>x>>y;
    x+=8000;
    y+=8000;
    //0->x,1->y;
    vector<int>proc[2];
    int t=0,parity=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='F')t++;
        else{
            if(parity==0){
                proc[parity].push_back(t);
                t=0;
                parity=1;
            }
            else{
                proc[parity].push_back(t);
                t=0;
                parity=0;
            }
        }
    }
    proc[parity].push_back(t);
    int xsize=(int)proc[0].size();
    int ysize=(int)proc[1].size();
    dpx[1][8000+proc[0][0]]=true;
    for(int i=1;i<xsize;i++){
        for(int j=0;j<=16000;j++){
            if(j>=proc[0][i]){
                dpx[i+1][j]=dpx[i][j-proc[0][i]]|dpx[i][j+proc[0][i]];
            }
            else {
                dpx[i+1][j]=dpx[i][j+proc[0][i]];
            }
        }
    }
    if(!dpx[xsize][x]){
        cout<<"No"<<endl;
        return 0;
    }
    dpy[0][8000]=true;
    for(int i=0;i<ysize;i++){
        for(int j=0;j<=16000;j++){
            if(j>=proc[1][i]){
                dpy[i+1][j]=dpy[i][j-proc[1][i]]|dpy[i][j+proc[1][i]];
            }
            else {
                dpy[i+1][j]=dpy[i][j+proc[1][i]];
            }
        }
    }
    if(!dpy[ysize][y])cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 123136
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

   // cin>>t;
    while(t--)
    {
       ll n,i;
       cin>>n;
       string s;
       cin>>s;
       i=0;
       ll ans=0;
       while(i<n-2)
       {
           if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
           {
               ++ans;
               i+=3;
           }
           else
            ++i;
       }
       cout<<ans;

    }
}


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  
  n %= 100;
  n %= 10;
  
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
  {
    cout << "hon";
  }
  else if(n == 0 || n == 1 || n == 6 || n == 8)
  {
    cout << "pon";
  }
  else
  {
    cout << "bon";
  }
  
  return 0;
}

Measured memory_bytes: 3640
from heapq import heappop, heappush
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

if N >= M:
  print("0")
else:
  queue = []
  for i in range(M):
    if i + 1 < M:
      heappush(queue, -abs(X[i+1] - X[i]))

  for i in range(N-1):
    heappop(queue)

  print(-sum(queue))

Measured memory_bytes: 13960
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	ll N, K;
	cin >> N >> K;

	ll mx = (N - 2) * (N - 1) / 2;
	ll dif = mx - K;

	if (dif < 0) {
		cout << -1 << endl;
		return 0;
	}

	cout << (N - 1) + (mx - K) << endl;

	rep(i, N-1) {
		cout << "1 " << i + 2 << endl;
	}

	ll count = 0;
	rep(i, N-1) {
		rep(k, N - 2 - i) {
			if (count == dif)break;
			cout << i + 2 << " " << k + i + 3 << endl;
			count++;
		}
		if (count == dif)break;
	}



	return 0;
}



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

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

int main() {
  int n; cin >> n;
  int c[n-1], s[n-1], f[n-1];
  REP(i, n-1) cin >> c[i] >> s[i] >> f[i];
  REP(i, n) {
    int t = 0;
    FOR(j, i, n-1) {
      if (t < s[j]) t = s[j];
      else if (t%f[j] == 0);
      else t += (f[j] - t%f[j]);
      t += c[j];
    }
    cout << t << endl;
  }
  return 0;
}

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

int main() {
    int n; cin >> n;
    
    vector<vector<int>> a(n, vector<int> (3, 0));

    for (int i = 0; i < n; i += 1)
        for (int j = 0; j < 3; j += 1)
            cin >> a[i][j];
    
    vector<vector<int>> dp(n + 1, vector<int> (3, 0));

    for (int i = 1; i <= n; i += 1) 
        for (int j = 0; j < 3; j += 1)
            for (int k = 0; k < 3; k += 1)
                if (k != j)
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i - 1][j]);

    cout << *max_element(dp[n].begin(), dp[n].end()) << "\n";
}

Measured memory_bytes: 11136
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
int H[100010];

signed main()
{
	cin >> N;
	REP(i, N) cin >> H[i];

	int ans = 0;
	int cnt = 1;
	int cur = H[0];
	for (int i = 1; i < N; i++)
	{
		if (cur >= H[i])
		{
			cnt++;
		}
		else
		{
			cnt = 1;
		}
		cur = H[i];
		ans = MAX(cnt, ans);
	}
	ans = MAX(cnt, ans);

	cout << (ans - 1) << endl;
}




Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
#define mxsize (int)1e4
int h,w;
char a[mxsize][mxsize];
int dis[mxsize][mxsize];
int dx[4]={-1,1,0,0};   //up down left right
int dy[4]={0,0,-1,1};
void fun(){
    cin>>h>>w;
    int srx,sry,desx,desy;
    cin>>srx>>sry>>desx>>desy;
    fi(1,h+1){
        fj(1,w+1){
            cin>>a[i][j];
            dis[i][j]=INT_MAX;
        }
    }
    
    deque<pair<int,int>> q;
    q.push_back({srx,sry});
    dis[srx][sry]=0;
    while(!q.empty()){
        int curx=q.front().F;
        int cury=q.front().S;
        q.pop_front();
        for(int i=0;i<4;i++){
            int x=curx+dx[i];
            int y=cury+dy[i];
            if(x<1||y<1||x>h||y>w||a[x][y]=='#')
                continue;
            if(dis[x][y]>dis[curx][cury]){
                dis[x][y]=dis[curx][cury];
                q.push_front({x,y});
            }
        }
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                int x=curx+i;
                int y=cury+j;
                if(x<1||y<1||x>h||y>w||a[x][y]=='#')
                    continue;
                if(dis[x][y]>dis[curx][cury]+1){
                    dis[x][y]=dis[curx][cury]+1;
                    q.push_back({x,y});
                }
            }
        }
    }
    if(dis[desx][desy]==INT_MAX)
        cout<<"-1\n";
    else    
        cout<<dis[desx][desy];
    
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 16476
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

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

        final int N = sc.nextInt();

        int cnt = 0;
        for (int i = 1; i <= N; i++) {
            if (String.valueOf(i).length() % 2 != 0) {
                cnt++;
            }
        }
        System.out.println(cnt);

//        IntStream.rangeClosed(1, N).filter(i -> String.valueOf(i).length() % 2 != 0).sum();
    }
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}

int n, m;

int main(void){
    cin >> n >> m;
    cout << binomial<int>(n, 2) + binomial<int>(m, 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,i;
  double x[10],ans=0;
  double bit_rate=380000.0;
  char u[10];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%lf %s",&x[i],&u[i]);
    if(u[i]=='J'){
      ans+=x[i];
    }else{
      ans+=x[i]*bit_rate;
    }
  }
  printf("%lf\n",ans);
}

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

main()
{ll n,dp[150000][5],a[150000][5],ma=-1;
  cin>>n;
  for(int i=1;i<=n;i++)
    for(int j=0;j<3;j++)
      cin>>a[i][j];
  
 dp[0][1]=0;dp[0][0]=0;dp[0][2]=0;
 
  for(int i=1;i<=n;i++)
    for(int j=0;j<3;j++)
    {
      int v1 = (j+1)%3;
      int v2 = (j+2)%3;
      dp[i][j] = max(dp[i-1][v1]+a[i][j],dp[i-1][v2]+a[i][j]);
    }
  for(int j=0;j<3;j++)
    ma = max(ma,dp[n][j]);
  
  cout<<ma;
}

Measured memory_bytes: 11776