akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

const ll mod = 2019; 

int main(){
    ll l, r, ans = LINF;
    cin >> l >> r;
    r = min(r, l + 2019);
    for(ll i = l; i <= r; i++){
        for(ll j = i + 1; j <= r; j++){
            ans = min(ans, (i * j) % mod);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx-sx, ty-sy
ans = 'U'*dy+'R'*dx+'D'*dy+'L'*dx + \
        'L'+'U'*(dy+1)+'R'*(dx+1)+'D' + \
        'R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print(ans)

Measured memory_bytes: 9040
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int sum = 0;
  int N,D,X;

  cin >> N >> D >> X;

  while(N--)
  {
    int tmp;
    cin >> tmp;

    for ( int i = 0; i*tmp+1 <= D; ++i ) ++sum;
  }

  cout << sum+X << "\n";
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N;
    cin >> N;
    map<string, int> mp;
    rep(i, N) {
        string S;
        cin >> S;
        mp[S] += 1;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov
//export PATH=PATH:~/.local/bin


int main(){
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    vvll d(n,vll(0));
    rep(i,m){
        ll a;
        cin >> a;
        ll b;
        cin >> b;
        d[a-1].push_back(b-1);
        d[b-1].push_back(a-1);
    }
    vll c(n,0);
    c[0]=1;
    vll ans(n);
    ll ansn=1;
    queue<ll>q;
    q.push(0);
    while(true){
        if(ansn==n)break;
        queue<ll> que;
        while(!q.empty()){
            rep(i,d[q.front()].size()){
                if(c[d[q.front()][i]]==0){
                    c[d[q.front()][i]]=1;
                    ans[d[q.front()][i]]=q.front();
                    ansn++;
                    que.push(d[q.front()][i]);
                }
            }
            q.pop();
        }
        q=que;
    }
    cout << "Yes" << endl;
    repi(i,1,n) cout << ans[i]+1 << endl;
}

Measured memory_bytes: 14468
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int64_t n, k;
    cin >> n >> k;

    int64_t r = n * n;
    if (k > 0) {
        for (int64_t b = 1; b <= n; b++) {
            int64_t x = (n + 1) / b;
            int64_t y = (n + 1) % b;
            int64_t t = x * min(k, b) + min(y, k);
            //if (b < 10) cout << b << ' ' << x << ' ' << y << endl;
            r -= t - 1;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#14:22
n,k = map(int,input().split())
whole = [1]
patty = [1]
for _ in range(n):
  whole.append(whole[-1] * 2 + 3)
  patty.append(patty[-1] * 2 + 1)
ans = 0
rest = k
for i in range(n,-1,-1):
  if i == 0:
    ans += [0,1,2,3,3][rest]
    rest = 0
  elif rest <= whole[i] - (i-1):
    rest -= 1
  elif rest <= whole[i]:
    rest = 0
    ans += patty[i]
  elif rest == whole[i] + 1:
    rest -= whole[i] + 1
    ans += patty[i] + 1
  else:
    rest -= whole[i] + 2
    ans += patty[i] + 1
  if rest == 0:
    print(ans)
    break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,x;
    cin>>n>>x;
    vector<int> vec(n);
    rep(i,n){
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    int ans=0;
    for(i=0;x>0;i++){
        x-=vec[i];
        if(x>=0)ans++;
        if(x>=0&&i==n-1){
            if(x!=0)ans--;
            break;
        }
    }
    cout<<ans<<endl;
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N;
   ll K;
   cin >> N >> K;
   vector<pair<ll, ll>> ab(N);
   rep(i, N) cin >> ab.at(i).first >> ab.at(i).second;
   sort(ab.begin(), ab.end());

   ll sum = 0;
   rep(i, N) {
     sum += ab.at(i).second;
     if (K <= sum) {
       cout << ab.at(i).first << endl;
       break;
     }
   }
 }


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
	int m,n,x,max,a;
	double q;
	scanf("%d%d%d",&m,&n,&x);
	max= m>n?m:n;
	a=x/max;
	if(a*max<x)
		a++;
	printf("%d",a);
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
vector<int>graph[100005];
bool visited[100005];
int dist[100005];
int main(){
	int n,m;
	cin>>n>>m;
	while(m--){
		int a,b;
		cin>>a>>b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	visited[1] = true;
	queue<pi>q;
	q.push(pi(1,0));
	while(q.size()){
		pi temp = q.front();
		int curr = temp.first;
		int d = temp.second;
		q.pop();
		dist[curr] = d;
		for(int i=0; i<graph[curr].size(); i++){
			int next_ = graph[curr][i];
			if(!visited[next_]){
				visited[next_] = true;
				q.push(pi(next_,curr));
			}
		}
	}
	cout<<"Yes"<<'\n';
	for(int i=2; i<=n; i++) cout<<dist[i]<<'\n';
}

Measured memory_bytes: 10780
using System;
using System.Linq;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var V = Console.ReadLine().Split(' ').Select((c => int.Parse(c))).ToArray();
            var C = Console.ReadLine().Split(' ').Select((c => int.Parse(c))).ToArray();

            int sum = 0;
            for (int i = 0; i < N; i++)
            {
                sum += Math.Max(V[i] - C[i], 0);
            }

            Console.WriteLine(sum);
        }
    }
}

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

int main() {
  long long  n;
  long long a;
  cin >> n >> a;
  
  long long  m= a;
  for(int i=0;i<4;i++){
      cin >> a;
      m=min (m,a);
     
  }  
  
  cout << (n-1)/m + 5   << endl;
}


Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())

S_list = list(S)

r = 1
a = []
b = []
d = deque(a)

for i in range(Q):
    q = input().split()
    if q[0] == '1':
        r *= -1
        continue
    elif len(q) == 3:
        if q[1] == '1':
            if r == -1:
                b.append(q[2])
            else:
                d.appendleft(q[2])
        else:
            if r == -1:
                d.appendleft(q[2])
            else:
                b.append(q[2])
                
answer = list(d) + S_list + b

if r == -1:
    answer = answer[::-1]
    
print(''.join(answer))

Measured memory_bytes: 10332
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int h,w,n;cin>>h>>w>>n;
    vector<int> c(n);
    rep(i,n){
        cin>>c[i];
    }
    int ans[h][w];
    rep(i,h)rep(j,w)ans[i][j]=0;
    int nh=0,nw=0;
    bool f =true;
    rep(i,n){
        while(c[i]>0){
        if(f){
            for(;nw<w&&c[i]>0;nw++){
                ans[nh][nw]=i+1;
                c[i]--;
            }
            if(nw==w){
                f=false;
                nh++;
                nw--;
            }
        }
        else{
            for(;nw>=0&&c[i]>0;nw--){
                ans[nh][nw]=i+1;
                c[i]--;
            }
            if(nw==-1){
                f=true;
                nh++;
                nw++;
            }
        }
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j]<<' ';
        }
        cout<<endl;
    }
    }

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int ans = 0;
	for (int i = 1;i <= N;++i) {
		int sum = i / 10000 + i % 10000 / 1000 + i % 1000 / 100 + i % 100 / 10 + i % 10;
		if (A <= sum && sum <= B) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}
template<typename S>
void print(S a){
    cout<<a<<endl;
}

int main(){
    int x,n;
    cin>>x>>n;
    int p;
    map<int,int> mp;
    rep(i,n){
        cin>>p;
        p-=x;
        mp[p] = 1;
    }
    int ansp=0;
    int ansm=0;
    int pm = 1;
    while(pm){
        if(mp[ansp] != 0){
            ansp++;
        }else{
            pm = 0;
        }
    }
    pm = 1;
    while(pm){
        if(mp[ansm] != 0){
            ansm--;
        }else{
            pm = 0;
        }
    }
    if(ansp+ansm>=0){
        fin(ansm+x);
    }else{
        fin(ansp+x);
    }



}



Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<string>
#include<cmath>
using namespace std;

class function {

public:


};



int main() {
	
	int R[1000000],n;
	long most = -1 * 1000000000,worse=-1*1000000000;
	
	cin >> n;
	cin >> R[0];
	worse = R[0];
	for (int i = 1; i < n; i++) {
		cin >> R[i];
		if (most < (R[i] - worse)) {
			most = R[i] - worse;
		}
	    if (worse > R[i] ) {
			worse = R[i];
		}

	}
	cout << most << endl;

	return 0;
}


Measured memory_bytes: 3896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if( a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) System.out.println("Possible");
        else System.out.println("Impossible");
    }
}

