akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		    b[i] = sc.nextInt();
		    c[i] = sc.nextInt();
		}
		
		// 計算
		int result = 0;
		int[][] dp = new int[n][3];
		dp[0][0] = a[0];
		dp[0][1] = b[0];
		dp[0][2] = c[0];
		for(int i = 0; i < n-1; i++){
		    dp[i+1][0] = max(dp[i][1], dp[i][2]) + a[i+1];
		    dp[i+1][1] = max(dp[i][2], dp[i][0]) + b[i+1];
		    dp[i+1][2] = max(dp[i][0], dp[i][1]) + c[i+1];
		}
		result = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 94264
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
    int a,b,c,sum=0;
    cin>>a>>b>>c;
    sum=a+b+c;
    
    cout<<sum-max(a,max(b,c))<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    if((N%1==0&&N/1<=9)||(N%2==0&&N/2<=9)||(N%3==0&&N/3<=9)||(N%4==0&&N/4<=9)||(N%5==0&&N/5<=9)||(N%6==0&&N/6<=9)||(N%7==0&&N/7<=9)||(N%8==0&&N/8<=9)||(N%9==0&&N/9<=9)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


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

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

using namespace std;

int main(){
	string s; cin>>s;
	int ans=0;
	rep(i,4) ans+=(s[i]=='+'?1:-1);
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque, defaultdict
from fractions import gcd
from functools import reduce
from itertools import groupby, combinations
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return list(map(lambda x: x + d, A))
def ldec(A, d=1): return list(map(lambda x: x - d, A))

N = n1()

ans = 0
for i in range(1, N):
    ans += (N-1) // i 

print(ans)
    

Measured memory_bytes: 72900
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main()
{
    int n;
    cin >> n;
    for(int i = n; i < 1000; i++){
        int ii = i,flag[10] = {};
        while(ii){
            flag[ii%10]++;
            ii /= 10;
        }
        int cnt = 0;
        for(int j = 0; j < 10; j++){
            if(flag[j]) cnt++;
        }
        if(cnt == 1){
            cout << i << endl;
            return 0;
        }
    }
}

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

using i64 = int64_t;

struct Item{
    i64 w, v;
};

i64 dp[102][100005]={0};

int main(){
    int n, w;
    cin >> n >> w;
    vector<Item> v;
    v.push_back((Item){0, 0});
    for(int i=0;i<n;++i){
        i64 weight, value;
        cin >> weight >> value;
        v.push_back((Item){weight, value});
    }

    for(int i=0;i<=n;++i){
        for(int j=1;j<=w;++j)dp[i][j] = -1;
    }

    for(int i=0;i<n;++i){
        for(i64 j=0;j<w;++j){
            if(dp[i][j] < 0)continue;
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if(j+v[i+1].w <= w)dp[i+1][j+v[i+1].w] = max(dp[i+1][j+v[i+1].w], dp[i][j]+v[i+1].v);
        }
    }

    i64 ans = 0;
    for(int i=0;i<=w;++i)ans = max(ans, dp[n][i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 79104
#include<iostream>
using namespace std;
int main(){
	int Q;
	cin>>Q;
	
	int c,a,n;
	int team;
	
	for(int i=0;i<Q;i++){
		cin>>c>>a>>n;
		team=0;
		
		while(c>0&&a>0&&n>0){
			team++;
			c--;
			a--;
			n--;
		}
		
		while(c>1&&a>0){
			team++;
			c=c-2;
			a--;
		}
		
		while(c>2){
			team++;
			c=c-3;
		}
		
		cout<<team<<endl;
	}
	
	return 0;
}
		

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
	int N;
  	cin >> N;
  	ll A[N+1];
  	ll B[N];
  	ll count = 0;
  	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; i++){
		ll c = min(A[i], B[i]);
      	count += c;
      	ll d = min(A[i+1], B[i]-c);
      	count += d;
      	A[i+1] -= d;
    }
  	cout << count << endl;
}

Measured memory_bytes: 1792
<?php
$n = trim(fgets(STDIN));

$input = trim(fgets(STDIN));
$ints = explode(' ', $input);

$nums = [];
foreach($ints as $i => $int) {
    $nums_solo[$int][] = true;

    $nums[$i%2][$int][] = true;
}

if(count($nums_solo) == 1) {
    echo $n/2;
    exit;
}
if(count($nums[0]) == 1 && count($nums[1]) == 1) {
    echo 0;
    exit;
}

$e = $nums[0];
$o = $nums[1];

uasort($e, function($a, $b){
    return count($a) < count($b);
});
uasort($o, function($a, $b){
    return count($a) < count($b);
});

if(key($e) == key($o)) {
    $e0 = array_shift($e);
    $e1 = array_shift($e);
    $o0 = array_shift($o);
    $o1 = array_shift($o);
    $r1 = $n - (count($e0) + count($o1));
    $r2 = $n - (count($e1) + count($o0));
    echo $r1 < $r2 ? $r1 : $r2;
    exit;
}

$e = $nums[0];
$o = $nums[1];
usort($e, function($a, $b){
    return count($a) < count($b);
});
usort($o, function($a, $b){
    return count($a) < count($b);
});
echo $n - (count($e[0]) + count($o[0]));

Measured memory_bytes: 101236
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, N = 1100000;

int n, ch[N][26], tot = 1, sz[N], sum[N][26], isEnd[N];
ll ans;
char s[N];

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

void dfs(int now) {
	sz[now] = isEnd[now];
	for (R int i = 0, v; i <= 25; ++i) {
		if (!(v = ch[now][i])) continue;
		dfs(v);
		sz[now] += sz[v];
		for (R int j = 0; j <= 25; ++j) {
			if (i == j) continue;
			sum[now][j] += sum[v][j];
		}
		sum[now][i] += sz[v];
	}
	for (R int i = 0, v; i <= 25; ++i) {
		if (!(v = ch[now][i]) || !isEnd[v]) continue;
		ans += sum[now][i] - 1;
	}
	return;
}

int main() {
	read(n);
	for (R int i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		int m = strlen(s + 1), now = 1;
		reverse(s + 1, s + 1 + m);
		for (R int j = 1; j <= m; ++j) {
			if (!ch[now][s[j] - 'a'])
				ch[now][s[j] - 'a'] = ++tot;
			now = ch[now][s[j] - 'a'];
		}
		isEnd[now] = 1;
	}
	dfs(1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 269912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			}
		}
	}
}


Measured memory_bytes: 24348
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);
  const c = parseInt(input.split(" ")[2], 10);
  console.log(a+b+c-Math.max.apply(null, [a,b,c]));
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val a = readint()
    println(a + a * a + a * a * a)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

