akhauriyash/Code-Regression huggingface dataset:
#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>>;

pair<int, int> sum1[101010], sum2[101010];

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  int q;
  cin >> q;
  map<pair<int, int>, int> eq;
  eq[make_pair(0, 0)] = eq[make_pair(1, 1)] = eq[make_pair(2, 2)] = 0;
  eq[make_pair(1, 0)] = eq[make_pair(0, 2)] = eq[make_pair(2, 1)] = 1;
  eq[make_pair(0, 1)] = eq[make_pair(2, 0)] = eq[make_pair(1, 2)] = 2;

  sum2[0] = sum1[0] = make_pair(0, 0);
  for (int i = 0; i < s.size(); i++) {
    sum1[i + 1] = sum1[i];
    if (s[i] == 'A') sum1[i + 1].first++;
    else sum1[i + 1].second++;
  }
  for (int i = 0; i < t.size(); i++) {
    sum2[i + 1] = sum2[i];
    if (t[i] == 'A') sum2[i + 1].first++;
    else sum2[i + 1].second++;
  }
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    c--;
    pair<int, int> v1 = make_pair((sum1[b].first - sum1[a].first) % 3, (sum1[b].second - sum1[a].second) % 3);
    pair<int, int> v2 = make_pair((sum2[d].first - sum2[c].first) % 3, (sum2[d].second - sum2[c].second) % 3);
    if (eq[v1] == eq[v2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 2512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

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

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

int main(){
	int N;
	cin >> N;
	vector<int> x;
	ll sum = 0;
	for(int i=1;i<=N;i++){
		int a;
		cin >> a;
		sum += a;
		if(a % 10 != 0) x.pb(a);
	}
	sort(x.begin(),x.end());
	if(sum % 10 != 0){
		cout << sum << "\n";
	}
	else{
		if(x.size())
		cout << sum - x[0] << "\n";
		else cout << 0 << "\n";
	}
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 100000

struct P{
    typedef int Type;
    
    Type x,y;
    
    P(Type X,Type Y){
        x = X;
        y = Y;
    }
    
    bool operator< (const P &B) const{
        return x==B.x ? y < B.y : x < B.x;
    }
};

/* ConvexHull(??????) */

bool ccw(P &base,P &A,P &B){
    //??´???????????????????????????
    //return (A.x-base.x)*(B.y-base.y) - (A.y-base.y)*(B.x-base.x) >= 0; //double?????? -EPS
    
    //??´?????????????????????
    return (A.x-base.x)*(B.y-base.y) - (A.y-base.y)*(B.x-base.x) > 0; //double?????? EPS
}

vector<P> ConvexHull(vector<P> s){
    vector<P> g;
    int n = (int)s.size();
    
    if(n<3) return s;
    
    sort(s.begin(),s.end());
    
    for(int i=0;i<n;i++){
        for(int m = (int)g.size();m>=2 && ccw(g[m-2],g[m-1],s[i]); m--){
            g.pop_back();
        }
        g.push_back(s[i]);
    }
    
    for(int i=n-2;i>=0;i--){
        for(int m = (int)g.size();m>=2 && ccw(g[m-2],g[m-1],s[i]); m--){
            g.pop_back();
        }
        g.push_back(s[i]);
    }
    
    reverse(g.begin(),g.end());
    g.pop_back();
    
    return g;
}

int main(){
    int n,x,y;
    int s=0,min_y=INF,min_x=INF;
    vector<P> point;
    vector<P> ans;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&x,&y);
        point.push_back(P(x,y));
    }
    
    ans = ConvexHull(point);
    int m = (int)ans.size();
    
    
    printf("%d\n",m);
    
    for(int i=0;i<m;i++){
        if(min_y > ans[i].y || (min_y==ans[i].y && min_x > ans[i].x)){
            min_y = ans[i].y;
            min_x = ans[i].x;
            s = i;
        }
    }
    
    for(int i=0;i<m;i++){
        printf("%d %d\n",ans[(s+i)%m].x,ans[(s+i)%m].y);
    }
    
    return 0;
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
	using namespace std;
	#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
	#define ll long long int


	int main()
	{
		FAST;
		//ll testcase;
		//cin>>testcase;
		//for(ll t=0;t<testcase;t++)
		{
			//use long long
			//donot memeset other than 0 or 1 or -1
			//segmentation fault-> check for uninitialized global variable or out of bounds
			//always check for bottle neck (whether original constraints can be reduced by introducing some condition)
			//dont rush to writing code think through the logic	
			int a[5];
			for(int i=0;i<5;i++)
				cin>>a[i];
			for(int i=0;i<5;i++)
			{
				if(a[i]==0)
				{
					cout<<i+1<<'\n';
					break;
				}
			}
			
			
		}
		return 0;
	}



































Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  long long  ans=0;
  long long N;
  long long tmp = 0;
  int flag =0;
  
  cin >> N;
  
  vector<long long > A(N),B(N);
  vector<pair<long ,long>> BA(N);
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
    BA[i] = make_pair(B[i], A[i]);
  }

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

  //  cout << " --- " << endl;

  for(int i = 0; i < N; i++){
    tmp += BA[i].second;

    if(tmp > BA[i].first){
      flag++;
    }
    
    //    cout << "BA[" << i << "].first = " << BA[i].first << "  ";
    //    cout << "BA[" << i << "].second = " << BA[i].second << endl;
  }

  if(flag > 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 6528
h, w = map(int, input().split())
p = 10**9+7
S = [input() for i in range(h)]
DP = [[0 for j in range(w)] for i in range(h)]
DP[0][0] = 1
for i in range(h):
    for j in range(w):
        if i > 0 and S[i-1][j] == '.':
            DP[i][j] += DP[i-1][j]
        if j > 0 and S[i][j-1] == '.':
            DP[i][j] += DP[i][j-1]
        DP[i][j] %= p
print(DP[h-1][w-1])


Measured memory_bytes: 44564
// https://atcoder.jp/contests/abc135/tasks/abc135_c

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int A_I_MAX = 1e9;
const int B_I_MAX = 1e9;

int N;
int A[N_MAX + 1];
int B[N_MAX];

void solve() {
  ll ans = 0;
  REP(i, N) {
    REP(j, 2) {
      int k = min(A[i + j], B[i]);
      ans += k;
      A[i + j] -= k;
      B[i] -= k;
    }
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N + 1) scanf("%d", A + i);
  REP(i, N) scanf("%d", B + i);
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_cxx;
#define dprint(v) cout << #v"=" << v << endl //;)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define INF (ll)1e16
#define endl '\n'
#define isin(x,y) ((y).find(x)!=(y).end())
#define forr(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

typedef pair<int,int> ii;

string binary(long long n)
{
  string result;

  do result.push_back( '0' + (n & 1LL) );
  while (n >>= 1LL);

  reverse( result.begin(), result.end() );
  return result;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
        cin>>n>>m;
        if(n>m){
            ll tmp=n;
            n=m;
            m=tmp;
        }
        //--n;
        string a=binary(n);
        string b=binary(m);
        string ans(sz(b),'.');
        if(sz(b)>sz(a)){
            string tmp(sz(b)-sz(a),'0');
            a=tmp+a;
        }
        forn(i,sz(b)-1){
            ll aa=0,bb=0;
            if(a[i]-'0'){
                for(ll j=i; j<sz(b); j++){
                    if(a[j]-'0')aa+=(1LL<<(sz(b)-j-1));
               }
                //++aa;
                aa=aa-(1LL<<(sz(b)-i));
            }
            if(b[i]-'0'){
                for(ll j=i+1; j<sz(b); j++){
                    if(b[j]-'0')bb+=(1LL<<(sz(b)-j-1));
                }
                ++bb;
            }
            if((aa+bb)%2)ans[i]='1';
            else ans[i]='0';
        }
        ll di=m-n+1;
        if((m-n+1)%2&&a[sz(a)-1]=='0')--di;
        ll p=di/2;
        if(di%2)++p;
        ans[sz(ans)-1]=(p%2?'1':'0');
        //dprint(a);dprint(b);
        //cout<<"  "<<ans<<endl;
        cout<<stoll(ans,nullptr,2)<<endl;

	return 0;
}


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


int main(){
  int c=0;
  string s,t;
  cin>>s>>t;
  for(int i=0;i<3;i++){
    if(s[i]==t[i]) c++;
  }
  cout<<c<<endl;
}

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

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



Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double N = scanner.nextDouble();
        int ceil = (int)Math.ceil(Math.sqrt(N));
        int min = Integer.MAX_VALUE;
        for (int i = 1; i < Math.max(2, ceil+1); i++) {
            if(N%i == 0){
                int f = Math.max(String.valueOf(i).length(), String.format("%.0f", N/i).length());
                min = Math.min(f, min);
            }
        }

        System.out.println(min);
    }
}


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

int gcd(long a, long b){
  int c;
  c = a % b;
  if (c==0) return b;
  else return gcd(b, c);
}

int main(){
  long a, b;
  cin >> a >> b;
  if (a < b) {
    a, b = b, a;
  }
  long ans=0;
  ans = gcd(a, b);
  ans = a * b / ans;
  cout << ans << endl;
}

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

int main(void) {
    int N;
    cin >> N;
    vector< int > d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int s_mid = d[N / 2 - 1];
    int b_mid = d[N / 2];
    printf("%d\n", b_mid - s_mid);
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      break;
    }
  }





  

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> x(n), y(n), z(n);
    rep(i, 0, n) cin >> x[i] >> y[i] >> z[i];
    ll ans = 0;
    for(int i = 0; i < 8; i++){
        ll c[3] = {1, 1, 1};
        for(int j = 0; j < 3; j++){
            if(i & (1<<j)) c[j] = -1;
        }
        ll tmp = 0;
        vector<ll> t;
        rep(j, 0, n) t.push_back(c[0] * x[j] + c[1] * y[j] + c[2] * z[j]);
        sort(t.begin(), t.end(), greater<ll>());
        rep(j, 0, m) tmp += t[j];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
function main(input){
  var a = input.split(" ");
  var b = a[0];
  var c = a[1];
  var count = 0;
  while(1) {
    b = b - ( c * 2 + 1 );
    count++;
    if (b <= 0) {
      break;
    }
  }
  console.log(count);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

    ll n, k;
    cin >> n >> k;

    if (k >= n) {
        cout << min(n, abs(n-k));
        return 0;
    }

    ll x = n/k;
    n -= x*k;

    cout << min(n, abs(n-k));







    return 0;
}


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


int main(void){
  int n;
  vector<int> list;
  cin >> n;
  int max1 = 0;
  int max2 = 0;
  for (int i = 0; i < n; i++){
    int num;
    cin >> num;
    if(max2 <= num){
      if(max1 <= num){
      max2 = max1;
      max1 = num;
      }
      else if(max1 > num){
        max2 = num;
      }
    }
    
  
    list.push_back(num);
    }

   for (int i = 0; i < n; i++){
     if(max1 == max2){
     cout << max1 << endl;
     }
     else{
       if(list[i] == max1){
       cout << max2 << endl;
       }
       else{
         cout << max1 << endl;
       }
     
     }
   }
    
  return 0;
}

Measured memory_bytes: 2548
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;


public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7);
	static List<Integer>[] edges ;
	static long[][] dp ;
	static int[] a;
	public static void main(String[] args) {

		int n = sc.nextInt();
	    a = new int[n+1];
	    long total = 0;
	    for(int i=1;i<=n;++i) {
	    	a[i] = sc.nextInt();
	    	total+=a[i];
	    }
	    
	    dp = new long[n+1][n+1];
	    for(int i=0;i<dp.length;++i) Arrays.fill(dp[i], -1);
	  
	   // out.println(f(1,n));
	    long x = f(1,n);
	    long y = total - x;
	    long ans = x - y;
	    out.println(ans);
	    

		
	out.close();
}
	private static long f(int i, int j) {
		if(i+1 == j) return Math.max(a[i], a[j]);
		if(i > j) return 0;
		if(dp[i][j] != -1) return dp[i][j];
		/*
		 * case 
		 * 1,2
		 * 1,n
		 * n,1
		 * n-1,n
		 * 
		 */
		long o1 = a[i] + f(i+2,j);
		long o2 = a[i] + f(i+1,j-1);
		long o3 = a[j] + f(i+1,j-1);
		long o4 = a[j] + f(i,j-2);
		return dp[i][j] = Math.max(Math.min(o1, o2),Math.min(o3, o4));
	}
	
	
}



