akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    ll n; cin >> n;
    for (ll i = 1; true; i *= 2) {
        if (i > n) {
            cout << i - 1 << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;

using Graph = vector<vector<int>>;

vector<bool> seen;
vector<long long> cnt;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    
    for(auto next_v : G[v]) {
        if(seen[next_v]) continue;
        cnt[next_v] += cnt[v];
        dfs(G, next_v);
    }
}

void solve() {
    int N, Q;
    cin >> N >> Q;
    int a, b;
    Graph G(N);
    for (int i = 0; i < N-1; i++)
    {
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cnt.assign(N, 0);
    int p, x;
    for (int i = 0; i < Q; i++)
    {
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    seen.assign(N, false);
    dfs(G, 0);

    for (int i = 0; i < N; i++)
    {
        cout << cnt[i] << endl;
    }
    
}

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

Measured memory_bytes: 25072
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
cnt = 0
#selectionSort(A, N)
for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    a = A[i]
    b = A[minj]
    A[i] = b
    A[minj] = a
    if minj != i:
        cnt += 1
print(' '.join(map(str, A)))
print(cnt)


Measured memory_bytes: 6796
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

const int MOD = 1000000000 + 7;

vector<int> h[2001];
vector<int> w[2001];


void count(vector<int>& v) {
    for(int i=1; i<v.size(); i++) {
        if(v[i] == 0) continue;
        v[i] += v[i-1];
    }
    
    for (int i=v.size()-2; i >= 0; i--) {
        if(v[i] == 0) continue;
        v[i] = max(v[i], v[i+1]);
    }
}

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

    vector<string> ss(H);
    for(int i=0;i<H;i++) cin>>ss[i];

    for(int i=0; i<H; i++) w[i] = vector<int>(W);
    for(int i=0; i<W; i++) h[i] = vector<int>(H);

    for (int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            h[j][i] = ss[i][j] != '#';
            w[i][j] = ss[i][j] != '#';
        }
    }

    for(int i=0; i<H; i++) count(w[i]);
    for(int i=0; i<W; i++) count(h[i]);

    int ans = 0;
    for (int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            ans = max(ans, h[j][i] + w[i][j] - 1);
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 35712
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>

using namespace std;

char c[5];

string rec(int d, int s) {
    if (d == 3) return s == 7 ? "=7" : "!";
    auto t = rec(d + 1, s + c[d + 1]);
    if (t != "!") return "+" + ((char) ('0' + c[d + 1]) + t);
    t = rec(d + 1, s - c[d + 1]);
    if (t != "!") return "-" + ((char) ('0' + c[d + 1]) + t);
    return "!";
}

int main() {
    cin >> c;
    for (int i = 1; i < 4; i++) c[i] -= '0';
    string r = rec(0, c[0] - '0');
    cout << c[0] << r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
ll gdc(ll,ll);
ll lcm(ll,ll);

ll gcd(ll a,ll b){
    if(a<b){
        ll temp=a;
        a=b;
        b=temp;
    }
    ll r=a%b;
    while(r>0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
int main(){
    ll n;
    cin>>n;
    vector<ll> t(n);
    for(ll i=0;i<n;i++){
        cin>>t[i];
    }
    for(ll i=0;i<n-1;i++){
        t[i+1]=lcm(t[i],t[i+1]);
    }
    cout<<t.back()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, cou=0, ans=0;
  cin >> N;
  vector<int> H(N);
  REP(i,N) cin >> H[i];
  REP(i,N-1) {
    if(H[i]>=H[i+1]) {
      cou++;
      ans=max(ans,cou);
    }
    else cou=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())
ChrL = [[] for T in range(0,26)]
for NT in range(0,N):
    S = input()
    for ST in range(0,26):
        ChrL[ST].append(S.count(chr(97+ST)))
Disp = ['']*26
for ST in range(0,26):
    Disp[ST] = chr(97+ST)*min(ChrL[ST])
print(''.join(Disp))

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N;
long long K;  
  cin >> N >> K;
int now = 0;
long long d[100010] = {0};
  
  for(int i = 0;i < N;i++){
  int ikaime, nanko;
  cin >> ikaime >> nanko;
  d[ikaime - 1] += nanko;
  }
  
  for(int i = 0;i < 100010;i++){
  if(K > d[i]){
  K -= d[i];
  }
  else{
  cout << i + 1 << endl;
  i = 100011;  
  }
  }
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void)
{
  char p[101],pring[201],s[101];
  scanf("%s",&p);
  scanf("%s",&s);
  strcpy(pring,p);
  strcat(pring,p);
  if(strstr(pring,s) == NULL){printf("No\n");}
  else{printf("Yes\n");}
   
   
    return 0;
}

Measured memory_bytes: 540
N,X=map(int,input().split())
A=[int(x) for x in input().split()]
if N>=2:
  Diff=[]
  for i in range(N):
    Diff +=[abs(X-A[i])]
  def gcd(a,b):#最大公約数
    return a if b == 0 else gcd(b,a%b)
  g=gcd(Diff[0],Diff[1])
  for i in range(2,N):
    g=gcd(Diff[i],g)
  print(g)
else:
  print(abs(X-A[0]))

Measured memory_bytes: 14224
fn main() {
    let n: u64 = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().parse().unwrap()
    };
    println!("{}", {
        let mut ans: u64 = 0;
        let mut t: u64 = 10;
        while n >= t {
            ans += n / t;
            t *= 5;
        }
        if n % 2 == 0 { ans } else { 0 }
    });
}


Measured memory_bytes: 4352
using namespace std;
using ll=long long;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#define out(S) cout<<(S)<<endl;
#define mod(i) ((i)%(ll)(1000000000 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define For(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFor(i,a,b) for(size_t i=(a)-1;i>=(b);i--)
#define Rep(i,a) for(size_t i=0;i<(a);i++)
#define rRep(i,a) for(size_t i=(a)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)

int main(){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	string R="", L="", D="", U="";
	Rep(i, abs(tx - sx)) {
		R += "R";
		L += "L";
	}
	Rep(i, abs(ty - sy)) {
		U += "U";
		D += "D";
	}
	string o1 = R + U + L + D;
	string o2 = "D" + R + "RU" + U + "LU" + L + "L" + D + "DR";
	out(o1 + o2);
	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------
ll gcd(ll a, ll b) {
  if (b == 0) return a;

  return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll N;
ll A[101010];

int main() {
  cin >> N;
  rep(i, 0, N) { cin >> A[i]; }
  ll ans = gcd(A[0], A[1]);
  rep(i, 2, N) { ans = gcd(ans, A[i]); }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;

    if(A - 2*B < 0){
        cout << 0 << endl;
    }
    else{
        cout << A - 2*B << endl;
    }
}

Measured memory_bytes: 3500
import java.util.Scanner;

class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String code;
		
		Tree tree = new Tree();
		int k;
		
		int n = scan.nextInt();
		
		for (int i = 0; i < n; i++) {
			code = scan.next();
			
			if(code.equals("insert")) {
				k = scan.nextInt();
				tree.insert(new Node(k));
			
			} else if(code.equals("print")) {
				tree.print(Tree.Order.Inorder);
				tree.print(Tree.Order.Preorder);
			}
		}
		
		scan.close();
	}

	public static class Tree {
 
		enum Order {Preorder, Inorder, Postorder}
	
		Node root;
	
		Node insert(Node node) {
			Node parent = null;
			Node child = root;
		
			while (child != null) {
				parent = child;
				if (node.key < child.key) child = child.left;
				else child = child.right;
			}
		
			node.parent = parent;
		
			if (parent == null) {
				this.root = node;
		
			} else if (node.key < parent.key) {
				parent.left = node;
		
			} else {
				parent.right = node;
			}
		
			return node;
		}
	
		void print(Order order) {
			switch (order) {
				case Preorder:
					walkPreorder(root);
					break;
				
				case Inorder:
					walkInorder(root);
					break;
				
				case Postorder:
					walkPostorder(root);
					break;
			}
			System.out.println();
		}
	
		void walkPreorder(Node node) {
			if (node == null) return;
		
			System.out.print(" " + node.key);
			walkPreorder(node.left);
			walkPreorder(node.right);
		}
	
		void walkInorder(Node node) {
			if (node == null) return;
		
			walkInorder(node.left);
			System.out.print(" " + node.key);
			walkInorder(node.right);
		}
	
		void walkPostorder(Node node) {
			if (node == null) return;
		
			walkPostorder(node.left);
			walkPostorder(node.right);
			System.out.print(" " + node.key);
		}
	}

	public static class Node {
		int key;
		Node parent, left, right;
	
		Node(int key) {
			this.key = key;
		}
	}
}

Measured memory_bytes: 215644
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	int i,j,n,minj,temp,count=0,change=0;
	int array[] = new int[101];

	Scanner scan = new Scanner(System.in);
	n = scan.nextInt();

	for(i=0;i<n;i++){
	    array[i] = scan.nextInt();
	}

	for(i=0;i<n;i++){
	    minj=i;
	    for(j=i;j<n;j++){
		if(array[j] < array[minj]){
		    minj = j;
		}
	    }
	    if(i!=minj){
	    temp = array[i];
	    array[i] = array[minj];
	    array[minj] = temp;
	    count++;
	    }
	}
	for(i=0;i<n;i++){
	    if(i==n-1){System.out.println(array[i]+"\n"+count);}
	    else System.out.print(array[i]+" ");
	    }
    }
}



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

int main(){
	int N;
	cin >> N;

	vector<int> L(N,1);

	int sum = 0;

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

		L.at(i) = n;
		sum += L.at(i);
	}

	int j = 0;

	for (int i = 0;i < N;i++) {
		if (L.at(i) >= (sum - L.at(i))) {
			j += 1;
		}
	}

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

}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

bool prime_test(int n){
  bool is_prime=true;
  if(n==1)is_prime=false;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      is_prime=false;
      break;
    }
  }
  return is_prime;
}

