akhauriyash/Code-Regression huggingface dataset:
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

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

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int
var s, t string

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	s, t = nextStr(), nextStr()

	if s == t {
		fmt.Println(N)
		return
	}

	for i := 0; i < N; i++ {
		//fmt.Println(s[i:] == t[:N-i])
		if s[i:] == t[:N-i] {
			fmt.Println(N + i)
			return
		}

	}

	fmt.Println(2 * N)
}


Measured memory_bytes: 1772
import sys

s = input()
s = s[::-1]

d ='maerd'
dr = 'remaerd'
e = 'esare'
er = 'resare'

i = 0
while True:
    try:
        if s[i:i+5] == d or s[i:i+5] == e:
            i += 5
            if i == len(s):
                print('YES')
                sys.exit(0)
        
        elif s[i:i+6] == er:
            i += 6
            if i == len(s):
                print('YES')
                sys.exit(0)
        
        elif s[i:i+7] == dr:
            i += 7
            if i == len(s):
                print('YES')
                sys.exit(0)
            
        else:
            print('NO')
            sys.exit(0)
            
    except Exception as err:
        print('NO')
        sys.exit(0)


Measured memory_bytes: 40560
#include <bits/stdc++.h>
 
using namespace std;
int main(){
	string s;
	int n,k;
	cin >> n >> s >> k;
	for(int i = 0;i <(int)s.size(); ++i){
		if(s[i] != s[k-1]) s[i] = '*';
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==0){
		if(1868<=b&&b<=1911){
			printf("M%d\n",b-1867);
		}
		if(1912<=b&&b<=1925){
			printf("T%d\n",b-1911);
		}
		if(1926<=b&&b<=1988){
			printf("S%d\n",b-1925);
		}
		if(1989<=b&&b<=2016){
			printf("H%d\n",b-1988);
		}
	}
	if(a==1){
		printf("%d\n",1867+b);
	}
	if(a==2){
		printf("%d\n",1911+b);
	}
	if(a==3){
		printf("%d\n",1925+b);
	}
	if(a==4){
		printf("%d\n",1988+b);
	}
	return 0;
}


Measured memory_bytes: 2756
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(N: int):
    m = 1e18
    for i in range(1, N):
        res = sum([int(a) for a in list(str(i))]) + sum([int(b) for b in list(str(N-i))])
        m = min(res, m)
    print(m)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5432
import numpy as np

n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
dt = np.array([int(e[0] == e[1]) for e in d])
s = dt[:n-2] + dt[1:n-1] + dt[2:]
if s.max() >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27180
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n = I[0]
txy = I[1:].reshape(-1, 3)

def main():
    t1, x1, y1 = txy[0]
    d1 = x1 + y1
    if d1 > t1 or (t1 - d1) & 1:
        return 'No'
    dt, dx, dy = np.absolute(np.transpose(txy[1:] - txy[:-1]))
    d = dx + dy

    return 'No' if np.any(np.logical_or(d > dt, (dt - d) & 1)) else 'Yes'

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 34224
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,k,t,s,ss;
   cin>>a>>b>>c>>k;
   s=a+b+c;
   t=max(a,b);
   t=max(t,c);
   s-=t;
   for(ss=1;k>0;k--)
    ss*=2;
   cout<<s+ss*t;
    return 0;
}


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

int main() {
	ios :: sync_with_stdio(false);
	string s;
	while(getline(cin, s)) {
		for(int t = 0; t < 26; t ++) {
			for(auto &c : s) if(isalpha(c)){
				c = (c - 'a' + 1) % 26 + 'a';
			}
			if(s.find("the") != -1 ||
				s.find("this") != -1 ||
				s.find("that") != -1) {
				cout << s << '\n';
				break;
			}
		}
	}
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}


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

signed main() {
  int N; cin >> N;
  map<string, int> m;
  rep(i, N) {
    string s; cin >> s;
    m[s] = 1;
  }
  cout << m.size() << endl;

}

Measured memory_bytes: 19220
while True:
    a, op, b = map(str, input().split())
    if op =='?':
        break
    
    a = int(a)
    b = int(b)
    
    if op =='+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)



Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];

	vector<int> ans;

	for(int i=0;i<n;i++)
	{
		if(ans.empty() or ans[0]>=a[i])
		{
			ans.insert(ans.begin(),a[i]);
		}
		else if(ans[ans.size()-1]<a[i])
		{
			ans[ans.size()-1]=a[i];

		}
		else
		{
			auto itr=lower_bound(ans.begin(),ans.end(),a[i]);
			itr--;
			*itr=a[i];
		}
		
	}
	cout << ans.size() << endl;