Measured memory_bytes: 132040
s=input()
t=int(input())
u=[input().split()for i in range(t)]
a=0
b=''
c=''
for i in range(t):
  if u[i][0]=='1':
    a+=1
  else:
    if u[i][1]=='1':
      if a%2==0:
        b=b+u[i][2]
      else:
        c=c+u[i][2]
    else:
      if a%2==0:
        c=c+u[i][2]
      else:
        b=b+u[i][2]
if a%2==0:
  b=b[::-1]
  s=b+s+c
  print(s)
else:
  s=s[::-1]
  c=c[::-1]
  s=c+s+b
  print(s)

Measured memory_bytes: 40440
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20180305_AOJ
{
    class ALDS1_4D
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int[] n_k = line.Split(' ').Select(x => int.Parse(x)).ToArray();
                int n = n_k[0];
                int k = n_k[1];
                int[] w = new int[n];
                for (int i = 0; i < n; i++)
                {
                    w[i] = int.Parse(Console.ReadLine());
                }

                int P = (int)Math.Ceiling(w.Sum() / (double)k);
                bool inProgress = true;
                while (inProgress)
                {
                    int wi = 0;
                    for (int ki = 0; ki < k; ki++)
                    {
                        int total = 0;
                        for (; wi < n; wi++)
                        {
                            total += w[wi];
                            if (total > P)
                            {
                                break;
                            }
                        }
                    }

                    if (wi == n)
                    {
                        inProgress = false;
                    }
                    else
                    {
                        P++;
                    }
                }

                Console.WriteLine(P);
            }
        }
    }
}



