akhauriyash/Code-Regression huggingface dataset:
let rec seq a b = if a > b then [] else a :: seq (a+1) b
let (>>=) x f = List.map f x |> List.concat

let len = 50
let costs = [|0;2;5;5;4;5;6;3;7;6|]

let cmp xs ys =
  let lx = List.fold_left (fun s (x, i) -> s+i) 0 xs in
  let ly = List.fold_left (fun s (y, i) -> s+i) 0 ys in
  if lx <> ly then lx - ly
  else
  let rec f xs ys =
    match xs, ys with
    | [], [] -> 0
    | _::_, [] -> -1
    | [], _::_ -> 1
    | ((x,i)::xs), ((y,j)::ys) ->
        if x <> y then x - y
        else if i <> j then i - j
        else f xs ys
  in f xs ys

let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let a = Array.init m (fun _ ->
    Scanf.scanf " %d" (fun x -> (costs.(x), -x, x)))
  |> Array.to_list
  |> List.sort compare
  in
  let ca, _, va = List.hd a in
  let la = max 0 (n - len) / ca in
  let ma = la * ca in

  let rec f th = function
    | [] -> if th = 0 then [[]] else []
    | (c, _, x) :: xs ->
        seq 0 (th / c) >>= fun i ->
          List.map (fun y -> (x, i) :: y) (f (th - i * c) xs)
  in

  let be =
    f (n - ma) a |> List.fold_left (fun ans xs ->
      let xs = List.sort (fun x y -> compare y x) xs in
      if cmp ans xs >= 0 then ans else xs) []
  in
  ((va, la) :: be) |> List.sort (fun x y -> compare y x)
  |> List.iter (fun (x, i) -> for n = 1 to i do Printf.printf "%d" x done);
  print_newline ()


Measured memory_bytes: 13696
import sys
import math

def insertion_sort(A, n, g):
	cnt = 0
	for i in range(g, n):
		v = A[i]
		j = i - g
		
		while j >= 0 and A[j] > v:
			A[j + g] = A[j]
			j = j - g
			cnt += 1

		A[j + g] = v

	return cnt

def shell_sort(A, n):
	cnt = 0
	m = math.floor(math.log(2 * n + 1) / math.log(3))
	print(m)

	G = [0 for i in range(m)]	
	G[0] = 1
	for i in range(1, m):
		G[i] = 3 * G[i - 1] + 1

	G.reverse()
	print(G[0], end = "")
	for i in range(1, m):
		print(" " + str(G[i]), end = "")

	print("")
	for i in range(m):
		cnt += insertion_sort(A, n, G[i])

	print(cnt)
	
	for i in range(n):
		print(A[i])


#fin = open("test.txt", "r")
fin = sys.stdin

n = int(fin.readline())
A = [0 for i in range(n)]

for i in range(n):
	A[i] = int(fin.readline())

shell_sort(A, n)

Measured memory_bytes: 47552
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int[] hoge = new int[3];
        int tmp;
        hoge[0] = a;
        hoge[1] = b;
        hoge[2] = c;
        //System.out.println(Arrays.toString(hoge));
        if(hoge[1] > hoge[2]){
        	tmp = hoge[1];
        	hoge[1] = hoge[2];
        	hoge[2] = tmp;
        	//System.out.println("fuga");
        }
        if (hoge[0] > hoge[1]) {
        	tmp = hoge[0];
        	hoge[0] = hoge[1];
        	hoge[1] = tmp;
        	//System.out.println("hoge");
        }
        if(hoge[1] > hoge[2]){
        	tmp = hoge[1];
        	hoge[1] = hoge[2];
        	hoge[2] = tmp;
        	//System.out.println("fuga");
        }

        System.out.printf("%d %d %d\n", hoge[0], hoge[1], hoge[2]);

	}
}


Measured memory_bytes: 26260
N, W = map(int, input().split())

item_list = [list(map(int, input().split())) for i in range(N)]

dp = [[0 for i in range(W + 1)] for j in range(N + 1)]

for i in range(N):
    for j in range(W + 1):
        if j - item_list[i][1] >= 0:
            dp[i + 1][j] = max([dp[i][j], dp[i][j - item_list[i][1]] + item_list[i][0]])
        else:
            dp[i + 1][j] = dp[i][j]