//	for(int i=0;i<ans.size();i++)
//		cout << ans[i] << endl;





}


Measured memory_bytes: 1276
s = input().split()
if int(s[0]) > int(s[1]):
    a = s[0]
    s[0] = s[1]
    s[1] = a
if int(s[1]) > int(s[2]):
    a = s[1]
    s[1] = s[2]
    s[2] = a
if int(s[0]) > int(s[1]):
    a = s[0]
    s[0] = s[1]
    s[1] = a
print(s[0], s[1], s[2])



Measured memory_bytes: 5596
main = getLine >>= putStrLn . unwords . map show . maybe [-1,-1] id . unbalance 1

unbalance i (c1:c2:c3:cs)
  | c1 == c2 = Just [i, i+1]
  | c1 == c3 = Just [i, i+2]
  | otherwise = unbalance (succ i) (c2:c3:cs)
unbalance i (c1:c2:cs)
  | c1 == c2 = Just [i, i+1]
  | otherwise = Nothing
unbalance _ _ = Nothing

Measured memory_bytes: 7548
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int main(){
	string s1="",s2="";
	int a,b;
	read(a),read(b);
	for(i,1,a) s1+=(char)(b+'0');
	for(i,1,b) s2+=(char)(a+'0');
	if(s1<s2) cout<<s1<<"\n";
	else cout<<s2<<"\n";
	exit(0); 
}

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


