akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);
int get_digent(int);


int main(){
  often();
  int N, D; cin >> N >> D;
  vvi X(N, vi(D));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < D; ++j) {
      cin >> X[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
      int norm = 0;
      for (int k = 0; k < D; ++k) {
        int diff = abs(X[i][k] - X[j][k]);
        norm += diff * diff;
      }
      bool flag = false;
      for (int k = 0; k <= norm; ++k) {
      if (k * k == norm) {
        flag = true;
        break;
      }
    }
    if (flag) ++ans;
  }
}
cout << ans << endl; 
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int get_digent(int x){
  string s;
  s = to_string(x);
  int digent = s.size();
  return digent;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int L, R, d;
  cin >> L >> R >> d;
  
  int ans = 0;
  
  for(int i=L;i<=R;i++){
    if(i % d == 0) ans ++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005, mod = 1e9 + 7;
int a[N], f[105][N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    rep(i, 1, n + 1) {
        cin >> a[i];
    }
    f[0][0] = 1;
    rep(i, 1, n + 1) {
        rep(j, 1, k + 1) {
            f[i - 1][j] += f[i - 1][j - 1];
            if(f[i - 1][j] >= mod) {
                f[i - 1][j] -= mod;
            }
        }
        rep(j, 0, k + 1) {
            f[i][j] = f[i - 1][j];
            if(j - a[i] - 1 >= 0) {
                f[i][j] -= f[i - 1][j - a[i] - 1];
                if(f[i][j] < 0) {
                    f[i][j] += mod;
                }
            }
        }
    }
    cout << f[n][k] << endl;
}

Measured memory_bytes: 41216
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>

#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 9223372036854775807

using namespace std;

// input
int n;

int gcm(int a,int b) {
  if(a > b) {
	int tmp = a;
	a = b;
	b = tmp;
  }
  while(a % b != 0) {
	int tmp = b;
	b = a % b;
	a = tmp;
  }
  return b;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  ll ans = 0;
  rep(i,n) rep(j,n) rep(k,n) {
	ans += gcm(gcm(i+1,j+1),k+1);
  }
  cout << ans;
}



Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main(void) {
  int x;
  scanf("%d", &x);
  int res = 0;
  res += x / 500 * 1000;
  x -= x / 500 * 500;
  res += x / 5 * 5;
  cout << res << endl;
  
  return 0;
}


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

//A
int main()
{
    int x, y;
    cin >> x >> y ;
    int d = x / y , r = x % y;
    double f = 1.0 * x / y;
    cout << d << " " << r << " " << fixed << setprecision(8) << f;
}


Measured memory_bytes: 3260
#                         author:  kagemeka 
#                         created: 2019-11-07 02:35:07(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    s = sys.stdin.readline().rstrip()
    print('Yes' if len(set(s)) == 3 else 'No')


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
X = input()

def popcount(n):
    cnt = 0
    while n > 0:
        cnt += n & 1
        n //= 2
    return cnt
def f(n):
    cnt = 0
    while n != 0:
        n = n % popcount(n)
        cnt += 1
    return cnt

ones = X.count('1')
MOD1 = ones + 1
MOD2 = ones - 1
pow1 = [1] * (len(X) + 1)
pow2 = [0] * (len(X) + 1)
if MOD2 != 0:
    pow1[0] = 1
    pow2[0] = 1
    for i in range(1, len(X) + 1):
        pow1[i] = (pow1[i - 1] * 2) % MOD1
        pow2[i] = (pow2[i - 1] * 2) % MOD2
else:
    for i in range(1, len(X) + 1):
        pow1[i] = (pow1[i - 1] * 2) % MOD1

X1 = 0
X2 = 0
for i in range(N):
    if X[i] == '1':
        X1 += pow1[N - i - 1]
        X2 += pow2[N - i - 1]
X1 %= MOD1
if MOD2 != 0:
    X2 %= MOD2

for i in range(N):
    d = N - i - 1
    if X[i] == '0':
        x = (X1 + pow1[d]) % MOD1
        print(f(x) + 1)
    else:
        if MOD2 != 0:
            x = (X2 - pow2[d]) % MOD2
            print(f(x) + 1)
        else:
            print(0)

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

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


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

	if(s[2]==s[3] && s[4]==s[5]){
		cout << "Yes" << endl;
	}else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
typedef long long ll;
#define loop(i,j) for(int i=0;i<j;i++)
#define scan1(a) scanf("%lld",&a);
#define print(a) printf("%lld\n",a);
using namespace std;
int main()
{
  ll N;
  scan1(N);
  ll ans=0;
  ll sum=0;
  ll araisan=0;
  ll mini=LLONG_MAX;
  vector<ll> a(N);
  loop(i,N){
    scan1(a[i]);
    sum+=a[i];
  }
  loop(i,N-1){
    ans+=a[i];
    araisan=sum-ans;
    mini=min(mini,abs(ans-araisan));
  }
  print(mini);
}


Measured memory_bytes: 1792
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n ;
  cin >>  n  ;
  vector<string> st(n) ;
 for(int i=0;i<n;i++){
  cin >> st.at(i) ;
 }
  
  bool cond = 1 ;
  
  for(int i=0 ; i<(n-1) ; i++){
    
    char target = st.at(i)[st.at(i).size()-1] ;
    if(target != st.at(i+1)[0]){
      cond = 0 ;
      break ;
    }
  }
  
  if(cond){
    for(int i=0; i<(n-1) ; i++){
      string tg = st.at(i) ;
      for(int j=i+1 ; j<n ; j++){
        if(tg == st.at(j)){
          cond = 0 ;
          break ; 
      }
    }
  }
  }
  
  if(cond)
    cout << "Yes" << endl ;
  else
    cout << "No" << endl ;
  
  return 0 ;
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	b1,b2 := 1,1
	
	for i := 0; i < n; i++ {
		t := scanInt()
		a := scanInt()

		c1 := (b1+t-1)/t
		c2 := (b2+a-1)/a
		
		ma := max(c1,c2)

		b1,b2 = t*ma,a*ma

		// debug(b1,b2)
	}

	fmt.Fprintln(wr, b1+b2)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod= 1e9+7;

int main(){
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout << a[0]+a[1] << endl;
  return 0;
}


Measured memory_bytes: 256
K=int(input())
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[K-1])

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

    int ans = 0;
    rep(i,s.size()/2)
    {
        if(s[i] != s[s.size()-i-1]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && a==c){
	    cout<<"No";
	    return 0;
	}
	else if(a!=b && a!=c && b!=c){
	    cout<<"No";
	    return 0;
	}
	else{
		cout<<"Yes";
		return 0;
	}
	
} 

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){

  int i,j,a,A[N],k,count=0,flag;

  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  flag = 1; // 逆の隣接要素が存在する
  while(flag==1){
    flag = 0;
    for(j=a-1;1<=j;j--){
      if (A[j] < A[j-1]){
	k = A[j];
	A[j] = A[j-1];
	A[j-1] = k;
	flag = 1;
	count++;
      }
    }
  }
  for(k=0;k<a-1;k++)
  printf("%d ",A[k]);
  printf("%d",A[k]);
  printf("\n");
  printf("%d\n",count);
  

 
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
const int nax = 1e4+500;
const ll inf = 1e18+5;
bool isPrime(int n) {
	for(int i= 2;i<=sqrt(n);i++) {
		if(n%i == 0) return false;
	} 
	return true;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin >> n;
	int wgcd = 0;
	vector<int> a(n);
	for(int &i:a) {
		cin >> i;
		wgcd = __gcd(wgcd,i);
	}
	if(wgcd != 1) {
		cout<<"not coprime";
		return 0;
	}
	unordered_map<int,int> mp;
	bool ok = 1;
	for(auto it:a) {
		if(!ok) break;
		if(it == 1) continue;
		if(isPrime(it)) {
			//debug()<<imie(it);
			mp[it]++;
			continue;
		}
		for(int i= 2;i<=sqrt(it);i++) {
			if(it%i ==0) {
				mp[i]++;
				if(it/i != i) mp[it/i]++;
				if(mp[i] >= 2 || mp[it/2] >=2) {
					ok = 0;
					break;
				}
			}
		}
	}
	int maxi = 0;
	for(auto it:mp) {
			if(it.second > maxi) {
				maxi = it.second;
				debug()<<imie(it.first);
			}
			if(maxi >=2) break;
	}
	//debug()<<imie(wgcd) imie(maxi);
	if(wgcd == 1) {
		if(maxi < 2) cout<<"pairwise coprime";
		else cout<<"setwise coprime";
	} else {
		cout<<"not coprime";
	}
}


Measured memory_bytes: 7072
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 3030;
int n , a[N];
vi g[N];

bool dfs(int c,int fa){
  bool win = false;
  for(auto t : g[c]) if(t != fa) {
    win |= a[t] < a[c] && !dfs(t , c);
  }
  return win;
}

int main(){
  cin >> n;
  rep(i,1,n+1) cin >> a[i];
  rep(i,1,n) {
    int u , v;
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  vi ans;
  rep(i,1,n+1) if(dfs(i , 0))
    ans.pb(i);
  rep(i,0,sz(ans)) cout << ans[i] << " \n"[i+1==sz(ans)];
  return 0;
}


Measured memory_bytes: 384
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}
int search(int x) {

	int k = 0;
	int p = 1;
	while (p * 2 <= max_n)
	{
		p *= 2;
	}
	for (int i = p; i > 0; i /= 2)
	{
		if (i + k < max_n && bit[i + k] < x) {
			x -= bit[i + k];
			k += i;
		}
	}
	return k + 1;
}
void solv() {
	
	for (size_t i = 0; i < 50; i++)
	{
		int m, f, r;
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) {
			break;
		}
		int sum = m + f;
		if (m == -1 || f == -1 || sum < 30) {
			cout << "F" << endl;
		}
		else if (sum >= 80) {
			cout << "A" << endl;
		}
		else if (sum >= 65) {
			cout << "B" << endl;
		}
		else if (sum >= 50) {
			cout << "C" << endl;
		}
		else if (r >= 50) {
			cout << "C" << endl;
		}
		else {
			cout << "D" << endl;
		}
	}

}
int main() {
	//	COMinit();
	solv();
	return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

int main(){
	string s;
	cin >> s;
	
	for(int i=0; i<s.size()-8; i++){
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
e = [0] * (n // 2)
o = [0] * (n // 2)
for i in range(n):
    if i % 2 == 0:
        e[i // 2] = v[i]
    else:
        o[(i-1) // 2] = v[i]
ce = Counter(e)
co = Counter(o)

if ce.most_common()[0][0] == co.most_common()[0][0]:
    if len(ce) == 1 and len(co) == 1:
        print(n // 2)
    else:
        print(n-max(ce.most_common()[0][1]+co.most_common()[1][1], ce.most_common()[1][1]+co.most_common()[0][1]))
else:
    print(n-ce.most_common()[0][1]-co.most_common()[0][1])


Measured memory_bytes: 19040
#include<iostream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdlib>
#include <math.h>
#include <algorithm>

using namespace std;


int main(){
  int a[3];
  for (auto&& it : a) {
    cin >> it;
  }
  sort(a,a+3);
  cout << a[0]+a[1]<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include<iomanip>
using namespace std;
typedef long long ll;

int main()
{
    int h, w;
    cin >> h >> w;
    string a[h];
    for (int i = 0; i < h; i ++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < w + 2 ; i ++)
    {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < h; i ++)
    {
        cout << "#" << a[i] << "#" << endl;
    }
    for (int i = 0; i < w + 2 ; i ++)
    {
        cout << "#";
    }
    cout << endl;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
char a[550][550];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
	for(int j=0;j<=n+1;j++)
        for(int o=0;o<=m+1;o++)
            a[j][o]='.';
    for(int j=1;j<=n;j++)
        for(int o=1;o<=m;o++)
            cin>>a[j][o];
    bool OK=true;
    for(int i=1;i<=n;i++)  
    	for(int j=1;j<=m;j++)
    	{
    		if(a[i][j]=='#')
    		{
    			if(a[i-1][j]!='#'&&a[i+1][j]!='#'&&a[i][j-1]!='#'&&a[i][j+1]!='#')
					OK=false;
			}
			if(OK==false)
				break;
		}
    if(OK==true)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------


ll flag=100;
ll a,b;

ll c,d;
ll ans;

string as;

int main(){
    cin>>a>>b;
    if(a==0){
        ans=0;
    }else if(b==0){
        ans=0;
    }else if(a<0 && 0<b){
        ans=0;
    }else if(0<a){
        ans=1;
    }else{
        c=b-a+1;
        ans=1;
        if(c%2==1){ans=-1;}
        
    }



    if(ans==1)as="Positive";
    if(ans==-1)as="Negative";
    if(ans==0)as="Zero";
    cout<<as<<endl;

    


    return 0;
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BFizzBuzzSum {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll n;
	    in >> n;

	    ll sum = 0;
	    for(int i=1; i<=n; i++){
            if(i%3 && i%5) sum += i;
	    }

	    out << sum << endl;
	}
};


int main() {
	BFizzBuzzSum solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int J(int n,int k)
{
	if (n <= 1)return 0;
	return (J(n - 1, k) + k) % n;
}
int main()
{
	int n, k, m;
	while (cin >> n >> k >> m && n != 0 || k != 0 || m != 0)
	{
		long ans = (J(n - 1,k)+ m) % n + 1;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1468
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  string s;cin>>s;
  cout<<(s[1]=='B'?"ARC":"ABC")<<endl;
}


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

using namespace std;

int main()
{
  string a,b,c;

  cin >> a >> b >> c;

  cout << ((a.at(a.length()-1)==b.at(0) && (b.at(b.length()-1)==c.at(0))) ? "YES":"NO") << endl;
  
  return 0;
}


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

int main(){ // 任意のnについて[n,2n]に素数の存在が保証されていることを利用
  const int Nmax= 2* 100000;
  const int Nbit= Nmax+ 1;

  int X;
  cin >> X;

  //// -素数判定
  bitset<Nbit> bits;
  bits.set(); bits.reset(0); bits.reset(1);
 
  int div= 2;
  while( div*div <= Nmax ){
    if( bits.test(div) ){
      for(int i=2*div; i<=Nmax; i+=div){
        bits.reset(i);
      }
    }
    div++;
  }

  for(int i=X; i<=2*X; i++){
    if(bits.test(i)){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*-----------------------*/
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define endl        "\n"
#define ff          first
#define ss          second
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define CC(x)       for(auto xx: x) cout<<xx<<" ";
#define ee          cout<<"\n";
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int,int>
#define mp          make_pair
#define all(x)      x.begin(),x.end()
#define ps(x)       push(x)
#define psb(x)      push_back(x)
#define psf(x)      push_front(x)
#define pp          pop()
#define ppb         pop_back()
#define ppf         pop_front()
#define OK          cout<<"Ok"<<"\n";
#define TESTS       ll test;cin>>test;for(ll   tcase=1;tcase<=test;tcase++)
/*------------------------*/
#define MAX int(1e6)
int nc2(int n)
{
    if(n<2) return 0;
    return (n*(n-1))/2;
}

int main()
{
    FAST
    int n,m;
    cin>>n>>m;
    cout<<nc2(n)+nc2(m)<<endl;




    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int A[2005];
int n;
int sum;

int search(int i,int m){
  if(sum < m)return 0;
  if(m == 0)return 1;
  if(i >= n)return 0;
  return search(i+1,m) || search(i+1,m-A[i]);
}


int main(){
  int q,m;
  int i;

  sum = 0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    sum+=A[i];
  }
  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&m);
    if (search(0,m)){
      printf("yes\n");
    }else{
      printf("no\n");
    }

  }
  return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    vector<int>v1(n),v2(m);
    for(int i=0;i<n;i++)
    {
        cin>>v1[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>v2[i];
    }
    int x1=*max_element(v1.begin(),v1.end());
    int y1=*min_element(v2.begin(),v2.end());
    int z=x1+1;
    if(z<=y1&&z<=y&&z>x){
        cout<<"No War\n";
    }
    else
    {
        cout<<"War\n";
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
L n,K;
L cal(L x){
	return x*x*x;
}
int main(){
#ifdef flukehn
	freopen("g.in","r",stdin);
#endif
	
	while(cin>>n>>K){
		L an=cal(n/K);
		if(K%2==0&&n>=K/2){
			an+=cal((n+K/2)/K);
		}
		cout<<an<<endl;
	}
}

Measured memory_bytes: 256
m, n = gets.split.map(&:to_i)
mod = 1_000_000_007

def pow(m, n, mod)
  return 1 if n == 0
  res = pow(((m * m) % mod), (n / 2), mod)
  if n.odd?
    res = res * m % mod
  end
  res
end

puts pow(m, n, mod)


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

#define MAX_N 200000

using namespace std;

typedef long long lint;

const lint sqrInf = 1LL * (1e18);

int n;
int a[MAX_N + 1];

lint cat(int poz)
{
    if(poz < 1 || poz > n)
        return sqrInf;

    lint rez = 0;
    for(int i = 1; i <= n; i ++)
        rez += abs(a[i] - a[poz]);

    return rez;
}

int main()
{
    cin >> n;

    int i;
    for(i = 1; i <= n; i ++)
    {
        cin >> a[i];
        a[i] -= i;
    }

    sort(a + 1, a + n + 1);

    cout << min(cat(n >> 1), cat((n + 1) >> 1)) << "\n";

    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<functional>
#include<iomanip>
#include<algorithm>
#include<vector>

using namespace std;
using ll = long long;

#define rep(i,n) for(int i = 0; i <(n); ++i)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

int main(){
  int y,m,d; char aaa,bbb;
  cin >> y >> aaa >> m >> bbb >> d;
  if(y > 2019 || (y == 2019 && m > 4) || (y == 2019 && m == 4 && d > 30))
    cout << "TBD" << endl;
  else
    cout << "Heisei" << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

N,M = map(int,input().split())
# edge[i]: 頂点iの出力辺の行き先
edge = [[] for i in range(N)]

#ins[i]: 頂点iの入力辺の数
ins = [0] * N
for i in range(M):
    x,y = map(int,input().split())
    edge[x-1].append(y-1)
    ins[y-1] += 1

# 入力辺を持たないノードのリスト
outs = deque([V for V in range(N) if ins[V] == 0])

# dp[i]: 頂点iを終点とする最長のパスの長さ
dp = [0] * N

# DFS的にトポロジカルソートしながらDPする
while outs:
    i = outs.pop()
    # 頂点iの行き先である頂点jについて
    # dp[j] = max(dp[j], dp[i]+1)
    for j in edge[i]:
        ins[j] -= 1
        if ins[j] == 0:
            outs.append(j)
        dp[j] = max(dp[j], dp[i]+1)

print(max(dp))

Measured memory_bytes: 55600
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int dp[MAX_N][62];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> x(n),y(n-1);
    rep(i,n){
        cin >> x[i];
    }
    rep(i,n-1){
        y[i] = x[i+1] - x[i];
    }
    vector<int> vec(n-1);
    rep(i,n-1){
        vec[i] = i;
    }
    int m;
    ll K;
    cin >> m >> K;
    rep(i,m){
        int a;
        cin >> a;
        swap(vec[a-2],vec[a-1]);
    }
    rep(i,n-1){
        dp[i][0] = vec[i];
    }
    rep(i,60){
        rep(j,n-1){
            dp[j][i+1] = dp[dp[j][i]][i];
        }
    }
    rep(i,n-1){
        vec[i] = i;
    }
    vector<int> tmp(n-1);
    rep(keta,60){
        if(K & (1LL<<keta)){
            rep(i,n-1){
                tmp[i] = dp[vec[i]][keta];
            }
            rep(i,n-1){
                vec[i] = tmp[i];
            }
        }
    }
    cout << x[0] << "\n";
    rep(i,n-1){
        x[i+1] = x[i]+y[vec[i]];
        cout << x[i+1] << "\n";
    }
    return 0;
}


Measured memory_bytes: 27904
n = gets.strip.to_i
a = gets.strip.split.map(&:to_i)

rui=[]
ruiura=[]

rui[0]=a[0]
(0..n-2).each do |i|
	rui[i+1]=rui[i].gcd(a[i+1])
end

ruiura[n-1]=a[n-1]
(0..n-2).reverse_each do |i|
	ruiura[i]=ruiura[i+1].gcd(a[i])
end

maxval=0
(0..n-1).each do |i|
	ruiindex=i-1
	ruiuraindex=i+1
	if ruiindex<0
		ruival=a[n-1]
	else
		ruival=rui[ruiindex]
	end

	if ruiuraindex>n-1
		ruiuraval=a[0]
	else
		ruiuraval=ruiura[ruiuraindex]
	end

	tmp=ruival.gcd(ruiuraval)
	if maxval<tmp
		maxval=tmp
	end
end

puts maxval


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

int main(){
    
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for(int i = 0; i < N; i++)
        std::cin >> A[i];
    std::sort(A.begin(), A.end());
    for(int i = 0; i < N; i++)
        if(A[i] == A[i+1]) {
            std::cout << "NO" << std::endl;
            return 0;
        }

    std::cout << "YES" << std::endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vl acc(n, 0);
    acc[0] = a[0];
    for (int i = 1; i < n; ++i) {
        acc[i] = acc[i - 1] + a[i];
    }
    ll ret = INF;
    for (int i = 2; i < n - 1; ++i) {
        ll lsum = acc[i - 1];
        ll rsum = acc[n - 1] - acc[i - 1];
        int lm  = upper_bound(acc.begin(), acc.end(), lsum / 2) - acc.begin();
        int rm  = upper_bound(acc.begin(), acc.end(), lsum + rsum / 2) - acc.begin();
        for (int j = max(0, lm - 1); j <= min(i - 1, lm + 1); ++j) {
            for (int k = max(i, rm - 1); k <= min(n - 1, rm + 1); ++k) {
                ll llsum = acc[j];
                ll lrsum = lsum - llsum;
                ll rlsum = acc[k] - lsum;
                ll rrsum = acc[n - 1] - rlsum - lsum;
                ll maxi  = max({llsum, lrsum, rlsum, rrsum});
                ll mini  = min({llsum, lrsum, rlsum, rrsum});
                chmin(ret, maxi - mini);
            }
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3328
import collections
a=int(input())
b=list(map(int,input().split()))

c=collections.Counter(b)
n,m=zip(*c.most_common())
n,m=list(n),list(m)
o=c.most_common()

result=[0]*a
for i in range(len(o)):
    result[o[i][0]-1]=o[i][1]

for i in result:
    print(i)

Measured memory_bytes: 57088
N, M = map(int, input().split())
S = [-1] * N
for _ in range(M):
  s, c = map(int, input().split())
  if S[s-1] != -1 and S[s-1] != c:
    print (-1)
    break
  else:
    S[s-1] = c
else:
  if S[0] == 0 and len(S) > 1:
    print (-1)
  else:
    if S[0] == -1:
      if len(S) > 1:S[0] = 1
      else: S[0] = 0
    for i in range(N):
      print (S[i] if S[i] != -1 else 0, end="")

Measured memory_bytes: 3064
fn calc(mut x: i32) -> i32 {
    let mut s = 0;
    while x > 0 {
        s += x % 10;
        x /= 10;
    }
    s
}
fn main() {
    let (n, a, b): (i32, i32, i32) = readln();
    let mut ans = 0;
    for x in 1..n + 1 {
        let c = calc(x);
        if a <= c && c <= b {
            ans += x;
        }
    }
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
from collections import deque
import sys
input = sys.stdin.readline


class DoublyLinkedList:
    def __init__(self):
        self.doubly_linked_list = deque()

    def insert(self, item):
        self.doubly_linked_list.appendleft(item)

    def delete(self, item):
        if item in self.doubly_linked_list:
            self.doubly_linked_list.remove(item)

    def delete_first(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.popleft()

    def delete_last(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.pop()


doubly_linked_list = DoublyLinkedList()


def command_controller(command, n):
    global doubly_linked_list

    if command == 'insert':
        doubly_linked_list.insert(n)
    if command == 'deleteFirst':
        doubly_linked_list.delete_first()
    if command == 'deleteLast':
        doubly_linked_list.delete_last()
    if command == 'delete':
        doubly_linked_list.delete(n)


n = int(input())
for _ in range(n):
    command = list(input().split())
    command_controller(command[0], command[-1])
print(*doubly_linked_list.doubly_linked_list)



Measured memory_bytes: 69784
#include <iostream>
//#include <fstream>

using namespace std;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    int A, B;
    cin >> A >> B;
    
    if (A>B)
    {
        cout << 2*A - 1 << endl;
    }
    else if (B>A)
    {
        cout << 2*B - 1 << endl;
    }
    else if (A==B)
    {
        cout << A+B << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

A,B,C = map(int,input().split())
K = int(input())

# A=red,B=green,C=blue
# B > A, C > B
def dfs(i,a,b,c):
  if i==K:
    if b>a and c>b:
      return True
    else:
      return False

  for j in range(3):
    if j==0:
      if dfs(i+1,2*a,b,c):
        return True
    elif j==1:
      if dfs(i+1,a,2*b,c):
        return True
    else:
      if dfs(i+1,a,b,2*c):
        return True

  return False

if dfs(0,A,B,C):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 62180
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        aaa = i % 2  # iが偶数なら0。奇数なら1。
        for j in range(W):
            if j % 2 == aaa:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()


Measured memory_bytes: 7000
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#include<cctype>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
	int n, m, c;
	cin >> n >> m >> c;
	int b[30];
	rep(i, m)cin >> b[i];
	int a[30][30];
	rep(i, n) {
		rep(j, m) {
			cin >> a[i][j];
		}
	}
	int cnt = 0;
	rep(i, n) {
		int sum = c;
		rep(j, m) {
			sum += a[i][j] * b[j];
		}
		if (sum > 0)cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

int main()
{
  int a;
  cin >> a;
  if (a == 25 ) cout << "Christmas" << endl;
  else if (a == 24) cout << "Christmas Eve" << endl;
  else if (a == 23) cout << "Christmas Eve Eve" << endl;
  
else if (a == 22) cout << "Christmas Eve Eve Eve" << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
int n;
cin >>n;
int a[n];
for(int i=0;i<n;i++){
  cin >>a[i];
}
for(int i=n-1;i>=0;i--){
  cout <<a[i];
  if(i!=0){
    cout <<" ";
  }
}
cout <<endl;
return 0;
}

Measured memory_bytes: 3024
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),k=sc.nextInt();
    int count=0;
    boolean flg[]=new boolean[n];
    for(int i=0;i<k;i++){
      int d = sc.nextInt();
      for(int j=0;j<d;j++){
        flg[sc.nextInt()-1] = true;
      }
    }
    for(int i=0;i<n;i++){
      if(!flg[i]){count++;}
    }
    pl(count+"");
  }

  public static int aa(int n){
    if(n>0){return 1;}
    return 0;
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Measured memory_bytes: 47372
#include<bits/stdc++.h>
using namespace std;
#define N 1111116

int n;
vector<long long> a,b;
long long cnt,ans;
char opt='+';

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

int main(){
	n=read();a.push_back(0);b.push_back(0);
	for (int i=1;i<=n;i++){
		if (i!=1) scanf(" %c",&opt);
		int x=read();cnt+=x;
		if (opt=='+') b.back()+=x;
		else a.push_back(x),b.push_back(0);
	}
	for (int i=1;i<(int) a.size();i++){
		ans=max(ans,cnt-2*(a[i]+b[i]));
		cnt-=2*a[i];
	}
	printf("%lld\n",max(ans,cnt));
	return 0;
}

Measured memory_bytes: 2036
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var s = Console.ReadLine();
        int k = int.Parse(Console.ReadLine());
        var subsList = new List<string>();
        var charList = new List<char>();
        for (int i = 0; i < s.Length; i++) charList.Add(s[i]);
        charList = charList.Distinct().OrderBy(c => c).ToList();

        for (int x = 0; x < charList.Count(); x++)
        {
            subsList.Add(charList[x].ToString());
            if (subsList.Count > k) break;
            for (int i = 1; i <= 4; i++)
                for (int j = 0; j < s.Length - i; j++)
                    if (s[j] == charList[x]) subsList.Add(s.Substring(j, i + 1));
            subsList = subsList.Distinct().ToList();
        }
        Console.WriteLine(subsList.OrderBy(x => x).Where((x, y) => y == k - 1).First());
    }
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> v(3 * N);
    for (int i = 0; i < 3 * N; i++)
    {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    long long int ans = 0;
    for (int i = 1; i < 2 * N; i += 2)
    {
        ans += v.at(i);
    }
    cout << ans;
}


Measured memory_bytes: 4628
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}

int main(){
  ll n,x;
  cin>>n>>x;
  vector<ll> d(n);
  rep(i,n){
    cin>>d[i];
    d[i] = abs(x - d[i]);
  }

  ll ans = d[0];
  
  rep(i,d.size()){
    if(i == 0)continue;
    ans = gcd(ans,d[i]);
  }
  ans = abs(ans);
  print(ans)
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

/**
 * A
 */
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int array[] = new int[n];

        for(int i=0; i<n; i++) {
            
            array[i] = sc.nextInt();
            System.out.print(array[i]);
            
            if(i<array.length-1) {
                System.out.print(" ");
                
            }
            
        }

        System.out.println();

        sc.close();

        for(int i=1; i<array.length; i++) {
            
            int key = array[i];
            /* insert A[i] into the sorted sequence A[0,...,j-1] */
            int j = i-1;
            while(j>=0 && array[j]>key) {
                array[j+1] = array[j];
                j--;
            }
            array[j+1] = key;

            for(int num=0; num<array.length; num++) {
                System.out.print(array[num]);
                if(num != array.length-1) {
                    System.out.print(" ");
                } else {
                System.out.println();
            }
        }
    }

    }
}


Measured memory_bytes: 32980
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

class UnionFind {
    private:
        ll node_num;
        vector<ll> parent;
        vector<ll> node_rank;
        vector<ll> sizes;
    public:
        UnionFind(ll n) {
            node_num = n;
            parent.resize(node_num);
            node_rank.resize(node_num);
            sizes.resize(node_num);
        }
        void init() {
            for (ll i = 0; i < node_num; i++) {
                parent[i] = i;
                node_rank[i] = 0;
                sizes[i] = 1;
            }
        }
        ll root(ll u) {
            return parent[u] == u ? u : parent[u] = root(parent[u]);
        }
        bool same(ll u, ll v) {
            return root(u) == root(v);
        }
        void unite(ll u, ll v) {
            u = root(u);
            v = root(v);
            if (u == v) return;
            if (node_rank[u] < node_rank[v]) {
                parent[u] = v;
                sizes[v] += sizes[u];
            }
            else {
                parent[v] = u;
                sizes[u] += sizes[v];
                if (node_rank[u] == node_rank[v]) {
                    node_rank[u]++;
                }
            }
        }
        ll get_size(ll u) {
            return sizes[root(u)];
        }
};

int main() {
    // This sample usage is Atcoder Beginners Contest 120 D
    ll N, M;
    cin >> N >> M;
    UnionFind UF(N);
    UF.init();
    vector<ll> A(M), B(M);
    for (ll i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }
    ll now_sizes = N * (N - 1) / 2;
    vector<ll> ans;
    for (ll i = M - 1; i >= 0; i--) {
        ans.push_back(now_sizes);
        if (UF.same(A[i], B[i])) {
            continue;
        }
        else {
            now_sizes -= UF.get_size(A[i]) * UF.get_size(B[i]);
            UF.unite(A[i], B[i]);
        }
    }
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6132
#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 mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int x;
  cin>>x;
  cout<<x*360/__gcd(x,360)/x<<endl;
  return 0;  
}


Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
        int count = 0;
        for(int i=0;i<a.Length;i++){
            if(a[i] == '1'){
                count++;
            }
        }
        WriteLine(count);
    }
}

Measured memory_bytes: 13140
import bisect
 
N = int(input())
L = list(map(int,input().split()))
L.sort()
 
count = 0
# aとbを固定
for a in range(N-2):
    for b in range(a+1,N-1):
        aADDb = L[a] + L[b]
        maxL = bisect.bisect_left(L,aADDb)
        # cの範囲は、[b+1,maxL)
        count += max(0,maxL-(b+1))
 
print(count)

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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if( 0 <= x-r and x+r <= W and 0 <= y-r and y+r <= H)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3036