Measured memory_bytes: 35880
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> AB;
  rep(i, N){
    int a, b;
    cin >> a >> b;
    AB.emplace_back(a, b);
  }
  sort(AB.begin(), AB.end());
  ll ans = 0;
  rep(i, N){
    ll a = AB[i].first;
    ll b = AB[i].second;
    if(M - b > 0){
      ans += b * a;
      M -= b;
    }else{
      ans += M * a;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  Int N, ans;
  cin >> N;
  
  ans = N * (N-1) / 2;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
ll ans = 0;
	ll A,B;	cin >> A >> B;
	if((A+B)%2 == 1)
	{
		cout << "IMPOSSIBLE" << endl;
	}
	else
	{
		ans = abs((A+B)/2);
		cout << ans << endl;
	}
	
}



Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    MOD = 10 ** 9 + 7
    N = int(rl())
    ans = pow(10, N, MOD) - (2 * pow(9, N, MOD) - pow(8, N, MOD))
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()


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

int main() {
	string s;
	cin >> s;
	bool t = true;
	for (int i = 0; i < s.length(); i++)
		if (i % 2 == 0 && s[i] == 'L')
			t = false;
		else if (i % 2 == 1 && s[i] == 'R')
			t = false;
	if (t == true)
		cout << "Yes";
	else
		cout << "No";
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			if(input.equals("0")){
				break;
			}

			int total = 0;
			char[] charAry = input.toCharArray();
			for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			}

			System.out.println(total);
		}


	}

}

