akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int     ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;




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

    ll a,b,c;
    cin>>a>>b>>c;
    ll ans=0;
    for(ll i=a;i<=b;i++)
    {
        if(i%c==0) ans++;
    }
    cout<<ans<<nn;




}


/* Final check before submit :

1. array size or integer overflow.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***

*/



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define pb push_back
#define all(x) x.begin(), x.end()
#define pi pair<int, int>
#define l first
#define r second
#define int long long

using namespace std;

const int maxn = 1e6 + 1;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s; cin >> s;
    int n = s.size(); int nl = n / 2;
    for (int i = 0; i < nl / 2; i++)
        if (s[i] != s[nl - i - 1]) {
            cout << "No";
            return 0;
        }
    string t = "";
    for (int i = 0; i < s.size(); i++)
        t += s[n - i - 1];
    s = t;
    for (int i = 0; i < nl / 2; i++)
        if (s[i] != s[nl - i - 1]) {
            cout << "No";
            return 0;
        }
    for (int i = 0; i < nl; i++)
        if (s[i] != s[n - i - 1]) {
            cout << "No";
            return 0;
        }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
int main(){
  string s;
  cin >> s;

  if(s == "MON"){
    cout << 6 << endl;
  }else if(s == "TUE"){
    cout << 5 << endl;
  }else if(s == "WED"){
    cout << 4 << endl;
  }else if(s == "THU"){
    cout << 3 << endl;
  }else if(s == "FRI"){
    cout << 2 << endl;
  }else if(s == "SAT"){
    cout << 1 << endl;
  }else if(s == "SUN"){
    cout << 7 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	int X[100] = { 0 };
	cin >> T;
	for (int i = 0; i < 3; i++) {
		if (T[i] == '1') {
			T[i] = '9';
		}
		else {
			T[i] = '1';
		}
	}
	cout << T;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

struct BIT{
    int N;
    VI bit; 
    BIT(VI s) : N(s.size()), bit(N, 0)  { 
        rep(i, 0, N) add(i, s[i]); //O(NlogN)
    }
    void add(int a, int w) { // s[a] += w. O(logN)
        for (int x = a; x < N;  x |= x + 1) bit[x] += w;
    }
    int sum(int a) { // [0, a) 和
        int ret = 0;
        for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) 
            ret += bit[x];
        return ret;
    }
    int parsum(int a, int b){ // [a, b) 和.
        return sum(b) - sum(a);
    }
};

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

int n , q; cin >> n >> q;
VI a(n+1, 0);
BIT b(a);

rep(_, 0, q){
    int c, x, y; cin >> c >> x >> y;
    if (c) cout << b.parsum(x, y+1) << "\n";
    else b.add(x, y);
}


return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．




Measured memory_bytes: 5116
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import time
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))

N,M=map(int,input().split())
LRC=[list(map(int,input().split())) for i in range(M)]
LRC.sort()


stack=[[0,-1,0]]
idle_max=10**18
visited=[idle_max for i in range(N+1)]
visited2=[0 for i in range(N+1)]
visited[1]=0
x=0
while stack:
    #print(stack)
    m,a,p=heappop(stack)
    a=-a
    if a==N:
        print(m)
        break
    if not visited2[a]:
        visited2[a]=1
        for i in range(x,M):
            l,r,c=LRC[i]
            x=i
            if l<=a:
                _m=m+c
                if _m<visited[r]:
                    visited[r]=_m
                    heappush(stack,[_m,-r,a+1])
            else:
                break
else:
    print(-1)


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    set < string > st;
    scanf("%d" , &n);


    while( n --) {
            string s;
            cin >> s;
            st.insert(s);
    }
    printf("%d\n" , st.size());

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 19344
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define output(x) cout<<x<<endl;
typedef long long int ll;



int main()
{
	ll  i, j, k, l, m, sum, flag,ans,W,H,N;
	sum = 0;
	flag = 0;
	char S[100001];
	cin >> S;
	N = strlen(S);
	vector<pair<int, int>>edge(N);
	i = 1;
	j = 0;
	if (S[0] == '0'||S[N-1]=='1'||S[N-2]=='0') {
		output("-1");
		return 0;
	}
	REP(i, 0, N-2) {
		if (S[i] != S[N - 2 - i]) {
			output("-1");
			return 0;
		}
	}
	i = 1;
	j = 0;
		while (i < N - 1) {
			if (S[i] == '1') {
				if (j != 0) {
					REP(k, i - j, i) {
						edge[k].first = k;
						edge[k].second = i + 1;
					}
				}
				j = 0;
				edge[i].first = i ;
				edge[i].second = i + 1;
				i++;
			}
			else {
				j++;
				i++;
			}
		}
		edge[N - 1].first = N - 1;
		edge[N - 1].second = N;
		REP(i, 1, N) {
			cout << edge[i].first << " " << edge[i].second << endl;
		}
	
	//ソートしてある配列aの各要素の数を前から数え上げることで新しい配列lenに入れている
	return 0;
}



