akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var n int
	var ans string
	fmt.Scan(&n)
	for {
		amari := n % 26
		var c rune
		if amari == 0 {
			n -= 26
			c = 'z'
		} else {
			n -= amari
			c = rune(int('a') + (amari - 1))
		}
		ans = string(c) + ans
		if n == 0 {
			break
		}
		n /= 26
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1768
#https://atcoder.jp/contests/abc156/tasks/abc156_c

n=int(input())
x=list(map(int, input().split()))
x.sort()
minimum=10**23
for i in range(x[0],x[-1]+1):
    sum=0
    for l in x:
        sum+=(l-i)**2
    minimum=min(sum,minimum)
print(minimum)

Measured memory_bytes: 38512
s = list(input())
t = list(input())
ans = "Yes"
s.sort()
t.sort(reverse=True)
for i in range(len(s)):
    try:
        if t[i] > s[i]:
            break
        elif t[i] == s[i]:
            pass
        else:
            ans = "No"
    except:
        if len(t) < len(s):
            ans = "No"
if s == t:
    ans = "No"
print(ans)

Measured memory_bytes: 3064
n,k,s = map(int,input().split())
a=0
b=0

list=[]

for i in range(k):
    list.append(s)

if len(list) < n:
    for i in range(n-len(list)):
        if s == 1:
            list.append(s+1)
        else:
            list.append(s-1)

for i in list:
    print(i,end=" ")

Measured memory_bytes: 8116
#include <bits/stdc++.h>
using namespace std;
    
typedef long long ll;
typedef unsigned long long ull;
    
#define MOD 1000000007
#define mi 18446744073709551615



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin>>T;
  while(T--)
  {
    int n;
    cin>>n;
    cout<<n+n*n+n*n*n;
  }
  return 0;
}

Measured memory_bytes: 3632
n = int(input())
L = []
for i in range(n):
    s,p = input().split()
    L.append([i,s,int(p)])
L = sorted(L, key=lambda x:x[2])
L.reverse()
L = sorted(L, key=lambda x:x[1])
for i in range(n):
    print(L[i][0]+1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    int len = s.length();

    while (true) {
      len -= 2;
      s = s.substring(0, len);
      int half = len / 2;
      if (s.substring(0, half).equals(s.substring(half, len))) {
        System.out.println(len);
        return;
      }
    }
  }

}

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

typedef long long ll;