Measured memory_bytes: 24344
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+5;
void FAST(){ios::sync_with_stdio(false);cin.tie(0);}
const ll mod =  1e9+7;

//int n, m, k, q;
ll a, b, n;
ll f(ll x){
    return x*a/b-a*(x/b);
}

void solve()
{
    cin>>a>>b>>n;
    ll ans = max(f(n-1), f(n));
    if(b-1<=n) ans = max(ans, f(b-1));
    printf("%lld\n", ans);
//    ll ans = sanfen(0, n);
//    printf("%lld\n", ans);
}


int main()
{

//    int _; scanf("%d", &_); while(_--)
//    while(~scanf("%d", &n))
//    while(scanf("%d", &n)&&n)
    solve();
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  str a,b;
  cin>>a>>b;
  ll ans=0;
  rep(i,3){
    if(a[i]==b[i])ans++;
  }
  cout<<(ans)<<endl;
  
  
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

  int K, S;
  cin >> K >> S;

  int counter = 0;

  for (int i = 0; i <= K; ++i){
    for (int j = 0; j <= K; ++j){
      if (0 <= S - i - j && S - i - j <= K) counter++;
    }
  }

  cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(nullptr)
#define INF (1LL<<62)-1
#define F first
#define S second
#define pb push_back

vector<vector<ll>> ans(100005,vector<ll>(3,INT_MIN));
vector<ll> a(100005),b(100005),c(100005);
ll f(ll i, ll n, ll k)
{
    if(ans[i][k]!=INT_MIN) return ans[i][k];
    if(i>=n) return 0;

    ll maxx=0;
    if(k==0)
    {
        maxx = max(b[i]+f(i+1,n,1), c[i]+f(i+1,n,2));
        ans[i][k]=maxx;
    }
    else if(k==1)
    {
        maxx = max(a[i]+f(i+1,n,0), c[i]+f(i+1,n,2));
        ans[i][k]=maxx;
    }
    else
    {
        maxx = max(a[i]+f(i+1,n,0), b[i]+f(i+1,n,1));
        ans[i][k]=maxx;
    }
    return maxx;
}

int main()
{
    FASTIO;
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];

    cout<<max(a[0]+f(1,n,0), max(b[0]+f(1,n,1), c[0]+f(1,n,2)));
}

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

using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i=(a); i<(b);i++)
#define FORD(i, a, b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

