akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '{';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "}");
    return o;
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

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

    int n, k;
    cin >> n >> k;
    vi hs(n);
    F0R (i, n)
        cin >> hs[i];
    vi dp(n, 1e9);
    dp[n - 1] = 0;
    for (int i = n - 2; ~i; --i)
        for (int j = i + 1; j < min(n, i + k + 1); ++j)
            ckmin(dp[i], dp[j] + abs(hs[i] - hs[j]));
    dout << dvar(dp) << endl;

    cout << dp[0] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

int n;

int main()
{
    cin >> n;
    int ans = 0;
    rrep(i,n) ans += i;
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0509-input.txt"));
		while (true) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			int c = scan.nextInt();
			if (a == 0 && b == 0 && c == 0)
				break;

			int n = scan.nextInt();

			int[] part = new int[a + b + c + 1];
			int[][] fail = new int[n][3];

			for (int i = 0, j = 0; i < n; i++) {
				int x = scan.nextInt();
				int y = scan.nextInt();
				int z = scan.nextInt();
				int r = scan.nextInt();
				if (r == 1) {
					part[x] = 1;
					part[y] = 1;
					part[z] = 1;
				} else {
					fail[j][0] = x;
					fail[j][1] = y;
					fail[j][2] = z;
					j++;
				}
			}
			for (int i = 0; i < n && fail[i][0] > 0; i++)
				if (part[fail[i][0]] + part[fail[i][1]] + part[fail[i][2]] == 2) {
					if (part[fail[i][0]] == 0)
						part[fail[i][0]] = -1;
					if (part[fail[i][1]] == 0)
						part[fail[i][1]] = -1;
					if (part[fail[i][2]] == 0)
						part[fail[i][2]] = -1;
				}
			for (int i = 1; i < part.length; i++)
				if (part[i] == 1)
					System.out.println(1);
				else if (part[i] == 0)
					System.out.println(2);
				else
					System.out.println(0);
		}

		scan.close();
		System.exit(0);
	}

}

Measured memory_bytes: 39252
s = input()[::-1]
size = len(s)
s += "4"

ans = 0
bef = 0

for i in range(size):
    v1 = int(s[i])
    v2 = int(s[i+1])
    if v1+bef>=6 or (v1+bef>=5 and v2>=5):
        ans += 10-(v1+bef)
        bef = 1
    else:
        ans += (v1+bef)
        bef = 0

ans += bef
print(ans)

Measured memory_bytes: 5492
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
//#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

