akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  vector<string> ans;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 1; j <= k; j++) {
      ans.push_back(s.substr(i, j));
    }
  }
  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());
  cout << ans[k - 1] << endl;
  return 0;
}


Measured memory_bytes: 1660
N = int(input())
H = list(map(int, input().split()))
for _ in range(10):
    H.append(10**9)
dp = [10**9] * (N+2)
dp[0] = 0
# 引っ張ってくる方式
for i in range(1, N):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))

print(dp[N-1])



Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> xy(n);
    vector<int> x(n), y(n);
    ll ans = __LONG_LONG_MAX__;
    
    rep(i, n) {
        cin >> x[i] >> y[i];
        xy[i].first = x[i];
        xy[i].second = y[i];
    }
    
    sort(all(x));
    sort(all(y));
    
    rep(lx, n) {
        reps(rx, lx, n) {
            rep(ly, n) {
                reps(ry, ly, n) {
                    int cnt = 0;
                    
                    rep(i, n) {
                        if (
                            (xy[i].first >= x[lx]) &&
                            (xy[i].first <= x[rx]) &&
                            (xy[i].second >= y[ly]) &&
                            (xy[i].second <= y[ry])
                        )
                        {
                            cnt++;
                        }
                    }
                    
                    if (cnt >= k) {
                        ans = min(ans, (ll)(x[rx] - x[lx]) * (y[ry] - y[ly]));
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll long long int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1000000007 ;
const ll N=1e6+5;
int main()
{
    FAST
    ll tc,i,j;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
        ll n;
        cin>>n;
        ll ans=0;
        for(i=1; i<=n; i++)
        {
            for(j=i; j<=n; j+=i)
                ans+=j;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int min(int a, int b){
  if(a<b) return a;
  else return b;
}
int main(){
  int i,j,n,m;
  int M=100000;
  int d[100010]={};
  
  for(i=1;i<M;i++)
    d[i]=1e9;
  
  scanf("%d %d",&n,&m);

  int a[m], b[m];
  for(i=0;i<m;i++){
    scanf("%d %d",&a[i],&b[i]);
  }

  for(i=0;i<m;i++){
    for(j=0;j<n;j++)d[j+a[i]]=min(d[j+a[i]],d[j]+b[i]);
    for(j=M-2;j;j--)d[j]=min(d[j],d[j+1]);
  }

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
#define __ ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {
 //   __

    ll n;
    cin >> n ;
    map<string , ll > mp ;
    while(n--) {
        string s ;
        cin >> s ;
        mp[s]++ ;
    }

    cout << "AC x " << mp["AC"] << endl ;
    cout << "WA x " << mp["WA"] << endl ;
    cout << "TLE x "<< mp["TLE"]<< endl ;
    cout << "RE x " << mp["RE"] << endl ;
    return 0 ;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    cout << (n%10==9||n/10==9?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1;
int a[10000]={3,13,23,43,53,73,83,103,113,163,173,193,223,233,263,283,293,313,353,373,383,433,443,463,503,523,563,593,613,643,653,673,683,733,743,773,823,853,863,883,953,983,1013,1033,1063,1093,1103,1123,1153,1163,1193,1213,1223,1283,1303};
int main()
{
   int n,i;
   scanf("%d",&n);
   printf("%d",a[0]);
   for(i = 1;i<n;i++)
    printf(" %d",a[i]);
}


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;
typedef long double ld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;

inline int add(int a, int b)
{
	int ret=((ll)a+b)%modn;
	if(ret<0) {
		ret=(ret+modn)%modn;
	}
	return ret;
}

inline int mul(int a, int b)
{
	int ret=((ll)a*b)%modn;
	if(ret<0) {
		ret=(ret+modn)%modn;
	}
	return ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int N, X;
	cin>>N>>X;
	vector<int> a(N+1);
	for(int i=1; i<=N; i++) {
		cin>>a[i];
	}
	sort(all(a));
	vector<vector<int>> dp(N+1, vector<int>(X+1, -1));
	function<int(int, int)> solve = [&](int n, int x)
	{
		if(n==1) {
			return x%a[n];
		}
		
		int &memo = dp[n][x];
		if(memo!=-1) return memo;
		
		int ans = 0;
		ans = add(ans, solve(n-1, x%a[n]));
		ans = add(ans, mul(n-1, solve(n-1, x)));
		return memo=ans; 
	};
	int ans = solve(N, X);
	cout<<ans<<"\n";
    return 0;
}




Measured memory_bytes: 79488
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)


Measured memory_bytes: 47548
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//char S[] = new char[3];
		int S[] = new int[3];
		for(int i=0;i<3;i++) {
			S[i] = sc.nextInt();
			//System.out.println(S[i]);
		}
		int temp=0;
		temp = S[0];
		S[0] = S[1];
		S[1] = temp;
		
		int temp2=0;
		temp2 = S[0];
		S[0] = S[2];
		S[2] = temp2;
		
		for(int j=0;j<3;j++) {
			System.out.print(S[j]+" ");
		}
	}
}

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

int main(){
	
	int n,x;
	
	while(1){
		cin >> n >> x ;
		if (n==0 && x==0) break;
		int y=0;
		for (int i=1; i<=n-2; i++){
			for (int j=2; j<=n-1; j++){
				for (int k=3; k<=n; k++){
					if (i+j+k==x && i<j && j<k) ++y;
				}
			}
		}
		cout << y <<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1720
#include <iostream>
#include <complex>
#include <string>
#define x real() 
#define y imag() 
using namespace std;
typedef complex <double> point;
typedef complex<double> vectol;

string ccw(point a,point b,point c) {
  vectol ab= b-a, ac = c-a;
  vectol d  = ac * conj(ab); 
  d /= abs(ab);
  if(d.y > 0) return "COUNTER_CLOCKWISE";
  if(d.y < 0) return "CLOCKWISE";
  vectol Ob = ab * conj(ab);
  Ob /= abs(ab);
  if(Ob.x < d.x) return "ONLINE_FRONT";
  if(0 > d.x) return "ONLINE_BACK";
  return "ON_SEGMENT";
}

int main() {
  double x0,y0,x1,y1;
  cin>>x0>>y0>>x1>>y1;
  point a = point( x0, y0);
  point b = point( x1, y1);
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x0 >> y0;
    cout << ccw(a,b,point(x0,y0)) <<endl;
  }

  return 0;
}

Measured memory_bytes: 1260
a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)
c = gets.split(" ").map(&:to_i)
bingos = []
n = gets.to_i

while bingo = gets do
    bingo = bingo.to_i
    bingos.push(bingo)
end

ary = [a,b,c]
result = []
ary.each do |line|
    line.each do |i|
        if bingos.include?(i)
            result.push(1)
        else
            result.push(0)
        end
    end
end

flag = "No"

if result[0]==1 and result[1]==1 and result[2]==1
    flag = "Yes"
elsif result[3]==1 and result[4]==1 and result[5]==1
    flag = "Yes"
elsif result[6]==1 and result[7]==1 and result[8]==1
    flag = "Yes"
elsif result[0]==1 and result[3]==1 and result[6]==1
    flag = "Yes"
elsif result[1]==1 and result[4]==1 and result[7]==1
    flag = "Yes"
elsif result[2]==1 and result[5]==1 and result[8]==1
    flag = "Yes"
elsif result[0]==1 and result[4]==1 and result[8]==1
    flag = "Yes"
elsif result[2]==1 and result[4]==1 and result[6]==1
    flag = "Yes"
end

puts flag

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

int main(){
  int N;
  int64_t count=0;
  cin >> N;
  for(int i=1;i<N+1;i++){
    if(!(i%3==0 || i%5==0)){
      count+=i;
    }
  }
  cout << count << endl;
}

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

int main() {
string s;
cin >> s;
int c = 0;
if(s.at(0) == '1'){
	c++;
}
if(s.at(1) == '1'){
	c++;
}
if(s.at(2) == '1'){
	c++;
}
cout << c << endl;
}

Measured memory_bytes: 256
# ABC124D - Handstand
def main():
    N, K = tuple(map(int, input().split()))
    S = input()
    A = [i for i in range(1, N) if S[i] != S[i - 1]]
    # change to start and end with length of "1"
    A = [0] + A if S[0] == "1" else [0, 0] + A
    A += [N] if S[-1] == "1" else [N, N]
    
    l, x = len(A), K * 2 + 1
    if l <= x:  # possible to change all to "1"
        print(N)
    else:
        # check all sections of the length x
        ans = max(A[i + x] - A[i] for i in range(0, l - x + 1, 2))
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 7884
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int,int> pii;

vector<int> dijkstra(int s, int n, vector< vector<pii> > &G){
  int INF = 1000000000;  
  priority_queue<pii> wait;
  vector<int> results(n,INF);
  results[s] = 0;
  wait.push(make_pair(0,s));
  while(!wait.empty()){
    int nowpoint = wait.top().second;
    int nowcost = -wait.top().first;
    wait.pop();
    for(int i = 0; i < (int)G[nowpoint].size(); ++i){
      int nextcost = nowcost + G[nowpoint][i].first;
      int nextpoint = G[nowpoint][i].second;
      if(nextcost < results[nextpoint]){
	results[nextpoint] = nextcost;
	wait.push(make_pair(-nextcost,nextpoint));
      }
    }
  }
  return results;
}

int solve(int n, int l, int m, int A, int H, vector< vector<pii> > &G, vector<int> &F){
  int INF = 1000000000;
  int dp[n][n];
  for(int i = 0; i < n; ++i)
    fill(dp[i],dp[i]+n,INF);
  for(int i = 0; i < n; ++i)
    dp[i][i] = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < (int)G[i].size(); ++j){
      int to = G[i][j].second, cost = G[i][j].first;
      dp[i][to] = cost;
      dp[to][i] = cost;
    }
  }
  for(int k = 0; k < n; ++k){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
	dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  /*
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */
  vector< vector<pii> > G2(l+2);
  if(dp[A][H] <= m){
    G2[0].push_back(make_pair(dp[A][H],1));
    G2[1].push_back(make_pair(dp[A][H],0));
  }
  for(int i = 0; i < l; ++i){
    if(dp[A][F[i]] <= m){
      G2[0].push_back(make_pair(dp[A][F[i]],i+2));
      G2[i+2].push_back(make_pair(dp[A][F[i]],0));
    }
    if(dp[H][F[i]] <= m){
      G2[1].push_back(make_pair(dp[H][F[i]],i+2));
      G2[i+2].push_back(make_pair(dp[H][F[i]],1));
    }
  }
  for(int i = 0; i < l; ++i){
    for(int j = 0; j < i; ++j){
      int s = F[i], t = F[j];
      if(dp[s][t] <= m){
	G2[i+2].push_back(make_pair(dp[s][t],j+2));
	G2[j+2].push_back(make_pair(dp[s][t],i+2));
      }
    }
  }
  /*
  for(int i = 0; i < l+2; ++i){
    cout << i << " : ";
    for(int j = 0; j < (int)G2[i].size(); ++j){
      cout << G[i][j].second << " ";
    }
    cout << endl;
  }
  */
  vector<int> ans = dijkstra(0,n,G2);
  //for(int i = 0; i < l+2; ++i) cout << ans[i] << " ";
  //cout << endl;
  return ans[1];
}

int main(){
  int N, M, L, K, A, H;
  int INF = 1000000000;
  while(cin >> N >> M >> L >> K >> A >> H, N){
    vector<int> F;
    int f;
    for(int i = 0; i < L; ++i){
      cin >> f;
      F.push_back(f);
    }
    int X, Y, T;
    vector< vector< pii > > G(N);
    for(int i = 0; i < K; ++i){
      cin >> X >> Y >> T;
      if(T <= M){
	G[X].push_back(pii(T,Y));
	G[Y].push_back(pii(T,X));
      }
    }
    int ans = solve(N,L,M,A,H,G,F);
    if(ans == INF) cout << "Help!" << endl;
    else if(ans <= M) cout << ans << endl;
    else cout << M + (ans-M)*2 << endl;
  }
  return 0;
}

Measured memory_bytes: 3336
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto D = scan!long;
  auto P = N.iota.map!(_ => Point(scan!long, scan!long)).array;

  long solve() {
    long ans;
    auto d = D*D;
    foreach(p; P) {
      auto dd = p.x*p.x + p.y*p.y;
      if (dd <= d) ans++;
    }
    return ans;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


Measured memory_bytes: 14284
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)

#define INF (1e5)
typedef long long unsigned int ll;


int main()
{
	string S;
	cin >> S;
	int n = S.size();
	int lng = 0;
	int def = 0;
	REP(i, n+1)
	{	
		if(i<n){
		if(S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C'){
			def += 1;
			
		}else{
			if(def>lng){
				lng = def;
			}
			def = 0;
		}
		}else{
			if(def>lng){
				lng = def;
			}
			def = 0;
		}
	}
	
	cout << lng << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf=1e18;
int a[200001];
int sum[200001];
int n;
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]),sum[i]=sum[i-1]+a[i];
	int ans=inf;
	for(int i=1;i<n;i++)
	{
		ans=min(ans,max(sum[i],sum[n]-sum[i])-min(sum[i],sum[n]-sum[i]));
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3328
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

N = INT()

if N % 2 == 0:
    print(1/2)
else:
    print(ceil(N, 2) / N)


Measured memory_bytes: 38484
n,m = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(m)]
red = [1]+[0]*(n-1)
ball = [1]*n
for i in xy:
  x,y = i[0]-1,i[1]-1
  if red[x] == 1:
    red[y] = 1
  ball[x] -= 1
  ball[y] += 1
  if ball[x] == 0:
    red[x] = 0
print(red.count(1))

Measured memory_bytes: 28948
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ll long long
#define endl "\n"
#define lu unsigned long long
#define mod 1000000007
#define ld long double
#define f(i, n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define v vector<ll>
#define vv vector<vector<ll> >
#define vs vector<string>
#define vpr vector<pair<ll,ll>>
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define bg(x)  x.begin()
#define sz(x)  x.size()
#define in(x,n) f(i,n) cin>>x[i]
#define out(x,n) f(i,n) cout<<x[i]<<" "
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define mem(x,val) memset(x,val,sizeof(x))
#define tc    ll t;cin>>t;while(t--)
#define pi pair<int,int>
#define prfloat(val,precise) cout<<fixed<<setprecision(precise)<<val<<endl;
const ld PI = 2 * acos(0.0);
void yes(){ cout<<"YES\n";}
void no(){cout<<"NO\n";}
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){ ;if((x1%y1)==0)return x1/y1;return x1/y1+1;}
ll power(ll a,ll b){ if(b==0)return 1;ll d=power(a,b/2);d=m(d*d);
if(b&1)d=m(d*a);return d;}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int fun(int h)
{
	if(h==1)
		return 1;
	return 1+2*fun(h/2);
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h;cin>>h;
	cout<<fun(h)<<endl;
	return 0;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n,x,m;
	cin>>n>>x>>m;
	int ans[m+2];
	map<int,int> bval;
	ans[1]=x;
	bval[x]=1;
	int cs = -1;
	int ced = -1;
	for(int i=2;i<=m+1;i++) {
		ans[i]=(ans[i-1]*ans[i-1])%m;
		if(bval[ans[i]]) {
			cs = bval[ans[i]];
			ced = i;
		}
		else {
			bval[ans[i]]=i;
		}
	}	
	int pre[m+2];
	pre[0]=0;
	for(int i=1;i<=m+1;i++) {
		pre[i]=pre[i-1]+ans[i];
	}
	if(n<=ced) {
		cout<<pre[n];
	}
	else {
		n-=cs;
		int cl = (ced-cs);
		int ncyc = (n/cl);
		n%=cl;
		int curr = pre[cs-1];
		// cout<<curr<<"\n";
		curr+=(pre[ced-1]-pre[cs-1])*ncyc;
		curr+=pre[cs+n]-pre[cs-1];
		// cout<<curr;
		cout<<curr;
	}

	return 0;
}

Measured memory_bytes: 8200
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
ans = 0
for i in range(n):
    if s[i] != t[i]:
        ans += 1
print(ans)

Measured memory_bytes: 68760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mxsize (int)1e6
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
void yn(bool check){
    if(check)	cout<<"YES\n";
    else		cout<<"NO\n";
}
void fun(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r=0,ans=0;
    fi(0,n)
        if(s[i]=='R')   r++;
    fi(0,n)
        if(s[i]=='W'&&i<r)  ans++;
    cout<<ans<<"\n";

}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define ll long long
#define m 1000000007
using namespace std;
const int mmax = 200005;
ll n;
ll a[mmax];
ll f[mmax][3];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //freopen("test.inp", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        f[i][1] = (f[i-1][1]+a[i])%m;
    }
    for (int i = 1; i <= n; i++)
        f[i][2] = ((f[i-1][1]*a[i])%m + f[i-1][2])%m;
    cout << f[n][2]%m;
    return 0;
}


Measured memory_bytes: 9864
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>

#define pai 3.14159265358979323846264338327950288
using namespace std;


//Next Prime
//*
int main() 
{
	long int x;
	bool flag;
	vector<int> sosu = {2};
	cin >> x;

	for (int i = 3; i <= 100007; i+=2) 
	{
		flag = false;
		for (int j = 3;j<i;j++) 
		{
			if (i%j==0) 
			{
				flag = true;
				break;
			}
		}
		if (flag == false) 
		{
			sosu.push_back(i);
		}
	}
		
	for (int jk = x; jk <= 100007; jk++) 
	{
		for (int i = 0; i < sosu.size(); i++)
		{
			if (jk == sosu[i]) 
			{
				cout << jk;
				return 0;
			}
		}
	}
		
	cout << "nuke";
	return 0;
	


}
//*/



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

int main(void)
{
    int N, T;
    cin >> N >> T;

    vector<int> cost(N, 0);
    vector<int> time(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> cost[i] >> time[i];
    }

    int min_cost = 1000;
    bool found = false;
    for (int i = 0; i < N; i++)
    {
        if (time[i] <= T)
        {
            if (min_cost >= cost[i])
            {
                min_cost = cost[i];
                found = true;
            }
        }
    }
    if (found == true)
        cout << min_cost << endl;
    else
        cout << "TLE" << endl;

    return (0);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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


		if (n == 1) {
			System.out.println(1);
		} else {
			long i2 = 2;
			long i1 = 1;
			long ii = 0;
			for (int i = 2; i <= n; i++) {
				ii = i1 + i2;
				i2 = i1;
				i1 = ii;
			}
			System.out.println(ii);
		}

		sc.close();
	}
}