Measured memory_bytes: 2304
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong();
		long b = scan.nextLong();
		long k = scan.nextLong();
		
		long copyA = a;
		if (a >= k) {
			a = a - k;
		} else if (b >= k - a) {
			a = 0;
			b = b - (k - copyA);
		} else {
			a = 0;
			b = 0;
		}
		
		System.out.println(a);
		System.out.println(b);
		
		
	}
}

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

int main() {
	int N, K, X, Y;
	cin >> N;
	cin >> K;
	cin >> X;
	cin >> Y;
	int yen = N * X;
	if (N > K) {
		yen += (N - K) * (Y - X);
	}
	cout << yen << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *r;
  struct node *l;
  struct node *parent;
  int key;
}node;

typedef struct node *Node;

Node root;

Node treeMinimum(Node x){
  while(x -> l != NIL)
    x = x -> l;
  return x;
}

Node treeMaximum(Node x){
  while(x -> r != NIL)
    x = x -> r;
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL && k == u ->key)return u;
  if(k < u -> key)return treeSearch(u -> l, k);
  if(k > u -> key)return treeSearch(u -> r, k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x -> r != NIL)return treeMinimum(x -> r);

  y = x -> parent;

  while(y != NIL && x == y -> r){
    x = y;
    y = y -> parent;
  }
  return y;
}

void treeDelete(Node z){
  Node x;
  Node y;

  if(z -> l == NIL || z -> r == NIL)y = z;
  else y = treeSuccessor(z);

  if(y -> l != NIL) x = y -> l;
  else x = y -> r;

  if(x != NIL) x -> parent = y -> parent;

  if(y -> parent == NIL) root = x;
  else if(y == y -> parent -> l) y -> parent -> l = x;
  else y -> parent -> r = x;

  if(y != z) z -> key = y -> key;
}

void insert(int k){
  Node x = root;
  Node y = NIL;
  Node z;

  z = malloc(sizeof(node));

  z -> key = k;
  z -> l = NIL;
  z -> r = NIL;

  while( x != NIL){
    y = x;
    if(z -> key < x -> key) x = x -> l;

    else x = x -> r;
  }
  z -> parent = y;

  if(y == NIL) root = z;

  else if(z -> key < y -> key) y -> l = z;

  else y -> r = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u -> l);
    printf(" %d", u -> key);
    inorder(u -> r);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d", u -> key);
    preorder(u -> l);
    preorder(u -> r);
  }
}