Measured memory_bytes: 10340
n = int(input())
a = list(map(int, input().split()))

print(*a)
for i in range(1, n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j -= 1
    a[j + 1] = v
    print(*a)


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

int main()
{
    int K, A, B, count = 0;
    cin >> K >> A >> B;
    for (int i = 1; i <= 1000; i++)
    {
        if (A <= K * i && K * i <= B)
        {
            count++;
        }
    }
    if (count > 0)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3592
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
vector<int>sosuu2(100001, 0);
vector<int>sosuu3(100001, 0);
vector<int>sosuu;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	vector<int>arr(8, 0);
	int jiyuu = 0;
	for (int i = 0; i < N; i++)
	{
		int a; cin >> a;
		if (a >= 3200)
		{
			jiyuu++;
		}
		else
		{
			arr[a / 400]++;
		}
	}
	int saisyo = 0;
	for (int i = 0; i < 8; i++)
	{
		if (arr[i] > 0)
		{
			saisyo++;
		}
	}
	if (saisyo == 0)
	{
		cout << 1 << " " << jiyuu << "\n";
		return 0;
	}
	cout << saisyo << " " << min(N, saisyo + jiyuu) << "\n";
}


Measured memory_bytes: 1024
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	int x=0;
	std::vector<int> used(n,false);
	for(int i=m;i>0;i--) {
		if(used[x%n]) {
			x++;
			debug(x);
		}
		std::cout << i << ' ' << i+x+1 << EL;
		x+=2;
		used[(n-2-x+n)%n]=true;
	}
	return 0;
}


