akhauriyash/Code-Regression huggingface dataset:
package main

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

var arr []int = []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
var K int

func main() {
	readVariables()
	fmt.Println(arr[K-1])
}

func readVariables() {
	K = nextInt()
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
 
using namespace std;
typedef long long ll;

int main()
{
	ll H,W;
	scanf("%lld %lld", &H, &W);
	
	ll ans = W % 2 == 0 ? H * (W/2) : H * (W/2) + (H % 2 == 0 ? H/2 : H/2 + 1);
	if( H == 1 || W == 1){
		ans = 1;
	}
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	int ans = 1 << 30;
	for (int x = -100; x <= 100; x++) {
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += (x - a[i])*(x - a[i]);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}


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

int main()
{
	int a;
	cin >> a;
	a%=10;
    if(a==2 || a==4 || a==5 || a==7 || a==9){cout << "hon";}
    if(a==0 || a==1 || a==6 || a==8){cout << "pon";}
    if(a==3){cout << "bon";}



}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
  int N;
  int ans = 0;
  scanf("%d",&N);
  int data[N];
  for(int i=0;i<N;i++){
    scanf("%d",&data[i]);
  }
  int cnt = 1;
  for(int i=0;i<N-1;i++){
    if(data[i] == data[i+1]){
      cnt += 1;
    }else{
      ans += cnt / 2;
      cnt = 1;
    }
  }

  if(cnt >= 2){
    printf("%d\n",ans + (cnt / 2));
  }else{
    printf("%d\n",ans);
  }
  return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;

int n;
int cost[1000010],src[10010],dst[10010];
int a[110][110];
int P[10010];
int M;
class edges{
public:
    int x;
    int y;
    int costs;
}edges[1000010];
bool comp(class edges a,class edges b)
{
    return a.costs<b.costs;
}
void init(int N) {
    for (int i=1; i<=N; ++i)
        P[i] = i;
}

int root(int a) {
    if (P[a] == a)
        return a;
    return (P[a] = root(P[a]));
}

bool same(int a, int b) {
    return root(a) == root(b);
}

void unite(int a, int b) {
    P[root(a)] = root(b);
}

void inits(){
    for(int r=0;r<n;r++){
        for(int c=r+1;c<n;c++){
            if(a[r][c]>-1){
                cost[M]=a[r][c];
                src[M]=r;
                dst[M]=c;
                M++;
            }
        }
    }
    for(int i=0;i<M;i++){
        edges[i].x=src[i];
        edges[i].y=dst[i];
        edges[i].costs=cost[i];
}
    sort(edges,edges+M,comp);
}
int solve()
{
    int sum=0;
    for(int i=0;i<M;i++){
        if(same(edges[i].x,edges[i].y))
            continue;
        unite(edges[i].x,edges[i].y);
        sum+=edges[i].costs;
    }
    return sum;
}

int main(){
    cin>>n;
    init(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
        cin>>a[i][j];
    }
    inits();
    cout<<solve()<<endl;
    return 0;
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


void naive(const string& S){
  map<string, int> memo;
  int n = S.size();

  rep(i,n){
    for(int len=1; i+len<=n; len++){
      string rev = S.substr(i,len);
      reverse(ALLOF(rev));
      string tmp = S.substr(0,i) + rev + S.substr(i+len);
      memo[tmp]++;
    }
  }

  FOR(it,memo){
    cout << it->first << " " << it->second << endl;
  }
  cout << memo.size() << endl;
}

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

  //naive(S);
  
  ll ret = (n * (ll)(n-1) / 2LL) + 1;

  //cout << ret << endl;

  vector<int> v(30);
  rep(i,S.size()){
    v[S[i]-'a']++;
  }

  rep(i,26){
    //cout << (char)('a'+i) << " " << v[i] << endl;
    ll x = v[i]-1;
    ll y = x * (x+1) / 2LL;
    ret -= y;
  }
  
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;


int main() {
    string s;
    cin >> s;
    cout << "ABC" << s << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define LL long long
int N;
LL A[200010];

bool judge(LL x){
    for(int s = 1; s <= N; s++){//始点
        int itr1 = lower_bound(A + s, A + s + N, x + A[s]) - A;
        int itr2 = lower_bound(A + itr1, A + s + N, x + A[itr1]) - A;
        if(A[s + N] - A[itr2] >= x) return true;
    }
    return false;
}

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
        A[i + N] = A[i];
    }
    for(int i = 1; i <= N * 2; i++){
        A[i] += A[i - 1];
    }
    LL lb = 0;
    LL ub = A[N - 1];
    while(ub - lb > 1){
        LL mid = (ub + lb) / 2;
        if(judge(mid)){
            lb = mid;
        }else{
            ub = mid;
        }
    }
    cout << lb << endl;
    return 0;
}


Measured memory_bytes: 4680
#include <iostream>

using namespace std;

int Q;
bool prime[100005];
int sum[100005];

int main(void)
{
	prime[1] = true;
	for(int i = 2; i <= 1005; i++){
		if(!prime[i]){
			for(int j = 2*i; j < 100005; j += i){
				prime[j] = true;
			}
		}
	}
	
	for(int i = 1; i < 100005; i++){
		sum[i] = sum[i-1] + (!prime[i] && !prime[(i+1)/2]);
	}
	
	cin >> Q;
	for(int q = 0; q < Q; q++){
		int l, r;
		cin >> l >> r;
		cout << sum[r] - sum[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

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

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, X;
	cin >> n >> X;
	vector<int> cities(n);
	vector<int> diffs(n);
	for (int i = 0; i < n; ++i) {
		cin >> cities[i];
		diffs[i] = abs(X - cities[i]);
	}

	int D = diffs[0];
	for (int i = 1; i < n; ++i) {
		D = gcd(D, diffs[i]);
	}

	cout << D << "\n";

	return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long a[n],ans=0-n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		ans+=a[i];
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
    
N,Q=map(int,input().split())
uf = UnionFind(N)
for i in range(Q):
  t,u,v=map(int,input().split())
  if t:
    print(int(uf.same(u,v)))
  else:
    uf.unite(u,v)

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    string S;
    cin >> S;

    ll n = S.size()-1;
    ll ans = 0;
    for (ll bit = 0; bit < (1<<n); bit++) {
        ll num = S[0]-'0';
        for (ll i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                ans += num;
                num = 0;
            }
            num = num*10+S[i+1]-'0';
        }
        ans += num;
    }

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

Measured memory_bytes: 256
/* Written by Filip Hlasek 2016 */
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstring>

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,b) for(int i=0;i<(b);i++)

using namespace std;

#define MAXN 2222
vector<int> graph[MAXN];

int dfs(int v, int f, int k) {
  if (k == 0) return 0;
  int ans = 1;
  REP(i, graph[v].size()) if (graph[v][i] != f) {
    ans += dfs(graph[v][i], v, k - 1);
  }
  return ans;
}

int main(int argc, char *argv[]) {
  int N, K;
  scanf("%d%d", &N, &K);
  REP(i, N - 1) {
    int a, b;
    scanf("%d%d", &a, &b); a--; b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int ans = 0;
  REP(i, N) {
    int best_diff = 0, total = 1;
    REP(j, graph[i].size()) {
      int tmp1 = dfs(graph[i][j], i, K / 2);
      int tmp2 = dfs(graph[i][j], i, (K + 1) / 2);
      total += tmp1;
      best_diff = max(best_diff, tmp2 - tmp1);
    }
    ans = max(ans, total + best_diff);
  }
  printf("%d\n", N - ans);
  return 0;
}

Measured memory_bytes: 384
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long H, W;
    scan(H, W);
    auto S = new string[](H);
    foreach (i; 0 .. H)
        S[i] = sread();
    foreach (y; 0 .. H)
        foreach (x; 0 .. W)
            if (S[y][x] == '#')
            {
                bool u = (0 < y) ? S[y - 1][x] == '#' : false;
                bool d = (y + 1 < H) ? S[y + 1][x] == '#' : false;
                bool l = (0 < x) ? S[y][x - 1] == '#' : false;
                bool r = (x + 1 < W) ? S[y][x + 1] == '#' : false;
                if (!(u || d || l || r))
                {
                    writeln("No");
                    return;
                }
            }
    writeln("Yes");
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int a, b;
  cin >> a >> b;
  if ((a * b) % 2) cout << "Odd" << '\n';
  else cout << "Even" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


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

class Col
{
public:
  int R,G,B;
  Col():R(0),G(0),B(0){}
  Col(int R,int G,int B):R(R),G(G),B(B){}
};

int _16to10(string s)
{
  int a[2];
  for(int i=0;i<2;i++)
    {
      if(s[i] == 'a')
	a[i] = 10;
      else if(s[i] == 'b')
	a[i] = 11;
      else if(s[i] == 'c')
	a[i] = 12;
      else if(s[i] == 'd')
	a[i] = 13;
      else if(s[i] == 'e')
	a[i] = 14;
      else if(s[i] == 'f')
	a[i] = 15;
      else 
	a[i] = s[i] - '0';
    }
  return a[1]+a[0]*16;
}

int main()
{
  string s;
  vector<Col> vec;
  vector<string> name;
  vec.resize(8),name.resize(8);
  int ff = _16to10("ff");
  vec[0] = Col(0,0,0);
  vec[1] = Col(0,0,ff);
  vec[2] = Col(0,ff,0);
  vec[3] = Col(0,ff,ff);
  vec[4] = Col(ff,0,0);
  vec[5] = Col(ff,0,ff);
  vec[6] = Col(ff,ff,0);
  vec[7] = Col(ff,ff,ff);
  name[0] = "black";
  name[1] = "blue";
  name[2] = "lime";
  name[3] = "aqua";
  name[4] = "red";
  name[5] = "fuchsia";
  name[6] = "yellow";
  name[7] = "white";
  while(true)
    {
      cin >> s;
      if(s == "0")
	break;
      int R,G,B;
      R = _16to10(s.substr(1,2));
      G = _16to10(s.substr(3,2));
      B = _16to10(s.substr(5,2));

      double men = (1<<28),pos = -1;
      for(int i=0;i<8;i++)
	{
	  double d =  sqrt(pow(R-vec[i].R,2)+pow(B-vec[i].B,2)+pow(G-vec[i].G,2));
	  if(men > d)
	    {
	      men = d;
	      pos = i;
	    }
	}
      cout << name[pos] << endl;

    }
  return 0;
}

Measured memory_bytes: 1192
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

class BTollGates {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        using namespace std;
        int n, m, x;
        cin >> n >> m >> x;
        int c1=0, c2=0;
        for(int i=0; i<m; i++) {
            int tp;
            cin >> tp;
            if(tp < x) c1++;
            else c2++;
        }
        cout << min(c1, c2) << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    BTollGates solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc136/submissions/6696720
# ほぼ写経、コメントをつけた

s = input()
n = len(s)
ans = [0] * n

cnt_l = 0  # RLのR上に来るまでに出会ったLの個数(直前のRLのLを含む)
cnt_r = 0  # RLのL上に来るまでに出会ったRの個数(直前のRLのRを含む,最初を除く)
curr = 'R'  # これが連続している間は、ansに計上しない
last_idx = 0  # RR[RL]LLLLLL <- このL列が集まるのは直前のRL, 直前のRLのLのidx

for idx, char in enumerate(s):
    if curr == 'R':
        if char == 'R':
            cnt_r += 1
            continue
        else:
            ans[idx] += cnt_r // 2  # ans[idx]: RLのL,偶数距離のRが集まる,RRR[RL]ならRrR[rL](大文字R)がLに集まる
            ans[idx - 1] += cnt_r - (cnt_r // 2)  # ans[idx-1]: RLのR,奇数距離のRが集まる,RRRRLならrRr[RL](大文字R)がR集まる
            last_idx = idx
            curr = 'L'
            cnt_r = 0
            cnt_l = 1  # Lの上に来たので、cnt_lを増やす
            continue
    else:
        if char == 'L':
            cnt_l += 1
            continue
        else:
            ans[last_idx - 1] += cnt_l // 2  # ans[last_idx - 1]: RLのR,偶数距離のLが集まる,[RL]LLなら[Rl]Ll(大文字L)がRに集まる
            ans[last_idx] += cnt_l - (cnt_l // 2)  # ans[last_idx]: RLのL,偶数距離のLが集まる,[RL]LLなら[RL]lL(大文字L)がLに集まる
            curr = 'R'
            cnt_l = 0
            cnt_r = 1  # Rの上に来たので、cnt_rを増やす

ans[last_idx - 1] += cnt_l // 2
ans[last_idx] += cnt_l - (cnt_l // 2)
# 末尾[RL]LLLLLLLLLのL列は、RLが来ないために計上されていないので、計上する

print(*ans)

# ループに入った人は、左右どちらかのLRに収まる


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

typedef vector<vector<int> > VVI;

struct State{
  int x, y;
  State(int x, int y): x(x), y(y){}
};

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

int H, W, c;
int org[10][10];
int field[10][10];
VVI pattern;

void dfs(vector<int> v, int color){  
  v.push_back(color);
  if(v.size() == 4){
    pattern.push_back(v);
    return;
  }
  for(int i = 1 ; i <= 6 ; i++){
    dfs(v, i);
  }
}

int bfs(vector<int> pat){
  int tmp[10][10];
  
  int ret = 0;
  
  for(int i = 0 ; i < (int)pat.size() ; i++){
    for(int j = 0 ; j < H ; j++)
      for(int k = 0 ; k < W ; k++) tmp[j][k] = field[j][k];            

    int color = tmp[0][0];    
    tmp[0][0] = pat[i];
    
    queue<State> que;
    que.push(State(0, 0));
    bool used[10][10];
    memset(used, false, sizeof(used));   
    while(!que.empty()){
      State q = que.front(); que.pop();    
      
      if(used[q.y][q.x]) continue;            
      
      used[q.y][q.x] = true;      
      field[q.y][q.x] = pat[i];
      for(int d = 0 ; d < 4 ; d++){
	int nx = q.x + dx[d], ny = q.y + dy[d];
	
	if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
	if(color == tmp[ny][nx]) que.push(State(nx, ny));
      }      
    }
  }
  
  queue<State> que;
  que.push(State(0, 0));
  bool used[10][10];
  memset(used, false, sizeof(used));
  while(!que.empty()){
    State q = que.front(); que.pop();
    if(used[q.y][q.x]) continue;
    if(field[q.y][q.x] == c) ret++;
    used[q.y][q.x] = true;
    for(int i = 0 ; i < 4 ; i++){
      int nx = q.x + dx[i], ny = q.y + dy[i];
      if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
      if(field[ny][nx] == c) que.push(State(nx, ny));
    }
  }
  return ret;  
}

void init(){
  for(int i = 0 ; i < 10 ; i++)
    for(int j = 0 ; j < 10 ; j++) org[i][j] = field[i][j] = 0;
}

int main(){ 
  
  vector<int> v;
  for(int i = 1 ; i <= 6 ; i++) dfs(v, i);

  while(cin >> H >> W >> c, H|W|c){
    init();
    
    for(int i = 0 ; i < H ; i++)
      for(int j = 0 ; j < W ; j++) cin >> org[i][j];        

    int ans = 0;    
    for(int i = 0 ; i < (int)pattern.size() ; i++){      
      for(int j = 0 ; j < H ; j++)
	for(int k = 0 ; k < W ; k++) field[j][k] = org[j][k];
      
      vector<int> pat = pattern[i];
      pat.push_back(c);
      
      ans = max(ans, bfs(pat));
    }
    
    cout << ans << endl;
    
  }  
  return 0;
}

Measured memory_bytes: 1340
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.next().equals("H") ? 0 : 1;
        int b = s.next().equals("H") ? 0 : 1;
        if (a + b == 1) {
            System.out.println("D");
        } else {
            System.out.println("H");
        }
    }
}

Measured memory_bytes: 21716
package main

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

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	A1 := io.nextInt()
	A2 := io.nextInt()
	A3 := io.nextInt()

	if A1+A2+A3 >= 22 {
		io.PutString("bust")
	} else {
		io.PutString("win")
	}
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() int {
	io.Scanner.Scan()
	i, _ := strconv.Atoi(io.Scanner.Text())
	return i
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


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

int main() {
    int N;
    cin >> N ;
    vector<int> vec(N);

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

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

    cout << vec[N-1] - vec[0] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#include<map>
#include<queue>
#define Max 9
int gg[Max]={1,2,3,4,5,6,7,8,0}, s[Max];

int ff[4][2] = {0,-1,1,0,0,1,-1,0};
int sum;
struct node
{
	int a[Max];
	int step;
};
map<int ,int >m;


int bfs()
{
	node tt;
	memcpy(tt.a,s,sizeof(s));
	tt.step = 0;
	queue<node > q;
	q.push(tt);
	while(!q.empty())
	{
		node star = q.front();
		q.pop();
		int i;
		for(i = 0;i<9;i++)
			if(star.a[i]==0)
				break;
		int y = i/3;
		int x = i%3;
		for(i = 0;i<4;i++)
		{
			int tx = x + ff[i][0];
			int ty = y + ff[i][1];
			if(tx >= 0&&ty>=0&&ty<3&&tx<3)
			{
				node end;
				memcpy(end.a,star.a,sizeof(star.a));
				int k = ty*3+tx;
				swap(end.a[k],end.a[y*3+x]);
				int sum1 = 0;
				for(int j = 0;j<9;j++)
					sum1 = sum1*10+end.a[j];
				if(!m[sum1])
				{
					m[sum1] = sum++;
					end.step = star.step+1;
					if(memcmp(end.a,gg,sizeof(gg))==0)
						return end.step;
					q.push(end);
				}
			}
		}
	}
}
int main()
{
	int i,j;

	while(~scanf("%d",&s[0]))
	{
		m.clear();
		int k = s[0];
		sum = 1;
		for(i = 1;i<9;i++)
		{
			scanf("%d",&s[i]);
			k = k*10+s[i];
		}
		m[k] = sum++;
		if(memcmp(s,gg,sizeof(gg))==0)
			printf("0\n");
		else printf("%d\n",bfs());
		
	}	
	return 0;
} 


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

int main() {

  int N,i;
  bool frag;
  frag = false;
  string name;
  
  cin >> N ;
  
  for (int i = 0; i < N; i++) {
    cin >> name;
    
    if(name == "Y" ){
    frag = true;
    }
  }
  
  if(frag == true){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" <<endl;
  }
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	if (N <= 2) {
		cout << 1 << endl;
		return 0;
	}
	vector<int>bef(200001, MOD);
	bef[v[0]] = 0;
	bef[v[1]] = 1;
	vector<long long int>dp(N);
	dp[0] = 1;
	dp[1] = 1;
	for (int i = 2; i < N; i++) {
		if (bef[v[i]] < i - 1) {
			dp[i] = dp[i - 1] + dp[bef[v[i]]];
		}
		else {
			dp[i] = dp[i - 1];
		}
		dp[i] %= MOD;
		bef[v[i]] = i;
	}
	cout << dp.back() << endl;
	return 0;
}

Measured memory_bytes: 3456
import itertools
N,M = map(int,input().split())
src = [tuple(map(float,input().split())) for i in range(N)]
if M <= 1:
    print(0)
    exit()
dists = [[None for j in range(N)] for i in range(N)]
for i in range(N-1):
    for j in range(i+1,N):
        l1,a1,b1 = src[i]
        l2,a2,b2 = src[j]
        dist = 0
        dist += (l1-l2)**2 + (a1-a2)**2 + (b1-b2)**2
        dists[i][j] = dists[j][i] = dist

ans = 0
for ptn in list(itertools.combinations(range(N),M)):
    total = 0
    for i in range(M-1):
        for j in range(i+1,M):
            total += dists[ptn[i]][ptn[j]]
    ans = max(ans, total)
print(ans)

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

int64_t lucas(int n, vector<int64_t> &cache) {
  if ( n == 0 ) {
    return 2;
  }
  if ( n == 1 ) {
    return 1;
  }
  if ( cache.at(n) >= 0 ) {
    return cache.at(n);
  }
  int64_t result = lucas(n-1, cache) + lucas(n-2, cache);
  cache.at(n) = result;
  return result;
}

int main() {
  int N;
  cin >> N;
  vector<int64_t> cache(N+1, -1);
  cout << lucas(N, cache) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,a[100009],b[100009]={};
    long long ans=0;
    cin>>n;
    for(int i=0;i<n+1;i++){
        cin>>a[i];
    }for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n+1;i++){
        if(i){
            int t=min(a[i],b[i-1]);
            a[i]-=t; ans+=t;
        }
        int t=min(a[i],b[i]);
        a[i]-=t; b[i]-=t; ans+=t;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s,t;
  int i=0,flag=0;
  cin >> s >> t;
  
  while(s[i]!='\0'){
    if(s[i]!=t[i]){
      flag=1;
    }
    i++;
  }
  if(flag==0)
    cout << "Yes" <<endl;
  else
    cout << "No"<<endl;
  return 0;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, l, r) for (__typeof(l) i = (l); i <= (r); ++i)
#define per(i, r, l) for (__typeof(r) i = (r); i >= (l); --i)
using namespace std;
typedef long long ll;
const int mod = 998244353;
int read() {
	int f = 1, x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return f * x;
}
int qpow(int a, int b) { int res = 1; while (b) { if (b & 1) res = (ll)res * a % mod; a = (ll)a * a % mod; b >>= 1; } return res; }
 
int main() {
	ll n, k;
	cin >> n >> k;
	// n - k - k - k - k
	ll l = 0, r = (n / k), ans = 0;
	while (l <= r) {
		ll mid = (l + r) >> 1; 
		if (n > k * mid) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	ll answer = n - k * ans;
	n -= k * (ans + 1);
	answer = min(answer, abs(n));
	cout << answer << endl; 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
typedef int TInt;
typedef std::vector<TInt> TList;

TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i];
    }
    return List;
}
int insertionSort(TList& A, int g)
{
    int cnt = 0;
    for(int i = g; i < A.size(); ++i){
        TInt v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
    return cnt;
}
void Reverse(TList& List)
{
    TList R;
    for(TList::reverse_iterator It = List.rbegin();
        It != List.rend();
        ++It)
    {
        R.push_back(*It);
    }
    std::swap(R, List);
}
TList GetG(int Max)
{
    TList G;
    int h = Max;
    while(h){
        G.push_back(h);
        h /= 2;
    }
    return G;
    // TList G;
    // int h = 1;
    // while(h <= Max){
    //     G.push_back(h);
    //     h = 3 * h + 1;
    // }
    // // Reverse(G);
    // std::reverse(G.begin(), G.end());
    // return G;
}
int shellSort(TList& A, const TList& G)
{
    int cnt = 0;
    for(TList::const_iterator It = G.begin();
        It != G.end();
        ++It){
        cnt += insertionSort(A, *It);
    }
    return cnt;
}
void OutputLine(const TList& List)
{
    TList::const_iterator It = List.begin();
    std::cout << *(It++);
    for(; It != List.end(); ++It){
        std::cout << " " << *It;
    }
    std::cout << std::endl;
}
void Output(const TList& List)
{
    TList::const_iterator It = List.begin();
    // std::cout << *(It++);
    for(; It != List.end(); ++It){
        std::cout << *It << std::endl;
    }
}
int main()
{
    TList A = Input();
    TList G = GetG(A.size());
    int cnt = shellSort(A, G);
    std::cout << G.size() << std::endl;
    OutputLine(G);
    std::cout << cnt << std::endl;
    Output(A);
    return 0;   
}

Measured memory_bytes: 6768
//This code is solely the property of StarnyC

#include<bits/stdc++.h>
using namespace std;
int main()

{
int n;
cin>>n;

char a[n];

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

int x=0;
int t=0;

for(int j=0;j<n;j++)
{if (a[j]=='I'){x=x+1;}
else if (a[j]=='D'){x=x-1;}

if(x>t){t=x;}

}


cout<<t;








}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
    return 0;
}

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

const int N=10005,P=998244353,G=3;
int n,e,m,f[N],rf[N];
char a[N],b[N];

int pw(int a,int x)
{
	int ans=1;
	for(;x;x>>=1,a=1ll*a*a%P)
		if(x&1)ans=1ll*ans*a%P;
	return ans;
}

void dft(int *a,int n,int inv)
{
	for(int i=0,j=0;i<n;i++)
	{
		if(i>j)swap(a[i],a[j]);
		for(int k=n>>1;(j^=k)<k;k>>=1);
	}
	for(int i=2;i<=n;i<<=1)
	{
		int m=i>>1,wn=pw(G,P-1+inv*(P-1)/i);
		for(int *p=a;p<a+n;p+=i)
			for(int j=0,w=1;j<m;j++,w=1ll*w*wn%P)
			{
				int t=1ll*w*p[m+j]%P;
				p[m+j]=(p[j]-t)%P;
				p[j]=(p[j]+t)%P;
			}
	}
	if(inv==-1)
		for(int i=0,t=pw(n,P-2);i<n;i++)a[i]=1ll*a[i]*t%P;
}

typedef vector<int> poly;
poly operator*(const poly&a,const poly&b)
{
	poly c;
	static int ta[N<<2],tb[N<<2];
	copy(a.begin(),a.end(),ta);
	copy(b.begin(),b.end(),tb);
	int l=1;
	for(;l<=m<<1;l<<=1);
	dft(ta,l,1),dft(tb,l,1);
	for(int i=0;i<l;i++)ta[i]=1ll*ta[i]*tb[i]%P;
	dft(ta,l,-1);
	for(int i=0;i<=m;i++)c.push_back(ta[i]);
	for(int i=0;i<l;i++)ta[i]=tb[i]=0;
	return c;
}
poly power(poly a,int n)
{
	poly ans(m+1);ans[0]=1;
	for(;n;n>>=1,a=a*a)
		if(n&1)ans=ans*a;
	return ans;
}

int main()
{
	scanf("%s%s",a+1,b+1);
	n=strlen(a+1);
	for(int i=1;i<=n;i++)
	{
		e+=a[i]=='1'&&b[i]=='0';
		m+=a[i]=='1'&&b[i]=='1';
	}
	for(int i=f[0]=1;i<=n;i++)f[i]=1ll*f[i-1]*i%P;
	rf[n]=pw(f[n],P-2);
	for(int i=n;i;i--)rf[i-1]=1ll*rf[i]*i%P;
	poly a;
	for(int i=0;i<=m;i++)
		a.push_back(rf[i+1]);
	a=power(a,e);
	int ans=0;
	for(int i=0;i<=m;i++)ans=(ans+a[i])%P;
	ans=1ll*ans*f[e]%P*f[m]%P*f[e+m]%P;
	printf("%d\n",(ans+P)%P);
	return 0;
}


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


namespace Swapping_Two_Numbers
{
    class Program
    {
        public static void Main(string[] args)
        {
            String str;
            while ((str = Console.ReadLine()) != "0 0")
            {
                String[] ss = str.Split(' ');
                int a = int.Parse(ss[0]);
                int b = int.Parse(ss[1]);
                if (a > b) Console.WriteLine("{0} {1}", b, a);
                else Console.WriteLine("{0} {1}", a, b);
            }
        }
    }
}


Measured memory_bytes: 9236
num = [int(s) for s in input().split()]
t_num = 0
k_num = 0
flag = False
for i in range(num[0]+1):
    t_num = i
    k_num = num[0] - t_num
    tmp = t_num * 2 + k_num * 4
    if tmp == num[1]:
        flag = True
if flag == True:
    print('Yes')
else:
    print('No')        

Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	for(int i = 0;i < s.size();i++){
		cout << s[i] << t[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, *A = map(int, read().split())

    hq = []
    for a in A:
        heappush(hq, -a)

    for _ in range(M):
        a = heappop(hq)
        a = int(a / 2)
        heappush(hq, a)

    print(-sum(hq))
    return


if __name__ == '__main__':
    main()


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

char table[9][5]={
  {'.',',','!','?',' '},
  {'a','b','c'},
  {'d','e','f'},
  {'g','h','i'},
  {'j','k','l'},
  {'m','n','o'},
  {'p','q','r','s'},
  {'t','u','v'},
  {'w','x','y','z'},
};
int size[9]={5,3,3,3,3,3,4,3,4};


int main(){
  int n;
  cin>>n;
  while(n--){
    string str;
    int p=0;
    int pos=0;
    cin>>str;
    for(int i=0;i<(int)str.size();i++){
      if(str[i]=='0'){
	if(p!=0){
	  cout<<table[pos-1][(p-1)%(size[pos-1])];
	  p=0;
	  pos=0;
	}
      }else{
	pos=int(str[i]-'0');
	p++;
      }

    }
    cout<<endl;

  }
}

Measured memory_bytes: 1200
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

use std::collections::BinaryHeap;
use std::collections::HashMap;

fn main() {
    input!{
      x: usize,
      y: usize,
      z: usize,
      k: usize,
      mut aa: [usize; x],
      mut bb: [usize; y],
      mut cc: [usize; z],
    }
    aa.sort();
    aa.reverse();
    bb.sort();
    bb.reverse();
    cc.sort();
    cc.reverse();

    let mut map = HashMap::new();
    let sum = |i, j, k| {
        return aa[i] + bb[j] + cc[k];
    };

    let new_entry = |i, j, k| {
        return (sum(i, j, k), i, j, k)
    };

    let mut heap = BinaryHeap::new();
    heap.push(new_entry(0, 0, 0));
    map.insert((0, 0, 0), true);

    let mut cnt = 0;
    while cnt < k {
        cnt += 1;
        let (sum, i, j, k) = heap.pop().unwrap();
        println!("{}", sum);

        let items = [
            (i+1, j, k),
            (i, j+1, k),
            (i, j, k+1),
        ];

        for &(i, j, k) in items.iter() {
            if !map.contains_key(&(i, j, k)) {
                if i < x && j < y && k < z {
                    let e = new_entry(i, j, k);
                    heap.push(e);
                    map.insert((i, j, k), true);
                }
            }
        }
    }
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            int n = ReadAndParseInt();
            int k = ReadAndParseInt();
            int a = 1;
            for(int i=0;i<n;++i)
            {
                a =Math.Min(2 * a, a + k);
            }
            Console.WriteLine(a);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, op, b, ans;
        while (true){
            ans = 0;
            a = sc.nextInt();
            op = sc.next().charAt(0);
            b = sc.nextInt();
            if (op == '+') ans = a + b;
            else if (op == '-') ans = a - b;
            else if (op == '*') ans = a * b;
            else if (op == '/') ans = a / b;
            else if (op == '?') break;
            System.out.println(ans);
        }
    }
}


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

int N;
string s;
ll ans = 0;

int main()
{
    cin >> N >> s;
    ll a = 0, b = 0, c = 0, ab = 0, bc = 0, ac = 0;
    for (int i = 0; i < N; i++)
    {
        if (s[i] == 'R')
        {
            a += 1;
            ab += b;
            ac += c;
            ans += bc;
        }
        else if (s[i] == 'G')
        {
            b += 1;
            ab += a;
            bc += c;
            ans += ac;
        }
        else if (s[i] == 'B')
        {
            c += 1;
            ac += a;
            bc += b;
            ans += ab;
        }
    }
    // cout << ans << endl;

    for (int i = 0; i < N; i++)
    {
        for (int k = 1; i + 2 * k < N; k++)
        {
            if (s[i] != s[i + k] && s[i] != s[i + 2 * k] && s[i + k] != s[i + 2 * k])
            {
                // cout << i << " " << i + k << " " << i + 2 * k << endl;
                ans--;
            }
        }
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 3636
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define N 2*10e5
#define precise cout<<fixed<<setprecision(10)
#pragma GCC optimize("O0")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#define rep(i,a,b) for(int i=a;i<b;i++)
#define min3(a,b,c) min(a,min(b,c))
#define nl cout<<"\n";
#define all(v) v.begin(),v.end()
#define F first
#define S second
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long,long>> vp;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
ll gcd(ll a,ll b);
ll binpow(ll a,ll b);
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	get(arr,n);
	sort(arr,arr+n);
	ll sum=0;
	rep(i,0,k) sum+= arr[i];
	cout<<sum;
}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
	 	solve();
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}
ll binpow(ll a, ll b) {
   ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    string s,t;
    cin>>s>>t;
    sort(ALL(s));
    sort(ALL(t),GREATER);
    cout<<(s<t?"Yes":"No")<<endl;


    return 0;
}




Measured memory_bytes: 256
c = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for i in range(0, 3):
    c[i] = [int(j) for j in input().split(" ")]

f = True
for i in range(0, 2):
    f = f and c[i][0] - c[i][1] == c[i + 1][0] - c[i + 1][1]
    f = f and c[i][1] - c[i][2] == c[i + 1][1] - c[i + 1][2]

for i in range(0, 2):
    f = f and c[0][i] - c[1][i] == c[0][i + 1] - c[1][i + 1]
    f = f and c[1][i] - c[2][i] == c[1][i + 1] - c[2][i + 1]

if f:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
struct Restaurant {
    int id;
    string S;
    int P;
};
int main() {
    int N;
    cin >> N;
    vector<Restaurant> v(N);
    map<string, vector<Restaurant*>> m;
    for (int i = 0; i < N; i++) {
        v[i].id = i + 1;
        cin >> v[i].S >> v[i].P;
        m[v[i].S].push_back(&v[i]);
    }
    for (auto& p : m) {
        sort(p.second.begin(), p.second.end(), [](const auto& p, const auto& q) {
            return p->P > q->P;
        });
        for (const auto& r : p.second) cout << r->id << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char N[5];
	scanf("%s", N);
	int i;
	int count=0;
	for (i = 0; i < 4; i++) {
		if (N[i] == '2') {
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}


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


using namespace std;

const int MOD = 1E9 + 7;
int main() {
        int n, k;
        scanf("%d%d", &n, &k);
        vector<long long> dp(k + 1);
        dp[0] = 1;
        for (int i = 0, w; i < n; i++) {
                scanf("%d", &w);
                vector<long long> pre(k + 2);
                for (int a = k; a >= 0; a--) {
                        (pre[a + 1] += dp[a]) %= MOD;
                        (pre[a + min(w, k - a) + 1] -= dp[a] - MOD) %= MOD;
                }
                for (int j = 0; j <= k; j++) {
                        if (j) (pre[j] += pre[j - 1]) %= MOD;
                        (dp[j] += pre[j]) %= MOD;
                }
        }

        printf("%lld\n", dp[k]);
}

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

int digit(int n){
    if(1 <= n && n <= 9) return 1;

    int s = n / 10;
    return digit(s) + 1;
}

int main(void){
    int a, b;
    cin >> a >> b;

    int n = digit(b);

    int c = a * pow(10, n) + b;

    bool flag = false;

    for(int i = 1; i <= sqrt(c) + 1; i++){
        if(c == i * i){
            flag = true;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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


using namespace std;

int H,W;

long long a[4];

void Work(){
	if(H%3==0){
		puts("0");
		return;
	}
	if(W%3==0){
		puts("0");
	}
	int ans=0x7f7f7f7f;
	if(H>3){
		ans=W;
	}
	if(W>3){
		ans=min(ans,H);
	}
	for(int i=1;i<H;i++){
		a[1]=1LL*i*W;
		a[2]=1LL*(H-i)*(W/2);
		a[3]=1LL*(H-i)*(W/2)+(W%2==1?H-i:0);
		sort(a+1,a+3+1);
		if(a[3]-a[1]<ans)ans=a[3]-a[1];
	}
	swap(H,W);
	for(int i=1;i<H;i++){
		a[1]=1LL*i*W;
		a[2]=1LL*(H-i)*(W/2);
		a[3]=1LL*(H-i)*(W/2)+(W%2==1?H-i:0);
		sort(a+1,a+3+1);
		if(a[3]-a[1]<ans)ans=a[3]-a[1];
	}
	printf("%d\n",ans);
}

void Init(){
	scanf("%d%d",&H,&W);
}

int main(){
	Init();
	Work();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, s[100005], sum;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, n) {
        cin >> s[i];
        sum += s[i];
    }
    int tmp = INF;
    rep(i, 0, n) {
        if (s[i] % 10 != 0) tmp = min(tmp, s[i]);
    }
    if (sum % 10 == 0) {
        if (tmp == INF) sum = 0;
        else sum -= tmp;
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

int R, C, grid[105][105];
int col[10005], N;

int main(){

    ios :: sync_with_stdio(false);
    cin >> R >> C;
    cin >> N;
    FOR(i,N) cin >> col[i];

    int cur = 1;
    FOR(i,R){
        if(i&1){
            FOR(j,C){
                if(col[cur]==0) cur++;
                grid[i][j] = cur;
                col[cur]--;
            }
        }
        else{
            FORD(j,C,1){
                if(col[cur]==0) cur++;
                grid[i][j] = cur;
                col[cur]--;
            }
        }
    }

    FOR(i,R){
        FOR(j,C) cout << grid[i][j] << " ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384