print(dp[-1][-1])


Measured memory_bytes: 25952
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	string s; cin >> s; int a = 0, b = 0;
	stringstream ss; ss << s; ss >> a;
	Rep(i, s.length()){
		b += s[i] - '0';
	}
	if(a % b == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
n,m=map(int,input().split())
z=n*(n-1)//2
l=[-1]*n
a=[1]*n
b=[input().split() for _ in range(m)]
c=[0]*m+[z]
def r(s):
  t=l[s]
  if t<0:
    return s
  else:
    l[s]=r(t)
    return l[s]
for i in range(m-1,-1,-1):
  x,y=map(lambda w:r(int(w)-1),b[i])
  if x!=y:
    z-=a[x]*a[y]
    l[x]=y
    a[y]+=a[x]
  c[i]=z
for x in c[1:]:
  print(x)

Measured memory_bytes: 50020
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   int n;
   cin>>n;

   vector<int> a(n);
   rep(i,n){
      cin>>a[i];
   }
   int rep=-1;
   bool f=true;
   rep(i,n){
      if(rep<=a[i]-1){
         rep=a[i]-1;
      }
      else if(rep==a[i]){
         rep=a[i];
      }
      else{
         f=false;
         break;
      }
   }
   f? cout<<"Yes":cout<<"No";
   return 0;
}


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

m = 0
manu = []

for i in range(1,N):
    if abs(a[m]) < abs(a[i]):
        m = i

for i in range(N):
    if a[m]*a[i] < 0:
        a[i] += a[m]
        manu.append([m,i])

if a[m] >= 0:
    for i in range(N-1):
        if a[i] > a[i+1]:
            a[i+1] += a[i]
            manu.append([i,i+1])

else:
    for i in range(N-1):
        if a[N-i-2] > a[N-i-1]:
            a[N-i-2] += a[N-i-1]
            manu.append([N-i-1,N-i-2])
    
print(len(manu))
for i in range(len(manu)):
    manu[i][0] += 1
    manu[i][1] += 1
    print(" ".join(list(map(str,manu[i]))))

Measured memory_bytes: 3064
import math
N = int(input())
Alist = list(map(int,input().split()))
box = [0]*(10**6+1)
sign = math.gcd(Alist[0],Alist[1])
Amax = max(Alist[0],Alist[1])
for i in range(0,len(Alist)):
    A = Alist[i]
    sign = math.gcd(sign, A)
    Amax = max(Amax, A)
    box[A] += 1
setwise = (sign == 1)
pairwise = (sign == 1)
Amax = math.sqrt(Amax)+1
for i in range(2,10**6+1):
    if sum(box[i::i]) >1:
        pairwise = False
        break
if setwise:
    if pairwise:
        print('pairwise coprime')
    else:
        print('setwise coprime')
else:
    print('not coprime')

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

