akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll solve(ll n) {
    ll dp[3][2] = {};
    dp[0][0] = 1;
    for (int i = 59; i >= 0; i--) {
        ll ndp[3][2] = {};
        if (n & (1LL << i)) {
            (ndp[0][1] += dp[0][0]) %= MOD;
            (ndp[1][0] += dp[0][0]) %= MOD;

            (ndp[0][1] += dp[0][1]) %= MOD;
            (ndp[1][0] += dp[0][1]) %= MOD;

            (ndp[2][0] += dp[1][0]) %= MOD;
            (ndp[1][0] += dp[1][0]) %= MOD;
            (ndp[2][1] += dp[1][0]) %= MOD;

            (ndp[2][0] += dp[1][1]) %= MOD;
            (ndp[1][0] += dp[1][1]) %= MOD;
            (ndp[2][1] += dp[1][1]) %= MOD;

            (ndp[2][0] += 2 * dp[2][0]) %= MOD;
            (ndp[2][1] += dp[2][0]) %= MOD;

            (ndp[2][0] += 2 * dp[2][1]) %= MOD;
            (ndp[2][1] += dp[2][1]) %= MOD;
        } else {
            (ndp[0][0] += dp[0][0]) %= MOD;

            (ndp[0][0] += dp[0][1]) %= MOD;

            (ndp[2][0] += dp[1][0]) %= MOD;
            (ndp[0][0] += dp[1][0]) %= MOD;
            (ndp[1][1] += dp[1][0]) %= MOD;

            (ndp[2][0] += dp[1][1]) %= MOD;
            (ndp[0][0] += dp[1][1]) %= MOD;
            (ndp[1][1] += dp[1][1]) %= MOD;

            (ndp[2][0] += 2 * dp[2][0]) %= MOD;
            (ndp[2][1] += dp[2][0]) %= MOD;

            (ndp[2][0] += 2 * dp[2][1]) %= MOD;
            (ndp[2][1] += dp[2][1]) %= MOD;
        }

        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 2; k++) {
                dp[j][k] = ndp[j][k];
            }
        }
    }

    ll res = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 2; j++) {
            (res += dp[i][j]) %= MOD;
        }
    }
    return res;
}

using P = pair<ll, ll>;

ll solveTLE(ll n) {
    set<P> s;
    for (ll a = 0; a <= n; a++) {
        for (ll b = a; b <= n; b++) {
            ll u = (a ^ b);
            ll v = a + b;
            if (u < 0 || u > n || v < 0 || v > n) continue;
            s.emplace(u, v);
        }
    }
    return s.size();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout << solve(n) << endl;

    /* 
    for (ll n = 1; n <= 1000; n++) {
        ll ans = solve(n);
        ll ans_tle = solveTLE(n);
        if (ans != ans_tle) {
            cerr << n << ": " << ans << ", " << ans_tle << endl;
            break;
        } else {
            //cerr << n << ": " << ans << endl;
        }
    }*/
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    Pair[] dishes = new Pair[N];
    for (int i = 0; i < N; i++) dishes[i] = new Pair(scanner.nextInt(), scanner.nextInt());

    Arrays.sort(dishes, (p1, p2) -> p2.a + p2.b - p1.a - p1.b);

    long score = 0;
    for (int i = 0; i < N; i++) {
      if (i % 2 == 0) score += dishes[i].a;
      else score -= dishes[i].b;
    }
    System.out.println(score);
  }

  private static class Pair {
    public final int a;
    public final int b;

    private Pair(int a, int b) {
      this.a = a;
      this.b = b;
    }
  }
}


Measured memory_bytes: 94276
#ABC077C

n=int(raw_input())
a=sorted(map(int,raw_input().split()))
b=sorted(map(int,raw_input().split()))
c=sorted(map(int,raw_input().split()))
x=0
z=0
res=0
for y in b:
 while x<n and a[x]<y:
  x+=1
 while z<n and c[z]<=y:
  z+=1
 res+=x*(n-z)
print res


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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

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

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


void solve()
{
    int n;
    cin >> n;
    cin.ignore();

    rep(i, n) {
        string str;
        unordered_set<string> s;

        getline(cin, str);
        s.insert(str);

        for(int i=1; i < str.length(); i++) {
            string prev = str.substr(0, i), latt = str.substr(i, str.length()- i);
            string rprev = string(prev.rbegin(), prev.rend()), rlatt = string(latt.rbegin(), latt.rend());
            s.insert({
                    prev + rlatt,
                    rlatt + prev,
                    rprev + latt,
                    latt + rprev,
                    rprev + rlatt,
                    rlatt + rprev,
                    latt + prev,
            });
        }

        cout << s.size() << endl;
    }
}

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

