akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	
	ll n;cin>>n;
	ll a[n];rep(i,0,n)cin>>a[i];
	ll num=1;
	rep(i,0,n){
		if(a[i]==num)num++;
	}
	if(num==1)cout<<-1;
	else cout<<n-num+1;
	return 0;
}



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

using namespace std;
mt19937_64 rng(58);

int rep[200002];
int rnk[200002];

int ds_find(int x) {
    if (rep[x] != x) {
        rep[x] = ds_find(rep[x]);
    }
    return rep[x];
}

void ds_union(int x, int y) {
    int xp = ds_find(x);
    int yp = ds_find(y);
    if (xp == yp) return;
    if (rnk[xp] < rnk[yp]) {
        rep[xp] = yp;
    } else if (rnk[xp] > rnk[yp]) {
        rep[yp] = xp;
    } else {
        rep[yp] = xp;
        rnk[xp]++;
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    vector<pair<int, int>> pt(n);
    for (int i = 0; i <= 200000; i++) {
        rep[i] = i;
        rnk[i] = 1;
    }
    for (int i = 0; i < n; i++) {
        cin >> pt[i].first >> pt[i].second;
    }
    vector<pair<int, int>> st = pt;
    sort(st.begin(), st.end());
    deque<int> q;
    for (auto s : st) {
        if (q.empty() || q.back() > s.second) {
            q.push_back(s.second);
        } else {
            int m = q.back();
            while (!q.empty() && q.back() < s.second) {
                ds_union(q.back(), s.second);
                q.pop_back();
            }
            q.push_back(m);
        }
    }
    vector<int> count(n + 1);
    for (int i = 0; i < n; i++) {
        count[ds_find(st[i].second)]++;
    }
    for (int i = 0; i < n; i++) {
        cout << count[ds_find(st[pt[i].first - 1].second)] << endl;
    }
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

struct Vec {
  ll x, y;
  bool operator < (const Vec& o) const {
    return atan2(x, y) < atan2(o.x, o.y);
  }
};

int main2() {
  int N; cin >> N;
  vector<Vec> v;
  REP(i, N) {
    ll x, y; cin >> x >> y;
    v.push_back((Vec){x, y});
  }
  sort(ALL(v));
  ll ans2 = 0;
  for (int i = 0; i < N; i++) {
    ll x = 0, y = 0;
    for (int k = 0; k < N; k++) {
      x += v[(i + k)%N].x;
      y += v[(i + k)%N].y;
      chmax(ans2, x*x + y*y);
    }
  }
  printf("%.10f\n", sqrt(ans2));
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#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<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
long long gcd(long long x1,long long x2)
{
	 if(!x2) 
	 return x1; 
	 else
	 return gcd(x2,x1%x2);
}
int main()
{
	long long n,a[105],ans=1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		ans*=a[i]/gcd(ans,a[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s = list(input())
    r = [0] * n
    g = [0] * n
    b = [0] * n
    # print(s)
    for i, rgb in enumerate(s):
        if rgb == 'R':
            r[i] += 1
        elif rgb == 'G':
            g[i] += 1
        else:
            b[i] += 1

        if i != 0:
            r[i] += r[i-1]
            g[i] += g[i-1]
            b[i] += b[i-1]
    # print(r)
    ans = 0
    mid = [0] * n
    # print('A')
    for i, rgb in enumerate(s):
        # print(i)

        # print('A')
        for j in range(1,i+1):
            # print(i,j,rgb)
            if i+j >= n or i-j < 0:
                break
            # print(s[i-j],rgb,s[i+j])
            if rgb != s[i-j] and s[i-j] != s[i+j] and rgb != s[i+j]:
                mid[i] += 1


    print(r[-1] * g[-1] * b[-1] - sum(mid))
    # # print(mid)
    # for i, ss in enumerate(s):
    #     if i == 0:
    #         continue
    #     if ss == 'R':
    #         tmp = g[i-1] * (b[-1] - b[i])
    #         tmp += b[i-1] * (g[-1] - g[i])
    #         tmp -= mid[i]
    #     elif ss == 'G':
    #         tmp = r[i-1] * (b[-1] - b[i])
    #         tmp += b[i-1] * (r[-1] - r[i])
    #         tmp -= mid[i]
    #     else:
    #         tmp = g[i-1] * (r[-1] - r[i])
    #         tmp += r[i-1] * (g[-1] - g[i])
    #         tmp -= mid[i]
    #     ans += tmp
    # print(ans)

if __name__=='__main__':
    main()


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

	int main () {
		
		int n, m;
		cin >> n >> m;
		
		int a[n+3];
		
		int sum = 0;
		
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
			sum += a[i];
		}
		
		sort (a, a + n);
		
		double frac = (double)sum / (4.0 * m);
		int x = a[n-m];
		if (x < frac) {
			cout << "No\n";
		}
		else {
			cout << "Yes\n";
		}
		
		return 0;
	}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

  int a = 'a';
  int z = 'z';
  long long c[z - a + 1] = { 0 };

  for ( auto& e : s ) {
    c[e-a]++;
  }

  long long x = 1 + s.size() * ( s.size() - 1 ) / 2;

  for ( int i = 0; i < z - a + 1; i++ ) {
    x -= c[i] * ( c[i] - 1 ) / 2;
  }

  cout << x << endl;

  return 0;
}


Measured memory_bytes: 644
#include <iostream>

using namespace std;

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

    return 0;
}

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

int main() {
	int a, b, q;	cin >> a >> b >> q;
	vector<LL> s(a + 2), t(b + 2), x(q);
	s[0] = -1e11;	s[a + 1] = 1e11;
	t[0] = -1e11;	t[b + 1] = 1e11;

	for (int i = 1; i <= a; i++) {
		cin >> s[i];
	}
	for (int i = 1; i <= b; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < q; i++) {
		cin >> x[i];
	}

	for (auto pos : x){
		LL ans = 1e11;
		auto s_itr = lower_bound(s.begin(), s.end(), pos);
		auto t_itr = lower_bound(t.begin(), t.end(), pos);
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				LL dist1 = abs(*(s_itr - i) - pos) + abs(*(s_itr - i) - *(t_itr - j));
				LL dist2 = abs(*(t_itr - j) - pos) + abs(*(s_itr - i) - *(t_itr - j));
				ans = min({ ans, dist1, dist2 });
			}
		}

		cout << ans << endl;
	}
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


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

const int MAX = 410;
int H,W;
ll numb=0,numw=0;
vector<string> fi;
bool seen[MAX][MAX];

void dfs(int x,int y){
    seen[x][y] = true;
    if(fi[x][y]=='#') numb++;
    else numw++;
    for(int dir=0;dir<4;dir++){
        int nx = x + dx[dir];
        int ny = y + dy[dir];
        if(nx<0 || nx >= H || ny < 0 || ny>=W) continue;
        if(fi[x][y]==fi[nx][ny]) continue;
        if(seen[nx][ny]) continue;
        dfs(nx,ny);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>H>>W;
    fi.resize(H);
    REP(i,H) cin>>fi[i];
    ll res=0;
    for(int x=0;x<H;++x){
        for(int y=0;y<W;++y){
            if(fi[x][y]=='.') continue;
            if(seen[x][y]) continue;
            numb = numw = 0;
            dfs(x,y);
            res += numb*numw;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

typedef vector<vector<ll>> mat;

mat mul(mat &A, mat&B,ll mo){
    mat C(A.size(),vector<ll>(B[0].size()));
    for(int i=0;i<A.size();i++){
        for(int k=0;k<B.size();k++){
            for(int j=0;j<B[0].size();j++){
                C[i][j]=(C[i][j]+A[i][k]*B[k][j])%mo;
            }
        }
    }
    return C;
}

mat pow(mat A,ll n,ll mo){
    mat B(A.size(),vector<ll>(A.size()));
    for(int i=0;i<A.size();i++){
        B[i][i]=1;
    }
    
    while(n>0){
        if(n&1) B=mul(B,A,mo);
        A=mul(A,A,mo);
        n/=2;
    }
    return B;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M,A,B,C,T;cin>>N>>M>>A>>B>>C>>T;
        if(N==0) break;
        mat S(N,vector<ll>(N));
        for(int i=0;i<N;i++){
            if(i-1>=0) S[i][i-1]=A;
            S[i][i]=B;
            if(i+1<N) S[i][i+1]=C;
        }
        
        S=pow(S,T,M);
        
        mat G(N,vector<ll>(1));
        
        for(int i=0;i<N;i++) cin>>G[i][0];
        
        S=mul(S,G,M);
        
        for(int i=0;i<N;i++){
            if(i) cout<<" ";
            cout<<S[i][0];
        }
        cout<<endl;
    }
}






Measured memory_bytes: 3240
#include <stdio.h>
#include <string.h>

int main(void){
	char str[21],gyaku[21];
	int mojisu,i;
	scanf("%s",str);
	mojisu = strlen(str);
	for(i = 0;i < mojisu;i++){
		gyaku[i] = str[mojisu-i-1];
	}
	gyaku[i] = '\0';
	
	printf("%s\n",gyaku);
	
	return 0;
}

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

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char[] sArray = sc.next().toCharArray();
        char[] tArray = sc.next().toCharArray();

        Arrays.sort(sArray);
        Arrays.sort(tArray);

        String sortS = new String(sArray);
        String sortT = new String(tArray);
        StringBuffer sb = new StringBuffer(sortT);
        sortT = sb.reverse().toString();

        System.out.println(sortS.compareTo(sortT) < 0? "Yes" : "No");
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using vll = vector<long long>;

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	ll n,input;
	in(n);
	vector<pair<ll, ll>> a(n);
	rep(i, 0, n) {
		in(input);
		a[i].first = input;
		a[i].second = i;
	}

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

	rep(i, 0, n) {
		for(int j=n-1;i>=0;j--){
			if (i != a[j].second) {
				outn(a[j].first);
				break;
			}
		}
	}

	return 0;
}



Measured memory_bytes: 4736
unittest
{
	assert( [ "4", "2 3 5", "2 1 5", "1 2 5", "3 2 5" ].parse.expand.solve == "2 2 6" );
	assert( [ "2", "0 0 100", "1 1 98" ].parse.expand.solve == "0 0 100" );
	assert( [ "3", "99 1 191", "100 1 192", "99 0 192" ].parse.expand.solve == "100 0 193" );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto xyhs = new long[ 3 ][ n ];
	foreach( ref xyh; xyhs )
	{
		input.popFront;
		xyh = input.front.split.to!( long[] );
	}
	return tuple( xyhs );
}

auto solve( long[ 3 ][] xyhs )
{
	foreach( cx; 0 .. 101 )
	{
		LOOP: foreach( cy; 0 .. 101 )
		{
			// 高さが0より大きくなるやつを判定基準にする
			auto ch = 0L;
			foreach( xyh; xyhs )
			{
				if( 0 < xyh[ 2 ] )
				{
					// max( ch - ( x - cx ).abs - ( y - cy ).abs, 0 ) == h
					// -->  ch == h + ( y - cy ).abs + ( x - cx ).abs
					auto ch_t = xyh[ 2 ] + ( xyh[ 0 ] - cx ).abs + ( xyh[ 1 ] - cy ).abs;
					if( ch_t != 0 )
					{
						ch = ch_t;
						break;
					}
				}
			}
			if( ch == 0 ) continue LOOP;
			
			// 高さが0になるやつ以外から基準を決める
			foreach( xyh; xyhs )
			{
				if( max( ch - ( xyh[ 0 ] - cx ).abs - ( xyh[ 1 ] - cy ).abs, 0 ) != xyh[ 2 ] ) continue LOOP;
			}
			return format("%d %d %d", cx, cy, ch );
		}
	}
	
	assert( false );
}


Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch-=1; cw-=1; dh-=1; dw-=1
area = [list(input()) for _ in range(h)]
inf = 10**100
dist = [[inf]*w for i in range(h)]
dwalk = [(0, 1), (0, -1), (1, 0), (-1, 0)]

q = deque([(ch, cw)])
dist[ch][cw] = 0
while q:
    y, x = q.popleft()
    for dy, dx in dwalk:
        py = y+dy; px = x+dx
        if not 0<=py<h: continue
        if not 0<=px<w: continue
        if area[py][px]=='#': continue
        if dist[py][px]>dist[y][x]:
            dist[py][px] = dist[y][x]
            q.appendleft((py, px))
    for dy in range(-2, 3):
        for dx in range(-2, 3):
            py = y+dy; px = x+dx
            if not 0<=py<h: continue
            if not 0<=px<w: continue
            if area[py][px]=='#': continue
            if dist[py][px]>dist[y][x]+1:
                dist[py][px] = dist[y][x]+1
                q.append((py, px))

if dist[dh][dw] == inf:
    print(-1)
else:
    print(dist[dh][dw])

Measured memory_bytes: 132520
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    if n>=30:
        print('Yes')
    else:
        print('No')

if __name__=='__main__':
    do()

Measured memory_bytes: 9180
#include<stdio.h>
#include<stdlib.h>
 
int main(void){
    int i,ex1,ex2,ex3,ex4,a,b,q;
    int dice[7];
    int command;
 
    for(i = 1;i <= 6;i++){
        scanf("%d",&dice[i]);
    }
 
    scanf("%d",&q);
 
    for(i = 0;i < q;i++){
        scanf("%d%d",&a,&b);
        while(1){
            command = rand() % 4;
            if(command == 0){
                ex1 = dice[1];
                ex2 = dice[2];
                ex3 = dice[5];
                ex4 = dice[6];
                dice[1] = ex3;
                dice[2] = ex1;
                dice[5] = ex4;
                dice[6] = ex2;
            }else if(command == 1){
                ex1 = dice[1];
                ex2 = dice[2];
                ex3 = dice[5];
                ex4 = dice[6];
                dice[1] = ex2;
                dice[2] = ex4;
                dice[5] = ex1;
                dice[6] = ex3;
            }else if(command == 2){
                ex1 = dice[1];
                ex2 = dice[3];
                ex3 = dice[4];
                ex4 = dice[6];
                dice[1] = ex3;
                dice[3] = ex1;
                dice[4] = ex4;
                dice[6] = ex2;
            }else if(command == 3){
                ex1 = dice[1];
                ex2 = dice[3];
                ex3 = dice[4];
                ex4 = dice[6];
                dice[1] = ex2;
                dice[3] = ex4;
                dice[4] = ex1;
                dice[6] = ex3;
            }
            if(dice[1] == a && dice[2] == b)
                break;
        }
        printf("%d\n",dice[3]);
    }
    return 0;
}

Measured memory_bytes: 596
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t A,B;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    double b;
    in >> A >> b;
    B = int64_t(b * 100 + 0.5);
    out << A * B / 100 << endl;
    return 0;
}
#endif


Measured memory_bytes: 3192
import scala.io.StdIn

object Main extends App {
  val ary  = StdIn.readLine().split(" ").map(_.toByte)
  val tup3 = ary match {case Array(a:Byte, b:Byte, c:Byte) => (a, b, c)}

  if(isMatch(tup3, 1)) println("YES")
  else println("NO")

  def isMatch(ary: (Byte, Byte, Byte), n: Byte): Boolean = {
    val (a, b, c) = ary
    if(b <= n) false
    else if((a * n) % b == c ) true
    else isMatch(ary, (n + 1.toByte).toByte)
  }
}


Measured memory_bytes: 25540
#include <stdio.h>
#include <math.h>
 
int main(int argc, const char * argv[]) {
    int n, i, j, k;
    int count;//?´???°????????°
    int l[100000];//?´???°?????°???????´?
     
    while (scanf("%d", &n) != EOF) {
        count = 0;
        //??¶??°??§?´???°???????????????2??????
        if (n >= 2){
            l[count++] = 2;
            //printf("l[%d] = %d\n",count - 1,l[count - 1]);//
        }
         
        //2????????§????????¶??°????´???°????????????????????§?\???°????????????
        if (n >= 3) {
            l[count++] = 3;
            //printf("l[%d] = %d\n",count - 1,l[count - 1]);//
             
            for (i = 5; i <= n; i+=2) {
                k = 0;
                //??¨??????????????????????????????
                for (j = 1; pow(l[j],2) <= i; j++) {
                    if (i % l[j] == 0) {
                        k = 1;
                        break;
                    }
                }
                 
                if (k == 0){
                    l[count++] = i;
                    //printf("l[%d] = %d\n",count - 1,l[count - 1]);//
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

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

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);

  ll H;
  cin >> H;

  ll ans = 0;
  ll tmp = 1;
  ll val = H;

  while (val != 0){
    ans += tmp;
    val = ll(val/2);
    tmp = tmp * 2;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>

#define int long long
#define double long double
#define incin(n) int (n); cin >> (n)
#define uniq(v) sort((v).begin(),(v).end()); (v).erase(unique((v).begin(),(v).end()),(v).end());
#define steprap(i,n,s) for(int (i)=0;i<(s)*(n);(i)+=(s))
#define rap(i,n) steprap((i),(n),1)

using intV = std::vector<int>;

using namespace std;
namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);
	int npr(int n,int r);
	int gcm(int a,int b);
	int lcm(int a,int b);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
	int npr(int n,int r){
		for (int i = 1; i < r; ++i)
		{
			n *= n-1;
		}
		return n;
	}
	int gcm(int a,int b){
		int p=max(a,b);
		int q=min(a,b);
		int r;
		while(true){
			if(p%q==0){
				return q;
			}
			r = p%q;
			p=q;
			q=r;
		}
	}
}

using namespace std;
// using StringMap = std::vector<std::vector<char>> map(h+2,vector<char>(w+2,'#'));
namespace tmp {
    template <typename T> bool inArry(T x,vector<T> v);
    template <typename T> void input(int n,vector<T> &v);

    template <typename T> bool inArry(T x,vector<T> v){
        int l = v.size();
        for(int i=0;i<l;i++){
            if(x==v[i]){
                return true;
            }
        }
        return false;
    }
    
    template <typename T> void input(int n,vector<T> &v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
    }
}

using namespace std;

signed main (){
	double a,b,c;
	cin >> a>>b>>c;
	double n = (a+b+c)/2;
	if(a+b==n || a+c==n || b+c==n){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<long int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  
  long int max=a[n-1];
  vector<long int> b(max+5);
  for(int i=0;i<n;i++){
    b[a[i]+2]++;
    b[a[i]+1]++;
    b[a[i]+0]++;
  }
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  cout<<b[0]<<endl;
}

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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n; ll l,t;
	cin>>n>>l>>t;
	ll a[n],d[n];
	f(i,0,n) cin>>a[i]>>d[i];
	ll x = 0;
	f(i,0,n) x += d[i] == 1;

	ll fi = 0;
	if (d[0] == 1) {
		f(i,1,n) if (d[i] == 2)
			if (a[i]-a[0]<=2*t)
				fi = (fi+1+(2*t-a[i]+a[0])/l)%n; 
	} else {
		f(i,1,n) if (d[i] == 1)
			if (l+a[0]-a[i]<=2*t)
				fi = (fi+2*n-1-(2*t-l-a[0]+a[i])/l%n)%n;
	}

	ll b[n];
	int cnt = 0;
	f(i,0,n) if (d[i] == 1) b[i] = (a[i]+t)%l;
	else b[i]=(l+a[i]-t%l)%l;
	f(i,1,n) if (d[i] == 2 && b[i] == b[0]) cnt++;
	ll v = b[0];
	sort(b,b+n);
	int j = 0;
	while (b[j] != v) j++;
	f(_,0,cnt) j++;
	f(_,0,fi) j = (j-1+n)%n;
	stringstream ss;
	f(i,0,n) ss << b[(j+i)%n] << endl;	
	cout << ss.str();

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}


Measured memory_bytes: 5636
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	int N, line[1000];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> line[i];
	}
	sort(line, line + N);
	double ans = 0;
	for (int i = 1; i < N - 2; ++i) {
		ans = max((double)(line[N - 1] + line[N - 2]) / (line[i] - line[i - 1]), ans);
	}
	ans = max((double)(line[N - 1] + line[N - 4]) / (line[N - 2] - line[N - 3]), ans);
	ans = max((double)(line[N - 3] + line[N - 4]) / (line[N - 1] - line[N - 2]), ans);
	printf("%.6lf\n", ans);
	return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ld long double
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
ll mod2=998244353;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactive problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
ll spf[1000005];

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<1000005; i++) {
        spf[i] = i; 
    }
    for (int i=4; i<1000005; i+=2) {
        spf[i] = 2; 
    }
  
    for (int i=3; i*i<1000005; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<1000005; j+=i) {
                if (spf[j]==j) {
                    spf[j] = i; 
                }
            }
        } 
    } 
} 

map<ll, ll> getFactorization(ll x) 
{ 
    map<ll, ll> ret; 
    while (x != 1) 
    { 
        ret[spf[x]]++; 
        x = x / spf[x]; 
    } 
    return ret; 
} 


int main(){ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    sieve();
    ll n;
    cin>>n;
    ll ans=0;
    for (int c = 1; c<n; ++c)
    {
        ll x = n-c;
        ll tot=1;
        map<ll, ll> m1 = getFactorization(x);
        for (auto j = m1.begin(); j != m1.end(); ++j)
        {
            tot = tot*(j->S+1);
        }
        ans+=tot;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 11456
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int a,b,h; cin>>a>>b>>h;
  int ans=(a+b)*h/2;
  cout<<ans<<endl;

  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] all = line.split(" ");

		ArrayList<Integer> allint = new ArrayList<Integer>();

		for (int i = 0; i < all.length; i++) {
			if (judge(all[i]) == true) {
				allint.add(Integer.parseInt(all[i]));
			} else if (all[i].equals("+")) {
				allint.set(allint.size() - 2, allint.get(allint.size() - 2)
						+ allint.get(allint.size() - 1));
				allint.remove(allint.size() - 1);
			} else if (all[i].equals("-")) {
				allint.set(allint.size() - 2, allint.get(allint.size() - 2)
						- allint.get(allint.size() - 1));
				allint.remove(allint.size() - 1);
			} else if (all[i].equals("*")) {
				allint.set(allint.size() - 2, allint.get(allint.size() - 2)
						* allint.get(allint.size() - 1));
				allint.remove(allint.size() - 1);
			}

		}

		System.out.println(allint.get(0));

	}

	String n;

	public Main(String n) {
		super();
		this.n = n;
	}

	public static boolean judge(String n) {
		try {
			Integer.parseInt(n);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}

	}
}