Measured memory_bytes: 34440
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
vector<int> edge[200005];
int n, m, vis[200005];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i ++) {
    int x, y; scanf("%d %d", &x, &y);
    edge[x].push_back(y); edge[y].push_back(x);
  }
  queue<pair<int, int> > Q;
  Q.push(make_pair(1, 0));
  while (!Q.empty()) {
    pair<int, int> tmp = Q.front(); Q.pop();
    if (tmp.second > 2) break;
    vis[tmp.first] = 1;
    for (vector<int>::iterator i = edge[tmp.first].begin(); i != edge[tmp.first].end(); i ++) {
      if (!vis[*i]) {
        Q.push(make_pair(*i, tmp.second + 1));
      }
    }
  }
  if (vis[n]) return printf("POSSIBLE\n"), 0;
  puts("IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 13552
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans = (n - 1) / (k - 1);
    if (n - 1) % (k - 1) != 0 {
        ans += 1;
    }

    return format!("{}", ans);
}


Measured memory_bytes: 4352
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    a, b, c = MAP()
    print(max(a*10 + b + c, a + b*10 + c, a + b + c*10))
    

if  __name__=='__main__':
    main()


Measured memory_bytes: 5384
#include<stdio.h>
int main(void){
    int W,H,x,y,r,a,b,c,d;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    b=x-r;
    a=x+r;
    c=y+r;
    d=y-r;
    if(W>=a && b>=0 && H>=c && d>=0){
        printf("Yes\n");
    }else if(b<=0 || a>=W || d<=0 || c>=H){
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
#[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;

fn main() {
    input!{
      x: i64,
      y: i64,
    }
    if (y-x).abs() <= 1 {
        println!("{}", "Brown");
    } else {
        println!("{}", "Alice");
    }
}


Measured memory_bytes: 4476
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 1000000000000
using namespace std;
using ll = long long;
bool ed[60][60]={};
ll ans = 0;
ll n,m;
void judge(ll v,ll res){
    ll count = 0;
    ll temp;
    for(ll i=1;i<=n;i++){
        if(ed[v][i]==true&&i!=res){
            count++;
            temp = i;
        }
    }
    if(count==1){
            ed[v][temp]=ed[temp][v]=false;
            ans++;
            judge(temp,v);
        }
}

int main(){
    cin >> n >> m;
    ll cnt[60]={};
    for(ll i=0;i<m;i++){
        ll x,y;
        cin >> x >> y;
        cnt[x]++;
        cnt[y]++;
        ed[x][y] = ed[y][x] = true;
    }
    for(ll i=1;i<=n;i++){
        if(cnt[i]==1){
            judge(i,0);
        }
    }
    cout << ans << endl;
}

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

struct P{
  double x, y;
};

void rec( int n, P left, P right ){
  if( n == 0 ) return;
  
  P s, t, u;
  s.x = ( 2 * left.x + right.x ) / 3;
  s.y = ( 2 * left.y + right.y ) / 3;
  t.x = ( left.x + 2 * right.x ) / 3;
  t.y = ( left.y + 2 * right.y ) / 3;
  u.x = ( t.x - s.x ) * cos( M_PI / 3 ) - ( t.y - s.y ) * sin( M_PI / 3 ) + s.x;
  u.y = ( t.x - s.x ) * sin( M_PI / 3 ) + ( t.y - s.y ) * cos( M_PI / 3 ) + s.y;

  rec( n - 1, left, s );
  printf( "%.8f %.8f\n", s.x, s.y );  
  rec( n - 1, s, u );
  printf( "%.8f %.8f\n", u.x, u.y );  
  rec( n - 1, u, t );
  printf( "%.8f %.8f\n", t.x, t.y );  
  rec( n - 1, t, right );
}

int main(){
  int n; cin >> n;
  printf( "%.8f %.8f\n", (double)0, (double)0 );
  rec( n, P{ 0, 0 }, P{ 100, 0 } );
  printf( "%.8f %.8f\n", (double)100, (double)0 );  
}



Measured memory_bytes: 3228
#include<cstdio>
const int sz = 50;
int n;
char s[110];
int d[200100][2];
int cnt[110][110];
void scanreal(int idx) {
	scanf("%s", s);
	long long int val = 0;
	int flag = 0;
	int divis = 0;
	for (int i = 0; s[i]; i++) {
		if (s[i] == '.') {
			flag = 1;
		}
		else {
			val *= 10;
			val += s[i] - '0';
			if (flag == 1)divis++;
		}
	}
	d[idx][0] = -divis;
	while (val % 2 == 0) {
		d[idx][0]++;
		val /= 2;
	}
	d[idx][1] = -divis;
	while (val % 5 == 0) {
		d[idx][1]++;
		val /= 5;
	}
	cnt[d[idx][0] + sz][d[idx][1] + sz]++;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanreal(i);
	}
	long long int ans = 0;
	for (int i = 0; i < 2 * sz; i++) {
		for (int j = 0; j < 2 * sz; j++) {
			if (i >= sz && j >= sz)ans -= cnt[i][j];
			for (int ii = 2 * sz - i; ii < 2 * sz; ii++) {
				for (int jj = 2 * sz - j; jj < 2 * sz; jj++) {
					ans += 1LL * cnt[i][j] * cnt[ii][jj];
				}
			}
		}
	}
	ans /= 2;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3264
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()

s2=["P" if x=="P" else "D" for x in s]
ans="".join(s2)
print(ans)

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const int MOD = 1000000007;
const int N = 202055;
const int M = 1211;

int a[N];
void solve() {
    int n;
    cin >> n;

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

    int x = 1;
    for (int i = 1; i <= n; i++){
        if (a[i] == x) x++;
    }
    x--;

    if (x == 0) cout << -1; else
        cout << n-x;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1024
import           Control.Monad
import qualified Data.Map      as M
import           Data.Maybe    (fromMaybe)
import           Debug.Trace

main :: IO ()
main = do
    [h, w] <- map read . words <$> getLine :: IO [Int]
    bs <- forM [1..h] $ \i -> do
        s <- map (== '#') <$> getLine
        return (zipWith (\j b -> ((i, j), b)) [1..] s)
    let m = M.fromAscList (concat bs)
    putStrLn $ if solve h w m then "Yes" else "No"

solve :: Int -> Int -> M.Map (Int, Int) Bool -> Bool
solve h w m = all f ls
    where
      ls = foldr (\a b -> zip (repeat a) [1..w] ++ b) [] [1..h]
      f (i, j)
          | not (m M.! (i, j)) = True
          | otherwise = let xs =
                                map (flip M.lookup m)
                                [
                                  (i+1, j)
                                , (i, j+1)
                                , (i-1, j)
                                , (i, j-1)]
                            g = fromMaybe False
                        in
                            any g xs



Measured memory_bytes: 1532
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j -= 1
    a[j + 1] = v
    print(*a)

Measured memory_bytes: 5980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    string S;
    cin >> S;
    int a = 0;
    int b = 0;
    int c = 0;
    for(int i = 0;i < S.size();i++) {
        if(S.at(i) == 'a') {
            a++;
        }
        else if(S.at(i) == 'b') {
            b++;
        }
        else {
            c++;
        }
    }
    if(max(a,max(b,c)) - min(a,min(b,c)) <= 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
template <class T>
struct segtree {
  // monoid f(X,X) -> X
  // 1. associative law f(f(a,b),c) = f(a,f(b, c))
  // 2. indentity element f(a, ie) = f(ie, a) = a
  // example) min, max, sum
 private:
  int n;
  vector<T> node;
  T IE;  // identity element of operation
  function<T(T, T)> operation;
  function<T(T, T)> update;
  /////////////////////////////////////////////////
  T query_sub(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return IE;
    } else if (a <= l && r <= b) {
      return node[k];
    } else {
      T vl = query_sub(a, b, 2 * k + 1, l, (l + r) / 2);
      T vr = query_sub(a, b, 2 * k + 2, (l + r) / 2, r);
      return operation(vl, vr);
    }
  }
  /////////////////////////////////////////////////
 public:
  segtree(size_t _n, T _IE, function<T(T, T)> _operation,
          function<T(T, T)> _update)
      : IE(_IE), operation(_operation), update(_update) {
    n = 1;
    while (n < _n) n *= 2;
    node = vector<T>(2 * n - 1, IE);
  }
  /////////////////////////////////////////////////
  void change(int i, T x) {
    i += n - 1;
    node[i] = update(node[i], x);
    while (i > 0) {
      i = (i - 1) / 2;
      node[i] = operation(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }
  /////////////////////////////////////////////////
  T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
  /////////////////////////////////////////////////
  T operator[](int i) { return node[i + n - 1]; }
};
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vecll h(n, 0), a(n, 0);
  REPe(e, h) cin >> e;
  REPe(e, a) cin >> e;
  auto f = [](ll a, ll b) -> ll { return max(a, b); };
  auto g = [](ll a, ll b) -> ll { return b; };
  segtree<ll> sgt(n + 1, 0LL, f, g);
  vecll dp(n, 0);
  // REP(i, n) { cout << sgt[i] << endl; }
  REP(i, n) {
    dp[i] = sgt.query(0LL, h[i]) + a[i];
    sgt.change(h[i], dp[i]);
  }
  ll ans = 0;
  REP(i, n) {
    ans = max(dp[i], ans);
    // cout << dp[i] << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

double deg2rad(double v){
    return (v/360.0)*(2*PI);
}

int main(void)
{
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double x1 = A*sin(deg2rad(360*((H+(M/60.0))/12.0)));
    double y1 = A*cos(deg2rad(360*((H+(M/60.0))/12.0)));

    double x2 = B*sin(deg2rad(360*(M/60.0)));
    double y2 = B*cos(deg2rad(360*(M/60.0)));

    double dist = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));

    printf("%.12f\n", dist);
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100001], b[100001];

bool solve() {
	sort(a, a + n);
	a[n] = -1;
	int c = 0;
	inc(i, n) {
		b[c]++;
		if(a[i] != a[i + 1]) { c++; }
	}
	
	if(c == 1) {
		return (a[0] == n - 1 || a[0] <= n / 2);
	}
	if(c == 2) {
		return (a[n - 1] - b[0] <= b[1] / 2 && b[0] <= a[0]);
	}
	return false;
}

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	cout << (solve() ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    string s;
    cin >> s;
    
    cout << ((s == "ABC") ? "ARC" : "ABC") << endl;

    return 0;
}

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

int main() {
	int A[4];
	cin >> A[0] >> A[1] >> A[2] >> A[3];
	sort(A, A + 4);
	if (A[0] == 1 && A[1] == 4 && A[2] == 7 && A[3] == 9) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    LL N,A,B;
    cin >> N >> A >> B;
    vector<int> v;
    if(A+B-1<=N&&N<=A*B){
        if(A==1){
            for(int i=N;i>0;i--){
                cout << i << (i==1?"\n":" ");
            }
            return 0;
        }
        int cnt=N-B;
        int t=N-cnt/(A-1)*A-cnt%(A-1);
        for(int i=1;i<t;i++){
            v.push_back(i);
        }
        for(int i=t+cnt%(A-1);i>=t;i--){
            if(t==0) break;
            v.push_back(i);
        }
        t+=cnt%(A-1);
        for(int i=0;i<cnt/(A-1);i++){
            for(int j=A;j>0;j--){
                v.push_back(t+i*A+j);
            }
        }
        for(int i=N-1;i>=0;i--){
            cout << v[i] << (i==0?"\n":" ");
        }
    }
    else puts("-1");
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  vector<int> D;
  
  for (int i = 0; i < 101; i++) {
    int count = 0;
    
    for (int j = 0; j < N; j++) {
      if (i == d.at(j)) {
        count ++;
      }
    }
    
    if (count > 0) {
      D.push_back(i);
    }
  }
  
  cout << D.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;
#define int ll
#define N 100005
#define pb push_back
#define pv(x) cout<<#x<<": ";for(auto k:x){ cout<<k<<" "; }cout<<endl;
#define dbg(x) cout<<#x<<": "<<x<<endl;

int n,m,ni,mi,k;
// int num[N];
int ok=false;

void solve(){
	cin >> k >> n;
	deque<int> v;
	for(int i=0;i<n;i++){
		cin >> ni;
		v.pb(ni%k);
	}
	sort(v.begin(),v.end());
	int mn= v[n-1]-v[0];
	for(int i=0;i<n;i++){
		mn=min(mn,k-(v[i+1]-v[i]));
	}
	cout<<mn<<endl;
}

int32_t main(){cin.tie(0);ios_base::sync_with_stdio(NULL);
	int t=1;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int a[5],check,ans,i;
  ans=0;
  check=0;
  rep(i,5){
    cin>>a[i];
    if(a[i]%10!=0&&a[i]%10<a[check]%10){
      check=i;
    }
  }
  int minus=10-a[check]%10;
  if(minus==10){
minus=0;
  }
  rep(i,5){
    rep(j,10){
      if(a[i]%10!=0){
        a[i]++;
      }
      else{
        ans+=a[i];
        break;
      }
    }
  }
  cout<<ans-minus<<endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 1050000000;
constexpr auto MOD = 1000000007;

int main() {
	int h, w;
	cin >> h >> w;
	vs s(h);
	rep(i, h)cin >> s[i];

	vvi lr(h, vi(w, 0));
	vvi ud(h, vi(w, 0));


	rep(i, h) {
		int k = 0;
		rep(j, w) {
			if (s[i][j] == '.') {
				lr[i][j] = k + 1;
				k++;
			}
			else k = 0;
		}

		rep(j, w - 1) {
			if (lr[i][w - 2 - j])
				lr[i][w - 2 - j] = max(lr[i][w - 2 - j], lr[i][w - 1 - j]);
		}
	}

	rep(j, w) {
		int k = 0;
		rep(i, h) {
			if (s[i][j] == '.') {
				ud[i][j] = k + 1;
				k++;
			}
			else k = 0;
		}

		rep(i, h - 1) {
			if (ud[h-2-i][j])
				ud[h - 2 - i][j] = max(ud[h - 2 - i][j], ud[h - 1 - i][j]);

		}
	}

	int ans = 0;

	rep(i, h)rep(j, w) {
		if (s[i][j] == '#')continue;
		ans = max(ans, ud[i][j] + lr[i][j] - 1);
	}

	cout << ans << endl;

}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

bool A[100];
 
int main(){
    int N, M, X;

    cin >> N >> M >> X;
    for(int i = 0; i < M; i++){
        int x;
        cin >> x;
        A[x] = true;
    }

    int r = 0, l = 0;

    for(int i = 0; i < X; i++){
        if(A[i]) l++;
    }

    for(int i = X+1; i < N; i++){
        if(A[i]) r++;
    }
    //cout << "r = " << r << endl;
    //cout << "l = " << l << endl;

    if(l < r) cout << l << endl;
    else cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n = 0;
    cin >> n;
    int A[1000];
    for(int i = 0; i < 1000; i++){
        A[i] = 0;
    }
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    int q = 0;
    cin >> q;
    for(int i = 0; i < q; i++){
        int b = 0, e = 0, k = 0;
        cin >> b >> e >> k;
        int count = 0;
        for(int j = b; j < e; j++){
            if(A[j] == k){
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
H,W = map(int, input().split())
a = []
a.append(''.join(['#'] * (W+2)))
for i in range(H):
    s = input()
    a.append('#'+s+'#')
a.append(''.join(['#'] * (W+2)))
for i in range(H+2):
    print(a[i])

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    int A1,A2,A3;
    cin >> A1 >> A2 >> A3;
    if((A1+A2+A3) >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int r = (a+b)/2;
		if ((a+b)%2==1) {
			r+=1;
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 21716
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;
const int mod = 1e9 + 7;



int main() {
	int h, w;
	string c[102];
	cin >> h >> w;
	rep(i, 0, h) {
		cin >> c[i];
	}
	rep(i, 0, 2*h) {
		print(c[i / 2]);
	}
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    L = Number(tmp0[0])
    R = Number(tmp0[1])
    
    if(R-L >= 2019)
    {
        console.log(0)
        return
    }
    L2 = L % 2019
    R2 = R % 2019

    ans = 2019
    if(L2 >= R2){
        console.log(0)
        return
    }
    for(i=L2; i < R2; i++)
    {
        for(j=i+1; j <= R2; j++)
        {
            ans = Math.min(ans, (i * j) % 2019)
        }
    }
    console.log(ans)
}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("2018 2021\n");

Measured memory_bytes: 7488
import java.util.Scanner;
public class Main {

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

		int n=sc.nextInt();
		
		switch(n%10) {
		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			
			break;
			
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			break;
			
		case 3:
			System.out.println("bon");
			break;
		}
		sc.close();
	}

}


Measured memory_bytes: 27032
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int X,Y,Z; cin >> X >> Y >> Z;
  int tmp = X;
  X = Y;
  Y = tmp;
  tmp = X;
  X = Z;
  Z = tmp;
  cout << X << " " << Y << " " << Z << endl;

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1e9; //1(1倍)e(指数)9(10^9)
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7; //1000000007で割った余りを聞かれたら使う
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    int n;
    scanf("%d", &n);
    printf("ABC%d\n", n);
    return 0;
}

Measured memory_bytes: 256
N, W = gets.split.map(&:to_i)

w = N.times.map { gets.split.map(&:to_i) }

dp = []
dp[0] = [0] * (W + 1)

1.upto(N) do |i|
  dp[i] = [0] * (W + 1)
  0.upto(W) do |j|
    if j >= w[i - 1][0]
      dp[i][j] = [dp[i - 1][j - w[i - 1][0]] + w[i - 1][1], dp[i - 1][j]].max
    else
      dp[i][j] = dp[i - 1][j]
    end
  end
end

puts dp[N][W]

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

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

signed main() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<pair<int, string>> v;
  for(auto i: mp) {
    v.push_back(make_pair(i.second, i.first));
  }
  sort(v.begin(), v.end());
  for(auto i: v) {
    if(i.first == v[v.size() - 1].first) {
      cout << i.second << endl;
    }
  }
}


Measured memory_bytes: 29552
#include<iostream>

using namespace std;

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

int main(){
	int n;
	while(cin>>n,n!=0){
		while(true){
			if(prime(n)&&prime(n-2)){
				cout<<n-2<<" "<<n<<endl;
				break;
			}
			n--;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
from itertools import *
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   for t in[f"({a} {x} {b}) {y} ({c} {z} {d})",f"(({a} {x} {b}) {y} {c}) {z} {d}",f"({a} {x} ({b} {y} {c})) {z} {d}"]:
    if eval(t)==10:return'('+t+')'
 else:return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;


#define pb push_back
#define ff first
#define ss second
#define INF int(3e9)
#define BIG_INF ll(9e18)
#define SIZE 100001
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define len(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout);


ll binpow(ll a, ll b, ll MOD = BIG_INF)
{
    ll res = 1;

    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= MOD;
        res %= MOD;
    }

    return res % MOD;
}

const ll mod = 1e9 + 7;

int T = 1;
ll n, m;
string s;
vector<int> a;

int to[256];


ll gcd(int a, int b)
{
    while(b)
    {
        a %= b;
        swap(a, b);
    }
    return a;
}

void solve()
{

    ll ans = 0;
    cin >> n;


    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            for(int k = 1; k <= n; k++)
            {
                ans += gcd(gcd(i, j), k);
            }
        }
    }


    cout << ans;
    return;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//    filein;fileout;

//    cin >> T;

    while(T--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3624
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve = calc . fromIntegral . head
  where
    calc r = 2 * pi * r 

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

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

int main(){
  int n;
  cin>>n;
  if(n<105){
    cout<<0<<endl;
  }else if(n<135){
    cout<<1<<endl;
  }else if(n<165){
    cout<<2<<endl;
  }else if(n<189){
    cout<<3<<endl;
  }else if(n<195){
    cout<<4<<endl;
  }else{
    cout<<5<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int ans=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length()-1;i++)
	{
		if(s.length()>=2)
		{
			if(s[i]!=s[i+1])
			{
				s.erase(i,2);
				if(i>=1)i-=2;
				else if(i==0)i--;
				ans+=2;
			}
		}
		else if(s.length()<2)break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
//Duplex Printing

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    float N;
    cin >> N;
    cout << ceil(N/2.0f) << endl;

    return 0;
}

Measured memory_bytes: 256
import math
N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]
d = A-B
high = 10**9
low = 0
while high-low>1:
    mid = (high+low)//2
    D = []
    for i in range(N):
        if H[i]-mid*B>0:
            D.append(H[i]-mid*B)
    cnt = 0
    for h in D:
        cnt += math.ceil(h/d)
    if cnt<=mid:
        high = mid
    else:
        low = mid
print(high)

Measured memory_bytes: 172244
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	// ios_base::sync_with_stdio(0);
	// cout.tie(0);
	// cin.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7')
		cout << "Yes";
	else
		cout << "No";



}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    int ans = -1;
    bool err = true;
    while(err)
    {
        for(int i = 0; i < N; i++)
        {
            if(A.at(i) % 2 != 0)
            {
                err = false;
            }
            else
            {
                A.at(i) /= 2;
            }
        }
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
#, setrecursionlimit, stdout
#setrecursionlimit(1000000)
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())
#mod=1000000007
res=['Yes', 'No']
############# CODE STARTS HERE #############

test_case=1
while test_case:
    test_case-=1

    v=[1]*110
    x, n=mi()
    for i in li():
        v[i]=0
    l=r=x
    while True:
        if v[l]:
            print(l)
            exit()
        elif v[r]:
            print(r)
            exit()
        l-=1
        r+=1

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

typedef long long ll;
#define EPSILON 1e-9
using namespace std;


int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("n.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    string s, t;
    cin >> s >> t;
    int c = 0;
    for (int i = 0; i < s.size(); i++) {
        c += (s[i] != t[i]);
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 3828
#include<stdio.h>
int main(){
  int x,y,max,sm;
  scanf("%d%d",&x,&y);
  if(x<y){
    sm=x;
    x=y;
    y=sm;
  }
  max=x%y;
  while(max!=0){
    x=y;
    y=max;
    max=x%y;
  }
  printf("%d\n",y);
  return 0;
  
}



Measured memory_bytes: 2144
from collections import deque
import sys
input=sys.stdin.readline
a,b=map(int,input().split())
e=[[]for i in range(a)]

for i in range(a-1):
  c1,c2=map(int,input().split())
  e[c1-1].append(c2-1)
  e[c2-1].append(c1-1)

g=[[]for i in range(a)]
f=deque([(0,-1)])
ans=[0 for _ in range(a)]
for i in range(b):
  ten,p=map(int,input().split())
  ans[ten-1]+=p
i=0
while len(f)!=0:
  i,fr=f.pop()
  for j in e[i]:
    if j==fr:
      continue
    else:
      ans[j]+=ans[i]
      f.append((j,i)) 
print(*ans)

    
  

  
  


Measured memory_bytes: 101452
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::map<int,int> mi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
int A[100010];
ll pow2[100010];
void make_pow2(){
  pow2[0]=1;
  rep1(i,100000){
    pow2[i]=(2*pow2[i-1])%MOD;
  }
}
int main(){
  make_pow2();
  cin>>N;
  rep(i,N) cin>>A[i];
  std::sort(A,A+N);
  bool f=true;
  if(N%2==0){
    rep(i,N/2){
      if(A[2*i]!=2*i+1||A[2*i+1]!=2*i+1){
	f=false;
	break;
      }
    }
  }
  else{
    if(A[0]!=0){
      f=false;
    }
    else{
      rep1(i,N/2){
	if(A[2*i-1]!=2*i||A[2*i]!=2*i){
	  f=false;
	  break;
	}
      }
    }
  }
  if(f){
    prin(pow2[N/2]);
  }
  else prin(0);

  
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int m,n;
int main()
{
    cin>>m>>n;
    if(m*10000<n)
	{
        cout<<"-1 -1 -1"<<endl;
        return 0;
    }
    if(m*1000>n)
	{
        cout<<"-1 -1 -1"<<endl;
        return 0;
    }
    if(n%1000!=0)
	{
        printf("-1 -1 -1");
        return 0;
    }
    for(int i=0;i<=m;i++)
    	for(int j=0;j<=m;j++)
    		for(int k=0;k<=m,i+j+k<=m;k++)
	       {
	            if(i+j+k==m && i*1000+j*5000+k*10000==n)
	            {
	                cout<<k<<" "<<j<<" "<<i<<endl;
	                return 0;   
	            }
	       }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256