int main(){
  int a[100010]={};
  int s[100010]={};
  for(int i=1;i<100001;i++){
    if(prime_test(i) && prime_test((i+1)/2) && i%2==1)a[i]++;
    s[i]=s[i-1]+a[i];
  }

  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int r,l;
    cin >> l >> r;
    cout << s[r]-s[l-1] <<endl;
  }
 
}

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

using namespace std;
#define ll long long
#define mod 1000000007

ll dp[3001][3001][2];
vector<ll> v, pre;

ll f(ll l, ll r, ll player) {
    if (l > r) return 0;
    else if (l == r) return v[l];

    if (dp[l][r][player] != -1) return dp[l][r][player];

    ll score1 = v[l] + pre[r] - pre[l] - f(l + 1, r, 1 - player);
    ll score2 = v[r] + pre[r - 1] - (l ? pre[l - 1] : 0) - f(l, r - 1, 1 - player);

    dp[l][r][player] = max(score1, score2);
    return dp[l][r][player];
}

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

    ll n;
    cin >> n;
    v.resize(n);
    pre.resize(n);

    memset(dp, -1, sizeof(dp));

    for (auto &i : v) {
        cin >> i;
    }

    pre[0] = v[0];
    for (ll i = 1; i < n; i++) {
        pre[i] = pre[i - 1] + v[i];
    }

    f(0, n - 1, 0);

    cout << 2 * f(0, n - 1, 0) - pre[n - 1];
}


