akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

int a[7]={1, 3, 5, 7, 8, 10 ,12};
int b[4]={4, 6, 9, 11};

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

    if(x==2 || y==2) cout << "No" << endl;
    else {
        bool xf=false, yf=false;
        rep(i, 7) {
            if(x==a[i]) xf = true;
            if(y==a[i]) yf = true;
        }
        if(xf==yf) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        long V = long.Parse(str[1]);
        long[] A = new long[N];
        str = Console.ReadLine().Split(' ');
        for(int i=0;i<N;i++){
            A[i] = long.Parse(str[i]);
        }
        long[] B = new long[N];
        str = Console.ReadLine().Split(' ');
        for(int i=0;i<N;i++){
            B[i] = long.Parse(str[i]);
        }
        long[] C = new long[N];
        str = Console.ReadLine().Split(' ');
        for(int i=0;i<N;i++){
            C[i] = long.Parse(str[i]);
        }
        long[] D = new long[N];
        str = Console.ReadLine().Split(' ');
        for(int i=0;i<N;i++){
            D[i] = long.Parse(str[i]);
        }
        long[] X = new long[N*N];
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                X[i*N+j] = A[i] + B[j];
            }
        }
        Array.Sort(X);
        long[] Y = new long[N*N];
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                Y[i*N+j] = C[i] + D[j];
            }
        }
        Array.Sort(Y);
        long count = 0;
        {
            int p = 0;
            int q = N*N-1;
            while(p < N*N){
                long c = 1;
                while(p < N*N-1 && X[p] == X[p+1]){
                    c++;
                    p++;
                }
                long d = 0;
                while(q >= 0 && Y[q] + X[p] > V){
                    q--;
                }
                while(q >= 0 && Y[q] + X[p] == V){
                    d++;
                    q--;
                }
                p++;
                count += c*d;
            }
        }
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 25224
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- 出力
    putStrLn . show $ solve a

solve :: Int -> Int
solve a = (^) 2 (pred . length $ takeWhile (<= a) [2 ^ k | k <- [0..]])


Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

int dfs(int n,int a,int l){
    if(a == 4){
        if(n == 0) return 1;
        else return 0;
    }
    if(n == 0){
        return 1;
    }
    int cnt = 0;
    for(int i=l;i*i<=n;i++){
        cnt += dfs(n-i*i,a+1,i);
    }
    return cnt;
}

int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << dfs(n,0,1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int map[][];
	int w, h;
	LinkedList<P> s;
	LinkedList<P> t;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			w = sc.nextInt();
			h = sc.nextInt();
			if((w|h)==0) break;
			map = new int[h][w];
			s = new LinkedList<P>();
			t = new LinkedList<P>();
			for(int i=0;i<h;i++) for(int j=0;j<w;j++) {
				char c = sc.next().charAt(0);
				if( c == 'S' ) {
					map[i][j] = 0;
					s.add(new P(j, i));
				}
				else if( c == 'T' ) {
					map[i][j] = 0;
					t.add(new P(j, i));
				}
				else if(c == 'X' )map[i][j] = -1;
				else map[i][j] = c - '0';
			}
			System.out.println(bfs());
		}
	}
	
	int bfs() {
		PriorityQueue<Pair> que = new PriorityQueue<Pair>(1, new Comp());
		for(P p: s) {
			que.add(new Pair(p, false, 0));
			que.add(new Pair(p, true, 0));
		}
		HashSet<Pair> isVisited = new HashSet<Pair>();
		for(;!que.isEmpty();) {
			Pair now = que.remove();
			P p = now.p;
			if(isGoal(p)) return now.t;
			if(isVisited.contains(now))continue;
			isVisited.add(now);
			for(int i=1;i<=3;i++) {
				for(int dy=-(3-i);dy<=(3-i);dy++) {
					int dx = now.left? i:-i;
					if(canMove(p.x+dx, p.y+dy)) {
						que.add(new Pair(new P(p.x+dx, p.y+dy),
								!now.left, 
								now.t + map[p.y+dy][p.x+dx]));
					}
				}
			}
		}
		
		
		return -1;
	}
	
	boolean isGoal(P p) {
		for(P pos: t) 
			if(p.x == pos.x && p.y == pos.y) return true;
		return false;
	}
	
	boolean canMove(int x, int y) {
		return 0 <= x && 0 <= y && x < w && y < h && map[y][x] >= 0 ;
	}

	public static void main(String[] args) {
		new Main().run();
	}
	
	class P {
		int x, y;
		P(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
	
	class Pair{
		P p;
		boolean left;
		int t;
		Pair(P p, boolean left, int t) {
			this.p = p;
			this.t = t;
			this.left = left;
		}
		@Override
		public int hashCode() {
			// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
			return p.y*60+p.x*2+(left?1:0);
		}
		public boolean equals(Object o) {
			Pair pp = (Pair) o;
			return left&pp.left && p.x == pp.p.x && p.y == pp.p.y;
		}
	}
	
	class Comp implements Comparator<Pair> {
		
		@Override
		public int compare(Pair o1, Pair o2) {
			// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
			Pair p1 = (Pair) o1;
			Pair p2 = (Pair) o2;
			return p1.t-p2.t;
		}
	}
}

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

int main(){
  int n, n1, sn=0;
  cin >> n;
  n1 = n;
  for(int i=0; i<11; i++){
    sn += n1%10;
    n1 /= 10;
  }
  if(n%sn==0)cout << "Yes";
  else cout << "No";
  return 0;
}

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

using namespace std;

signed main(){
	int a , b ;
	cin>>a>>b;
	if(a < b) cout<<min(a , b - a)<<endl;
	else if(a % b == 0) cout<<0<<endl;
	else{
		a %= b;
		cout<<abs(a - b)<<endl;
    }
}

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

int main() {
	int N;
	int x = 0;
	int max = 0;
	char chr[100];

	cin >> N >> chr;

	for (int i = 0; i < N; i++) {
		if (chr[i] == 'I') {
			x++;
		}
		else if(chr[i] == 'D'){
			x--;
		}

		if (x > max) {
			max = x;
		}
	}

	cout << max << endl;
}

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

public class Program
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine();
        var gusu = input.Where((c, i) => i % 2 == 0).All(c => c == 'R' || c == 'U' || c == 'D');
        var kisu = input.Where((c, i) => i % 2 == 1).All(c => c == 'L' || c == 'U' || c == 'D');
        Console.WriteLine(gusu && kisu ? "Yes" : "No");
    }
}

Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
#define int long long

