akhauriyash/Code-Regression huggingface dataset:
H,N=map(int,input().split())
L=[0]*N
for i in range(N):
    a,b=map(int,input().split())
    L[i]=(a,b)


DP=[float("inf")]*(H+1)
DP[0]=0

for (A,B) in L:
    for k in range(1,H+1):
        if k>=A:
            DP[k]=min(DP[k],DP[k-A]+B)
        else:
            DP[k]=min(DP[k],B)

print(DP[-1])

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    set<int> st;
    for(int i = 1; i < b+1; i++){
        st.insert(a*i%b);
    }
    if(st.count(c)){
        cout << "YES\n";
    }else cout << "NO\n";

}


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

struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const long long INF = 9223372000000000000/2145;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define int ll

int F[87];

void f(){
    for(int i=2;i<87;i++){
        F[i] = F[i-1] + F[i-2];
    }
    return ;
}

signed main(){
    int n;
    scanf("%lld",&n);
    F[0] = 2;
    F[1] = 1;
    f();
    n;
    printf("%lld\n",F[n]);
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanInit()

	s := nextStr()
	ans := fmt.Sprintf("%c%d%c", s[0], len(s)-2, s[len(s)-1])

	fmt.Println(ans)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define PI 3.141592653589793238

typedef long long ll;

using namespace std;



int main() {
    
    ll n,m,sum=0;
    
    cin>>n>>m;
    
    ll a[m];
    
    for(ll i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    
    if(sum>n)
    cout<<-1<<endl;
    else
    cout<<abs(n-sum)<<endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int arr[105];
int n, cnt;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "a", stdout);
    // #endif
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> arr[i];
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            for(int k = j + 1; k < n; k++) {
                if(arr[i] == arr[j] || arr[i] == arr[k] || arr[j] == arr[k])    continue;
                if(arr[i] < arr[j] + arr[k] && arr[j] < arr[i] + arr[k] && arr[k] < arr[i] + arr[j])    cnt++;
            }
        }
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    ll N,M;
    cin>>N>>M;
    if(abs(N-M)>=2){
        cout<<"0"<<endl;
        return 0;
    }
    ll ans=1;
    ll mod=1e9+7;
    for(ll i=1; i<=N; i++){
        ans*=i;
        ans%=mod;
    }
    for(ll i=1; i<=M; i++){
        ans*=i;
        ans%=mod;
    }
    if(abs(N-M)==0){
        cout<<ans*2%mod<<endl;
    }else{
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define inf (int)1e18+7
#define mod 1000000007
const int nmax = (int) 1e3 + 10;

struct Matrix {
    
    vector<vector<int > > a;
    int n, m;
    Matrix(int n) : n(n), m(n) {
        a.assign(n, vector<int > (m, 0));
    }
    void make_identity() {
        for (int i = 0; i < n; i ++) {
            a[i][i] = 1;
        }
    }

    void mult(Matrix B) {
        
        vector < vector<int > > c(n, vector<int > (n, 0));

        for (int i = 0; i < n; i ++) {
            for (int j = 0; j < n; j ++) {
                for (int k = 0; k < n; k ++) {
                    c[i][j] += (a[i][k] * B.a[k][j]) % mod;
                    c[i][j] %= mod;
                }
            }
        }            

        a = c;
    }

};

Matrix powermod(Matrix A, int b) {
    Matrix C(A.n);
    C.make_identity();
    while(b) {
        if(b & 1) {
            C.mult(A);
        }
        A.mult(A);
        b /= 2;
    }

    return C;
}
                           
                     
signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    Matrix A(n);

    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < n; j ++) {
            cin >> A.a[i][j];
        }
    }

    A = powermod(A, k);

    int ans = 0;
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < n; j ++) {
            ans += A.a[i][j];
            ans %= mod;
        }
    }

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


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

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int[][] arr = new int[3][3];
		int[] A = new int[2];
		int[] B = new int[2];
		Arrays.fill(A, 101);
		Arrays.fill(B, 101);
		String ans = "Yes";
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				arr[i][j] = reader.nextInt();
			}
		}
		A[0] = arr[0][0] - arr[1][0];
		A[1] = arr[1][0] - arr[2][0];
		B[0] = arr[0][0] - arr[0][1];
		B[1] = arr[0][1] - arr[0][2];

		for (int i = 1; i < 3; i++) {
			for (int j = 1; j < 3; j++) {
				if (arr[i-1][j] - A[i-1] != arr[i][j] ||
					arr[i][j-1] - B[j-1] != arr[i][j]) {
					ans = "No";
				}
			}

		}

		System.out.print(ans);
		reader.close();
	}
}





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