int main() {
    
    int H,W;
    while(cin >> H >> W){
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(i % 2 == 0){
                    if(j % 2 == 0) cout << "#";
                    else cout << ".";
                }else{
                    if(j % 2 == 0) cout << ".";
                    else cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
#include <stdio.h>
#include <math.h>

int main(void) {
	double x1, y1, x2, y2;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	printf("%f", hypot(x1 - x2, y1 - y2));

	return 0;
}

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

using namespace std;

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

int a, b, c;

bool init() {
	cin >> a >> b >> c;
	return a != -1 || b != -1 || c != -1;
}

char solve() {
	if (a == -1 || b == -1) return 'F';
	if (a + b >= 80) return 'A';
	if (a + b >= 65) return 'B';
	if (a + b >= 50 || c >= 50) return 'C';
	if (a + b >= 30) return 'D';
	return 'F';
}

int main() {
	while (init()) {
		cout << solve() << endl;
	}
}


Measured memory_bytes: 3072
#include <stdio.h>

int main(){
  int n, l;
  scanf("%d %d", &n, &l);
  int sum = (l + (l + n - 1)) * n / 2;
  if(1 - l < 1){
    printf("%d\n", sum - l);
  }else if(1 - l <= n){
    printf("%d\n", sum);
  }else{
    printf("%d\n", sum - (l + n - 1));
  }
  return 0;
}


Measured memory_bytes: 128
/* ex 7_3
   Stuartyg */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int height,width,i,j;
    char **array;
    int *col;
    int *row;

    scanf("%d %d",&height,&width);

    //メモリ確保
    //各行の配列へのポインタ分のメモリ領域を確保
    array = (char**)calloc(height,sizeof(char*));

    if (array == NULL){ //確保失敗
        exit(1);
    }

    for (i= 0;i<height;i++ ){
        //各行の要素分のメモリ領域を確保
        array[i] = (char*)calloc(width,sizeof(char));
        if (array[i] == NULL){ //確保失敗
            exit(1);
        }
    }
    //配列col,rowの分のメモリ領域を確保
    col = (int*)calloc(width, sizeof(int));
    if (col == NULL){ //確保失敗
        exit(1);
    }
    row = (int*)calloc(height,sizeof(int));
    if (row == NULL){ //確保失敗
        exit(1);
    }

    for (i=0;i<height;i++){
        for(j=0;j<width;j++){
            scanf(" %c",&array[i][j]); //array[i][j]の値の受取り

            //白しかない行、列があるかのチェック       
            if (array[i][j] == '#'){ //黒を含む
                row[i] = 1;
                col[j] = 1;
            }
        }
    }

    //出力
    for (i=0;i<height;i++){
        if(row[i] == 1){ //行には黒を含む
            for (j=0;j<width;j++){
                    if (col[j] == 1){ //列にも黒を含む
                        printf("%c", array[i][j]);
                    }
            }
            printf("\n"); //1行出力するごとに改行
        }
    }

    //メモリ領域の開放
    for (i= 0;i<height;i++ ){
        //各行の要素分のメモリ領域を開放
        free(array[i]);
    }

    //各行の配列へのポインタ分のメモリ領域を開放
    free(array);

    free(col);
    free(row);

    return 0;
}



Measured memory_bytes: 1632
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	static class State implements Comparable<State>{
		int x, y, cost, foot;
		State(int foot, int y, int x, int cost){
			this.foot=foot;
			this.y=y;
			this.x=x;
			this.cost=cost;
		}
		public int compareTo(State s) {
			return this.cost-s.cost;
		}
	}

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int w=sc.nextInt();
				int h=sc.nextInt();
				if(w+h==0) break;
				int INF=100000000;
				int[][] board=new int[h+1][w+1];
				int[][][] dist=new int[2][h+1][w+1];
				for(int i=1; i<=h; i++) {
					for(int j=1; j<=w; j++) {
						String str=sc.next();
						if(str.equals("S")) board[i][j]=-1;
						else if(str.equals("T")) board[i][j]=-2;
						else if(str.equals("X")) board[i][j]=INF;
						else board[i][j]=Integer.parseInt(str);
					}
				}
				PriorityQueue<State> pq=new PriorityQueue<>();
				for(int k=0; k<2; k++) {
					for(int i=1; i<=h; i++) {
						for(int j=1; j<=w; j++) {
							dist[k][i][j]=INF;
							if(board[i][j]==-1) {
								pq.add(new State(k, i, j, 0));//あらかじめ左startと右startいれておく
							}
						}
					}
				}

				while(!pq.isEmpty()) {//foot:0左 1右
					State state=pq.poll();
					if(dist[state.foot][state.y][state.x]<state.cost) continue;
					dist[state.foot][state.y][state.x]=state.cost;
					for(int j=1; j<=3; j++) {
						for(int i=-2; i<=2; i++) {
							if(j+Math.abs(i)<=3) {
								int ny=state.y+i;
								int nx=state.x+(state.foot==0?j:-j);
								if(0>ny || ny>h || 0>nx | nx>w) continue;
								if(board[ny][nx]==INF) continue;
								if(dist[1-state.foot][ny][nx]<INF) continue;
								pq.add(new State(1-state.foot,ny, nx, state.cost+(board[ny][nx]>0?board[ny][nx]:0)));
							}
						}
					}
				}
				int ret=INF;
				for(int k=0; k<2; k++) {
					for(int i=1; i<=h; i++) {
						for(int j=1; j<=w; j++) {
							if(board[i][j]==-2) {
								ret=Math.min(ret, dist[k][i][j]);
							}
						}
					}
				}
				System.out.println(ret>=INF? -1:ret);
				


			}

		}

	}
}


Measured memory_bytes: 174260
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[5][105],f[5][105];
inline int read()
{
	char ch=getchar(),la;
	while (ch<'0' || ch>'9') la=ch,ch=getchar();
	int ans=0;
	while (ch<='9' && ch>='0')
	{
		ans=ans*10+ch-48;
		ch=getchar();
	}
	if (la=='-') ans=-ans;
	return ans;
}
void write(int x)
{
	if (x<0)
	{
		printf("-");
		x=-x;
	}
	if (x>9) write(x/10);
	putchar(x%10+48);
}
int main()
{
	int n=read();
	for (int i=1; i<=2; i++)
		for (int j=1; j<=n; j++) a[i][j]=read();
	for (int i=1; i<=2; i++)
		for (int j=1; j<=n; j++) f[i][j]=max(f[i-1][j],f[i][j-1])+a[i][j];
	write(f[2][n]); 
	return 0;
}

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