int main(){
  int n, i, x;
  char com[20];

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s",com);

    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    
    else if ( com[0] == 'i' ){
      scanf("%d",&x);
      insert(x);
    }
    
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    
    else if ( com[0] == 'd' ){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }

  return 0;
}




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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,x; cin>>n>>x;
	int d=0,ans=1;
	for(int i=0;i<n;++i){
		int l; cin>>l;
		d+=l;
		if(d>x)break;
		++ans;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<map>
#define INF 0x3f3f3f3f
using namespace std;

const int MAXN=120;

long long w[MAXN];
int vis[MAXN];
long long dis[MAXN][MAXN];
bool hash[MAXN];

int main()
{
    int n,m;
    int S,T;
    while(scanf("%d%d",&n,&m) && (n||m))
    {
        memset(hash,0,sizeof(hash));
        memset(dis,0,sizeof(dis));
        long long tmp = 0LL;
        while(m--)
        {
            int u,v,weigh;
            scanf("%d%d%d",&u,&v,&weigh);
            if(weigh <= 0)
            {
                tmp += weigh;
            }
            else
            {
                dis[u][v]+=weigh;
                dis[v][u]+=weigh;
            }
        }
        long long ans=INT_MAX*(1LL<<20);
        for(int cot=n; cot>1; cot--)
        {
            memset(vis,0,sizeof(vis));
            memset(w,0,sizeof(w));
            priority_queue<pair<int,int> >q;
            int u;
            for(u=0; hash[u]; u++)
            {
                ;
            }
            vis[u]=1;
            for(int v=0; v<n; v++)
                if(!hash[v]&&!vis[v])
                {
                    w[v]+=dis[u][v];
                    q.push(make_pair(w[v],v));
                }
            for(int tot=2; tot<=cot; tot++)
            {
                int maxi,maxn=-1;
                for(int u=0; u<n; u++)
                    if(!hash[u]&&!vis[u])
                    {
                        if(w[u]>maxn)
                        {
                            maxn=w[u];
                            maxi=u;
                        }
                    }
                vis[maxi]=tot;
                for(int v=0; v<n; v++)
                    if(!hash[v]&&!vis[v])
                    {
                        w[v]+=dis[maxi][v];
                    }
            }
            for(int i=0; i<n; i++)
            {
                if(vis[i]==cot-1)S=i;
                else if(vis[i]==cot)T=i;
            }
            ans=min(ans,w[T]);
            hash[T]=true;
            for(int i=0; i<n; i++)
            {
                dis[S][i]+=dis[T][i];
                dis[i][S]+=dis[i][T];
            }
        }
        printf("%lld\n",ans+tmp);
    }
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, y;
	cin >> n >> y;

	for (int i = n; i >= 0; i--) {
		for (int j = 0; j <= n - i; j++) {
			for (int k = 0; k <= n - i - j; k++) {
				if (i + j + k == n && i * 10000 + j * 5000 + k * 1000 == y) {
					cout << i << " " << j << " " << k << "\n";
					return 0;
				}
			}
		}
	}
	cout << "-1 -1 -1\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1.0e9
using namespace std;
typedef long long ll;

int N, M;

vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n/i);
            }
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