int main(){
  int n, m;
  cin >> n >> m;
  if (n < m){
  vector<int>vec(m);
  for (int i = 0; i < m ; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  vector<int>change(m-1);
  for (int j = 0; j < m-1; j++){
    change.at(j) = vec.at(j+1)-vec.at(j);
  }
  sort(change.begin(),change.end());
  reverse(change.begin(),change.end());
  int s = 0;
  for (int k = n-1;k<m-1;k++){
    s += change.at(k);
  }
    cout << s <<endl;
  }
  else
    cout << 0 << endl;
}
    
    
      
    

Measured memory_bytes: 1024
# N<=8　で　8! = 40000　程度なので全通り計算
import math
import itertools

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

# 順列を計算
s_per = list(itertools.permutations(s))
N = len(s_per)

dist = 0

# 全ての距離の足し合わせ
for i in range(N):
    for j in range(n-1):
        dist += math.sqrt((s_per[i][j+1][0] - s_per[i][j][0])**2 + (s_per[i][j+1][1] - s_per[i][j][1])**2)

# N!を求める
n_sum = 1
for i in range(n):
    n_sum *= (n-i)

print(dist/n_sum)

Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
#define f first
#define s second
typedef pair<int,int> pii;
const int N=1e5+5;
const int mod=998244353;
const int inf=1e9+7;
int n,w[105],W,v[105],dp[N];
int main()
{
    scanf("%d%d",&n,&W);
    forn(i,1,N-1){dp[i]=inf;}
    forn(i,1,n){
        scanf("%d%d",&w[i],&v[i]);
        ford(j,n*1000,v[i]){
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
        }
    }
    /*ford(j,n*1000,1){
        if(dp[j]<inf&&dp[j]>0){
            printf("dp[%d]:%d\n",j,dp[j]);
        }
    }*/
    ford(j,n*1000,1){
        if(dp[j]<=W){
            printf("%d\n",j);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 640
from operator import itemgetter
import sys
sys.setrecursionlimit(1000000)

N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A.sort()
BC = [[int(x) for x in input().split()]for _ in range(M)]
BC.sort(key = itemgetter(1),reverse=True)

x = 0
bc_ind = 0
ans = 0
for ind,i in enumerate(A):
    bc = 0
    if(BC[bc_ind][0]>x):
        bc = BC[bc_ind][1]
        x+=1
    else:
        bc_ind+=1
        x = 1
        if(len(BC)<=bc_ind):
            ans += sum(A[ind:])
            break
        else:
            bc = BC[bc_ind][1]
    if(bc>i):
        ans += bc
    else:
        ans += sum(A[ind:])
        break
print(ans)


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N;
    string S, T;
    cin >> N >> S >> T;

    rep(i,N) {
        cout << S[i] << T[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

vector< vector<int> > generate( int num, int val, vector<bool>&vis )
{
    if( num == 0 )
    {
        return {{}};
    }
    vector< vector<int> > ans;
    for(int i=1;i<=val;i++)
    {
        if( vis[i] ) continue;
        vis[i] = 1;
        vector< vector<int> > temp = generate(num-1,val,vis);
        for( auto x : temp )
        {
            vector<int> tt = x;
            tt.pb(i);
            ans.pb(tt);
        }
        vis[i] = 0;
    }
    return ans;
}

int main() 
{
    fastio();

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

    vector<bool>vis(n,0);
    vector< vector<int> > all = generate(n,n,vis);
    sort(all(all));

    int a = -1, b = -1;
    for(int k=0;k<(int)all.size();k++)
    {
        int pe = 0, qe = 0;
        for(int i=0;i<n;i++)
        {
            // cout<<x[i]<<" ";
            if( all[k][i] == p[i] )
                pe++;
            if( all[k][i] == q[i] )
                qe++;
        }
        // nl;
        if( pe == n )
            a = k;
        if( qe == n )
            b = k;
    }
    cout<<abs(a-b);



    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

namespace aoj2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(Math.Pow(n,3));
        }
    }
}

Measured memory_bytes: 9392
import kotlin.math.sqrt

fun main() {
  val N = readInt()

  val f = Array(N + 1) { 0 }

  val lim = sqrt(N.toDouble()).toInt() + 1
  for (x in 1..lim) {
    for (y in 1..lim) {
      for (z in 1..lim) {
        val v = x * x + y * y + z * z + x * y + y * z + z * x
        if (v <= N) f[v]++
      }
    }
  }

  for (i in 1..N) {
    println(f[i])
  }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 37700
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main(){

    int k,n;

    cin >> k >> n;

    vector<int> a_(n);

    rep(i,n) cin >> a_[i];

    sort(a_.begin(), a_.end());
    ll res = 0;
    vector<int> dis(n);
     int dis_max=0;
    rep(i,n) {
        if(i == n - 1) dis[i] = k - a_[i] + a_[0];
        else dis[i] = a_[i+1]-a_[i];
        dis_max = max(dis[i], dis_max);
    }

    rep(i,n){
        res += dis[i];   
    }
    res -= dis_max;

    cout << res;

    return 0;
}

Measured memory_bytes: 1792
class Combination:
    def __init__(self, n_max=10**6, mod=10**9+7):
        # self._n_max = n_max
        self._fac, self._finv, self._inv = [0]*n_max, [0]*n_max, [0]*n_max
        self._fac[0], self._fac[1] = 1, 1
        self._finv[0], self._finv[1] = 1, 1
        self._inv[1] = 1
        for i in range(2, n_max):
            self._fac[i] = self._fac[i - 1] * i % MOD
            self._inv[i] = MOD - self._inv[MOD%i] * (MOD // i) % MOD
            self._finv[i] = self._finv[i - 1] * self._inv[i] % MOD
    def com(self, n, r):
        if n < r: return 0
        if n < 0 or r < 0: return 0
        return self._fac[n] * (self._finv[r] * self._finv[n - r] % MOD) % MOD


def modinv(a,m):
    b, u, v = m, 1, 0
    while b:
        t = a//b
        a -= t*b
        a,b = b,a
        u -= t * v
        u,v = v,u
    u %= m
    return u


MOD = 10**9+7
comb = Combination(10**6, MOD)
n,m,k = map(int, input().split())

ans = 0
for i in range(m):
    other_sum = i*(i+1)//2 + (m-1-i)*(m-i)//2
    # other_sum *= n
    pattern = n*n*comb.com(n*m-2,k-2)
    ans += pattern*other_sum
    ans%=MOD

for i in range(n):
    other_sum = i*(i+1)//2 + (n-1-i)*(n-i)//2
    # other_sum *= m
    pattern = m*m*comb.com(n*m-2,k-2)
    ans += pattern*other_sum
    ans%=MOD

a = modinv(2,MOD)
ans = (ans*a)%MOD
print(ans)

Measured memory_bytes: 108140
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]

    bit_k = bin(K)[2:]

    telepo_list = [A_list]

    for _ in range(len(bit_k)-1):
        temp_list = telepo_list[-1]
        new_telep = [temp_list[i-1] for i in temp_list]
        telepo_list.append(new_telep)

    # print(telepo_list)

    goto = 1
    for i in range(len(bit_k)):
        temp_list = telepo_list[i]
        if ((K >> i) & 1):
            goto = temp_list[goto - 1]
            # print(i, goto)

    print(goto)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 111652
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  string S; cin >> S;
  int win = 0;
  for(char c : S){ if(c=='o') win++; }
  int k = S.size();
  win += 15 - k;
  if(win>7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
// AtcoderCpp.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <iostream>

void ShowValue(float f)
{
	std::cout << f << std::endl;
}

int main()
{
	int i;
	std::cin >> i;
	std::cout << i * i;
}

const int mod = 1000000007;
struct mint {
	long long x; // typedef long long ll;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(long long t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
int memo[100100][5],n,a[100050],b[100050],c[100050] ;
// 0 swim
//1 Catch bugs
// 2 homework
int dp(int i,int last){
   if(i > n)
        return 0;
        int Res1=-2e9,Res2=-2e9,Res3=-2e9;
  
  if(memo[i][last]+1)	return memo[i][last];
  
if(last==0){
     Res1=dp(i+1,1)+b[i];
     Res2=dp(i+1,2)+c[i];
     Res3=max(Res1,Res2);
}
else if(last==1){
     Res1=dp(i+1,0)+a[i];
     Res2=dp(i+1,2)+c[i];
     Res3=max(Res1,Res2);
}
else{
 
     Res1=dp(i+1,0)+a[i];
     Res2=dp(i+1,1)+b[i];
     Res3=max(Res1,Res2);
}
 
return memo[i][last]=Res3;
 
}
 
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i]>>b[i]>>c[i];
 
        memset(memo,-1,sizeof(memo));
    cout<<max(max(dp(1,1),dp(1,2)),dp(1,0));
 
    return 0;
}
 

Measured memory_bytes: 8064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<math.h>
using namespace std;

int main(){
  long long a,b,k;
  std::cin >> a>>b>>k;
  if(a>=k){
    std::cout << a-k<<'\n'<<b<<'\n';
  }
  else if(a+b>=k){
    std::cout << 0<<'\n'<<b-(k-a)<<'\n';
  }
  else {
    std::cout << 0<<'\n'<<0 << '\n';
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define fir first
#define sec second
using namespace std;
int main()
{
    ll n;
    cin >> n;
    bool win = false;
    rep(i, n)
    {
        ll t;
        cin >> t;
        if (t % 2 == 1)
            win = true;
    }
    if (win)
        cout << "first" << endl;
    else
        cout << "second" << endl;
    return 0;
}


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

vector<pair<int, int>> bf;

void match_fighter(int l, int r){
	while(l < r){
		pair<int, int> p(l, r);
		bf.push_back(p);
		l++;
		r--;
	}
}

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

	match_fighter(1, m);
	match_fighter(m+1, 2*m+1);

	for(int i=0; i<bf.size(); i++){
		cout << bf[i].first << ' ' << bf[i].second << endl;
	}
}


Measured memory_bytes: 4240
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = long long;

i64 MOD = 1000000007;

i64 N, M;

int main() {
    cin >> N >> M;
    if (N == 1) {
        cout << (M+1)%MOD << endl;
        return 0;
    }

    i64 k = (M / (N-1)) % MOD;

    i64 a = (2*k+1) % MOD * ((M+1) % MOD) % MOD;
    i64 b = (N-1) % MOD * k % MOD * (k+1) % MOD;
    cout << (a - b + MOD) % MOD << endl;
    // d = 0 -> M - 0 + 1
    // d = 1 -> M - (N-1) + 1
    // d = 2 -> M - 2*(N-1) + 1
    // ...
    // d = k -> M - k*(N-1) + 1
    // where k <= M/(N-1)
    return 0;
}

Measured memory_bytes: 3100
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
t = [0] * (N + 1)
vis = set()
for _ in range(M):
  p, s = input().split()
  p = int(p)
  if p in vis: continue
  if s == "AC":
    vis.add(p)
  else:
    t[p] += 1
res = 0
for i in range(N + 1):
  if i in vis:
    res += t[i]
print(len(vis), res)

Measured memory_bytes: 47708
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




//UnionFind Template
struct UnionFind{ //構造体の定義
    vector<int> d; 
    UnionFind(int n=0): d(n,-1) {} //コンストラクタ
    int find(int x){
        if(d[x]<0) return x;
        return d[x]=find(d[x]);
    }
    bool unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return false;
        if(d[x]<d[y]) swap(x,y);//d[x] is smaller. Then, connect d[x] to d[y].
        d[y]+=d[x];
        d[x]=y;
        return true;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return -(d[find(x)]);   
    }
    int rootsize(){
        int cnt=0;
        for(auto& v: d){
            if(v<0) cnt++;
        }
        return cnt;
    }
};
//How to use
//UnionFind uf(n); などと書けば使えるようになる.ufというobjectが生成される
//uf.unite(a,b);などで中の関数を使える



int main(){
    int n,m; cin>>n>>m;
    vector<int> a(m), b(m);
    rep(i,m) cin>>a[i]>>b[i];
    UnionFind uf(n);
    rep(i,m){
        uf.unite(a[i],b[i]);
    }
    int si=0;
    rep(i,n){
        si=max(si, uf.size(i));
    }
    cout<<si<<endl;
    return 0;
}

Measured memory_bytes: 5632
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  bool n = false, w = false, s = false, e = false;
  string S;
  cin >> S;
  rep(i,S.size()) {
    if(S[i] == 'N') n = true;
    if(S[i] == 'W') w = true;
    if(S[i] == 'S') s = true;
    if(S[i] == 'E') e = true;
  }

  bool res = false;
  if(n && w && s && e) res = true;
  if((n && s) && !(w ^ e)) res = true;
  if(!(n ^ s) && (w && e)) res = true;

  YesorNo(res);
  return 0;
}

Measured memory_bytes: 256
# -- not using buffer ----------------------
import itertools
import sys
import math
'''
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

a, b = map(int, readline().split())
print(a)

lis = [int(readline().rstrip('\n')) for _ in range(b)]
print(lis)
c = int(read())
print(c)
'''
# -- using buffer ------------------
# --------------------------------------------
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
'''
a, b = map(int, readline().split())
print(a)

lis = [int(readline()) for _ in range(b)]
print(lis)
c = int(read())
print(c)
'''
# -----------------------
# -----------------------------------
n = int(readline())
p = tuple(map(int, readline().split()))
q = tuple(map(int, readline().split()))
ansList = [i for i in range(1, n + 1)]

div = n // 2
#com = list(itertools.product(ansList, repeat=n))
com = list(itertools.permutations(ansList))


a = com.index(p)
b = com.index(q)

ans = abs(a - b)
print(ans)


Measured memory_bytes: 13936
#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#define wl            ll t;cin>>t;while(t--)
#define rep(a,b,c)    for(ll a = b; a<c; a++)
#define mp            make_pair
#define pb            push_back
#define all(v)        v.begin(), v.end()
#define endl          "\n"
#define ll            long long int
#define ld            long double
#define pi            pair<ll , ll>
#define ull           unsigned long long
#define ps(x,y)       fixed<<setprecision(y)<<x
#define li            long int
#define frs           first
#define sec           second
#define inf           INT_MAX
#define ninf          INT_MIN
#define ul            unsigned long int
#define fast          std::ios::sync_with_stdio(false); cin.tie(NULL);
const ll mod = 1e9 + 7;
const ll N = 1e6 + 5;
using namespace std;

ll r[102][100005];

ll rec(ll w[], ll v[], ll n, ll tw)
{
    if(n < 0 || tw <= 0)
        return 0;
    if(r[n][tw] != -1)
        return r[n][tw];
    else
    if(w[n] > tw)
    {
        r[n][tw] =  rec(w, v, n-1, tw);
        return r[n][tw];
    }

    else
    if(w[n] <= tw)
    {
        r[n][tw] = max(v[n] + rec(w, v, n-1, tw- w[n]), rec(w, v, n-1, tw));
        return r[n][tw];
    }
}

void solve()
{
    ll n, tw;
    cin>>n>>tw;
    ll v[n], w[n];
    memset(r, -1, sizeof(r));
    rep(i, 0, n)
    {
        ll a, b;
        cin>>a>>b;
        w[i] = a;
        v[i] = b;
    }
    // cout<<n<<endl;
    ll ans = rec(w, v, n-1, tw);
    cout<<ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast
    // wl
    // {
        solve();
    // }
    return 0;
}

Measured memory_bytes: 83308
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  sort(ALL(a));
  cout << a.back() - a.front() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge> >;

int main()
{
    int A[3][3];
    bool OK[3][3];
    for (int i = 0; i < 3; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            cin >> A[i][j];
            OK[i][j] = false;
        }
    }
    int N;
    cin >> N;
    for (int n = 1; n <= N; ++n)
    {
        int b;
        cin >> b;
        for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 3; ++j)
            {
                if (b == A[i][j]) OK[i][j] = true;
            }
        }
    }

    for (int i = 0; i < 3; ++i)
    {
        if (OK[i][0] && OK[i][1] && OK[i][2])
        {
            cout << "Yes" << endl;
            return 0;
        }

        if (OK[0][i] && OK[1][i] && OK[2][i])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (OK[0][0] && OK[1][1] && OK[2][2])
    {
        cout << "Yes" << endl;
        return 0;        
    }

    if (OK[0][2] && OK[1][1] && OK[2][0])
    {
        cout << "Yes" << endl;
        return 0;        
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
long long n, s[100000], t[100000], K, ret, inf = (1LL << 40), num[2];
vector<pair<long long, int>>vec[3200000]; bool used[100000]; vector<bool>vec2[3200000];
long long solve(long long I) {
	long long ret = 1;
	for (long long i = 2; i*i*i <= I; i++) {
		long long U = 0; while (I%i == 0) { I /= i; U++; U %= 3; }
		for (int j = 0; j < (3 - U % 3) % 3; j++) {
			if (ret*i <= inf)ret *= i;
			else ret = inf;
		}
	}
	long long G = (1.0L*sqrtl(1.0L*I) + 0.5L); if (G*G == I) { ret *= G; }
	else { for (int i = 0; i < 2; i++) { if ((inf / I) >= ret)ret *= I; else ret = inf; } }
	return min(ret, inf);
}
void dfs(int pos, int depth) {
	if (used[pos] == true)return;
	num[depth]++; used[pos] = true;
	for (int i = 1; i <= 2000; i++) {
		long long P = 1LL * i*i*i*t[pos]; if (P > 10000000000LL)break;
		int B = (P >> 12); if (vec[B].size() == 0)continue;
		
		int pos1 = lower_bound(vec[B].begin(), vec[B].end(), make_pair(P, 0)) - vec[B].begin();
		if (pos1 >= vec[B].size() || vec[B][pos1].first != P || vec2[B][pos1] == true)continue;
		vec2[B][pos1] = true;
		while (pos1 < vec[B].size() && vec[B][pos1].first == P) {
			dfs(vec[B][pos1].second, depth ^ 1); pos1++;
		}
	}
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i]; t[i] = solve(s[i]);
		if (t[i] != 1)vec[s[i] >> 12].push_back(make_pair(s[i], i)); else K = 1;
	}
	for (int i = 0; i < 3200000; i++) { sort(vec[i].begin(), vec[i].end()); vec2[i].resize(vec[i].size()); }
	for (int i = 0; i < n; i++) {
		if (t[i] == 1 || used[i] == true)continue;
		num[0] = 0; num[1] = 0;
		dfs(i, 0); ret += max(num[0], num[1]);
	}
	cout << ret + K << endl;
	return 0;
}

Measured memory_bytes: 208128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      int num;
      int result;
      int primeMax;
      List<Integer> prime = new ArrayList<>();

      prime.add(2);
      primeMax = 2;

      while(true) {

        if( ((line = br.readLine()) == null) || line.isEmpty() ) break;

        num = Integer.parseInt(line);
        if( num == 0 || num == 1) {
          result = 0;
          System.out.println(result);
          continue;
        }
        
        result = 1;
        for ( int i = 3; i <= num; i+=2 ) {
          if( isPrime(i,prime) ) {
            result += 1;
            if( i > primeMax ) prime.add(i);
          }
        }
        System.out.println(result);
      }
    }
  }

  public static boolean isPrime(int num,List<Integer> prime) {
    int k = Double.valueOf( Math.sqrt(num) ).intValue();
    for(Integer i: prime) {
      if ( num % i == 0 ) return false;
      if ( i > k ) return true;
    }
    return true;
  }
}


