akhauriyash/Code-Regression huggingface dataset:
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

ll N;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    solve();
}

// 与えられる入力は全て整数
// 1 <= N <= 10^4

// ll N
// N 行出力せよ。i 行目には f(i) の値を出力せよ。
void solve(){
    vl ans(60005);
    rep(i,1,100)rep(j,1,100)rep(k,1,100){
        ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
    }
    repe(i,1,N)cout<<ans[i]<<endl;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if(i%2==0)continue;
        int cnt = 0;
        for(int j = 1;j <= i;j++){
            if(i%j==0)cnt++;
        }
        if(cnt==8)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }



int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	//cin >> t;
	while (t--) {
		int n, k;
		cin >> n >> k;
		vi a(n);
		lop(i, n) cin >> a[i];
		loop(i, k, n) cout << (a[i] > a[i - k] ? "Yes\n" : "No\n");
	}


	return 0;
}


Measured memory_bytes: 3984
x=int(input())
for a in range(101):
    for b in range(101):
        if a**5+b**5==x:
            print(f"{a} {-b}")
            exit(0)
for a in range(201):
    for b in range(201):
        if a**5-b**5==x:
            print(f"{a} {b}")
            exit(0)
            

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

public class Main {
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        public long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int[] arr = new int[] {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5,
                                1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int n = sc.nextInt();
        for(int i = 0; i < arr.length; ++i ){
            if(i == n-1){
                System.out.println(arr[i]);
                break;
            }
        }
    }
}


Measured memory_bytes: 32664
def main
  k,n = gets.chomp.split(" ").map(&:to_i)
  as = gets.chomp.split(" ").map(&:to_i)

  maxdis = 0
  as.each_with_index do |a,i|
    dis = as[i] - as[i-1]
    dis = as[i] + k - as[i-1] if i == 0
    maxdis = dis if dis > maxdis
  end
  puts k - maxdis
end

main



Measured memory_bytes: 28816
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    long Y = sc.nextLong();
    long tmp=X;
    long ans =0;
    while(tmp<=Y){

      tmp=tmp*2;
      ans++;
    }
    System.out.println(ans);

  }

  
}


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

x = [[] for i in range(n+1)]

for i in range(m):
    x1, y1 = [int(i) for i in input().split()]
    x[x1].append(y1)
    x[y1].append(x1)

ans = [10**10] * n
ans[0] = 0
root = [10**10] * n
root[0] = 0

from collections import deque
q = deque() # FIFOキューの作成
for i in x[1]:
    q.append((1,i))#現在の深さ、次に行ける所
    root[i-1] = 1

while q:
    a,b = q.popleft() #aが現在の位置　bが次に行く所
    #ここを簡略化したい
    if (ans[a-1] + 1) < ans[b-1]:
        root[b-1] = a
        ans[b - 1] = ans[a - 1] + 1
    else:
        continue

    for i in x[b]:
        if ans[i-1] > (ans[a-1]+1):
            q.append((b,i))


for i in ans[1:]:
    if i == 10**10:
        print("No")
        exit()

print("Yes")
[print(i) for i in root[1:]]