int main() {
    cin >> N >> M;
    int ans = 0;
    vector<int> vec = divisor(M);
    for (int i = 0; i < vec.size(); i++) {
        if (vec[i] <= M/N) {
            ans = vec[i];
        }
        else {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const int mod = 1e9+7;


main(){
    int n;cin>>n;
    int count=0;
    for(int i=1;i<n;i++){
        int add = n/i;
        if(n%i == 0) add--;
        count+= add;
    }
    cout<<count;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
using namespace std;
long long INF = 1000000009;
map<int, int> mp;
int main()
{
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	bool ans = false;
	for (int i = 0; i < s.size(); i++) {
		if (s == t) {
			ans = true;
			break;
		}
		s = s.back() + s.substr(0, s.size() - 1);
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 380
#include<stdio.h>

int main(){

int i, n, min, max;
long int sum;
int a[10000];

scanf("%d", &n);

for(i=0;i<n;i++)
scanf("%d", &a[i]);

max=a[0];
min=a[0];
sum=a[0];

for(i=1;i<n;i++){
if(a[i]<min)
min=a[i];

if(a[i]>max)
max=a[i];

sum+=a[i];
}
printf("%d %d %ld\n", min, max, sum);

return 0;
}

Measured memory_bytes: 2744
import math

n = int(input())

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
prime = callIsPrime(55555)

ans = []
for p in prime:
    if p % 5 == 1:
        ans.append(p)
        if len(ans) == n:
            break
for p in ans:
    print(p)

Measured memory_bytes: 41708
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
 
        long cnt = 0;
        for (int i = 0; i < n; i++) {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        }
        System.out.println(cnt);
    }
 
}

Measured memory_bytes: 53876
while True:
    m, f, r = list(map(int, input().split()))

    if m == -1 and f == -1 and r == -1:
            break

    if (m == -1 or f == -1) or m+f < 30:
        print('F')
    elif 80 <= m+f:
        print('A')
    elif 65 <= m+f < 80:
        print('B')
    elif (50 <= m+f <65) or (30 <= m+f <50 and 50 <= r):
        print('C')
    elif 30 <= m+f <50:
        print('D')

Measured memory_bytes: 7592
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  string a,b;
  cin>>a>>b;
  a+=b;
  int t=stoi(a);
  for(int i=1;i<=t;i++){
    if(i*i==t){cout<<"Yes"<<endl;return 0;}
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3584
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=2e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int arr[MAXN];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<n;i++)
    {
        int a;cin>>a;
        arr[a]++;
    }
    for(int i=1;i<=n;i++)cout<<arr[i]<<endl;
    return 0;
}


Measured memory_bytes: 4376
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var x string
	var y string
	var z string
	fmt.Scan(&x, &y)
	z = x + y
	var i int
	i, _ = strconv.Atoi(z)

	a := math.Sqrt(float64(i))
	if a == float64(int64(a)) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        long k = sc.nextLong();
        long[] a = new long[n + 1];
        long[] b = new long[m + 1];
        int max = 0;
        for (int i = 1; i < n + 1; i++) {
            a[i] = a[i - 1] + sc.nextLong();
        }
        for (int i = 1; i < m + 1; i++) {
            b[i] = b[i - 1] + sc.nextLong();
        }

        int j = b.length - 1;
        for (int i = 0; i < n + 1; i++) {
            if (a[i] > k) {
                break;
            }
            while (j > 0 && a[i] + b[j] > k) {
                j--;
            }
            max = Math.max(i + j, max);

        }
        System.out.println(max);
    }
}

Measured memory_bytes: 63240
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vb=vector<bool>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
#define NIL (-1)

typedef struct node{
    int id;
    int left=NIL,right=NIL;
    int parent=NIL;
    int h=NIL;
    int d=NIL;
}Node;

Node n[30];;

void height(int id,int h){
    chmax(n[id].h,h);
    if(n[id].parent!=NIL){
        height(n[id].parent,h+1);
    }
}

void depth(int id,int d){
    chmax(n[id].d,d);
    if(n[id].left!=NIL)depth(n[id].left,d+1);
    if(n[id].right!=NIL)depth(n[id].right,d+1);
}


int numchild(int id){
    int num=0;
    if(n[id].left!=NIL)num++;
    if(n[id].right!=NIL)num++;
    return num;
}

int sib(int id){
    int parent=n[id].parent;
    if(parent==NIL)return NIL;
    else if(numchild(parent)==2)return n[parent].right+n[parent].left-n[id].id;
    else return NIL;
}

void kind(int id){
    if(n[id].parent==NIL)cout<<"root";
    else if(numchild(id))cout<<"internal node";
    else cout<<"leaf";
}

int in;
int root(){
    rep(id,0,in){
        if(n[id].parent==NIL)return id;
    }
    return -1;
}
void print(int id){
    cout<<"node "<<id<<": parent = "<<n[id].parent<<", sibling = "<<sib(id)<<", degree = "<<numchild(id)<<", depth = "<<n[id].d;
    cout<<", height = "<<n[id].h<<", ";
    kind(id);
    cout<<endl;
}
long long INF = 1LL<<60;
int main( ){
    cin>>in;
    list<int> leaf;
    rep(i,0,in){
       int id;
       int left,right;
       cin>>id>>left>>right;
       n[id].id=id;
       n[id].left=left;
       n[id].right=right;
       n[left].parent=id;
       n[right].parent=id;
       if(right==NIL&&left==NIL)leaf.push_back(id);
    }
    int r=root();
    depth(r,0);
    for(int itr:leaf){
        height(itr,0);
    }
    rep(id,0,in){
        print(id);
    }
    return 0;
}





Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
int n,q,m,k,l,ans;
vi a,b;
ll llans;
vll lla,llb;
string s;

int func(ll x){
    int cnt = 0;
    while(x >0 && x%2==0){
        x /= 2;
        cnt++;
    }
    return cnt;
}

int main() {
    cin >> n;
    ans = 0;
    rep(i,n) {
        int x;cin >> x;
        ans += func(x);
    }

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

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
char S[100];
int main(){
	cin>>N;
	int R[101]={};
	int ans=0;
	for(int i=1;i<N+1;i++){
		cin>>S[i];
		if(S[i]=='I')R[i]=R[i-1]+1;
		if(S[i]=='D')R[i]=R[i-1]-1;
		ans=max(ans,R[i]);
	}

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


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;

	cout << (1000 - N % 1000) % 1000 << "\n";

	return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>

int main(){
	char s[19];
	scanf("%[^\n]",s);
	int lol;
	for(int i=0;i<19;i++){
		if(s[i]==','){
			printf(" ");
		}else {
			printf("%c",s[i]);
		}
	}
return 0;
}

Measured memory_bytes: 1532
#!/usr/bin/env python
# coding: utf-8

import sys


def get_answer(param):
    answer = 1
    for i in xrange(1, param + 1):
        answer += i
    return answer


def main():
    params = [int(line) for line in sys.stdin.readlines()]
    for param in params:
        print get_answer(param)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7256
#include<bits/stdc++.h>
using namespace std;
struct stu{
	int x,y;
}xs[100];
struct node{
	int x,y;
}dot[100];
int dis(stu a,node b){
	return abs(a.x-b.x)+abs(a.y-b.y);
}
int main(){
	int n,m,i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		cin>>xs[i].x>>xs[i].y;
	}
	for(i=1;i<=m;i++){
		cin>>dot[i].x>>dot[i].y;
	}
	int pos,d;
	for(i=1;i<=n;i++){
		d=dis(xs[i],dot[1]);
		pos=1;
		for(j=2;j<=m;j++){
			if (dis(xs[i],dot[j])<d ||dis(xs[i],dot[j])==d &&j<pos){
				d=dis(xs[i],dot[j]);
				pos=j;
			}
		}
		cout<<pos<<endl;
	}
		
	return 0;
}
/*
2 2
2 0
0 0
-1 0
1 0

3 4
10 10
10 10
3 3
1 2
2 3
3 5
3 5


3
1
2


5 5
100000000 100000000
100000000 100000000
100000000 100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 100000000
100000000 100000000
100000000 100000000
*/

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, C[500], S[500], F[500];
    cin >> N;

    for (int i = 0; i < N-1; i++) {
        cin >> C[i] >> S[i] >> F[i];
    }

    for (int i = 0; i < N; i++) {
        int t = 0;
        for (int j = i; j < N-1; j++) {
            if (t < S[j]) { t = S[j]; }
            else if (t % F[j] == 0) {;}  // 何もしない
            else { t = (t / F[j] + 1) * F[j]; }
            t += C[j];
        }
        cout << t << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

typedef tree< pair < ll, ll >, null_type, less< pair < ll, ll > >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll mod = 998244353;
const ll MAXN = 1e5+5;
const ll inf = 1e18;

int main()
{
    fastio;
    string s;
    cin >> s;
    ll n = s.length();
    ll ans = 0, r = n - 1;
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == 'B'){
            ans += r - i;
            r--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, a;
	cin >> n >> a;
	int ans = n * n - a;
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a 

def solv_quadratic_equation(a, b, c):
    """ 2次方程式を解く  """
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)
    x_2 = (-b - D) / (2 * a)
    if x_2 > 0:
        return x_2
    else:
        return x_1

n = int(input())
A = Counter(prime_factorize(n))
#print(A)
ans = 0
for (i, j) in A.items():
    c = int(solv_quadratic_equation(1, 1, -2 * j))
    ans += c

print(ans)

Measured memory_bytes: 9728
"""
A - Still TBD
"""
import datetime

if __name__ == '__main__':
    s = input()
    s = s.split('/')
    s = datetime.date(int(s[0]),int(s[1]),int(s[2]))
    border = datetime.date(2019,4,30)
    
    result = 'TBD'
    if(s <= border):
        result = 'Heisei'

    print(result)


Measured memory_bytes: 3312
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll x;
	cin>>x;
	if(x==1){
		cout<<0<<"\n";
	}else{
		cout<<1<<"\n";
	}
	return 0;
	}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define Int int64_t
const Int MOD=998244353;
using namespace std;

Int N,K,M,A,B;
int main()
{
  cin>>A>>B>>N;
  N=min(N,B-1);
  cout<<((A*N)/B)-(A*(N/B))<<"\n";
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,k,n) for(int i = k; i <= n; i++) 
#define per(i,k,n) for(int i = k; i >= n; i--)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii; 
typedef vector<ii> vii;
typedef vector<char> vchar;
typedef vector<int> vi;
#define ff first
#define ss second

#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));

#define INF 1000000000
#define mod 998244353
//#define mod 1000000007
#define endl "\n"


   //=\/=\/=\/=\/=\/=\/=\/=\/=\/=\        Jai Hind Dosto        /=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\
  //=\/=\/=\/=\       RETARDED     ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿      NISHAN                 /=\/=\/=\/=\\
 //=\/=\/=\/=\         APE                                           SINGH                   /=\/=\/=\/=\\
//=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\


int modPow(int a, int b);
void solve(){


    int a;
    double b;
    cin >> a >>b;
    b*=100;
    int c = b;
    int d = a*c;
    d/=100;
    cout << d <<endl;



}






signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(2);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
   // int test=1; cin >> test;
   // while(test--)
    solve();
}


int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}


