akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;
#define INF 100000000;

bool comp(const pair<string,int> a, const pair<string,int> b) {
  if (a.first != b.first)
    return a.first < b.first; // 高い順に並べたいので演算子を逆に
  else{
      return a.second > b.second;
  }
}

int Dx[6] = { 0, 0, 1, 1,-1,-1};
int Dy[6] = { 1,-1, 1, 0, 0,-1};

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;
int main(){
    int b[201] = {0};
    int dp[1000001] = {0};
    int dpOdd[1000001] = {0};

    for(int i = 0;i<201;i++){
        b[i] = i*(i+1)*(i+2)/6;
    }

    for(int i = 0;i<1000001;i++){
        dp[i] = dpOdd[i] = 99999999;
    }
    dp[0] = 0;dpOdd[0] = 0;
    for(int i = 0;i<1000001;i++){
        for(int j = 0;j < 201;j++){
            if(i+b[j] <= 1000000)dp[i+b[j]] = min(dp[i+b[j]] , dp[i]+1);
            if((b[j]%2 == 1 )&& (i+b[j] <= 1000000))dpOdd[i+b[j]] = min(dpOdd[i+b[j]] , dpOdd[i]+1);
        }
    }

    int N;

    while (cin >>N,N){
        cout <<dp[N]<<" "<<dpOdd[N]<<endl;
    }



    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

*/


Measured memory_bytes: 10876
#include<bits/stdc++.h>
using namespace std;
const int N=55;
struct point
{
	double x,y;
}a[N],k;
inline double dis(point a,point b){return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}
int main()
{
	int n,num=100000,p;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lf%lf",&a[i].x,&a[i].y);
		k.x+=a[i].x,k.y+=a[i].y;
	}
	k.x/=n,k.y/=n;
	double zh=1.0/n;
	while(num--)
	{
		p=1;
		for(int i=2;i<=n;i++)
			if(dis(k,a[p])<dis(k,a[i]))
				p=i;
		k.x+=(a[p].x-k.x)*zh;
		k.y+=(a[p].y-k.y)*zh;
		zh*=0.999;
	}
	printf("%.12lf\n",sqrt(dis(k,a[p])));
	return 0;
}

Measured memory_bytes: 256
# import bisect
# from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string


import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=list(input())
    gr = groupby(A)
    cnt=0
    for key, group in gr: # groupはイテレータ。list(group)でリスト化  
        """ex.
        0: [0, 0, 0]
        1: [1, 1]
        0: [0, 0, 0]
        1: [1, 1]
        0: [0]
        1: [1]
        """
        cnt+=1
    print(cnt)
        

    
resolve()

Measured memory_bytes: 49264
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int cnt[1001001];

int main(void){
	int n,i,j,a;
	bool flag = true;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a;
		++cnt[a];
	}
	for(i=2; i<=1000000; ++i){
		a = 0;
		for(j=i; j<=1000000; j+=i){
			a += cnt[j];
		}
		if(a==n){
			std::cout << "not coprime" << std::endl;
			return 0;
		}else if(a>1){
			flag = false;
		}
	}
	std::cout << (flag?"pair":"set") << "wise coprime" << std::endl;
	return 0;
}


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

	for(int i = 1; i<=5; i++){
		cin >> x;
		if(x==0){
			cout << i;
		}

	}

	cin >> x;
	
	return 0;	
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
ll dp[1005][30005]={0};
const ll inf=1744174417441744;
int main(){
  ll h,n;
  cin>>h>>n;
  for(int i=0;i<=n;i++){
    for(int j=0;j<30005;j++) dp[i][j]=inf;
  }
  dp[0][0]=0;
  for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    for(int j=0;j<30005;j++){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      if(j+a<30005) dp[i][j+a]=min(dp[i][j+a],dp[i][j]+b);
    }
  }
  ll ans=inf;
  for(int i=h;i<30005;i++) ans=min(ans,dp[n][i]);
  cout<<ans<<endl;
}


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

const int N = 100005, MOD = 1000000007; 
int n, a[N], pre[N], fac[N], ifac[N];

int qpow(int a, int b) {
    int res = 1;
    while (b) {if (b & 1) res = 1ll * res * a % MOD; a = 1LL * a * a % MOD; b >>= 1; }
    return res; 
}

