akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main () {
  int a, b;
  cin >> a >> b;
  string s;
  rep(_,b) s += '0'+a;
  string t;
  rep(_,a) t += '0'+b;
  cout << min(s,t) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
int main() {
  long double W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << W / 2 * H;
  if (x * 2 == W && y * 2 == H) {
    cout << " 1" << endl;
  } else {
    cout << " 0" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
dp = [N]*(N+1)
dp[0] = 0

for i in range(N+1):
  for j in [6**i for i in range(7)]:
    if i+j <= N:
      dp[i+j] = min(dp[i+j],dp[i]+1)
  for j in [9**i for i in range(6)]:
    if i+j <= N:
      dp[i+j] = min(dp[i+j],dp[i]+1)

print(dp[-1])

Measured memory_bytes: 3828
h, n = map(int, input().split())
dp = [10**10]*(h+1)
dp[0] = 0
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))

for a, b in ab:
    for start in range(h):
        end = min(start+a, h)
        dp[end] = min(dp[end], dp[start]+b)
print(dp[h])


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

void Mr_J(string *str){
  
  string s1,s2;
  
  s1=(*str).substr(0,1);
  s2=(*str).substr(1);
  
  (*str)=s2+s1;
  
}
void Miss_C(string *str){

  string s1,s2;
  
  s1=(*str).substr(0,(*str).size()-1);
  s2=(*str).substr((*str).size()-1);
  
  (*str)=s2+s1;
  
}
void Mr_E(string *str){
  
  string s1,s2,s3;
  
  if((*str).size() % 2 == 0){
    s1=(*str).substr(0,(*str).size()/2);
    s2=(*str).substr((*str).size()/2);
    (*str)=s2+s1;
  }else{
    s1=(*str).substr(0,(*str).size()/2);
    s2=(*str).substr(((*str).size()/2)+1);
    s3=(*str).substr((*str).size()/2,1);
    (*str)=s2+s3+s1;
  }
  
}
void Mr_A(string *str){
  
  string s1;
  
  s1="";
  
  for(int i=(*str).size()-1 ; i >= 0 ; i--){
    s1+=(*str)[i];
  }
  
  (*str)=s1;
  
}
void Dr_P(string *str){
  
  for(int i=0 ; i < (*str).size() ; i++){
    if((*str)[i] >= '0' && (*str)[i] <= '9'){
      (*str)[i]=(*str)[i]+1;    
      if((*str)[i] > '9')(*str)[i]='0';
    }
  }
  
}
void Mr_M(string *str){
  
  for(int i=0 ; i < (*str).size() ; i++){
    if((*str)[i] >= '0' && (*str)[i] <= '9'){
      (*str)[i]=(*str)[i]-1;
      if((*str)[i] < '0')(*str)[i]='9';
    }
  }
}
int main(){
  
  int n;
  
  cin >>n;
  
  for(int i=0 ; i < n ; i++){
    string key,str;
    cin >>key;
    cin >>str;
    for(int j=key.size()-1 ; j >= 0; j--){
      switch(key[j]){
      case 'J':
	Miss_C(&str);
	break;
      case 'C':
	Mr_J(&str);
	break;
      case 'E':
	Mr_E(&str);
	break;
      case 'A':
	Mr_A(&str);
	break;
      case 'P':
	Mr_M(&str);
	break;
      case 'M':
	Dr_P(&str);
	break;
      }
    }
    cout <<str<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1212
import java.util.Scanner;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<Integer>();
        int num;

        num = Integer.parseInt(scan.next());
        for (int i = 0; i < num; i++) {
            list.add(Integer.parseInt(scan.next()));
        }
        for (int i = num - 1; i >= 0; i--) {
            System.out.print(list.get(i));
            if (i != 0) {
                System.out.print(" ");
            }
        }
        System.out.print("\n");
    }
}



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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


void quit() {
  cout << "No" << endl;
  exit(0);
}

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

  int x[26];
  REP (i, 26) {
    x[i] = -1;
  }

  REP (i, s.size()) {
    if (x[s[i] - 'a'] == -1) x[s[i] - 'a'] = t[i] - 'a';
    else if (x[s[i] - 'a'] != t[i] - 'a') quit();
  }

  int done[26] = {false};
  REP (i, 26) {
    if (x[i] == -1) continue;
    int next = x[i];
    if (done[next]) quit();
    done[next] = true;
    int cnt = 0;
    while(next != -1 && next != i) {
      cnt++;
      if (cnt > 30) quit();
      next = x[next];
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 904
#include<iostream>
using namespace std;
int main(){
    int i,count[100]={0},suu,o=0;
    char x,y;
    while(cin>>x){
		o++;
        if(o>1200){
        break;
        }
        if(x<=90){
    suu=x-65;
    count[suu]++;
        }
        else{
        suu=x-97;
        count[suu]++;
        }
    }
    for(i=0;i<26;i++){
        y=i+'a';
    cout<<y<<" : "<<count[i]<<endl;
    }
return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  
  int n;
  scanf("%d", &n);
  
  char s[n][11];
  for(int i = 0; i < n; i++){
    scanf("%s", s[i]);
  }
  
  qsort(s, n, 11, strcmp);
  
  int count = 1;
  for(int i = 0; i < n-1; i++){
    if(strcmp(s[i], s[i+1]) != 0){
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


Measured memory_bytes: 6072
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1005;
char mp[N][N];int n;
void m4(int k){
	int len=3;
	string s="aabc";
	fp(i,0,len)mp[k][k+i]=s[i];
	s="ddbc";
	fp(i,0,len)mp[k+1][k+i]=s[i];
	s="bcaa";
	fp(i,0,len)mp[k+2][k+i]=s[i];
	s="bcdd";
	fp(i,0,len)mp[k+3][k+i]=s[i];
}
void m5(int k){
	int len=4;
	string s="aabba";
	fp(i,0,len)mp[k][k+i]=s[i];
	s="bcc.a";
	fp(i,0,len)mp[k+1][k+i]=s[i];
	s="b..cb";
	fp(i,0,len)mp[k+2][k+i]=s[i];
	s="a..cb";
	fp(i,0,len)mp[k+3][k+i]=s[i];
	s="abbaa";
	fp(i,0,len)mp[k+4][k+i]=s[i];
}
void m6(int k){
	int len=5;
	string s="aabc..";
	fp(i,0,len)mp[k][k+i]=s[i];
	s="ddbc..";
	fp(i,0,len)mp[k+1][k+i]=s[i];
	s="..aabc";
	fp(i,0,len)mp[k+2][k+i]=s[i];
	s="..ddbc";
	fp(i,0,len)mp[k+3][k+i]=s[i];
	s="bc..aa";
	fp(i,0,len)mp[k+4][k+i]=s[i];
	s="bc..dd";
	fp(i,0,len)mp[k+5][k+i]=s[i];
}
void m7(int k){
	int len=6;
	string s="aabbcc.";
	fp(i,0,len)mp[k][k+i]=s[i];
	s="dd.dd.a";
	fp(i,0,len)mp[k+1][k+i]=s[i];
	s="..d..da";
	fp(i,0,len)mp[k+2][k+i]=s[i];
	s="..d..db";
	fp(i,0,len)mp[k+3][k+i]=s[i];
	s="dd.dd.b";
	fp(i,0,len)mp[k+4][k+i]=s[i];
	s="..d..dc";
	fp(i,0,len)mp[k+5][k+i]=s[i];
	s="..d..dc";
	fp(i,0,len)mp[k+6][k+i]=s[i];
}
int main(){
	scanf("%d",&n);
	if(n<=2)return puts("-1"),0;
	if(n==3)return printf("aa.\n..a\n..a\n"),0;
	fp(i,1,n)fp(j,1,n)mp[i][j]='.';
	R int p=1;
	for(p=1;p+7<=n;p+=4)m4(p);
	switch(n%4){
		case 0:m4(p);break;
		case 1:m5(p);break;
		case 2:m6(p);break;
		case 3:m7(p);break;
	}
	fp(i,1,n){
		fp(j,1,n)putchar(mp[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;

ll euclid(ll a, ll b ){
ll temp;
if( a < b ) { temp = a; a = b; b = temp; }
if( b < 1 ) return -1;
if( a % b == 0 ) return b;
return euclid( b, a % b );
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    ll A, B; cin >> A >> B;
    ll gcd = euclid(A, B);
    vector<pair<long long, long long> > res = prime_factorize(gcd);
    cout << res.size() + 1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    const int mod = 1e9+7;
    int ans = 1;
    vi v(n,0);
    rep(i,n) {
        int a;
        cin >> a;
        v[a]++;
    }
    if(n%2 == 0) {
        for(int i = 1; i < n; i += 2) {
            if(v[i] == 2) ans = ans*2%mod;
            else ans = 0;
        }
    } else {
        if(v[0] != 1) ans = 0;
        if(n != 1) for(int i = 2; i < n; i += 2) {
                if(v[i] == 2) ans = ans*2%mod;
                else ans = 0;
        }
    }
    cout << ans << endl;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<vector<ll>> A(2, vector<ll>(N));

    REP(i, 2){
        REP(j, N){
            cin >> A[i][j];
        }
    }

    ll ans = 0;

    for(ll i=0; i<N; i++){
        ll temp = 0;
        for(ll j=0; j<=i; j++){
            temp += A[0][j];
        }
        for(ll j=i; j<N; j++){
            temp += A[1][j];
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    ll N; cin >> N;
    ll a = 1, b = N;
    for (ll i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            a = i;
            b = N / i;
        }
    }
    cout << (a - 1) + (b - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sz(x) (sizeof(x)/sizeof(*x))
#define F first
#define S second


int main(){
    //ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,a[21],b[21],sum=0;
    cin>>n;
    REP(i,n)cin>>a[i];
    REP(i,n)cin>>b[i];
    REP(i,n){
        if(a[i]>b[i])sum+=a[i]-b[i];
    }
    cout<<sum<<endl;
//    system("pause");
    return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

char c;
bool f[205];

int main()
{
    _FastIO;
    string s;
    cin >> s;
    f[65] = true;
    f[67] = true;
    f[71] = true;
    f[84] = true;
    int m = 0;
    int ans = 0;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(f[int(s[i])])
            m++;
        else{
            ans = max(ans , m);
            m = 0;
        }
    }
    cout << max(ans , m) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x) // big bug here if "-x" is not surrounded by "()"
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}};

int n;
int v[111];
int c[111];
void dane() {
    cin>>n;
    F(i,0,n) cin>>v[i];
    F(i,0,n) cin>>c[i];
    int sum = 0;
    F(i,0,n) {
        if(v[i] > c[i]) sum+=v[i]-c[i];
    }
    cout<<sum<<endl;
}


int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

struct uf_tree {
  vector<int> par, sizes;
  uf_tree(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
    }
  }
  int find(int x) {
    if (x == par[x]) {
      return x;
    }
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return;
    }
    if (sizes[x] < sizes[y]) {
      swap(x, y);
    }
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return sizes[find(x)]; }
};

int N, M;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  uf_tree uf(N);
  for (int i = 0; i < M; i++) {
    int xi, yi, zi;
    cin >> xi >> yi >> zi;
    xi--;
    yi--;
    uf.unite(xi, yi);
  }

  int ans = 0;
  set<int> st;
  for (int i = 0; i < N; i++) {
    int v = uf.find(i);
    if (st.find(v) == st.end()) {
      ans++;
      st.insert(v);
    }
  }

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

Measured memory_bytes: 5760
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;
//use ac_library_rs::*;

#[fastout]
fn main() {
    input! {
        s: String,
    }
    let n = s.len();

    print!("{}", s);
    if &s[n-1..] == "s" {
        println!("es");
    } else {
        println!("s");
    }

}


Measured memory_bytes: 2204
from sys import stdin
from bisect import bisect_left


def input():
    return stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    B.sort()
    C.sort()

    nums = [0] * (N + 1)

    pos = 0
    for i, b in enumerate(B):
        pos = bisect_left(C, b + 1, pos)
        nums[i] = N - pos

    for i in range(N, 0, -1):
        nums[i - 1] += nums[i]

    ans = 0
    pos = 0
    for a in A:
        pos = bisect_left(B, a + 1, pos)
        ans += nums[pos]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24052
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vp(m);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    vp[i] = make_pair(b, a);
  }
  sort(vp.begin(), vp.end());
  int x = 0;
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    if (x <= vp[i].second) {
      x = vp[i].first;
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n,m;
  cin >> n >> m;
  if(n==m) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
import copy

def bi_search(money,M,N):
    money.sort()
    #list = []
    #for i in range(0,money[N-1]+2,1):
        #list.append(i)
    left = 0
    right = money[N-1]+1
    mid = 0
    #print(list,left,right)
    while True:
        mid = int( (left+right)/2 )
        cnt = 0
        #print(left,right,mid)
        #print(money)
        money_tmp = copy.copy(money)
        for i in range(N):
            while True:
                #print(money_tmp[i],i)
                if money_tmp[i] <= mid:
                    break
                else:
                    money_tmp[i] //= 2
                    cnt += 1
        #print(cnt)
        if cnt == M:
            return mid,cnt
        elif cnt < M:
            right = mid
            tmp = cnt
        elif cnt > M:
            left = mid + 1

        if left == right:
            return right,tmp

def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    max_money,cnt = bi_search(A,M,N)
    #print (cnt)
    cnt = M-cnt
    ans = 0
    for i in range(N):
        if max_money >= A[i]:
            continue
            #ans += A[i]
        else:
            while True:
                A[i] //= 2
                if max_money >= A[i]:
                    #ans += A[i]
                    break
    A.sort(reverse = True)
    j = 0
    if A[j] == 0:
        return 0
    for i in range(cnt):
        A[j] //= 2
        j += 1

    for i in range(N):
        ans += A[i]

    return ans

print(main())


Measured memory_bytes: 20504
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var b = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var res = (long)0;
        for (int i = 0; i < n; i++)
        {
            var totalKill = b[i];
            var kill = Min(totalKill, a[i]);
            a[i] -= kill;
            totalKill -= kill;
            res += kill;
            kill = Min(totalKill, a[i + 1]);
            a[i + 1] -= kill;
            totalKill -= kill;
            res += kill;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 33888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec p(n), q(n);
	rep(i, n) cin >> p[i];
	rep(i, n) cin >> q[i];

	Vec t(n);
	rep(i, n) t[i] = i + 1;
	ll a, b, cnt = 0;
	do {
		if (t == p) a = cnt;
		if (t == q) b = cnt;
		cnt++;
	} while (next_permutation(all(t)));

	co(abs(a - b));

	return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()

using namespace std;

vector<int> X[100001];
vector<int> Y[100001];
bool visx[100001],visy[100001];

int main()
{
    IOS;
    int n;
    cin>>n;
    int x[n],y[n];
    memset(visx,false,sizeof visx);
    memset(visy,false,sizeof visy);
    repf(i,0,n) 
    {
        cin>>x[i]>>y[i];
        X[x[i]].pb(i);
        Y[y[i]].pb(i);
    }
    bool vis[n]={false};
    ll ans=0;
    repf(i,0,n)
    {
        if(vis[i]) continue;
        vis[i]=true;
        queue<int> q;
        set<int> ux,uy;
        ux.insert(x[i]);uy.insert(y[i]);
        q.push(i);
        while(!q.empty())
        {
            int cur=q.front();
            q.pop();
            vector<int> to;
            if(!visx[x[cur]])
            {
                visx[x[cur]]=true;
                for(auto j:X[x[cur]])
                {
                    to.pb(j);
                }
            }
            if(!visy[y[cur]])
            {
                visy[y[cur]]=true;
                for(auto j:Y[y[cur]])
                {
                    to.pb(j);
                }
            }
            for(auto j:to)
            {
                if(vis[j]) continue;
                vis[j]=true;
                ux.insert(x[j]);uy.insert(y[j]);
                q.push(j);
            }
        }
        ans+=(ll)ux.size()*uy.size();
    }
    cout<<ans-n<<endl;
}
 

Measured memory_bytes: 13824
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ShekharN
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int m = in.nextInt();
            out.println(24 + 24 - m);
        }

    }

    static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        public String nextString() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 21588
n = int(input())
mod = 10**9+7
# https://note.nkmk.me/python-prime-factorization/
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

table = [0] * (n+1)
for i in range(2, n+1):
  p = prime_factorize(i)
  for pi in p:
    table[pi] += 1
ans = 1
for t in table:
  ans = ans * (t+1) % mod
print(ans)
  



Measured memory_bytes: 70776
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long 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;
}

void solve() {
		int n; cin >> n;
		vector<int64> a(n);
		rep (i, n) {
			cin >> a[i];
		}
		int64 ans = 0;
		for (int i = 0; i < 60; ++i) {
			int64 cnt = 0;
			rep (j, n) {
				 cnt += (a[j] >> i & 1);
			}
			cnt = cnt * (n - cnt);
			int64 num = cnt;
			for (int j = 0; j < i; ++j) {
				num = (num * 2) % MOD;
			}
			ans += (num % MOD);
		}
		cout << ans % MOD << endl;
    return;
}

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



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

int main() {
	//cout<<"GfG!";
	string s, t;
	cin>>s>>t;
	t.pop_back();
	if (s == t)
	    cout<<"Yes";
	else
	    cout<<"No";
	return 0;
}

Measured memory_bytes: 3628
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

L = list(itertools.permutations(range(1,N+1)))
L.sort()
for l in L:
    if l == P:
        a = L.index(l)
    if l == Q:
        b = L.index(l)
print(abs(a-b))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

vector<int> sorted;

void dfs(int node, const vector<vector<int>> &g, vector<bool> &visited) {
    visited[node] = 1;
    for(auto it : g[node])
        if(!visited[it])
            dfs(it, g, visited);

    sorted.push_back(node);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n + 1);
    for(int i = 1; i <= m; i ++) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }

    vector<bool> visited(n + 1, 0);
    for(int i = 1; i <= n; i ++)
        if(!visited[i])
            dfs(i, g, visited);
    reverse(sorted.begin(), sorted.end());

    vector<int> dp(n + 1, 0);
    int ans = 0;
    for(auto node : sorted) {

        for(auto it : g[node])
            dp[it] = max(dp[it], dp[node] + 1);
        ans = max(ans, dp[node]);
    }
    cout << ans;

    return 0;
}


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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define br cout<<endl;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pp pair<int,int>
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 100005;
const int INF = 1e9+7;
const ll LINF = 1e18 + 7;

/***************************************************************************/

int main()
{
    ios::sync_with_stdio(0);
    ll r,x,d;
    cin>>r>>d>>x;
    int t=10;
    while(t--)
    {
        ll f=(r*x)-d;
        cout<<f<<endl;
        x=f;
    }
    return 0;
}


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	static List<String> l;
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int p[] = fs.nextIntArray(n);
		int q[] = fs.nextIntArray(n);
		
		String sp = "", sq = "";
		for(int i=0;i<n;i++) {
			sp += p[i];
			sq += q[i];
		}
		
		if(sp.equals(sq)) {
			System.out.println(0);
			return;
		}
		
		//1~nの順列を作る
		String s = "";
		for(int i=1;i<=n;i++) {
			s += i;
		}
		String ans = "";
		l = new ArrayList<String>();
		permutation(s, ans);
		int a = 0;
		int b = 0;
		boolean bb = false;
		for(int i=0;i<l.size();i++) {
			if(l.get(i).equals(sp)||l.get(i).equals(sq)) {
				if(bb == false) {
					a = i+1;
					bb = true;
				}else {
					b = i+1;
				}
			}
		}
		int res = b - a;
		System.out.println(res);
		
	}
    public static void permutation(String q, String ans){
        // Base Case
        if(q.length() <= 1) {
           l.add(ans + q);
        	// System.out.println(ans + q);
        }
        // General Case
        else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1),
                        ans + q.charAt(i));
            }
        }
    


}
}
 