int main() {
	int R[200000], n;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = -1000000000;
	int minv =  R[0];

	for (int j = 1; j < n; j++) {
//		if (maxv < R[j] - minv) {
//			maxv = R[j] - minv;
//		}
//		if (minv > R[j]) {
//			minv = R[j];
//		}
		maxv = max(maxv, R[j] - minv);
		minv = min(minv, R[j]);
	}

	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 3864
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int dp[1<<15];

int main(){
	while(1){
		int n,m; cin >> n >> m;
		if(n+m == 0) break;
		rep(i,1<<n) dp[i] = inf;
		vector<int> s(n), d(m);
		rep(i,n) cin >> s[i];
		rep(i,1<<n) dp[i] = inf;
		dp[0] = 0;
		rep(i,m) cin >> d[i], dp[0] += d[i];
		rep(bit,1<<n){
			int sum = 0;
			rep(i,n){
				if(bit>>i & 1) sum += s[i];
			}
			rep(i,n){
				if(bit>>i & 1) continue;
				int diff = 0;
				rep(j,m){
					if(d[j] < sum) continue;
					if(sum <= d[j] && d[j] <= sum + s[i]){
						diff += min(0,(sum + s[i] - d[j]) - (d[j] - sum));
					}
					if(sum + s[i] < d[j]) diff += -s[i];
				}
				chmin(dp[bit|(1<<i)], dp[bit] + min(diff,0));
			}
		}
		cout << dp[(1<<n)-1] << "\n";
	}
}


Measured memory_bytes: 3204
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<string> a,b;
  in n,m;
  cin>>n>>m;
  a.resize(n);
  b.resize(m);
  forn(i,n)
    cin>>a[i];
  forn(i,m)
    cin>>b[i];
  for(in x=0;x+m<=n;++x){
    for(in y=0;y+m<=n;++y){
      bool ok=1;
      forn(i,m){
	forn(j,m){
	  if(b[i][j]!=a[i+x][j+y])
	    ok=0;
	}
      }
      if(ok){
	cout<<"Yes"<<endl;
	return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll D, T, S;
	cin >> D >> T >> S;
	if(D <= T*S)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}







Measured memory_bytes: 3648
a=list(input())
b=list(input())
c=list(input())

flag=True
turn='a'

while flag:
    if turn=='a':
        if len(a)==0:
            winner='A'
            flag=False
        else:
            turn=a.pop(0)

    if turn=='b':
        if len(b)==0:
            winner='B'
            flag=False
        else:
            turn=b.pop(0)

    if turn=='c':
            if len(c)==0:
                winner='C'
                flag=False
            else:
                turn=c.pop(0)

print(winner)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int sort(void *a, void *b) {
	return *(int *)a - *(int *)b;
}

int main(void) {
	int n, q;
	int v, c = 0;
	int S[10000];
	int i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; ++i) {
		scanf("%d", &v);
		S[i] = v;
	}
	
	qsort(S, n, sizeof(int), sort);
	
	scanf("%d", &q);
	
	++q;
	while (--q) {
		scanf("%d", &v);
		for (i = 0; i < n; ++i) {
			if (S[i] == v) {
				++c;
				break;
			} else if (S[i] > v) {
				break;
			}
		}
	}
	
	printf("%d\n", c);
	
	return 0;	
}

Measured memory_bytes: 716
#include<stdio.h>
#include<string.h>
#include<math.h>
#define ll long long int

void sort(int array[],ll n){

ll i,j,temp;

for(i=0;i<n;i++)
{

    for(j=0;j<n;j++)
    {

        if (array[j] > array[j + 1])
            {
                temp = array[j];
                array[j] = array[j + 1];
                array[j + 1] = temp;
            }

    }



}




}



int main()
{


ll x,n,i,flag,ans,c;

flag=0;

scanf("%lld",&x);

   

    n=x;
    while(1)
    {   c=0;
        for(i=1;i<=sqrt(n);i++)
        {

            if(n%i==0)
            {
                c++;

            }
            if(c>1)
            {
                c=0;
                break;

            }

        }
        if(c==1)
        {   ans=n;
            break;

        }
        n++;





    }

   printf("%lld",ans);







    return 0;
}


Measured memory_bytes: 128
import itertools
N = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))
As.insert(0,0)
As.append(0)
cost1 = []
for a,b in zip(As[:-1],As[1:]):
    cost1.append(abs(a-b))
cost2 = []
for a,b in zip(As[:-2],As[2:]):
    cost2.append(abs(a-b))
original = sum(cost1)
# print(cost1)
# print(cost2)
for c1,c2,c3 in zip(cost1[:-1],cost1[1:],cost2):
    print(original -c1 - c2 + c3)

Measured memory_bytes: 17544
n=int(input())
if n==111:
    print(999)
elif n==119:
    print(991)
elif n==191:
    print(919)
elif n==199:
    print(911)
elif n==911:
    print(199)
elif n==919:
    print(191)
elif n==991:
    print(119)
elif n==999:
    print(111)


Measured memory_bytes: 2940
from functools import lru_cache
import sys


def count(n):
    c = 0
    for s in str(n):
        if s != "0":
            c += 1
    return c


@lru_cache()
def fact(n):
    if n == 0:
        return 1
    return n * fact(n - 1)


def C(i, j):
    return fact(i) // (fact(j) * fact(i - j))


def calc(N, K):
    if K==0:
        return 1
    if N < 10000:
        retval = 0
        for i in range(N + 1):
            if count(i) == K:
                retval += 1
        return retval

    keta = len(str(N))
    retval = C(keta - 1, K) * (9**K)
    retval += calc(int(str(N)[1:]),K-1)
    retval += (int(str(N)[0])-1)*calc(10**(keta-1)-1,K-1)
    return retval