Measured memory_bytes: 4476
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

#define LL long long int

int main()
{
	int N, check = 1;
	LL sum = 0;

	vector<vector<LL>> A;

	cin >> N;

	A = vector<vector<LL>>(N, vector<LL>(N, 0));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int cnt = 1;
			for (int k = 0; k < N; k++) {
				if (k == i || k == j)
					continue;
				if (A[i][j] == A[i][k] + A[k][j])
					cnt = -1;
				else if (A[i][j] > A[i][k] + A[k][j])
					check = -1;
			}
			if (cnt == 1)
				sum += A[i][j];
		}
	}

	if (check != 1)
		sum = -1;

	cout << sum << endl;

    return 0;
}



Measured memory_bytes: 1024
def c_splitting_pile(N, A):
    # Aの要素の総和をX、カードの山の先頭i枚の総和をxとすると、
    # |y-x|=|X-2x|である。各iについてこの値を計算すればよい
    total = sum(A)
    ans = float('inf')
    s = 0
    for i in range(N-1):
        s += A[i]
        ans = min(ans, abs(total - s * 2))
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(c_splitting_pile(N, A))

Measured memory_bytes: 24828
n, x = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
num = 0
if sum(a) < x:
    print(n-1)
elif a[-1] > x:
    print(0)
else:
    while x > 0:
        x = x - a.pop()
        if x >= 0:
            num += 1
    print(num)

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
using ll=long long int;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
#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 RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

#define EVALe 1

#ifdef EVAL
#define LOG(i) 0
#else
#define LOG(i) cerr<<#i<<": "<<i
#endif

