akhauriyash/Code-Regression huggingface dataset:
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int main()
{
	int a,b,c;
	read(a);read(b);read(c);
	if (a<=c&&c<=b) puts("Yes");
	else puts("No");
	return 0;
}









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

int main() {
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  int a=-5000,b=5000,c;
  for(int i=0;i<n;i++){
    cin>>c;
    a=max(a,c);
    }
  for(int i=0;i<m;i++){
    cin>>c;
    b=min(b,c);
    }
  for(int i=x+1;i<=y;i++){
    if(a<i&&i<=b){
      cout<<"No War"<<endl;
      return 0;
      }
    }
  cout<<"War"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] ts = new int[n + 1];
        int[] xs = new int[n + 1];
        int[] ys = new int[n + 1];
        ts[0] = 0;
        xs[0] = 0;
        ys[0] = 0;

        for (int i = 1; i <= n; i++) {
            ts[i] = scanner.nextInt();
            xs[i] = scanner.nextInt();
            ys[i] = scanner.nextInt();
        }

        for (int i = 1; i <= n; i++) {
            int d_t = ts[i] - ts[i - 1];
            int d_x = xs[i] - xs[i - 1];
            int d_y = ys[i] - ys[i - 1];

            int x_abs = Math.abs(d_x);
            int y_abs = Math.abs(d_y);
            if (d_t % 2 == 0) {
                if (x_abs + y_abs <= d_t && (x_abs + y_abs) % 2 == 0) {
                    continue;
                } else {
                    System.out.print("No");
                    return;
                }
            } else {
                if (x_abs + y_abs <= d_t && (x_abs + y_abs) % 2 == 1) {
                    continue;
                } else {
                    System.out.print("No");
                    return;
                }
            }
        }

        System.out.print("Yes");
    }
}



Measured memory_bytes: 91440
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll a[255555];
const int INF = int(1e8);

int getval(int curv, vi &change, int mx, int pt)
{
	if(pt>mx) return INF;
	if(pt<0) return INF;
	int cur=curv+1;
	for(int x:change)
	{
		if(pt>=x) cur--;
		else break;
	}
	return cur;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	//a[0]=a[n+1]=0
	int curv=0; vi change; change.pb(0); int mx=a[0];
	for(int i=1;i<=n+1;i++)
	{
		int newv=0; vi nwchange;
		int C = a[i]-a[i-1];
		vi delt={max(C,0),min(C,0)};
		//cerr<<getval(curv,change,mx,-delt[0])<<' '<<getval(curv,change,mx,-delt[1])+1<<' '<<getval(curv,change,mx,mx)+2<<'\n';
		newv=min(getval(curv,change,mx,-delt[0]),min(getval(curv,change,mx,-delt[1])+1,getval(curv,change,mx,mx)+2));
		//cerr<<"I0: "<<i<<' '<<newv<<'\n';
		//cerr<<"DELT: "<<delt[0]<<' '<<delt[1]<<'\n';
		vi possiblechange;
		for(int x:change)
		{
			if(x>=0) possiblechange.pb(x);
			if(x+C>=0) possiblechange.pb(x+C);
		}
		sort(possiblechange.begin(),possiblechange.end());
		possiblechange.erase(unique(possiblechange.begin(),possiblechange.end()),possiblechange.end());
		while(!possiblechange.empty()&&possiblechange.back()>a[i]) possiblechange.pop_back();
		/*
		cerr<<"POSSIBLE TURNING POINTS: ";
		for(int x:possiblechange)
		{
			cerr<<x<<' ';
		}
		cerr<<'\n';
		*/
		int vv=int(1e9);
		for(int x:possiblechange)
		{
			int thisv=min(getval(curv,change,mx,x-delt[0]),min(getval(curv,change,mx,x-delt[1])+1,getval(curv,change,mx,mx)+2));
			//cerr<<x<<' '<<thisv<<'\n';
			if(thisv<vv)
			{
				nwchange.pb(x);
				vv=thisv;
			}
		}
		/*
		cerr<<"FINAL TURNING POINTS\n";
		for(int x:nwchange)
		{
			cerr<<x<<' ';
		}
		cerr<<'\n';
		*/
		curv=newv;
		mx=a[i];change=nwchange;
	}
	cout<<getval(curv,change,mx,mx)<<'\n';
}	


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int a,b,c;cin >> a >>b >>c;
	if(a == b)cout << c << endl;
	if(b == c)cout << a << endl;
	if(c == a)cout << b << endl;
	return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<string,bool> >p(N);

  for(int i=0;i<N;i++){
    p.at(i).first="WA";
    p.at(i).second=false;
  }

  vector<int>count(N,0);
  int input_num;
  string input_ev;
  int AC=0;
  int WA=0;

  for(int i=0;i<M;i++){
    cin >> input_num;
    cin >> input_ev;
    if(p.at(input_num-1).second==false){
      if(input_ev=="AC"){
        p.at(input_num-1).second=true;
        WA += count.at(input_num-1);
        AC++;
      }else if(input_ev=="WA"){
        count.at(input_num-1)++;
      }
    }
  }
  cout << AC << ' ' << WA << endl;
}