int main(){
	int n;
	ll a[52];
	cin >> n;
	for(int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	
	ll ret = 0;
	while(1){
		ll memo = ret;
		for(int i = 0 ; i < n ; i ++){
			ll x = a[i]/n;
			ret += x;
			a[i] %= n;
			for(int j = 0 ; j < n ; j ++){
				if(i!=j)a[j] += x;
			}
		}
		if(memo == ret)break;
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define EPS 0.00000001
using namespace std;

double eq(double x,double y){
  double z=abs(x-y);
  return z<EPS;
}
double di(double x1,double y1,double x2,double y2){
  return sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0));
}


int n;
double xa,ya,ra,xb,yb,rb;

int main(){
  cin>>n;
  while(n--){
    cin>>xa>>ya>>ra>>xb>>yb>>rb;
    if     (di(xa,ya,xb,yb)+rb<ra)cout<<2<<endl;
    else if(di(xa,ya,xb,yb)+ra<rb)cout<<-2<<endl;
    else if(di(xa,ya,xb,yb)<=ra+rb)cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
import sys
input = sys.stdin.readline
N = int(input())
s = list(input())[: -1]
d = ["S", "W"]
for i in range(2):
  for j in range(2):
    res = [d[i], d[j]]
    for k in range(1, N - 1):
      if (s[k] == "o" and res[k] == "S") or (s[k] == "x" and res[k] == "W"):
        if res[k - 1] == "S": res.append("S")
        else: res.append("W")
      elif (s[k] == "x" and res[k] == "S") or (s[k] == "o" and res[k] == "W"):
        if res[k - 1] == "S": res.append("W")
        else: res.append("S")
    if (s[0] == "o" and res[0] == "S") or (s[0] == "x" and res[0] == "W"):
      if res[-1] != res[1]:
        continue
    if (s[0] == "x" and res[0] == "S") or (s[0] == "o" and res[0] == "W"):
      if res[-1] == res[1]:
        continue
    if (s[-1] == "o" and res[-1] == "S") or (s[-1] == "x" and res[-1] == "W"):
      if res[-2] != res[0]:
        continue
    if (s[-1] == "x" and res[-1] == "S") or (s[-1] == "o" and res[-1] == "W"):
      if res[-2] == res[0]:
        continue
    print("".join(res))
    exit(0)
print(-1)

Measured memory_bytes: 64580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll m,n;
	cin>>n>>m;
	 ll left[m];
	 ll right[m];
	 for(int i=0;i<m;i++)
	 {
	 	cin>>left[i]>>right[i];
	 }
	 ll lo =left[0],hi=right[0];
	 //ll c=0;
	 for(int i=1;i<m;i++)
	 {
	 	if(hi<left[i]||lo>right[i])
	 	{	
	 		cout<<"0\n";
	 		return 0;
	 	}
	 	else
	 	{
	 	 		
	 			lo = max(left[i],lo);
	 			hi = min(right[i],hi);
	 		  
		 	
		}
	}
	cout<<hi-lo+1<<"\n"; 		
}

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

using namespace std;
#define mod 1000000007
#define int long long
int maxAbsValExpr(vector<int>& x, vector<int>& y) {
        int res = 0, n = x.size(), smallest, cur;
        for (int p : {1, -1}) {
            for (int q : {1, -1}) {
                smallest = p * x[0] + q * y[0];
                for (int i = 1; i < n; ++i) {
                    cur = p * x[i] + q * y[i];
                    res = max(res, cur - smallest);
                    smallest = min(smallest, cur);
                }
            }
        }
        return res;
    }
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
   // pre();
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    int i;
    for(i=0;i<n;i++)
        cin >> x[i] >> y[i];
    cout << maxAbsValExpr(x, y)  << '\n';
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int a=0;
	in(n);

	a = (n - (n % 15)) / 15;
	cout << 800 * n - 200 * a << endl;
	
	return 0;
}


Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	k := readInt()
	x := readInt()
	answer := solve(k, x)
	sort.Ints(answer)
	for _, a := range answer {
		fmt.Printf("%d ", a)
	}
	fmt.Println("")
}

func solve(k, x int) []int {
	var answer []int
	for i := x - k + 1; i < x + k; i++ {
		answer = append(answer, i)
	}
	return answer
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int[] a = new int[4];
			int[] b = new int[4];
			for(int i = 0;i < 4;i++){
				a[i] = scan.nextInt();
			}
			for(int i = 0;i < 4;i++){
				b[i] = scan.nextInt();
			}
			int hit = 0;
			int blow = 0;
			for(int i = 0;i < 4;i++){
				for(int j = 0;j < 4;j++){
					if(a[i] == b[j]){
						if(i == j){
							hit++;
						}else{
							blow++;
						}
					}
				}
			}
			System.out.println(hit + " " + blow);
		}
	}
}

Measured memory_bytes: 12000
import sys

N, C = map(int, sys.stdin.readline().split())

sushi_set = []
for i in range(N):
    x, v = map(int, sys.stdin.readline().split())
    sushi_set.append((x, v))
sushi_set.sort()

ans = -1

# 方向転換は一回まででと考えて良いのではないか？
# right
right = [0 for _ in range(N)]
max_n = -float("inf")
energy = 0
right_back = [0 for _ in range(N)]
for i, (x, v) in enumerate(sushi_set):
    energy += v
    if energy - x > max_n:
        max_n = energy - x
    right[i] = max_n
    right_back[i] = energy - 2 * x

# left
left = [0 for _ in range(N)]
max_n = -float("inf")
energy = 0
left_back = [0 for _ in range(N)]
for i, (x, v) in enumerate(sushi_set[::-1]):
    energy += v
    if energy - (C - x) > max_n:
        max_n = energy - (C - x)
    left[i] = max_n
    left_back[i] = energy - 2 * (C - x)

# print("right", right)
# print("right_back", right_back)
# print("left", left)
# print("left_back", left_back)

ans = max(max(right), max(left))
# print(ans)
# right -> left
for i in range(N-1):
    ans = max(ans, right_back[i] + left[N-2-i])