bool field[1000][1000] = {};
ll dp[1000][1000] = {};

int main() {
	cin.sync_with_stdio(false);

	ll h, w;
	cin >> h >> w;
	FOR(i, 0, h) {
		FOR(j, 0, w) {
			char c;
			cin >> c;
			if (c == '#') {
				field[i][j] = true;
			}
		}
	}

	FORD(j, 0, w) {
		if (field[h - 1][j]) {
			break;
		}
		dp[h - 1][j] = 1;
	}

	FORD(i, 0, h - 1) {
		if (field[i][w - 1]) {
			dp[i][w - 1] = 0;
		} else {
			dp[i][w - 1] = dp[i + 1][w - 1] % 1000000007;
		}
		FORD(j, 0, w - 1) {
			if (field[i][j]) {
				dp[i][j] = 0;
			} else {
				dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % 1000000007;
			}
		}
	}

	cout << dp[0][0];
}

Measured memory_bytes: 9088
package main

import (
	"fmt"
	"math"
)

func main() {
	var (
		n int
		d int
	)

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

	xd := make([][]float64, n)

	for i := 0; i < n; i++ {
		xd[i] = make([]float64, d)
		for j := 0; j < d; j++ {
			var t float64
			fmt.Scanf("%f", &t)
			xd[i][j] = t
		}
	}

	count := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			var dist float64
			dist = 0.0
			for k := 0; k < d; k++ {
				temp := xd[i][k] - xd[j][k]
				dist += temp * temp
			}
			dist = math.Sqrt(dist)
			check := float64(int(dist))
			if int(check/dist) == 1 {
				count++
			}
			// fmt.Printf("%d %d %f\n", i, j, dist)
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
import sys
import itertools

def main():
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))

    kai = []
    for i in range(1, N+1):
        kai.append(i)

    jun_lis = list(itertools.permutations(kai))

    P_point = jun_lis.index(P)
    Q_point = jun_lis.index(Q)
    print(abs(P_point - Q_point))

main()


Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W,N;
  cin >> H >> W >> N;
  if (H<W) {
    int a = N/W;
    if (a*W==N){
      cout << a << endl;
    } else {
      cout << a+1 << endl;
    };
  } else {
    int a = N/H;
    if (a*H==N){
      cout << a << endl;
    } else {
      cout << a+1 << endl;
    };
  };
}

Measured memory_bytes: 256
def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]

    n = c.index(max(c)) + 1

    for i in range(D):
        print(n)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9392
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    LL ss; R(ss);
    LL sq=sqrt((LD)ss);
    while(sq*sq<ss)sq++;
    W(1,sq);
    W(sq,sq*sq-ss);
    W(0,0);
    return 0;
}


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

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //setIO("");
    string s;
    cin >> s;
    bool yes = false;
    if(s[2] == s[3] && s[4] == s[5])
    {
        yes = true;
    }

    if(yes)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