Measured memory_bytes: 144652
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
vector<ll> avec[40], bvec[40];
ll n, a, b, sum[40], res;

ll pow(ll x, ll y){
    if (y == 0) return 1;
    if (y % 2) {
        return x * pow(x, y - 1);
    } else {
        ll z = pow(x, y / 2);
        return z * z;
    }
}

ll lower(ll x, ll y){
    ll lb = -1, ub = n;
    while(lb + 1 < ub){
        ll mid = (lb + ub) / 2;
        if (bvec[y][mid] >= x) ub = mid;
        else lb = mid;
    }
    return ub;
}


int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> a;
        for (ll j = 0; j < 30; j++){
            ll amr = pow(2, j + 1);
            avec[j].push_back(a % amr);
        }
    }
    for (ll i = 0; i < n; i++) {
        cin >> b;
        for (ll j = 0; j < 30; j++){
            ll amr = pow(2, j + 1);
            bvec[j].push_back(b % amr);
        }
    }
    for (ll i = 0; i < 30; i++) {
        sort(avec[i].begin(), avec[i].end());
        sort(bvec[i].begin(), bvec[i].end());
    }
    for (ll i = 0; i < 30; i++) {
        for (ll j = 0; j < n; j++) {
            ll one = lower(pow(2, i) - avec[i][j], i);
            ll two = lower(pow(2, i + 1) - avec[i][j], i);
            ll thr = lower(pow(2, i) * 3 - avec[i][j], i);
            (sum[i] += n - thr + two - one) %= 2;
        }
    }
    for (ll i = 30; i >= 0; i--) {
        res *= 2;
        res += sum[i];
    }
    cout << res << endl;
}


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

int a[110], c[110];

void prime_factor(int n){
    for(int i = 2; i * i <= n; i++){
        while(n % i == 0){
            a[i]++;
            n /= i;
        }
    }
    if(n != 1) a[n]++;
}