Measured memory_bytes: 21332
H, W = map(int, input().split())

def divide(H, W):
    if (H*W)%2 == 0:
        return H*W//2, H*W//2
    else:
        if H > W:
            return W*(H-1)//2, W*(H+1)//2
        else:
            return H*(W-1)//2, H*(W+1)//2

minval = 10000000000
for i in range(1, H):
    S0 = W*i
    S1, S2 = divide(H-i, W)
    minval = min(minval, max(abs(S0-S1), abs(S1-S2), abs(S2-S0)))
for i in range(1, W):
    S0 = H*i
    S1, S2 = divide(H, W-i)
    minval = min(minval, max(abs(S0-S1), abs(S1-S2), abs(S2-S0)))
print(minval)

Measured memory_bytes: 3064
//sieu nhan
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inp "test.inp"
#define out "test.out"
#define oo 100005
#define inf 1e15
#define mod 1000000007
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define y1 hungdzno1
int n,k,sum,ans,maxx,a[oo];
double res;
void nhap(){
  cin>>n>>k;
}
void xuly(){
  for(int i=1;i<=n;++i){
    int z=i,dem=0;
    while(z<k){
      z*=2;
      ++dem;
    }
    a[++ans]=(1<<dem);
  }
  for(int i=1;i<=ans;++i) maxx=max(maxx,a[i]);
  for(int i=1;i<=ans;++i) sum+=maxx/a[i];
  maxx*=n;
  res=double(sum)/double(maxx);
  cout<<fixed<<setprecision(10)<<res;
}
main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //freopen(inp,"r",stdin);
  //freopen(out,"w",stdout);
  nhap();
  xuly();
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve(){
	int n,r;
	cin>>n>>r;
	if(n>=10) {
		cout<<r<<endl;
		return;
	}
	int res = r;
	res+=100 *(10-n);
	cout<<res<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import copy
n = int(input())
l=[int(input()) for x in range(n)]
ll=copy.copy(l)
ll.sort()
setl=list(set(ll))
m=max(l)
for i in range(n):
    if len(setl)==1:
        print(m)
    elif l[i]==m:
        print(ll[-2])
    else:
        print(m)

Measured memory_bytes: 19768
k,t = map(int, input().split())
al = list(map(int, input().split()))

prev = -1
ans = 0
for i in range(k):
    max_v = max(al)
    max_ind = al.index(max_v)
    max_v = 0
    max_i = -1
    for j, v in enumerate(al):
        if max_v < v and j != prev:
            max_v = v
            max_i = j
    if max_i != -1:
        al[max_i] -= 1
        prev = max_i
    else:
        ans += 1

print(ans)

Measured memory_bytes: 71888
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_W = 31;
const int MAX_H = 61;
const int INF = 1e9 + 7;

//start: 0, goal: 0, X: -1

int my[9] = {2, 1, 0, -1, -2, 1, 0, -1, 0};
int mx[9] = {1, 1, 1, 1, 1, 2, 2, 2, 3};

class C{
  public:
    int y, x, foot, cost;
    C(int _y, int _x, int _f, int _c){ y = _y, x = _x; foot = _f, cost = _c; }
    C(){}
    bool operator > (const C &c) const { return cost > c.cost; }
};

int W, H, v[MAX_H][MAX_W];

int dij(){
  priority_queue<C, vector<C>, greater<C> > open;
  REP(x, W){
    if(v[H - 1][x] == 0){
      open.push( C(H - 1, x, 0, 0) );
      open.push( C(H - 1, x, 1, 0) );
    }
  }
  int closed[MAX_H][MAX_W][2];
  REP(y, H) REP(x, W) REP(i, 2) closed[y][x][i] = INF;
  while(!open.empty()){
    C tmp = open.top(); open.pop();
    int y = tmp.y, x = tmp.x, foot = tmp.foot, cost = tmp.cost;
    //cout <<y <<", " <<x <<", " <<foot <<", " <<cost <<endl;
    if(closed[y][x][foot] <= cost) continue;
    closed[y][x][foot] = cost;
    REP(i, 9){
      int ny = y + my[i], nx = (foot == 0 ? x + (mx[i] * -1) : x + mx[i]);
      if(ny >= 0 && nx >= 0 && ny < H && nx < W && v[ny][nx] >= 0){
        //cout <<"    " <<ny <<", " <<nx <<", " <<(foot + 1) % 2 <<endl;
        open.push( C(ny, nx, (foot + 1) % 2, cost + v[ny][nx]) );
      }
    }
  }
  int ans = INF;
  REP(x, W) REP(i, 2) if(v[0][x] == 0) ans = min(ans, closed[0][x][i]);
  return (ans == INF ? -1 : ans);
}

int main() {
  while(cin >>W >>H && W){
    REP(y, H){
      REP(x, W){
        char c; cin >>c;
        if(c == 'S') v[y][x] = 0;
        else if(c == 'T') v[y][x] = 0;
        else if(c == 'X') v[y][x] = -1;
        else v[y][x] = c - '0';
      }
    }
    //debug
    //REP(y, H){
    //  REP(x, W) cout <<v[y][x] <<" ";
    //  cout <<endl;
    //}
    //cout <<"--------" <<endl;
    cout <<dij() <<endl;
  }
  return 0;
}

Measured memory_bytes: 1332
#include <stdio.h>

char S[222222], T[222222];

int main(void) {
	int sumipe = 0, i;
	if (scanf("%222221s", S) != 1) return 1;
	if (scanf("%222221s", T) != 1) return 1;
	for (i = 0; S[i] != '\0' || T[i] != '\0'; i++) {
		sumipe += S[i] != T[i];
	}
	printf("%d\n", sumipe);
	return 0;
}


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

int main(){
  int n, w;
  cin >> n >> w;
  vi weight(n+1), value(n+1);
  rep(i,n) cin >> weight[i+1] >> value[i+1];
  vector<vector<ll>> dp(n+1, vector<ll>(w+1));
  dp[0][0] = 0;
  for(int i=1; i<=n; i++){
    for(int j=0; j<=w; j++){
      if(j - weight[i] >= 0) dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight[i]] + value[i]);
      else dp[i][j] = dp[i-1][j];
    }
  }
  cout << dp[n][w] << endl;
}


