akhauriyash/Code-Regression huggingface dataset:
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        long N = Long.parseLong(scanner.next());
        long max = 1;
        for (long i = 1; i * i <= N ; i++) {
            if (N % i == 0) {
                max = i;
            }
        }
        System.out.println(max + N / max - 2);
    }
}


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

int main(){
    int n,r=1;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<n;i++){
        r=a[r];
        if(r==2){
            cout<<i<<endl;
            break;
        }
        if(i==n-1){
            cout<<-1<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);
 
int32_t main(){
	fast;
	int n,k;
	cin >> n >> k;
	for(int i= k-n + 1 ; i<=n +k -1 ; i++)	cout << i << " ";
}
 
 

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

#define PI 3.141592653589793

int main(void)
{
	double a,b,C,S,L,h;
        double radian;

	scanf("%lf %lf %lf",&a,&b,&C);

        radian = C * PI / 180.0;

	S = (a * b * sin(radian)) / 2;
	L = a + b + sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(radian));
	h = b * sin(radian);

	printf("%f\n",S);
	printf("%f\n",L);
	printf("%f\n",h);
	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int x[5]={};
    int ans;
    rep(i,5){
        cin>>x[i];
        if(x[i]==0){
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#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)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

int main(void){
    int N; cin >> N;
    VI p(N); REP(i,N) cin >> p[i];
    SORT(p);
    int ans = 0; REP(i,N) ans += p[i];
    ans -= p[N-1]/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rg register
#define LL long long 

using namespace std;

const int M=500010;
const int N=1000010;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int cnt,head[M],nxt[N<<1],to[N<<1],w[N<<1];
void add(int x,int y,int z){
	to[++cnt]=y;
	w[cnt]=z;
	nxt[cnt]=head[x];
	head[x]=cnt;
}
int d[M];bool vis[M];
void spfa(){
	queue<int>q;
	memset(d,63,sizeof(d));
//	memset(vis,false,sizeof(vis));
	d[1]=0;q.push(1);vis[1]=true;
	while(!q.empty()){
		int k=q.front();q.pop();vis[k]=false;
		for(int i=head[k];i;i=nxt[i]){
			int kk=to[i];
			if(d[kk]-d[k]>w[i]){
				d[kk]=d[k]+w[i];
				if(!vis[kk]){
					vis[kk]=true;
					q.push(kk);
				}
			}
		}
	}
}
int main()
{
//	freopen("magic.in","r",stdin);
//	freopen("magic.out","w",stdout);
	int k=read();
	if(k==1){puts("1");return 0;}
	for(rg int i=0;i<k;i++){
		add(i,(i+1)%k,1);
		add(i,(i*10)%k,0);
	}
	spfa();
	printf("%d\n",d[0]+1);
	return 0;
}

Measured memory_bytes: 12288
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 3e5 + 1;
const long long MNN = 1e5 + 1;
const long long MOD = 1e9;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong x;

int main(){
	ios;
	cin >> x;
	llong a = x / 2;
	llong b = (x + 1) / 2;
	cout << a * b;
	return 0;
}

/*

6
4 -2 -5 10 5 1
1 2
2 4
2 5
1 3
3 6
 
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main() {
  ll A,B,M,Min=3*100000;
  cin>>A>>B>>M;
  vector<ll> a(A),b(B);
  rep0(i,A){cin>>a[i];}
  rep0(i,B){cin>>b[i];}
  vector<vector<ll>> dsc(M,vector<ll>(3));
  rep0(i,M){rep0(j,3){cin>>dsc[i][j];}}
  rep0(i,M){Min=min(Min,a[dsc[i][0]-1]+b[dsc[i][1]-1]-dsc[i][2]);}
  sort(all(a));
  sort(all(b));
  Min=min(Min,a[0]+b[0]);
  cout<<Min<<endl;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
double sum(int a){
	double b=a,c=0;
	while(a){
		c+=a%10;
		a/=10;
	}
	return b/c;
}
signed main(){
	int a,ans=0,an=0,x=1;
	cin>>a;
	while(a){
		if(sum(ans+x)<=sum(an+x*10)){
			ans+=x;
			cout<<ans<<endl;
			a--;
		}
		else x*=10;
		if(ans>=an+x*9) an=ans;
	}
	return 0;
}


Measured memory_bytes: 256
while 1:
        a,b = map(int, raw_input().split())
        if a == 0 and b == 0: break
        r = [0 for i in range(b)]
        n = range(1, b+1)
        for j in range(a):
                vote = map(int, raw_input().split())
                for i in range(b):
                        r[i] += vote[i]

        for i in range(1, b):
                for j in range(b-i):
                        if r[j] < r[j+1]:
                                temp = (r[j], n[j])
                                r[j] = r[j+1]
                                n[j] = n[j+1]
                                r[j+1] = temp[0]
                                n[j+1] = temp[1]

        n = map(str, n)
        ans = ''
        for i in range(b):
                if i == 0: ans += n[i]
                else: ans += ' ' + n[i]
        print ans

Measured memory_bytes: 4280
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

    ll dp[N + 1];
    dp[0] = 2;
    dp[1] = 1;
    repi(i, 2, N + 1) {
        dp[i] = dp[i - 2] + dp[i -1];
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 256
import sys
N = input()
ds = list(map(int, input().split()))
max_d = 0
now_d = 0
now_t = ds[0]
for d in ds[1:]:
    if d > now_t:
        now_t = d
        now_d = 0
    else:
        now_t = d
        now_d += 1
        if max_d < now_d:
            max_d = now_d
print(max_d)

Measured memory_bytes: 14252
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

// vector set 等
#include <map>
#include <set>
#include <vector>

//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto& i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

// 負の数にも対応した % 演算
ll mod(ll x) {
  ll res = x % MOD;
  if (res < 0) x += MOD;
  return res;
}

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

// a^{-1} mod を計算する
ll minv(ll a) { return mpow(a, MOD - 2); }

signed main() {
  //入力の高速化用のコード
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll n, mx, Ai, ans;
  cin >> n;
  vector<ll> A(n);

  REP(i, n) { cin >> A[i]; }
  ans = 0;

  sort(ALL(A));
  mx = A[n - 1];
  vector<bool> frags(mx + 1, true);
  vector<bool> frags_kaburi(mx + 1, true);
  vector<bool> frags_kabutta(mx + 1, true);
  REP(i, n) {
    Ai = A[i];
    if (frags_kaburi[Ai]) {
      frags_kaburi[Ai] = false;
      if (frags[Ai]) {
        for (ll j = Ai * 2; j <= mx; j += Ai) frags[j] = false;
      }
    } else {
      frags_kabutta[Ai] = false;
    }
  }

  REP(i, n) {
    Ai = A[i];
    if (frags[Ai] && frags_kabutta[Ai]) {
      ans += 1;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4612
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int m,f,b;
    cin>>m>>f>>b;
    if(m+f<b){
            cout<<"NA"<<endl;
    }
    else if(m>b){
            cout<<"0"<<endl;
    }
    else{
         cout<<b-m<<endl;   
    }
}



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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

    string s;
    cin>>s;

    char data[4]={'S','N','E','W'};
    lli ans[4]={0};

    REP(i,0,s.size()){
        REP(j,0,4){
            if(data[j]==s.at(i))ans[j]++;
        }
    }

    if(ans[0]>0 && ans[1]==0)cout<<"No"<<endl;
    else if(ans[0]==0 && ans[1]>0)cout<<"No"<<endl;
    else if(ans[2]==0 && ans[3]>0)cout<<"No"<<endl;
    else if(ans[3]==0 && ans[2]>0)cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
    }

	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  map<string, int> mp;
  rep(i, N) {
    string s; cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for (auto &e: mp) {
    ans += (ll)e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11136
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
const int MAX = 200000;
const int MOD = 1e+9+7;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n,int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(){
	COMinit();
	ll B,W;
	scan(B>>W);
	ll N=B+W;
	ll beki2[200001],inv2[200001];
	inv2[0]=1;
	beki2[0]=1;
	rep(i,N){
		inv2[i+1]=inv2[i]*inv[2]%MOD;
		beki2[i+1]=beki2[i]*2%MOD;
	}
	ll tasu=0,hiku=0;
	rep(i,N){
		if(i==W) tasu=COM(W,0);
		else if(i>W){
			tasu+=tasu+COM(i-1,i-W);
		}
		tasu%=MOD;
		if(i==B) hiku=COM(B,0);
		else if(i>B){
			hiku+=hiku+COM(i-1,i-B);
		}
		hiku%=MOD;
		ll ans=(beki2[i]+tasu-hiku+MOD)*inv2[i+1]%MOD;
		//printf("tasu:%lld hiku:%lld  %lld/%lld  ",tasu,hiku,(beki2[i]+tasu-hiku+MOD)%MOD,beki2[i+1]);
		prin(ans);
	}

	return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi ans;
  if(n==0){cout<<0<<endl;return 0;}
  while(n!=0){
    if(n%2){ans.pb(1);n--;n/=-2;}
    else{ans.pb(0);n/=-2;}
  }
  reverse(ALL(ans));
  for(auto a:ans)cout<<a;
  cout<<endl;
  return 0;
}


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

int main() {
  //freopen("input.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0);
 
  int n; cin >> n;
  vector<string> s(n);
  REP(i, n) cin >> s[i];

  int ans = 0;
  REP(a, n) {
    bool ok = true;
    REP(i, n) REP(j, n) if (s[(i + a) % n][j] != s[(j + a) % n][i]) {
      ok = false;
      break;
    }
    if (ok) ans++;
  }

  cout << ans * n << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long n, a[51], b[51], c[51], f[51], k, d, ans, o;
bool dfs(int x, int y){bool u=false;
	f[x]=1;
	if(x==y)return true;
	for (int i=1; i<=50; i++)
		if(c[i] && !f[x%i])u|=dfs(x%i, y);
	return u;
}
int main(){
    cin>>n;k=51;
    for (int i=1; i<=n; i++)cin>>a[i];
	for (int i=1; i<=n; i++)cin>>b[i];
	for (int i=1; i<51; i++)c[i]=1;
	for (int i=1; i<=n; i++)if(!dfs(a[i], b[i])){cout<<-1; return 0;}else for (int i=0; i<=50; i++)f[i]=0;
	while(k>0){
		d=1;
		while(d && k){c[k--]=0;
			for (int i=1; i<=n; i++){
				for (int i=0; i<=50; i++)f[i]=0;
				if(!dfs(a[i], b[i]))d=0;
			}
			if(!k && d)o=1;
		}
		if(!o)
			c[k+1]=1,
			ans+=(1ll<<(k+1));
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
n,ma,mb = map(int,input().split())
abc = [list(map(int,input().split())) for i in range(n)]
dp = [[[10000 for i in range(n*10+1)] for j in range(n*10+1)] for k in range(n+1)]
for i in range(n+1):
  dp[i][0][0] = 0
for i in range(1,n+1):
  x,y,c = abc[i-1]
  for j in range(1,n*10+1):
    for k in range(1,n*10+1):
      if j>=x and k>=y:
        dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k],dp[i-1][j-x][k-y]+c)
      else:
        dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k])
ans = 10000000
for i in range(1,n*10+1):
  for j in range(1,n*10+1):
    if i*mb == j*ma:
      ans = min(ans,dp[n][i][j])
if ans == 10000:
  print(-1)
else:
  print(ans)

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

int main () {
  long long N; cin >> N;
  bool j = false;
  long long count = 0;

  if (N > 0) {
    for (int i = 1; i <= N; ++i) {
      if (i == 1 || i == 100 || i == 10000) {
        j = true;
      } else if (i == 10 || i == 1000) {
        j = false;
      } else if (i == 100000) {
        break;
      }

      if (j == true) {
        count += 1;
      } else {
        continue;
      }
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
using namespace std;
//
const int inf=1e9+7;//0x3f
//

struct WeightUnionFind{
	//
	vector<int> ran,par,wei;
	//
	WeightUnionFind(int n){
		init(n);
	}
	//
	void init(int n){
		par.resize(n);
		ran.resize(n,0);
		wei.resize(n,0);
		for(int i=0;i<n;i++){
			par[i]=i;
		}
	}
	//
	int find(int x){
		if(par[x]==x){
			return x;
		}else{
			int r=find(par[x]);
			wei[x]+=wei[par[x]];
			return par[x]=r;
		}
	}
	//
	int weight(int x){
		find(x);
		return wei[x];
	}
	//
	bool same(int x,int y){
		return find(x)==find(y);
	}
	//
	bool unite(int x,int y,int w){
		w+=weight(x);
		w-=weight(y);
		x=find(x);
		y=find(y);
		if(x==y){
			return false;
		}else if(ran[x]<ran[y]){
			swap(x,y);
			w=-w;
		}else if(ran[x]==ran[y]){
			ran[x]++;
		}
		par[y]=x;
		wei[y]=w;
		return true;
	}
	//
	int diff(int x,int y){
		return weight(y)-weight(x);
	}
	//
};
int main(){
	int N,Q;
	cin>>N>>Q;
	WeightUnionFind UF(N);
	while(Q--){
		int L,R,D;
		cin>>L>>R>>D;
		L--;R--;
		if(UF.same(L,R)){
			if(UF.diff(L,R)==D){
				continue;
			}else{
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			UF.unite(L,R,D);
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1408
<?php
define('MOD', 10 ** 9 + 7);
list($n) = ints();
$c = [];
for ($i = 1; $i <= $n; ++$i) {
    $a = primeFactorization($i);
    foreach ($a as $j => $v) {
        if (isset($c[$j])) $c[$j] += $v;
        else $c[$j] = $v;
    }
}
$cnt = 1;
foreach ($c as $v) $cnt = modMul($cnt, $v + 1);
echo $cnt;

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
/**
 * 素数列挙（エラトステネスのふるい）
 * $max以下の素数を格納した配列を返す
 */
function primesArr($max)
{
    $arr = array_fill(2, $max - 1, true);
    $rmax = (int) floor(sqrt($max));
    for ($i = 2; $i <= $rmax; $i++) {
        if (!isset($arr[$i])) continue;
        for ($j = 2 * $i; $j <= $max; $j += $i) {
            unset($arr[$j]);
        }
    }
    return array_keys($arr);
}

/**
 * 素数判定（エラトステネスのふるい）
 * $max以下の整数が素数かどうかboolを格納した配列を返す
 */
function isPrimeArr($max)
{
    $arr = array_fill(0, $max + 1, true);
    $arr[0]  = $arr[1] = false;
    $rmax = (int) floor(sqrt($max));
    for ($i = 2; $i <= $rmax; $i++) {
        for ($j = 2 * $i; $j <= $max; $j += $i) {
            $arr[$j] = false;
        }
    }
    return $arr;
}

// 素因数分解（エラトステネスのふるい）
// インデックスに素数、値に数を格納した配列を返す
// （1は素数ではないので含まない）
function primeFactorization($n)
{
    $res = [];
    if ($n === 1) return $res;

    $primes = primesArr((int) sqrt($n) + 1);

    foreach ($primes as $prime) {
        while ($n % $prime === 0) {
            if (isset($res[$prime])) {
                $res[$prime]++;
            } else {
                $res[$prime] = 1;
            }
            $n /= $prime;
        }
    }

    if ($n > 1) {
        if (isset($res[$n])) {
            $res[$n]++;
        } else {
            $res[$n] = 1;
        }
    }

    return $res;
}

// 素数列挙（試し割り）
function primes($max)
{
    $arr = [];
    for ($i = 2; $i <= $max; $i++) {
        if (isPrime($i)) $arr[] = $i;
    }
    return $arr;
}

// 素数判定（試し割り）
function isPrime($n)
{
    if ($n === 1) return false;
    $rmax = (int) floor(sqrt($n));
    for ($i = 2; $i <= $rmax; $i++) {
        if ($n % $i === 0) return false;
    }
    return true;
}

// 約数列挙
function divisors($max)
{
    $arr = [];
    $rmax = (int) floor(sqrt($max));
    for ($i = 1; $i <= $rmax; $i++) {
        if ($max % $i === 0) {
            $arr[] = $i;
            $arr[] = $max / $i;
        }
    }
    sort($arr);
    return array_unique($arr);
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}


Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
  string s;
  
  cin>>s;
  if(s[s.length()-1]=='s'){
      cout<<s<<"es";
  }
  else{
      cout<<s<<"s";
  }
}

Measured memory_bytes: 3668
#include <iostream>

int digit(int x){
	
	int y;
	
	while(x){
		x/=10;
		y++;
	}
	return y;
}


int main(){

	int a,b;

	while(std::cin >> a >> b ){
		std::cout << digit(a+b) <<  std::endl;
	}
}

Measured memory_bytes: 1160
import fractions

n, m  = map(int, input().split())
a = list(map(int, input().split()))

exp2 = 0
temp = a[0]
while(True):
    if(temp%2 == 1):
        break
    exp2 += 1
    temp /= 2

a_div = []
for i in range(n):
    if(a[i] % 2**exp2 != 0):
        print(0)
        exit()
    if( a[i] % (2**(exp2+1)) == 0):
        print(0)
        exit()

    a_div.append(a[i]//(2**exp2))

lcm = a_div[0]
for i in range(1, n):
    lcm = lcm * a_div[i] // fractions.gcd(lcm, a_div[i])

base = lcm * 2**(exp2 -1)

print( ((m // base) + 1)//2 )

Measured memory_bytes: 90080
# -*- coding: utf-8 -*-

S = input()

# 最終出力は1のみか0のみとなるはず
# つまり、0と1の個数をカウントし、その差分から答えが求められる

c0 = S.count("0")
c1 = S.count("1")

fin = abs(c0-c1)    # 最後に残る0か1の個数
res = len(S) - fin

print(res)


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

#define M1 1000000007
#define M2 1000000009
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define f0(i, n) for (int i = 0; i < (int)(n); ++i)
#define f1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fc0(i,l,r) for(int i = (int)(l); i<(int)(r); ++i)
#define fc1(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define fr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
 
void init()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
      freopen("error.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(0);
    cout << fixed;
}

signed main()
{
    init();

    int t;
    cin>>t;
    cout<<t*t<<endl;
    
    cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
int main(){
  	long long n;
  	long long a[100000];
  	long long b[100000],c[100000];
  	cin>>n;
  	long long sa=0,sb=0;
  	for(int i=0;i<n;i++){
      	cin>>a[i];
      	sa+=a[i];
    }
  	for(int i=0;i<n;i++){
      	cin>>b[i];
      	sb+=b[i];
    }
  	if(sa<sb){
      	cout<<-1<<endl;
      	return 0;
    }
  	for(int i=0;i<n;i++){
      	c[i]=a[i]-b[i];
    }
  	long long mi=0;
  	long long ans=0;
  	vector<long long> v;
  	for(int i=0;i<n;i++){
      	if(c[i]<=0){
          	if(c[i]!=0){
              	ans++;
            }
          	mi+=abs(c[i]);
        }else{
          	v.push_back(c[i]);
        }
    }
  	sort(v.rbegin(),v.rend());
  	int idx=0;
  	while(mi>0){
      	mi-=v[idx];
      	idx++;
      	ans++;
    }
  	cout<<ans<<endl;
  	return 0;
}


Measured memory_bytes: 3196
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, M, s[12], c[12];

int main() {

	cin >> N >> M;
	rep(i, M) cin >> s[i] >> c[i];

	char ans[5] = {};

	rep(i, M) {
		if (ans[s[i] - 1] != '\0' && ans[s[i] - 1] != '0' + c[i]) {
			cout << "-1" << endl;
			return 0;
		}
		ans[s[i] - 1] = '0' + c[i];
	}
	if (N == 1) {
		if (ans[0] == 0) cout << 0 << endl;
		else cout << ans << endl;
		return 0;
	}
	else {
		if (ans[0] == '0') {
			cout << -1 << endl;
		}
		else {
			rep(i, N) {
				if (ans[i] == 0) {
					if (i == 0) ans[i] = '1';
					else ans[i] = '0';
				}
			}
			cout << ans << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i, j;
	int n;
	int len;
	char str[1024];
	
	scanf("%d\n", &n);
	
	for (j = 0; j < n; j++){
		fgets(str, 1024, stdin);
		
		len = strlen(str);
		for (i = 0; i < len; i++){
			if (strncmp(&str[i], "Hoshino", 7) == 0){
				strncpy(&str[i], "Hoshina", 7);
			}
		}
		printf("%s", str);
	}
	
	return (0);
}

Measured memory_bytes: 1028
#include<iostream>
#include<cmath>
#include<cctype>
#include<vector>
using namespace std;
int main(){
        double a,b,c,rad,cs;
        scanf("%lf %lf %lf",&a,&b,&c);
        rad=c*3.14159263/180;
        cs=sqrt(a*a+b*b-2*a*b*cos(rad));
        double h=b*sin(rad);
        printf("%lf\n%lf\n%lf\n",h*a/2,a+b+cs,h);
        return 0;
}

Measured memory_bytes: 1224
n,k = map(int,input().split())
m = 10**9+7
b = 1
r = n-k+1
print(b*r%m)
for i in range(2,k+1):
  b *= k-i+1
  b //= i-1
  r *= n-k-i+2
  r //= i
  print(b*r%m)

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

using namespace std;

#define int             long long


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}





int f( vector<int>& a, int k) {

	int dp[k + 1];
	memset(dp, 0, sizeof dp);


	for (int i = 1; i <= k; i++) {


		for (auto x : a) {
			if (x > i)
				continue;
			if (dp[i - x] == 0)
				dp[i] = 1;
		}
	}
	return dp[k];
}
int32_t main() {
	c_p_c();

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

	if (z == 1)
		cout << "First";
	else cout << "Second";

	return 0;
}


Measured memory_bytes: 4416
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=105;

int n;
vector<pair<int,int>> ans;

int main()
{
    scanf("%d",&n);
    int S=n;
    if(n%2==0)
        S=n+1;
    for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
            if(i+j!=S)
                ans.push_back(make_pair(i,j));
    printf("%d\n",(int)ans.size());
    for(auto u:ans)
        printf("%d %d\n",u.first,u.second);
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int H, W, h, w; cin >> H >> W >> h >> w;
    cout << H * W - h * W - H * w + h * w << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	int N;
    cin >> N;
    VI X;
    rep(i,N){
        int x;
        cin >> x;
        X.PB(x);
    }
    sort(all(X));
    //cout << X[N-1] << endl;
    ll ans = INF;

    rep(i,X[N-1]+1){
        ll sum = 0;
        rep(j,N){
            sum += (ll)(X[j]-i)*(X[j]-i);
            //cout << sum << " ";
        }
        //cout << endl;
        chmin(ans,sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
    vector<int> arr;
    int n, k;
    cin >> n >> k;
    long long curr = 0;

    while (n > 0) {
        int num;
        cin >> num;
        arr.push_back(num);
        n--;
    }
    if (k >= arr.size()) {
        cout << curr << endl;
    } else {
        sort(arr.begin(), arr.end());
        for (int i = 0; i < arr.size() - k; i++) {
            curr += arr[i];
        }
        cout << curr << endl;
    }

    // sort, use k on end, return sum of 0 to N - k
}


Measured memory_bytes: 1400
#include<iostream>
using namespace std;
long long large_array[10000005];
int main(){
  int n;
  cin>>n;
  
  for(int i=1;i<=n;i++){
    for(int j=i;j<=n;j+=i){
      large_array[j]++;
    }
  }
  
  long long ans=0;
  for(int i=1;i<=n;i++){
    ans+=i*large_array[i];
  }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 81756
#include<iostream>
#include<fstream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[5];
int main()
{
 //freopen(".in","r",stdin);
 //freopen(".out","w",stdout);
 cin>>s[1]>>s[2]>>s[3];
 sort(s+1,s+3+1);
 cout<<s[1]+s[2];
 return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))

int main()
{
    int n,k;
    sint2(n,k);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int a;
        sint(a);
        if(a>=k)
            sum++;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, m;
  cin >> n >> m;
  ll t = m/n;
  for (ll i = t; i > 0; --i) {
    if (m%i == 0) {
      cout << i << '\n';
      return 0;
    }
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3620
import sys
from collections import deque

s = input()
q = int(input())
ans = deque()
ans.append(s)
reverseFlg = False

for i in range(q):
    query = list(input().split())
    # print(query)

    if query[0]=='1':
        reverseFlg = not reverseFlg
    else:
        if reverseFlg:
            if query[1]=='1':
                ans.append(query[2])
            else:
                ans.appendleft(query[2])
        else:
            if query[1]=='1':
                ans.appendleft(query[2])
            else:
                ans.append(query[2])
    

out = ''.join(ans)

if reverseFlg:
    print(out[::-1])
else:
    print(out)

Measured memory_bytes: 6900
program sample
	implicit none
    character(len=3) ::N
    
    read(*,*) N
    
    if (N(1:1)=='7' .or. N(2:2)=='7' .or. N(3:3)=='7') then
    	write(*,*) 'Yes'
    else 
    	write(*,*) 'No'
    end if
    
    stop
end program sample

Measured memory_bytes: 2716
#include<stdio.h>
#include<stdlib.h>


void swap(int *x, int *y) {
	int temp;   

	temp = *x;
	*x = *y;
	*y = temp;
}


int partition(int array[], int left, int right) {
	int i, j, pivot;
	i = left;
	j = right + 1;
	pivot = left;   

	do {
		do { i++; } while (array[i] < array[pivot]);
		do { j--; } while (array[pivot] < array[j]);
		if (i < j) { swap(&array[i], &array[j]); }
	} while (i < j);

	swap(&array[pivot], &array[j]);   

	return j;
}

void quick_sort(int array[], int left, int right) {
	int pivot;

	if (left < right) {
		pivot = partition(array, left, right);
		quick_sort(array, left, pivot - 1);  
		quick_sort(array, pivot + 1, right);
	}
}

int main()
{
	int N, K, m;
	int d[100000];
	scanf("%d", &N);
	for (m = 1; m < N + 1; m++)
	{
		scanf("%d", &d[m]);
	}
	quick_sort(d, 1, N);
	printf("%d", d[N / 2 + 1] - d[N / 2]);
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size(); ++i) {
		if ('2' == S[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define int int64_t
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000*1000*1000+7
#define mem(dp,a) memset(dp,a,sizeof dp)
int32_t main()
{
    int h,a;cin>>h>>a;
    int ar[1<<18];
    for(int i=0;i<h;i++)
        cin>>ar[i];
    sort(ar,ar+h);
    int ans=0;
    for(int i=0;i<h-a;i++)
        ans+=ar[i];
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1792
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]

    pos = [f() for i in range(n)]

    notz = 0
    for i in range(n):
        if pos[i][2]!=0:
            notz = i
            break


    for i in range(101):
        for j in range(101):
            d1 = abs(pos[notz][0] - i) + abs(pos[notz][1] - j)
            h = d1 + pos[notz][2]

            ok = True
            for k in range(n):
                if max(0,h - abs(pos[k][0] - i) - abs(pos[k][1] - j)) != pos[k][2]:
                    ok = False
                    break

            if ok:
                print(i,j,h)
                return




solve()


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int N, K; scanf("%d %d", &N, &K);
	vector<int> snukes;
	while (K--) {
		int d; scanf("%d", &d);
		int s;
		for (int i = 0; i < d; i++) {
			scanf("%d", &s);
			snukes.push_back(s);	
		}		
	}
	int victim = 0;
	for (int i = 1; i <= N; i++) {
		if (find(snukes.begin(), snukes.end(), i) == snukes.end())
			victim++;
	}
	cout << victim << "\n";
}


Measured memory_bytes: 3756
#include<iostream>
#include<stack>
#include<cstdlib>
using namespace std;

int main()
{
  string cal;
  int n,M=0,L=0;
  long long l=0,m=0,top;
  stack<int> S;
  cin>>cal>>n;
  S.push((cal[0]-'0'));
  for(int i=1;i<cal.length()-1;i+=2){
    if(cal[i]=='+'){
      S.push((cal[i+1]-'0'));
    }
    if(cal[i]=='*'){
      top=S.top();S.pop();
      S.push(top*(cal[i+1]-'0'));
    }
  }
  while(!S.empty()){
    m+=S.top();
    S.pop();
  }
  if(m==n)M=1;
  l=(cal[0]-'0');
  for(int i=1;i<cal.length();i+=2){
    if(cal[i]=='+'){
      l+=(cal[i+1]-'0');
    }
    if(cal[i]=='*'){
      l*=(cal[i+1]-'0');
    }
  }
  if(l==n)L=1;
  if(L==1 && M==1)cout<<"U"<<endl;
  else if(L==0 && M==1)cout<<"M"<<endl;
  else if(L==1 && M==0)cout<<"L"<<endl;
  else cout<<"I"<<endl;
  return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int main(void) {
	vector<int> a(300000,0);
	int n, k, temp, i;
	int count = 0;
	int ans = 0;

	cin >> n >> k;

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

	sort(a.begin(), a.end());

	for (i = 0;i < 300000;i++) {
		if (a[i] != 0) {
			break;
		}
	}

	count = 300000 - i;

	for (i = 300000 - count;i < 300000 - k;i++) {
		ans += a[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h) cin >> s[i];

    VVI a(h, VI(w));
    REP(i,h) REP(j,w) a[i][j] = (s[i][j] == '#');

    VVI b(a);
    REP(i,h) REP(j,w){
        if ((i + j) % 2 == 1) b[i][j] ^= 1;
    }

    ll ans = 0;
    VVI visit(h, VI(w));
    REP(i,h) REP(j,w){
        if (visit[i][j]) continue;
        queue<P> que;
        que.push(P(i, j));
        visit[i][j] = 1;
        ll c0 = 0, c1 = 0;
        while (!que.empty()){
            P p = que.front();
            que.pop();
            int x = p.first, y = p.second;
            // cout << x << y << endl;
            if ((x + y) % 2 == 0) c0++;
            else c1++;
            REP(d,4){
                int xx = x + dx[d], yy = y + dy[d];
                if (xx < 0 || xx >= h || yy < 0 || yy >= w || visit[xx][yy] || b[xx][yy] != b[i][j]) continue;
                visit[xx][yy] = 1;
                que.push(P(xx, yy));
            }
        }
        ans += c0 * c1;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
    fasterthanlight;
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
    //cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

class sieve
{
protected:
    int _n;
    std::vector<bool> _f;
public:
    sieve(int n) : _n(n), _f(n+1, true) {
        _f[0] = false;
        _f[1] = false;
        for (int i = 4; i < _f.size(); i+=2)
            _f[i] = false;
        for (int i = 3; i*i < _f.size(); i+=2) {
            if (!_f[i]) continue;
            for (int j = i*i; j < _f.size(); j += i)
                _f[j] = false;
        }
    }
    bool prime(int x) const { return _f[x]; }
    int size() const { return _n; }
};

int main()
{
    int X; cin >>X;
    sieve sv((int)1e5+1000);
    for (int i = X; i <= sv.size(); i++) {
        if (sv.prime(i)) {
            cout << i <<endl;
            return 0;
        }
    }
    cout << "NG" <<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define prime 1000000007
#define INF 40000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
signed main(void){
    int n;cin>>n;
    vector<P>V(n);
    rep(i,n){
        int r,c;cin>>r>>c;
        V[i]=make_pair(r,c);
    }
    vector<int>Grid(8);
    rep(i,8)Grid[i]=i;
    do{
        bool judge=true;
        rep(i,n){
            if(Grid[V[i].F]!=V[i].S)judge=false;
        }
        vector<vector<bool>>JJ(8,vector<bool>(8,false));
        rep(i,8){
            int r=i,c=Grid[i];
            for(int j=0;j<8;j++){
                if(j==i)continue;
                JJ[j][c]=true;
            }
            for(int j=1;j<8;j++){
                if(r+j>=8||c-j<0)break;
                JJ[r+j][c-j]=true;
            }
            for(int j=1;j<8;j++){
                if(r-j<0||c+j>=8)break;
                JJ[r-j][c+j]=true;
            }
            for(int j=1;j<8;j++){
                if(r-j<0||c-j<0)break;
                JJ[r-j][c-j]=true;
            }
            for(int j=1;j<8;j++){
                if(r+j>=8||c+j>=8)break;
                JJ[r+j][c+j]=true;
            }
        }
        rep(i,8){
            if(JJ[i][Grid[i]])judge=false;
        }
        if(!judge)continue;
        rep(i,8){
            string s="";
            rep(j,8){
                if(j==Grid[i])s+='Q';
                else s+='.';
            }
            cout<<s<<endl;
        }
        return 0;
    }while(next_permutation(all(Grid)));
}
        



Measured memory_bytes: 3212
#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 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; }
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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin >> a >>b;
    cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 3616