# left -> right
for i in range(N-1):
    ans = max(ans, left_back[i] + right[N-2-i])

print(max(ans, 0))

Measured memory_bytes: 38960
import math
n=int(input())
a=[]
for i  in range(2):
    s = list(map(int, input().split()))
    a.append(s)
d1=0
for i in range(n):
    d1+=abs(a[0][i-1]-a[1][i-1])
print(format(d1, '.6f'))
d2_1=0
for i in range(n):
    d2_1+=(abs(a[0][i-1]-a[1][i-1]))**2
d2=math.sqrt(d2_1)
print(format(d2, '.6f'))
d3_1=0
for i in range(n):
    d3_1+=(abs(a[0][i-1]-a[1][i-1]))**3
d3=(d3_1)**(1/3)
print(format(d3, '.6f'))
dn=0
for i in range(n):
    dn=max(abs(a[0][i-1]-a[1][i-1]),dn)
print(format(dn, '.6f'))


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

    string s, t; cin >> s >> t;
    bool ok = false;
    for( int i = (int)s.size() - (int)t.size() ; i >= 0 ; i-- ){
        bool p = true;
        for( int j = i ; j < i+(int)t.size() ; ++j ){
            if( s[j] != '?' && s[j] != t[j-i] ){
                p = false;
            }
        }
        if( p == true ){
            ok = true;
            for( int k = 0 ; k < i ; ++k ){
                if( s[k] == '?' ) cout << 'a';
                else cout << s[k];
            }
            cout << t;
            for( int k = i+(int)t.size() ; k < (int)s.size() ; ++k ){
                if( s[k] == '?' ) cout << 'a';
                else cout << s[k];
            }
            break;
        }
    }
    if( !ok ) cout << "UNRESTORABLE\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define vinn(n,v) int n;cin>>n;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define vinm(n,m,v) int n,m;cin>>n>>m;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define debug(x) cerr<<#x<<" : "<<x<<endl;
mt19937 rd(time(0)); // i = rd%n
int gcd(int a,int b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}
signed main() 
{
    fastio();
    int n,k;
    cin>>n>>k;
    cout<<min(n%k,((-n)%k+k)%k);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    vector<int> ans;
    while(true){
        int n;
        cin >> n;
        if(n == 0)break;

        vector<int> w(n);
        rep(i, n)cin >> w[i];

        ll dp[n+1][n+1] = {};

        //i個の達磨を考える
        for(int i = 2; i <= n; ++i){
            for(int l = 0; l+i-1 < n; ++l){
                int r = i+l-1;

                //真ん中が全部消せるのであればlとrが隣あう
                if(dp[l+1][r-1] == i-2 && abs(w[l] - w[r]) <= 1){
                    dp[l][r] = dp[l+1][r-1] + 2;
                }
                
                for(int c = l; c < r; ++c){
                    dp[l][r] = max(dp[l][r], dp[l][c] + dp[c+1][r]);
                }
             }
        }

        ans.push_back(dp[0][n-1]);
    }

    rep(i, ans.size())cout << ans[i] << endl;
}


Measured memory_bytes: 3864
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	a := readInt()
	b := readInt()
	if a+b == 15 {
		println("+")
	} else if a*b == 15 {
		println("*")
	} else {
		println("x")
	}
}


Measured memory_bytes: 640
import java.util.*;

class Main{

    char[] in;
    int p;

    void solve(){
	Scanner sc = new Scanner(System.in);

	int dataset = sc.nextInt();
	while(dataset-->0){
	    in = sc.next().toCharArray();
	    p = 0;
	    System.out.println(expr());
	}
    }

    int expr(){
	int a = term();
	while(in[p]=='+' || in[p]=='-'){
	    int enzan = 0;
	    if(in[p]=='-') enzan = 1;
	    p++;
	    int b = term();
	    if(enzan==0) a += b;
	    else a -= b;
	} 
	return a;
    }

    int term(){
	int a = factor();
	while(in[p]=='*' || in[p]=='/'){
	    int enzan = 0;
	    if(in[p]=='/') enzan = 1;
	    p++;
	    int b = factor();
	    if(enzan==0) a *= b;
	    else a /= b;
	} 
	return a;
    }

