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

typedef double Real;
constexpr Real EPS = 1e-8;

int sign(Real d) {
	if (d>EPS) { return 1; }
	if (d<-EPS) { return -1; }
	return 0;
}

struct Point {
	Real x,y;

	Point(Real x_=0, Real y_=0): x(x_), y(y_) {}

	Point operator+(const Point &p) const {
		return Point(x+p.x,y+p.y);
	}
	Point operator-(const Point &p) const {
		return Point(x-p.x,y-p.y);
	}
	Point operator*(Real s) const {
		return Point(x*s,y*s);
	}
	Point operator/(Real s) const {
		return Point(x/s,y/s);
	}
	Point operator<(const Point &p) const {
		return sign(x - p.x) == -1 || (sign(x - p.x)==0 && sign(y - p.y)==-1);
	}
	Point operator==(const Point &p) const { return sign(x-p.x) == 0 && sign(y - p.y)==0; }
};

struct Line : public array<Point, 2> { //??????
	Line(const Point &a, const Point &b) { at(0) = a; at(1) = b; }
};

struct Segment : public array<Point, 2> { //??´???
	Segment(const Point &a, const Point &b) { at(0) = a; at(1) = b; }
};

struct Circle {
	Point c;
	Real r;
	Circle(const Point &c_, Real r_): c(c_), r(r_) {}
};

typedef vector<Point> Polygon;




//--- solve ---
Point rotate90(const Point &p) { //???????¨???????
	return Point(-p.y,p.x);
}

Point rotate(const Point &p, Real theta) {
	const Real s = sin(theta), c = cos(theta);
	return Point(c*p.x - s*p.y, s*p.x + c*p.y);
}

Real angle(const Point &p) {
	return atan2(p.y, p.x);
}

Real norm(const Point &p) {
	return p.x * p.x + p.y * p.y;
}

Real abs(const Point &p) {
	return sqrt(norm(p));
}

Real dot(const Point &a, const Point &b) { //??????
	return a.x * b.x + a.y * b.y;
}

Real cross(const Point &a, const Point &b) { //??????
	return a.x * b.y - a.y * b.x;
}

int main() {
	int N;

	cin >> N;
	for(int i=0; i<N; i++) {
		int x0,y0,x1,y1,x2,y2,x3,y3;
		Point p[2];
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		p[0].x = x0 - x1;
		p[0].y = y0 - y1;
		p[1].x = x2 - x3;
		p[1].y = y2 - y3;
		
		Real res1 = dot(p[0],p[1]);
		Real res2 = cross(p[0],p[1]);
		//cout << res1 << " " << res2 << endl;
		if (sign(res1) == 0) {
			//?????´
			cout << 1 << endl;
		}
		else if (sign(res2) == 0) {
			//??????
			cout << 2 << endl;
		}
		else {
			//?????????
			cout << 0 << endl;
		}
	}

	return EXIT_SUCCESS;
}

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


namespace ALDS1_3_A_Stack
{
	class Program
	{
		static void Main ( string[] args )
		{
			//input
			string[] inputStr = Console.ReadLine ().Trim ().Split (' ');
			
			//process
			Stack stack = new Stack (inputStr.Length);

			//push
			for (int lp = inputStr.Length - 1; lp >= 0; lp--)
			{
				stack.Push (inputStr[lp]);
			}

			//calculate
			while (true)
			{
				List<string> element = new List<string> (3);

				//????????????
				if (stack.Index <= 1)
				{
					string result = stack.Pop ();
					Console.WriteLine (result);
					return;
				}

				//?¬????????????????????????§??????
				//?°?????????¨???3????????????????????????
				do
				{
					element.Add (stack.Pop ());
				} while (!IsFlag (element[element.Count - 1]));


				//?¬??????????????????????????????´????????°???2??????????±?????¨??????????
				int num = int.Parse (element[element.Count - 3]);
				int num2 = int.Parse (element[element.Count - 2]);
				int calculate = 0;

				switch (element[element.Count - 1])
				{
					case "+": calculate = num + num2; break;
					case "-": calculate = num - num2; break;
					case "*": calculate = num * num2; break;
					case "/": calculate = num / num2; break;
					default:
						Console.WriteLine ("Error"); break;
				}

				//?¨??????????????????¨????¨????????????¨???????????£??????????????¨????????????????????????
				stack.Push (calculate.ToString ());

				for (int index = element.Count - 1 - 3; index >= 0; index--)
				{
					stack.Push (element[index]);
				}
			}
		}

		static bool IsFlag ( string element )
		{
			switch (element)
			{
				case "+":
				case "-":
				case "*":
				case "/": return true;
				default: return false;
			}
		}
	}

	class Stack
	{
		public Stack ( int length )
		{
			Elements = new string[length];
			this.Index = 0;
		}