Measured memory_bytes: 73260
#include <bits/stdc++.h>
#define dump(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1000000007;
/* テンプレートここまで */

/* 二項係数 C(n,k) mod p を計算 */
const int MAX = 201000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  COMinit();
  ll ans = 0;

  FOR(d,1,N){
    ans += d * (N-d) % MOD * M % MOD * M % MOD * COM(M*N-2, K-2) % MOD;
    ans %= MOD;
  }

  FOR(d,1,M){
    ans += d * (M-d) % MOD * N % MOD * N % MOD * COM(M*N-2, K-2) % MOD;
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4992
#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int,int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;




signed main() {
    ll a,b,c;
    cin >>a>>b>>c;
    if(a== b and a != c){
        cout << "Yes";
    }else  if(a== c and a != b){
        cout << "Yes";
    }else if(b== c and a != b){
        cout << "Yes";
    }else
        
        cout <<"No";

        return 0;
}

Measured memory_bytes: 256
import bisect
x=int(input())
y=list(map(int, input().split()))
 
y.sort()
 
a=0
b=0
c=0
ans=0
for i in range(x):
	a=y[i]
	for j in range(i+1,x):
		b=y[j]
		c=bisect.bisect_left(y,a+b)
		ans=ans+c-j-1
print(ans)

Measured memory_bytes: 3316
# D - Brick Break

N = int(input())
A = [int(a) for a in input().split()]

ls = []
i = 1
for j in range(N):
    if A[j] == i:
        ls.append(A[j])
        i += 1

print(len(A) - len(ls) if 0 < len(ls) else -1)


Measured memory_bytes: 26268
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n;cin >> n;
	n = -n;
	while(n < 0)n += 1000;
	cout << n << endl;

	return 0;
}