using namespace std;

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

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

    vector<string> b(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    bool res = false;
    for (int i = 0; i + m <= n; i++) {
        for (int j = 0; j + m <= n; j++) {
            bool r = true;
            for (int k = 0; k < m; k++) {
                for (int l = 0; l < m; l++) {
                    if (a[i + k][j + l] != b[k][l]) {
                        r = false;
                    }
                }
            }

            if (r) {
                res = true;
            }
        }
    }

    cout << (res ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
#define mod 1000000007
char a[100], b[100];
int main()
{
    int n;

    scanf("%d%s%s", &n, a, b);
    long long ans = 1;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            if (a[i] == b[i]) {
                ans = 3;
            } else {
                ans = 6;
                i++;
            }
            continue;
        }
        if (a[i] == b[i]) {
            if (a[i - 1] == b[i - 1]) {
                ans *= 2;
            }
        } else {
            if (a[i - 1] == b[i - 1]) {
                ans *= 2;
            } else {
                ans *= 3;
            }
            i++;
        }
        ans %= mod;
    }
   cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back

using namespace std;



int main(){

    int a;
    cin >> a;
    string s,t;
    cin >> s >> t;

    rep(i,a){

        cout << s[i] << t[i];
    }

    cout << endl;
    return 0;
}


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

int main(void) {
	int i, j;
	int r, c;
	int sum1;
	int sum2;
	int **data;

	scanf("%d %d\n", &r, &c);

	data = (int **)malloc(sizeof(int *) * (r+1));
	if(data == NULL){  exit(1); }
	for(i = 0; i < (r+1); i++){
		data[i] = malloc(sizeof(int) * (c+1));
		if(data[i] == NULL){ exit(1); }
	}

	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
			scanf("%d", &data[i][j]);
		}
	}
	
	for(i = 0; i < (r+1); i++){
		sum1 = 0;
		for(j = 0; j < (c+1); j++){
			sum1 += data[i][j];
		}
		data[i][c] = sum1;
	}
	
	for(i = 0; i < (c+1); i++){
		sum2 = 0;
		for(j = 0; j < r; j++){
			sum2 += data[j][i];
		}
		data[r][i] = sum2;
	}
	
	for(i = 0; i < (r+1); i++){
		for(j = 0; j < c; j++){
			printf("%d ", data[i][j]);
		}
		if(j == c) printf("%d\n", data[i][j]);
	}

	for(i = 0; i < (r+1); i++){
		free(data[i]);
	}
	free(data);

	return 0;
}


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

int main(void) {
    int k, s;
    cin >> k >> s;

    int count = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            if ((i+j <= s) && (s-(i+j) <= k)) {
                count++;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int countDivisibles(int A, int B, int M) 
{ 
    int counter = 0; 
  
    // Running a loop from A to B and check 
    // if a number is divisible by M. 
    for (int i = A; i <= B; i++) 
        if (i % M == 0) 
            counter++; 
  
    return counter; 
} 
int main(){
    ll n,k,i,l,r,d;
    cin>>l>>r>>d;
    
    cout<<countDivisibles(l,r,d);

}

Measured memory_bytes: 3588
#include <iostream>
#include <math.h>

using namespace std;

main() {
	ios::sync_with_stdio(false);

	int ab, bc, ca;
	cin >> ab >> bc >> ca;

	int p;
	p = (ab + bc + ca) / 2;

	int area;
	area = sqrt(p * (p - ab) * (p - bc) * (p - ca));
	cout << area << endl;

	return 0;
}

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

#define int int64_t
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,m) for(int i=1; i<=(m); ++i)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define ll long long
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

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

    int h,w,cnt=0;
    cin>>h>>w;
    vector<vector<int> > x(h,vector<int>(w,0));
    vector<vector<int> > y(h,vector<int>(w,0));

    rep(i,h){
        rep(j,w){
            cin>>x[i][j];
        }
    }

    rep(i,w){
        if(x[0][i] == 1) y[0][i] = 0;
        else y[0][i] = 1,cnt=1;
    }

    for(int i=1; i<h; ++i){
        if(x[i][0] == 1) y[i][0] = 0;
        else y[i][0] = 1,cnt=1;
    }

    for(int i=1; i<h; ++i){
        for(int j=1; j<w; ++j){
            if(x[i][j]==0){
                y[i][j] = min(y[i-1][j-1],min(y[i-1][j],y[i][j-1]))+1;
                cnt = max(cnt,y[i][j]);
            }
        }
    }
    
    cout<<cnt*cnt<<'\n';
}


Measured memory_bytes: 33620
use proconio::input;
use proconio::marker::Usize1;