		private string[] Elements { set; get; }
		public int Index { private set; get; }

		public void Push ( string element )
		{
			this.Elements[Index] = element;
			Index++;
		}
		public string Pop ()
		{
			Index--;
			return Elements[Index];
		}
		public bool IsEmpty ()
		{
			return Index <= 0 ? true : false;
		}
	}
}

Measured memory_bytes: 9280
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	long long int n, m, cha, ans = 0;
	vector<long long int> v;

	cin>> n >> m;
	v.resize(n+1);
	v[0] = 0;
	for (int i = 1;i <= n;i++) {
		cin >> v[i];
		v[i] += v[i - 1];
		v[i] = v[i] % m;
		if (v[i] == 0) ans++;
	}

	sort(v.begin()+1, v.end());

	//for (int i = 1;i < v.size();i++) cout << v[i] << endl;

	cha = 0;
	for (int i = 2;i < v.size();i++) {
		if (v[i] == v[i - 1]) cha++;
		else {
			ans += cha * (cha + 1) / 2;
			cha = 0;
		}
	}
	if (cha > 1) ans += cha * (cha + 1) / 2;

	cout<< ans << endl;


}


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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

vector<bool> ng;
bool check(int k) {
    while (k) {
        if (ng[k % 10]) return false;
        k /= 10;
    }
    return true;
}

void solve(long long N, long long K, std::vector<long long> D) {
    ng = vector<bool>(10);
    rep (i, K) ng[D[i]] = 1;
    loop (i, N, 100000) if (check(i)) {
        cout << i << endl;
        break;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> D(K);
    for (int i = 0; i < K; i++) {
        scanf("%lld", &D[i]);
    }
    solve(N, K, std::move(D));
    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll h;
    cin>>h;
    ll depth = 0;
    ll n = 1e9;
    for(ll i = 0; i<n; i++){
        h = (h/2);
        depth ++;
        if(h < 1)break;
    }
    
    ll step = 1;
    ll total = 1;
    for(ll i = 1; i < depth; i++){
        step *= 2;
        total += step;
    }
    cout<< total << endl;
    return 0;
}



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

int main(){
  int x;
  cin>>x;
  int ans=1;
  for(int i=1;i<x;i++){
    int y=i;
    for(int j=2;j<x;j++){
      y*=i;
      if(y>x)break;
      ans=max(ans,y);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
N,M,L = map(int,input().split())
 
A = [list(map(int,input().split())) for i in range(N)] #N*M配列の取得
B = [list(map(int,input().split())) for i in range(M)] #M*L配列の取得
ANS = [[0]*L for i in range(N)] #N*L
 
 
for x in range(N):
    for y in range(L):
        for z in range(M):
            ANS[x][y] += B[z][y]*A[x][z]
 
for row in range(N):
    print("%d"%ANS[row][0],end = "")
    for col in range(1,L):
        print(" %d"%(ANS[row][col]),end = "")
    print()


Measured memory_bytes: 7072
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
    int n,k;
    char s[11];
    int i;
    scanf("%d",&n);
    // s=(char*)malloc(sizeof(char)*n);
    scanf("%s",s);
    scanf("%d",&k);
    for(i=0;i<n;i++){
        if(s[i]!=s[k-1]){
            s[i]='*';
        }
    }
    printf("%s\n",s);
    return 0;
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		sc.close();

		List<Integer> a = new ArrayList<>();
		a.add(A + B);
		a.add(A - B);
		a.add(A * B);

		out.println(Collections.max(a));

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int l = scanner.nextInt();
		scanner.nextLine();
		String[] lines = new String[n];
		for (int i = 0; i < n; i++) {
			lines[i] = scanner.nextLine();
		}
		Arrays.sort(lines);
		String result = String.join("", lines);
		System.out.println(result);
	}
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
		
			long k = 1;
			int kosuu = 0;
			int count = 0;
			while(true) {
				count++;
				if(count>100000)break;
				
				
				long s = k;
				int kurai = 0;
				while(s/(int)Math.pow(10, kurai)>0) {
					//System.out.println("yea");
					String p = String.valueOf(s);
					if(p.charAt(p.length()-1-kurai)=='4') {
						s+=7*(int)Math.pow(10, kurai);
						
						//System.out.println("ok");
					}
					kurai++;
				}
				k=s;
				//System.out.println(k);

				
				String S = String.valueOf(k);
				int zero=0;int one=0;int two=0;
				char[]u = new char[S.length()];
				for(int i = 0;i<S.length();i++) {
					if(S.charAt(i)=='1') {
						zero++;
						u[i] = '3';
					}
					if(S.charAt(i)=='2') {
						one++;
						u[i]='5';
					}
					if(S.charAt(i)=='3') {
						two++;
						u[i] ='7';
					}
				}
				String an = new String(u);
				long X = Long.valueOf(an);
				
				//System.out.println(X);
				
				
				if(X>N)break;
				
				if(zero>=1&&one>=1&&two>=1) {
					if(N>=X) kosuu++;
				}
				//System.out.println(k);
				
				
				
				k++;
				
				
				
			}
			
			
			
			
			
			System.out.println(kosuu);
			
			
		}
	}
	
	
	
	
	
	
		
	





	
		

}


