akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;
#define X first
#define Y second

void go() {
	int n;
	cin >> n;
	int t0,x0,y0;
	t0 = x0 = y0 = 0;
	for(int i = 0; i < n; i++) {
		int t, x, y;
		cin >> t >> x >> y;
		int dt = t-t0;
		int d = abs(x-x0)+abs(y-y0);
		// cout << dt << " " << d << endl;
		if(d>dt || (dt-d)%2==1) {
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	// int t; cin >> t; for(;t--;)
	go();
	return 0;
}



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

using namespace std;
typedef long long ll;

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
  
    long double x;
    vector<ll> aa;

    ll Q,N;
    long double a, b;
    string S;
    cin >> Q;
    ll flag=0;
    ll t1=0;
    ll t2=0;
  	ll sum=0;
    ll dig;
    ll Q1=Q;
while(Q){
    dig = Q % 10;
    sum = sum + dig;
    Q = Q / 10;
  }


    if(Q1%sum==0) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
      
    
      
   
    return 0;
}

Measured memory_bytes: 256
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	ll n;
	cin>>n;
	vector<ll> v(n);
    bool zero = false;
	for(ll i=0;i<n;i++)
    {
        cin>>v[i];
        if(v[i]==0)
            zero=true;
    }
    if(zero)
    {
        cout<<"0";
        return 0;
    }
	ll pro = 1;
	ll limit = 1000000000000000000;
	for(ll i=0;i<n;i++)
	{
		if(v[i] <= limit/pro)
			pro *= v[i];
		else
		{
			pro = -1;
			break;
		}
	}
	cout<<pro;
	return 0;
}


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

const ll MOD = 1e9+7;

ll calc(ll a,ll b){//a^(b) mod  
	if(b==0)return 1;
	ll y = calc(a,b/2);y=(y*y)%MOD;
	if(b & 1) y = (y * a) % MOD;
	return y;
}
ll inv(ll a){
	return calc(a,MOD-2);
}

int main(){

	ll N, A, B, C;
	cin >> N >> A >> B >> C;
	ll ANSWER = 0;
	ll DACOR = 100 * inv(100-C) % MOD;
	vector<ll> a(2*N), b(2*N), f(2*N), fr(2*N);

	a[0] = b[0] = f[0] = fr[0] = f[1] = fr[1] = 1;
	a[1] = A * inv(A+B) % MOD;
	b[1] = B * inv(A+B) % MOD;

	for(int i=2;i<2*N;i++){
		a[i] = a[i-1] * a[1] % MOD;
		b[i] = b[i-1] * b[1] % MOD;
		f[i] = f[i-1] * i % MOD;
		fr[i] = inv(f[i]);
	}

	for(int i=N;i<2*N;i++){
		ll pa = a[N] * b[i-N] % MOD * f[i-1] % MOD * fr[N-1] % MOD * fr[i-N] % MOD;
		ll pb = b[N] * a[i-N] % MOD * f[i-1] % MOD * fr[N-1] % MOD * fr[i-N] % MOD;
		( ANSWER += ( pa + pb ) * i % MOD * DACOR % MOD ) %= MOD;
	}

	cout << ANSWER << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
int main(){
	ll ans=INF;
	vector<ll> a(5);
	FOR(i,0,5)cin>>a[i];
	vector<ll> e={0,1,2,3,4};
	do{
		ll p = 0;
		FOR(i,0,5){
			p += a[e[i]];
			if(i!=4)p += (10 - p%10)%10;
		}
		ans = min(ans,p);
	}while(NEXTP(e));
	cout << ans << endl;
}

Measured memory_bytes: 256
/**
 *  Hi, I'm Arpan.
 *
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back
#define popb pop_back()
#define endl "\n"
#define fi first
#define se second
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
#define sortv(v) sort(v.begin(),v.end())
#define rsortv(v) sort(v.begin(),v.end(), greater<>());

ll modPower(ll num,ll r) {
	if(r==0) return 1;
	if(r==1) return num%MOD;
	ll ans=modPower(num,r/2)%MOD;
	if(r%2==0) {
		return (ans*ans)%MOD;
	} return (((ans*ans)%MOD)*num)%MOD;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    if (r > n - r) {
        r = n - r;
    }
    for(int i=0;i<r;i++) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

/*******************************************/
//
void solve()
{
	string s;
	cin >> s;
	int curr = 0;
	int mx = 0;
	for(int i=0;i<3;i++){
		if(s[i] == 'R')curr++;
		else{
			mx = max(curr,mx);
			curr = 0;
		}
	}
	cout << max(curr,mx) << endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;

    while (t--)
        solve();
    return 0;
}




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

int main() {
  int p, w, g, y, n;
  char s;
  p = 0, w = 0, g = 0, y = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == 'P') {
      p = 1;
    }
    else if (s == 'W') {
      w = 1;
    }
    else if (s == 'G') {
      g = 1;
    }
    else if (s == 'Y') {
      y = 1;
    }
  }

  if ((p == 1 && w == 1) && (w == 1 && g == 1) && (g == 1 && y == 1) && (y == 1 && p == 1)) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3580