    int factor(){
	if(in[p]=='('){
	    p++;
	    int res = expr();
	    p++;
	    return res;
	}
	return digit();
    }

    int digit(){
	int res = 0;
	while(p<in.length-1 && Character.isDigit(in[p])){
	    res = res * 10 + (in[p]-'0');
	    p++;
	}
	return res;
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 17176
#include <algorithm>
#include <cassert>
#include <cctype>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

int p;
string s;

int expr(int& t);

int inv(int n)
{
    if(n == 0) throw 0;
    
    int r = 1;
    int t = n;
    for(int e = p-2; e; e >>= 1){
        if(e & 1) r = (r * t) % p;
        t = (t * t) % p;
    }
    return r;
}

int num(int& t)
{
    if(s[t] == '('){
        ++t;
        int v = expr(t);
        ++t;
        return v;
    }
    else{
        int v = 0;
        while(isdigit(s[t])){
            v = v * 10 + s[t++] - '0';
        }
        return v;
    }
}

int term(int& t)
{
    int a = num(t);
    while(s[t] == '*' || s[t] == '/'){
        char c = s[t++];
        int u = num(t);
        if(c == '/') u = inv(u);
        a = (a * u) % p;
    }
    return a;
}

int expr(int& t)
{
    int a = term(t);
    while(s[t] == '+' || s[t] == '-'){
        char c = s[t++];
        int u = term(t);
        if(c == '-') u *= -1;
        a = (a + u + p) % p;
    }
    return a;
}

string func(string str)
{
    p = stoi(str);
    
    stringstream sstr(str.substr(str.find(':') + 1));
    str = "";
    for(string t; sstr >> t;){
        str += t;
    }
    
    try{
        int t = 0;
        s = str + '\0';
        int v = expr(t);
        return str + " = " + to_string(v) + " (mod " + to_string(p) + ")";
    }
    catch(...){
        return "NG";
    }
}

int main()
{
    string str;
    while(getline(cin, str), str != "0:"){
        cout << func(str) << endl;
    }
}

Measured memory_bytes: 1784
#include<stdio.h>
int main()
{
    int i,j,r,c;
    while(scanf("%d%d",&r,&c))
    {
        if(r==0 && c==0)
            break;
        for(i=1;i<=r;i++){
            for(j=1;j<=c;j++){
                if(i%2!=0){
                    if(j%2!=0)
                        printf("#");
                        else
                            printf(".");
                }
                else if(i%2==0){
                        if(j%2!=0)
                        printf(".");
                else
                    printf("#");

                }

            }
            printf("\n");
        }
        printf("\n");
    }
}



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

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 2e5 + 5;

struct Edge{
	int to,w,nxt;	
}e[MAXN<<1];
int head[MAXN],cnt = 1;
int used[MAXN<<1];//1 正 2 反
int bk[MAXN];
inline void add(int u,int v,int w){
	e[++cnt] = (Edge){v,w,head[u]};head[u] = cnt;
	e[++cnt] = (Edge){u,w,head[v]};head[v] = cnt;
}

inline void dfs(int v){
	for(int &i = head[v];i;i = e[i].nxt){
		if(used[e[i].w]) continue;
		used[e[i].w] = 1+(i&1);
		dfs(e[i].to);
	}
}

std::vector<int> G[MAXN];
std::vector<P> edge;
int du[MAXN];
std::vector<int> T1[MAXN],T2[MAXN];
int sm[MAXN],val[MAXN],n,rt1,rt2;

inline void Dfs(int v,int opt){
	sm[v] = val[v];
	for(auto x:(opt?T2:T1)[v]){
		Dfs(x,opt);sm[v] += sm[x];
	}
}

inline bool check(){
	Dfs(rt1,0);
	FOR(i,1,n) if(std::abs(sm[i]) != 1) return 0;
	Dfs(rt2,1);
	FOR(i,1,n) if(std::abs(sm[i]) != 1) {DEBUG(i);return 0;}
	return 1;
}

int main(){
	#ifdef RainAir
	freopen("aa.in","r",stdin);
	freopen("aa.out","w",stdout);
	#endif
	scanf("%d",&n);//DEBUG(n);
	FOR(i,1,n){
		int f;scanf("%d",&f);
		if(f == -1) rt1 = i;
		else add(f,i,i),du[i]++,du[f]++;
		if(f != -1) T1[f].pb(i),G[f].pb(i);
	}
	FOR(i,1,n){
		int f;scanf("%d",&f);
		if(f == -1) rt2 = i;
		else add(f,i,n+i),du[i]++,du[f]++;
		if(f != -1) T2[f].pb(i);
	}
	add(n+1,rt1,2*n+1);add(n+1,rt2,2*n+2);
	++du[rt1];++du[rt2];
	FOR(i,1,n) if(du[i]&1) {puts("IMPOSSIBLE");return 0;}
	puts("POSSIBLE");
	FOR(i,1,n+1) bk[i] = head[i];
	dfs(n+1);
	FOR(i,1,n){
		int ans = 0;
		int ru=0,chu=0;
		for(auto x:G[i]) ans += used[x]==1?1:-1;
		int opt = i==rt1?used[2*n+1]:used[i];
		if(opt == 1) ans = 1-ans;
		else ans = -1-ans;
		printf("%d ",val[i] = ans);
	}
//	assert(check());
	return 0;
}


Measured memory_bytes: 32256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n;
int a[100];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	bool l = 1;
	int sum = 0;
	while (l) {
		l = 0;
		for (int i = n - 1; i > 0; i--) {
			if (a[i] < a[i - 1]) {
				swap(a[i], a[i - 1]);
				l = 1;
				sum++;
			}
		}
	}
	
	for (int i = 0; i < n; i++)
		cout << (i == 0 ? "" : " ") << a[i];
	cout << endl << sum << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	
	int n;
	cin >> n;
	cout << 800 * n - 200 * (n / 15);
}

Measured memory_bytes: 256
n,p=map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
num=factorization(p)
ans=1
for i in range(len(num)):
    ans*=num[i][0]**(num[i][1]//n)
print(ans)
 


Measured memory_bytes: 9420
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, x, y;std::cin >> n >> x >> y;
  vll a(n);
  re(i, n) std::cin >> a[i];
  std::cout << max(abs(a[n-1]-y), (n==1?0:abs(a[n-2]-a[n-1]))) << '\n';
  return 0;
}


Measured memory_bytes: 504
use std::io;

fn main() {
    let s = parse_line::<String>();
    let mut result = String::new();
    for _ in 0..s.len() {
        result.push('x');
    }
    println!("{}", result);
}

fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  ll h,w;cin>>h>>w;
  string MAP[h+1];
  ll dp[h+10][w+10]={};
  for(int i=0;i<h;i++)cin>>MAP[i];
  for(int i=0;i<h;i++){
    if(MAP[i][0]=='.')dp[i][0]=1;
    else break;
  }
  for(int j=0;j<w;j++)
    if(MAP[0][j]=='.')dp[0][j]=1;
    else break;
  for(int i=1;i<h;i++){
    for(int j=1;j<w;j++){
      if(MAP[i-1][j]=='.'){
	dp[i][j]=(dp[i][j]+dp[i-1][j])%MOD;
      }
      if(MAP[i][j-1]=='.'){
	dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
      }
    }
  }
  cout<<dp[h-1][w-1]<<endl;
  return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a;
int main() {
  cin >> n;
  read_n(a, n);
  i64 ans = 0;
  for (i64 i = 0, v = 1; i < n; ++i) {
    if (a[i] == v) {
      v++;
      continue;
    }
    ans += (a[i] - 1) / v;
    if (v == 1) v = 2;
  }
  cout << ans << endl;
  return 0;
}


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

#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef tuple<int, int, int> TP;
typedef vector<int> VI;
typedef double T;
typedef vector<T> VT;
typedef vector<VT> VVT;

const LL MOD = 1e9 + 7;
const double EPS = 1e-10;
mt19937 rng(7); // random generator using 7 for seed

const int MAXN = 1e5 + 10;

LL h[MAXN];
LL dp[MAXN];

int main() {
    int n;
    int k;
    scanf("%d%d", &n, &k);
    for(int i=1;i<=n;i++) {
        cin >> h[i];
    }
    for(int i=2;i<=n;i++) {
        dp[i] = -1llu/2;
        for(int j=1;j<=k && i-j>=1;j++) {
            dp[i] = min(abs(h[i]-h[i-j]) + dp[i-j], dp[i]);
        }
    }
    printf("%lld\n", dp[n]);
}

Measured memory_bytes: 1792
/*
 * A.cpp
 *
 *  Created on: 2017/06/18
 *      Author: jin
 */

#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
typedef std::complex<int> P;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}

