akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int a,b;
    cin>>a>>b;
    if(a*500>=b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<atcoder/dsu>
using namespace std;
using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n,q; cin >> n >> q;
    dsu d(n);
    rep(i,q){
        int t; cin >> t;
        int u,v; cin >> u >> v;
        if(t == 0){
            d.merge(u,v);
        }
        else{
            if(d.same(u,v)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
}



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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main()
{
  int n,m;
  cin>>n>>m;
  ll arr[n];
  for(int i=0;i<n;i++)
   cin>>arr[i];
  vpll v;
  for(int i=0;i<m;i++)
  {
      ll x,y;
      cin>>x>>y;
      v.pb({y,x});
  }
  sort(v.begin(),v.end(),sortinrev);
  sort(arr,arr+n);
  ll sum=0;
  int l=0;
  for(int i=0;i<v.size();i++)
  {
      int p=1;
      ll a=v[i].second;
      ll val=v[i].first;
      while(l<n&&(a>0))
      {
          a--;
          if(arr[l]<val)
           sum+=val,l++;
           else
        {
            p=0;
            break;
        }
      }
      if(!p)
       break;
       //cout<<sum<<"\n";
  }
  for(int i=l;i<n;i++)
   sum+=arr[i];
   cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_115
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nk = ReadInts();
            var hs = new int[nk[0]];
            for(int i = 0; i < nk[0]; i++)
            {
                hs[i] = ReadInt();

            }
            Array.Sort(hs);
            int res = int.MaxValue;
            for (int i = 0; i <= nk[0] - nk[1]; i++)
            {
                int margin = hs[i + nk[1]-1] - hs[i];
                res = Math.Min(res, margin);
            }
            Console.WriteLine(res);
        }

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


Measured memory_bytes: 15452
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long llong;
#define MAXI 100000
#define MAXIV 1000000000
int main(void){
    llong n;
    cin>>n;
    llong x[MAXI],l[MAXI];
    vector<pair<llong,llong>> rob(n);
    for(llong i=0;i<n;i++){
        cin>>x[i]>>l[i];
        rob.at(i).second=x[i]-l[i];
        rob.at(i).first=x[i]+l[i];
    }
    //for(llong i=0;i<n;i++) cout<<rob.at(i).second<<rob.at(i).first<<endl;
    
    sort(rob.begin(),rob.end());
    llong ans=0; llong t=-MAXIV;
    for(llong i=0;i<n;i++){
       // cout<<t<<' '<<rob.at(i).second<<' ';
        if(t<=rob.at(i).second){
            ans++;
            t=rob.at(i).first;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
using namespace std;
int main()
{
 ll x,a;
 cin>>x>>a;
 if(x<a) cout<<0;
 else cout<<10;	
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N, M;
    cin >> N >> M;
    string ans = string(N, 'x');
    for (int i = 0; i < M; i++) {
        int s;
        char c;
        cin >> s >> c;
        if (ans[s - 1] != 'x' && ans[s - 1] != c) {
            cout << -1 << endl;
            return 0;
        }
        ans[s - 1] = c;
    }
    if (N > 1 && ans[0] == '0') {
        cout << -1 << endl;
        return 0;
    } else if (N > 1 && ans[0] == 'x')
        ans[0] = '1';
    for (int i = 0; i < N; i++) {
        if (ans[i] == 'x') ans[i] = '0';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,M=gets.split.map(&:to_i)
PY=M.times.map{gets.split.map(&:to_i)}

data=Array.new(N){[]}
M.times do |i|
    city_id = i
    prefe_id, year = PY[i]
    data[prefe_id-1] << [year, city_id]
end

N.times {|prefe_id| data[prefe_id].sort_by!{|year,_| year}}

ans=Array.new(M)
N.times do |prefe_id|
    data[prefe_id].size.times do |id|
        _, city_id = data[prefe_id][id]
        ans[city_id] = sprintf("%06d", prefe_id+1) + sprintf("%06d", id+1)
    end
end

puts ans


Measured memory_bytes: 43128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  ll x,k,d;cin>>x>>k>>d;

  ll num = abs(x) / d;
  ll dif = abs(x) - d*num;
  if(k < num){
    print(abs(abs(x) - k*d));
    return 0;
  }
  k -= num;
  if(k%2)print(abs(d-dif));
  else print(abs(dif));
  return 0;
}

Measured memory_bytes: 3640
A,B,K = list(map(int,input().split()))
if A+(K-1)*2 >= B:
  for i in range(A,B+1):
    print(i)
else:
  for i in range(K):
    print(A+i)
  for i in range(K-1,-1,-1):
    print(B-i)

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

int main(){
    int p,q,r;
    cin >> p >> q >> r;
    int res=p+q+r;
    if( res > p+q ) res = p+q;
    if( res > q+r ) res = q+r;
    if( res > r+p ) res = r+p;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#define INF 99999999
using namespace std;
void print_v(vector<long long> v){
    for(long long i : v){
        cout << i << " ";
    }
    cout << endl;
}
int main() {
    long long n, tmp;
    long long ans = 0;
    cin >> n;
    long long nn = n;
    vector<long long> a(n+1);
    bool u = true;
    for (long long i = 0; i < n; ++i) {
        cin >> tmp;
        a[i] = tmp;
    }
    if(n & 1) {
        a[n] = 0;
        ++nn;
    }
    //cout << nn << endl << n << endl;
    sort(a.begin(), a.end());
    //print_v(a);
    long long s = n & 1? 0 : 1;
    if(!s) { //奇数個
        for (long long i = 0; i < nn; i += 2) {
            if (a[i] != s or a[i + 1] != s) {
                u = false;
            }
            s += 2;
        }
    } else { //偶数語
        for (long long i = 1; i <= nn; i += 2) {
            if (a[i] != s or a[i + 1] != s) {
                u = false;
            }
            s += 2;
        }
    }

    long long mod = 1e9+7;
    if(u) {
        ans = 1;
        for (int i = 0; i < (n >> 1); ++i) {
            ans *= 2;
            ans %= mod;
        }
        //ans = pow(2, n >> 1);
    }
    cout << ans%mod << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;

int N, A, B, C;
int Li[8];

int magic(int i, int a, int b, int c, int x, int y, int z, int v)
{
	int ans = INT_MAX;
	if (i == N)
	{
		if (x == 0 || y == 0 || z == 0)
			ans = INT_MAX;
		else
			ans = abs(a - A) + abs(b - B) + abs(c - C) + (x + y + z - 3) * 10;
		return ans;
	}
	ans = min(ans, magic(i + 1, a + Li[i], b, c, x + 1, y, z, v));
	ans = min(ans, magic(i + 1, a, b + Li[i], c, x, y + 1, z, v));
	ans = min(ans, magic(i + 1, a, b, c + Li[i], x, y, z + 1, v));
	ans = min(ans, magic(i + 1, a, b, c, x, y, z, v + 1));
	return ans;
}

void func()
{
	cin >> N >> A >> B >> C;

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

	cout << magic(0,0,0,0,0,0,0,0) << endl;

	return;
}

int main() {

//	while (1)
		func();
	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define lli long long int
 
int main()
{   
    int n , m ;
    cin >> n >> m ;

    if (n == 1 && m == 0)
    {
        cout << "0\n";
        return 0 ;
    }
    
    int array [n];
 
    for (int i = 0 ; i < n ; i++)
    {
        array[i] = 0 ;
    }
    
    array[0] = 1 ;
 
    for (int i = 0 ; i < m ; i++)
    {
        int p , k ;
        cin >> p >> k ;
        
        if (array[p - 1] == 0)
        {
            array[p - 1] = k ;
        }
        else if (p - 1 == 0)
        {
            if (array[0] == 1)
            {
                array[0] = k ;
            }
            else if (array[0] == k)
            {
                array[0] = k ;
            }
            else 
            {
                cout << "-1\n" ;
                return 0 ;
            }
            
        }
        else if (array[p - 1] == k)
        {
            array[p - 1] = k ;
        }
        else
        {
            cout << "-1\n" ;
            return 0 ;
        }
    }
    
    if (array[0] == 0 && n > 1)
    {
        cout << "-1\n" ;
    }
    else
    {
        for (int i = 0 ; i < n ; i++)
        {
            cout << array[i];
        }
 
        cout << endl ;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
#define PI 3.141592653589
int main(int argc,char* argv[])
{
  double a,b,c,S,L,h;
  cin >> a >> b >> c;
  S=a*b*sin(PI*c/180)*0.5;
  L=a+b+sqrt(pow(a,2.0)+pow(b,2.0)-2*a*b*cos(PI*c/180));
  h=b*sin(PI*c/180);
  printf("%.8lf\n%.8lf\n%.8lf\n",S,L,h);
}

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

using namespace std;

int main() {
   int n, a, b;
   cin >> n;
   if(n==1)
   cout << "Hello World" << endl;
   else {
   cin >> a >> b;
   cout << a+b << endl;
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <numeric>

using namespace std;

typedef unsigned long ulong;

static unordered_map<ulong, unordered_map<ulong, ulong>> g_gcd_cache;
static unsigned long euclidean_gcd(unsigned long a, unsigned long b) {

    auto origA = a, origB = b;
    auto it1 = g_gcd_cache.find(a);
    if (it1 != g_gcd_cache.end())
    {
        auto it2 = it1->second.find(b);
        if (it2 != it1->second.end())
        {
            return it2->second;
        }
    }

    if (a < b)
    {
        auto v = euclidean_gcd(b, a);
        return v;
    }
    unsigned r;
    while ((r = a%b)) {
        a = b;
        b = r;
    }
    g_gcd_cache[origA][origB] = b;
    g_gcd_cache[origB][origA] = b;
    return b;
}


void processB()
{
    string input;
    cin >> input;

    int maxLen = 0;
    for (int start = 0; start < input.size(); start++)
    {
        int len = 0;
        for (int i = start; i < input.size(); i++)
        {
            char c = input[i];
            if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
                len++;
            }
            else {
                break;
            }
        }
        maxLen = std::max(maxLen, len);
    }
    cout << maxLen << endl;
}

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


Measured memory_bytes: 256
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(b % a == 0) System.out.println(a+b);
        else System.out.println(b-a);

    }
}


Measured memory_bytes: 25300
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }

int main(){
    int n; cin >> n;
    int ma = 0, sum = 0;
    rep(i,n){
        int x; cin >> x;
        ma = max(ma, x);
        sum += x;
    }
    if(sum - ma > ma) yes();
    else no();
    return 0;
}


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

int main(){
    using namespace std;

    string str;
    string inst;
    int a,b,n;
    string change;
    int i,j,k;
    string tem;

    cin>>str>>n;

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

        if(inst=="print"){
            cin>>a>>b;
            for(j=a;j<=b;j++){
                cout<<str[j];
            }
            cout<<endl;
        }else if(inst=="reverse"){
            cin>>a>>b;
            tem=str;
            for(j=0;(j+a)<=b;j++){
                str[j+a]=tem[b-j];
            }
        }else{
            cin>>a>>b>>change;
            for(j=a;j<=b;j++){
                { str[j]=change[j-a];}
            }
        }
            
    }

    return 0;

}


Measured memory_bytes: 3152
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

n_ = 2 * 10**6 + 5
mod = 10**9 + 7
fun = [1] * (n_ + 1)
for i in range(1, n_ + 1):
    fun[i] = fun[i - 1] * i % mod
rev = [1] * (n_ + 1)
rev[n_] = pow(fun[n_], mod - 2, mod)
for i in range(n_ - 1, 0, -1):
    rev[i] = rev[i + 1] * (i + 1) % mod

def nCr(n, r):
    if r > n:
        return 0
    return fun[n] * rev[r] % mod * rev[n - r] % mod

def modinv(x, mod):
    a, b = x, mod
    u, v = 1, 0
    while b:
        t = a // b
        a -= t * b; a, b = b, a
        u -= t * v; u, v = v, u
    return u % mod


inv26 = modinv(26, mod)


def solve():
    k = ni()
    s = ns()
    n = len(s)
    ans = 0
    v = 1
    u = pow(26, k, mod)
    for i in range(n, n+k+1):
        ans = (ans + nCr(i-1, n-1) * v * u) % mod
        u = u * inv26 % mod
        v = v * 25 % mod
    print(ans)
    return

solve()


Measured memory_bytes: 169200
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var str = Console.ReadLine();
        string[] strer = str.Split(' ');
        int a = int.Parse(strer[0]);
        int b = int.Parse(strer[1]);

        int d, r;
        double f;

        d = a / b;
        r = a % b;
        f = (double)a / b;

        Console.WriteLine(String.Format("{0} {1} {2:F5}", d, r, f));
        
    }
}


Measured memory_bytes: 19972
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
const int N = 2e3 + 5, M = 2e5;
int main()
{
    Hello
    string s, t;
    cin >> s >> t;
    cout << t + s;
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(){
  int n, s[100000], q, t[50000], c = 0, key = 0, left, mid, right, i, j;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &s[i]);
  scanf("%d", &q);
  for(i = 0; i < q; i++) scanf("%d", &t[i]);

  for(i = 0; i < q; i++){
    key = t[i];
    left = 0;
    right = n;
    while(left < right){
      mid = (left + right) / 2;
      if(key == s[mid]){
	c++;
	break;
      }
      else if(key < s[mid]) right = mid;
      else left = mid + 1;
    }
  }
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define M 998244353

ll fast(ll n,ll a)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        if(n%2==0)
        {
            ll res=fast(n/2,a);
            return (((res%M)*(res%M))%M);
        }
        else
        {
            ll res=fast(n/2,a);
            return (((((res%M)*a)%M)*res)%M);
        }
    }

}
const int N=1e6+5;
int d[N]={0};
void calc()
{
    int i,j;
    for(i=1;i<N;i++)
    {
        for(j=i;j<N;j+=i)
        {
            d[j]++;
        }
    }
}
int main()
{
   string S;
   cin>>S;
   int n=S.length();
   if(S[n-1]=='s')
    S+="es";
   else
    S+="s";

   cout<<S;



}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
	ll n,d;
	cin>>n>>d;
	ll cnt = 0;
	while(n--)
	{
		ll x,y;
		cin>>x>>y;
		ll sum = pow(x,2)+pow(y,2);
		double res = sqrt(sum);
		if(res<=d)
		{
			cnt++;
		}
	}
	cout<<cnt<<"\n";
}

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

const int N=2e5+20;

int n,mod=2019,m[N];
long long dp[N],p[N],ans;
char a[N];

int main()
{
	scanf(" %s",a+1);
	n=strlen(a+1);

	p[0]=1;
	for(int i=1;i<=n;i++)
	{
		p[i]=(p[i-1]*10)%mod;
		dp[i]=(dp[i-1]*10+a[i]-'0')%mod;
	}

	m[0]++;
	for(int i=1;i<=n;i++)
	{
		dp[i]=(dp[i-1]+(a[i]-'0')*p[n-i])%mod;
		m[dp[i]]++;
		ans+=m[dp[i]]-1;
	}

	printf("%lld",ans);
}

Measured memory_bytes: 7020
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,ans=0,p;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++){
        cin >> a.at(i);
        if (a.at(i)<=0) p=a.at(i)*(-1);
        else p=a.at(i);
        ans+=p;
    }
    sort(a.begin(),a.end());
    if (a.at(0)<=0 && a.at(n-1)>=0) cout << ans << endl;
    else if (a.at(n-1)<0) cout << ans+a.at(n-1)*2 << endl;
    else cout << ans-a.at(0)*2 << endl;
    int t=a.at(0);
    for (int i=1;i<n-1;i++){
        if (a.at(i)>=0) {cout << t << " " << a.at(i) << endl;
        t=t-a.at(i);}
    }
    cout << a.at(n-1) << " " << t << endl;
    t=a.at(n-1)-t;
    for (int i=1;i<n-1;i++){
        if (a.at(i)<0) cout << t << " " << a.at(i) << endl;
        t=t-a.at(i);
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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;
}

const ll N_MAX = 100005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll Combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

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

    ll N;
    cin >> N;
    ll M = (1ll<<N);
    vector<ll> S(M);
    REP(i, M) cin >> S[i];

    sort(S.rbegin(), S.rend());
    multiset<ll> mt;
    ll L = S[0];
    REP(i, M) mt.insert(S[i]);
    vector<ll> sumi;
    sumi.push_back(L);
    mt.erase(mt.find(L));

    REP(i, N){
    	ll s = sumi.size();
    	REP(j, s){
    		auto itr = mt.lower_bound(sumi[j]);
    		if(itr==mt.begin()){
    			cout << "No" << endl;
    			return 0;
    		}
    		itr--;
    		sumi.push_back(*itr);
    		mt.erase(itr);
    	}
    	sort(sumi.rbegin(), sumi.rend());
    }
    cout << "Yes" << endl; 
    return 0;
}

Measured memory_bytes: 19188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

#define ll long long
const ll  modu = 1e9 + 7;
using namespace std;

int Qa()
{
	int a, b, c;
	cin >> a >> b >> c;

	return min(a + b + 1, c) + b;
}

int main()
{
	vector<int> nums = { 2,1,3 };
	cout << Qa();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<complex>
#include<algorithm>
#include<cmath>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P complex<double>
#define X real()
#define Y imag()
const double EPS = 1e-9;

int n;
vector<P> vv;

int count_points(P a, P b, double mx, double my){
    P v = (a - b);
    double d_v = abs(v);
    if(d_v >= 2.0 + EPS) return 0;
    P m = v / 2.0 + b;
    double half_d_v = d_v / 2;
    double d = sqrt(1.0 - half_d_v * half_d_v);
    P u = (v * P(mx, my)) / abs(v) * d;
    //debug
    //cout <<"s " <<a <<", " <<b <<endl;
    //cout <<v <<", " <<d_v <<", " <<m <<", " <<d <<", " <<u <<endl;
    int cnt = 0;
    REP(i, n){
        P c = m + u;
        //cout <<"c = " <<c <<endl;
        //cout <<"! " <<i <<", " <<vv[i] <<": " <<abs(c - vv[i]) <<endl;
        if(abs(c - vv[i]) <= 1.0 + EPS) cnt++;
    }
    return cnt;
}

int main(){
    while(cin >>n && n){
        vv = vector<P>(n);
        REP(i, n) cin >>vv[i].X >>vv[i].Y;

        int ans = 1;
        REP(a, n){
            FOR(b, a + 1, n){
                ans = max(ans, count_points(vv[a], vv[b], 0, 1));
                ans = max(ans, count_points(vv[a], vv[b], 0, -1));
            }
        }
        cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 1276
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;

int n,m,q;
int a[50], b[50], c[50], d[50];
int A[10];
int ans = 0;

void dfs(int k){
  if (k == n){
    int s_num = 0;
    rep(i,q){
      if (A[b[i]] - A[a[i]] == c[i]) s_num += d[i];
    }
    ans = max(ans, s_num);
    return;
  }
  for (int j=A[k-1]; j<=m; j++) {
    A[k] = j;
    dfs(k+1);
  }
}

int main() {
  cin >> n >> m >> q;
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i];
    --b[i];
  }
  A[0] = 1;
  dfs(1);
  cout << ans << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

int main() {
  int H, W;
  cin >> H >> W;

  char s[H][W];
  rep (i, H) rep (j, W) cin >> s[i][j];

  int minDist[H][W];
  rep (i, H) rep (j, W) minDist[i][j] = INF;
  minDist[0][0] = 1;
  queue<pair<int, int>> Q;
  Q.push(mp(0, 0));

  while(!Q.empty()) {
    int x = Q.front().F;
    int y = Q.front().S;
    Q.pop();

    rep (i, 4) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (!(0 <= nx && nx < W && 0 <= ny && ny < H)) continue;
      if (s[ny][nx] == '#') continue;
      if (minDist[ny][nx] <= minDist[y][x] + 1) continue;
      minDist[ny][nx] = minDist[y][x] + 1;
      Q.push(mp(nx, ny));
    }
  }

  int bCnt = 0;
  rep (i, H) rep (j, W) if (s[i][j] == '#') bCnt++;

  if (minDist[H - 1][W - 1] == INF) cout << "-1" << endl;
  else cout << H * W - bCnt - minDist[H - 1][W - 1] << endl;
}


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

long long N, M, X;
long long C[12];
long long A[12][12];
long long m = 999999999999;

void r(long long n, long long c, const long long a[]) {
    for (int i = n + 1; i < N; i++) {
        long long b[12];
        bool flag = true;
        for (int j = 0; j < M; j++) {
            b[j] = a[j] + A[i][j];
            if (b[j] < X) flag = false;
        }
        if (flag && c + C[i] < m) {
            m = c + C[i];
        }
        r(i, c + C[i], b);
    }
}

int main(){
    //FILE *fp = fopen("in_3.txt", "r");
    FILE *fp = stdin;
    fscanf(fp, "%lld %lld %lld\n", &N, &M, &X);
    for (int i = 0; i < N; i++) {
        fscanf(fp, "%lld", &C[i]);
        for (int j = 0; j < M; j++) {
            fscanf(fp, "%lld", &A[i][j]);
        }
    }
    for (int i = 0; i < N; i++) {
        bool flag = true;
        for (int j = 0; j < M; j++) {
            if (A[i][j] < X) {
                flag = false;
                break;
            }
        }
        if (flag && C[i] < m) m = C[i];
        r(i, C[i], A[i]);
    }
    if (m == 999999999999) {
        printf("-1\n");
    } else {
        printf("%lld\n", m);
    }
    return 0;
}


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

using ll = long long;

int main()
{
    vector<ll> even, odd;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        if (i % 2 == 0)
            odd.push_back(a);
        else
            even.push_back(a);
    }
    vector<ll> ans;
    if (n % 2 == 0)
    {
        for (int i = even.size() - 1; 0 <= i; i--)
        {
            ans.push_back(even[i]);
        }
        for (int i = 0; i < odd.size(); i++)
        {
            ans.push_back(odd[i]);
        }
    }
    else
    {
        for (int i = odd.size() - 1; 0 <= i; i--)
        {
            ans.push_back(odd[i]);
        }
        for (int i = 0; i < even.size(); i++)
        {
            ans.push_back(even[i]);
        }
    }

    for (int i = 0; i < ans.size(); i++)
    {
        if (i == ans.size() - 1)
        {
            cout << ans[i] << endl;
        }
        else
        {
            cout << ans[i] << " ";
        }
    }
    return 0;
}

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

using namespace std;

int main(){

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

	int a[m];
	int s,b;
	int ans1=0;
	int ans2=0;
	for(int i=0;i<m;i++){
	
		cin>>a[i];
	}
	s=a[0];
	b=a[m-1];

	for(int i=x;i<n+1;i++){

		if(i<=b){
		
			for(int j=m-1;j>-1;j--){

				if(a[j]==i){
				
					ans1++;
					break;
				}
			}
		}
	}
	for(int i=x;i>-1;i--){
	
		if(i>=s){
		
			for(int j=0;j<m;j++){
			
				if(a[j]==i){
				
					ans2++;
					break;
				}
			}
		}
	}

	cout<<min(ans1,ans2)<<'\n';
	return 0;
}


Measured memory_bytes: 3636
# coding: utf-8
# Your code here!

n,k=[int(i) for i in input().split()]

td = []
for _ in range(n):
    t,d= [int(i) for i in input().split()]
    td.append([t-1,d])


td.sort(key= lambda x: x[1],reverse=True)


greedy = []
c=0
oisi = [0]*n
neta = [0]*n
ans = 0
for i in range(k):
    t_temp = td[i][0]
    d_temp = td[i][1]
#    print(neta,t_temp)
    ans += d_temp
    if neta[t_temp] == 0:
        c+=1
        oisi[t_temp] = d_temp
        neta[t_temp] += 1
    else:
        if oisi[t_temp] > d_temp:
            greedy.append(d_temp)
        else:
            greedy.append(oisi[t_temp])
            oisi[t_temp] = d_temp


#print(td)
ans += c*c
#print(c,ans)

amari=[]
for i in range(k,n):
    t_temp= td[i][0]
#    print(neta,t_temp)
    if neta[t_temp] == 0:
        amari.append(td[i][1])
        neta[t_temp] += 1

greedy.sort(reverse=True)
amari.sort()

#print(greedy)
#print(amari)

temp=ans
while(len(greedy)!= 0 and len(amari)!=0):
    a=greedy.pop()
    b=amari.pop()
    temp += b-a+2*c+1
    if ans < temp:
        ans = temp
    c+=1

print(ans)





Measured memory_bytes: 21656
m = int(input())
n = int(input())

X = [0 for i in range(n)]
Y = [0 for i in range(n)]

for l in range(n):
    X[l],Y[l] = [int(i) for i in input().split()]

ans = []
while True:
    flag = True
    for i in range(1, m+1):
        if not (i in Y) and not (i in ans):
            ans.append(i)

            for j in range(len(X))[::-1]:
                if X[j] == i:
                    X.pop(j)
                    Y.pop(j)
            flag = False
            break
    if flag:
        break

for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 5604
///*
#include<iostream>
#include<string>
using namespace std;

struct otoshidama {
	double money;
	string AD;
};

//1.0BTC=380000.0JPY

int main() {

	otoshidama okane[10];
	int n;
	double ans = 0;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> okane[i].money >> okane[i].AD;
		if (okane[i].AD == "JPY") ans += okane[i].money;
		else ans += okane[i].money * 380000;
	}

	cout << ans << endl;

	return 0;
}
//*/

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

int main() {
    int N, K, ans=0;
    int l[60];
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> l[i];

    sort(l, l + N, greater<int>());
    for (int i = 0; i < K; ++i) ans += l[i]; 
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinArr()
	N, _ := strconv.Atoi(list[0])
	M, _ := strconv.ParseFloat(list[1], 64)
	n := N
	m := int(math.Round(M * 100))
	fmt.Printf("%d\n", (n*m)/100)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 1772
#include <stdio.h>
#include <string.h>
int main()
{
    char str[1005];
    scanf("%s", str);

    int len = strlen(str);
    if(str[len-1] != 's')
    {
        for(int i = 0; str[i] != '\0'; i++)
        {
            printf("%c", str[i]);
        }
        printf("s\n");
    }
    else
    {
        for(int i = 0; str[i] != '\0'; i++)
        {
            printf("%c", str[i]);
        }
        printf("es\n");
    }
    return 0;
}

Measured memory_bytes: 1664
/*
ID:yaoxinw1
TASK:xxxx
LANG:C++
*/
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
int main() {
	string ans="";
	long long n;
	cin>>n;
	while(n) {
		long long s=n/-2,y=n%-2;
		if(y<0){
			y+=2;
			s++;
		}
		n=s;
		ans=(char)((int)y+'0')+ans;
	}
	if(ans=="")
		puts("0");
	else
		puts(ans.c_str());
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout <<"NO" <<endl;
    return 0;
}


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


typedef struct{
	char gara;
	int num;
}CARD_T;

int main()
{
	char in_str[120];
	int N;
	int bk;
	char bk_c, *tp;
	CARD_T box[36], box2[36], bk_box;
	int min_pos, flag;
	int i, j;


	fgets(in_str, sizeof(in_str), stdin);
	sscanf(in_str, "%d", &N);

	fgets(in_str, sizeof(in_str), stdin);
	tp = strtok(in_str, " ");
	i = 0;
	sscanf(tp, "%c%d", &bk_c, &bk);
	box[i].gara = box2[i].gara = bk_c;
	box[i].num = box2[i].num = bk;
	while( tp = strtok(NULL, " ") ){
		i++;
		sscanf(tp, "%c%d", &bk_c, &bk );
		box[i].gara = box2[i].gara = bk_c;
		box[i].num = box2[i].num = bk;
	}

	// バブルソート
	for(i = 0; i < N - 1; i++){
		for(j = N - 1; j > i; j--){
			if(box[j - 1].num > box[j].num){
				bk_box = box[j - 1];
				box[j - 1] = box[j];
				box[j] = bk_box;
			}
		}
	}

	for(i = 0; i < N; i++){
		printf("%c%d", box[i].gara, box[i].num);
		if(i != N - 1)
			printf(" ");
		else
			printf("\n");
	}
	printf("Stable\n");


	// 選択ソート
	for(i = 0; i < N - 1; i++){
		min_pos = i;
		for(j = i + 1; j < N; j++){
			if(box2[j].num < box2[min_pos].num)
				min_pos = j;
		}
		if(i != min_pos){
			bk_box = box2[min_pos];
			box2[min_pos] = box2[i];
			box2[i] = bk_box;
		}
	}

	flag = 1;
	for(i = 0; i < N; i++){
		printf("%c%d", box2[i].gara, box2[i].num);
		if(flag == 1 && box[i].gara != box2[i].gara)
			flag = 0;
		if(i != N - 1)
			printf(" ");
		else
			printf("\n");
	}

	if(flag == 1)
		printf("Stable\n");
	else
		printf("Not stable\n");

	return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>

int main(){
  int h, w;

  scanf("%d %d", &h, &w);

  char a[h+1][w+1];
  int i, j;

  for(i = 0; i < h; i++){
    scanf("%s", a[i]);
  }

  /*  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      printf("%c", a[i][j]);
    }
    printf("\n");
    }*/

  int tate[h], yoko[w];
  int tate_count, yoko_count;

  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      if(a[i][j] == '.'){
	yoko_count++;
      }
    }
    //printf("%d\n", yoko_count);
    if(yoko_count > 0 && yoko_count == w){
      yoko[i] = 1;
    }
    else{
      yoko[i] = 0;
    }
    yoko_count = 0;
  }

  for(j = 0; j < w; j++){
    for(i = 0; i < h; i++){
      if(a[i][j] == '.'){
	tate_count++;
      }
    }
    //printf("%d\n", tate_count);
    if(tate_count > 0 && tate_count == h){
      tate[j] = 1;
    }
    else{
      tate[j] = 0;
    }
    tate_count = 0;
  }

  int check = 0;

  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      if(yoko[i] == 0 && tate[j] == 0){
	printf("%c", a[i][j]);
	check = 1;
      }
    }
    if(check == 1){
      check = 0;
      printf("\n");
    }
  }
  
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if (a == b){
        cout << "a == b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a < b" << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>

int
main(int argc, char *argv[])
{
  double n, k;
  scanf("%lf %lf", &n, &k);

  int temp; double p, ans = 0;

  if(k > 1){
    for(int i = 1; i < (n > k ? k : (n + 1)); i++){
      p = 1; temp = i;
      while(temp < k){
	temp *= 2;
	p *= 0.5000;
      }
      ans += p / n;
    }
    ans += (n + 1 - (n > k ? k : (n + 1))) / n;
    printf("%.12lf\n", ans);
  }
  else if(k <= 1) printf("%d\n", 1);

  return 0;
}

Measured memory_bytes: 128
h, w, a, b = map(int, input().split(" "))
for i in range(h):
  str = ""
  for j in range(w):
    if i < b:
      if j < a:
        str += "1"
      else:
        str += "0"
    else:
      if j < a:
        str += "0"
      else:
        str += "1"
  print(str)


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

int main()
{
	int n;
	if (scanf("%d", &n) == 1)
	{
		if (n >= 1 && n < 1000) {
			printf("ABC");
		}
		else if (n >= 1000 && n <= 1998) {
			printf("ABD");
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[10000],i,j,k,l,cnt=0,r;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=n-1;i>=1;i--)
    {
        l=0,r=i-1;
        while(l<r)
        {
            if(a[l]+a[r]>a[i])
            {
                cnt+=r-l;
                r--;
            }
            else
                l++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

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

Measured memory_bytes: 19128
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
bool judge(ll k,V vec,ll &a,ll &b){
   // cout<<k<<endl;
    rep(i,vec.size()){
        vec[i] -= b*k;
    }
    sort(all(vec), greater<ll>());
    ll cnt = 0;
    rep(i,vec.size()){
        if(vec[i]<=0){
            break;
        }
        if(vec[i]%(a-b)==0){
            cnt += vec[i] / (a-b);
        }else{
            cnt += vec[i] / (a-b) + 1;
        }
    }
    return cnt <= k;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    V vec(n);
    rep(i,n)cin>>vec[i];
    ll MAX=1e9;
    ll Min = 0;
    rep(i,100){
        ll Half = (MAX + Min) / 2;
        if(judge(Half,vec,a,b)){
            MAX = Half;
        }else{
            Min = Half;
        }
    }
    cout << Min+1 << endl;
}


Measured memory_bytes: 1792
L=list()
R=list()
N,M=map(int,input().split())
for i in range(M):
  a,b=map(int,input().split())
  if a==1:
    L.append(b)
  elif b==1:
    L.append(a)
  if a==N:
    R.append(b)
  elif b==N:
    R.append(a)
L=set(L)
R=set(R)
if len(L&R)==0:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    REP(i, M) cin >> X[i];

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

    vector<int> h;
    REP(i, M-1) {
        h.push_back(abs(X[i+1] - X[i]));
    }

    int total = 0;
    REP(i, h.size()) {
        total += h[i];
    }
    sort(h.begin(), h.end());
    if (N >= M) {
        print(0);
    } else {
        int total = 0;
        REP(i, h.size()-N+1) total += h[i];
        print(total);
    }

}

signed main() {
    solve();
}


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

typedef long long ll;
#define pii pair<int ,int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005


int main()
{
    _FastIO;

    int n;
    cin >> n;
    if(n % 2)   n *= 2;
    cout << n << endl;
    return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

signed main(){

	int n, m;
	string s;
	cin >> n >> s;
	m = s.size();

	// n回虚無をするパターン数

	auto mpow = [&](i64 x, i64 y){
		i64 ret = y & 1 ? x : 1, z = x;
		while(z = (z * z) % MOD, y >>= 1)
			if(y & 1)
				ret = (ret * z) % MOD;

		return ret;
	};

	vector<i64> fac(2 * n + 1, 1), inv(2 * n + 1, 1);
	for(int i = 1; i <= 2 * n; ++i){
		fac[i] = (fac[i - 1] * i) % MOD;
		inv[i] = mpow(fac[i], MOD - 2);
	}

	vector<i64> dp(n + 1, 0);
	dp[0] = 1;
	for(int i = 0; i < n; ++i){
		vector<i64> nex(n + 1, 0);
		for(int j = 0; j < n; ++j){
			nex[j + 1] = (nex[j + 1] + dp[j] * 2) % MOD;
			nex[max(0, j - 1)] = (nex[max(0, j - 1)] + dp[j]) % MOD;
		}
		dp = move(nex);
	}
	cout << (dp[m] * mpow(mpow(2, m), MOD - 2)) % MOD;
}


Measured memory_bytes: 512
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

void show(vi b) {
	REP(i, b.size()) {
		cout << b[i] << " ";
	}
	cout << endl;
}

int main() {
	int N, M;
	cin >> N >> M;
	vi b(N), p(M);
	REP(i, N) {
		cin >> b[i];
	}
	REP(i, M) {
		cin >> p[i];
	}
	FOR(i, 1, M - 1) {
		p[i] += p[i - 1];
	}

	int ans = INF;
	REP(i, 2) {
		int pp = 0, st = i, step = 0;
		vi bb(b);
		REP(j, N) {
			if (j == p[pp]) {
				pp++;
				st = (st + 1) % 2;
			}
			if (bb[j] != st) {
				FOR(l, j, N) {
					if (l == N) {
						goto next;
					}
					if (bb[l] == st) {
						swap(bb[j], bb[l]);
						step += l - j;
						break;
					}
				}
			}
			//show(bb);
		}
		ans = min(ans, step);
	next:;
	}

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

Measured memory_bytes: 1216
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 < b)
			System.out.println("a < b");
		
		else if(a > b)
			System.out.println("a > b");
		
		else if(a == b)
			System.out.println("a == b");
		
		sc.close();

	}

}

Measured memory_bytes: 26288
N = int(input())
a = list(map(int,input().split()))
s = sum(a)
su = a[0]
ar = s - su
ans = abs(su-ar)
for i in range(1,N-1):
    su += a[i]
    ar = s - su
    if ans > abs(su-ar):
        ans = abs(su-ar)
print(ans)

Measured memory_bytes: 30564