akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, j) for(int i = 0; i < j; ++i)
#define INF (1 << 30)
#define MAX 10000

int main() {
	int n, m, p[MAX];
	while(cin >> n >> m, n || m) {
		int total = 0;
		rep(i, n) {
			cin >> p[i];
			total += p[i];
		}
		sort(p, p + n);
		for(int i = n - m; i >= 0; i -= m) total -= p[i];
		cout << total << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
import math

a,b,h,m=map(int,input().split())

m2 = 6 * m
h2 = 30 * h + m*30/60
kakudo = abs(h2-m2)

ruuto= math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo)))
print(ruuto)

Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

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

  ans = a - 2 * b > 0 ? a - 2 * b : 0;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, C = map(int, readline().split())

    if A + B >= C:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
    string S;
    cin >> S;

    int N = 0, W = 0, s = 0, E = 0;
    for (int i = 0; i < S.length(); i++){
        if (S[i] == 'N'){
            N ++;
        }else if(S[i] == 'W'){
            W ++;
        }else if(S[i] == 'S'){
            s ++;
        }else if(S[i] == 'E'){
            E ++;
        }
    }

    if (max(E, W) != 0 && E * W == 0){
        cout << "No" << endl;
    }else if(max(N, s) != 0 && N * s == 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        if (a > 8 || b > 8)
            System.out.println(":(");
        else
            System.out.println("Yay!");
    }
}