Measured memory_bytes: 104828
#include<cstdio>
#define N 500005
struct mzls
{
	int key;
	mzls *ch[2];
};
mzls tree[N];
bool f1=1;
mzls *root,*NIL,*ncnt;
inline void Init()
{
	NIL=&tree[0];
	NIL->ch[0]=NIL->ch[1]=NIL;
	ncnt=&tree[1];
	root=NIL;
}
inline mzls *newnode(int ml)
{
	mzls *p=++ncnt;
	p->key=ml;
	p->ch[0]=p->ch[1]=NIL;
	return p;
}
inline void Insert(mzls *&rt,int ml)
{
	if(rt==NIL)
	{
		rt=newnode(ml);
		return;
	}
	int d=(ml>=rt->key);
	Insert(rt->ch[d],ml);
}
inline void InOrder(mzls *rt)
{
	if(rt==NIL)
		return;
	InOrder(rt->ch[0]);
	printf(" %d",rt->key);
	InOrder(rt->ch[1]);
}
inline void Preorder(mzls *rt)
{
	if(rt==NIL)
		return;
	printf(" %d",rt->key);
	Preorder(rt->ch[0]);
	Preorder(rt->ch[1]);
}
inline mzls *Find(mzls *rt, int ml) 
{
	if(rt==NIL) return NIL;
	if(rt->key==ml) return rt;
	int d=(ml>=rt->key);
	return Find(rt->ch[d],ml);
}
int main()
{
	int n,x;
	char op[100];
	Init();
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s",op);
		if(op[0]=='i')
		{
			scanf("%d",&x);
			Insert(root,x);
		}
		else if(op[0]=='f') 
		{
			scanf("%d", &x);
			mzls *p=Find(root, x);
			if(p==NIL)
				puts("no");
			else
				puts("yes");
		}
		else
		{
			InOrder(root);
			puts("");
			Preorder(root);
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 11968
#include<iostream>
using namespace std;
int x, y, z, qaq, ans;
int main()
{
    cin >> x >> y >> z;
    qaq = z;//将qaq初始值定为z（座位末端的人与椅子边缘的间隔为Z厘米长）
    while(qaq + y + z <= x){
        qaq += y + z;//每做一个人要多占要y+z的位置（坐在座位上的人总是占据长度为Y厘米的间隔，两个人之间必须有至少Z厘米的长度差距）
        ans ++;
    }
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// C- Poll

/*
We have N voting papers. The 
i-th vote (1≤i≤N) has the string Si

written on it.

Print all strings that are written on t
he most number of votes, in lexicographical order.

*/

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

int main(){
	int n; cin>>n;
	map<string,int> hash;
	int maXX = INT_MIN;

	for(int i = 0; i < n; i++){
		string s; cin>>s;
		hash[s]++;
		if(hash[s] > maXX){
			maXX = hash[s];
		}
	}
	//cout<<maXX<<endl;

	for(auto it = hash.begin(); it!=hash.end(); ++it){
		if((int)it->second == maXX)
			cout<<it->first<<endl;
	}
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int a;
  std::cin >> a;
  int ans = a + a * a + a * a * a;
  std::cout << ans << '\n';
}


Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		String s = sc.nextToken();
		int N = s.length();

		int ans = 0;
		int l = 0;
		int r = N-1;
		while (l < r) {
			char a = s.charAt(l);
			char b = s.charAt(r);
			
			if (a == b) {
				l++;
				r--;
			} else if (a == 'x' && b != 'x') {
				ans++;
				l++;
			} else if (a != 'x' && b == 'x') {
				ans++;
				r--;
			} else {
				System.out.println(-1);
				return;
			}
		}
		
		System.out.println(ans);
	}

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}
}

