akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e4 + 7;
typedef pair<int,int>P;

struct UnionFind{

  vector<int> parent;
  vector<int> rank;

  UnionFind(int n) : parent(n),rank(n) {
    rep(i,0,n){
      parent[i]=i;
      rank[i]=0;
    }
  }

  int root(int x){
    if(parent[x]==x)return x;
    return parent[x]=root(parent[x]);
  }

  void unite(int x,int y){
    int rx=root(x),ry=root(y);
    if(rx==ry)return ;

    if(rank[rx]<rank[ry])parent[rx]=ry;
    else {
      parent[ry]=rx;
      if(rank[rx]==rank[ry])rank[rx]++;
    }
  }

  bool same(int x,int y){
    int rx=root(x),ry=root(y);
    return rx==ry;
  }
};

int main(){

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

  UnionFind tree(n);
  vector<int> p(n);rep(i,0,n)cin>>p[i],p[i]--;

  rep(i,0,m){
    int x,y;cin>>x>>y;
    tree.unite(x-1,y-1);
  }

  int count=0;
  rep(i,0,n){
    if(tree.same(i,p[i])){
      count++;
    }
  }

  out(count);

  return 0;
}


Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
s = input()
ans = 0
for i in range(n):
    if s[i] == "A" and s[i+1:i+3] == "BC": ans += 1
print(ans)

Measured memory_bytes: 3060
n,k=map(int,input().split())
s=[i for i in input()]
if s[k-1]=="A":
  s[k-1]="a"
elif s[k-1]=="B":
  s[k-1]="b"
elif s[k-1]=="C":
  s[k-1]="c"
for i in range(len(s)):
  print(s[i],end="")

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

int main(void)
{
    int X;
    cin >> X;

    if (X == 7 || X == 5 || X == 3)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return (0);
}

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

using namespace std;

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    int n = 0;
    if (A == B) n++;
    if (B == C) n++;
    if (C == A) n++;

    string ans = (n == 1) ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define for(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll =long long ;
typedef pair<int,int > P;


ll j=0;
ll t;
ll k;
ll d(ll x,ll y){
  if (j==k){
    return t+1;
  }
  if (x%t==0 &&y%t==0){
    j++;
    t--;
    d(x,y);
  }
  else{
    t--;
    d(x,y);
  }
}


int main(){
  ll a,b;
  cin>>a>>b>>k;
  t=a;
  cout<<d(a,b)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
ll n;
ll x[100000+5], y[100000+5];
int main(){
  cin >> n;
  for(int i=0 ; i<n ; i++){
    cin >> x[i];
  }
  ll sum = 0;
  for(int i=0 ; i+1<n ; i++){
    y[i] = abs(x[i+1] - x[i]);
    sum += y[i];
  }
  sum += abs(x[n-1])+abs(x[0]);
  
  for(int i=0 ; i<n ; i++){
    ll a = 0;
    if(i) a = x[i-1];
    ll b = x[i];
    ll c = 0;
    if(i != n-1) c = x[i+1];
    ll ans = sum;
    ans -= abs(b-a);
    ans -= abs(c-b);
    ans += abs(a-c);
    cout << ans << endl;
  }
  return 0;
}


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

int main(void){
    int N, K, xi, yi, s;
    char C;
    cin >> N >> K;
    int XY[2005][2005];
    int ans=0;
    for(int i = 0 ;i < N ; i++){
        cin >> xi >> yi >> C;
        if(C == 'B') xi += K;
        XY[xi % (2*K)+1][yi % (2*K)+1]++;
    }

    for(int i=1;i<=2*K;i++){
		for(int j=1;j<=2*K;j++){
			XY[i][j] += -XY[i-1][j-1] +XY[i-1][j]+XY[i][j-1];
            
		}
	}

   
	for(int i=0;i<=K;i++){
		for(int j=0;j<=K;j++){
			s=XY[i][j]-XY[i][0]-XY[0][j]+XY[0][0];
            s+=XY[i+K][0]-XY[i+K][j]-XY[2*K][0]+XY[2*K][j];
            s+=XY[0][j+K]-XY[0][2*K]-XY[i][j+K]+XY[i][2*K];
            s+=XY[i][j]-XY[i][j+K]-XY[i+K][j]+XY[i+K][j+K];
            s+=XY[2*K][2*K]-XY[i+K][2*K]-XY[2*K][j+K]+XY[i+K][j+K];
            ans = max(ans, s);
            ans = max(ans, XY[2*K][2*K]-s);
		}
	}
  
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

ll mod = 1e9 + 7;

vector<ll> fact;

void init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % mod;
}

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % mod;
    if (pow % 2 == 1) a *= x;
    return a % mod;
}

ll calc_div(ll a, ll b) {
    return a * calc_pow(b, mod - 2) % mod;
}

int n;
ll ret = 0;
vector<vector<int>> graph;
vector<bool> visited;
ll uku;

int dfs(int v) {
    ret += calc_div(1, 2) - uku;
    ret = (ret + mod) % mod;

    int child = 0;
    for (auto nv:graph[v]) {
        if (!visited[nv]) {
            visited[nv] = true;
            int x = dfs(nv);
            ll y = uku * (calc_pow(2, x) - 1 + mod);
            y %= mod;
            ret -= y, ret = (ret + mod) % mod;
            child += x;
        }
    }

    ll y = uku * ((calc_pow(2, n - 1 - child) - 1 + mod));
    y %= mod;
    ret -= y, ret = (ret + mod) % mod;

    return child + 1;
}

int main() {
    cin >> n;
    graph = vector<vector<int>>(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b), graph[b].push_back(a);
    }

    uku = calc_div(1, calc_pow(2, n));
    visited = vector<bool>(n), visited[0] = true;
    dfs(0);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 20096
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
class CStep {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin >> n;

        vector<ll> a(n);
        for (ll i = 0; i < n; ++i) {
            cin >> a[i];
        }

        ll sum = 0;
        for (ll i = 1; i < n; ++i) {
            if (a[i - 1] > a[i]){
                ll d = abs(a[i] - a[i - 1]);
                sum += d;
                a[i] += d;
            }
        }

        cout << sum << endl;
	}
};