int add(int a1, int b1) {
    a1 += b1;
    if (a1 >= MOD) a1 -= MOD;
    return a1; 
}
int main() {
    scanf("%d", &n);
    fac[0] = 1; 
    for (int i = 1; i <= n;i++) scanf ("%d", &a[i]), fac[i] = 1LL * fac[i - 1] * i % MOD;
    ifac[n] = qpow(fac[n], MOD - 2);
    for (int i = n-1; i >= 0; i--) ifac[i] = 1LL * ifac[i + 1] * (i + 1) % MOD; 
    for (int i = 1; i <= n; i++) pre[i] = (pre[i - 1] + qpow(i, MOD - 2)) % MOD;
    LL ans = 0; 
    for (int i = 1; i <= n; i++) {
        int p1 = pre[i], p2 = pre[n - i + 1];
        ans = add(ans, 1LL * (p1 + p2 - 1) % MOD * a[i] % MOD);
    }

 //   cerr << ans << endl; 
    cout << ans * fac[n] % MOD << endl; 
    return 0; 
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int a = sc.nextInt();

        if (a==0)
            System.out.println("1");
        else
            System.out.println("0");


    }
}


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

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> e[n];
	set<int> v;
	int start = 0,end = 0;
	for (int i = 0;i < m;i++) {
		int x,y;
		cin >> x >> y;
		e[x-1].push_back(y-1);
		e[y-1].push_back(x-1);
	}
	int ans[3 * n];
	for (int i = 0;i < 3 * n;i++) {
		ans[i] = -1;
	}
	ans[n] = 1;
	int spos = n-1,epos = n+1;
	v.insert(0);
	bool ok = false;
	while (!ok) {
		ok = true;
		for (int i = 0;i < e[start].size();i++) {
			if (v.find(e[start][i]) == v.end()) {
				ok = false;
				start = e[start][i];
				v.insert(start);
				ans[spos] = start+1;
				spos--;
				break;
			}
		}
		for (int i = 0;i < e[end].size();i++) {
			if (v.find(e[end][i]) == v.end()) {
				ok = false;
				end = e[end][i];
				v.insert(end);
				ans[epos] = end+1;
				epos++;
				break;
			}
		}
	}
	cout << v.size() << endl;
	for (int i = 0;i < v.size();i++) {
		cout << ans[i+spos+1];
		if (i != n-1) cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 12160
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
int n;
string s;
int main(){
    cin >> n >> s;
    if(n&1) cout << "No" << endl;
    else{
        for(int i = 0; i < n/2; i++) if(s[i]!=s[i+n/2]) return cout << "No" << endl,0;
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>

using namespace std;

#define ALL(g) (g).begin(), (g).end()
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define F(i, j, k) fill(i[0], i[0] + j * j, k)
#define P(p) cout << (p) << endl;
#define EXIST(s, e) ((s).find(e) != (s).end())
#define INF 1 << 25
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;

double dp[1000000+1];

int main(){
	fill(dp,dp+1000000,0);
	dp[1]=1;
	for(int i=2;i<1000000+1;i++){
		double p=1,n=0.5;
		for(int j=1;j<i;j++){
			double tmp=p*(1-n);
			if(tmp<1e-15)break;
			dp[i]+=(j+dp[i-j-1])*tmp;
			p*=n;
			n*=0.5;
		}
		dp[i]+=i*p;
	}
	int a;
	while(scanf("%d",&a)&&a!=0)printf("%.15f\n",dp[a]);
	return 0;
}


Measured memory_bytes: 9036
d, n = map(int, input().split())
if d == 0:
  if n < 100:
    print(n)
  else:
    print(n+1)
elif d == 1:
  if n < 100:
    print(n*100)
  else:
    print((n+1)*100)
else:
  if n < 100:
    print(n*10000)
  else:
    print((n+1)*10000)
  

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

int Size[200010], father[200010];

int findfa(int a){
    if(a == father[a]){
        return a;
    } else{
        return father[a] = findfa(father[a]);
    }
}

void merge(int a, int b){
    a = findfa(a);
    b = findfa(b);
    if(a != b){
        if(Size[a] < Size[b]){
            swap(a, b);
        }
        Size[a] += Size[b];
        father[b] = a;
    }
}


void testCase(){
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; i++){
        Size[i] = 1;
        father[i] = i;
    }

    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        merge(x, y);
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(i == father[i]){
            ans = max(ans, Size[i]);
        }
    }

    cout << ans << endl;
}
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int t = 1;
    // int t; cin >> t;
    while(t--)
        testCase();
    
    return 0;
}

Measured memory_bytes: 6780
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;
const int N = 1e5+5;
int a[N], n;

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

Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np

def main():
	N, M, Q = map(int, input().split(" "))
	N_list = [[0 for _ in range(N)] for _ in range(N)]
	
	for _ in range(M):
		l, r = map(int, input().split(" "))
		l -= 1
		r -= 1
		N_list[l][r] += 1
		
	#print(N_list)
	
	for i in range(N):
		for j in range(N):
			if i == 0 and j == 0:
				continue
			if i == 0:
				N_list[i][j] = N_list[i][j] + N_list[i][j-1]
				continue
			if j == 0:
				N_list[i][j] = N_list[i][j] + N_list[i-1][j]
				continue
			N_list[i][j] = N_list[i][j] + N_list[i-1][j] + N_list[i][j-1] - N_list[i-1][j-1]
			
	#print(N_list)
		
	for _ in range(Q):
		p, q = map(int, input().split(" "))
		p -= 1
		q -= 1
		
		a = 0
		b = 0
		c = 0
		if p != 0:
			a = N_list[q][p-1]
			b = N_list[p-1][q]
			c = N_list[p-1][p-1]
		ans = N_list[q][q] - a - b + c
		print(ans)
		
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 23848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 1e5 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;


