akhauriyash/Code-Regression huggingface dataset:
#include <unistd.h>
#include <stdlib.h>

void writing(int ans)
{
    char c;
    if (ans < 10)
    {
        c = ans + '0';
        write(1, &c, 1);
    }
    else
    {
        writing(ans / 10);
        writing(ans % 10);
    }
}

int get_num(char *s)
{
    int num;
    int i;
    
    i = -1;
    while (s[++i] != 10)
    {
        if (s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                    
            }
            return (num);
        }
    }  
}

void get_nums(int *array, char *s, int count)
{
    int num;
    int i;
    
    i = -1;
    while (s[++i])
    {
        if (s[i] != 10 && s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                if (!s[i])
                {
                    array[count] = num;
                    return ;                    
                }
            }
            array[count++] = num;
            i--;
        }
    }  
}

void get_num_plus(int *tab, char *tmp, int pass_flag, int count)
{
    int i;
    
    i = -1;
    while (count < pass_flag)
    {
        while (tmp[++i] != 10)
            ;
        count++;
    }
    get_nums(tab, &tmp[++i], 0);
}

void get_ans(int n, char *tmp)
{
    int i;
    int j;
    int tab[n];
    int count;
    
    get_num_plus(tab, tmp, 1, 0);
    count = 0;
    j = 0;
    i = -1;
    while (++i < n)
    {
        count++;
        if (tab[j] == 2)
        {
            writing(count);
            return ;
        }
        j = tab[j] - 1;
    }
    write(1, "-1", 2);
}

char *create_array(char *s, char *new_arr, char *t, int size)
{
    int i;
    int j;
    
    i = -1;
    while (s[++i])
        new_arr[i] = s[i];
    free(s);
    j = 0;
    while (j < size)
        new_arr[i++] = t[j++];   
    new_arr[i] = 0;
    return (new_arr);
}

char *get_data(char *s)
{
    int size;
    int sum_size;
    char t[1000000];
    char *new_arr;
    
    sum_size = 0;
    while ((size = read(0, t, 1000000)))
    {
        if (size == -1)
            return (NULL);
        sum_size += size;
        if (!(new_arr = (char*)malloc(sum_size + 1)))
            return (NULL);
        s = create_array(s, new_arr, t, size);
    }
    return (s);
}