Measured memory_bytes: 3280
#include<iostream>

using namespace std;

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    if(k-a>=0)
    {
        cnt += a;
        k -= a;
    }
    else
    {
        cnt = k;
        cout << cnt << endl;
        return 0;
    }
    if(k-b>=0)
    {
        k -= b;
    }
    else
    {
        cout << cnt << endl;
        return 0;
    }
    if(k-c>=0)
    {
        cnt -= c;
    }
    else
    {
        cnt -= k;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3596
using namespace std;
#include <iostream>/*{{{*/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

#include <bits/stdc++.h>

#define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#define DEBUG_ // 提出時はコメントアウト
#ifdef DEBUG_
#define DEB
#else
// DEB と打つとデバッグ時以外はコメントアウトになる
#define DEB /##/
#endif

// 変数ダンプ用マクロ。デバッグ時以外は消滅する
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DEB DUMPOUT<<"  "; \
DUMPOUT<<#__VA_ARGS__; \
DUMPOUT<<":=> "; \
dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/
#define debug(x)                 cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define debug2(x, y)             cerr << __LINE__ << #x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define debug3(x, y, z)          cerr << __LINE__ << #x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug4(a, b, c, d)       cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define debug5(a, b, c, d, e)    cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define debug6(a, b, c, d, e, f) cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define db_2d(d,n,m) rep(i,n){rep(j,m){ cerr << (d)[i][j] << (((j)==(m-1))?"\n":" "); }}
#define db_1d(d,n) rep(i,n){cout << d[i] << (((i)==(n-1))?"\n":" ") << __LINE__}
#define INF 999999999
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

int main() {
  int a,b;cin>>a>>b;
  cout << (a+b)%24 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define TARUNNO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
   #define INF 99999
   #define MAX 100000
   #define pb push_back
   #define pf push_front
   #define pob pop_back
   #define pof pop_front
   #define ins insert
   #define mp make_pair
   #define F first
   #define S second
   #define Endl endl
   #define PII pair<ll,ll>
   #define pii pair<int, int>
   #define PIPII pair<ll , pair<ll, ll> >
#define testing() {cout<<"OK"<<endl;}
#define array(a,n) for(int i=0;i<int(n);i++){cout<<a[i];}
#define vector(v) for(int i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl;
using namespace std;
template<typename T>
string to_string(T str){stringstream stream;stream << str;return stream.str();}


int main(){
    TARUNNO;
    ll a, b, k; cin>> a>> b>>k;
    if(a >= k){
        cout << a - k <<" "<<b;
    }
    else if( a < k){
        cout<<0<<" ";
        k -= a;
        if(b > k){
            cout<<b-k;
        }
        else{
            cout<<0;
        }
    }
    return 0;
}



                             //   C O M F O R T A B L Y   N U M B   //


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

int main(){
  long n,i;
  long a[200000];
  long now,r;
 
  scanf("%ld", &n);
 
  for (i=0;i<n;i++)
  {
    scanf("%ld", &a[i]);
  }
  
  now = 1;
  r = 0;
  for (i=0;i<n;i++)
  {
    if(a[i] == now)
    {
      now++;
    }
    else
    {
      r++;
    }
  }

  if(r==n) r=-1;
  printf("%ld\n",r);
  
  return 0;
}

Measured memory_bytes: 1664
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let cols = lines.shift().split(/\s/).map((v) => v - 0);
    let N = cols[0], T = cols[1];
    let CT = [];
    for (let n = 0; n < N; n++) {
        let cols = lines.shift().split(/\s/).map((v) => v - 0);
        CT.push([n + 1, cols[0], cols[1]]);
    }
    CT.sort((a, b) => a[1] - b[1]);
    for (let n = 0; n < N; n++) {
        if (CT[n][2] <= T) {
            console.log(CT[n][1]);
            return;
        }
    }
    console.log('TLE');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);


    ll n; cin>>n;
    vector<string> s(n);
    rep(i,n) cin>>s[i];

    map<string, ll> m;
    for(auto e:s) m[e]++;

    vector<string> arr = {"AC", "WA", "TLE", "RE"};

    for(auto t:arr){
        cout<<t<<" x "<<m[t]<<endl;
    }

    return 0;

}

Measured memory_bytes: 6364
h, w = map(int, input().split())
if (h * w) % 2 == 0:
    if h != 1 and w != 1:
        
        print(int((h * w) / 2))
    else:
        print(1)
elif h == 1 or w == 1:
    print(1)
