akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main()
{
  int n,i,b,f,r,v,room[4][3][10]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++,room[b-1][f-1][r-1]+=v)
  {
    scanf("%d%d%d%d",&b,&f,&r,&v);
  }
  for(b=0;b<4;b++)
  {
    for(f=0;f<3;f++)
    {
      for(r=0;r<10;r++)
      {
        printf(" %d",room[b][f][r]);
      }
      printf("\n");
    }
    if(b!=3)
    {
      for(i=0;i<20;i++)
      {
        printf("#");
      }
      printf("\n");
    }
  }
  return 0;
}

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

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int[] blood = new int[4];
		Arrays.fill(blood, 0);

		while(sc.hasNext()) {
			String[] str = sc.next().split(",");

			if(str[1].equals("A")) {
				blood[0]++;
			} else if(str[1].equals("B")) {
				blood[1]++;
			} else if(str[1].equals("AB")) {
				blood[2]++;
			} else {
				blood[3]++;
			}
		}

		for(int $ = 0; $ < blood.length; $++) {
			System.out.println(blood[$]);
		}

	}

}

Measured memory_bytes: 26076
#[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)*}
    };
}

#[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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        k: usize,
        h: [i64; n],
    }

    let mut h = h;
    h.sort();

    let mut ans = std::i64::MAX;

    for i in 0..n + 1 - k {
        ans = std::cmp::min(ans, h[i + k - 1] - h[i]);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  int a[h][w];
  string b[h];
  fill_n(*a,h*w,-1);
  for(int i = 0;i < h;i++){
    cin >> b[i];
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(b[i][j] == 'c') a[i][j] = 0;
    }
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w-1;j++){
      if(a[i][j] != -1 && a[i][j+1] == -1){
	a[i][j+1] = a[i][j]+1;
      }
    }
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      cout << a[i][j];
      if(j == w-1) cout << endl;
      else cout << " ";
    }
  }
  return (0);
}