//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

int main(){
	string s;
	cin >> s;
	int n = s.size() - 1;
	for(int i = 0; i < n / 2; i++) {
		if(s[i] != s[n - i]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}


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


int main(){

  int n;
  cin >> n;
  
  int p[n];
  int q[n];
  
  bool valid[n];
  
  for(int i=0; i<n; i++){
  	cin >> p[i];
  }
  
  for(int i=0; i<n; i++){
  	cin >> q[i];
  }
  
  for(int i=0; i<n; i++){
    valid[i] = true;
  }
  
  int pnum = 0;
  for(int i=0; i<n; i++){
    valid[p[i] -1] = false;
      	int count = 0;
  	for(int j=0; j<p[i]; j++){
    	if(valid[j] == true){
        	count++;
        }
    }
    int factorial = 1;
    for(int j=1; j<n-i; j++){
      factorial *= j;
    }
    pnum += count * factorial;
  }

  for(int i=0; i<n; i++){
    valid[i] = true;
  }
  
  int qnum = 0;
  for(int i=0; i<n; i++){
    valid[q[i] -1] = false;
    
    int count = 0;
  	for(int j=0; j<q[i]; j++){
    	if(valid[j] == true){
        	count++;
        }
    }
    int factorial = 1;
    for(int j=1; j<n-i; j++){
      factorial *= j;
    }
    qnum += count * factorial;
  }

  cout << abs(qnum - pnum) << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,K;
    cin >> N >> K;
    vl A(N);
    rep(i,N){
        cin >> A[i];
    }
    vl NA(N*(N+1)/2);
    ll now=0;
    rep(i,N){
        ll nowa=A[i];
        ll j=i;
        while(j<N){
            NA[now]=nowa;
            now++;
            j++;
            if(j<N){
                nowa+=A[j];
            }
        }
    }
    ll ans=0;
    per(i,50){
        ll res=ans+pow(2,i)+1e-6,cnt=0;
        cerr << res << endl;
        rep(i,N*(N+1)/2){
            if((NA[i]|res)==NA[i]){
                cnt++;
            }
        }
        if(cnt>=K){
            ans=res;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7096
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <random>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

#define INF 1000000

ll evalNow(vector<vector<int>>& s, vector<int>& c, vector<int>& t, int d, vector<int> last) {
    ll ans = 0;
    ans += s[d][t[d]-1];
    last[t[d]-1] = d+1;
    rep(j, 26) {
        ans -= c[j]*(d+1 - last[j]);
    }
    return ans;
}

ll evalAll(vector<vector<int>>& s, vector<int>& c, vector<int>& t, int d) {
    ll ans = 0;
    vector<int> last(26,0);
    rep(i, d) {
        ans += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        rep(j, 26) {
            ans -= c[j]*(i+1 - last[j]);
        }
    }
    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> c(26);
    rep(i, 26) {
        cin >> c[i];
    }
    vector<vector<int>> s(d, vector<int>(26,0));
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    ll ans = 0;
    vector<int> last(26,0);

    rep(i, d) {
        ll tmpmax = - (1LL << 60);
        ll candidate = -1;
        rep(j, 26) {
            t[i] = j+1;
            if(tmpmax < evalNow(s,c,t,i,last)) {
                tmpmax = evalNow(s,c,t,i,last);
                candidate = j+1;
            }
        }
        last[t[i]-1] = i + 1;
        t[i] = candidate;
    }
    ll tmpmax = evalAll(s,c,t,d);

    double start,end;
    start = 20000;
    end = 0;

    double loop = 200000;

    rep(x, loop) {
        int i = rand()%d;
        int j = rand()%26;
        int original = t[i];
        t[i] = j+1;
        ll tmp = evalAll(s,c,t,d);
        if(tmpmax < tmp) {
            tmpmax = tmp;
        } else {
            double temp = start + (end - start)*x/loop;
            double prob = exp((tmpmax-tmp)/temp);
            ll diff = tmpmax - tmp;
            if (prob > (rand()%INF)/(double)INF) {
                t[i] = original;
            }
        }
    }


    rep(i, d) {
        cout << t[i] << endl;
    }
}


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

ll a[300000];
int main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%lld",&a[i]);
	multiset<ll>ms;
	rep(i,n)ms.insert(a[i]);
	int cnt=0;
	while(ms.size()>1){
		ll a=*ms.rbegin();ms.erase(--ms.end());
		ll i=1;
		for(;i<INT_MAX;i<<=1);
		for(;i;i>>=1){
			if(i>=a){
				auto it=ms.find(i-a);
				if(it!=ms.end()&&*it==i-a){
					ms.erase(it);
					cnt++;
					goto g;
				}
			}
		}
		g:;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 11264
while True:
    m,f,r=map(int,input().split())

    if m==-1 and f==-1 and r==-1:
        break
    if m==-1 or f==-1:
        print('F')
    elif m+f>=80:
        print('A')
    elif 80>(m+f)>=65:
        print('B')
    elif 65>(m+f)>=50 :
        print('C')
    elif 50>(m+f)>=30:
        if r>=50:
            print('C')
        else:
            print('D')
    elif r>=50:
        print('C')
    elif m+f<30:
        print('F')
    
    else:
        pass



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,l;
	cin>>n>>l;
	int sum=0;
	for(int i=l;i<l+n;i++)
		sum+=i;
	cout<<(l+n-1<=0?sum-(l+n-1):l>=0?sum-l:sum)<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	a := sc.NextInt()
	b := sc.NextInt()
	a = n * a
	if b > a {
		fmt.Printf("%+v\n", a) // output for debug
	} else {
		fmt.Printf("%+v\n", b) // output for debug
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
n,m = (int(i) for i in input().split())

ac,wa = 0,0
score = {i+1:[] for i in range(n)}

for _ in range(m):
    p,s = (i for i in input().split())
    score[int(p)].append(s)

for v in score.values():
    if "AC" in v:
        wa += len(v[:v.index("AC")])
        ac += 1

print(ac,wa)


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

constexpr ll INF = ll(1e18) + 1;

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

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

  sort(a.begin(),a.end());
  ll lb = -INF, ub = INF;

  while(lb + 1 < ub) {
    ll x = (lb + ub) / 2;
    bool ok = [&]{
        ll tot = 0;

        for (int i = 0; i < n; i++) {
          if (a[i] < 0) {
            int l = -1, r = n;
            while (l + 1 < r) {
              int c = (l + r) / 2;
              if (a[i] * a[c] < x) r = c;
              else l = c;
            }
            tot += n - r;
          } else {
            int l = -1, r = n;
            while(l + 1 < r) {
              int c = (l + r) / 2;
              if(a[i] * a[c] < x) l = c;
              else r = c;
            }
            tot += r;
          }
          if(a[i] * a[i] < x) tot--;
        }
        tot /= 2;
        return tot < k;
    }();
    if(ok) lb = x;
    else ub = x;
  }

  cout << lb << '\n';
  return 0;
}

Measured memory_bytes: 1792