Measured memory_bytes: 26112
#include <stdio.h>
#include <ctype.h>
 
#define MAX 100000
#define _MAX 2000000

int par[MAX];
 
void init(int);
int depth(int);
int input(void);

char *p;
char in[_MAX];
int tree[MAX][20],idx[MAX];

int main(){
  int n,i,j;

  fread(in,sizeof(in),1,stdin);  
  p = in;

  n = input(); init(n);
  for(i = 0 ; i < n ; i++){
    int id,k,c;
 
    id = input();
    k = input();
    for(j = 0 ; j < k ; j++){
      c = input();
      par[c] = id;
      tree[id][idx[id]++] = c;
    }
  }
 
  for(i = 0 ; i < n ; i++){
    printf("node %d: parent = %d, depth = %d, "
           ,i,par[i],depth(i));
    
    if(par[i] == -1){
      printf("root, [");
    }else if(!idx[i]){
      printf("leaf, [");
    }else{
      printf("internal node, [");
    }

    for(j = 0 ; j < idx[i] ; j++){
      printf("%d",tree[i][j]);
      if(j < idx[i]-1) printf(", ");
    }
    puts("]");
  }
 
  return 0;
}

void init(int n){
  int i;
  for(i = 0 ; i < n ; i++){
    par[i] = -1;
  }
}