N = int(input())
K = int(input())

print(calc(N,K))


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    ll n; cin>>n;
    ll N=3*n;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    /**for(auto k:a){
        cout<<k<<" ";
    }
    cout<<endl;
    **/
    ll ans=0;
    for(int i=1;i<=2*n;i+=2){
        ans+=a[i];
    }
    cout<<ans<<endl;
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  int avg = sum / n;
  int avg2 = avg + 1;
  int res = 0;
  int res2 = 0;
  for (int i = 0; i < n; ++i) {
    res += (a[i] - avg) * (a[i] - avg);
    res2 += (a[i] - avg2) * (a[i] - avg2);
  }
  if (res < res2) cout << res << '\n';
  else cout << res2 << '\n';
  return 0;
}
// x^2 - 2px + p^2 => sum(p^2 - 2px) = n p^2 - 2p * sum(x)


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    if (n < 10) {
      System.out.println(n);
      return;
    }

    String s = Long.toString(n);
    long tmp = (long) Math.pow(10, s.length()) - 1;
    long miner = (long) Math.pow(10, s.length() - 1);

    while (true) {
      if (tmp <= n) {
        String o = Long.toString(tmp);
        int a = 0;
        for (int i = 0; i < o.length(); i++) {
          a += Character.getNumericValue(o.charAt(i));
        }
        System.out.println(a);
        return;
      }

      tmp -= miner;
    }

  }
}

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



Measured memory_bytes: 3116
while True:
  n = int(input())
  if n==0:
    break

  s = []
  maxlen = 0
  for i in range(n):
    st = input()
    stt = ""
    for j in range(len(st)):
      if j==0 or st[j-1] in "aiueo":
        stt += st[j]
    s.append(stt)
    maxlen = max(maxlen, len(stt))
  ans = -1
  k = 1
  while k<=maxlen:
    code = set()
    for e in s:
      code.add(e[:k])
    if len(code)==len(s):
      ans = k
      break
    k += 1
  print(ans)


Measured memory_bytes: 5616
#include <cstdint>
#include <cstdio>
#include <utility>
#include <vector>

int main() {
  size_t n;
  intmax_t k;
  scanf("%zu %jd", &n, &k);

  std::vector<size_t> a(n);
  for (auto& ai: a) scanf("%zu", &ai), --ai;

  size_t res = 0;
  for (int j = 0; k >> j; ++j) {
    std::vector<size_t> na(n);
    for (size_t i = 0; i < n; ++i) na[i] = a[a[i]];
    if (k >> j & 1) res = a[res];
    a = std::move(na);
  }

  printf("%zu\n", res+1);
}


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

int main(){
    string s;
    while(cin >> s){
        int n = s.size();
        int l = -2, r = -2;
        for(int i = 0; i < n-1; ++i){
            if(s[i] == s[i+1]){
                l = i;
                r = i+1;
            }
        }
        for(int i = 0; i < n-2; ++i){
            if(s[i] == s[i+2]){
                l = i;
                r = i+2;
            }
        }
        ++l; ++r;
        cout << l << ' ' << r << endl;
    }
}


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