Measured memory_bytes: 3616
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [1] * n
for i in range(m):
    ai, bi = map(int, input().split()) 
    if h[ai-1] >= h[bi-1]:
        ans[bi-1] = 0
    if h[ai-1] <= h[bi-1]:
        ans[ai-1] = 0
print(sum(ans))

Measured memory_bytes: 20104
A, B, C, X, Y = gets.split.map(&:to_i)
ret = 10000000000
([X,Y].max).downto(0) do |c_|
    c = c_ * 2
    a = [0, X - c.div(2)].max
    b = [0, Y - c.div(2)].max
    ret = [ret, a*A + b*B + c*C].min
end
puts ret

Measured memory_bytes: 1788
#include <stdio.h>
#include <algorithm>
int n, t, x;
int a[100000];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	std::sort(a, a + n);
	t = 1;
	for (int i = 0; i < n; i++) {
		if (i == n - 1 || a[i] != a[i + 1]) {
			if (t % 2)x++;
			t = 1;
		}
		else t++;
	}
	printf("%d\n", x);
}

Measured memory_bytes: 2092
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0])
    var M = Number(lines[0].split(" ")[1])
    
    var p = Math.pow(0.5, M)
    var t = 1900 * M + 100 * (N - M)

    // ans = (100 * (N - M) + 1900 * M) + (1 - 1/2^M) * ans
    console.log(t / p)
});