int main() {
	int tmp = 0;
	long ans = 0;
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == 'W') {
			ans += i - tmp;
			++tmp;
		}
	}
	cout << ans;
}

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

int main()
{
    int a, b;
    
    cin >> a >> b;
    if (a < b)
        cout << "a < b" << endl;
    else
    if (a > b)
        cout << "a > b" << endl;
    else
    if (a == b)
        cout << "a == b" << endl;

    
    
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if (A == 5){
        if (B == 5){
            if(C == 7){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
        }
        else if (B == 7){
            if (C == 5){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
        }
        else{
            cout << "NO" << endl;
        }
    }
    else if (A == 7){
        if (B == 5 && C == 5){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    else{
        cout << "NO" << endl;
    }
}

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

int gcd(int x,int y,int z){
  int w;
  for(int i= min(x,min(y,z));i>=1;i--){
    if(x%i == 0 && y%i == 0 && z%i == 0){
      w = i;
      break;
    }
  }
  return w;
}

int main(){
  long long n,ans=0;
  cin >> n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int h=1;h<=n;h++){
        ans += gcd(i,j,h);
      }
    }
  }
  
  cout << ans << endl;    
  
  return 0;
}

Measured memory_bytes: 3636
from fractions import gcd
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
a,b = map(int,input().split())
g = gcd(a,b)
c = collections.Counter(prime_factorize(g))
print(len(c)+1)

Measured memory_bytes: 5344
package main

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

var debug = false

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	var input string
	fmt.Scanf("%d", &n)
	if sc.Scan() {
		input = sc.Text()
	}
	arr := strings.Split(input, " ")
	var targets []int
	for _, i := range arr {
		ii, _ := strconv.Atoi(i)
		targets = append(targets, ii)
	}

	res := GetAnswer(n, targets)
	fmt.Printf("%v\n", res)
}

// GetAnswer ...
func GetAnswer(n int, inputs []int) int {
	prt("inputs: n:%d inputs%v", n, inputs)
	result := 0
	inputs = sortAsc(n, inputs)
	prt("sorted: inputs%v", inputs)

	alice := 0
	bob := 0
	for i, pt := range inputs {
		if i%2 == 0 {
			alice += pt
		} else {
			bob += pt
		}
	}
	result = alice - bob

	prt("%v\n", result)
	return result
}

func sortAsc(n int, inputs []int) []int {
	prt("bubble sort start: inputs%v", inputs)
	for i := 0; i < len(inputs)-1; i++ {
		for j := len(inputs) - 1; j > i; j-- {
			if inputs[i] < inputs[j] {
				tmp := inputs[i]
				inputs[i] = inputs[j]
				inputs[j] = tmp
				prt("sorting: i=%d, j=%d, %v", i, j, inputs)
			}
		}
	}
	return inputs
}

func prt(format string, inputs ...interface{}) {
	if debug {
		fmt.Printf(format+"\n", inputs...)
	}
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n, k, ans = 1e18;
  cin >> n >> k;
  n = k + n % k;
  for (int i = 0; i < 3; i++) {
    ans = min(ans, n);
    n = abs(n - k);
  }
  cout << ans;
  return 0;
}

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

anslist = []

if S < 10**9:
    for i in range(K):
        anslist.append(S)
    for i in range(N-K):
        anslist.append(S+1)
elif S == 10**9:
    for i in range(K):
        anslist.append(S)
    for i in range(N-K):
        anslist.append(1)

ansString = [str(i) for i in anslist]

print(" ".join(ansString))


Measured memory_bytes: 17048
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>
#include <cstring>
#include <bitset>

using namespace std;

typedef long double ld;
typedef long long li;
typedef vector<li> vec;
typedef vector<vector<li>> mt;
typedef pair<li, li> pll;

#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

double eps = 1e-9;
const int INF = 1e9 + 7;
const li LINF = 1e18 + 7;