int main(){
    int n, ans = 0;
    cin >> n;
    for(int i = 2; i <= n; i++) prime_factor(i);
    for(int i = 0; i < 100; i++) c[a[i]]++;
    for(int i = 100; i >= 0; i--) c[i] += c[i + 1];
    ans += c[74] + c[24] * (c[2] - 1) + c[14] * (c[4] - 1) + c[4] * (c[4] - 1) / 2 * (c[2] - 2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
typedef long long lld;
const int MAXN = 1e5+5;
int A[MAXN], B[MAXN];
int N;
lld ret;

void dec(int j, int i) {
    int val = std::min(A[j], B[i]);
    A[j] -= val;
    B[i] -= val;
    ret += val;
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N+1; ++i) {
        scanf("%d", &A[i]);
    }
    for (int i = 1; i <= N; ++i) {
        scanf("%d", &B[i]);
    }
    ret = 0LL;
    for (int i = 1; i <= N; ++i) {
        dec(i, i);
        dec(i+1, i);
    }
    for (int i = N; i >= 1; --i) {
        dec(i+1, i);
        dec(i, i);
    }
    printf("%lld\n", ret);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
using namespace std;
long long int dp[1005][1005] = { 0 };
int main()
{
    long long int n, m;
    cin >> n >> m;
    for(int i=0;i<1005;i++){
      for(int j=0;j<1005;j++) dp[i][j]=1000000000000;
    }
    long long int di[1005] = { 0 }; long long int cl[1005] = { 0 };
    for (int i = 1; i < n+1; i++)cin >> di[i];
    for (int i = 1; i < m+1; i++){cin >> cl[i];dp[i][0]=0;}
    dp[0][0]=0;
    for (int i = 1; i < m + 1; i++) {
        for (int j = 1; j < n + 1; j++) {
            dp[i][j] = min(dp[i-1][j-1]+di[j]*cl[i],dp[i-1][j]);
        }
    }

    /*for(int i=0;i<=m;i++){
      for(int j=0;j<=n;j++){cout<<dp[i][j]<<" ";}
      cout<<endl;
    }*/
    cout << dp[m][n]<<endl;
}



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

int main(void){

   unsigned long long int a,b,x;
   cin >> a >> b >> x;
   if(a % x == 0) cout << (b / x) - (a / x) + 1 << endl;
   else cout << (b / x) - (a / x) << endl;
}


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

int main(){
	int D,N;
	cin>>D>>N;
	int T[D],A[N],B[N],C[N];
	for(int d=0; d<D; ++d)	cin>>T[d];
	for(int n=0; n<N; ++n)	cin>>A[n]>>B[n]>>C[n];
	int dp[D][N];
	for(int n=0; n<N; ++n)	dp[0][n]=(A[n]<=T[0]&&T[0]<=B[n]? 0: -(1<<29));
	for(int d=1; d<D; ++d)for(int n=0; n<N; ++n)	dp[d][n]=-(1<<29);
	for(int d=1; d<D; ++d)for(int n=0; n<N; ++n)for(int i=0; i<N; ++i){
		if(A[i]<=T[d]&&T[d]<=B[i])	dp[d][i]=max(dp[d][i], dp[d-1][n]+abs(C[n]-C[i]));
	}
	int ans=0;
	for(int i=0; i<N; ++i)	ans=max(ans, dp[D-1][i]);
	cout << ans << endl;
}

Measured memory_bytes: 1320
def main():
  n, m = map(int, input().split())
  H = list(map(int, input().split()))
  set_tmp = set()
  for i in range(m):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
      set_tmp.add(b)
    elif H[a-1] == H[b-1]:
      set_tmp.add(a)
      set_tmp.add(b)
    else:
      set_tmp.add(a)
  print(n - len(set_tmp))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 85324
n, a, b=map(int, input().split())
ans=0
for num in range(1, n+1):
    num=str(num)
    length=len(num)
    S=0
    for j in range(length):
        S+=int(num[j])
    
    if a<= S <= b:
        ans+=int(num)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
   ll n,m;
   cin>>n>>m;
   
   ll a,b;
   cin>>a>>b;
   
   char ans[n+2][m+2];
   
   for(ll i=0;i<n;i++){
       for(ll j=0;j<m;j++)
       ans[i][j]='0';
   }
   
   for(ll i=0;i<b;i++){
       for(ll j=a;j<m;j++)
       ans[i][j]='1';
   }
   
   for(ll i=b;i<n;i++){
       for(ll j=0;j<a;j++)
       ans[i][j]='1';
   }
   
   
   for(ll i=0;i<n;i++){
       for(ll j=0;j<m;j++)
       cout<<ans[i][j];
       
       cout<<endl;
   }
   
}
int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int p[N];
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &p[i]);
    }
    sort(p, p + N);
    int sum = 0;
    for (int i = 0; i < K; i++)
    {
        sum += p[i];
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3764
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;

#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

void work() {
    int n;
    cin >> n;
    LL ansx = 1, ansy = 1;
    for (int i = 1; i <= n; ++i) {
        LL a, b;
        cin >> a >> b;
        LL k1 = 1;
        if (a < ansx) {
//            k1 = max(k1, (LL)ceil(1.0 * ansx / a));
//            k1 = (ansx + a - 1) / a;
            k1 = ansx / a;
            if (ansx % a != 0) k1++;
        }
        if (b < ansy) {
//            k1 = max(k1, (LL)ceil(1.0 * ansy / b));
//            k1 = max(k1, (ansy + b - 1) / b);
            LL t = ansy / b;
            if (ansy % b != 0) t++;
            k1 = max(k1, t);
        }
        ansx = a * k1;
        ansy = b * k1;
    }
    cout << ansx + ansy << endl;
}

int main() {
#ifdef local
    freopen("data.txt","r",stdin);
#endif
    work();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int minimum(int[], int);

int main(){
    int n, x, m[100];
    int i, cnt, min;

    scanf("%d %d", &n, &x);

    for(i=0; i<n; i++){
        scanf("%d", &m[i]);
        x -= m[i];
    }
    cnt = n;

    min = minimum(m, n);

    cnt += x/min;

    printf("%d\n", cnt);

    return 0;
}

int minimum(int a[], int n){
    int i, min=a[0];

    for(i=0; i<n; i++){
        if(min > a[i])
            min = a[i];
    }

    return min;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,a;
    cin >> n >> a;

    vector <int> v(a);
    rep(i,a) cin >> v[i];

    int s=0;
    rep(i,a) s+=v[i];


    if (s<n) No();
    else Yes();
    return 0;

}

Measured memory_bytes: 3728
function median(list)
  table.sort(list)
  local center = math.floor(#list / 2)
  if #list % 2 == 0 then
    return (list[center] + list[center + 1]) / 2
  else
    return list[center + 1]
  end
end

function sad(A, b)
  local acc = 0
  for i, v in ipairs(A) do
    acc = acc + math.abs(v - (b + i))
  end
  return acc
end

local N = tonumber(io.read())
local A = {}
for n in io.read():gmatch('%d+') do
  table.insert(A, tonumber(n))
end

local B = {}
for i, v in ipairs(A) do
  table.insert(B, (v - i))
end

io.write(sad(A, median(B)))


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        long m = sc.NextLong();

        UnionFind uf = new UnionFind(n);

        for (int i = 0; i < m; i++)
        {
            uf.Unite(sc.NextInt(), sc.NextInt());
        }

        SortedSet<int> set = new SortedSet<int>();

        for (int i = 1; i <= n; i++)
        {
            set.Add(uf.GetRoot(i));
        }

        long answer = set.Count - 1;

        Console.WriteLine(answer);
    }

    // 木の併合
    class UnionFind
    {
        private readonly int[] parents;
        private readonly int[] sizes;

        public UnionFind(int count)
        {
            parents = new int[count + 1];
            sizes = new int[count + 1];
            for (int i = 0; i < count + 1; i++)
            {
                parents[i] = i;
                sizes[i] = 1;
            }
        }

        // TreeのNode数の取得
        public int GetSize(int branch)
        {
            return sizes[GetRoot(branch)];
        }

        // Treeの併合、Node数の合算
        public void Unite(int x, int y)
        {
            int rootX = GetRoot(x);
            int rootY = GetRoot(y);
            if (rootX == rootY) return;
            sizes[rootX] += sizes[rootY];
            parents[rootY] = rootX;
        }

        // 同じTreeに含まれるか
        public bool IsSameRoot(int x, int y)
        {
            return GetRoot(x) == GetRoot(y);
        }

        // Rootの取得
        public int GetRoot(int n)
        {
            if (parents[n] == n)
            {
                return n;
            }
            else
            {
                return parents[n] = GetRoot(parents[n]);
            }
        }
    }


    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 41500
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<vector<int>> g(n);
  vector<vector<int>> deg(2, vector<int>(n));
  set<pair<int, int>> st;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
    deg[s[b] - 'A'][a]++;
    deg[s[a] - 'A'][b]++;
  }

  for (int i = 0; i < n; ++i) {
    st.insert(make_pair(min(deg[0][i], deg[1][i]), i));
  }

  vector<bool> live(n, true);
  for (;;) {
    if (st.empty()) break;
    auto it = st.begin();
    if (it->first != 0) break;
    int a = it->second;
    live[a] = false;
    st.erase(st.begin());
    for (int i : g[a]) {
      if (!live[i]) continue;
      st.erase(st.find(make_pair(min(deg[0][i], deg[1][i]), i)));
      deg[s[a] - 'A'][i]--;
      st.insert(make_pair(min(deg[0][i], deg[1][i]), i));
    }
  }

  cout << (st.empty() ? "No" : "Yes") << endl;

  return 0;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int a1 = cin.Int();
			int a2 = cin.Int();
			int a3 = cin.Int();
			if (a1 + a2 + a3 >= 22) {
				Console.WriteLine("bust");
			} else {
				Console.WriteLine("win");
			}
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11092
a = list(input()+"A")
b = list(input()+"B")
c = list(input()+"C")
 
def card(x):
  first = x.pop(0)
  if first.isupper():
    print(first)
    return
  elif first == "a":
    card(a)
  elif first == "b":
    card(b)
  else:
    card(c)
    
card(a)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back

ll a[100100][3];
ll dp[100100][3];

using namespace std;
int main() {
    IOS;
    ll n;
    cin >> n;
    for(int i=0;i<n;i++) {
        for (int j = 0; j < 3; j++) {
            cin>>a[i][j];
        }
    }
    for (int i = 0; i < 3; i++) {
        dp[0][i] = a[0][i];
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i][j] = max(dp[i - 1][k] + a[i][j], dp[i][j]);
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < 3; i++) {
        ans = max(ans, dp[n - 1][i]);
    }
    cout << ans;

    return 0;
}


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