const int maxalph = 30;
int r[maxalph], l[maxalph], bw[maxalph];
string alph = "abcdefghijklmnopqrstuvwxyz";
string s;
const int INF = 1000;

void count(char c) {
  int mini = INF, maxi = -1, maxb = -1;
  int size = s.size();
  int past = 0;
  for (int i = 0; i < size; ++i) {
    if (s[i] == c) {
      mini = min(mini, i);
      maxi = max(maxi, i);
      maxb = max(maxb, i - past - 1); //dabba
      past = i;
    }
  }
  int k = c - 'a';
  l[k] = (mini < 0 ? INF : mini);
  r[k] = (maxi < 0 ? INF : size - 1 - maxi);
  bw[k] = (maxb < 0 ? 0 : maxb);
}

void solve() {
  cin >> s;
  int ans = INF;
  for (char c = 'a'; c <= 'z'; ++c) {
    count(c);
    int k = c - 'a';
    ans = min(ans, max(l[k], max(r[k], bw[k])));
//    dbp4(c, l[k], r[k], bw[k]);
  }
  cout << ans << endl;
}

int main() {
  solve();
}



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

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

    rep(i,k){
        if(a<b&&b<c)break;
        if(a>=b)b*=2;
        else if(b>=c)c*=2;
    }

    cout << ((a < b && b < c) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3616
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let v:Vec<char> = buf.trim().chars().collect();
	let mut flag = true;
	if v[a as usize] == '-' {
		for i in 0..a {
			if v[i as usize] == '-' {
				flag = false;
				break;
			}
		}
		for i in (a+1)..(v.len() as i32){
			if v[i as usize] == '-' {
				flag = false;
				break;
			}
		}
		if flag {
			println!("Yes");
		}else{
			println!("No");
		}
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int a = fs.nextInt();
		int b = fs.nextInt();
		
		System.out.println(Math.max(a+b, Math.max(a-b, a*b)));
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21204
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;
 
int main()
{
    ll N;  cin >> N;
    ll i, j, k, a, b, tmp;
    for(ll i=1; i<=3500; i++){
        for(ll j=1; j<=3500; j++){
          	tmp = N*i*j;
            a = 4*i*j;
            b = N*(i+j);
            if(a > b){
                if(tmp % (a-b) == 0){
                    k = tmp / (a-b);
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int a,b;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>a>>b;
    vector<int> v;
    v.push_back(a+b);
    v.push_back(a-b);
    v.push_back(a*b);
    sort(v.begin(),v.end());
    cout<<v.back();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool alf[26];
int main(){
    string s;
    bool none=true;
    cin>>s;
    for(int i=0;i<s.size();i++){
        int num=s[i]-(int)'a';
        alf[num]=true;
    }
    for(int i=0;i<26;i++){
        if(!alf[i]){
            putchar((int)'a'+i);
            none=false;
            break;
        }
    }
    if(none)cout<<"None"<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    int i, j, n;
    string s, t;
    cin >> n >> s >> t;
    REP (i,n) {
        if (s.substr(i) == t.substr(0,n-i)) {
            cout << n + i << endl;
            return 0;
        }
    }
    cout << 2 * n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2

using namespace std;

int main() {
	int n, ans = 0;
	int mi = 99999999, x;
	scanf( "%d", &n );
	for( int i = 0; i < n; ++i ) {
		scanf( "%d", &x );
		mi = min( x, mi );
		if( x <= mi )
			++ans;
	}
	printf( "%d", ans );
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  


void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<int> touched(N,0);
  vector<int> ball(N,1);
  touched[0] = 1;
  for (int i = 0; i < M; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    // touched[A] |= 1;
    if(touched[A] == 1)
    touched[B] |=1;
  
    if(ball[A] == 0)continue;

    ball[A]--;
    ball[B]++;
    if(ball[A] == 0)touched[A] = 0;
  }

  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    if(touched[i] >0 && ball[i]> 0)ANS++;
  }
  cout<<ANS<<endl;
  
  
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

int main()
{
    int n,d,x,total,i,j;
    scanf("%d %d %d",&n,&d,&x);
    total=x;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&j);
        total+=(d-1)/j + 1;
    }
    printf("%d\n",total);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	const string a = "yuiophjklnm";
	string b;
	while (getline(cin, b)) {
		if (b.size() == 1 && b[0] == '#') {
			break;
		}
		int count = 0;
		int hantei;
		int mae;
		for (int i = 0; i < b.size(); i++) {
			if (i != 0) {
				mae = hantei;
			}
			hantei = 1;
			for (int j = 0; j < a.size(); j++) {
				if (b[i] == a[j]) {
					hantei = 0;
					break;
				}
			}
			if (i != 0) {
				if (hantei != mae) {
					count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

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

int main() {
  int x; cin >> x;
  if (x == 3 || x == 5 || x == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3116
N, X = map(int, input().split())
g = list(map(int, input().split()))
s = [0]
for gi in g:
    s.append(s[-1] + gi)

ans = float('inf')
for t in range(1, N + 1):
    m = 5 * s[N] + t * X
    for i in range(N - t * 2, 0, -t):
        m += 2 * s[i]
    ans = m if t == 1 else min(ans, m)
print(ans + N * X)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())


int N, M;
vi used;
vvi edges;

int dp(int now, int length){
    if (used[now]) return 0;
    if (length == N) return 1;

    int ans=0;
    used[now] = 1;

    for (int i = 0; i < N; i++) {
        if (edges[now][i]) {
            ans += dp(i, length+1);
        }
    }

    used[now] = 0;

    return ans;
}

void solve(){
    cin >> N >> M;
    used = vi(N,0);
    edges = vvi(N, vi(N,0));

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a][b] = 1;
        edges[b][a] = 1;
    }


    cout << dp(0, 1) << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n)  for(int i=0;i<(n);++i)
#define ALL(x) (x).begin(),(x).end()
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main() {
  int N;
  cin >> N;
  vector<string> W(N);
  bool multi = false;
  REP(i, N) {
    string s;
    cin >> s;
    if (count(ALL(W), s) > 0) {
      multi = true;
    }
    W.at(i) = s;
  }
  if (multi) {
    cout << "No";
  }
  else {
    bool succese = true;
    REP(i, N - 1) {
      if (W.at(i).at(W.at(i).size() - 1) != W.at(i + 1).at(0)) {
        cout << "No";
        succese = false;
        break;
      }
    }
    if (succese) {
      cout << "Yes";
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
// Charan Sriramula

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll lg=14;
const ll N=1e5+5;
const ll INF=1e9;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%lld",&n)
#define longp(n) printf("%lld\n",n)

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

ll n,a[N][4],dp[N][4];

int main()
{
  ll n;
  cin>>n;
  for(ll i=1;i<=n;i++){cin>>a[i][1]>>a[i][2]>>a[i][3];}
  dp[1][1]=a[1][1];
  dp[1][2]=a[1][2];
  dp[1][3]=a[1][3];
  for(ll i=2;i<=n;i++)
  {
    dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][3]);
    dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][3]);
    dp[i][3]=a[i][3]+max(dp[i-1][2],dp[i-1][1]);
  }
  cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        switch (a) {
        case "A":
            System.out.println("T");
            break;
        case "T":
            System.out.println("A");
            break;
        case "G":
            System.out.println("C");
            break;
        case "C":
            System.out.println("G");
            break;
        default:
        }
    }
}


Measured memory_bytes: 21844
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
a1, b1 = A[:N//2], sorted(A[N//2:], reverse=True)
a2, b2 = A[:N//2+1], sorted(A[N//2+1:], reverse=True)

cand1 = 2 * sum(b1[:len(a1) - 1]) + sum(b1[len(a1) - 1:]) - (2 * sum(a1[:len(b1) - 1]) + sum(a1[len(b1) - 1:]))
cand2 = 2 * sum(b2[:len(a2) - 1]) + sum(b2[len(a2) - 1:]) - (2 * sum(a2[:len(b2) - 1]) + sum(a2[len(b2) - 1:]))
print(max(cand1, cand2))

Measured memory_bytes: 9044
def func(n):
    return n*(n+1)//2

def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    ans = 0
    for i in range(1,N+1):
        ans += i * func(N//i)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
// #define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

using Int = __int128_t;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}


struct UnionFind {
    vector<int> uni;
    UnionFind(int n): uni(n+5, -1) {}
    int  root(int x)        { return (uni[x] < 0)? x : uni[x] = root(uni[x]); }
    bool same(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y){
        if ( (x=root(x)) == (y=root(y)) )return false;
        if ( uni[y] < uni[x] ) swap(x,y);
        uni[x] += uni[y],  uni[y] = x;
        return true;
    }
    int size(int i)     { return (-uni[root(i)]); }
};



signed main() {

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    UnionFind uf(n);

    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        uf.unite(a[i], b[i]);
    }

    int ans = 0;

    for(int i = 0; i < n; i++) {
        chmax(ans, uf.size(i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5568
#include<iostream>
#include<math.h>
using namespace std;
bool snt(int a){
    if(a==2 || a==3)
        return true;
    if(a<2)
        return false;
   int n=(int)sqrt(a);
    for(int i=2;i<= n;i++)
        if(a%i==0)
            return false;
    return true;
}

int main(){
    int n,b,d=0;
    cin >>n;
    while(n>0)
    {        n--;
        cin >>b;
        if(snt(b))
            d++;
    }
    cout <<d<<endl;
    return 0;
}

Measured memory_bytes: 3064
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		if (n == 2) {
			System.out.println(Math.max(a[0], a[1]));
			return;
		}

		Set<Integer> set = new HashSet<Integer>();
		set.add(a[0]);
		set.add(a[1]);
		int[] gcda = new int[n];
		gcda[0] = a[0];
		for (int i = 1; i < n; i++) {
			int ai = a[i];
			Integer[] arr = set.toArray(new Integer[0]);
			set = new HashSet<Integer>();
			for (int j : arr) {
				set.add(BigInteger.valueOf(j).gcd(BigInteger.valueOf(ai)).intValue());
			}
			set.add(gcda[i - 1]);
			gcda[i] = BigInteger.valueOf(gcda[i - 1]).gcd(BigInteger.valueOf(ai)).intValue();
		}

		int ans = 0;
		for (int j : set) {
			ans = Math.max(ans, j);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 94972
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>

using namespace std;

int n;

int main(){
    scanf("%d",&n);
    cout<<(n<1200 ? "ABC":n<2800 ? "ARC":"AGC")<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	string s;
	cin >> s;
	int n = s.size();

	if (n == 1) {
		cout << stoi(s) << endl;
		return 0;
	}
	ll ans = 0;
	rep(t,1<<(n-1)) {
		int las = 0;
		rep(i,n-1) {
			if ((t>>i) & 1) {
				string sub = s.substr(las,i-las+1);
				ans += stoll(sub);
				las = i+1;
			}
		}
		ans += stoll(s.substr(las,n-las));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#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 = long long;
using P = std::tuple<int,int>;

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

int A[1100];

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

    int N;
    std::cin >> N;

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

    int res = 0;
    while(true){
        int l = to_string(res).size();
        
        bool isFound = false;
        for(int i=0;i+l<=N;++i){
            int x = 0;
            for(int j=0;j<l;++j){
                x = x * 10 + A[i+j];
            }

            if(x == res){
                isFound = true;
                break;
            }
        }

        if(!isFound){
            break;
        }

        ++res;
    }

    std::cout << res << std::endl;
}



Measured memory_bytes: 3272
from bisect import *
n, d, a = map(int, input().split())
monster = []

for i in range(n):
    x, h = map(int, input().split())
    monster.append([x, h])

monster.sort()
hp = []
x = []
damage = [0] * (n+1)

for i in range(n):
    hp.append(monster[i][1])
    x.append(monster[i][0])

ans = 0
for i in range(n):
    bomb = max((hp[i] - damage[i] - 1) // a + 1, 0)
    ans += bomb
    damage[i] += bomb * a
    damage[bisect_right(x, x[i]+2*d)] -= bomb * a
    damage[i+1] += damage[i]

print(ans)


Measured memory_bytes: 48520