int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

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

	vector<int> a(n);
	forn(i, n) {
		cin >> a[i];
	}

	vector<int> d(n + 1);
	for (int i = 1; i <= k; ++i) {
		d[i] = 1;
	}

	for (int i = k + 1; i <= n; ++i) {
		d[i] = d[i - k + 1] + 1;
	}

	int ans = d[n];
	for (int i = 1; i < n; ++i) {
		ans = min(ans, d[n - i + 1] + d[i]);
	}

	cout << ans << endl;
}

	

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int count = 0;
	REP(i,a){
		i<=b-1 ? count+=c : count+=d;
	}
	cout << count << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int x, y;
    cin >> x >> y;

    int prize[206]{0};
    prize[1] = 300000;
    prize[2] = 200000;
    prize[3] = 100000;

    int moni = prize[x] + prize[y];
    if (x == 1 && y == 1)
        moni += 400000;
    cout << moni << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  string s;
  cin>>s;
  for(int i=0;i<(int)s.size()-1;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 768
n = int(input())

def enable_move(old_pos, new_pos):
    old_t, old_x, old_y = old_pos
    new_t, new_x, new_y = new_pos
    t = new_t - old_t
    d = abs(new_x - old_x) + abs(new_y - old_y)
    if t < d:
        return False
    return ((t - d) % 2 == 0)

ans = "Yes"
old_pos = [0, 0, 0]
for _ in range(n):
    new_pos = [int(s) for s in input().split()]
    if not enable_move(old_pos, new_pos):
        ans = "No"
        break
    old_pos = new_pos
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <map>
 
#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
 
using namespace std;
 
using ll = long long;
 
typedef stack<int> IntStack;
typedef queue<int> IntQueue;
typedef vector<int> IntVector;
typedef list<int> IntList;
 
typedef struct S{
  int a;
  int b;
} Object;
 
int main(){
  int N, K;
  cin >> N >> K;
  
  ll sum  = 0;
  ll min, max;
  for(long long i=K;i<=N;i++){
    if(i == 1){
      min = 0;
    }else if(i == 2){
      min = 1;
    }else{
      min = i*(i-1)/2;
    }
    max = i*(2*N-i+1)/2;
    sum += (max-min+1);
    sum = sum%1000000007;
  }
  sum++;
  
  cout << sum << endl;
    
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,0,sizeof(p));
#define mp make_pair;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);}

int main() {
	fast();
	int a,b;
	cin>>a>>b;
	if (a>=13) cout<<b<<endl;
	else if (a>=6) cout<<b/2<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	int a,b,h ;
      	a = sc.nextInt();
      	b = sc.nextInt();
     	h = sc.nextInt();
      System.out.println((a+b)*h/2);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    map<ll,ll>mp;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        mp[x]++;
    }
    vector<ll>v;
    ll ans=0,x=0,y=0;
    for(map<ll,ll>::iterator it=mp.begin();it!=mp.end();it++){
        ll x=it->first;
        if(it->second>=2)v.push_back(x);
        if(it->second>=4)ans=max(ans,x*x);
    }
    if(v.size()>1){
        x=v.back();
        v.erase(find(v.begin(),v.end(),x));
        y=v.back();
    }
    cout<<max(ans,x*y)<<endl;
}


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

int main(){
  int a,b,c;
  string ans;
  cin >> a >> b >> c;
  if(a+b+c>=22) ans="bust";
  else ans = "win";
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
function main(input) {
  var args = input.split(/\s|\n/);
  var animals = args[0] * 1;
  var turu = 0;
  var kame = animals;
  var footSum = 0;
  var correct = false;
  for (var i = 0;i < animals + 1;i++) {
    footSum = kame * 4 + turu * 2;
    if (footSum == args[1] * 1) {
      correct = true;
    }
    turu++;
    kame--;
  }
  if (correct) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
string s;
cin>>s;
ll ca=0;
ll cb=0;
rep(i,n){
if(s.at(i)=='#'){
ca++;}
else cb++;}
ll ans = min(ca,cb);
ll aa=0;
ll ab=0;
ll q=cb;
rep(i,n){
if(s.at(i)!='#'){
q--;}
else q++;
ans = min(q,ans);}
cout << ans << endl;}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[404],f[404][404],ans,f1[404][404];
int main()
{
	memset(f1,0x7f,sizeof(f1));
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		f[i][i]=a[i];
		f1[i][i]=0;
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=n-i;j++)
		{
			for(int k=j;k<j+i;k++)
			{
				if(f1[j][k]+f1[k+1][j+i]+f[j][k]+f[k+1][j+i]<f1[j][j+i])
				{
					f[j][j+i]=f[j][k]+f[k+1][j+i],f1[j][j+i]=f[j][j+i]+f1[j][k]+f1[k+1][j+i];
				}
			}
	//		cout<<f[j][j+i]<<' '<<f1[j][j+i]<<endl;
		}
	}
	cout<<f1[1][n]<<endl;
	return 0;
}


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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const int MAX = 2E5 + 100;