n=int(input())
list = list(map(int,input().split()))
ave=sum(list)/len(list)
k=(Decimal(str(ave)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
sum=0
for i in range(n):
	sum+=(k-list[i])**2
print(sum)

Measured memory_bytes: 5076
#include <iostream>
using namespace std;
int n;
int cnt[102];
int count;
int main(){
	cin>>n;
	for(int i=0;i<n;++i)cin>>cnt[i];
	// 0-->n-1
	for(int i=0;i<n;++i){
		for(int j=n-1;j>i;j--){
			if(cnt[j]<cnt[j-1]){
				swap(cnt[j],cnt[j-1]);
				count++;
			}
		}
	}
	for(int i=0;i<n-1;++i){
		cout<<cnt[i]<<' ';
	}
	cout<<cnt[n-1]<<'\n';
	cout<<count<<'\n';
}

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <utility>
#define rep(i, n) for(int i = 0; i < n; i++);

using namespace std;

const int INF = 1000000007;
const double PI = acos(-1.0);
typedef long long llong;

const int N = 10000;
char mp[51][51];
int dp[51][51];

int main()
{
	int w, h;
	char tmp;
	cin >> h >> w;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> tmp;
			mp[i][j] = tmp - 48;
		}
	}

	dp[0][0] = mp[0][0];
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (i == 0 && j == 0) continue;
			if (i == 0)
				dp[i][j] = dp[i][j - 1] + mp[i][j];
			else if (j == 0)
				dp[i][j] = dp[i - 1][j] + mp[i][j];
			else
				dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + mp[i][j];
		}
	}

	cout << dp[h - 1][w - 1] << endl;

	return 0;


}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;
ll mul(ll x,ll y){
    return (1ll* (x%mod1)*(y%mod1));
}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=(z*x);x =(x*x) ;y/=2;}return z;}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
//ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
    #endif
    ll n,m,x;
    cin>>n>>m>>x;
    ll p[n];
    
    vll a[n];
    ll total[m];
    fo(i,m)total[i] = 0;
    ll temp;
    fo(i,n){
    	cin>>p[i];
    	fo(j,m){
    		cin>>temp;
    		a[i].pb(temp);
    		total[j]+=temp;
    	}
    }
    fo(i,m){
    	if(total[i]<x){
    		cout<<"-1"<<endl;
    		return 0;
    	}
    }
    vll ans;
    fo(i,power(2,n)){
    	ll temp[m],cost = 0;
    	fo(j,m)temp[j] = 0;
    	fo(j,n){
    		if(i & 1<<j){
    			fo(k,m){
    				temp[k]+=a[j][k];
    			}
    			cost+=p[j];
    		}
    	}
    	ll f = 1;
    	fo(j,m){
    		if(temp[j]<x){
    			f = 0;
    			break;
    		}
    	}
    	if(f)ans.pb(cost);
    }
    if(ans.size()==0)cout<<-1<<endl;
   	else {
   		ll mn = (ll)1e10;
   		for(ll x:ans){
   			mn = min(x,mn);
   		}
   		cout<<mn<<endl;
   	}

    

    


}

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

using ll = long long;
#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)

string s;
int n;

int odd;
int cnt[30];
void init() {
	for (int i = 0; i < n; i++)cnt[s[i] - 'a']++;
	for (int i = 0; i < 26; i++)odd += (cnt[i] % 2);
	if (odd > 1 || (n % 2 != odd)) {
		cout << -1 << '\n';
		exit(0);
	}
}
string t = "";
void get_opt() {
	char ext;
	if (odd) {
		for (int i = 0; i < 26; i++)if (cnt[i] % 2 == 1) {ext = (char)('a' + i); break;}
	}
	//////////////////
	for (int i = 0; i < 26; i++)cnt[i] /= 2;
	for (int i = 0; i < n; i++) {
		if (cnt[s[i] - 'a']) {
			t += s[i];
			cnt[s[i] - 'a']--;
		}
	}
	string r = t;
	reverse(r.begin(), r.end());
	if (odd)t += ext;
	t += r;
}
queue<ll> pos[30];
vector<ll> b;
void get_b(){
	for(int i=0;i<n;i++){
		pos[t[i]-'a'].push(i);
	}	
	b.resize(n);
	for(int i=0;i<n;i++){
		b[i]=pos[s[i]-'a'].front()+1;
		pos[s[i]-'a'].pop();
	}
}
/*
*	verified : http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4713284#1
*	last revised : 29.July.2020 
 */
template<class T> class BIT {
private:
	int n;
	vector<T> dat;//[1,n]
public:
	BIT(int maxn, int _n) {
		dat.assign(maxn + 1, 0);
		n = _n;
	}
	T sum(int i) {
		T res = 0;
		while (i > 0) {
			res += dat[i];
			i -= i & -i;
		}
		return res;
	}
	void add(int i, T x) {
		while (i <= n) {
			dat[i] += x;
			i += i & -i;
		}
	}
};
/*
*	verified : http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4713284#1
*	last revised : 29.July.2020 
 */