#[allow(non_snake_case)]
fn main() {

    input! {
        N: usize,
    }

    let mut n_children = vec![0usize; N];

    for _ in 0..N - 1 {
        input! {
            A: Usize1,
        }
        n_children[A] += 1;
    }

    for i in 0..N {
        println!("{}", n_children[i]); 
    }
}


Measured memory_bytes: 4712
#include <stdio.h>

int main(void)
{
  	int		n;
  	char	s[100001][3];
 	int		i;
  	int		ac;
  	int		wa;
  	int		tle;
  	int		re;
  
  	scanf("%d\n", &n);
  	for(i=0;i<n;i++)
    {
      	scanf("%s\n", s[i]);
    }
  	ac = 0;
  	wa = 0;
  	tle = 0;
  	re = 0;
  	for(i=0;i<n;i++)
    {
        switch (s[i][0]){
          	case 'A':
            	ac++;
      			break;
      		case 'W':
              	wa++;
      			break;
      		case 'T':
              	tle++;
      			break;
      		case 'R':
              	re++;
              	break;
      		default:
              	break;
        }
    }
  	printf("AC x %d\n", ac);
  	printf("WA x %d\n", wa);
  	printf("TLE x %d\n", tle);
  	printf("RE x %d\n", re);
  	return(0);
}

Measured memory_bytes: 2020
program Project1;
     
{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  g,l,r,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t:Integer;
  //l:array of Integer;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(s1);
    Readln(s2);

    if (s1[1]=s2[3])and(s1[2]=s2[2])and(s1[3]=s2[1]) then
      Writeln('YES')
    else
      Writeln('NO');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n,m;
int me[1001][(1<<12)];
int vi[1001][(1<<12)];
int k[1001];
int p[1001];

int dp(int key, int mask){
	if(vi[key][mask]){
		return me[key][mask];
	}
	vi[key][mask]=1;
	if(key==m){
		if(mask == (1<<n)-1){
			return me[key][mask]=0;
		}
		return me[key][mask]=-1;
	}
	me[key][mask]=dp(key+1,mask);
	int c2=dp(key+1,mask|k[key]);
	if(c2!=-1)c2+=p[key];
	if(me[key][mask] == -1 || (c2!=-1&&c2 < me[key][mask])){
		me[key][mask] = c2;
	}
	return me[key][mask];
}
int main(){
	
	cin>>n>>m;
	int b,c;
	for(int i=0;i<m;i++){
		cin>>p[i]>>b;
		k[i]=0;
		while(b--){
			cin>>c;
			c--;
			k[i]|=(1<<c);
		}
	}
	cout<<dp(0,0)<<endl;;
	
	return 0;
}

Measured memory_bytes: 32256
#include <stdio.h>
int S[100000];
int n;
int binarySearch(int[],int,int);

int main(){
  int count=0;
  int T[50000];
  int q,i;
  int re;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    count+=binarySearch(S,T[i],n);
  }
  printf("%d\n",count);
  return 0;
}
int binarySearch(int S[],int key,int n){
  int mid=0;
  int left=0;
  int right=n;
   while(left<right){
     mid=(left+right)/2;
     if(S[mid]==key) return 1;
     else if(key<S[mid])
       right=mid;
     else
       left=mid+1;
   }
   return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>
#include <stdlib.h>

int cmpnum(const void * n1, const void * n2)
{
	if (*(int *)n1 > *(int *)n2)
	{
		return 1;
	}
	else if (*(int *)n1 < *(int *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void){

  int n,k;
  scanf("%d %d", &n, &k);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  qsort(a, n, sizeof(int), cmpnum);
  int size = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i-1]) {
      size++;
    }
  }
  int list[size];
  int list_number = 0;
  int count = 0;
  for (int i = 0; i < n-1; i++) {
    count++;
    if (a[i] != a[i+1]) {
      list[list_number] = count;
      list_number++;
      count = 0;
    }
  }
  count++;
  list[list_number] = count;
  qsort(list, size, sizeof(int), cmpnum);
  int change = size-k;
  int answer = 0;
  if (change > 0) {
    for (int i = 0; i < change; i++) {
      answer += list[i];
    }
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 2156
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

int main() {
	int x=read();
	for (int i=1;;++i)
		if (1ll*i*(i+1)/2>=x) { printf("%d\n",i); break; }
	return 0;
}

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

const int MOD = 1e9+7;

int memo[2][1<<21];

int main(){ _

	int n; cin >> n;
	vector<vector<int>> g(n, vector<int>(n));
	for(auto& w : g) for(auto& i : w) cin >> i;

	memo[0][0] = memo[1][0] = 1;

	for(int mask = 0; mask < (1<<n); mask++) {
		int i = __builtin_popcount(mask) - 1;
		for(int k = 0; k < n; k++) if(i >= 0 and g[i][k] and (mask & (1<<k))) {
			memo[i&1][mask] = (memo[i&1][mask] + memo[(i&1)^1][mask^(1<<k)]) % MOD;	
		}
	}	

	cout << memo[(n-1)&1][(1<<n)-1] << endl;

	return 0;
}


Measured memory_bytes: 20012
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int d;
    cin >> d;
    if(d == 25){
        print("Christmas");
    }else if(d == 24){
        print("Christmas Eve")
    }else if(d == 23){
        print("Christmas Eve Eve")
    }else if(d == 22){
        print("Christmas Eve Eve Eve")
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int r, c;
    cin >> r >> c;
    
    int X[r][c], Rsum[c], Csum[r], total = 0;
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            Csum[i] = 0;
            Rsum[j] = 0;
        }
    }
    
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> X[i][j];
            Csum[i] += X[i][j];
            Rsum[j] += X[i][j];
            total += X[i][j];
        }
    }
    
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            std::cout << X[i][j] << ' ';
        }
        cout << Csum[i] << std::endl;
    }
    
    for (int j = 0; j < c; j++) {
        cout << Rsum[j] << " ";
    }
    
    std::cout << total << std::endl;
}

