akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#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(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a,k) distance((v).begin(),(k)+upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a,k) distance((v).begin(),(k)+lower_bound((v).begin(),(v).end(),(a)))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};

struct D21{
  int is,js;
  D21(int isize,int jsize){
    is = isize;
    js = jsize;
  }
  int operator()(int i,int j){
    return i*js+j;
  }
};


void Main(){
  int n;
  cin>>n;

  vi dp(n+1,INF);
  dp[0] = 0;
  srep(i,1,n+1){
    // 1
    dp[i] = min(dp[i], dp[i-1]+1);

    // 6
    int k = i;
    int dn = 6;
    while(k/=6){
      dp[i] = min(dp[i],dp[i-dn]+1);
      dn*=6;
    }

    // 9
    k = i;
    dn = 9;
    while(k/=9){
      dp[i] = min(dp[i],dp[i-dn]+1);
      dn*=9;
    }
    
  }
  cout<<dp[n]<<endl;
} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


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

int main(){

  int a[1000][1000] = {0};
  int x,y,z;
  int count = 0,kosa = 0;
  char s,t;

  while(cin >> x >> s >> y >> t >> z){

    if(z == 1){
      for(int i=x-1;i<x+2;i++) a[i][y]++;
      a[x][y+1]++;
      a[x][y-1]++;
    }

    if(z == 2){
      for(int i=x-1;i<x+2;i++){
	for(int j=y-1;j<y+2;j++) a[i][j]++;
      }
    }

    if(z == 3){
      for(int i=x-1;i<x+2;i++){
	a[i][y+1]++;
	a[i][y-1]++;
      }

      for(int i=x-2;i<x+3;i++) a[i][y]++;
      a[x][y+2]++;
      a[x][y-2]++;
    }

  }

  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(a[i][j] == 0) count++;
      if(kosa < a[i][j]) kosa = a[i][j];
    }
  }

  cout << count << endl << kosa << endl;

}

Measured memory_bytes: 5076
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long  A[100], B, C, D,a[3000], c[10], d[10], now, num, N, K, M, ans;
string S, s[100];
bool h,w[10], k[100];
char cc;


int main() {
	cin >> N;
	cin >> D >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		ans += (D - 1) / A[i];
		ans++;
	}
	
	cout <<ans+M<<endl;
	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define SIZE 100

void push(int);
int pop(void);

int stack[SIZE];
int top = 0;

int main(){
  char data;
  int num,status,i,j,k,count = 0;

  while(1){
    status = scanf("%c",&data);
    if(status != 1) break;
    if(data == ' '){
       count = 0;
       continue;
     }
    if(data <= '9' && data >= '0'){
      num = data - 48;
      count++;
      if(count >= 2){
        num = pop()*10 + num;
      }
       push(num);
     }

    if(data == '+' || data == '-' || data == '*'){
      count = 0;
      i = pop();
      j = pop();
      if(data == '+') k = j + i;
      if(data == '-') k = j - i;
      if(data == '*') k = j * i;
      push(k);
    }
  }
  printf("%d\n",stack[0]);
  return 0;
}

void push(int data){
  if(top == SIZE) exit(2);
  stack[top] = data;
  top++;
}

int pop(void){
  if(top == 0) exit(3);
  top--;
  return stack[top];
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
const ull MOD = 998244353;
#ifdef LOCAL
#include "../../pp.hpp"
#define debug pp::debug
#else
#define debug(args...)
#endif

void visit(int u, const vvi& G, vi& vis, vi& order) {
    if (vis[u]) return;
    for (int v : G[u]) {
        visit(v, G, vis, order);
    }
    vis[u] = true;
    order.push_back(u);
}

vi top_order(const vvi& G) {
    int n = G.size();
    vi order; order.reserve(n);
    vi vis(n, false);
    for (int i = 0; i < n; ++i) {
        if (!vis[i]) {
            visit(i, G, vis, order);
        }
    }
    reverse(order.begin(), order.end());

    return order;
}

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

    int n, m; cin >> n >> m;
    vvi G(n);
    vvi par(n);
    for (int i = 0; i < m; ++i) {
        int x, y; cin >> x >> y;
        --x; --y;
        G[x].push_back(y);
        par[y].push_back(x);
    }

    auto order = top_order(G);
    debug("top order", order);

    vi dp(n,  0);
    for (int i = 0; i < n; ++i) {
        int u = order[i];
        for (int p : par[u]) {
            dp[u] = max(dp[u], dp[p] + 1);
        }
    }

    debug("dp", dp);
    cout << *max_element(dp.begin(), dp.end()) << '\n';
}


