akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

int main()
{
  int n, s, i, j, ans, sum, num;
  while(cin >> n >> s, n + s){
    ans = 0;
    for(i = 0; i < (1 << 10); i++){
      num = sum = 0;
      for(j = 0; j < 10; j++){
        if(1 << j & i){
          num++;
          sum += j;
        }
      }
      if(num == n && sum == s){
        ans++;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include <stdio.h>

int expr(const char **p);
int term(const char **p);
int factor(const char **p);
int number(const char **p);

int expr(const char **p) {
  int val = term(p);
  while (1) {
    if (**p == '+') {
      (*p)++;
      val += term(p);
    } else if (**p == '-') {
      (*p)++;
      val -= term(p);
    } else {
      break;
    }
  }
  return val;
}

int term(const char **p) {
  int val = factor(p);
  while (1) {
    if (**p == '*') {
      (*p)++;
      val *= factor(p);
    } else if (**p == '/') {
      (*p)++;
      val /= factor(p);
    } else {
      break;
    }
  }
  return val;
}

int factor(const char **p) {
  if (**p == '(') {
    (*p)++;
    int val = expr(p);
    (*p)++;
    return val;
  }
  return number(p);
}

int number(const char **p) {
  int val = 0;
  while ('0' <= **p && **p <= '9') {
    val = val * 10 + **p - '0';
    (*p)++;
  }
  return val;
}

int main() {
  int n;
  char s[101];
  scanf("%d", &n);
  while (n--) {
    scanf("%s", s);
    const char *p = s;
    printf("%d\n", expr(&p));
  }
}

Measured memory_bytes: 1760
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

vector<int>primes;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}

int main() {
	hurui(1e6 + 5);
	int num;
	while (cin >> num) {
		auto it = upper_bound(primes.begin(), primes.end(),num);
		cout << it - primes.begin() << endl;
	}
	return 0;
}

Measured memory_bytes: 7092
import numpy

def main():
    N = int(input())
    a1j = list(map(int, input().split()))
    a2j = list(map(int, input().split()))
    
    a2j.reverse()
    #print(a2j)
    #exit()
    
    a1 = numpy.cumsum(a1j)
    a2 = numpy.cumsum(a2j)
    
    ans = 2
    
    for i in range(N):
        ans_new = a1[N-i-1] + a2[i]
        if ans_new > ans:
            ans = ans_new
    print(ans)
    
main()

Measured memory_bytes: 12500
while 1:
    h,w=map(int, input().split())
    if h==0 and w==0:
        break
    for j in range(w):
        print("#", end="")

    print()

    for i in range(h-2):
        for j in range(w):
            if j==0 or j==w-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    for j in range(w):
        print("#", end="")
    print()
    print()


Measured memory_bytes: 7004
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(x) ((int)(x).size())
#define el "\n"
#ifdef LOCAL_tqk
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint ans = 0;
	char s[5];
	cin >> s;
	rep(i, 4) {
		if (s[i] == '+')ans++;
		else ans--;
	}
	cout << ans << el;
	gc();
}

Measured memory_bytes: 256
# coding: utf-8

list = []
for i in range(10):
    list.append(int(raw_input()))


for i in range(3):
    max = list[0]
    idx = 0
    for i in range(len(list)):
        if i != idx and list[i] > max:
            max = list[i]
            idx = i
    print max
    del list[idx]

        

Measured memory_bytes: 6448
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N+1),b(N+1);

    for(int i=1;i<=N;i++) cin>>a[i];
    for(int i=1;i<=N;i++) cin>>b[i];

    for(int i=2;i<=N;i++) a[i]+=a[i-1];
    for(int i=N-1;i>=1;i--) b[i]+=b[i+1];

    int ans=0;
    for(int i=1;i<=N;i++){
        ans=max(ans,a[i]+b[i]);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
use std::io::stdin;
use std::io::BufRead;

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    loop {
        let mut buf = String::new();

        stdin.read_line(&mut buf).unwrap();

        let mut buf = buf.trim().split(" ");

        let a = buf.next().unwrap().parse::<i64>().unwrap();
        let op = buf.next().unwrap();
        let b = buf.next().unwrap().parse::<i64>().unwrap();

        if op == "?" { break; }

        println!("{}", match &*op {
            "+" => a + b,
            "-" => a - b,
            "*" => a * b,
            "/" => a / b,
            _ => 0
        });
    }
}


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

int gcd(int i, int j){
  if (j == 0) return i;
  return gcd(j, i%j);
}

int main(){
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  vector<int> l(n), r(n);
  l.at(0) = 0;
  for (int i = 1; i < n; i++){
    l.at(i) = gcd(l.at(i-1), a.at(i-1));
  }
  r.at(n-1) = 0;
  for (int i = n-2; i >= 0; i--){
    r.at(i) = gcd(a.at(i+1), r.at(i+1));
  }
  int ans = 0;
  for (int i = 0; i < n; i++){
    ans = max( ans, gcd(l.at(i), r.at(i)) );
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
m[97][52],C;R(x,y,i,j){if(m[x][y]){m[x][y]=0;for(i=2;~i--;)for(j=2;~j--;)i|j&&R(x+i,y+j);}}main(w,h,x,y){for(;scanf("%d%d",&w,&h)*w;printf("%d\n",C)){for(memset(m,y=0,2e4);y++<h;)for(x=0;x++<w;)scanf("%d",m[x]+y);for(C=y=0;y++<h;)for(x=0;x++<w;)m[x][y]&&R(x,y,C++);}}                                                         

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    if (a + b == c || a + c == b || b + c == a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] $){
		var s=new Scanner(System.in);

		var n=s.nextInt();
		var b=new String[n];
		Arrays.setAll(b,i->s.next());

		var m=s.nextInt();
		var a=new String[m];
		Arrays.setAll(a,i->s.next());

		var r=Arrays.stream(b).mapToLong(o->
				Arrays.stream(b).filter(o::equals).count()
						-Arrays.stream(a).filter(o::equals).count())
				.max().getAsLong();

		System.out.println(Math.max(0,r));
	}
}


Measured memory_bytes: 36476
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

//Class.
vector<int> list[1000];
int N, M, E, P;
int match[1000];
bool used[1000];
int x[1000], y[1000];

bool DFS(int V) {
	used[V] = true;
	for (int i = 0; i < list[V].size(); i++) {
		int u = list[V][i]; int w = match[u];
		if (w < 0 || !used[w] && DFS(w)) {
			match[V] = u;
			match[u] = V;
			return true;
		}
	}
	return false;
}

int supermatching() {
	int r = 0;
	memset(match, -1, sizeof(match));
	for (int j = 0; j < P; j++) {
		if (match[j] < 0) {
			memset(used, 0, sizeof(used));
			if (DFS(j)) { r++; }
		}
	}
	return r;
}

//main.
int main() {
	while (true) {
		for (int i = 0; i < 1000; i++) { list[i].clear(); }
		cin >> N >> M; if (!N) { break; }
		P = N + M;
		for (int i = 0; i < N; i++) {
			cin >> x[i];
		}
		for (int i = 0; i < M; i++) {
			cin >> y[i];
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				if (__gcd(x[i], y[j]) != 1) {
					list[i].push_back(j + N);
				}
			}
		}
		cout << supermatching() << endl;
	}
	return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int inf = 1e16;

const int N = 51;
vector<pair<int,pii> > g[N];
int n,m,s;
int c[N];
int d[N];
int dp[N][(N*N)];
int dis[N][N];

void build()
{
    f(i,n) f(j,n) dis[i][j] = inf;
    f(i,n) dis[i][i] = 0;
    
    f(i,n) for(auto x : g[i]) dis[i][x.F] = x.S.S;
    
    f(i,n) f(j,n) f(k,n) 
        dis[j][k] = min(dis[j][k],dis[j][i] + dis[i][k]);
}

void solve()
{
   cin >> n >> m >> s;
    
   int u,v,w,x;
    
   f(i,m)
   {
       cin >> u >> v >> w >> x;
       u--; v--;
       
       g[u].pb({v,{w,x}});
       g[v].pb({u,{w,x}});
   }
    
   f(i,n) cin >> c[i] >> d[i];
    
   build(); 
    
   if(s >= 2500)
   {
       for(int i=1;i<n;i++) cout << dis[0][i] << '\n';
       return;
   }
    
   f(i,n) f(j,2501) dp[i][j] = inf; 
   dp[0][s] = 0;
    
  f(go,n+1)  
   for(int i=0;i<n;i++)
   {
       for(auto x : g[i])
           for(int j=0;j<=2500;j++)
       {
         if(j - x.S.F >= 0)  
           dp[i][j - x.S.F] = min(dp[i][j - x.S.F], dp[x.F][j] + x.S.S);
       }
      
       for(int j=0;j<=2500;j++)
       {
           if(j - c[i] >= 0)
           {
                dp[i][j] = min(dp[i][j],dp[i][j-c[i]] + d[i]);
           }
       }
       
   }
    
    
   for(int i=1;i<n;i++)
   {
       int res = inf;
       
       for(int j=0;j<=2500;j++) res = min(res,dp[i][j]);
       
       cout << res << '\n';
   }
}

signed main()
{
    fast;
    solve();
}

Measured memory_bytes: 4688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
vector<int>p;

int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		int t;
		cin>>t;
		p.push_back(t);
	}
	sort(p.begin(),p.end());
	int ans=0;
	for(int i=0; i<n-1; i++)ans+=p[i];
	ans+=p[n-1]/2;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int N = 2e5 + 10;
 