Measured memory_bytes: 83088
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll N;

void out(ll a, ll b, vector<ll> v) {//aからbまで下kけた埋める
	if (v.size() == 1) { cout << a << " " << b << " "; return; }

	for (ll i : v) {
		if ((a>>i&1) != (b>>i&1)) {
			vector<ll> w;
			for (ll j : v) {
				if (i != j) { w.push_back(j); }
			}
			out(a, a ^ (1 << w[0]), w);
			out(a ^ (1 << w[0]) ^ (1 << i), b, w);

			return;
		}
	}

}



int main() {
	ll A, B;
	cin >>N>> A >> B;

	ll a=0, b=0;
	rep(i, N) {
		a += (A >> i) % 2;
		b += (B >> i) % 2;
	}

	if (a % 2 == b % 2) {
		cout << "NO";
	}

	else {
		cout << "YES" << endl;

		vector<ll> v;
		rep(i, N) v.push_back(i);
		out(A, B, v);
	}
	system("PAUSE");
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
#include <atcoder/all>

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(a)  (a).begin(),(a).end()
#define LL long long

int n,q;
int x[200000],y[200000];

struct S{
    int idx;
    int x;
    int y;
};

vector<S> v;

int main() {
    cin>>n;
    v.resize(n);
    REP(i,n){
        int x,y;
        cin>>x>>y;
        v[i]=S{i,x,y};
    }

    auto uf = atcoder::dsu(n);
    sort(ALL(v),[](S p1,S p2){return p1.x < p2.x;});

    /*REP(i,n){
        cerr<<v[i].x<<" "<<v[i].y<<endl;
    }*/

    int idx = v[0].idx;
    int miny = v[0].y;
    FOR(i,1,n){
        if(miny < v[i].y)uf.merge(idx,v[i].idx);
        else{
            idx = v[i].idx;
            miny = v[i].y;
        }
    }

    /*REP(i,n){
        cout<<uf.size(i)<<endl;
    }*/

    sort(ALL(v),[](S p1,S p2){return p1.x > p2.x;});

    /*REP(i,n){
        cerr<<v[i].x<<" "<<v[i].y<<endl;
    }*/
    idx = v[0].idx;
    int maxy = v[0].y;
    FOR(i,1,n){
        if(maxy > v[i].y){
            uf.merge(idx,v[i].idx);
        }
        else{
            idx = v[i].idx;
            maxy = v[i].y;
        }
    }

    /*REP(i,n){
        cout<<uf.size(i)<<endl;
    }*/

    sort(ALL(v),[](S p1,S p2){return p1.y < p2.y;});
    idx = v[0].idx;
    int minx = v[0].x;
    FOR(i,1,n){
        if(minx < v[i].x)uf.merge(idx,v[i].idx);
        else{
            idx = v[i].idx;
            minx = v[i].x;
        }
    }

    /*REP(i,n){
        cout<<uf.size(i)<<endl;
    }*/

    sort(ALL(v),[](S p1,S p2){return p1.y > p2.y;});
    idx = v[0].idx;
    int maxx = v[0].x;
    FOR(i,1,n){
        if(maxx > v[i].x)uf.merge(idx,v[i].idx);
        else{
            idx = v[i].idx;
            maxx = v[i].x;
        }
    }
    
    REP(i,n){
        cout<<uf.size(i)<<endl;
    }

}

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


int main() {
    int n, a;
    cin >> n;
    a = n % 10;
    if(a == 3) {
        cout << "bon";
    }
    else if(a==0 || a==1 || a==6 || a==8) {
        cout << "pon";
    }
    else {
        cout << "hon";
    }
    cout << "\n";


}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int h[] = new int[N];
		int min = Integer.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}

		Arrays.sort(h);

		for (int i = 0; i + K - 1 < N; i++) {
			if (h[i + K - 1] - h[i] < min) min = h[i + K - 1] - h[i];
		}


		System.out.println(min);

	}
}

