akhauriyash/Code-Regression huggingface dataset:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, M = MAP()
H = LIST()
lights = [0] * N
for _ in range(M):
    a, b = MAP()
    a -= 1; b -= 1
    if lights[a] == 0:
        if H[a] <= H[b]:
            lights[a] += 1
    if lights[b] == 0:
        if H[b] <= H[a]:
            lights[b] += 1

print(lights.count(0))

# ans = 0
# for i in range(N):
#     flag = True
#     j = 0
#     while flag or j < len(AB):
#         a, b = AB[j][0], AB[j][1]
#         if a == i and H[a] <= H[b]:
#             flag = False
#             break

#         j += 1
#         if j == len(AB):
#             break

#     if flag:
#         ans += 1
# import deque





# print(ans)

 

Measured memory_bytes: 84912
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, s;
	for(;;){
		scanf("%d %d", &n, &s);
		if(n == 0 && s == 0) break;
		int ans = 0;
		for(int i = 0; i < (1 << 10); i++){
			int num_1 = 0;
			int sum = 0;
			for(int j = 0; j < 10; j++){
				if(1 << j & i){
					sum += j;
					num_1++;
				}
			}
			if(num_1 == n && sum == s) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>

int main() {

    ll N, K;
    cin >> N >> K;

    static ll mod = 1e9+7;

    ll sum = 0;
    ll sum_a = 0;
    ll sum_b = 0;
    for (int k = 0; k <= N; ++k) {
        sum_a += (N-k);
        sum_b += k;
        if (k+1 >= K) {
            sum += (sum_a - sum_b + 1);
            sum %= mod;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3648
import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static int aa = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, List<Point>> map = new HashMap<>();

        for (int i = 0; i<n; i++) {
            String s = sc.next();
            Integer p = sc.nextInt();
            Point po = new Point(p, i+1);
            List<Point> list = map.getOrDefault(s, new ArrayList<>());
            list.add(po);
            map.put(s, list);
        }

        List<String> keys = map.keySet().stream().sorted().collect(Collectors.toList());

        for (String k : keys) {
            List<Point> l = map.get(k);
            l.sort((e1, e2) -> e2.x - e1.x);
            for (Point a : l)
                System.out.println(a.y);
        }

    }
}

Measured memory_bytes: 29652
def sentou(NT, ts):
    N, T = map(int, NT.split())
    before_oshitano = None
    total_s = 0
    for t in map(int, ts.split()):
        if before_oshitano is None:
            before_oshitano = t
            continue
        elif T > (t - before_oshitano):
            total_s += t - before_oshitano
        else:
            total_s += T
        before_oshitano = t
    total_s += T

    print(total_s)


# sentou("9 10", "0 3 5 7 100 110 200 300 311")
sentou(input(), input())


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<pair<int, int>> p(m);

  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  //  rep(i, m) cin >> p[i].second >> p[i].first;
  rep(i, m) {
    int b, c;
    cin >> b >> c;
    p[i] = {c, b};
  }
  sort(p.rbegin(), p.rend());

  ll i = 0;
  ll j = 0;

  while (a[i] < p[j].first && i < n && j < m) {
    a[i] = p[j].first;
    i++;
    if (p[j].second > 1)
      p[j].second--;
    else
      j++;
  }

  // int l = 0;
  // for (auto pp : p) {
  //   int cnt = pp.second;
  //   while (cnt-- && a[l] < pp.first && l < n) {
  //     a[l++] = pp.first;
  //   }
  // }

  ll ans = 0;

  rep(i, n) ans += 1LL * a[i];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X, Y;
  cin >> X >> Y;
  
  if (2*X > Y || 4*X < Y || Y % 2 == 1) {
    cout << "No" << endl;
  }
  
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            string s = Console.ReadLine();
            long k = ReadAndParseLong();
            // 1がどこまで続いているか？
            int len = 0;
            for(int i=0;i<s.Length;++i)
            {
                if(s[i] != '1')
                {
                    break;
                }
                else
                {
                    len++;
                }
            }

            if( k <= len)
            {
                Console.WriteLine('1');
            }
            else
            {
                Console.WriteLine(s[len]);
            }
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int64_t *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%lld", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 300000
#define POWER_MAX 60

#define power2(bit) (1LL<<bit)
#define DIVISOR 1000000007

int main(void) {
    int num = get_int();
    static int64_t arr[NUM_MAX];
    static int cum[NUM_MAX+1][POWER_MAX+1];
    fget_array(arr, num);

    int i, bit;
    for(i = num-1; i >= 0; i--) {
        for(bit = 0; bit <= POWER_MAX; bit++) {
            if(!(arr[i] & power2(bit))) continue;
            cum[i][bit]++;
        }
        // cumulative
        for(bit = 0; bit <= POWER_MAX; bit++) {
            cum[i][bit] += cum[i+1][bit];
        }
#ifdef DEBUG
        for(bit = 0; bit <= POWER_MAX; bit++) {
            printf(" %d", cum[i][bit]);
        }
        putchar('\n');
#endif
    }

    static int64_t bit_sum[POWER_MAX+1];
    for(i = 0; i < num-1; i++) {
        for(bit = 0; bit <= POWER_MAX; bit++) {
            if(!(arr[i] & power2(bit))) {
                bit_sum[bit] += cum[i+1][bit];
            } else {
                bit_sum[bit] += ((num-i-1) - cum[i+1][bit]);
            }
            bit_sum[bit] = bit_sum[bit]%DIVISOR;
        }
    }
    int64_t ans = 0;
    int64_t power2 = 1;
    for(i = 0; i <= POWER_MAX; i++) {
        ans = (ans + power2 * bit_sum[i])%DIVISOR;
        power2 = (power2 * 2) % DIVISOR;
    }
    printf("%d\n", (int)ans);
    return 0;
}

Measured memory_bytes: 73984
import math
N, K = map(int, input().split())
# A =[]
# D = []
H = [0 for i in range(N)]
for i in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        H[j-1] += 1
    # D.append(d)
    # A.append(a)

Ns = 0
for i in H:
    if i ==0:
        Ns+=1

# print(A,D)
# print(H)
print(Ns)

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

int main(){
  int n, s;
  cin >> n >> s;
  ll x[n], y[n];
  rep(i, n) cin >> x[i] >> y[i];
  ll ans = 4e18;
  rep(i,n){
    rep(j,n){
      rep(k,n){
        rep(l,n){
          ll xl = min(x[i],x[j]), xr = max(x[i],x[j]);
          ll yl = min(y[k],y[l]), yr = max(y[k],y[l]);
          int c = 0;
          rep(m, n){
            if(x[m] >= xl && x[m] <= xr && y[m] >= yl && y[m] <= yr) c++;
          }
          if(c >= s) ans = min(ans, (xr-xl)*(yr-yl));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
//ll power(int a, int b){
//    return (ll)(pow(a,b)+0.5);
//}

vector<int> gV(int n){
    vector<int> v(n);
    int input;
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}


void solve(){
    int N;
    cin>>N;
    if(N%1000==0)
        cout<<0<<endl;
    else{
        cout<<(N/1000+1)*1000-N<<endl;
    }
}


int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 3612
import math

a , b , x = map(int,input().split())
if  x <= a*a*b/2:
    h = 2*x / (b*a)
    theta = math.degrees(math.atan(h/b))
else:
    upper=(2*x / (a*a)) - b
    if b == upper:
        theta = 90
    else:
        theta = math.degrees(math.atan(a / (b - upper)))

print(90-theta)

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.HashMap;

class Main {
  public static void main(String[] args) {
    String line;
    Scanner sc = new Scanner(System.in);
    while(sc.hasNextLine()) {
      line = sc.nextLine();
      int n = Integer.parseInt(line);
      int[] not_prime = new int[1000000];
      for(int i=0;i<1000000;i++) {
        not_prime[i]=0;
      }
      int count_prime = 0;
      for(int i=2;i<=n;i++) {
        if(not_prime[i]==1) {
          continue;
        }
        count_prime++;
        for(int j=i+i;j<=n;j+=i) {
          not_prime[j]=1;
        } 
      }
      System.out.println(count_prime);
    }
  }
}

Measured memory_bytes: 82460
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t N, M, X;

void solve()
{
    std::cin >> N >> M >> X;
	std::vector<int64_t> C(N);
	boost::multi_array<int64_t, 2> A(boost::extents[N][M]);

	for (int64_t i = 0; i < N; i++)
	{
		std::cin >> C[i];
		for (int64_t j = 0; j < M; j++)
		{
			std::cin >> A[i][j];
		}
	}

	int64_t ans = INT64_MAX;
	for (int64_t bit = 0; bit < (1 << N); bit++)
	{
		std::vector<int64_t> rikai(N);
		int64_t cost = 0;
		for (int64_t i = 0; i < N; i++)
		{
			if (bit & (1 << i)){
				cost += C[i];
				for (int64_t j = 0; j < M; j++)
				{
					rikai[j] += A[i][j];
				}
			}
		}
		bool ok = true;
		for (int64_t j = 0; j < M; j++)
		{
			if (rikai[j] < X) ok = false;
		}
		if (ok)
		{
			ans = std::min(ans, cost);
		}
	}

	if (ans == INT64_MAX) ans = -1;
	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int A[3];

int main(){
	
	cin>>A[0]>>A[1]>>A[2];
	
	sort( A, A+3 );
	
	if( A[0]+A[1] == A[2] ) puts("Yes");
	else{			    puts("No");}
	
	return 0;

}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define vii vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main()
{   fastio;

    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    sort(arr , arr+n);
    int cnt = 0;
    for(int i=0; i<n-2; i++)
    {
        for(int j=i+1; j<n-1; j++)
        {
            for(int k=j+1; k<n; k++)
            {
                if(arr[i]+arr[j]>arr[k] && arr[k]+arr[j]>arr[i] && arr[i]+arr[k]>arr[j] && arr[i] != arr[j] && arr[j] != arr[k] && arr[i] != arr[k]) cnt++;
            }
        }
    }
    cout<<cnt<<"\n";

}

Measured memory_bytes: 3652
def main():
    import numpy as np
    def bfs(S,s,h,w):
        dist = np.ones((h,w))*-1
        dist[s[0],s[1]]=0
        que = [s]
        while len(que)>0:
            v = que.pop(0)
            if v[0]+1<h:
                if S[v[0]+1][v[1]]=='.' and dist[v[0]+1][v[1]] == -1:
                    dist[v[0]+1][v[1]]=dist[v[0]][v[1]]+1
                    que.append([v[0]+1,v[1]])
            if v[0]-1>-1:
                if S[v[0]-1][v[1]]=='.' and dist[v[0]-1][v[1]]==-1:
                    dist[v[0]-1][v[1]]=dist[v[0]][v[1]]+1
                    que.append([v[0]-1,v[1]])
            if v[1]+1<w:
                if S[v[0]][v[1]+1]=='.' and dist[v[0]][v[1]+1]==-1:
                    dist[v[0]][v[1]+1]=dist[v[0]][v[1]]+1
                    que.append([v[0],v[1]+1])
            if v[1]-1>-1:
                if S[v[0]][v[1]-1]=='.' and dist[v[0]][v[1]-1]==-1:
                    dist[v[0]][v[1]-1]=dist[v[0]][v[1]]+1
                    que.append([v[0],v[1]-1])
        return np.max(dist)

    h,w = map(int,input().split())
    S = []
    for i in range(h):
        S.append(input())
    m = 0
    spot = []
    for i in range(h):
        for j in range(w):
            spot.append([i,j])
    for i in range(len(spot)):
        s = spot[i]
        if S[s[0]][s[1]]=='#':
            continue
        d = bfs(S,s,h,w)
        if m<d:
            m = d
    print(int(m))


if __name__ == "__main__":
    main()

Measured memory_bytes: 12500
<?php
  fscanf(STDIN, "%d %d", $a, $b);    
if($a > $b){
  for($a; $a>0; $a--){
    echo($b);
  }
}else if($b > $a){
  for($b; $b>0; $b--){
    echo($a);
  }
}else{
  for($a; $a>0; $a--){
    echo($b);
  }
}
?>

Measured memory_bytes: 4732
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>

using namespace std;

inline long long read()
{
    char c;long long out=0,f=1;
    for (c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
    if (c=='-'){f=-1;c=getchar();}
    for (;c>='0'&&c<='9';c=getchar()){out=(out<<3)+(out<<1)+c-'0';}
    return out*f;
}
void write(long long x)
{
	if (x<0){putchar('-');write(-x);return;}
    if (x>9){write(x/10);}
	putchar(x%10+'0');
}

int n,k,a[100010],ans=0x7fffffff;

int main()
{
	int i;
	
	n=read();
	k=read();
	
	for (i=1;i<=n;++i)
	{
		a[i]=read();
	}
	
	sort (a+1,a+n+1);
	
	for (i=1;i+k-1<=n;++i)
	{
		ans=min(ans,a[i+k-1]-a[i]);
	}
	
	cout<<ans;
	
	return 0;
}

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


ll solve(const vector<int>& X, const vector<int>& Y, const vector<int>& Z) {
    ll res = 0;
    for (int i=0; i<X.size(); i++) {
        auto yIter = upper_bound(Y.begin(), Y.end(), X[i]);
        while (yIter != Y.end()) {
            auto zIter = upper_bound(Z.begin(), Z.end(), *yIter);
            while(zIter != Z.end()) {
                if (X[i] + *zIter !=  2*(*yIter)) res++;
                zIter++;
            }
            yIter++;
        }
    }
    return res;
}


int main() 
{
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> R(0);
    vector<int> G(0);
    vector<int> B(0);

    rep(i,n) {
        char ch = s[i];
        if (ch == 'R') R.push_back(i);
        if (ch == 'G') G.push_back(i);
        if (ch == 'B') B.push_back(i);
    }

    ll ans = 0;
    ans += solve(R, G, B);
    ans += solve(R, B, G);
    ans += solve(G, R, B);
    ans += solve(G, B, R);
    ans += solve(B, R, G);
    ans += solve(B, G, R);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3628
N,M=map(int,input().split())
A=list(map(int,input().split()))

weight=[0,2,5,5,4,5,6,3,7,6]
dp = [-1] * (N+1)
dp[0] = 0
for i in range(N+1):
  for a in A:
    if i+weight[a] < N+1:
      dp[i+weight[a]] = max(dp[i+weight[a]], dp[i]*10+a)
print(dp[N])      

Measured memory_bytes: 14692
#include <iostream>
#define ll long long 
using namespace std;


ll bmm(ll a, ll b) {
    if (b > a) {
        ll t = b;
        b = a;
        a = t;
    }
    while(b!=0) {
        ll t = b;
        b = a%b;
        a = t;

    }
    return a;

}

ll kmm (ll a, ll b) {
    return a*b /bmm(a, b);

}

ll f (ll c,ll d, ll b ) {
    return b - ( b / c + b /d - b /kmm(c, d) );

}

int main() {
    ll a, b, c, d;
    cin >> a>> b>>c>>d;
    cout << f(c, d ,b) - f(c, d, a-1);
    //cout << bmm(33 , 15)<< endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a = 1, b = 1;
    for(int a = 1; a <= 9; a++){
        for(int b = 1; b <= 9; b++){
            cout << a << "x" << b << "=" << a*b << endl;
        }
        b = 1;
    }
    return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long N, std::vector<std::string> S) {
  vector<int> left, right;
  vector<pair<int, int>> t1;
  vector<pair<int, int>> t2;
  int left_buf = 0, right_buf = 0;
  rep(i, N) {
    int cnt1 = 0;
    int ma_cnt1 = 0;
    rrep(j, S[i].size()) {
      if (S[i][j] == '(')
        cnt1++;
      else
        cnt1--;
      chmax(ma_cnt1, cnt1);
    }
    int cnt2 = 0;
    int ma_cnt2 = 0;
    rep(j, S[i].size()) {
      if (S[i][j] == ')')
        cnt2++;
      else
        cnt2--;
      chmax(ma_cnt2, cnt2);
    }
    if (ma_cnt1 == 0 && ma_cnt2 == 0) {
    } else if (ma_cnt2 == 0) {
      left.push_back(i);
      left_buf += ma_cnt1;
    } else if (ma_cnt1 == 0) {
      right.push_back(i);
      right_buf += ma_cnt2;
    } else {
      if (ma_cnt2 > ma_cnt1)
        t1.push_back({ma_cnt2, ma_cnt1});
      else if (ma_cnt2 <= ma_cnt1)
        t2.push_back({ma_cnt2, ma_cnt1});
    }
  }
  // cerr << left_buf << " " << right_buf << endl;
  // t2は左につけるのが最適
  sort(t2.begin(), t2.end(), [](auto l, auto r) {
    if (l.first == r.first)
      return l.second > r.second;
    return l.first < r.first;
  });

  sort(t1.begin(), t1.end(), [](auto l, auto r) {
    if (l.second == r.second)
      return l.first > r.first;
    return l.second < r.second;
  });

  rep(i, t2.size()) {
    auto [l, r] = t2[i];
    if (left_buf < l) {
      cout << "No" << endl;
      return;
    }
    left_buf = left_buf - l + r;
  }
  rep(i, t1.size()) {
    auto [l, r] = t1[i];
    if (right_buf < r) {
      cout << "No" << endl;
      return;
    }
    right_buf = right_buf - r + l;
  }
  if (left_buf != right_buf) {
    cout << "No" << endl;
    return;
  }
  cout << "Yes" << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  std::vector<std::string> S(N);
  for (int i = 0; i < N; i++) {
    std::cin >> S[i];
  }
  solve(N, std::move(S));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 42656
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 500010

using namespace std;

int n;
int v[N];

int main()
{
	cin >> n;
	
	for(int i=1; i <= n; i++)
		cin >> v[i];
	
	sort(v+1, v+n+1);
	
	int ans=  0;
	
	for(int i=2; i <= n; i++)
		ans += v[i]-v[i-1];
	
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int vis[605][605];
int n,d1,d2;
inline void deal(int d)
{
    int gs=0,i,j;
    while((d&3)==0)++gs,d>>=2;
    if(d&1)
    {
        for(i=0;i<n;++i)for(j=0;j<n;++j)
            if(((i>>gs)+(j>>gs))&1)vis[i][j]=1;
    }
    else
    {
        for(i=0;i<n;++i)for(j=0;j<n;++j)
            if((i>>gs)&1)vis[i][j]=1;
    }
}
int main()
{
    n=read(),d1=read(),d2=read();
    reg int i,j,need=n*n,gs=0;
    n<<=1;deal(d1);deal(d2);
    for(i=0;i<n;++i)for(j=0;j<n;++j)
    {
        if(!vis[i][j])printf("%d %d\n",i,j),++gs;
        if(gs==need)return 0;
    }
	return 0;
}


Measured memory_bytes: 2304
from collections import Counter
from itertools import combinations
n = int(input())
s = []
for _ in range(n):
  t = input()[0]
  if t in {"M","A","R","C","H"}:
    s.append(t)

count = Counter(s)
if len(count) < 3:
  print(0)
  exit()

nums = []
for i in count.values():nums.append(i)

ans = 0
for i in combinations(nums, 3):
  ans += i[0]*i[1]*i[2]
print(ans)

Measured memory_bytes: 10080
#移動の最小値(高速化問題)
x,k,d = map(int,input().split())
x = abs(x)
if (x//d) > k:
    ans = x - d*k
elif (k-(x//d))%2 == 0:
    y = x-(x//d)*d
    ans = y
else:
    y = x-(x//d)*d
    ans = y-d
print(abs(ans))

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

int dfs(int s, vector<int>adj[], int dp[]){
	if(dp[s] != 0)
		return dp[s];
	for(auto itr: adj[s]){
		dp[s] = max(dp[s], 1+ dfs(itr, adj, dp));
	}
	return dp[s];
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("ip.txt", "r", stdin);
    freopen("op.txt", "w", stdout);
#endif
	int n, m, x, y;
	cin >> n >> m;
	vector<int> adj[n +1];
	for(int i = 0; i < m; ++i){
		cin >> x >> y;
		adj[x].push_back(y);
	}
	int dp[n +1] = {0};
	bool visited[n +1] = {0};

	for(int i = 1; i <= n; ++i){
		dfs(i, adj, dp);
	}
	int res = 1;
	for(int i = 1; i <= n; ++i){
		res = max(res, dp[i]);
	}	
	cout << res << endl;


}

Measured memory_bytes: 11456
import java.io.*;
import java.math.*;
import java.util.*;


public class Main	 {
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	long n = sc.nextLong();
        	long k = sc.nextLong();
        	System.out.println(n*k);
    }
}


Measured memory_bytes: 35744
N = int(input())
a = list(map(int, input().split()))

avg = sum(a)/N

ans = 0
tmpmin = abs(a[0]-avg)
for i in range(1, N):
    if abs(a[i]-avg) < tmpmin:
        tmpmin = abs(a[i]-avg)
        ans = i

print(ans)


Measured memory_bytes: 3060
N,M = map(int,input().split())
H = list(map(int,input().split()))
H.insert(0,0)
S = set()

for m in range(M):
  A,B = map(int,input().split())
  if H[A]<=H[B]:
    S.add(A)
  if H[A]>=H[B]:
    S.add(B)

print(N-len(S))

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    print(max({a + b, a - b, a * b}));

    return 0;
}


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

int main()
{
	int n; cin >> n;
	int f[max];
	f[0] = 1;
	f[1] = 1;
	for (int i = 2; i <= n; i++) f[i] = f[i - 1] + f[i - 2];

	cout << f[n] << endl;
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res = 0;

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    vector<int> data(1000005, 0);
    sort(A.begin(), A.end());
    for (int x : A)
    {
        if (data[x] != 0)
        {
            data[x] = 2;
            continue;
        }
        for (int i = x; i < 1000005; i += x)
        {
            data[i]++;
        }
    }
    res = 0;
    for (int x : A)
    {
        if (data[x] == 1)
        {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 7944
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
string s;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>s;
    int ans=0;
    for (int i = 0; i < n-2; i++)
    {
        if(s[i]=='A'){
            if(s[i+1]=='B'&&s[i+2]=='C'){
                ans++;
                i+=2;
            }
        }
    }
    cout << ans << "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int a[3][3];
int d[3][3];
int main() {
   rep(i, 3) rep(j, 3) cin >> a[i][j];
   int n;
   cin >> n;
   rep(i, n) {
      int b;
      cin >> b;
      rep(j, 3) rep(k, 3) {
         if (a[j][k] == b)
            d[j][k] = 1;
      }
   }
   bool isok = false;
   rep(i, 3) {
      if (d[i][0] && d[i][1] && d[i][2])
         isok = true;
   }
   rep(i, 3) {
      if (d[0][i] && d[1][i] && d[2][i])
         isok = true;
   }
   if (d[0][0] && d[1][1] && d[2][2])
      isok = true;
   if (d[0][2] && d[1][1] && d[2][0])
      isok = true;
   if (isok)
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  ll n;
  cin >> n;
  vl v(n);
  for (int i=0; i<n; i++){
    cin >> v[i];
    v[i] -= i+1;
  }
  sort(rng(v));
  ll ans=0;
  ll ans1=0;
  ll ans2=0;
  if(n%2==1){
    for (int i=0; i<n; i++){
      ans += abs(v[i]-v[n/2]);
    }
  }
  else {
    for (int i=0; i<n; i++){
      ans1 += abs(v[i]-v[n/2]);
      ans2 += abs(v[i]-v[n/2-1]);
    }
    ans = min(ans1, ans2);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static llong MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

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

    map<pair<int, int>, int> M;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            M[{X[i] - X[j], Y[i] - Y[j]}]++;
        }
    }

    int max_cnt = 0;
    stl_rep(itr, M) {
        max_cnt = max(max_cnt, itr->second);
    }

    cout << n - max_cnt << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
   int s1[5], s2[5];

   while(true){
       for(int i = 0; i < 5; i++){
           cin >> s1[i] >> s2[i];
           if(s1[0] == 0 && s2[0] == 0) return 0;
       }

       int sum[5];
       int max = 0; 
       char n[5] = {'A', 'B', 'C', 'D', 'E'};
       int p;

       for(int i = 0; i < 5; i++){
           sum[i] = s1[i] + s2[i];
           if(sum[i] > max){
               max = sum[i];
               p = i;
           }
       }
       cout << n[p] << " " << max << endl;
   }
}


Measured memory_bytes: 3072
#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 _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

int main() {
    int n,k;
    cin>>n>>k;
    ll a[n+1];
    rep(i,n){
        cin>>a[i+1];
    }
    ll dp[n+1][k+1];
    //dp[i][j]でi人目までで飴をj個配る場合の数
    memset(dp,0,sizeof(dp));
    for (int i=0;i<a[1]+1;i++){
        dp[1][i]=1;
    }
    for (int i=2;i<n+1;i++){
        vll v1;
        ll now=0;
        for (int j=0;j<k+1;j++){
            now+=dp[i-1][j];
            now%=MOD;
            v1.push_back(now);
        }
        for (int j=0;j<k+1;j++){
            if (j-a[i]<=0){
                dp[i][j]=v1[j];
            }
            else{
                dp[i][j]=v1[j]-v1[j-a[i]-1]+MOD;
                dp[i][j]%=MOD;
            }
        }
    }
    cout<<dp[n][k]<<endl;
    

    return 0;
}

Measured memory_bytes: 81016
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const int INF = 1 << 27;

int main(){
    while(true){
        int N,M;
        cin >> N >> M;
        if(N == 0 and M == 0) break;
        vector<vector<vector<int> > > dist(2,vector<vector<int> >(N,vector<int>(N,INF)));
        for(int i=0;i<M;i++){
            int x,y,t;
            char sl;
            cin >> x >> y >> t >> sl;
            x--;y--;
            int isl = (sl=='L')?0:1;
            dist[isl][x][y] = min(dist[isl][x][y],t);
            dist[isl][y][x] = min(dist[isl][y][x],t);
        }
        for(int i=0;i<N;i++){
            dist[0][i][i] = dist[1][i][i] = 0;
        }
        for(int k=0;k<N;k++){
            for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                    dist[0][i][j] = min(dist[0][i][j],dist[0][i][k]+dist[0][k][j]);
                    dist[1][i][j] = min(dist[1][i][j],dist[1][i][k]+dist[1][k][j]);
                }
            }
        }
        int R;
        cin >> R;
        vector<int> togo(R);
        for(int i=0;i<R;i++){
            cin >> togo[i];
            togo[i]--;
        }
        vector<vector<int> > dp(R,vector<int>(N,INF));
        dp[0][togo[0]] = 0;
        for(int i=0;i<R-1;i++){
            for(int j=0;j<N;j++){
                if(dp[i][j] == INF) continue;
                for(int k=0;k<N;k++){
                    dp[i+1][k] = min(dp[i+1][k],dp[i][j] + 
                            dist[0][togo[i]][j] +
                            dist[1][j][k] +
                            dist[0][k][togo[i+1]]);
                }
                dp[i+1][j] = min(dp[i+1][j],
                        dp[i][j]+dist[0][togo[i]][togo[i+1]]);
            }
        }
        int ret = INF;
        for(int i=0;i<N;i++){
            ret = min(ret,dp[R-1][i]);
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 2324
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll 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;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	string s;
	cin >> s ;
	string p = "";
	cout << s[0] << s[1] << s[2] << endl;
}
int main() {
	solve();
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(void)
{
	int a,b,sum;
	int i;
	
	while(scanf("%d %d",&a,&b)!=EOF){
		sum=a+b;

		i=0;
		while(sum>0){
			sum=sum/10;
			i++;
		}
		printf("%d\n",i);
	}
	return 0;
}

		

Measured memory_bytes: 1028
def c_colon():
    import math
    A, B, H, M = [int(i) for i in input().split()]

    choshin_degree = 6 * M
    tanshin_degree = 0.5 * (60 * H + M)

    degree = abs(choshin_degree - tanshin_degree)
    if degree > 180:
        degree = 360 - degree
    theta = math.radians(degree)
    return math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(theta))

print(c_colon())

Measured memory_bytes: 9576
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp

while true
  n = gets.to_i

  break if n == 0

  arr = n.times.map{ gets.to_i }

  puts (arr.reduce(:+) - arr.max - arr.min) / (n-2)
end

Measured memory_bytes: 8596
n,k = gets.chomp.split(" ").map{|i|i=i.to_i}
s = gets.chomp

now_muki = s[0]
count=0
saisho=0
(n-1).times{|i|
  if s[(i+1)]!=now_muki then
    count+=1
    now_muki=s[(i+1)]
  else
    saisho+=1
  end
}
#puts "saisho : #{saisho}\ncount : #{count}"
if count%2==0 then
  puts saisho + ([k,(count/2)].min*2)
elsif count%2==1 then
  if k < ((count/2)+1) then
    puts saisho + (2*k)
  else
    puts s.length-1
  end
end





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

using namespace std;

int main() {
    int N;
    cin >> N;
    long long int T, A;
    cin >> T >> A;
    long long int t=T, a=A;
    for(int n=1; n<N; n++) {
        cin >> T >> A;
        
        if(T>=t && A>=a) {
            t = T;
            a = A;
        } else {
            long long int tt, ta, at, aa;
            tt = t/T;
            if(t%T!=0) tt++;
            ta = tt;
            
            tt *= T;
            ta *= A;
            
            
            aa = a/A;
            if(a%A!=0) aa++;
            at = aa;
            
            aa *= A;
            at *= T;
            
            if(tt>=t && ta>=a) {
                if(at>=t && aa>=a) {
                    t = min(tt, at);
                    a = min(ta, aa);
                } else {
                    t = tt;
                    a = ta;
                }
            } else {
                t = at;
                a = aa;
            }
        }
    }

    cout << t+a << endl;

    return 0;
    
}

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

typedef struct Node{
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
} node;

node *root;
node *nil;

void insert(int k){
  node *a=root;
  node *b=nil;
  node *c;
  c=(node *)malloc(sizeof(node));
  c->key=k;
  c->left=nil;
  c->right=nil;
  while(a!=nil){
    b=a;
    if(c->key<a->key){
      a=a->left;
    }else{
      a=a->right;
    }
  }
  c->parent=b;
  if(b==nil){
    root=c;
  }else{
    if(c->key<b->key){
      b->left=c;
    }else{
      b->right=c;
    }
  }
}

void inorder(node *u){
  if(u==nil)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(node *u){
  if(u==nil)return;
  printf(" %d",u->key );
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char c[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",c);
    if(strcmp(c,"insert")==0){
      scanf("%d",&x);
        insert(x);
    }else if(strcmp(c,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n" );
    }
  }
  return 0;
}



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

using namespace std;

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

	int N = S.size();

	for (int i = 0; i < N / 2; i++) {
		if (S[i] != S[(N + 1) / 2 + i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


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

// C - Traveling Salesman around Lake
int main() {
    int K, N;
    cin >> K >> N;
    int A[N + 1];
    int maxA = 0;
    // int maxPoint = 0;
    long long sum =0;
    int before = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        /*if (A[i] - before > maxA) {
            maxA = A[i] - before;
            maxPoint = i;
        }*/
        maxA = max((A[i] - before), maxA);
        sum += A[i] - before;
        before = A[i];
    }
    A[N] = K;
    maxA = max((A[N] - before + A[0]), maxA);
    sum += A[N] - before;
        
    /*if (A[N] - before > maxA) {
        maxA = A[N] - before;
        maxPoint = i;
    }*/
    cout << sum - maxA;

}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int n, K; cin>>n>> K;
    int niz[n];
    for(int i=0; i<n; i++) cin>>niz[i];
    
    int df[K+1];
    df[0]=2;
    for(int i=1; i<K+1; i++)
    {bool t=false;
        for(int j=0; j<n; j++)
        {
            if(i>=niz[j] && df[i-niz[j]]==2)
            {t=true;
            break;}
        }
        if(t==true) df[i]=1;
        else df[i]=2;
    }

//for(int i=0; i<K+1; i++) cout<<df[i]<<" ";
if(df[K]==1) cout<< "First"<<endl;
else cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 640
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

def main():
    #a = int(input())
    #l = list(map(int, input().split()))
    n,k = map(int, input().split())

    x10 = n
    x2 = Base_10_to_n(x10, k)
    print(len(x2))




if __name__ == '__main__' :
    main()

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

int main()
{
    int count = 0;
    vector<int> num(3);
    for (int i = 0; i < 3;i++){
        cin >> num.at(i);
        if(num.at(i)==5){
            count++;
        }
        else if(num.at(i)==7){
            count = count + 2;
        }
    }
    if(count==4){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
d=[-1 for _ in range(n)]
for b in s:
  if d[b[0]-1]== -1:
    d[b[0]-1]=b[1]
  else:
    if d[b[0]-1]!=b[1]:
      print(-1)
      sys.exit()
if d[0]==-1 and n>1:
  d[0]=1
elif d[0]== -1 and n==1:
  d[0]=0
elif d[0]==0 and n>1:
  print(-1)
  sys.exit()
  
for i in range(n):
  if d[i] ==-1:
    d[i]=0
print("".join(map(str,d)))
    
  

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    while(cin >> N >> K) {
        vll A(N);
        rep(i, N)cin >> A[i];
        vll sm(N + 1), psm(N + 1);
        rep(i, N) {
            sm[i + 1] = A[i] + sm[i];
            psm[i + 1] = psm[i];
            if(A[i] > 0)psm[i + 1] += A[i];
        }
        ll ans = LLONG_MIN;
        for(int i = 0; i + K <= N; ++i) {
            ll x = sm[i + K] - sm[i];
            if(x < 0)x = 0;
            x += psm[N] - psm[i + K];
            x += psm[i] - psm[0];
            smax(ans, x);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2560
// 0157 最長増加部分列
#include <iostream>
#include <algorithm>
#include <map>

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

using namespace std;
bool compare_h(pair<int, int> a, pair<int, int> b){
	return a.first < b.first;
}
bool compare_r(pair<int, int> a, pair<int, int> b){
	return a.second < b.second;
}


int main(){
	int n, m;
	while(cin >> n && n){
		int dp[256];
		// h, r
		pair<int, int> dolls[256];
		rep(i, n){
			cin >> dolls[i].first >> dolls[i].second;
		}
		cin >> m;
		rep(i, m){
			cin >> dolls[i+n].first >> dolls[i+n].second;
		}


		// hについてソートしrの最長増加部分列を求める
		int hlis = 0;
		sort(dolls, dolls+n+m, compare_h);
		dp[0] = 1;
		for(int i = 1; i < n+m; i++){
			dp[i] = 1;
			for(int j = 0; j < i; j++){
				if(dolls[j].second < dolls[i].second && dolls[j].first != dolls[i].first){
					dp[i] = max(dp[i], dp[j] + 1);
				}
			}
			hlis = max(hlis, dp[i]);
		}					

		cout << hlis << endl;
	}

	return 0;
}

Measured memory_bytes: 1168