vector<int> G[N];
vector<int> depth, p;
int dep, x;
 
void dfs(int v, int pai, int d) {
 
    depth[v] = d;
    if(v == x) dep = d;
    for(int u : G[v]) if(u != pai) {
        dfs(u, v, d + 1);
        depth[v] = max(depth[v], depth[u]); 
        p[u] = v;
    }
 
}
 
int main() {
    ios::sync_with_stdio(false);
 
    int n, y; cin >> n >> x >> y; y--; x--;
    depth.resize(n);
    p.resize(n);
    for(int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v; --u; --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
 
    dfs(y, -1, 0);
    int turns = (dep - 1) / 2;
    p[0] = 0;
    while(turns) {
        x = p[x];
        turns--;
    }
 
    cout << depth[x] - 1 << '\n';
 
 
    return 0;
}

Measured memory_bytes: 17024
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
	string s;
	int K;
	cin >> s >> K;
	int n = s.size();

	for(int i = 0; i < n - 1; ++i){
		int a = (26 - (s[i] - 'a')) % 26;
		if(a <= K){
			s[i] = 'a';
			K -= a;
		}
	}
	s[n-1] = (s[n-1] - 'a' + K) % 26 + 'a';
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 512
N = int(input())
a = [int(i) for i in input().split()]
ap = [i + 1 for i in a]
am = [i - 1 for i in a]

a3 = []
a3.extend(a)
a3.extend(ap)
a3.extend(am)
a3 = [str(i) for i in a3]

from collections import Counter
c = Counter(a3)
c = dict(c)

print(max(c.values()))

Measured memory_bytes: 49532
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=998244353;
int n,a[100010],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	if(a[1]!=0)return printf("0"),0;
	if(n==1)return printf("1"),0;
	sort(a+1,a+1+n);
	if(a[2]==0)return printf("0"),0;
	int cnt=1,now=1;ans=1;
	for(int i=2;i<=n;++i)
	{
		if(a[i]!=a[i-1])
		{
			cnt=now,now=0;
			if(a[i]!=a[i-1]+1)return printf("0"),0;
		}
		
		ans=1ll*ans*cnt%mod;
		++now;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <set>

using namespace std;

int graph[500][500];

int n, m; 

set<int> s;

void rec(int depth, int fr)
{
	if (depth == 3) return;

	s.insert(fr);

	for (int i = 0; i < n; ++i) {
		if (i == fr) continue;
		if (graph[fr][i]) {
			rec(depth + 1, i);
		}
	}
}

int main()
{
	while (cin >> n >> m, n && m) {
		for (int i = 0; i < 500; ++i) for (int j = 0; j < 500; ++j) {
			graph[i][j] = 0;
		}
		s.clear();

		for (int i = 0; i < m; ++i) {
			int a, b; cin >> a >> b;
			a--; b--;
			graph[a][b] = graph[b][a] = 1;
		}

		rec(0, 0);

		cout << s.size() - 1 << endl;
	}
}

Measured memory_bytes: 2184
#include <stdio.h>

int main(void)
{
	int n;
	long long int a[300000];
	long long int all = 0;
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
		all ^= a[i];
	}

	for (i = 0; i < n; i++)
	{
		printf("%lld ", all ^ a[i]);
	}
	putchar('\n');

	return 0;
}


Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int N;
	int i;
	string ch;
	int a[10001];
	
	int sum;
	int wk,wk1,wk2,wk3;
	queue<int>que;
	while(1){
		cin>>N;
		if(N==0){
			break;
		}
		sum=1;
		int dice[7]={0,5,4,1,3,6,2};
		fill(a,a+N,0);
		for(i=0;i<N;i++){
			cin>>ch;
			if(ch=="North"){
				a[i]=1;
			}
			else if(ch=="East"){
				a[i]=2;
			}
			else if(ch=="South"){
				a[i]=3;
			}
			else if(ch=="West"){
				a[i]=4;
			}
			else if(ch=="Right"){
				a[i]=5;
			}
			else{
				a[i]=6;
			}
		}
		
		
		
		
		
		
		for(i=0;i<N;i++){
			if(a[i]==1){
				wk=dice[3];
				wk1=dice[1];
				wk2=dice[5];
				wk3=dice[6];
				dice[1]=wk;
				dice[5]=wk1;
				dice[6]=wk2;
				dice[3]=wk3;
			}
			else if(a[i]==2){
				wk=dice[3];
				wk1=dice[4];
				wk2=dice[5];
				wk3=dice[2];
				dice[4]=wk;
				dice[5]=wk1;
				dice[2]=wk2;
				dice[3]=wk3;
			}
			else if(a[i]==3){
				wk=dice[3];
				wk1=dice[6];
				wk2=dice[5];
				wk3=dice[1];
				dice[6]=wk;
				dice[5]=wk1;
				dice[1]=wk2;
				dice[3]=wk3;
			}
			else if(a[i]==4){	
				wk=dice[3];
				wk1=dice[2];
				wk2=dice[5];
				wk3=dice[4];
				dice[2]=wk;
				dice[5]=wk1;
				dice[4]=wk2;
				dice[3]=wk3;
			}
			else if(a[i]==5){
				wk=dice[1];
				wk1=dice[4];
				wk2=dice[6];
				wk3=dice[2];
				dice[4]=wk;
				dice[6]=wk1;
				dice[2]=wk2;
				dice[1]=wk3;
			}
			else if(a[i]==6){
				wk=dice[1];
				wk1=dice[2];
				wk2=dice[6];
				wk3=dice[4];
				dice[2]=wk;
				dice[6]=wk1;
				dice[4]=wk2;
				dice[1]=wk3;
			}
			
			sum+=dice[3];
		}
		
		
		cout<<sum<<endl;
		
	}
	return 0;
}

		
			


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

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

    vector<int> L(N);
    for(int i = 0; i < N; i++)
    {
        cin >> L[i];
    }

    int maxL = *max_element(L.begin(), L.end());
    int sumL = 0;
    for(int i = 0; i < N; i++)
    {
        sumL += L[i];
    }

    int x = sumL - maxL;
    if(maxL < x)
    {
        cout << "Yes" << endl;
    }

    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