Measured memory_bytes: 50920
#include<stdio.h>
#include<math.h>

int main(){
    int N,M,i,j,k,a;
    int syurui=0;
    scanf("%d %d",&N,&M);
    int suki[M];
    for(i=0;i<M;i++){
        suki[i]=0;
    }
    for(i=0;i<N;i++){
        scanf("%d",&k);
        for(j=0;j<k;j++){
            scanf("%d",&a);
            suki[a-1]++;
        }
    }
    for(i=0;i<M;i++){
        if(suki[i]==N){
            syurui++;
        }
    }
    printf("%d",syurui);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

int main(void){

    int a,b;
    char op;

    while(scanf("%d %c %d",&a, &op, &b) != EOF){
        if(op == '?'){
            return 0;
        }else if(op == '+'){
            printf("%d\n",a + b);
        }else if(op == '-'){
            printf("%d\n",a - b);
        }else if(op == '*'){
            printf("%d\n",a * b);
        }else if(op == '/'){
            printf("%d\n",a / b);
        }else{
            printf("Arithmatics error!\n");
            exit(1);
        }

        }
  }

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
// ll mod(long long val) {
//     long long res = val % MOD;
//     if (res < 0) res += MOD;
//     return res;
// }
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }

ll n;
vector<ll> a;
vector<ll> b;
vector<ll> c;