Measured memory_bytes: 1200
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = R[1] - R[0];
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int s=S.size()-1;
  long long ans=0;
  for (int bit=0;bit<(1<<s);bit++){
    long long sum=0,count=S[0]-'0';
      for (int i=0;i<s;i++){
        if (bit&(1<<i)){
          sum+=count;
          count=0;
        }
        if (!(bit&(1<<i))){
          count*=10;
        }
        count+=S[i+1]-'0';
        if (i==s-1){
          sum+=count;
        }
      }
    ans+=sum;
  }
  if (s==0){
    ans+=S[0]-'0';
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

	int sum = 0;
	int sa = 1000000;
	bool ki = true;
	for (int i = l; i < l + n; i++) {
		if (chmin(sa, abs(i))) ki = (i < 0 ? false : true);
		sum += i;
	}

	cout << sum - sa * (ki ? 1 : -1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const ll N = 5005, MOD = 1e9 + 7;

ll n;
ll A, B;

ll a[N], b[N];
ll d[N][N];
ll dp[N][N];


main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> n >> A >> B;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        b[a[i]] = i;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j < b[i]; j++)
            dp[i][j] = dp[i - 1][j];
        ll num = -1;
        for (int j = b[i]; j <= n; j++){
            if (a[j] > i){
                dp[i][j] = dp[i][j - 1];
                continue;
            }
            num++;
            dp[i][j] = min (dp[i - 1][j] + A, dp[i - 1][b[i] - 1] + num * B);
        }
    }
    cout << dp[n][n] << endl;
    return 0;
}


Measured memory_bytes: 196992
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<bitset>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>


using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))

const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);


int main(){
  int n,t;
  double a;
  double num;
  cin>>n>>t>>a;
  double rtmp=-1;
  double ret=0;
  REP(i,n){
    cin>>num;
    double tmp=t-num*0.006;
    if(i==0||abs(rtmp-a)>abs(tmp-a)){
      ret=i+1;
      rtmp=tmp;
    }

  }
  cout<<ret<<"\n";
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	 long long int n,k;
cin >> n;
long long int i;
vector<long long int>in(n);
for(i=0;i<n;i++){cin >> in[i];
}
vector<long long int>dp(n,0);
dp[0]=0;
dp[1]=abs(in[1]-in[0]);
for(i=2;i<n;i++){
	dp[i]=min((dp[i-2]+abs(in[i]-in[i-2])),(dp[i-1]+abs(in[i]-in[i-1])));
}
cout << dp[n-1] ;
return 0;}//6
//30 10 60 10 60 50