Measured memory_bytes: 23124
//abc164_c.cpp
//Sun Apr 26 20:56:43 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

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

	map<string, int> mp;
	int kind = 0;
	for (int i=0;i<n;i++){
		string tmp;
		cin >> tmp;
		auto itr = mp.find(tmp);
		if (itr != mp.end()){
			mp[tmp]++;
		}else {
			mp[tmp] = 1;
			kind++;
		}
	}

	cout << kind << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 19224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    while (true) {
        int n, x; cin >> n >> x;
        if (n+x==0) break;

        int ans = 0;
        FOR(i, 1, n-1) FOR(j, i+1, n) FOR(k, j+1, n+1) {
            if (i+j+k==x) ans++;
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : x)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
using namespace std;
signed main() {
    int a, b, c, t;
    cin >> a >> b >> c;
    t = a;
    a = b;
    b = t;
    t = a;
    a = c;
    c = t;
    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 924844033
#define N 2005
int n,k,cnt;
long long fac[N],f[N][N][2][2],num[N];
bool s[N];
int main()
{
	scanf("%d%d",&n,&k);fac[1]=1;fac[0]=1;
	for(int i=2;i<=n;i++) fac[i]=(fac[i-1]*1LL*i)%mod;
	for(int i=1;i<=n;i++)if(!s[i])for(int j=i;j<=n;j+=k) s[j]=1,num[++cnt]=j;
	f[0][0][0][0]=1;
	num[0]=-(1<<30);
	for(int i=1;i<=n;i++)//链 
	{
		f[i][0][0][0]=1;
		for(int j=1;j<=i;j++)
		{//继承，或后面放前面 
			f[i][j][0][0]=(f[i-1][j][1][0]+f[i-1][j][0][0]+((num[i]-num[i-1])==k)*f[i-1][j-1][0][0])%mod;
		 //继承 
			f[i][j][1][0]=(f[i-1][j][0][1]+f[i-1][j][1][1]+((num[i]-num[i-1])==k)*f[i-1][j-1][0][1])%mod;
		 //前面放后面 
			f[i][j][0][1]=((num[i+1]-num[i])==k)*(f[i-1][j-1][1][0]+f[i-1][j-1][0][0])%mod;
			f[i][j][1][1]=((num[i+1]-num[i])==k)*(f[i-1][j-1][0][1]+f[i-1][j-1][1][1])%mod; 
		}
	}
	long long ans=0;
	for(int i=0;i<=n;i++)
	{
		long long sum=(f[n][i][0][0]+f[n][i][0][1]+f[n][i][1][0]+f[n][i][1][1])%mod;
		if(i&1) ans=(ans+mod-(sum*fac[n-i])%mod)%mod;
		else ans=(ans+(sum*fac[n-i])%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin>>n>>s;
	int ans=0;
	rep(i,1000){
		string t=to_string(i);
		while(t.size()<3){
			t='0'+t;
		}
		int now=0;
		//cout<<t<<endl;
		rep(j,n){
			//cout<<t[now]<<' '<<s[j]<<endl;
			if(t[now]==s[j]){
				now++;
				if(now==3){
					ans++;
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
struct tower{
    ll w, s, v;
};
ll n;
tower a[1009];
ll dp[1009][20003];
ll ans;
ll sfunc(tower a, tower b){
    return a.s-b.w > b.s-a.w;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n;
    for(ll i = 0; i < n; ++i){
        cin >> a[i].w >> a[i].s >> a[i].v;
        ans = max(ans, a[i].v);
    }
    sort(a, a+n, sfunc);
    dp[0][a[0].s] = a[0].v;
    for(ll i = 1; i < n; ++i){
        dp[i][a[i].s] = a[i].v;
        for(ll j = 0; j < 10003; ++j){
            if(j >= a[i].w){
                dp[i][min(a[i].s, j-a[i].w)] =
                max(dp[i][min(a[i].s, j-a[i].w)], dp[i-1][j]+a[i].v); 
                ans = max(ans, dp[i][min(a[i].s, j-a[i].w)]);
            }
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
        }
    }
    cout << ans << "\n";
}

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

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    vector<ll> b(n);
    b[0] = a[0];
    for(ll i=1;i<n;i++){
        b[i] = b[i-1] + a[i];
    }
    vector<ll> v;
    for(ll i=2;i<n-1;i++){
        auto itr1 = lower_bound(b.begin()+1,b.begin()+i-1,b[i-1]/2);
        auto itr2 = lower_bound(b.begin()+i,b.end(),(b[n-1]-b[i-1])/2+b[i-1]);
        ll p,r;
        if(abs(*(itr1)-b[i-1]/2)<=abs(*(itr1-1)-b[i-1]/2)){
            p = *(itr1);
        }else{
            p = *(itr1-1);
        }
        ll q = b[i-1]-p;
        if(abs(*itr2-(b[n-1]-b[i-1])/2-b[i-1])<=abs(*(itr2-1)-(b[n-1]-b[i-1])/2-b[i-1])){
            r = *itr2-b[i-1];
        }else{
            r = *(itr2-1)-b[i-1];
        }
        ll s = b[n-1]-p-q-r;
        v.push_back(max({p,q,r,s})-min({p,q,r,s}));
    }
    cout << *min_element(v.begin(),v.end()) << endl;
    return 0;

}

Measured memory_bytes: 5492
#include <cstdio>
#include <deque>
using namespace std;
 
int main() {
  int num_query; scanf("%d", &num_query);
  deque<int> nums;
   
  while (num_query--) {
    int command; scanf("%d", &command);
     
    switch (command) {
      case 0:
        int d1, x; scanf("%d %d", &d1, &x);
        if (d1) nums.push_back(x);
        else nums.push_front(x);
        break;
         
      case 1:
        int p; scanf("%d", &p);
        printf("%d\n", nums[p]);
        break;
      
      case 2:
        int d2; scanf("%d", &d2);
        if (d2) nums.pop_back();
        else nums.pop_front();
        break;
    }
  }
}


Measured memory_bytes: 4156
#include <iostream>
int main(){
	int n, v[5000], m;
	while(std::cin >> n, m=n){
		for(;m--;)std::cin >> v[m];

		m = *v;
		for(int i=0;i<n;i++)
			for(int j=i,k=v[i];j<n;j++,k+=v[j])
				m=k>m?k:m;

		std::cout << m << '\n';
	}	
}

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

int main(){

	int x,y,z;

	for (int i = 0;; i++)
	{
		cin >> x>>y;
		if (x == 0 &&y==0){
			break;
		}

		if (x > y){
			z = x; x = y; y = z;
		}

		cout << x<<" "<<y<< endl;

	}



	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 


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

int N; cin >> N;

cout << (N + 2 -1)/2 << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int h,n,dp[10001];

signed main() {
    rep1(i,10000) dp[i] = INF/100;
    cin >> h >> n;
    rep(i,n) {
        int a,b;
        cin >> a >> b;
        rep(j,h+1) dp[min(h, j+a)] = min(dp[min(h, j+a)], dp[j]+b);
    }
    cout << dp[h] << endl;
}



Measured memory_bytes: 384
#define PROBLEM http://http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_C&lang=jp
#include<bits/stdc++.h>
using namespace std;
template<class T>
class StronglyConnectedComponents{
    vector<vector<T>>edge,rev_edge,compressed_edge,point_set;
    vector<int>order,vcomp,sort_order_vec;
    vector<bool>visit;
    int v_size = 0,compress_size = 0;
    void dfs(int v){
        visit[v] = true;
        for(auto nv : edge[v])
            if(not visit[nv]) dfs(nv);
        order.push_back(v);
    }
    void dfs_compress(int v){
        vcomp[v] = compress_size;
        for(auto nv : rev_edge[v])
            if(vcomp[nv] == -1) dfs_compress(nv);
    }
    void build_rev_edge(){
        for(int nv = 0; nv < edge.size(); ++nv)
            for(auto v : edge[nv])
                rev_edge[v].push_back(nv);
    }
    void popsort(){
        for(int v = 0; v < edge.size(); ++v)
            if(not visit[v]) dfs(v);
    }
    void compress_vertex(){
        for(auto itr = order.rbegin(); itr != order.rend();++itr ){
            auto v = *itr;
            if(vcomp[v] == -1){
                dfs_compress(v); compress_size++;
            }
        }
    }
    void construct_strcomp(){
        compress_vertex();
        //create compressed graph
        compressed_edge = vector<vector<T>>(compress_size);
        for(int frm = 0; frm < edge.size(); ++frm)
            for(auto to : edge[frm]){
                if(vcomp[frm] == vcomp[to])continue;
                compressed_edge[vcomp[frm]].push_back(vcomp[to]);
            }
    }
    void construct_point_set(){
        point_set = vector<vector<int>>(compress_size);
        for(int v = 0; v < vcomp.size(); ++v){
            point_set[vcomp[v]].push_back(v);
        }
    }
public:
    StronglyConnectedComponents(vector<vector<T>>&e)
    :v_size((int)e.size()),edge(e),order{},rev_edge(e.size()){};
    int operator [](int v){
        return vcomp[v];
    }
    void build(){
        build_rev_edge();
        visit = vector<bool>(v_size,false);
        popsort();
        vcomp = vector<int>(v_size,-1);
        construct_strcomp();
        construct_point_set();
    }
    bool isSamePointSet(int v, int u){return vcomp[v] == vcomp[u];}
    // scc_size return the size of compressed vertexs.
    int scc_size(){return compress_size;}
    
    vector<vector<int>> get_point_set(){
        return point_set;
    }
};
using Int = long long;
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N,E;
    cin >> N >> E;
    vector<vector<int>>v(N);
    for(int i = 0; i < E; ++i){
        int s,t; cin >> s >> t;
        v[s].push_back(t);
    }
    StronglyConnectedComponents<int>scc(v);
    scc.build();
    int Q;
    cin >> Q;
    while(Q--){
        int a,b; cin >> a >> b;
        cout  << (scc.isSamePointSet(a,b) ? "1" : "0") << endl;
    }
}



Measured memory_bytes: 5088
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a>b)?a:b);
#define min(a,b) ((b>a)?a:b);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert                                                                      //copy NUL check.cpp
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ atc.cpp -o atc.exe
#define zeroes(x) memset(x,0,sizeof(x))                                        //all elements to 0
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;




long int j=0,sum=0;




void primeFactors(long int n,long int m)  
{  
	long int p=n;;
	long int q=m;
    
    while (n % 2 == 0 && m % 2==0)  
    {  
    	j++;

         
        n = n/2;
        m=m/2;  
    } 
    if(j>0) 

    sum++;
  
    
    j=0;
    for (long int i = 3; i <= sqrt((m>n)?m:n); i = i + 2)  
    {  
        
        while (n % i == 0 && m%i==0)  
        {  
        	j++;
              
            n = n/i;  
            m=m/i;
        }  
        if(j>0)
        sum++;
        j=0;

        while (n % i == 0)  
        {  
        	
              
            n = n/i;  
            
        }  
        while ( m%i==0)  
        {  
        	
              
              
            m=m/i;
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  

    //if(p==n && p!=1 && q==m && q!=1 && m==n)
    	//sum++;
     //if(((m>n)?m:n)%((n>m)?m:n)==0 && m!=n && p!=1 && q!=1 )
     	//sum++;

     if (n > 2 && m==n )  
        sum++; 
    if(m!=n && n>2 && m>2 && ((m>n)?m:n)%((m>n)?n:m)==0)
    	sum++;
 
    cout<< sum+1;
}  






bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 




int main()
{
	long int n,m;
	
	cin>>n>>m;
	primeFactors(n,m);

	
	

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

    bool ok = false;
    for (int z = X + 1; z <= Y; z++) {
        bool cl = true;
        for (int i = 0; i < N; i++)
            if (x[i] >= z) {
                cl = false;
                break;
            }
        for (int i = 0; i < M; i++)
            if (y[i] < z) {
                cl = false;
                break;
            }

        if (cl) {
            ok = true;
            break;
        }
    }

    cout << (ok ? "No War" : "War") << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int

	fmt.Scanf("%d", &n)

	hights := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &hights[i])
	}

	count := 0

	for i := 0; i < n; i++ {
		if judge(i, hights) {
			count++
		}
	}

	fmt.Println(count)
}

func judge(here int, hights []int) bool {
	result := true

	for i := 0; i < here; i++ {
		if hights[i] > hights[here] {
			result = false
		}
	}

	return result
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;

  std::vector<int> P(N);
  rep(i, N) {
    std::cin >> P[i];
  }

  int min = 1e+6;
  int ans = 0;
  rep(i, N) {
    if(P[i] <= min) {
      ++ans;
      min = P[i];
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int ip(int k){
	if (k==1) return 0;
	for(int i=2;i*i<=k;i++) if (!(k%i)) return 0;
	return 1;
}
int main(){
	int x;
	cin>>x;
	for(int i=x;;i++) if (ip(i)){cout<<i;return 0;}
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(10000010, 0);

    rep(1, i, N + 1)
    {
        for (ll j = i; j <= N; j += i)
        {
            a.at(j)++;
        }
    }

    ll ans = 0;
    rep(1, i, N + 1)
    {
        ans += i * a.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 81404
fn main() {
 let v:u64 = {
  let mut b = String::new();
  let s = std::io::stdin();
  s.read_line(&mut b).unwrap();
  b.trim().parse().unwrap()
 };
 let mut f;
 let mut c = 0;
 while c < v{
  f = true;
  c += 1;
  let mut x = c;
  if x % 3 == 0{
   print!(" {}", c);
   continue
  }
  while x != 0 && f{
   if x % 10 == 3 {
    print!(" {}", c);
    f = false;
   }
   x = x / 10;
  }
 }
 println!();
}


Measured memory_bytes: 5036
//#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
//#define "limits.h"
using namespace std;




int main()
{
	int a, b, c;
	cin >> a >> b>>c;
	//scanf_s("%d%d%d", &a, &b, &c);
	if (a + b >= c) { printf("Yes"); }
	else { printf("No"); }

	return 0;
}


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

int main() {
    ll n; cin >> n;
    if (n % 2 == 1) {
        cout << 0 << endl;
    }
    else {
        ll ans = 0;
        ll div = 10;
        while (n/div > 0) {
            ans += n/div;
            div *= 5;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_152
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] ab = ReadInts();
            if (ab[0] < ab[1])
            {
                for (int i = 0; i < ab[1]; i++)
                {
                    Write(ab[0]);
                }
            }
            else {
                for (int i = 0; i < ab[0]; i++)
                {
                    Write(ab[1]);
                }
            }
            WriteLine();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

static const int MAX = 100;

int main(void)
{
	int N, A[MAX];
	int minj, count = 0;
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
	
	for(int i=0;i<N;i++){
		minj = i;
		for(int j=i+1;j<N;j++){
			if (A[minj] > A[j]){
				minj = j;
			}
		}
		if (i != minj){
			swap(A[i], A[minj]);
			count++;
		}
	}
	for(int i=0;i<N;i++){
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1164
H, N = map(int, input().split())
A_list = []
for i in range(1, N+1):
    A_list.append("A_" + str(i))

A_list = map(int, input().split())
A_total = sum(A_list)

if A_total >= H:
    print("Yes")
else:
    print("No")

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

int main(void)
{
	double x1 = 0;
	double y1 = 0;
	double x2 = 0;
	double y2 = 0;
	
	double x = 0;	//(x2 - x1)
	double y = 0;	//(y2 - y1)
	
	double sum = 0;
	double num = 0;	//??????
	
	scanf("%lf %lf %lf %lf", &x1,&y1, &x2, &y2);
	x = x2 - x1;
	y = y2 - y1;
	
	sum = (x * x) + (y * y);
	
	num = sqrt(sum);
	
	printf("%lf\n", num);
	
	return 0;
}

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

int main(){
    long int X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    long int p[A],q[B],r[C];
    for (long int i=0;i<A;i++){
        cin>>p[i];
    }
    for (long int i=0;i<B;i++){
        cin>>q[i];
    }
    for (long int i=0;i<C;i++){
        cin>>r[i];
    }
    sort(p,p+A,greater<long int>());
    sort(q,q+B,greater<long int>());
    sort(r,r+C,greater<long int>());
    long int l=0,m=0,j=0; 
    int s=0;
    for (long int i=0;i<C;i++){
        if (l>=X){
            s=1;
            j=i;
            break;
        }
        else if (m>=Y){
            s=2;
            j=i;
            break;
        }
        if (r[i]>p[X-1-l]||r[i]>q[Y-1-m]){
            if (p[X-1-l]>q[Y-1-m]) m+=1;
            else l+=1;            
        }
        else break;
    }
    if (s==1){
        for (long int k=j;k<C;k++){
            if (m>=Y) break;
            if (r[k]>q[Y-1-m]) m+=1;
            else break;
        }
    }
    if (s==2){
        for (long int k=j;k<C;k++){
            if (l>=X) break;
            if (r[k]>p[X-1-l]) l+=1;
            else break;
        }
    }
    long long ans=0;
    for (long int i=0;i<X-l;i++){
        ans+=p[i];
      //  cout<<p[i]<<'R'<<endl;
    }
    for (long int i=0;i<Y-m;i++){
        ans+=q[i];
       // cout<<q[i]<<'G'<<endl;
    }
    for (long int i=0;i<l+m;i++){
        ans+=r[i];
       // cout<<r[i]<<'M'<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if (a == 1) a += 13;
  if (b == 1) b += 13;
  if (a == b) cout << "Draw" << endl;
  else if (a < b) cout << "Bob" << endl;
  else cout << "Alice" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007
const ll INF = 1e18+5;
int main(){
    ios_base::sync_with_stdio(false);
      // #ifndef ONLINE_JUDGE
      //   freopen("input.txt", "r", stdin);
      //   freopen("output.txt", "w", stdout);
      // #endif
    ll n,w; cin>>n>>w;
    vector<int> wt(n), v(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>wt[i]>>v[i];
        sum+=v[i];
    }
    vector<ll> dp(sum+1,INF );
    dp[0]=0;
    for(int i=1;i<=n;i++){
        for(int j=sum;j>=v[i-1];j--){
            dp[j]=min(dp[j],wt[i-1]+dp[j-v[i-1]]);
            // cout<<dp[j]<<' ',"\n"[j==v[i-1]];
        }
    }
    for(int i=sum;i>=0;i--)
        if(dp[i]<=w){
            cout<<i<<"\n";
            break;
        }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <unordered_set>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    unordered_set<char> s;
    for(int i = 0; i < n; ++i){
        char c;
        cin >> c;
        s.insert(c);
    }
    if(s.size() == 3){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)




int main() {
  
  ll A, B, K;
  cin >> A >> B >> K;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));
  if (K <= A) cout << A - K << " " << B << endl;
  else if(K <= (A+B))  cout << 0 << " " << (A+B) - K << endl;
  else cout << 0 << " " << 0 << endl;
  

  return 0;
}


Measured memory_bytes: 3632
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

INF = pow(10, 15)

def main():
  n, m = map(int, input().split())
  edges = [[] for _ in range(n)]
  for _ in range(m):
    u, v = map(int, input().split())
    edges[u-1].append(v-1)

  dd = [[INF, INF, INF] for _ in range(n)]
  visited = [[False, False, False] for _ in range(n)]
  s, t = map(int, input().split())
  s -= 1
  t -= 1
  dd[s] = [0,0,0]
  q = [(0, s)]
  ans = -1
  while q:
    d, v = heappop(q)
    if visited[v][d%3]:
      continue
    visited[v][d%3] = True
    if v == t and d % 3 == 0:
      ans = d // 3
      break
    to_d = d + 1
    for to_v in edges[v]:
      if visited[to_v][to_d % 3]:
        continue
      heappush(q, (to_d, to_v))
  print(ans)

if __name__ == '__main__':
  main()


Measured memory_bytes: 38516
/*
 * to compile
 * g++ -std=c++11 two.cpp -o two
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int n, l;
	vector<string> v;

	cin >> n >> l;

	for(int i=0; i<n; i++) {
		string s;
		cin >> s;
		v.push_back(s);
	}

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

	for(auto s : v) {
		cout << s;
	}
	cout << endl;

	return 0;
}


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

int n,w;
int nep[110100];

main()
{
	nep[0]=1;
    scanf("%d %d",&n,&w);
    for(int i=1;i<100100;i++)
    	nep[i]=2e9;
    for(int i=0;i<n;i++)
    {
    	int a,b;
    	scanf("%d %d",&a,&b);
    	for(int j=100010;j>=0;j--)
    	{
    		if(nep[j]!=2e9&&nep[j]+a<=w+1)
    		{
    			if(j==0)
    			nep[j+b]=min(nep[j+b],a);
    			else
    			nep[j+b]=min(nep[j+b],nep[j]+a);
			}
		}
	}
	for(int i=100010;i>=0;i--)
	{
		if(nep[i]<=w)
		{
			printf("%d",i);
			return 0;
		}
	}
}


Measured memory_bytes: 640
s = input()
n = len(s)
odd = {'R','U','D'}
even = {'L','U','D'}

cnt = 0

for i in range(n):
  if i % 2 == 0 and s[i] in odd:
    cnt += 1
  elif i % 2 == 1 and s[i] in even:
    cnt += 1
    
print('Yes' if cnt == n else 'No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int n;
  
  cin >> n;
  vector<int>a(n);
  rep(i,n){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  vector<int>b(n);
  rep(i,n){
    if(i%2==0){
      b.at(i)=a.at(i/2);
    }
    else{
      b.at(i)=a.at(n-(i+1)/2);
    }
  }
  long ans=0;
  rep(i,n-1){
    ans+=abs(b.at(i+1)-b.at(i));
  }
  if(n%2==0){
    ans+=abs(b.at(n-2)-b.at(0));
  }
  else{
    ans+=abs(b.at(n-3)-b.at(0));
  }
  
  reverse(a.begin(),a.end());
  vector<int>c(n);
  rep(i,n){
    if(i%2==0){
      c.at(i)=a.at(i/2);
    }
    else{
      c.at(i)=a.at(n-(i+1)/2);
    }
  }
  long ans2=0;
  rep(i,n-1){
    ans2+=abs(c.at(i+1)-c.at(i));
  }
  if(n%2==0){
    ans2+=abs(c.at(n-2)-c.at(0));
  }
  else{
    ans2+=abs(c.at(n-3)-c.at(0));
  }
  cout<<max(ans,ans2)<<endl; 
}

Measured memory_bytes: 1408
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int d = a / b;
		int r = a % b;
		double f = (double)a / b;
		System.out.println(d + " " + r + " " + BigDecimal.valueOf(f).toPlainString());

	}

}

Measured memory_bytes: 26456
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace B {
    class Program {
        static void Main (string[] args) {
            int n = int.Parse (Console.ReadLine ());
            int[] p = Console.ReadLine ().Split ().Select (t => int.Parse (t)).ToArray ();
            int result = 0;

            for (int i = 0; i < n - 2; i++) {
                if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])) result++;
            }
            Console.WriteLine (result);
        }
    }
}

Measured memory_bytes: 13268
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
import queue
 
 
N = int(input())
S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
 
ch = False
ans = 0
bl  = 0
b_total = []
w_total = []
tot = 0
for s in S:
	b_total.append(tot)
	if s == "#":
		tot += 1
tot = 0
for s in S:
	if s == ".":
		tot += 1
	w_total.append(tot)
ans = 100000000
for i in range(len(S)):
	ans = min(ans,b_total[i]+w_total[-1]-w_total[i])
print(ans)

Measured memory_bytes: 15968
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,a,b;
    cin>>n>>a>>b;
    
    cout<<min(a*n,b);
    
    
    
   
    
    
    return 0;
}

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

int main()
{
    int cnt[2] = {0, 0};
    string s;
    cin >> s;
    for (auto &ch : s) {
        ++cnt[ch - 'A'];
    }
    int num = 0;
    if (cnt[0]) {
        ++num;
    }
    if (cnt[1]) {
        ++num;
    }
    cout << ((num == 2) ? "Yes" : "No") << endl;
}

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();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int[] ans = new int[n];
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i + 1; j <= n; j++) {
                if (j <= x || i >= y) {
                    ans[j - i]++;
                    continue;
                }
                if (i <= x && j >= y) {
                    ans[j - i - (y - x - 1)]++;
                    continue;
                }
                int idx = Math.min(j - i, Math.abs(x - i) + 1 + Math.abs(y - j));
                ans[idx]++;
            }
        }
        for (int i = 1; i < n; i++) {
            System.out.println(ans[i]);
        }
    }

}


Measured memory_bytes: 22868
def main():
    import math
    import sys
    input = sys.stdin.readline

    n,k = map(int,input().split())
    a = sorted(list(map(int,input().split())))
    f = sorted(list(map(int,input().split())),reverse=True)
    check = []
    for i in range(n):
        check.append((a[i]*f[i],a[i],f[i]))

    def search(x):
        count = 0

        for i,j,k in check:
            if i > x:
                y = math.floor(x/k)
                count += j-y
        return count

    left = -1
    right = 10**12+2
    while right > left+1:
        mid = (right+left)//2
        if search(mid) > k:
            left = mid
        else:
            right = mid
    print(right)
if __name__ == "__main__":
    main()

Measured memory_bytes: 126924
//b.c B-Collatz Problem
#include<stdio.h>

int main(void){
    int s;
    scanf("%d",&s);

    int a[1000000];
    if(s ==1){
        printf("4\n");
        return 0;
    }else if(s==2){
        printf("4\n");
        return 0;
    }

    int i=0,num=0,ans;
    a[0] = s;
    while(1){
        if(a[i]%2==0){
            a[i+1] = a[i]/2;
        }else{
            a[i+1] = 3*a[i] + 1;
        }
        if(a[i]==4){
            num++;
            ans = i;
        }
        if(num==2){
            printf("%d\n",i+1);
            break;
        }
        i++;
    }
    return 0;

}

Measured memory_bytes: 128
def main():
    integar, length = [int(x) for x in input().split()]
    numbers = {int(x) for x in input().split()}
    for diff in range(101):
        aa = integar - diff
        bb = integar + diff
        if aa not in numbers:
            print(aa)
            return
        elif bb not in numbers:
            print(bb)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
char s[101],t[101];
int S[100]={0},T[100]={0},m,i,x,n;
scanf("%s %s",s,t);
for(m=0;s[m]!='\0';m++){
S[m]=s[m];
}
for(n=0;t[n]!='\0';n++){
T[n]=t[n];
}
sort(S,S+m);
sort(T,T+n,greater<int>());
for(i=0;i<100;i++){
x=S[i]-T[i];
if(x<0){printf("Yes");break;}
else if(x>0){printf("No");break;}
else if(x==0&&i!=99)continue;
else printf("No");
}
return 0;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int Cyf(int a)
{
    int x = 0;
    while (a != 0)
    {
        x += a % 10;
        a /= 10;
    }
    return x;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int odp = 100000;
    for (int a = 1; a <= n; ++a)
    {
        int b = n - a;
        if (b > 0)
            odp = min(odp, Cyf(a) + Cyf(b));
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
N, T = map(int, input().split())
c = [0] * N
t = [0] * N
for i in range(N): c[i], t[i] = map(int, input().split())
idx = []
ans = 1000
for i in t:
    if i <= T:
        idx.append(t.index(i))
if len(idx) == 0:
    print("TLE")
    exit()
else:
    for i in idx:
        if ans > c[i]:
            ans = c[i]
print(ans)

Measured memory_bytes: 3064
A,B,K = map(int,input().split())

def give_cookie(x,y):
    if x % 2 != 0:
        x -= 1
    x /= 2
    y += x
    return x,y

for i in range(K):
    if i % 2 == 0:
        A,B = give_cookie(A,B)
    else:
        B,A = give_cookie(B,A)

print(int(A),int(B))

Measured memory_bytes: 3064