void solve(){
	int H,N;
	cin>>H>>N;
	int j;
	REP(i,N){
		scanf("%d",&j);
		H-=j;
	}
	cout<<(H<=0?"Yes":"No")<<endl;
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int x , a , b;
  cin >> x >> a >> b;
  int k = a * 10 + b;
  if(k % 4 == 0)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll dp[1001][1001];
char a[1001][1001];
int main()
{
  ll n,m;
  cin>>n>>m;
  

  for(ll i=1;i<=n;i++)
    for(ll j=1;j<=m;j++)
      cin>>a[i][j];
  for(ll i=1;i<=n;i++)
  dp[i][0]=0;
  for(ll j=1;j<=m;j++)
  dp[0][j]=0;
  dp[1][1]=1;
  for(ll i=1;i<=n;i++)
  {
    for(ll j=1;j<=m;j++)
    { 
      if(a[i][j]=='.')
      {
      dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
      //cout<<dp[i][j];
      }
      dp[1][1]=1;
    }
   
  }
  //cout<<dp[1][1];
  //cout<<dp[2][1];
  cout<<dp[n][m];
  return 0;
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		sc.close();

		int rest = A % B;
		boolean check = false;
		for(int i = 1; i <= B; i++) {
			int tmp = rest * i;
			if(tmp % B == C) {
				check = true;
				break;
			}else {
				continue;
			}
		}
		if(check) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,m;cin >> n>>m;
    lint ans=0;

    if (n == m){

        cout << "Yes"
             << "\n";
    }else{

        cout << "No"
             << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int x=10001;
	int i = 0;

	while (x>0) {
		
		if (x <= 10000){

		i++;
		printf("Case %d: %d\n", i, x);
}
scanf("%d", &x);
	}
	
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
			sum += L[i];
		}
		sc.close();
		Arrays.sort(L);
		sum -= L[N - 1];
		if(L[N - 1] < sum) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {

	long long a, b, x, numa, numb;

	cin >> a >> b >> x;

	numa = a / x;

	numb = b / x;

	if (a%x == 0) {
		cout << numb - numa+1 << "\n";
	}
	else {
		cout << numb - numa << "\n";
	}

	

	return 0;
}

Measured memory_bytes: 256
dice = [1,2,3,4,5,6]
number = list(map(int,input().split()))
direction = str(input())

rotate_n =[2,6,3,4,1,5]
rotate_s =[5,1,3,4,6,2]
rotate_e =[4,2,1,6,5,3]
rotate_w =[3,2,6,1,5,4]

for i in direction:
    result = []
    if i == "N":
        for j in range(6):
            dice[j] = rotate_n[j]
    elif i == "S":
        for j in range(6):
            dice[j] = rotate_s[j]
    elif i == "E":
        for j in range(6):
            dice[j] = rotate_e[j]
    else:
        for j in range(6):
            dice[j] = rotate_w[j]
    for k in dice:
        result.append(number[k-1])
    number = result

print(number[0])

Measured memory_bytes: 7576
# coding: utf-8
import heapq
n,m,s,t=map(int,input().split())
s,t=s-1,t-1
gy=[[]for i in range(n)]
gs=[[]for i in range(n)]
for i in range(m):
    u,v,a,b=map(int,input().split())
    u,v=u-1,v-1
    gy[u].append((a,v))
    gy[v].append((a,u))
    gs[u].append((b,v))
    gs[v].append((b,u))

d_y=[9999999999999999 for i in range(n)]
d_s=[9999999999999999 for i in range(n)]
h=[(0,s)]
while len(h):
    c,x=heapq.heappop(h)
    if c<d_y[x]:
        d_y[x]=c
    else:
        continue
    for i in range(len(gy[x])):
        if gy[x][i][0]+c<d_y[gy[x][i][1]]:
            heapq.heappush(h,(gy[x][i][0]+c,gy[x][i][1]))
h=[(0,t)]
while len(h):
    c,x=heapq.heappop(h)
    if c<d_s[x]:
        d_s[x]=c
    else:
        continue
    for i in range(len(gs[x])):
        if gs[x][i][0]+c<d_s[gs[x][i][1]]:
            heapq.heappush(h,(gs[x][i][0]+c,gs[x][i][1]))
ans=[0]
for i in range(n):
    ans.append(max(10**15-d_y[n-i-1]-d_s[n-i-1],ans[i]))
for i in range(n):
    print(ans[-i-1])

Measured memory_bytes: 80000
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<ll> pqL;
priority_queue<ll> pqR;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

vector<int> val;

int main()
{
    ll n,m,k,a,b,x,y,q;
    ll sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    ll cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    int ty;

    ll L = 0,R = 0;

    ll res = 0;

    for(int i=0;i<n;i++){
        cin>>ty;
        if(ty==1){
            cnt++;
            cin>>a>>b;
            sum+=(ll)b;
            if(cnt==1)pqL.push(a),L+=a;
            else if(cnt&1){
                cur = -pqR.top();
                if(cur<a){
                    R-=cur;
                    R+=a;
                    L+=cur;
                    pqL.push(cur);
                    pqR.pop();
                    pqR.push(-a);
                }
                else {
                    L+=a;
                    pqL.push(a);
                }
            }
            else {
                cur = pqL.top();

                if(cur>a){
                    L-=cur;
                    pqL.pop();
                    L+=a;
                    pqL.push(a);
                    R+=cur;
                    pqR.push(-cur);
                }
                else {
                    R+=a;
                    pqR.push(-a);
                }
            }
        }
        else {
            cur = pqL.top();
            res = cur*(ll)((cnt+1)>>1)-L;
            res += R-cur*(ll)(cnt>>1);
            cout<<cur<<" "<<res+sum<<"\n";
        }
    }


    return 0;
}


Measured memory_bytes: 3828
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main(void){
    int n;
    cin >> n;
    set<string> s;
    for(int i=0; i<n; i++){
        string t;
        cin >> t;
        s.insert(t);
    }
    cout << s.size() << '\n';
    return 0;
}

Measured memory_bytes: 19144
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, M;
std::vector<std::vector<LL>>G;
std::vector<LL>color;

bool dfs(LL v, LL c)
{
	color[v] = c;
	for (auto u : G[v])
	{
		if (color[u] == c) return false;
		if (color[u] == 0 && !dfs(u, -c)) return false;
	}
	return true;
}

bool solve(LL V)
{
	color.resize(V + 1);
	for (LL i = 1; i <= V; ++i)
	{
		if (color[i] == 0)
		{
			if (!dfs(i, 1)) return false;
		}
	}
	return true;
}

int main()
{
	in >> N >> M;
	std::vector<LL>A(M), B(M);
	G.resize(N + 1);
	rep(i, M)
	{
		in >> A[i] >> B[i];
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}
	if (solve(N))
	{
		LL B = 0, W = 0;
		for (LL i = 1; i <= N; ++i)
		{
			if (color[i] == 1) ++W;
			else ++B;
		}
		out << B * W - M << std::endl;
	}
	else out << N * (N - 1) / 2 - M << std::endl;
	return 0;
}


Measured memory_bytes: 8960
n, m = gets.split( " " ).map { | val | val.to_i }
ai = Array.new( n )
ai.each_index { |i|
	ai[i] = gets.split( " " ).map { | val | val.to_i }
}
bi = Array.new( m )
bi.each_index { |i|
	bi[i] = gets.to_i
}

ai.each_index { |i|
	c = 0
	ai[i].each_index { |j|
		c += ( ai[i][j] * bi[j] )
	}
	puts( c )
}

Measured memory_bytes: 6124
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
#define db double
using namespace std;
ll n,m,cnt,ans;
bool flag;
ll gcd(ll a,ll b)
{
	if(a<b)swap(a,b);
	if(!b)return a;
	return gcd(b,a%b);
}
int main()
{
	ll i,s,a,b,c,d,j,k;
	while(cin>>n)
	{
		scanf("%lld",&a);
		for(i=2;i<=n;i++)
		{
			scanf("%lld",&b);
			k=gcd(a,b);a*=b/k;
		}
		printf("%lld\n",a);
	}
	return 0;
}

Measured memory_bytes: 256
struct tranp{
  char gara;
  int atai;
};

void bbsort(struct tranp C[], int);
void selsort(struct tranp C[], int);
void pr(struct tranp C[], int);


int main(){
  int i=0,j=0;
  struct tranp C[100];
  struct tranp CC[100];
  int N=0;
  int count=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c%d",&C[i].gara,&C[i].atai);
  }
  for(i=0;i<N;i++){
      CC[i]=C[i];
  }
  bbsort(C,N);
  selsort(CC,N);
  pr(C,N);
  printf("Stable\n");
  pr(CC,N);
  for(i=0;i<N;i++){
    if(C[i].gara!=CC[i].gara){
      printf("Not stable\n");
      break;
    }
  }
  if(i==N)printf("Stable\n");
  return 0;
}
void bbsort(struct tranp A[],int N){
  int i=0,j=0;
  struct tranp temp;
  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(A[j].atai<A[j-1].atai){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
      }
    }
  }
}
void selsort(struct tranp A[], int N){
  int i=0,j=0;
  struct tranp temp;
  int min=0;
  for(i=0;i<=N-1;i++){
    min=i;
    for(j=i;j<=N-1;j++){
      if(A[j].atai<A[min].atai){
	min=j;
      }
    }
    temp=A[i];
    A[i]=A[min];
    A[min]=temp;
  }
}
void pr(struct tranp A[],int N){
  int i=0;
  if(N>1){
    for(i=0;i<N;i++){
      if(i<N-1){
	printf("%c%d ",A[i].gara,A[i].atai);
      }
      if(i==N-1){
	printf("%c%d",A[i].gara,A[i].atai);
      }
    }
    printf("\n");
  }
  else {
    for(i=0;i<N;i++){
      printf("%c%d",A[i].gara,A[i].atai);
    }
    printf("\n");
    }
 
  /*
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%c%d",A[i].gara,A[i].atai);
  }
  printf("\n"); */  
}



