akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    D, N = map(int, input().split())

    if D == 0:
        ans = 0
        c = 0
        for i in range(1, 10**5, 1):
            if i % 100 != 0:
                c += 1
                ans = i
                if c == N:
                    print(ans)
                    exit()

    elif D == 1:
        ans = 0
        c = 0
        for i in range(100, 10**5, 100):
            if i % 100 == 0 and i % 10000 != 0:
                c += 1
                ans = i
                if c == N:
                    print(ans)
                    exit()

    elif D == 2:
        ans = 0
        c = 0
        for i in range(1, 10**5):
            if (i * 100**D) % 1000000 != 0:
                c += 1
                ans = i * 100**D
                if c == N:
                    print(ans)
                    exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 62116
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

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

int main(){
	ll N,K;
	cin >> N >> K;
	long double ans = 0;
	ll key = 1, c = 0;

	//初期化
	while(1){
		if(key>=K){
			break;
		}else{
			key *= 2;
			c++;
		}
	}
	for(ll i=1;i<=N;i++){
		//cout << c << endl;
		ans += ( 1/(long double)(1<<c));
		//cout << ans << endl;
		while(1){
			if((i+1)*key>=K){
				if(key==1){
					if((i+1)*key>=K){
						break;
					}else{
						key *= 2;
						c++;
						break;
					}
				}
				key /= 2;
				c--;
			}else{
				key *= 2;
				c++;
				break;
			}
		}
	}

	printf("%.9LF\n",ans/(long double)N);
}

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

int main(void){
  int x1, y1, x2, y2, x3, y3, x4, y4;

  cin >> x1 >> y1 >> x2 >> y2;

  int d1, d2;
  d1 = x2 - x1;
  d2 = y2 - y1;

  x3 = x2 - d2;
  y3 = y2 + d1;
  x4 = x3 - d1;
  y4 = y3 - d2;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void debug(String str){
        boolean debug = false;
        if(debug != true){
            return;
        }
        System.out.println(str);
    }
    public static void scanArray(Scanner sc ,int[] array, int num){
        for(int i =0;i<num;i++){
            array[i] = sc.nextInt();
        }
    }
    //最小公倍数
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (long)(c/b);
    }

    public static void main(String[] args) {

        long A;
        long B;
        long C;
        long D;

        try (Scanner sc = new Scanner(System.in)) {
            A = sc.nextLong();
            B = sc.nextLong();
            C = sc.nextLong();
            D = sc.nextLong();
        }
        long sumSet = B - (A-1);
        long cSet = (B/C) - ((A-1)/C);
        long dset = (B/D) - ((A-1)/D);
        long temp = lcm(C,D);
        long cdSet= (B/temp) - ((A-1)/temp);
        debug(sumSet+"");
        System.out.println(sumSet - (cSet+dset)+cdSet);
    }
}


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

double db(double x) {
    return x * x;
}

int main() {
    int n;
    cin >> n;
    double div = 1;
    double x[10], y[10];
    vector<int> v;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        div *= (i + 1);
        v.push_back(i);
    }

    double len = 0;
    do {
        double a[10],b[10];
        for (int i = 0; i < n; i++) {
            a[v[i]] = x[i];
            b[v[i]] = y[i];
        }
        for (int i = 1; i < n; i++) {
            len += sqrt(db(a[i] - a[i - 1]) + db(b[i] - b[i - 1]));
        }
    } while (std::next_permutation(v.begin(), v.end()));
    cout << setprecision(20) << len / div << endl;
    return 0;
}


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