Measured memory_bytes: 11596
from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]


def main():
	n=int(nextLine())
	n3=n//3
	s3=n3*(n3+1)//2*3
	n5=n//5
	s5=n5*(n5+1)//2*5
	n15=n//15
	s15=n15*(n15+1)//2*15
	s=n*(n+1)//2
# 	print(s3)
# 	print(s5)
# 	print(s15)
# 	print(s)
	print(s-(s3+s5-s15))
	
	
if __name__=="__main__":
	main()


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int c[3][3];
int a[3];
int b[3];

int main(){
  REP(i,3)REP(j,3)cin >> c[i][j];

  FOR(i,0,101){
    a[0]=i;

    REP(j,3)b[j]=c[0][j]-a[0];
    FOR(j,1,3)a[j]=c[j][0]-b[0];

    bool ok=true;
    FOR(j,1,3)FOR(k,1,3){
      if(c[j][k] != a[j]+b[k]){
        ok=false;
        break;
      }
    }

    if(ok){
      cout << "Yes" << endl;
      exit(0);
    }

  }
  cout << "No" << endl;

}



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

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

long long dp[N][4];

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	long long n; cin >> n;
	
	vector<long long> a(n + 1), b(n + 1), c(n + 1);
	for(long long i = 1; i <= n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	
	dp[1][1] = a[1], dp[1][2] = b[1], dp[1][3] = c[1];
	for(long long i = 2; i <= n; i++){
		dp[i][2] = max(dp[i][2], dp[i - 1][1] + b[i]);  
		dp[i][3] = max(dp[i][3], dp[i - 1][1] + c[i]);
		dp[i][1] = max(dp[i][1], dp[i - 1][2] + a[i]);
		dp[i][3] = max(dp[i][3], dp[i - 1][2] + c[i]);
		dp[i][1] = max(dp[i][1], dp[i - 1][3] + a[i]);
		dp[i][2] = max(dp[i][2], dp[i - 1][3] + b[i]);
	}
	
	cout << max({dp[n][1], dp[n][2], dp[n][3]});
	return 0;
}