Measured memory_bytes: 35668
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    
    bool flag = true;
    for (int i = 0; i < N-1; ++i) {
        if (H[i+1] > H[i]) H[i+1]--;
        if (H[i+1] < H[i]) {
            flag = false;
            break;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    S = input()
    print(S[:3])

if __name__ == '__main__':
    solve()


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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

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

  if(b-a == c-b) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
int main(){
  int a = 0;
  cin >> a;
  vector<int> b(a);
  for(int i = 0;i <= a - 1;i++){
    b[i] = 1000000;
  }
  int c = 0;
  int d = 0;
  int e = 0;
  int mina = 0;
  mina = 1000000;
  for(int i = 0;i <= a - 1;i++){
    cin >> b[i];
    if(b[i] <= mina){
      c++;
      mina = b[i];
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
n = int(input())
x = input()
cnt = x.count("1")
x_cnt_plus = 0
x_cnt_minus = 0
for i in range(n):
    if x[i] == "1":
        x_cnt_plus += pow(2, n - i - 1, cnt + 1)
        x_cnt_plus %= cnt + 1
        if cnt > 1:
            x_cnt_minus += pow(2, n - i - 1, cnt - 1)
            x_cnt_minus %= cnt - 1
for i in range(n):  # 上からi 桁目に注意
    if x[i] == "0":
        f = x_cnt_plus + pow(2, n - i - 1, cnt + 1)
        f %= cnt + 1
    else:
        if cnt == 1:
            print(0)
            continue
        f = x_cnt_minus + cnt - 1 - pow(2, n - i - 1, cnt - 1)
        f %= cnt - 1
    ans = 1
    while f != 0:
        cnt_f_1 = 0
        k = f
        while k:
            if k % 2:
                cnt_f_1 += 1
            k //= 2
        f = f % cnt_f_1
        ans += 1
    print(ans)
"""
step1; 1を数える cnt_1 
step2 : 全体の計算をする cnt1 + 1 とcnt1 -1 それぞれ
step3 : それぞれの桁に対して0 なら cnt+ 1 を適用 + 2**k mod cnt + 1
            1ならcnt - 1　を適用 - 2**k mod (cnt-1)
step4 : その中でf(x)を0になるまで計算
"""



Measured memory_bytes: 78096
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	b := make([]int, n)
	ans := make([]int, 0, n)
	for i := len(a); i >= 1; i-- {
		x := 0
		for j := 2; j <= n; j++ {
			if i*j > n {
				break
			}
			x ^= b[i*j-1]
		}
		b[i-1] = x ^ a[i-1]
		if b[i-1] == 1 {
			ans = append(ans, i)
		}
	}

	fmt.Println(len(ans))
	for i, v := range ans {
		if i == len(ans)-1 {
			fmt.Println(v)
			continue
		}
		fmt.Printf("%d ", v)
	}
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
    #define int long long
    #define gcd            __gcd
    #define setbits(x)     __builtin_popcountll(x)
    #define zrobits(x)     __builtin_ctzll(x)
    #define mod            1000000007
    #define mod2           998244353
    #define maxe           *max_element
    #define mine           *min_element
    #define inf            1e18
    #define deci(x,y)      fixed<<setprecision(y)<<x
    #define w(t)           int t; cin>>t; while(t--)
    #define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
    #define PI             3.141592653589793238
    using namespace std;

    int power(int x, int y, int p)
    {
        int res = 1;
        x = x % p;
        while (y > 0)
        {
            if (y & 1)
                res = (res * x) % p;
            y = y >> 1;
            x = (x * x) % p;
        }
        return res;
    }
    int modi(int a, int m)
    {
        return power(a, m - 2, m);
    }
    int32_t main()
    {
        nitin;
        int n,k;
        cin>>n>>k;
        vector<int>v(n+1,0);
        for(int i=1;i<=n;i++)
        {
            cin>>v[i];
        }
        vector<int>fp(n+2,0);
        vector<int>bp(n+2,0);
        for(int i=1;i<=n;i++)
        {
            if(v[i]>0)
            {
                fp[i]=bp[i]=v[i];
            }
        }
        for(int i=1;i<=n+1;i++)
        {
            fp[i]+=fp[i-1];
        }
        for(int i=n;i>=0;i--)
        {
            bp[i]+=bp[i+1];
        }
        for(int i=1;i<=n;i++)
        {
            v[i]+=v[i-1];
        }
        int ans=0;
        int i=k;
        for(i=k;i<=n;i++)
        {
            ans=max(ans,v[i]-v[i-k]+fp[i-k]+bp[i+1]);
        }
        for(int i=k;i<=n;i++)
        {
            ans=max(ans,fp[i-k]+bp[i+1]);
        }
        cout<<ans<<endl;
    }

Measured memory_bytes: 5548
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#include <complex>
#define ll long long
using namespace std;


int main() {
	string s;
	int fi, se;
	bool f1,f2;
	cin >> s;
	fi = (int)(s[0] - '0') * 10 + (int)(s[1] - '0');
	se = (int)(s[2] - '0') * 10 + (int)(s[3] - '0');
	if (fi >= 1 && fi <= 12)f1 = true;
	else f1 = false;
	if (se >= 1 && se <= 12)f2 = true;
	else f2 = false;
	if (f1 && f2) cout << "AMBIGUOUS" << endl;
	else if (f2) cout << "YYMM" << endl;
	else if (f1) cout << "MMYY" << endl;
	else cout << "NA" << 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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main() {
  int n,m,x;
  cin >> n>>m>>x;
  vector<int>a(m);
  rep(i,m){
    cin>>a.at(i);
  }
  int co=0;
  rep(i,m){
    if(a.at(i)<x){
      co++;
    }
  }
  int ans=min(co,m-co);
  
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;

struct edge {
    int v, cost;
    ll time;
};

struct status {
    ll time;
    int coin, v;

    bool operator>(const status &rhs) const { return time > rhs.time; };
};

constexpr ll INF = 1e17;
constexpr int LIMIT = 3000;

int n, init;
vector<vector<edge>> graph;
vector<pair<int, int>> vertex;

void dijkstra() {
    priority_queue<status, vector<status>, greater<>> que;
    vector<vector<ll>> dis(n, vector<ll>(LIMIT, INF));
    dis[0][init] = 0;
    que.push({0, init, 0});

    while (!que.empty()) {
        status now = que.top();
        que.pop();

        if (dis[now.v][now.coin] < now.time)continue;

        ll nextTime = now.time + vertex[now.v].second;
        int nextCoin = min(LIMIT, now.coin + vertex[now.v].first);

        if (dis[now.v][nextCoin] > nextTime) {
            dis[now.v][nextCoin] = nextTime;
            que.push({dis[now.v][nextCoin], nextCoin, now.v});
        }

        for (auto next:graph[now.v]) {
            nextCoin = now.coin - next.cost;
            if (nextCoin < 0)continue;
            if (dis[next.v][nextCoin] > now.time + next.time) {
                dis[next.v][nextCoin] = now.time + next.time;
                que.push({dis[next.v][nextCoin], nextCoin, next.v});
            }
        }
    }

    for (int i = 1; i < n; i++) {
        ll ret = INF;
        for (int j = 0; j < LIMIT; j++) ret = min(ret, dis[i][j]);
        cout << ret << endl;
    }
}

int main() {
    int m;
    cin >> n >> m >> init;
    init = min(init, LIMIT);

    graph.resize(n);
    for (int i = 0; i < m; i++) {
        int from, to, cost, time;
        cin >> from >> to >> cost >> time, from--, to--;
        graph[from].push_back({to, cost, time});
        graph[to].push_back({from, cost, time});
    }
    vertex.resize(n);
    for (int i = 0; i < n; i++) {
        int c, d;
        cin >> c >> d;
        vertex[i] = {c, d};
    }

    dijkstra();
    return 0;
}

Measured memory_bytes: 6464
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int count=0;
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			int state=0;
			int a=sc.nextInt();
			for(int j=2;j<=Math.sqrt(a);j++){
				if(a%j==0){
					state=1;
					break;
				}
			}
			if(state==0){
				//System.out.println(a);
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 41348
#include <bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
#define S second
#define F first
using namespace std;


typedef struct node{
    int s, e, val, pos;
    bool operator<(const node& n) const{
        if(e != n.e) return e < n.e;
        return val > n.val;
    }
    node(){};
    node(int ss, int ee, int v, int p){
        s = ss, e = ee, val = v, pos = p;
    }
}node;
 
int occs[5*(int)1e6 + 5], tree[5000005], n, ans[5000005];
 
void update(int x, int val){
    while(x <= n){
        tree[x] += val;
        x += x & -x;
    }
}
 
int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}
void solve()
{
   int q, s, e;
    vector<node> v;
    scanf("%d", &n);
    
    scanf("%d", &q);
    for(int i = 1; i <= n; i++){
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }
    for(int i = 0; i < q; i++){
        scanf("%d %d", &s, &e);
        v.push_back(node(s, e, 0, i));
    }
 
    sort(v.begin(), v.end());
 
    for(int i = 0;i < v.size(); i++){
        if(v[i].val == 0){
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        }else{
            if(occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }
 
    for(int i = 0; i < q; i++){
        printf("%d\n", ans[i]);
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    //cin >> t;
    t=1;
    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 25416
#include <bits/stdc++.h>
#define tt long t;cin>>t;while(t--)
#define tez ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define plli pair<lli,lli>
#define vlli vector<lli>
#define vplli vector<plli>
#define pqlli priority_queue <lli>
#define pqplli priority_queue <plli>
#define mplli map<lli,lli>
#define all(v) v.begin(),v.end()
#define alll(s) s.begin(),s.end(),s.begin(), ::tolower
#define allu(s) s.begin(),s.end(),s.begin(), ::toupper

#define mod 1000000007
#define ff first
#define ss second
#define fori(i,a,b)    for(int i=a;i<b;i++)
#define ford(i,a,b)    for(int i=a;i>=b;i--)
#define br cout<<endl
#define sz(v) (long)v.size()
#define YS cout<<"YES"<<endl
#define ys cout<<"yes"<<endl
#define Ys cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define no cout<<"no"<<endl
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define bs binary_search
#define mp make_pair
#define llmn LLONG_MIN
#define llmx  LLONG_MAX
#define stp setprecision
#define fxd fixed
#define tu (char)toupper
#define tl (char)tolower
#define coutv(v) for(lli index=0;index<v.size();index++) {cout<<v[index]<<" ";} br;

using namespace std;

/*
lli count01(string s,char ch){
  lli mx=0,c=0;
  if(ch=='0'){

   fori(i,0,sz(s)){
     if(s[i]=='0'){
        c++;}
     else{
        c=0;}
        if(c>mx){mx=c;}

   }

  }
  else{

    fori(i,0,sz(s)){
     if(s[i]=='1'){
        c++;}
     else{
        c=0;}
        if(c>mx){mx=c;}

    }

  }
return mx;

}*/
/*
vector<lli> prime(lli n){
  bool a[n+1];
  memset(a,true,sizeof(a));
  for(lli i=2;i*i<=n;i++){
    if(a[i]){
      for(lli j=i*i;j<=n;j+=i)
      {  a[j]=false;}
    }
  }
  vector<lli>v;
  for(lli i=2;i<=n;i++){
    if(a[i]){
      v.pb(i);
    }
  }
  return v;
}

*/
void solve(){
    lli n=0,m;
    string s,ss;
    cin>>n;
    while(n>0){
        lli k=n%26;
        if(k==0){
            s.pb('z');
            n/=26;
            n--;
        }else{
            char ch;
            ch='a'+(k-1);
            s.pb(ch);
            n/=26;
        }
    }
    reverse(all(s));
    cout<<s<<endl;


}

int main(){
tez
    solve();
return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

vector<P> v;

int main() {
  ll N;
  cin >> N;
  ll a[N], b[N];
  for (int i = 0; i < N; i++) cin >> a[i] >> b[i];

  for (int i = 0; i < N; i++) {
    v.push_back(P(b[i], a[i]));
  }
  sort(v.begin(), v.end());

  ll t = 0;
  for (int i = 0; i < N; i++) {
    if (t + v[i].second > v[i].first) {
      cout << "No" << endl;
      return 0;
    }
    t += v[i].second;
  }

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


Measured memory_bytes: 9584
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    double ans = 0.0;
    REP(i,n){
        double x;
        string u;
        cin >> x >> u;
        if(u=="BTC"){
            ans += x*380000.0;
        }else{
            ans += x;
        }
    }
    printf("%.6f\n",ans);
    return 0;
}

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

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

    string s;
    cin >> s;
    int ans = 0;
    for (char c : s) {
        if (c == '1') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endre getchar();getchar();return 0
#define moder 998244353
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/


signed main() {
	int n, x;
	cin >> n >> x;
	if (n == 2 && x != 2) {
		cout << "No" << endl;
		endre;
	}
	else if (n == 2) {
		cout << "Yes" << endl;
		cout << 1 << endl << 2 << endl << 3 << endl;
		endre;
	}
	n = n * 2 - 1;
	if (x == 1 || x == n) {
		cout << "No" << endl;
		endre;
	}
	cout << "Yes" << endl;
	if (x == 2) {
		queue<int>ans;
		REP(i, n + 1) {
			if (i > 4)ans.push(i);
		}
		rep(i, n / 2 - 1) {
			cout << ans.front() << endl;
			ans.pop();
		}
		cout << 3 << endl << 2 << endl << 1 << endl << 4 << endl;
		rep(i, n / 2 - 2) {
			cout << ans.front() << endl;
			ans.pop();
		}
	}
	else {
		queue<int>ans;
		REP(i, n + 1) {
			if (i<x - 2 || i>x + 1)ans.push(i);
		}
		rep(i, n / 2 - 1) {
			cout << ans.front() << endl;
			ans.pop();
		}
		cout << x - 1 << endl << x << endl << x + 1 << endl << x - 2 << endl;
		rep(i, n / 2 - 2) {
			cout << ans.front() << endl;
			ans.pop();
		}
	}
	endre;
}


Measured memory_bytes: 3200
def sales_price(a, b)
    return a * b
end

def sales_check(staff_num, unit_price, quantity)
    if @sales_hash.key?(staff_num)
        @sales_hash[staff_num] = @sales_hash[staff_num] + sales_price(unit_price, quantity)
    else
        @sales_hash[staff_num] = sales_price(unit_price, quantity)
    end
end

while data_num = gets.to_i
    break if data_num == 0

    @sales_hash = {}
    data_num.times do
        a, b, c = gets.chomp.split(' ').map!(&:to_i)
        sales_check(a, b, c)
    end

    sales_check_result = []
    @sales_hash.each do |staff_num, sales_price|
        if sales_price >= 1000000
            sales_check_result << staff_num
        end
    end

    if sales_check_result == []
        puts "NA"
    else
        puts sales_check_result
    end
end

Measured memory_bytes: 6112
#include <cstdio>
#include <algorithm>
using namespace std;
int N, h[100005], dp[100005];
int main() {
  scanf("%d", &N);
  for(int i = 1; i <= N; ++i) scanf("%d", &h[i]);
  dp[0] = 1e9, dp[1] = 0;
  for(int i = 2; i <= N; ++i) {
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
  }
  printf("%d\n", dp[N]);
}

Measured memory_bytes: 896
#include<iostream>
#include<queue>
#include<functional>
#define N 200
#include<vector>
#define INF 100000000
#include<map>
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,k,x,a,b,c,d,e,dp[N];
	while(cin>>n>>k,n||k){
		vector<P> E[N];
		while(k--){
		cin>>x;
		if(x==0){
			cin>>a>>b;
			a--;b--;
			priority_queue<P,vector<P>,greater<P> > que;
			fill(dp,dp+n,INF);
			dp[a]=0;
			que.push(P(a,0));
			while(!que.empty()){
				P p=que.top();
				que.pop();
				if(dp[p.first]<p.second)
				continue;
				for(int i=0;i<E[p.first].size();i++)
				if(dp[E[p.first][i].first]>p.second+E[p.first][i].second){
					que.push(P(E[p.first][i].first,p.second+E[p.first][i].second));
					dp[E[p.first][i].first]=p.second+E[p.first][i].second;
				}
			}if(dp[b]==INF)
			cout<<-1<<endl;
			else
			cout<<dp[b]<<endl;
		}else{
			cin>>c>>d>>e;
			c--;d--;
			E[c].push_back(P(d,e));
			E[d].push_back(P(c,e));
		}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
using namespace std;

int main() {
  int N; cin >> N;
  int A[200010];
  for (int i = 0; i < N; i++)
    cin >> A[i];
  
  long x = A[0];
  long y = 0;
  for (int j = 1; j < N; j++)
    y += A[j];
  long ans = abs(x - y);
  for (int k = 1; k <= N - 2; k++) {
    x += A[k];
    y -= A[k];
    ans = min(ans, abs(x - y));
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
int a,b,K;

  scanf("%d %d",&a,&b);
    K=(a+b)/2;
  if((a%2==0 && b%2==0)||(a%2==1 && b%2==1))
   {
	 printf("%d",K);}
  else{printf("IMPOSSIBLE");}
}

Measured memory_bytes: 128
n,m=map(int,input().split())
student=[]
check=[]
for i in range(n):
    a,b=map(int,input().split())
    student.append([a,b])
for i in range(m):
    a,b=map(int,input().split())
    check.append([a,b])
for i in student:
    minimam=10**10
    point=0
    for j in range(m):
        if abs(i[0]-check[j][0])+abs(i[1]-check[j][1]) < minimam:
            minimam=abs(i[0]-check[j][0])+abs(i[1]-check[j][1])
            point = j+1
    print(point)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int main(){

	while(1){
		string instr = "";
		int n;
		cin >> n;
		if(n == 0)
			break;
		map<char,char> mcc;
		for(int i = 0; i <= 200; i++){
			mcc[i] = i;
		}
		for(int i = 0; i < n; i++){
			char c,d;
			cin >> c;
			cin >> d;
			mcc[c] = d;
		}
		int m;
		cin >> m;
		for(int i = 0; i < m; i++){
			char c;
			cin >> c;
			instr += c;
		}
		
		string nstr = "";
		for(int i = 0; i < instr.size(); i++){
			nstr += mcc[instr[i]];
		}
		cout << nstr << endl;
	}


	return 0;
}

Measured memory_bytes: 1136
import Control.Monad  -- replicateM

main = do 
  n  <- readLn
  ss <- replicateM n getLine
  putStr . unlines . map snakeType $ ss

snakeType s
  | isTypeA s = "A"
  | isTypeB s = "B"
  | otherwise = "NA"

isTypeA s =
  s == ">'" ++ eqs ++ "#" ++ eqs ++ "~" && length eqs >= 1
  where eqs = takeWhile (== '=') (drop 2 s)

isTypeB s =
  s == ">^" ++ qs ++ "~~" && length qs >= 2
  where qs = concat $ replicate ((length s - 4) `div` 2) "Q="

Measured memory_bytes: 9140
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int[] a = new int[5];
                int last = 0;
                int[] b = new int[5];
                for(int i = 0 ; i < 5 ; i++){
                        a[i] = sc.nextInt();
                        if(a[i] % 10 == 0){
                                b[i] = 10;
                        }else{
                                b[i] = a[i] % 10;
                        }
                        if(b[last] > b[i]) last = i;
                }
                int yono = 0;
                yono += a[last];
                a[last] = 0;
                for(int i = 0 ; i < 5 ; i++){
                        a[i] = (int)Math.ceil(a[i] / 10.0);
                        a[i] *= 10;
                        yono += a[i];
                }
                System.out.println(yono);
        }
}//0=48
//鶏になれ

Measured memory_bytes: 35828
#include<bits/stdc++.h>
using namespace std;
map<string,bool>mp;

int main(){
  int n;
  char last;
  bool f=0;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(i!=0&&last!=s[0]){
      f=true;
    }
    if(mp.count(s)==0){
      mp[s]=1;
    }
    else{
      f=true;
    }
    last=s[s.size()-1];
  }
  if(f)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return(0);
}

Measured memory_bytes: 256
package main
/* 
aaa
*/
import (
        "bufio"
        "fmt"
        "os"
  		"strconv"
)

func main() {

        stdin := bufio.NewScanner(os.Stdin)
        stdin.Scan()
        n, _ := strconv.Atoi(stdin.Text())
  if n >= 0 && n < 1200{
    fmt.Println("ABC")
  }
  if n >= 1200 && n < 2800 {
    fmt.Println("ARC")    
  }
  if n >= 2800 {
    fmt.Println("AGC")    
  }
     
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  cout << a.at(N - 1) - a.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int n;
double p, dp[1501];

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

    cin >> n;
    dp[0] = 1.0;
    rep(i, n) {
        cin >> p;
        for(int j = min((int)i, n / 2); j >= 0; j--) {
            dp[j + 1] += dp[j] * p;
            dp[j] *= 1.0 - p;
        }
    }

    printf("%.10f\n", dp[n / 2 + 1]);

    return 0;
}

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

int main(){//main_program
  vector<int> X(5);
  int N;
  
  for(int i = 0;i < 5; i++){
    cin >> X.at(i);
    if(X.at(i) == 0){
      N = i +1;
    }
  }
  cout << N << endl;
  
}

Measured memory_bytes: 3544
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    int K;
    int Q;
    int i;
    
    scanf("%d %d %d",&N,&K,&Q);
    int count[N];
    for(i=0;i<N;i++){
        count[i]=0;
    }
    for(i=0;i<Q;i++){
        int d;
        scanf("%d",&d);
        count[d-1]=count[d-1]+1;//そいつが何回正解したか
    }
    
    for(i=0;i<N;i++){
        if(K>Q){
            printf("Yes\n");
        }else{
            if((K-Q)+count[i]>0){
                printf("Yes\n");
            }else{
                printf("No\n");
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 896
<?php
//Sの部分文字列になりうる全パターンに対して一致率を算出して一致率が高いパターンに関して
//Tが部分文字列となるのに必要な文字の変更数を算出する
fscanf(STDIN,"%d",$n);
$sum = 0;
$mod = 10**9+7;
$sum_ini = 0;
$a_li = explode(" ",trim(fgets(STDIN)));
for($i=0;$i<$n;$i++){
  $sum_ini += $a_li[$i];
  $sum_ini %= $mod;
}
for($i=0;$i<$n;$i++){
 $sum_ini -= $a_li[$i];
 if ($sum_ini < 0) $sum_ini += $mod;
 $sum += ($a_li[$i])*($sum_ini);
 $sum %= $mod;
}

echo ($sum);

//echo (10**9)*(10**9);

Measured memory_bytes: 31960
n = int(input())
A = list(map(int, input().split()))
if n==0:
    print(1 if A[0] == 1 else -1)
    exit()
if A[0]!=0:
    print(-1)
    exit()
node1=[0]*(n+1)
node1[0]=1
node2=[0]*(n+1)
node2[0]=1
node2[-1]=A[-1]
for i in range(n):
    x=(node1[i]-A[i])*2
    node1[i+1]=x

for i in range(n,0,-1):
    x=(node2[i]+A[i-1])
    node2[i-1]=x

ans=[]

for i in range(n+1):
    x=min(node1[i],node2[i])
    if x<A[i]:
        print(-1)
        exit()
    ans.append(x)
print(sum(ans))

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

int main() {
	
	int n, a, b;
	cin >> n >> a >> b;
	
	int min, max;
	if (a<=b) {
		max = a;
	} else {
		max = b;
	}
	
	if (a+b>n) {
		min = a+b-n;
	} else {
		min = 0;
	}
	
	cout << max << " " << min << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

// 抽象二次元累積和
// 構築 O(hw), get O(1)
// TODO verify (https://atcoder.jp/contests/arc089/tasks/arc089_b)

//       ^
//       u
//  <= l   r =>
//       d
//       v      

template<typename T>
struct RecSum{
private: 
  size_t h, w;
  vector<vector<T>> dat;

public: 
  RecSum(const vector<vector<T>> &v){
    h = v.size();
    w = v[0].size();
    dat.resize(h + 1);
    for(size_t i = 0; i < h + 1; i++) dat[i].resize(w + 1, 0);
    for(size_t i = 0; i < h; i++){
      for(size_t j = 0; j < w; j++){
        dat[i + 1][j + 1] = v[i][j] + dat[i + 1][j];
      }
    }
    for(size_t j = 0; j < w; j++){
      for(size_t i = 0; i < h; i++){
        dat[i + 1][j + 1] += dat[i][j + 1];
      }
    }
  }

  T get(size_t l, size_t r, size_t u, size_t d) const { // 0-indexed, [l, r), [u, d)
    return dat[d][r] - dat[u][r] - dat[d][l] + dat[u][l];
  }
};

int main() {
  
  int h, w, d; cin >> h >> w >> d;
  vector<vector<int>> a(h, vector<int> (w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c; cin >> c;
      if (c == '#') {
        a[i][j] = 1;
      } else {
        a[i][j] = 0;
      }
    }
  }

  RecSum<int> rs(a);

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j <= w - d; j++) {
      int sum = rs.get(j, j + d, i, i + 1);
      if (sum == 0) ans++;
    }
  }

  for (int j = 0; j < w; j++) {
    for (int i = 0; i <= h - d; i++) {
      int sum = rs.get(j, j + 1, i, i + d);
      if (sum == 0) ans++;
    }
  }

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



Measured memory_bytes: 3228
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

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

using namespace std;

int N;
char S[1000000];
int dp[1000000];

int main()
{
    scanf("%d", &N);
    REP(i, N)
        scanf(" %c", &S[i]);

    int tmp = 0;
    FOR(i, 1, N) {
        if(S[i]=='E')
            tmp++;
    }
    dp[0] = tmp;

    int ans = dp[0];
    REP(i, N-1) {
    tmp = 0;
        if(S[i]=='W')
            tmp++;
        if(S[i+1]=='E')
            tmp--;
        dp[i+1] = dp[i] + tmp;
        ans = min(ans, dp[i+1]);
    }
    //REP(i, N)
    //    printf("%d ", dp[i]);
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main(){
 int a,b,c,d;
 cin>>a>>b>>c;
 if(a==b){
 d=c;
 }
 else if(a==c){
 d=b;
 }
 else if(b==c){
 d=a;
 }
 cout<<d;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

const int MAXN = 100010;
int R, C, n, pn;
int s[MAXN], top;
struct Point {
	int loc, id, t;
	bool operator < (const Point &rhs) const {
		return loc < rhs.loc;
	}
}P[MAXN<<1];

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x * f;
}

inline int turn(int x, int y) {
	if(x == 0) return y;
	if(y == C) return C+x;
	if(x == R) return C+R+(C-y);
	return 2*C+R+(R-x);
}

int main() {
	int i;
	R = read(), C = read(), n = read();
	for(i = 1; i <= n; i++) {
		int x1 = read(), y1 = read(), x2 = read(), y2 = read();
		if(x1 != 0 && x1 != R && y1 != 0 && y1 != C) continue;
		if(x2 != 0 && x2 != R && y2 != 0 && y2 != C) continue;
		int lef = turn(x1, y1), rig = turn(x2, y2);
		if(lef > rig) swap(lef, rig);
		P[++pn].loc = lef, P[pn].id = i, P[pn].t = 1;
		P[++pn].loc = rig, P[pn].id = i, P[pn].t = -1;
	}
	sort(P+1, P+pn+1);
	//for(i = 1; i <= ln; i++) printf("%d %d\n", L[i].l, L[i].r);
	for(i = 1; i <= pn; i++) {
		if(P[i].t == -1) {
			if(P[i].id != P[s[top]].id) break;
			top--;
			continue;
		}
		else s[++top] = i;
	}
	if(i <= pn) printf("NO\n");
	else printf("YES\n");
	return 0;
}


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

int main() {
    ll ans=0;
    int n; cin >> n;
    vector<ll> a(n),b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());

    if(a[0]%b[0]!=0) ans += b[0]-a[0]%b[0];
    for(int i = 1; i < n; i++) {
        a[i]+= ans;
        if(a[i]%b[i]==0) continue;
        ll x=b[i]-a[i]%b[i];
        ans += x;
    }

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

Measured memory_bytes: 4836
using System;
class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            char[] line = Console.ReadLine().ToCharArray();
            if (line[0] == '-') break;
            int linecount = line.Length;
            int count = int.Parse(Console.ReadLine());
            for (int i = 0; i < count; i++)
            {
                char[] answer = new char[linecount];
                int h = int.Parse(Console.ReadLine());
                int index = linecount - h;
                for(int j = 0;j<h;j++){
                    answer[index + j] = line[j]; 
                }
                for (int j = h; j < linecount; j++)
                {
                    answer[j - h] = line[j];
                }
                line = answer;
            }
            Console.WriteLine(line);
        }
    }
}

Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,k;

int main(){
	cin>>n>>k;
	int t;
	double ans=0;
	for(int i=1;i<=n;i++){
		t=i;
		double l=1;
		while(t<k){
			t*=2;
			l=l/2;
		}
		ans=ans+l;
	}
	ans=ans/(double)n;
	printf("%.15f",ans);
	return 0;
}
	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

#define rep(a, b, c) for (int a = b; a < (c); a++)
#define repe(a, b, c) for (int a = b; a <= (c); a++)

using namespace std;

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

    vector< vector<long long unsigned> > dp(N, vector<long long unsigned>(21, 0));
    int num;
    cin >> num;
    dp[0][num] = 1;
    rep(i, 1, N) {
        cin >> num;
        repe(j, 0, 20) {
            if (j + num <= 20) dp[i][j + num] += dp[i - 1][j];
            if (j - num >= 0) dp[i][j - num] += dp[i - 1][j];
        }
    }
    cin >> num;
    cout << dp[N - 2][num] << endl;

    return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int a;
    cin >> a;
    double ans;
    if(a == 0){
        ans = 1.0;
    }else if(a % 2 == 0){
        ans = (a / 2.0) / a;
    }else{
        ans = ((a + 1) / 2.0) / a;
    }
    cout << fixed << ans << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    set<int> s;
    for(int i=0;i<n;i++){
        s.insert(d[i]);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
vector<int> getoffset(const string &a, const string &b) {
    vector<int> ans(a.size() + 1);
    for (int off = 0; off <= a.size(); off++) {
        bool ok = true;
        for (int i = 0, end = min(a.size() - off, b.size()); i < end; i++) {
            if (a[off + i] != '?' && b[i] != '?' && a[off + i] != b[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ans[off] = 1;
    }
    return ans;
}
int main() {
    vector<string> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(begin(A), end(A));
    int ans = 1e9;
    do {
        auto ab = getoffset(A[0], A[1]);
        auto bc = getoffset(A[1], A[2]);
        auto ac = getoffset(A[0], A[2]);
        for (int off1 = 0; off1 <= 2000; off1++) {
            for (int off2 = 0; off2 <= 2000; off2++) {
                if (off1 < ab.size() && ab[off1] == 0) continue;
                if (off2 < bc.size() && bc[off2] == 0) continue;
                if (off1 + off2 < ac.size() && ac[off1 + off2] == 0) continue;
                int len = max({A[0].size(), off1 + A[1].size(), off1 + off2 + A[2].size()});
                ans = min(ans, len);
            }
        }
    } while (next_permutation(begin(A), end(A)));
    cout << ans << endl;
    return 0;
}


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

struct node{
    int key;
    node *left,*right,*p;
    node(){}
    node(int key):key(key){left=right=p=NULL;};
};
node *root;
int f=0;
int insert(node z){
    node *y=NULL;
    node *x=root;
    while(x!=NULL){
        y=x;
        if(z.key<x->key){
            x=x->left;
        }
        else{
            x=x->right;
        }
    }
    z.p=y;
    if(y==NULL){
        root=new node(z);
    }
    else if(z.key<y->key){
        y->left=new node(z);
    }
    else{
        y->right=new node(z);
    }
    return 0;
}
int t(node *a){
    if(a==NULL)return 0;
    t(a->left);
    cout <<" " << a->key;
    t(a->right);
    return 0;
}
int u(node *a){
    if(a==NULL)return 0;
    cout <<" "<< a->key;
    u(a->left);
    u(a->right);
    return 0;
}
int find(node *a,int z){
    if(a==NULL)return 0;
    else if(a->key==z)f=1;
    else if(a->key>z)find(a->left,z);
    else if(a->key<z)find(a->right,z);
    return 0;
}
int main(void){
    int m;
    root=NULL;
    cin >> m;
    for(int i=0;i<m;i++){
        string s;
        cin >> s;
        if(s=="print"){
            t(root);
            cout << endl;
            u(root);
            cout << endl;
            continue;
        }
        if(s=="find"){
            int n;
            cin >> n;
            find(root,n);
            if(f==1)cout <<"yes"<<endl;
            else if(f==0)cout << "no" <<endl;
            f=0;
            continue;
        }
        int n;
        cin >> n;
        insert(node(n));
        
    }
    return 0;
}



Measured memory_bytes: 21856
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, long> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<int> t(n+1), v(n);t[0]=0;
  rep(i, n)cin>>t[i+1];
  rep(i, n){
  	t[i+1]+=t[i];
  }
  rep(i, n)cin>>v[i];
  int Mt=t[n];
  int dtime=1;
  int dmv, pdmv=0;
  int ans=0;
  while(dtime<=Mt*2){
    dmv=min(dtime, Mt*2-dtime);
    rep(i, n){
      if(t[i]*2<=dtime && dtime<=t[i+1]*2){
      	dmv=min(dmv, v[i]*2);
      }else if(dtime<t[i]*2){
        dmv=min(dmv, (t[i]*2-dtime)+v[i]*2);
      }else{
      	dmv=min(dmv, (dtime-t[i+1]*2)+v[i]*2);
      }
    }
    // cout<<dtime*0.5<<"sec: "<<dmv*0.5<<"m/s"<<endl;
    ans+=(dmv+pdmv);
    pdmv=dmv;
    dtime++;
  }
  cout<<fixed<<setprecision(10)<<ans*0.125<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<char> > button(10);


int main(void){
  char c = 'a';
  button[1].push_back('.');
  button[1].push_back(',');
  button[1].push_back('!');
  button[1].push_back('?');
  button[1].push_back(' ');
  for(int i=2; i <= 9; i++){
    if(i == 7 || i == 9){
      for(int j=0; j < 4; j++){
	button[i].push_back(c);
	c++;
      }
    }else{
      for(int j=0; j < 3; j++){
	button[i].push_back(c);
	c++;
      }
    }
  }


  int n;
  string s;
  cin >> n;
  while(n--){
    cin >> s;
    int cnt=0;
    string mes;
    for(int i=0; i < s.length(); i++){
      if(s[i] == '0'){
	if(i == 0)      continue;
	if(s[i-1] == '0') continue;
	mes.append(1, button[s[i-1]-'0'][(cnt-1)%button[s[i-1]-'0'].size()]);
	cnt = 0;
      }else{
	cnt++;
      }
    }
    cout << mes << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
n = int(input())
l = list(map(int, input().split()))#複数の数字を入力して，リストにしまう
i = 0
min = 10000000
max = -10000000
sum = 0
while i<n:
    if l[i] <= min: min = l[i]
    if l[i] >= max: max = l[i]
    sum = sum + l[i]
    i +=1
print("{0} {1} {2}".format(min, max, sum))
        


Measured memory_bytes: 6600
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
static const int SIZE = 1000003;

int h1(int x){
  return x % SIZE;
}

int h2(int x){
  return 1 + (x % (SIZE-1));
}

int h(int x, int i){
  return (h1(x) + i*h2(x)) % SIZE;
}

void insert(int *T, int str){
  int key, i=0;
  while(1){
    key = h(str, i);
    if(T[key] == 0){
      T[key] = str;
      break;
    }
    i++;
  }
  return;
}

void find(int *T, int str){
  int key, i=0;
  while(1){
    key = h(str, i);
    if(T[key] == 0 || i >= SIZE){
      cout << "no" << endl;
      return;
    }else if(T[key] == str){
      cout << "yes" << endl;
      return;
    }
    i++;
  }
}

int conversion(string str){
  int base, a=0;
  for(int i=0; i<str.size(); i++){
    if(str[i] == 'A') base = 1;
    else if(str[i] == 'C') base = 2;
    else if(str[i] == 'G') base = 3;
    else if(str[i] == 'T') base = 4;
    a += base*pow(5, i);
  }
  return a;
}

int main(){
  int n, T[SIZE], key;
  for(int i=0; i<SIZE; i++) T[i] = 0;

  cin >> n;
  for(int i=0; i<n; i++){
    string command, str;
    cin >> command >> str;
    key = conversion(str);

    if(command[0] == 'i') insert(T, key);
    if(command[0] == 'f') find(T, key);
  }
  return 0;
}



Measured memory_bytes: 7240
import itertools


n, m = map(int, (input().split()))

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

# 8 pattern

max_of_sum = 0
for pick in range(8):
    sum_scores = []
    for score in scores:
        sum_of_score = 0
        if pick & 0b001 == 0:
            # plus
            sum_of_score += score[0]
        else:
            sum_of_score -= score[0]

        if pick & 0b010 == 0:
            # plus
            sum_of_score += score[1]
        else:
            sum_of_score -= score[1]

        if pick & 0b100 == 0:
            # plus
            sum_of_score += score[2]
        else:
            sum_of_score -= score[2]

        sum_scores.append(sum_of_score)

    sum_scores.sort(reverse=True)
    current_sum = sum(sum_scores[:m])
    if current_sum > max_of_sum:
        max_of_sum = current_sum

print(max_of_sum)



Measured memory_bytes: 3380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi acos(-1)
double eps=1e-8;
main(){
    double a,b;int h,m;
    cin>>a>>b>>h>>m;
    int hour=h%12,minute=m;
    hour=double(hour),minute=double(minute);
    double angle=fabs(hour*30.0+minute/2.0-minute*6.0)*pi/double(180);
    //if(angle<eps) puts("0.0000000000000000");
    printf("%.20f",sqrt(a*a+b*b-2.0*a*b*cos(angle)));
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int n, k;
ll ans;
ll l[maxn], r[maxn], sum[maxn];
int a[maxn];
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &a[i]);
		sum[i] = sum[i - 1] + a[i];
	}
	for(int i = 1; i <= n; ++i) l[i] = l[i - 1] + max(a[i], 0); 
	for(int i = n; i; --i) r[i] = r[i + 1] + max(a[i], 0);
	for(int i = k; i <= n; ++i) ans = max(ans, r[i + 1] + l[i - k] + max(sum[i] - sum[i - k], 0ll));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
#include <cmath>
using namespace std;

typedef string::const_iterator iter;

double expr(iter &it);
double term(iter &it);
int number(iter &it);

int N;
double expr(iter &it) {
    double r = term(it);
    while(*it == '+') {
        it++; // skip +
        r += term(it);
    }
    return r;
}

double term(iter &it) {
    it++; // skip n
    it++; // skip ^
    int k = number(it);
    return pow<double>(N, k);
}

int number(iter &it) {
    int r = *it - '0';
    it++;
    return r;
}

int main(void) {
    int T;
    cin >> N >> T;
    string s; cin >> s;
    iter it = s.begin();
    double r = expr(it);
    if(T*r > 1e9) {
        cout << "TLE" << endl;
    } else {
        cout << (int)(T * r) << endl;
    }
}

Measured memory_bytes: 1244
//2020-08-20, Thu

#include<iostream>
using namespace std;

int main(){
    int n, sum = 0, m;
    cin >> n;
    int t[n - 1];
    for (int i = 0; i < n; i++){
        cin >> t[i];
        sum += t[i];
    }
    
    cin >> m;
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        cout << (sum - (t[x - 1] - y)) << endl;
    }

    return 0;
}

Measured memory_bytes: 3572