akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

struct RollingHash{ //ローリングハッシュ法
private:
    static const int mod1 = 1031326447, mod2 = 993766717;
    static const int base1 = 281, base2 = 383;
    vector<long long> hash1, hash2, pow1, pow2;
public:
    string str;
    RollingHash(const string& s) : str(s) { //初期化
        int sz = (int)s.size();
        hash1.assign(sz + 1, 0); hash2.assign(sz + 1, 0);
        pow1.assign(sz + 1, 1); pow2.assign(sz + 1, 1);
        for(int i = 0; i < sz; i++){
            hash1[i + 1] = (hash1[i] * base1 + s[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + s[i]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    inline pair<long long, long long> get(int l, int r){ //[l, r)
        long long res1 = (hash1[r] - hash1[l] * pow1[r - l]) % mod1;
        long long res2 = (hash2[r] - hash2[l] * pow2[r - l]) % mod2;
        if(res1 < 0)res1 += mod1; if(res2 < 0)res2 += mod2;
        return { res1, res2 };
    }
    inline int getLCP(int x, int y){ //LCP S[a:], S[b:]
        int len = min((int)size() - x, (int)size() - y) + 1;
        int l = 0, r = len;
        while(r - l > 1){
            int m = (l + r) >> 1;
            if(get(x, x + m) != get(y, y + m))r = m;
            else l = m;
        }
        return l;
    }
    inline void add_str(const string& s){ //string型を連結
        int ns = (int)str.size(), ms = (int)s.size();
        str += s;
        hash1.resize(ns + ms + 1); hash2.resize(ns + ms + 1);
        pow1.resize(ns + ms + 1); pow2.resize(ns + ms + 1);
        for(int i = ns; i < ns + ms; i++){
            hash1[i + 1] = (hash1[i] * base1 + s[i - ns]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + s[i - ns]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    inline void add_char(const char& c){ //char型を連結
        str += c;
        hash1.push_back((hash1.back() * base1 + c) % mod1);
        hash2.push_back((hash2.back() * base2 + c) % mod2);
        pow1.push_back((pow1.back() * base1) % mod1);
        pow2.push_back((pow2.back() * base2) % mod2);
    }
    inline void add_rh(const RollingHash& rh){ //rhを連結
        add_str(rh.str);
    }
    inline size_t size(){ //strのsizeを返す
        return str.size();
    }
};

int main(){

    int N;
    cin >> N;

    string S;
    cin >> S;
    RollingHash rh(S);

    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < i; j++){
            int lcp = rh.getLCP(i, j);
            chmin(lcp, i - j);
            chmax(ans, lcp);
        }
    }

    cout << ans << endl;
    return 0;

}

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

int main(){
    int n;
    string s;
    cin>>n>>s;
    int r=0,b=0;
    rep(i,n){
      if(s[i]=='R')r++;
      else b++;
    }
    if(r>b)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}
int main()
{
    int n=read();
    int ans=n%1000;
    ans=1000-ans;
    if(ans==1000) ans=0;
    printf("%d\n",ans);
}


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

using namespace std;

using ll = long long;

// i-1番目までの品物から
// 価値がv以上になるように選んだときの
// 重さの総和の最小値
ll solve(vector<pair<ll, ll>> &v_wv, int i, int v, vector<vector<ll>> &memo) {
  if (v <= 0) {
    return 0;
  }

  if (i == 0) {
    return -1;
  }

  if (memo[i][v] < -1) {
    auto &p = v_wv[i - 1];
    ll ans1 = solve(v_wv, i - 1, v, memo),
       ans2 = solve(v_wv, i - 1, v - p.second, memo);
    if (ans2 != -1) {
      ans2 += p.first;
    }

    if (ans1 == -1 || ans2 == -1) {
      memo[i][v] = ans1 == -1 ? ans2 : ans1;
    } else {
      memo[i][v] = min(ans1, ans2);
    }
  }

  return memo[i][v];
}

int main(int argc, const char *argv[]) {
  int n;
  ll w;
  cin >> n >> w;

  vector<pair<ll, ll>> v_wv(n);
  for (int i = 0; i < n; ++i) {
    cin >> v_wv[i].first >> v_wv[i].second;
  }

  ll v = 100100;
  ll ans_w, ans_v;
  vector<vector<ll>> memo(n + 1, vector<ll>(v + 1, -2));
  do {
    ans_w = solve(v_wv, v_wv.size(), v, memo);
    ans_v = v;
    v--;
  } while (ans_w < 0 || ans_w > w);

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

Measured memory_bytes: 80256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,N=0;ll a[333];
ll k;
queue<vector<ll> > qs;
map<vector<ll>,int> vs;
Edgc
int dd[SZ]; bool inq[SZ];
vector<ll> fy[SZ];
void spfa()
{
	queue<int> q; q.push(1);
	for(int i=1;i<=N;++i) dd[i]=1e9;
	dd[1]=0; inq[1]=1;
	while(!q.empty())
	{
		int x=q.front(); q.pop();
		for esb(x,e,b)
		{
			int&d=dd[b];
			if(d<=vc[e]+dd[x]) continue;
			d=vc[e]+dd[x];
			if(!inq[b]) q.push(b),inq[b]=1;
		}
		inq[x]=0;
	}
}
map<vector<ll>,map<ll,ll> > aa;
int main()
{
	cin>>n>>k;
	vector<ll> v;
	for(int i=0;i<n;++i) cin>>a[i], v.pb(a[i]);
	sort(v.begin(),v.end());
	qs.push(v); vs[v]=++N;
	while(!qs.empty())
	{
		auto p=qs.front(); qs.pop();
		auto r=p;
		if(r[0])
		{
		for(int i=0;i<n;++i) r[i]=(r[i]-1)/2;
		if(!vs.count(r))
			vs[r]=++N,qs.push(r);
		ad_de(vs[p],vs[r],2);
		}
		r=p;
		for(int i=0;i<n;++i) r[i]=r[i]/2;
		if(!vs.count(r))
			vs[r]=++N,qs.push(r);
		ad_de(vs[p],vs[r],1);
	}
	for(auto p:vs) fy[p.se]=p.fi;
	spfa();
	for(int i=1;i<=N;++i) if(dd[i]<=k)
	{
		auto s=fy[i]; ll p=s.front(),
		np=max(p-(k-dd[i]),0LL);
		for(auto&xx:s) xx-=p;
		++aa[s][np]; --aa[s][p+1];
	}
	ll ans=0;
	const ll MOD=1e9+7;
	for(auto& s:aa)
	{
		ll ls=0;
		for(auto r=s.se.begin();r!=s.se.end();++r)
		{
			//cout<<r->fi<<","<<r->se<<" ";
			ls+=r->se;
			if(ls) ans-=r->fi,ans%=MOD,ans+=(++r)->fi,--r,ans%=MOD;
		}
		//cout<<"\n";
	}
	ans=(ans%MOD+MOD)%MOD;
	printf("%lld\n",ans);
}


Measured memory_bytes: 73088
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;
#define i64  long long

void solve(void)
{
  i64 N;
  cin>>N;
  multiset<i64,greater<i64>> s;
  vector<i64> b;
  i64 in;   
  for (i64 i = 0; i < (1<<N); i++)
  {
    cin>>in;
    s.insert(in);
  }

 
  b.push_back(*s.begin());
  s.erase(s.begin());
  for (i64 i = 0; i < N; i++)
  {
    for (i64 j = 0; j < (1<<i); j++)
    {
      auto si = s.upper_bound(b[j]);
      // cout<<*s.end()<<endl;
      //iteratorのendは最後の次
      if(si == s.end()){
        cout<<"No";
        return ;
      }
      b.push_back(*si);
      s.erase(si);
    }
  }

  cout<<"Yes";
  return;
  
}
int main(int argc, const char *argv[])
{

  solve();
  
  return 0;
}


Measured memory_bytes: 14712
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>
#include <set>
#define FOR(i,n) for(int i=0;i<n;++i)
#define _CRT_SECURE_NO_WARNINGS
using namespace std;

using ti = tuple < int, int, int >;
using lint = long long;
using ii = pair < int, int >;
using ll = pair < lint, lint >;

const int N = 105;

int a[N][10];
int p[N][10];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= 10; j++) {
			scanf("%d", &p[i][j]);
		}
	}
	int ans = -1000000000;
	for (int i = 1; i < (1 << 10); i++) {
		vector < int > f(n);//각각의 상인과 겹친 날짜.
		for (int j = 0; j < 10; j++) {
			if (i&(1 << j)) {//열었다. 
				for (int k = 0; k < n; k++) {
					if (a[k][j] == 1)
						++f[k];
				}
			}
		}
		int tmp = 0;
		for (int i = 0; i < n; i++) {
			tmp += p[i][f[i]];
		}
		ans = max(tmp, ans);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long A[] = new long[N];
        int min = 0;
        int count = 0;
        long sum = 0;
        Arrays.setAll(A, i -> scanner.nextInt());

        for (int i = 0; i < N; i ++) {
            if (Math.abs(A[min]) > Math.abs(A[i])) min = i;
            if (A[i] < 0) count ++;
            sum += Math.abs(A[i]);
        }

        if (count % 2 != 0) sum -= Math.abs(A[min]) * 2;

        System.out.println(sum);
    }
}


Measured memory_bytes: 61652
a=int(input())
b=list(map(int,input().split()))
d=[]
d.append(0)
d=d+b
sumx=0
for i in range(1,a+1):
	sumx+=abs(d[i]-d[i-1])
for i in range(1,a):
	sumx1=sumx-abs(d[i]-d[i-1])-abs(d[i+1]-d[i])+abs(d[i+1]-d[i-1])
	sumx1+=abs(d[-1]-0)
	print(sumx1)
sumx1=sumx-abs(d[-1]-d[-2])+abs(d[-2]-0)
print(sumx1)


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch =='A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1+(key%(M-1));}

int find(char str[]){
    long long key,i,h;
    key = getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key,i,h;
    key = getKey(str);
    for(i=0; ;i++){
        h = (h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i,n,h;
    char str[L],com[9];
    for(i=0;i<M;i++) H[i][0] = '\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s%s",com,str);
        
        if(com[0]=='i'){
            insert(str);
    }else{
        if(find(str)){
            printf("yes\n");
    }else{
        printf("no\n");
    }
    }
}
return 0;
}


Measured memory_bytes: 16992
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"

using namespace std;
typedef long long ll;

int n, m;
int x[100100], y[100100];
int depth[100100];
vector<vector<int> > a(100100);

int rec(int i)
{
  if (depth[i] > 0)
  {
    return depth[i];
  }
  else
  {
    int ans = 0;
    for (auto&j:a[i])
    {
      ans = max(ans, rec(j) + 1);
    }
    return depth[i] = ans;
  }
}

int main()
{
  cin >> n >> m;
  for (int i = 0; i < m; i++)
  {
    cin >> x[i] >> y[i];
    a[x[i]].push_back(y[i]);
  }
  memset(depth, -1, sizeof(depth));

  int ans = 0;
  for (int i = 1; i <= n; i++)
  {
    ans = max(ans, rec(i));
  }
  cout << ans << "\n";
}

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

int main()
{
    string name;
    cin>> name;

    int Count;

    bool x = true;


    for(int i = 0; i < name.size(); i++)
    {
        Count = count(name.begin(),name.end(),name[i]);
        if(Count % 2 != 0)
        {
            x = false;
            break;
        }

    }

    if(!x)
        cout<< "No";

    else
        cout<< "Yes";

    return 0;

}


Measured memory_bytes: 3624
#include<stdio.h>

void exp1(int An[], int N){

  int i;
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%d",An[i]);
  }
  printf("\n");
}


  void cal(int An[], int N){
    int j,i,e;
    for(i=1;i<N;i++){
      e = An[i];
      j = i-1;
      while(j>=0 &&An[j] > e){
	An[j+1] = An[j];
	j--;
      }

      An[j+1] =e;
      exp1(An,N);
    }
  }

int main(){
  int N,j,i;
  int An[100];

  scanf("%d",&N);
  for(i=0;i<N;i++){

    scanf("%d",&An[i]);

  }

  exp1(An,N);
  cal(An,N);

  return 0;






}



Measured memory_bytes: 2036
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<utility>
#include <bits/stdc++.h>

using namespace std;

/**
ワーシャルフロイド
計算量O(n^3)
全体全の最短距離を求める
**/
#define NODE 301
long long dist[NODE][NODE];
void WF(int num){
	for(int k = 0;k < num;k++){
		for(int i = 0;i < num;i++){
			for(int j = 0;j < num;j++){
				dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
			}
		}
	}
}

int main(void)
{
  int h,w;
  cin>>h>>w;
  for(int i=0;i<10;i++)
    {
      for(int j=0;j<10;j++)
	{
	  cin>>dist[i][j];
	}
    }
  WF(10);
  int ans=0;
  int tmp;
  for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
	{
	  cin>>tmp;
	  if(tmp!=-1)
	    {
	      ans+=dist[tmp][1];
	    }
	}
    }
  /**/
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

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

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	int maxv = 0;
	for(int i = 1;i * i <= m;++i){
		if(m % i == 0){
			if(i >= n) maxv = max(maxv,m / i);
			if((m / i) >= n) maxv = max(maxv,i);
		}
	}
	cout << maxv << '\n';
	return 0;	
}


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


int main (void) {
int H,N;
scanf("%d %d",&H,&N);
int A[N];
int sum=0;
for (int i=0;i<N;i++){
    scanf("%d",&A[i]);
    sum+=A[i];
}
if (sum>=H) {printf("Yes");}
  else {printf("No");}


return EXIT_SUCCESS;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  int N=0;
  int a[10000]={0},b[10000]={0},c[10000]={0};
  cin>>N;
  for(int i=0;i<N;i++){
	cin>>a[i]>>b[i]>>c[i];
  }
  for(int i=0;i<N;i++){
	if(a[i]*a[i]==b[i]*b[i]+c[i]*c[i]||b[i]*b[i]==c[i]*c[i]+a[i]*a[i]||c[i]*c[i]==a[i]*a[i]+b[i]*b[i]){
     	cout<<"YES"<<endl;
     }
    else{
    	cout<<"NO"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3172
n,m=io.read("*n","*n","*l")
if n>=m then
    print(0)
    return
end

x={}
for i=1,m do
    x[i]=io.read("*n")
end
table.sort(x)

l={}
for i=1,m-1 do
    table.insert(l,x[i+1]-x[i])
end
table.sort(l)

distance=0
for i=1,m-n do
    distance=distance+l[i]
end
print(distance)

Measured memory_bytes: 4472
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const ll N=1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll a[200100];
int main(){
	ll n;
	scanf("%lld",&n);
	ll i,j;
	for(i=0;i<n;i++)
		scanf("%lld",&a[i]);
	sort(a,a+n);
	ll m=n-2;
	ll t=m/2,p=m%2,s=0;
	for(i=n-2;i>n-2-t;i--)
		s+=a[i];
	s*=2;
	if(p==1)
		s+=a[i];
	s+=a[n-1];
	cout<<s<<endl;
}

Measured memory_bytes: 4788
#include<stdio.h>
int main(void)
{
	int a,b,c,aa,bb,cc,s,ss;
	int i,j,w[4],h,m,z;
	for(i=1;i<=3;i++){
		scanf("%d %d %d %d %d %d",&a,&b,&c,&aa,&bb,&cc);
		s=(a*3600)+(b*60)+c;
		ss=(aa*3600)+(bb*60)+cc;
		w[i]=ss-s;
	}	
	for(i=1;i<=3;i++){
		m=w[i]%3600;
		h=w[i]/3600;
		s=m%60;
		m=m/60;
		printf("%d %d %d\n",h,m,s);
	}
	return 0;
}

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

int a, b, c, x;

int main(){
    int count = 0;
    cin >> a >> b >> c >> x;
    for(int i = 0; i <= x/500 && i <= a; i++){
        int amount1 = x - 500 * i;
        for(int j = 0; j <= amount1/100 && j <= b; j++){
            int amount2 = amount1 - 100 * j;
            for(int k = 0; k <= amount2/50 && k<= c; k++){
                if(amount2 == k * 50) count++;
            }
        }
    }
    cout << count <<endl;
    return 0;
}

Measured memory_bytes: 256
readlines.each{|line|
  xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = line.split.map(&:to_f)
  if xa2 < xb1 || xb2 < xa1 || ya2 < yb1 || yb2 < ya1
    puts "NO"
  else
    puts "YES"
  end
}

Measured memory_bytes: 8672
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b; scanf("%d%d",&a,&b);
	int res=-1;
	for(int x=1;x<=10000;x++)
	{
		int t1=floor(0.08*x); int t2=floor(0.1*x);
		if(t1==a&&t2==b)
		{
			res=x;
			break;
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val A, B = sc.nextInt()

    def foo(a: Int, b: Int, sum: Int = 0, deps: Int = 2): Int = {
      if (deps == 0) sum else {
        if (a < b) {
          foo(a, b - 1, sum + b, deps - 1)
        } else {
          foo(a - 1, b, sum + a, deps - 1)
        }
      }
    }

    val c = foo(A, B)
    println(c)
  }
}


Measured memory_bytes: 25420
#include<iostream>
#include<math.h>
using namespace std;
int checkp(int a)
{
	for(int i=2;i<=sqrt(a);i++)
	if(a%i==0) return 1;
	return 0;
}
int main()
{
	int x;
	cin>>x;
	while(checkp(x)==1)
	{
		x+=1;
	}
	cout<<x;
}

Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  cout.precision(15); cout << fixed;
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  bool multiple = x*2 == w and y*2 == h;
  cout << (double)w*(double)h*0.5 << " " << multiple << endl;
}


Measured memory_bytes: 3812
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
L=[n//a,n//b,n//c,n//d,n//e]
M=[a,b,c,d,e]
if L[L.index(max(L))]*M[L.index(max(L))] == n:
  print(max(L)+4)
else:
  print(max(L)+5)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
ll n,w,h,k;
bool bomb[55][55];

inline int query(int a,int b,int c,int d){
	cout << "? " <<  a << " " << b << " " << c-1 << " " << d-1 << endl << flush;
	int ret;
	cin >> ret;
	return ret;
}

inline int rec(int a,int b,int c,int d,int rest){
	if(c<=a or d<=b) return 0;
	if(rest==0) return 0;
	//cout << a << " " << b << " " << c << " " << d << endl;
	
	const int area=(c-a)*(d-b);
	int res=query(a,b,c,d);
	if(res==0) return 0;
	if(res==area){
		rep(y,a,c)rep(x,b,d) bomb[y][x]=true;
		return area;
	}

	chmin(rest,res);
	if(1.0*res/area>0.6){
		rep(y,a,c)rep(x,b,d) rest-=rec(y,x,y+1,x+1,rest);
		return res;	
	}

	const int ym=(a+c)/2,xm=(b+d)/2;
	rest-=rec(a,b,ym,xm,rest);
	rest-=rec(ym,b,c,xm,rest);
	rest-=rec(a,xm,ym,d,rest);
	rest-=rec(ym,xm,c,d,rest);
	return rest;
}

int main(void){
	cin >> h >> w >> n >> k;
	rec(0,0,h,w,n);
	
	ll ans=0LL,cur=1LL;
	rep(i,h)rep(j,w){
		if(bomb[i][j]) ans=(ans+cur)%k;
		cur=(2LL*cur)%k;
	}

	cout << "! " << ans << endl  << flush;
	return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll N, H;
	cin >> N >> H;
	ll a[N], b[N];
	for (ll i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + N);
	sort(b, b + N);
	ll a_max = a[N - 1];
	ll cnt = 0;
	for (ll i = N - 1; i >= 0; i--) {
		if (a_max <= b[i]) {
			H -= b[i];
			cnt++;
		}
		if(H<=0){cout<<cnt<<endl; return 0;}
    }
	while (H > 0) {
		H -= a_max;
		cnt++;
	}
	cout << cnt << endl;
}

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


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt()+1;
        int Q = sc.nextInt();
        String S = "-"+sc.next();

        int[] acCount = new int[N];
        for(int n=1; n<N; n++){
            if(S.substring(n-1,n+1).equals("AC")) acCount[n]=acCount[n-1]+1;
            else acCount[n] = acCount[n-1];
        }

        for(int q=0; q<Q; q++){
            int L = sc.nextInt()-1;
            int R = sc.nextInt();
            System.out.println(S.substring(L,L+2).equals("AC") ? acCount[R]-acCount[L]-1 : acCount[R]-acCount[L]);
        }

    }
}

Measured memory_bytes: 70800
import sys
from heapq import heappush, heappop

INF = 10 ** 7

n, m = map(int, sys.stdin.readline().split())
abc = map(int, sys.stdin.read().split())
abc = zip(*[abc] * 3)
graph = [[] for _ in range(n)]
for a, b, c in abc:
    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))

def dijkstra(v):
    used_edges = [set() for _ in range(n)]
    hq = []
    heappush(hq, (0, v, None))
    dist = [INF] * n
    pars = [set() for _ in range(n)]
    while hq:
        d, x, z = heappop(hq)
        if dist[x] != INF:
            if d == dist[x]:
                pars[x].add(z)
                used_edges[x] |= used_edges[z]
                if z < x:
                    used_edges[x].add((z, x))
                else:
                    used_edges[x].add((x, z))
            continue   
        