void upd(vector<int> &f, int pos, int del) {
	int siz = f.size();
	for(; pos < siz; pos |= pos + 1)
		f[pos] += del;
}

int get(vector<int> &f, int pos) {
	int ret = 0;
	for(; pos >= 0; pos = (pos & (pos + 1)) - 1)
		ret += f[pos];

	return ret;
}

int main() {
	int n;
	cin >> n;
	vector<int> x(n), y(n), res(n);
	vector<pair<int, int>> points;
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		points.push_back({x[i], y[i]});
	}

	sort(points.begin(), points.end());	
	// cout << '\n';
	// for(auto pp : points) {
	// 	cout << pp.first << ' ' << pp.second << '\n';
	// }

	// vector<int> f1(n + 1), f2(n + 1);
	// for(int i = 1; i <= n; i++) {
	// 	upd(f2, i, 1);
	// }

	// for(int i = 0; i < n; i++) {
	// 	int a = points[i].first, b = points[i].second;
	// 	res[i] = get(f1, b) + (get(f2, n) - get(f2, b - 1));
	// 	upd(f1, b, 1);
	// 	upd(f2, b, -1);
	// }

	// for(int i = 0; i < n; i++) {
	// 	cout << res[x[i] - 1] << '\n';
	// }

	set<int> s;
	for(int i = 1; i <= n; i++)
		s.insert(i);

	for(int i = 0; i < n; i++) {
		int j = i;
		int mn = points[i].second;
		s.erase(points[i].second);

		while(j + 1 < n && *s.rbegin() > mn) {
			j++;
			mn = min(mn, points[j].second);
			s.erase(points[j].second);
		}

		for(int k = i; k <= j; k++)
			res[points[k].first - 1] = j - i + 1;

		i = j;
	}

	for(int i = 0; i < n; i++)
		cout << res[x[i] - 1] << '\n';
}


Measured memory_bytes: 16680
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e5+200;
const int mod = 1e9+7;
int main() {
	string s,t;
	cin >> s >> t;
	cout << t << s;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		char[] input = Console.ReadLine().ToCharArray();
		char a = 'a';
		char z = 'z';
		char A = 'A';
		char Z = 'Z';
		if(a <= input[0] && input[0] <= z) Console.WriteLine("a");
		else Console.WriteLine("A");
	}
}



Measured memory_bytes: 25876
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD (int)1e9+7
int dx4[]={1,0,-1,0};
int dy4[]={0,-1,0,1};
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int n;scanf("%d",&n);
    printf("%d\n",n%2?n/2+1:n/2);
}

Measured memory_bytes: 128
#include <iostream>

void solve_t()
{
    int N;
    std::cin >> N;

    int dig = N % 10;
    if (dig == 2 || dig == 4 || dig == 5 || dig == 7 || dig == 9)
    {
        std::cout << "hon";
    }
    else if (dig == 0 || dig == 1 || dig == 6 || dig == 8)
    {
        std::cout << "pon";
    }
    else {
        std::cout << "bon";
    }
}

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

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

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	
	int n = s.length() + 1;
	//cout << n;
	int arr[n];
	fill(arr,arr+n,-1);
	
	for(int i = 0;i < n;i++){
		if(i == 0){
			if(s[0] == '<'){
				arr[0] = 0;
			}
		}
		else if(i == n-1){
			if(s[i-1] == '>'){
				arr[i] = 0;
			}
		}
		else{
			if(s[i-1] == '>' && s[i] == '<'){
				arr[i] = 0;
			}
		}
	}
	for(int i = 0;i < n;i++){
		if(arr[i] != 0 && i != 0 && s[i-1] == '<'){
			arr[i] = max(arr[i], arr[i-1]+1);
		}
	}
	
	for(int i = n-1;i >= 0;i--){
		if(arr[i] != 0 && i != n-1 && s[i] == '>'){
			arr[i] = max(arr[i], arr[i+1]+1);
		}
	}
	long long ans = 0;
	for(int i = 0;i < n;i++){
		//cout << arr[i] << " ";
		ans += arr[i];
	}
	cout << ans;
}