int main(void){
    int num;
    char *s;
    
    s = malloc(1);
    s = get_data(s);
    num = get_num(s);
    get_ans(num, s);
    free(s);
    return (0);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 1000000000

int main() {
    int k,ans=0,r=0;
    cin >> k;
    vector<bool> C(k+1);
    while (1){
        r = (10*r+7)%k;
        if (C.at(r)){
            cout << -1 << endl;
            break;
        }
        ans += 1;
        if (r==0){
            cout << ans << endl;
            break;
        }
        C.at(r) = 1;
    }
}

Measured memory_bytes: 3684
d = raw_input()

d_list = []
for i in range(len(d)):
    d_list.append(ord(d[i]))

ans = ord('a')
while True:
    if ans not in d_list:
        break
    if ans > ord('a')+122:
        break
    ans += 1

if ans > 122:
    print 'None'
else:
    print chr(ans)


Measured memory_bytes: 6720
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007

using namespace std;

int n;
ll a, bin[60], pow2 = 1, ans;

ll modx(ll x)
{
  return (x%MOD+MOD)%MOD;
}

int main()
{
  cin >> n;
  for(int i = 0; i<n; i++)
  {
    cin >> a;
    for(int j = 0; j<60; j++)
    {
      if(a%2) bin[j]++;
      a/=2;
    }
  }
  for(int i = 0; i<60; i++)
  {
    ll cur = modx(bin[i]*(n-bin[i]));
    ans = modx(ans+modx(cur*pow2));
    pow2 = modx(pow2*2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.);
const long long mod = 1000000007;
typedef long long ll;
//printf("%.12lf\n",mid);
//const long long sze = 2*(2^(long long)(ceil(log(100000)/log(2))));
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
long long lcm(int a, int b){
  return ((long long)a*(long long)b)/gcd(a, b);
}
inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};
long long modpow(long long x, long long n) { 
  if (n == 0) return 1%mod; 
  long long u = modpow(x,n/2); 
  u = (u*u)%mod; 
  if (n%2 == 1) u = (u*x)%mod; 
  return u;
}
 
long long modpow2(long long x, long long n, long long modd) { 
  if (n == 0) return 1LL%modd; 
  long long u = modpow2(x,n/2LL, modd); 
 
  u = (long long)(u*u)%modd; 
  if (n%2LL == 1) u = (long long)(u*x)%modd; 
  return u;
}
 
bool chosen[1001]={false};

vector<int> permutation;
int arr[4];
bool mapp[501][501] = {{false}};
int maxxx = -1;
void search(int n) {
  if (permutation.size() == n) {
    
  } else {
    for (int i = 0; i < n; i++) {
      if (chosen[i]) continue;
      chosen[i] = true;
      permutation.push_back(i);
      search(n);
      chosen[i] = false;
      permutation.pop_back();
    }
  }
}

vector<long long> primeFactors(long long n)
{
    // Print the number of 2s that divide n
    vector<long long> res;
    bool found = false;
    while (n%2 == 0)
    {
      found = true;
        n = n/2;
    }
    if (found){
      res.push_back(2);
    }
    // n must be odd at this point.  So we can skip 
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
      
        // While i divides n, print i and divide n
        bool found2 = false;
        while (n%i == 0)
        { 
          found2 = true;
            n = n/i;
        }
        if (found2){
          res.push_back(i);
        }
    }

    // This condition is to handle the case when n 
    // is a prime number greater than 2
    if (n > 2)
        res.push_back(n);
    return res;
}

int main(){
  prep();
  int a, b;
  cin >> a >> b;
  if (a == 2 || b == 2){
    cout << "No";
  }else{
    cout << "Yes";
  }
     
  return 0;
}
// if TLE think about switching or removing loops & try not to use vector functions like size() or create new vector in a loop
// never use brackets with map when accessing value
// if the input/output is just a number see if it fits into a function (linearly, exponentially)
// if getting error for no reason check overflows
// if can't think of anything efficient try brute force
// look at solved problems of other ppl 2 see which is easiest
// if can precompute 
// if getting random error w/ loop check if boundaries are being changed during loop
// if you can't solve any more problems check for hacks in ur code then hack 
// in reversing problems if checking for a pattern use write down indices
// if already sure about wrong answers check TLE

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=100;i>=1;i--){
    if(a%i==0&&b%i==0){
      k--;
      if(k==0){
        cout<<i<<endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

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

    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    int x[q][2];
    rep(i,q) cin >> x[i][0] >> x[i][1];
    
    int d[n];
    d[0] = 0;
    
    for(int i=1; i<n; i++){
        if(s[i-1]=='A' && s[i]=='C') d[i] = d[i-1] + 1;
        else d[i] = d[i-1];
    }
    
    rep(i,q){
        cout << d[x[i][1] - 1] - d[x[i][0] - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 2256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int MAX = 100000;
int arr[MAX + 1];
vector<int> L;
int n;
int lis()
{
	L.push_back(arr[0]);
	for (int i = 1; i < n; i++)
		if (arr[i] > L.back())
			L.push_back(arr[i]);
		else
			*lower_bound(L.begin(), L.end(), arr[i]) = arr[i];
	return L.size();
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	cout << lis() << endl;
}


Measured memory_bytes: 3720
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
print('Yes' if s == t[:n] else 'No')

Measured memory_bytes: 10192
#include <bits/stdc++.h>
using namespace std;
#define int long long
int N;
vector<int> A;
bool check(int k) {
	if (k <= 0) return false;
	int p = 0;
	for (int i = 0; i < N; i++) {
		if ((A[i] + k) % (N + 1) == N) {
			return false;
		}
		p += (A[i] + k) / (N + 1);
	}
	return (p == k);
}
signed main() {
	cin >> N;
	A.resize(N);
	int sum = 0;
	int mx = -1;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
		mx = max(mx, A[i]);
	}
	if (mx < N) {
		cout << 0 << endl;
		return 0;
	}
	int res = -1;
	int x;
	for (int i = 0; i <= 49 * N; i++) {
		x = sum - i;
		if (check(x)) {
			res = x;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define sz(x) (int)(x.size())

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    int n = sz(s);
    int a[n + 1];
    a[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
        a[i] = a[i + 1];
        if (s[i] == 'T')
            a[i]++;
    }
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'S') {
            if (a[i] > ans){
                ans++;
            }
        }
    }
    cout << n - 2 * ans << "\n";
}

Measured memory_bytes: 2196
import itertools

n, m, q = map(int, input().split())
l = []
ans = 0
ref = 0

for i in range(q):
    abcd = list(map(int, input().split()))
    l.append(abcd)

for i in itertools.combinations_with_replacement(range(1, m + 1), n):
    for a, b, c, d in l:
        if i[b - 1] - i[a - 1] == c:
            ref += d
    ans = max(ans, ref)
    ref = 0

print(ans)

Measured memory_bytes: 9108
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int a[10]={0};
    int k=0;
    while(n){
        a[k++]=n%10;
        n/=10;
    }
    if((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3]))
    printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

#define ll int

void solve(){
    ll n,m;
    ll ans;

    while(cin>>n>>m,n|m){
        vector<ll> v,sum_v;

        for(ll i=0;i<n;i++){
            ll t;
            cin >> t;
            v.push_back(t);
        }

        v.push_back(0);

        for( auto t:v ){
            for( auto s:v ){
                sum_v.push_back(t+s);
            }
        }

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

        ans=-1;
        for( auto t:sum_v ){
            if( binary_search(sum_v.begin(),sum_v.end(),m-t) ){
                ans=m;
                break;
            }else{
                auto it=upper_bound(sum_v.begin(),sum_v.end(),m-t);
                if( it != sum_v.begin() ){
                    ans=max(ans,t + *(--it));
                }
            }
        }

        cout<<ans<<endl;
    }
}

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

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
#define MAXN 1000000007
 
 
int main() {
	ll a,b;
	cin>>a>>b;
	if (a>b) {
		cout<<"a > b"<<endl;
	}
	else {
		if (a<b) {
			cout<<"a < b"<<endl;
		}
		else {
			cout<<"a == b"<<endl;
		}
	}
}
	


Measured memory_bytes: 3084
use std::cmp;
use std::io::stdin;

fn calc_num_i_j_for_k(x: i32, y: i32, k: i32, n: i32) -> i32 {
    let mut res = 0;
    for i in 1..n {
        for j in i + 1..n + 1 {
            let min_dist = cmp::min(j - i, (x - i).abs() + (j - y).abs() + 1);
            if min_dist == k {
                res += 1;
            }
        }
    }

    res
}

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let in_vec: Vec<i32> = s
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    let n = in_vec[0];
    let x = in_vec[1];
    let y = in_vec[2];

    let mut reses: Vec<i32> = Vec::new();
    for k in 1..n {
        reses.push(calc_num_i_j_for_k(x, y, k, n));
    }

    for i_res in reses {
        println!("{}", i_res);
    }
}


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

int findgcd(int a, int b){
    if(b == 0) return a;
    return findgcd(b,a%b);
}

int main(){
    int n;
    cin >> n;
    
    vector<int> x;
    vector<int> d;
    
    rep(i,n+1){
        int x_;
        cin >> x_;
        x.push_back(x_);
    }
    
    sort(x.begin(), x.end());
    
    rep(i,n){
        d.push_back(x[i+1]-x[i]);
    }
    
    int gcd = findgcd(d[0],d[1]);
    
    if(d.size()>2){
        for(int i = 2; i < n - 1; i++){
            gcd = findgcd(gcd, d[i]);
        }
    }
    
    cout << gcd;
}


Measured memory_bytes: 1400
import fractions
import math
a,b = [int(i) for i in input().split()]

gcd = fractions.gcd(a,b)

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    return divisors

l = make_divisors(gcd)

print(len([i for i in l if is_prime(i)]) +1)

Measured memory_bytes: 5308
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	ll N, K; cin >> N >> K;
	V<ll> a(N); REP(i, N) cin >> a[i];
	sort(ALL(a));
	corner(accumulate(ALL(a), 0LL) < K, N);
	int ok = N-1, ng = -1, md;
	while(ok-ng>1){
		md = (ok + ng) / 2;
		
		if(a[md]>=K){
			ok = md;
			continue;
		}

		V<ll> b(N,0);
		int idx = 1;
		REP(i, N) if (i != md) b[idx++] = a[i];

		V<V<int>> dp(N, V<int>(K, 0));
		dp[0][0] = 1;
		FOR(i,1,N){
			REP(j,K){
				dp[i][j] = max(dp[i][j], dp[i - 1][j]);
				if(j+b[i]<K)dp[i][j+b[i]] = max(dp[i][j+b[i]], dp[i-1][j]);
			}
		}
		bool flg = false;
		FOR(j, K - a[md], K) if (dp[N-1][j]) flg = true;
		((flg) ? ok : ng) = md;
	}
	cout << ok << endl;
	
	return 0;
}



Measured memory_bytes: 98248
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long int
#define ld long double
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl
 
using namespace std;
 
int main() {
    IOS;    

    ll n; cin>>n;
    vec<ll> v(n);
    forn(i) cin>>v[i];

    ll ans = 0;
    ll actual = 1;
    for(ll i=1; i<n; i++){
        //esta i en la seq que venia?
        if(v[i]<=v[i-1LL]) actual++;
        else{
            ans = max(actual-1, ans);
            actual = 1;
        }
    }
    ans = max(actual-1, ans);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	first := make([]int, 0, n/2)
	second := make([]int, 0, n/2)
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			first = append(first, nextInt())
		} else {
			second = append(second, nextInt())
		}
	}

	a := make([]int, 0, n)
	if n%2 == 0 {
		for i := len(second) - 1; i >= 0; i-- {
			a = append(a, second[i])
		}
		a = append(a, first...)
	} else {
		for i := len(first) - 1; i >= 0; i-- {
			a = append(a, first[i])
		}
		a = append(a, second...)
	}

	for _, v := range a {
		fmt.Printf("%v ", v)
	}
	fmt.Println()
}