Measured memory_bytes: 42140
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort()
    t = 0
    for a, b in ab:
        cnt = min(b, m)
        m -= cnt
        t += (cnt * a)
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 56540
// #define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using pll = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; using vb = vector<bool>; using vvb = vector<vb>;
#define rep0(TMS) for (int CNT = 0; CNT < (int)(TMS); CNT++)
#define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++)
#define rep2(CNT, START, GOAL) for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++)
#define rep3(CNT, START, GOAL) for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--)
#define all(CONT) begin(CONT), end(CONT)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
void prec(const int &DIG) { cout << fixed << setprecision(DIG); cerr << fixed << setprecision(DIG); }
template <typename T> void CERR(const T &ELEM) { cerr << ELEM; }
#define dbl(OBJ) cerr << #OBJ << ": "; CERR(OBJ); cerr << "\n"
template <typename T, typename ...Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); }
#define dbs(...) cerr << "(" << #__VA_ARGS__ << "): ("; CERR(__VA_ARGS__); cerr << ")\n"
#define itrep(ITR, CONT) for (auto ITR = begin(CONT); ITR != end(CONT); ITR++)
template <typename T> void CERR(const vector<T> &VEC) { cerr << "{ "; itrep(ITR, VEC) { CERR(*ITR); cerr << ", "; } cerr << "}"; }
#define YN(FLG) cout << (FLG ? "YES" : "NO") << "\n"
#define Yn(FLG) cout << (FLG ? "Yes" : "No") << "\n"
#define yn(FLG) cout << (FLG ? "yes" : "no") << "\n"

// #include <atcoder/all>

// using namespace atcoder;

// const ll INF = LONG_LONG_MAX;
const int INF = INT_MAX;
// const ll MOD = 1000000007; // 998244353;

// const vi dx = { 1, 1, 0, -1, -1, -1, 0, 1, };
// const vi dy = { 0, 1, 1, 1, 0, -1, -1, -1, };

int main() {
	// 座標は1-ind
	ll H, W; int N; cin >> H >> W >> N;
	vector<vector<set<pii>>> s(3, vector<set<pii>>(3));
	// s[i][j]に((x,y))が含まれる->(x-1+i,y-1+j)に点がある
	rep(i, N) {
		int a, b; cin >> a >> b;
		rep(i, 3) rep(j, 3) s[i][j].insert(pii(a + 1 - i, b + 1 - j));
		// dbs(a, b);
		rep(i, 3) rep(j, 3) {
			// dbs(i, j);
			// for (auto p : s[i][j]) { dbs(p.first, p.second); }
		}
	}
	map<pii, int> m;
	// mに((x,y),k)が含まれる->(x,y)を中心とする3x3にk個の点がある
	// 1<x<H,1<y<W の制約は後で考慮
	rep(i, 3) rep(j, 3) for (pii p : s[i][j]) {
		auto[x, y] = p;
		// if (x <= 1 or H - 1 <= x or y <= 1 or W - 1 <= y) continue;
		m[p]++;
	}
	// for (auto t : m) {
	// 	auto [q, k] = t;
	// 	dbs(q.first, q.second);
	// 	dbl(k);
	// }

	vl ans(10); ans[0] = max(W - 2, 0LL) * max(H - 2, 0LL);
	for (auto t : m) {
		auto [q, k] = t;
		auto [x, y] = q;
		if (x <= 1 or H <= x or y <= 1 or W <= y) continue;
		ans[k]++;
		ans[0]--;
		// dbl(ans);
	}
	rep(i, 10) cout << ans[i] << endl;
}

Measured memory_bytes: 102072
#include <bits/stdc++.h>
#define int long long

using namespace std;

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

    int n, ac = 0, tle = 0, wa = 0, re = 0;
    cin >> n;
    string res;
    while(n--) {
        cin >> res;
        if(res ==  "AC") ac++;
        else if(res == "WA") wa++;
        else if(res == "TLE") tle++;
        else if(res == "RE")  re++;
    }
    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";;
    cout << "TLE x " << tle << "\n";;
    cout << "RE x " << re << "\n";;


    return 0;

}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  uint64_t a,b,x;
  cin >> a >> b >> x;
  
  uint64_t res = 0LL;
  if(a != 0) a--;
  else res++;
  res += b/x - a/x;
  
  printf("%lld\n", res);
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  in3(a, b, c);
  out(max(0ll, c - (a - b)));
  memi;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<queue>
