akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#define int long long int
#define endl '\n'
using namespace std;
typedef long long ll;
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 #define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) FOR(i,0,sz(v)-1) cout << v[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll MOD = 1e10;
const ll N = 2e4 + 1;
const ll m = MOD;
int power(int x,int y, int m) 
{ 
    if (y == 0) 
        return 1;
    int p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
int modInverse(int a, int m) 
{     
        return power(a, m-2, m); 
}
int mod(int x)
{
	if(x>=0) return x;
	else return -x;
}
signed main()
{
  read(n);
  long double p[n+1]={0};
  FOR(i,1,n) cin>>p[i];
  long double prob[n+1][n+1];
  FOR(i,0,n)
  FOR(j,0,n)
  {
   prob[i][j]=0;	
  }
  setprecision(100);
  prob[1][1]=p[1];
  prob[0][0]=1;
  FOR(i,1,n)
  {
   prob[i][0]=prob[i-1][0]*(1.00-p[i]);	
  } 
  FOR(i,1,n)
  {
  	FOR(j,1,i)
  	{ 
  	prob[i][j]=prob[i-1][j]*(1.00-p[i]) + prob[i-1][j-1]*(p[i]);	
	}
  }
   long double answer=0;
  FOR(i,(n+1)/2,n)
  {
  	//cout<<prob[n][i]<<" ";
	  answer+=prob[n][i];
  }
  cout<<fixed<<setprecision(10)<<answer<<endl;
}

Measured memory_bytes: 140928
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

int main(void){
    string a;
    int A,b = 0;
    cin >> a;
    A = stoi(a);
    for(int i = 0;i < a.size();i++){
        b += a[i]-48;
    }
    if(A%b == 0){
        cout << "Yes" << endl;
    }else{
        cout<< "No" << endl;
    }
    return 0;
}


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

int main() {
	int n;
	int r, t;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> r >> t;
		
		int f = 0;
		for (int j = 100; j <= 500; j += 100) {
			if (r % j == 0) {
				if (t % 30 == 0) {
					cout << t / 30 * 5 + (r / 100) << endl;
					f = 1;
				}
				else {
					cout << t / 30 * 5 + r / 100 << ' ';
					cout << (t / 30 + 1) * 5 + r / 100 << endl;
					f = 1;
				}
				break;
			}
		}
		
		if (!f && t % 30 == 0) {
			cout << t / 30 * 5 + r / 100 << ' ';
			cout << t / 30 * 5 + (r / 100 + 1) << endl;
			f = 1;
		}
		
		if (!f) {
			cout << t / 30 * 5 + r / 100 << ' ';
			cout << t / 30 * 5 + r / 100 + 1 << ' ';
			cout << (t / 30 + 1) * 5 + r / 100 << ' ';
			cout << (t / 30 + 1) * 5 + r / 100 + 1 << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) begin (x), end (x)
#define dump(x) cerr << #x " = " << boolalpha << (x) << endl;
using namespace std;
template <typename T>
inline auto input () { T a; return cin >> a ? a : throw runtime_error ("no input"); }

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

  auto n = input <size_t> ();

  vector <int64_t> v (n);
  rep(i, n) v [i] = input <int64_t> ();
  rep(i, n) v [i] -= input <int64_t> ();

  auto ans = int64_t {};
  for (auto && elem : v) ans += max <decay_t <decltype (elem)>> (elem, 0);

  cout << ans << endl;
}


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

#define llint long long int

using namespace std;

int main(){
    int A, B, H, M;

    cin >> A >> B >> H >> M;

    double theta_A = ((H + M / 60.0) / 12.0) * 2 * M_PI;
    double theta_B = (M / 60.0) * 2 * M_PI;
    double theta = abs(theta_B - theta_A);

    if(theta >= M_PI){
        theta = 2 * M_PI - theta;
    }
    double x2 = A * A + B * B - 2 * A * B * cos(theta);

    cout << fixed << setprecision(10) << sqrt(x2) << endl;
}

Measured memory_bytes: 4252
/* In The Name of Anton*/

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;

void pre(){

}

void solve(){
  int n,x,t; cin>>n>>x>>t;

  int temp=n/x;
  if(n%x!=0){
    temp++;
  }

  cout<<(temp*t)<<"\n";
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    for (;;) {
        int m, f, r;
        char g;

        scanf("%d %d %d\n", &m, &f, &r);
        if ((m == -1) && (f == -1) && (r == -1)) {
            break;
        }
        if ((m == -1) || (f == -1))
            g = 'F';
        else if ((m + f) >= 80)
            g = 'A';
        else if (65 <= (m + f) && (m + f) < 80)
            g = 'B';
        else if (50 <= (m + f) && (m + f) < 65)
            g = 'C';
        else if (30 <= (m + f) && (m + f) < 50) {
            if (r >= 50)
                g = 'C';
            else
                g = 'D';
        } else
            g = 'F';
        printf("%c\n", g);
    }

    return 0;
}


Measured memory_bytes: 2012
#include <cstdio>
#include <complex>
#include <cmath>
#include <vector>

using namespace std;

typedef complex<double> xy_t;

double cross_product(xy_t a, xy_t b) {
	return (conj(a) * b).imag();
}

int main() {
	double x, y;
	double s = 0;
	vector<xy_t> vertex;
	while (scanf("%lf,%lf", &x, &y) != EOF) {
		vertex.push_back(xy_t(x, y));
	}
	for (int i = 1; i < vertex.size() - 1; i++) {
		s += cross_product(vertex[i] - vertex[0], vertex[i + 1] - vertex[0]) / 2;
	}
	printf("%.6f", abs(s));
}

Measured memory_bytes: 1092
(let ((x (read))
      (y (read))
      (str (read-line)))
  (multiple-value-bind (a b) (parse-integer str :junk-allowed t)
    (if (= (length str) b)
        (princ "No")
    (multiple-value-bind (c d) (parse-integer str :start (1+ b) :junk-allowed t)
      (if (and (= x b) (= y (- d 1 b)) a c)
          (princ "Yes")
          (princ "No")))
    )))


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

int main(){
  int n,t,a; cin >> n>>t>>a;
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  double min_sub =abs( a - (t - h[0]*0.006) );
  int ans = 1;
  for( int i=0; i<n; i++){
    if( abs( a - (t - h[i]*0.006) ) < min_sub){
      min_sub = abs( a- (t - h[i]*0.006) );
      ans = i+1;
    }
  }
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# abc139/abc139_b
import sys, math

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    A, B = i2nn()
    print(math.ceil((B - 1) / (A - 1)))
    return

main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
#define inf 1000000007

int main(void){
    int n;
    cin >> n;
    long long int t[n];
    for(int i = 0; i < n; i++)
        cin >> t[i];
    long long int ans=1;
    long long int check;
    for(int i = 0; i < n; i++){
        check = __gcd(ans, t[i]);
        ans = check*(ans/check)*(t[i]/check);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;cin>>n;
  ll a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  ll c=0,j=0,ans=0;
  for(int i=0;i<n;i++){
    if(a[i+1]<=a[i]){
      c++;
    }else{
      if(ans<c)ans=c;
      c=0;
     }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
template <typename T> 
using lim = numeric_limits<T>;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

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

    string s; cin >> s;
    cout << (s == "ARC" ? "ABC" : "ARC") << "\n";
	
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

double dist(int i, int j, vector<double> x, vector<double> y)
{
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

int main()
{
    int N;
    cin >> N;
    vector<double> x(N);
    vector<double> y(N);

    rep(i, N) cin >> x[i] >> y[i];

    vector<int> vec(N);
    rep(i, N) vec[i] = i;

    double s = 0.0, cnt = 0;
    do
    {
        cnt++;
        rep(i, N - 1)
        {
            s += dist(vec[i], vec[i + 1], x, y);
        }
    } while (next_permutation(all(vec)));
    cout << fixed << setprecision(10);
    double ans = s / cnt;
    cout << ans << endl;

    return 0;
}

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

int main()
{
  i64 n;
  cin >> n;
  if (65 <= n && n <= 90)
    cout << 1 << endl;
  else if (97 <= n && n <= 122)
    cout << 2 << endl;
  else
    cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 3108
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			int n=in.nextInt();
			long ans = 1;
			for(int i=1; i<=n; i++){
				ans = ans*i;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;
import java.util.*;

class Main{
  public static void main(String args[]){
    	
    Scanner in = new Scanner(System.in);
    Stack<Integer> stack = new Stack<Integer>();

    while(in.hasNextInt()){
      final int input = in.nextInt();
      
      if(input != 0){
        stack.push(input);
      }else{
        System.out.println(stack.pop());
      }
    }

  }
}

Measured memory_bytes: 17208
#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 main() {
	string sin;
	cin >> sin;
	char sout[4];
	sout[3] = '\0';
	rep(i,3) {
		sout[i] = sin[i];
	}
	cout << sout << endl;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
//using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb emplace_back
#define mp std::make_pair
//
#define endl "\n"
//using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
//
constexpr ll MOD=1e9+7;
//constexpr ll MOD=998244353;
//constexpr ll MOD=10000000;
//constexpr ll MOD=1e5;
constexpr ll MAX=1e7;
constexpr ll INF=(1ll<<62);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
const ll N=26;
ll solve(ll D,vii &A,vi &C,vi &S){
    vi last(N,-1);
    ll a=0;
    rep(i,0,D){
        ll memo; memo=S[i];
        last[memo]=i;
        a+=A[i][memo];
        rep(j,0,N) a-=(i-last[j])*C[j];
    }
    return a;
}
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    srand((unsigned)time(NULL));
    ll D; cin>>D;
    vi C(N);
    rep(i,0,N) cin>>C[i];
    vii A(D,vi(N));
    rep(i,0,D){
        rep(j,0,N) cin>>A[i][j];
    }
    vi last(N,-1);
    vi ans(D);
    rep(i,0,D){
        ll max=0,memo=0;
        rep(j,0,N){
            if(max<A[i][j]+(i-last[j])*C[j]){
                max=A[i][j]+(i-last[j])*C[j];
                memo=j;
            }
        }
        last[memo]=i;
        ans[i]=memo;
    }
    ll max=solve(D,A,C,ans);
    rep(_,0,45){
        if(_%3!=1){
            rep(i,0,D){
                rep(j,0,N){
                    vi S=ans;
                    S[i]=j;
                    ll X=solve(D,A,C,S);
                    if(max<X){
                        max=X;
                        ans[i]=j;
                    }
                }
            }
        }
        else{
            per(i,D-1,0){
                rep(j,0,N){
                    vi S=ans;
                    S[i]=j;
                    ll X=solve(D,A,C,S);
                    if(max<X){
                        max=X;
                        ans[i]=j;
                    }
                }
            }
        }
    }
    rep(i,0,D) cout<<ans[i]+1<<endl;
}


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

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  string t;
  cin >> t;
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int n, k;

int search(int x, int sum) {
    if (x == 0) return 1;
    return min(search(x-1, sum)*2, search(x-1, sum)+k);
}

int main(void) {
    cin >> n >> k;
    cout << search(n, 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int h, w;
  cin >> h >> w;
  
  rep(i, 0, h) {
    rep(j, 0, w) {
      string s;
      cin >> s;
      if(s == "snuke")
        cout << (char)(j +0x41) << i+1 << "\n";
    }
  }
}


Measured memory_bytes: 256
N,K = map(int, input().split())
D = [int(d) for d in input().split()]

ans = 0
for i in range(N, 10**6):
    t = list(str(i))
    f = 0
    for s in t:
        if int(s) in D:
            break
        f += 1
    if f == len(t):
        print(i)
        break

Measured memory_bytes: 41052
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll a[3005][3005],dp[4][3005][3005],n,m,k;

ll go(int tk,int i,int j)
{
	if(i==n-1&&j==m-1)
	{
		if(tk<=2)return a[i][j];
		return 0;
	}
	if(dp[tk][i][j]!=-1)return dp[tk][i][j];
	ll &r=dp[tk][i][j];
	r=0;
	if(j<m-1)
	{
		if(tk<=2)r=max(r,a[i][j]+go(tk+1,i,j+1));
		r=max(r,go(tk,i,j+1));
	}
	if(i<n-1)
	{
		r=max(r,go(0,i+1,j));
		if(tk<=2)
		r=max(r,a[i][j]+go(0,i+1,j));
	}
	return r;
}

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m>>k;
while(k--)
{
	int x,y,v;
	cin>>x>>y>>v;
	a[x-1][y-1]=v;
}

rep(i,0,3)rep(j,0,n-1)rep(kk,0,m-1)dp[i][j][kk]=-1;
ol(go(0,0,0));
return 0;
}



Measured memory_bytes: 356268
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <cctype>
#include <cstring>
#define fi first
#define se second
#define N 100005

using namespace std;
typedef long long ll;

template <class T> inline void read(T &x) {
	char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	if (flag) x = -x;
}

inline int input() {
	int x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

const int mod = 1e9 + 7;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; }
inline void inc(int &x, int y) { x += y; x -= x >= mod ? mod : 0; }

inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = (ll) res * x % mod;
		x = (ll) x * x % mod, y >>= 1;
	} return res;
}

template <class T> void chkmax(T &x, T y) { x = x > y ? x : y; }
template <class T> void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }

int q, A, B, C, D;

int main() {
	q = input();
	while (q--) {
		A = input(), B = input(), C = input(), D = input();
		int n = A + B, len = (max(A, B) - 1) / (min(A, B) + 1) + 1;
		int l = 0, r = n + 1, mid, ans = n + 1;
		while (l <= r) {
			mid = (l + r) >> 1;
			int a = A - mid / (len + 1) * len - mid % (len + 1);
			int b = B - mid / (len + 1);
			if (b <= (ll) a * len) l = mid + 1;
			else r = mid - 1, ans = mid;
		}
		int a = A - ans / (len + 1) * len - ans % (len + 1);
		int b = B - ans / (len + 1), P = ans + b - a * len + 1;
		for (int i = C; i <= min(D, ans); ++i) putchar(i % (len + 1) ? 'A' : 'B');
		for (int i = max(C, ans + 1); i <= D; ++i) putchar(abs(P - i) % (len + 1) ? 'B' : 'A');
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        String A = sc.next();
        int la = A.length();
        String B = sc.next();
        int lb = B.length();
        String C = sc.next();
        int lc = C.length();

        if(A.charAt(la-1)==B.charAt(0) && B.charAt(lb-1)==C.charAt(0)){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
}

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

struct node
{
  struct node *parent;
  struct node *left;
  struct node *right;
  int key;
};
typedef struct node * Node;

void insert(int);
void preorder(Node);
void inorder(Node);
void Tprint(Node);

Node root;

int main()
{
  int m, i, k;
  char str[8];

  scanf("%d", &m);
  for(i=0; i<m; i++)
    {
      scanf("%s", str);
      if(strcmp(str, "insert") == 0)
	{
	  scanf("%d", &k);
	  insert(k);
	}
      else if(strcmp(str, "print") == 0)
	{
	  Tprint(root);
	}
    }
  
  
  return 0;
}

void insert(int key)
{
  Node t, x, y;
  t = (Node)malloc(sizeof(struct node));
  t->key=key;
  t->right = NULL;
  t->left = NULL;
  y = NULL;
  x = root;

  while(x != NULL)
    {
      y = x;
      if(key<x->key)
	x = x->left;
      else
	x = x->right;
    }
  t->parent = y;

  if(y==NULL)
    root = t;
  else if(t->key<y->key)
    y->left = t;
  else
    y->right = t;
}

void preorder(Node T)
{
  if(T == NULL) return;

  printf(" %d", T->key);
  preorder(T->left);
  preorder(T->right);
}
void inorder(Node T)
{
  if(T == NULL) return;

  inorder(T->left);
  printf(" %d", T->key);
  inorder(T->right);
}
void Tprint(Node T)
{
  inorder(T);
  printf("\n");
  preorder(T);
  printf("\n");
}

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

#define pb push_back
#define mp make_pair

using namespace std;

vector<int> g[2222];
int d[2222][2222];
int n, k;

void dfs(int u, int s, int p){
	for(int i = 0; i < g[u].size(); ++i){
		int v = g[u][i];
		if (v != p) d[s][v] = d[s][u] + 1, dfs(v, s, u);
	}
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&n,&k);
	for(int i = 1; i < n; ++i){
		int a, b;
		scanf("%d%d",&a,&b);
		g[a].pb(b);
		g[b].pb(a);
	}
	int an = n;
	for(int i = 1; i <= n; ++i) dfs(i, i, 0);
	if (!(k % 2)) for(int i = 1; i <= n; ++i){
		int tmp = 0;
		for(int j = 1; j <= n; ++j) tmp += d[i][j] > k / 2;
		an = min(an, tmp);
	}
	else for(int i = 1; i <= n; ++i) for(int x = 0; x < g[i].size(); ++x){
		int j = g[i][x];
		int tmp = 0;
		for(int t = 1; t <= n; ++t){
			if (max(d[i][t], d[j][t]) > (k + 1) / 2) ++tmp;
		}
		an = min(an, tmp);
	}
	printf("%d",an);
	return 0;
}

Measured memory_bytes: 18944
import java.util.Scanner;
         
        public class Main {
         
        	public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                String price = scan.nextLine();
                scan.close();
         
                int otsuri = Integer.parseInt(price) % 1000;
                if (otsuri == 0) {
                    System.out.println(otsuri);
                } else {
                    System.out.println(1000 - otsuri);
                }
            }
        }

Measured memory_bytes: 35628
n=int(input())
from collections import deque
k=deque([])
z=9
m=0
if n<10:
    print(n)
    exit()
for i in range(1,10):
    k.append(i)
while z!=n:
    m=k.popleft()
    if m%10!=0:
        ans=10*m+(m%10)-1
        k.append(ans)
        z+=1
        if z==n:
            print(ans)
            exit()
    ans=10*m+(m%10)    
    k.append(ans)
    z+=1
    if z==n:
        print(ans)
        exit()
    if m%10!=9:
        ans=10*m+(m%10)+1
        k.append(ans)
        z+=1
        if z==n:
            print(ans)
            exit()


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


    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();
            string[] arrS = new string[num];
            arrS = str.Split(' ');

            int max = -1000000;
            int min = 1000000;
            long total = 0;
            for (int i = 0; i <= num - 1; i++)
            {
                if (max <= int.Parse(arrS[i]))
                {
                    max = int.Parse(arrS[i]);

                }
                if(min >= int.Parse(arrS[i]))
                {
                    min = int.Parse(arrS[i]);

                }

                total += int.Parse(arrS[i]);
            } // end for
            Console.WriteLine(min + " " + max + " " + total);

        }   // end main

    }   // end class



Measured memory_bytes: 17812
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define why         (ll)1000000007
//#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod)
{
    ll result=1;
    while(power)
    {
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod)
{
    return fast_power(base,mod-2,mod);
}

ll solve(){ 
    ll n; cin>>n;
    vl b(n+1,0);
    vl a(n-1); lp(i,0,n-1) cin>>a[i],b[a[i]]++;
    lp(i,1,n+1)
    cout<<b[i]<<dl;
    return 0;
}  

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;cin >> N;
	
	bool ans = false;
	FOR(i, 1, 10) FOR(j, 1, 10) if (i * j == N) ans = true;
	puts(ans ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
s =list(str(input()))
s_replace = [1 if i == "B" else 0 for i in s]

count = 0
ans = 0

for i in range(len(s_replace)):
  if s_replace[i] == 1: #もし黒だったらカウントしてください
    count += 1
    continue
  else: #もし白だったら黒の数を足してください
    ans = ans + count
    continue
    
print(ans)

Measured memory_bytes: 6436
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a, b, x[100009];
int main() {
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) cin >> x[i];
	long long ret = 0;
	for (int i = 1; i < n; i++) {
		ret += min(1LL * a * (x[i] - x[i - 1]), 1LL * b);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] ab = str.split(" ", 0);
		int a = Integer.parseInt(ab[0]);
		int b = Integer.parseInt(ab[1]);

		if(a<b){
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else if(a==b){
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 24144
//
//  main.cpp
//  atCoder
//
//  Created by 佐々木勇星 on 2019/07/23.
//  Copyright © 2019 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <regex>
#include <cmath>


int main(void) {
    
    using namespace std;
    
    int N;
    int x, y, j ,k, p, q;
    
    
    cin >> N;
    
    x = N * 100 / 108;
    
    j = x-1;
    k = x+1;
    
    y = x * 1.08;
    p = j * 1.08;
    q = k * 1.08;
    
    if( y == N || p == N || q == N){
        if(y == N){
            cout << x << endl;
        } else if(p == N){
            cout << j << endl;
        } else if(q == N){
            cout << k << endl;
        }
        
    } else{
        cout << ":(" << endl;
    }
    
    
    
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> keihin(n);
  for(int i = 0; i < n; i++){
    cin >> keihin.at(i);
  }
  set<string> gacha;
  for(int i = 0; i < n; i++){
   gacha.insert(keihin[i]);
  }
  cout << gacha.size() << endl;
}

Measured memory_bytes: 25004
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using Pair = pair<int, int>;
const ll mod = 1e9 + 7;


template<class T>
T gcd(T a, T b)
{
  if(a && b) {
    return gcd(min(a, b), max(a, b) % min(a, b));
  } else {
    return a;
  }
}

template<class T>
T lcm(T a, T b)
{
  return a / gcd(a, b) * b;
}

ll power(ll base, ll exponent, ll module)
{
  if(exponent % 2) {
    return power(base, exponent - 1, module) * base % module;
  } else if(exponent) {
    ll root_ans = power(base, exponent / 2, module);
    return root_ans * root_ans % module;
  } else {
    return 1;
  }
}

struct combination
{
  vector<ll> fact, inv;
  combination(int sz) : fact(sz + 1), inv(sz + 1)
  {
    fact[0] = 1;
    for(int i = 1; i <= sz; i++) {
      fact[i] = fact[i - 1] * i % mod;
    }
    inv[sz] = power(fact[sz], mod - 2, mod);
    for(int i = sz - 1; i >= 0; i--) {
      inv[i] = inv[i + 1] * (i + 1) % mod;
    }
  }
  ll Pair(int n, int r)
  {
    if(r < 0 || n < r) return 0;
    return (fact[n] * inv[n - r] % mod);
  }
  ll C(int p, int q)
  {
    if(q < 0 || p < q) return 0;
    return (fact[p] * inv[q] % mod * inv[p - q] % mod);
  }
};

template<typename T>
void print_vec(vector<T>& v)
{
  for(const auto& e: v) {
    cout << e << " ";
  }
  cout << endl;
}
template<typename T>
void print_2dvec(vector<vector<T>>& m)
{
  for(const auto& v: m) {
    for(const auto& e: v) {
      cout << e << " ";
    }
    cout << endl;
  }
}


int main(int argc, char const* argv[])
{
  ll h;
  cin >> h;

  ll ans = pow(2, (int)log2(h) + 1) - 1;

  cout << ans << endl;

  return 0;
}


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

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

int arr[205];

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int n, i, j, ans = 1e9, curr;
	
	cin >> n;
	
	for (i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	
	for (j = -100; j <= 100; j++)
	{
		curr = 0;
		
		for (i = 1; i <= n; i++)
		{
			curr += (arr[i] - j)*(arr[i] - j);
		}
		
		ans = min(ans, curr);
	}
	
	cout << ans;
		
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, K: int):
    ans = 0
    while N >= K:
        N //= K
        ans += 1

    print(ans+1)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

int main(){
	double x1, y1, x2, y2, x3, y3, x4, y4;
	cin>>x1;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){
		double x12 = x2-x1;
		double y12 = y2-y1;
		double x34 = x4-x3;
		double y34 = y4-y3;
		if(x12<0){
			x12 *= -1;
			y12 *= -1;
		}
		if(x34<0){
			x34 *= -1;
			y34 *= -1;
		}
		if(x12==0&&x34==0){
			cout<<"YES"<<endl;
		} else if(x12==0||x34==0){
			cout<<"NO"<<endl;
		} else {
			if(y12/x12==y34/x34){
				cout<<"YES"<<endl;
			} else {
				cout<<"NO"<<endl;
			}
		}
	}
	return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a, b, k;
  cin >> a >> b >> k;
  
  if(a < k){
    k -= a;
    a = 0;
  }
  else{
    a -= k;
    k = 0;
  }
  
  if(b < k){
    k -= b;
    b = 0;
  }
  else{
    b -= k;
    k = 0;
  }
  
  cout << a << " " << b << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
typedef pair<int,int> pr;
typedef vector<pr > vpr;
const int INF=1<<30;
int C[1000];
vpr edge[1000];
int cut(int num,int from,int fromP){
	if(C[num])
		return fromP;
	int all=fromP;
	int sum=0;
	REP(i,edge[num].size())
		if(edge[num][i].first!=from)
			sum+=cut(edge[num][i].first,num,edge[num][i].second);
	return min(all,sum);
}
int main() {
	int N;
	cin >> N;
	FOR(i,1,N)
		cin >> C[i];
	REP(i,N-1){
		int a,b,c;
		cin >> a >> b >> c;
		edge[a].push_back(pr(b,c));
		edge[b].push_back(pr(a,c));
	}
	cout << cut(0,-1,INF) << endl;
	// your code goes here
	return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int n = N - 1;
  vector<int> C(n), S(n), F(n);
  for(int i = 0; i < n; i++){
    cin >> C[i] >> S[i] >> F[i];
  }
  for(int s = 0; s < n; s++){
    long long int t = S[s] + C[s];
    for(int i = s + 1; i < n ; i++){
      if(t <= S[i]) t = S[i];
      else if((t - S[i]) % F[i] == 0) t = t;
      else t += F[i] - (t - S[i]) % F[i];
      t += C[i];
    }
    cout << t << endl;
  }
  cout << 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long int

int main(void){
  ll a[3];
  std::cin >> a[0] >> a[1] >> a[2];

  std::sort(a, a+3);

  if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0){
    std::cout << 0 << std::endl;
  }else{
    std::cout << a[0]*a[1] << std::endl;
  }
  return 0;
}


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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//#define int int64_t
signed main()
{
	int a,b,c,d,e; cin >> a >> b >> c >> d >> e;

	vector<int> z{a, b, c, d, e};

	int mi{9};
	int keep{};
	int flag{};
	for(int i = 0; i < 5; ++i){
		if(z[i]%10 != 0){
			if(mi%10 >= z[i]%10)
			{
				mi = z[i];
				keep = i;
			}
		}
		else{
			flag++;
		}
	}

	//下一桁が全て0のもの用のコーナーケース対策
	if(flag == 5){
		mi = z[0];
		keep = 0;		
	}

	//割る時の切り上げは(a+b-1)/b
	//割らないときの切り上げはx進数なら,(i+x-1)/x*x
	int sum = mi;
	for(int i = 0; i < 5; ++i/*auto i: z*/){
		/*入力が等しいときに困る
		if(i != mi)*/
		if(i != keep)
		sum += (z[i]+9)/10*10;
	}

	cout << sum << '\n';
}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, d[100], a[100], mxd;
int dp[110][7*6*5*4*3*2 + 1];

int hash(vi ord){
	int res = 0;
	rep(i, mxd){
		res *= mxd - i;
		res += ord[i];
		for(int j = i + 1; j < mxd; j++)
		if(ord[j] > ord[i]) ord[j]--;
	}
	return res;
}
vi tov(int hash){
	vi res;
	rep(i, mxd){
		res.pb(hash % (i + 1));
		hash /= i + 1;
	}
	reverse(all(res));
	for(int i = mxd - 1; i >= 0; i--) for(int j = i + 1; j < mxd; j++)
	if(res[i] <= res[j]) res[j]++;
	
	return res;
}

int main(){
	
	cin >> n;
	rep(i, n) cin >> d[i];
	rep(i, n) cin >> a[i];
	
	mxd = min(n, 7);
	vi ord;
	int f = 1;
	
	rep(i, mxd) ord.pb(i), f *= i + 1;
	
	do{
		int tmp = 0;
		rep(i, mxd) rep(j, mxd)
		if(ord[j] < ord[i] && abs(j - i) <= d[j]) tmp += a[j];
		
		dp[mxd - 1][hash(ord)] = tmp;
		
	}while(next_permutation(all(ord)));
	
	
	for(int i = mxd; i < n; i++) rep(j, f) rep(k, mxd + 1){
		
		vi ord = tov(j);
		int nxt = dp[i - 1][j];
		
		rep(l, mxd){
			if(ord[l] >= k){
				if(mxd - l <= d[i]) nxt += a[i];
			}
			else{
				if(mxd - l <= d[i - mxd + l]) nxt += a[i - mxd + l];
			}
		}
		rep(l, mxd) if(ord[l] >= k) ord[l]++;
		ord.pb(k);
		
		int del = ord[0];
		ord.erase(ord.begin());
		rep(l, mxd) if(ord[l] >= del) ord[l]--;
		
		int nj = hash(ord);
		dp[i][nj] = max(dp[i][nj], nxt);
	}
	
	int ans = 0;
	rep(i, f) ans = max(ans, dp[n - 1][i]);
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<string,int> a;
map<string,int> ::iterator iter;
string s;
int main(){
    int n,m=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>s;
    	a[s]++;
    }
    for(iter=a.begin();iter!=a.end();iter++)
    {
    	if(iter->second>m)m=iter->second;
    }
    for(iter=a.begin();iter!=a.end();iter++)
    {
    	if(iter->second==m)cout<<iter->first<<endl;
    }
    return 0;
}


Measured memory_bytes: 25216
let shuffle s h =
  String.sub s h (String.length s - h) ^ String.sub s 0 h

let () =
  let rec doit () =
    match read_line () with
    | "-" -> ()
    | s -> begin
        let m = read_int () in
        let s = ref s in
        for _ = 1 to m do
          let h = read_int () in
          s := shuffle !s h;
        done;
        Printf.printf "%s\n" !s;
        doit ();
      end
  in
  try doit () with End_of_file -> ()

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

vector<int> solve(int N, const vector<int>& xs)
{
    vector<int> ys(xs);

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

    vector<int> ans(N);

    for (int i = 0; i < N; ++i)
        ans[i] = (xs[i] == ys[N - 1] ? ys[N - 2] : ys[N - 1]);

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    for (auto x : ans)
        cout << x << '\n';

    return 0;
}


Measured memory_bytes: 3184
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int n;
  while(cin >> n) {
    if(n == 0) return 0;
    int a[n];
    FOR(i,0,n) scanf("%d", a+i);
    sort(a, a + n);
    int ans = 1000000000;
    FOR(i,0,n-1) ans = min(ans, a[i+1] - a[i]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    REP(i, n) cin >> l[i];
    vector<int> aa(1 << n), bb(1 << n), cc(1 << n);
    FOR(i, 1, 1 << n){
        int sum = -10;
        int h = 0;
        REP(j, n){
            if(i & (1 << j)){
                sum += 10;
                h += l[j];
            }
        }
        aa[i] = sum + abs(h - a);
        bb[i] = sum + abs(h - b);
        cc[i] = sum + abs(h - c);
    }

    int ans = INF;
    FOR(i, 1, 1 << n) FOR(j, 1, 1 << n) FOR(k, 1, 1 << n){
        bool flag = false;
        if(i & j || i & k || j & k) continue;
        //cout << bitset<8>(i) << " " << bitset<8>(j) << " " << bitset<8>(k) << " " << aa[i] + bb[j] + cc[k] << endl;
        ans = min(ans, aa[i] + bb[j] + cc[k]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace ITP_3_D{
    public class Program{
        public static void Main(string[] args){
            string[] temp = Console.ReadLine().Split(' ');
            int a = int.Parse(temp[0]);
            int b = int.Parse(temp[1]);
            int c = int.Parse(temp[2]);
            int count = 0;

            for(int i=a; i<=b; i++){
                if(c%i == 0){
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
int n,l,q,x[110001],go[110001][19];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",x+i);
	scanf("%d%d",&l,&q);
	for(int i=1;i<=n;i++)go[i][0]=upper_bound(x+1,x+n+1,x[i]+l)-x-1;
	for(int i=1;i<19;i++)
		for(int j=1;j<=n;j++)go[j][i]=go[go[j][i-1]][i-1];
	while(q--)
	{
		int a,b,k=18,ans=0;
		scanf("%d%d",&a,&b);
		if(a>b)swap(a,b);
		while(a<b)
		{
			while(k&&go[a][k]>=b)k--;
			a=go[a][k];
			ans+=1<<k;
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 9344
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        N=Integer.parseInt(br.readLine().trim());
        String s[]=br.readLine().trim().split(" ");
        Integer a[]=new Integer[N];
        for(i=0;i<N;i++) a[i]=Integer.parseInt(s[i]);
        Arrays.sort(a,Collections.reverseOrder());

        long ans=a[0]; int cur=0;
        for(i=2;i<N;i++)
        {
            if(i%2==0) cur++;
            ans+=a[cur];
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 63060
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	if(a==1||a==3||a==5||a==7||a==8||a==10||a==12 ){
		if(b==1||b==3||b==5||b==7||b==8||b==10||b==12){
			cout<<"Yes"<<endl;
			return 0;
		}
	}else if(a==4||a==6||a==9||a==11){
		if(b==4||b==6||b==9||b==11){
			cout<<"Yes"<<endl;
			return 0;
		}
	}else if(a==2 && b==2){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int i,j;
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0){
                break;
            }
                for(i=0;i<H;i++){
                    for(j=0;j<W;j++){
                        if(i%2==1 && j%2==1){
                            System.out.print("#");
                        }
                        if(i%2==0 && j%2==1){
                            System.out.print(".");                            
                        }
                        if(i%2==1 && j%2==0){
                            System.out.print(".");  
                        }
                        if(i%2==0 && j%2==0){
                            System.out.print("#");                            
                        }
                    }
                System.out.println();                       
                }
                System.out.println();                   
        }
    }
}


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

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

    int q,l,r; cin >> q;

    // START : 素数を用意
    bitset<1000000> is_prime(0);
    for (int i=2; i<=200002; i++) is_prime.set(i);
    for (int i=2; i<=100000; i++) {
        if (is_prime[i]) {
            for (int j=i*2; j<=200002; j+=i) {
                is_prime.reset(j);
            }
        }
    }

    /* for (li i=100000; i>=2; i--) {
        if (is_prime[i]) {
            if (is_prime[(i+1)/2]==0) {
                is_prime.reset(i);
            }
        }
    } */

    vector<int> forsum(100000, 0);
    for (int i=100000; i>=2; i--) {
        if (is_prime[i]&&is_prime[(i+1)/2]) {
            forsum[i] = 1;
        }
    }
    // END : 素数を用意
    vector<int> s(100001, 0);
    for (int i = 0; i < 100000; ++i) s[i+1] = s[i] + forsum[i];

    for (int i=1; i<=q; i++) {
        cin >> l >> r;
        cout << s[r+1] - s[l] << "\n";
    }



    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
int main(void) {
	
	int x[3000], y[3000];
	int i = 1, j = 1, k = 1;
	int tmp;

	while (1) {
		scanf("%d %d\n", &x[i], &y[i]);
		if (0<=x[i] && x[i] <= 10000 && 0<=y[i] && y[i] <= 10000) {
			if (x[i] == 0 && y[i] == 0) break;
			i++;
		}
		else return 0;
	}


	while(1){
		if (x[j] > y[j]) {
			tmp = x[j];
			x[j] = y[j];
			y[j] = tmp;
		}
		j++;
		if (j == i) break;
	}
	

	while (1) {
		printf("%d %d\n", x[k], y[k]);
		k++;
		if (k == i) break;
	}
	
	return 0;
}

Measured memory_bytes: 628