int main() {
  vector<int> v(3);
  for (int i = 0; i < 3; i++) {
    cin >> v.at(i);
  }
  
  int f = 0, s = 0;
  for (int i = 0; i < 3; i++) {
    if (v.at(i) == 5) {
      f++;
    } else if (v.at(i) == 7) {
      s++;
    }
  }
  
  if (f == 2 && s == 1) {
    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;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  REP(i, n) { cout << s[i] << t[i]; }
  cout << endl;
}

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

int main() {
	char A[4];
	int a[4];
	for (int i = 0; i < 4; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < 4; i++) {
		a[i] = A[i] - '0';
	}

	if (a[0] + a[1] + a[2] + a[3] == 7) {
		cout << a[0] << '+' << a[1] << '+' << a[2] << '+' << a[3] << "=7" << endl;
		return 0;
	}
	else if (a[0] + a[1] + a[2] - a[3] == 7) {
		cout << a[0] << '+' << a[1] << '+' << a[2] << '-' << a[3] << "=7" << endl;
		return 0;
	}
	else if (a[0] + a[1] - a[2] + a[3] == 7) {
		cout << a[0] << '+' << a[1] << '-' << a[2] << '+' << a[3] << "=7" << endl;
		return 0;
	}
	else if (a[0] + a[1] - a[2] - a[3] == 7) {
		cout << a[0] << '+' << a[1] << '-' << a[2] << '-' << a[3] << "=7" << endl;
		return 0;
	}
	else if (a[0] - a[1] + a[2] + a[3] == 7) {
		cout << a[0] << '-' << a[1] << '+' << a[2] << '+' << a[3] << "=7" << endl;
		return 0;
	}
	else if (a[0] - a[1] + a[2] - a[3] == 7) {
		cout << a[0] << '-' << a[1] << '+' << a[2] << '-' << a[3] << "=7" << endl;
		return 0;
	}
	else if (a[0] - a[1] - a[2] + a[3] == 7) {
		cout << a[0] << '-' << a[1] << '-' << a[2] << '+' << a[3] << "=7" << endl;
		return 0;
	}
	else if (a[0] - a[1] - a[2] - a[3] == 7) {
		cout << a[0] << '-' << a[1] << '-' << a[2] << '-' << a[3] << "=7" << endl;
		return 0;
	}


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a>=b&&a>=c){
    printf("%d\n",10*a+b+c);
    return 0;
  }
  if(b>=a&&b>=c){
    printf("%d\n",10*b+a+c);
    return 0;
  }
  if(c>=a&&c>=b){
    printf("%d\n",10*c+a+b);
    return 0;
  }
  return 0;
}
  

Measured memory_bytes: 128
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


# import re
# import array
# import copy
# import functools
# import operator

# import math
# import string
import fractions
# from fractions import Fraction
from fractions import gcd

# import collections
# import itertools
# import bisect

# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
from queue import Queue

# from itertools import accumulate

# from collections import deque
# from collections import Counter

from operator import mul
from functools import reduce

# def lcm(n,m):
#     return int(n*m/gcd(n,m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


# import random
# import time

n, t = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
a.append(sys.maxsize)

l_continuous = [[]]
l_distinct = []
k = 0

continuous_flag=0

i=0
while i<n:
    if a[i] + t >= a[i + 1]:
        continuous_flag=1
        l_continuous[k].append(i)
        i+=1
    else:
        if continuous_flag==1:
            l_continuous[k].append(i)
            continuous_flag=0
            k+=1
            l_continuous.append([])
        else:
            l_distinct.append(i)
            
        i+=1
del i

ans = 0
for i in range(len(l_continuous)):
    if l_continuous[i].__len__() > 0:
        ans += a[max(l_continuous[i])] - a[min(l_continuous[i])] + t
for i in range(len(l_distinct)):
    ans += t
print(ans)


Measured memory_bytes: 115696
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line0 = sc.nextLine();
		String line1 = sc.nextLine();
		String line2 = sc.nextLine();

		List<String> lines1 = Arrays.asList(line1.split(" "));
		List<String> lines2 = Arrays.asList(line2.split(" "));

		int ame = 0;
		int newAme = 0;
		for (int i = 0, o = 0; i < lines1.size(); o++) {
			newAme = newAme + Integer.parseInt(lines1.get(o));
			if (o == i) {
				for (int j = i; j < lines2.size(); j++) {
					newAme = newAme + Integer.parseInt(lines2.get(j));
					if (j == lines2.size() - 1) {
						if (ame < newAme) {
							ame = newAme;
						}
						newAme = 0;
						o = -1;
						i++;
						break;
					}
				}
			}

		}

		System.out.println(ame);
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define TEST int inox,t;cin>>t; for(inox=1;inox<=t;inox++)
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,n) for(i=n-1;i>=0;i--)
#define mp(x,y)  make_pair(x,y)
#define FAST    ios::sync_with_stdio(false); cin.tie(0);
#define modd 1000000007
using namespace std;
 