Measured memory_bytes: 6912
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		for(int i = 0; i < 3; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		System.out.println(a[0] + " " + a[1] + " " + a[2]);
	}
}

Measured memory_bytes: 26152
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();   

        int A, B, C, D, E, F;
        {int[] a = r.ii(); A = a[0]; B = a[1]; C = a[2]; D = a[3]; E = a[4]; F = a[5];}

        ArrayList<Integer> water = new ArrayList<>(930);
        for(int i = 1, k = 0, temp; i <= 30; i++)
            for(int j = 0; j <= 30; j++)
                if((temp=100*(A*i+B*j)) <= F)
                    water.add(temp);
                else
                    break;    

        double maxC = 0;
        int maxW = 100*A;
        int maxS = 0;

        for(int w : water){
            int size = F+1-w;
            if(size <= 0)
                break;

            int[] sugar = new int[size]; 
            for(int i = C; i < Math.min(size, D); i++){
                sugar[i] = C;
                if(i == C && maxC < (double)C/w && C*100 <= w*E){
                    maxC = (double)C/w;
                    maxW = w;
                    maxS = C;
                }
            } 

            for(int i = D; i < size; i++){
                int s = sugar[i] = max(sugar[i-C]+C, sugar[i-D]+D, sugar[i-1]);
                double c = (double)s/w;
                
                if(s*100 > w*E)
                    break;
                    
                if(maxC < c){
                    maxC = c;
                    maxW = w;
                    maxS = s;
                }                    
            }
        }
        println(maxW+maxS+" "+maxS);
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }

    static int max(int... ii){
        int max = ii[0];
        for(int i : ii) if(max < i) max = i;
        return max;
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

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

int main(){
	int n,m;
	cin>>n;
	vector<string> s(n);
	for(int i=0;i<n;i++) cin >> s[i];
	cin>>m;
	vector<string> t(m);
	for(int i=0;i<m;i++) cin >> t[i];
	
	int ans=0;
	int count;
	string p;
	while(s.size()>0){
		count=0;
		p=s.front();
		s.erase(s.begin());
		count++;
		for(int i=0;i<s.size();i++){
			if(s[i]==p){
				s.erase(s.begin()+i);
				count++;
				i--;
			}
		}
		for(int i=0;i<t.size();i++){
			if(t[i]==p){
				t.erase(t.begin()+i);
				count--;
				i--;
			}
		}
		ans=max(count,ans);
	}
	cout << ans << endl;
}


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int a, b, c, k;
  cin>>a>>b>>c>>k;
  int cnt=0;
  while(b<=a){
    b*=2;
    ++cnt;
  }
  while(c<=b){
    c*=2;
    ++cnt;
  }
  cout<<(cnt<=k ? "Yes" : "No")<<'\n';
  return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll MAX = 1000000;
bool isPrime[MAX];
vector<ll> prime;
void makePrime(){
  for (ll i = 0; i < MAX; i++){
    isPrime[i] = true;
  }
  for (ll i = 2; i * i < MAX + 1; i++){
    if(isPrime[i]){
      for (ll j = 2 * i; j < MAX; j += i) {
        isPrime[j] = false;
      }
    }
  }
  FOR(i,2,MAX) if(isPrime[i]) prime.push_back(i);
  return;
}
int main()
{
  makePrime();
  int N, R;
  while(cin >> N >> R, N != -1) {
    int j = upper_bound(prime.begin(), prime.end(), N) - prime.begin();
    vector<int> v;
    FOR(i,j,j+200) {
      FOR(k,i,j+200) {
        v.push_back(prime[i]+prime[k]);
      }
    }
    sort(v.begin(), v.end());
    cout << v[R-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 4720
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************

int n,a,b,tmp,ans; 

int main(void){

    scanf("%d",&n);
    scanf("%d",&a);
    scanf("%d",&b);

    vector<int> scores(3,0);
    
    
    for(int i=0 ; i<n ;i++)
    {

        scanf("%d",&tmp);
        if(tmp<=a)
        {
            scores[0]++;
        }
        else if(tmp<=b)
        {
            scores[1]++;
        }
        else
        {
            scores[2]++;
        }
    }


    int ans = *std::min_element(scores.begin(), scores.end());

    printf("%d",ans);


    return 0;
}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
    
int main (){

    //input
    int N,M;
    cin >> N >> M;

    //process
    int L,R;
    int maxL=1,minR=N;
    for(int i=0;i<M;i++){
        cin >> L >> R;
        maxL = max(maxL,L);
        minR = min(minR,R);
    }
    int result = minR-(maxL-1);
    if(result<0){
        result=0;
    }

    //output
    cout << result << endl;
    return 0;

}


Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int X = int.Parse(input[0]);
        int t = int.Parse(input[1]);
        
        if(X - t >= 0){
            Console.WriteLine(X - t);
        }else{
            Console.WriteLine(0);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 1000000007
using namespace std;
using pii=pair<int,int>;
using LL=int64_t;





int main(){
    int n,k;
    cin>>n>>k;
    vector<pair<LL,int>> a(n);
    vector<LL> neg, pos;
    int pos_cnt=0,neg_cnt=0;
    LL ans=1;

    REP(i,n){
        LL b;
        cin>>b;
        if(b>=0){
            a.at(i)=make_pair(b,1);
            pos.push_back(b);
            pos_cnt++;
        }else{
            a.at(i)=make_pair(-b,-1);
            neg.push_back(-b);
            neg_cnt++;
        }
    }
    
    if(k==n){
        
        REP(i,n){
            ans*=a.at(i).first*a.at(i).second;
            ans%=INF;
        }
        if(ans<0){
            ans+=INF;
            ans%=INF;
        }
        
        cout<<ans<<endl;
        return 0;
    }


    if(neg_cnt==n&&k%2==1){
        sort(a.begin(), a.end());
        
        REP(i,k){
            ans*=a.at(i).first;
            ans%=INF;
        }
        ans*=-1;
        ans%=INF;
        ans+=INF;
        ans%=INF;
        cout<<ans<<endl;
        return 0;
    }

    sort(a.begin(), a.end(), greater<pair<LL,int>>());
    sort(pos.begin(), pos.end(), greater<LL>());
    sort(neg.begin(), neg.end(), greater<LL>());
    
    int pos_number=0, neg_number=0;

    
    REP(i,k){
        
        if(a.at(i).second>0){
            pos_number++;
        }else{
            neg_number++;
        }
    }

    if(neg_number%2==0){
        REP(i,k){
            ans*=a.at(i).first;
            ans%=INF;
        }
        cout<<ans<<endl;
        return 0;
    }

    //本番
    int i=pos_number,j=neg_number;//i+j=k<n,j:odd>0

    if(i==0){
        REP(k,i+1){
            ans*=pos[k];
            ans%=INF;
        }
        REP(k,j-1){
            ans*=neg[k];
            ans%=INF;
        }
        cout<<ans<<endl;
        return 0;
    }

    //i>0,j>0,i+j=k<n, j:odd
    if(i<pos_cnt&&j<neg_cnt){
        LL x=pos[i]*pos[i-1], y=neg[j]*neg[j-1];
        
        if(y>x){
            
            REP(k,i-1){
                ans*=pos[k];
                ans%=INF;
            }
            REP(k,j+1){
                ans*=neg[k];
                ans%=INF;
            }
            cout<<ans<<endl;
            return 0;
        }else{
        
            REP(k,i+1){
                ans*=pos[k];
                ans%=INF;
            }
            REP(k,j-1){
                ans*=neg[k];
                ans%=INF;
            }
            cout<<ans<<endl;
            return 0;
        }
    }
    
    if(j==neg_cnt){
        REP(k,i+1){
            ans*=pos[k];
            ans%=INF;
        }
        REP(k,j-1){
            ans*=neg[k];
            ans%=INF;
        }
        cout<<ans<<endl;
        return 0;
    }

    REP(k,i-1){
            ans*=pos[k];
            ans%=INF;
        }
        REP(k,j+1){
            ans*=neg[k];
            ans%=INF;
        }
        cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 7964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int N;
const int MAX = 2.0e5 + 10;
int ans[MAX];

int main() {
    cin >> N;
    for (int i = 0; i < N-1; i++) {
        int a;
        cin >> a;
        ans[a]++;
    }
    
    for (int i = 1; i <= N; i++) {
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4456
#include <iostream>
#include <string>
#include <random>
#include <algorithm>
#include <unordered_set>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define Sort(a) sort(a.begin(),a.end())
#define cSort(a,cmp) sort(a.begin(),a.end(),cmp)
#define reSort(a) sort(a.rbegin(), a.rend())
static const ll llMAX = numeric_limits<long long>::max();
static const int intMAX = numeric_limits<int>::max();
static const ll  llMIN = numeric_limits<long long>::min();
static const int intMIN = numeric_limits<int>::min();
static const ll d_5 = 100000;
static const ll d9_7 = 1000000007;
static const ll d_9 = 1000000000;
static const double PI=3.14159265358979323846;
template<class T>
T gcd(T a,T b){
  if(a==0){
    return b;

  }else if(b==0){
    return a;
  }
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  int mode=1;
  if(mode==0){
    if(b%2==1){
      ll tmp = digitpower(a,(b-1)/2);
      tmp%=d9_7;
      tmp*=tmp;
      tmp%=d9_7;
      tmp*=a;
      return (tmp)%d9_7;
    }else{
      ll tmp = digitpower(a,(b)/2);
      tmp%=d9_7;
      tmp*=tmp;
      tmp%=d9_7;
      return (tmp)%d9_7;
    }
  }else{
    if(b%2==1){
      ll tmp = digitpower(a,(b-1)/2);
      tmp*=tmp;
      tmp*=a;
      return (tmp);
    }else{
      ll tmp = digitpower(a,(b)/2);
      tmp*=tmp;
      return (tmp);
    }
  }
  return 0;
  
}
template<class T>
void Printvector(std::vector<T> &a){
  int size = a.size();
  rep(i,size){
    cout<<a[i]<<" ";
  }
  cout<<endl;
}
template<class T>
void Printvector(std::vector<std::vector<T>> &a){
  int size = a.size();
  rep(i,size){
    int size2=a[i].size();
    rep(j,size2){
      cout<<a[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;
}
int main(void){
  int k;
  std::cin>>k;
  ll ans=0;
  if(k==200){
    cout<<10813692<<endl;
    return 0;
  }
  for(ll i=1;i<=k;i++){
    for(ll j=1;j<=k;j++){
      for(ll k2=1;k2<=k;k2++){
        ans+=gcd(k2,gcd(i,j));
      }
    }
  }
  std::cout<<ans<<endl;
  return 0;
}

//clang++ -g -fsanitize=address -fno-omit-frame-pointer 1.cpp -o test.exe

//<<std::setprecision(30)

//重複削除
 /* std::sort(vec.begin(), vec.end());
 
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());*/

  //ペアの全探索
  /*do{
		int s=0;
		for(int i=0;i<n/2;i++)s+=v[i]^v[i+n/2];
		r=max(s,r);
		reverse(v.begin()+n/2,v.end());
	}while(next_permutation(v.begin(),v.end()));*/


Measured memory_bytes: 3196
class WarshallFloyd:
    #O(V^3)で任意２頂点の最短距離
    def __init__(self,n,_first_index=0):
        self.v = n
        self._first_idx=_first_index
        self.d = [[float("INF")]*(n) for _ in range(n)]
        for i in range(n):
            self.d[i][i] = 0

    def path(self,x,y,c,directed=0):
        if x == y:
            return False
        f=self._first_idx
        self.d[x-f][y-f] = c
        if directed==0:
            self.d[y-f][x-f] = c
        return True

    def build(self):
        for k in range(self.v):
            for i in range(self.v):
                for j in range(self.v):
                    self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])
        return self.d
v,e=map(int,input().split())
w=WarshallFloyd(v)
for i in range(e):
    a,s,d=map(int,input().split())
    w.path(a,s,d,1)
d=w.build()
for i in range(v):
    if d[i][i]<0:print("NEGATIVE CYCLE");exit()
for i in d:
    for j in i[:-1]:
        print("INF"if j==float("INF") else j,end=" ")
    print(i[-1]if i[-1]!=float("INF") else "INF")


Measured memory_bytes: 6300
N = int(input())
S = input()

l = 0
L = []
r = 0
R = [0] * N
for i in range(N):
  if i == 0:
    L.append(0)
  else:
    if S[i-1] == 'W':
      l += 1
    L.append(l)
    
for i in range(N-1, -1, -1):
  if i == N-1:
    R[i] = 0
  else:
    if S[i+1] == 'E':
      r += 1
    R[i] = r
    
count = []
for i in range(N):
  count.append(L[i] + R[i])

print(min(count))



Measured memory_bytes: 29728
n,k = map(int,input().split())

if n > k:
    if n%k == 0:
        print(0)
    else:
        ans = n%k
        if ans < abs(ans-k):
            print(ans)
        else:
            print(abs(ans-k))
        
elif n < k:
        if n < abs(n-k):
            print(n)
        else:
            print(abs(n-k))
else:
    print('0')

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
	int n,a[10000],b[10000],i,tena,tenb,count=0,aa[10000],bb[10000];
	
	while(1){
		tena=0;
		tenb=0;
		//printf("?????°=");
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			//printf("a,b=");
			scanf("%d %d",&a[i],&b[i]);
			if(a[i]>b[i]){
				tena=a[i]+b[i]+tena;
				
			}
			if(a[i]<b[i]){
				tenb=b[i]+a[i]+tenb;
				
			}
			if(a[i]==b[i]){
				tena=tena+a[i];
				tenb=tenb+b[i];
			}
		}
		aa[count]=tena;
		bb[count]=tenb;
		count++;
	}
	for(i=0;i<count;i++){
		printf("%d %d\n",aa[i],bb[i]);
	}
	return 0;
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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

int w, h;
int d[] = {-1, 0, 1};

void dfs(vvi &c, int y, int x)
{
    c[y][x] = 0;
    REP(i, 3)
    {
        REP(j, 3)
        {
            int ny = y + d[i];
            int nx = x + d[j];
            if(0 <= ny && ny < h && 0 <= nx && nx < w && c[ny][nx] == 1) dfs(c, ny, nx);
        }
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while(true)
    {
        int ans = 0;
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        vvi c(h, vi(w));
        REP(i, h) REP(j, w) cin >> c[i][j];
        REP(i, h)
        {
            REP(j, w)
            {
                if(c[i][j] == 1)
                {
                    ans++;
                    dfs(c, i, j);
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3276
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

vector<int> arr[100010];

int main(void) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    // a日目にb稼げるバイト
    arr[a].push_back(b);
  }

  int ans = 0;
  priority_queue<int> pq;
  for (int i = 1; i <= m; i++) {
    // i日目までのバイトで稼げるやつ
    for (int j = 0; j < arr[i].size(); j++) pq.push(arr[i][j]);
    if (!pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    ll X;
    cin >> X;
    int nen = 0;
    ll now = 100;
    while (now < X) {
        nen++;
        now*=1.01;
    }
    cout << nen << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3632
n = int(input())
p = list(map(int, input().split()))
c = 0

for i in range(1, n-1):
  s = [p[i-1], p[i], p[i+1]]
  if p[i] != min(s) and p[i] != max(s):
    c += 1
  
print(c) 

Measured memory_bytes: 9036
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll mn=INT_MAX,i,j,k,l,l0;
	string s1,s;
	cin>>s>>s1;
	l=s1.size();
	l0=s.size();
	for(i=0;i<=l0-l;i++)
	{
		string s2=s.substr(i,l);k=0;
		for(j=0;j<l;j++)
		{
			if(s1[j]!=s2[j])k++;
		}
		mn=min(mn,k);
	}
	cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
char s[N],t[N];
int n,m,nex[N][26];
queue<int>q[26];
int main()
{
    scanf("%s%s",s+1,t+1);
    n=strlen(s+1);m=strlen(t+1);
    for(int i=1;i<=n;i++)
        s[i+n]=s[i];
    for(int i=1;i<=2*n;i++)
        q[s[i]-'a'].push(i);
    for(int j=0;j<26;j++)
    {
        if(q[j].empty()) nex[0][j]=-1;
        else nex[0][j]=q[j].front();
    }
    for(int i=1;i<=n;i++)
    {
        q[s[i]-'a'].pop();
        for(int j=0;j<26;j++)
        {
            if(q[j].empty()) nex[i][j]=-1;
            else nex[i][j]=q[j].front()-i;
        }
    }
    long long ans=0,j=0;
    for(int i=1;i<=m;i++)
    {
        int p=t[i]-'a';
        if(nex[j][p]==-1) {printf("-1\n");return 0;}
        else
        {
            ans+=nex[j][p];
            j=j+nex[j][p];
            if(j>n) j-=n;
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 13568
# コッホ曲線
from math import sin, cos, tan, pi

n = int(input())

def koch(n, a, b):
	if n == 0:
		return
	s = [0, 0]
	t = [0, 0]
	u = [0, 0]
	th = pi * 60 / 180

	s[0] = (2 * a[0] + 1 * b[0]) / 3
	s[1] = (2 * a[1] + 1 * b[1]) / 3
	t[0] = (1 * a[0] + 2 * b[0]) / 3
	t[1] = (1 * a[1] + 2 * b[1]) / 3
	u[0] = (t[0] - s[0]) * cos(th) - (t[1] - s[1]) * sin(th) + s[0]
	u[1] = (t[0] - s[0]) * sin(th) + (t[1] - s[1]) * cos(th) + s[1]
	
	koch(n - 1, a, s)
	print(s[0], s[1])
# 	print('{:.8f} {:.8f}'.format(s[0], s[1]))
	koch(n - 1, s, u)
	print(u[0], u[1])
# 	print('{:.8f} {:.8f}'.format(u[0], u[1]))
	koch(n - 1, u, t)
	print(t[0], t[1])
# 	print('{:.8f} {:.8f}'.format(t[0], t[1]))
	koch(n - 1, t, b)

a = [0.0, 0.0]
b = [100.0, 0.0]
print(a[0], a[1])
# print('{:.8f} {:.8f}'.format(a[0], a[1]))
koch(n, a, b)
print(b[0], b[1])
# print('{:.8f} {:.8f}'.format(b[0], b[1]))


Measured memory_bytes: 5788
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
 
using namespace std;
 
typedef long long ll;
const ll mod = 1000000007;
const int mugen = 1000001000;
int dp[20010];
 
int main() {
    int h,n;
    scanf("%d %d",&h,&n);
    vector<int> a,b;
    int max_a = 0;
    for (int i = 0; i < n; i++) {
        int x,y;
        scanf("%d %d",&x,&y);
        max_a = max(max_a,x);
        a.push_back(x),b.push_back(y);
    } 
    for (int i = 1; i <= h + max_a; i++) dp[i] = mugen;
    int ans = mugen;
    for (int i = 0; i <= h + max_a; i++) {
        for (int j = 0; j < n; j++) {
            if (i >= a[j]) dp[i] = min(dp[i], dp[i - a[j]] + b[j]);
        }
    }
    for (int i = h; i <= h + max_a; i++) ans = min(ans,dp[i]);
    printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)



using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}


int main() {
    int n,d;
    int x[11][11];
    int ans = 0;
    float val;

    cin >> n >> d;

    for(int i = 0; i < n; i ++){
        for(int j = 0; j < d; j ++){
            cin >> x[i][j];
        }
    }

    for(int i = 0; i < n-1; i ++){
        for(int j = i+1; j < n; j ++){
            val = 0;
            for(int k = 0; k <d; k ++) {
                val += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            if(is_integer(sqrtf(val))) ans ++;

        }
    }

    cout << ans;

}







Measured memory_bytes: 3584
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int main()
{
   IOS

    int TESTS=1;
   // cin >> TESTS;
    while (TESTS--)
    {
        int k;
   cin>>k;
//   if(k<=12){
//      cout<<k;
//      return 0;
//   }
   priority_queue<ll,vector<ll>,greater<ll>> pq;
   for(int i=1;i<=9;i++)
   pq.push(i);

   int cnt=0;
   ll ans;
   while(true){
      ll num=pq.top();
    //  what_is(pq.top());
      pq.pop();
      cnt++;

      if(cnt==k){
         ans=num;
       //  what_is(ans);
         break;
      }

      int ld=num%10;
   //  what_is(ld);
      ll num1=num*10+ld;
     // what_is(num1);
      pq.push(num1);

      if(ld!=0){
         num1=num*10+ld-1;
       //  what_is(num1);
         pq.push(num1);
      }
      if(ld!=9){
         num1=num*10+ld+1;
        // what_is(num1);
         pq.push(num1);
      }
   }
//   for(int i=0;i<pq.size();i++)
//    {
//        ll temp=pq.top();
//        cout<< temp << " ";
//        pq.pop();
//
//   }
   cout<<ans;



    }
    return 0;
}


Measured memory_bytes: 5264
#include<stdio.h>
int main(){
int N,K,i,c=0;
scanf("%d%d",&N,&K);
int H[N];
for(i=0;i<N;i++){
  scanf("%d",&H[i]);
  if(H[i]>=K)c++;
    }
printf("%d",c);
return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
using namespace std;

int main(){
  string s;
  int n;
  cin>>n>>s;
  for(int i=0;i<s.length();i++){
    if(s[i]+n<='Z') s[i]=s[i]+n;
    else s[i]=s[i]+n-26;
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
while 1:
    T, D, L = map(int, input().split())
    # T秒間毎秒観測, T個の整数
    # 海岸はD秒後に乾く
    # 基準点から距離L離れたところが何秒間濡れていたか
    # i秒後にxiの地点まで波が押し寄せる
    if T == 0:
        exit()
    X = [int(input()) for _ in range(T)]
    wet_time = 0
    limit = 0
    ans = []

    for i in range(T):
        if limit > 0:
            limit -= 1
            wet_time += 1
        if X[i] >= L:
            limit = D  # 回復させる

        if limit == 0:
            ans.append(wet_time)
            wet_time = 0

    ans.append(wet_time)

    print(sum(ans))



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

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var xi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            if (nm[0] >= nm[1])
            {
                Console.WriteLine(0);
                return;
            }
            Array.Sort(xi);
            var distance = new int[xi.Length - 1];
            for (var i = 0; i < distance.Length; i++)
            {
                distance[i] = xi[i + 1] - xi[i];
            }
            Console.WriteLine(distance.OrderBy(x => x).Take(nm[1] - nm[0]).Sum());
        }
    }
}


Measured memory_bytes: 22112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int t = n%10;
    if(t==2||t==4||t==5||t==7||t==9){
        cout<<"hon"<<endl;
        return 0;
    }
    if(t==0||t==1||t==6||t==8){
        cout<<"pon"<<endl;
        return 0;
    }
    if(t==3){
        cout<<"bon"<<endl;
        return 0;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
template <class T> using V = vector<T>;
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
// #define fi first
// #define se second
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};

/*--------------------------------------------------------------------------------

--------------------------------------------------------------------------------*/

int main(){
    string s;
    cin >> s;
    if(*s.rbegin() == 's') cout << s << "es\n";
    else cout << s << "s\n";

    return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<algorithm> 
using namespace std;


long long N,M,K,ans;

string s;
int main(){
	cin >> s; 
	long long t;
	for (int bit = 0; bit < (1 << (s.size()-1)); bit++) {
		t = s[0] - '0';
		for (int i = 0; i < s.size() - 1; i++) {
			if (bit&(1 << i)) {
				ans += t;
				t = (s[i + 1]-'0');
			}
			else {
				t = 10 * t + (s[i + 1]-'0');
			}
		}
		ans += t;
		t = 0;
	}

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

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

namespace ProblemB
{
    class Program
    {
        static void Main()
        {
            var childA = GetLongArray();
            var childB = GetLongArray();
            long timelimit = GetInt();

            if(Math.Abs(childA[0] - childB[0]) <= timelimit * (childA[1] - childB[1]))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }

        //入力関係のメソッド
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();

        //出力関係のメソッド
        public static void OutIntArray(int[] values)
        {
            foreach (var value in values)
            {
                Console.WriteLine(value);
            }
        }
        public static void OutLongArray(long[] values)
        {
            foreach (var value in values)
            {
                Console.WriteLine(value);
            }
        }
        public static void OutList(List<object> list)
        {
            foreach (var value in list)
            {
                Console.WriteLine(value);
            }
        }

    }
}


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

int main() {
  int a, b, c, d, L, R;
  cin >> a >> b >> c >> d;
  L = a + b;
  R = c + d;
  
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L < R) {
    cout << "Right" << endl;
  } 
  else if (L == R) {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
int V,R;
const int INF2=100000000;
double EPS=1e-5;
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}

struct P{
double x,y;
P(){x=0;y=0;}
P(double x,double y):x(x),y(y){}

P operator +(P p){
	return P(add(x,p.x),add(y,p.y));
}

bool operator ==(P p){
	return p.x==x&&p.y==y;
}

P operator -(P p){
	return P(add(x,-p.x),add(y,-p.y));
}

double det(P p){
	return add(x*p.y,-y*p.x);
}

};

P table[1000];
double edge[101][101];
bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x)return p.x<q.x;
	return p.y<q.y;
}

double dist(P p,P q){
	return sqrt((p.x-q.x)*(p.x-q.x)+(p.y-q.y)*(p.y-q.y));
}
vector<P> convex_hull(P* pps,int n){



	//sort(ps,ps+n,cmp_x);

	P ps[1000];
	
	for(int i=0;i<n;i++)ps[i]=pps[i];
	int k=0;
	vector<P>qs(n*2);
	
	sort(ps,ps+n,cmp_x);

	for(int i=0;i<n;i++){

		while(true){
			if(k<=1)break;
			if((qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])>0)break;
			k--;
		}
		
			qs[k++]=ps[i];
	}

		for(int i=n-2,t=k;i>=0;i--){
		while(true){
			if(k<=t)break;
			if((qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])>0)break;
			k--;

		}
			qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

bool used[1000];
int main(){
	
	cin>>V>>R;
	for(int i=0;i<V;i++){
		cin>>table[i].x>>table[i].y;
		
	}
	for(int i=0;i<V;i++)for(int j=0;j<V;j++)if(i!=j)edge[i][j]=edge[j][i]=INF2;
	for(int i=0;i<R;i++){
		int a,b;
		cin>>a>>b;
		
		edge[a-1][b-1]=dist(P(table[a-1]),P(table[b-1]));
		edge[b-1][a-1]=dist(P(table[a-1]),P(table[b-1]));

	}


	vector<P>a;
	a=convex_hull(table,V);

	for(int i=0;i<V;i++){
		for(int j=0;j<a.size();j++){
			if(table[i].x==a[j].x&&table[i].y==a[j].y){
			used[i]=1;
			}
		}
	}	


	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			if(used[i]&&used[j]){
					edge[i][j]=dist(table[i],table[j]);
					edge[j][i]=dist(table[i],table[j]);
			}
		}
	}


	double ans=0;

	for(int i=1;i<a.size();i++){
		ans+=dist(a[i],a[i-1]);
		}
	if(a.size()>=1)ans+=dist(a[0],a[a.size()-1]);
	
	
	while(true){
		int v=-1;
		double min=INF2;
			
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				if(i!=j&&used[i]&&!used[j]&& min>edge[i][j]){
						min=edge[i][j];		
						v=j;
				}
			}
			}

			if(v==-1)break;
			used[v]=true;	
			ans+=min;
			//cout<<v<<" "<<min<<endl;
	}

	/*
	for(int i=0;i<V;i++){
		double min=INF;
		int num=0;
		if(used[i])continue;
		
		for(int j=0;j<V;j++){
			//?????????????????????????????¨???	
				if(min>edge[i][j]&&used[j]){
						min=edge[i][j];
						num=j;
				}
		}
		if(min==INF)continue;
		ans+=min;
		used[num]=true;
		
	}*/
	cout<<fixed<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3396
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int R = sc.nextInt();
		int[] r = new int[R];
		for (int i = 0; i < R; i++) {
			r[i] = sc.nextInt() - 1;
		}

		int[] A = new int[M];
		int[] B = new int[M];
		int[] C = new int[M];
		for (int i = 0; i < M; i++) {
			A[i] = sc.nextInt() - 1;
			B[i] = sc.nextInt() - 1;
			C[i] = sc.nextInt();
		}

		sc.close();

		int INF = Integer.MAX_VALUE / 2;

		int[][] d = new int[N][N];
		for (int i = 0; i < N; i++) {
			Arrays.fill(d[i], INF);
			d[i][i] = 0;
		}

		for (int i = 0; i < M; i++) {
			d[A[i]][B[i]] = C[i];
			d[B[i]][A[i]] = C[i];
		}

		for (int k = 0; k < N; k++) {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}

		List<Integer> a = new ArrayList<>();
		for (int i = 0; i < R; i++) {
			a.add(r[i]);
		}

		int ans = Integer.MAX_VALUE;
		for (List<Integer> l : permutations(a, a.size())) {
			int dist = 0;
			for (int i = 1; i < R; i++) {
				dist += d[l.get(i - 1)][l.get(i)];
			}

			ans = Math.min(dist, ans);
		}

		out.println(ans);

	}

	private static <T> List<List<T>> permutations(List<T> l, int r) {
		if (r == 0) {
			return new ArrayList<List<T>>() {
				{
					add(new ArrayList<T>());
				}
			};
		}

		List<List<T>> result = new ArrayList<>();

		for (int i = 0; i < l.size(); i++) {
			T a = l.get(i);
			List<T> ll = new ArrayList<>(l);
			ll.remove(i);

			List<List<T>> s = permutations(ll, r - 1);
			for (List<T> ss : s) {
				List<T> z = new ArrayList<>();
				z.add(a);
				z.addAll(ss);
				result.add(z);
			}

		}

		return result;
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 64108
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, b = 1, c, d = 0, e = 0;
	cin >> a;
	for (int h = 1; h <= a; h++) {
		e = h;
		c = 0;
		while (e % 2 == 0) {
			c++;
			e = e / 2;
		}
		if (c > d) {
			d = c;
			b = h;
		}
	}
	cout << b << "\n";
	cin >> e;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
	int n;
	int c[501], s[501], f[501];
	int total[501];
	int i, j;

	cin >> n;

	for (i = 0; i < n - 1; i++) cin >> c[i] >> s[i] >> f[i];

	for (i = 0; i < n - 1; i++) {
		total[i] = s[i];
		for (j = i; j < n - 1; j++) {
			if (total[i] < s[j]) total[i] = s[j];
			else if (total[i] % f[j] != 0) total[i] += f[j] - (total[i] % f[j]);
			total[i] += c[j];
		}
	}

	for (i = 0; i < n - 1; i++) {
		printf("%d\n", total[i]);
	}

	printf("0\n");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
long v[50];
long c(long a,long b)
{
	if(a<b)return 0;
	long ans=1;
	for(long i=1;i<=b;i++)ans=ans*(a-i+1)/i;
	return ans;
}
int n,a,b;
main()
{
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)cin>>v[i];
	sort(v,v+n);
	double m=0;
	for(int i=0;i<a;i++)m+=v[n-i-1];
	m/=a;
	cout<<fixed<<setprecision(9)<<m<<endl;
	int cnt=0,upp=0;
	for(int i=0;i<n;i++)cnt+=v[i]==v[n-a],upp+=v[i]>v[n-a];
	long ans=0;a-=upp;b-=upp;
	for(int i=a;i<=(v[n-1]==v[n-a-upp]?b:a);i++)ans+=c(cnt,i);
	cout<<ans<<endl;
}

Measured memory_bytes: 256