Measured memory_bytes: 2076
object Main extends App {

  val n = io.StdIn.readLine().toInt
  val all = (1 to n).toSet
  val p = io.StdIn.readLine().split(' ').map(_.toInt).toList
  val q = io.StdIn.readLine().split(' ').map(_.toInt).toList

  def fact(n: Int): BigInt = {
    def factAcc(n: Int, acc: BigInt): BigInt = if (n == 0)
      acc
    else
      factAcc(n - 1, acc * n)
    factAcc(n, 1)
  }

  def orderOf(p: List[Int], used: Set[Int], acc: BigInt): BigInt = p match {
    case Nil => acc + 1
    case x :: xs =>
      val less = ((1 until x).toSet -- used).size
      orderOf(xs, used + x, acc + less * fact((all -- used - x).size))
  }

  val answer = p.zip(q).span {
    case (pi, qi) => pi == qi
  } match {
    case (_, Nil) => 0
    case (same, diff) =>
      val used = same.map(_._1).toSet
      val orderP = orderOf(diff.map(_._1), used, 0)
      val orderQ = orderOf(diff.map(_._2), used, 0)
      math.abs((orderP - orderQ).toLong)
  }

  println(answer)
}


Measured memory_bytes: 27324
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(unknown_lints)]
#![allow(unused_variables)]
#![allow(unused_must_use)]
#![allow(unused_mut)]
#![allow(dead_code)]
#![allow(unused_assignments)]