int depth(int x){
  if(par[x] == -1){
    return 0;
  }
  return depth(par[x]) + 1;
}

int input(){
  int val = 0;
  while(!isdigit(*p)) ++p;
  val = *p++&15;
  while(isdigit(*p)){
    val = (val<<3)+(val<<1)+(*p++&15);
  }
  return val;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	int d;
	double e;
	while(cin >> d >> e, d||e){
		double mini = 1e9;
		rep(i,d + 1){
			int j = d - i;
			mini = min(mini, abs(hypot(i,j) - e));
		}
		cout << fixed << setprecision(10) << mini << endl;
	}
}



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

int main(void){

  int MAX = 200000;
  int R[MAX],n;
  int maxv = -2000000000;
  int i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d", &R[i]);
  }
  int minv = R[0];
  for(i=1;i<n;i++){
    if(maxv<R[i]-minv) maxv = R[i]-minv;
    if(minv>R[i]) minv = R[i];
      }
  printf("%d\n",maxv);
  //  printf("minv;%d\n", minv);
  return 0;
}



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

int main()
{
	double a,b,c,d,e,f;
	double x,y;
	while(cin>>a>>b>>c>>d>>e>>f)
	{
		-1000 <= a, b, c, d, e, f <= 1000;
		x= (c*e-b*f)/(a*e-b*d);
		y= (c*d-a*f)/(b*d-a*e);
		if(x == -0.00){x=0.00;}
		if(y == -0.00){y=0.00;}
		cout<<setprecision(3);
                cout<<fixed;
		cout<<x<<" "<<y<<endl;
	}
	return 0;
}
	

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