Measured memory_bytes: 3692
n=int(input())
h=list(map(int,input().split()))
ans=1
for j in range(1,n):
    # print(j)
    if h[j-1]<=h[j]:
        if h[0]>h[j]:
            pass
        elif max(h[:j])<=h[j]:
            ans=ans+1 
        # print(h[j])
print(ans)

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

class edge;

class vertex{
    public:
        vector<edge*> edges;
        int color;
        vertex(int _color){
            color = _color;
        }
};

class edge{
    public:
        vertex *to;
        edge(vertex *_to){
            to = _to;
        }
};

class list_node{
    public:
        list_node *prev,*next;
        vertex *data;
        list_node(list_node *_prev,list_node *_next,vertex *_data){
            prev = _prev;
            next = _next;
            data = _data;
        }
};

class list{
    public:
        list_node *back,*front;
        list(){
            back = new list_node(0,0,0);
            front = new list_node(0,back,0);
            back->prev = front;
        }
        list_node *get_first(){
            return front->next;
        }
        list_node *get_last(){
            return back->prev;
        }
        void push_back(vertex *data){
            list_node *node = back->prev;
            node->next = new list_node(node,back,data);
            back->prev = node->next;
        }
        bool isEmpty(){
            if(front->next == back) return true;
            return false;
        }
};

