akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

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

int fact[N * N], inv_fact[N * N], dp[N][N];

int binom(int n, int k)
{
    return 1LL * fact[n] * inv_fact[k] % MOD * inv_fact[n - k] % MOD;
}

void update(int& x, int a)
{
    x += a;
    if (x >= MOD) {
        x -= MOD;
    }
}

int main()
{
    fact[0] = fact[1] = inv_fact[1] = 1;
    for (int i = 2; i < N * N; ++ i) {
        fact[i] = 1LL * fact[i - 1] * i % MOD;
        inv_fact[i] = 1LL * inv_fact[MOD % i] * (MOD - MOD / i) % MOD;
    }
    inv_fact[0] = 1;
    for (int i = 1; i < N * N; ++ i) {
        inv_fact[i] = 1LL * inv_fact[i - 1] * inv_fact[i] % MOD;
    }
    int n, m;
    scanf("%d%d", &n, &m);
    if (m == 1) {
        puts("1");
    } else {
        dp[0][0] = 1;
        for (int z = 0; z <= n; ++ z) {
            for (int f = 0; f <= z; ++ f) {
                if (z < n) {
                    update(dp[z + 1][f], dp[z][f]);
                }
                if (f < z) {
                    int left = (n - z) + (n - f - 1) + (m - 2) * (n - f);
                    update(dp[z][f + 1], 1LL * dp[z][f] * binom(left, m - 2) % MOD);
                }
                // printf("%d ", dp[z][f]);
            }
            puts("");
        }
        printf("%d\n", (int)(1LL * fact[n] * dp[n][n] % MOD));
    }
}


Measured memory_bytes: 46208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef long double lb;
#define ri register int
const lb PI=3.141592653589793238462643383279;
const ll inf=1000000000000000000ll;
const int N=1000005,M=998244353;
long long qpow(long long a,long long b)
{
	long long s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		b>>=1;
		s=s*s%M;
	}
	return ans;
}
int n,a[N],m,v,p,i,l,r;
bool check(int d)
{
	while(d<=n&&a[d]==a[d+1])
		++d;
	if(d>n-p)
		return true;
	int t=v-(p-1)-d;
	if(a[d]+m<a[n-p+1])
		return false;
	long long s=1ll*m*t;
	for(i=d+1;i<=n-p+1;++i)
		s-=a[d]+m-a[i];
	return (s<=0);
}
int main()
{
	scanf("%d %d %d %d",&n,&m,&v,&p);
	for(i=1;i<=n;++i)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	l=1,r=n;
	while(l<r)
	{
		int mid=l+r>>1;
		if(!check(mid))
			l=mid+1;
		else
			r=mid;
	}
	cout<<n-l+1;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL h;
    cin>>h;
    LL ans=0,t=1;
    while(h!=0){
        ans+=t;
        t*=2;
        h/=2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int n,y,b,r,t;
  double d;
  while(1){
    scanf("%d",&n);
    if(!n)break;
    scanf("%d",&y);
    double m=-1;
    int ans;
    FOR(n){
      scanf("%d %d %d",&b,&r,&t);
      if(t-1){
        d=pow(1+r/100.0,y);
      }else{
        d=1+y*r/100.0;
      }
      if(m<d){
        ans=b;
        m=d;
      }
    }
    PRN(ans);
  }
  return 0;
}



Measured memory_bytes: 2032
N, K = map(int, input().split(" "))
towns = list(map(lambda x: int(x)-1, input().split(" ")))
assert len(towns) == N

# print(towns)

score = {0: 0}
current = 0
move = 0
while 1:
  next_town = towns[current]
  move += 1
  # print(f"move {current} to {next_town}")
  if score.get(next_town) is not None:
    # print(f"find loop!")
    loop_move = move - score.get(next_town)
    loop_town = next_town
    until_loop = score.get(next_town)
    # print(f"loop start town : ", loop_town)
    # print(f"cost to start to loop town : ", until_loop)
    # print(f"loop length : ", loop_move)
    break
  score[next_town] = move
  current = next_town

if K < until_loop:
  result = 0
  for k in range(K):
    result = towns[result]
else:
  result = loop_town
  for k in range((K - until_loop) % loop_move):
    result = towns[result]
print(result + 1)



Measured memory_bytes: 38808
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int l,num,k;
string mid,ans;
void solve(int step,char cur)
{
    if(ans!="") return;
    mid+=cur;
    if(step==l)
    {
        num++;
        if(num==k) ans=mid;
        mid.pop_back();
        return;
    }
    if(cur!='0') solve(step+1,cur-1);
    solve(step+1,cur);
    if(cur!='9') solve(step+1,cur+1);
    mid.pop_back();
    return;
}
int main()
{
    scanf("%d",&k);
    mid=ans="";
    for(int i=1;ans=="";i++)
    {
        l=i;
        for(char s='1';s<='9'&&ans=="";s++)
            solve(1,s);
    }
    cout<<ans<<endl;
    return 0;
}


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

ll dp[3007][3007];
bool vis[3007][3007];
int arr[3007];

ll rec( int l, int r )
{
//    cout<<l<<" "<<r<<endl;
    if( l>r )
        return 0;
    if( l==r )
        return arr[l];

    if( vis[l][r] )
        return dp[l][r];

    ll ret= -1e18;
    ll x= 0;
    ret= max( ret, arr[l]-rec(l+1,r) );
    ret= max( ret, arr[r]-rec(l,r-1) );

    vis[l][r]= 1;

    return dp[l][r]= ret;
}

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

    for( int i=0;i<n;i++ )
        cin>> arr[i];

    cout<< rec( 0,n-1 ) <<endl;
}