Measured memory_bytes: 6656
N = int(input())
original = N

cnt = 0
while N >= 10:
    N //= 10
    cnt += 1
    #print(N)
temp = (N+1) * 10 ** cnt - 1
temp2 = N * 10 ** cnt - 1
#print(temp)
#print(temp2)
if temp == original:
    print(sum(list(map(int, list(str(temp))))))
else:
    print(sum(list(map(int, list(str(temp2))))))

Measured memory_bytes: 38256
#include <cmath>
#include <complex>
#include <vector>
#include <cfloat>
#include <algorithm>
#include<cstdio>
#include<iostream>
using namespace std;
class point;
class line;
point vec_add(point vec1,point vec2);//ベクトルの足し算
point vec_sub(point vec1,point vec2);//ベクトルの引き算
double inner_product(point a,point b);//内積
double outer_product(point a,point b);//外積
bool vec_parallel(point vec1,point vec2);//ベクトルの並行判定(交差判定falseとしても使える)
bool vec_angle_right(point vec1,point vec2);//ベクトルの直行判定
bool cross_line_segment(line a,point p1,point p2);//直線と線分の交差判定
class point{
public:
double x,y;
point(){
x=0;
y=0;
}
point(double a,double b){
x=a;
y=b;
}
void in(double a,double b){
x=a;
y=b;
return ;
}
};
//直線クラス
class line{
public:
point s,v;
public:
line(point a,point b){
s=a;
v=vec_sub(a,b);
}
};
//ベクトルの足し算
point vec_add(point vec1,point vec2){
point res(vec1.x+vec2.x,vec1.y+vec2.y);
return res;
}
//ベクトルの引き算
point vec_sub(point vec1,point vec2){
point res(vec1.x-vec2.x,vec1.y-vec2.y);
return res;
}
//内積
double inner_product(point a,point b){
return a.x * b.x + a.y * b.y;
}
//外積
double outer_product(point a,point b){
return a.x * b.y - a.y * b.x;
}
point p[6];
bool solve(){
bool judge;
bool ans;
if(outer_product(p[0],p[1])>0){
judge=true;
}else{
judge =false;
}
for(int i=1;i<4;i++){
if(outer_product(p[i],p[i+1])>0){
if(judge!=true) return false;
}else if(outer_product(p[i],p[i+1])==0){
return false;
}else{
if(judge!=false) return false;
}
}
return true;
}
int main(){
while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&p[0].x,&p[0].y,&p[1].x,&p[1].y,&p[2].x,&p[2].y,&p[3].x,&p[3].y)!=EOF){
p[4]=p[0];
p[5]=p[1];
for(int i=0;i<5;i++){
p[i]=vec_sub(p[i],p[i+1]);
}
bool ans=solve();
if(ans){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
char S[12];
int main(){
  int c, i, ok;
  N = rd(S);
  ok = 1;
  if(S[0]!='A'){
    ok = 0;
  }
  c = 0;
  for(i=2;i<N-1;i++){
    if(S[i]=='C'){
      c++;
    }
  }
  if(c!=1){
    ok = 0;
  }
  c = 0;
  for(i=0;i<N;i++){
    if('A'<=S[i] && S[i]<='Z'){
      c++;
    }
  }
  if(c!=2){
    ok = 0;
  }
  if(ok){
    wt_L("AC");
    wt_L('\n');
  }
  else{
    wt_L("WA");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190630-1

// --- original code ---
// int N; char S[12];
// {
//   int i, c, ok;
//   rd(S@N);
// 
//   ok = 1;
//   if(S[0]!='A') ok = 0;
// 
//   c = 0;
//   rep(i,2,N-1) if(S[i]=='C') c++;
//   if(c!=1) ok = 0;
// 
//   c = 0;
//   rep(i,N) if('A'<=S[i]<='Z') c++;
//   if(c!=2) ok = 0;
// 
//   wt(if[ok,"AC","WA"]);
// }


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>

int main() {
  int n = 0, a = 0, b = 0;

  scanf(" %d", &n);

  if (n % 2 == 0)
    printf("%d", n);
  else
    printf("%d", n * 2);

  return 0;
}


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

#define int long long

string S;

signed main()
{
	string ans;
	cin >> S;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == 'B') { if (ans.size() > 0) ans.pop_back(); }
		else ans.push_back(S[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256