ll n,m;

vector<ll>adj[Max+10];

ll indeg[Max+10];

ll dis[Max+10];



void input()
{
      ll i,a,b;


       for(i=1; i<=m; i++)
       {
           cin>>a>>b;

           adj[a].eb(b);

           indeg[b]++;
       }
}

ll topsort()
{
    ll u,mx=0;

       queue<ll>q;

       for(ll i=1; i<=n; i++)
       {
           if(!indeg[i])q.push(i);
       }

         while(!q.empty())
         {
              u=q.front();

              q.pop();

                for(auto v  : adj[u])
                {
                   dis[v]=max(dis[v],dis[u]+1);

                   mx=max(dis[v],mx);

                   indeg[v]--;

                   if(!indeg[v])
                    q.push(v);
                }
         }

         return mx;
}
int main()
{

   fastread();

   ll i,j,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;


     string str;

   bool flag=true;

     cin>>n>>m;

     input();


      cout<<topsort()<<endl;







}



Measured memory_bytes: 10624
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

struct Edge{
  int cost, from, to;
  Edge(int cost, int from, int to):
    cost(cost), from(from), to(to) {}
};

bool operator<(const Edge& a, const Edge& b){
  return a.cost != b.cost ? a.cost < b.cost : a.from != b.from ? a.from < b.from : a.to < b.to;
}

struct UnionFind{
  vector<int> data;
  UnionFind(int n) : data(n, -1) {}
  bool unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x != y){
      if(data[y] < data[x]) swap(x,y);
      data[x] += data[y];//高さを更新
      data[y] = x;//親を更新
    }
    return x != y;
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int find(int x){
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
};

int kruskal(vector<Edge> &E, int N){
  UnionFind uf(N);
  int ret = 0, t = 0;
  for(int i = 0; i < E.size(); ++i){
    int c = E[i].cost, s = E[i].from, d = E[i].to;
    if(!uf.same(s,d)){
      ret += c;
      uf.unite(s,d);
      ++t;
      if(t == N-1) break;
    }
  }
  return ret;
}

pair<int, vector<int> > mst(vector<Edge> &E, int N){
  UnionFind uf(N);
  int ret = 0, t = 0;
  vector<int> V;
  for(int i = 0; i < E.size(); ++i){
    int c = E[i].cost, s = E[i].from, d = E[i].to;
    if(!uf.same(s,d)){
      ret += c;
      uf.unite(s,d);
      ++t;
      V.push_back(i);
      if(t == N-1) break;
    }
  }
  return make_pair(ret,V);
}

pair<int,int> solve(vector<Edge> &E, int N){
  pair<int,vector<int> > p = mst(E,N);
  int min_cost = p.first;
  vector<int> V = p.second;
  int ans = 0, INF = 1e9, c = 0;
  for(int i = 0; i < N-1; ++i){
    vector<Edge> E_ = E;
    E_[V[i]].cost = INF;
    sort(E_.begin(), E_.end());
    if(kruskal(E_,N) != min_cost){
      ++ans;
      c += E[V[i]].cost;
    }
  }
  return make_pair(ans,c);
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<Edge> E;
  int s, d, c;
  for(int i = 0; i < M; ++i){
    cin >> s >> d >> c;
    --s;--d;
    E.push_back(Edge(c,s,d));
  }
  sort(E.begin(), E.end());
  pair<int,int> ans = solve(E,N);
  cout << ans.first << " " << ans.second << endl;
  return 0;
}



Measured memory_bytes: 4304
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    string l;
    cin >> l;

    int n = (int)l.size();
    vector<int> b2(n + 1), b3(n + 1);
    b2[0] = b3[0] = 1;
    for (int i = 0; i < n; i++) {
        b2[i + 1] = (int)((ll)b2[i] * 2 % P);
        b3[i + 1] = (int)((ll)b3[i] * 3 % P);
    }

    int k = 0;
    ll r = 0;
    for (int i = 0; i < n; i++) {
        if (l[i] == '1') {
            //2^k*3^(n-1-i)
            r += (ll)b2[k] * b3[n - 1 - i] % P;
            k++;
        }
    }
    r += b2[k];

    cout << r % P << endl;

    //100100010
    //100000000未満 3^(n-1)
    //100100000未満
    //100100010未満 関係ないとこに1が2つある 2^2
    //100100010
    //012の3通り3^n

    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, M, X;
	int cnt1 = 0;
	int cnt2 = 0;

	cin >> N >> M >> X;

	for (int i = 0; i < M; i++)
	{
		int tmp;
		cin >> tmp;
		if (tmp < X&&tmp>0) {
			cnt1++;
		}
		if (tmp > X&&tmp<N) {
			cnt2++;
		}
	}

	cout << min(cnt1, cnt2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n, t;
    cin >> n >> t;
    ll hmax = 0;
    ll start = 0;
    for(int i = 1; i <= n; i++) {
        ll h;
        cin >> h;
        hmax = max(h, hmax);
        ll delta = (t - start);
        delta = max(delta, 0LL);
        ll ans = delta / hmax;
        //cerr << delta % hmax << " " << h << endl;
        if(delta % hmax >= h) ans++;
        cout << ans + 1 << endl;
        start = start + h;
    }
}