Measured memory_bytes: 1792
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int i,j,k,l;
  int x[5][1000],y[5][1000],a[5][1000],b[5],w,h,sx,sy,gx,gy;
  int mn,bm;
  char c;
  while(cin>>w>>h&&w+h){
    memset(b,0,sizeof(b));
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cin>>c;
	if(0){
	}else if(c=='.'){
	}else if(c=='S'){
	  sx=j;
	  sy=i;
	}else if(c=='G'){
	  gx=j;
	  gy=i;
	}else{
	  x[c-'1'][b[c-'1']]=j;
	  y[c-'1'][b[c-'1']]=i;
	  b[c-'1']++;
	}
      }
    }
    if(0){
    }else if(!!b[0]+!!b[1]+!!b[2]+!!b[3]+!!b[4]==4){
      for(i=0;b[i];i++);
      mn=0;
      memset(a,0,sizeof(a));
      for(j=0;j<b[(i+1)%5];j++)
	a[(i+1)%5][j]=abs(sx-x[(i+1)%5][j])+abs(sy-y[(i+1)%5][j]);
      for(j=1;j<4;j++){
	for(k=0;k<b[(i+j)%5];k++){
	  for(l=0;l<b[(i+j+1)%5];l++){
	    if(a[(i+j+1)%5][l]==0||a[(i+j+1)%5][l]>abs(x[(i+j+1)%5][l]-x[(i+j)%5][k])+abs(y[(i+j+1)%5][l]-y[(i+j)%5][k])+a[(i+j)%5][k])
	      a[(i+j+1)%5][l]=abs(x[(i+j+1)%5][l]-x[(i+j)%5][k])+abs(y[(i+j+1)%5][l]-y[(i+j)%5][k])+a[(i+j)%5][k];
	  }
	}
      }
      for(k=0;k<b[(i+j)%5];k++){
	if(mn==0||mn>abs(gx-x[(i+j)%5][k])+abs(gy-y[(i+j)%5][k])+a[(i+j)%5][k]){
	  mn=abs(gx-x[(i+j)%5][k])+abs(gy-y[(i+j)%5][k])+a[(i+j)%5][k];
	  bm=i+1;	    
	}
      }
      cout<<bm<<" "<<mn<<endl;
    }else if(!!b[0]+!!b[1]+!!b[2]+!!b[3]+!!b[4]==5){
      mn=0;
      for(i=0;i<5;i++){
	memset(a,0,sizeof(a));
	for(j=0;j<b[(i+1)%5];j++)
	  a[(i+1)%5][j]=abs(sx-x[(i+1)%5][j])+abs(sy-y[(i+1)%5][j]);
	for(j=1;j<4;j++){
	  for(k=0;k<b[(i+j)%5];k++){
	      for(l=0;l<b[(i+j+1)%5];l++){
		  if(a[(i+j+1)%5][l]==0||a[(i+j+1)%5][l]>abs(x[(i+j+1)%5][l]-x[(i+j)%5][k])+abs(y[(i+j+1)%5][l]-y[(i+j)%5][k])+a[(i+j)%5][k])
		    a[(i+j+1)%5][l]=abs(x[(i+j+1)%5][l]-x[(i+j)%5][k])+abs(y[(i+j+1)%5][l]-y[(i+j)%5][k])+a[(i+j)%5][k];
	      }
	  }
	}
	for(k=0;k<b[(i+j)%5];k++){
	  if(mn==0||mn>abs(gx-x[(i+j)%5][k])+abs(gy-y[(i+j)%5][k])+a[(i+j)%5][k]){
	    mn=abs(gx-x[(i+j)%5][k])+abs(gy-y[(i+j)%5][k])+a[(i+j)%5][k];
	    bm=i+1;
	  }
	}
      }
      cout<<bm<<" "<<mn<<endl;
    }else{
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

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

int main() {
  int N;
  cin >>N;
  vector<int>suuretsu(N);
  for (int i=0;i<N;i++){
    cin >>suuretsu.at(i);
        }
  int s=0;
  for (int i=0; i<N;i++){
    if (suuretsu.at(i)!=i+1){
      s+=1;
    }
  }
      
 if (s==0){
   cout << "YES"<< endl;
 }
 else if  (s==2){
   cout << "YES"<< endl;
 }
 else {
   cout <<"NO"<<endl;
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
map<string,int> tmp;
//int cc=0;
//#define edg(a,b) ((abs((a)-(b))==1))
int ask(string s)
{
	int r=0;
	for(int i=0;i<s.size();i++) r+=(s[i]=='1');
	if(r<=1) return 0;
	if(tmp.count(s)) return tmp[s];
	/*
	++cc; vi rp;
	for(int i=0;i<s.size();i++)
		if(s[i]=='1') rp.pb(i);
	if(rp.size()==2)
	return tmp[s]=edg(rp[0],rp[1]);
	if(rp.size()!=3) throw "RE";
	bool a=edg(rp[0],rp[1]),b=edg(rp[0],rp[2]),
	c=edg(rp[1],rp[2]);
	return tmp[s]=a+b+c;*/
	cout<<"? "<<s<<endl;
	int x; cin>>x; return tmp[s]=x;
}
int n,ff[SZ]; vector<int> vs[SZ],rs;
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}
void uni(int a,int b)
{int ga=gf(a),gb=gf(b);if(ga^gb)ff[ga]=gb;}
int cnt()
{
	int ans=0; rs.clear();
	for(int i=1;i<=n;i++) vs[i].clear();
	for(int i=1;i<=n;i++)
	{
		vs[gf(i)].pb(i);
		if(gf(i)==i);else continue;
		++ans; rs.pb(i);
	}
	random_shuffle(rs.begin(),rs.end());
	for(int i=1;i<=n;i++)
		random_shuffle(vs[i].begin(),vs[i].end());
	return ans;
}
const int B=13;
vector<pii> es;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) vs[i].pb(i);
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<i;j+=B)
		{
			string s; s.resize(n);
			for(int i=0;i<n;i++) s[i]='0';
			for(int k=0;k<B&&j+k<i;++k) s[j+k-1]='1';
			int a=ask(s); s[i-1]='1';
			int b=ask(s);
			if(a==b) continue;
			for(int k=0;k<B&&j+k<i;++k)
			{
				for(int i=0;i<n;i++) s[i]='0';
				s[j+k-1]=s[i-1]='1';
				if(ask(s)==1)
					es.pb(pii(j+k,i));
			}
		}
	}
	cout<<"!";
	for(auto r:es) printf(" (%d,%d)",r.fi-1,r.se-1);
	puts("");
	//cerr<<cc<<"\n";
}