Measured memory_bytes: 14720
N,K = map(int,input().split())
gcddic = {}
mod_n = (10**9+7)
for i in range(K,0,-1):
    x = pow((K//i),N,mod_n)
    ll=2
    while(ll*i<=K):
        x -= gcddic[ll*(i)]
        ll += 1
    gcddic[i] = x
sumnation = 0
for i,l in gcddic.items():
    sumnation += i*l
print(sumnation%mod_n)

Measured memory_bytes: 77748
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

#define bit(n,r) ((n>>r)&1)

int main(){
	bool a[22][22]={};
	vl dp(10000000,0);
	int n;
	cin>>n;
	dp[0]=1;
	rep(i,0,n)rep(j,0,n)cin>>a[i][j];
	rep(S,1,1<<n){
		int i=0;
		rep(j,0,n)if(S>>j&1)i++;
		rep(j,0,n)
			if(bit(S,j)&&a[i-1][j]==true)
				dp[S]=(dp[S]+dp[S^(1<<j)])%inf;
	}
	print(dp[(1<<n)-1]);
}



Measured memory_bytes: 78336
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define pi acos(-1.0)
#define maxd 1000000007
typedef long long ll;
int n;
ll a[100100],b[1000100],c[100100];

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

bool cmp(ll p,ll q)
{
	return p>q;
}

int main()
{
	n=read();int i,cnt=0,ans=0;ll sum=0;
	for (i=1;i<=n;i++) a[i]=read();
	for (i=1;i<=n;i++) b[i]=read();
	for (i=1;i<=n;i++)
	{
		if (a[i]>b[i]) c[++cnt]=a[i]-b[i];
		else if (a[i]<b[i]) {ans++;sum+=(b[i]-a[i]);}
	}
	if (sum==0) {cout << 0;return 0;}
	sort(c+1,c+1+cnt,cmp);
	for (i=1;i<=cnt;i++)
	{
		if (sum>=c[i]) sum-=c[i];
		else sum=0;
		ans++;
		if (sum==0) break;
	}
	if (sum) cout << -1;
	else cout << ans;
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

class BIT{
  static const int MAX_N = 1 << 17;
  int n, bit[MAX_N+1];
public:
  BIT(int n_){
    n = n_;
    for(int i=0; i<n+1; i++) bit[i] = 0;
  }
  //a_1+...+a_iを計算する
  int sum(int i){
    int s = 0;
    while(i>0){
      s+=bit[i];
      i-=i&(-i);
    }
    return s;
  }
  //a_i += xをする(1<=i<=n)
  void add(int i, int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&(-i);
    }
  }
};

ll solve(int X, const vector<ll>& A){
  vector<ll> B;
  rep(i,A.size()){
    if(A[i] >= X) B.push_back(+1);
    else B.push_back(-1);
  }

  vector<ll> sum(B.size()+1);
  sum[0] = 0;
  ll minSum = sum[0];
  rep(i,B.size()){
    sum[i+1] = sum[i] + B[i];
    minSum = min(minSum, sum[i+1]);
  }

  ll maxSum = -10000;
  rep(i,sum.size()){
    sum[i] += -minSum + 1;
    maxSum = max(maxSum, sum[i]);
  }

  BIT bit(maxSum+10);
  ll tmp = 0;
  rep(i,sum.size()){
    tmp += i - bit.sum(sum[i]);
    bit.add(sum[i], 1);
  }

  ll z = A.size();
  ll ret = z * (z+1) / 2 - tmp;
  return ret;
}


int main(){
  int N;
  cin >> N;
  vector<ll> A;
  ll maxA = 0;
  rep(i,N){
    ll a;
    cin >> a;
    A.push_back(a);

    maxA = max(maxA, a);
  }

  ll num = N * (ll)(N+1) / 2;
  num = (num+1) / 2;

  ll lb = 0, ub = maxA+1;
  while(ub-lb>1){
    ll X = (lb+ub)/2;
    ll cnt = solve(X, A);
    //cout << X << " " << cnt << " " << num << endl;
    if(cnt >= num) lb = X;
    else ub = X;
  }

  cout << lb << endl;
  
  return 0;
}


Measured memory_bytes: 3292
import java.util.*;

class Main{
  public static void main(String[] args){
  Scanner sc=new Scanner(System.in);
  int A=sc.nextInt();
  int B=sc.nextInt();
  
  if(A<=8&&B<=8){
    System.out.println("Yay!");
  }else{
    System.out.println(":(");

  }
  }
}


Measured memory_bytes: 21716
///***Bismillahir Rahmanir Rahim***///

///*********************************///
///******Ashraful Haque Toni********///
///********Dept. of CSE,JnU*********///
///email:ashrafulhaquetoni@gmail.com///
///*******contact:01640690531*******///
///*********************************///


#include<bits/stdc++.h>

using namespace std;

#define         ash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         pb push_back
#define         mp make_pair
#define         sc(n) scanf("%d",&n);
#define         scl(n) scanf("%I64d",&n);
#define         sc2(m,n) scanf("%d%d",&m,&n);
#define         sc2l(m,n) scanf("%I64d%I64d",&m,&n);
#define         pf printf
#define         Big(x,y) max(x,y);
#define         Small(x,y) min(x,y);
#define         input(array,size) for(int i=0;i<size;i++)cin>>array[i];
#define         newline pf("\n");
#define         f(s,l,in) for(ll i=s;i<l;i+=in)
#define         Max INT_MAX
#define         Min INT_MIN
#define         pi acos(-1.0)
#define         Memset(a,val) memset(a,val,sizeof(a));

const int mod =1e9+7;
const int N =5e6+5;
typedef long long ll;



int main()
{

    ash;
    string s;
    cin>>s;
    for(int i=1;i<s.size();i++)
    {
        if(s[i]==s[i-1]){
            cout<<"Bad\n";
            exit(0);
        }
    }
    cout<<"Good\n";



    return 0;
}




Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define eps 0.00000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define f(n) for(int i=0;i<n;++i)
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	int cnt[3] = {};
	for (int i = 0;i < n;++i) {
		int hoge;
		cin >> hoge;
		if (hoge % 4 == 0) {
			cnt[2]++;
		}else if(hoge % 2 == 0){
			cnt[1]++;
		}
		else cnt[0]++;
	}
	if (cnt[0] <= cnt[2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (cnt[1] == 0) {
		if (cnt[0] <= cnt[2] + 1) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ull n;
    cin >> n;
    ull k = 100;
    ull ans = 0;
    while (k < n){
        ans++;
        k += k*(0.01);
    }
    cout << ans << endl;
} 

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

using namespace std;

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

	string S;
	cin >> S;

	int counter = 0;

	for (int i = 0; i < N - 2; i++) 
	{
		if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C') 
		{
			counter++;
		}
	}

	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 256
def eu(a,b):
    q = -1
    if(a<b):
        tmp = a
        a = b
        b = tmp
    while(q!=0):
        r = a // b
        q = a % b
        re = b
        a = b
        b = q
    return re    
N,=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
sum = 0
for i in range(1,N+1):
    for j in range(1,i+1):
        for k in range(1,j+1):
            if (i==j and j==k):
                sum+=eu(eu(i,j),k)
            elif (i==j or j==k or i==k):
                sum+=eu(eu(i,j),k)*3
            else:
                sum+=eu(eu(i,j),k)*6
print(sum)

Measured memory_bytes: 9240
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std ;
template< class T > inl T read() {
	T x = 0 ; int f = 1 ; char k = getchar() ;
	for( ; k > '9' || k < '0'; k = getchar() ) if( k == '-' ) f = -1 ;
	for( ; k >= '0' && k <= '9'; k = getchar() ) x = x * 10 + k - '0' ;
	return x * f ;
}
template< class T > inl T read( T &x ) { return x = read<T>() ; }
int _num, _buf[20];
template< class T > il print( T x ) {
   	if( x == 0 ) return putchar( '0' ) ,void() ;
	if( x < 0 ) putchar( '-' ), x = -x ;
	while( x ) _buf[++_num] = x % 10, x /= 10 ;
	while( _num ) putchar( _buf[_num--] + '0' ) ;
}
ll mul( ll a, ll b, ll mod ) { long double c = 1. ; return ( a * b - (ll)( c * a * b / mod ) * mod ) % mod ; }
it qpow( int x, int m, int mod ) {
	int res = 1, bas = x ;
	while(m) {
		if( m & 1 ) res = ( 1ll * res * bas ) % mod ;
		bas = ( 1ll * bas * bas ) % mod, m >>= 1 ;
	}
	return res ;
}
int k;
char s[105];
int main() {
//	freopen( ".in", "r", stdin ) ;
//	freopen( ".out", "w", stdout ) ;
	k = read<int>(), scanf( "%s", s + 1 ) ;
	int n = strlen( s + 1 ) ;
	if( n <= k ) {
		for( ri i = 1; i <= n; ++i )
			putchar( s[i] ) ;
	}
	else {
		for( ri i = 1; i <= k; ++i )
			putchar( s[i] ) ;
		puts( "..." ) ;
	}
	cerr << 1. * clock() / CLOCKS_PER_SEC << "\n" ;
	return 0;
}

Measured memory_bytes: 3848
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define INF 999999999

int n,m,l,k,a,h;
bool cold[200];

#define MAX_V 101
#define MAX_B 101

struct edge{pii to;int cost;};
vector<edge> G[MAX_V][MAX_B];
int d[MAX_V][MAX_B];

void dijkstra(pii s,int V){
    priority_queue< pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>> > que;
    rep(i,MAX_V)rep(j,MAX_B)d[i][j]=INF;
    d[s.first][s.second]=0;
    que.push(make_pair(0,s));
    
    while(que.size()){
        pair<int,pii> p=que.top();
        que.pop();
        
        int v=p.second.first;
        int b=p.second.second;
        if(d[v][b]<p.first)continue;
        
        rep(i,G[v][b].size()){
            edge e=G[v][b][i];
            if(d[e.to.first][e.to.second]>d[v][b]+e.cost){
                d[e.to.first][e.to.second]=d[v][b]+e.cost;
                que.push(make_pair(d[e.to.first][e.to.second],e.to));
            }
        }
    }
}





int main(){
    while(cin>>n>>m>>l>>k>>a>>h && (n||m||l||k||a||h)){
        rep(i,MAX_V)rep(j,101)G[i][j].clear();
        rep(i,200)cold[i]=false;
        
        rep(i,l){
            int a;
            cin>>a;
            cold[a]=true;
        }

        rep(i,k){
            int x,y,t;
            cin>>x>>y>>t;
            rep(j,m+1){
                if(j-t<0)continue;
                G[x][j].pb(edge{pii(y,j-t),t});
                G[y][j].pb(edge{pii(x,j-t),t});
            }
        }
        
        rep(i,n){
            if(cold[i]==false)continue;
            rep(j,m){
                G[i][j].pb(edge{pii(i,j+1),1});
            }
        }
        
        
        dijkstra(pii(a,m),n);
        
        int mini = INF;
        rep(i,101)mini = min(mini,d[h][i]);
        if(mini==INF)cout<<"Help!"<<endl;
        else cout<<mini<<endl;
        
    }
}

Measured memory_bytes: 6916
// inputに入力データ全体が入る
function Main(input) {
   input = input.split("\n");
  var n= parseInt(input[0], 10);
 
   var tmp = input[1].split(" ");
     var c = [];
for (var i = 0; i <n ; i++){
  var r= parseInt(tmp[i], 10);
 
  c[i] = r;}
  c.sort((a, b) => a - b);
   var t = c[0];
   for ( i = 0;i < n-1 ;i++){var t = (t+ c[i+1])/2;
     } 
  console.log(t);
}
 
  
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7500
#include <iostream>
#include <string>
using namespace std;
int main(){
int a;//アンナのカード数
cin >> a;
int b;//ブルーノのカード数
cin >> b;
int c;
c=0;
int d[a];
int e[b];
while(c<a){
cin >> d[c];
c=c+1;}
c=0;
while(c<b){
cin >> e[c];
c=c+1;}
c=0;//ブルーノの最初
int f;//アンナの今調べているところ
int g;//現在の得点
int h;//得点の最高値
h=0;

while(c<b){
f=0;
g=0;
while(f<a){
if(d[f]==e[c+g]){g=g+1;}
if(c+g>b-1){break;}
f=f+1;}
if(g>h){h=g;}
c=c+1;
}
cout << h<< endl;
}

Measured memory_bytes: 1200
#include <stdio.h>

int main(){
    int n,a,b,c;
    scanf("%d",&n);
    a=(int)n/100;
    b=(int)(n-a*100)/10;
    c=(int)(n-a*100-b*10);
    a == 1 ? a = 9 : a = 1;
    b == 1 ? b = 9 : b = 1;
    c == 1 ? c = 9 : c = 1;
    printf("%d\n",a*100+b*10+c);
    return 0;
}


Measured memory_bytes: 128
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	in := scanner.Text()
	v, _ := strconv.Atoi(in)
	fmt.Printf("%d", v+v*v+v*v*v)
}

Measured memory_bytes: 1772
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    list<int> ls; char c[21];
    int n; cin >> n;
    while (n--) {
        scanf("%s", c);
        if (c[0] == 'i') { int t; scanf("%d", &t); ls.push_front(t); }
        else if (c[6] == 'F') ls.pop_front();
        else if (c[6] == 'L') ls.pop_back();
        else {
            int t; scanf("%d", &t);
            auto ite = find(ls.begin(), ls.end(), t);
            if (ite != ls.end()) ls.erase(ite);
        }
    }
    int cnt = 0;
    for (auto ite : ls) {
        if (cnt) cout << ' ';
        cout << ite; cnt++;
    }
    cout << endl;
}

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

int count;

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int main()
{
  int n,left,right,i;
  int *S;

  count = 0;

  /* 入力 */
  scanf("%d",&n);
  S = (int *)malloc(sizeof(int) * n);
  if(S == NULL) exit(0);
  for(i = 0;i < n;i++){
    scanf("%d",&S[i]);
  }

  mergeSort(S,0,n);

  for(i = 0;i < n;i++){
    printf("%d",S[i]);
    if(i != (n - 1)) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  free(S);

  return 0;
}

/* n1,n2個の整数が格納された配列LとRを配列Aにマージ */
void merge(int *A,int left,int mid,int right)
{
  int n1,n2,i,j,k;
  int *L,*R;

  n1 = mid - left;
  n2 = right - mid;

  L = (int *)malloc(sizeof(int) * (n1 + 1));
  if(L == NULL) exit(0);
  R = (int *)malloc(sizeof(int) * (n2 + 1));
  if(R == NULL) exit(0);

  for(i = 0;i < n1;i++){
    L[i] = A[left + i];
  }
  for(i = 0;i < n2;i++){
    R[i] = A[mid + i];
  }

  /* 番兵として、どの要素よりも大きな値を末尾に配置 */
  L[n1] = 10000000000;
  R[n2] = 10000000000;

  /* ソートしつつ連結する */
  i = 0;
  j = 0;
  for(k = left;k < right;k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      count++;
    }
    else{
      A[k] = R[j];
      j = j + 1;
      count++;
    }
  }
  free(R);
  free(L);
}

void mergeSort(int *A,int left,int right)
{
  int mid;  

  if((left + 1) < right){
    mid = (left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

  
    

Measured memory_bytes: 4484
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;
    vec h(N); readv(h);
    vec dp(N);
    dp[0] = 0;
    dp[1] = llabs(h[1] - h[0]);
    FOR(i, 2, N) dp[i] = min(dp[i - 1] + llabs(h[i] - h[i - 1]), dp[i - 2] + llabs(h[i] - h[i - 2]));
    cout << dp[N - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int i=s.size()-1;
	if((s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[4]=='n'&&s[5]=='c'&&s[6]=='e')||(s[i-6]=='k'&&s[i-5]=='e'&&s[i-4]=='y'&&s[i-3]=='e'&&s[i-2]=='n'&&s[i-1]=='c'&&s[i]=='e')||(s[0]=='k'&&s[i-5]=='e'&&s[i-4]=='y'&&s[i-3]=='e'&&s[i-2]=='n'&&s[i-1]=='c'&&s[i]=='e')||(s[0]=='k'&&s[1]=='e'&&s[i-4]=='y'&&s[i-3]=='e'&&s[i-2]=='n'&&s[i-1]=='c'&&s[i]=='e')||(s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[i-3]=='e'&&s[i-2]=='n'&&s[i-1]=='c'&&s[i]=='e')||(s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[i-2]=='n'&&s[i-1]=='c'&&s[i]=='e')||(s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[4]=='n'&&s[i-1]=='c'&&s[i]=='e')||(s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[4]=='n'&&s[5]=='c'&&s[i]=='e'))
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int k = sc.nextInt();
			int t = sc.nextInt();
			int u = sc.nextInt();
			int v = sc.nextInt();
			int l = sc.nextInt();
			int [] d = new int[n];
			for(int i = 0; i < n; i++){
				d[i] = sc.nextInt();
			}
			int stock = 0, start = 0,end = 0, sum = 0;
			for(int i = 0; i < n; i++){
				if(d[i] <= end){
					if(stock == k){
						end = Math.min(l, d[i] + t * v);
					}
					else{
						stock++;
					}
				}
				else{
					while(stock != 0 && d[i] > end){
						stock--;
						end = Math.min(l, end + t * v);
					}
					if(d[i] <= end){
						stock++;
					}
					else{
						sum += end - start;
						start = d[i];
						end = Math.min(l, d[i] + t * v);
					}
				}
			}
			sum += Math.min(l, (long)end + (long)stock * t * v) - start;
			double res = (double)(l - sum) / u + (double)sum / v;
			System.out.printf("%.7f\n", res);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 20708
from math import sqrt
import sys
def input(): return sys.stdin.readline().strip()

def main():
    n = int(input())
    i = int(sqrt(n))
    while i > 0:
        if n % i == 0:
            print(i - 1 + (n // i) - 1)
            return
        i -= 1
main()

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
const int N=1e5+5;
int n, arr[N];
int main()
{
	cin >> n;
	bool ans=false;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		if(arr[i]%2) ans=true;
	}
	if(ans) cout << "first";
	else cout << "second";
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
 
int main(){
    int H, W;
    int i, j;
    while(1){
        cin >> H >> W;
        if(H + W == 0) break;
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++) cout << "#";
            cout << endl;
        }
		cout << endl;
    };
    return 0;
}
// データセットの直後の改行を忘れやすいので注意する。


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
typedef bitset<64> b64;
int main(){
	b64 b;int n,x;
	cin>>n;vector<b64> v(n);
	for(int i=0,j;i<n;i++)for(cin>>j;j--;v[i][x]=1)cin>>x;
	int q,a;
	for(cin>>q;q--;){
		cin>>a;
		if(a==0)cin>>x,cout<<b[x]<<endl;
		if(a==1)cin>>x,b|=v[x];
		if(a==2)cin>>x,b&=~v[x];
		if(a==3)cin>>x,b^=v[x];
		if(a==4)cin>>x,cout<<((b&v[x])==v[x])<<endl;
		if(a==5)cin>>x,cout<<(b&v[x]).any()<<endl;
		if(a==6)cin>>x,cout<<(b&v[x]).none()<<endl;
		if(a==7)cin>>x,cout<<(b&v[x]).count()<<endl;
		if(a==8)cin>>x,cout<<(b&v[x]).to_ulong()<<endl;
	}
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;

void solve() {
    string s;
    cin >> s;
    int mindiff = 10000000;
    for (int i = 0; i < s.size() - 2; i++) {
        int tmp = abs(stoi(s.substr(i, 3)) - 753);
        if (tmp < mindiff) mindiff = tmp;
    }
    cout << mindiff << endl;
}

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

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

int main()
{
    int num;
    int t[100][10];
    scanf("%d",&num);
    int i;
    int p[100][11];
    for(i=0;i<num;i++)
    {
        scanf("%d %d %d %d %d %d %d %d %d %d ",&t[i][0],&t[i][1],&t[i][2],&t[i][3],&t[i][4],&t[i][5],&t[i][6],&t[i][7],&t[i][8],&t[i][9]);
    }
    for(i=0;i<num;i++)
    {
        scanf("%d %d %d %d %d %d %d %d %d %d %d",&p[i][0],&p[i][1],&p[i][2],&p[i][3],&p[i][4],&p[i][5],&p[i][6],&p[i][7],&p[i][8],&p[i][9],&p[i][10]);
    }
    int count,count1;
    int max,sum;
    int a[10];
    for(count1=1;count1<1024;count1++)
    {
        count=count1;
        int j;
        for(j=0;j<10;j++)
        {
            a[j]=count%2;
            count=count>>1;
        }
        int n;
        for(n=0;n<num;n++)
        {
            int m;
            int count2=0;
            for(m=0;m<10;m++)
            if((t[n][m]==1)&&(a[m]==1))
            {
                count2++;
            }
                if(n==0)
                    sum=p[n][count2];
                else
                    sum+=p[n][count2];
        }
        if(count1==1)
            max=sum;
        if(max<sum)
                max=sum;
    }
    printf("%d",max);

    return 0;
}

Measured memory_bytes: 128
namespace global
  open System
  open System.Collections
  open System.Collections.Generic

  [<AutoOpen>]
  module Operators =
    let read f = Console.ReadLine().Split([|' '|]) |> Array.map f

  module Program =
    [<EntryPoint>]
    let main _ =
      match [|for _ in 0..2 -> read int|] with
      | [|
          [|c11; c12; c13|]
          [|c21; c22; c23|]
          [|c31; c32; c33|]
        |] ->
        let db1 = c12 - c11
        let db2 = c13 - c12
        let da1 = c21 - c11
        let da2 = c31 - c21
        let ok =
          c22 - c12 = da1 && c23 - c13 = da1
          && c32 - c22 = da2 && c33 - c23 = da2
          && c22 - c21 = db1 && c32 - c31 = db1
          && c23 - c22 = db2 && c33 - c32 = db2
        printfn "%s" (if ok then "Yes" else "No")
      | _ -> ()
      0


Measured memory_bytes: 14172
N, K = map(int, input().split())
h = [0]*N
for i in range(N):
    h[i] = int(input())
h.sort()
if(N==K):
    print(h[N]-h[0])
else:
    distance = []
    for i in range(N-K+1):
        distance_next = h[i+K-1] - h[i]
        distance.append(distance_next)
    print(min(distance))

Measured memory_bytes: 11252
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
void print(vector<int> v){
    cout<<endl;
    for(int i=0;i<v.size();i++)if(i==0)cout<<v[i];else cout<<" "<<v[i];
    cout<<endl;
}

struct S{
    int a[3];
};

signed main (){
    int n;cin>>n;
    int a,b;cin>>a>>b;
    vector<int> v(n);
    rep(i,0,n){
        cin>>v[i];
    }
    sort(all(v));
    int x=0,y=0,z=0;
    rep(i,0,n){
        if(v[i]<=a)x++;
        else if(v[i]<=b)y++;
        else z++;
    }
    cout<<min(x,min(y,z))<<endl;

}
/*
*/


Measured memory_bytes: 256
/*==============================================*\
ID:          shahidul_brur

Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh

 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    ll a, b; cin>>a>>b;
    ll k = (a+b)/2;
    if(abs(a-k)==abs(b-k) /*|| a+k==b-k || a-k==b+k || a-k==b-k*/)
        cout << k << "\n";
    else cout << "IMPOSSIBLE\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	int x,y; cin >> x >> y;
	char g[13];
	rep1(i, 12)
	{
		if (i == 2)
			g[i] = 'c';
		else if (i == 4 || i == 6 || i == 9 || i == 11)
			g[i] = 'b';
		else
			g[i] = 'a';
	}
	if (g[x] == g[y])
		cout << yes;
	else
		cout << no;
	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    if(n>=24){
        cout << 0 << endl;
        return 0;
    }
    int d[n];
    int mp[24]={};
    mp[0] = 1;
    vector<int> v[2];
    int cnt = 0;
    rep(i, n)
    {
        cin >> d[i];
        if(mp[d[i]]==0){
            if(d[i]!=12)cnt++;
            mp[d[i]]++;
        }else{
            if(mp[24-d[i]]==0){
                cnt--;
                mp[24 - d[i]]++;
                mp[d[i]]++;
            }else{
                cout << 0 << endl;
                return 0;
            }
        }
    }
    rep(i,11){
        if(mp[i+1]!=1)continue;
        v[0].push_back(i + 1);
        v[1].push_back(24 - (i + 1));
    }
    int k = 1 << cnt;
    int ans = 0;
    rep(i,k){
        int x = i;
        vector<int> v2;
        v2.push_back(0);
        v2.push_back(24);
        if(mp[12])v2.push_back(12);
        rep(j,11){
            if(mp[j+1]==2){
                v2.push_back(j+1);
                v2.push_back(24 - (j + 1));
            }
        }
        rep(j,cnt){
            v2.push_back(v[x % 2][j]);
            x /= 2;
        }
        int tmp = 50;
        rep(j, v2.size())
        {
            rep(k,v2.size()){
                if(j==k)continue;
                tmp = min(abs(v2[k] - v2[j]), tmp);
            }
        }
        ans = max(tmp, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int x, j = x;
    cin >> x;
    if((x >= 0) && (x <=1)){
        if(x == 0)
        cout << "1" << endl;
        else if(x == 1)
        cout << "0" << endl;
        else
        cout << "Invalid Input!\n";
    }
    else
    {
        cout << "Invalid" << endl;
    }
    return 0;
    
}

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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9,mod=1e9+7;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int main(){
	//IO();
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(int i=1;i<n;i++)
		if (a[i-1]==a[i])
			return !printf("NO\n");
	printf("YES\n");
}


Measured memory_bytes: 2304
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
  int a, b;
  scanf("%d %d", &a, &b);
  int outlet = 1;
  int tap = 0;
  bool loop = true;
  while (loop){
    if (outlet < b){
      tap++;
      outlet += a -1;
    }else{
      loop = false;
      printf("%d\n", tap);
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
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;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  ll n;
  cin >> n;
  map<string,ll>mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;
}


Measured memory_bytes: 31228
class UnionFind():
  def __init__(self):
    self.roots = {}
    self.nums = {}

  def find_root(self, a):
    if a not in self.roots:
      self.nums[a] = 1
      return a
    else:
      self.roots[a] = self.find_root(self.roots[a])
      return self.roots[a]

  def unite(self, a, b):
    root_a = self.find_root(a)
    root_b = self.find_root(b)
    n_a = self.nums[root_a]
    n_b = self.nums[root_b]
    if root_a == root_b:
      return
    else:
      if n_a > n_b: #多い方に合流させる
        self.roots[root_b] = root_a
        self.nums[root_a] = n_a + n_b
        del self.nums[root_b]
      else:
        self.roots[root_a] = root_b
        self.nums[root_b] = n_a + n_b
        del self.nums[root_a]
      return
  
  def is_union(self, a,b):
    return self.find_root(a) == self.find_root(b)

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

answer = 0
for i in range(M):
  temp = AB[:i] + AB[i+1:]
  ai, bi = AB[i]
  uf = UnionFind()
  for ab in temp:
    a,b = ab
    uf.unite(a,b)
  answer += not uf.is_union(ai, bi)


print(answer)

Measured memory_bytes: 3064
n=int(input())
T=0
H=0

for i in range(n):
    cards_t,cards_h=map(str,input().split())
    
    if cards_t==cards_h:
        T+=1
        H+=1
    elif cards_t>cards_h:
        T+=3
    else:
        H+=3
print(T,H)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */
 
#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "T" : "F");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


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

  int n; cin >> n;
  if( n == 1 ){
    cout << 0 << endl;
    return 0;
  }
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];

  int ans = 0;
  for(int j=0, i=0; i<n; ) {
    for( j=i+1; j<n and a[j]-a[j-1] <= 0; j++);
    smax(ans, j-i-1);

    i = j;
  }
  cout << ans << endl;

}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,x;cin>>n>>x;
  ll ans = 0;
  while(n--){
    ll a;cin>>a;
    ans += 2*min(a,x-a);
  }
  cout<<ans<<endl;
  return 0;
}


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

#define F first
#define S second
#define pb push_back
#define mp make_pair

ll gcd(ll a, ll b){
	if (a == 0) return b;
	return gcd(b%a, a);
}

ll lcm(ll a, ll b){
	return (a/gcd(a, b))*b;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n,i,j;

	cin >> n;
	ll a[n];

	ll prime[1000003];

	memset(prime , 0 ,sizeof(prime));

	for(i=2;i<1000001;i++)
	{
		if(prime[i] == 0)
		{
			for(j=i;j<1000001;j += i)
			{
				prime[j] = i;
			}
		}
	}

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

	map <ll,ll> pf;

	for(i=0;i<n;i++)
	{
		map <ll,ll> m;

		ll x = a[i];

		while(x!=1)
		{
			if(m.find(prime[x]) == m.end())
			{
				m.insert(mp(prime[x],1));
			}

			x/=prime[x];
		}

		for(auto it : m)
		{
			if(pf.find(it.first) != pf.end())
				pf.find(it.first)->second++;
			else
				pf.insert(mp(it.first,1));
		}
	}


	ll flag1 =0 , flag2 = 0;
	for(auto it : pf)
	{
		if(it.second != 1)
			flag1 = 1;
		if(it.second == n)
			flag2 = 1;
	}

	if(flag1 == 0)
		cout << "pairwise coprime\n";
	else if(flag2 == 0)
		cout << "setwise coprime\n";
	else
		cout << "not coprime\n";
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N,K;
int node [100001];
list<int> edge [100001];
const int INF = 1e9;

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

	cin >> N;
	FOR(i,0,N - 1){
		int A,B;
		cin >> A >> B;
		edge [A].push_back(B);
		edge [B].push_back(A);
	}
	cin >> K;
	fill_n(node,N + 1,INF);
	priority_queue< pair<int,int> > pq;
	FOR(i,0,K){
		int V,P;
		cin >> V >> P;
		node [V] = P;
		pq.emplace(P,V);
	}

	while(pq.empty() == false){
		int p = pq.top().first,v = pq.top().second;
		pq.pop();

		for(auto&& it : edge [v]){
			if(node [it] == INF){
				node [it] = p - 1;
				pq.emplace(p - 1,it);
			}
			else if(abs(node [it] - p) != 1){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
	for(int i = 1;i <= N;i++){
		cout << node [i] << endl;
	}

	return 0;
}


Measured memory_bytes: 10104
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
using ll = long long;
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

const ll MOD = 1e9+7;
int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0;i<n;i++)cin >> a[i];
	ll xx = 0;
	for(int i = 0;i<n;i++)
	{
		(xx += a[i])%=MOD;
	}
	ll ans =0 ;
	for(int i = 0;i<n;i++)
	{
		xx += (MOD-a[i]);
		xx %=MOD;
		ans += xx*a[i]%MOD;
		ans %= MOD;
		
		
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4732
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0

for i in range(N):
  ans += B[A[i]-1]
  if A[i]-A[i-1]==1 and i >= 1:
    ans += C[A[i]-2]
print(ans)

Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

long long gcd(int a, int b){
  if (a%b == 0){
    return(b);
  }
  else{
    return(gcd(b, a%b));
  }
}

int main(){    
  long long R;
  cin >> R;
  long long sum = 0;


  cout << R * 2 * M_PI<< endl;

}
 


Measured memory_bytes: 3788