int main(){
ll k; cin>>k;
ll g=7; ll f=-1,c=1;
while(1){
	 g=g%k;
	// cout<<g<<" ";
	if(g==0){f=c;break;}
	c++; g*=10;g+=7;
	// cout<<g<<" ";
	if(c==10000000)break;
}
cout<<f;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int main()
{
    string s,t;
    cin >> s >> t;
    int sz = s.size();
    int sz_t = t.size();
    int res = sz_t;
    _for(i,0,sz){
        if(i + sz_t > sz) break;
        int c = 0;
        _for(j,0,sz_t){
            if(s[i+j] != t[j]) c++;
        }
        //cout << c << endl;
        res = min(res,c);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;





int main(void) {

    int odd=0,even=0;
    int n;
    cin>>n;
    rep(i,n){
        int d;
        cin>>d;
        if(d%2==1)odd++;
        else even++;
    }
    if(odd==0||even==0){
        fin(0);
        return 0;
    }
    if(odd%2==0){
        cout<<even+(odd-1)/2*2<<endl;
    } else {
        cout<<even+(odd-0)/2*2<<endl;
    }
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N , x, y, p, a, b;
  cin >> N;
  x = N / 15;
  y = N % 15;
  a = y / 3;
  b = y / 5;
  p = 15 * x * (y - a - b) + y *(y + 1)/2 - 3*a*(a + 1)/2 - 5*b *(b + 1)/2;
  cout << 60 * x * x + p << endl;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N, K;
    string s;
    cin >> N >> s >> K;
    rep(i, N){
        if(s[i] == s[K - 1])cout << s[i];
        else cout << "*";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 3000  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
    
N,K = map(int,input().split())
for i in range(1,K+1):
  print(cmb(N-K+1,i,p)*cmb(K-1,i-1,p)%p)

Measured memory_bytes: 9460
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    ll k;
    cin >> s;
    cin >> k;
    int n = sz(s);
    int hatu = 0;
    rep(i, n) {
        if (s[i] != '1') {
            hatu = i;
            break;
        }
    }
    if (k <= hatu) cout << 1 << endl;
    else cout << s[hatu] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
  	cin >> n >> m;
  	pair<int, string> data[n];
  	
  	for(int i=0;i<n;i++) data[i] = make_pair(0, "WA");
  
  	for(int i=0;i<m;i++) {
    	int a;
      	string s;
      	cin >> a;
        cin >> s;
      	
      	if(s == "AC") {
          	data[a-1].second = "AC";

        } else {
        	if("WA" == data[a-1].second) data[a-1].first += 1;
        }
    }
  
  	int ac = 0;
  	int wa = 0;
  	
  	for(int i=0;i<n;i++) {
      
    	if(data[i].second == "AC") {
          	ac += 1;
            wa += data[i].first;
        }
    }
  	cout << ac << " " << wa << endl;
}

Measured memory_bytes: 6528
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABA solver = new ABA();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();
            if (b % a == 0)
                out.println(a + b);
            else
                out.println(b - a);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
 
using namespace std;
 
int main() {
  int A, B, K;
  cin >> A >> B >> K;
  int d;
  
  if (A > B) {
    d = A;
  } else {
    d = B;
  }
 
  int count = 0;
  while (count < K) {
    if (A % d == 0 && B % d == 0) {
      count++;
    }
    d--;
  }
  cout << (d+1);
  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	double l; cin >> l;
	cout << setprecision(12) << l/3*l/3*l/3;
}

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


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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 <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

struct MyStruct {
	int idx, a, b, pl;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.pl != t.pl)
		return s.pl > t.pl; // 降順
	return s.idx < t.idx;
}



int main() {

	int a, b;
	cin >> a >> b;

	if (b%a == 0) {
		ANS(a + b);
	}
	else {
		ANS(b - a);
	}


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<ctype.h>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<utility>
#define For(a,b) for(int i=(a);i<(b);i++)
#define Rep(n) for(int i=0; i<(n); ++i)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
//----------program from here----------

int main(){
    ull A=0,B=0;
    cin >> A >> B;
    if((A+B)&1) cout << "IMPOSSIBLE" << endl;
    else cout << (A+B)/2 << endl;
}

Measured memory_bytes: 256
import itertools
import math
n = int(input())
m = math.factorial(n)
l = [list(map(int,input().split())) for i in range(n)]
x,y = [list(i) for i in zip(*l)]
z = list(range(n))
z = list(itertools.permutations(z))
ans = 0
for i in range(m):
    for j in range(n - 1):
        ans += math.sqrt((x[z[i][j]] - x[z[i][j+1]]) ** 2 + (y[z[i][j]] - y[z[i][j+1]]) ** 2)
print(ans / m)

Measured memory_bytes: 13920
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        int m=0;
        int t=1;
        while(n>0){
          if(n%10==1){
            m+=9*t;
        
          }else if(n%10==9){
            m+=t;
           
          }else{
             m+=n%10*t;
            
          }
          n/=10;
          t*=10;
        }
        // 出力
        System.out.println(m);
    }
}


Measured memory_bytes: 21332
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  SORT(s);
  bool test = true;
  REP(i,s.size()-1){
    if(s[i+1] == s[i]) test = false;
  }
  yes(test);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define ll long long

using namespace std;

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    if(ceil(double(a)/k)*k <= b) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
w = []
for i in range(n) :
    w.append(input())

check = []
for i in range(len(w)-1):
    if w[i][-1] == w[i+1][0] :
        check.append(True)
    else :
        check.append(False)

if len(w) == len(list(set(w))) and all(check) :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3060
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0

for a in range(K + 1):
    for b in range(K - a + 1):
        if a + b > N:
            continue
        # 左からa個、右からb個取り出す
        get = []
        get += V[:a]
        get += list(reversed(V))[:b]
        # (a+b)回操作した時点でのスコア
        tmp = sum(get)

        # まだ操作出来るなら、負の数を取り除く
        get.sort()
        for i in range(min(K - a - b, len(get))):
            if get[i] < 0:
                tmp += -get[i]
        ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 74076
#include <iostream>
#include <set>

int main() {
  int AB;
  int BC;
  int CA;

  std::multiset<int> mst;

  std::cin >> AB >> BC >> CA;
  mst.insert(AB);
  mst.insert(BC);
  mst.insert(CA);

  int tmp = 1;
  int count = 0;

  for (auto i : mst) {
    if (count < 2) {
      tmp *= i;
      count += 1;
    }
  }
  std::cout << tmp / 2 << std::endl;
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(str, input().split())
T = list(str(input()))

output = []
all_score = 0
for i in range(N):
    if T[i] == "r":
        point = P
        te = "r"
    elif T[i] == "s":
        point = R
        te = "s"
    elif T[i] == "p":
        point = S
        te = "p"
    if i-K >=0:
        if output[i-K] == te:
            point = 0
            te = "None"
    all_score += int(point)
    output.append(te)

print(all_score)

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

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 5;
int na, nb, m, a[N], b[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    cin >> na >> nb >> m;
    forn(i, na) cin >> a[i];
    forn(i, nb) cin >> b[i];
    int res = *min_element(a, a+na) + *min_element(b, b+nb);
    forn(i, m) {
        int x, y, c;
        cin >> x >> y >> c;
        --x, --y;
        res = min(res, a[x] + b[y] - c);
    }
    cout << res << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

#define ll long long
#define tc                int T;cin>>T;while(T--)
int a[100000];
int main()
{
	int n, c, b, k ; cin >> n >> k;
	for (int& e : a)cin >> e;
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int e = i + 1; e <= i + k; ++e) {
			if (e < n)
				if ((dp[i] + abs(a[e] - a[i])) < dp[e])
					dp[e] = dp[i] + abs(a[e] - a[i]);
		}
	}
	cout << dp[n - 1] << '\n';
	return 0;
}


Measured memory_bytes: 1024
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  D,T,S = readint()
  
  if D <= T*S 
    println("Yes")
  else
    println("No")
  end

end

main()


Measured memory_bytes: 183640
import sys
input=sys.stdin.readline
n,k,c=map(int,input().split())
s=input().rstrip()
nc=[0]*n
co=0
d=c+1
for i in range(n):
    if s[i]=='x':
        d+=1
    else:
        if d>=c:
            d=0
            co+=1
            nc[i]+=1
        else:
            d+=1
    if co==k:
        break
sn=list(s)
sn.reverse()
co=0
d=c+1
for i in range(n):
    if sn[i]=='x':
        d+=1
    else:
        if d>=c:
            d=0
            co+=1
            nc[n-1-i]+=1
        else:
            d+=1
    if co==k:
        break
co=0
da=c+1
db=c+1
for i in range(n):
    if s[i]=='x':
        da+=1
    else:
        if da>=c:
            da=0
            co+=1
            nc[i]+=1
        else:
            da+=1
    if co==k:
        break
    if sn[i]=='x':
        db+=1
    else:
        if db>=c:
            db=0
            co+=1
            nc[n-1-i]+=1
        else:
            db+=1
    if co==k:
        break
for i in range(n):
    if nc[i]==3:
        print(i+1)






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

int n;
vector<int> p;

int main()
{
	cin >> n;
	p.resize(n + 1);

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

	int result = 0;

	for(int i = 1;i < n;i++)
	{
		if(p[i] == i)
		{
			swap(p[i] , p[i + 1]);
			result++;
		}
	}

	if(p[n] == n) result++;

	cout << result << endl;
	return 0;
}


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

const int MOD = 1000000007;

vector<int> Power2;

void initPower2(int n){
    ll rtn=1;
    for(int i=0; i<=n; i++){
        Power2.push_back(rtn);//0乗は1
        rtn *= 2;
        rtn %= MOD;
    }
}

ll gcd(ll c, ll d){//c*d=0をもとから除外
    if(c<d)
        swap(c,d);
    while(c%d!=0){
        c %= d;
        swap(c,d);
    }
    return d;
}

//C_i = A_i/B_iが同じものは同一視
//
//C_i = 0/0 -> xyでカウント
//C_i = 1/0 -> xでカウント
//C_i = 0/1 -> yでカウント
//C_i > 0 ->seme
//C_i < 0 ->uke

int main(){
    
    ll n; cin >>n;
    initPower2(n);
    
    ll c,d;
    
    int xy0=0;
    
    map<pair<ll,ll>, pair<int, int>> yuri;
    
    for(int i=0; i<n; i++){
        cin >> c >> d;
        if(!c && !d){//(0,0)
            xy0++;
        }
        else if(!c){//(0,b)
            yuri[{0,1}].first++;
        }else if(!d){//(a,0)
            yuri[{0,1}].second++;
        }else if((c/abs(c))==(d/abs(d))){//傾き正
            
            ll g = gcd( abs(c), abs(d) );
            yuri[{abs(c)/g, abs(d)/g}].first++;
        }else{//傾き負
            
            ll g = gcd( abs(c), abs(d) );
            yuri[{abs(d)/g, abs(c)/g}].second++;
        }
    }
    
    ll ans = 1;
    
    for( auto p : yuri){
        int yuriri = Power2[(int)p.second.first]-1;
        yuriri += Power2[(int)p.second.second];
        yuriri %= MOD;
        ans *= yuriri;
        ans %= MOD;
    }
    
    ans = (ans-1+xy0+MOD)%MOD;
    cout << ans << endl;
}


Measured memory_bytes: 16388
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  while(cin>>n,n){
    int q=12,o=1;
    while(q--){
      cin>>a>>b;
      n-=a-b;
      if(o&&n<=0){
        cout<<12-q<<endl;
        o--;
      }
    }
    if(o)cout<<"NA"<<endl;
  }
}

Measured memory_bytes: 2976
#include <stdio.h>

char change(char c){
  if(c>='A'&&c<='Z')return c+'a'-'A';
  return c;
}

int b_end(char W[]){
  char T[12]="END_OF_TEXT";
  int j,b=1,i;
  for(j=0; j<11; j++){
    if(T[j]!=W[j])break;
    if(j==10)b=0;
  }
  if(!b) return 1;
  else return 0;
}
int main(){
  char W[11],T[1001];
  int ans=0,i,j=0,k,b=1;
  for(i=0; i<11; i++){
    scanf("%c",&W[i]);
    W[i]=change(W[i]);
    if(W[i]=='\n')break;
  }
while(b){
    scanf("%s",&T);
    if(b_end(T)){
      b=0;
      break;
    }
    for(k=0; k<i; k++){
      T[k]=change(T[k]);
      if(T[k]!=W[k])break;
      if(k==i-1&&T[k+1]=='\0')ans+=1;
    }
    // printf("1 %s\n",T);                                                      
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 544
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        long ans_1=100_000_000_000_000L;
        long ans_2=100_000_000_000_000L;
        for (int i=1;i<Math.sqrt(N)+1;i++) {
            if (N%i==0) {
                if ((i+N/i)<(ans_1+ans_2)) {
                    ans_1 = i;
                    ans_2 = N/i;
                }
            }
        }
        System.out.println((ans_1+ans_2-2));
    }
}

Measured memory_bytes: 21844