        dist[x] = d
        if x != v:
            used_edges[x] |= used_edges[z]
            pars[x].add(z)
            if z < x:
                used_edges[x].add((z, x))
            else:
                used_edges[x].add((x, z))

        for (y, c) in graph[x]:
            if y in pars[x] or pars[y]:
                continue
            heappush(hq, (d+c, y, x))

    res = set()
    for i in range(n):
        res |= used_edges[i]
    return res

def main():
    res = set()
    for v in range(n):
        res |= dijkstra(v)
    
    
    ans = m - len(res)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int n;
    string s;
    cin >> n >> s;
    int x = 0, ans = 0;
    REP(i, n) {
        if (s[i] == 'I') x++;
        else x--;
        chmax(ans, x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int64_t X,Y,Z;
int main(){
  cin>>X>>Y>>Z;
  int64_t ans=0;
  vector<pair<int64_t,pair<int64_t,int64_t>>>a(X+Y+Z);
  for(int i=0;i<X+Y+Z;i++){
  int64_t A,B,C;cin>>A>>B>>C;ans+=A;
    pair<int64_t,int64_t>p(B-A,C-A);
    pair<int64_t,pair<int64_t,int64_t>>q(C-B,p);
    a.at(i)=q;
   }sort(a.begin(),a.end());
  vector<int64_t>b(X+Y+Z);
  vector<int64_t>c(X+Y+Z);
  for(int i=0;i<X+Y+Z;i++){
  pair<int64_t,int64_t>p=a.at(i).second;
    b[i]=p.first;
    c[i]=p.second;
  }vector<int64_t>b1(X+Y+Z);
  vector<int64_t>c1(X+Y+Z);
  priority_queue<int64_t,vector<int64_t>,greater<int64_t>>que1;
  int64_t b2=0;
  for(int i=0;i<Y;i++){
  b2+=b[i];que1.push(b[i]);
  }b1[Y-1]=b2;
  for(int i=Y;i<X+Y+Z;i++){
  int64_t u=que1.top();
    que1.pop();
    int64_t v=max(b[i],u);
    que1.push(v);
    b2+=(v-u);
    b1[i]=b2;
  } priority_queue<int64_t,vector<int64_t>,greater<int64_t>>que2;
  int64_t c2=0;
  for(int i=X+Y+Z-1;X+Y<=i;i--){
  c2+=c[i];que2.push(c[i]);
  }c1[X+Y]=c2;
  for(int i=X+Y-1;0<=i;i--){
  int64_t u=que2.top();
    que2.pop();
    int64_t v=max(c[i],u);
    que2.push(v);
    c2+=(v-u);
    c1[i]=c2;
  }int64_t ans1=-10000000000000000;
  for(int i=Y-1;i<=X+Y-1;i++)
    if(ans1<b1[i]+c1[i+1])ans1=b1[i]+c1[i+1];
  ans+=ans1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 9688
//
// Created by yjq on 2019/11/13.
//

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int maxn = 2e5 + 10;
int n, a[maxn];
bool b[maxn];

bool check(int x) {
    for (int i = 1; i < n + n; ++i) {
        if (a[i] >= x)b[i] = 1;
        else b[i] = 0;
    }
    int l = n - 1, r = n + 1;
    for (; l >= 1 && r < n + n; --l, ++r) {
        if (b[l] == b[l + 1])return b[l];
        if (b[r] == b[r - 1])return b[r];
    }
    return (b[1] & b[n + n - 1]);
}

int main() {
    __;
    cin >> n;
    for (int i = 1; i < n + n; ++i)cin >> a[i];
    int l = 1, r = n + n - 1;
    while (l < r) {
        int mid = (l + r + 1) >> 1;
        if (check(mid))l = mid;
        else r = mid - 1;
    }
    cout << l << endl;
    return 0;
}

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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

struct Solution
{
    Solution() {}
    void solveCase();
};

void Solution::solveCase()
{
    int n;
    cin >> n;
    ll res = 0;
    int maxPref = 0;
    for (size_t i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if (x < maxPref)
            res += maxPref - x;
        maxPref = max(maxPref, x);
    }
    cout << res << '\n';
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<set>
#include<string>

using namespace std;

int main()
{
	set<string>st;
	int n = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		string s;
		cin >> s;
		st.insert(s);
	}
	
	cout << st.size() << '\n';

	return 0;

}

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

using namespace std;

struct CWW{CWW(){ios::sync_with_stdio(false);cin.tie(0);}}cww;

typedef long long LL;
const LL MOD=1e9+7;
typedef vector<int> V;
typedef vector<V> VV;


int main(){
    int N,x,y,z;
    cin>>N>>x>>y>>z;
    int X=(1<<x)-1;
    int Y=(1<<(y+x))-1-X;
    int Z=(1<<(z+y+x))-1-Y-X;
    int A=1<<(x+y+z);
    int sz=A<<1;
    VV M(10,V(sz));
    for(int c=0;c<10;c++){
	int C=c+1;
	for(int bit=0;bit<sz;bit++){
	    int xx=bit&X;
	    int yy=bit&Y;
	    int zz=bit&Z;
	    int aa=bit&A;
	    xx=(xx<<C)&(X<<1);
	    yy=(yy<<C)&(Y<<1);
	    zz=(zz<<C)&(Z<<1);
	    M[c][bit]=xx|yy|zz|aa|1;
	}
    }
    vector<LL> dp(sz,0);
    dp[1]=1;
    for(int i=0;i<N;i++){
	vector<LL> nxt(sz,0);
	 for(int c=0;c<10;c++)
	     for(int bit=0;bit<sz;bit++){
		 (nxt[M[c][bit]]+=dp[bit])%=MOD;
	    }
	 swap(dp,nxt);
    }
    
    LL res=0;
    for(int i=A;i<sz;i++)
	(res+=dp[i])%=MOD;
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 14588
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>a(n);
  vector<int>s(n);
  map<int,int>d;

  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    s[i]=a[i]+i+1;
    d[i+1-a[i]]++;
  }
  long long ans=0;
  for(int i=0;i<n;i++)
  {
    ans+=d[s[i]];
  }
  cout<<ans<<endl;
    
  
  return 0;
}

Measured memory_bytes: 21768
#include<iostream>
#include<algorithm>
#include <numeric>

using namespace std;
int main(void){
  long long int n, i, sum=0, tmp, pre=0;
  cin >> n;
  int a[n];
  for(i=0;i<n;i++) {
    cin >> tmp;
    if(tmp==pre+1) {
      pre++;
    } else {
      sum++; 
    }
  }
  if(pre==0) cout << -1 << endl;
  else cout << sum << endl;
}

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

ll solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> X(N), Y(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> X[i] >> Y[i];
    }
    vector<ll> xx(X), yy(Y);
    auto comp = [](vector<ll>& u) {
        vector<ll> v(u);
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        for ( int i = 0; i < v.size(); i++ ) {
            u[i] = lower_bound(v.begin(), v.end(), u[i]) - v.begin();
        }
    };
    comp(xx);
    comp(yy);
    vector<ll> x2X(N), y2Y(N);
    vector<vector<ll>> c(xx.size()+1, vector<ll>(yy.size()+1));
    for ( int i = 0; i < N; i++ ) {
        c[xx[i]+1][yy[i]+1] = 1;
        x2X[xx[i]] = X[i]; 
        y2Y[yy[i]] = Y[i]; 
    }
    for ( int i = 1; i <= xx.size(); i++ ) {
        for ( int j = 0; j <= yy.size(); j++ ) {
            c[i][j] += c[i-1][j];
        }
    }
    for ( int j = 1; j <= yy.size(); j++ ) {
        for ( int i = 0; i <= xx.size(); i++ ) {
            c[i][j] += c[i][j-1];
        }
    }
    ll ans = 1LL << 62;
    for ( int xl = 0; xl < xx.size(); xl++ ) {
        for ( int xr = xl+1; xr < xx.size(); xr++ ) {
            for ( int yl = 0; yl < yy.size(); yl++ ) {
                for ( int yr = yl+1; yr < yy.size(); yr++ ) {
                    ll x1 = xl, x2 = xr, y1 = yl, y2 = yr;
                    if ( x1 > x2 ) swap(x1,x2);
                    if ( y1 > y2 ) swap(y1,y2);
                    ll k = c[x2+1][y2+1] - c[x1][y2+1] - c[x2+1][y1] + c[x1][y1];
                    if ( k < K ) continue;
                    ll m = (x2X[x2] - x2X[x1]) * (y2Y[y2] - y2Y[y1]);
                    ans = min(ans, m);
                }
            }
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<int> A(26, 0x3f3f3f3f);
    for (int i = 0; i < n; ++i) {
        vector<int> B(26, 0);
        string s;
        cin >> s;
        for (char c: s) {
            B[c - 'a']++;
        }
        for (int i = 0; i < 26; ++i) {
            A[i] = min(A[i], B[i]);
        }
    }
    string fans;
    for (int i = 0; i < 26; ++i) {
        while (A[i]-- > 0) {
            fans += (char) (i + 'a');
        }
    }
    cout << fans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    ll n;cin>>n;
    vector<ll> in(5);
    rep(i,5) cin>>in[i];
    sort(in.begin(),in.end());
    ll m = in[0];
    ll ans = (n+m-1)/m + 4;
    cout << ans << endl;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

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

int l;
int x,y;
int tmp[25],sl=0;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if(fopen("A.INP", "r")){
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  scanf("%d ",&l);

  int k=log2(l);

  while(l>0)
  {
    if(l%2==1)
        tmp[++sl]=x;
    x++;
    l/=2;
  }

  printf("%d %d\n",k+1,2*k-1+sl);

  for(int i=1; i<=k; ++i)
  {
    printf("%d %d %d\n",i,i+1,0);
    printf("%d %d %d\n",i,i+1,1<<(i-1));
  }

  y=1<<k;

  for(int i=1; i<sl; ++i)
  {
    printf("%d %d %d\n",tmp[i]+1,k+1,y);
    y+=1<<tmp[i];
  }
}


Measured memory_bytes: 512
t = int(input())

a = b = c = d = 0
for i in range(t):
    case = input()

    if case == 'AC':
        a += 1
    elif case == 'WA':
        b += 1
    elif case == 'TLE':
        c += 1
    elif case == 'RE':
        d += 1


print('AC x ' + str(a))
print('WA x ' + str(b))
print('TLE x ' + str(c))
print('RE x ' + str(d))

Measured memory_bytes: 69804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>v;
bool prime(ll x){
	ll num=sqrt(x);
	for(int i=0;i<v.size();i++){
		if(v[i]>num)break;
		if(x%v[i]==0){
			return 0;
		}
	}
	return 1;
}
int main() {
	ll n,p,ans=1;
	cin>>n>>p;
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
	else{
		v.push_back(2);
		for(int i=3;i<sqrt((p+1)/2);i+=2)if(prime(i))v.push_back(i);
		for(int i=0;i<v.size();i++){
			ll cnt=0;
			while(p%v[i]==0){
				cnt++;
				p/=v[i];
			}
			for(int j=1;j<=cnt/n;j++)ans*=v[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define ll long long
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define bug cout << "ok" << endl

const ll INF = 1e9 + 5, N = 2e5 + 5, mod = 1e9 + 7, M = 1e5 + 5;

int p[N], sz[N];

void make_set(int v){
	p[v] = v;
	sz[v] = 1;	
}

int find_set(int v){
	if(p[v] == v) return v;
	return p[v] = find_set(p[v]);
}
void union_set(int a, int b){
	a = find_set(a);
	b = find_set(b);
	if(a == b) return;
	if(sz[a] < sz[b]) swap(a, b);
	sz[a] += sz[b];
	p[b] = a;
}

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++) make_set(i);
	while(m--){
		int a, b;
		cin >> a >> b;
		union_set(a, b);
	}
	int mx = 0;
	for(int i = 1; i <= n; i++) mx = max(mx, sz[i]);
	cout << mx << endl;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
 
#define int long long
#define MOD 1000000007
 
using namespace std;
 
template <class T> ostream &operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for (auto v : V)
        os << v << " ";
    os << "]";
    return os;
}
template <class T> ostream &operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for (auto s : S)
        os << s << " ";
    return os << "}";
}
template <class L, class R> ostream &operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for (auto m : M)
        os << "(" << m.first << ":" << m.second << ") ";
    return os << "}";
}
template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
  
void solve() {
    int n;
    cin >> n;
    int a[n];
    int count = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] % 2 == 1 && i % 2 == 0) {
            count++;
        }
    }
    cout << count << endl;
}
 
int32_t main() {
    int t;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    // cin >> t;
    // while(t--) {
    //     solve();
    // }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int M;
  cin>>M;
  vector<ll> D(M),C(M);
  rep(i,M) cin>>D[i]>>C[i];

  ll ans=0;
  for(int i=0;i<M;i++) ans+=C[i];
  ans--;
  ll now=0;
  for(int i=0;i<M;i++){
    now+=D[i]*C[i];
    //ans+=now/10;
    //now%=10;
  }

  while(now>=10){
    ans+=now/10;
    now=now%10+now/10;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3328
#include<iostream>

#define rep(i,n) REP(i,0,n)
#define REP(i,a,n) for(int i = a; i < (int)n; i++)

using namespace std;

signed main(){
  int h;
  int A[251];
  cin >> h;
  for(int i = 1; i <= h; i++){
    cin >> A[i];
  }

  for(int i = 1; i <= h; i++){
    cout << "node " << i << ": key = " << A[i] << ", ";
    if(i/2 >= 1) cout << "parent key = " << A[i/2] << ", ";
    if(2*i <= h) cout << "left key = " << A[2*i] << ", ";
    if(2*i + 1 <= h) cout << "right key = " << A[2*i + 1] << ", ";
    cout << "\n";
  }
}



Measured memory_bytes: 3092
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                      
using namespace std;
                      
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                      
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228
#define next next228

const int N = 11;

bool bad[N];

bool check(int n) {
	while (n) {
		if (bad[n % 10]) return 0;
		n /= 10;
	}
	return 1;
}

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; ++i) {
		int x;
		cin >> x;
		bad[x] = 1;
	}
	while (!check(n)) ++n;
	cout << n << '\n';
    return 0;
} // kek;








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  long long ans = 1;
  int N;
  cin >> N;
  bool prime[N+1];
  fill(prime,prime+N+1,true);
  prime[0] = false;
  prime[1] = false;
  //エラトステネスの篩
  for(int i = 2; i * i <= N; i++){
    if(prime[i] == false) continue;
    else{
      int x = 2;
      while(x*i <= N){
        prime[x*i] = false;
        x++;
      }
    }
  }
  long long cnt;
  rep(i,N+1){
    if(prime[i] == false) continue;
    else{
      cnt = 0;
      FOR(j,i,N+1){
        int tmp = j;
        while(tmp % i == 0 && tmp != 0){
          tmp /= i;
          cnt++;
        }
      }
      if(cnt > 0) ans *= (cnt+1);
      ans %= (int)(1e9 + 7);
    }
  }
  cout << ans << endl;


  rep(i,N){
  }
  return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] answer = new int[N];