int d[11];
bool ans=false;
bool rec(int i,int a,int b){
  //cout<<"ball["<<i<<"]"<<d[i]<<" a:"<<a<<" b:"<<b<<endl;
  if(10==i)ans=true;
  if(a<d[i]){
    a=d[i];
    rec(i+1,a,b);
  }
  else if(b<d[i]){
    b=d[i];
    rec(i+1,a,b);
  }
  else return false;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    ans=false;
    for(int j=0;j<10;j++){
      cin>>d[j];
    }
    //    cout<<(rec(0,0,0)?"YES":"No")<<endl;
    rec(0,0,0);

    cout<<(ans?"YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
n,m = map(int, input().split())
pyi = [list(map(int, input().split())) + [i] for i in range(m)]
pyi.sort()

pnow = pyi[0][0]
cnt = 1

ans = [-1 for _ in range(m)]

for p,y,i in pyi:
  if pnow != p:
    cnt = 1
    pnow = p
  ans[i] = str(p).zfill(6) + str(cnt).zfill(6)
  cnt += 1
print("\n".join(ans))

Measured memory_bytes: 34500
N = input()
K = int(input())
m = len(N)

dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]
dp [0][0][0] = 1

for i in range(1, m + 1):
    l = int(N[i - 1])
    for k in range(K + 1):
        dp[i][1][k] += dp[i - 1][1][k]
        if l != 0:
            dp[i][1][k] += dp[i - 1][0][k]
        else:
            dp[i][0][k] += dp[i - 1][0][k]
        if k - 1 >= 0:
            dp[i][1][k] += 9 * dp[i -1][1][k - 1]
            if l != 0:
                dp[i][0][k] += dp[i - 1][0][k - 1]
                dp[i][1][k] += (l - 1) * dp[i - 1][0][k -1]


print(dp[m][0][K] + dp[m][1][K])


Measured memory_bytes: 3064
import java.util.HashSet;
import java.util.Scanner;

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

        HashSet<Integer> set = new HashSet<>();
        int counts = scanner.nextInt();

        for (int i = 0; i < counts; i++) {
            set.add(scanner.nextInt());
        }

        System.out.println(set.size());
    }
}