#include <stdio.h>

int main()
{
	char s[2];
	scanf("%s",s);
	if (s[0]=='A') printf("T\n");
	else if (s[0]=='T') printf("A\n");
	else if (s[0]=='C') printf("G\n");
	else printf("C\n");

	return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#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++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
// index が条件を満たすかどうか
bool isOK(int index, int key , vector<int>& a) {
    if (a[index] == key) return true;
    else return false;
}
// 二分探索
int binary_search(int key, vector<int>& a) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (isOK(mid, key , a)) right = mid;
        else left = mid;
    }
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

int main(){
  string s;
  cin >>s;
  int key=0;
  int ans;
  for(int i=2;i<=s.size();i+=2){
    int a=0;
    rep(j,(s.size()-i)/2){
      if(s[j]!=s[j+(s.size()-i)/2]) a=1;
    }
    if(a==0){
      ans=i;
      break;
    }
  }
      cout <<s.size()-ans<<endl;   
}

Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn          printf("\n")
#define nl          cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup erase(unique(V.begin(),V.end()),V.end())

#define Inf     1000000000000000
#define mod     1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli N,i;
    cin>>N;
    
    if(N<=6)
    {
        cout<<1;
        exit(0);
    }
    
    lli x=ceil(N/5.500);
    
    lli y=x-1;
    
    lli Count=(y/2+y%2)*6+(y/2)*5;
    
    if(Count>=N)
    {
        cout<<y;
        exit(0);
    }
    
    Count=(x/2+x%2)*6+(x/2)*5;
        
    if(Count>=N)
    {
        cout<<x;
        exit(0);
    }
    
    cout<<x+1;
    
    


 return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(int)
N = int(input())
A = sorted(int(i) for i in input().split())
ans = 0
for i in A:
  d[i] += 1
for i,j in d.items():
  if i < j:
    ans += j-i
  elif i > j:
    ans += j
print(ans)

Measured memory_bytes: 18672
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main{

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int[] ps = new int[100000];
	void prime() {
		boolean[] p = new boolean[1500000];
		int index = 0;
		for(int i=2;i<=1299709;i++)if(!p[i]) {
			ps[index++] = i;
			for(int j=i*2;j<=1299709;j+=i) p[j] = true;
		}
	}
	
	int binSearch(int x) {
		int l = 0, r = 100000;
		for(;l < r;) {
			int c = (l+r) / 2;
			if(x == ps[c]) return c;
			else if( x < ps[c] ) r = c;
			else if( x > ps[c] ) l = c+1;
		}
		return l;
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		prime();
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			int id = binSearch(n);
			if(ps[id] == n) System.out.println(0);
			else System.out.println(ps[id] - ps[id-1]);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == '?')
            S.replace(i, 1, "D");
    }
    cout << S;
}

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

int n, k, a[55];
long long memo[55][55][2555];