ll solve() {
    string S;
    cin >> S;
    ll X, Y, l = 0;
    cin >> X >> Y;
    vector<ll> ax, ay;
    ll x0 = -1, y0 = 0;
    bool fx = true;
    auto pushL = [&]() {
            if ( fx ) {
                if ( x0 < 0 ) x0 = l;
                else if ( l > 0 ) ax.push_back(l);
            } else {
                if ( l > 0 ) ay.push_back(l);
            }
            fx = !fx;
            l = 0;
    };
    for ( int i = 0; i < S.size(); i++ ) {
        if ( S[i] == 'F' ) l++;
        else {
            pushL();
        }
    }
    if ( S.back() == 'F' ) pushL();

    auto canMove = [](ll dist, vector<ll> x) -> bool {
        unordered_set<ll> p, pp;
        p.insert(0);
        for ( ll dx : x ) {
            p.swap(pp);
            p.clear();
            for ( ll cp : pp ) {
                p.insert(cp + dx);
                p.insert(cp - dx);
            }
        }
        return p.find(dist) != p.end();
    };

    bool ans = canMove(X-x0, ax) && canMove(Y, ay);
    return ans;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
A,B,C,D=map(int,input().split())
import math,fractions
cd=C*D//fractions.gcd(C,D)
Cnum=B//C-(A-1)//C
Dnum=B//D-(A-1)//D
CDnum=B//cd-(A-1)//cd
print(B-A+1-Cnum-Dnum+CDnum)

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  string s="",t="";
  std::cin >> x>>s;
  if(s.size()<=x)std::cout << s << '\n';
  else{
    rep(i,x){
      std::cout << s[i];
    }
    std::cout << "..." << '\n';
  }
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char S[27];

    scanf("%s", S);

    int c['z'-'a'+1];

    for(int i = 0; i <= 'z'-'a'; i++){
        c[i] = 0;
    }

    for(int i = 0; i < strlen(S); i++){
        c[S[i]-'a']++;
    }

    int t = 1;

    for(int i = 0; i < strlen(S); i++){
        if(c[i] >= 2){
            t = 0;
            break;
        }
    }

    if(t == 1){
        printf("yes\n");
    }else{
        printf("no\n");
    }

    return 0;
}