#include<vector>
#define LL long long
#define ULL unsigned long long
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define itn int
#define pritnf printf
#define mp make_pair
#define pb push_back
using namespace std;

int n,k;
bool ban[10];

bool divide(int n){
	while(n){
		if (ban[n%10]) return 0;
		n/=10;
	}
	return 1;
}

int main(){
	cin>>n>>k;
	For(i,1,k){
		int temp;scanf("%d",&temp);
		ban[temp]=1;
	}
	For(i,n,1000000){
		if (divide(i)){printf("%d",i);break;}
	}
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
n = int(input())
ls_odd = [i for i in range(1,n+1,2)]
cnt = 0
for odd in ls_odd:
    ls_div = [odd % (i+1) == 0 for i in range(odd)]
    if sum(ls_div) == 8:
        cnt += 1
print (cnt)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
#define ll long long
using namespace std;
int main(){
	nes;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	//if(a==0&&b==0||c==0&&d==0) cout<<0;
	//else if(a>0&&b>0&&c>0&&d>0) cout<<max(a,b)*max(c,d);
	//else if()
	cout<<max({a*c,a*d,b*c,b*d});
	return 0;
}

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

int main(){
  
  int a,b,c;
  cin >> a >> b >> c;
  if((a==b && b!=c)||(b==c && a != b) || (a==c && a !=b)){
    cout << "Yes" << endl;
  }
  
    
  
  else{
    cout << "No" << endl;
    
  }
}

Measured memory_bytes: 256
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    x, y = il()
    p1 = [1, 3, 5, 7, 8, 10, 12]
    p2 = [4, 6, 9, 11]
    p3 = [2]
    print('Yes' if x in p1 and y in p1 or x in p2 and y in p2 or x in p3 and y in p3 else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    int64_t x;
    cin>>x;
    int64_t money=100;
    int year = 0;
    while(money<x){
        money *= 1.01;
        year++;
    }
    cout<<year<<endl;
}

Measured memory_bytes: 3612
//Deep Godhani
//DAIICT

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

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x,d) cout << fixed << setprecision(d) << x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

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

const ll M = 1e9+7;
const ll L = 1e18;

void solve()
{
  ll n;
  cin >> n;
  ll a[n];
  ll f = 0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i] == 0){
      f = 1;
    }
  }
  if(f == 1){
    cout << 0 << endl;
    return;
  }
  //cout << L << endl;
  ll ans = 1;
  for(int i=0;i<n;i++){
    //cout << ans << " ";
    if(ans!=0 && a[i] > L/ans){
      cout << -1 << endl;
      return;
    }
    else{
      ans = ans*a[i];
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 4440
#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 STLL(s) strtoll(s.c_str(), NULL, 10)
#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;
#define endl '\n';
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;


int main() {
    
    string n;
    cin>>n;
    vector<vector<vector<bool> > > dp(30,vector<vector<bool> >(2,vector<bool>(1010,false)));
    dp[0][0][0]=1;
    for(int i=0;i<n.size();i++){
        rep(y,2){
            for(int j=0;j<10;j++){
                for(int k=0;k<1010;k++){
                    int ni=i+1;
                    int ny=y;
                    int nk=k+j;
                    if(!y&&j>n[i]-'0'){
                        continue;
                    } else if(!y&&j<n[i]-'0'){
                        ny=1;
                    }
                    if(!dp[i][y][k])continue;
                    dp[ni][ny][nk] = dp[ni][ny][nk] | dp[i][y][k];
                }
            }
        }
    }
    int ans=0;
    rep(i,1010)rep(j,2)chmax(ans,(dp[n.size()][j][i]?i:0));
    fin(ans);
    // rep(i,7){
    //     rep(k,2){
    //         cout<<dp[i][k]<<" ";
    //     }
    //     cout<<endl;
    // }
}


Measured memory_bytes: 384
#include<iostream>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define MOD 1000000007
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }



int main() {
  string s; cin >>s;
  int n=s.size(); 
  if(s[n-1]=='s') s.push_back('e');
  s.push_back('s');
  print(s);
}


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

string s[1005];

int dist[1005][1005],dx[]={0,0,-1,1},dy[]={-1,1,0,0};
int h,w;

int ok(int x,int y){
    if(x>=h || y>=w || x<0 || y<0 || s[x][y]=='#')
    return 0;
    return 1;
}

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

   
   cin>>h>>w;

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

   queue<pair<int,pair<int,int> > >q;
   for (int i=0;i<h;i++){
       for (int j=0;j<w;j++){
           dist[i][j]=1e8;
           if(s[i][j]=='#'){
               q.push(make_pair(0,make_pair(i,j)));
           }
       }
   }

   while (!q.empty()){
       pair<int,pair<int,int> >p=q.front();
       q.pop();
       int dd=p.first;
       int x=p.second.first;
       int y=p.second.second;

       if(dd>=dist[x][y]){
           continue;
       }
       dist[x][y]=dd;

       for (int i=0;i<4;i++){
           int xx=x+dx[i];
           int yy=y+dy[i];
           if(ok(xx,yy) && dist[xx][yy]>(dd+1)){
               q.push(make_pair(dd+1,make_pair(xx,yy)));
           }
       }
   }

   int maxi=0;
   for (int i=0;i<h;i++){
       for (int j=0;j<w;j++){
           maxi=max(maxi,dist[i][j]);
       }
   }
   cout<<maxi;
}


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