long long solve(int id, int taken, int sum) {
	if (id == n) {
		if (sum != 0 && taken != 0 && sum == k * taken) return 1;
		else return 0;
	}

	if (memo[id][taken][sum] != -1) return memo[id][taken][sum];

	long long res = solve(id + 1, taken, sum) + solve(id + 1, taken + 1, sum + a[id]);
	return memo[id][taken][sum] = res;
}

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	memset(memo, -1, sizeof(memo));
	long long ans = solve(0, 0, 0);

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 60672
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(s: String);

    let vs: Vec<char> = s.chars().collect();

    let s_f: usize = format!("{}{}", vs[0], vs[1]).parse().unwrap();
    let s_b: usize = format!("{}{}", vs[2], vs[3]).parse().unwrap();

    let is_month_b = !(s_b > 12 || s_b == 0);
    let is_month_f = !(s_f > 12 || s_f == 0);

    let ans = if is_month_b && is_month_f {
        "AMBIGUOUS"
    } else if is_month_b {
        "YYMM"
    } else if is_month_f {
        "MMYY"
    } else {
        "NA"
    };

    println!("{}", ans);
}


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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

ll f(ll x)
{

  if (x == 1)
    return 1LL;

  else
    return 2LL * f(x / 2LL) + 1LL;
}