use std::collections::HashMap;
use std::io::{stderr, Write};
use std::process::exit;

macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn csvec_new(src: Vec<char>) -> Vec<i32> {
    let mut cs: Vec<i32> = vec![0];
    cs.push(0);
    debug!(cs);
    let len = src.len();
    let mut new = 0;
    for i in 1..len {
        if src[i-1] == 'A' && src[i] == 'C' {
            new = new + 1;
        }
        cs.push(new);
        debug!(src[i-1]);
        debug!(src[i]);
        debug!(cs);
    }
    cs
}

fn main() {
    input!{
        n: usize,
        q: usize,
        s: String,
        lr: [(usize, usize); q]
    } debug!(n);
    debug!(q);
    debug!(s);
    debug!(lr);
    let s: Vec<char> = s.chars().collect();
    let cs = csvec_new(s);
    debug!(cs);
    for i in 0..q {
        debug!(i);
        let (l, r) = lr[i];
        debug!(l);
        debug!(r);
        let res = cs[r] - cs[l];
        //println!("{}", res);
        let stdout_ = std::io::stdout();
        let mut stdout = std::io::BufWriter::new(stdout_.lock());
        writeln!(stdout, "{}", res).unwrap();
    }
}

Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    cin >> n;
    float a[n];
    for (int i = 0; i < n;i++){
        cin >> a[i];
    }

    float ans=0;
    for (int i = 0; i < n; i++)
    {
        ans += (1.0 / a[i]);
    }
    ans = 1.0 / ans;

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
int i, sx, sy, tx, ty;

int main() {
    scanf(" %d %d %d %d", &sx, &sy, &tx, &ty);
    tx = tx - sx; ty = ty - sy;
    rep(0, tx) printf("R");
    rep(0, ty) printf("U");
    rep(0, tx) printf("L");
    rep(0, ty+1) printf("D");
    rep(0, tx+1) printf("R");
    rep(0, ty+1) printf("U");
    printf("LU");
    rep(0, tx+1) printf("L");
    rep(0, ty+1) printf("D");
    printf("R");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    string s;
    cin >> s;

    rep(i, 3) {
        cout << s[i];
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int str1 = sc.nextInt() * 800;
		str1 = str1 - (str1 / (800 * 15)) * 200; 
		System.out.println(str1);

	}
}

Measured memory_bytes: 21844
import java.util.*;

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

    String s = sc.next();

    int l = s.length();
    String[] x = new String[l];
    for (int i = 0; i < l; i++)
      x[i] = s.substring(i, i + 1);
    
    int r = (int)Math.pow(2, l - 1);
    long sum = 0;
    for (int i = 0; i < r; i++) {
      String a = "";
      for (int j = 0; j < l - 1; j++) {
        a += x[j];
        if ((1 & i >> j) == 1) {
          sum += Long.parseLong(a);
          a = "";
        }
      }
      a += x[l-1];
      sum += Long.parseLong(a);
    }
    
    System.out.println(sum);
  }
}