int main() {
  int64_t N,K;
  cin >> N >> K;
  int64_t x = N%K;
  if(x==0){
    cout << 0;
  }
   else if(x <= K/2){
      cout << x;
   }
   else{
     cout << K-x;
   }
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n){
    string s;
    cin >> s;

    rep(i,n){
//       cout << s << endl;
      ll cnt = 0;
      char c = s[0];
      string s2 = "";
      rep(j,s.size()){
        if(c == s[j]){
          ++cnt;
        }
        else{
          s2 += to_string(cnt) ;
          s2 += c;
          c = s[j];
          cnt = 1;
        }
      }
      s2 += to_string(cnt) ;
      s2 += c;
      s = s2;
    }
    cout << s << endl;
  }
  return 0;
}

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

typedef long long ll;

int R, S, P;

ll getPoint(char c){
    if (c == 'r') return (ll)P;
    else if (c == 's') return (ll)R;
    else return (ll)S;
}

int main() {
    int N, K;
    cin >> N >> K;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    ll ans = 0;
    for (int i=0;i<K;i++){
        vector<char> sub;
        for (int j=i;j<N;j+=K){
            sub.push_back(T[j]); 
        }
        //前から貪欲法
        ll sum = getPoint(sub[0]);
        bool win = true; //前のターンで勝ったか
        for (int j=0;j<sub.size()-1;j++){
            if (win && sub[j] == sub[j+1]) {
                win = false;
                continue;
            }else{
                win = true;
                sum += getPoint(sub[j+1]);
            }
        }
        ans += sum;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define FR(i,a,b) for(int i = (a);i<(b);i++)
#define RF(i,a,b) for(int i = (a);i>(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 51
#define INF 100000000000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-14
using namespace std;
inline int Max(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^b;
}
inline int Min(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^a;
}

int a[N],b[N];
int main()
{
    int n;
    while(cin>>n)
    {
        FOR(i,1,n)
        {
            char c;
            cin>>c;
            a[i] = (c == 'x');
        }
        int f = 0;
        FOR(i,0,1)
        {
            FOR(j,0,1)
            {
                b[1] = i;
                b[2] = j;
                FOR(k,3,n)
                {
                    int f = a[k-1]^b[k-1];
                    if(f == 0)b[k] = b[k-2];
                    else b[k] = 1-b[k-2];
                }
                if((a[n]^b[n] == 0&&b[n-1] == b[1])||(a[n]^b[n] == 1&&b[n-1] != b[1]))
                {
                    if((a[1]^b[1] == 0&&b[n] == b[2])||(a[1]^b[1] == 1&&b[n] != b[2]))
                    {
                        f = 1;
                        FOR(k,1,n)
                        {
                            if(b[k] == 0)cout<<"S";
                            else cout<<"W";
                        }
                        cout<<endl;
                        break;
                    }
                }
            }
            if(f)break;
        }
        if(!f)cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s.at(5) == '0' && s.at(6) > 52) {
		cout << "TBD" << endl;
	}
	else if (s.at(5) == '1') {
		cout << "TBD" << endl;
	}
	else if (s.at(5) == '0' && s.at(6) <= 52) {
		cout << "Heisei" << endl;
	}
}


Measured memory_bytes: 256
/// Updated! https://www.youtube.com/watch?v=U07_n9xGIlM
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int maxn = 2e5+100;

const ll inf = 1e18;

int main()
{
    ll n , m;
    ll sum = 0; cin >> n >> m;
    for(int i = 1; i<=m; i++){
        ll k; cin >> k; sum += k;
    }
    if(sum >= n)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
/*



*/



Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int f;
	f=false;
	int len=s.size();
	int i;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			f=true;
		}
		if(f&&s[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
# include <iostream>

int n;
int sum = 0;

int main() {
	while (1) {
		sum = 0;
		int a;
		std::cin >> n;
		if (n == 0)
			break;
		for (int i = 0; i < n / 4; ++i) {
			std::cin >> a;
			sum += a * 4;
		}
		std::cout << sum/4 << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
  int n;
  static int t[200002];
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> t[i];
    }

    int ans = 0;
    int now = 1;
    for (int i = 0; i < n; i++) {
      if (now == t[i]) {
        now++;
        continue;
      }
      ans++;
    }
    
    if (now == 1) {
      cout << -1 << endl;
    } else {
      cout << ans << endl;
    }
  }
}


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

int main()
{
    long long  int x,y,l1,l2;
    string s1="",s2="";
    cin>>x>>y;
    char a= x+48;
    char b= y+48;
    for(long long i=0; i<y; i++)
    {
        s1=s1+a;
    }
    for(long long i=0; i<x; i++)
    {
        s2=s2+b;
    }

    if(s1==s2)
        cout<<s1<<endl;
    else if(s1<s2)
        cout<<s1<<endl;
    else
        cout<<s2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define PUT(a, n) FOR(i, n) cin >> a[i]
#define OUT(a, n) FOR(i, n) cout << a[i] << ' '

using namespace std;

const int N = 1e5 + 5;

int main() {
	fast;
    int n; cin >> n;
    string s; cin >> s;
    int k; cin >> k;
    char a = s[k - 1];
    FOR(i, n, 0)
    {
        if(s[i] != a)
        {
            s[i] = '*';
        }
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
/*
auhtor:hbohra98
chandigarh univeristy
*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define VP vector < pair < ll , ll > >
#define VI vector< ll >
#define VS vector< string >
#define mk make_pair


using namespace std;
int main(){

 ll n,d;cin>>n>>d;
 ll io=2*d+1;

 cout<<ceil((double)n/io);


}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int A, B; cin >> A >> B;
    cout << A*B << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7760
#include <bits/stdc++.h>
using namespace std;
vector<int> ruiseki(300000,0);
vector<bool> isPrime(300000,true);
void Eratosthenes(){
    isPrime[0] = false; isPrime[1] = false;
    for(int i=2;i<sqrt(300000);i++){
        if(isPrime[i]){
            for(int j=i*2;j<300000;j+=i){
                isPrime[j] = false;
            }
        }
    }
}
int main(){
    Eratosthenes();
    for(int i=0;i<300000;i++){
        if(isPrime[i]) ruiseki[i]++;
    }
    for(int i=1;i<300000;i++){
        ruiseki[i] = ruiseki[i]+ruiseki[i-1];
    }
    while(1){
        int N;
        cin >> N;
        if(N==0) return 0;
        cout << ruiseki[N*2] - ruiseki[N] << endl;
    }
}


Measured memory_bytes: 3964
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int N; cin >> N;
    map <string,int> M;
    vector <string> S(N);
    rep(i,N) cin >> S[i];
    sort(S.begin(),S.end());
    
    int ans=0;
    rep(i,N){
        M[S[i]]++;
        ans=max(ans,M[S[i]]);
    }
    
    rep(i,N){
        if (ans==M[S[i]]) cout << S[i] << endl;
        M[S[i]]=0;
    }
}

Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn = 1e18;
typedef pair<ll,ll> pii;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)

ll n,m;
ll a[6],d;
map<ll,ll> f;
map<ll,int> g;

queue<ll> q1;

void solve(){
   f.clear(); g.clear();
   
   scanf("%lld",&n);
   scanf("%lld%lld%lld%lld",&a[2],&a[3],&a[5],&d);
   ll x2,x3,x5;
   x2 = 1;
   fr(i,0,60){
      x3 = 1;
      fr(j,0,40){
         x5 = 1;
         fr(k,0,30){
            if(n/x2/x3/x5 < 1)continue ;
            g[n/x2/x3/x5] = 1;
            g[n/x2/x3/x5+1] = 1;
            x5 *= 5;
         }
         x3 *= 3;
      }
      x2 *= 2;
   }
   g[0] = g[1] = 1;

   f[n] = 0;
   q1.push(n);
   while(!q1.empty()){
      ll curpos = q1.front(); q1.pop();
      for(ll i = 2;i <= 5; ++i){
         if(i == 4)continue ;
         ll np1 = curpos/i,np2 = curpos/i+1;
         if(g.find(np1) != g.end()){
            if(f.find(np1) == f.end() ||
                  f[np1] > f[curpos]+a[i]+d*(curpos-np1*i)){
               f[np1] = f[curpos]+a[i]+d*(curpos-np1*i);
               q1.push(np1);
            }
         }
         if(g.find(np2) != g.end()){
            if(f.find(np2) == f.end() ||
                  f[np2] > f[curpos]+a[i]+d*(np2*i-curpos)){
               f[np2] = f[curpos]+a[i]+d*(np2*i-curpos);
               q1.push(np2);
            }
         }
      }
   }

   ll ans = 0x3f3f3f3f3f3f3f3f;
   for(map<ll,ll>::iterator i = f.begin();i != f.end(); ++i){
      if(i->first > ans/d)break;
      ans = min(ans,i->second+(i->first)*d);
   }
   printf("%lld\n",ans);
   return ;
}

int main(){
   int t; scanf("%d",&t);
   while(t--)solve();
   return 0;
}


Measured memory_bytes: 5436
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
    int q=0;char ch=' ';
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
    return q;
}
typedef long long LL;
const int N=200005,inf=0x3f3f3f3f;
int h[N],ne[N<<1],to[N<<1],mx[N],se[N],d[N],sz[N];
int n,tot;LL ans;char S[N];

void add(int x,int y) {to[++tot]=y,ne[tot]=h[x],h[x]=tot;}
void dfs1(int x,int las) {
    if(S[x]=='1') d[x]=0,sz[x]=1;
    else d[x]=inf;
    for(RI i=h[x];i;i=ne[i]) {
        if(to[i]==las) continue;
        int y=to[i];dfs1(y,x),sz[x]+=sz[y];
        if(mx[y]+1>mx[x]) se[x]=mx[x],mx[x]=mx[y]+1;
        else if(mx[y]+1>se[x]) se[x]=mx[y]+1;
        if(sz[y]) d[x]=min(d[x],mx[y]+1);
    }
}
void dfs2(int x,int las) {
    int R=min(se[x]+1,mx[x]-1);
    if(d[x]<=R) ans+=(LL)(R-d[x]+1);
    for(RI i=h[x];i;i=ne[i]) {
        if(to[i]==las) continue;
        int y=to[i],kl=(mx[y]+1==mx[x]?se[x]+1:mx[x]+1);
        if(kl>mx[y]) se[y]=mx[y],mx[y]=kl;
        else if(kl>se[y]) se[y]=kl;
        if(sz[1]-sz[y]) d[y]=min(d[y],kl);
        dfs2(y,x);
    }
}
int main()
{
    int x,y;
    n=read();
    for(RI i=1;i<n;++i) x=read(),y=read(),add(x,y),add(y,x);
    scanf("%s",S+1);
    dfs1(1,0),dfs2(1,0);
    printf("%lld\n",ans+1);
    return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{ return firstElof.second < secondElof.second; }
//**Snippetリスト**//
//rep, vin, all//
//gcdlcm, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; 
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color; vll path; vl D;
//***********//
int main() {
	cin >> H >> W >> K;
	vector<string> S(H);
	vll P(H, vl(W, 0));
	for (i = 0; i < H; i++) {
		cin >> S[i];
		for (j = 0; j < W; j++) {
			P[i][j] = ctoi(S[i][j]);
		}
	}
	//1で切らない
	for (k = 0; k < pow(2,H-1); k++) {
		ll pre = 0;
		vll Q = P;
		ll p = k;
		for (l = 0; l < H-1; l++) {
			if (p % 2 == 1) {
				pre++;
				for (j = 0; j < W; j++) {
					Q[l + 1][j] += Q[l][j];
					Q[l][j] = 0;
				}
			}
			p /= 2;
		}
		ll check = 1;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				//cout << Q[i][j];
				if (Q[i][j] > K) {
					check = 0;
				}
			}
			//cout << endl;
		}
		if (!check)continue;
		//cout << endl;
		ll pre2 = 0;
		vll Q2 = Q;
		for (l = 0; l < W - 1; l++) {
			ll can = 1;
			for (i = 0; i < H; i++) {
				if(Q[i][l] + Q[i][l + 1] > K){
					can = 0;
					break;
				}
			}
			if (can == 1) {
				pre2++;
				for (i = 0; i < H; i++) {
					Q[i][l + 1] += Q[i][l];
					Q[i][l] = 0;
				}
			}
		}
		ll pre3 = 0;
		for (l = W-1; l >= 1; l--) {
			ll can = 1;
			for (i = 0; i < H; i++) {
				if (Q2[i][l] + Q2[i][l - 1] > K) {
					can = 0;
					break;
				}
			}
			if (can == 1) {
				pre3++;
				for (i = 0; i < H; i++) {
					Q2[i][l - 1] += Q2[i][l];
					Q2[i][l] = 0;
				}
			}
		}
		//cout << pre2 << pre3 << endl;
		pre += max(pre2, pre3);
		ans = max(pre, ans);
	}
	cout <<(H - 1) + (W - 1) - ans;
}


Measured memory_bytes: 548
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val n = readInt()

    val a = readLongs()

    val ai = a.mapIndexed { index, i -> index.toLong() - i }
        //.onEach { println(it) }
        .groupingBy { it }.eachCount()
    //println(ai)

    println((0 until n - 1).asSequence().map { x ->
//        (x + 1..n).count { y ->
//            (y - x) == a[y - 1] + a[x - 1]
//            (- x) == a[y - 1] - y + a[x - 1]
//            - a[x - 1] - x == a[y - 1] - y
//            a[x - 1] + x == y - a[y - 1]
//        }.toLong()
        ai[a[x] + x.toLong()] ?: 0
    }.map { it.toLong() }.sum())
}




Measured memory_bytes: 90844
#include <cstdio>
#include <cstring>
#include <set>
#define f first
#define s second
#define par pair<int,int>
using namespace std;

typedef long long llint;
const int MAXN = 100005;

int h, w, n, x,y;
llint ans[10];
bool around[5][5];

set < pair<int,int> > s;

bool check(int x, int y) {
  return x < 0 || x >= h || y < 0 || y >= w;
}

void count(int x, int y) {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      int cnt = 0;
      bool flag = 1;
      for (int ii = 0; ii < 3; ++ii)
        for (int jj = 0; jj < 3; ++jj) {
          if (check(x+i-2+ii, y+j-2+jj)) {
            flag = 0;
          }
          cnt += around[i+ii][j+jj];
        }
      if(flag) {
        ans[cnt]++;
      }
    }
  }
}

void print() {
  for (int i = 0; i < 5; ++i) {
    for (int j = 0; j < 5; ++j)
      printf("%d", around[i][j]);
    printf("\n");
  }
}

int main() {
  scanf("%d%d%d", &h, &w, &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &x, &y); x--; y--;
    s.emplace(x, y);
  }
  for (auto it = s.begin(); it != s.end(); it++) {
    memset(around, 0, sizeof around);
    for (int ii = -2; ii < 3; ++ii) {
      for (int jj = -2; jj < 3; ++jj) {
        if (s.find(par(it->f+ii, it->s+jj)) != s.end()) {
          around[ii+2][jj+2] = 1;
        }
      }
    }
    count(it->f, it->s);
  }
  ans[0] += (llint)(h-2) * (w-2);
  for (int i = 1; i < 10; ++i) {
    ans[i] /= i;
    ans[0] -= ans[i];
  }
  for (int i = 0; i < 10; ++i)
    printf("%lld\n", ans[i]);
  return 0;
}



Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  int sum = 0;
  int N,K;
  cin >> N >> K;
  
  vector<int> data(N);
  REP(i,N) cin >> data.at(i);
  
  sort(ALL(data));
  
  REP(i,K) sum += data.at(i);
  
  cout << sum << endl;
}