Measured memory_bytes: 3196
from math import gcd
class SEGTree:
    def __init__(self,n):
        self.Unit=0
        i=1
        while(i<n):
            i*=2
        self.SEG=[self.Unit]*(2*i-1)
        self.d=i
    def update(self,i,x):
        i+=self.d-1
        self.SEG[i]=x
        while i>0:
            i=(i-1)//2
            self.SEG[i]=gcd(self.SEG[i*2+1],self.SEG[i*2+2])
    def find(self,a,b,k,l,r):
        if r<=a or b<=l:
            return self.Unit
        if a<=l and r<=b:
            return self.SEG[k]
        else:
            c1=self.find(a,b,2*k+1,l,(l+r)//2)
            c2=self.find(a,b,2*k+2,(l+r)//2,r)
            return gcd(c1,c2)
    def get(self,a,b):
        return self.find(a,b,0,0,self.d)

N=int(input())
SEG=SEGTree(N)
A=list(map(int,input().split()))
for i in range(N):
    SEG.update(i,A[i])
ans=1
for i in range(N):
    l,r=SEG.get(0,i),SEG.get(i+1,N)
    ans=max(ans,gcd(l,r))
print(ans)

Measured memory_bytes: 88696
#include<stdio.h>
int main(){
  int a,b,d,r;
  double f;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=1.00000*a/b;
  printf("%d %d %.5lf\n",d,r,f);
  return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		Integer n = sc.nextInt();
		List<Integer> nLst = new ArrayList<Integer>();
		int max = 0;
		int preNum = 0;
		int count = 0;
		for (int i = 0; i < n; i++) {
			nLst.add(sc.nextInt());
		}
		for (Integer num : nLst) {
			if(preNum >= num) {
				count++;
				if(max < count) {
					max = count;
				}
			} else {
				count = 0;
			}
			preNum = num;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 60632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		int sum = 0;
		
		for (int i = 0; i < s.length(); i++) {
			sum += s.charAt(i) - '0';
		}
		
		System.out.println((Integer.parseInt(s) % sum == 0) ? "Yes" : "No");
		
	}

}


Measured memory_bytes: 22996
import sys

l = []
for i in sys.stdin:
    l.append(i.split())

count = 0
for i in range(1,len(l)-1):
    for j in range(0,len(l[i])):
        l[i][j] = l[i][j].lower()
    count += l[i].count(l[0][0])

print(count)


Measured memory_bytes: 5568
#include<stdio.h>
int main(void){
        int n;
        scanf("%d",&n);
        if(n>=195) printf("5\n");
        else if(n>=189) printf("4\n");
        else if(n>=165) printf("3\n");
        else if(n>=135) printf("2\n");
        else if(n>=105) printf("1\n");
        else printf("0\n");
        return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=210;bool vis[maxn];
int f[maxn],n,ans,a[maxn],mp[maxn][maxn],b[maxn],tot1,tot2,x[maxn];
bool check(int x){
    if((!(x&1))||x==1)return 0;
    int n=sqrt(x);
    for(rg int i=2;i<=n;i++)
        if(!(x%i))return 0;
    return 1;
}
inline bool dfs(int x){
    for(rg int i=1;i<=tot2;i++)
        if(!vis[i]&&mp[x][i]){
            vis[i]=1;
            if(!f[i]||dfs(f[i]))return f[i]=x,1;
        }
    return 0;
}
int main(){
    read(n);
    for(rg int i=1;i<=n;i++)read(x[i]);
    if(n==1){printf("3\n");return 0;}
    for(rg int i=1;i<=n;i++){
        if(x[i+1]-x[i]!=1||i==n){
            if((x[i]+1)%2==0)a[++tot1]=x[i]+1;
            else b[++tot2]=x[i]+1;
        }
        if(x[i]-x[i-1]!=1||i==1){
            if(x[i]&1)b[++tot2]=x[i];
            else a[++tot1]=x[i];
        }
    }
    for(rg int i=1;i<=tot1;i++)
        for(rg int j=1;j<=tot2;j++)
            if(check(abs(a[i]-b[j])))mp[i][j]=1;
    for(rg int i=1;i<=tot1;i++){
        memset(vis,0,sizeof vis);
        if(dfs(i))ans++;
    }
    printf("%d\n",ans+(tot1-ans)/2*2+(tot2-ans)/2*2+(tot1-ans)%2*3);
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
using ll = long long int;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if (A + B + 1 < C) {
		cout << A + 2*B + 1;
	}
	else {
		cout << B + C;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <map>

#define rep(i, a, b) for ( long long  i = (a); i < (b); i++ )
#define per(i, a, b) for ( long long i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

/*
1                m    r              14
b b p p p b p b p p p b b

   b p p p b    b p p p b
   
                      b 
*/

ll X;
int N;
// brgr: レベルiのときのバーガー全体の数
//p: レベルiのパティの数
ll brgr[51], p[51];

ll dc(ll r, int level) { 
  //printf("level:%d  r:%lld\n", level, r);
  if (r<2 || r <= level+1 || level < 0) return 0;
  if (r == brgr[level] + 1LL) return p[level];
  
  ll ret = 0;
  ll m = (brgr[level]+1) / 2LL;
  
  
  if (r > m) {
     ret += 1; // 真ん中のパティ分
    ret += p[level-1];
    ret += dc(r-m, level-1);
  } else {
    ret += dc(r-1, level-1);
  }
  
  return ret;


}


int main(void) {
    scanf("%d %lld", &N, &X);
    
    brgr[0] = p[0] = 1;
    rep(i, 1, N+1) {
     brgr[i] = brgr[i-1] * 2LL + 3LL;
     p[i] = p[i-1] * 2LL +1LL;
    }
    
    ll ans = dc(X+1LL, N);
    
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, d[102][5][5][5] = {}, z = 0;
    d[0][4][4][4] = 1;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 4; j++) {
            for (int k = 0; k <= 4; k++) {
                for (int l = 0; l <= 4; l++) {
                    for (int m = 0; m < 4; m++) {
                        bool y = 0;
                        if (k == 0 && l == 2 && m == 1) y = 1;
                        if (k == 0 && l == 1 && m == 2) y = 1;
                        if (k == 2 && l == 0 && m == 1) y = 1;
                        if (j == 0 && l == 2 && m == 1) y = 1;
                        if (j == 0 && k == 2 && m == 1) y = 1;
                        if (!y) {
                            d[i][k][l][m] += d[i - 1][j][k][l];
                            if (d[i][k][l][m] >= mod) d[i][k][l][m] -= mod;
                        }
                    }
                }
            }
        }
    }
    for (int i = 0; i <= 4; i++) {
        for (int j = 0; j <= 4; j++) {
            for (int k = 0; k <= 4; k++) {
                z += d[n][i][j][k];
                if (z >= mod) z -= mod;
            }
        }
    }
    cout << z;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 1000000
void insertionSort(int A[],int n,int g);
void ShellSort(int A[],int n);

int cnt,m;
int G[100];

int main(void){
	
	int n,a[N];
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){ scanf("%d",&a[i]);}
	
	ShellSort(a,n);
	
	printf("%d\n",m);
	for(int i=m-1;i>0;i--){
		printf("%d ",G[i]);
	}
	
	printf("%d\n",G[0]);
	
	printf("%d\n",cnt);
	
	for(int i=0;i<n;i++){
	printf("%d\n",a[i]);
	}
	return 0;
}

void insertionSort(int A[],int n,int g){
	
	int v,j;
	
	for(int i=g;i<n;i++){
		
		v = A[i];
		j = i - g;
		
		while( j >= 0 && A[j] >v){
			
			A[j+g] = A[j];
			j = j -g;
			
			cnt++;
			A[j+g] = v;
			}
		
		
		
	}
}

void ShellSort(int A[],int n){
	
	
	G[0]=1;
	
	for(int i= 1;i<N;i++){
		
		G[i]=3*G[i-1] + 1;
		
		if(G[i]>n){	
			m=i;
			break;
			}                  
		}

	for(int i=0;i<m;i++){
		
		 insertionSort(A, n, G[m-i-1]);
	}
}





Measured memory_bytes: 6524
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (x, t) = listOfInt()
    println(when {
        x - t > 0 -> x - t
        else -> 0
    })
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << 1000*(n/1000 + (n % 1000 != 0)) - n << '\n';
}

Measured memory_bytes: 3632
<?php
$n = trim(fgets(STDIN));
$t_score = 0;
$h_score = 0;

for($i = 0; $i < $n; $i++){
    $card = explode(" ", trim(fgets(STDIN)));
    $t_card = $card[0];
    $h_card = $card[1];
    if($t_card > $h_card){
        $t_score += 3;
    }elseif ($t_card == $h_card) {
        $t_score += 1;
        $h_score += 1;
    }elseif ($t_card < $h_card) {
        $h_score += 3;
    }
}
printf("%d %d",$t_score,$h_score).PHP_EOL;
?>

Measured memory_bytes: 15008
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>

using namespace std;

#define MAX 15
#define INF 1e9

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

struct Segment{
  Point s,t;
  Segment(){}
  Segment(Point s,Point t) : s(s), t(t) {}
};

int N;
double dp[1<<MAX][MAX][2];
Segment Seg[MAX];
double d[MAX];

double getDistance(Point &p1,Point &p2){
  return sqrt(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2));
}

double solve(int S,int now,bool st){
  if((1<<N)-1 == S){
    if(st){
      return dp[S][now][st] = d[now];
    }else{
      return dp[S][now][st] = d[now];
    }
  }
  if(dp[S][now][st] != INF){
    return dp[S][now][st];
  }
  double res = INF;
  for(int i = 0 ; i < N ; i++){
    if(S >> i & 1) continue;
    if(st){
      res = min(res,solve(S|(1<<i),i,true) + d[now] + getDistance(Seg[now].t,Seg[i].s));
      res = min(res,solve(S|(1<<i),i,false) + d[now] + getDistance(Seg[now].t,Seg[i].t));     
    }else{
      res = min(res,solve(S|(1<<i),i,true) + d[now] + getDistance(Seg[now].s,Seg[i].s));
      res = min(res,solve(S|(1<<i),i,false) + d[now] + getDistance(Seg[now].s,Seg[i].t));   
    }
  }
  return dp[S][now][st] = res;
}

int main(){
  int Tc = 1;
  while(cin >> N, N){
    for(int i = 0 ; i < N ; i++){
      cin >> Seg[i].s.x >> Seg[i].s.y >> Seg[i].t.x >> Seg[i].t.y;
      d[i] = getDistance(Seg[i].s,Seg[i].t);
    }
    for(int i = 0 ; i < (1<<MAX) ; i++){
      for(int j = 0 ; j < MAX ; j++){
        for(int k = 0 ; k < 2 ; k++){
          dp[i][j][k] = INF;
        }
      }
    }
    double res = INF;
    for(int i = 0 ; i < N ; i++){
      res = min(res,solve(1<<i,i,true));
      res = min(res,solve(1<<i,i,false));
    }
    printf("Case %d: %.5f\n",Tc++,res);
  }
  return 0;
}

Measured memory_bytes: 8928
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(x);
    int res = 0;
    rep(i, 10000000){
      if(i * (i + 1) / 2 >= x)break;
    }
    pri(i);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int n,m;

void proc(){
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      printf("%c",((i+j)%2==0)?'#':'.');
    }
    printf("\n");
  }
  printf("\n");
}