Measured memory_bytes: 18516
import java.util.Scanner;

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

		int a = scan.nextInt();
		String m = "Christmas";
		for(int i = 25; i > a; i--){
			m += " Eve";
		}
		System.out.println(m);
	}
}


Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

int cmp(const void* x, const void* y) {
	int a = *(const int*)x;
	int b = *(const int*)y;
	if (a > b) return 1;
	if (a < b) return -1;
	return 0;
}

int N;
int a[1000000];

int zaatu_num;
int zaatu_table[1000000];

int get_id(int num) {
	int left, right, mid;
	left = 0; right = zaatu_num;
	while (left <= right) {
		mid = (left + right) / 2;
		if (zaatu_table[mid] == num) {
			return mid;
		} else if (zaatu_table[mid] < num) {
			left = mid + 1;
		} else {
			right = mid - 1;
		}
	}
	printf("%d not found!\n", num);
	exit(1);
}

uint64_t isi_count[1000000];

int main(void) {
	int i;
	int prev_count = 0;
	int prev_index = -1;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
		zaatu_table[i] = a[i];
	}
	/* 座標圧縮 */
	qsort(zaatu_table, N, sizeof(int), cmp);
	zaatu_num = 0;
	for (i = 1; i < N; i++) {
		if (zaatu_table[i] != zaatu_table[zaatu_num]) {
			zaatu_table[++zaatu_num] = zaatu_table[i];
		}
	}
	/* 各種類が何個あるかを調べる */
	for (i = 0; i < N; i++) {
		isi_count[get_id(a[i])]++;
	}
	/* その数以上のところをその数に含める */
	for (i = N - 1; i > 0; i--) {
		isi_count[i - 1] += isi_count[i];
	}
	/* 計算する */
	for (i = 0; i < N; i++) {
		if (prev_count < a[i]) {
			/* この階層を全部削るまで出せる */
			int current_index = get_id(a[i]);
			int j;
			uint64_t current_count = 0;
			for (j = prev_index + 1; j <= current_index; j++) {
				current_count += (uint64_t)(zaatu_table[j] - (j > 0 ? zaatu_table[j - 1] : 0)) * isi_count[j];
			}
			printf("%"PRIu64"\n", current_count);
			prev_count = a[i];
			prev_index = current_index;
		} else {
			puts("0");
		}
	}
	return 0;
}

/*
1階層だけ見てもダメ
撃墜例
3
1 3 2

辞書順最小→なるべく少ない値を出したい
最大のなかで一番右の所を取る

1 2 1 3 2 4 2 5 8 1 -> 9
1 2 1 3 2 4 2 5 7 1 -> 9
1 2 1 3 2 4 2 5 6 1 -> 9
1 2 1 3 2 4 2 5 5 1 -> 8
1 2 1 3 2 4 2 5 4 1 -> 8
1 2 1 3 2 4 2 4 4 1 -> 6
1 2 1 3 2 4 2 4 3 1 -> 6
1 2 1 3 2 4 2 3 3 1 -> 6
1 2 1 3 2 3 2 3 3 1 -> 4
1 2 1 3 2 3 2 3 2 1 -> 4
1 2 1 3 2 3 2 2 2 1 -> 4
1 2 1 3 2 2 2 2 2 1 -> 4
1 2 1 2 2 2 2 2 2 1 -> 2
1 2 1 2 2 2 2 2 1 1 -> 2
1 2 1 2 2 2 2 1 1 1 -> 2
1 2 1 2 2 2 1 1 1 1 -> 2
1 2 1 2 2 1 1 1 1 1 -> 2
1 2 1 2 1 1 1 1 1 1 -> 2
1 2 1 1 1 1 1 1 1 1 -> 2
1 1 1 1 1 1 1 1 1 1 -> 1
1 1 1 1 1 1 1 1 1 0 -> 1
1 1 1 1 1 1 1 1 0 0 -> 1
1 1 1 1 1 1 1 0 0 0 -> 1
1 1 1 1 1 1 0 0 0 0 -> 1
1 1 1 1 1 0 0 0 0 0 -> 1
1 1 1 1 0 0 0 0 0 0 -> 1
1 1 1 0 0 0 0 0 0 0 -> 1
1 1 0 0 0 0 0 0 0 0 -> 1
1 0 0 0 0 0 0 0 0 0 -> 1
*/