Measured memory_bytes: 3072
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Numerics;

class Myon
{
    //chokudaiさんのコードをコピペ
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        //Console.SetOut(new Printer(Console.OpenStandardOutput()));
        cin = new Scanner();
        new Myon().calc();
        Console.Read();

        return 0;
    }


    public void calc()
    {
        int n = cin.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = cin.nextInt();
        int[] b = new int[n];

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

        for (int i = 0; i < n; i++)
        {
            Console.Write(b[i]);
            Console.Write(" ");
        }

    }


    

    public void backetSort(ref int[] a)
    {
        //max a << a.len に対して有効なソート
        //よってa = int[] とする
        long n = a.Length;
        var count = new int[n];
        var loc = new long[n];//loc[i] は i が終わる 位置 max index where c[index] = loc[i]
        for (long i = 0; i < n; i++) count[a[i]]++;
        loc[0] = count[0] - 1;
        for (long i = 0; i < n-1; i++) loc[i+1] = loc[i] + count[i+1]; 
        long index = 0;

        for(int i = 0; i < n; i++)
        {
            while (index <= loc[i]) a[index++] = i; //incex <= loc[i] == index < loc[i] + 1
        }
    }

    public static void showL(long n) { Console.WriteLine(n); }
    public static void showL(string s) { Console.WriteLine(s); }
}