else:
    print((h * w // 2) + 1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int x;
    cin >> x;
    int a = x;
    while(1){
        bool prime = true;
        for(int i = 2;i < sqrt(a);i++){
            if(a%i == 0){
                prime = false; 
                //cout << "f" << endl;
            }
        }
        if(prime){
            cout << a << endl;
            break;
        }
        a += 1;
        //cout << "a" << a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void) {
	int x, y, z, cnt = 1;
	cin >> x >> y >> z;
	x -= y + 2 * z;
	
	while (1) {
		x -= y + z;
		if (x < 0) break;
		cnt++;
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll L, n;
    cin >> L >> n;
    ll a[n];
    rep(i,n) cin >> a[i];

    ll suml[n] = {}, sumr[n] = {};
    rep(i,n){
        if(i > 0) suml[i] = suml[i-1];
        suml[i] += a[i] * 2;
    }
    drep(i,n){
        if(i < n-1) sumr[i] = sumr[i+1];
        sumr[i] += (L-a[i]) * 2;
    }

    ll ans = max(a[n-1], L-a[0]);

    // [0,i]まで右側、(i,n-1]まで左側。
    rep(i,n-1){
        int j = n - 1 - i;
        if(i+1 == j){
            ll tmp = suml[i] + sumr[i+1];
            tmp -= min(a[i], L-a[i+1]);
            ans = max(ans, tmp);
        }else if(i+1 > j){
            int diff = i + 1 - j;
            ll tmp = suml[i] - suml[diff-1] + sumr[i+1];
            tmp -= min(a[i], L-a[i+1]);
            ans = max(ans, tmp);

            tmp = suml[i] + sumr[i+1];
            if(diff > 1){
                tmp -= suml[diff-2];
            }
            tmp -= a[i];
            ans = max(ans, tmp);
        }else{
            int diff = j - (i + 1);
            ll tmp = suml[i] + sumr[i+1] - sumr[n-diff];
            tmp -= min(a[i], L-a[i+1]);
            ans = max(ans, tmp);

            tmp = suml[i] + sumr[i+1];
            if(diff > 1){
                tmp -= sumr[n+1-diff];
            }
            tmp -= L-a[i+1];
            ans = max(ans, tmp);
        }
        // cout << i << ' ' << ans << endl;
    }



    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 8336
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    string t = "qwertasdfgzxcvb";
    while(cin >> s, s!="#"){
        int ans = 0;
        int c = -1;
        for(int i = 0; i < s.size(); i++){
            int p = 0;
            for(int j = 0; j < t.size(); j++)if(s[i]==t[j])p = 1;
            if(c != p)ans++;
            c = p;
        }
        cout << ans-1 << endl;
    }
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int k, x;
	cin >> k >> x;

	if (500 * k >= x) {
		col("Yes");
	}
	else {
		col("No");
	}

	return 0;
}


Measured memory_bytes: 3552
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

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

int main()
{
	ll A, B, C, D = 0;
	string ret = "";
	string inp = "";

	cin >> inp;
	A = char(inp[0]) - '0';
	B = char(inp[1]) - '0';
	C = char(inp[2]) - '0';
	D = char(inp[3]) - '0';

	Rep(i, 2){
		Rep(j, 2) {
			Rep(k, 2) {
				ll tmp = A;

				if ( i == 0 ) {
					tmp += B;
				}
				else {
					tmp -= B;
				}
				if (j == 0) {
					tmp += C;
				}
				else {
					tmp -= C;
				}
				if (k == 0) {
					tmp += D;
				}
				else {
					tmp -= D;
				}

				if ( tmp == 7 ) {
					string ret = "";
					ret += (char)A + '0';
					ret += (i == 0 ? '+' : '-');
					ret += (char)B + '0';
					ret += (j == 0 ? '+' : '-');
					ret += (char)C + '0';
					ret += (k == 0 ? '+' : '-');
					ret += (char)D + '0';
					printf("%s=7\n", ret.c_str() );
					goto err;
				}
			}
		}
	}

err:
	return 0;
}





Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCorder
{
    public static class Program
    {
        static public void Main(string[] args)
        {
            int[] input=  Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int box = 0;

            box = input[0];
            input[0] = input[1];
            input[1] = box;

            box = input[0];
            input[0] = input[2];
            input[2] = box;


            Console.WriteLine(input[0].ToString() +" "+ input[1].ToString() +" " + input[2].ToString());
            //int max = input1[0];
            //for (int num = 1; num < input1.Length; num++)
            //{
            //    if (input1[num]- max > max)
            //    {

            //    }
            //}


            //ans = (input / 500) * 1000;

            //if (input % 500 == 0)
            //{
            //    //
            //}
            //else
            //{
            //    ans = ans + (((input % 500) / 5 )* 5);

            //}


        }
    }
}




Measured memory_bytes: 11348
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
    	int n, m, v, p;
    	cin >> n >> m >> v >> p;
    	vector<int> a(n);
    	for(int i = 0; i < n; i++)
    		cin >> a[i];
    	sort(a.begin(), a.end());

    	auto poss = [&] (int x) {
    		int my = a[x] + m, cd = 0;
			for(int i = 0; i < n; i++) {
				if(x == i)
					continue;
				if(i > n - min(v, p))
					cd += m;
				else if(i > n - p)
					continue;
				else if(a[i] > my)
					return false;
				else
					cd += min(m, my - a[i]);
			}
			return (cd >= m * (v - 1));
    	};

    	int lo = 0, hi = n - 1, lt = -1;
    	while(lo <= hi) {
    		int mid = (lo + hi) / 2;
    		if(poss(mid)) {
    			lt = mid;
    			hi = mid - 1;
    		}
    		else 
    			lo = mid + 1;
    	}

    	cout << n - lt << '\n';

    	
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 1024
#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; }
const ll INF = 1000000000000;

typedef pair<ll,ll> P;



int main() {
    ll H, W;
    cin >> H >> W;

    ll ch, cw, dh, dw;
    cin >> ch >> cw;
    cin >> dh >> dw;
    ch--;
    cw--;
    dh--;
    dw--;

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

    vector<string>shw(H);
    for (ll i=0; i<H; i++)cin >> shw[i];

    //全探索して
    vector<vector<ll>>d(H, vector<ll>(W)); // 距離の配列
    vector<vector<bool>>checked (H, vector<bool>(W));
    vector<vector<bool>>queued(H, vector<bool>(W));
    for (ll i=0; i<H; i++){
        for (ll j=0; j<W; j++){
            d[i][j] = INF;
        }
    }
    deque<P>que;
    d[ch][cw] = 0;

    que.push_front(P(ch,cw));
    queued[ch][cw] = true;
    // O(HW*25) = O(HW)
    while (que.size()){
        P p = que.front(); que.pop_front();
        // あるいて行ける場合
        for (ll i=0; i<4; i++){
            ll ny = p.first + dy[i];
            ll nx = p.second + dx[i];

            if (0 <= ny and ny < H and 0 <= nx and nx < W and shw[ny][nx] == '.'){
                if (not queued[ny][nx] and d[ny][nx] > d[p.first][p.second]) {
                    que.push_front(P(ny,nx));
                    queued[ny][nx] = true;
                  	d[ny][nx] = d[p.first][p.second];
                }   
            }
        }   
        //魔法を使う場合
        for (ll i=-2; i<3; i++){
            for (ll j=-2; j<3; j++){
                ll ny = p.first + i;
                ll nx = p.second + j;
                if (i==0 and j==0)continue;

                if (0 <= nx and nx < W and 0 <= ny and ny < H and shw[ny][nx] == '.'){
                    // 現状見つかってるルートよりも，このワープのほうが効率的な場合
                    if (d[ny][nx] > d[p.first][p.second] + 1){
                        que.push_back(P(ny,nx));
                        d[ny][nx] = d[p.first][p.second]+1;
                    }
                    
                }
            }
        }
    }
    ll ans = 0;
    if (d[dh][dw] == INF)ans = -1;
    else ans = d[dh][dw];

    cout << ans << endl;

}


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

int main() {
  int x,n,c = 0,d = 0;
  cin >> x >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  for(int j = 0; j < n; j++){ 
    if(c != j || d != j){
      break;
    }
    for(int i = 0; i < n; i++){
      if(x - j ==  p[i]){
        c += 1;
        break;
      }
    }
    for(int i = 0; i < n; i++){
      if(x + j ==  p[i]){
        d += 1;
        break;
      }
    }
  }
  if(c <= d){
    cout << x - c << endl;
  }else{
    cout << x + d << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

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

		//??????10??????
		int debt = 100000;

		//n??±???
		int n = scanner.nextInt();

		for(int i=0; i<n; i++){
			debt *= 1.05;
			debt = roundOff(debt);
		}
		System.out.println(debt);
	}

	public static int roundOff(int debt){
		String strDebt = String.valueOf(debt);
		int splitDebt = Integer.parseInt(strDebt.substring(strDebt.length()-3));

		if(0<splitDebt){
			//debt = (105000 + 10000) - 5000
			debt = (debt+1000) - splitDebt;
		}
		return debt;
	}

}

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

int gcd(int a,int b,int c){
    int re;
    for(int i=1;i<=min(a,min(b,c));i++){
        if(a%i==0&&b%i==0&&c%i==0) re=i;
    }
    return re;
}
int main(){
    int k; cin>>k;
    int ans=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans+=gcd(a,b,c);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

class Main{
  static int cnt = 0;

  static void insertionSort(int[] a, int n, int g){
    for(int i = g; i < n; i++){
      int w = a[i];
      int j = i;
      while(j - g >= 0 && a[j-g] > w){
        a[j] = a[j-g];
        j -= g;
        cnt++;
      }
      a[j] = w;
    }
  }

  static void shellSort(int[] a, int n){
    int m = 0;
    int h = 1;
    while(h <= n){
      m++;
      h = 3*h + 1;
    }

    System.out.println(m);

    int[] g = new int[m];
    int k = 1;
    for(int i = 0; i < m; i++){
      g[i] = k;
      k = 3*k + 1;
    }
    rtrace(g);
    for(int i = g.length-1; i >= 0; i--)
      insertionSort(a, n, g[i]);
  }

  static void rtrace(int[] a){
    int i;
    for(i = a.length-1; i > 0; i--)
      System.out.print(a[i] + " ");
    System.out.println(a[i]);
  }

  static void trace2(int[] a){
    for(int i = 0; i < a.length; i++)
      System.out.println(a[i]);
  }


  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int a[] = new int[n];
    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    shellSort(a, n);
    System.out.println(cnt);
    trace2(a);
  }
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  string s, t;
  cin >> s >> t;

  string now = t;
  REP(i, 30) {
    // sの中にnowが含まれるか判定
    int cnt = 0;
    REP(j, s.size()) if(cnt < now.size() && s[j] == now[cnt]) cnt++;
    if(cnt < now.size()) {
      cout << i << endl;
      return 0;
    }
    int n_sz = now.size() * t.size() + now.size() + t.size();
    if(n_sz > s.size()) {
      cout << i+1 << endl;
      return 0;
    }
    string n = now;
    REP(j, t.size()) n += t[j] + now;
    now = n;
  }

  return 0;
}



Measured memory_bytes: 3396
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;



void main() {
    int N;
    scan(N);
    auto x = new double[](N);
    auto y = new double[](N);
    foreach (i ; 0 .. N) {
        scan(x[i], y[i]);
    }

    auto p = iota(N).array;

    double ans = 0;

    do {
        double t = 0;
        foreach (i ; 0 .. N - 1) {
            auto pos = p[i];
            auto nex = p[i + 1];
            t += hypot(x[nex] - x[pos], y[nex] - y[pos]);
        }
        ans += t;
    } while (nextPermutation(p));

    foreach (i ; 1 .. N + 1) {
        ans /= i;
    }

    writefln("%.12f", ans);
}






void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 2401
 
int makeTime(int a, int b){
    int ah, bh, am, bm;
    am = a % 100; a /= 100;
    ah = a;
 
    bm = b % 100; b /= 100;
    bh = b;
  
    int diff_h = bh - ah;
    int diff_m = bm - am;
    if(diff_m < 0){
	diff_m += 60;
	diff_h--;
    }
    return diff_h*60 + diff_m;
}
 
int main(){
    int N, P, Q, K, p, q;
 
    while(cin >> N >> P >> Q, (N | P | Q)){
	bool watch[MAX];
	memset(watch, false, sizeof(watch));
	for(int i = 0 ; i < N ; i++){
	    cin >> K;
	    vector<int> vec; 
	    vec.push_back(P);
	    for(int j = 0 ; j < K ; j++){
		cin >> p >> q;
		vec.push_back(p);
		vec.push_back(q);
	    }
	    vec.push_back(Q);
	    for(int j = 0 ; j < (int)vec.size() ; j+=2){
		for(int k = vec[j] ; k <= vec[j+1] ; k++){
		    watch[k] = true;
		}
	    }
	}
	int max = 0, cnt = P-1, prev = P, pos;
	for(int i = P ; i <= Q ; i++){
	    if(i % 100 >= 60){ 
		cnt++; 
		continue;
	    }
	    if(watch[i]){
		cnt++;
		pos = i;
	    }else{
		while(!watch[i] || i % 100 >= 60) i++;
		max = std::max(max, makeTime(prev,cnt));
		prev = i;       
		cnt = i;
	    }
	}
 
	max = std::max(max, makeTime(prev, cnt));
	cout << max << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3064
while True:
    H,W= map(int, input().split())
    if H==0 and W==0:
        break
    s = "#"
    a = H
    b = "."
    for i in range(H):
        if 1<a<H:
            y = s+b*(W-2)+s
            print(y)
            a-=1
        elif a==H or a==1:
            x = s*W
            print(x)
            a-=1                    
    print("")

Measured memory_bytes: 7548
#include <iostream>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  int N,K;
  cin >> N >> K;

  int res = N%K;
  long long quo = N/K;

  if(K%2!=0)
    cout << quo*quo*quo << "\n";
  else{
    if(res < K/2)
      cout << 2*quo*quo*quo << "\n";
    else
      cout << quo*quo*quo + (quo+1)*(quo+1)*(quo+1) << "\n";
    }
  }


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

public class B{
    public static void Main(){
        int[] nx =  Console.ReadLine().Split(' ').Select(y=>int.Parse(y)).ToArray();
        int n = nx[0]; int x = nx[1];
        int[] l =  Console.ReadLine().Split(' ').Select(y=>int.Parse(y)).ToArray();

        int ans = 1;
        int d = 0;
        //2分探索すべきだがn小さいので
        for (int i = 0;i<n;i++){
            d += l[i];
            if (d<=x){
            ans += 1;
            }
            else{
                break;
            }
        }
        Console.WriteLine(ans);
        
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n);
#define DEBUG printf("%s\n","debug")
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main() {
	int n; SCD(n);
	queue<int>Q;
	deque<int> deq;
	
	REP(i,n){
		int a; SCD(a);
		Q.push(a);
	}
	
	int turn;
	if (n % 2 == 1) turn = 1;
	else turn = -1;
	
	while(!Q.empty()){
		int x;
		x = Q.front(); Q.pop();
		if (turn == 1) deq.push_front(x);
		else deq.push_back(x);
		turn *= -1;
	}
	
	printf("%d",deq.front());
	deq.pop_front();
	
	while(!deq.empty()){
		printf(" %d",deq.front());
		deq.pop_front();
	}
	
	printf("\n");
	
	return 0;
} 
 

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(4*i+7*j==a){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        int K, X;
        Scanner scan = new Scanner(System.in);
        K = scan.nextInt();
        X = scan.nextInt();
        if(K*500>=X){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

template<typename T>
T kiriage(T a, T b)
{
	return (a + b - 1) / b;
}

void Main() {
	int N, X, T; cin >> N >> X >> T;
	cout << kiriage(N, X) * T << endl;
}

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


Measured memory_bytes: 3648
import math

A, B, H, M = map(int, input().split())

h_theta = 2 * math.pi * (H+M/60)/12
m_theta = 2 * math.pi * M/60

dx = A * math.cos(h_theta) - B * math.cos(m_theta)
dy = A * math.sin(h_theta) - B * math.sin(m_theta)

print(math.sqrt(dx**2+dy**2))

Measured memory_bytes: 9556
import sys
import math
from itertools import permutations
input = sys.stdin.readline

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

cur = []
for i in permutations(range(1, n + 1)):
    copy = []
    for u in i:
        copy.append(u)
    cur.append(str(copy))

a = cur.index(str(p))
b = cur.index(str(q))
print(abs(b - a))

Measured memory_bytes: 6708
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,s=0;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int j=k;j>0;j--)
	{
		s+=a[n-1];
		n--;
	}
	cout<<s<<endl;
	return 0;
	
}

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s; cin >> s;
    map<char,int> mp;
    for (char c: s) {
        mp[c]++;
    }
    if (mp.size() != 2) {
        cout << "No\n";
    }
    else {
        if (mp.begin()->second != 2 || mp.rbegin()->second != 2) {
            cout << "No\n";
        }
        else {
            cout << "Yes\n";
        }
    }
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	public static void main(String... args) {
		int M = 1_000_000_007;
		String S = IN.next();
		
		long a   = 0;
		long ab  = 0;
		long abc = 0;
		long t   = 1;

		for (int i = 0; i < S.length(); i++) {
			switch (S.charAt(i)) {
				case 'A':
					a = (a + t) % M;
					break;
				case 'B':
					ab = (ab + a) % M;
					break;
				case 'C':
					abc = (abc + ab) % M;
					break;
				default:
					abc = (abc * 3 + ab) % M;
					ab  = (ab * 3 + a) % M;
					a   = (a * 3 + t) % M;
					t   = (t * 3) % M;
			}
		}
		puts(abc);
		flush();
	}
	static final Scanner IN = new Scanner(System.in);
	static final PrintWriter OUT = new PrintWriter(System.out);
	static <T> void puts(T arg) { OUT.println(arg); }
	static void flush() { OUT.flush(); }
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if(s.back() == 's') s += "es";
  else s += "s";
  cout << s << '\n';
}


Measured memory_bytes: 3624
"""Shortest Path"""

import sys
import os
import pprint

#fd = os.open('ALDS1_12_B.txt', os.O_RDONLY)
#os.dup2(fd, sys.stdin.fileno())

level = True
def debug(v):
    if level:
        print(v)

n = int(input())
INF = float('inf')
W = [[INF for j in range(n)] for i in range(n)]

for _ in range(n):
    l = list(map(int, input().split()))
    node_index = l[0]
    num = l[1]
    data = l[2:]
    for i in range(num):
        node = data[i*2]
        weight = data[i*2+1]
        W[node_index][node] = weight

d = [INF] * n
visited = [False] * n
parent = [None] * n

# root
d[0] = 0

while True:
    min_dist = INF
    min_index = None
    for i in range(n):
        if not visited[i] and d[i] < min_dist:
            min_dist = d[i]
            min_index = i

    if min_index is None:
        break

    # accept
    visited[min_index] = True

    for i in range(n):
        if not visited[i] and d[i] > d[min_index] + W[min_index][i]:
            d[i] = d[min_index] + W[min_index][i]
            parent[i] = min_index
for i in range(len(d)):
    s = '{} {}'.format(i, d[i])
    print(s)

Measured memory_bytes: 8296
#include <stdio.h>
#include <algorithm>
#include <limits.h>
#define SIZE 100005

   long long int dp[100005], h[100005];
   int main(void) {
        int n;
        scanf("%d",&n);
        for(int i=1; i<=n; i++) scanf("%lld",&h[i]);

        dp[0] = INT_MAX;
        for(int i=2; i<=n; i++) dp[i] = std::min(dp[i-1]+std::abs(h[i]-h[i-1]), dp[i-2]+std::abs(h[i]-h[i-2]));

        printf("%lld",dp[n]);
        return 0;
   }







Measured memory_bytes: 1664
#include<stdio.h>
#include<vector>
#include<algorithm>
int main()
{
	int N;
	scanf("%d", &N);

	std::vector<int> input(N, 0);
	for (int i = 0; i < N; i++) {
		scanf("%d", &input[i]);
	}
	long long output = 0;
	int minuscount = 0;
	int minabs = 100000000;
	int temp = 0;
	for (int i = 0; i < N; i++) {
		if (input[i] < 0) {
			minuscount++;
		}
		temp = std::abs(input[i]);
		minabs = std::min(minabs, temp);
		output += temp;
	}

	if (minuscount % 2 == 1) {
		output = output - (minabs * 2);
	}

	printf("%lld", output);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod = 1000000007;
#define REP(i,f,n) for(int i=f; i<(n); i++)

ll afd(ll e, ll n){
  ll ans = 1;
  REP(i,0,n){
    ans *= e;
    ans%=mod;
  }
  return ans;
}

int main()
{
  ll ans, n;
  //                  966971091
  cin >> n;
  ans = afd(10,n) - (2*afd(9,n))%mod + afd(8,n);
  ans %= mod;
  ans = (ans+mod)%mod;
  cout << ans << endl;

  //--debug : end_stop 5er
  //string end_stoper; cin >> end_stoper;

  return 0;
}

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

int n, k;

int main() {
    cin >> n >> k;
    int bridge = (n - 1) * (n - 2) / 2 - k;
    if (bridge < 0) {
        cout << -1 << endl;
    } else {
        cout << n - 1 + bridge << endl;
        //ウニ部分
        for (int i = 1; i < n; i++) {
            cout << 1 << " " << i + 1 << endl;
        }
        //橋部分
        int count = 0;
        for (int i = 1; i < n && count < bridge; i++) {
            for (int j = i + 1; j < n && count < bridge; j++) {
                cout << i + 1 << " " << j + 1 << endl;
                count++;
            }
        }
    }
}

Measured memory_bytes: 256
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<std::string> s){
    vector<string> v = {
            "AC", "WA", "TLE", "RE"
    };
    vector<int> cnt(4, 0);
    for(int i = 0; i < s.size(); ++i){
        for(int j = 0; j < 4; ++j)
            if(s[i] == v[j])
                ++cnt[j];
    }
    for(int i = 0; i < 4; ++i){
        cout << v[i] << " x " << cnt[i] << endl;
    }
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 6444
#include<stdio.h>
int main(void){
  char s[5];
  scanf("%s",s);
  if(s[0]=='M')
    printf("6\n");
  else if(s[0]=='T'){
    if(s[1]=='U')
      printf("5\n");
    else
      printf("3\n");}
  else if(s[0]=='W')
    printf("4\n");
  else if(s[0]=='F')
    printf("2\n");
  else{
    if(s[1]=='A')
      printf("1\n");
    else if(s[1]=='U')
      printf("7\n");
  }

  return 0;}


Measured memory_bytes: 128
N = int(input())
S = ['0'] * N
for i in range(N):
    S[i] = input()
import collections
c = collections.Counter(S)
li = list(c.values())
ca = c.keys()
li.sort()
max = li[-1]
from collections import deque
lia = deque()
for i in ca:
    if c[i] == max:
        lia.append(i)
liaa = list(lia)
liaa.sort()
n = len(lia)
for i in range(n):
    print(liaa[i])

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

int main() {
    int a,b,c,num;
    cin >> num; //自然数xを代入
    a = num % 10;//１の位=xmod10
    b = (num - a)/10 % 10 ;//10の位＝x-a/10mod10
    c = num / 100;//100の位＝x/100(端数切捨)

    cout << (a == 1) + (b == 1) + (c == 1) << endl;
}


Measured memory_bytes: 256
def convert():
    str = input().rstrip()
    n = int(input().rstrip())
    
    for _ in range(n):
        columns = input().rstrip().split()
        order = columns[0]
        a = int(columns[1])
        b = int(columns[2])
        
        if order == 'print':
            print(str[a:b+1])
            
        if order == 'reverse':
            str = str[:a] + str[a:b+1][::-1] + str[b+1:]
        
        if order == 'replace':        
            p = columns[3]
            str = str[:a] + p + str[b+1:] 
if __name__ == '__main__':
    convert()


Measured memory_bytes: 5616
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

 const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
#define rep(i, n) for (int i = 0; i < (n); i++)
// 2数の最大公約数,O(log max(a,b))
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
// 2数の最小公倍数,O(log max(a,b))
long long lcm(long long i, long long j) {
  return i * (j / gcd(i, j));
}
int main(){
  int n;
  cin>>n;
  vector<lint> a(n);
  rep(i,n)cin>>a[i];
  vector<lint> prime,d(1000010);
  for(int i=2;i<=1000000;i++){
    bool is=true;
    for(int j=0;j<prime.size();j++){
      if(i%prime[j]==0){
        is=false;
        d[i]=j;
        break;
      }
      if(prime[j]*prime[j]>i)break;
    }
    if(is){
      prime.push_back(i);
      d[i]=prime.size()-1;
    }
  }
  vector<bool> inc(prime.size(),false);
  bool ret1=true,ret2=true;
  rep(i,n){
    int e=a[i];
    int before=mod;
    while(e>1){
      if(before!=prime[d[e]]&&inc[d[e]])ret1=false;
      inc[d[e]] = true;
      before = prime[d[e]];
      e/=prime[d[e]];
    }
  }
  int gc=a[0];
  rep(i,n)gc=gcd(gc,a[i]);
  if(gc!=1)ret2=false;
  if (ret1) cout << "pairwise coprime"<<endl;
  else if(ret2)
    cout << "setwise coprime"<<endl;
    else
      cout << "not coprime"<<endl;
}


Measured memory_bytes: 19896
#include <stdio.h>

int main() {
  int i, n, num;
  int S[13], H[13], C[13], D[13];
  char s;
  for(i=0; i < 13; i++) {
    S[i] = H[i] = C[i] = D[i] = 0;
  }
  scanf("%d", &n);
  for(i=0; i < 2*n; i++) {
    scanf("%c %d", &s, &num);
    //printf("%c ", s);
    if(s == 'S') S[num-1]++;
    else if(s == 'H') H[num-1]++;
    else if(s == 'C') C[num-1]++;
    else if(s == 'D') D[num-1]++;
  }
  for(i=0; i < 13; i++) {
    if(!S[i]) printf("S %d\n", i+1);
  }
  for(i=0; i < 13; i++) {
    if(!H[i]) printf("H %d\n", i+1);
  }
  for(i=0; i < 13; i++) {
    if(!C[i]) printf("C %d\n", i+1);
  }
  for(i=0; i < 13; i++) {
    if(!D[i]) printf("D %d\n", i+1);
  }
  return 0;
}


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



int main() {
    ll n , i , ans = 0 ;
    cin >> n;
    vector<ll> a(n) , b(n) ;
    for(i  = 0 ; i< n;  i++) {
      cin >> a[i] >> b[i] ;
    }
    sort(a.begin(),a.end()) ;
    sort(b.begin(),b.end()) ;
    if (n%2) {
        cout << b[n/2] - a[n/2] + 1 ;
    }
    else {
        cout << (b[n/2]+b[n/2-1]) - (a[n/2]+a[n/2-1]) + 1 << endl ;
    }

    return 0 ;
}


Measured memory_bytes: 6408