int bfs(list l){
    int count = 0;
    list *L = new list[10000];
    L[0] = l;
    int i = 0;
    while(true){
        for(list_node *j = L[i].get_first(); j != L[i].back; j = j->next){
            vertex *v = j->data;
            for(int k = 0; k < v->edges.size(); k++){
                vertex *to = v->edges[k]->to;
                if(to->color) continue;
                to->color = 1;
                L[i+1].push_back(to);
            }
        }
        count++;
        if(L[i+1].isEmpty()) break;
        i++;
    }
    return count;
}

int main(){
    int H,W,color;
    string str;
    cin >> H >> W;
    list l;
    vertex *A[H+2][W+2];
    for(int i = 0; i <= H+1; i++){
        if(i != 0 && i != H+1) cin >> str;
        for(int j = 0; j <= W+1; j++){
            if(i  == 0 || j == 0 || i == H+1|| j == W+1){
                A[i][j] = new vertex(1);
            }else{
                if(str[j-1] == '.') color = 0;
                else color = 1;
                A[i][j] = new vertex(color);
            }
        }
    }

    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(A[i][j]->color) l.push_back(A[i][j]);
            A[i][j]->edges.push_back(new edge(A[i-1][j]));
            A[i][j]->edges.push_back(new edge(A[i][j+1]));
            A[i][j]->edges.push_back(new edge(A[i+1][j]));
            A[i][j]->edges.push_back(new edge(A[i][j-1]));
        }
    }

    cout << bfs(l)-1 << endl;
    
}

Measured memory_bytes: 262328
#include <cstdio>
#include <algorithm>
using namespace std;
int a[101], sum;
int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i<=n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    int minv = sum;
    for (int i = 1; i<=n; i++) {
        minv = min(minv, abs(sum - a[i] * n));
    }
    for (int i =1; i <= n; i++) {
        if (abs(sum - a[i] * n ) == minv) {
            printf("%d ", i-1);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	final double[] limit500 = { 35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0 };
	final double[] limit1000 = { 71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0 };
	final String[] rank = { "AAA", "AA", "A", "B", "C", "D", "E", "NA" };
	
	while ( stdin.hasNextDouble() ) {

	    final double time500 = stdin.nextDouble();
	    final double time1000 = stdin.nextDouble();
	    
	    int i = limit500.length;
	    while ( 0 < i && time500 < limit500[i - 1] && time1000 < limit1000[i - 1] ) {
		i--;
	    }
	    System.out.println( rank[i] );
	}	
    }    
}