int main(void)
{
  ll h;
  cin >> h;

  cout << f(h) << endl;

  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	while (1) {
		int n;
		cin>>n;
		if(n == 0)break;
		int dice[3] = {1,2,3};
		int before[3] = {1,2,3};
		int sum = 1;
		for (int i = 0; i < n; i++) {
			string verb;
			cin>>verb;
			if (verb == "North") {
				dice[0] = before[1];
				dice[1] = 7-before[0];
			} else if (verb == "East") {
				dice[0] = 7-before[2];
				dice[2] = before[0];
			} else if (verb == "West") {
				dice[0] = before[2];
				dice[2] = 7-before[0];
			} else if (verb == "South") {
				dice[0] = 7-before[1];
				dice[1] = before[0];
			} else if (verb == "Right") {
				dice[1] = before[2];
				dice[2] = 7-before[1];
			} else if (verb == "Left") {
				dice[1] = 7-before[2];
				dice[2] = before[1];
			}
			for (int j = 0; j < 3; j++) {
				before[j] = dice[j];
			}
			sum += dice[0];
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//大きい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return bNum - aNum;}

int main(void){
    int N,K;
    int min=1000000000;
    scanf("%d%d",&N,&K);
    int vl[N];
    for(int i=0;i<N;i++){
        scanf("%d",&vl[i]);
    }
    qsort(vl,N,sizeof(int),compareInt);
    for(int i=0;i+K<=N;i++){
        if((vl[i]-vl[i+K-1])<min){
            min=vl[i]-vl[i+K-1];
        }
    }
    printf("%d",min);
    return 0;
}


Measured memory_bytes: 892
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math
from functools import lru_cache

# prime_200 = {
#     2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
#     73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
#     179, 181, 191, 193, 197, 199
# }

@lru_cache(maxsize=None)
def get_gcd(a, b):
    return math.gcd(a, b)


def main():
    k = int(input().strip())
    sum = 0

    # すべて同じ(a, a, a)
    sum += k * (k + 1) // 2

    # 2 つ同じ（a, a, b）
    for a in range(1, k + 1):
        # if a in prime_200:
        #     sum += 3 * (k - 1)  # 自分と同じを除く分 * 3c1
        #     continue
        for b in range(1, k + 1):
            if a == b:
                continue  # 同じは除く
            # if b in prime_200:
            #     sum += 3  # b が素数なら gcd は 1 * 3c1
            #     continue
            a_, b_ = (a, b) if a < b else (b, a)
            sum += 3 * get_gcd(a_, b_)

    # 3 つ違う (a, b, c)
    for a in range(1, k + 1):
        for b in range(a + 1, k + 1):
            if a == b:
                continue
            a_b_ = get_gcd(a, b)
            for c in range(b + 1, k + 1):
                if a == c or b == c:
                    continue
                sum += 6 * get_gcd(a_b_, c)
    print(sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11316
#include <cstdio>
#include <algorithm>
#define N 4006
#define mo 924844033
using namespace std;
int n,k,t,ans,v[N][2],a[N],g[N],fac[N],f[N][N][2];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		for(int j=0;j<=1;j++)if(!v[i][j]){
			int len=0;
			for(int x=i,y=j;x<=n;x+=k,y^=1)++len,v[x][y]=1;
			a[t+=len]=1;
		}
	f[0][0][1]=1;
	for(int i=0;i<=t;i++)
		for(int j=0;j<=n;j++){
			f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mo;
			if(!a[i])f[i+1][j+1][1]=f[i][j][0];
		}
	for(int i=1;i<=n;i++)g[i]=(f[t][i][0]+f[t][i][1])%mo;
	fac[0]=1;for(int i=1;i<=n;i++)fac[i]=1LL*fac[i-1]*i%mo;ans=fac[n];
	for(int i=1,j=-1;i<=n;i++,j=-j)ans=(ans+1LL*j*g[i]%mo*fac[n-i]%mo+mo)%mo;
	printf("%d\n",ans);
}

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

    int max = Math.max(a, c);
    int min = Math.min(b, d);

	System.out.println(Math.max(0, min-max));
    }
}

Measured memory_bytes: 35356
#include <stdio.h>

int main(void) {
  int i, j, k, w;
  while( scanf("%d", &w) != EOF ) {
    int now = 1, f = 1;
    while(w) {
       if(w % 2) {
         if(f) {
           printf("%d", now);
           f = 0;
         } else printf(" %d", now);
       }
       w /= 2, now *= 2;
    }
    printf("\n");
  }
  return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    string s;
    cin >> s >> k;
    string t = "", tmp;
    vector<string> v;
    for(int i = (int) s.size() - 1; i >= 0; i --) {
        t += s[i];
        tmp = t;
        reverse(tmp.begin(), tmp.end());
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    set<string> st;
    for(int i = 0; i < (int) v.size(); i ++) {
        t = "";
        for(int j = 0; j < (int) v[i].size(); j ++) {
            t += v[i][j];
            st.insert(t);
            if(st.size() == k) {
                cout << t << '\n';
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 13568
#include<stdio.h>

int main(void) {
	int N = 0;long cnt = 0;
	int n[10000] = { 0 };
	int max = -10000000, min = 10000000;
	scanf("%d",&N);
	for (int i = 0; i < N; i++) {
		scanf("%d",&n[i]);
		if (max < n[i]) {
			max = n[i];
		}
		if (min > n[i]) {
			min = n[i];
		}
		cnt += n[i];
	}
	printf("%d %d %ld\n",min,max,cnt);
	return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>

int t1,t2;

int n;
int off[20005];

int main()
{
    scanf("%d",&n);
    for (int i=1; i<=n; i++) {
        scanf("%d",&t1);
        off[t1]=i;
    }
    for (int i=1; i<=n; i++) {
        printf("%d ",i*20005+off[i]);
    }
    printf("\n");
    for (int i=1; i<=n; i++) {
        printf("%d ",(n-i+1)*20005);
    }
    printf("\n");
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <unordered_set>
#include <map>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

struct V {
	int a, b;
	int color;
};

struct Tree {
	map<int, Tree*> connect;
	map<int, int*> color;
	unordered_set<int> mp;
};

int main() {
	int n;
	cin >> n;
	vector<V> v(n - 1);

	rep(i, n - 1) {
		cin >> v[i].a >> v[i].b;
		v[i].a--;
		v[i].b--;
		v[i].color = 0;
	}
	vector<Tree> tree(n);
	rep(i, n - 1) {
		tree[v[i].a].connect[i] = &tree[v[i].b];
		tree[v[i].a].color[i] = &v[i].color;

		tree[v[i].b].connect[i] = &tree[v[i].a];
		tree[v[i].b].color[i] = &v[i].color;
	}
	int colormax = 1;
	rep(i, n) {
		int color = 1;
		for (auto bgn = tree[i].connect.begin(); bgn != tree[i].connect.end(); bgn++) {
			if (*tree[i].color[bgn->first] != 0) continue;
			while (!tree[i].mp.insert(color).second || !bgn->second->mp.insert(color).second) color++;
			*tree[i].color[bgn->first] = color;
			colormax = max(colormax, color);
		}
	}
	cout << colormax << endl;
	rep(i, n - 1) {
		cout << v[i].color << endl;
	}

}

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

using namespace std;

int main() {
    string s; cin >> s;
    int n = s.size();
    vector <int> ans(n, 0);

    int r = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == 'R' and s[i + 1] == 'L') {
            ans[i]++, ans[i + 1]++;
            
            int ex = r / 2;
            ans[i] += ex;
            ans[i + 1] += (r - ex);

            int l = 0;
            for (int j = i + 2; j < n; j++) {
                if (s[j] != 'L') break;
                l++;
            }

            ex = l / 2;
            ans[i + 1] += ex;
            ans[i] += (l - ex);

            r = 0;
            i += l + 1;
        } else {
            if (s[i] == 'R') r++;
            if (s[i] == 'L') r = 0;
        }
    }

    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 3872
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  int arm[5];
  while(cin>>arm[0]&&arm[0]){
    bool d[3];
    memset(d,false,sizeof(d));
    arm[0]--;
    d[arm[0]]=true;
    for(int i=1;i<5;i++){
      cin>>arm[i];
      arm[i]--;
      d[arm[i]]=true;
    }
    int cnt=0;
    for(int i=0;i<3;i++){
      if(d[i])cnt++;
    }
    if(cnt!=2){
      for(int i=0;i<5;i++){
        cout<<3<<endl;
      }
    }else{
      int win,lose;
      if(d[0]&&d[1]){
        win=0;lose=1;
      }else if(d[1]&&d[2]){
        win=1;lose=2;
      }else if(d[2]&&d[0]){
        win=2;lose=0;
      }
      for(int i=0;i<5;i++){
        if(arm[i]==win)cout<<1<<endl;
        else cout<<2<<endl;
      }
    }
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int a;
    cin >> a;
    if(a == 1) cout << 0 << endl;
    else cout << 1 << endl;
return 0;
}

Measured memory_bytes: 3632
# わからんだろこれ 降順ソート*昇順ソートからの発想が浮かばず
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())), reverse=True)
l, r = -1, 10**12 + 1  # ちゃんと「取りうることがないもののうち最大値」「取りうることのない最小値」でやる.....

while r - l > 1:
    mid = (r + l) // 2  # 最大値これをめざす
    cur = 0
    for i in range(n):
        if a[i] * b[i] <= mid:
            # Kを使う必要がない
            pass
        else:
            # Kからどんくらい使うか これむずくない？
            cur += a[i] - mid // b[i]
        if cur > k:
            l = mid
            break
        # cur += max(0, a[i] - mid // b[i])
        # if cur > k:
        #     break
    if cur > k:
        l = mid
    else:
        r = mid
print(r)

Measured memory_bytes: 121036
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int n,A,B,C,ans = 1e5;
vector<int> l(8);

int count(int x, int a, int b, int c){
    if(x == n){
        if(min({a, b, c}) > 0){
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        }else{
            return 1e5;
        }
    }
    int cnt0 = count(x + 1,a,b,c);
    int cnt1 = count(x + 1,a + l[x],b,c) + 10;
    int cnt2 = count(x + 1,a,b + l[x],c) + 10;
    int cnt3 = count(x + 1,a,b,c + l[x]) + 10;
    return min(min(cnt0,cnt1),min(cnt2,cnt3));
}

int main()
{
    cin >> n >> A >> B >> C;
    rep0(i, n)cin >> l[i];
    ans = count(0,0,0,0);
    pf(ans)
    return 0;
}


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

int score[100], ranking[100], check1[100], check2[100];

int main()
{
    int n; cin >> n;
    int len = n*(n-1)/2;

    for(int i=0;i < len;++i) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        if (c > d) score[a-1] += 3;
        else if (d > c) score[b-1] += 3;
        else ++score[a-1], ++score[b-1];
    }

    for(int i=0;i < n;++i) ranking[i] = score[i];

    sort(ranking, ranking+n, greater<int>());

    for(int i=0;i < n;++i) {
        for(int j=0;j < n;++j) {
            if (check1[i]) break;
            if (score[i] == ranking[j]) {
                if (ranking[j] == check2[j]) {
                    score[i] = j+1;
                    check1[i] = 1;
                    continue;
                }
                if (!check2[j]) score[i] = j+1;
                check1[i] = 1, check2[j] = ranking[j];
            }
        } 
    }

    for(int i=0;i < n;++i) printf("%d\n", score[i]);

}

Measured memory_bytes: 1160
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int h, w, n;
  cin >> h >> w >> n;
  int m = max(h, w);
  cout << (n + m - 1) / m << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3604
using System;

class Program
{
  static void Main()
  {
    var line = Console.ReadLine();
    var _line = line.Split(" ");
    string _str = null;
    for (int i = 0; i< 5; i++)
    {
      _str += _line[i];
    }
    int num = _str.IndexOf("0", 0, 5) + 1;
    Console.WriteLine(num);
  }
}

Measured memory_bytes: 26052
import heapq
 
L1 = input().split(" ")
L2 = input().split(" ")
tickets = int(L1[1])
L2int = [-int(s) for s in L2]
 
heapq.heapify(L2int)
 
for t in range(tickets):
    heapq.heappush(L2int,-(-heapq.heappop(L2int)//2))
print(-sum(L2int))

Measured memory_bytes: 72020
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1 << 25;

int main() {
  int N, K;
  while (cin >> N >> K) {
    vector<vector<int>> G(N), rG(N);
    for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      --a;
      G[i].push_back(a);
      rG[a].push_back(i);
    }
    vector<int> dist(N, INF);
    dist[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int u : rG[v]) {
        if (dist[v] + 1 < dist[u]) {
          dist[u] = dist[v] + 1;
          q.push(u);
        }
      }
    }
    auto comp = [&](int a, int b) {
      if (dist[a] != dist[b]) {
        return dist[a] > dist[b];
      }
      return a > b;
    };
    set<int, function<bool(int, int)>> S(comp);
    for (int i = 1; i < N; i++) {
      S.insert(i);
    }
    int res = 0;
    if (G[0][0] != 0) {
      ++res;
    }
    while (!S.empty() && dist[*S.begin()] > K) {
      int v = *S.begin();
      for (int i = 0; i < K - 1; i++) {
        v = G[v][0];
      }
      queue<int> q;
      q.push(v);
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        S.erase(v);
        for (int u : rG[v]) {
          if (S.count(u)) {
            q.push(u);
          }
        }
      }
      ++res;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 16256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 
class dsu{
    public:
    unordered_map<int,int> p,sz;
    void make_set(int x)
    {
        p[x] = x;
        sz[x]+=1;
    }
    int find(int x)
    {
        if(x == p[x])return x;
        return p[x] = find(p[x]);
    }
    void merge(int a,int b)
    {
        a = find(a);
        b = find(b);
        if(a == b)return;
        if(sz[a]<sz[b])swap(a,b);
        p[b] = a;
        sz[a]+=sz[b];
        sz.erase(b);
    }
};
template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = (res*a);
        b>>=1;
        a*=a;
    }
    return res;
}


int kmp(string s){
    vector<int> lps(s.size(),0);
    for(int i = 1; i<lps.size(); ++i){
        int prev_index = lps[i-1];
        while(prev_index>0&&s[i]!=s[prev_index]){
            prev_index = lps[prev_index-1];
        }
        lps[i] = prev_index+(s[i] == s[prev_index]?1:0);
    }
    return lps[lps.size()-1];
}

int main()
{
    fastio();
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    int sum = 0;
    fori(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    int the = ceil(sum/(4*m*1.0));
    int count = 0;
    fori(i,0,n){
        if(a[i]>=the)count+=1;
    }
    if(count>=m)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
import sys,queue,math as np
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
LI = lambda : [int(x) for x in input().split()]

N,Q = LI()
g = [i for i in range(N)]

def root(x):
    if x == g[x] : return x
    g[x] = root(g[x])
    return g[x]

for _ in range(Q):
    c,x,y = LI()
    if c == 0:
        g[root(x)] = root(y)
    else:
        print (int(root(x) == root(y)))


Measured memory_bytes: 14500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


public class Hello{

    public static void Main(){
        // Your code here!
        int X = int.Parse(Console.ReadLine());
        int N = int.Parse(Console.ReadLine());
        
        int a = X%500;
        
        if(a <= N){
            System.Console.WriteLine("Yes");
        }else{
            System.Console.WriteLine("No");
        }
        

        
    }
}


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

int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	a[0] = toupper(a[0]);
	b[0] = toupper(b[0]);
	c[0] = toupper(c[0]);
	cout << a[0] << b[0] << c[0] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		// ret
		int rad = a * b;
		int syu = (a + b) * 2;
		System.out.println(rad + " " + syu);
	}
}

Measured memory_bytes: 17352
package main

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

func main() {
	N := ReadInt()
	fmt.Println(f(N))
}

var memo = make([]int, 87)

func f(i int) int {
	if i == 0 {
		return 2
	}
	if i == 1 {
		return 1
	}
	if memo[i] > 0 {
		return memo[i]
	}
	memo[i] = f(i-1) + f(i-2)
	return memo[i]
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1860
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    println(problem114a(x))
}

fun problem114a(x: Int): String {
    return when (x) {
        3,5,7 -> "YES"
        else -> "NO"
    }
}

Measured memory_bytes: 31264
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define n 200004
typedef long long ll;


void main(void)
{
  
  ll N=0,ans=0;
  //scanf("%d",&N);
  char str[n];
  scanf("%s",str);
  ll i=0;
  while(str[i]!='\0'){
    i++;
    N++;
  }
  ll str_int[N+1],tmp=0,tmp1=1;
  //str_int[0]=atol(str);
  for(ll j=1;j<=N;j++){
    str_int[j]=str[j-1]-'0';
  }
  
  tmp=0;
  ll mod[2019]={0};;
  for(ll k=0;k<=(N-1);k++){
    tmp+=tmp1*str_int[N-k];
    tmp=tmp%2019;
    tmp1=(tmp1*10)%2019;
    mod[tmp]++;
  }
  mod[0]++;
  for(ll k=0;k<=2018;k++){
    ans+=mod[k]*(mod[k]-1)/2;
  }
        
  printf("%lld",ans);
}

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

struct UnionFind {
  vector<int> par; //親の番号
  UnionFind(int n) : par(n, -1) { }
  int find(int x){ //親の番号を求める
    if(par[x] < 0) return x; //負なら親
    return find(par[x]); //xの親を参照
  }
  bool unite(int x, int y){
    int px = find(x); //xの親
    int py = find(y); //yの親
    if( px == py) return false; //すでに繋がっている
    if(par[px] > par[py]) swap(px, py); //xの方が小さくしたい
    par[px] += par[py];
    par[py] = px;
    return true;
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
  int size(int x){
    return -par[find(x)];
  }
};

int main(){
  int N, K, L;
  cin >> N >> K >> L;
  UnionFind way(N);
  UnionFind rail(N);
  int p, q;
  rep(i, K){
    cin >> p >> q;
    p--; q--;
    way.unite(p, q);
  }
  rep(i, L){
    cin >> p >> q;
    p--; q--;
    rail.unite(p, q);
  }
  map<P, int> cnt;
  rep(i, N){
    cnt[P(way.find(i), rail.find(i))]++;
  }
  rep(i, N){
    cout << cnt[P(way.find(i), rail.find(i))] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 13568
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Read();
            for (int i = 0; i < N.Length; i++)
            {
                if (N[i] == '7')
                {
                    WriteLine("Yes");
                    return;
                }
            }
            WriteLine("No");
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

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

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

int main(){
  int N;
  cin >> N;
  double K=0;
  vector<int> X(N),Y(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i) >> Y.at(i);
  }
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      int X2=X.at(i)-X.at(j);
      int Y2=Y.at(i)-Y.at(j);
      K+=sqrt(X2*X2+Y2*Y2);
    }
  }
  cout << fixed << setprecision(10) << 2*K/N << endl;
}
      
      
    

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int N, K;
	cin >> N >> K;

	vector<int>A(N);

	REP(i, N) cin >> A[i];

	vector<int>freq(N, 0);

	for (int i = 0; i < N; i++) {
		freq[--A[i]]++;
	}

	//REP(i, N) cout << freq[i] << " ";

	sort(freq.begin(), freq.end(), greater<int>());

	int ans = 0;
	for (int i = K; i < N; i++) {
		ans += freq[i];
	}

	cout << ans << endl;


	return 0;

}

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

int main()
{
	int N;
	cin >> N;
	vector<string> S( N );
	for( int i = 0; i < N; i++ ) {
		cin >> S[i];
	}

	map<string, int> mp;
	for( int i = 0; i < N; i++ ) {
		mp[ S[i] ]++;
	}

	cout << mp.size() << endl;

}


Measured memory_bytes: 25080
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    dd = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

    while True:
        b = [[c for c in S()] for _ in range(8)]
        def g(ps,i,j,di,dj):
            if not (0 <= i < 8) or not (0 <= j < 8):
                return
            if b[i][j] == '.':
                return
            if b[i][j] == ps:
                return 0
            tr = g(ps,i+di,j+dj,di,dj)
            if tr is None:
                return
            return tr + 1

        def ff(ps,i,j,di,dj):
            if not (0 <= i < 8) or not (0 <= j < 8):
                return
            if b[i][j] == '.':
                return
            if b[i][j] == ps:
                return 0
            tr = ff(ps,i+di,j+dj,di,dj)
            if tr is None:
                return
            b[i][j] = ps
            return tr + 1

        def f(pf, pp):
            ps = 'o'
            es = 'x'
            if not pf:
                ps = 'x'
                es = 'o'
            mc = 0
            mij = (0,0)
            for i in range(8):
                for j in range(8):
                    if b[i][j] != '.':
                        continue
                    c = 0
                    for di,dj in dd:
                        tc = g(ps,i+di,j+dj,di,dj)
                        if not tc is None:
                            c += tc
                    if mc < c or (mc == c and not pf):
                        mc = c
                        mij = (i,j)

            if mc > 0:
                i,j = mij
                b[i][j] = ps
                for di,dj in dd:
                    ff(ps,i+di,j+dj,di,dj)
                f(not pf, False)
            elif pp:
                return
            else:
                f(not pf, True)

        f(True, False)

        for i in range(8):
            rr.append(''.join(b[i]))
        break

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9068
numbers = []
n = raw_input()

numbers = n.split(" ")

for i in range(2):
	numbers[i] = int(numbers[i])

if numbers[0] > numbers[1]:
	print "a > b"
elif numbers[0] < numbers[1]:
	print "a < b"
elif numbers[0] == numbers[1]:
		print "a == b"

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

using namespace std;

int main(){
  long long n;
  cin>> n;
  long long ans = 0;

  for(long long i = 1; i*i <= n; i++) {
    long long q = n / i;
    ans += i * q * (q + 1) / 2;
    if (i ^ q) {
      long long p = n/(i+1);

      long long k = i * (i + 1) * (q - p) * (p + q + 1) / 4;

      ans += k;
    }
  }
  cout<< ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
int32_t main(){
    int a,b,c;
    cin >> a >> b >> c;
    for (int i = 0;i < 1e6;i++){
        if (a % 2 + b % 2 + c % 2){
            cout << i << endl;
            return 0;
        }
        int a1 = a/ 2,b1 = b / 2,c1 = c/2;
        a = b1 + c1,c = a1 +b1,b = a1 + c1;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, m, d, s[MAXN];
II f[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m >> d;
    FOR(i,1,n)
        FOR(j,1,m) {
            int x;
            cin >> x;
            f[x] = II(i, j);
        }
    FOR(i,1,n*m) {
        if (i - d <= 0) s[i] = 0;
        else {
            II g = f[i-d];
            II h = f[i];
            s[i] = s[i-d] + abs(g.FI - h.FI) + abs(g.SE - h.SE);
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int u, v;
        cin >> u >> v;
        cout << s[v] - s[u] << "\n";
    }
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44


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

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

/*int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/

using namespace std;

const int MAXN = (int) 1e5;

char str[MAXN + 1];

int dp[2][13];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> str + 1;
    n = strlen(str + 1);

    dp[0][0] = 1;

    for(i = 1; i <= n; i++) {
        memset(dp[i & 1], 0, sizeof(dp[i & 1]));
        for(int c = 0; c < 10; c++) {
            if(str[i] == '?' || (isdigit(str[i]) && str[i] == c + '0')) {
                for(int r = 0; r < 13; r++) {
                    add(dp[i & 1][(r * 10 + c) % 13], dp[1 - i & 1][r]);
                }
            }
        }
    }

    cout << dp[n & 1][5];

    return 0;
}


Measured memory_bytes: 384