Measured memory_bytes: 22868
K, N = map(int, input().split())
A = [int(x) for x in input().split()]
diff = [0] * N
for i in range(N-1):
    diff[i] = A[i+1] - A[i]
diff[-1] = (K - A[-1]) + A[0]
print(sum(diff)-max(diff))

Measured memory_bytes: 26444
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
//#include <math.h>
int main(void) 
{
    int a, b;
    cin >>a >>b;

    
    rep(i, max(a,b)) {
        cout << min(a,b);
    }
   
    
    return 0;
}

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

int main(){
  int a,b;
  while(1){
    cin>>b>>a;
    if(a==0&&b==0)break;
    for(int i=0;i<a;i++)cout<<"#";
    cout<<endl;
    for(int i=2;i<b;i++){
      cout<<"#";
      for(int j=2;j<a;j++){
	cout<<".";
      }
      cout<<"#"<<endl;
    }
    for(int i=0;i<a;i++)cout<<"#";
    cout<<endl<<endl;
  }
  return 0;
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int ans = 0;
    while (true)
    {
        if (k >= a)
        {
            k -= a;
            ans += a;
        }
        else
        {
            ans += k;
            break;
        }
        if (k >= b)
        {
            k -= b;
        }
        else
        {
            break;
        }
        if (k >= c)
        {
            ans -= c;
        }
        else
        {
            ans -= k;
        }
        break;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<cstdio>
#define mes(a, b) memset(a, b, sizeof a)
#define pb push_back
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 2e6+10;
const double eps = 1e-1;
int T, n, m, k, q;
int main(){
    double r, pi = acos(-1);
    scanf("%lf", &r);
    printf("%f\n", 2.0*r*pi);
    return 0;
}


Measured memory_bytes: 3224
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
    string c;
    cin >> c;
    int numa = 0, ans = 0;
    bool flag = 1;
    for(int i = 0; i < c.size(); ++i)
    {
        if(c[i] == 'A' && flag)
        {
            numa = i;
            flag = 0;
        }
        else if(c[i] == 'Z') ans = i - numa + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import bisect
N = int(input())
L = sorted(list(map(int, input().split())))
res = 0
for i in range(N - 1, 1, - 1):
    for j in range(i - 1, 0, - 1):
        k = L[i] - L[j] + 1
        if k > L[j - 1]:
            break
        res += j - bisect.bisect_left(L, k)
print(res)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;

	int cnt=0;
	int mmin=1e9;
	lint sum=0;

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

		if(A<0)
			cnt++;
		A=abs(A);
		sum+=A;
		mmin=min(mmin,A);
	}
	
	if(cnt%2==1)
		sum-=2*mmin;
	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <complex>
#include <utility>

using namespace std;

typedef complex<int> ci;
typedef pair<int,ci> Parsed;

Parsed expr(const string& s,int i);

Parsed fact(const string& s,int i)
{
	if(s[i]=='-'){
		Parsed p=fact(s,i+1);
		p.second=-p.second;
		return p;
	}
	if(s[i]=='('){
		Parsed p=expr(s,i+1);
		p.first++;
		return p;
	}
	if(s[i]=='i')
		return Parsed(i+1,ci(0,1));
	int val=0;
	while(i<s.size() && isdigit(s[i])){
		val=val*10+s[i++]-'0';
		if(val>10000)
			throw "overflow";
	}
	return Parsed(i,ci(val));
}

Parsed term(const string& s,int i)
{
	Parsed p1=fact(s,i);
	i=p1.first;
	ci val=p1.second;
	while(i<s.size() && (s[i]=='*')){
		Parsed p2=fact(s,i+1);
		val*=p2.second;
		if(abs(real(val))>10000 || abs(imag(val))>10000)
			throw "overflow";
		i=p2.first;
	}
	return Parsed(i,val);
}

Parsed expr(const string& s,int i)
{
	Parsed p1=term(s,i);
	i=p1.first;
	ci val=p1.second;
	while(i<s.size() && (s[i]=='+' || s[i]=='-')){
		Parsed p2=term(s,i+1);
		if(s[i]=='+')
			val+=p2.second;
		else
			val-=p2.second;
		if(abs(real(val))>10000 || abs(imag(val))>10000)
			throw "overflow";
		i=p2.first;
	}
	return Parsed(i,val);
}

void solve(const string& s)
{
	try{
		ci res=expr(s,0).second;
		if(real(res)==0 && imag(res)==0)
			puts("0");
		else if(real(res)==0)
			printf("%di\n",imag(res));
		else if(imag(res)==0)
			printf("%d\n",real(res));
		else
			printf("%d%+di\n",real(res),imag(res));
	}
	catch(const char* message){
		cout<<message<<endl;
	}
}

int main()
{
	for(string s;getline(cin,s);)
		solve(s);
	
	return 0;
}

Measured memory_bytes: 0
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,4);
  myout(lcm(input[0],input[1]));
}
function lcm(m, n) {return m * n / gcd(m, n);}
function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}
Main(myin());