int main() {
	CStep solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();


    ll n, d, x, y, c=0;

    cin>> n>> d;
    d*= d;

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

        if(((x)*(x)+ (y)*(y))<=d)
            c++;
    }

    cout<< c;
    nl;

    return 0;
}




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

typedef long long LL;

int main()
{
	LL a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (abs(a - b) <= (v - w) * t) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 3624
<?php
fscanf(STDIN, '%d %d', $n, $m);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$q = new SplPriorityQueue;
for ($i = 0; $i < $n; $i++) {
    $q->insert($a[$i], $a[$i]);
}
$i = 0;
while ($i < $m) {
    $x = $q->extract();
    $x = $x / 2;
    $q->insert($x, $x);
    $i++;
}
$ans = 0;
while ($q->count() > 0) {
    $ans += (int)floor($q->extract());
}
echo $ans . PHP_EOL;

Measured memory_bytes: 53748
#include <iostream>

using namespace std;

int s[1000][1000] = { 0 };

int main()
{
	int H, W, A, B;

	cin >> H >> W >> A >> B;

	for (int i = 0; i < B; i++) {
		for (int j = 0; j < A; j++) {
			s[i][j] = 1;
		}
	}

	for (int i = B; i < H; i++) {
		for (int j = A; j < W; j++) {
			s[i][j] = 1;
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << s[i][j];
		}
		cout << endl;
	}

	return 0;
}


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

int calc(int x){
	int ret=0;
	while(x%100==0){
		x/=100;
		++ret;
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(0);
	int D,N;
	cin>>D>>N;
	int cnt=0,val=0;
	while(cnt<N){
		++val;
		if(calc(val)==D)++cnt;
	}
	cout<<val<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;

#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define double long double
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const i64 MOD = 1000000007;
const i64 INF = 2e15;

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

	int n, d;
	cin >> n >> d;

	int t = 2 * d + 1;

	cout << (n + t - 1) / t << endl;

	return 0;
}

Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((a (read))
         (b (read))
         (c (read)))
    (write-line (if (= a b c ) "Yes" "No"))))

#-swank(main)


Measured memory_bytes: 14436
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int A[3],ans=0;