Measured memory_bytes: 3660
s = list(input())

flag_N,flag_E,flag_W,flag_S = 0,0,0,0

if "N" in s:
    flag_N = 1
if "E" in s:
    flag_E = 1
if "W" in s:
    flag_W = 1
if "S" in s:
    flag_S = 1

if ((flag_N == 1 and flag_S == 0) or (flag_N == 0 and flag_S == 1)
    or (flag_E == 1 and flag_W ==0) or (flag_E == 0 and flag_W == 1)):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ll a;
    cin >> a;
    string b;
    cin>>b;
    ll c=(ll)(b[0]-'0')*100+(ll)(b[2]-'0')*10+(ll)(b[3]-'0');
    cout<<a*c/100<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string s; cin >> s;
	cout << s.substr(0,s.length()-8);
}

// read!
// ll vs. int!

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

using namespace std;

int main(){

  int n;

  cin >> n;

  vector<int> a(n);
  vector<int> b(n);
  vector<int> num(1000000,0);
  int min = 1000000;
  
  for(int i = 0;i < n;++i){
	cin >> a[i] >> b[i];
	if(min > a[i])
	  min = a[i];
	for(int j = a[i];j <= b[i];++j)
	  num[j]++;
  }

  int max_fri = 0;
  
  for(int i = min;i <= n + 1;++i){
	for(int j = 0;j < n;++j){
	  if(i <= num[i] + 1 & max_fri < i - 1)
		max_fri = i - 1;
	}
  }
  
  cout << max_fri << endl;
  
}



Measured memory_bytes: 7504
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int n;
	cin>>n;
	int res=1;
	rb(i,1,3)  res*=n;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll ans=0;
    ll N,M;
    cin >> N >> M;
    vector<pair<int,int>> v;
    rep(i,N) {
        int a,b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(rbegin(v), rend(v));
    priority_queue<int> q;
    for (int d=M-1; d>=0; --d) {
        while (!v.empty() && (d + v.back().first <= M)) {
            q.push(v.back().second);
            v.pop_back();
        }
        if (q.empty())
            continue;
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 4776