int main(){
int N;
string S;
  cin>>N>>S;
  
  int x=0, ans=0;
  for(int i=0; i<N; i++){
   if(S[i]=='I'){x++;}
   if(S[i]=='D'){x--;}
   ans=max(ans, x); 
  }
  
  cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

typedef struct dice
{
	int front;		/* the front side of the dice. */
	int south;		/* the south side of the dice. */
	int east;		/* the  east side of the dice. */
	int west;		/* the  west side of the dice. */
	int north;		/* the north side of the dice. */
	int back;		/* the  back side of the dice. */
} dice_t;

void turn(int *a, int *b, int *c, int *d);
dice_t turn_dice(dice_t d, char side);

int main()
{
	dice_t dice;
	int i;
	char move[100];
	scanf("%d %d %d %d %d %d\n%s", 
		&dice.front, &dice.south, &dice.east,
		 &dice.west, &dice.north, &dice.back, move);
	
	for(i = 0; i < strlen(move) ; i++)
	{
		dice=turn_dice(dice, move[i]);
	}
	
	printf("%d\n", dice.front);
	
	return 0;
}

void turn(int *a, int *b, int *c, int *d)
{
	int tmp = *a;
	*a = *b;
	*b = *c;
	*c = *d;
	*d = tmp;
}

dice_t turn_dice(dice_t d, char side)
{
	int side_int = side;
		
	switch(side_int)
	{
	case 'N':
		turn(&d.front, &d.south, &d.back, &d.north);
		break;
	case 'S':
		turn(&d.front, &d.north, &d.back, &d.south);
		break;
	case 'W':
		turn(&d.front, &d.east, &d.back, &d.west);
		break;
	case 'E':
		turn(&d.front, &d.west, &d.back, &d.east);
		break;
	}
	
	return d;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;
int main() {
 double N,x;
 string u;
 cin>>N;
 double sum=0;
 
 while(cin>>x>>u){
     if(u=="JPY"){sum+=x;}
     else{sum+=x*380000.0;}
 }
 cout<<fixed<<setprecision(9)<<sum<<endl;
 return 0;}

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

char p[100005];
int S[100005],P[100005],n; 

int main(){
	scanf("%d%s",&n,&p);
	for(int i=0;i<n;i++){
		if(p[i]=='o') P[i+1]=0;
		else P[i+1]=1;
	}
	P[n+1]=P[1];
	for(int i=0;i<8;i++){
		S[0]=i&1;
		S[1]=(i>>1)&1;
		S[2]=(i>>2)&1;
		for(int j=2;j<=n+1;j++){
			S[j+1]=S[j-2]^P[j];
		}
		if((S[0]^S[1]^S[n]^S[n+1])||(S[1]^S[2]^S[n+1]^S[n+2])) continue;
		for(int j=1;j<=n;j++){
			printf("%c",(S[j-1]^S[j])?'W':'S');
		}
		return 0;
	}
	printf("-1\n");
	return 0;
} 

Measured memory_bytes: 1152
a = gets.chomp.to_i
i = 0
cnt = 0
if a % 11 >= 7
  puts a / 11 * 2 + 2
elsif a % 11 <= 6 && a % 11 != 0
  puts a / 11 * 2 +1
else
  puts a /11 * 2
end

Measured memory_bytes: 1788
def main():
    from builtins import int, map, list, print, len, min
    from bisect import bisect_right
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N, M, X = input_number_list()
    A = input_number_list()
    A.sort()
    idx = bisect_right(A, X)
    l = len(A[:idx])
    r = len(A[idx:])
    print(min(l, r))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
{-# OPTIONS_GHC -O2 #-}
import Control.Applicative
import Data.Array.Unboxed
import Data.List (foldl')
import Data.Foldable (maximumBy)
import Data.Ord (comparing)
import qualified Data.Set as Set

main = do
  len <- (read :: String -> Int) <$> getLine
  xs <- map (read :: String -> Int) . lines <$> getContents
  let arr = listArray (1,len) xs :: UArray Int Int
  print $ snd $ maximumBy (comparing snd) $ syorinaiyou arr len

syorinaiyou arr len =
  foldl' (keisan arr) Set.empty (reverse [1..len])
    where
      keisan arr set n
        | Set.null set =  Set.insert ((arr ! n),1) set
        | otherwise  = seisa arr set n
        where
          seisa arr set n
            | Set.null set'     = Set.insert (hikaku_moto,1) set
            | Set.size set1 <= 1 =  Set.insert (hikaku_moto, oldLIS + 1) set'
            | otherwise  = Set.insert (hikaku_moto, oldLIS + 1) set2
            where
              hikaku_moto = arr ! n
              (set1, set')   = Set.split (hikaku_moto + 1 , 0) set
              (old,oldLIS) = Set.elemAt 0 set'
              set2 = Set.union (Set.delete (Set.elemAt ((Set.size set1)-1) set1) set1) (snd (Set.split (old,oldLIS-1) set'))

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


int main(){
  int N,M;cin>>N>>M;
  vvi A(N, vi(M));
  vi B(M);
  rep(i,N)rep(j,M)cin>>A[i][j];
  rep(i,M)cin>>B[i];

  rep(i,N){
    int ans = 0;
    rep(j,M){
      ans += A[i][j]*B[j];
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3152
"use strict";

function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    let s = input[0];
    let t = input[1];
    let count = 0;

    for (let i = 0; i < s.length; i++) {
        if (s.charAt(i) != t.charAt(i)) {
            count++;
        }
    }

    //出力
    console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33184
//g++ test.cpp -o test.out
//入出力：http://kaitei.net/cpp/iostream/
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
using namespace std;

char day[3];

int main(){
	cin >> day;
	if(strcmp(day,"SUN")==0){
		cout << 7;
	}else if(strcmp(day,"MON")==0){
		cout << 6;
	}else if(strcmp(day,"TUE")==0){
		cout << 5;
	}else if(strcmp(day,"WED")==0){
		cout << 4;
	}else if(strcmp(day,"THU")==0){
		cout << 3;
	}else if(strcmp(day,"FRI")==0){
		cout << 2;
	}else if(strcmp(day,"SAT")==0){
		cout << 1;
	}
	return 0;
}

Measured memory_bytes: 256
(n,m,),*a=$<.map{|z|z.split.map &:to_i}
r=[-1]*-~n
c=r.dup
f=->x{r[x]>0?f[r[x]]:x}
a.map{|u,v|x,y=[f[u],f[v]].sort|[]
[c[u]-=1,c[v]-=1]if !y||m>0&&[r[x]+=r[y],r[y]=x]
m-=1}
(1..n).map{|i|p c[i]-r[f[i]]}

Measured memory_bytes: 32508
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::vector<int> a(5);
	for(int i = 0; i < 5; i++) scanf("%d", &a[i]);
	int k; scanf("%d", &k);
	
	bool ans = true;
	for(int i = 0; i < a.size(); i++) {
		for(int j = i + 1; j < a.size(); j++) {
			int dist = std::abs(a[j] - a[i]);
			
			if(dist > k) ans = false;
		}
	}
	
	if(!ans) printf(":(\n");
	else printf("Yay!\n");
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;


int main() {
	int N,M;cin>>N>>M;
	queue<int>que;
	map<int,int>ins;
	for (int i = 0; i < N; ++i) {
		int a;cin>>a;
		if (ins.find(a)!=ins.end()) {
			ins[a]=i;
			continue;
		}
		else {
			if (que.size() == M) {
				int ou=que.front();
				ins.erase(ou);
				que.pop();
			}
			que.push(a);
			ins[a]=i;
		}
	}
	vector<pair<int,int>>anss;
	for (auto m : ins) {
		anss.push_back(make_pair(m.second,m.first));
	}
	sort(anss.begin(),anss.end());
	for (int i = 0; i < anss.size(); ++i) {
		cout<<anss[anss.size()-1-i].second<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {

  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A*B > C*D){
      cout << A*B << endl;
  }
  if(A*B < C*D){
      cout << C*D << endl;
  }
  if(A*B == C*D){
      cout << A*B << endl;
  }
  }

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

multiset<int> A;

void fail(){
    cout << "Impossible" << endl;
    exit(0);
}


void solve(long long N, vector<long long> a){
    for( auto i : a) A.insert(i);

    int len = *A.rbegin();

    for(int i = 0 ; i <= len ; i++){
        auto it = A.find(max(len - i, i));
        if( it == A.end() ) fail();
        A.erase(it);
    }

    if( A.count((len+1) / 2) > 0 ){
        fail();
    }
    cout << "Possible" << endl;

}

int main(){    
    long long N;
    scanf("%lld",&N);
    vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, a);
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
k = [list(map(int,input().split())) for _ in range(3)]
cnt = [[0] * n for _ in range(2)] 
# cnt[0][i]がb[i]より小さいa[j]の個数、cnt[1][i]がb[i]より大きいc[j]の個数
a = sorted(k[0])
b = sorted(k[1])
c = sorted(k[2])
i = 0
j = 0
while i < n:
    if b[i] < c[j]: 
        cnt[1][i] = n-j
        i +=1
    else: j+=1
    if j >= n:
        j = n-1
        cnt[1][i] = 0
        i += 1
i = 0
j = 0
while i < n:
    if b[i] > a[j]:
        j+= 1
    else:
        cnt[0][i] = j
        i += 1
    if j >= n:
        j = n-1
        cnt[0][i] = n
        i += 1
ans = 0
for i in range(n):
    ans += cnt[0][i]*cnt[1][i]
print(ans) 

Measured memory_bytes: 25716
#include <iostream>

void judgeTriangle(int, int, int);

int main()
{
    int number;
    std::cin >> number;
    for (int i = 0; i < number; ++i) {
        int a, b, c;
        std::cin >> a >> b >> c;
        judgeTriangle(a, b, c);
    }
    return 0;
}

void judgeTriangle(int a, int b, int c)
{
    if (a * a + b * b == c * c
        || b * b + c * c == a * a
        || c * c + a * a == b * b) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 1152
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    s = IS()
    print(s[:]+'s' if s[-1] != 's' else s[:]+'es')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9116
m = int(input())
deck = [(suit, num) for suit in ['S', 'H', 'C', 'D'] for num in range(1, 14)]
for _ in range(m):
    s, n = input().split()
    if (s, int(n)) in deck:
        deck.remove((s, int(n)))
for item in deck:
    print(item[0], str(item[1]))



Measured memory_bytes: 5608
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
chomp $n;
my @s;
{
    for (my $i=0; $i<$n; $i++)
    {
        my $in = <STDIN>;
        chomp $in;
        $s[$i] = $in;
    }
}
my %h;
for my $key (@s)
{
    if (exists $h{$key})
    {
        $h{$key} += 1;
    }
    else
    {
        $h{$key} = 1;
    }
}
my $max = 0;
for my $v (values %h)
{
    $max = $v if $max < $v;
}
my @ans;
while (my ($k, $v) = each %h)
{
    push @ans, $k if $v == $max;
}
@ans = sort {$a cmp $b} @ans;
print "$_\n" for @ans;

Measured memory_bytes: 54756
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] v = new int[2][n];
        for(int i = 0 ; i < 2 ; i++ ){
            for(int j = 0 ; j < n ; j++ ){
                v[i][j] = sc.nextInt();
            }
        }
        int s = 0;
        for(int i = 0 ; i < n ; i++ ){
            if(v[0][i] > v[1][i]){
                s += (v[0][i] - v[1][i]);
            }
        }
        sc.close();
        System.out.println(s);
    }
}

Measured memory_bytes: 35660
package main

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

//scanで一行づつ読み込む
var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

//sort
// array := []int{5, 1, 4, 2, 3}
// sort.Sort(sort.IntSlice(array))

func main() {
	// a := make([]int, n)
	// A := strings.Split(nextLine(), " ")

	Y := strings.Split(nextLine(), " ")
	// Z := strings.Split(nextLine(), " ")

	// n, _ := strconv.Atoi(input[0])

	// memo = make([]bool, n+1, n+2)

	N, _ := strconv.Atoi(Y[0])
	M, _ := strconv.Atoi(Y[1])

	// ans := false

	tmp := N / 2
	if N%2 == 1 {
		tmp += 1
	}

	if tmp >= M {
		fmt.Fprintln(wtr, "YES")
	} else {
		fmt.Fprintln(wtr, "NO")
	}

	_ = wtr.Flush()
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func com(a, b int) int {

	if a > b {
		return 0
	}
	return abs(a - b)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

type dishh struct {
	first  int
	second int
}

type dish []dishh

func (p dish) Len() int {
	return len(p)
}

func (p dish) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p dish) Less(i, j int) bool {

	return p[i].first+p[i].second > p[j].first+p[j].second
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, m;
ll Max[8*MAXN], lazy[8*MAXN];
vector<II> a[MAXN], b[MAXN];

void lazyupd(int k, int l, int r) {
    if (lazy[k] == 0) return;
    Max[k] += lazy[k];
    if (l < r) {
        lazy[k*2] += lazy[k];
        lazy[k*2+1] += lazy[k];
    }
    lazy[k] = 0;
}

void update(int k, int l, int r, int u, int v, ll gt) {
    lazyupd(k, l, r);
    if (r < u || v < l || l > r) return;
    if (u <= l && r <= v) {
        lazy[k] = gt;
        lazyupd(k, l, r);
        return;
    }
    int m = (l + r) >> 1;
    update(k*2, l, m, u, v, gt);
    update(k*2+1, m+1, r, u, v, gt);
    Max[k] = max(Max[k*2], Max[k*2+1]);
}

ll get(int k, int l, int r, int u, int v) {
    lazyupd(k, l, r);
    if (r < u || v < l || l > r) return -1e18;
    if (u <= l && r <= v) return Max[k];
    int m = (l + r) >> 1;
    return max(get(k*2, l, m, u, v), get(k*2+1, m+1, r, u, v));
} 

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,m) {
        int u, v, c;
        cin >> u >> v >> c;
        a[v].emplace_back(II(u, c));
        b[u].emplace_back(II(v, c));
    }
    ll res = 0;
    FOR(i,1,n) {
        FOR(j,0,SZ(b[i])-1) {
            int c = b[i][j].SE;
            update(1,0,n,0,i-1,c);
        }

        FOR(j,0,SZ(a[i-1])-1) {
            int u = a[i-1][j].FI;
            int c = a[i-1][j].SE;
            update(1,0,n,0,u-1,-c);
        }

        ll kq = get(1,0,n,0,i-1);
        res = max(res, kq);
        update(1,0,n,i,i,kq);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 33280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b, c; cin >> a ;
	//string s,t; cin >> s>>t;
	if (a < 1200)cout << "ABC";
	else cout << "ARC";


	cout << endl;
	return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    b = a;
    sort(all(b));
    int res = 0;
    rep(i,n){
        if(a[i] != b[i]) res++;
    }
    cout << (res<= 2?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long LL;

const int N = 200005;

int n;
LL k, a[N], f[N];

bool cmp(int x, int y){ return x > y; }

bool check(LL M){
	LL cnt = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] * f[i] > M){
			LL kk = (a[i] * f[i] - M) / f[i];
			if((a[i] - kk) * f[i] > M)
				kk++;
			cnt += kk;
			if(cnt > k)
				return false;
		}
	}
	return true;
}

int main(){
	scanf("%d%lld", &n, &k);
	for(int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	for(int i = 1; i <= n; i++)
		scanf("%lld", &f[i]);
	if(n == 1){
		printf("%lld\n", f[1] * max(0ll, a[1] - k));
		return 0;
	}
	sort(a+1, a+n+1, cmp);
	sort(f+1, f+n+1);
	LL l = 0, r = 1e18, ans = 1e18;
	while(l <= r){
		LL mid = (l + r) >> 1;
		if(check(mid)){
			ans = min(mid, ans);
			r = mid - 1;
		}
		else
			l = mid + 1;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;

int main()
{
    fast;

	
	string s;
	cin>>s;
	ll n;
	for(ll i=1;i<s.size()-1;i++)
	{
			
			if( (s[i]!=s[0]||s[i]!=s[s.size()-1] ))
			{
				
				n=s.size()-2;
				break;		
			}
			
	}
 
 if(s[0]!=s[s.size()-1])
 {
 	if(n%2==0)cout<<"Second";
 	else
 	cout<<"First";
 }
 else
 {
 	if(n%2==0)cout<<"First";
 	else
 	cout<<"Second";
 }
    
   
}

		
	
	
	
	


Measured memory_bytes: 3756
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in(),K=in();
	vector<ll> V=vecin<ll>(N);

	ll ans = 0;
	for(int i=0;i<=K;i++){
		for(int left=0;left<=min(i,N);left++){
			priority_queue<ll,vector<ll>,greater<ll>> Q;
			ll sum = 0;

			int right = min(i,N)-left;
			for(int l=0;l<left;l++){
				sum += V[l];
				ans = max(ans,sum);
				Q.push(V[l]);
			}
			for(int r=0;r<right;r++){
				sum += V[N-1-r];
				ans = max(ans,sum);
				Q.push(V[N-1-r]);
			}
			for(int d=0;d<K-i && !Q.empty();d++){
				ll p = Q.top();
				Q.pop();
				sum -= p;
				ans = max(ans,sum);
			}
		}
	}
	out(ans);

	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
S,C=[],[]
for _ in range(M):
    s,c=map(int,input().split())
    S.append(s)
    C.append(c)

# 数字の頭から設定していく．なんの制約もない場合は１か0．制約がある場合はその数字を制約が多重でかかっている場合は-1を出力して終了
min_num = [0 for _ in range(N)]
for i in range(1,N+1):
    if i in S:
        # 合致する数字を全てけんさくする．これならnumpyを使っても良かったかも？どうせ大した要素数ではないので
        same_value_num = S.count(i)
        values = []
        for _ in range(same_value_num):
            ind = S.index(i)
            value = C[ind]
            values.append(value)
            del(S[ind])
            del(C[ind])


        same_value_bool = [v == values[0] for v in values]
        if not sum(same_value_bool) == same_value_num:
            min_num = -1
            break

        restrict_num = values[0]
        # もしN>1の場合に頭に0を指定した場合はおかしいのでbreak
        if i == 1 and restrict_num == 0 and N>1:
            min_num = -1
            break

        min_num[i-1] = restrict_num
        continue

    if i == 1 and N>1:
        min_num[i-1] = 1
    else:
        min_num[i-1] = 0

if min_num == -1:
    print(min_num)
else:
    min_num = map(str,min_num)
    print(''.join(min_num))


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
       //[a-z]の26種の配列を用意
        int[] ch = new int[26];
      
        //初期値は0個
        for(int i = 0; i < 26; i++) ch[i] = 0;  
        
        //[a-z]の個数をカウント
        for(int i = 0; i < S.length(); i++){
            int num = S.charAt(i) - 'a';
            ch[num]++;
        }
        
        //[a-z]の個数が2個以上ならばfalse判定 
        boolean state = true;
        for(int i = 0; i < 26; i++){
            if(ch[i] > 1){
                state = false;
                break;
            }
        }
        System.out.println(state ? "yes" : "no");
    }
}


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

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define F first
#define precise std::cout << std::fixed;std::cout << std::setprecision(6); 
#define S second  
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

int binexpo(int x, int y, int p) {    
    int res = 1;     // Initialize result  
    x = x % p; // Update x if it is more than or  
                // equal to p  

    while (y > 0)  {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;
}
// --------------------------template ends here------------------------------

int dp[100005] = {0};

void solve() {
    int n, k;
    cin >> n >> k;

    vector <int> v(n);

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

    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);

    for(int i=1;i<k;i++) {
        int ans = MAX;
        int j = i-1;
        int temp = k;
        while(temp > 0 && j >= 0) {
            ans = min(ans, dp[j] + abs(v[i]-v[j]));
            temp--;
            j--;
        }
        dp[i] = ans;
    }

    for(int i=k;i<n;i++) {
        int j=i-1;
        int temp = k, ans = MAX;
        while(temp > 0 && j >= 0) {
            ans = min(ans, dp[j] + abs(v[i]-v[j]));
            temp--;
            j--;
        }
        dp[i] = ans;
    }

    // for(int i=0;i<n;i++)
    //     cout << dp[i] << " ";
    // cout << endl;

    cout << dp[n-1] << endl;

    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  if (N / 10 % 111 == 0 || N % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

//カッコ列の整合性に関する問題は超定番の判定方法がある
//stackを用意する
//左カッコが来たらstackに追加
//右カッコがきたときstackが空だったらエラー検出で空じゃなかったらstackにある左カッコと
//今ある右カッコとをペアにしてstackからpopする

int main() {
	string s; cin >> s;
	stack<int>st;
	int ans = s.size();
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'S') {
			st.push(1);
		}
		else {
			if (!st.empty()) {
				st.pop();
				ans -= 2;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 900
#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 n, l[100] = {}, max = 0, max_i = 0, sum = 0;
	cin >> n;
	rep(i, n){
		cin >> l[i];
		if(max < l[i]){
			max = l[i];
			max_i = i;
		}
	}

	rep(i, n){
		if(i != max_i)
			sum += l[i];
	}

	if(max < sum)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
n,m=io.read("*n","*n","*l")
t={}
for i=1,m do
    x=io.read()
    p,s=x:match("(%d+) (%u+)")
    if not t[p] then
        t[p]={}
    end
    table.insert(t[p],s)
end

ac_counter=0
wa_counter=0
for k in pairs(t) do
    for i=1,#t[k] do
        if t[k][i]=="AC" then
            ac_counter=ac_counter+1
            wa_counter=wa_counter+i-1
            break
        end
    end
end

print(ac_counter.." "..wa_counter)

Measured memory_bytes: 23396
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  var n = Number(input[0].split(" ")[0]);
  var m = Number(input[0].split(" ")[1]);

  var countWA = 0;
  var score = {};
  var scoreCount = {};
  for (var i = 1; i <= m; i++) {
    var pi = Number(input[i].split(" ")[0]);
    var si = input[i].split(" ")[1];
    if (scoreCount[pi] === undefined) scoreCount[pi] = 0;
    if (score[pi] === undefined || score[pi] === "WA") {
      score[pi] = si;
      if (score[pi] === "WA") countWA++;
    }
    if (score[pi] === "WA") scoreCount[pi]++;
  }
  var countAC = 0;
  for (var element in score) {
    if (score[element] === "AC") countAC++;
    if (score[element] === "WA") countWA = countWA - scoreCount[element];
  }
  //出力
  console.log(countAC, countWA);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 36660
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> c(n);
    rep(i, 0, n){
        cin >> c[i];
    }
    vector<int> a;
    int pre = -1;
    rep(i, 0, n){
        if(pre != c[i]) a.push_back(c[i]);
        pre = c[i];
    }
    n = a.size();
    map<int, int> mp;
    int now = 1;
    rep(i, 0, n){
        // cout << i << ' ' << now << ' ' << mp[a[i]] << endl;
        now += mp[a[i]];
        now %= mod;
        mp[a[i]] = now;
    }
    cout << now % mod << endl;
}

Measured memory_bytes: 15856
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

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

    priority_queue<int> que;

    rep(i,N) {
        int A;
        cin >> A;
        que.push(A);
    }

    rep(i,M) {
        int A = que.top(); que.pop();
        que.push(A / 2);
    }
    long long ans = 0;
    rep(i,N) {
        ans += que.top(); que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <math.h>
int main(void)
{
	double v,t;
	int N;
	while(scanf("%lf",&v)!=EOF){
		N=ceil((4.9*(v/9.8)*(v/9.8)+5)/5);
		printf("%d\n",N);
	}
	
	return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s, t;
  cin >> n >> s >> t;
  rep(i, n)
    cout << s[i] << t[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = zeros(Int,n)
	for i in 1:n-1
		b[a[i]]+=1
	end
	for i in 1:n
		println(b[i])
	end
end

main()

Measured memory_bytes: 201416
N, X = gets.split.map(&:to_i)
a_list = gets.split.map(&:to_i)

sum = 0
(1..(N - 1)).each do |i|
  if a_list[i - 1] + a_list[i] > X
    rest = (a_list[i - 1] + a_list[i]) - X
    sum += rest
    a = [a_list[i], rest].min
    a_list[i] -= a
    rest -= a
    a_list[i - 1] -= rest
  end
end
puts sum


Measured memory_bytes: 11140
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){

  int n,W;
  cin >> n >> W;

  vector<int>v(n),w(n);
  for(int i=0;i<n;i++)cin >> v[i] >> w[i];

  int dp[W+1];
  fill(dp,dp+W+1,0);

  for(int i=0;i<n;i++)
    for(int j=W;j>=0;j--)
      if(w[i]+j<=W)dp[w[i]+j]=max(dp[w[i]+j],dp[j]+v[i]);

  cout << dp[W] << endl;

  return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#include<string.h>
#define rep(i,l,r) for(ll i=l;i<r;i++)

typedef long long ll;

int main() {
    char s[200001];
    scanf("%s", s);
    ll sum = 0;
    rep(i, 0, strlen(s)) {
        sum += s[i] - 48;
        sum %= 9;
    }
    if (sum == 0) {
        printf("Yes");
    }
    else printf("No");

    return 0;
}

Measured memory_bytes: 2280
# https://atcoder.jp/contests/abc137/tasks/abc137_c
# アナグラムの個数を求める問題
# アナグラムの条件→各alphabetの文字数が一致 もしくは ソートすると並び順が同じでもok
# 同じ文字カウント(ソートして同じ文字列)がN個あるとき、i,jの組み合わせは1/2(n*n-n)となる (組み合わせを考えて確かめてみよ)

from collections import Counter

char_sorted = []
N = int(input())
for _ in range(N):
    s = input()
    char_sorted.append(''.join(sorted(s)))

ans = 0
for a in Counter(char_sorted).values():
    ans += ((a - 1) * a) // 2
print(ans)


Measured memory_bytes: 19824
N, M = map(int, input().split())
route_1 = [0] * (N+1)
route_n = [0] * (N+1)

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        route_1[b] = 1
    elif b == N:
        route_n[a] = 1

for i in range(2, N+1):
    if route_1[i] == 1 and route_n[i] == 1:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


Measured memory_bytes: 11888
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

int main() {
    ll n, m, c;
    cin >> n >> m >> c;
    VE b(m);
    vector<vector<ll>> a(n, vector<ll>(m));
    REP(i, m) cin >> b[i];
    REP(i, n)REP(j, m) cin >> a[i][j];
    ll ans = 0;
    REP(i, n) {
        ll cnt = 0;
        REP(j, m) {
            cnt += b[j] * a[i][j];
        }
        cnt += c;
        if(cnt > 0)ans++;
    }
    print(ans);
}


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

namespace ABC171_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            long N = long.Parse(str);
            string ans = string.Empty;

            while (N != 0)
            {
                N--;
                long mod = N % 26;
                ans = (char)('a' + mod) + ans;
                N /= 26;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27476
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N;
int A[21];
int B[21];
int C[21];

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> N;
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N - 1) cin >> C[i];

    int ans = 0;
    REP(i, N) { 
        ans += B[A[i] - 1];
        if (i > 0 && A[i - 1] + 1 == A[i]) {
            ans += C[A[i - 1] - 1];
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    int s;
    cin >> s;
    int left, right, okl = 0, okr = 0;
    left = s/100;
    right = s%100;
    if(left>0 && left < 13) okl = 1;
    if(right>0 && right < 13) okr = 1;
    if(okl){
        if(okr) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    } else {
        if(okr) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
int main (void){
    int i,a[10];
    for(i = 0; i < 3; i++){
        scanf("%d",&a[i]);
    }
    for(i = 0; i < 2; i++)
        for(int j = i + 1; j < 3; j++){
        if(a[i] > a[j]){
            int m;
            m = a[i];
            a[i] = a[j];
            a[j] = m;
        }
    }
    printf("%d %d %d\n",a[0],a[1],a[2]);
    return 0;
}


Measured memory_bytes: 2756
import sys
input = sys.stdin.readline

def main():
    N = int(input())

    MOD = int(1e9) + 7

    MAX_PRIME = N
    primes = []
    is_prime = [True] * (MAX_PRIME+1)
    for i in range(2, MAX_PRIME+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_PRIME+1, i):
                is_prime[j] = False
    
    count = [0] * len(primes)
    for i in range(2, N+1):
        tmp = i
        for j in range(len(primes)):
            while tmp%primes[j] == 0:
                count[j] += 1
                tmp //= primes[j]
    
    ans = 1
    for c in count:
        if c > 0:
            ans *= c+1
            ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
int main()
{
	int n,i,j=0,flag=0;
	char a[100];
	fgets(a,100,stdin);
	n=strlen(a);
	for(i=0;i<n;i++)
	{
		if(a[i]=='A'||a[i]=='T'||a[i]=='C'||a[i]=='G')
		{
			j++;
			if(flag<j)
				flag=j;
		}
		if(a[i]!='A'&&a[i]!='T'&&a[i]!='C'&&a[i]!='G')
			j=0;
	}
	printf("%d\n",flag);
	return 0;
}

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

typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> x(N);
    for(ll i=0; i<N; i++) cin >> x[i];

    ll k=K-1;
    ll mi=(ll)1e15;
    for(ll i=0; i<=N-K; i++){
        ll t1,t2;
        if(x[i+k]<=0){
            t1 = abs(x[i]);
            mi = min(mi,t1);
        }
        else if(x[i]>=0){
            t1 = abs(x[i+k]);
            mi = min(mi,t1);
        }
        else {
            t1 = abs(x[i]);
            t1 += abs(x[i+k]-x[i]);
            t2 = abs(x[i+k]);
            t2 += abs(x[i+k]-x[i]);
            mi = min(mi,min(t1,t2));
        }
    }
    cout << mi << endl;
}

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

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

    if(A+B+C>=22)
    {
        cout<<"bust"<<endl;
        return 0;
    }
    else
    {
        cout<<"win"<<endl;
        return 0;
    }
    

    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>

int max(int a,int b){
	return (a > b) ? a : b;
}

void solve(int data[100][50],int cnt){
	int i,j;

	for(i = 0;i < cnt/2;i++){
		data[i+1][0] += data[i][0];
		for(j = 1;j <= i;j++){
			data[i+1][j] += max(data[i][j-1],data[i][j]);
		}
		data[i+1][i+1] += data[i][i];
	}
	for(i = cnt/2+1;i < cnt;i++){
		for(j = 0;j < cnt-i;j++){
			data[i][j] += max(data[i-1][j],data[i-1][j+1]);
		}
	}
}

int main(){
	int h,i,j,cnt,len,num;
	int data[100][50];
	char str[1024];

	memset(data,0,sizeof(data));

	i = 0;
	cnt = 0;
	while(scanf("%s",str) != EOF){
		h = 0;
		j = 0;
		len = strlen(str);
		while(h <= len){
			if(h < len && str[h] != ','){
				num = 0;
				while(h < len && str[h] != ','){
					num *= 10;
					num += str[h]-'0';
					h++;
				}
				data[i][j] = num;
				j++;
			}
			h++;
		}
		i++;
		cnt++;
	}

	solve(data,cnt);

	printf("%d\n",data[cnt-1][0]);

	return 0;
}

Measured memory_bytes: 572
fun main(args: Array<String>) = println(run {
    val (n,a,b,c) = readLine()!!.split(" ").map { it.toInt() }
    val l = (1..n).map { readLine()!!.toInt() }

    var min = Int.MAX_VALUE
    fun dfs(list: List<Int>) {
        if(list.size < n) return (0..3).forEach { dfs(list+it) }
        if((1..3).any { it !in list }) return
        val len = IntArray(4)
        var mp = 0
        for (i in list.indices) {
            if(list[i]!=0) {
                if(len[list[i]]!=0) mp += 10
                len[list[i]] += l[i]
            }
        }
        mp += Math.abs(a-len[1]) + Math.abs(b-len[2]) + Math.abs(c-len[3])
        min = Math.min(min, mp)
    }
    dfs(emptyList())
    min

})

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

int main() {
	std::string S, T;

	std::cin >> S >> T;

	std::string temp = S + S;

	bool check = false;
	for (int i = 0; i < temp.size(); i++) {
		if (S.size() < T.size())
			break;
		if (temp.substr(i, T.size()) == T) {
			check = true;
			break;
		}
	}

	if (check)
		std::cout << "Yes\n";
	else
		std::cout << "No\n";

}

Measured memory_bytes: 256