int main(){
    rep(i,3)cin>>A[i];
    sort(A,A+3);
    if(A[1]%2!=A[0]%2)A[2]++,A[0]++,ans++;
    ans+=(A[2]*2-A[1]-A[0])/2;
    out(ans);
    
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i=0; i<N; i++){
    set<char> X, Y;
    for(int j=0; j<N; j++){
      if(j<i) X.insert(S[j]);
      else Y.insert(S[j]);
    }
    int tmp=0;
    for(auto x: X){
      if(Y.find(x)!=Y.end()) tmp++;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}


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

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A = keyboard.nextInt();
		int B = keyboard.nextInt();
		
		int p1 = 0;
		int p2 = 0;
		int p3 = 0;
		
		p1 = A + (A - 1);
		p2 = A + B;
		p3 = B + (B - 1);
		
		int[] ArrayX = {p1, p2, p3};
		Arrays.sort(ArrayX);

			System.out.println(ArrayX[2]);
			
		keyboard.close();	
	}
}

Measured memory_bytes: 22612
#include <stdio.h>

int main(void) {
    int A, B, M;
    scanf("%d %d %d", &A, &B, &M);

    int a[A+1];int b[B+1];
    int x, y, c, m;
    int mina = 200003;int minb = 200003;
    int minm, i;

    for (i = 1; i <= A; i++) {
        scanf("%d", &a[i]);
        if (mina > a[i]) mina = a[i];
    }
    for (i = 1; i <= B; i++) {
        scanf("%d", &b[i]);
        if (minb > b[i]) minb = b[i];
    }
    minm = mina + minb;

    for (i = 0; i < M; i++) {
        scanf("%d %d %d", &x, &y, &c);
        m = a[x]+b[y]-c;
        if (minm > m) minm = m;
    }

    printf("%d\n", minm);
    return 0;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        for(int i=0; i<=100; i++){
            for(int j=0; j<=100; j++){
                if(N == i*4 + j*7){
                    System.out.println("Yes");
                    return;
                }

            }
        }

        System.out.println("No");
        return;

    }

    static List<Integer> primeList(int n) {
        List<Integer> list = new ArrayList<>();
        boolean[] prime = new boolean[n + 1];
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        for (int i = 2; i < Math.sqrt(n); i++) {
            if (!prime[i]) continue;
            for (int j = 2; i * j <= n; j++) {
                prime[i * j] = false;
            }
        }
        for (int i = 0; i < prime.length; i++) {
            if (prime[i]) list.add(i);
        }

        return list;
    }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

queue<ll> que;

int main(void){
	int k,i;
	ll v;
	cin >> k;
	for(i=1; i<10; ++i){
		que.push(i);
	}
	while(!que.empty()){
		v = que.front();
		que.pop();
		--k;
		if(!k){
			cout << v << endl;
			break;
		}
		if(v%10!=0){
			que.push(v*10+v%10-1);
		}
		que.push(v*10+v%10);
		if(v%10!=9){
			que.push(v*10+v%10+1);
		}
	}
	return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

class Main {
	static final int M = 1000000007;

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		String k = sc.next();
		int d = sc.nextInt();

		int[][][] dp = new int[k.length() + 1][101][2];
		dp[0][0][0] = 1;

		for (int i = 0; i < k.length(); i++) {
			for (int j = 0; j < d; j++) {
				for (int l = 0; l < 2; l++) {
					int c = Character.digit(k.charAt(i), 10);
					for (int next = 0; next < 10; next++) {
						if (next < c) dp[i + 1][(j + next) % d][1] += dp[i][j][l];
						else if (next == c) dp[i + 1][(j + next) % d][l] += dp[i][j][l];
						else if (l == 1) dp[i + 1][(j + next) % d][l] += dp[i][j][l];
						dp[i + 1][(j + next) % d][0] %= M;
						dp[i + 1][(j + next) % d][1] %= M;
					}
				}
			}
		}

		System.out.println((((dp[k.length()][0][0] - 1 + M) % M) + dp[k.length()][0][1]) % M);
	}
}


Measured memory_bytes: 58324
import java.util.*;
import java.io.*;
import java.math.*;
class Main{

