akhauriyash/Code-Regression huggingface dataset:
def happiness_from_golden_coins():
    # 入力
    X = int(input())
    # 初期化
    count_500yen = 0
    count_5yen = 0
    # 両替処理
    # 500円の個数
    while True:
        if X >= 500:
            count_500yen += 1
            X -= 500
        else:
            break
    # 5円の個数
    while True:
        if X >= 5:
            count_5yen += 1
            X -= 5
        else:
            break
    # 嬉しさ集計
    happiness = (1000 * count_500yen) + (5 * count_5yen)
    return happiness

result = happiness_from_golden_coins()
print(result)

Measured memory_bytes: 9156
package main

import (
  "fmt"
)

func main() {
  var a, b, c int
  fmt.Scanf("%d %d %d", &a, &b, &c)
  
  ans := "No"
  if a == b && b == c {
    ans = "Yes"
  }
  fmt.Printf("%s\n", ans)
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int i = 0;
  int x = 1;
  while(i < N) {
    if(x < K) {
      x *= 2;
    }
    
    else {
      x += K;
    }
    i++;
  }
    cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main(void){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		double x1,y1,x2,y2,x3,y3;
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		double a,b,c,d,e,f;
		a=-2*(x1-x2);
		b=-2*(y1-y2);
		c=x1*x1+y1*y1-x2*x2-y2*y2;
		d=-2*(x1-x3);
		e=-2*(y1-y3);
		f=x1*x1+y1*y1-x3*x3-y3*y3;
		double x,y,r;
		x=(b*f-c*e)/(a*e-b*d);
		y=(c*d-a*f)/(a*e-b*d);
		r=(x-x1)*(x-x1)+(y-y1)*(y-y1);
		r=sqrt(r);
		cout<<fixed<<setprecision(3)
			<<x<<" "<<y<<" "<<r<<endl;
	}
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if(n<a+b-1||a*b<n){
        cout<<-1<<endl;
        return 0;
    }
    vector<ll> ans;
    ll remove=a*b-n;
    for(ll i=0;i<b;i++){
        for(ll j=0;j<a;j++){
            if(i>0&&j==1&&remove>0){
                ll t=min(a-1,remove);
                remove-=t;
                j+=t-1;
            }
            else ans.push_back(a*b-i*a-a+j+1);
        }
    }
    vector<pair<ll,int>> v;
    for(int i=0;i<ans.size();i++){
        v.push_back({ans[i],i});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        ans[v[i].second]=i+1;
    }
    for(int v:ans){
        cout<<v<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 14292
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for(int i = (int)(n-1); i > -1; i--)


ull MOD = 1000000007;
const int D = 160 * 80 + 5;
const int D2 = D * 2;

int height_max, width_max;
int subtract[80][80];
bitset<D2> memo[80][80]; 

int main(){
    int ans = D;
    cin >> height_max >> width_max;

    rep(i,height_max){
        rep(j,width_max){
            cin >> subtract[i][j];
        }
    }
    rep(i,height_max){
        rep(j,width_max){
            int x;
            cin >> x;
            subtract[i][j] = abs(subtract[i][j] - x);
        }
    }
    memo[0][0][D+subtract[0][0]] = true;
    rep(i,height_max) rep(j,width_max) {
        if(i){
            memo[i][j] |= memo[i-1][j]<<subtract[i][j];
            memo[i][j] |= memo[i-1][j]>>subtract[i][j];
        }
        if(j){
            memo[i][j] |= memo[i][j-1]<<subtract[i][j];
            memo[i][j] |= memo[i][j-1]>>subtract[i][j];
        }
    }
    rep(i,D2){
        if(memo[height_max-1][width_max-1][i]){
            ans = min(ans, abs(i - D));
        }
    }
    cout << ans << endl;
}

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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    sort(a.begin(), a.end());

    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            for (int k = j + 1; k < n; k++){
                if (a[i] != a[j] && a[j] != a[k] && (a[i] + a[j] > a[k]))
                    ans += 1;
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3660
A,B,M=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
l=[min(a)+min(b)]
for i in range(M):
   x,y,c=map(int,input().split())
   x-=1
   y-=1
   l.append(a[x]+b[y]-c)
print(min(l))   

Measured memory_bytes: 18488
void solve(string[] s){
	foreach(elm; s){
		writeln(elm);
		writeln(elm);
	}
}
void main(){
	int[] hw = inln();
	string[] s;
	foreach(_; 0..hw[0])s ~= readln().chomp();
	solve(s);
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


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

int main() {
  int N,result=0 ;
  cin >> N;
  for(int i=0;i<N;i++){
    char S;
    cin >> S;
    if (S=='Y')
      result=1;
}
  if (result==0)
    cout<< "Three"<< endl;
  else cout <<"Four"<< endl;
}

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

int main() {
    int N, X;
    cin >> N >> X;

    int B = 1, D = 0;

    for(int i=0; i<N ; i++){
        int L;
        cin >> L;

        D += L;
        if(D <= X) B++;
    }

    cout << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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

int main(){
	int N; SCD(N);
	vector<ll> A,B,U;
	vector<ll> Q;
	ll req = 0;
	ll sum = 0;
	ll ans = 0;
	REP(i,N){
		int a; SCD(a);
		A.PB(a);
	}

	REP(i,N){
		int b; SCD(b);
		B.PB(b);
	}

	REP(i,N){
		sum += (A[i] - B[i]);
		U.PB(A[i]-B[i]);
		if (A[i] < B[i]) {
			req += (B[i] - A[i]);
			ans++;
		}

		if (A[i] > B[i]) Q.PB(A[i] - B[i]);
	}

	if (sum < 0){
		PRINTD(-1);
		return 0;
	}

	sort(ALL(Q));
	reverse(ALL(Q));
	REP(i,Q.size()){
		if (req <= 0) break;
		ll q = Q[i];
		ans++;
		req -= q;
	}

	PRINTD(ans);

	return 0;
}

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

int main(){
    int A, B;
    scanf("%d %d", &A, &B);
    if(A > 9 || B > 9) {
        printf("-1\n");
    }else{
        printf("%d\n", A*B);
    }
    return 0;
}

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ALphabet {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      char c; cin >> c;
      if (c >= 'a') {
        cout << 'a' << endl;
      } else {
        cout << 'A' << endl;
      }
    }
};

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

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

int main() {
	int n;cin>>n;
	vector<int> b(n-1);
	for(int i=0;i<n-1;i++){
		cin>>b[i];
	}
	int ans=b[0];
	for(int i=1;i<n-1;i++){
		ans+=min(b[i],b[i-1]);
	}
	ans+=b[n-2];
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
  ll n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.rbegin(), h.rend());
  ll sum = 0;
  for (ll i = k; i < n; i++)
  {
    sum += h[i];
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
   ll n,k;
   cin>>n>>k;
   vll a(n+1),b(n+1);
   for(ll i=0;i<n;i++)cin>>a.at(i+1);
   for(ll i=0;i<n;i++)b.at(i+1)=0;
   b.at(1)=1;
   ll next_area=a.at(1);
   ll loopst=1,loopt=0;
   while(1){
       if(b.at(next_area)==1)break;
       else{
           b.at(next_area)=1;
           next_area=a.at(next_area);
           loopst++;
       }
   }
   
   ll loops=next_area;
   loopt++;
   next_area=a.at(next_area);
   
   while(1){
       if(next_area==loops)break;
       else{
           next_area=a.at(next_area);
           loopt++;
       }
   }
   if(k==1)cout<<a.at(1);
   else if(k<=loopst){
       next_area=a.at(1);
       for(ll i=0;i<k-1;i++){
           next_area=a.at(next_area);
       }
       cout<<next_area<<endl;
   }else{
       k-=loopst;
       //k++;
       k=k%loopt;
       next_area=loops;
       for(ll i=0;i<k;i++){
           next_area=a.at(next_area);
           //cout<<next_area<<endl;
       }
       cout<<next_area<<endl;
   }
   //cout<<loopst<<" "<<loops<<" "<<loopt<<endl;
}
   



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

int main(){
    string s1;
    string s2;
    cin>>s1>>s2;
    int n1 = s1.length();
    int n2 = s2.length();

    int dp[n1+1][n2+1];
    for(int i=0;i<=n1;i++){
        for(int j=0;j<=n2;j++){
            if(i==0 || j==0) dp[i][j]=0;
            else{
                if(s1[i-1]==s2[j-1]) dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    string ans="";
    int i=n1,j=n2;
    while(i>0 && j>0){
         if(dp[i][j]==dp[i-1][j])
            i--;
        else if(dp[i][j]==dp[i][j-1])
            j--;
        else{
            ans=s1[i-1]+ans;
            i--;
            j--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 38856
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



void solve(){
  int x;
  cin >> x;
  vector<int>v;
  v.push_back(1);
  for(int i=2;i*i<=x;i++){
    int tmp=i;
    while(1){
      if(tmp>x)break;
      tmp*=i;
    }
    v.push_back(tmp/i);
  }
  sort(v.begin(),v.end());
  cout << v[v.size()-1] << endl;
}

int main(){
  solve();
  return 0;
}


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

int main(){
  int N;
  int count=0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for(int i=0; i<N; i=i+2){
    if(a.at(i)%2==1){
      ++count;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
#include<cstdio>
using namespace std;
int main()
{
	int n,x[365],y[365],b[365],p[365],i,sum,a,min;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&x[i],&y[i],&b[i],&p[i]);
	}
	for(i=0;i<n;i++){
		//printf("i=%d\n",i);
		min=x[i]*b[i]+y[i]*p[i];
		if(p[i]<2){
			p[i]=2;
		}
		if(b[i]<5){
			b[i]=5;
		}
		//printf("b=%d p=%d\n",b[i],p[i]);
		a=x[i]*b[i]+y[i]*p[i];
		a-=a*2/10;
		if(min>a){
			min=a;
		}
		//printf("sum=%d a=%d\n",sum,a);
		printf("%d\n",min);
	}
	return 0;
}



Measured memory_bytes: 2768
// God put a smile upon your face <3

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

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

//    slld(testcase);

    string str;

    while(cin >> str)
    {
		str.resize(3);
		cout <<str << '\n';
    }


}




Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define N 5005
using namespace std;
const int INF=0x3f3f3f3f;
int n,p[N],x[N];
vector<int> v[N];
int dp[1005],temp[2][5005];
inline void mmin(int &x,int y){x>y?x=y:0;}
int main(){
    scanf("%d",&n);
    for(int i=2;i<=n;i++) scanf("%d",&p[i]),v[p[i]].push_back(i);
    for(int i=1;i<=n;i++) scanf("%d",&x[i]);
    for(int i=n;i>=1;i--){
        if(v[i].size()==0) dp[i]=0;
        else{
            memset(temp,0x3f,sizeof(temp));
            int now=0;temp[now][0]=0;
            for(int j:v[i]){
                memset(temp[now^1],0x3f,sizeof temp[0]);
                for(int k=0;k<=x[i];k++)
                    if(temp[now][k]!=INF){
                        if(k+x[j]<=x[i]) mmin(temp[now^1][k+x[j]],temp[now][k]+dp[j]);
                        if(k+dp[j]<=x[i]) mmin(temp[now^1][k+dp[j]],temp[now][k]+x[j]);
                    }
                now^=1;
            }
            dp[i]=temp[now][0];
            for(int j=0;j<=x[i];j++) mmin(dp[i],temp[now][j]);
            if(dp[i]==INF) return puts("IMPOSSIBLE"),0;
        }
    }
    return puts("POSSIBLE"),0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

long long DIV = (long long)(1e9+7);

long long Hatvany(long long n, long long h)
{
    if(h == 0)
        return 1;
    return ((h&1) ? Hatvany(n*n%DIV, (h>>1))*n : Hatvany(n*n%DIV, (h>>1)))%DIV;
}

long long fakt[(int)(5e5+1)], fakt2[(int)(5e5+1)];

long long Komb(int n, int k)
{
    return (fakt[n]*fakt2[k]%DIV)*fakt2[n-k]%DIV;
}

long long Perm(int n, int k)
{
    return fakt[n]*fakt2[k]%DIV;
}

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

    fakt[0] = 1;
    for(int i = 1; i < (int)(5e5+1); i++)
        fakt[i] = (fakt[i-1] * (long long)i)%DIV;
    for(int i = 0; i < (int)(5e5+1); i++)
        fakt2[i] = Hatvany(fakt[i], DIV-2);

    int n, m;
    cin>>n>>m;

    if(n > m)
    {
        cout<<"0\n";
        return 0;
    }

    long long x = 0;
    for(int i = 0; i <= n; i++)
    {
        if((i&1))
            x = (x - Komb(n, i)*Perm(m-i, m-n)%DIV + DIV)%DIV;
        else
            x = (x + Komb(n, i)*Perm(m-i, m-n))%DIV;
    }

    cout<<(x*Perm(m, m-n)%DIV)<<"\n";

    return 0;
}


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

int main(){
    string N;
    cin >> N;
    unsigned long long sum = 0LL;
    for(int i = 0; i < N.length(); i++) {
      sum += (int)N[i] - 48;
    }
    if(sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <complex>
#include <vector>
#include <set>
#define rep(i, n) for(i = 0; i < n; i++)
#define repn(i, m, n) for(i = m; i < n; i++)
#define int long long
using namespace std;
typedef complex<double> P;

int mod = 998244353;
int pow2[201];
int n;
P p[200];

double cross(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); }
bool onLine(P a, P b, P p) { return cross(b - a, p - a) == 0; }

signed main() {
	int i, j, k;
	
	pow2[0] = 1;
	repn(i, 1, 201) pow2[i] = (pow2[i - 1] * 2) % mod;
	
	cin >> n;
	rep(i, n) { double x, y; cin >> x >> y; p[i] = P(x, y); }
	
	int ans = pow2[n];
	
	set<vector<int> > dict;
	rep(i, n) {
		repn(j, i + 1, n) {
			vector<int> vec;
			rep(k, n) if (onLine(p[i], p[j], p[k])) vec.push_back(k);
			if (dict.find(vec) != dict.end()) continue;
			dict.insert(vec);
			ans += mod - (pow2[vec.size()] - vec.size() - 1);
			ans %= mod;
		}
	}
	ans += mod - n - 1; ans %= mod;
	cout << ans << endl;
	return 0;
}

//点集合Sについて、Sが凸多角形なら「2^(凸多角形Sの内部にある点の個数)」がスコアになる。それ以外なら0がスコアになる。スコアの和を求めたい。
//2^nが何を表すか？例えば、{1,2,…,n}の部分集合は2^n個ある。つまり、Sが凸多角形のときのスコアは、{Sの内部にある点}の部分集合の個数と等しい。
//そこで、「点集合Sについて、Sの凸法が存在するなら1点, 存在しないなら0点」というスコアリングを考える。実はこれの和が、そのまま答えになる。
//なぜだろうか。Sの凸法が存在するとき、凸法の点集合をTとおいてみる。Sが与えられたとき、Tはちょうど1個に定まる。ここで、S->Tという写像fを
//考える。すると、各Tについて「2^(凸多角形Tの内部にある点の個数)」だけ矢印が来ていることが分かる。
//また、写像fによって得られるTの集合（値域）は、与えられたN個の点によって作ることのできる「凸多角形」の集合と一致する。
//新しいスコアリングでは、矢印の個数の和が合計スコアとなるが、これは上述より本問の答えと一致した。
//
//したがって、「凸法が存在するような点集合S」の個数を求める問題になる。補問題として「凸法が存在しないような点集合S」を考えると、Sは
//直線または点または空集合を表すことが分かる。したがって、まず「答え=2^N」を仮定し、
//そのような直線を全部列挙し、2^(乗っている点の個数) - (乗っている点の個数) - 1
//を答えから引いていき、最後に答えからN+1を引けば、正しい答えが求まる。
//計算量はO(N^3)となる()
//
//直線の列挙法：
//直線は「乗っている点の集合X」と一対一対応するので、Xが今までに出現していないときだけ、リストに追加すればOK.
//既に現れた点集合Xを、ハッシュで管理するとO(N^3), setで管理するとO(N^3logN)となる。

Measured memory_bytes: 2176
N = int(input())
Z = int(N/1.08)

for i in range(Z,Z+2):
    if N/1.08 <= i < (N+1)/1.08:
        if int(N/1.08) == int((N+1)/1.08):
            print(Z)
            break
        else:
            print(Z+1)
            break
else:
    print(":(")

Measured memory_bytes: 3060
use std::io;


fn main() {
    let x = read_one::<usize>();
    let con = if x < 1200 { "ABC" } else { "ARC" };
    println!("{}", con);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll a, b;
  cin >> a >> b;
  ll ans = 0;
  if (a > b) ans = a - b;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v) cout << i << ' ' << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vin2(v, w) for (ll i = 0; i < v.size(); ++i) cin >> v[i] >> w[i];
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }

template <typename T>
map<T, T> prime_factor(T n) {
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++) {
        T tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        ret[i] = tmp;
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

template <typename T>
T divisor_num(T N) {
    map<T, T> pf = prime_factor(N);
    T ret = 1;
    for (auto p : pf) {
        ret *= (p.second + 1);
    }
    return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(18);

	long long N;
	cin >> N;
	long long int cnt = 0;

	repk(i, 1, N){
		cnt +=  floor((double)(N - 1) / (double)i);
		//cout << i << " " << cnt << endl;
	}
	cout << cnt;

    return 0;
}


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

int main()
{
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  int i;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for(i = 0; i < n; i++)
  {
    if(x >= a.at(i))
    {
      ans++;
      x -= a.at(i);
    }
  }
  if(ans == n && x > 0) ans--;
  cout << ans << endl;
}

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

int main() {
	int a[3],tmp;
	cin >> a[0];
	cin >> a[1];
	cin >> a[2];
	for (int j = 0; j < 3; j++) {
		for (int i = 0; i < 3; i++) {
			if (a[j] < a[i]) {
				tmp = a[j];
				a[j] = a[i];
				a[i] = tmp;
			}
		}
	}
	

	cout <<a[0]<<" "<< a[1]<< " " << a[2] << endl;
	


	return 0;
}

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

using namespace std;
using ll = long long;

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

  const ll mod = 1e9 + 7;

  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;

  vector<int> patterns;
  for (int i = 0; i < n;) {
    if (s1[i] == s2[i]) {
      // 縦は1
      patterns.push_back(1);
      i++;
    } else {
      // 横は0
      patterns.push_back(0);
      i += 2;
    }
  }

  ll ans = 1;
  if (patterns[0] == 0) {
    ans = 6;
  } else {
    ans = 3;
  }
  for (int i = 1; i < patterns.size(); i++) {
    if (patterns[i - 1] == 0 && patterns[i] == 0) {
      // aabb
      // ccdd
      ans *= 3;
    } else if (patterns[i - 1] == 0 && patterns[i] == 1) {
      // aab
      // ccb
    } else if (patterns[i - 1] == 1 && patterns[i] == 0) {
      // abb
      // acc
      ans *= 2;
    } else {
      // ab
      // ab
      ans *= 2;
    }
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

long long n;

int main()
{
	scanf("%lld",&n);
	long long min_step=1e18;
	for(register long long i=1;i*i<=n;++i)
	{
		if(n%i==0)
		{
			long long step=(i-1)+(n/i-1);
			min_step=min(min_step,step);
		}
	}
	printf("%lld",min_step);
	return 0;
}

Measured memory_bytes: 256
f _  [_] = 1
f o (x:xs@(y:_))
  | p == EQ = f o xs
  | o == EQ || o == p = f p xs
  | otherwise = 1 + f EQ xs
  where p = x `compare` y
main = do
  getLine
  as <- map read . words <$> getLine :: IO [Integer]
  print $ f EQ as

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

int main() {
	int n, m;
	cin >> n;
	vector<string> A(n);
	for (int i = 0; i < n; i++)cin >> A.at(i);
	cin >> m;
	vector<string> B(m);
	for (int i = 0; i < m; i++)cin >> B.at(i);
	vector<string> name(m+n, " ");
	vector<int> mny(m+n, 0);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (A.at(i) == name.at(j))
			{
				mny.at(j)++;
				break;
			}
			else if (name.at(j) == " ")
			{
				name.at(j) = A.at(i); mny.at(j)++;
				break;
			}
		}

	}
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (B.at(i) == name.at(j))
			{
				mny.at(j)--;
				break;
			}
			else if (name.at(j) == " ")
			{
				name.at(j) = B.at(i); mny.at(j)--;
				break;
			}
		}

	}

	int max = 0;
	for (int i = 0; i < m+n; i++)
	{
		if (max < mny.at(i)) max = mny.at(i);
		// cout << name.at(i) << " " << mny.at(i) << endl;
	}
	cout << max << endl;

}


Measured memory_bytes: 3592
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

X, N = map(int, input().split())
P = list(map(int, input().split()))

dist_min = 1000000
ans = 10000
for i in range(-10, 110):
    if i in P:
        continue
    else:
        dist = abs(X-i)
        # print(i, dist)
        if dist_min>dist:
            dist_min = dist
            ans = i
print(ans)

Measured memory_bytes: 65460
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    cout << n / 3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<ll,int> P;

int main() {
	int n,m;
	string a[50];
	string b[50];

	cin>>n>>m;
	for(int i=0;i<n;++i)cin>>a[i];
	for(int i=0;i<m;++i)cin>>b[i];
	bool flg;
	for(int i=0;i<n-m+1;++i){
		for(int j=0;j<n-m+1;++j){
			flg=true;
			for(int k=0;k<m;++k){
				for(int h=0;h<m;++h){
					if(a[i+k][j+h]!=b[k][h])flg=false;
				}
			}
			if(flg){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define edge(u) for(re int i=head[u];i;i=e[i].nxt)
#define ll long long
using namespace std;
const int mod=924844033;
const int N=8e5+5;
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,lim=1,l,r[N],head[N],num[N],sz[N],cnt;
struct edge{
	int to,nxt;
}e[N];
void add(int a,int b){
	e[++cnt].to=b;
	e[cnt].nxt=head[a];
	head[a]=cnt;
}
ll ans[N],fac[N],inv[N],f[N],g[N];
ll c(int n,int m){return fac[n]*inv[m]%mod*inv[n-m]%mod;}
ll qp(ll x,ll k){
	ll res=1;
	while(k){
		if(k&1) res=res*x%mod;
		k>>=1,x=x*x%mod;
	}
	return res;
}
void ntt(ll *tmp,int tp){
	inc(i,0,lim-1) if(i<r[i]) swap(tmp[i],tmp[r[i]]);
	for(re int mid=1;mid<lim;mid<<=1){
		ll gn=qp(5,(mod-1)/(mid<<1));
		if(tp==-1) gn=qp(gn,mod-2);
		for(re int i=0;i<lim;i+=(mid<<1)){
			ll g=1;
			inc(j,0,mid-1){
				ll x=tmp[i+j],y=g*tmp[i+j+mid]%mod;
				tmp[i+j]=(x+y)%mod;
				tmp[i+j+mid]=(x-y+mod)%mod;
				g=g*gn%mod;
			}
		}
	}
	if(tp==-1){
		ll inv=qp(lim,mod-2);
		inc(i,0,lim-1) tmp[i]=tmp[i]*inv%mod;
	}
}
void init(){
	n=read();
	inc(i,2,n){
		int a=read(),b=read();
		add(a,b),add(b,a);
	}
	fac[0]=inv[0]=inv[1]=1;
	inc(i,1,n) fac[i]=fac[i-1]*i%mod;
	inc(i,2,n) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	inc(i,3,n) inv[i]=inv[i-1]*inv[i]%mod;
}
void dfs(int u,int f){
	sz[u]=1;
	edge(u){
		int v=e[i].to;
		if(v==f) continue;
		dfs(v,u);
		sz[u]+=sz[v];	
	}
	if(u!=1){
		num[sz[u]]++;
		num[n-sz[u]]++;
	} 
}
int main(){
	init();dfs(1,0);
	inc(i,1,n) g[i]=inv[n-i];
	inc(i,1,n) f[i]=num[i]*fac[i]%mod;
	inc(i,1,n) ans[i]=n*c(n,i)%mod;
	while(lim<=2*n) lim<<=1,l++;
	inc(i,0,lim-1) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	ntt(g,1),ntt(f,1);
	inc(i,0,lim-1) f[i]=f[i]*g[i]%mod;
	ntt(f,-1);
	inc(i,1,n) (ans[i]+=mod-inv[i]*f[i+n]%mod)%=mod;
	inc(i,1,n) printf("%lld\n",ans[i]);	
}
/*
3
1 2
2 3
*/

Measured memory_bytes: 37344
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1e5+10;
int n,v,a[N];
long long ans;
int main(){
	scanf("%d%d",&n,&v);
	for (int i=1,x;i<=n;++i){
		scanf("%d",&x);
		a[i]=min(v-a[i-1],x);
		ans+=x-a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	int min_num = *min_element(v.begin(), v.end());
	int max_num = *max_element(v.begin(), v.end());
	cout << max_num - min_num << endl;
}

Measured memory_bytes: 256
n = int(input())
w = []
for i in range(n):
  a, b = map(int, input().split())
  w.append((b, a))
w = sorted(w)
t, ans = 0, 0
for i in range(n):
  t += w[i][1]
  if t > w[i][0]:
    ans += 1
    break
if ans == 1:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 30988
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <unordered_map>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<pair<T, T> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> balls(n);
	vector<int> occs(n + 1);
	for (int i = 0; i < n; ++i) {
		cin >> balls[i];
		++occs[balls[i]];
	}

	long long ways = 0;
	for (int i = 1; i <= n; ++i) {
		ways += ((long long) occs[i] * (occs[i] - 1) / 2);
	}

	for (int i = 0; i < n; ++i) {
		long long old_ways = (long long) occs[balls[i]] * (occs[balls[i]] - 1) / 2;
		--occs[balls[i]];
		long long new_ways = (long long) occs[balls[i]] * (occs[balls[i]] - 1) / 2;
		++occs[balls[i]];
		cout << ways - (old_ways - new_ways) << "\n";
	}

	return 0;

}

Measured memory_bytes: 4224
#!/usr/bin/env python

n = int(input())
a = list(map(int, input().split()))
mod = int(1e9)+7

s = sum(a)
ans = sub = 0 
for i in range(n):
    ans += a[i]*s
for i in range(n):
    sub += a[i]*a[i]
ans = ((ans-sub)//2)%mod
print(ans)


Measured memory_bytes: 31608
#include <cstdio>
#include <algorithm>
#define maxn 100010
using namespace std;
typedef long long ll;
int n;
ll a,b,h[maxn];
bool test(ll mid) {
	ll cnt=0;
	for (int i=1;i<=n;i++) {
		ll c=h[i]-mid*b;
		if (c>0) {
			if (c%(a-b)==0)
				cnt+=c/(a-b);
			else cnt+=c/(a-b)+1;
		}
	}
	return cnt<=mid;
}
int main() {
	scanf("%d %lld %lld",&n,&a,&b);
	ll maxh=0;
	for (int i=1;i<=n;i++) {
		scanf("%lld",&h[i]);
		maxh=max(maxh,h[i]);
	}
	ll l=0,r=maxh/b+1;
	while (l<r) {
		ll mid=(l+r)/2;
		if (test(mid))
			r=mid;
		else l=mid+1;
	}
	printf("%lld\n",l);
	return 0;
}

Measured memory_bytes: 896
K, T, *a = map(int, open(0).read().split())
a = sorted(a)
for i in range(T-1):
  a[i+1] += a[i]
ans = K - 1
for i in range(T-1):
  ans = max(0, min(ans, abs(a[T-1] - 2 * a[i]) - 1))
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

ll pow(ll a, ll p){
  ll ret = 1;
  for (int i=0; i<p; i++) ret *= a;
  return ret;
}

int main(){
  ll X;
  cin >> X;
  vector<vector<ll>> table;
  for (ll i=-1000; i<=1000; i++){
    vector<ll> tmp;
    for (ll j=-1000; j<=1000; j++){
      tmp.push_back(pow(i, 5) - pow(j, 5));
    }
    table.emplace_back(tmp);
  }
  ll A = 0, B = 0;
  for (int i=0; i<2001; i++){
    for (int j=0; j<2001; j++){
      if (table[i][j] == X){
        A = i - 1000;
        B = j - 1000;
        break;
      }
    }
  }
  cout << A << " " << B << "\n";
  return 0;
}

Measured memory_bytes: 34620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w; cin >> h >> w;
    auto a = vec<ll>(h, w), b = a; 
    cin >> a >> b;

    auto cost = a;
    FOR(i, 0, h)FOR(j, 0, w)cost[i][j] = abs(a[i][j] - b[i][j]);
    
    auto dp = vec<bool>(h, w, 80 * (h + w));
    dp[0][0][cost[0][0]] = true;
    FOR(i, 0, h)FOR(j, 0, w)FOR(k, 0, 80 * (h + w)) {
        if (!dp[i][j][k])continue;
        if (i < h - 1) {
            dp[i + 1][j][k + cost[i + 1][j]] = true;
            dp[i + 1][j][abs(k - cost[i + 1][j])] = true;
        }
        if (j < w - 1) {
            dp[i][j + 1][k + cost[i][j + 1]] = true;
            dp[i][j + 1][abs(k - cost[i][j + 1])] = true;
        }
    }

    FOR(i, 0, 80 * (h + w))if (dp[h - 1][w - 1][i]) {
        cout << i << "\n";
        return 0;
    }
}


Measured memory_bytes: 12928
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto D = s[1];
    auto A = iota(N).map!(_ => readln.split.map!(to!long).array).array;
    long ans = 0;

    foreach (i; 0..N) foreach (j; i+1..N) {
        auto x = D.iota.map!(k => (A[i][k] - A[j][k])^^2).sum;
        auto sq = sqrt(x.to!real).to!long;
        if (sq * sq == x) ans += 1;
    }

    ans.writeln;
}

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

int main() 
{
        int n;
        cin>>n;
        vector<double> v(n) ;
        for(int i=0;i<n;i++)cin>>v[i];
        double t= 0;
        for(int i=0;i<n;i++)t+=(1/v[i]);
        t= 1/t;
        cout<<t<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int k;
    cin >>k;
    int c = 0;
    for(int i = 1; i <= k; i++)
    {
        for(int j =i+1;j<=k;j++)
        {
            if (i %2 == 0 && j%2 == 1)
                c++;
            if (j %2 == 0 && i%2 == 1)
                c++;
        }
    }
    cout << c;
}

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

int span(int a, int m) {
  int cnt = 1;
  int x = a % m;
  while(x != 1) {
    x = (a * x) % m;
    cnt++;
  }
  return cnt;
}

int gcd(int m, int n) {
  if ((m == 0) || (n == 0)) return 0;
  int r = 1;
  while(r != 0) {
    r = m % n;
    m = n;
    n = r;
  }
  return m;
}

int lcm(int m, int n) {
  if ((m == 0) || (n == 0)) return 0;
  return (m * n) / gcd(m, n);
}

int solve(vector<int> a, vector<int> m) {
  vector<int> s(3);
  for (auto i = 0; i < 3; i++) {
    s[i] = span(a[i], m[i]);
  }
  
  int ans = lcm(s[0], s[1]);
  ans = lcm(ans, s[2]);

  return ans;
}

signed main() {
  vector<int> a(3), m(3);
  int a1, m1, a2, m2, a3, m3;
  while(cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2], a[0] != 0) {
    cout << solve(a, m) << endl;
  }
  
  return 0;
}


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

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define rep2(name,container) for(auto name=begin(container); name != end(container);name++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;

using people = uint16_t;
const ll MAX_N = 15;
people dp[MAX_N + 1][2] = {};


ll count_people(people p) {
	ll cnt = 0;
	while (p) {
		cnt += p & 1;
		p >>= 1;
	}
	return cnt;
}


ll dfn(people cur, people ok, people ng, ll i, ll n)
{
	if (i == n) {
		if (((cur & ok) == ok) && ((cur & ng) == 0))
			return count_people(cur);
		else
			return 0;
	}
	return max(dfn(cur, ok, ng, i + 1, n), dfn(cur | 1 << i, ok | dp[i][1], ng | dp[i][0], i + 1, n));
}


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

	ll n;
	cin >> n;
	rep(i, 0, n) {
		ll c; cin >> c;
		rep(j, 0, c) {
			ll x, y; cin >> x >> y; x--;
			dp[i][y] |= 1 << x;
		}
	}
	cout << dfn(0, 0, 0, 0, n) << endl;

	return 0;
}


Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var z0 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
        var z1 = new string[]  { "00000", "00001", "00010", "00011", "00100", "00101", "00110", "00111", "01000", "01001", "01010", "01011", "01100", "01101", "01110", "01111", "10000", "10001", "10010", "10011", "10100", "10101", "10110", "10111", "11000", "11001", "11010", "11011", "11100", "11101", "11110", "11111" };
        var z2 =  new string[] { "101", "000000", "000011", "10010001", "010001", "000001", "100101", "10011010", "0101", "0001", "110", "01001", "10011011", "010000", "0111", "10011000", "0110", "00100", "10011001", "10011110", "00101", "111", "10011111", "1000", "00110", "00111", "10011100", "10011101", "000010", "10010010", "10010011", "10010000" };
        var z3= " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        var d0 = new Dictionary<char, string>();
        var d1 = new Dictionary<string,char>();
        for (int i = 0; i < 32; i++)
        {
            d0[z0[i]] = z1[i];
            d1[z2[i]] = z3[i];
        }
        string a;
        for (; (a = Console.ReadLine()) != null;)
        {
            var s = "";
            for (int i = 0; i < a.Length; i++)
                s += d0[a[i]];
            getAns(d1, s);
        }
    }
    static void getAns ( Dictionary<string,char> d ,  string s)
    {
        var ans = "";
        var sL = s.Length;
        var p = 0;
        while (p <= sL -3 )
        {
            for (int i = 3; i <= 8; i++)
            {
                if (p + i > sL) goto next;
                var w = s.Substring(p, i);
                if (d.ContainsKey(w)) { ans += d[w];  p += i;     break; }
            }
        }
        next:;
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 18040
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 n = sc.nextInt();
      	while (n>=1000) {
         	n-=1000; 
        }
      	System.out.println(n==0 ? n : 1000-n);
    }
}


Measured memory_bytes: 35644
import std.conv, std.stdio, std.algorithm, std.string, std.range;

void main() {
  const input = readln.split.map!(to!int).array;
  if (1 <= min(input[0], input[1]) && max(input[0], input[1]) <= 9) {
    (input[0] * input[1]).writeln;
  } else {
    (-1).writeln;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if((abs(a-b)-1)&1)
	{
		cout<<"Alice";
	}
	else cout<<"Borys";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> p(n);
	rep(i,n){
		cin >> p[i];
		p[i]--;
	}
	union_find uf(n);
	rep(i,m){
		int x, y;
		cin >> x >> y;
		x--; y--;
		uf.unite(x,y);
	}
	int ans = 0;
	rep(i,n){
		if(i == p[i] || uf.same(i, p[i])) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
//
//  QuickSort.cpp
//  AtCoder
//
//  Created by A on 2018/06/01.
//  Copyright © 2018年 A. All rights reserved.
//

#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX / 2+2], R[MAX / 2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
    int i, j, k;
    int n1 = mid-left;
    int n2 = right-mid;
    for(i=0; i<n1; i++) L[i]=A[left+i];
    for(i=0; i<n2; i++) R[i]=A[mid+i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for(k=left; k<right; k++){
        if(L[i].value <= R[j].value){
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right){
    int mid;
    if(left+1<right){
        mid = (left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int partition(struct Card A[], int n, int p, int r){
    int i, j;
    struct Card t, x;
    x = A[r];
    i = p - 1;
    for(j=p; j<r; j++){
        if(A[j].value <= x.value){
            i++;
            t=A[i]; A[i]=A[j]; A[j]=t;
        }
    }
    t=A[i+1]; A[i+1]=A[r]; A[r]=t;
    return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
    int q;
    if(p<r){
        q = partition(A, n, p, r);
        quickSort(A, n, p, q-1);
        quickSort(A, n, q+1, r);
    }
}

int main(){
    int n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
    
    scanf("%d", &n);
    
    for(i=0; i<n; i++){
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
    
    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n-1);
    
    for(i=0; i<n; i++){
        if(A[i].suit != B[i].suit) stable = 0;
    }
    
    if(stable==1) printf("Stable\n");
    else printf("Not stable\n");
    for(i=0; i<n; i++){
        printf("%c %d\n", B[i].suit, B[i].value);
    }
    
    return 0;
}



Measured memory_bytes: 5036
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll a,b;
  cin >> a >> b;
  if(a<b){
    rep(i,b)cout << a;
    cout << endl;
  }else{
    rep(i,a)cout << b;
    cout << endl;
  }
return 0;}

Measured memory_bytes: 256
n, x = map(int, input().split())
xs = list(map(int, input().split()))

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

import numpy as np

xs = np.array(xs)
diffs = abs(xs - x)

ans = diffs[0]
for i in range(1, n):
    ans = gcd(ans, diffs[i])
print(ans)


Measured memory_bytes: 17148