Measured memory_bytes: 20672
#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	double x1, y1, x2, y2;

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

	double square = pow(x1 - x2, 2) + pow(y1 - y2, 2);
	
	double ans = sqrt(square);

	printf("%8f", ans);

	


}




Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s,t;
  cin>>s>>t;
  char c = t[s.size()];
  if(t==s+c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(){
  int n, ret=0;
  cin >> n;
  for(int i=0; i<n; i++){
    int a, c=0;
    cin >> a;
    while(a%2==0){
      c++;
      a/=2;
    }
    ret += c;
  }
  cout << ret;
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  int slen = S.length();
  int ans = slen;
  REP(i,slen-1) {
    if (S[i] != S[i+1]) {
      ans = min( ans, max(slen-i-1, i+1) );
    }
  }
 cout << ans << endl;
}



Measured memory_bytes: 3724
using System;
using System.Linq;
class A{
  static void Main(){
    var arr = new int[] { 4, 6, 9, 11 };
    var s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    Console.WriteLine(!s.Contains(2) && arr.Contains(s[0]) == arr.Contains(s[1])?"Yes":"No");
  }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
//datatypes
	#define ll 			long long
	#define vi 			vector<int>
	#define vll 		vector<ll>
	#define si 			set<int>
	#define vii 		vector<ii>
	#define ii 			pair<int,int>
	#define vpll		vector<pll>
	#define pii 		pair<int,int>
	#define pll 		pair<ll, ll>
	#define mii 		map<int,int>
	#define ord_set		tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
	#define M 			1000000007
	#define narak 		998244353
	#define pi 			acos(-1)
	#define inf 		2147483647
	#define infl 		9223372036854775807
	#define infd 		1.7e308
	#define invd 		1.7e-308
	#define sz(x) 		(ll)x.size()
	#define fr 			first
	#define sc 			second
	#define pb 			push_back
	#define mkp 		make_pair
	#define rep(i,a,b) 	for(int i=a; i<b; ++i)
	#define rep0(i,a)	for(int i=0; i<a; ++i)
	#define rep1(i,a)	for(int i=1; i<=a; ++i)
	#define trav(a) 	for(auto &x:a)
	#define test 		cout<<"hello\n";
	#define all(x) 		(x).begin(),(x).end()
	#define mem(x,val)	memset(x, val, sizeof(x))
	#define sa(x) 		std::sort(all(x))
	#define endl 		'\n'
	#define __lcm(m,n) 	m*(n/__gcd(m,n))
	#define fill(a,n) 	for(int xxx=0;xxx<n;++xxx) cin>>(a)[xxx]
	#define maxa(v)		*(max_element(all(v)))
	#define mina(v)		*(min_element(all(v))
	#define inputFile 	freopen("input.txt", "r", stdin); 
	#define outputFile	freopen("output.txt", "w", stdout);
	#define disp(a) 	trav(a) cout<<x<<" "; cout<<endl;
  	#define int long long

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T,typename U> std::ostream& operator<<(std::ostream& out, std::pair<T,U> a) {out<<a.fr<<" "<<a.sc; return out;}
template<typename T,typename U> std::istream& operator>>(std::istream& in, std::pair<T,U> &a) {in>>a.fr>>a.sc; return in;}
template<typename T> static inline void sd(vector<T> &x) {sort(all(x), greater<T>()) ; }

signed solve()
{
    int n;cin>>n;
    int ans=0LL;
    rep(i,1,n+1)
    {
    	ans+=i*(n+1-i);
    }
    rep(i,0,n-1)
    {
    	int a,b;
   		cin>>a>>b;
   		if(a<b)swap(a,b);
   		ans -= b*(n+1-a); 
    }
    cout<<ans;
	return 0;
}

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
        
		solve();
        
	}
	//cout << "\nTime : " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3524
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	int x = 0,y = 0;
	int i;
	int t;
	
	scanf("%d",&n);

	for(i = 0;i < n;i++)
	{
		scanf("%d",&t);

		if((t & 0x03) == 0)
		{
			y++;
		}
		else if((t & 0x01) == 0)
		{
			x++;
		}
	}

	bool flag = false;
	int p = n - x - y;
	
	if(y >= (p - 1))
	{
		if((x >= 1) && (p >= 1))
		{
			flag = (y >= p);
		}
		else
		{
			flag = true;
		}
	}

	printf(flag ? "Yes\n" : "No\n");
	return 0;
}

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

int main() {
    int n;
    int a, b;
    scanf("%d", &n);
    if (n == 1) {
        printf("Hello World");
        return 0;
    } else if (n == 2) {
        scanf("%d%d", &a, &b);
        printf("%d", a + b);
        return 0;
    }
}


Measured memory_bytes: 256
import heapq

class Solver(object):
    def __init__(self):
        self._input()
        self.heap = []

    def solve(self):
        if self.n >= self.m:
            print(0)
            return

        self.x_s.sort()
        for i in range(len(self.x_s) - 1):
            heapq.heappush(self.heap, -abs(self.x_s[i+1] - self.x_s[i]))

        for i in range(self.n - 1):
            heapq.heappop(self.heap)

        print(-sum(self.heap))

    def _input(self):
        self.n, self.m = list(map(int, input().split(" ")))
        self.x_s = list(map(int, input().split(" ")))


