akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define DBG 1

#define BIG 999999999999999L
#define MAXN 401
int a[MAXN];
long b[MAXN][MAXN][2];

int main() {
  int n;
  cin >> n;
  forr(i,0,n-1)
    cin >> a[i];
  forr(i,0,n-1) {
    b[i][i][0] = a[i];
    b[i][i][1] = 0;
  }
  forr(d,1,n-1)
    forr(i,0,n-1-d) {
      long mnwt = BIG;
      long mnpast = BIG;
      forr(j,i,i+d-1) {
        long wt = b[i][j][0] + b[j+1][i+d][0];
        long past = b[i][j][1] + b[j+1][i+d][1];
        if (wt + past < mnpast) {
          mnwt = wt;
          mnpast = wt + past;
        }
      }
      b[i][i+d][0] = mnwt;
      b[i][i+d][1] = mnpast;
    }
  cout << b[0][n-1][1];
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n,g;
    cin>>n>>g;
    
    vector<int> p(n), c(n);
    rep(i,n){
        cin>>p[i]>>c[i];
    }
    
    
    int ans = INF;
    rep(i,1<<n){
        int sum = 0;
        int solved = 0;
        int t = i;
        
        int notComp = -1;
        rep(j,n){
            if(t%2){
                sum += c[j];
                sum += p[j]*(j+1)*100;
                solved += p[j];
            }
            else notComp = j;
            t/=2;
        }
        
        if(sum>=g){
            ans = min(ans,solved);
        }else{
            for(int j=0;j<p[notComp]&&sum<g;j++){
                sum += (notComp+1)*100;
                solved++;
            }
            if(sum>=g){
                ans = min(ans,solved);
            }
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main(void) {
    int n;
    cin>>n;
    string s[n+1];
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<n;i++){
        char c[10];
        for(int j=0;j<10;j++){
            c[j]=s[i][j];
        }
        sort(c,c+10);
        for(int j=0;j<10;j++){
            s[i][j]=c[j];
        }
    }
    sort(s,s+n);
    ll count=1;
    s[n]="zzzzzzzzzzzzzzzzzzzzzzzz";
    ll ans=0;
    for(int i=0;i<n;i++){
        if(s[i]!=s[i+1]){
            if(count%2==0){
                ans+=((count/2)*(count-1));
            }
            else{
                ans+=(((count-1)/2)*count);
            }
            count=1;
        }
        else count++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7296
#include<iostream>
#include<cassert>
#include<algorithm>
#include<vector>
using namespace std;
#define H_MAX 100000
int W, H, N;
int MX[H_MAX], X[H_MAX];

main(){
  int x, y;
  cin >> W >> H >> N;
  for ( int i = 0; i < H; i++ ) MX[i] = X[i] = -1;
  for ( int i = 0; i < N; i++){
    cin >> x >> y;
    X[y] = max(X[y], x);
  }
  MX[H-1] = 0;
  for ( int i = H-2; i >= 0; i-- ){
    MX[i] = max(MX[i+1], X[i+1]);
  }

  int ans = H;
  for ( int i = 0; i < H; i++ ){
    ans = min(ans, i + MX[i]);
  }

  cout << ans << endl;

  return 0;
}




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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, k, q;
li cnt[100100];

int main() {
    li a[5];
    li res = 0;
    li hanpa_min = 123;
    rep(i, 5) {
        cin >> a[i];
        res += (a[i] + 9) / 10 * 10;
        if (a[i] % 10 != 0) {
            hanpa_min = min(hanpa_min, a[i] % 10);
        }
    }
    if (hanpa_min != 123) {
        res = res - 10 + hanpa_min;
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
from fractions import gcd #Python3.4
import functools
#from math import gcd #Python3.8
N = int(input())
T = [int(input()) for i in range(N)]
#最小公倍数を求める
def lcm(a,b):
    return a*b//gcd(a,b)

print(functools.reduce(lcm,T))

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define ve vector 
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007
#define PRECISE cout.precision(18);
#define all(c) c.begin(), c.end()
#define sec second
#define fst first
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
int main()
{
	FAST
	ll n,k;cin>>n>>k;
	ll h[n];
	for(ll i=0;i<n;i++)
		cin>>h[i];
	ll dp[n];
	memset(dp,0,sizeof(dp));
	dp[0]=0;
	for(ll i=1;i<=k-1&&i<n;i++)
	{
		ll mn=dp[i-1]+abs(h[i]-h[i-1]);
		for(ll j=i-2;j>=0;j--)
		{
			ll f=dp[j]+abs(h[i]-h[j]);
			mn=min(mn,f);

		}
		dp[i]=mn;
	}
	for(ll i=k;i<=n-1;i++)
	{
		ll mn=dp[i-1]+abs(h[i]-h[i-1]);
		for(ll j=i-2;j>=i-k;j--)
		{
			ll f=dp[j]+abs(h[i]-h[j]);
			mn=min(mn,f);

		}
		dp[i]=mn;
	}
	cout<<dp[n-1];

}	

Measured memory_bytes: 1792
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
n,a = IR(2)
print(n**2-a)
"""
#B
n,k = IR(2)
x = LI()
ans = 0
for i in range(n):
    ans += min(x[i]*2,(k-x[i])*2)
print(ans)
#C
"""
a,b,c,d,e,f = LI()
a *= 100
b *= 100
ans = [a,0]
for i in range(f//a+1):
    for j in range((f-a*i)//b+1):
        for k in range((f-a*i-b*j)//c+1):
            for l in range((f-a*i-b*j-c*k)//d+1):
                if i or j or k or l:
                    s = c*k+d*l
                    w = a*i+b*j
                    q = w*e//100
                    if s <= q:
                        if w+s <= f:
                            if ans[1]/ans[0] < s/(s+w):
                                ans = [w+s,s]
print(*ans)
"""

#D
"""
n = I()
d = LIR(n)
l = [[1 for j in range(n)] for i in range(n)]
for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k]+d[k][j]:
                print(-1)
                quit()
            if d[i][j] == d[i][k]+d[k][j]:
                l[i][j] = l[i][k]+l[k][j]

ans = 0
for i in range(n):
    for j in range(n):
        if l[i][j] == 4:
            ans += d[i][j]
ans //= 2
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

int main() {
    int a,b,c;
    int d = 0;
    cin >> a >> b >> c;
    for (int i = 0;i < c;i++){
        b = b - a;
        if (b < 0) break;
        d++;
    }
    cout << d << endl;
}

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

int main(void){
    int n;
    double xa,ya,ra,xb,yb,rb;
    double dx,dy,dr;
    
    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%lf %lf %lf", &xa, &ya, &ra);
        scanf("%lf %lf %lf", &xb, &yb, &rb);
        dx = xa - xb;
        dy = ya - yb;
        dr = sqrt(dx*dx + dy*dy);
        
        if (dr > ra + rb){
            printf("0\n");
        } else if (dr + ra < rb){
            printf("-2\n");
        } else if (dr + rb < ra){
            printf("2\n");
        } else {
            printf("1\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 1048
<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",fgets(STDIN)));
	}
}
//ECHO Answer
function echoa($ans_word=null){
	if($ans_word===null){
		return false;
	}else{
		echo $ans_word."\n";
		return true;
	}
}

/*		START		*/
$S = getq();
if($S[0]=="A"){
	$S[0]="a";
	$Cche = false;
	for($i=2; $i<strlen($S)-1;$i++){
		if($S[$i]=="C"){
			if($Cche){
				echo("WA\n");
				exit();
			}
			$Cche=true;
			$S[$i]="a";
		}
	}
	if($Cche==true && ctype_lower($S)){
		echo("AC\n");
		exit();
	}
}
echo("WA\n");
exit();
?>

Measured memory_bytes: 4604
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

ll p[200];
ll c[200];
int main(){
    ll n,g;
    cin >> n >> g;
    rep(i,n){
        cin >> p[i] >> c[i];
    }
    ll ans = inf;
    rep(bit,1<<n){
        ll tmp = 0;
        ll sc = 0;
        rep(j,n){
            if((bit>>j)&1){
                tmp += p[j];
                sc += 100LL*(j+1)*p[j];
                sc += c[j];
            }
        }
        if(sc>=g){
            ans = min(ans,tmp);
        }else{
            for(ll j=n-1;j>=0;j--){
                if(((bit>>j)&1)==0){
                    rep(k,p[j]){
                        sc += 100LL*(j+1);
                        tmp++;
                        if(sc>=g){
                            ans = min(ans,tmp);
                        }
                    } 
                }
            }
            ans = min(ans,tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// B - Ruined Square
// https://abc108.contest.atcoder.jp/tasks/abc108_b

import scala.io.StdIn.readLine

object Main extends App {

  val Array(x1, y1, x2, y2) = readLine.split(" ").map(_.toInt)

  val (a, b) = (x2 - x1, y2 - y1)

  val (x3, y3) = (x2 - b, y2 + a)
  val (x4, y4) = (x1 - b, y1 + a)

  println("%d %d %d %d".format(x3, y3, x4, y4))

}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    string s;
    cin >> s;

    for (auto&& c : s) {
        c -= '0';
    }

    vector<int64_t> t(2019);
    t[0] = 1;
    int64_t m = 0, d = 1;
    for (auto i : irange(0uL, s.size()) | reversed) {
        m += d * s[i];
        m %= 2019;
        d *= 10;
        d %= 2019;
        ++t[m];
    }

    int64_t ans = 0;
    for (auto i : irange(0L, 2019L)) {
        ans += t[i] * (t[i] - 1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3696
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <fstream>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };

const int MOD = 1000000007;
const int _MOD = 1000000009;
double EPS = 1e-10;
const int INF = INT_MAX / 10;

typedef pair<int, i_i> P;

int main() {
	int x; cin >> x;
	int t;
	for (t = 1; ; t++) {
		x -= t;
		if (x <= 0) break;
	}
	cout << t << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int a = input[0],
            b = input[1],
            c = input[2],
            d = input[3],
            count = 0;
        while (a > 0 && c > 0)
        {
            if (count % 2 == 0)
            {
                c -= b;
            }
            else
            {
                a -= d;
            }
            count++;
        }

        Console.WriteLine(a > 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 27476
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int h,w;
    const int INF = INT32_MAX>>3;
    cin >> h >> w;
    //ベルマンフォード法
    /*
    struct edge {
        int from, to, cost;
    };
    vector<edge> G(9*9);
    rep(i,10) rep(j,10) {
        int c;
        cin >> c;
        if(i == j) continue;
        G.push_back({i,j,c});
    }
    vector<int> A;
    rep(i,h) rep(j,w) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    vector<int> d_min(10);
    rep(i, 10) {
        vector<int> d(10, INF);
        d[i] = 0;
        rep(j, 10) {
            for(auto e: G) {
               if(d[e.from] != INF && d[e.from] + e.cost < d[e.to]){
                   d[e.to] = d[e.from] + e.cost;
               }
            }
        }
        d_min[i] = d[1];
    }
    int ans = 0;
    rep(i, A.size()) {
        if(A[i] != -1) {
            ans+=d_min[A[i]];
        }
    }
    cout << ans << endl;
    */

    //ワーシャルフロイド法
    vector<vector<int>> d(10,vector<int>(10,INF));
    rep(i,10) rep(j,10) cin >> d[i][j];
    vector<vector<int>> a(h, vector<int>(w));
    rep(i,h) rep(j,w) cin >> a[i][j];
    rep(k,10) rep (i,10) rep(j,10) chmin(d[i][j], d[i][k] + d[k][j]);
    int ans = 0;
    rep(i,h) rep(j,w) if(a[i][j]!=-1)ans+=d[a[i][j]][1];
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<cstdio> 
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<string>
#define ms(i, j) memset(i, j, sizeof i)
#define LL long long
#define db double
#define fir first
#define sec second
#define mp make_pair
using namespace std;

namespace flyinthesky {

	char s[105];
	LL n, k, b[105], gg = -1;

    void clean() {
	}
    int solve() {
    	
		clean();
		
		scanf("%s%lld", s + 1, &k);
		n = strlen(s + 1);
		LL cnt = 0, lst = 0;
		for (int i = 1; i <= n + 1; ++i) {
			if (s[i] != s[i - 1]) {
				b[++gg] = i - lst;
				lst = i;
			}
		}
		for (int i = 1; i <= gg; ++i) cnt += b[i] / 2;
		if (k == 1) {
			cout << cnt;
		} else {
			if (s[1] != s[n]) cout << cnt * k; else {
				if (gg == 1) {
					cout << (b[1] * k) / 2;
				} else if (gg == 2) cout << cnt * k; else {
					LL cnt2 = cnt - b[1] / 2 - b[gg] / 2;
					LL ans = cnt2 * k + (b[1] + b[gg]) / 2 * (k - 1) + b[1] / 2 + b[gg] / 2;
					cout << ans;
				}
			}
		}
		
        return 0;
    }  
}
int main() {
	flyinthesky::solve();
    return 0;
}
/*
*/


Measured memory_bytes: 256
def resolve():
    A, B, K = map(int, input().split())
    A_res = A - K
    if A_res >= 0:
        print(A_res, B)
        return
    
    B_res = B + A_res
    if B_res >= 0:
        print(0, B_res)
        return 

    print(0, 0)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
#include <cstdio>
#include <queue>
#include <algorithm>

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

using namespace std;

typedef pair<int, int> P;

const int inf = (int)2e5;

struct E{
	E(int t, int c) :
		t(t), c(c)
	{}

	int t, c;
};

int n, m;
vector<E> g[2][100];
int d[100];

int dijkstra(vector<E>* g, int start, int goal){
	fill(d, d + n, inf);

	priority_queue<P, vector<P>, greater<P> > q;
	d[start] = 0;
	q.push(P(0, start));
	while(!q.empty()){
		P v = q.top();
		q.pop();

		if(v.first > d[v.second]){
			continue;
		}

		rep(i, g[v.second].size()){
			E e = g[v.second][i];
			if(d[e.t] > d[v.second] + e.c){
				d[e.t] = d[v.second] + e.c;
				q.push(P(d[e.t], e.t));
			}
		}
	}

	return d[goal];
}

int main(){
	while(1){
		scanf("%d%d", &m, &n);
		if(n == 0 && m == 0){
			break;
		}

		rep(i, m){
			int a, b, c, d;
			scanf("%d%d%d%d", &a, &b, &c, &d);

			g[0][--a].push_back(E(--b, c));
			g[0][b].push_back(E(a, c));

			g[1][a].push_back(E(b, d));
			g[1][b].push_back(E(a, d));
		}

		int z;
		scanf("%d", &z);
		rep(i, z){
			int t, a, b;
			scanf("%d%d%d", &a, &b, &t);
			printf("%d\n", dijkstra(g[t], a - 1, b - 1));
		}

		rep(i, n){
			g[0][i].clear();
			g[1][i].clear();
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

bool equal(int x, int y, int z)
{
  if(x == y && y == z) return true;
  else return false;
}

int main(){
  int c11, c12, c13;
  int c21, c22, c23;
  int c31, c32, c33;
  cin >> c11 >> c12 >> c13;
  cin >> c21 >> c22 >> c23;
  cin >> c31 >> c32 >> c33;

  bool ok = true;
  if(!equal(c12-c11, c22-c21, c32-c31)) ok = false;
  if(!equal(c12-c13, c22-c23, c32-c33)) ok = false;
  if(!equal(c21-c11, c22-c12, c23-c13)) ok = false;
  if(!equal(c21-c31, c22-c32, c23-c33)) ok = false;
  
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//Prints the Longest common subsequence
void printLCS( char *s1, char *s2, int m, int n )
{
   int L[m+1][n+1];
 
   //Building L[m][n] as in algorithm
   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         L[i][j] = 0;
       else if (s1[i-1] == s2[j-1])
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }
 
   //To print LCS
   int index = L[m][n];
   //charcater array to store LCS
   char LCS[index+1];
   LCS[index] = '\0'; // Set the terminating character
   
   //Stroing characters in LCS
   //Start from the right bottom corner character
   int i = m, j = n;
   while (i > 0 && j > 0)
   {
      //if current character in s1 and s2 are same, then include this character in LCS[]
      if (s1[i-1] == s2[j-1])
      {
          LCS[index-1] = s1[i-1]; // Put current character in result
          i--; j--; index--;     // reduce values of i, j and index
      }
      // compare values of L[i-1][j] and L[i][j-1] and go in direction of greater value.
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }
 
   // Print the LCS
   cout<<LCS<<endl;
}
 
/* Driver program to test above function */
int main()
{
  char s1[3000];
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
  	s1[i]=s[i];
  }
  char s2[3000];
  string ss;
  cin>>ss;
  for(int i=0;i<ss.size();i++){
  	s2[i]=ss[i];
  }
  printLCS(s1, s2, strlen(s1), strlen(s2));
  return 0;
}

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

ll s;

int main(){
    cin >> s;
    ll memo=1e9;
    ll y=(s+memo-1)/memo;
    ll x=y*memo-s;
    cout << 0 << ' ' <<  0 << ' ' << memo << ' ' << 1 << ' ' << x << ' ' << y << endl;
    return 0;
}  


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
int dp[100010];
void rec(int v, const Graph &G, vector<bool> &seen, vector<int> &order) {//recした後にreverseするとトポロジカルソートになる。
    seen[v] = true;
    for (auto next : G[v]) {
        if (seen[next]) continue; // 既に訪問済みなら探索しない
        rec(next, G, seen, order);
    }
    order.push_back(v);
}

int main(){
    int n,m; cin >> n >> m;
    Graph G(n);
    vector<bool> seen(n,0);
    vector<int> order;
    for(int i=0;i<n;++i) dp[i] = 0;
    for(int i=0;i<m;++i){
        int x,y; cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
    }
    for(int v=0;v<n;++v){
        if(seen[v]) continue;
        rec(v,G,seen,order);
    }
    reverse(order.begin(),order.end());//トポロジカルソート

    for(int i=0;i<n;++i){
        int v = order[i];
        for(auto nv : G[v]){
            dp[nv] = max(dp[nv],dp[v]+1);
        }
    }
    int ans = 0;
    for(int v=0;v<n;++v){
        ans = max(ans,dp[v]);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 10236
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

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

typedef long long ll;

const ll INF = ll(1e18) + 1;

void Main()
{
	ll h, a ,ans = 0; cin >> h >> a;
	ans = (h % a == 0) ? h / a : h / a + 1;
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include <numeric>
// #include<string>
#include<vector>
#include <algorithm>
#include <cmath>
// #include <functional>
#include <complex>

using namespace std;

int main()
{
    // Input
    long long int n, k;
    cin >> n >> k;

    if (n < abs(n - k)) {
        cout << n;
    } else {
        // unsigned long long div = ldiv(n, k).quot;
        long long int div = n / k;

        if (abs(n - k * div) < abs(n- k * (div + 1))) {
            cout << abs(n - k * div) << endl;
        } else {
            cout << abs(n - k * (div + 1)) << endl;
        }
        // cout << div << endl;
        // cout << k * (div + 1LL) << endl;
        // cout << n - k * (div + 1LL) << endl;
        // cout << n << endl;
        // cout << n - k * div << endl;
        // cout << abs(n - k * (div + 1LL)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  int i,j,k;
  int v[1000][3];
  int N;
  int temp;

  cin>>N;
  for(i=0;i<N;i++)
    for(j=0;j<3;j++)
      cin>>v[i][j];

  for(i=0;i<N;i++)
    for(j=0;j<2;j++)
      for(k=0;k<2;k++)
	if(v[i][k] > v[i][k+1]){
	  temp = v[i][k];
	  v[i][k] = v[i][k+1];
	  v[i][k+1] = temp;
	}

  for(i=0;i<N;i++)
    if(pow(v[i][0],2) + pow(v[i][1],2) == pow(v[i][2],2))
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;

  return 0;

}

      
  
	  

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    for(int i = 1; i < n; i++){
        for(int j = i + 1; j <= n; j++){
            if(i % 2 != j % 2) cout << 1 << " ";
            else if(i % 4 != j % 4) cout << 2 << " ";
            else if(i % 8 != j % 8) cout << 3 << " ";
            else if(i % 16 != j % 16) cout << 4 << " ";
            else if(i % 32 != j % 32) cout << 5 << " ";
            else if(i % 64 != j % 64) cout << 6 << " ";
            else if(i % 128 != j % 128) cout << 7 << " ";
            else if(i % 256 != j % 256) cout << 8 << " ";
            else if(i % 512 != j % 512)cout << 9 << " ";
        }
        cout << endl;
    }
    return 0;
}

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

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

const long long INF = 1LL << 60;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<long long> h(N);
  for (int i = 0; i < N; i++)
  {
    cin >> h[i];
  }
  long long dp[100010];
  for (int i = 0; i < 100010; i++)
  {
    dp[i] = INF;
  }

  dp[0] = 0;

  for (int i = 1; i < N; i++)
  {
    for (int j = 1; j <= K; j++)
    {
      if (i >= j)
      {
        chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
      }
    }
  }
  cout << dp[N - 1] << endl;
}


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

using namespace std;

int H, W;
string s[30][30];

int main(){
    
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> s[i][j];
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(s[i][j] == "snuke"){
                cout << (char)('A' + j) << i + 1 << endl;
            }
        }
    }

    return 0;
}


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

//MACROS
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef long long LL;
typedef pair <int,int> PII;


int t[1<<20], n, m, cur;
vector <PII> v[1<<20];

void update(int idx, int val) { for (;idx <= m; idx += (idx & -idx)) t[idx] += val; }
int get(int idx) {
    int res = 0;
    for (;idx; idx -= (idx & -idx)) res += t[idx];
    return res;
}


int main() {
	cin >> n >> m;
	rep(i,0,n) {
        int x, y;
        cin >> x >> y;
        v[y-x+1].pb({x,y});
	}

	rep(i,1,m+1) {
	    cur += v[i].size();
        for (auto p : v[i]) update(p.first,1), update(p.second+1,-1);
        int ans = n - cur;
        for (int j = i; j <= m; j += i) ans += get(j);
        cout << ans << "\n";
	}
}


Measured memory_bytes: 31872
import sys

S=input()
K=int(input())
result=0

a=S[0]
renzoku=0
sumInS=0
for s in S:
    if a==s:
        renzoku=renzoku+1
    else:
        sumInS=sumInS+renzoku//2
        renzoku=1
    a=s
sumInS=sumInS+renzoku//2
result = sumInS*K

if S[0]==S[-1]:
    rst=0
    for s in S:
        if s==S[0]:
            rst=rst+1
        else:
            break
    ren=0
    for s in S[::-1]:
        if s==S[-1]:
            ren=ren+1
        else:
            break
    if rst%2==1 and ren%2==1:
        result=result+(K-1)

if renzoku==len(S):
    total=len(S)*K
    result=total//2

print(result)

Measured memory_bytes: 3064
import java.util.* ;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
  int a = scan.nextInt();
    int b =scan.nextInt();
    if(a>8 || b> 8){
      System.out.println(":(") ;
    }else{
      System.out.println("Yay!");
    }
  }
}


Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int x; cin >> x;
  int a = x/100, b = x%100;
  if (5*a >= b) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;
const int MAX_N=1e5;
int divup(int x,int y){
    if(x%y==0)return x/y;
    else return x/y+1;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
typedef pair<int,int>P;

signed main(){
    int H,W,K;cin>>H>>W>>K;
    char maze[H][W];
    int depth[H][W];
    int sx,sy;
    REP(i,H)REP(j,W){
        cin>>maze[i][j];
        if(maze[i][j]=='S'){
            sx=i;sy=j;
        }
    }
    REP(i,H)REP(j,W)depth[i][j]=INF;
    queue<P> q;
    int ans=INF;
    q.push({sx,sy});
    depth[sx][sy]=0;
    while(!q.empty()){
        P t=q.front();q.pop();
        int nx=t.first;
        int ny=t.second;
        chmin(ans,1+divup(min(min(H-1-nx,nx),min(W-1-ny,ny)),K));
        if(depth[nx][ny]==K)continue;
        REP(i,4){
            int x=nx+dx[i];
            int y=ny+dy[i];
            if(x<0||x>=H||y>W||y<0||depth[x][y]!=INF)continue;
            if(maze[x][y]=='#')continue;
            if(x==0||x==H-1||y==0||y==W-1){
                cout<<1<<endl;
                return 0;
            }
            q.push({x,y});  
            depth[x][y]=depth[nx][ny]+1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6016
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	H := getInt()
	W := getInt()
	D := getInt()

	numMap := make(map[int][]int)
	for i := 0; i < H; i++ {
		for j, a := range getIntArray(W) {
			numMap[a] = []int{j, i}
		}
	}

	costs := make([]map[int]int, D)
	for i := 1; i <= D; i++ {
		index := i % D
		costs[index] = make(map[int]int)
		costs[index][index] = 0
		for j := i+D; j <= H*W; j += D {
			costs[index][j] = costs[index][j-D] + abs(numMap[j-D][0] - numMap[j][0]) + abs(numMap[j-D][1] - numMap[j][1])
		}
	}

	Q := getInt()
	for i := 0; i < Q; i++ {
		l := getInt()
		r := getInt()

		lIndex := l % D
		rIndex := r % D

		startCost := costs[lIndex][l]
		endCost := costs[rIndex][r]

		fmt.Println(endCost - startCost)
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntArray(n int) []int {
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = getInt()
	}
	return array
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}


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

int main()
{
	string  word; //string型直接代入できる
	char alp[26] = { 0 }; //a~z
	int result[26] = { 0 }; //0~25
	int n;

	//alpにアルファベット格納する
	for (int i = 97; i <= 122; i++)
	{
		alp[i - 97] = i;
	}


	while (getline(cin, word))// getline:空白が入ってても1行分読み込める
	{
		//入力
		for (int i = 0; i < word.length(); i++)
		{
			if (word[i] >= 'A' && word[i] <= 'Z')
			{
				n = word[i] - 'A';
				result[n]++;
			}
			if (word[i] >= 'a' && word[i] <= 'z')
			{
				n = word[i] - 'a';
				result[n]++;
			}
		}
	}
		//出力
		for (int k = 0; k < 26; k++)
		{
			cout << alp[k] << " " << ":" << " " << result[k] << "\n";
		}

	return 0;

}



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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-d>k||e-c>k||e-b>k||e-a>k) {
    cout <<":(" <<endl;
  }
  else {
    cout << "Yay!" <<endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
using ll = long long;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=int(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1000000007;
using namespace std;

int main() {
    int N, x; cin >> N >> x;
    vector<int> v;
    for(int i=0; i<N; ++i){
        int a; cin >> a;
        v.push_back(a);
    }
    long long ans=0;
    if(v[0]>x){
        ans+=v[0]-x;
        v[0] = x;
    }
    for(int i=0; i<N-1; ++i){
        if(v[i]+v[i+1]>x){
            ans += v[i+1]+v[i]-x;
            v[i+1] = x-v[i];
        }
    }
    cout << ans << endl;
    
    
	return 0;
}

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

int main() {
    int a;
    string s;
    cin >> a;
    cin >> s;

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s=list(input())
cnt=0
for i in range(len(s)-1):
    if s[i]==s[i+1] and s[i]=='0':
        s[i+1]='1'
        cnt+=1
    elif s[i]==s[i+1] and s[i]=='1':
        s[i+1]='0'
        cnt+=1
print(cnt)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
    int n,total = 0;
    cin >> n;
    vec(a,n);
    vec(b,n);
    REP(i,n){
        cin >> a[i] >> b[i];
        
    }
    for(int i = n-1;i >= 0;i--){
        a[i] += total;
        a[i] = a[i]%b[i];
        if(a[i] != 0) total += b[i]-a[i];
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
	int i,time,j;
	for(i=0; i<3; i++){
		time=0;
		scanf("%d",&j);
		time-=j*3600;
		scanf("%d",&j);
		time-=j*60;
		scanf("%d",&j);
		time-=j;
		scanf("%d",&j);
		time+=j*3600;
		scanf("%d",&j);
		time+=j*60;
		scanf("%d",&j);
		time+=j;
		printf("%d %d %d\n",time/3600,(time%3600)/60,time%60);
	}
	return 0;
}

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

int n;
lli arr[50];

int main() {
    lli k=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lld",arr+i);

    bool f=true;
    while(f) {
        f=false;
        
        lli c=0;
        for(int i=0;i<n;i++) if(arr[i]>=n) {
            f=true;
            c+=arr[i]/n;
        }
        for(int i=0;i<n;i++) arr[i]+=(c-arr[i]/n)-(arr[i]/n*n);
        k+=c;
    }
    printf("%lld\n",k);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	int[] a;
	a=new int[100000];
	int k,n,x,t;
	Scanner sc=new Scanner(System.in);
	n=sc.nextInt();
	k=sc.nextInt();
	for(int i=0;i<n;i++) {
		a[i]=sc.nextInt();
	}
	x=(n-1)/(k-1);
	t=(n-1)%(k-1);
	if(t>0)
		x++;
	System.out.println(x);
	}

}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var sb = new StringBuilder();
		var ca = S.ToCharArray();
		var BT = new BIT[26];
		for(int i=0;i<26;i++) BT[i] = new BIT(N + 10);
		for(int i=0;i<N;i++){
			BT[S[i] - 'a'].Add(i + 1, 1);
		}
		
		for(int q=0;q<Q;q++){
			var ss = rsa();
			switch(ss[0][0]){
				case '1': {
					int pos = int.Parse(ss[1]) - 1;
					char c = ss[2][0];
					BT[ca[pos] - 'a'].Add(pos + 1, -1);
					ca[pos] = c;
					BT[ca[pos] - 'a'].Add(pos + 1, 1);
				} break;
				case '2': {
					int l = int.Parse(ss[1]) - 1;
					int r = int.Parse(ss[2]) - 1;
					
					int cnt = 0;
					for(int i=0;i<26;i++){
						int cc = BT[i].Sum(r + 1) - BT[i].Sum(l);
						if(cc == 0) cnt++;
					}
					
					sb.AppendLine((26 - cnt).ToString());
				} break;
			}
		}
		
		Console.Write(sb.ToString());
	}
	int N;
	String S;
	int Q;
	public Sol(){
		N = ri();
		S = rs();
		Q = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class BIT{
	int MM;
	int n;
	int[] bit;
	public BIT(int n_){
		n = n_;
		MM = 1 << 2;
		while(MM < n * 2) MM <<= 1;
		bit = new int[MM + 1];
	}
	//1-origin!!
	public void Add(int i, int x){
		while(i <= n){
			bit[i] += x;
			i += (i&-i);
		}
	}
	
	// i=>sum(a_1,...,a_i)
	// i=0 -> return 0;
	public int Sum(int i){
		int s = 0;
		while(i > 0){
			s += bit[i];
			i -= (i&-i);
		}
		return s;
	}
}


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

int main() {
    int a,b;
    cin>>a>>b;
    if(a<b)
        cout<<"a < b"<<endl;
    if(a>b)
        cout<<"a > b"<<endl;
    if(a==b)
        cout<<"a == b"<<endl;
}



Measured memory_bytes: 3080
#include <stdio.h>

int main(void) {
  int h,w,i,j;
  while(1){
  scanf("%d %d",&h,&w);
  if(h==0&&w==0){
    break;
  }
  for(j=0;j<h;j++){
  for(i=0;i<w;i++){
  printf("#");
  }
  printf("\n");
  }
  printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2124
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


int main(){
	int N;
	ll K;
	cin >> N >> K;
	vector<ll> A(N), F(N);// 計算に使うんでllにします
	for(int i=0; i<N; i++) cin >> A[i];
	for(int i=0; i<N; i++) cin >> F[i];

	sort(A.rbegin(), A.rend());
	sort(F.begin(), F.end());
	ll left = -1, right = 1e12+1;
	while(right - left > 1){
		ll mid = (left+right) / 2;
		bool is_ok = true;
		// ll sumK = 0;
		// for(int i=0; i<N; i++){
		// 	sumK += max(A[i]-mid/F[i], (ll)0);
		// }
		// if(sumK > K) is_ok = false;
		ll tmpK = K;
		for(int i=0; i<N; i++){
			tmpK -= max(A[i] - mid/F[i], (ll)0);
		}
		if(tmpK < 0) is_ok = false;

		
		if(is_ok) right = mid;
		else left = mid;
		// cout << " left: " << left << " mid: " << mid << " right: " << right << endl;
	}
	cout << right << endl;
	return 0;
}



Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,k;
ll a[555];
priority_queue<ll,vector<ll>,greater<ll> >q;
int main()
{
    ll ans=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(int i=0;i<=min(n,k);i++)
        for(int j=0;i+j<=min(n,k);j++)
    {
        for(int h=1,t=1;h<=i;h++,t++)
            q.push(a[t]);
        for(int h=1,t=n;h<=j;h++,t--)
            q.push(a[t]);
        int p=k-i-j;
        while(!q.empty()&&p>0&&q.top()<0)
        {
            q.pop();
            p--;
        }
        ll res=0;
        while(!q.empty())
        {
            res+=q.top();
            q.pop();
        }
        ans=max(ans,res);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
s = input()
l = len(s)

INF = float('inf')
dp = [[INF]*2 for _ in range(l+1)]
dp[0][0]=0
dp[0][1]=1
for i in range(l):
    num = int(s[i])
    dp0 = dp[i][0]
    dp1 = dp[i][1]
    dp[i+1][0] = min(dp0+num, dp1+min(10-num,num+1))
    dp[i+1][1] = min(dp0+num+1,dp1+10-num-1)

print(dp[-1][0])



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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int n,k;
    cin >> n >> k;

    vector<int> v(n);
    int ma = 0;

    rep(i, n){
        cin >> v[i];
        ma = max(ma, v[i]);
    }

    int g = v[0];

    for(int i = 1; i < n; i++){
        g = __gcd(g, v[i]);
    }

    if(k % g == 0 && k <= ma){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }





    return 0;
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

vvi v_set;

void recursive_comb(int s, int rest, vi v) {
  if (rest == 0) {
    // for (int i : v) cout << i << ", ";
    // cout << endl;
    v_set.emplace_back(v);
  } else {
    if (s < 0) return;
    recursive_comb(s - 1, rest, v);
    v[rest - 1] = s;
    recursive_comb(s - 1, rest - 1, v);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k) {
  vi v(k);
  recursive_comb(n - 1, k, v);
}

int ans(int n, int x) {
    int res = 0;
    v_set.clear();
    foreach_comb(n,3);
    for (vi v : v_set) 
    {
        if (accumulate(ALL(v),0) + 3 == x) res ++;
    }

    return res;
}

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

    int n = -1, x = -1;
    while (!(n == 0 and x == 0))
    {
        cin >> n >> x;
        if (n == 0 and x == 0) break;
        assert(n>=0);
        assert(x>=0);
        cout << ans(n, x) << endl;;
    }
    

    return 0;
}



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

ll rec(vector<vector<ll>> &dp, vector<vector<ll>> &arr, ll &p, ll &n, ll &k, ll pickup, ll stno)
{
	if (pickup >= p)
		return 0;
	if (stno >= n)
		return 0;

	ll sumv = 0;

	if (dp[stno][pickup] != -1)
		return dp[stno][pickup];
	ll max_pro = rec(dp, arr, p, n, k, pickup, stno + 1);

	for (int i = 0; i < min(k, p - pickup); i++)
	{
		// cout<<stno<<" "<<i<<endl;
		sumv += arr[stno][i];
		max_pro = max(rec(dp, arr, p, n, k, pickup + i + 1, stno + 1) + sumv, max_pro);
	}

	dp[stno][pickup] = max_pro;
	// cout<<pickup<<" "<<stno<<" "<<max_pro<<endl;
	return max_pro;
}

int main()
{

	ll n, m;
	cin >> n >> m;
	cout << (n * (n - 1) + m * (m - 1)) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<int,int>
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 500005;

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
     ll n,x,y;
     cin >> n >> x >> y;
     ll ans[n];
     memset(ans,0,sizeof(ans));
     for(ll i=1;i<=n;i++)
     {
          for(ll j=i+1;j<=n;j++)
          {
               ll dis = j - i;
               dis = min(dis,abs(i-x) + 1 + abs(j-y));
               ans[dis]++;
          }
     }
     for(ll i=1;i<n;i++)   cout<<ans[i]<<"\n";
}

int main()
{
     FAST;
     int t = 1;
   //  cin >> t;
     while(t--)
     {
          solve();
     }
}

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

int main(){
  long long a, b;
  cin >> a >> b;
  
  set<long long> div;
  if(a > b) swap(a, b);
  for(long long i = 2; i * i <= a; i++){
    if(a % i) continue;
    div.insert(i);
    while(a%i == 0) a /= i;
  }
  div.insert(1);
  div.insert(a);
  long long ans = 0;
  for(auto now : div){
    if(b % now) continue;
    ans++;
  }
      
  cout << ans << endl;
}

Measured memory_bytes: 256