func next() string {
	scanner.Scan()
	return scanner.Text()
}
func nextInt() int {
	i, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 10112
#include <iostream>

using namespace std;

const long long mod=1e9+7;

int main() {
	int N, M, a;
	cin >> N >> M;
	int dp[N+1] = {0};
	for (int i = 0; i < M; ++i) {
		cin >> a;
		dp[a] = -1;
	}
	dp[0] = 1;
	for (int i = 1; i <= N; ++i) {
		if (dp[i] != -1)
			for (int j = 1; j <=2;j++) {
				if (i-j >=0 && dp[i-j] != -1) {
					dp[i]+=dp[i-j];
					dp[i]%=mod;
				}
			}
	}
	cout << dp[N] << endl;
	return 0;
}

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

using namespace std;

int main(){
	int a, b, c, x, ans = 0; cin >> a >> b >> c >> x;
	for(int i = 0; i <= a; ++i){
		for(int j = 0; j <= b; ++j){
			for(int k = 0; k <= c; ++k){
				if(500*i + 100*j + 50*k == x) ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

long long sum;
string s;
bool add[10];

void go(int p){
	if(p==s.length()-1){
		string now;
		for(int i=0;i<s.length();i++){
			now.push_back(s[i]);
			if(add[i]){
				long long tmp;
				sscanf(now.c_str(),"%lld",&tmp);
				now.clear();
				sum+=tmp;
			}
		}
		long long tmp;
		sscanf(now.c_str(),"%lld",&tmp);
		sum+=tmp;
	}
	else{
		go(p+1);
		add[p]=true;
		go(p+1);
		add[p]=false;
	}
}

int main(){
	cin>>s;
	go(0);
	cout<<sum<<endl;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

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


Measured memory_bytes: 3084
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define ri register int
#define max maxx
#define min minn
using namespace std;
template <class T> void in(T &x) {
	x = 0;
	bool f = 0;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') f = 1;
		c = getchar();
	}
	while ('0' <= c && c <= '9') {
		x = (x << 3) + (x << 1) + (c ^ 48);
		c = getchar();
	}
	if (f) x = -x;
}
inline int maxx(int x,int y) {
	return x>y?x:y;
}
inline int minn(int x,int y) {
	return x<y?x:y;
}
inline int gcd(int x,int y) {
	return !y?x:gcd(y,x%y);
}
int col[120000],b[2];
int tot,to[120000*2],nxt[240000],head[120000];
int n,m,x,y,flag;
inline void add(int x,int y) {
	tot++;
	to[tot]=y;
	nxt[tot]=head[x];
	head[x]=tot;
}
inline int color(int x) {
	int temp=true;
	for(ri i=head[x]; i; i=nxt[i]) {
		int t=to[i];
		if(col[t]==-1)
			col[t]=!col[x],b[col[t]]++,temp=color(t);
		else if(col[t]==col[x])
			temp=false;
		if(!temp)
			return false;
	}
	return true;
}
int main() {
	memset(col,-1,sizeof col);
	in(n),in(m);
	for(ri i=1; i<=m; ++i) {
		in(x),in(y);
		add(x,y);
		add(y,x);
	}
	col[1]=0;
	b[0]++;
	int flag=color(1);
	if(flag==1)
		printf("%lld",(long long )b[0]*b[1]-m);
	else 
		printf("%lld",(long long )n*(n-1)/2-m);
	return 0;
}

Measured memory_bytes: 2816
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}


Int combination(Int n, Int r) {
    if(n == 1){return 0;}
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

unsigned GetDigit(Int num){
    return std::to_string(num).length();
}
int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}

int ans =0;

void dfs(string bit, int length,vector<vector<pii>> &answers){
    if(bit.size() == length){
        int tmp_ans = 0;
        int count_shoujiki = 0;
        rep(i,length){
            if(bit[i] =='1'){
                count_shoujiki++;
                bool goal = true;
                rep(j,answers[i].size()){
                    int x = answers[i][j].first;
                    int y = answers[i][j].second;

                    if (ctoi(bit[x]) != y) {goal = false;}
                }

                if(goal){
                    tmp_ans++;
                }
            }
        }
        if(tmp_ans == count_shoujiki){
            ans = max(ans,count_shoujiki);
        }

        return;
    }
    dfs(bit+"1", length, answers);
    dfs(bit+"0", length, answers);
    return ;
}

int main() {
    Int A,B;
    Int Ans;

    cin >> A >> B;

    Ans = A*B/GCD(A,B);


    cout << Ans << endl;



    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
int k[1000];
int main()
{
	int n,m,ans,i,j,temp;
	ans=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++) scanf("%d",&k[i]);
    for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
        if(k[j]>k[i]){
            temp=k[j];
            k[j]=k[i];
            k[i]=temp;
        }}}
    //for(i=0;i<n;i++) printf("%d ",k[i]);
    for(i=0;i<m;i++) ans+=k[i];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

template < typename T >
void max_self (T & a, T b) {
	if (a < b) a = b;
}

int main() {
	int n, W, w, v;
	scanf ("%d %d", &n, &W);
	vector < ll > dp (W + 1);
	for (int i = 0; i < n; i++) {
		scanf ("%d %d", &w, &v);
		for (int weight = W; weight >= w; weight--) {
			max_self (dp[weight], dp[weight - w] + v);
		}
	}
	ll answer = 0LL;
	for (int i = 0; i <= W; i++) {
		max_self (answer, dp[i]);
	}
	printf ("%lld\n", answer);
	return 0;
}


Measured memory_bytes: 1024
def resolve():
	N = int(input())
	A = [int(i) for i in input().split()]
	if 0 in A:
		print(0); return
	A.sort()
	ans = 1
	for i in reversed(range(N)):
		ans *= A[i]
		if ans > 10**18:
			print(-1); return
	print(ans)

resolve()

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

const int n_max = 100;
const int w_max = 10000;
int n,W;
int w[n_max], v[n_max];
int dp[n_max + 1][w_max +1]; //i番目のまで、重さの総和w以下という条件のもとでの最大値の表。


int rec(int i, int j){
    //i調べるナップ,j残りの重さ
    if (dp[i][j] != -1){
        return dp[i][j]; //調べてるところはそれを返す
    }
    int res;
    if (i == n){
        res = 0; //荷物は0〰n-1まで,resとは価値の合計
    }
    else if (j<w[i]){
        res = rec(i+1,j); //おもすぎるなら使わない        
    }
    else{
        res = max(rec(i+1,j),rec(i+1,j-w[i])+v[i]);
    }
    return dp[i][j] = res;
}

int main(){
    cin >> n >> W;
    rep(i,n) cin >> v[i] >> w[i];
    memset(dp, -1, sizeof(dp)); //すべてを-1で初期化
    cout  << rec(0,W) << endl;
}


Measured memory_bytes: 7048
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define SORT(x) sort((x).begin(),(x).end(),greater<int>())
using LL=long long;
using ULL=unsigned long long;
using PII=pair<int,int>;
const int INF = numeric_limits<int>::max();
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N;
    cin >> N;
    vector<int> A( N );
    for( auto &x : A )
    {
        cin >> x;
        ++x;
    }
    vector<int> vc( *max_element( ALL( A ) ) + 3 );
    REP2( i, 0, N )
    {
        vc[ A[ i ] - 1 ]++;
        vc[ A[ i ] ]++;
        vc[ A[ i ] + 1 ]++;
    }
    cout << *max_element( ALL( vc ) ) << endl;
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &i:A)cin >> i;
	
	double ans=0.0;
	for(auto i:A)ans+=1.0/((double)i);
	ans=1/ans;
	printf("%.9lf\n",ans);
	return 0;
}

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

MAX_A = 1000001

dp = [0]*MAX_A

for i in A:
  if dp[i] == 0:
    for j in range(i, MAX_A,i):
      dp[j] += 1
  else:
    dp[i] += 1

c = 0
for i in A:
  if dp[i] == 1:
    c += 1

print(c)

Measured memory_bytes: 132336
/*{{{*/
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>

using namespace             std;
typedef long long           ll;
typedef unsigned long long  ull;
typedef pair<ll, ll>        P;
const double                PIE = 3.141592;

#define rep_n(i, a, b)  for (int i=a; i<b; i++)
#define rep(i, n)       rep_n(i, 0, n)
#define all(v)          (v).begin(), (v).end()
#define item(v)         sizeof(v)/sizeof(v[0])
#define tov(v)          v, v+item(v)
#define mp(x, y)        make_pair(x, y)
#define mset(x, y)      memset(x, y, sizeof(x))
#define chmin(x,y)      (x=min(x, y))
#define chmax(x,y)      (x=max(x, y))
#define SORTI(v)        sort(v, v+item(v))
#define SORT(v)         sort(d.begin(), d.end());
#define UNIQUE(x)       x.erase(unique(all(x)), x.end())
#define ins(x, y, z)    x.insert(x.begin()+y, z)
#define era(x, y)       x.erase(x.begin()+y)
#define era1(x, y, z)   x.erase(x.begin()+y, x.begin()+z)
#define COUNT(x, y)     count(all(x), y)
#define FIND(x, y)      find(all(x), y) - x.begin()

#define ci1(a)          cin>>a 
#define ci2(a, b)       cin>>a>>b
#define ci3(a, b, c)    cin>>a>>b>>c
#define ci4(a, b, c, d) cin>>a>>b>>c>>d
#define co1(a)          cout<<a<<endl;
#define co2(a, b)       cout<<a<<" "<<b<<endl;
#define co3(a, b, c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define co4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
/*}}}*/

int x, y, z, ans;
vector<ll> v;

int main() {
    ci3(x, y, z);
    ans = (x-z)/(y+z);
    co1(ans);

}

///*debug*/co1();


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


int main(){
    string S; cin >> S;
    int countA = 0, countB = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == 'A') countA++;
        if(S.at(i) == 'B') countB++;
    }
    if(countA == 2 || countB == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []ans = new int [26];
		
		for(int i = 0 ; i < n; i++) {
			
			int []alp = new int [26];
			
			char[]c = sc.next().toCharArray();
			
			for(int j = 0 ; j < c.length ; j++) {
				alp[c[j] - 'a']++;
			}
			
			for(int k = 0 ; k < 26 ; k++) {
				if(i == 0) {
					ans[k] = alp[k];
				}
				else {
					ans[k] = Math.min(ans[k], alp[k]);
				}
			}
		}
		for(int i = 0; i < 26 ; i++) {
			for(int j = 0 ; j < ans[i]; j++) {
				System.out.print((char) (i + 'a'));
			}
		}
		
		System.out.println("");
		

	}

}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
long long sum=0;
int main(){
	int i,j,k,n;
	cin>>n;
	for(i=1;i<=n;i++){
		long long l,r;
		cin>>l>>r;
		sum+=(r-l)+1;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
ans = 1
flag = 0

n = int(input())
a = list(map(int, input().split()))

if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans > 1000000000000000000:
            flag = 1
            print(-1)
            break
    
    if flag == 0:
        print(ans)

Measured memory_bytes: 21784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////


int main() {
    ll n;string s;cin>>n>>s;
    ll l=0,r=0;
    ll c=0;
    for(ll i=0;i<=n-1;i++){
        if(s[i]=='(')c--;
        else c++;
        l=max(l,c);
    }
    c=0;
    for(ll i=n-1;i>=0;i--){
        if(s[i]==')')c--;
        else c++;
        r=max(r,c);
    }
    rep(i,1,l)cout<<'(';cout<<s;
    rep(i,1,r)cout<<')';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int N;
  cin >> N;
  
  string w[1] = {"ABC"};
 
  int i = 0;
  int counter = 0;
 
  string str;
  cin >> str;
  
 
  while(true){
    
    if( i == N)
      break;
    
    if(str.substr(i,3) == w[0]){
      counter++;
      i += 3;
      continue;
    }
    
    i++;

  }
 
 

   cout << counter <<endl;
 
}

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

int main() {
  int N,M,C,c=0;cin>>N>>M>>C;
  vector<int> B(M);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0; i<M; i++)cin>>B[i];
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      cin>>A[i][j];
    }
  }
  for(int i=0; i<N; i++){
    int wa=0;
    for(int j=0; j<M; j++){
      wa+=A[i][j]*B[j];
    }
    if(wa+C>0)c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
(let ((q (read))
      (h (read))
      (s (read))
      (d (read))
      (n (read))
      ans)
  (setf s (min s (* 2 h) (* 4 q)))
  (cond ((> d (* 2 s)) (setf ans (* s n)))
        ((evenp n) (setf ans (* d (/ n 2))))
        (t (setf ans (+ (* d (/ (1- n) 2)) s))))
  (princ ans))


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

using namespace std;

int gcd(int a, int b) {
    return (b ? gcd(b, a % b) : a);
}

int Solve(vector<int> a, int x) {
    int n = a.size();
    int ans = 0;
    for(int i = 0; i < n; i++) {
        ans = gcd(abs(a[i] - x), ans);
    }
    return ans;
}

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, x;
   cin >> n >> x;
   vector<int> a(n);
   for(int i = 0; i < n; i++) {
       cin >> a[i];
   }
   cout << Solve(a, x) << endl;
}

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
using LLint = long long int;