if __name__ == "__main__":
    Solver().solve()

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

int main(){
	bool cards[4][13];
	for(int i=0;i<4;i++){ //カードのデータ入れ
		for(int j=0;j<13;j++){
			cards[i][j]=false;
		}
	}
	
	int n,r,cs;
	char s;
	cin >> n;
	while(n>0){
		cin >> s >> r;
		if(s=='S')
			cs=0;
		else if(s=='H')
			cs=1;
		else if(s=='C')
			cs=2;
		else
			cs=3;
		cards[cs][r-1]=true;
		n--;
	}

	for(int i=0;i<4;i++){ 
		for(int j=0;j<13;j++){
			if(cards[i][j]==false){
				if(i==0)
					cout << 'S';
				else if(i==1)
					cout << 'H';
				else if(i==2)
					cout << 'C';
				else if(i==3)
					cout << 'D';
				cout<<" ";
				cout << j+1;
				cout << "\n";
			}
		}
	}
}


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

using namespace std;

int max_dist(int node, int parent, vector<int>& dist, vector<vector<int>>& tree){
  int mx = dist[node];
  for(int next : tree[node]){
    if(next == parent) continue;
    
    dist[next] = dist[node] + 1;
    mx = max(max_dist(next, node, dist, tree), mx);
  }
  
  return mx;
}

void search_max_degree(int node, int parent, vector<long long>& max_degree, vector<int>& dist, vector<vector<int>>& tree){
  for(int next : tree[node]){
    if(next == parent) continue;
    
    max_degree[dist[next]] = max((long long)tree[next].size() - 1, max_degree[dist[next]]);
    
    search_max_degree(next, node, max_degree, dist, tree);
  }
};

int main(){
  int N;
  cin >> N;
  
  vector<vector<int>> tree(N);
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    --a; --b;
    
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  
  int min_color = N;
  long long min_leaf = (1ll << 61);
  for(int i = 0; i < N; i++){
    vector<int> dist(N, N);
    dist[i] = 0;
    
    int color = max_dist(i, -1, dist, tree) + 1;
    
    if(color <= min_color){
      vector<long long> max_degree(color, 0);
      max_degree[0] = tree[i].size();
      search_max_degree(i, -1, max_degree, dist, tree);
      
      long long leaf = 1;
      for(long long d : max_degree){
        if(d && d * leaf / d == leaf) leaf *= d;
        else if(d) leaf = -1;
      }
      
      if(leaf == -1) break;
      
      if(color < min_color) min_leaf = leaf;
      else min_leaf = min(leaf, min_leaf);
      
      min_color = color;
    }
  }
  
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      bool co = false;
      for(int next : tree[i]){
        if(next == j){
          co = true;
          break;
        }
      }
      if(!co) continue;
      
      vector<int> dist(N, N);
      dist[i] = dist[j] = 0;
      
      int color = max(max_dist(i, j, dist, tree), max_dist(j, i, dist, tree)) + 1;
      
      if(color <= min_color){
        vector<long long> max_degree(color, 0);
        max_degree[0] = max((long long)tree[i].size(), (long long)tree[j].size()) - 1;
        search_max_degree(i, j, max_degree, dist, tree);
        search_max_degree(j, i, max_degree, dist, tree);
        
        long long leaf = 2;
        for(long long d : max_degree){
          if(d && d * leaf / d == leaf) leaf *= d;
          else if(d) leaf = -1;
        }
        
        if(leaf == -1) break;
        
        if(color < min_color) min_leaf = leaf;
        else min_leaf = min(leaf, min_leaf);
        
        min_color = color;
      }
    }
  }
  
  cout << min_color << ' ' << min_leaf << endl;
  
  return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>
#include <sstream>

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

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

int main() { 
  i64 a,b;
  cin >> a >> b;
  if(abs(b-a) % 2 == 1LL)cout << "IMPOSSIBLE" << endl;
  else cout << (a+b)/2 << endl;
  return 0;
}


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int M = (int) 1e9 + 7;

ll g(ll p) {
  return p * (p + 1) / 2;
}

ll g(ll l, ll r) {
  return g(r) - g(l - 1);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  n++;
  ll sol = 0;
  for (int t = k; t <= n; t++) {
    ll mn = g(0, t - 1);
    ll mx = g(n - t, n - 1);
    sol = (sol + mx - mn + 1) % M;
  }
  cout << sol << "\n";
  return 0;
}


Measured memory_bytes: 3636