int main() {
    cin >> n;
    ll t;
    for (ll i = 0; i < n; ++i) {
        cin >> t;
        a.push_back(t);
    }
    for (ll i = 0; i < n; ++i) {
        cin >> t;
        b.push_back(t);
    }
    for (ll i = 0; i < n; ++i) {
        cin >> t;
        c.push_back(t);
    }

    vector<ll> sums(n + 1, 0);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    for (ll i = 0; i < n; ++i) {
        ll e = b[i];
        auto it = lower_bound(c.begin(), c.end(), e + 1);
        sums[i + 1] += distance(it, c.end());
        sums[i + 1] += sums[i];
    }

    ll ans = 0;
    for (ll i = 0; i < n; ++i) {
        ll e = a[i];
        auto it = lower_bound(b.begin(), b.end(), e + 1);
        ll ix = distance(b.begin(), it);
        ans += sums[n] - sums[ix];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include<math.h>
 
using namespace std;
 
int main(){
 
	int a,b,c;
	cin >> a >> b >> c;
	cout << max(max(a,b),max(b,c)) - min(min(a,b),min(b,c)) <<endl;
 
	return 0;
}

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

int main(){
  int N, L;
  cin >> N >> L;
  vector<string> moji(N);
  for(int i = 0; i < N; i++){
    cin >> moji[i];
  }
  sort(moji.begin(), moji.end());
  string result = "";
  for(int i = 0; i < N; i++){
    result += moji[i];
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
using namespace std;

int N, M;
string s, t;
int dp[3001][3001];
string sol;
int main() {
    cin >> s >> t;
    N = s.length();
    M = t.length();
    for (int i = 1; i <= N; ++i)
        for (int j = 1; j <= M; ++j) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (s[i - 1] == t[j - 1])
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
        }
    int i = N, j = M;
    while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1] && dp[i][j] == dp[i - 1][j - 1] + 1) {
            sol = sol + s[i - 1];
            --i;
            --j;
        }
        else {
            if (dp[i - 1][j] > dp[i][j - 1])
                --i;
            else --j;
        }
    }
    reverse(sol.begin(), sol.end());
    cout << sol;
    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    REP(i, S.length()) {
        S[i] += N;
        if (S[i] > 'Z') {
            S[i] -= 26;
        }
    }
    print(S);
}