        for (int i = 0; i < N; i++)
        {
            string[] str = Console.ReadLine().Split(' ');

            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);
            int z = int.Parse(str[2]);

            int x2y = x*x + y*y;
            int y2z = y*y + z*z;
            int z2x = z*z + x*x;

            
            if ((Math.Sqrt(x2y) == z)||(Math.Sqrt(y2z) == x))
            {
                answer[i] = 1;
            }
            else
            {
                if (Math.Sqrt(z2x) == y)
                    answer[i] = 1;
            }
        }

        

        for (int i = 0; i < N; i++)
        {
            
            if (answer[i] == 1)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }

    }
}

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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 310;
int n, m, L;
int f[N][N], g[N][N];
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	read(n), read(m), read(L);
	memset(f, 0x3f, sizeof(f));
	for (int i = 1, x, y, z; i <= m; i++) {
		read(x), read(y), read(z);
		f[x][y] = f[y][x] = z;
	}
	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				f[i][j] = min(f[i][k] + f[k][j], f[i][j]);
	memset(g, 0x3f, sizeof(g));
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (f[i][j] <= L) g[i][j] = 1;
	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				g[i][j] = min(g[i][k] + g[k][j], g[i][j]);
	int q; read(q);
	while (q--) {
		int x, y;
		read(x), read(y);
		printf("%d\n", (g[x][y] > 1000000000 ? 0 : g[x][y]) - 1);
	}
	return 0;
}


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

