akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int c[5];
int m[50][50];
int ijk[50][50][4];
int v[50][50][4];
int main(){
	int a,b;
	while(scanf("%d%d",&b,&a),a){
		for(int i=0;i<a;i++)
			for(int j=0;j<b;j++)
				scanf("%d",&m[i][j]);
		for(int i=0;i<4;i++)scanf("%d",c+i);
		priority_queue<pair<pair<int,int>,pair<int,int> > >Q;
		Q.push(make_pair(make_pair(0,0),make_pair(0,0)));
		for(int i=0;i<a;i++)
			for(int j=0;j<b;j++)
				for(int k=0;k<4;k++){
					ijk[i][j][k]=999999999;
					v[i][j][k]=0;
				}
		ijk[0][0][0]=0;
		while(Q.size()){
			int cost=-Q.top().first.first;
			int dir=Q.top().first.second;
			int row=Q.top().second.first;
			int col=Q.top().second.second;
			Q.pop();
			if(v[row][col][dir])continue;
			v[row][col][dir]=1;
			for(int i=0;i<4;i++){
				int val=cost;
				if(m[row][col]!=i){
					val+=c[i];
				}
				int tr=row;
				int tc=col;
				int td=dir;
				if(i==1)td=(td+1)%4;
				if(i==2)td=(td+2)%4;
				if(i==3)td=(td+3)%4;
				tr+=dx[td];
				tc+=dy[td];
				if(0<=tr&&tr<a&&0<=tc&&tc<b&&!v[tr][tc][td]&&ijk[tr][tc][td]>val){
					ijk[tr][tc][td]=val;
					Q.push(make_pair(make_pair(-val,td),make_pair(tr,tc)));
				}
			}
		}
		int ret=999999999;
		for(int i=0;i<4;i++)ret=min(ret,ijk[a-1][b-1][i]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1196
n=int(input())
CSF=[list(map(int,input().split())) for _ in range(n-1)]

for i in range(n-1):
    time=0
    for j in range(i,n-1):
        c,s,f=CSF[j]
        if i==j:
            time +=c+s
            continue
        else:
            if time<s:time=s
            elif time%f!=0:time +=f-(time%f)
            time +=c
    print(time)
print(0)

Measured memory_bytes: 43116
import sys
from math import ceil

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    
    ans = [0] * (N + 1)
    for x in range(1, ceil(N ** 0.5) + 1):
        for y in range(1, ceil(N ** 0.5) + 1):
            tmp = x ** 2 + y ** 2 + x * y
            if N <= tmp:
                break
            for z in range(1, ceil(N ** 0.5) + 1):
                n = tmp + z ** 2 + y * z + z * x
                if n <= N:
                    ans[n] += 1
    print(*ans[1:], sep='\n')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 74764
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <complex>

using namespace std;

int main(){

    int e;

    while(cin>>e,e){

        int x,y,z;
        int answer = 1000000;
        /*for(int i=0;i<=e;i++){
            for(int j=0;j<=sqrt(e)-i;j++){
                for(int k=0;k<=pow(e,1.0/3.0)-i+pow(j,2.0);k++){
                    if(i+pow(j,2.0)+pow(k,3.0)==e&&answer>i+j+k){
                        answer = i+j+k;
                    }
                }
            }
        }*/

        for(int k=0;k*k*k<=e;k++){
            for(int j=0;j*j<=e-k*k*k;j++){
                int i=e-j*j-k*k*k;
                    if(answer>i+j+k){
                        answer = i+j+k;
                    }
            }
        }

        cout<<answer<<endl;
    }

    return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
int main()
{
    int a,b,i,j;
    int d=0,f,g,h;
    scanf("%d",&a);
    int x[a];
    char c[12];
    for(i=0;i<a;i++){
        scanf("%s %d",c,&b);
        if(c[0]=='i'){
            x[i]=b;
        }
        else if(c[6]=='F'){
            i-=2;a-=2;
        }
        else if(c[6]=='L'){
            i--;a--;d++;
        }
        else{
            i--;a--;
            f=0;
            for(j=i;j>=0;j--){
                if(f>0)break;
                if(b==x[j]){
                    g=i-j;
                    h=0;
                    f++;
                    while(g!=h++)x[j+h-1]=x[j+1+h-1];
                i--;a--;
                }
            }
        }
    }
    for(i=0;i<a-d;i++){
        if(i==a-d-1)printf("%d\n",x[a-1-i]);
        else printf("%d ",x[a-1-i]);
    }
    return 0;
}

Measured memory_bytes: 5544
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  int d,n;
  cin >> d >> n;
  if(d == 0){
    if(n != 100){
      cout << n << endl;
      return 0;
    }else{
      cout << "101" << endl;
      return 0;
    }
  }
  if(d == 1){
    if(n != 100){
      cout << n*100 << endl;
      return 0;
    }else{
      cout << "10100" << endl;
      return 0;
    }
  }
  if(d == 2){
    if(n != 100){
      cout << n*10000 << endl;
      return 0;
    }else{
      cout << "1010000" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
n,x=gets.chomp.split(" ").map(&:to_i)
xa=gets.chomp.split(" ").map(&:to_i)

#if n==1
  #puts xa[0]-x
#else
xa.push(x)
xa.sort!
d=Array.new(n-1){0}
(n).times do|i|
  d[i]=(xa[i]-xa[i+1] ).abs
end
puts d.inject{|a,b| a.gcd(b)}
#end


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

double kyori(double x1,double y1,double x2,double y2){
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main(){
  double n,res=0.0,x[10],y[10];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];cin>>y[i];
  }
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      res+=kyori(x[i],y[i],x[j],y[j]);
    }
  }
  res=res*2/n;
  cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


 
 
int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> x(n), y(n);
    pair<int,int> maxpt=make_pair(-INF,-INF);
    int maxid=0;
    int i;
    for(i=0; i<n; i++) {
        scanf("%d%d", &x[i], &y[i]);
        if(maxpt<make_pair(x[i],y[i])) {
            maxpt=make_pair(x[i],y[i]);
            maxid=i;
        }
    }
    vector<int> ans;
    ans.push_back(maxid);

    const double PI=3.14159265358979323846;
    const double tol=1e-12;
    double ang0=PI/2;
    while(1) {
        int i0=ans[(int)ans.size()-1];

        vector<pair<double,int> > z;
        for(i=0; i<n; i++) {            
            if(i==i0) continue;

            double t = atan2((double)y[i]-y[i0], (double)x[i]-x[i0]);
            t-=ang0;
            if(t<tol) t+=PI*2;

            z.push_back(make_pair(t, i));
        }
        sort(z.begin(), z.end());

        double maxlen2=0;
        double t0=z[0].first;
        for(i=0; i<n-1; i++) {
            if(z[i].first>t0+tol) break;
            
            int id=z[i].second;
            double len2=(double)(y[id]-y[i0])*(y[id]-y[i0])+(double)(x[id]-x[i0])*(x[id]-x[i0]);
            if(maxlen2<len2) {
                maxlen2=len2;
                maxid=id;
            }
        }

        if(maxid==ans[0]) break;

        ans.push_back(maxid);
        ang0 = atan2((double)y[maxid]-y[i0], (double)x[maxid]-x[i0]);
    }

    vector<double> ans0(n);

    int siz=(int)ans.size();
    if(siz==2) {
        ans0[ans[0]]=0.5;
        ans0[ans[1]]=0.5;
    }
    else {
        vector<double> angles(siz), angles2(siz);
        for(i=0; i<siz; i++) {
            int i0=ans[i];
            int i1=ans[(i+1)%siz];
            angles[i]=atan2((double)y[i1]-y[i0], (double)x[i1]-x[i0]);
        }


        for(i=0; i<siz; i++) {
            angles2[i]=angles[i]-angles[(i-1+siz)%siz];
            if(angles2[i]<0) angles2[i]+=2*PI;

            ans0[ans[i]]=angles2[i]/(2*PI);
        }
    }

    for(i=0; i<n; i++) {
        printf("%.10lf\n", ans0[i]);
    }

    return 0;
}



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

int main()
{
    data_type n,k;
    cin>>n>>k;
    vector<data_type>vc(n),dp(n,INT_MAX);
    for(auto &i:vc)
        cin>>i;
    dp[n-1]=0;
    for(int i=n-2; i>=0; i--)
    {
       for(int j=1;j<=k;j++)
       {
          if(i+j>n-1)
            continue;
          dp[i]=min(dp[i+j]+abs(vc[i]-vc[i+j]),dp[i]);
       }
    }

    cout<<dp[0]<<endl;

    return 0;
}


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

int main() {
    int N;

    cin >> N;

    int A = N / 1000;
    int B = N / 100 - A * 10;
    int C = N / 10 - A * 100 - B * 10;
    int D = N % 10;    

    if (A == B && A == C) {
        cout << "Yes" << endl;
    } else if (B == C && B == D) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin>>n>>m;
    vector<vector<long long int> > v(n, vector<long long int>(2, 0));
    for(int i=0; i<n; i++)
        cin>>v[i][0]>>v[i][1];

	long long int dp[n+1][100001];
	
	for(int i=0; i<=n; i++)
    {
        for(int j=0; j<=100000; j++)
        {
        	if(j==0)
				dp[i][j] = 0;
			else
				dp[i][j] = INT_MAX;
		}
	}
			
	
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=100000; j++)
        {
        	dp[i][j] = dp[i-1][j];
        	if(j-v[i-1][1]>=0)
        	{
        		dp[i][j] = min(dp[i][j], dp[i-1][j-v[i-1][1]]+v[i-1][0]);
			}
		}
    }
    int ans;
    for(int j=1;j<=100000;j++)
	{
		if(dp[n][j]<=m)
		{
			ans=j;
		}
	}
//     for(int i=0; i<=n; i++)
//     {
//         for(int j=0; j<=50; j++)
//         {
//         	cout<<dp[i][j]<<" ";
// 		}
// 		cout<<endl;
//     }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 79104
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
    n: u32,
    m:usize,
    sc: [(usize, usize); m]
    }
    let range = if n == 1 {0..10} else { 10usize.pow(n-1)..10usize.pow(n) };
    for i in range {
        if m == 0 {println!("{}", i); return;};
        let c: Vec<char> = i.to_string().chars().collect();
        let cc = &c;
        for (num, j) in sc.iter().enumerate() {
           if cc[j.0 - 1].to_string()  != j.1.to_string() {
              break;
           }
           if num + 1 == m {
               for i in cc {
                   print!("{}", i);
               }
               return;
           }

        }
    }
    println!("{}", -1);
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll A, B, C, D; cin >> A >> B >> C >> D;
    string ans = (C/B + (C%B!=0) <= A/D + (A%D!=0)) ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;		
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b) 
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	int n, m;
	cin >> n >> m;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	vector<pair<int, ll>> in(m);
	for (int i = 0; i < m; i++)
		cin >> in[i].first >> in[i].second;
	sort(a.begin(), a.end());
	sort(in.begin(), in.end(), [](const pair<int, ll> &l, const pair<int, ll> &r) {return l.second > r.second; });
	int done = 0;
	ll result = 0;
	for (int i = 0; i < m; i++)
	{
		int num = lower_bound(a.begin(), a.end(), in[i].second) - a.begin();
		num -= done;
		if (num <= in[i].first)
		{
			result += in[i].second * num;
			done += num;
			break;
		}

		result += in[i].second * in[i].first;
		done += in[i].first;
	}

	for (int i = done; i < n; i++)
		result += a[i];
	printf("%lld", result);

	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/

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


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    double n;
    cin>>n;
    rep(i,0,n+1){
        if(i*1.08>=n&&i*1.08<n+1){
            cout<<i<<endl;
            exit(0);
        }
    }
    cout<<":("<<endl;

    

}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, ans = 0;
vector<ll> L(2001,0);