Measured memory_bytes: 1596
#include<stdio.h>
#include<math.h>
int main(void){
  int a,b,c,k,max;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  max=fmax(a,fmax(b,c));
  printf("%d",a+b+c-max+(max<<k));
  return 0;
}

Measured memory_bytes: 128
lists = []
n = int(input())
 
for i in range(n):
    query = list(map(int, input().split()))
    if(query[0] == 0):
        lists.append(query[1])
    elif(query[0] == 1):
        print(lists[query[1]])
    elif(query[0] == 2):
        lists.pop()


Measured memory_bytes: 13360
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;
ll dp[100001][4];

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  
  dp[0][0] = 1;
  dp[0][1] = 0;
  dp[0][2] = 0;
  dp[0][3] = 0;
  for(int i = 0; i < s.size(); i++){
    // j = 0
    dp[i + 1][0] = dp[i][0];
    if(s[i] == '?')dp[i + 1][0] = 3 * dp[i + 1][0] % mod;
    // j = 1
    dp[i + 1][1] = dp[i][1];
    if(s[i] == '?')dp[i + 1][1] = 3 * dp[i + 1][1] % mod;
    if(s[i] == '?' || s[i] == 'A')dp[i + 1][1] = (dp[i + 1][1] + dp[i][0]) % mod;
    // j = 2
    dp[i + 1][2] = dp[i][2];
    if(s[i] == '?')dp[i + 1][2] = 3 * dp[i + 1][2] % mod;
    if(s[i] == '?' || s[i] == 'B')dp[i + 1][2] = (dp[i + 1][2] + dp[i][1]) % mod;
    // j = 3
    dp[i + 1][3] = dp[i][3];
    if(s[i] == '?')dp[i + 1][3] = 3 * dp[i + 1][3] % mod;
    if(s[i] == '?' || s[i] == 'C')dp[i + 1][3] = (dp[i + 1][3] + dp[i][2]) % mod;
  }

  cout << dp[s.size()][3] << endl;
	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
using namespace std;
vector<vector<int> >G(252),R(252);
int n,m;
int d[552];
bool u[252];
void f(int v)
{
	u[v]=1;
	for(int i=0;i<R[v].size();i++)
	{
		if(!u[R[v][i]])f(R[v][i]);
	}
}
bool vi[252];
void ok(int v)
{
    vi[v]=1;
    for(int i=0;i<G[v].size();i++)
    {
        if(!vi[G[v][i]])ok(G[v][i]);
    }
}
main()
{
	while(cin>>m,m)
	{
		cin>>n;
		for(int i=0;i<=n+1;i++)G[i].clear(),R[i].clear(),d[i]=vi[i]=u[i]=0;
		for(int i=1;i<=n;i++)cin>>d[i];
		for(int i=0;i<=n;i++)
		{
			for(int j=1;j<=m&&i+j<=n+1;j++)
			{
				int k=i+j+d[i+j];
				if(k>n+1)k=n+1;
				if(k<0)k=0;
				G[i].push_back(k);
				R[k].push_back(i);
			}
		}
		f(n+1);ok(0);
		bool flag=1;
		for(int i=0;i<=n+1;i++)if(vi[i]&&!u[i])flag=0;
		cout<<(flag?"OK":"NG")<<endl;
	}
}