class Printer : StreamWriter
{
    public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
    public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {

#ifdef LOCAL_DEFINE
	FILE* fp;
	freopen("input.txt", "rt", stdin);
#endif

	int n;
	cin >> n;

	if (n < 1200) cout << "ABC" << endl;
	else if (n < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;

#ifdef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,x,n) for(int i=x;i<n;++i)
#define ar array
void func(int n){
    for(int i=0;i<=n;++i)
        cout<<i<<" ";
    for(int i=n-1;i>=0;--i)
        cout<<i<<" ";
    cout<<endl;
}
int32_t main()
{
  deque<char> q;
  string s; cin>>s;
  for(int i=0;i<s.size();++i){
    q.push_back(s[i]);
  }
  int ch=0;
  int Q; cin>>Q;
  while(Q--)
  {
    int x; cin>>x;
    if(x==1){
      ch=1-ch;
    }else {
      int f; cin>>f;
      char tp; cin>>tp;
      if(f==1 && ch==0){
        q.push_front(tp);
      }else if(f==1 && ch==1){
        q.push_back(tp);
      }else if(f==2 && ch==0){
        q.push_back(tp);
      }else {
        q.push_front(tp);
      }
    }
  } 
  string ret="";
  while(!q.empty()){
    char pp=q.front();
    ret+=pp;
    q.pop_front();
  }
  if(ch==1)
  reverse(ret.begin(),ret.end());
  cout<<ret;
  return 0;
}


Measured memory_bytes: 1412
from math import sqrt

N,D = [int(i) for i in input().split()]
XY_l = [[int(i) for i  in input().split()] for _ in range(N)]
ans = 0

for i in range(N):
  for j in range(N):
    if i <= j :
      continue
    S = float()
    for d in range(D):
      S += ((XY_l[i][d]) - (XY_l[j][d]))**2
    if sqrt(S).is_integer():
      ans+=1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    ll a[n];
    f(i,0,n)cin>>a[i];
    ll cnt=1;ll mini=a[0];
    f(i,1,n){
        if(mini>=a[i]){cnt++;mini=a[i];}
    }
    cout<<cnt;
    return 0;  
} 

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n, m, a[110000], b[110000];
bool can_survibe[110000];
bool used[110000];
Int eaten_by[440];
bool survibe(int x){
    fill(used, used + 110000, false);
    fill(eaten_by, eaten_by + 440, -1);
    eaten_by[x] = m;
    for(int i = m-1;i >= 0;i--){
        Int &u = eaten_by[a[i]];
        Int &v = eaten_by[b[i]];
        if(u != -1 && v != -1)return false;
        if(u == -1 && v == -1)continue;
        used[i] = true;
        if(u == -1)u = i;
        else v = i;
    }
    for(int i = 0;i < m;i++){
        if(used[i])continue;
        Int &u = eaten_by[a[i]];
        Int &v = eaten_by[b[i]];
        if(u != -1 && v != -1)continue;
        if(u == -1 && v == -1)continue;
        if(u == -1)u = i;
        else v = i;
    }
    return true;
}

int cnt(int x){
    fill(used, used + 110000, false);
    fill(eaten_by, eaten_by + 440, -1);
    eaten_by[x] = m;
    for(int i = m-1;i >= 0;i--){
        Int &u = eaten_by[a[i]];
        Int &v = eaten_by[b[i]];
        if(u != -1 && v != -1)return 0;
        if(u == -1 && v == -1)continue;
        used[i] = true;
        if(u == -1)u = i;
        else v = i;
    }
    for(int i = 0;i < m;i++){
        if(used[i])continue;
        Int &u = eaten_by[a[i]];
        Int &v = eaten_by[b[i]];
        if(u != -1 && v != -1)continue;
        if(u == -1 && v == -1)continue;
        if(u == -1)u = i;
        else v = i;
    }
    int ans = 0;
    for(int i = 1;i <= n;i++)if(can_survibe[i] && eaten_by[i] == -1)ans++;
    return ans;
}

int main(){
    cin >> n >> m;
    for(int i = 0;i < m;i++){
        cin >> a[i] >> b[i];
    }

    for(int i = 1;i <= n;i++){
        can_survibe[i] = survibe(i);
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        ans += cnt(i);
    }
    cout << ans / 2 << endl;
    
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    int d = a[n-1]-a[0];
    if(d>1){
        cout << "No\n";
    }
    else if(d==0){
        if(n==a[0]+1 || n>=2*a[0]){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }
    else{
        int amtsmall = 0;
        while(amtsmall < n && a[amtsmall]==a[0]){
            ++amtsmall;
        }
        int amtbig = n-amtsmall;

        int small = a[0], big = a[n-1];

        if(amtsmall<=small && amtbig>=2*(big-amtsmall)){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


map<pair<int,int>,int> mp;
void DFS(int V,vector<vector<int> >&GRAPH,vector<int>& used,int C)
{
  // if(used[V] == 1)return;
  used[V] = C;
  // DEBUG(V,C,"\n");
  // DEBUG(V);
  int cC = 1;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    if(cC == C) cC++;
    if(used[GRAPH[V][i]] == 0)
    {
      DFS(GRAPH[V][i],GRAPH,used,cC);
      mp[make_pair(V,GRAPH[V][i])] = cC;
      mp[make_pair(GRAPH[V][i],V)] = cC;
      cC++;
    }
  }
  return;
}

void solve(void)
{
  int N;
  cin>>N;
  vector<vector<int> > GRAPH(N);
  vector<pair<int,int> > Es;

  for (int i = 0; i < N-1; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    GRAPH[A].push_back(B);
    GRAPH[B].push_back(A);
    if(A > B)swap(A,B);
    Es.emplace_back(A,B);
  }
  vector<int> used(N,0);

  DFS(0,GRAPH,used,-1);
  set<int> SET;
  for (int i = 0; i < N-1; i++)
  {
    SET.insert(mp[Es[i]]);
  }
  cout<<SET.size()<<endl;
  for (int i = 0; i < N-1; i++)
  {
    cout<<mp[Es[i]]<<endl;
  }
  
  
  return;
}




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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 21364
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
	public static void main(String[] args) {  //Recursion is OVERPOWERED
		//Requirement was 10^5 upper-bound, this works for even 10^8 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long K = I.nextLong();
		long[] a = new long[2000]; //This is the answer in the form of an array of digits
		Arrays.fill(a,-1);
		while (K>0) {
			UPD(a,a.length-1);
			//for (int i = 0; i < a.length; i++) O.p(a[i]+" ");
			//O.p("\n");
			K--;
		}
		boolean print = false;
		for (int i = 0; i < a.length; i++) {
			if (a[i]>0) print=true;
			if (print) O.p(a[i]);
		}
	}
	public static void UPD(long[] a, int in) {
		if (a[in]==-1) a[in]=1;
		else {
			a[in]++;
			a[in]%=10;
			if (a[in]==0) {
				UPD(a,in-1);
				a[in]=a[in-1]-1;
				a[in]=Math.max(a[in], 0); //Can't have negative digits now
			}
			if (a[in-1]!=-1&&Math.abs(a[in]-a[in-1])>1) {
				//-1 means those digit slots haven't been used yet
				UPD(a,in-1);
				a[in]=a[in-1]-1; //Reset and recurse left starting with lower-bound
				a[in]=Math.max(a[in], 0); //Can't have negative digits now
			}
		}
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}

Measured memory_bytes: 26340
#include <iostream>

using namespace std;

int main()
{
  int N,T,c=0;
  cin>>N>>T;
  int a[N][2];
  for(int i=0;i<N;i++){
      for(int j=0;j<2;j++){
    cin>>a[i][j];
    }}
  for(int i=0;i<N;i++){
    for(int j=0;j<N-1;j++){
    if (a[j][0]>a[j+1][0]){
        swap(a[j][0],a[j+1][0]);
        swap(a[j][1],a[j+1][1]);}
    }}

   for(int i=0;i<N;i++){
        if(a[i][1]<=T){
            cout<<a[i][0];
            c=1;
            break;
        }
      } if(c!=1)
      cout <<"TLE";



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    while (a>=b) {
        b*=2;
        k--;
    }
    while (b>=c) {
        c*=2;
        k--;
    }
    if (k>=0) cout << "Yes" <<endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
N = int(input())
TA = [[int(_) for _ in input().split()] for _ in range(N)]
tak = TA[0][0]
aok = TA[0][1]

if N == 1:
    print(tak+aok)
else:
    for i in range(1, N):
        nowTrate = TA[i][0]
        nowArate = TA[i][1]
        T = tak//nowTrate if tak % nowTrate == 0 else tak//nowTrate+1
        A = aok//nowArate if aok % nowArate == 0 else aok//nowArate+1
        y = max(T, A)
        tak = nowTrate * y
        aok = nowArate * y
    print(tak+aok)

Measured memory_bytes: 3188
# coding: utf-8
n = str(input())
int_n = int(n)
#print(len(n), int_n)

ans = 0
for i in range(1,len(n)+1):
    if i%2==1:
        if i==len(n):
            ans += int_n - 10**(i-1) + 1
        else:
            ans += 10**(i)-10**(i-1)
        #print(ans)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int x, y;
    cin>>x>>y;
    cout<<x + y/2<<endl;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    int group[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    if(group[x] == group[y]){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<int, int>::iterator;

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

	vector<vector<int> > vvPosi(26, vector<int>(0));
	for (int i = 0; i != s.length(); i++) {
		int chara = (int)(s[i] - 'a');
		vvPosi[chara].push_back(i);
	}

//	for (int i = 0; i != 26; i++) {
//		sort(vvPosi[i].begin(), vvPosi[i].end());
//	}

	bool fail = false;
	for (int i = 0; i != t.size(); i++) {
		// t[i]がsの何番目の文字かを求める
		if (vvPosi[(int)(t[i] - 'a')].empty()) {
			fail = true;
			break;
		}
	}

	if (!fail) {
		long long nDecrease = 0;
		long long previdx = -1;
		for (int i = 0; i != t.size(); i++) {
			int c = (int)(t[i] - 'a');
//			const vector<int>& vtmpPosi = vvPosi[(int)(t[i] - 'a')];

			//			bool judge = false;
		A:
			auto it = lower_bound(vvPosi[c].begin(), vvPosi[c].end(), (previdx + 1));
			//			for (int j = 0; j != vtmpPosi.size(); j++) {
			//				int tmpidx2 = vtmpPosi[j];
			//				if (tmpidx2 > tmpidx1) {
			//					previdx = tmpidx2;
			//					judge = true;
			//					break;
			//				}
			//			}

			if (it == vvPosi[c].end()) {
				nDecrease++;
				previdx = -1;
				goto A;
			}

			previdx = (*it);
			//			if (!judge) {
			//				nDecrease++;
			//				previdx = 0;
			//			}
		}

		long long ans = (long long)nDecrease * s.size() + previdx + 1;

		cout << ans << endl;
	}
	else {
		cout << "-1" << endl;
	}

	return 0;
}

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

double dist(vector<double> &x, vector<double> &y, pair<double, double> vertex)
{
    double ret = 0.;
    double xx = vertex.first;
    double yy = vertex.second;
    for (int i = 0; i < x.size(); i++)
    {
        ret = max(ret, (x[i] - xx) * (x[i] - xx) + (y[i] - yy) * (y[i] - yy));
    }
    return sqrt(ret);
}

double f(double A, double B, double C, double a, double b, double c)
{
    double numerator = 0.;
    a *= a;
    b *= b;
    c *= c;
    numerator += a * (b + c - a) * A;
    numerator += b * (c + a - b) * B;
    numerator += c * (a + b - c) * C;

    double denominator = 0.0;
    denominator += a * (b + c - a);
    denominator += b * (c + a - b);
    denominator += c * (a + b - c);
    if (denominator <= 0)
    {
        return 2000.;
    }
    return numerator / denominator;
}

pair<double, double> center(set<pair<double, double>> vertex)
{
    if (vertex.size() == 1)
    {
        return *vertex.begin();
    }
    if (vertex.size() == 2)
    {
        double x = 0.;
        double y = 0.;
        for (pair<double, double> v : vertex)
        {
            x += v.first / 2.;
            y += v.second / 2.;
        }
        return make_pair(x, y);
    }
    if (vertex.size() == 3)
    {
        // https://ja.wikipedia.org/wiki/%E5%A4%96%E6%8E%A5%E5%86%86#%E5%A4%96%E5%BF%83%E3%81%AE%E4%BD%8D%E7%BD%AE
        vector<double> xs;
        vector<double> ys;
        for (pair<double, double> v : vertex)
        {
            xs.push_back(v.first);
            ys.push_back(v.second);
        }
        double a = sqrt(pow(xs[1] - xs[2], 2) + pow(ys[1] - ys[2], 2));
        double b = sqrt(pow(xs[2] - xs[0], 2) + pow(ys[2] - ys[0], 2));
        double c = sqrt(pow(xs[0] - xs[1], 2) + pow(ys[0] - ys[1], 2));
        double Ax = xs[0];
        double Bx = xs[1];
        double Cx = xs[2];
        double Ay = ys[0];
        double By = ys[1];
        double Cy = ys[2];
        return make_pair(f(Ax, Bx, Cx, a, b, c), f(Ay, By, Cy, a, b, c));
    }
    else
    {
        return make_pair(0., 0.);
    }
}

int main()
{
    int N;
    cin >> N;
    vector<double> x(N);
    vector<double> y(N);

    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }

    double ans = 1000. * 1000.;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            for (int k = 0; k < N; k++)
            {
                set<pair<double, double>> vertex;
                vertex.insert(make_pair(x[i], y[i]));
                vertex.insert(make_pair(x[j], y[j]));
                vertex.insert(make_pair(x[k], y[k]));
                pair<double, double> c = center(vertex);
                ans = min(ans, dist(x, y, c));
            }
        }
    }
    cout << fixed << setprecision(8) << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
int main() {
	string s, t; cin >> s >> t;

	ll maxI = -1;
	rep(i, 0, s.size()) {
		ll j = 0;
		bool same = true;
		while (t[j]) {
			same &= (t[j] == s[i + j] || s[i + j] == '?');
			if (!same) {
				break;
			}
			j++;
		}
		if (same) {
			maxI = max(maxI, i);
		}
	}
	if (maxI == -1) {
		cout << "UNRESTORABLE " << endl;
		return 0;
	}

	rep(i, 0, t.size()) {
		s[i + maxI] = t[i];
	}

	rep(i, 0, s.size()) {
		if (s[i] == '?') {
			cout << 'a';
		}
		else {
			cout << s[i];
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void)
{
  int n, m, a[1000];
  int i, j, sum = 0, result = 0;
  
  scanf("%d %d", &n, &m);
  
  for( i = 0; i < n; i++ ){
    scanf("%d", &a[i]);
    sum += a[i];
  }
  
  for( i = 0; i < n; i++ ){
    if( a[i] * 4 * m >= sum ){
      result++;
    }
  }
  
  if( result >= m ){
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
from itertools import permutations
n = int(input())

xy = [list(map(int,input().split())) for i in range(n)]

permus = list(permutations(list(range(n)),n))

def calc(i,j):
    return ((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5

sum = 0
for permu in permus:
    for i in range(n-1):
        sum += calc(permu[i],permu[i+1])

ans = sum/len(permus)
print(ans)


Measured memory_bytes: 45424
// d <= dt は時間・距離・速度から来る制約
// 設定から毎秒 x+y の偶奇が変わり、それが時間の偶奇とも一致する必要がある：具体例で考えるとわかる
// そして上の注意の逆も成り立つのがポイント
let checkCoords (((t1, x1, y1), (t2, x2, y2))) =
    let dt: int = t2 - t1
    let d: int = (abs (x2 - x1)) + (abs (y2 - y1))
    d <= dt && (d % 2 = dt % 2)

let fc =
    Array.pairwise
    >> Array.map checkCoords
    >> Array.fold (&&) true
    >> fun x -> if x then "Yes" else "No"

//let input = [| [| (0, 0, 0); (3, 1, 2); (6, 1, 1) |]; [| (0,0,0); (2,100,100) |]; [| (0,0,0); (5,1,1); (100,1,1) |] |]
//for i in input do fc i |> printfn "%s"

[<EntryPoint>]
let main argv =
    let n = stdin.ReadLine() |> int
    let targetCoords: (int * int * int) [] = Array.zeroCreate (n + 1)
    targetCoords.[0] <- (0, 0, 0)
    for i in [ 1 .. n ] do
        let [| x; y; z |] = stdin.ReadLine().Split(' ') |> Array.map int
        targetCoords.[i] <- (x, y, z)
    targetCoords |> fc |> printfn "%s"
    0

Measured memory_bytes: 27796
#include<bits/stdc++.h>
#define N 105
using namespace std;
#define add(x,y,f) (Dinic::addedge(x,y,f)) 
const int INF = 0x3f3f3f3f;
namespace Dinic{
	struct edge{
		int t,flow,next;
	}e[N*N*100];int ecnt,head[N*N*2];
	void addedge(int f,int t,int flow){
		e[++ecnt]=(edge){t,flow,head[f]};head[f]=ecnt;
		e[++ecnt]=(edge){f,0,head[t]};head[t]=ecnt;
	}
	
	int S,T,sz;
	int cur[N*N*2],dis[N*N*2];
	int DFS(int u,int a){
		if(u==T||a==0) return a;
		int ret=0;
		for(int &i=cur[u];i;i=e[i].next){
			if(e[i].flow!=0&&dis[e[i].t]==dis[u]+1){
				int t=DFS(e[i].t,min(e[i].flow,a));
				if(t){
					e[i].flow-=t;e[i^1].flow+=t;
					a-=t;ret+=t;
				}
			}
		}
		return ret;
	}
	
	bool BFS(){
		memset(dis,0x3f,sizeof(int)*(sz+2));
		queue<int> q;
		q.push(S);dis[S]=0;
		while(!q.empty()){
			int u=q.front();q.pop();
			for(int i=head[u];i;i=e[i].next){
				if(e[i].flow!=0&&dis[e[i].t]==INF){
					dis[e[i].t]=dis[u]+1;
					q.push(e[i].t);
				}
			} 
		}
		return dis[T]!=INF;
	}
	
	int work(int S1,int T1,int size){
		S=S1,T=T1;sz=size;
		int ret=0;
		while(BFS()){
			memcpy(cur,head,sizeof(int)*(sz+2));
			ret+=DFS(S1,INF);
			if(ret>=INF) return -1;
		}
		return ret;
	}
}

int cnt;
int id[N][N][2];//0 in 1 out
char mp[N][N];
int r[N],c[N];
int main(){
	Dinic::ecnt=1;
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++) scanf("%s",mp[i]+1);
	for(int i=1;i<=h;i++) r[i]=++cnt;
	for(int i=1;i<=w;i++) c[i]=++cnt;
	int S,T;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++){
			if(mp[i][j]=='.') continue;
			id[i][j][0]=++cnt;
			id[i][j][1]=++cnt;
			if(mp[i][j]=='S') S=id[i][j][1];
			if(mp[i][j]=='T') T=id[i][j][0];
			add(id[i][j][0],id[i][j][1],1);
			add(id[i][j][1],r[i],INF);
			add(id[i][j][1],c[j],INF);
			add(r[i],id[i][j][0],INF);
			add(c[j],id[i][j][0],INF);
		}
	printf("%d\n",Dinic::work(S,T,cnt));
	return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int n;
int a[4000];
ll dp[4000][4000][2];

ll rec(int i,int j,int k){
	if(dp[i][j][k]!=-1)return dp[i][j][k];
	if(i+j==n)return 0;
	int s=i,t=n-j-1;
	if(k==0){
		return dp[i][j][k]=max(rec(i+1,j,!k)+a[s],rec(i,j+1,!k)+a[t]);
	}
	else{
		return dp[i][j][k]=min(rec(i+1,j,!k),rec(i,j+1,!k));
	}
}
int main(){
	scanf("%d",&n);
	ll sum=0;
	rep(i,n){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	memset(dp,-1,sizeof(dp));
	ll ans=rec(0,0,0);
	ll d=sum-ans;
	cout<<ans-d<<endl;
}

Measured memory_bytes: 250368
sa = input()
sb = input()
sc = input()
da = 0
db = 0
dc = 0
turn = 'a'
while True:
  if turn == 'a':
    if da == len(sa):
      print('A')
      break
    turn = sa[da]
    da += 1
  if turn == 'b':
    if db == len(sb):
      print('B')
      break
    turn = sb[db]
    db += 1
  if turn == 'c':
    if dc == len(sc):
      print('C')
      break
    turn = sc[dc]
    dc += 1


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 2e3 + 5;
const int mod = 1e9 + 7;

int f[MAXN][MAXN], g[MAXN][MAXN];

int main(void)
{
	int n;
	scanf("%d",&n);
	
	int ans = 0;
	
	f[0][0] = 1;
	for(int i=0; i<=n; ++i) g[0][i] = 1;
	for(int i=1; i<=n; ++i)
	{
		for(int j=3; j<=n; ++j)
		{
			f[i][j] = g[i-1][j-3];
			g[i][j] = (g[i][j-1] + f[i][j]) %mod;
		}
		ans = (ans + f[i][n]) %mod;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 33004
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
		string[] str = Console.ReadLine().Split(' ');
		int n = int.Parse(str[0]);
		string output = "";
		int baseNum = -2;
		List<int> nums = new List<int>();
		while(n != 0){			
			nums.Add(seizyoyo(n, baseNum));
			n = (n - seizyoyo(n, baseNum)) / baseNum;
			//Console.WriteLine(n);
		}
		if(nums.Count==0){
			output = "0";
		}
		else{
			for (int i = 0; i < nums.Count; i++)
            {
                output += nums[nums.Count - 1 - i].ToString();
            }
		}

		//出力        
		Console.WriteLine(output);

    }

	static int seizyoyo(int n,int m){
		int amari=0;
		if (n >= 0){
			amari = n % m;
		}
		else{
			amari = (-n) % m;
		}
			return amari;
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{

 map<int,int>m;
vector<int>v,vv;
int a,n,b,c,d,e,o=0,i,j,k;
cin>>a>>b;
for(i=1;i<=a;i++)
{
cin>>c;
m[c]++;
if(m[c]==1)v.push_back(c);

}
   // cout<<v.size()<<endl;
    if(v.size()<=b)cout<<"0"<<endl;
   else
  {
  for(i=0;i<v.size();i++)
  {
  k=m[v[i]];vv.push_back(k);
  }
        sort(vv.begin(),vv.end());
 for(i=0;i<v.size()-b;i++)
    {o+=vv[i];
  }
       cout<<o<<endl; 
  }
}

Measured memory_bytes: 11892