const int mod = 1000000007;
int main(){
	int N;
	cin>>N;
	int A[3][110];
	for(int i=0;i<N;++i)cin>>A[0][i];
	for(int i=0;i<N;++i)cin>>A[1][i];
	
	int ans=0;
	for(int i=0;i<N;++i)
	{
		int count=0;
		for(int j=0;j<=i;++j)
		{
			count+=A[0][j];
		}
		for(int j=i;j<N;++j)
		{
			count+=A[1][j];
		}
		ans=max(ans,count);
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n,s) for (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define _GLIBCXX_DEBUG
// head

int main(){
    int n,nr,ans=0;
    cin >> n;
    for (int i=0;i*i<=n;i++){
        ans=max(ans,i*i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
 
//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int 

//typedef
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long inf = 1000000000000000000;

using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void solve()
{
    int h, w;
    cin>>h>>w;
    vll v1(h+1,0), v2(w+1,0);
    ll m;
    cin>>m;
    vii v;
    vi vv[h+1];
    rep(i,m)
    {
        int x, y;
        cin>>x>>y;
        v1[x]++;
        v2[y]++;
        v.pb(mp(x,y));
        vv[x].pb(y);
    }
    ll ans=0;
    trav(p,v)
    {
        ans=max(ans,v1[p.fi]+v2[p.se]-1ll);
    }
    multiset<ll> s;
    repu(i,1,w)
        s.insert(v2[i]);
    repu(i,1,h)
    {
        trav(p,vv[i])
            s.erase(s.find(v2[p]));
        if(!s.empty())
        {
            auto aa=s.end();
            aa--;
            ans=max(ans,v1[i]+(*aa));
        }
        trav(p,vv[i])
            s.insert(v2[p]);
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 40628
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
//unordered_map
typedef long long ll;
int vis[MAXN],dist[MAXN];
vector<int>ve[MAXN];
void dfs(int now)
{
	if(vis[now]) return ;
	vis[now]=1;
	for(int i=0;i<ve[now].size();i++)
	{
		int ne=ve[now][i];
		if(!vis[ne])
		{
			dfs(ne);
			dist[now]+=dist[ne];
		}
	}
	return ;
}
int main()
{
	int n,m,ans=0;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++) dist[i]=1;
	while(m--)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		ve[x].push_back(y);
		ve[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
		    dfs(i);
		    ans=max(ans,dist[i]);
		} 
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 28740
#include<stdio.h>

int main(void)
{
	const double PI = 3.14159265359;
	double r, area, cir;

	scanf("%lf", &r);

	area = PI * r * r;
	cir = 2 * PI * r;

	printf("%lf %lf\n", area, cir);

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int gap = b - a;
  int ans = 0.5 * gap * (gap + 1) - b;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();

      Map<Integer, ArrayList<int[]>> ps = new HashMap<>();

      for(int i = 1; i <= m; i++) {
        int pNum = sc.nextInt();
        int year = sc.nextInt();
        if(!ps.containsKey(pNum))
          ps.put(pNum, new ArrayList<>());
        ps.get(pNum).add(new int[]{year, i});
      }
          
      for(ArrayList<int[]> pp : ps.values()) {
        Collections.sort(pp, (a, b) -> a[0] - b[0]);
      }

      String[] cities = new String[m+1];
      for(Map.Entry<Integer, ArrayList<int[]>> entry : ps.entrySet()) {
        ArrayList<int[]> pp = entry.getValue();
        
        for(int k = 0; k < pp.size(); k++) {
            
          StringBuilder sb = new StringBuilder();
          String pStr = String.valueOf(entry.getKey());
          for(int j = 0; j < 6 - pStr.length(); j++)
            sb.append("0");
          sb.append(pStr);

          pStr = String.valueOf(k+1);
          for(int j = 0; j < 6 - pStr.length(); j++)
            sb.append("0");
          sb.append(k+1);

          cities[pp.get(k)[1]] = sb.toString();
        }
      }
      
      for(int i = 1; i < cities.length; i++)
       System.out.println(cities[i]);
  }
}

Measured memory_bytes: 106428
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int s, w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18+500
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
#define cerr if(0)cout
#endif
int32_t main() {
	IAMSPEED
	int n; cin >> n;
	vector<int>a(n+2);
	FOR(i,1,n)cin>>a[i];
	int ans = inf;
	FOR(i,1,100) {
		int sum = 0;
		FOR(j,1,n) {
			sum+=(i-a[j]) * (i-a[j]);
		}
		minself(ans,sum);
	}
	cout<<ans;
}


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

using namespace std;
typedef long long ll;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

ll keta(ll a, ll b)
{
    int cnt_a = 0, cnt_b = 0;
    while (a)
    {
        cnt_a++;
        a /= 10;
    }
    while (b)
    {
        cnt_b++;
        b /= 10;
    }
    ll ans = max(cnt_a, cnt_b);
    return ans;
}

int main()
{

    ll n;
    cin >> n;

    ll ans = 1001001001;
    for (ll a = 1; a * a <= n; a++)
    {
        if (n % a)
        {
            continue;
        }
        ll b = n / a;
        ans = min(ans, keta(a, b));
    }

    cout << ans << '\n';
    return (0);
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */
//文字列中の一文字⇒数字の時は s[i]-'0'
int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

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

int main (void)
{
	long long int n,i,min,k,a,max,j=1,count=0;
scanf("%lld",&n);
if(n==0){
  printf("1");
  return 0;
}

  
  
  printf("0");
return 0;
}


Measured memory_bytes: 1660
n,*a=map(int,open(0).read().split())
m=min(a)
while len(a)>1:
    m=min(a)
    f=0
    for i in range(len(a)):
        if a[i]!=m or f:
            a[i]%=m
        else:
            f=1
    *a,=filter(lambda x:x,a)
print(m)

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

int main() {
  int N, Y;
  cin >> N >> Y;
  int sum;
  bool finished = false;
  int a, b, c;
  
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      int k = N - i - j;
      sum = 10000 * i + 5000 * j + 1000 * k;
      if (sum == Y) {
        a = i;
        b = j;
        c = k;
        finished = true;
        break;
      }
    }
    if (finished) {
      break;
    }
  }
  if (finished) {
    cout << a << " " << b << " " << c << endl;
  }
  else {
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k;
	vector<int>p(n),c(n);
	for(auto&&i:p)cin>>i,--i; for(auto&&i:c)cin>>i;
	int64_t ans=INT64_MIN;
	for(int i=0;i<n;++i){
		int P=i;
		vector<int>v;
		int64_t sum=0,mx=INT64_MIN;
		do{
			P=p.at(P);
			sum+=c.at(P);
			mx=max(mx,sum);
			v.emplace_back(c.at(P));
		}while(P!=i);
		if(sum<=0){
			ans=max(ans,mx);
		}
		else{
			int64_t tsum=0;
			for(int j=0,lim=v.size();j<min(k,lim);++j){
				tsum+=v.at(j);
				ans=max(ans,sum*((k-j-1)/lim)+tsum);
			}
		}
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3740
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i
k = gets.chomp.to_i

if b - a <= k && c - a <= k && c - b <= k && d - a <= k && d - b <= k && d - c <= k && e - a <= k && e - b <= k && e - c <= k && e - d <= k
  puts "Yay!"
else
  puts ":("
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define vv vector<lli>
#define vp vector<pair<lli,lli>>
#define vpp vector<pair<lli,pair<lli,lli>>>
#define lims(w) (w).begin(),(w).end()
#define rlims(w) (w).rbegin(),(w).rend()
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(lli i=a;i<b;i++)

int main()
{
	lli h,w,k;
	cin>>h>>w>>k;
	string s[h+1];
	lli temp;
	f(i,0,h)
		cin>>s[i];
	lli hub = (lli)(pow(2,h));
	lli wub = (lli)(pow(2,w));
	vv r;
	vv c;
	lli bit1,bit2;
	bool R,C;
	lli ans = 0, ctr = 0;

	f(val,1,hub)
	{
		r.clear();
		temp = val;

		f(i,0,h)
		{
			bit1 = temp & 1;

			if(bit1 == 1)
				r.pb(i);
			temp /= 2;
		}

		sort(lims(r));

		f(val2,1,wub)
		{
			c.clear();
			temp = val2;

			f(i,0,w)
			{
				bit2 = temp & 1;
				if(bit2 == 1)
					c.pb(i);
				temp /= 2;
			}

			sort(lims(c));
			ctr = 0;

			f(i,0,h)
			{
				R = binary_search(lims(r),i);

				f(j,0,w)
				{
					C = binary_search(lims(c),j);
							
					if(R && C && s[i][j] == '#')
						ctr++;
				}
			}

			if(ctr == k)
				ans++;
		}	
	}

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


Measured memory_bytes: 4088
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
  std::size_t n, m;
  std::cin >> n >> m;

  std::vector<std::size_t> a(n);
  for (auto&& ai : a) std::cin >> ai;
  std::sort(a.begin(), a.end());

  std::vector<std::size_t> b(m), c(m), id(m);
  for (std::size_t i = 0; i < m; ++i) std::cin >> b[i] >> c[i];
  std::iota(id.begin(), id.end(), 0ULL);
  std::sort(id.begin(), id.end(), [&c](auto i, auto j) { return c[i] > c[j]; });

  std::size_t k = 0;
  for (auto&& i : id) {
    const auto bi = b[i];
    const auto ci = c[i];
    for (std::size_t j = 0; j < bi; ++j) {
      if (a[k] < ci)
        a[k++] = ci;
      else
        break;
    }
  }

  const auto sum = std::accumulate(a.begin(), a.end(), 0ULL);
  std::cout << sum << std::endl;
}


Measured memory_bytes: 3328