Measured memory_bytes: 22076
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//#include "atcoder/all"
//using namespace atcoder;

int f[10000001];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll ans = 0;
	for(ll i = 1; i <= n; ++i){
		for(int j = i; j <= n; j+=i){
			++f[j];
		}
		ans += i * f[i];
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int x = max({ a,b,c });
	int res = x;
	for (int i = 1;i <= k;++i) {
		res *= 2;
	}
	int ans = (a + b + c) + res - x;
	cout << ans << endl;
	return 0;
}


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

int main(){
    int K,X; cin >> K >> X;
    if(500*K>=X) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

for h in range(1, 3501):
    for n in range(h, 3501):
        a = N*h*n
        b = 4*h*n - N*n - N*h
        if not b:
            continue
        if a%b == 0 and a//b > 0:
            print(h, n, a//b)
            exit()

Measured memory_bytes: 9108
#include<stdio.h>

int main(void){

	double r,s,l;
	
	scanf("%lf",&r);
	
	s = r*r*3.141592653589;
	l = 2*r *3.141592653589;
	
	printf("%.6lf %.6lf\n",s,l);
	
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <algorithm>

using namespace std;


int main(){
	/*input*/
	double w,h,x,y;
    cin >> w >> h >> x >> y;


	/*calc*/
    double ans_area = 0;
    int ans_method = 0;
	ans_area = w*h / 2;

	if((w/x == 2) && (h/y == 2)){
    	ans_method = 1;
    }

	/*output*/
   	cout<<ans_area<<" "<< ans_method <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    cout << r/d - (l-1)/d << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <iomanip>

using ll = long long int;
using P = std::pair<int, ll>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

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

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

int a[123],b[123],dv[123],d[123],p[123],cnt[123];
std::vector<int> g[123];
std::queue<int> que;

P bfs(void){
	int u,v,j,i,m=0;
	ll ret = 1ll;
	std::fill(cnt,cnt+123,0);
	while(!que.empty()){
		u = que.front();
		que.pop(); i = 0;
		m = std::max(m,d[u]);
		for(j=(g[u].l_ength()-1); j>=0; --j){
			v = g[u][j];
			if(v==p[u]){
				continue;
			}
			p[v] = u;
			d[v] = d[u] + 1; ++i;
			que.push(v);
		}
		cnt[d[u]] = std::max(cnt[d[u]],i);
	}
	for(i=0; i<m; ++i){
		ret *= cnt[i];
	}
	return P(m+1,ret);
}

int main(void){
	int n,i,j,u,v;
	P tmp,ans=P(INF,INFLL);
	std::cin >> n;
	for(i=1; i<n; ++i){
		std::cin >> a[i] >> b[i];
		--a[i]; --b[i];
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
		++dv[a[i]]; ++dv[b[i]];
	}
	for(i=0; i<n; ++i){
		p[i] = n; d[i] = 0;
		que.push(i);
		tmp = bfs();
		if(dv[i]==1){
			++tmp.second;
		}
		ans = std::min(ans,tmp);
	}
	for(i=1; i<n; ++i){
		p[a[i]] = b[i]; p[b[i]] = a[i];
		d[a[i]] = 0; d[b[i]] = 0;
		que.push(a[i]); que.push(b[i]);
		tmp = bfs();
		tmp.second *= 2;
		ans = std::min(ans,tmp);
	}
	std::cout << ans.first << " " << ans.second << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ii pair <int , int>
#define is pair <int, string>
#define ll long long
#define mx 100000
#define sf scanf
#define sf(n) scanf("%d",&n)
#define pf printf
using namespace std;
vector <int> v;

/*int intConvert(string s){
    int n;
    stringstream geek(s);
    geek >> n;
    return n;
}*/

/*string strConvert(int n){
    string s;
    stringstream ss;
    ss << n;
    s=ss.str();
    return s;
}*/


int main(){
    string s,ss="";
    cin>>s;

    int len=s.size();
    for(int i=len-1; i>=0; i--){
        ss+=s[i];
    }

    int cnt=0;
    for(int i=0; i<len; i++){
        if(s[i]!=ss[i]) cnt++;
    }
    pf("%d\n",cnt/2);
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int y, m, d;

	while(scanf("%d%d%d", &y, &m, &d) != EOF){

		if(y <= 1867)
			printf("pre-meiji\n");
		if(y == 1868){
			if(m <= 8)
				printf("pre-meiji\n");
			if(m == 9){
				if(d <= 7)
					printf("pre-meiji\n");
				else
					printf("meiji 1 %d %d\n", m, d);
			} else
				printf("meiji 1 %d %d\n", m, d);
		}
		if(y >= 1869 && y <= 1911)
			printf("meiji %d %d %d\n", y-1867, m, d);
		if(y == 1912){
			if(m <= 6)
				printf("meiji %d %d %d\n", y-1867, m, d);
			if(m == 7){
				if(d <= 29)
					printf("meiji %d %d %d\n", y-1867, m, d);
				else
					printf("taisho 1 %d %d\n", m, d);
			} else
				printf("taisho 1 %d %d\n", m, d);
		}
		if(y >= 1913 && y <= 1925)
			printf("taisho %d %d %d\n", y-1911, m, d);
		if(y == 1926){
			if(m <= 11)
				printf("taisho %d %d %d\n", y-1911, m, d);
			else {
				if(d <= 24)
					printf("taisho %d %d %d\n", y-1911, m, d);
				else
					printf("showa 1 %d %d\n", m, d);
			}
		}
		if(y >= 1927 && y <= 1988)
			printf("showa %d %d %d\n", y-1925, m, d);
		if(y == 1989){
			if(m == 1){
				if(d <= 7)
					printf("showa %d %d %d\n", y-1925, m, d);
				else
					printf("heisei 1 %d %d\n", m, d);
			} else
				printf("heisei 1 %d %d\n", m, d);
		}
		if(y >= 1990)
			printf("heisei %d %d %d\n", y-1988, m, d);

	}

	return 0;
}

Measured memory_bytes: 608
# Studying https://atcoder.jp/contests/abc140/submissions/7391384

N = gets.to_i
P = gets.split.map &:to_i

Pi = [nil] * N
P.each_with_index{|p, i|
	Pi[p-1] = i
}

RU = (1..N).to_a + [N, N]
LU = (-1..(N-2)).to_a + [-1, -1]

p Pi.inject(0){|sum, i|
	 l,  r = LU[i], RU[i]
	ll, rr = LU[l], RU[r]
	LU[r], RU[l] = l, r
	next sum + P[i] * ((i-l)*(rr-r) + (r-i)*(l-ll))
}


Measured memory_bytes: 12044
//atRto TLH
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define ll long long
const ll MOD = 1e9 + 7;
#define ln '\n'
#define all(x) (x).begin(), (x).end()
#define rotate rotate(vec.begin(), vec.begin() + k, vec.end())
#define alloc(v) set<int> S(all(v))
#define bitset(n)  bitset<20>(n)
#define Min min({a, b, c, d})
 
      const ll INF=2*1e5;
      char tt[2003][2003];
    
     int vis[107];
     //vector<ll>v[107];
    int size=0;
 

 
 void solve(){
 
 }
    
 
    int main() {
      IOS;
    #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif
   
   ll n;
   cin>>n;

   ll a[n][3];
   for(ll i=0;i<n;i++){
    for(ll j=0;j<3;j++){
      cin>>a[i][j];
    }
   }
   ll dp[n][3];
   dp[0][0]=a[0][0];
   dp[0][1]=a[0][1];
   dp[0][2]=a[0][2];

   for(ll i=1;i<n;i++){
    dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
    dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
    dp[i][2]=max(dp[i-1][0]+a[i][2],dp[i-1][1]+a[i][2]);
  }
  ll t1=0,t2=0,t3=0;
  for(ll i=0;i<n;i++) t1=max(t1,dp[i][0]);
    for(ll i=0;i<n;i++) t2=max(t2,dp[i][1]);
      for(ll i=0;i<n;i++) t3=max(t3,dp[i][2]);

        cout<<max(t1,max(t2,t3));
      return 0;
    }

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

#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define fi first
#define se second

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())

#define PF(a) push_front(a)
#define PB(a) push_back(a)
#define EMPF(...) emplace_front(__VA_ARGS__)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, -1, sizeof(a))

#define PW(n) (1LL << (n))
#define NUM(x) char(x + '0')
#define ALP(x) char(x + 'a')

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNIQUE(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int A, B, K;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> A >> B >> K;
  if (A > B) swap(A, B);
  int num = 0;
  FORR(i, A+1, 1) {
    if (A % i == 0 && B % i == 0) {
      num++;
      if (num == K) {
        cout << i << endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cstring>
#include <functional>
#include <iostream>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <iomanip>
#include <math.h>
#include <cmath>
#include <array>
#include <complex>

#define endl '\n'

using namespace std;

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

    int n; cin >> n;

    map<tuple<int, int, int>, int> freq;

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

        long long a = 0;
        int comma = 0;

        int started = 0;

        for (auto x : s) {
            if (x == '.')
                started = 1;
            else {
                a = 10 * a + x - '0';
                comma += started;
            }
        }

        while ((a % 10 == 0) && comma) {
            comma--;
            a /= 10;
        }

        int f2 = 0, f5 = 0;

        while (a % 5 == 0) {
            ++f5;
            a /= 5;
        }

        while (a % 2 == 0) {
            ++f2;
            a /= 2;
        }

        int f = min(f2, f5);
        f2 -= f;
        f5 -= f;
        comma -= f;

        freq[{ f2, f5, comma }]++;
        
    }

    int a2, a5, ac, at;
    int b2, b5, bc, bt;
    long long total = 0;

    for (auto a : freq) {
        tie(a2, a5, ac) = a.first;
        at = a.second;

        for (auto b : freq) {
            tie(b2, b5, bc) = b.first;
            bt = b.second;

            if (min(a2 + b2, a5 + b5) >= ac + bc) {
                total += 1LL * at * bt;

                if (a.first == b.first) {
                    total -= at;
                }
            }
        }
    }

    cout << total / 2 << endl;

    return 0;
}




Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main(){

    int x,a;
    cin>>x>>a;


    if(x<a){
        cout<<"0"<<endl;
      //  cout<<x<< " is less than "<<a<<",so we should print 0."<<endl;
    }
    else{
        cout<<"10"<<endl;
        // cout<<x<< " is not less than "<<a<<",so we should print 10."<<endl;
    }


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B;cin>>A>>B;
  cout<<max({A+B,A-B,A*B})<<endl;
  return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<bool>>grid(h, vector<bool>(w));
  vector<pair<pair<int, int>, pair<int, int>>>ret;
  int cnt=0;
  for(int i=0; i<h; i++)for(int j=0; j<w; j++){
    int t;
    cin >> t;
    grid[i][j]=((t%2)==1);
  }
  bool trig=false;
  pair<int, int>podd;
  int c=0;
  for(int i=0; i<h; i++){
    if(i%2==0){
      for(int j=0; j<w; j++){
        if(grid[i][j]){
          if(!trig){podd.first=i; podd.second=j; trig=true; c=0;}
          else {
            ret.push_back(make_pair(podd, make_pair(i, j)));
            cnt+=c+1;
            trig = false;
          }
        }
        else c++;
      }
    }
    else {
      for(int j=w-1; j>=0; j--){
        if(grid[i][j]){
          if(!trig){podd.first=i; podd.second=j; trig=true; c=0;}
          else {
            ret.push_back(make_pair(podd, make_pair(i, j)));
            cnt+=c+1;
            trig = false;
          }
        }
        else c++;
      }
    }
  }
  cout << cnt << endl;
  int d;
  for(pair<pair<int, int>, pair<int, int>>p: ret){
    pair<int, int>p1=p.first, p2=p.second;
    while(p1.first!=p2.first || p1.second!=p2.second){
      d=(p2.first%2)*2-1;
	  while((0<=p2.second+d && p2.second+d<w) && (p1.first!=p2.first || p1.second!=p2.second)){
        cout << p2.first+1 << ' ' << p2.second+1 << ' ' << p2.first+1 << ' ' << p2.second+d+1 << endl;
        p2.second += d;
      }
      if(p1.first==p2.first && p1.second==p2.second)break;
      cout << p2.first+1 << ' ' << p2.second+1 << ' ' << p2.first << ' ' << p2.second+1 << endl;
      p2.first--;
    }
  }
  return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int h,w;cin>>h>>w;

  for(int i=0;i<w+2;i++)cout<<'#';
  cout<<endl;

  for(int i=0;i<h;i++){
    string s;cin>>s;
    cout<<'#'<<s<<'#'<<endl;
  }

  for(int i=0;i<w+2;i++)cout<<'#';
  cout<<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 x = sc.nextInt();
        int t = sc.nextInt();
        int ans = n / x;
        int mod = n % x;
        if(mod == 0) System.out.println(ans * t);
        else System.out.println((ans + 1) * t);
    }
}

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

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    int i;
    for (i = 0 ; i < K ; i++ ){
        if(i % 2 == 0){
            if(A % 2 == 1){
                A = A - 1;
            }
            A = A / 2;
            B = B + A;
        }else{
            if(B % 2 == 1){
                B = B - 1;
            }
            B = B / 2;
            A = A + B ;
        }
    }
    cout << A << ' ' << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main()
{
    ll n;
    cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> q[i];
    }
    vector<int> a(n);
    bool flag1 = true;
    bool flag2 = true;
    ll cnt = 0, cnt1 = 0, cnt2 = 0;
    for (int i = 0; i <= n; i++)
    {
        a[i] = i + 1;
    }
    for (int i = 0; i < kaizyou(n); ++i)
    {
        cnt++;
        for (int i = 0; i < n; i++)
        {
            if (a[i] != p[i])
            {
                flag1 = false;
            }
            if (a[i] != q[i])
            {
                flag2 = false;
            }
        }
        if (flag1 == true)
        {
            cnt1 = cnt;
        }
        if (flag2 == true)
        {
            cnt2 = cnt;
        }
        flag1 = true;
        flag2 = true;
        next_permutation(begin(a), end(a)); //次の順列が生成される
    }
    cout << abs(cnt1 - cnt2) << endl;
}


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

using namespace std;

typedef long long ll;

const int maxn=2e5+10;



int main()
{
	int x;
	cin>>x;
	if( x<600 ) puts("8");
	else if( x<800 )  puts("7");
	else if( x<1000 )  puts("6");
	else if( x<1200 )  puts("5");
	else if( x<1400 )  puts("4");
	else if( x<1600 )  puts("3");
	else if( x<1800 )  puts("2");
	else if( x<2000 )  puts("1");
} 

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    ll ans;
    if(k <= x/d){
        ans = x - k*d;
    }else{
        ll nokori = k - x/d;
        if(nokori%2 == 0)ans = x%d;
        else ans = abs(x%d-d);
        // ans = min(x%d,d-x%d);
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  a = a * b;
  if (a % 2 == 0)
    cout << "Even" << endl;
  if (a % 2 == 1)
    cout << "Odd" << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double norm(point a){
  return sqrt(dot(a,a));
}

typedef point Vector;
typedef pair<point,point> Line;

point projection(Vector p,Vector b){
  return b*dot(p,b)/dot(b,b);
}

point projection(Line l,Vector p){
  point a=l.second-l.first;
  point b=p-l.first;
  return l.first+projection(b,a);
}

int main(void){

  Line l;
  point c;
  int q;
  cin >> l.first.x >> l.first.y >> l.second.x >> l.second.y;
  cin >> q;
  while(q--){
    cin >> c.x >> c.y;
    point res=projection(l,c);
    printf("%.10f %.10f\n",res.x,res.y);
  }

  return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main(){ IO;
  int n;
  cin >> n;

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

  int ans = INT_MAX;
  for(int x = -100; x <= 100; ++x) {
    int cnt = 0;
    for (auto & y : v) {
      cnt += (x - y) * (x - y);
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    int cnt0 = 0, cnt1 = 0;

    rep(i, N) {
        if(S[i] == '0') {
            cnt0++;
        }
        else if(S[i] == '1') {
            cnt1++;
        }
    }

    int ans = min(cnt0, cnt1) * 2;

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 512