Measured memory_bytes: 7608
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


int n[5];
string cal[3];
bool isOut = false;
void rec(int i) {
	if (i == 3) {
		string plus = "+";
		string minus = "-";
		int sum = n[0];
		//cout << n[0] << cal[0] << n[1] << cal[1] << n[2] << cal[2] << n[3] << "=7?" << '\n';
		for (int j = 0; j < 3; j++) {
			if (cal[j] == plus) {
				sum = sum + n[j+1];
			}
			else {
				sum = sum -  n[j+1];
			}
		}
		//debug(sum);
		if (sum == 7) {
			if(!isOut)
				cout << n[0] << cal[0] << n[1] << cal[1] << n[2] << cal[2] << n[3] << "=7" << '\n';
			isOut = true;
		}
		return;
	}
	cal[i] = '+';
	rec(i + 1);
	cal[i] = '-';
	rec(i + 1);
}

signed main() {
	ios::sync_with_stdio(false);
	char in[5];
	cin >> in;
	for (int i = 0; i < 4; i++) {
		n[i] = in[i] - '0';
	}
	rec(0);
	return 0;
}

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

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int a[3];
	for(int i = 0;i < 3;i++){
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[0] + a[1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int f[4][4];
int main()
{
    int a,b,c;
    scanf("%d%d%d",&f[1][1],&f[1][2],&f[2][2]);
    a=f[2][2]*3;
    f[1][3]=a-f[1][1]-f[1][2];
    f[3][1]=a-f[1][3]-f[2][2];
    f[3][3]=a-f[1][1]-f[2][2];
    f[2][1]=a-f[1][1]-f[3][1];
    f[2][3]=a-f[2][1]-f[2][2];
    f[3][2]=a-f[1][2]-f[2][2];
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
        {
            printf("%d ",f[i][j]);
        }
        printf("\n");
    }
    return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


int N;
int A[100000];

signed main(){
    cin >> N;
    REP(i, N) cin >> A[i];
    bool updated = true;
    int m = INT32_MAX;
    while(updated){
        updated = false;
        m = INT32_MAX;
        REP(i, N){
            if(A[i] == 0) continue;
            m = min(m, A[i]);
        }
        REP(i, N){
            if(m < A[i]){
                A[i] %= m;
                updated = true;
            }
        }
    }
    PRINT(m);
    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



int main() {
	int k, n, i, j;
	cin >> k >> n;
	if (k % 2 == 0) {
		cout << k / 2 << " ";
		for (i = 0; i < n - 1; i++) {
			cout << k << " ";
		}
		cout << endl;
		return 0;
	}
	if (k == 1) {
		for (i = 0; i < (n + 1) / 2; i++) {
			cout << k << " ";
		}
		cout << endl;
		return 0;
	}

	vi a(n, k / 2 + 1);
	for (i = 0; i < n / 2; i++) {
		if (a[a.size() - 1] == 1) {
			a.pop_back();
		}
		else {
			a[a.size() - 1]--;
			while (a.size() != n) {
				a.push_back(k);
			}
		}
	}

	for (i = 0; i < a.size(); i++) {
		if (a[i] == 0) {
			cout << endl;
			return 0;
		}
		cout << a[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 200200;
ll L;
ll G = 0;
int m;
int go[N][2];
char s[N];
int q, n;

ll getG(ll x) {
	if (x <= 0) return 0;
	ll res = 1;
	while(x % 2 == 0) {
		x >>= 1;
		res <<= 1;
	}
	return res;
}

void dfs(int v, ll h) {
	if (v == -1) {
		if (L >= h) G ^= getG(L + 1 - h);
		return;
	}
	if (go[v][0] == -1 && go[v][1] == -1) return;
	dfs(go[v][0], h + 1);
	dfs(go[v][1], h + 1);
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	for (int i = 0; i < N; i++)
		go[i][0] = go[i][1] = -1;
	m = 1;

	scanf("%d%lld", &q, &L);
	while(q--) {
		scanf("%s", s);
		n = strlen(s);
		int v = 0;
		for (int i = 0; i < n; i++) {
			int y = (int)(s[i] - '0');
			if (go[v][y] == -1) {
				go[v][y] = m++;
			}
			v = go[v][y];
		}
	}
	dfs(0, 0);
	if (G == 0)
		printf("Bob\n");
	else
		printf("Alice\n");

	return 0;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  for (int &x : m) {
    cin >> x;
  }
  int sum = 0;
  for (int x : m) {
    sum += x;
  }

  int min = m.at(0);
  for (int x : m) {
    if (x < min) {
      min = x;
    }
  }

  cout << (x - sum) / min + n << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a[10000]={0};
    int x,cnt=1;
    while(1){
        scanf("%d",&x);
        if(x == 0){
            break;
        }
        printf("Case %d: %d\n",cnt,x);
        cnt++;
    }
return 0;

}

Measured memory_bytes: 600
n=int(input())
#n,p=map(int,input().split())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
i=1
mn=len(str(n))
while i*i<=n:
    if n%i==0:
        mn=min(mn,
        max(len(str(n//i)),len(str(i))))
    i+=1
print(mn)

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

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        List<int> x = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        List<int> y = new List<int>(x);
        y.Sort();

        int idx = n / 2;
        for (int i = 0; i < n; i++)
        {
            if(x[i] < y[idx])
            {
                Console.WriteLine(y[idx]);
            }
            else
            {
                Console.WriteLine(y[idx - 1]);
            }
        }       
    }
}

Measured memory_bytes: 37960
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = max(A, B); i > 0; i--) {
		if (A % i == 0 && B % i == 0) K--;
		if (K == 0) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    string s;
    cin >> s;

    int z = 0;
    int o = 0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='0')z++;
        else o++;
    }    
    cout << s.length()-abs(z-o)<<endl;
    
        
    
}

Measured memory_bytes: 512
if __name__ == "__main__":
    while True:
        variables = input().split(" ")
        a = int(variables[0])
        op = variables[1]
        b = int(variables[2])

        if (op == '?'):
            break

        if ('+' == op):
            print(f"{a + b}")
        elif ('-' == op):
            print(f"{a - b}")
        elif ('*' == op):
            print(f"{a * b}")
        elif ('/' == op):
            print(f"{a // b}")



Measured memory_bytes: 5604
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=200010;
int a[N],c[N],w[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,m,ans;
    cin>>n>>m,ans=n;
    for(int i=1;i<=n;i++) {
	int x=gi();
	a[i]=x,++c[x];
	if(x-c[x]>=0&&!w[x-c[x]]) --ans;
	++w[x-c[x]];
    }
    while(m--) {
	int x=gi(),y=gi(),z=a[x];
	if(z-c[z]>=0)
	    --w[z-c[z]],ans+=!w[z-c[z]];
	--c[z],++c[a[x]=y];
	if(y-c[y]>=0)
	    ans-=!w[y-c[y]],++w[y-c[y]];
	printf("%d\n",ans);
    }
    return 0;
}

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

using namespace std;
using   vi = vector<int>;
using   vvi = vector<vi>;
using   vs = vector<string>;
#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
const int maxn=1e5+10;
int h,w;
int main()
{    
    
    cin>>h>>w;
   ll dp[h][w];
   memset(dp,0,sizeof(dp));
   string s[h];
   ffor(i,0,h)
   cin>>s[i];
   ffor(i,0,h)
   {
       ffor(j,0,w)
       {   if(s[i][j]=='#') dp[i][j]=0;
           else if(i==0&&j==0&&s[i][j]=='.')
           {
               dp[i][j]=1;
           }
           else if(i==0)
           {  if(s[i][j-1]=='.')
            dp[i][j]=dp[i][j-1];   
           }
           else if(j==0)
           { if(s[i-1][j]=='.')
             dp[i][j]=dp[i-1][j];   
           }
           else
           {
              if(s[i][j]=='.')
              {
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
              }
           }
       }
   }
//    ffor(i,0,h)
//    {ffor(j,0,w)
//    cout<<s[i][j]<<" ";
//    cout<<endl;}
   cout<<dp[h-1][w-1]%mod<<endl;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> xy_t;
xy_t a, b, q, p;
char c;
double x1, x2, xq, y_1, y2, yq;
double s1, s2, s3;
int main()
{
	while(cin >> x1 >> c >> y_1 >> c >> x2 >> c >> y2 >> c >> xq >> c >> yq)
	{
		a=xy_t(x1, y_1);
		b=xy_t(x2, y2);
		q=xy_t(xq, yq);
		p=a+(b-a)*conj((q-a)/(b-a));
		cout << p.real() << ' ' << p.imag() << endl; 
	}
	return 0;
}

Measured memory_bytes: 3248