Measured memory_bytes: 2844
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, q;
  string s;
  scanf("%d %d", &n, &q);
  cin >> s;
  vector<int> a(n + 1, 0);
  for(int i = 0; i < n - 1; i++){
    if(s[i] == 'A' && s[i + 1] == 'C') a[i + 1] = a[i] + 1;
    else a[i + 1] = a[i];
  }
  for(int i = 0; i < q; i++){
    int b, e;
    scanf("%d %d", &b, &e);
    b--; e--;
    cout << a[e] - a[b] << endl;
  }
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    // b=1の場合(aプラグ必要なし)
    if(b==1) {
      System.out.println(0);
      System.exit(0);
    }
    // a>bの場合(aプラグが1つ必要)
    if(a>b) {
      System.out.println(1);
      System.exit(0);
    }

    // b>=2の場合(aプラグがn個必要)
    int ans = 1; // 最後のプラグ分を事前に加算
    b += -a;      // 最後のプラグは、穴がa個空いている
    --a;          // 最後のプラグ以外は、穴がa-1空いている
    if(b%a == 0)
      ans += b/a;
    else
      ans += b/a+1;

    System.out.println(ans);
  }
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;

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

  std::cin >> N;

  int res = N * N * N;
  std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string s; cin >> s;
  sort(s.begin(),s.end());
  COUT(s == "abc" ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
      int k;
      cin>>k;
      string s;
      cin>>s;
      if(s.ln<=k){
         cout<<s<<"\n";
         return 0;
      }
      rep(i,0,k){
         cout<<s[i];
      }
      cout<<"...\n";
   return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s,t("keyence");
    cin>>s;
    int cnt=0,n=s.size();
    rep(i,n){
        if(s[i]==t[i]) cnt++;
        else break;
    }
    rep(i,n){
        if(s[n-1-i]==t[6-i]) cnt++;
        else break;
    }
    if(cnt>=7) cout<<"YES";
    else cout<<"NO";
}

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

int main(void) {
    int N, M, L;
    long tmpSum;
    vector< vector<long> > matrix1;
    vector< vector<long> > matrix2;

    cin >> N >> M >> L;

    for(int i=0; i < N; i++) {
        vector<long> tmpVect1(M, 0);
        for(int j=0; j < M; j++)
            cin >> tmpVect1[j];
        matrix1.push_back(tmpVect1);
    }

    for(int i=0; i < M; i++) {
        vector<long> tmpVect2(L, 0);
        for(int j=0; j < L; j++)
            cin >> tmpVect2[j];
        matrix2.push_back(tmpVect2);
    }

    for(int i=0; i < N; i++) {
        for(int j=0; j < L; j++) {
            tmpSum = 0;
            for(int k=0; k < M; k++) {
                tmpSum += matrix1[i][k] * matrix2[k][j];
            }
            cout << tmpSum << (j == L-1 ? "" : " ");
        }
        cout << endl;
    }

    return 0;
}

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

#define ll long double

// Return the maximum volume.
ll maxvolume(ll s)
{
    // finding length
    ll length = s / 3;

    s -= length;

    // finding breadth
    ll breadth = s / 2;

    // finding height
    ll height = s - breadth;

    return length * breadth * height;
}