int main(){
  while(true){
    scanf("%d%d",&n,&m);
    if(!n&&!m)return 0;
    proc();
  }
}

Measured memory_bytes: 1000
z=0..9
l=[[z.to_a,[0]]]
a=[[0]]
z.map{|i|r=[]
a<<l.flat_map{|m,s|m.flat_map{|n|t=n*(i+1)
(r.assoc(u=m-[n])||(r<<[u,[]])[-1])[1]+=b=s.map{|j|j+t}
b}}
l=r}
$<.map{|l|c,d=l.split.map &:to_i;p a[c].count(d)}

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

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}

int main(){
	string s,t;
	cin >> s;
	t = s;
	reverse(t.begin(), t.end());
	rep(i,t.length()){
		char c = '_';
		switch(t[i]){
			case 'b':
				c = 'd';
				break;
			case 'd':
				c = 'b';
				break;
			case 'p':
				c = 'q';
				break;
			case 'q':
				c = 'p';
				break;
			default: break;
		}
		t[i] = c;
	}
	cout << (t == s ? "Yes": "No") << endl;

	return 0;
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll n=in();
    vector<ll>p(n);REP(i,n)p[i]=in();
    REP(i,n){
        REP(j,n){
            swap(p[i],p[j]);
            if(is_sorted(ALL(p))){
                cout<<"YES"<<endl;
                return 0;
            }
            swap(p[i],p[j]);
        }
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

void solve(long long A, long long B){
    vector<LL> v = {A+B, A-B, A*B};
    cout << *max_element(all(v)) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
index=Hash.new{|word,page| word[page] = []}
while line =gets do
	word,page= line.split(" ")
	page =page.to_i
	index[word]<<page
end
index.each{|word,page|page.sort!}
index2=index.sort

index2.each{|key,value|
	puts key
	puts value.join(" ")
}

Measured memory_bytes: 8508
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main(){
    // 引数の受け取り
    char A[100],B[100],C[100];
    scanf("%s %s %s",A,B,C);

    printf("%C%C%C",A[0],B[0],C[0]);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

ll comb(ll N_, ll C_) {
	const int NUM_ = 400001;
	static ll fact[400002], factr[400002], inv[400002];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mod, factr[i] = factr[i - 1] * inv[i] % mod;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % mod*factr[N_ - C_] % mod;
}
ll modpow(ll a, ll n = mod - 2) {
	ll r = 1;
	while (n) r = r * ((n % 2) ? a : 1) % mod, a = a * a%mod, n >>= 1;
	return r;
}

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

	int N, M, K; cin >> N >> M >> K;
	int ans = 0;

	REP(i, N) {
		int d = (N - i - 1);
		d = (d*(d + 1)) / 2;
		d *= M * M;
		d %= mod;
		ans += d;
		ans %= mod;
	}

	REP(i, M) {
		int d = (M - i - 1);
		d = (d*(d + 1)) / 2;
		d *= N * N;
		d %= mod;
		ans += d;
		ans %= mod;
	}
	
	cout << (ans*comb(N*M - 2, K - 2)) % mod << endl;

	return 0;
}



Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll f(ll x)
{
  ll res = 0;
  if (x % 4 == 1 || x % 4 == 2)
    res++;
  ll pow2 = 2;
  while (pow2 <= x)
  {
    if (x % (pow2 * 2) >= pow2 && x % 2 == 0)
      res += pow2;
    pow2 *= 2;
  }
  return res;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);

  ll a, b;
  cin >> a >> b;
  cout << (f(a - 1) ^ f(b)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;

int main() {

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

    ll ans = k;

    for (int i = 0; i < n-1; i++) {
        ans *= k - 1;
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a;
    cin >> a;
    cout << a + (a * a) + (a * a * a);
    
    
    
    return 0;
}

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

const LL MOD = 998244353;

LL powmod(LL a, LL n){
    if(n == 0) return 1;
    if(n % 2) return (a*powmod(a,n-1)) % MOD;
    LL c = powmod(a, n/2);
    return (c*c) % MOD;
}
LL inv(LL a){
    return powmod(a, MOD-2);
}
LL fact[1100000];
LL invfact[1100000];

LL ncr(LL n, LL r){
    if(r < 0 || n < 0) return 0;
    if(n < r) return 0;
    LL a = fact[n];
    a = (a * invfact[r]) % MOD;
    a = (a * invfact[n-r]) % MOD;
    return a;
}
void init(){
    fact[0] = 1;
    invfact[0] = 1;
    LL inv2 = inv(2);
    for(LL i = 1; i < 1100000; i++){
        fact[i] = (i*fact[i-1]) % MOD;
        invfact[i] = inv(fact[i]);
    }
}

int main(){
	init();
	LL n, a, b, k;
	cin >> n >> a >> b >> k;
	LL ans = 0;
	for(LL j = 0; j <= n; j++){
		LL c = (k - a*j)/b;
		if(c >= 0 && c <= n && j*a+c*b == k){
			ans += (ncr(n,c)*ncr(n,j)) % MOD;
			ans %= MOD;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 17408
#%%
N, X = map(int, input().split())
point = []
ans = 0

a = 1
p = 1
for i in range(N):
    a *= 2
    a += 3
    p *= 2
    p += 1

#print(a, p)

while a >= 1:
    if X == a :
        ans += p
        break
    elif (a+1)//2+1 <= X <= a-1:
        X -= 2+(a-3)//2
        ans += p//2 + 1
    elif  X == (a+1)//2:
        ans += p//2 + 1
        break
    elif 2 <= X <= (a+1)//2-1:
        X -= 1
    elif X == 1:
        break

    a -= 3
    a //= 2
    p -= 1
    p //= 2

    #print(a, p)

print(ans)




Measured memory_bytes: 3064
let () =
	let n = read_int () in
	let s = read_line () in
	let t = read_line () in
	let rec loop s t n =
		if n = 0 then 0
		else if Str.last_chars s n = Str.first_chars t n then n
		else loop s t (n - 1)
	in
	loop s t n
	|> ( - ) (n * 2)
	|> print_int
	|> print_newline


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

/*long C(long n, long r){
    if(n < r) return 0;
    long p[n+1][n+1];
    p[0][0] = 1;
    for(int i = 1; i <= n; i++){
        p[i][0] = 1;
        p[i][i] = 1;
        for(int j = 1; j <= i-1; j++){
            p[i][j] = p[i-1][j] + p[i-1][j-1];
        }
    }
    return p[n][r];
}*/

void solve()
{
    int N;
    cin >> N;
    vector<long long> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    long long sum = accumulate(a.begin(), a.end(), 0LL);
    long long x = a[0];
    long long ans = abs(sum - 2*x);
    for(int i = 1; i < N-1; i++){
        x += a[i];
        ans = min(ans, abs(sum - 2*x));
    }
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N;
  	cin >> N;
  	int array[N];
  	for(int i=0;i<N;i++) array[i] = i+1;

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

  	int Pnum, Qnum;
  	int i = 0;
  	do{
  		bool flag = true;
  		for(int i=0;i<N;i++){
  			if(array[i]!=P[i]){
  				flag = false;
  				break;
  			}
  		}
  		if(flag){
  			Pnum = i;
  			break;
  		}
  		i++;
  	}while(next_permutation(array, array+N));

  	for(int i=0;i<N;i++) array[i] = i+1;

  	//cout << Pnum <<endl;
  	i = 0;
  	do{
  		bool flag= true;
  		for(int i=0;i<N;i++){
  			if(array[i]!=Q[i]){
  				flag = false;
  				break;
  			}
  		}
  		if(flag){
  			Qnum = i;
  			break;
  		}
  		i++;
  	}while(next_permutation(array, array+N));

  	//cout << Qnum <<endl;

  	cout << abs(Pnum - Qnum) <<endl;

    
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;


int main() {
  int N;
  std::cin >> N;
  std::vector<mp::cpp_int> a(N);  
  mp::cpp_int x = 1;
  bool flag = false;
  for (int i = 0; i < N; ++i) {
    std::cin >> a[i];
    if (a[i] == 0) {
      flag = true;
    }
  }

  if (flag) {
    std::cout << "0" << std::endl;
    return 0;
  }
  
  for (mp::cpp_int y : a) {
    x *= (mp::cpp_int)y;
    
    if (x > (mp::cpp_int)pow(10,18) || x < 0) {
      std::cout << "-1" << std::endl;
      return 0;
    }
 
  }
  
  
  std::cout << x << std::endl;
  return 0;
}

Measured memory_bytes: 5996
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,max=-1,maxp;
  cin>>n;
  REP(i,1,n+1){
    int a=i;
    int count=0;
    while(true){
      if(a%2!=0){
        break;
      }
      a/=2;
      count++;
    }
    if(chmax(max,count)){
      maxp=i;
    }
  }
  cout<<maxp<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, b, d, r;
	scanf("%d %d", &a, &b);
	double f;
	d=a/b;
	r=a%b;
	f=1.0*a/b;
	printf("%d %d %lf\n", d, r, f);
	
	return 0;
}


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

using namespace std;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()

const int INF = 1000000000;

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

    int r = 0;
    rep (x, N+1) {
        rep (y, N+1-x) {
            int z = N - x - y;
            int sum = x*10000 + y*5000 + z*1000;
            if (Y == sum) {
                cout << x << ' ' << y << ' ' << z << endl;
                r = 1;
                break;
            }
        }
        if (r) break;
    }

    if (!r) cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}


Measured memory_bytes: 256
N, L = map(int, input().split())
a = list(map(int, input().split()))

I = [i + 1 for i in range(N - 1) if a[i] + a[i + 1] >= L]
ans = (
    'Possible\n{}'.format(
        '\n'.join(
            map(
                str,
                list(range(1, I[0])) + list(range(N - 1, I[0], -1)) + [I[0]]
            )
        )
    ) if I else
    'Impossible'
)

print(ans)


Measured memory_bytes: 21352
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int t = stdIn.nextInt();
        int x = stdIn.nextInt();
        //int c = stdIn.nextInt();
        //int w = stdIn.nextInt();
        //int n = stdIn.nextInt();
        //int k = stdIn.nextInt();
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //boolean heisei = true;
        
        System.out.println((double)t / x);
        
        //System.out.println();
        //System.out.print();
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++)
#define all(v) v.begin(), v.end()
#define pb push_back
//入力
#define vin(v,N) for(int i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(a);lin(b);
  if(a<10&&b<10)
    cout<<a*b;
  else
    cout<<-1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=200005,K=32;
PI a[N];
int dp[N][K];
int n,T;
bool cmp(PI a,PI b){
	return a.se*b.fi+b.se<a.fi*b.se+a.se;
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read(); T=read();
	For(i,1,n){
		a[i].fi=read(); a[i].se=read();
		a[i].se+=a[i].fi+1; a[i].fi++; 
	}
	sort(a+1,a+n+1,cmp);
	For(i,1,n+1)For(j,1,K-1)dp[i][j]=T+1;
	dp[1][0]=0;
	//For(i,1,n)cout<<a[i].fi<<" "<<a[i].se<<endl;
	int p=0;
	For(i,1,n+1)if(i<=n&&a[i].fi!=1){
		For(j,0,K-1)if(dp[i][j]<=T){
			dp[i+1][j+1]=min((ll)dp[i+1][j+1],dp[i][j]*a[i].fi+a[i].se);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		}
	}else {
		p=i; break;
	}
	sort(a+p,a+n+1);
	ll sum=0; int dq=p,ans=0;
	Rep(i,K-1,0)if(dp[p][i]<=T){
		while(dq<=n&&sum+a[dq].se+dp[p][i]<=T){
			sum+=a[dq].se; dq++;
		}
		ans=max(ans,i+dq-p);
	}
	writeln(ans);
}
/*
t t+1 (a+1)t+a+b+1
c(at+b)+d
a(ct+d)+b
act+bc+d
act+ad+b
b/(a-1)<d/(c-1)
*/

Measured memory_bytes: 31680
s = gets.chop
if s[0] == s[1] && s[1] == s[2]
  puts "No"
elsif s[0] == s[1] && s[2] == s[3]
  puts "Yes"
elsif s[0] == s[2] && s[1] == s[3]
  puts "Yes"
elsif s[0] == s[3] && s[1] == s[2]
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 3836
N, K = map(int, input().split())

"""
while N > K:
  N = abs(N - K)
  #print(N)

print(min(N, abs(N-K)))
"""
"""
m = -(-N//K)
print(abs(N - m*K))
"""

print(min(N%K, abs(N%K - K)))

Measured memory_bytes: 9096
N, Y = map(int, input().split())

for i in range(N + 1):
    for j in range(N + 1):
        if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
            if i >= 0 and j >= 0 and N >= i + j:
                print(i, j, N - i - j)
                quit()

else:
    print(-1, -1, -1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;
#include <queue>

using P = pair<int, int>;

int main(void){
    Cin(int, h, w);
    Vec2(int, 10, 10, c, 0);
    For(i, 10) For(j, 10) cin >> c[i][j];
    
    vector<int> s(10, -1);
    priority_queue<P, vector<P>, greater<P>> q;
    q.emplace(0, 1);
    while(!q.empty()){
        auto e = q.top();
        q.pop();
        if(s[e.second] != -1) continue;
        s[e.second] = e.first;
        For(i, 10){
            q.emplace(e.first + c[i][e.second], i);
        }
    }

    int ans = 0;
    Rep(h*w){
        Cin(int, i);
        if(i != -1) ans += s[i];
    }
    Cout(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define ms(a) memset(a,0,sizeof(a))
#define ms_inf(a) memset(a,0x3f,sizeof(a))
#define ms_ninf(a) memset(a,0xcf,sizeof(a))
#define pb push_back
#define mp make_pair
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define lc (o<<1)
#define rc (o<<1|1)
//#include<ext/pb_ds/priority_queue.hpp>
//typedef __gnu_pbds::priority_queue<no> heap;  //?????
typedef long long ll; 
typedef unsigned long long ull;
ull MOD=212370440130137957ll;
const int mod=1e9+7;
ll INF=1e18;
const int maxn=1e4+10;
const int maxl=70+10;
const double PI=acos(-1.0);
const double eps=1e-10;
mt19937_64 rng((ull)(new char));
int n,k;
pair<double,double>p[maxn],a[maxn];
const double W=sqrt(3);
vector<pair<double,int>>v[3];
double ans;
int sta[maxn];
void er(int i,int id)
{
	auto&w=v[i];
	_for(t,0,w.size())
	{
		if(w[t].second==id)
		{
			w.erase(w.begin()+t);
			return;
		}
	}
}

double tr(double y0)
{
	_for(i,0,n)sta[i]=0;
	int r=0;
	int out=0;
	for(r=v[2].size()-1;r>=0;--r)
	{
		++sta[v[2][r].second];++out;
	}
	r=0;
	int tot=v[1].size();
	int req=n-k;
	int li=tot-req;
	if(li<0)return 1e20;
	double ans=1e20;
	for(auto&w:v[1])
	{
		while(r<tot&&out>li)
		{
			if(!--sta[v[2][r].second])--out;
			++r;
		}
//		if(r>=tot)return ans;
		if(out>li)continue;
		double d1=p[w.second].second-y0;
		
		double x1=p[w.second].first-d1/W;
		double d2=p[v[2][r-1].second].second-y0;
		double x2=p[v[2][r-1].second].first+d2/W;
		ans=min(ans,fabs(x1-x2));
		if(++sta[w.second]==1)++out;
	}
	return ans;
}
int main()
{
	while(cin>>n>>k&&n)
	{
		_for(i,0,n)scanf("%lf%lf",&p[i].first,&p[i].second);
		ans=1e20;
		_for(i,0,3)v[i].clear();
		_for(i,0,n)
		{
			double&x=p[i].first,&y=p[i].second;
			v[0].pb({y,i});
			v[1].pb({W*x-y,i});
			v[2].pb({W*x+y,i});
		}
		_for(i,0,3)sort(v[i].begin(),v[i].end());
		for(auto&w:v[0])
		{
			int&id=w.second;
			ans=min(ans,tr(w.first));
			_for(t,1,3)er(t,id);
		}
		printf("%.12lf\n",ans*3);
	}
}


Measured memory_bytes: 3860
import sys


class Bigint:

    mod = 10**9 + 7

    def __init__(self, n):
        self.n = n % self.mod

    @classmethod
    def set_mod(cls, mod):
        cls.mod = mod

    @staticmethod
    def _to_int(n):
        t = type(n)
        if t == int:
            return n
        elif t == Bigint:
            return n.n
        else:
            raise

    @staticmethod
    def _to_bigint(n):
        t = type(n)
        if t == int:
            return Bigint(n)
        elif t == Bigint:
            return n
        else:
            raise

    def __str__(self):
        return f"{self.n}"

    def __add__(self, other):
        return Bigint(self.n + self._to_int(other))

    def __iadd__(self, other):
        self.n = (self.n + self._to_int(other)) % self.mod
        return self

    def __sub__(self, other):
        return Bigint(self.n - self._to_int(other))

    def __isub__(self, other):
        self.n = (self.n - self._to_int(other)) % self.mod
        return self

    def __mul__(self, other):
        return Bigint(self.n * self._to_int(other))

    def __imul__(self, other):
        self.n = (self.n * self._to_int((other))) % self.mod
        return self

    def __pow__(self, other):
        assert type(other) == int, "power should be integer"
        #
        if other < 0:
            return self ** (other % (self.mod-1))
        ret = Bigint(1)
        now = Bigint(self.n)
        while other > 0:
            if other & 1:
                ret *= now
            other >>= 1
            now *= now
        return ret

    def __truediv__(self, other):
        return self * (self._to_bigint(other) ** (self.mod-2))

    def __itruediv__(self, other):
        self *= (self._to_bigint(other) ** (self.mod-2))
        return self


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n, m, k = _ia()
    Bigint.set_mod(998244353)
    power = [Bigint(1)]
    for i in range(n-1):
        power.append(power[i] * (m-1))

    fact = Bigint(1)
    inv = [Bigint(1)] * n
    for i in range(1, n):
        fact *= i
        inv[i] = inv[i-1] * Bigint(i) ** (-1)

    ans = Bigint(0)
    for i in range(k+1):
        c = fact * inv[n-1-i] * inv[i]
        ans += (c * m * power[n-1-i])

    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 103408
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val r: Int = sc.nextInt()
    if (r < 1200) println("ABC")
    else if (2800 <= r) println("AGC")
    else println("ARC")
  }

}


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

#define MAX_N 200001
#define INF 0x3FFFFFFF

using namespace std;

struct interval {
  int l, r;
  int val;
};

bool operator<(const interval &a, const interval &b) {
  return a.val > b.val;
}

int a[MAX_N], idx[MAX_N], even[4 * MAX_N], odd[4 * MAX_N];

void initEven(int k = 0, int X = 0, int Y = MAX_N - 1) {
  if (X == Y) { even[k] = X & 1 ? INF : a[X]; return; }
  int M = (X + Y) / 2;
  initEven(2 * k + 1, X, M);
  initEven(2 * k + 2, M + 1, Y);
  even[k] = min(even[2 * k + 1], even[2 * k + 2]);
}

void initOdd(int k = 0, int X = 0, int Y = MAX_N - 1) {
  if (X == Y) { odd[k] = X & 1 ? a[X] : INF; return; }
  int M = (X + Y) / 2;
  initOdd(2 * k + 1, X, M);
  initOdd(2 * k + 2, M + 1, Y);
  odd[k] = min(odd[2 * k + 1], odd[2 * k + 2]);
}

int query(int *tree, int x, int y, int k = 0, int X = 0, int Y = MAX_N - 1) {
  if (x <= X && Y <= y) return tree[k];
  if (y < X || Y < x) return INF;
  int M = (X + Y) / 2;
  return min(query(tree, x, y, 2*k+1, X, M), query(tree, x, y, 2*k+2, M+1, Y));
}

void addInterval(priority_queue<interval> &pq, int l, int r) {
  if (l < r) {
    if (l & 1) pq.push(interval {l, r, query(odd, l, r - 1)});
    else pq.push(interval {l, r, query(even, l, r - 1)});
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    idx[a[i]] = i;
  }
  initEven();
  initOdd();
  priority_queue<interval> pq;
  pq.push(interval {1, n, query(odd, 1, n - 1)});
  vector<int> result;
  while (!pq.empty()) {
    interval iv = pq.top();
    pq.pop();

    result.push_back(iv.val);
    int second;
    if (idx[iv.val] & 1) second = query(even, idx[iv.val] + 1, iv.r);
    else second = query(odd, idx[iv.val] + 1, iv.r);
    result.push_back(second);

    addInterval(pq, iv.l, idx[iv.val] - 1);
    addInterval(pq, idx[iv.val] + 1, idx[second] - 1);
    addInterval(pq, idx[second] + 1, iv.r);
  }
  for (int r : result) printf("%d ", r);
  printf("\n");
  return 0;
}


Measured memory_bytes: 10636
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		boolean b=false;
		String str1=sc.next();
		String str2=sc.next();
		String str3=str1+str1;
		char [] ch2=str2.toCharArray();
		char [] ch3=str3.toCharArray();
		for(int i=0;i<str1.length();i++) {
			for(int j=0;j<str2.length();j++) {
				if(ch2[j]!=ch3[i+j])break;
				if(j+1==str2.length()&&ch2[j]==ch3[i+j]) {
					b=true;
				}
			}
		}
		if(b==true) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 26188
# coding: utf-8
# Your code here!

W = []
K = []
for i in range(10):
   W.append(int(input()))
   W.sort()
   W.reverse()
for i in range(10):
   K.append(int(input()))
   K.sort()
   K.reverse()

print(sum(W[0:3]), sum(K[0:3]))


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

int main(){
    int n;
    cin >> n;
    int c = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(a % 2) c++;
    }
    cout << (c%2 ? "NO" : "YES") << endl;
    return 0;
}

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

int main(){
  string a,b;
  cin >> a >> b;
  int x=stoi(a+b);
  double sq=sqrt(x);
  if(sq==(int)sq){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long L[] = new long[N];
		for(int i = 0 ; i < N  ; ++i){
			L[i]  = sc.nextLong();
		}
		Arrays.sort(L);
		long ret = 0;
		for(int i = 0 ; i < N ; ++i){
			for(int j = i + 1 ; j < N ; ++j){
				for(int k = j + 1 ; k < N ; ++k){
					if(L[i] == L[j] || L[j] == L[k]){
						continue;
					}
					if(L[i] + L[j] <= L[k]){
						continue;
					}
					++ret;
				}
			}
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 36104