Measured memory_bytes: 3192
#include <iostream>

using namespace std;

int main() {
    int N, L;
    cin >> N;
    cin >> L;

    int app1 = L + 1 - 1;
    int appN = L + N - 1;
    
    int eat_num;

    if(0 < app1) {
        eat_num = 1;
    } else if(app1 <= 0 && 0 <= appN) {
        eat_num = 1 - L;
    } else if(appN < 0) {
        eat_num = N;
    }

    int sum = 0;
    for(int i = 1; i <= N; i++) {
        if(i != eat_num) {
            sum += L + i - 1;
        }
    }

    cout << sum << endl;

    return 0;
}

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

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

  if ( ( x % 2 ) * ( y % 2 ) == 0 ) {
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
}


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

ll GCD(ll a, ll b) {
  if(b == 0) return a;
  else return GCD(b, a % b);
}

int main() {
  ll a,b,c,d,ans = 0;
  cin >> a >> b >> c >> d;
  ll cd = (c*d)/GCD(c,d);
  ans = b - (b/c + b/d - b/cd);
  a--;
  ans -= a - (a/c + a/d - a/cd);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import static java.util.Comparator.*;

import java.util.ArrayList;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		ArrayList<SI> list = new ArrayList<SI>();
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for(int i = 1; i  <= n; i++) {
			SI si = new SI();
			si.loc = sc.next();
			si.p = sc.nextInt();
			si.no = i;
			list.add(si);
		}
		list.stream().sorted(comparing(SI::getLoc).thenComparing(SI::getP, reverseOrder()))
		.forEach(li -> System.out.println(li.getNo()));
	}

	
	
	

}
 class SI {
	String loc;
	int p;
	int no;
	public String getLoc() {
		return loc;
	}
	public void setLoc(String loc) {
		this.loc = loc;
	}
	public int getP() {
		return p;
	}
	public void setP(int p) {
		this.p = p;
	}
	public int getNo() {
		return no;
	}
	public void setNo(int no) {
		this.no = no;
	}
}


Measured memory_bytes: 27340
/*
  Esteban Arango Medina
*/
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <tuple>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

using ll=long long;
#define int ll

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <char,int> mci;
typedef map <int,int> mii;
typedef map <string,string> mss;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define endl '\n' // Normal `cout << endl` flushes the output every time wich hit performance badly
#define INF 1000000000
#define deb(x) cout<<#x<<": "<<x<<endl;
#define printArray(arr) for(auto x: arr) { cout<<x<<", "; }
#define printMatrix(mat) for(auto x: mat) { cout<<" "; printArray(x); cout<<endl; }
#define printMap(mmap) for(auto p: mmap) { cout<< p.first<<": "<<p.second<<endl; }

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); // Fast input
  #ifdef LOCAL_PROJECT
    freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
  #endif

  int T = 1; //cin>>T;
  while(T--) {
    int n; cin>>n;
    vi stones(n);
    rep(i,0, n) { cin>>stones[i]; }
    vi DP(n, 0);
    DP[0] = 0;
    DP[1] = abs(stones[0] - stones[1]);
    rep(i,2, n) {
      DP[i] = min(DP[i-2] + abs(stones[i] - stones[i-2]), DP[i-1] + abs(stones[i] - stones[i-1]));
    }
    cout<<DP[n-1];
  }
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int x = a+b, y = a+c, z = b+c;
	if(x<y&&x<z) printf("%d\n", x);
	else if(y<x&&y<z) printf("%d\n", y);
	else printf("%d\n", z);
	return 0;
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;
use std::cmp::min;

fn main() {
    let n: usize = read();
    let mut maxv = 0;
    let mut minv = std::i64::MAX;
    for _ in 0..n {
        let a: i64 = read();
        maxv = max(maxv, a);
        minv = min(minv, a);
    }
    println!("{}", maxv- minv);
}


Measured memory_bytes: 4352
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;

int exist_n(int N, string S, int K){
    
    //fprintf(stderr, "%d, %d\n", N, K);
    if (K == 0){
        return 1;
    }
    map<string,int> dict;
    for (int i = 0; i < N; i++){
        string sub1 = S.substr(i, K); 
        //fprintf(stderr, "i = %d, i + K = %d\n", i, i + K);
        //cout << S << "\n";
        //cout << sub1<< "\n";
        //exit(1);
        if (dict.find(sub1)  != dict.end() && dict[sub1] <= i - K){
            //fprintf(stderr, "OK, K = %d\n", K);
            return 1;
        }
        if (dict.find(sub1) == dict.end()){
            dict[sub1] = i;
        }
    }
    return 0;
}