// Driven Program
int main()
{
    ll s;
    cin>>s;
    cout <<setprecision(14)<<maxvolume(s) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll n;
int main() {
	cin >> n;
	vector<ll> a(n), b(n);
	REP(i, n)a[i] = (i + 1) * 21000;
	b = a;
	reverse(ALL(b));
	REP(i, n) {
		ll c; cin >> c; c--;
		a[c] += i + 1;
	}
	REP(i, n) {
		if (i != 0)cout << " ";
		cout << a[i];
	}
	cout << endl;
	REP(i, n) {
		if (i != 0)cout << " ";
		cout << b[i];
	}
	cout << endl;
}



Measured memory_bytes: 896
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int N,M,S;
int dp[2][50][3001];
#define AMA (100000)
int solve(){
  memset(dp,0,sizeof(dp));
  int now;
  int next;
  int ret = 0;
  dp[1][0][0]=1;
  for(int m=1;m<=M;m++){
    now = m&1;
    next = now^1;
    memset(dp[next],0,sizeof(dp[next]));
    for(int id = 0;id<N*N;id++){
      for(int j=0;j<S;j++){
	if(!dp[now][id][j]) continue;
	if(j+m>S) break;
	//	printf("dp[%d][%d][%d] = %d , %d\n",m,id,j,dp[now][id][j],j+m);
	if(id==N*N-1 && j+m==S) ret+=dp[now][id][j]%AMA;
	else {
	  // printf("%d %d %d next = %d\n",m+1,id,j,dp[next][id][j]);
	  dp[next][id+1][j+m] += dp[now][id][j]%AMA;
	  dp[next][id][j] += dp[now][id][j]%AMA;
	}
      }
    }
  }
  return ret%AMA;
}
int main(){
  while(1){
    scanf("%d %d %d",&N,&M,&S);
    if(!N && !M && !S) break;
    printf("%d\n",solve());
  }
}

Measured memory_bytes: 2368
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#define rep(i,n) for(int i=0; i<n; ++i)

using namespace std;

int N, n;
int H,W;

char m[50][50];
bool used[26];
int U[26],D[26],L[26],R[26];


bool check(char ch){
  int z = ch-'A';
  for(int i=U[z]; i<=D[z]; ++i){
    for(int j=L[z]; j<=R[z]; ++j){
      if(m[i][j] != '.' && used[m[i][j]-'A'] == false) continue;
      if(m[i][j]!=ch) return false;
    }
  }
  return true;
}
void input(){
  int x;
  string str;
  cin >> H >> W;
  rep(i,H){
    cin>>str;
    rep(j,W){
      m[i][j] = str[j];
      if(m[i][j]=='.')continue;
      x=m[i][j]-'A';
      used[x] = true;
      U[x]=min(U[x],i);
      D[x]=max(D[x],i);
      L[x]=min(L[x],j);
      R[x]=max(R[x],j);
    }
  }
}

void init(){
  rep(i,26){
    U[i] = 50;
    D[i] = 0;
    L[i] = 50;
    R[i] = 0;
    used[i] = false;
  }
}
int main(){
  cin >> N;
  while(N--){
    init();
    input();
    while(1){
      bool flag = false;
      rep(i,26){
        if(used[i]==false)continue;
        if(check(i+'A')==true){
          used[i] = false;
          flag = true;
          break;
        }
      }
      if(flag == false) break;
    }
      bool flag = false;
      rep(i,26) flag |= used[i];
      cout << (flag ? "SUSPICIOUS" : "SAFE") << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_Therefore_168
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            string a = Console.ReadLine();

            string result;

            result = a.Substring(a.Length - 1, 1);

            int n = int.Parse(result);

            if (n == 3)
            {
                Console.WriteLine("bon");
            }
            else if(n == 0 || n == 1 || n == 6 || n == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27520
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

int a[1001][1001][3];
//3つ目の要素：0 = Jungle, 1 = Ocean, 2 = Ice

int main()
{
	int m, n, k;

	cin >> m >> n;
	cin >> k;
	memset(a, 0, sizeof(a));

	string str;

	for (int i = 1; i <= m; i++)
	{
		cin >> str;
		for (int j = 1; j <= n; j++)
		{
			for (int l = 0; l < 3; l++)
			{
				a[i][j][l] = a[i - 1][j][l] + a[i][j - 1][l] - a[i - 1][j - 1][l];
			}
			switch (str[j - 1])
			{
				case 'J':
					a[i][j][0]++;
					break;

				case 'O':
					a[i][j][1]++;
					break;

				case 'I':
					a[i][j][2]++;
					break;

				default:
					break;
			}
		}
	}

	for (int i = 0; i < k; i++)
	{
		int startx, starty, endx, endy;
		cin >> startx >> starty >> endx >> endy;
		
		for (int j = 0; j < 3; j++)
		{
			cout << a[endx][endy][j] - a[endx][starty - 1][j] - a[startx - 1][endy][j] + a[startx - 1][starty - 1][j];
			if (j != 2)
			{
				cout << " ";
			}
			else
			{
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 12960
n = int(raw_input())

x = 0
y = 0
t = 0
do = True
for i in range(0, n):
 z = raw_input().split(" ")
 nt = int(z[0])
 nx = int(z[1])
 ny = int(z[2])
 dt = nt - t
 dx = nx - x
 dy = ny - y
 t = nt
 x = nx
 y = ny
 
 if (abs(dx)+abs(dy))%2 != (dt)%2:
  do = False
  break
 if abs(dx)+abs(dy) > abs(dt):
  do = False
  break
if do:
 print "Yes"
else:
 print "No"


Measured memory_bytes: 5764
N = int(input().strip())
V = list(map(int, input().strip().split()))
C = list(map(int, input().strip().split()))
#print(N, V, C)
total = 0
for i in range(N):
    if V[i] > C[i]:
        total += V[i] - C[i]
print(total)

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;
ll n;
ll a[200000+5],pos[200000+5];
\
class UnionFind{
    private:
        vector<ll> parent,rank,tree_w;
    public:
        UnionFind(int size){
            for (int i=0; i<size; i++){
                parent.push_back(i);
                rank.push_back(0);
                tree_w.push_back(1);
            }
        }

        int findset(int x){
            return x==parent[x] ? x : parent[x]=findset(parent[x]);
        }

        void unite(int x,int y){
            x=findset(x);y=findset(y);
            if (x==y) return;
            if (rank[x]>rank[y]) swap(x,y);
            parent[x]=y;
            tree_w[y]+=tree_w[x];
            if (rank[x]==rank[y]) rank[y]+=1;
        }

        ll tree_weight(int x){
            return tree_w[findset(x)];
        }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    rep(i,n) pos[a[i]]=i;
    UnionFind uf(n);
    bool check[n]={};
    ll ans=0LL;
    rrep(i,n-1){
        ll l=max<ll>(pos[i]-1,0);
        ll r=min<ll>(pos[i]+1,n-1);
        ll lnum=1LL;
        ll rnum=1LL;
        if (check[l]){
            lnum+=uf.tree_weight(l);
        }
        if (check[r]){
            rnum+=uf.tree_weight(r);
        }
        if (check[l]){
            uf.unite(l,pos[i]);
        }
        if (check[r]){
            uf.unite(r,pos[i]);
        }
        check[pos[i]]=true;
        ans+=(i+1)*lnum*rnum;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int N, A, B,x,p1,p2;
	string ans;
	cin >> N >> A >> B;
	p1 = A * N;
	p2 = B;

	if (p1 <= p2) x = p1;
	else x = p2;

	cout << x << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int a,b;
  cin >> a >> b;
  if(a+b==15)cout << '+' << endl;
  else if(a*b==15)cout << '*' << endl;
  else cout << 'x' << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	long a,b,x,y,z,ans=0;

	cin >> a >> b >> x;

	if(a==0){
		y=0;
	}
	else{
		y=((a-1)/x)+1;
	}

		z=(b/x)+1;

	ans = z-y;

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

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
    ans += A[i] // 2
    A[i] %= 2
    if A[i] == 1 and i < N-1 and A[i+1] > 0:
        A[i+1] -= 1
        ans += 1
print(ans)

Measured memory_bytes: 13044
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp

v = {}
v["r"] = p
v["s"] = r
v["p"] = s

sum = 0
for i in 0...k do
  j = i
  prev = "."
  while j < n do
    if t[j] != prev
      sum += v[t[j]]
      prev = t[j]
    else
      prev = "."
    end
    j += k
  end
end
puts sum


Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(),x.end()
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define PI 3.1415926535897932384626
#define mod 1000000007
#define modd 998244353

void io() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	io();
	
	int n;
	string s;
	cin>>n>>s;
	int cnt=0;
	for(auto x:s)
		if(x=='R') cnt++;
	int ans=0;
	for(int i=0;i<cnt;i++)
		if(s[i]=='W') ans++;
	cout<<ans;
 	return 0;
}


Measured memory_bytes: 3728
#include    <stdio.h>

int main(void)
{
  int a, b, c, t;

  scanf("%d %d %d", &a, &b, &c);
  if (a > b) {
    t = a;
    a = b;
    b = t;
  }
  if (b > c) {
    t = b;
    b = c;
    c = t;
  }
  if (a > b) {
    t = a;
    a = b;
    b = t;
  }
  printf("%d %d %d\n", a, b, c);
  
  return 0;
}

Measured memory_bytes: 596