Measured memory_bytes: 78592
#include <stdio.h>

int main(void) {
	for(;;) {
		int i, j, H, W;
		scanf("%d", &H);
		scanf("%d", &W);

		if (H == 0 || W == 0) break;

		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;
int N;
int P[MAX_N];

signed main()
{
  cin >> N;
  int S = MAX_N;
  int ans = 0;
  REP(n,N) {
    cin >> P[n];
    if(S > P[n]) {
      ans++;
    }
    S = min(S, P[n]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n, p;
  cin >> n >> p;

  if(n == 1){
    cout << p << endl;
    return 0;
  }

  map<llong, llong> mp;
  for(llong i = 2; i * i <= p; ++i){
    if(p % i == 0){
      while(p % i == 0){
        mp[i]++;
        p /= i;
      }
    }
  }
  llong ans = 1;
  REPI(itr, mp){
    if(itr->second >= n){
      llong num = itr->second / n;
      REP(j,num)
        ans = ans * itr->first;
    }
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

struct TimeTable{
  int dpt;
  int arv;
};

int main(){
  int N,T;
  while(~scanf("%d %d",&N,&T)){
    map<string,TimeTable> trains;
    vector<string> stations;
    string start,last;

    for(int i=0;i<N;i++){
      char from[64];
      int from_h,from_m;

      char to[64];
      int to_h,to_m;

      scanf("%d:%d %s %d:%d %s",&from_h,&from_m,from,&to_h,&to_m,to);
      trains[from].dpt = from_h*60 + from_m;
      trains[to].arv = to_h*60 + to_m;
      stations.push_back(from);
    }

    vector<string> outputs;
    for(int i=1;i<stations.size();i++){
      if(abs(trains[stations[i]].arv - trains[stations[i]].dpt) >= T){
	char buf[128];
	sprintf(buf,"%s %d",stations[i].c_str(),abs(trains[stations[i]].arv - trains[stations[i]].dpt));
	outputs.push_back(buf);
      }
    }

    cout << outputs.size() << endl;
    for(int i=0;i<outputs.size();i++){
      cout << outputs[i] << endl;
    }
  }
}

Measured memory_bytes: 1276
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<queue>
#include<functional>
#include<iomanip>

#define INF 114514810

using namespace std;

long double num[10];
int main()
{
	while (cin>> num[0]){
		
		long double sum = num[0];
		int i;
		for (i = 1; i < 10; i++)
		{
			if (i % 2 == 1){
				num[i] = num[i - 1] * 2;
			}
			else if (i % 2 == 0){
				num[i] = num[i - 1] / 3;
			}
			sum += num[i];
		}
		cout << setprecision(10) << sum << endl;
	}
		return 0;
}

Measured memory_bytes: 1284
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
      String[] t=sc.nextLine().split(" ");
 
//    String nyuA=sc.nextLine();
 //  String nyuB=sc.nextLine();

//int n=Integer.parseInt(nyu);

//int A=Integer.parseInt(t[0]);
//int B=Integer.parseInt(t[1]);
long A=Long.parseLong(t[0]);
long B=Long.parseLong(t[1]);
long C=Long.parseLong(t[2]);

//boolean[][] data=new boolean[H][W];

long countA=0;
long countB=0;

if((A-1)>=0)
countA=(A-1)/(C)+1;
if(B>=0)
countB=(B)/(C)+1;



System.out.println(countB-countA);
	}
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<int> a(n), sum(n);
  int su = 0;
  REP(i, n) cin >> a[i];
  REP(i, n) {
    su += a[i];
    sum[i] = su;
  }
  int ans = abs(2 * sum[0] - sum[n-1]);
  FOR(i, 1, n-1) {
    ans = min(ans, abs(2 * sum[i] - sum[n-1]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
//
// Created by egor http://github.com/chermehdi/egor
// 
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main() {
	string s; cin >> s;
	if(s.length() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0; i < s.length(); i += 2) {
		if(s[i] != 'h' || s[i + 1] != 'i') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

ll choose2(ll n) { return n * (n - 1) / 2; }

int main() {
  int n;
  cin >> n;
  ivec a(n);
  REP(i, n) cin >> a[i];
  REP(i, n) a[i]--;
  ivec cnt(n);
  REP(i, n) cnt[a[i]]++;
  ll total = 0;
  REP(i, n) { total += choose2(cnt[i]); }
  REP(i, n) {
    ll ans = total;
    ans -= choose2(cnt[a[i]]);
    ans += choose2(cnt[a[i]] - 1);
    print(ans);
  }
  return 0;
}

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

int main() {
    int n, k;
    ll ans = 0;
    cin >> n >> k;
    vector<ll> hitpoints(n + 10);
    for (int i = 0; i < n; i++)  cin >> hitpoints[i];
    sort(hitpoints.begin(), hitpoints.end(), greater<>());
    if (n <= k)
    {
        cout << 0;
        return 0;
    }
    else
    {
        for (int i = k; i < n; i++)  ans += hitpoints[i];
    }
    cout << ans;
    return 0;
}

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

public class Main {

	static long m = (long) (1e9 + 7);

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		int a[] = { scn.nextInt(), scn.nextInt() };
		int a2[] = { scn.nextInt(), scn.nextInt() };

		int c1 = a2[0] / a[1] + (a2[0] % a[1] != 0 ? 1 : 0);
		int c2 = a[0] / a2[1] + (a[0] % a2[1] != 0 ? 1 : 0);

		if (c1 <= c2)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

	static class Scanner {

		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 32728
#include <iostream>
#include<cstdlib>
#include <stdio.h>
#include <string.h>
using namespace std;
int table[10+1][331];
bool memo[10];
int n;

void rec(int depth, int sum) {
	table[depth][sum]++;
	for (int i = 0; i <= 9; i++) {
		if (memo[i]) continue;
		memo[i] = true;
		rec(depth + 1, sum + i * (depth+1));
		memo[i] = false;
	}
}

void q70() {
	memset(table, 0, sizeof(table));
	memset(memo, 0, sizeof(memo));
	rec(0, 0);
	int n, s;
	for (; cin >> n >> s;) {
		if (n > 10 || s > 330) {
			cout << "0" << endl;
			continue;
		}
		cout << table[n][s] << endl;
	}
}

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

Measured memory_bytes: 3044
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int l,r,u,d,h,w;
bool flag;
void moveT(char c){
  if(c=='L'){
    l++;
  }
  else if(c=='R'){
    r--;
  }
  else if(c=='U'){
    u++;
  }
  else if(c=='D'){
    d--;
  }
  if(l==w||r==1){
    flag=true;
  }
  if(u==h||d==1){
    flag=true;
  }
}
void moveA(char c){
  if(c=='R'&&l>0){
    l--;
  }
  else if(c=='L'&&r<w+1){
    r++;
  }
  else if(c=='D'&&u>0){
    u--;
  }
  else if(c=='U'&&d<h+1){
    d++;
  }
}
signed main(){
  int n;cin>>h>>w>>n;
  int sr,sc;cin>>sr>>sc;
  string s,t;cin>>s>>t;
  l=0;u=0;r=w+1;d=h+1;
  flag=false;
  moveT(s[n-1]);
  //printf("(l,r,u,d)= %d %d %d %d\n",l,r,u,d);
  for(int i=n-2;i>=0;i--){
    moveA(t[i]);
    //printf("(l,r,u,d)= %d %d %d %d\n",l,r,u,d);
    moveT(s[i]);
    //printf("(l,r,u,d)= %d %d %d %d\n",l,r,u,d);
  }
  if(sr<=u||sr>=d){
    flag=true;
  }
  if(sc<=l||sc>=r){
    flag=true;
  }
	if(!flag){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 776
import math
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def available_n(v):
    value = ((1+8*v)**(1/2) - 1)/2
    return math.floor(value)

n=int(input())
ls = prime_factorize(n)
d={}
for i in ls:
    d.setdefault(i,0)
    d[i]=d[i]+1

count=0
for k,v in d.items():
    count+=available_n(v)

print(count)

Measured memory_bytes: 9480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  string key = "abcdefghijklmnopqrstuvwxyz";
  ll N;
  cin >> N;
  char ans[20];
  ll cal[14];
  cal[0] = 1;
  ll kj = 1;
  for (int i = 1; i < 14; i ++) {
    kj *= 26;
    cal[i] = cal[i - 1] + kj;
  }
  int a = 0;
  while (cal[a] <= N) a ++;
  a --;
  N -= cal[a];
  for (int i = a; i >= 0; i --) {
    ans[i] = key[N % 26];
    N /= 26;
  }
  for (int i = 0; i <= a; i ++) {
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

int main()
{
	int N = 0;
	int point = 0;

	std::cin >> N;

	std::vector<int> a(N);

	for (int i = 0; i < N; i++) {
		std::cin >> a[i];
	}

	std::sort(a.begin(), a.end(), std::greater<int>());

	for (int i = 0; i < N; i = i + 2) {
		point += a[i];
	}

	for (int i = 1; i < N; i=i+2) {
		point -= a[i];
	}

	std::cout << point << std::endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>){
    val scanner = Scanner(System.`in`)
    val N = scanner.nextInt()
    val ss: Array<Int> = arrayOf(7, 17, 37, 47, 67, 97, 107, 127, 137, 157, 167, 197, 227, 257, 277, 307, 317, 337, 347, 367, 397, 457, 467, 487, 547, 557, 577, 587, 607, 617, 647, 677, 727, 757, 787, 797, 827, 857, 877, 887, 907, 937, 947, 967, 977, 997, 1087, 1097, 1117, 1187, 1217, 1237, 1277, 1297, 1307)
    for (i in 0 until N-1){
        print(ss[i])
        print(" ")
    }
    println(ss[N-1])
}

Measured memory_bytes: 31396
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a, b;
    cin >> a >> b;

    if (a.length() > b.length()) {
      puts("GREATER");
      return 0;
    }
    else if (a.length() < b.length()) {
      puts("LESS");
      return 0;
    }
    
    if (a == b) {
        puts("EQUAL");
    }    
    else if (a > b) {
      puts("GREATER");
    }
    else {
      puts("LESS");
    }
    return 0;
}

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

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

    if ( N%1111 == 0 ) {
    cout << "Yes" << endl;
  }
    else if ( (N/10)%111 == 0) {
    cout << "Yes" << endl;
  }
   else if ( (N%1000)%111 == 0) {
    cout << "Yes" << endl;
  }
    else {
    cout << "No" << endl;
  }
}

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ');
            int[] w = a.Select(x=>int.Parse(x)).ToArray();
        
            int sum = w.Sum();
            int result =sum;

            for(int i = 0; i<n-1; i++)
            {
                int s1 = 0;
                int s2 = 0;

                for(int j = 0; j<=i; j++)
                {
                    s1= s1 + w[j];
                }
                s2 = sum-s1;
                
                if(result > Math.Abs(s2-s1))
                {
                    result = Math.Abs(s2-s1);
                }

            }

            Console.WriteLine(result);
        }
    }
}

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

using namespace std;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int ab=abs(a-b);
    int bc=abs(b-c);
    int ac=abs(a-c);

    if(ab<=d && bc<=d || ac<=d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string answer = "No";
    for (int i = 0; i * 4 <= N; i++)
    {
        for (int j = 0; i * 4 + j * 7 <= N; j++)
        {
            if (i * 4 + j * 7 == N)
            {
                answer = "Yes";
                break;
            }
        }
    }
    cout << answer << endl;
    return 0;
}


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

template <typename T> struct combination{

    T mpow(T x,T n){
        T res = 1;
        while(n != 0){
            if(n&1) res = res*x % mod;
            x = x*x % mod;
            n = n >> 1; 
        }
        return res;
    }

    vector<T> fac,ifac;
    combination (int max_N){
        fac.push_back(1);
        ifac.push_back(1);
        for(int i = 0;i < max_N;i ++){
            fac.push_back(fac[i]*(i+1) % mod);
            ifac.push_back(ifac[i]*mpow(i+1,mod-2) % mod);
        }
    }

    T comb(T a,T b){
        if(a==0 && b==0) return 1;
        if(a<b || a<0) return 0;
        T tmp = ifac[a-b]*ifac[b] % mod;
        return tmp*fac[a] % mod;
    }
    T perm(T a,T b){
        if(a==0 && b==0) return 1;
        if(a<b || a<0) return 0;
        return ifac[a-b]*fac[a] % mod;
    }
};


int main(){
    ll h,w,a,b,ans=0;
    cin >> h >> w >> a >> b;
    combination<ll> c(200001);
    for(int i = 0;i < h-a;i ++){
        ans += c.comb(i+b-1,i)*c.comb(w+h-2-b-i,w-1-b);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#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() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> aa(a), bb(b);
  rep(i, a) {
    cin >> aa[i];
  }
  rep(i, b) {
    cin >> bb[i];
  }
  int result = *min_element(aa.begin(), aa.end()) + *min_element(bb.begin(), bb.end());
  rep(i, m) {
    int x, y, c;
    cin >> x >> y >> c;
    int discounted = aa[x - 1] + bb[y - 1] - c;
    result = min(discounted, result);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define mm map<ii>
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
	fast

	ll n,qu;
	cin>>n>>qu;

	ll a,b;

	vector<vector<ll>> v(n);

	forn(i,0,n-1)
	{
		cin>>a>>b;
		v[a-1].pb(b-1);
		v[b-1].pb(a-1);
	}

	vector<ll> total(n,0);

	while(qu--)
	{
		cin>>a>>b;

		total[a-1] += b;
 	}
 	
 	vector<bool> visited(n,0);

 	queue<ll> q;
 	q.push(0);

 	visited[0] = true;

 	while(!q.empty())
 	{
 		ll p = q.front();
 		q.pop();

 		forn(i,0,v[p].sze)
 		{
 			if(!visited[v[p][i]])
 			{
 				visited[v[p][i]] = true;
 				total[v[p][i]] += total[p];
 				q.push(v[p][i]);
 			}
 		}
 	}

 	forn(i,0,n)
 	{
 		cout<<total[i]<<" ";
 	}



	return 0;
}

Measured memory_bytes: 17904
n, k = [int(_) for _ in input().split()]
ary = [int(input()) for _ in range(n)]


def search_v(p):
    v = 0
    w = 0
    tmp_k = 1
    ind = 0

    while True:

        if tmp_k > k:
            return v
        if ind == n:
            return n

        tmp = ary[ind]
        if w + tmp <= p:
            w += tmp
            v += 1
            ind += 1
        else:
            w = 0
            tmp_k += 1


max_p = n * 10000
ps = range(max_p + 1)
left = 0
right = max_p

while left + 1 < right:
    mid = (left + right) // 2
    v = search_v(ps[mid])

    if v >= n:
        right = mid
    else:
        left = mid

print(ps[right])



Measured memory_bytes: 9556
a, b, k = [int(i) for i in input().split()]
a_1 = a
b_1 = b
k_1 = k

if a < k:
  a_1 = 0
  k_1 = k - a
  b_1 = b - k_1
  if b_1 < 0:
    b_1 = 0
else:
  a_1 = a - k
print(a_1, b_1)


Measured memory_bytes: 9088
import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	
    	double a = scan.nextDouble();
    	double b = scan.nextDouble();
    	double C = scan.nextDouble();
    	
    	double c = Math.sqrt(((a*a) + (b*b))-2*a*b*Math.cos(Math.toRadians(C)));
    	
    	double L = a + b + c;
    	double h = b * Math.sin(Math.toRadians(C));
    	double S = a * h / 2.0;
    	
    	System.out.println(String.format("%.8f", S));
    	System.out.println(String.format("%.8f", L));
    	System.out.println(String.format("%.8f", h));
     }
}

Measured memory_bytes: 28128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;

typedef long long ll;
typedef long double ld;
 
#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int, int>
#define Point Vect
#define no {cout << "No\n"; return;}

const int N = 1e5 + 7;

 void solve() {
    int x, y, z; cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
 }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2000005;
const int mod = 1e9 + 7;
int x[7], y[7], fac[MAXN], inv[MAXN], ans;
inline int C(int x, int y) { return 1LL * fac[x + y] * inv[x] % mod * inv[y] % mod; }
inline int F(int x1, int y1, int x2, int y2) { return (1LL * C(x2 + 1, y2 + 1) + C(x1, y1) - C(x1, y2 + 1) - C(x2 + 1, y1) + mod + mod) % mod; }
int main() {
  for (int i = 1; i <= 6; i ++) {
    scanf("%d", x + i);
  }
  for (int i = 1; i <= 6; i ++) {
    scanf("%d", y + i);
  }
  fac[0] = inv[0] = fac[1] = inv[1] = 1;
  for (int i = 2; i <= 2000000; i ++) {
    fac[i] = 1LL * fac[i - 1] * i % mod;
    inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
  }
  for (int i = 2; i <= 2000000; i ++) {
    inv[i] = 1LL * inv[i - 1] * inv[i] % mod;
  }
  for (int i = x[3]; i <= x[4]; i ++) {
    ans = (1LL * (mod - y[3] - i) * F(i - x[2], y[3] - 1 - y[2], i - x[1], y[3] - 1 - y[1]) % mod * F(x[5] - i, y[5] - y[3], x[6] - i, y[6] - y[3]) + ans) % mod;
  }
  for (int i = x[3]; i <= x[4]; i ++) {
    ans = (1LL * (i + y[4] + 1) * F(i - x[2], y[4] - y[2], i - x[1], y[4] - y[1]) % mod * F(x[5] - i, y[5] - y[4] - 1, x[6] - i, y[6] - y[4] - 1) + ans) % mod;
  }
  for (int i = y[3]; i <= y[4]; i ++) {
    ans = (1LL * (mod - x[3] - i) * F(i - y[2], x[3] - 1 - x[2], i - y[1], x[3] - 1 - x[1]) % mod * F(y[5] - i, x[5] - x[3], y[6] - i, x[6] - x[3]) + ans) % mod;
  }
  for (int i = y[3]; i <= y[4]; i ++) {
    ans = (1LL * (i + x[4] + 1) * F(i - y[2], x[4] - x[2], i - y[1], x[4] - x[1]) % mod * F(y[5] - i, x[5] - x[4] - 1, y[6] - i, x[6] - x[4] - 1) + ans) % mod;
  }
  return printf("%d\n", ans), 0;
}



Measured memory_bytes: 16000
/*
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const ll INF=20050208;
/*------------main part------------*/


ll num[200005];
ll hav[200005];
ll last=1;
int main()
{
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		cin>>num[i];
		ll c=i-num[i];// 0 1 2 3
		if(c<last)
		{
			cout<<-1<<endl;
			return 0;
		}
		hav[c]=i;
		last=c;
	}
	ll ans=0;
	for(ll i=n;i>0;i--)
	{
		if(hav[i])
		{
			ans+=num[hav[i]];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3328
N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
K.times do |k|
    imosu = Array.new(N+1, 0)
    0.upto(N-1) do |i|
        l = [i - a[i], 0].max
        r = [i + a[i] + 1, N].min
        imosu[l] += 1
        imosu[r] += -1
    end
    s = 0
    all_n = true
    0.upto(N-1) do |i|
        s += imosu[i]
        a[i] = s
        all_n = false if a[i] != N
    end
    break if all_n
end
puts a.join(' ')

Measured memory_bytes: 80664
n = int(input())


def memoize(f):
    memo = [1, 1] + [0] * max(0, n - 1)

    def main(i):
        if memo[i]:
            return memo[i]
        result = memo[i] = f(i)
        return result

    return main


@memoize
def fibonacci(i):
    return fibonacci(i - 1) + fibonacci(i - 2)


print(fibonacci(n))

Measured memory_bytes: 7744
#include <iostream>

using namespace std;

int W, H;
int x, y;
char tile[20][20];
int checked[20][20];
int dfs(int x, int y){
    checked[x][y] = 1;
    bool dead = false;
    if((x==0 || tile[x-1][y] == '#' || checked[x-1][y] == 1) &&
    (x==W-1 || tile[x+1][y] == '#' || checked[x+1][y] == 1) &&
    (y==0 || tile[x][y-1] == '#' || checked[x][y-1] == 1) &&
    (y==H-1 || tile[x][y+1] == '#' || checked[x][y+1] == 1)) dead = true;
    if(dead){
        return 1;
    }
    int tmp=0;
    if(x>0 && tile[x-1][y] == '.' && checked[x-1][y] == 0) tmp += dfs(x-1, y);
    if(x<W-1 && tile[x+1][y] == '.' && checked[x+1][y] == 0) tmp += dfs(x+1, y);
    if(y>0 && tile[x][y-1] == '.' && checked[x][y-1] == 0) tmp += dfs(x, y-1);
    if(y<H-1&&tile[x][y+1] == '.' && checked[x][y+1] == 0) tmp += dfs(x, y+1);
    return 1+tmp;
}
int main(){
    char tmp;
    while(cin >> W >> H && W && H){
        for(int j=0; j<H; ++j){
            for(int i=0; i<W; ++i){
                checked[i][j] = 0;
                cin >> tmp;
                switch(tmp){
                    case '.':
                        tile[i][j] = '.';
                        break;
                    case '#':
                        tile[i][j] = '#';
                        break;
                    case '@':
                        tile[i][j] = '.';
                        x = i;
                        y = j;
                        break;
                }
            }
        }
        cout << dfs(x, y) << endl;
    }
    return 0;
}

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


class doubling_LCA {
private:
    std::vector<std::vector<int>> Tree;
    std::vector<std::vector<int>> par;
    std::vector<int> depth;

    void dfs(int v, int p){
        for(auto& c : Tree[v]) {
            if(c == p) continue;
            depth[c] = depth[v] + 1;
            par[0][c] = v;
            dfs(c, v); 
        }
    }
    void doubling(const int& V){
        const int D = par.size();
        for(int d = 1; d < D; d++){
            for(int v = 0; v < V; v++){
                if(par[d-1][v] < 0) par[d][v] = -1;
                else par[d][v] = par[d-1][par[d-1][v]];
            }
        }
    }

public: 
    doubling_LCA() = delete;
    doubling_LCA(const doubling_LCA&) = delete;
    doubling_LCA& operator=(const doubling_LCA&) = delete;

    doubling_LCA(std::vector<std::vector<int>>& tree, int root = 0) : Tree(tree) {
        int V = Tree.size();
        int D = 1;
        while((1 << D) < V) D++;
        depth.assign(V, -1);
        par.assign(D, std::vector<int>(V, -1));

        dfs(root, -1);
        doubling(V);
    }

    int operator()(int u, int v){
        if(depth[u] < depth[v]) std::swap(u, v);
        int D = par.size();
        for(int d = 0; d < D; d++){
            if((depth[u] - depth[v]) & (1 << d)) u = par[d][u];
        }

        if(u == v) return u;
        for(int d = D - 1; d >= 0; d--){
            if(par[d][u] != par[d][v]) {
                u = par[d][u];
                v = par[d][v];
            }
        }
        return par[0][u];
    }
};

int main(){
    using namespace std;
    int N;
    cin >> N;

    std::vector<std::vector<int>> Tree(N);
    for(int i = 0; i < N; i++){
        int K; cin >> K;
        Tree[i].resize(K);
        for(int k = 0; k < K; k++){
            cin >> Tree[i][k];
        }
    }

    doubling_LCA LCA(Tree);

    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int u, v;
        cin >> u >> v;
        cout << LCA(u, v) << endl;
    }
}


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

using namespace std;

int main()
{
    double N;
    while(cin >> N, N >= 0)
    {
        int n = N * 16 + 1e-8;
        if (abs(N * 16 - (int)(N * 16)) > 1e-8 || n >= (1 << 12))
        {
            puts("NA");
            continue;
        }
        for (int i = 11; i >= 0; i--)
        {
            printf("%d", (n >> i) & 1);
            if (i == 4) printf(".");
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstdio>
using namespace std;
#define F first
#define S second
#define INF 2e9
#define MP(i, j) make_pair((i), (j))
typedef pair<int, int> P;
int level[500][500];

int r, w, h, x, y;
vector<P> able, able2;
struct S{
	int x, y, r;
	S(int inx, int iny, int inr): x(inx), y(iny), r(inr){}
	bool operator < (const S &s)const{
		return r > s.r;
	}
};
void dijkstra(vector<P> &able){
	int nowr = 1, cnt = 0;
	bool flag[500][500] = {};
	priority_queue<S> que;
	que.push(S(x - 1, y - 1, 1));
	flag[y - 1][x - 1] =  true;
	while(!que.empty()){
		S p = que.top();
		if(nowr < level[p.y][p.x]){
			able.push_back(MP(cnt, nowr));
			nowr = level[p.y][p.x];
		}
		cnt++;
		
		que.pop();
		for(int i = -1; i <= 1; i++){
			if(!flag[p.y + i][p.x]&& p.y + i >= 0 && p.y + i < h && p.x >= 0 && p.x < w){
				que.push(S(p.x, p.y + i, level[p.y + i][p.x]));
				flag[p.y + i][p.x] = true;
			}
			if(!flag[p.y][p.x + i]&& p.y >= 0 && p.y < h && p.x + i >= 0 && p.x + i < w){
				que.push(S(p.x + i, p.y, level[p.y][p.x + i]));
				flag[p.y][p.x + i] = true;
			}
		}
	}
	able.push_back(MP(cnt, nowr));
}
int main(){
	while(scanf("%d", &r) && r){
		scanf("%d%d%d%d", &w, &h, &x, &y);
		int ans = INF;
		able.clear();
		able2.clear();
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				scanf("%d", &level[i][j]);
			}
		}
		dijkstra(able);
		scanf("%d%d%d%d", &w, &h, &x, &y);
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				scanf("%d", &level[i][j]);
			}
		}
		dijkstra(able2);

		for(int i = 0; i < able.size(); i++){
			P pp = MP(r - able[i].F, 0);
			if(pp.F > 0){
				int p = lower_bound(able2.begin(),able2.end(), pp) - able2.begin();
				if(p != able2.end() - able2.begin())
					ans = min(ans, able2[p].S + able[i].S);
			}
			else{
				ans = min(ans, able[i].S);
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 4836
N, Y = map(int, input().split())

def solve():
  for i in range(N + 1):
    for j in range(N + 1):
      k = N - i - j
      if k < 0:
        continue
      if 10000 * i + 5000 * j + 1000 * k == Y:
        return (i, j, k)
  return (-1, -1, -1)

x, y, z = solve()
print(x, y, z)

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

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

    vector<int> m(N);
    int set_cost = 0;
    int minimum_cost = X;
    for (int i = 0; i < N; i++)
    {
        cin >> m[i];
        set_cost += m[i];
        minimum_cost = min(minimum_cost, m[i]);
    }
    // printf("set_cost = %d\n", set_cost);
    // printf("minimum_cost = %d\n", minimum_cost);

    int ans = 0;
    X -= set_cost;
    ans = m.size();
    // printf("X = %d\n", X);
    ans += (X / minimum_cost);
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  vector<int>a(10,0),b(10,0);
  rep(i,10){
    cin>>a[i];
  }
  rep(i,10){
    cin>>b[i];
  }
  sort(all(a));
  sort(all(b));
  cout<<a[9]+a[8]+a[7]<<" "<<b[9]+b[8]+b[7]<<endl;
}

Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef unsigned long long ull;

ull N,M;
constexpr int MAX_N = 1e5;
vector<int> par(MAX_N);
vector<ull> size(MAX_N);

int find(int i){
  if(par[i]==i) return i;
  else {
    par[i] = find(par[i]);
    return par[i];
  }
}
void unite(int i, int j){
  int ri = find(i);
  int rj = find(j);
  if(ri!=rj) {
    par[rj] = ri;
    size[ri] += size[rj];
  }
}

int main(){
  cin>>N>>M;
  vector<pair<int,int>> b;

  for(int i=0;i<M;i++){
    int A,B; cin>>A>>B;
    b.push_back(make_pair(A,B));
  }
  for(int i=0;i<N;i++){
    par[i] = i;
    size[i] = 1;
  }

  vector<ull> ans;
  ans.push_back((N-1)*N/2);
  for(int i=M-1; i>=1; i--){
    int A,B; A = b[i].first; B = b[i].second;
    int ra = find(A); int rb = find(B);
    if(ra!=rb){
      ans.push_back(ans.back()-size[ra]*size[rb]);
    } else {
      ans.push_back(ans.back());
    }
    unite(A,B);
  }

  for(int i=M-1; i>=0; i--){
    cout<<ans[i]<<endl;
  }

  return 0;
}

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

#define MOD 1000000007

typedef long long ll;

int n, m;

int main() {
    cin >> n >> m;
    int g = m / n;
    while (1) {
        if (m % g == 0) {
            break;
        }
        g--;
    }

    cout << g << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>=13)
        printf("%d",b);
    else
        if(a>=6&&a<=12)
        printf("%d",b/2);
    else
        printf("0");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,a,b;
    scanf("%d %d",&a,&b);
    char s[20];
    scanf("%s",s);
    for(i=0; i<a; i++)
    {
        if(s[i]<48||s[i]>57)
        {
            printf("No");
            return 0;
        }
    }
    if(s[a]!='-')
    {
        printf("No");
        return 0;
    }
    for(i=a+1; i<=a+b; i++)
    {
        if(s[i]<48||s[i]>57)
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}


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

int main() {
  ll n, k, c, r = 0;
  cin >> n >> k;
  vector<ll> a(n + 1), b(n + 1, -1);
  map<int, int> p;
  for (ll i = 1; i <= n; i++) cin >> a[i];

  int i = 1, j = 0;
  while (b[i] == -1) {
    p[j] = i;
    b[i] = j;
    i = a[i];
    j++;
  }
  c = j - b[i];

  if (i == 1)
    cout << p[k % c] << endl;
  else if (k < b[i])
    cout << p[k] << endl;
  else {
    cout << p[(k - b[i]) % c + b[i]] << endl;
  }
}

Measured memory_bytes: 15604
#abc 079 b

def ryuka(x,memo):
    if x==0:
        return 2
    elif x==1:
        return 1
    if memo[x]!=-1:
        return memo[x]
    memo[x]=ryuka(x-1,memo)+ryuka(x-2,memo)
    return memo[x]


n=int(input())
memo=[-1]*(n+1)
ans=ryuka(n,memo)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define in inline
#define int long long
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9') {
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int n,m,ans;
signed main(){
	n=read();
	for(re int i=-1000;i<=1000;++i){
		for(re int j=-1000;j<=1000;++j){
			if(i*i*i*i*i-j*j*j*j*j==n){
				printf("%lld %lld\n",i,j);
				return 0;
			}
		}
	}
}

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

using namespace std;

typedef long long ll;

ll dp[4][5005];
ll dp2[4][25000005];
ll ga[3];
ll gb[3];
int main() {
  ll n;
  cin >> n;

  for(int i = 0; i < 3; i++) cin >> ga[i];
  for(int i = 0; i < 3; i++) cin >> gb[i];

  for(int i = 0; i < 3; i++) {
    for(int j = 0; j <= n; j++) {
      if(j - ga[i] < 0) {
	dp[i+1][j] = dp[i][j];
      }
      else {
	dp[i+1][j] = max(dp[i][j],dp[i+1][j-ga[i]] + gb[i]-ga[i]);
      }
    }
  }

  ll m = 0;
  for(int i = 0; i <= n; i++) m = max(m,dp[3][i]);
  m += n;
  //cout << m << endl;
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j <= m; j++) {
      if(j - gb[i] < 0) {
	dp2[i+1][j] = dp2[i][j];
      }
      else {
	dp2[i+1][j] = max(dp2[i][j],dp2[i+1][j-gb[i]] + ga[i]-gb[i]);
      }
    }
  }

  ll ans = 0;
  for(int i = 0; i <= m; i++) ans = max(ans,dp2[3][i]);

  cout << m + ans << endl;
      
}


Measured memory_bytes: 587008
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a, b, s = 0, c = 0;
  double i = 0;
  while (scanf("%d,%d", &a, &b) != EOF) {
    s += a * b;
    c += b;
    i++;
  }
  cout << s << endl << round(c / i) << endl;
  return 0;
}

Measured memory_bytes: 1280
x = gets.to_s.to_i
# a,b = gets.to_s.split.map{|t|t.to_i}
# m = Array.new(n){ gets.to_s.split.map{|t|t.to_i} }
# s = gets.to_s.chomp

i = 0
b = 100
loop do
  
  b = (b * 1.01).floor
  i += 1
  
  if x <= b
    puts i
    exit
  end
end

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

#define ll long long
#define ar array

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

	ll h;
	cin >> h;
	ll c=1, ans=0;
	while(h>0) {
		ans+=c;
		c*=2;
		h/=2;
	}
	cout << ans;
}


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

string s , t;

int main(){
  cin >> s;
  t = s;
  reverse(all(t));
  for(auto&ch : t) {
    if(ch == 'b' || ch == 'd')
      ch ^= 'b' ^ 'd';
    if(ch == 'p' || ch == 'q')
      ch ^= 'p' ^ 'q';
  }
  cout << (s == t ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a); (i)<=(b); (i)++)
#define REP(i,N) FOR((i), 0, (N)-1)
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << (A*B/2) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

int A[200000];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), K = getint();
	rep(i, N) A[i] = getint() - 1;

	int L = 0, R = 1000000000;
	while (L + 1 < R) {
		int H = (L + R) / 2;
		ll k = 0;
		rep(i, N) k += A[i] / H;
		if (k <= K) R = H;
		else L = H;
	}
	printf("%d\n", R);


	Would you please return 0;
}

Measured memory_bytes: 2460
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  long long int N, K, ans, tmp;
  cin >> N >> K;
  if(K == 1) ans = 0;
  else{
    if(N > K){
      tmp = N%K;
      ans = min(abs(tmp-K), tmp);
    }else{
      ans = min(abs(N-K), N);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256