int main()
{
    // �����̓���
    int N, K;
    string S;
    cin >> N;
    cin >> S;
    int lb = 0, ub = N/2 + 1;
    
    while( ub - lb > 1){
        int mid = (lb + ub) / 2;
        if (exist_n(N, S, mid)){
            lb = mid;
        } else {
            ub = mid;
        }
    }
    cout << lb;
    return 0;
}


Measured memory_bytes: 9956
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
struct node{
	ll num,time;
};
bool cmp(node a,node b){
	return a.time<b.time;
}
int main(){
	fast;
	ll n;
	cin>>n;
	node a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i].time;
		a[i].num=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		cout<<a[i].num<<' ';
	}cout<<endl;return 0;
}/*『你强归你强，我永不示弱』*/




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

int main (){
	ll n;
	cin >> n;
    ll ans = 1e18;
    for(ll i=1; i*i<=n; i++){
        if(n%i!=0){
            continue;
        }
        ll j = n/i;
        ans = min(ans, i+j-2);
    }
    
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
  int n;
  ll a, b;
  cin >> n >> a >> b;
  ll X[n];
  for(int i=0;i<n;i++){
    cin >> X[i];
  }
  ll ans=0;
  for(int i=0;i<n-1;i++){
    ll tmp=(X[i+1]-X[i])*a;
    if (tmp<b){
      ans+=tmp;
    }else{
      ans+=b;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
//
//  main.cpp
//  Competitive
//
//  Created by Ashutosh Tiwari on 16/05/20.
//  Copyright © 2020 Ashutosh Tiwari. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <climits>
#include <functional>
#include <unordered_map>
#include <tuple>
#include <iterator>
#include <unordered_set>
#include <chrono>
#include <regex>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
//    freopen("../in.txt", "r", stdin);
    using ll = long long;
    const ll INF = 1e18L + 5;
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    int sum_value = 0;
    for (int i = 0;i < n; i ++) {
        scanf("%d%d", &weight[i], &value[i]);
        sum_value += value[i];
    }
    vector<ll> dp(sum_value + 1, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i ++)
        for (int j = sum_value - value[i]; j >= 0; j --)
            dp[j + value[i]] = min(dp[j + value[i]], dp[j] + weight[i]);
    ll ans = 0;

//    for (auto i: dp) cout << i << " ";
//    cout << endl;
    for (int i = 0; i <= sum_value; i ++) //{
        if (dp[i] <= W) //continue;
        ans = max(ans, (ll)i);
//    }
    printf("%lld\n", ans);


    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <set>
using namespace std;

const int MAX_SIZE = 20;
typedef pair<int, int> P;

int calc(char f[][MAX_SIZE], queue<P> q, int W, int H) {
  set<P> s;
  while (q.size()) {
    P p = q.front();
    q.pop();
    s.insert(p);
    int di[] = {-1, 1, 0, 0};
    int dj[] = {0, 0, -1, 1};
    for (int k = 0; k < 4; ++k) {
      int i = p.first  + di[k];
      int j = p.second + dj[k];
      if (i >= 0 && j >= 0 && i < H && j < W && f[i][j] == '.') {
        pair<set<P>::iterator, bool> r = s.insert(P(i, j));
        if (r.second) q.push(*r.first);
      }
    }
  }
  return s.size();
}
int main() {
  int W, H;
  char f[MAX_SIZE][MAX_SIZE];
  char c[MAX_SIZE + 1];
  while (true) {
    queue<P> q;
    cin >> W >> H;
    if (W == 0 && H == 0) break;
    for (int i = 0; i < H; ++i) {
      cin >> c;
      for (int j = 0; j < W; ++j) {
        f[i][j] = c[j];
        if (f[i][j] == '@') {
          q.push(P(i, j));
        }
      }
    }
    cout << calc(f, q, W, H) << endl;
  }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define int long long
#define INT INT_MAX
#define LONG LLONG_MAX
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
typedef long long ll;
using namespace std;

ll GCD(ll a, ll b) {
	if (b == 0)return a;
	return GCD(b, a%b);
}

ll LCM(ll a, ll b) {
	return a / GCD(a, b)*b;
}

ll mypow(ll a, ll b, ll c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	else return mypow(a, b / 2, c)*mypow(a, b / 2, c) % c;
}

signed main(){
	int a,b,x[110],y[110];
	cin>>a>>b>>x[0]>>y[0];
	f(i,a){
		cin>>x[i+1];
	}
	f(i,b) cin>>y[i+1];
	sort(x,x+a+1);
	sort(y,y+b+1);
	if(x[a]<y[0]) puts("No War");
	else puts("War");
	return 0;
}


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

int main() {
	int x; cin >> x;
	vector<int> f;
	while (x) {
		f.push_back(abs(x) % 2);
		x -= f.back(); x /= (-2);
	}
	if (f.empty()) f.push_back(0);
	reverse(f.begin(), f.end());
	for (int x : f) cout << x;
}

Measured memory_bytes: 256