int main()
{
    solve();

    return 0;
}


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

int bubblesort(int arr[], int n){
  int cnt = 0;
  for(int i = n - 1; i > 0; i--){
    for(int j = 0; j < i; j++){
      if(arr[j] > arr[j+1]){
        swap(arr[j], arr[j+1]);
        cnt++;
      }
    }
  }
  return cnt;
}

int main(void){
  int n;
  while(cin >> n, n != 0){
    int *arr = new int[n];
    for(int i = 0; i < n; i++){
      cin >> arr[i];
    }
    int cnt = bubblesort(arr, n);
    cout << cnt << endl;
  }
  return 0;
}

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

int main() {
  // 3つのグループに分ける用の配列を用意する
  int group[12] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
  int x, y;
  cin >> x >> y;
  cout << (group[x-1] == group[y-1] ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll arr[n + 1] = {0}, sum = 0, tmp[n + 1] = {0};
		for (int i = 1; i <= n; i++) cin >> arr[i], tmp[i] = arr[i];
		for (int i = 1; i <= n; i++) arr[i] = (arr[i] % mod + arr[i - 1] % mod) % mod;
		for (int i = 1; i <= n - 1; i++) {
			sum = (tmp[i] * (arr[n] - arr[i] + mod) % mod + sum) % mod;
		}
		cout << sum << '\n';
	}
	return 0;
}

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