Measured memory_bytes: 22996
import java.util.ArrayList;
import java.util.Scanner;

// *** at 2018/**/**

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

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        String word = "aiueo";
        if (-1 < word.indexOf(N)) {
            System.out.println("vowel");
        } else {
            System.out.println("consonant");
        }
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        sc.nextLine();
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < H; i++) {
            list.add(sc.nextLine());
        }
        for (String string : list) {
            System.out.println(string);
            System.out.println(string);
        }
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 22740
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ld dp[301][301][301];
struct vertice { int x, y, z; };
vector<vertice> u[901];
int n; int c[4];
int main() {
	cout << fixed << setprecision(10);
	cin >> n;
	vector<int> v; v.resize(4);
	rep(i, n) {
		int a; cin >> a; v[a]++;
	}
	int sum = 0; rep(i, 4)sum += i * v[i];
	rep(i, n + 1) {
		rep(j, n-i+1) {
			rep(k, n-i-j+1) {
				int l = n - i - j - k;
				u[j + 2*k + 3*l].push_back({ i,j,k });
			}
		}
	}
	rep(i, sum + 1) {
		rep(j, u[i].size()) {
			vertice vv = u[i][j];
			ld val = 0;
			ld num = n - vv.x;
			if (num == 0)continue;
			rep1(k, 3) {
				c[0] = vv.x; c[1] = vv.y; c[2] = vv.z; c[3] = n - c[0] - c[1] - c[2];
				if (c[k] == 0)continue;
				c[k]--; c[k-1]++;
				val += (c[k]+1) / (ld)n*dp[c[0]][c[1]][c[2]];
			}
			val = (val + 1)*(ld)n / num;
			dp[vv.x][vv.y][vv.z]= val;
		}
	}
	cout << dp[v[0]][v[1]][v[2]] << endl;
	//stop
	return 0;
}

Measured memory_bytes: 488544
#include <iostream>
#include <string>
#include <math.h>
#include <cstdlib>

using namespace std;

int main()
{
	int x, a,b;
	cin >> x >> a >> b;
	if (b - a <= x && b-a > 0) cout << "safe" << endl;
	else if (b-a <= 0) cout << "delicious" << endl;
	else if (b - a >= x+1) cout << "dangerous" << endl;

	
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int K, N;
vector<int> v;

bool check(int n) {
    int t = K;
    for(int i = 0; i < N; ++i) {
        t -= v[i] / n;
        if(v[i] >= n && v[i] % n == 0) ++t;
    }
    return (t >= 0);
}

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

    cin >> N >> K;

    int mx = 0;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        v.pb(a);
        mx = max(mx, a);
    }

    int l, r;
    l = 0, r = mx;
    while(r - l > 1) {
        int mid = (l + r) / 2;
        if(check(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;

    return 0;
}



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

int main() {
  bool ans = true;
  vector<int> b(3);
  cin >> b[0] >> b[1] >> b[2];
  vector<int> c(3);
  cin >> c[0] >> c[1] >> c[2];
  int A2 = c[0]-b[0];
  if(A2+b[1]!=c[1] || A2+b[2]!=c[2]) ans =false;
  vector<int> d(3);
  cin >> d[0] >> d[1] >> d[2];
  int A3 = d[0]-b[0];
  if(A3+b[1]!=d[1] || A3+b[2]!=d[2]) ans =false;

  cout << (ans? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
from collections import deque
from sys import stdin
input=stdin.readline

N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
L=[ [] for _ in range(N)]
for i in range(N-1):
  a[i],b[i],c[i]= map(int,input().split())
  L[a[i]-1].append((b[i]-1,c[i]))
  L[b[i]-1].append((a[i]-1,c[i]))
Q,K= map(int,input().split())
         
#Lの中のitemの0は接続先、1は距離

d=[ -1 for i in range(N)]

def BFS(x):
  v=deque([x])
  d[x]=0
  
  while len(v)>0:
    s=v.popleft() #sはint
    for item in L[s]:
      if d[item[0]]==-1:
        d[item[0]]=d[s]+item[1]
        v.append(item[0])
BFS(K-1)

x=[0]*Q
y=[0]*Q
for i in range(Q):
  x[i],y[i] = map(int,input().split())
  print(d[x[i]-1]+d[y[i]-1])

Measured memory_bytes: 60320