using namespace std;

int main() {
  while (true) {
    int H, W;
    cin >> H >> W;
    if (H + W == 0) {
      break;
    }
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 update : [s,t)にxを加算する
 query : [s,t) の総和を出力する
 */
const ll INIT = 0;
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node, lazy;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
        lazy.resize(2 * N - 1, init_v);
    }
    
    ll merge(ll l,ll r){
        return l + r;
    }
    
    void lazy_evaluate(int k) {
        node[k] += lazy[k]; // add のため加算
        if (k < N - 1) {
            lazy[2 * k + 1] += lazy[k] / 2; // add のため加算
            lazy[2 * k + 2] += lazy[k] / 2;
        }
        lazy[k] = 0;
    }
    
    /* [a,b) 引数の範囲に注意!! s~tまでを更新→update(s,t+1,~) */
    ll update(int a, int b, int x) { return update(a, b, 0, 0, N, x); }
    ll update(int a, int b, int k, int l, int r, int x) {
        if (r <= a || b <= l) {
            lazy_evaluate(k); // nodeを参照する前には必ず更新
            return node[k];
        }
        if (a <= l && r <= b) {
            lazy[k] += (r - l) * x; // 参照区間が指定区間を完全に含んでいれば, 参照区間長*加算値分nodeに加算される
            lazy_evaluate(k);
            return node[k];
        }
        else {
            lazy_evaluate(k);
            ll vl = update(a, b, 2 * k + 1, l, (l + r) / 2, x);
            ll vr = update(a, b, 2 * k + 2, (l + r) / 2, r, x);
            return node[k] = merge(vl,vr);
        }
    }
    
    /* [a,b) 引数の範囲に注意!! */
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) {
            lazy_evaluate(k);
            return node[k];
        }
        else {
            lazy_evaluate(k);
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return merge(vl,vr);
        }
    }
};