int main() {
	cin >> N;
	vector<ll> L(N + 1, 0);
	rep(i, N)cin >> L[i];
	L[N] = 1e4;
	stable_sort(L.begin(), L.end());
	rep(i, N - 1) {
		for (int j = i + 1; j < N; j++) {
			ans += max((ll)0, LBI(L, L[i] + L[j]) - UBI(L, abs(L[i] - L[j])));
			if (abs(L[i] - L[j]) < L[i])ans--;
			if (abs(L[i] - L[j]) < L[j])ans--;
		}
	}
	cout << ans / 3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
	ll n,q,ans[200010];
	set<pair<ll,ll>>d;
	vector<tuple<ll,ll,ll>>ch;
int main() {

	cin>>n>>q;
	for(ll i=0;i<n;i++){
		ll S,T,X;
		cin>>S>>T>>X;
		T--;
		S-=X;
		T-=X;
		ch.push_back(make_tuple(X,S,T));
	}
	sort(ch.begin(),ch.end());
	for(ll i=0;i<q;i++){
		ll now;
		cin>>now;
		d.insert(make_pair(now,i));
		ans[i]=-1;
	}
	for(ll i=0;i<n;i++){
		ll now1=get<1>(ch[i]);
		ll now2=get<2>(ch[i]);
		ll now3=get<0>(ch[i]);
		auto itr=d.lower_bound(make_pair(now1,-1));		
		while(itr!=d.end()){
			if(now2>=itr->first){
			ans[itr->second]=now3;
			itr=d.erase(itr);
			}
			else{
				break;
			}
		}

	}
	for(ll i=0;i<q;i++){
		cout <<ans[i]<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 22124
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

int main() {
    int a, b;
    while(cin >> a >> b) cout << a+b << endl;
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

ll gcd(ll a,ll b){return b ? gcd(b,a%b) :a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}
ll M=1000005;

int main()
{
ll n;
cin >>n;

vector<pair<ll,int>> fs;
for(ll i=2;i*i<=n;++i){
    int x=0;
    while(n%i==0){
        n /=i;
        ++x;
    }
    fs.emplace_back(i,x);
}
if(n!=1)fs.emplace_back(n,1);

int ans =0;
for(auto p:fs){
    ll x=p.second;
    ll b=1;
    while(b<=x){
       x-=b;
       b++;
       ans++;
    }
}
cout<<ans<<endl;
}



Measured memory_bytes: 19780
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    long double a, b;
    cin >> a >> b;
    cout << (long long int)floor(a*b) << endl;
    return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define de(x) cout << #x << " = " << x << endl
#define dd() cout << "Out Put!\n"
const int mod= 1e9+7,maxn=1000010;
const double eps = 1e-8,PI = acos(-1.0);
const int inf=0x7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],v[maxn];
string s;
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b,c;
	cin >> a >> b >> c;
	int ans = 0;
	rep(i,a,b)
		if(i%c==0)
			ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3636
while True:
    H,W=map(int,input().split())
    if H==0 and W==0 :
        break
    for i in range(H):
        s=''
        for j in range(W):
            if (i+j)%2==0:
                s +='#'
            else :
                s +='.'
        print(s)
    print( )


Measured memory_bytes: 5608
def prog(x):
    n = len(x)

    def count25(s): # count25(0)
        if s.find('.') == -1:
            s += '.'
        s = s.rstrip('0')
        decimal_point = s.find('.')
        int_part = s[:decimal_point]
        float_part = s[decimal_point+1:]
        float_part += '0' * (9 - len(float_part))
        n = int(int_part + float_part)
        if n == 0:
            return (0, 0)
        two = five = 0
        while n % 2 == 0:
            two += 1
            n //= 2
        while n % 5 == 0:
            five += 1
            n //= 5
        return (two, five)

    d = {}
    for a in x:
        t = count25(a)
        d.setdefault(t, 0)
        d[t] += 1
    two_five = list(d.keys())
    count = 0
    for i in range(len(two_five)): # i = 0
        two, five = two_five[i]
        cnt = d[two_five[i]]
        if two >= 9 and five >= 9:
            count += cnt * (cnt -1) // 2
        for j in range(i + 1, len(two_five)):
            two2, five2 = two_five[j]
            if two + two2 >= 18 and five + five2 >= 18:
                count += cnt * d[two_five[j]]
    print(count)

n = int(input())
x = [input() for i in range(n)]
prog(x)


Measured memory_bytes: 23276
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;

ll mod = 1000000007;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    ll power = 1;
    for (int i = 1; i <= n; ++i) {
        power = (power*i)%mod;
    }
    cout << power << std::endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    n = N

    f = 0
    while n > 0:
        f += n % 10
        n //= 10

    if N % f == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    int N[10000] ;
    for(int i=0;i<10000;i++){
        N[i] = 0 ;
        cin >> N[i] ;
    }

    int p = 0 , prime[10000] ;
    bool is_prime[10001] ;
    is_prime[1] = false  ;
    
    for(int i=2;i<=10000;i++){
        is_prime[i] = true ;
    }
    
    
   for(int i=2;i<=10000;i++){
       if(is_prime[i]){
           prime[p++] = i ;
           for(int j=i+i;j<=10000;j+=i){
              is_prime[j] = false ; 
           }
       }
   }
   
   int i= 0 ;
   while(N[i]!=0){
       int ans = 0 ;
    
           for(int j=0 ; prime[j]<=N[i]/2 ; j++){
                if(is_prime[N[i]+1-prime[j]]){
                        ans += 2 ;
               }
           }
       if(N[i]==3){
           cout << 1 << endl ;
       }else if(N[i]%2!=0&&is_prime[N[i]/2+1]){
           cout << ans + 1 << endl ;
       }else{
           cout << ans << endl ;
       }
       
       i++ ;
   }
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

int Sum(vector<int> A){return accumulate(A.begin(), A.end(),0LL);}
int Cnt(vector<int> A){
  int cnt = 0;
  for(int a:A) cnt += a%2;
  return cnt;
}

void solve(int n,int m, vector<int> A){
  sort(A.begin(), A.end(), [&](int a,int b){return a%2 < b%2;});
  int cnt = 0;
  for(int a:A) cnt += a%2;
  
  if(cnt >= 3){
    cout<<"Impossible"<<endl;
    return;
  }

  vector<int> B;
  if(cnt == 0 && n % 2 == 0){
    B.push_back(1);
    for(int a:A) B.push_back(a);
    B.back()--;
  }
  
  if(cnt == 2 && n % 2 == 0){
    if(A[m-1] < A[m-2]) swap(A[m-1],A[m-2]);
    swap(A[0], A[m-2]);
    assert(A[0] % 2 == 1 && A[m-1] % 2 == 1 && A[0] <= A[m-1]);
    B = A;
    B[0]++, B[m-1]--;
  }

  if(cnt == 1 && n % 2 == 1){
    B.push_back(1);
    for(int a:A) B.push_back(a);
    B.back()--;
  }

  if(B.back() == 0) B.pop_back();
  assert(accumulate(B.begin(), B.end(), 0LL) == n);
  assert(accumulate(A.begin(), A.end(), 0LL) == n);
  cout<<A<<endl;
  cout<<B.size()<<endl;
  cout<<B<<endl;
}



signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m;
  cin>>n>>m;
  vector<int> A(m);
  cin>>A;
  solve(n, m, A);		 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIN freopen("E:/in.txt", "r", stdin)
using namespace std;
const int maxn = 1e5+5;
char s[maxn];
int main(){
    //FIN;
    scanf("%s", s+1);
    int len = strlen(s+1);
    if(s[1] == '0' || s[len] == '1') {
        printf("-1\n");
        return 0;
    }
    for(int i = 2; i <= len/2; i++){
        if((s[i] == '0' && s[len-i] != '0') || (s[i] == '1' && s[len-i] == '0')){
            printf("-1\n");
            return 0;
        }
    }
    int u = 1, v = 1, pos = 2;
    for(int i = 1; i < len; i++){
        if(s[i] == '0'){
            printf("%d %d\n", u, pos++);
        }
        else{
            printf("%d %d\n", u, pos++);
            u = pos-1;
        }
    }
    return 0;
}

Measured memory_bytes: 1536
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut queue: VecDeque<usize> = VecDeque::with_capacity(n);

    for i in 0..n {
        let a: usize = iterator.next().unwrap().parse().unwrap();
        if i % 2 == 0 {
            queue.push_back(a);
        } else {
            queue.push_front(a);
        }
    }

    let mut result = String::new();

    if n % 2 == 0 {
        for v in queue.iter() {
            result.push_str(&format!("{} ", v));
        }
    } else {
        for v in queue.iter().rev() {
            result.push_str(&format!("{} ", v));
        }
    }

    return result.trim().to_string();
}


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

int a[100000];

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

	int c = 0;
	for(int i=0; i<n; i++){
		if(a[i]%2 == 1) c++;
	}
	if(c%2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
bool visited[100005];
const int max_N=1e5+10;
int A,B;
int main(void)
{
  int N;
  cin >> N;
  cout << 180*(N-2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    ll a[200005];
    ll b[200005];
    ll c[200005];
    int main()
    {
        fastread;
        ll n,i,j,k,l;
        //int n;
        cin>>n;
        for(i=1;i<=n-1;i++)
        cin>>b[i];
        ll sum=b[1];
        for(i=2;i<=n-1;i++)
        sum+=min(b[i-1],b[i]);
        sum+=b[n-1];
        cout<<sum;
        return 0;
    }

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

int main() {
    vector<int> cooking_times;
    for (int i = 0; i < 5; i++) {
        int tmp;
        cin >> tmp;
        cooking_times.emplace_back(tmp);
    }
    int min_arrival_time = (1 << 30) - 1;
    do {
        int arrival_time = 0;
        for (int i = 0; i < cooking_times.size() - 1; i++) {
            int time = cooking_times.at(i);
            time = int(ceil((double)time / 10) * 10);
            arrival_time += time;
        }
        arrival_time += cooking_times.at(4);
        min_arrival_time = min(min_arrival_time, arrival_time);
    } while (next_permutation(cooking_times.begin(), cooking_times.end()));
    cout << min_arrival_time << "\n";
}

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

int main(){
    int N,K;
    cin >> N >> K;
    int num;
    int num2;
    int num3[N];
    int count=0;
    for(int i=0; i<N; i++){
        num3[i]=0;
    }
    for(int i=0; i<K; i++){
        cin >> num;
        for(int j=0; j<num; j++){
            cin >> num2;
            num3[num2-1]++;
        }
    }
    for(int i=0; i<N; i++){
        if(num3[i]==0){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 200010
/*------------------------------------------------------------*/
int n,m;
int a[maxn];
int main(){
	string s;
	cin>>s;
	int l=s.length();
	if(s[0]==s[1]&&s[1]==s[2])outy;
	 else if(s[1]==s[2]&&s[2]==s[3])outy;
	  else outn;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    vector<int> hist(2 * 1010, 0);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        hist[v[i] - 1]++;
    }
    
    // ヒストグラムの累積とるよー
    vector<int> sum(hist.size() + 1, 0);
    for(int i = 1; i < sum.size(); i++) {
        sum[i] = sum[i - 1] + hist[i - 1];
    }
    
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            int left = abs(v[i] - v[j]) + 1;
            int right = v[i] + v[j] - 1;
            
            ans += sum[right] - sum[left - 1];
            
            if(left <= v[i] && v[i] <= right) ans--;
            if(left <= v[j] && v[j] <= right) ans--;
        }
    }
    
    cout << ans / 3 << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0

for i in range(1,n):
    cnt = 0
    x = s[:i]
    y = s[i:]

    x = set(x)
    y = set(y)
    for j in x:
        if j in y: cnt+= 1
    ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 9108
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair

using namespace std;
const int N=2e5+5;
int n,k,a[N];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>k>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    int res=a[n]-a[1];
    for(int i=1;i<n;i++)
    {
        res=min(res,a[i]+k-a[i+1]);
    }
    cout<<res;
}


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

int main(){
      int n;cin >> n;
      long long int arr[n + 5];
      arr[0] = 2;
      arr[1] = 1;
      for(int i = 2;i <= n;i++)arr[i] = arr[i - 1] + arr[i - 2];
      cout << arr[n];
}

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

using ll = long long;

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

    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        if((k & a[i]) == a[i]) {
            ans += b[i];
        }
    }
    for(int i = 30, mask = 0; i >= 0; mask |= (1 << i), --i) {
        if(!(k & (1 << i))) continue;
        const int x = k & mask;
        ll tans = 0;
        for(int j = 0; j < n; ++j) {
            if(a[j] & (1 << i)) continue;
            const int y = a[j] & mask;
            if((y & x) == y) {
                tans += b[j];
            }
        }
        ans = max(ans, tans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
n = int(input())
a = sorted(list(map(int,input().split())),reverse = True)
ans1 = 0
ans2 = 0
for i in range(n):
    if i % 2 == 0:
        ans1 += a[i]
    else:
        ans2 += a[i]
print(ans1-ans2)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll x;
  cin >>x;
 
  for(ll i=0;i<50000;i++){
    if(i*(i+1)/2<x && x<=(i+1)*(i+2)/2) {
    cout << i+1 << 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 N = sc.nextInt();
		int K = sc.nextInt();

		if(N%K == 0) {
			System.out.println("0");
		}else {
			System.out.println("1");
		}

	}

}


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

int main(){
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  int s = a1 + a2 + a3;
  if(s >= 22){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
}


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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define rep(i, n) for (long long i = 0; i < (n); i++)

int main() {
    long long n;
    cin >> n;
    map<int, int> cnt;
    rep(i, n) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    int max = 0;
    for (int i = 0; i < 100000; i++) {
        if (cnt[i] + cnt[i + 1] + cnt[i + 2] > max) {
            max = cnt[i] + cnt[i + 1] + cnt[i + 2];
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		long n = scan.nextLong();
		long k = scan.nextLong();
		
		long x, y = 0;
		
		x = n % k;	//x < k
		y = k - x;
		
		if(x < y) {
			System.out.println(x);
		}
		else if(x > y) {
			System.out.println(y);
		}
		
	}

}


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

double kyori(vector<int> z1, vector<int> z2){
  
  double sum = 0;
  for(int i = 0; i < z1.size(); i++){
    sum += pow(z1.at(i) - z2.at(i), 2);
  }
  
  return pow(sum, 0.5);
}

int main(){
 
  int N, D, i, j, Sum = 0;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  
  for (i = 0; i < N; i++){
    for (j = 0; j < D; j++){
      cin >> X.at(i).at(j);
    }
  }
   
  for (i = 0; i < N; i++){
    for (j = i + 1; j < N; j++){
      
      double Kr = kyori(X.at(i), X.at(j));

      if((Kr - (int)Kr) == 0) Sum++;
    }
  }
  
  cout << Sum << endl;
    
  return 0;
}




Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
using ll=long long;

int main() {
	ll K, X;
	cin >> K >> X;


	if (K*500 >= X) {

		cout << "Yes";
	}
	else {

		cout << "No";
	}



}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    S = input()

    for i in range(len(S)):
        if i + 1 < len(S):
            if S[i] == S[i + 1]:
                print(i + 1, i + 2)
                return
        if i + 2 < len(S):
            if S[i] == S[i + 2]:
                print(i + 1, i + 3)
                return
    print(-1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
//2019.5.20 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace MAIN {
    int n,A,B,o;
    void dfs(res x,res y,res p){
        if(pc(p^o)==1){printf("%d %d ",y,x^y);return;}
        for(res i=0;i<n;i++)
            if((~p>>i&1)&&(x>>i&1))
                for(res j=0;j<n;j++)
                    if((~p>>j&1)&&i!=j){dfs(1<<j,y,p|1<<i),dfs(x^(1<<i)^(1<<j),y^(1<<i)^(1<<j),p|1<<i);return;}
    }
    inline void MAIN(){
        n=read(),A=read(),B=read(),o=(1<<n)-1;
        if(pc(A^B)&1)puts("YES"),dfs(A^B,A,0);
        else puts("NO");
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
    int X,Y,n,fld[20][20],i,j,x,y,z;
    while(1){
        scanf ("%d %d",&X,&Y);
        if (X==0&&Y==0){break;}
        for(i=0; i<=Y;i++){
                for(j=0; j<=X; j++){
                    fld[j][i]=0;
                }

        }
        scanf("%d",&n);
        for(z=0;z<n;z++){
            scanf("%d %d",&x,&y);
            fld[x][y]=-1;
        }
         for(i=1; i<=Y;i++){
                for(j=1; j<=X; j++){
                    if(j==1&&i==1){
                        fld[j][i]=1;}
                        else if(fld[j][i]==-1){
                                fld[j][i]=0;}


                        else{
                            fld[j][i]=fld[j-1][i]+fld[j][i-1];
                        }

                }

        }
        printf ("%d\n",fld[X][Y]);




    }
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;


int main(void){
    // Your code here!
   long long int s;
    cin>>s;
    
    long long int cnt=0;
    long long int id=1;
    
    if(s<5){
        if(s==1){
            id =4;
        }
        
        if(s==2){
            id=4;
        }
        
        if(s==3){
            id=9;
        }
        
        if(s==4){
            id=4;
        }
        
    }else{
    while(cnt!=2){
        
        if(s%2==0){
            s/=2;
        }else{
            s=3*s+1;
        }
        
        if(s==4){
            cnt++;
        }
        
        id++;
    }
    }
    
    cout<<id<<endl;
}


Measured memory_bytes: 256
def findSumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

def main():
    N, A, B = map(int, input().split())
    sum = 0
    for i in range(1, N+1):
        tmp = findSumOfDigits(i)
        if A <= tmp <= B:
            sum += i

    print(sum)

    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys
from io import StringIO
import unittest

def resolve():
    a,b,c = list(map(int,input().strip().split()))
    if (a==b and c!=b):
        print("Yes")
        return
    
    if (a==c and c!=b):
        print("Yes")
        return

    if (b==c and a!=b):
        print("Yes")
        return

    print("No")
    return

resolve()

Measured memory_bytes: 6352
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, K;
    cin >> A >> B >> K;
    ll diff = min(A, K);
    A -= diff;
    K -= diff;
    diff = min(B, K);
    B -= diff;
    K -= diff;
    cout << A << ' ' << B << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt(), a = scanner.nextInt(), b = scanner.nextInt();
		int y = (x - a) / b;
		int result = x - ((a * 1) + (b * y));
		System.out.println(result);
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>

using namespace std;

int n, m, k;
bool bo;

int main()
{
    scanf("%d%d%d", &n, &m, &k);
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= m; j++)
        {
            if(k == (n - i) * j + (m - j) * i) bo = true;
        }
    }
    if(bo) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int n;
		cin>>n;
		if(n >= 30) cout<<"Yes\n";
		else cout<<"No\n";
 	}
 	return 0;
}


Measured memory_bytes: 3632