int32_t main()
{
    int n,k;cin>>n>>k;
    int a[n+1];
    a[0] = 0;
    for(int i=1;i<=n;i++){cin>>a[i];}
    int dp[k+1];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=k;i++){
        for(int j=1;j<=n;j++){
                if(a[j]<=i){
                    if(dp[i-a[j]] == 0){
                        dp[i] = 1;
                    }
                }
        }
    }
   
    string ans = dp[k] ? "First" : "Second";
    cout<<ans;
}


Measured memory_bytes: 4388
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

a,b,h=[int(input()) for i in range(3)]
print((a+b)*h//2)

Measured memory_bytes: 64364
#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char *argv[])
{
    int n, k;
    std::vector<int> vec;
    std::cin >> n >> k;
    for(int i= 0; i < n; i++){
        int t;
        std::cin >> t;
        vec.push_back(t);
    }
    std::sort(vec.begin(), vec.end(), std::greater<int>());
    int min = 1e9;
    for(int i = k-1; i < n; i++){
        min = std::min(min, vec[i-k+1]-vec[i]);
    }
    std::cout << min << std::endl;
    return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

int a[10];

int main() {
    int k;
    for (int i = 0; i < 5; i++) scanf("%d", &a[i]);
    scanf("%d", &k);
    int f = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            if (a[j] - a[i] > k) {f = 1; break;}
        }
    }
    printf("%s\n", (f ? ":(" : "Yay!"));
	return 0;
}


Measured memory_bytes: 256