int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    SegTree ST(n);
    int q; cin >> q;
    while(q--){
        int com; cin >> com;
        if(com == 0){
            int s,t,x; cin >> s >> t >> x;
            ST.update(s-1,t,x);
        }else{
            int s,t; cin >> s >> t;
            cout << ST.query(s-1,t) << endl;
        }
    }
}



Measured memory_bytes: 7072
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main ()
{
  prep();
  int a, b;
  cin >> a >> b;
  if (a > b){
      for (int i=0; i<a; i++){
          cout << b;
      }
  }else{
      for (int i=0; i<b; i++){
          cout << a;
      }
  }
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int main()
{
  int N;
  std::cin >> N;
  if(N == 1){
  	std::cout << "Hello World"<<std::endl;
  } else {
    int A, B;
    std::cin >> A >> B;
    std::cout << A+B<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}




//-----CODE------//
void topological_sort_BFS(vector<vector<int> >&GRAPH,vector<bool> & V,vector<int>& DEG, int NODE,vector<int>& sorted)
{
  queue<int> q;
  q.push(NODE);
  V[NODE] = true;
  while(!q.empty())
  {
    int u = q.front();
    q.pop();
    sorted.push_back(u);
    for (int i = 0; i < GRAPH[u].size(); i++)
    {
      int v = GRAPH[u][i];
      DEG[v]--;
      if((DEG[v] == 0)&&(V[v] == false))
      {
        V[v] = true;
        q.push(v);
      }
    }
    
  }
}

vector<int> topological_sort(vector<vector<int> >&GRAPH)
{
  int N = GRAPH.size();
  vector<bool> V(N,false);
  vector<int> DEG(N,0);
  vector<int> sorted;
  for (int i = 0; i < N ; i++)
  {
    for (int s = 0; s < GRAPH[i].size(); s++)
    {
      DEG[GRAPH[i][s]]++;
    }
  }
  for (int i = 0; i < N; i++)
  {
    if((DEG[i] == 0) && (V[i] == false))
    {
      topological_sort_BFS(GRAPH,V,DEG,i,sorted);
    }
  }
  
  return sorted;
}
void solve(void)
{
  int N;
  int M;
  cin>>N>>M;;
  vector<vector<int> > GRAPH(N);
  for (int i = 0; i < M; i++)
  {
    int A,B;
    cin>>A>>B;
    GRAPH[A].push_back(B);
  }
  vector<bool>V(N,false);
  vector<int> sorted;
  sorted = topological_sort(GRAPH);
  for (int i = 0; i < N; i++)
  {
    cout<<sorted[i]<<endl;
  }
  cout<<endl;
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}


Measured memory_bytes: 3968
import sys

k, s = map(int, sys.stdin.readline().split())

def main():
    cnt = 0
    for x in range(min(s, k) + 1):
        t = s - x
        if 0 <= t <= k:
            cnt += t + 1
        elif k < t <= k * 2:
            cnt += k + 1 - (t - k)
    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int sx, sy, tx, ty;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> sx >> sy >> tx >> ty;
    int w = tx - sx, h = ty - sy;
    cout << string(h, 'U');
    cout << string(w, 'R');
    cout << string(h, 'D');
    cout << string(w, 'L');
    cout << 'L';
    cout << string(h + 1, 'U');
    cout << string(w + 1, 'R');
    cout << 'D';
    cout << 'R';
    cout << string(h + 1, 'D');
    cout << string(w + 1, 'L');
    cout << 'U';
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mpr make_pair
#define PB push_back
#define FS first
#define SC second
typedef pair < int , int > pii;
typedef long long LL;
int n,m,a,b,rem[1005];
bool g[1005][1005];
int main(){
	int i,j,k;
	scanf("%d%d%d%d",&n,&m,&a,&b);
	int fi=-1,fj=-1;
	for(i=0;i<=n;++i){
		for(j=0;j<=m;++j){
			if(i*a+(n-i)*(m-a)==j*b+(m-j)*(n-b)){
				fi=i;fj=j;
				break;
			}
		}
		if(fi!=-1) break;
	}
	if(fi==-1)
		printf("-1\n");
	else{
		for(i=0;i<fi;++i) rem[i]=a;
		for(i=fi;i<n;++i) rem[i]=m-a;
		for(j=0;j<m;++j){
			int c=(j<fj?b:(n-b));
			if(!c) continue;
			vector < pii > vec;
			for(i=0;i<n;++i){
				if(rem[i]) vec.PB(mpr(rem[i],i));
			}
			sort(vec.begin(),vec.end());
			for(i=(int)vec.size()-1;i>=0;--i){
				--c;
				--rem[vec[i].SC];
				g[vec[i].SC][j]=1;
				if(!c) break;
			}
		}
	}
	for(i=0;i<n;++i){
		for(j=0;j<m;++j){
			putchar('0'+(int)g[i][j]);
		}
		putchar('\n');
	}
	return 0;
}

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

int main(void){
    int A, B;
    cin >> A >> B;
    if (A==B) cout << "Draw" <<endl;
    else if (A>B && 2<=B && B<=13) cout << "Alice" << endl;
    else if (A==1) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        for (int i = 0; i < 3; i++) {
                                System.out.print(sc.next().charAt(0));
                        }
                        System.out.println("");
                }
        }
}