int main(){
  ll n, ans;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for(ll i = 0; i < n; i++) for(ll j = i + 1; j < n; j++) for(ll k = j + 1; k < n; k++) if(a[i] + a[j] > a[k]) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int K;
VI ans;


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


double g(int x){
    return (double)x/S(x);
}


signed main(){
    cin >> K;

    repe(i, 1, 999) ans.pb(i);
    int p10 = 10, n = 9;
    repe(i, 1, 12){
        repe(j, 1, 999) ans.pb(j*p10+n);
        n *= 10;
        n += 9;
        p10 *= 10;
    }

    sort(ALL(ans), greater<int>());
    UNIQUE(ans);
    ans.erase(ub(ALL(ans), 999'999'999'999'999LL), end(ans));

    auto it = begin(ans);
    double m = g(*it);
    it++;
    while(it != end(ans))
        if(chmin(m, g(*it), true)) it++;
        else it = ans.erase(it);

    reverse(ALL(ans));
    rep(i, 0, K) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
N = int(input())
xn = list(map(int, input().split()))
xn_sorted = sorted(xn)
val_a = xn_sorted[(len(xn_sorted))//2 - 1]
val_b = xn_sorted[(len(xn_sorted))//2]

for xi in xn:
    if xi <= val_a:
        print(val_b)
    else:
        print(val_a)


Measured memory_bytes: 26016
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

d = 5000000000000000

s = gets.chomp
k = gets_i

s.chars.each_with_index do |s, i|
  if s != "1"
    puts s
    exit
  elsif i == k - 1
    puts 1
    exit
  end
end


Measured memory_bytes: 14516