signed main() {
	int a, b, c;
	string s;
	cin >> a >> b >> c;

	//vector<int> v(n);
	//for (size_t i = 0; i < n; i++)
	//{
	//	cin >> v[i];
	//}

	if (a < c && b > c) {
		cout << "Yes" << endl;
	}
	else if(a > c && b < c){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}




Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    long long N, K;
    cin >> N >> K;

    vector<long long> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    vector<long long> b;
    for (int i = 0; i < N; i++) {
        long long sum = 0;
        for (int j = i; j < N; j++) {
            sum += a[j];
            b.push_back(sum);
        }
    }

    vector<long long> cand = b;
    for (long long i = 55; i >= 0; i--) {
        vector<long long> d;
        for (int j = 0; j < cand.size(); j++) if (cand[j] & (1LL << i))d.push_back(cand[j]);
        if (d.size() >= K) cand = d;
    }

    if (cand.size() < K) cout << 0 << endl;
    else {
        long long ans = cand.front();
        for (auto x : cand) ans &= x;
        cout << ans << endl;
    }

    return 0;
}

















































Measured memory_bytes: 10096
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int a,b,c=1,d=0;
    cin>>a>>b;
    while(true){
    if(c>=b) break;
    c=c-1+a;
    d++;
    //cout<<c<<"\n";
    }
    cout<<d<<"\n";
    }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
public class Main{
    public static void main(String[] arg)throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String strARY[] = str.split(" ");
		int a = Integer.parseInt(strARY[0]);
		int b = Integer.parseInt(strARY[1]);
		
		double m = 3.305785;
		
		System.out.println((double)a*b/m);
    }
}

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

