akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
ll pre[100010];
int n;
ll ans;
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(a, a+n);
	partial_sum(a, a+n, pre);
	if (n % 2)
	{
		ll am = 0;
		if (n != 3) am = -2*pre[n/2 - 2];
		am -= a[n/2-1];
		am -= a[n/2];
		am += 2*(pre[n-1] - pre[n/2]);
		ans = am;
		reverse(a, a+n);
		partial_sum(a, a+n, pre);
		am = 0;
		if (n != 3) am = 2*pre[n/2 - 2];
		am += a[n/2-1];
		am += a[n/2];
		am -= 2*(pre[n-1] - pre[n/2]);
		//printf("%lld\n", am);
		ans = max(ans, am);
	}
	else
	{
		ll am = -2*pre[n/2-2];
		am -= a[n/2-1];
		am += a[n/2];
		am += 2*(pre[n-1]-pre[n/2]);
		ans = max(ans, am);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1792
a,b = [ int(i) for i in  input().split(" ")]
if b<10:
    target = a*10+b
elif 10<= b < 100:
    target = a*100+b
else:
    target = a*1000+b
flag = 0
i = 0
while(i ** 2 <= 100100):
    if i**2 == target:
        print("Yes")
        flag=1
        break
    i+=1
        
if flag == 0:
    print("No")


Measured memory_bytes: 3060
// E - Picking Goods
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int r, c, n;
	cin >> r >> c >> n;
	vector<vector<long long>> a(r, vector<long long>(c));
	for (int k = 0; k < n; k++) {
		long long i, j, r;
		cin >> i >> j >> r;
		a[i - 1][j - 1] = r;
	}

	vector<vector<vector<long long>>> dp(r + 1, vector<vector<long long>>(c + 1, vector<long long>(4)));

	for (int i = 1; i <= r; i++)
		for (int j = 1; j <= c; j++) {
			long long x = 0;
			for (int k = 0; k <= 3; k++) x = max(x, dp[i - 1][j][k]);
			dp[i][j][0] = x;
			dp[i][j][1] = x + a[i - 1][j - 1];
			for (int k = 0; k <= 3; k++) {
				dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]);
				if (k > 0) dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + a[i - 1][j - 1]);
			}
		}
	long long ans = 0;
	for (int i = 0; i <= 3; i++)
		ans = max(ans, dp[r][c][i]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 706684
import math

a, b, x = [int(i) for i in input().split()]

if x*2 > a*a*b:
    rest = a*a*b - x
    #h = 2*rest / a*a
    #print(math.degrees(math.atan2(a, h)))
    print(90 - math.degrees(math.atan2(a*a*a, 2*rest)))
else:
    print(90 - math.degrees(math.atan2(2*x, a*b*b)))
    



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N,H,W;
    cin >> N >> H >> W;
    ll ans = 0;
    rep(i,N){
      ll A,B;
      cin >> A >> B;
      if(A >= H && B >= W) ans++;
    }
    print(ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int time;
    scanf("%d", &time);
    int hours = time / 3600;
    int minutes = (time % 3600) / 60;
    int seconds = (time % 3600) % 60;
    
    printf("%d:%d:%d\n", hours, minutes, seconds);
}


Measured memory_bytes: 2148
using System;
class Program {
	static void Main() {
		string s = Console.ReadLine();
		int n = int.Parse(Console.ReadLine());
		int ret = 0;
		for(int i = 0; i < n; i++) {
			string t = Console.ReadLine();
			t += t;
			for(int j = 0; j <= t.Length - s.Length; j++) {
				if(t.Substring(j, s.Length) == s) {
					ret++; break;
				}
			}
		}
		Console.WriteLine(ret);
	}
}

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

int main()
{
  int h, w;
  vector<int> cnt(30);
  cin >> h >> w;
  rep(i, h) rep(j, w) 
  {
    char c;
    cin >> c;
    cnt[c - 'a']++;
  }
  priority_queue<int> que;
  rep(i, 30)
  {
    if(cnt[i]) que.push(cnt[i]);
  }
  
  int hh = h - (h & 1), ww = w - (w & 1);
  int n1 = h & w & 1;
  int n2 = (((h & 1) * ww) + ((w & 1) * hh)) / 2;
  int n4 = (h * w - 2 * n2 - n1) / 4;
  
  
  
  rep(i, n4)
  {
    int a;
    a = que.top();
    que.pop();
    a -= 4;
    if(a < 0)
    {
      cout << "No" << endl;
      return 0;
    }
    if(a != 0) que.push(a);
  }
  
  rep(i, n2)
  {
    int a;
    a = que.top();
    que.pop();
    a -= 2;
    if(a < 0)
    {
      cout << "No" << endl;
      return 0;
    }
    if(a != 0) que.push(a);
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
k = []
a = []
for _ in range(n):
    words = input().split()
    k.append(int(words[0]))
    a.append(list(map(int, words[1:])))

like_cnt = {i: 0 for i in range(1, m + 1)}
for ai in a:
    for aij in ai:
        like_cnt[aij] += 1
print(list(like_cnt.values()).count(n))


Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll A, B, C;
  cin >> A >> B >> C;

  cout << ((A+B+C>21) ? "bust" : "win") << "\n";
  return 0;
}


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

int main() {
  ll N;
  std::cin >> N;
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) std::cin >> A[i];
  std::vector<ll> cumsum(N + 1);
  cumsum[0] = 0;
  for (int i = 0; i < N; i++) {
    cumsum[i + 1] = cumsum[i] + A[i];
  }
  std::unordered_map<ll, ll> counter;
  for (auto&& v : cumsum) {
    counter[v]++;
  }
  ll res{0};
  for (auto&& p : counter) {
    ll k {p.second};
    res += (k * (k - 1)) / 2;
  }
  std::cout << res << std::endl;
  return 0;
}

Measured memory_bytes: 11592
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>
#include <iomanip>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

inline double dot(const P &a, const P &b) {
	return (conj(a) * b).real();
}

int main() {
	for (double x, y; cin >> x >> y; ) {	
		vector<P> ps;
		ps.pb(P(x, y));
		rep(i, 3) {
			double x, y; cin >> x >> y;
			ps.pb(P(x, y));
		}
		if (dot(ps[0] - ps[1], ps[2] - ps[3]) == 0) cout << "YES" <<endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
     public static void main(String[] args){
             Scanner sc=new Scanner(System.in);
             int a=sc.nextInt();
             int b=sc.nextInt();
             int h=sc.nextInt();

             int area=(a+b)*h/2;

             System.out.println(area);
      }
}

Measured memory_bytes: 8916
#include <stdio.h>

#define TRAIN_STACK 10

// int[0] is array size
// int[1~] is data itself
// int[n] = 0 ; out of range

int pop ( int* array )
{
    if ( array[0] <= 0 )
    {
        return 0;
    }

    array[0] -= 1;
    return array[array[0] + 1];
}

int push ( int* array, int input )
{
    if ( array[0] >= TRAIN_STACK )
    {
        return 0;
    }

    array[0] += 1;
    array[array[0]] = input;

    return input;
}

int unshift ( int* array, int input )
{
    if ( array[0] >= TRAIN_STACK )
    {
        return 0;
    }

    int i;
    array[0] += 1;
    for ( i = array[0]; i > 1; i-- )
    {
        array[i] = array[i - 1];
    }
    array[1] = input;

    return input;
}

int shift ( int* array )
{
    if ( array[0] <= 0 )
    {
        return 0;
    }

    int i, retval = array[1];

    for ( i = 2; i <= array[0]; i++ )
    {
        array[i - 1] = array[i];
    }
    array[0] -= 1;

    return retval;
}

int main ( void )
{
    int stdinput, i;
    int instack[TRAIN_STACK + 1] = { 0 };
    int outstack[TRAIN_STACK + 1] = { 0 };

    while ( scanf( "%d", &stdinput ) != EOF )
    {
        if ( stdinput <= 0 )
        {
//            push( outstack, pop( instack ) );
           printf( "%d\n", pop( instack ) );
        }
        else
        {
            push( instack, stdinput );
        }
    }

    for ( i = 1; i <= outstack[0]; i++ )
    {
        if ( outstack[i] != 0 )
        {
            printf( "%d\n", outstack[i] );
        }
    }

    return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

void out(int a, int b) {
	cout <<"?"<<" "<< a+1 << " " << b+1 << endl;
	fflush(stdout);
}
int in(void) {
	int a; cin >> a;
	return a;
}

int main() {
	int N; cin >> N;
	if (N == 1) {
		cout << "!" << " " << 1 << endl;
		return 0;
	}
	vector< vector<int>>diss(N);
	for (int i = 0; i < N - 1; ++i) {
		out(0, i + 1);
		int dis = in();
		diss[dis].push_back(i + 1);
	}
	deque<int>ans(1, 0);
	ans.push_back(diss[1][0]);
	if (diss[1].size() == 2)ans.push_front(diss[1][1]);
	int pre_r = diss[1][0];
	for (int i = 2; i < diss.size(); ++i) {
		if (diss[i].empty())break;
		else {
			if (diss[i].size() == 1) {
				out(diss[i][0], pre_r);
				if (in() != 1)ans.push_front(diss[i][0]);
				else {
					ans.push_back(diss[i][0]);
					pre_r = diss[i][0];
				}
			}
			else {
				out(diss[i][0], pre_r);
				if (in() != 1) {
					ans.push_front(diss[i][0]);
					ans.push_back(diss[i][1]);
					pre_r = diss[i][1];
				}
				else {

					ans.push_front(diss[i][1]);
					ans.push_back(diss[i][0]);
					pre_r = diss[i][0];
				}
			}
		}
	}
	assert(ans.size() == N);
	auto it = ans.begin();
	cout << "!";
	for (int i = 0; i < ans.size(); ++i) {
		cout << " " << 1+(*it);
		it++;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>

using namespace std;

int main()
{
	int H, W;

	while (true)
	{
		cin >> H >> W;

		if (H == 0 && W == 0)
			break;

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (i == 0 || i == H - 1)
					cout << '#';
				else
				{
					if (j == 0 || j == W - 1)
						cout << '#';
					else
						cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3124
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();
		int C = sc.nextInt();
		int D = sc.nextInt();
		if ( (A+B) > (C+D) ) System.out.println("Left");
		else if ( (A+B) == (C+D) ) System.out.println("Balanced");
		else if ( (A+B) < (C+D) ) System.out.println("Right");
	}
}


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


int main(){
  int n,m;
  cin >> n >> m;
  int a[n];
  int g = 0;
  for (int i=0; i<n; i++){
    cin >> a[i];
    g += a[i];
  }
  int v = 0;
  float s = (float)g/(4*m);
  for (int i=0; i<n; i++){
    if(a[i]>=s){v++;}
  }
 
  if(v>=m){cout << "Yes" << endl;}
  else{cout << "No" << endl;}

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char u[1000],l[1000],r[1000],c;
  int a,b,d,m;
  while(scanf("%s",u),u[0]-'-'){
    a=b=d=0;
    scanf("%s %s",l,r);
    c=l[b++];
    m=strlen(l)+strlen(u);
    while(--m){
      if(c==r[d]){
	c=u[a++];
	d++;
      }
      else{
	printf("%c",c);
	c=l[b++];
      }
    }
    printf("%c\n",c);
  }
  return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);

int main() {
  int n,m,s[10],c[10];
  cin >> n >> m;
  for(int i = 0; i < m; i++)
    cin >> s[i] >> c[i];
  
  int st = pow(10, n-1);
  if(st == 1) st = 0;
  int end = pow(10, n);
  
  
  for(int i = st; i < end; i++) {
    bool flag = 1;
    string str = to_string(i);
    for(int j = 0; j < m; j++) {
      if(str[s[j]-1] != c[j]+'0') 
        flag = 0; 
    }
    if(flag) {
      cout << str << endl;
      return 0;
    }
  }
  cout << -1 << endl; 
}

Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,j,k;
  cin>>n>>k;
  int height[n];
  for(i=0;i<n;i++)
    cin>>height[i];
  vector<int> dp(n,INT_MAX);
 // memset(dp,INT_MAX,sizeof(dp));
  dp[0]=0;
  for(i=0;i<n;i++)
  {
      for(j=i+1;j<=i+k;j++)
      if(j<n)
       dp[j]=min(dp[j],dp[i]+abs(height[j]-height[i]));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int count = 0;
	int odd = 0;
	int keta = 0;
	for (int i = 1; i <= N; i++) {
		count = i;
		while (count != 0) {
			keta++;
			count = count / 10;
		}
		if (keta % 2 == 1) {
			odd++;
			keta = 0;
		}
		else {
			keta = 0;
		}
	}
	cout << odd << endl;
	return 0;
}

Measured memory_bytes: 256
w, h, n = map(int, input().split(" "))
area = [[0] * w for i in range(h)]

for i in range(n):
    x, y , a = map(int, input().split(" "))
    if a == 1:
        for j in range(x):
            for k in range(h):
                area[k][j] = 1
    elif a == 2:
        for j in range(x, w):
            for k in range(h):
                area[k][j] = 1
    elif a == 3:
        for j in range(w):
            for k in range(y):
                area[k][j] = 1
    elif a == 4:
        for j in range(w):
            for k in range(y, h):
                area[k][j] = 1
c = 0
for i in range(h):
    for j in range(w):
        if area[i][j] == 0:
            c += 1
print(c)

Measured memory_bytes: 9280
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import java.util.HashMap;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[][] A = new int[K][N];
        int[] d = new int[K];
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<K; i++){
            d[i] = sc.nextInt();
            for(int j=0; j<d[i]; j++){
                A[i][j] = sc.nextInt();
                if(!list.contains(A[i][j])){
                    list.add(A[i][j]);
                }
            }
        }
        System.out.println(N - list.size());
    }
}

Measured memory_bytes: 46232
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;
const std::string S = "IOTJLSZ";

std::map<char, ll> a;

int main()
{
  rep( i, S.size() )
  {
    ll b;
    std::cin >> b;

    a[S[i]] = b;
  }

  // T, S, Z 除外

  ll ans = a['O'], add = 0;

  rep( b, 2 )
  {
    ll aI = a['I']-b;
    ll aJ = a['J']-b;
    ll aL = a['L']-b;

    if( aI < 0 || aJ < 0 || aL < 0 )
      continue;
    
    chmax( add, b*3+aI/2*2+aJ/2*2+aL/2*2 );
  }

  ans += add;

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	double r;
	cin>>r;
	cout<< fixed << setprecision(10) << r*r*pi<<" " ;
	cout<< fixed << setprecision(10) <<r*2*pi<<endl;
	return 0;
}

Measured memory_bytes: 1288
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;

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

int main(void) {
	ll n, x; cin >> n >> x;
	
	
	long long ans = n;
	ll a, b;
	a = max(x, n - x), b = min(x, n - x);
	do {
		ans += b * (a / b) * 2;
		ll k = b, w = a % b;
		a = k, b = w;
		if (b == 0) ans -= a;
	} while (b != 0);
	cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = read.to!int;
	int m = read.to!int;
	
	X[] xs;
	foreach(i; 0 .. n){
		xs ~= X(read.to!int, read.to!long);
	}
	
	X[][int] xl;
	foreach(x; xs){
		if(x.a !in xl) xl[x.a] = [];
		xl[x.a] ~= x;
	}
	
	long ans;
	auto xh = new RedBlackTree!(X, "a.b>b.b", true);
	foreach(i; 0 .. m + 1){
		if(i !in xl) xl[i] = [];
		X[] xq = xl[i];
		foreach(x; xq) xh.insert(x);
		
		if(xh.length == 0) continue;
		X x = xh.front;
		xh.removeFront;
		ans += x.b;
	}

	ans.writeln;
	
	
}

struct X{
	int a;
	long b;
}


Measured memory_bytes: 21116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359

int main() {
    string a[] = {"Sunny", "Cloudy", "Rainy", "Sunny"};
    string s;
    cin >> s;
    for(int i=0;i<3;i++){
        if(s == a[i])cout << a[i+1] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> v(n, k - q);
    for (int i = 0; i < q; i++){
        int t;
        cin >> t;
        t--;
        v[t]++;
    }

    for (int i = 0; i < n; i++){
        if (v[i] <= 0)
            cout << "No\n";
        else
            cout << "Yes\n";
    }
    return 0;
}  


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[100000],a;
    int i,j;
    scanf("%s",s);
    for(a='a';a<='z';a++){
        i=0; j=0;
        while(s[i]!='\0'){
            if(a!=s[i])
                j++;
            i++;
        }
        if(j==strlen(s)){
            printf("%c\n",a);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}

Measured memory_bytes: 256
using System;

namespace Atcoder
{
    class Program
    //ABC126 C - Dice and Coin
    {
        private static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(' ');
            var n = double.Parse(nk[0]);
            var k = int.Parse(nk[1]);
            double ans = 0.0;
            for (var i = 1; i <= n; i++)
            {
                if (i >= k)
                {
                    ans += 1/n;
                }
                else
                {
                    var temp = i * 2;
                    var count = 1;
                    while (temp < k)
                    {
                        temp = temp * 2;
                        count++;
                    }
                    ans += (1 / n) * Math.Pow(0.5, count);
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main() {
  int W,H,N; cin >> W >> H >> N;
  int X,Y=0;
  rep(i, N) {
    int x,y,a;
    cin >> x >> y >> a;
    if (a==1) {
      X=max(X,x);
    } else if(a ==2) {
      W=min(W,x);
    } else if(a==3) {
      Y=max(Y,y);
    } else {
      H=min(H,y);
    }
  }
  dump(max(W-X,0)*max(H-Y,0));
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  ll A,B,C,K;
  cin >> A >> B >> C >> K;
  ll a = 0;
  ll b = 0;
  ll c = 0;

  if(A<K && K >0){
    a = A;
    K -= A;
  }else{
    a = K;
    cout << a << endl;
    return 0;
  }

  if(B<K && K >0){
    b = B;
    K -= B;
  }else{
    b = K;
    cout << a << endl;
    return 0;
  }

  if(C<K && K >0){
    c = C;
    K -= C;
  }else{
    c = K;
    cout << a+(-1)*c << endl;
    return 0;
  }





}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll n,m,si[N],p[N],ans[N];
struct node
{
    int x,y;
}a[N];
ll find(ll x)
{
    if(x!=p[x])p[x]=find(p[x]);
    return p[x];
}
void join(ll x,ll y)
{
    p[find(x)]=find(y);
}
ll get_sum(ll x)
{
    return x*(x-1)/2;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>a[i].x>>a[i].y;
    }
    for(int i=1;i<=n;i++)
    {
        p[i]=i;
        si[i]=1;
    }
    ll sum=0;
    ll rest=n*(n-1)/2;
    for(int i=m;i>=1;i--)
    {
        ans[i]=rest-sum;
        ll x=a[i].x;
        ll y=a[i].y;
        ll fx=find(x);
        ll fy=find(y);
        if(fx!=fy)
        {
            ll s1=get_sum(si[p[x]]);
            ll s2=get_sum(si[p[y]]);
            //printf("x=%lld y=%lld p[x]=%lld p[y]=%lld\n",x,y,p[x],p[y]);
            //printf("x块大小%lld y块大小%lld\n",si[p[x]],si[p[y]]);
            si[p[y]]+=si[p[x]];//x并到y上
            si[p[x]]=0;
            //printf("合并后的y块大小=%lld\n\n",si[p[y]]);
            ll s3=get_sum(si[p[y]]);
            join(x,y);
            ll tmp=s3-s1-s2;
            sum+=tmp;
            //printf("i=%d s1=%lld s2=%lld s3=%lld tmp=%lld sum=%lld\n",i,s1,s2,s3,tmp,sum);
        }
        //else sum++;
    }
    for(int i=1;i<=m;i++)
        printf("%lld\n",ans[i]);
    return 0;
}


Measured memory_bytes: 4480
n = int(input())
b = list(map(int, input().split()))

a = [0 for k in range(n)]
a[0] = b[0]
a[n-1] = b[n-2]

for i in range(1, n-1):
  a[i]=min(b[i], b[i-1])
  
ans = 0
for x in range(n):
  ans += a[x]

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

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

    string ans = "";
    REP(i, N) {
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)



int main()
{
	ios::sync_with_stdio(false);
	ll a,b,n,k;
	cin>>a>>b>>n;
	if(n>=b-1)
	{
		k=(a*(b-1))/b;
		cout<<k;
	}
	else
	{
		k=(a*n)/b;
		cout<<k;
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
#define len 100005

typedef struct pp {
  string name;
  int time;
} P;

int head, tail;
P que[len];

void enqueue(P x) {
  que[tail] = x;
  tail = (tail + 1) % len;
}

P dequeue() {
  P x = que[head];
  head = (head + 1) % len;
  return x;
}

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

  for (int i = 1; i <= n; i++) {
    cin >> que[i].name >> que[i].time;
  }

  head = 1;
  tail = n + 1;

  int now = 0;
  while (head != tail) {
    P u = dequeue();
    if (u.time - q > 0) {
      now += q;
      u.time = u.time - q;
      enqueue(u);
    } else {
      now += u.time;
      cout << u.name << " " << now << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 7136
N = int(input())

prime = [2]
for i in range(3, 55556):
    flag = 1
    for j in prime:
        if i % j == 0:
            flag = 0
            break
    if flag == 1:
        prime.append(i)

ans = []
for i in prime:
    if i % 5 == 1:
        ans.append(i)
print(" ".join(map(str, ans[:N])))


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
#define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m, a[N];
int f[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	while(m--) {
		int pos; cin >> pos;
		a[pos] = -1;
	}
	f[0] = 1;
	f[1] = (a[1] != -1)?1:0;
	for(int i=2; i<=n; i++){
		if (a[i] == -1) f[i] = 0;
		else f[i] = (f[i-1] + f[i-2]) % MOD;
	}
	int ans = f[n];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
while True:
    m, f, r = map(int, input().split())
    if (m, f, r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65 and m+f < 80:
        print("B")
    elif m+f >= 50 and m+f < 65:
        print("C")
    elif m+f >= 30 and m+f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;

ll n, k;
int main(){
	IOS;
	cin >> n >> k;
	cout << (n - 1) / (k - 1) + ((n - 1) % (k - 1) != 0); 
	
	
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d",&n);
  int i,a[n],b[n];
  for(i = 0;i < n;i++) {
    scanf("%d",&a[i]);
    b[a[i] - 1] = i + 1;
  }
  
  for(i =0;i < n;i++) printf("%d ",b[i]);
  
  return 0;
}


Measured memory_bytes: 1536
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = len(a) * len(b)
s = [0] * l
ans = [0] * (3000 * len(c))

i = 0
for A in a:
    for B in b:
        s[i] = A + B
        i += 1
s.sort(reverse=True)

i = 0
for S in s[:3000]:
    for C in c:
        ans[i] = C + S
        i += 1
ans.sort(reverse=True)

for i in ans[:k]:
    print(i)


Measured memory_bytes: 98844
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<long long int> H(N);
  vector<long long int> H_sub(N);
  for(int i = 0; i < N; i++) {
    cin >> H.at(i);
    H_sub.at(i) = H.at(i);
  }
  for(int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    if(H.at(A - 1) > H.at(B - 1)) {
      H_sub.at(B - 1) -= 1000000000;
    }
    else if(H.at(A - 1) < H.at(B - 1)) {
      H_sub.at(A - 1) -= 1000000000;
    }
    else {
      H_sub.at(A - 1) -= 1000000000;
      H_sub.at(B - 1) -= 1000000000;
    }
  }
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(H_sub.at(i) > 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

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

    vector<int> X(N);
    for (int i = 0; i < N; ++i)
        cin >> X[i];

    int ans = INT_MAX;
    for (int i = 0; i + K <= N; ++i) {
        int tmp = abs(X[i + K - 1] - X[i]) + min(abs(X[i]), abs(X[i + K - 1]));
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
/*************************************************************************
	> File Name: A.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Created Time: 2020/4/19 19:57:23
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
using namespace std;
const double pi=acos(-1.0);
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	double r;
	scanf("%lf",&r);
	printf("%lf\n",r*pi*2);
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> v{istream_iterator<int>(cin), istream_iterator<int>()};
  
  std::sort(v.begin(),v.end());
  rep(i,int(v.size())-1){
    if(int(v.at(i)) == v.at(i+1)){
      cout << "NO" <<endl;
      return 0;
    }
  }
  cout << "YES" <<endl;
  return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}
int dp[100100];
int dfs(whei(int)&G, int v){
	if (dp[v] != -1)return dp[v];
	int s = 0;
	for (auto x : G[v])s = max(s, dfs(G, x)+1);
	return dp[v] = s;
}

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	whei(int) dp(n+1,hei(int)(m+1,0));
	rep(i, 0, n) {
		rep(j, 0, m) {
			if (s[i] == t[j])dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			dp[i + 1][j + 1] = max({ dp[i + 1][j + 1], dp[1 + i][j],dp[i][j + 1] });
		}
	}
	string ans = "";
	while (n > 0 && m > 0) {
		if (dp[n][m] == dp[n - 1][m])n--;
		else {
			if (dp[n][m] == dp[n][m - 1])m--;
			else {
				ans += s[n-1];
				n--;
				m--;
			}
		}
	}
	reverse(ans);
	cout<<ans<< endl;
	return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll h, w, a, b;
const ll MOD = 1e9+7;
ll fact[200003];
ll invfact[200003];

ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

ll modinv(ll a){
    ll x,y;
    if (extgcd(a, MOD, x, y) == 1) return (x + MOD) % MOD;
    else                           return 0; // unsolvable
}

void setup(){
    fact[0] = 1;
    invfact[0] = 1;
    for(ll i=1;i<=200000;i++){
        fact[i] = i*fact[i-1]%MOD;
        invfact[i] = modinv(fact[i]);
    }
}

ll comb(ll x, ll y){
    return fact[x+y]*invfact[x]%MOD*invfact[y]%MOD;
}

int main() {
    setup();
    cin >> h >> w >> a >> b;
    ll ans = 0;
    for(ll i=b+1;i<=w;i++){
        ans += comb(h-a-1,i-1)*comb(a-1,w-i)%MOD;
        ans = ans%MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	cout << (char) toupper(s1[0])
	     << (char) toupper(s2[0])
	     << (char) toupper(s3[0])
	     << endl;
	return 0;
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    answer = []
    if N % 2 == 1:
        for i in range(1, N):
            answer.append((N, i))
        for j in range(1, N):
            for k in range(j + 1, N):
                if j + k == N:
                    continue
                else:
                    answer.append((j, k))
    else:
        for i in range(2, N):
            answer.append((N, i))
            answer.append((1, i))
        for j in range(2, N):
            for k in range(j + 1, N):
                if j + k == N + 1:
                    continue
                else:
                    answer.append((j, k))
    M = len(answer)
    print(M)
    for i in range(M):
        print(*answer[i], sep=" ")


if __name__ == "__main__":
    main()


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

int main() {
  int N;
  cin >> N;
  
  long long result = 0;
  long long result_tmp1 = 2;
  long long result_tmp2 = 1;
  
  if (N == 1)
    cout << result_tmp2 << endl;
  else {
    for (int i = 2; i <= N; i++) {
      result = result_tmp1 + result_tmp2;
      result_tmp1 = result_tmp2;
      result_tmp2 = result;
    }

    cout << result << endl;    
  }
}

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

using namespace std;

int main()
{
    int z;

    while (cin >> z, z) {
        int max_xy = 0;
        int z3 = z * z * z;

        for (int x = 1; x * x * x <= z3; ++x) {
            int x3 = x * x * x;
            for (int y = 1; y * y * y <= z3 - x3; ++y)
                max_xy = max(max_xy, x3 + y * y * y);
        }

        cout << z3 - max_xy << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
struct state{int x,y,d,dir;}st[5][11001];
char s[110001],t[110001];
int n,m,q,sl[110001][2],sr[110001][2],tl[110001][2],tr[110001][2],ex,ey,sx,sy,ans,cnt[5];
void go(int id,int x,int y,int d,bool ns)
{
	if(ns)
		if(t[y]=='S')
		{
			if(sr[x][0])st[id][cnt[id]++]={sr[x][0],y,d+sr[x][0]-x,ns};
			if(sr[x][1])st[id][cnt[id]++]={sr[x][1],y,d+sr[x][1]-x,ns};
			if(ex>x)
			{
				if(ey==y)ans=min(ans,d+ex-x);
				if(int z=sr[ex-1][ey>y])st[id][cnt[id]++]={z,y,d+z-x,ns};
			}
		}
		else
		{
			if(sl[x][0])st[id][cnt[id]++]={sl[x][0],y,d+x-sl[x][0],ns};
			if(sl[x][1])st[id][cnt[id]++]={sl[x][1],y,d+x-sl[x][1],ns};
			if(ex<x)
			{
				if(ey==y)ans=min(ans,d+x-ex);
				if(int z=sl[ex+1][ey>y])st[id][cnt[id]++]={z,y,d+x-z,ns};
			}
		}
	else if(s[x]=='E')
	{
		if(tr[y][0])st[id][cnt[id]++]={x,tr[y][0],d+tr[y][0]-y,ns};
		if(tr[y][1])st[id][cnt[id]++]={x,tr[y][1],d+tr[y][1]-y,ns};
		if(ey>y)
		{
			if(ex==x)ans=min(ans,d+ey-y);
			if(int z=tr[ey-1][ex>x])st[id][cnt[id]++]={x,z,d+z-y,ns};
		}
	}
	else
	{
		if(tl[y][0])st[id][cnt[id]++]={x,tl[y][0],d+y-tl[y][0],ns};
		if(tl[y][1])st[id][cnt[id]++]={x,tl[y][1],d+y-tl[y][1],ns};
		if(ey<y)
		{
			if(ex==x)ans=min(ans,d+y-ey);
			if(int z=tl[ey+1][ex>x])st[id][cnt[id]++]={x,z,d+y-z,ns};
		}
	}
}
int main()
{
	cin>>n>>m>>q>>(s+1)>>(t+1);
	for(int i=2;i<=n;i++){sl[i][0]=sl[i-1][0];sl[i][1]=sl[i-1][1];sl[i][s[i-1]=='E']=i-1;}
	for(int i=2;i<=m;i++){tl[i][0]=tl[i-1][0];tl[i][1]=tl[i-1][1];tl[i][t[i-1]=='S']=i-1;}
	for(int i=n-1;i;i--){sr[i][0]=sr[i+1][0];sr[i][1]=sr[i+1][1];sr[i][s[i+1]=='E']=i+1;}
	for(int i=m-1;i;i--){tr[i][0]=tr[i+1][0];tr[i][1]=tr[i+1][1];tr[i][t[i+1]=='S']=i+1;}
	while(q--)
	{
		cin>>sx>>sy>>ex>>ey;
		ans=1<<30;
		memset(cnt,0,sizeof cnt);
		go(0,sx,sy,0,0);
		go(0,sx,sy,0,1);
		for(int i=0;i<4;i++)
			for(int j=0;j<cnt[i];j++)go(i+1,st[i][j].x,st[i][j].y,st[i][j].d,st[i][j].dir^1);
		cout<<(ans==(1<<30)?-1:ans)<<'\n';
	}
}


Measured memory_bytes: 5376
H=int(input())
W=int(input())
N=int(input())
a=0
b=0
if H>W:
  a=N//H
  b=N%H
  if b>0:
    b=1
  print(a+b)
else:
  a=N//W
  b=N%W
  if b>0:
    b=1
  print(a+b)  

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

int main() {
  int64_t n,ans,a;
  a=0;
  cin>>n;
  ans=1;
  vector<int64_t> vec(n);
  for(int64_t i=0;i<n;i++){
  cin>>vec.at(i);
  }
   sort(vec.begin(), vec.end());
  if(vec.at(0)==0){cout<<0<<endl;
                  a=1;}
 if(a==0){for(int64_t i=0;i<n;i++){
 
    if(ans>1000000000000000000/vec.at(i)){cout<<-1<<endl;
                                a=1;
                               break;}
     ans=ans*vec.at(i);
  }}
  if(a==0){cout<<ans<<endl;}
  
}

Measured memory_bytes: 4052
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	l, r := make([]int, n), make([]int, n)
	s := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i], &r[i])
		s += r[i] - l[i] + 1
	}
	fmt.Println(s)
}


Measured memory_bytes: 512
#include <stdio.h>
#define X_MAX 600

int main(void){
	int x, sum, d;
	
	while(scanf("%d",&d)==1){
		sum=0;
		for(x=0; x<X_MAX; x+=d) sum+=x*x*d;
		printf("%d\n",sum);
	}
	
	return 0;
}

Measured memory_bytes: 0
# coding: utf-8

# https://atcoder.jp/contests/abc106


def main():
    S = list(map(int, input()))
    K = int(input())

    head = 0
    for i in range(len(S)):
        if S[i] > 1:
            head = i
            break
    
    if K == 1:
        return S[0]
    
    if K >= head+1:
        return S[head]
    else:
        return S[0]


print(main())


Measured memory_bytes: 9164
import java.awt.geom.Point2D;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class Main {	
	Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){		
		new AOJ0588();
	}

	class AOJ0588{

		public AOJ0588() {
			int result = in.nextInt();
			for(int s=0;;s++){
				String input = in.next();
				if(!input.equals("=")){
					if(input.equals("+")){
						result+=in.nextInt();
					}else if(input.equals("-")){
						result -= in.nextInt();
					}else if (input.equals("*")){
						result*=in.nextInt();
					}else if(input.equals("/")){
						result /= in.nextInt();
					}
				}
				else  break;
			}
			System.out.println(result);
		}
	}

	class AOJ2503{
		int MAX = 0;
		public AOJ2503() {
			Scanner in = new Scanner(System.in);
			int n = in.nextInt();
			int m = in.nextInt();

			int[][] cost = new int[n][n];

			int[] dp = new int[n];
			for(int i=0;i<n*n;i++){
				cost[i/n][i%n]=MAX;
			}
			for(int i=0;i<m;i++){
				int a = in.nextInt();
				int b = in.nextInt();
				cost[a][b]=in.nextInt();
			}	
			//			TODO 一番大きいパスを0のポイントからn-1のポイントまでの

			for(int s=1;s<n;s++){
				for(int i=0;i<=s;i++){
					if(cost[i][s]==MAX)continue;
					dp[s]=Math.max(dp[s],dp[i]+cost[i][s]);
				}
			}
			for(int s=0;s<n;s++)for(int i=0;i<n;i++){
				if(cost[s][i]==MAX)continue;
				dp[i]=Math.max(dp[s]+cost[s][i],dp[i]);
			}
			for(int i=0;i<n;i++)System.out.print(dp[i]+" ");
			System.out.println();
			System.out.println(dp[n-1]);
		}
	}
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a%2==1 && b%2==1){puts("Hom");return 0;}
    if(c%2==1 && b%2==1){puts("Hom");return 0;}
    if(a%2==1 && c%2==1){puts("Hom");return 0;}
    puts("Tem");return 0;
}




Measured memory_bytes: 3088
import sys
N, K = [int(x) for x in input().split()]
A = [None] + [int(x) for x in input().split()]

visited = [False] * (N + 1)
by = [None] * (N + 1)

visited[1] = True
by[1] = 0 # 0番目のテレポーテーションで到着

i = 1
tel = 0
for tel in range(1, N + 2):
    i = A[i]
    if tel == K:
        print(i)
        sys.exit(0)
    if visited[i]:
        cycle = tel - by[i]
        offset = by[i]
        break
    visited[i] = True
    by[i] = tel

# iからスタートして、M回移動した地点
M = (K - offset) % cycle

for j in range(M):
    i = A[i]

print(i)

Measured memory_bytes: 32124