Measured memory_bytes: 9556
#include <iostream>
#include <cmath>

using namespace std;

int isPrime(int n) {
  int flag = 1;
  for(int i=2; i<=sqrt(n) && flag==1; i++) {
    if(n%i == 0) {
      flag = 0;
    }
  }
  return flag;
}

int main() {

  int n;

  while(cin>>n && n!=0) {
    int ans = 0;
    for(int i=n+1; i<=2*n; i++) {
      if(isPrime(i)) {
	ans++;
      }
    }
    cout<<ans<<endl;
  }

}

Measured memory_bytes: 1160
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int a,b;
	cin>>a>>b;
	a += (b-a)*2;
	cout<<a<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

int main(){
	int n,m,na,nb;
	cin >> n >> m;
	vector<bool> a(n,false),b(n,false);
	for(int i=0;i<m;i++){
		cin >> na >> nb;
		if(na == 1) a[nb] = true;
		else if (nb == n) b[na] = true;
	}

	bool flag = false;
	for(int i=1;i<n;i++){
		if(a[i] && b[i]){
			flag = true;
			break;
		}
	}

	if(flag == true) cout << "POSSIBLE";
	else cout << "IMPOSSIBLE";

	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
for i in range(n):
  a.append(input())
b = []
for i in range(m):
  b.append(input())
flag = 0
judge = []
for i in range(n-m+1):
  judge = []
  for j in range(n-m+1):
    judge = []
    for k in range(m):
      judge.append(a[i+k][j:j+m])
    if judge == b:
      flag += 1
if flag == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9144
#include<stdio.h>
int main(void)
{
	int a,b,c,x,z,y;
	y=0;
	scanf("%d %d %d",&a,&b,&c);
	for(x=a;x<=b;x++) {
		z=c%x;
		if(z==0){
			if(z<=b){
				y++;
			}
		}
	}
	printf("%d\n",y);
	return 0;
}

Measured memory_bytes: 2720
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String W = sc.next();
        String W2 = W.toLowerCase();
        int count = 0;
        while(true)
        {
            String str = sc.next();
            if(str.equals("END_OF_TEXT"))
                break;
            else
            {
                String str2 = str.toLowerCase();
                if(str2.equals(W2))
                    count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26180
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,sin,cos
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=list(ss())

cntx=0

chk=True
i=0
j=len(s)-1



while chk:
    if s[i]==s[j]:
        i+=1
        j-=1
    
    elif s[i]!=s[j] and s[i]!="x" and s[j]!="x":
        print(-1)
        exit()
    
    elif s[i]!=s[j] and s[i]=="x" and s[j]!="x":
        cntx+=1
        i+=1
    
    elif s[i]!=s[j] and s[i]!="x" and s[j]=="x":
        cntx+=1
        j-=1
    
    #print(i,s[i],j,s[j])
    
    if i>=j:
        print(cntx)
        exit()


            
            
            
        
        
        
        
        
    







Measured memory_bytes: 74732
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, D: "List[int]", M: int, T: "List[int]"):
    
    D.sort()
    T.sort()

    from bisect import bisect_left, bisect_right

    if M > N:
        print(NO)
        exit()


    for i in range(M):
        lf = bisect_left(D, T[i])
        ri = bisect_right(D, T[i])
        if lf != ri:
            D[lf] = 0
        else:
            print(NO)
            exit()

    print(YES)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    M = int(next(tokens))  # type: int
    T = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, D, M, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 36940