//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define FS first
#define SE second

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal var
//------------------------------------------


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int N;
  str S;
  int K;
  char c;
  cin >> N ;
  cin >> S ;
  cin >> K ;
  str ans = S;
  c = S[K-1];
  EACH(i,S){
    if(*i!=c) ans[i-S.begin()]='*';
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
n = int(input())
aa = list(map(int,input().split()))

ans = [[0]*w for _ in range(h)]
nums = []

for i in range(n):
  for j in range(aa[i]):
    nums.append(i+1)
  
for i in range(len(nums)):  
  ans[i//w][i%w] = nums[i]  
  
for hi in range(h):
  if hi % 2 == 1:    
    print(' '.join(map(str,list(reversed(ans[hi])))))
  else:
    print(' '.join(map(str,ans[hi])))

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 2147483647;
const ll MAX_N = 100010;

struct SegmentTree {
private:
    ll n;
    vector<ll> node;

public:

    SegmentTree(vector<ll> v) {
        ll sz = v.size();
        n = 1;
        while(n < sz) {
            n *= 2;
        }
        node.resize(2*n - 1, INF);
        rep(i, sz) {
            node[i+n-1] = v[i];
        }
        for(ll i = n-2; i >= 0; i--) {
            node[i] = min(node[2*i + 1], node[2*i + 2]);
        }
    }

    // i番目の葉の値をxに変える
    void update(ll i, ll x) {
        i += n-1;  // i番目の葉のノード番号
        node[i] = x;
        while(i > 0) {
            i = (i - 1)/2;  // ノードiの親ノードの番号に変える
            node[i] = min(node[2*i + 1], node[2*i + 2]);  // 左右の子のminを計算する
        }
    }

    // 区間[a,b)の最小値を返す
    ll getmin(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
        // 区間[a,b)に対するクエリについてノードk(区間[l, r)担当)が答える
        if(r < 0) {
            r = n;  // 最初に呼び出されたときの対象区間は[0,n)
        }
        if(b <= l || r <= a) {
            return INF;  // 区間が被らない場合はINFを返す
        }
        if(a <= l && r <= b) {
            return node[k];  // ノードkの担当範囲が区間[a,b)に完全に含まれる
        }
        // 一部だけ範囲が被る場合は左右の子に委託する
        ll c1 = getmin(a, b, 2*k + 1, l, (l + r)/2);
        ll c2 = getmin(a, b, 2*k + 2, (l + r)/2, r);
        return min(c1, c2);  // 左右の子の値のminをとる
    }

};

int main() {
    ll n, q;
    cin >> n >> q;
    
    SegmentTree seg(vector<ll>(n, INF));
    rep(i, q) {
        ll c, x, y;
        cin >> c >> x >> y;
        if(c == 0) {
            seg.update(x, y);
        }
        else {
            out(seg.getmin(x, y+1));
        }
    }
    
    re0;
}


Measured memory_bytes: 5656
#Infinite Coins
n=parse(Int,readline())
a=parse(Int,readline())
flag=1
for j = 0 : a
    for i = 0 : 20
        if j + 500*i == n
           global flag = 0
        end
    end
end
if flag == 0
  println("Yes")
else
  println("No")
end

Measured memory_bytes: 155996
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {for(auto x : v) cout << x << ' '; cout << endl;}
#define printn(v, n) {for(int _i = 0; _i < n; _i++) cout << *(v + _i) << ' '; cout << endl;}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
const int MAXN = 1e3 + 20;
int n;
int a[MAXN][MAXN];

int get_node(int x, int y){
	if(x > y) swap(x, y);
	return x * n + y;
}

vector<int> graph[MAXN * MAXN];
int tin[MAXN * MAXN], tout[MAXN * MAXN], t;
vector<int> order;
bool dfs(int node) {
    tin[node] = t++;
    for(auto to : graph[node]) {
        if(tout[to]) continue;
        if(tin[to]) return false;
        else {
            bool tmp = dfs(to);
            if(!tmp) return false;
        }
    }
    tout[node] = t++;
    order.push_back(node);
    return true;
}
bool tp_sort() {
    memset(tin, 0, sizeof(tin));
    memset(tout, 0, sizeof(tout));
    t = 1;
    // loop through all possible root
    for(int i = 0; i < n * n; i++) {
    	if(i / n >= i % n)
    		continue;
        if(!tin[i]) {
            bool tmp = dfs(i);
            if(!tmp) return false;
        }
    }
    return true;
}

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

    cin >> n;
    for(int i = 0; i < n; i++) {
    	for(int j = 0; j < n - 1; j++) {
    		cin >> a[i][j];
    		a[i][j]--;
    		if(j)
    			graph[get_node(i, a[i][j - 1])].push_back(get_node(i, a[i][j]));
    	}
    }
    int valid = tp_sort();
    reverse(order.begin(), order.end());
    if(!valid) {
    	cout << -1 << endl;
    	return 0;
    }

    vector<int> cur(n, 1);
    for(int i : order) {
    	int x = i / n, y = i % n;
    	int d = max(cur[x], cur[y]);
    	cur[x] = d + 1;
    	cur[y] = d + 1;
    }
    cout << *max_element(cur.begin(), cur.end()) - 1 << endl;
    //print(order);

    return 0;
}











Measured memory_bytes: 54648
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"----------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define bug(x) cerr << "[" << #x << "] = ["<<x<<"]"<<'\n'
using namespace std;
ll  n,d,a;
vector<pair<ll,ll> > v;
ll  ara[200009];
int main()
{
    fast;
    cin>>n>>d>>a;
    for(ll  i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        v.pb(mp(a,b));
    }
    sort(v.begin(),v.end());
    ll  ans=0;
    int ind=0;
    for(ll  i=0;i<n;i++)
    {
        ll  dd=(v[i].second+a-1)/a;
        if(dd>ara[i])
        {
            int dis=dd-ara[i];
            ans+=dis;
            ara[i]+=dis;
            while(ind<n and v[ind].first<=v[i].first+2*d) ind++;
            ara[ind]-=dis;
        }
        ara[i+1]+=ara[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6256
#include<stdio.h>
#include<math.h>
int main(void){
  int a,b,i;
  scanf("%d%d",&a,&b);
  for(i=1;b>=i;i*=10);
  puts(sqrt(a*i+b)-(int)sqrt(a*i+b)?"No":"Yes");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    LL a, b, c , d;
    cin >> a >> b >> c >> d;

    vector<LL> Cross(4, 0);
    Cross[0] = a*c;
    Cross[1] = a*d;
    Cross[2] = b*c;
    Cross[3] = b*d;

    LL ans = *max_element(Cross.begin(), Cross.end());
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		long[] b = new long[x + 1];
		long[] a = new long[x];
		for (int i = 0; i < x + 1; i++) b[i] = sc.nextLong();
		for(int i = 0;i<x;i++)a[i]=sc.nextLong();
		long output = 0;
		for(int i = 0;i<x;i++) {
			long v = Math.min(a[i],b[i]);
			a[i]-=v;
			b[i]-=v;
			output+=v;
			v=Math.min(a[i],b[i+1]);
			a[i]-=v;
			b[i+1]-=v;
			output+=v;
		}
		System.out.println(output);
		
	}
}


Measured memory_bytes: 83164
#include <iostream>

using namespace std;

int main()
{
    int N, D, X;

    cin >> N >> D >> X;
    
    int A[N];
    int ans = X;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= D; j++) {
            if (D >= (1 + A[i] * (j - 1))) {
                  ans++;
            }
        }
    }

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A_len = sum(A)

tyuuou = float(A_len) / 2


index = 0
s = 0
flag = 0 # 0 left, 1 right
f = 0
nokori = 0
for i in range(N-1):
    s += A[i]
    if s >= tyuuou:
        index = i
        nokori = A_len - s
        if s-A[i] > nokori:
            index -= 1
            s -= A[i]
            nokori += A[i]
        f = 1
        break
if f==0:
    index = N-2
    nokori = A_len - s

print(abs(nokori-s))




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

using namespace std;

long long inf=1000000007;

int main(){
	int n;
	cin>>n;
	long long ans=1;
	long long ruiseki=0;
	long long pre=-1;
	bool flag=false;

	for(int i=0;i<n;i++){
		long long a;
		cin>>a;
		ans*=a;

		while(a>=10){
			a/=10;
			ruiseki++;
		}

		if(ruiseki>18 || ans>1000000000000000000 || ans<0 || pre>ans){
			flag=true;
		}

		if(a==0){
			cout<<0<<endl;
			return 0;
		}

		pre=ans;
	}

	if(flag) cout<<-1<<endl;
	else cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3636
using System;
public class Hello
{
    public static void Main ()
    {
        string[] str = Console.ReadLine().Split();
        int[] a = new int[3];
        for(int i=0;i<3;i++)
        {
            a[i] = int.Parse(str[i]);
        }
        Array.Sort(a);
        Console.WriteLine(a[0] + " " + a[1] +" " + a[2]);
        
        return ;
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    double h;
    cin >> n >> h;

    vector<double> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    sort(ALL(b));
    double m = *max_element(ALL(a));
    auto itr = lower_bound(ALL(b), m);

    sort(ALL(b), greater<double>());
    int cnt = 0;

    rep(i, b.end() - itr)
    {
        h -= b[i];
        cnt++;
        if (h <= 0)
        {
            OP(cnt);
            return 0;
        }
    }

    cnt += ceil(h / m);
    OP(cnt);

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N ;
  if( N[1]==N[2] &&( N[0]==N[1] || N[2]==N[3] ) ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
def main():
  S = input()
  flag1 = (S[0] == 'A')
  flag2 = (S[2:-1].count('C') == 1)
  flag3 = (S.replace('A', '').replace('C', '').lower()
           == S.replace('A', '').replace('C', ''))

  if flag1 and flag2 and flag3:
    print('AC')
  else:
    print('WA')


if __name__ == "__main__":
  main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)          
{
	char ctype;
	int cnumber;
	int have[4][14];
	int n;
	int i, j;

	for (i = 0; i < 4; i++) 
	{
		for (j = 0;j < 14; j++)
		{
			have[i][j] = 0;
		}
	}

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%*c%c %d", &ctype, &cnumber);
		
		if (ctype == 'S')
		{	
			have[0][cnumber] = 1;
		}
		if (ctype == 'H')
		{
			have[1][cnumber] = 1;
		}
		if (ctype == 'C')
		{
			have[2][cnumber] = 1;
		}
		if (ctype == 'D')
		{
			have[3][cnumber] = 1;
		}
	
	}
	for (i = 0; i < 4; i++)
	{
		for (j = 1; j < 14; j++)
		{
			if (have[i][j] == 0 && i == 0) printf("S %d\n", j);
			if (have[i][j] == 0 && i == 1) printf("H %d\n", j);
			if (have[i][j] == 0 && i == 2) printf("C %d\n", j);
			if (have[i][j] == 0 && i == 3) printf("D %d\n", j);


		}
	}

	return 0;
}

Measured memory_bytes: 596
# ABC138D - Ki
import sys

input = sys.stdin.readline
sys.setrecursionlimit(2 * 10 ** 5 + 3)


def dfs(v: int, p: int) -> None:
    x = cnt[v]
    for u in T[v]:
        if u != p:  # p: parent -> skip
            cnt[u] += x  # cumulative sum
            dfs(u, v)


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, cnt
    N, Q = tuple(map(int, input().split()))  # vertices and queues
    E = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # tree, N+1: 1-idx
    for a, b in E:
        T[a] += [b]
        T[b] += [a]
    cnt = [0] * (N + 1)
    for p, x in P:
        cnt[p] += x  # increase vertex p by x
    dfs(1, -1)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

Measured memory_bytes: 265740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B_012_49
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //new Logic_A().Start();
            new Logic_B().Start();
            Console.ReadLine();
        }

        public class Logic_B
        {
            public void Start()
            {
                var S = Console.ReadLine().Split(' ');
                var H = Convert.ToInt32(S[0]);
                var W = Convert.ToInt32(S[1]);
                var imageList = new List<string>();

                for (int i = 0; i < H; i++)
                {
                    imageList.Add(Console.ReadLine());
                }

                foreach (var t in imageList)
                {
                    Console.WriteLine(t);
                    Console.WriteLine(t);
                }
            }
        }

        public class Logic_A
        {
            public void Start()
            {
                var str = Console.ReadLine();

                Console.WriteLine("aeiou".Contains(str) ? "vowel" : "consonant");
            }
        }
    }
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

void solve(long long N, long long K)
{
    int ans = 0;
    while (N >= K)
    {
        N /= K;
        ans++;
    }
    ans++;
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
from itertools import groupby
S = input()
K = int(input())
if len(set(list(S)))==1:
  print(len(S)*K//2)
  exit()
ans = 0
L = []
for key, val in groupby(S):
  tmp = len(list(val))
  L.append(tmp)
sum_A = sum(k//2 for k in L)
ans = sum_A * K
if S[0] == S[-1]:
  ans += ((L[0]+L[-1])//2 - (L[0]//2+L[-1]//2))*(K-1)
print(ans)

Measured memory_bytes: 3316
N, M = gets.split.map(&:to_i)
as = Array.new(N)
bs = Array.new(N)
N.times do |i|
  as[i], bs[i] = gets.split.map(&:to_i)
end
cs = Array.new(M)
ds = Array.new(M)
M.times do |i|
  cs[i], ds[i] = gets.split.map(&:to_i)
end

N.times do |i|
  ans = M.times.min_by do |j|
    (as[i] - cs[j]).abs + (bs[i] - ds[j]).abs
  end
  puts ans + 1
end


Measured memory_bytes: 1788
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
vector<int> vertexs[400000];
int cost[400000];
void solve() {
    int x, y, z, n, m, s, t;
    cin >> x >> y >> z >> n >> m >> s >> t;
    s--;
    t--;
    pair<int, int> start, ending;
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        b += x;
        if (i == s) {
            start = make_pair(a,b);
        }
        vertexs[a].push_back(b);
        vertexs[b].push_back(a);
    }
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        a += x;
        b += x + y;
        if (i == t) {
            ending = make_pair(a,b);
        }
        vertexs[a].push_back(b);
        vertexs[b].push_back(a);
    }
    queue<int> next;
    next.push(start.first);
    next.push(start.second);
    REP(i, 400000) {
        cost[i] = 1e9;
    }
    cost[start.first] = 0;
    cost[start.second] = 0;
    int ans = 1e9;
    while (next.empty() == false) {
        int now = next.front();
        next.pop();
        for (auto x : vertexs[now]) {
            int nextcost = cost[now] + 1;
            if (cost[x] > nextcost) {
                cost[x] = nextcost;
                next.push(x);
            }
        }
    }
    ans = min(cost[ending.first], cost[ending.second]) + 1;
    if (ans > 1e6) ans = -1;
    cout << ans << endl;
}

int main() {
    init();
    solve();
}


Measured memory_bytes: 21660
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ss second
#define ff first
#define endl "\n";
int32_t main(){
	int n;
	cin>>n;
	int k=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(x!=i+1) k++;
	}
	if(k==2||k==0){cout<<"YES"<<endl;}
	else{cout<<"NO"<<endl;}
}

Measured memory_bytes: 256
let rec f x =
  if x mod 2 = 0 then
    1 + f (x/2)
  else
    0
let () =
  let n = Scanf.scanf "%d" (fun x -> x) in
  let ss = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  Array.to_list ss
  |> List.filter (fun x -> x mod 2 = 0)
  |> List.map (fun x -> f x)
  |> List.sort compare
  |> List.fold_left (+) 0
  |> Printf.printf "%d\n"



Measured memory_bytes: 5120
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <memory>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

struct segment_tree_min {
	int n; vector<ll> v;
	segment_tree_min(int _n) {
		for (n = 1; n < _n; n *= 2);
		v = vector<ll>(n * 2 - 1, LLONG_MAX / 10);
	}
	void set(int i, ll x) {
		int k = i + n - 1;
		v[k] = x;
		while (k > 0) {
			k = (k - 1) / 2;
			v[k] = min(v[k * 2 + 1], v[k * 2 + 2]);
		}
	}
	ll _get(int i, int j, int k, int l, int r) {
		if (r <= i || j <= l) return LLONG_MAX / 10;
		if (i <= l && r <= j) return v[k];
		ll vl = _get(i, j, k * 2 + 1, l, (l + r) / 2);
		ll vr = _get(i, j, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
	ll get(int i, int j) { return _get(i, j, 0, 0, n); }
};

int main() {
	int N, E, T;
	cin >> N >> E >> T;
	vector<int> x(N);
	rep(i, N) scanf("%d", &x[i]);
	vector<ll> dp(N + 1);
	dp[0] = 0;
	segment_tree_min st1(N + 1), st2(N + 1);
	st1.set(0, 0); st2.set(0, - x[0] * 2);
	for (int i = 1; i <= N; i++) {
		ll ans = LLONG_MAX / 10;
		int lb = -1, ub = i - 1;
		while (ub - lb > 1) {
			int mid = (lb + ub) / 2;
			if ((x[i - 1] - x[mid]) * 2 <= T) ub = mid;
			else lb = mid;
		}
		int l = ub;
		ans = min(ans, st1.get(l, i) + T);
		ans = min(ans, st2.get(0, l) + x[i - 1] * 2);
		dp[i] = ans;
		st1.set(i, ans);
		if (i < N) st2.set(i, ans - x[i] * 2);
	}
	cout << dp[N] + E << endl;
	return 0;
	for (int i = 0; i <= N; i++)
		for (int j = i + 1; j <= N; j++)
			dp[j] = min(dp[j], dp[i] + max(T, (x[j - 1] - x[i]) * 2));
	cout << dp[N] + E << endl;
}


Measured memory_bytes: 5632
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 998244353ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	doin();
	int n, k, z;
	double ans = 0, pw[100100];
	pw[0] = 1;
	cin >> n >> k;
	for(int i = 1; i <= max(n, k);i++)pw[i] = pw[i-1]/2.0;
	for(int i = 1; i <= n; i++) {
		int t = i;
		z = 0;
		while(t < k) t*=2, z++;
		ans += pw[z];
	}
	ans/=n;
	cout << fixed << setprecision(15) << ans;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <map>
#include <cassert>

/* development:
 *     /\  /\  /\  /\  /\
 *    / 0\/ 1\/ 2\/ 3\/ 4\
 *    --------------------
 *   /\ 5/\ 6/\ 7/\ 8/\ 9/
 *  /10\/11\/12\/13\/14\/
 *  --------------------
 *  \15/\16/\17/\18/\19/
 *   \/  \/  \/  \/  \/
 *
 * roll / direction (top view)
 *   direction = 0:   direction = 1:
 *     1 /\ 0             0
 *      /xx\             ----
 *      ----             \xx/
 *        2             1 \/ 2
 */

using namespace std;
typedef pair<int, int> pii;

class Dice20 {

private:
	struct Face3 {
		int index[3];
		Face3(int f = -1, int s = -1, int t = -1){
			index[0] = f; index[1] = s; index[2] = t;
		}
		void rotate(){
			int tmp = index[0];
			index[0] = index[1];
			index[1] = index[2];
			index[2] = tmp;
		}
	};
	static Face3 TABLE[3][20][20];
	static bool s_initialized;
	static void init_table(int t, int f1, int f2, int f3){
		Face3 f(f1, f2, f3);
		for(int i = 0; i < 3; ++i){
			for(int j = 0; j < 3; ++j){
				TABLE[j][t][f.index[j]] = f;
			}
			f.rotate();
		}
	}


public:
	int dir, top, first;

	Dice20(int d, int t, int f) : dir(d), top(t), first(f) {
		if(!s_initialized){
			s_initialized = true;
			for(int i = 0; i < 5; ++i){
				// 0 - 4
				init_table(i, (i + 1) % 5, (i + 4) % 5, i + 5);
				// 5 - 9
				init_table(i + 5, i, i + 10, 10 + (i + 1) % 5);
				// 10 - 14
				init_table(i + 10, i + 5, 5 + (i + 4) % 5, i + 15);
				// 15 - 19
				init_table(i + 15, i + 10, 15 + (i + 4) % 5, 15 + (i + 1) % 5);
			}
		}
	}

	void roll(int f){
		const Face3 &cur = TABLE[0][top][first];
		const Face3 &next = TABLE[(f + 1 + dir) % 3][cur.index[f]][top];
		top = cur.index[f];
		first = next.index[0];
		dir = 1 - dir;
	}
	int neighbor(int f){ return TABLE[0][top][first].index[f]; }

};

Dice20::Face3 Dice20::TABLE[3][20][20];
bool Dice20::s_initialized = false;

const int dx[2][3] = { { -1, 1, 0 }, { 0, 1, -1 } };
const int dy[2][3] = { { 0, 0, -1 }, { 1, 0, 0 } };
const int INF = 1000000000;

struct Entry {
	int x, y, top, first;
	Entry(int x, int y, int t, int f) : x(x), y(y), top(t), first(f) { }
};

int mindist[201][201][20][20];

int main(){
	for(int i = 0; i < 201; ++i){
		for(int j = 0; j < 201; ++j){
			for(int k = 0; k < 20; ++k){
				for(int l = 0; l < 20; ++l){ mindist[i][j][k][l] = INF; }
			}
		}
	}
	mindist[100][100][0][5] = 0;
	queue<Entry> q;
	q.push(Entry(100, 100, 0, 5));
	while(!q.empty()){
		Entry e = q.front();
		q.pop();
		int curcost = mindist[e.y][e.x][e.top][e.first];
		int dir = 1 - ((e.x + e.y) & 1);
		for(int i = 0; i < 3; ++i){
			Dice20 dice(dir, e.top, e.first);
			dice.roll(i);
			int nx = e.x + dx[dir][i], ny = e.y + dy[dir][i];
			int nt = dice.top, nf = dice.first;
			if(curcost < 100 && mindist[ny][nx][nt][nf] == INF){
				mindist[ny][nx][nt][nf] = curcost + 1;
				q.push(Entry(nx, ny, nt, nf));
			}
		}
	}
	while(true){
		int gx, gy, gt;
		cin >> gx >> gy >> gt;
		if(gx == 0 && gy == 0 && gt == 0){ break; }
		gx += 100; gy += 100;
		int answer = INF;
		for(int i = 0; i < 20; ++i){
			answer = min(answer, mindist[gy][gx][gt][i]);
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 62000
#include <bits/stdc++.h>
#define ll long long
#define p pair<int, int>
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

int main() {
    string s;
    while (cin >> s) {
        if (s == ".") break;
        string ans = "";
        int cnt = 0;
        stack<int> st;
        for (int i = 0; i < s.size(); i++) {
            if(s[i] == '['){
                st.push(ans.size());
            }else if(s[i] == '+'){
                cnt++;
            } else if (s[i] == '-') {
                cnt--;
            }else if(s[i] == '?'){
                ans += 'A';
                cnt = 0;
            }else if(s[i] == ']'){
                int from = st.top();
                st.pop();
                reverse(ans.begin() + from, ans.end());
            }else{
                ans += (s[i] - 'A' + cnt + 104) % 26 + 'A';
                cnt = 0;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
    int n;
    string s;

    cin >> n >> s;
    int cnt=0;

    for(int i=0;i<n-2;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2] == 'C'){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
//????????¨???????????????	
	static void print(boolean ln, boolean even){
		char a;
		if(even == true){
			a = '#';
		}else{
			a = '.';
		}
		if(ln == true){
			System.out.println(a);
		}else{
			System.out.print(a);
		}
	}
//??¶??°?\???°??§??¨??????????????´	
	static boolean judge(int num){
		if(num % 2 == 0){
			return true;
		}else{
			return false;
		}
	}
	
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner sc = new Scanner(System.in);
		while(true){
//??¨??¢???H,W????¨????		
	//?????°H????¨????		
		int H = sc.nextInt();
	//?????°W????¨????
		int W = sc.nextInt();
//??????????????\?????????????????????
		if(H == 0 && W == 0){
			break;
		}
		
//??¨?????????
	//???????????°???????????????		
		for(int i = 0; i < H; i++){
			//?¨?????????°???????????????
			for(int j = 0; j < W; j++){
				//??????????????????????????????
				if(j == W -1){
					print(true, judge(i + j + 2));
				}else{
					print(false, judge(i + j + 2));
				}
			}
		}
//??¨?????????
	//??????????????????			
		System.out.println("");
		}
		sc.close();
	}
}

Measured memory_bytes: 37388
from collections import deque
n, m = map(int,input().split())
AB = [tuple(map(int, input().split())) for _ in range(m)]

def bfs(start):
    queue = deque()
    visited = [False] * n
    visited[start-1] = True
    queue.append(start)
    while queue:
        target = queue.popleft()
        for i in g[target]:
            if not visited[i-1]:
                ans[i-2] = target
                visited[i-1] = True
                queue.append(i)

ans = [0] * (n-1)
g = dict()
for a, b in AB:
    if a in g:
        g[a].append(b)
    if b in g:
        g[b].append(a)
    if a not in g:
        g[a] = [b]
    if b not in g:
        g[b] = [a]
start = 1
bfs(start)
if len([i for i in ans if i == 0]) == 0:
    print("Yes")
    print(*ans, sep="\n")
else:
    print("No")

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;

    rep(i, a + 1)
    {
        rep(j, b + 1)
        {
            int num = x / 50 - 10 * i - 2 * j;
            if (0 <= num && num <= c)
            {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
			t[i] = sc.nextInt();
		}
		String x = sc.next();
		
		int sum = 0;
		boolean sleep = false;
		for (int i = 0; i < n; i++) {
			if (sleep) {
				sum += t[i];
			}
			if (s[i].equals(x)) {
				sleep = true;
			}
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0,cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='R')
      ans++;
    else{
      cnt=max(ans,cnt);
      ans=0;
    }
  }
  cnt=max(cnt,ans);
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    string s,t;
    cin>>s>>t;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(ll i=s.size()-t.size();i>=0;i--){
        bool flag=1;
        rep(j,t.size()){
            if(s[i+j]!=t[j]&&s[i+j]!='?'){
                flag=0;
                break;
            }
        }
        if(flag){
            rep(j,t.size()) s[i+j]=t[j];
            break;
        }
        if(flag==0&&i==0){
            cout<<"UNRESTORABLE"<<endl;
            return 0;
        }
    }
    rep(i,s.size()){
        if(s[i]=='?') s[i]='a';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
using namespace std;
int main(){
	long long n;
	vector<int> ans;
	cin>>n;
	if(n==0){
		cout<<0<<endl;
	}else{
		int now=0;
		while(n!=0){
			if(now%2==0&&n==(1LL<<now)){
				ans.push_back(1);
				break;
			}else if(now%2==1&&n==-(1LL<<now)){
				ans.push_back(1);
				break;
			}else if(n%(1LL<<(now+1))==0){
				ans.push_back(0);
			}else{
				ans.push_back(1);
				if(now%2==0){
					n-=(1LL<<now);
				}else{
					n+=(1LL<<now);
				}
			}
			now++;
		}
	}
	for(int  i=0;i<ans.size();i++){
		cout<<ans[ans.size()-1-i];
	}
	cout<<endl;
	return 0;
}


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

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


Measured memory_bytes: 3640
#include <stdio.h>

void insertionSort(int*, int);

int main(){
  int i, n, A[1000];
  
  scanf("%d", &n);
  for(i=0; i < n; i++){
    scanf("%d", &A[i]);
  }

  for(i=0; i < n; i++){ // 入力した内容を表示
    if(i != 0)printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  
  insertionSort(A, n);  // 挿入ソート
  
  return 0; 
}

void insertionSort(int *A, int n){ 
  int i, j, k, v;
  
  // 挿入ソート //
  for(i=1; i < n; i++){
    v = A[i];           // 対象の配列の中身をvに保存する
    j = i-1;            // i番目の手前の配列要素を参照するためのj
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    
    // 配列の内容を表示 //
    for(k=0; k < n; k++){
      if(k != 0)printf(" ");
      printf("%d", A[k]);
    }
    printf("\n");
  }
}



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

int main() {
 int num; cin >> num;
 vector<int> ans(num);
  
 for(int i = 1; i <= num; i++) {
   int current;
   cin >> current;
   
   ans.at(current - 1) = i;
 }
 
 for(int i = 0; i < num; i++) {
  cout << ans.at(i) << " "; 
 }
  cout << endl;
 
  return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  int i;
  for(i=0;i<str.size();i++){
    if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
    else if(str[i]>='A'&&str[i]<='Z') str[i]+='a'-'A';
  }
    cout << str << endl;
  return 0;
}



Measured memory_bytes: 3192