template<class T> vector<T> compress(vector<T>& a) {
	vector<T> b = a;
	vector<T> res(a.size());
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	for (int i = 0; i < a.size(); i++)res[i] = 1 + (lower_bound(b.begin(), b.end(), a[i]) - b.begin());
	return res;
}
// caution : to get the inversion for 64bit_integer, T must be "long long".  
template<class T> long long inversion(vector<T> a, int maxn) {
	BIT<T> B(maxn, a.size());
	T res = 0;
	for (int i = 0; i < a.size(); i++) {
		res += i - B.sum(a[i]);
		B.add(a[i], 1);
	}
	return res;
}
int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	n = s.size();
	init();
	get_opt();
	get_b();
	cout<<inversion(b,200020) << '\n';
}


Measured memory_bytes: 10004
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    int N, M;
    cin >> N;
    vector<int> T(N);
    rep(i, N) cin >> T[i];
    cin >> M;
    int P, X;
    int total = 0;
    rep(i, N) total += T[i];
    rep(i, M) {
        cin >> P >> X;
        cout << total - T[P - 1] + X << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 12
using namespace std;

int main() {
	char b, ans;
	cin >> b;
	if (b == 'A')
		ans = 'T';
	else if (b == 'T')
		ans = 'A';
	else if (b == 'G')
		ans = 'C';
	else
		ans = 'G';
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int g = 0;
        int p = 0;
        string s = Console.ReadLine();
        int score = 0;
        foreach (var c in s)
        {
            if (p < g)
            {
                if (c == 'g')
                {
                    p++;
                    score++;
                }
                else
                {
                    p++;
                }
            }
            else
            {
                if (c == 'g')
                {
                    g++;
                }
                else
                {
                    g++;
                    score--;
                }
            }
        }
        Console.WriteLine(score);
    }
}


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

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

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

int main() {
  std::string S;
  std::cin >> S;

  std::string ans = "No";
  if((S[0] == S[1] && S[0] != S[2] && S[2] == S[3])
    or
    (S[0] == S[2] && S[0] != S[1] && S[1] == S[3])
    or
    (S[0] == S[3] && S[0] != S[1] && S[1] == S[2])) {
    ans = "Yes";
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
signed main(){
    string S;
    cin >>S;
    int zero=0;
    int one=0;
    REP(i,S.size()){
        S[i]=='0'?zero++:one++;
    }
    cout<<min(zero,one)*2<<endl;
}


Measured memory_bytes: 512
import itertools
import math

n, m = map(int, input().split())

prefs = []
ids = {}

for i in range(n):
    prefs.append({})

for i in range(m):
    pref_num, year = map(int, input().split())
    prefs[pref_num-1].setdefault(i, year)

for i in range(n):
    sorted_cities = sorted(prefs[i].items(), key=lambda x: x[1])
    for j, city in enumerate(sorted_cities):
        ids.setdefault(city[0], (i, j))


sorted_ids = sorted(ids.items())

for data in sorted_ids:
    print(str(data[1][0]+1).zfill(6)+str(data[1][1]+1).zfill(6))

# city_name: (pref, ~th)

Measured memory_bytes: 77416
a, b = map(int, open(0).read().split())

a_l = a / 0.08
a_r = (a + 1) / 0.08
b_l = b / 0.1
b_r = (b + 1) / 0.1

x_l = max(a_l, b_l)
x_r = min(a_r, b_r)

if x_l < x_r:
    if(x_l * 10 % 10 == 0):
        print(int(x_l))
    else:
        print(int(x_l + 1))
else:
    print(-1)

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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll big = 10e10 + 11 ;

int  main (  ) {

    FASTIO ;

    int n , x ;
    cin >> n >> x ;

    ll ans = 0 , z = 0 ;

    if( z <= x ) ans++ ;

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

        z += k ;

        if( z <= x ) ans++ ;
    }

    cout <<  ans << endl ;


    return  0 ;
}



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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  vector<int> Nums;
  int now = 1;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == (char)('0' + now))
      cnt++;
    else {
      Nums.push_back(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  if (cnt != 0) {
    Nums.push_back(cnt);
  }

  if (Nums.size() % 2 == 0) {
    Nums.push_back(0);
  }

  int Add = 2 * k + 1;
  int right = 0, left = 0;
  int ans = 0;
  int sum = 0;
  for (int i = 0; i < Nums.size(); i += 2) {
    int nextLeft = i;
    int nextRight = min(i + Add, (int)Nums.size());
    while (nextLeft > left) {
      sum -= Nums[left];
      left++;
    }
    while (nextRight > right) {
      sum += Nums[right];
      right++;
    }
    ans = max(sum, ans);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;

int main()
{
	int x, y, z;
	cin >> x >> y >> z;

	int s = x + y + z;
	if (s >= 22)
	{
		cout << "bust";
	}
	else
	{
		cout << "win";
	}
	
}


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int n = sc.nextInt();
            int count = 0;
            for(int a=0; a<10; a++){
                for(int b=0; b<10; b++){
                    for(int c=0; c<10; c++){
                        for(int d=0; d<10; d++){
                            if(a+b+c+d==n){
                                count = count + 1;
                                break;
                            }else if(a+b+c+d>n){
                                break;
                            }
                        }
                    }
                }
            }
            System.out.println(count);
        }


    }
}