	public static void main(String args[]){
		FastReader sc = new FastReader();
		int n,k,i,j; 
		n=sc.nextInt();
		k=sc.nextInt();
		int a[]=new int[n+1];
		for(i=1;i<=n;i++)
			a[i]=sc.nextInt();
		int dp[]=new int[n+1];
		Arrays.fill(dp,Integer.MAX_VALUE);
		dp[1]=0;
		for(i=2;i<=n;i++){
			for(j=1;j<Math.min(i,k+1);j++)
				dp[i]=Math.min(dp[i],dp[i-j]+Math.abs(a[i]-a[i-j]));
		}
		out.println(dp[n]);
		out.flush();

	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

	static class pair{
		int first,second;
		pair(int f,int s){
			first=f;
			second=s;
		}
	}

	public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	}

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(int a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        int L[]=new int[n1];
        int R[]=new int[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(int a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
}



Measured memory_bytes: 33804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    ll d,n;
    cin>>d>>n;
    if(d==0&&n!=100){
      cout<<n<<endl;
    }else if(d==0&&n==100){
      cout<<101<<endl;
    }
   else if(d==1&&n!=100){
      cout<<100*n<<endl;
    }
  else if(d==1&&n==100){
      cout<<100*(n+1)<<endl;
  }
  else if(d==2&&n!=100){
      cout<<10000*n<<endl;
    }
  else{
    cout<<10000*(n+1)<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;
const ll mod = 1000000007;

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
S = list(input().strip())

L = []
t = S[0]
counter = 1
for i in range(1, N):
    if t == S[i]:
        counter += 1
    else:
        L.append((counter, t))
        t = S[i]
        counter = 1
        
L.append((counter, t))

P = [0] * (len(L) + 1)
for i in range(len(L)):
    P[i + 1] = P[i] + L[i][0]
    
ma = 0
t = K * 2 + 1
for i in range(len(P) - 1):
    if L[i][1] == '0':
        index = min(i + t - 1, len(P) - 1)
        ma = max(ma, P[index] - P[i])
    else:
        index = min(i + t, len(P) - 1)
        ma = max(ma, P[index] - P[i])
    
print(ma)

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll ans = 0;
    ans += min(a, k) - min(c, max(0LL, k - (a + b)));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
import java.io.*;
import java.util.*;

 
public class Main{
	static class FastReader{
        BufferedReader br,br1;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        public FastReader(String fileName) throws FileNotFoundException{br = new BufferedReader(new FileReader(fileName));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        char[][] readCharArray(int n,int m) {
        	String str;
        	char[][] arr = new char[n][m];
        	for(int i=0;i<n;i++) {
        		str=nextLine();
        		for(int j=0;j<n;j++) {
        			arr[i][j]=str.charAt(j);
        		}
        	}
        	return arr;
        }
        char[][] readCharArray(int n){
        	return readCharArray(n,n);
        }
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static final Random random=new Random();
    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    static List<Integer>[] arr;
	static boolean[] vis;
    static void addEdge(int n,int m) {
		arr[n-1].add(m-1);
		arr[m-1].add(n-1);
	}
    static int dfs(int n) {
    	int count=0;
    	if(!vis[n]) {
    		vis[n]=true;
    		count++;
    		for(int i:arr[n]) {
    			if(!vis[i]) {
    				count+=dfs(i);
    			}
    		}
    	}
    	return count;
    }
    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws NumberFormatException, IOException {
//    	long time = System.currentTimeMillis();
//		FastReader st = new FastReader("src/input.txt");
//		PrintWriter out = new PrintWriter(new FileWriter("src/output.txt"));
    	FastReader st = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        int n = st.nextInt();
        int m = st.nextInt();
        int temp,len,ele;
        arr = new List[n];
        vis = new boolean[n];
        for(int i=0;i<n;i++) arr[i] = new ArrayList<Integer>();
        for(int i=0;i<m;i++) addEdge(st.nextInt(),st.nextInt());
        int ans=0;
        for(int j=0;j<n;j++) {
        	if(!vis[j]) {
        		ans = Math.max(ans, dfs(j));
        	}
        }
        out.println(ans);
        out.close();
//        System.err.println(System.currentTimeMillis()-time);
    }
}


Measured memory_bytes: 87676
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> S(H, vector<int>(W));
{
    string s[H];
    rep(i, H) cin >> s[i];
    rep(i, H) rep(j, W) S[i][j] = s[i][j] - '0';
}   
    int ans = 1e9;
    vector<vector<int>> w_sum(H, vector<int>(W+1, 0));
    rep(i, H) rep(j, W) w_sum[i][j+1] += w_sum[i][j] + S[i][j];
    for(int bit = 0; bit < (1 << H); bit++){
        vector<int> divi; divi.emplace_back(0);
        int res = 0;
        for(int i = 0; i < H; i++){
            if(bit & (1 << i)) {
                divi.emplace_back(i+1);
                res++;
            }
        }

        divi.emplace_back(H);
        int last = 0;
        int MAX = 0;
        for(int w = 1; w <= W; w++){
            for(int i = 1; i < divi.size(); i++){
                int sum = 0;
                for(int k = divi[i-1]; k < divi[i]; k++) sum += w_sum[k][w] - w_sum[k][last];
                MAX = max(MAX, sum);
            }
            if(MAX > K){
                if(last == w-1) {
                    res = 1e9;
                    break;
                }
                last = w-1;
                w--;
                MAX = 0;
                res++;

                //for(auto& d : divi) cout << d << " ";
                //cout << ":" << w << endl;
            }
        }

        ans = min(ans, res);
    }

    cout << ans << endl;

}


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

using namespace std;

long long N, X, M;
map <long long, int> values;
long long sums[4000000];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N >> X >> M;
	
	values[X] = 1;
	sums[1] = X;
	
	long long rep_beg, rep_end;
	long long rep_sum;
	for (int i = 2; ; i++) {
		X = (X * X) % M;
		
		if (values.count(X) != 0) {
			rep_beg = values[X];
			rep_end = i - 1;
			rep_sum = sums[rep_end] - sums[rep_beg - 1];
			break;
		}
		
		values[X] = i;
		sums[i] = sums[i - 1] + X;
	}
	
	long long ans;
	
	if (rep_beg > N) {
		ans = sums[N];
	} else {
		long long cycles = (N - rep_beg + 1) / (rep_end - rep_beg + 1);
		ans = 0;
		ans += rep_sum * cycles;
		ans += sums[N - cycles * (rep_end - rep_beg + 1)];
	}
	
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 7108
#include <iostream>

using namespace std;

int main(void) {
    int N, K, S;
    cin >> N >> K >> S;
    if(S == 1'000'000'000) {
        for(int i=0; i<K; i++) {
            cout << S << endl;
        }
        for(int i=K; i<N; i++) {
            cout << 1 << endl;
        }
    } else {
        for(int i=0; i<K; i++) {
            cout << S << " ";
        }
        for(int i=K; i<N; i++) {
            cout << 1'000'000'000 << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)170 * 80;

vector<vector<ll>> A;
vector<vector<ll>> B;

// vector<vector<set<ll>>> Dif;
vector<vector<vector<bool>>> Dif;

void Update(int h, int w) {
   if (h>0) {
      // for (auto el: Dif[h-1][w]) {
      //    Dif[h][w].insert(abs(el + A[h][w] - B[h][w]));
      //    Dif[h][w].insert(abs(el - A[h][w] + B[h][w]));
      // }
      rep(i,0,MAX) {
         if (!Dif[h-1][w][i]) continue;
         Dif[h][w][abs(i+A[h][w] - B[h][w])] = true;
         Dif[h][w][abs(i-A[h][w] + B[h][w])] = true;
      }
   }
   if (w>0) {
      // for (auto el: Dif[h][w-1]) {
      //    Dif[h][w].insert(abs(el + A[h][w] - B[h][w]));
      //    Dif[h][w].insert(abs(el - A[h][w] + B[h][w]));
      // }
      rep(i,0,MAX) {
         if (!Dif[h][w-1][i]) continue;
         Dif[h][w][abs(i+A[h][w] - B[h][w])] = true;
         Dif[h][w][abs(i-A[h][w] + B[h][w])] = true;
      }
   }
   return;
}

int main(void) {
   ll H,W;
   cin>>H>>W;
   A.resize(H);
   B.resize(H);
   rep(i,0,H) A[i].resize(W,0);
   rep(i,0,H) B[i].resize(W,0);
   rep(i,0,H) rep(j,0,W) cin>>A[i][j];
   rep(i,0,H) rep(j,0,W) cin>>B[i][j];
   Dif.resize(H);
   rep(i,0,H) Dif[i].resize(W);
   rep(i,0,H) rep(j,0,W) Dif[i][j] = vector<bool>(MAX,false);
   Dif[0][0][abs(A[0][0] - B[0][0])] = true;
   // Dif[0][0].insert(abs(A[0][0] - B[0][0]));
   // Dif[0][0].insert(B[0][0] - A[0][0]);
   rep(i,0,H) rep(j,0,W) Update(i,j);

   rep(i,0,MAX) {
      if (Dif[H-1][W-1][i]) {
         cout<<i<<endl;
         break;
      }
   }

   // for (auto el: Dif[H-1][W-1]) cout<<el<<endl;
   // auto itr = Dif[H-1][W-1].lower_bound(0);
   // cout<<*itr<<endl;
   // if (itr != Dif[H-1][W-1].begin()) {
   //    itr--;
   //    cout<<*itr<<endl;
   // }


   


   return 0;
}

Measured memory_bytes: 11264
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

template <typename T>
T abs(T x) {return (x < 0) ? -x : x;}

cat pw(cat a, cat e, cat mod) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2, mod);
	x = x * x % mod;
	return (e&1) ? x * a % mod : x;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
	int T;
	cin >> T;
	while(T--) {
		int N;
		cin >> N;
		vector<cat> A(N);
		for(int i = 0; i < N; i++) cin >> A[i];
		string S;
		cin >> S;
		vector<cat> V;
		vector<int> pivot;
		int ans = 0;
		for(int i = N-1; i >= 0; i--) {
			if(S[i] == '0') {
				for(int j = 0; j < (int)V.size(); j++)
					if(A[i]&(1LL<<pivot[j])) A[i] ^= V[j];
				if(A[i]) {
					V.push_back(A[i]);
					for(int j = 0; j < 60; j++) if((A[i]>>j)&1) {
						pivot.push_back(j);
						break;
					}
				}
			}
			else {
				for(int j = 0; j < (int)V.size(); j++)
					if(A[i]&(1LL<<pivot[j])) A[i] ^= V[j];
				if(A[i]) ans = 1;
			}
		}
		cout << ans << "\n";
	}
}

// look at my code
// my code is amazing


Measured memory_bytes: 3512
from collections import defaultdict as dd
N = input()
a_raw = list(map(int, input().split()))
num_count = dd(int)
for item in a_raw:
    num_count[item] += 1
    num_count[item-1] += 1
    num_count[item+1] += 1
print(max(num_count.values()))

Measured memory_bytes: 20012
#include <iostream>
#include <string>
#include <cctype>
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
using namespace std;

int main(void){
	string s;
	getline(cin,s);	
	EACH(i,s)
		if(islower(*i))
			*i=toupper(*i);
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int n,d,z;cin>>n>>d;
   vector<vector<int>> x(n,vector<int>(d));
   rep(i,n){
   rep(j,d){
     cin>>x.at(i).at(j);
   }
   }
  rep(i,n){
   for(int j=i+1;j<n;j++){
     int u=0,t=0;
     rep(k,d){
      u=x.at(i).at(k)-x.at(j).at(k);
       u=u*u;
       t+=u;
     }
     u=t;
     bool ans=false;
     rep(l,u*2){
      if(t==l*l)ans=true;
     }
     if(ans)z++;
   }
  }
  cout<<z<<endl;
}


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

typedef long long ll;

const int Maxn = 100005;

int n;
int a[Maxn];
ll my[Maxn];

int main()
{
	scanf("%d", &n);
	a[0] = 0;
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	a[n + 1] = 0;
	ll tot = 0;
	for (int i = 0; i <= n; i++) {
		tot += abs(a[i + 1] - a[i]);
		if (i > 0) my[i] = abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]) - abs(a[i + 1] - a[i - 1]);
	}
	for (int i = 1; i <= n; i++)
		printf("%lld\n", tot - my[i]);
	return 0;
}

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

using namespace std;

using ll = long long;
const int N = 1001;
vector<int> adj[N];
int color[N], parent[N];
int inDeg[N], outDeg[N];
int n, m;

#define WHITE 0
#define GREY 1
#define BLACK 2

void print(int st, int en) {
    vector<int> cycle;
    for (int v = en; v != st; v = parent[v]) {
        cycle.push_back(v);
    }
    cycle.push_back(st);
    cout << cycle.size() << '\n';
    for (auto nx : cycle) {
        cout << nx << '\n';
    }
}

void check(int st, int en) {
    set<int> nodes;
    for (int v = en; v != st; v = parent[v]) {
        nodes.insert(v);
    }
    nodes.insert(st);
    int cnt = 0;
    for (auto v : nodes) {
        for (auto nx : adj[v]) {
            if (nodes.count(nx)) {
                cnt++;
            }
        }
    }
    if (cnt == (int) nodes.size()) {
        print(st, en);
        exit(0);
    }
}

void dfs(int v) {
    color[v] = GREY;
    for (auto nx : adj[v]) {
        if (color[nx] == WHITE) {
            parent[nx] = v;
            dfs(nx);
        } else if (color[nx] == GREY) {
            int st = nx;
            int en = v;
            check(st, en);
        }
    }
    color[v] = BLACK;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        inDeg[v]++;
        outDeg[u]++;
    }
    for (int i = 1; i <= n; i++) {
        if (color[i] == WHITE) {
            dfs(i);
        }
    }
    cout << -1;
    return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	string str;
	cin>>str;
	if (str[a] != '-') {
		cout << "No" << endl;
		return 0;
	}
	else
		str[a] = '5';
	for (int i = 0; i < a+b+1; i++) {
		if (str[i] > '9' || str[i] < '0') {
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for i in range(N)]

    base_w = wv[0][0]
    dic = {wv[0][0]:[], wv[0][0]+1:[], wv[0][0]+2:[], wv[0][0]+3:[]}
    for i in range(N):
        w, v = wv[i]
        dic[w].append(v)
    
    wv = sorted(list(dic.items()))
    tmp = [None for i in range(4)]
    for i in range(4):
        num, l = wv[i]
        l = sorted(l, reverse=True)
        for j in range(1, len(l)):
            l[j] += l[j-1]
        tmp[i] = [0] + l

    # for i in range(4):
    #     print(tmp[i][:10])

    ans = 0
    for i in range(len(tmp[0])):
        for j in range(len(tmp[1])):
            for k in range(len(tmp[2])):
                for l in range(len(tmp[3])):
                    weight = base_w * i + (base_w + 1) * j + (base_w + 2) * k + (base_w + 3) * l
                    if weight <= W:
                        val = tmp[0][i] + tmp[1][j] + tmp[2][k] + tmp[3][l]
                        if ans < val:
                            ans = val
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n;
vector<int> h;

int main()
{
    cin >> n;
    h.resize(n);
    bool f = true;

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

    for (int i = n-1; i > 0; --i){
        if ((h[i] + 1) == h[i-1]) --h[i-1];
        if (h[i] < h[i-1]) {
            f = false;
            break;
        }
    }

    if (f) printf("Yes\n");
    else printf("No\n");

    return 0;
}
        


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

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

typedef long long ll;

using namespace std;

int INF = 1e9;

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

  bool ok = false;
  if(s.size() % 2 == 1) ok = true;
  for(auto&i:s){
    if(i != s[0]) ok = false;
  }

  ll on = 0, tw = 0;
  char b = '!';
  for(auto &i: s){
    if(i == b){
      on++;
      b = '!';
    }
    else b = i;
  }
  b = '!';
  for(auto &i: s+s){
    if(i == b){
      tw++;
      b = '!';
    }
    else b = i;
  }

  if(ok){
    if( k % 2 == 1 ) cout << tw * (k-1) / 2 + on << endl;
    else cout << tw * k / 2 << endl;
    return 0;
  }
  ll ans = (tw - on) * (k-1) + on;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

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

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


int main() {

  string s;
  cin >> s;

  int N = s.length();

  const int MOD = 1e9 + 7;

  vector<ll> p3;
  vector<ll> p2;
  ll tmp2 = 1;
  ll tmp3 = 1;
  REP(i, N + 1){
    p2.push_back(tmp2);
    p3.push_back(tmp3);

    tmp2 = (tmp2 * 2) % MOD;
    tmp3 = (tmp3 * 3) % MOD;
  }

  ll ans = p3[N];

  ll cum = 0;
  REP(i, N){
    if (s[i] == '1') {
      cum++;
      continue;
    }
    ll tmp = p2[cum + 1];
    tmp = (tmp * p3[N - 1 - i]) % MOD;
    ans = (ans + MOD - tmp) % MOD;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  while (B <= A) B *= 2, K--;
  while (C <= B) C *= 2, K--;
  cout << ((K >= 0) ? "Yes" : "No") << "\n";
}

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

int main()
{
  int y, yy, i;
  bool f, ff;

  ff = false;
  while (cin>>y>>yy, y||yy) {
    if (ff) cout<<endl;
    f = true;
    if (y%4)
      y += 4-y%4;
    for(i = y; i <= yy; i += 4) {
      if( ( !(i%100) + !(i%400) ) == 1) continue;
      cout<<i<<endl;
      f = false;
    }
    if (f) cout<<"NA"<<endl;
    ff = true;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll d, n;
    cin >> d >> n;
    ll k = 1;
    while(d--) k *= 100;
    for(ll i = 1; i <= 10000000; i++){
        if(i%k == 0 && (i% (k*100) != 0)) n--;
        if(n == 0) ANS(i);
    }

}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
// C - Lining Up
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

	vector<int> A(N);
	for(int i=0; i<N; i++){
		int a; cin>>a;
		A[a]++;
		if(A[a]>2){ cout<<'0'<<endl; return 0; }
	}

	int odd = N%2;
	int ans = odd? 1:2;

	if(A[!odd]!=ans){ cout<<'0'<<endl; return 0; }

	for(int i=3-odd; i<N; i+=2){
		if(A[i]<2){ cout<< '0' <<endl; return 0; }
		ans = ans * 2 % MOD;
	}
	cout<< ans <<endl;
}

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

int main() {
    int H, W;

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



Measured memory_bytes: 3116
N, K = gets.split.map(&:to_i)
V = gets.split.map(&:to_i)

ans = []
N.times do |l|
  l.upto(N - 1) do |r|
    t = N - (r - l + 1)
    next if t > K

    hand = []
    l.times do |i|
      hand << V[i]
    end
    (r + 1).upto(N - 1) do |i|
      hand << V[i]
    end
    hand.sort!

    tmp = hand.empty? ? 0 : hand.reduce(:+)
    (K - t).times do |i|
      break if i >= t || hand[i] > 0
      tmp -= hand[i]
    end
    ans << tmp
  end
end

if K >= N
  tmp = V.reduce(:+)
  V.sort!
  (K - N).times do |i|
    break if i >= N || V[i] > 0
    tmp -= V[i]
  end
  ans << tmp
end

p ans.max

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 1e9  //
#define INFLL 4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define PB(a) push_back(a)
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

// a 0x61  z 0x7a  0 0x30

//------------------------------------------------------

int main() {
    int n, a;
    cin >> n >> a;
    int x[n];

    rep(i, n) {
        cin >> x[i];
    }

    ll dp[n + 1][n + 1][50 * a + 1]; //i枚目まで調べる & k枚取る & 合計がs

    rep(i, n + 1) {

        rep(j, a + 1) {
            dp[0][i][j] = 0;
        }
    }

    dp[0][0][0] = 1;

    rep(i, n) {

        rep(k, n + 1) {

            rep(s, 50 * a + 1) {
                if (s < x[i]) {
                    dp[i + 1][k][s] = dp[i][k][s];
                } else {
                    dp[i + 1][k][s] = dp[i][k][s] + dp[i][k - 1][s - x[i]];
                }
            }
        }
    }

    ll sum = 0;

    rep2(i, n) {
        sum += dp[n][i][i * a];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 51072
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=3005;
typedef long long ll;
ll s[N][N];int a[N],n,t;
int main(){
	scanf("%d",&n),t=n&1;
	fp(i,1,n)scanf("%d",&a[i]),s[i][i]=t?a[i]:-a[i];
	fp(k,2,n)if((k&1)==t)for(R int i=1,j=k;j<=n;++i,++j)s[i][j]=max(s[i+1][j]+a[i],s[i][j-1]+a[j]);
	else for(R int i=1,j=k;j<=n;++i,++j)s[i][j]=min(s[i+1][j]-a[i],s[i][j-1]-a[j]);
	printf("%lld\n",s[1][n]);
	return 0;
}

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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,t[100],m,p,x,memo[100],sum;

main() {
    cin >> n;
    rep(i,n) {
        cin >> t[i];
        sum += t[i];
    }
    cin >> m;
    rep(i,m) {
        cin >> p >> x;
        memo[i] = x-t[p-1];
    }
    rep(i,m) ct(sum+memo[i])
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define show(x) std::cerr << #x << "=" << x << std::endl
using namespace std;
typedef long long ll;
const double eps=1e-8;
const int maxn = 2e5+5;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
ll n ;
ll p = 26;
ll d[2005];
int main()
{
    //cout<<26*26<<"\n";
    int cnt = 0;
    while(cin>>n){
    cnt = 0;
    while(n)
    {
        d[++cnt] = n%p;
        n/=p;
    }

    for(int i=1;i<=cnt-1;++i)
    {
        if(d[i]<1)
        {
            d[i+1]-=1,d[i]+=26;
        }
    }
    for(int i=cnt;i>=1;--i)
    {
        if(d[i]==0) continue;
        cout<<(char)(d[i]-1+'a');
    } cout<<"\n";}
    return 0;
}


Measured memory_bytes: 3636