Measured memory_bytes: 26572
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int mod = 1e9 + 7;
    int r, c;
    cin >> r >> c;
    char a[r][c];
    for(int i = 0; i < r; ++i) {
        for(int j = 0; j < c; ++j) {
            cin >> a[i][j];
        }
    }
    int dp[r][c]{};
    dp[0][0] = 1; // No of ways to reach first cell is 1
    for(int i = 0; i < r; ++i) {
        for(int j = 0; j < c; ++j) {
            if(!(a[i][j] == '#')) {
                if(i > 0)
                    dp[i][j] += dp[i - 1][j] % mod;
                if(j > 0)
                    dp[i][j] += dp[i][j - 1] % mod;
            }
        }
    }
    cout << dp[r - 1][c - 1] % mod << "\n";
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, x, a);

  puts(x < a ? "0" : "10");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int N;
    cin >> N;
    long A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    long cumulative_sum[N + 1];
    cumulative_sum[0] = 0;
    for(int i = 0; i < N; i++){
        cumulative_sum[i + 1] = cumulative_sum[i] + A[i];
    }
    long ans = 1e18;
    for(int i = 2; i < N - 1; i++){
        auto first = lower_bound(cumulative_sum, cumulative_sum + N, (cumulative_sum[i] + 1) / 2);
        auto first_minus = first;
        first_minus--;
        auto third = lower_bound(cumulative_sum, cumulative_sum + N, cumulative_sum[i] + ((cumulative_sum[N] - cumulative_sum[i]) + 1) / 2);
        auto third_minus = third;
        third_minus--;
        for(auto j: {first, first_minus}){
            for(auto k: {third, third_minus}){
                ans = min(ans, max({*j, cumulative_sum[i] - (*j), (*k) - cumulative_sum[i], cumulative_sum[N] - (*k)}) -
                          min({*j, cumulative_sum[i] - (*j), (*k) - cumulative_sum[i], cumulative_sum[N] - (*k)}));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3840
d,n = map(int,input().split())
if d == 0:
    if n == 100:
        print(101)
    else:
        print(n)
elif d == 1:
    if n == 100:
        print(10100)
    else:
        print(100*n)
else:
    if n == 100:
        print(1010000)
    else:
        print(10000*n)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	string sstr;
	while(1){
		getline(cin,sstr);
		if(cin.eof())
			break;

		string retStr;
		for(int i = 0; i < 26; i++){
			string str=sstr;
			if(i==4){
			//	cout<<endl;
			}
			for(int j = 0; j < str.size(); j++){
				if(str[j] >= 'a' && str[j] <= 'z'){
					str[j] = str[j] - i;
					if(str[j] < 'a'){
						str[j]+=26;
					}
				}
			}
			bool f=false;
			for(int j = 0; j + 2 < str.size(); j++){
				if(str.substr(j,3)=="the"){
					f=true;
					break;
				}
				else if(j+3<str.size()&& str.substr(j,4)=="this"){
					f=true;
					break;
				}
				else if(j+3<str.size()&&str.substr(j,4)=="that"){
					f=true;
					break;
				}
			}
			if(f){
				retStr=str;
				break;
			}
		}

		cout<<retStr<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
s = int(input())

def f(n):
  if n % 2 == 0:
    return n / 2
  else:
    return 3 * n + 1

a = [s]
cnt = 1
ans = -1
while True:
  a.append(f(a[cnt - 1]))
  if a.count(a[cnt]) > 1:
    ans = cnt + 1
    break
  cnt += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

template<typename T>
vector<T> divisor_count(T n) {
    vector<T> res(n + 1, 2);
    for(T i = 2; i <= n; i++) {
        for(T j = (2 * i); j <= n; j += i) {
            res[j]++;
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    auto dc = divisor_count(n);
    ll ans = -1;
    reps(i, 1, n + 1) {
        ans += i * dc[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81340
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char s[3];
int ans=0;
cin >> s;
REP(i,3) {
  if(s[i]=='1') ans++;
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int A, B;
  scanf("%d %d", &A, &B);
  char c[A + B + 2];
  scanf("%s", c);
  for(int i = 0; i < A + B + 1; i++){
    if(i != A && (0 > c[i] - '0' || c[i] - '0' > 9)){
      printf("No\n");
      return 0;
    }
    else if(i == A && c[i] != '-'){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <stack>
#define MAX 32

using namespace std;

//int main1()
//{
//    unsigned int a, b;
//    scanf("%d %d", &a, &b);

//    int arr[MAX] = {0}, brr[MAX] = {0};
//    int idx = MAX - 1;
//    while (a != 0)
//    {
//        arr[idx--] = a % 2;
//        a = a / 2;
//    }

//    idx = MAX - 1;
//    while (b != 0)
//    {
//        brr[idx--] = b % 2;
//        b = b / 2;
//    }

//    int AND[MAX] = {0}, OR[MAX] = {0}, XOR[MAX] = {0};
//    for (int loop = 0; loop < MAX; loop++)
//    {
//        if (arr[loop] == 1 && brr[loop] == 1)
//        {
//            AND[loop] = 1;
//        }
//        if (arr[loop] == 1 || brr[loop] == 1)
//        {
//            OR[loop] = 1;
//        }
//        if (arr[loop] != brr[loop])
//        {
//            XOR[loop] = 1;
//        }
//    }

//    for (int i = 0; i < MAX; i++)
//    {
//        printf("%d", AND[i]);
//    }
//    printf("\n");
//    for (int i = 0; i < MAX; i++)
//    {
//        printf("%d", OR[i]);
//    }
//    printf("\n");
//    for (int i = 0; i < MAX; i++)
//    {
//        printf("%d", XOR[i]);
//    }
//    printf("\n");

//    return 0;
//}

void outPut(int value)
{
    stack<int> S;
    for (int loop = 0; loop < 32; loop++)
    {
        if (value & (1 << loop))
        {
            S.push(1);
        }
        else
        {
            S.push(0);;
        }
    }
    while (!S.empty()) {
        printf("%d", S.top());
        S.pop();
    }
    printf("\n");
}

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    outPut(a & b);
    outPut(a | b);
    outPut(a ^ b);
    return 0;
}



Measured memory_bytes: 3216
import itertools
N,M,Q = map(int, input().split())
l = [[int(i) for i in input().split()] for j in range(Q)]
A = []
nums = list(range(1,M+1))
for B in itertools.combinations_with_replacement(nums, N):
	A.append(B)

A_s = []*len(A)
m = 0
for i in range(0,len(A)):
  for j in range(0,Q):
    if(A[i][l[j][1]-1] - A[i][l[j][0]-1] == l[j][2]):
      m = m + l[j][3]
  A_s.append(m)
  m = 0
ans = max(A_s)
print(ans)

Measured memory_bytes: 25368
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

int main(){

  ll n = in();
  ll m = in();
  vector<ll> w(n);
  vector<ll> v(n);
  REP(i, n){
    w[i] = in();
    v[i] = in();
  }
  vector<ll> dp(2 * m + 1, -INFLL);
  dp[0] = 0;
  REP(i, n){
    for(int j = m; j >= 0; j--){
      chmax(dp[j + w[i]], dp[j] + v[i]);
    }
  }
  ll ans = -INFLL;
  REP(i, m + 1){
    chmax(ans, dp[i]);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1792