akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}
//cout << fixed << setprecision(10);

struct UnionFind{
 vector<ll>par;
  
  UnionFind(ll n) : par(n){
  rep(i,n) par[i]=i;
  }

  ll root(ll x){
  if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  
  void unite(ll x,ll y){
    ll rx=root(x),ry=root(y);
 if(rx==ry) return;
   par[rx]=ry;
  }
  
  bool same(ll x,ll y){
  return root(x)==root(y);
  }

};

int main(){
  ll n,m; cin>>n>>m;
  vector<ll>p(n+1);
  rep(i,n) cin>>p[i+1];
  
  UnionFind tree(n+1);
  
  rep(i,m){
  ll x,y; cin>>x>>y;
    tree.unite(x,y);
  }
  
  ll ans=0;
  rep(i,n) if(tree.same(i+1,p[i+1])) ans++;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
import math

def simultaneous_equasion(a, b, c, d, e, f):
    "??£???????¨????"
    det = a * d - b * c
    a11 = d / det
    a12 = - b / det
    a21 = - c / det
    a22 = a / det
    return a11 * e + a12 * f, a21 * e + a22 * f

n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    # ?????????O??¨????????¨???OP1 ^ 2 = OP2 ^ 2
    # (x - x1) ^ 2 + (y - y1) ^ 2 = (x - x2) ^ 2 + (y - y2) ^ 2
    # - 2 * x * x1 + x1 ^ 2 - 2 * y * y1 + y1 ^ 2 = - 2 * x * x2 + x2 ^ 2 - 2 * y * y2 + y2 ^ 2
    # 2 * (x1 - x2) * x + 2 * (y1 - y2) * y = x1 ^ 2 + y2 ^ 2 - x2 ^ 2 - y2 ^ 2
    a = 2 * (x1 - x2)
    b = 2 * (y1 - y2)
    c = 2 * (x1 - x3)
    d = 2 * (y1 - y3)
    e = x1 ** 2 + y1 ** 2 - x2 ** 2 - y2 ** 2
    f = x1 ** 2 + y1 ** 2 - x3 ** 2 - y3 ** 2
    px, py = simultaneous_equasion(a, b, c, d, e, f)
    r = math.sqrt((px - x1) ** 2 + (py - y1) ** 2)
    print("%.3f %.3f %.3f" % (round(px, 3), round(py, 3), round(r, 3)))

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    lld N,Q;
    lld cnt[100001];
    mem0(cnt);
    cin >> N;
    lld ans = 0;
    for (int i = 0; i < N; i++) {
        lld a;
        cin >> a;
        cnt[a-1]++;
        ans += a;
    }
    cin >> Q;
    lld b,c;
    for (int i = 0; i < Q; i++) {
        cin >> b >> c;
        ans -= b*cnt[b-1];
        ans += c*cnt[b-1];
        cnt[c-1] += cnt[b-1];
        cnt[b-1] = 0;
        cout << ans << endl;
    }
}

Measured memory_bytes: 4416
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main(){
  string s;
  int i;
  getline(cin,s);
  stringstream ss;
  vector<string>v;
  for(i=0;i<s.length();i++)
      if(s[i]==','||s[i]=='.')s[i]=' ';
  for(ss<<s;ss>>s;)if(2<s.length()&&s.length()<7)v.push_back(s);
  for(i=0;i<v.size();i++){
    if(i)cout<<' ';
    cout<<v[i];
  }
  cout<<endl;
}

Measured memory_bytes: 1204
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int length = s.length();
    int flag[] = new int[26];
    for(int i=0;i<26;i++){
      flag[i] = 0;
    }
    for(int i=0;i<length;i++){
      flag[s.charAt(i)-'a'] = 1;
    }
    for(int i=0;i<26;i++){
      if(flag[i] == 0){
        System.out.println((char)('a'+i));
        break;
      }
      if(i == 25)System.out.println("None");
    }

  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main(){
    vector<int> a(3);
    rep(i,3){
        cin>>a[i];
    }
    SORT(a);
    cout<<a[1]-a[0]+(a[2]-a[1])<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 998244353;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vl a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    vector<ll> ans = convolution<mod>(a, b);
    
    rep(i, ans.size()) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 27288
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define  fo(i,a,b) for(ll i=a;i<b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

#define err() cout<<"----------"<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589
const ll MOD=(1e9+7);
ll mod(ll x)
{
   return (x%MOD+MOD)%MOD;
   // works for neg and pos values of x.
}
void solve()
{
    ll n;
    cin>>n;
    ll ans=1,ans1=1,ans2=1;
    //deb(ans);
    fo(i,0,n)
    {
        ans=mod(mod(ans)*10);
    }
    fo(i,0,n)
    {
        ans1=mod(mod(ans1)*9);
    }
    fo(i,0,n)
    {
        ans2=mod(mod(ans2)*8);
    }
    
    
    cout<<mod(ans-2*ans1+ans2);

}
int main()
{
//  clock_t time_req;
//  time_req = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

// time_req = clock()-time_req;
//  cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
int p[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int c[25];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int now=i;
		while(now!=1){
			for(int j=0;j<25;j++){
				if(now%p[j]==0){
					while(now%p[j]==0){
						now/=p[j];
						c[j]++;
					}
				}
			}
		}
	}
	for(int i=0;i<25;i++){
		if(c[i]){
			c[i]++;
		}
	}
	int th=0,fi=0,zy=0,ni=0,na=0;
	for(int i=0;i<25;i++){
		if(c[i]>=3){
			th++;
		}
		if(c[i]>=5){
			fi++;
		}
		if(c[i]>=15){
			zy++;
		}
		if(c[i]>=25){
			ni++;
		}
		if(c[i]>=75){
			na++;
		}
	}
	int ans=0;
	ans+=na;
	ans+=ni*(th-1);
	ans+=zy*(fi-1);
	ans+=fi*(fi-1)/2*(th-2);
	cout<<ans<<endl;
	return 0;
}


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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

int main()
{
	LL x;
	cin >> x;

	LL amt = 100;
	LL t = 0;

	while (amt < x) {
		amt += amt/100;
		t++;
	}
	cout << t << "\n";
}



Measured memory_bytes: 3632
/* *
 *
 * Author: Hamkor
 *
 * */

#include <bits/stdc++.h>

/* * * *   Knacks   * * * */
typedef long long ll;
const int oo = 1e9;
/* * * *   * * *   	* * * */

using namespace std;

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, w; cin>>n>>w;
	ll a[n][w+1];
	vector<pair<int, int> > b(n);
	for (int i=0; i<n; ++i) cin>>b[i].first>>b[i].second;
	sort(b.begin(), b.end());
	for (int i = 0; i<n; ++i) a[i][0] = 0;
	for (int i = 0; i<=w; ++i) a[0][i] = i<b[0].first ? 0: b[0].second;
	for (int i = 1; i<n; ++i){
        for(int j=1; j<=w; ++j){
            if(b[i].first > j ){
                a[i][j] = a[i-1][j];
                continue;
            }
            a[i][j] = max(a[i-1][j- b[i].first] + b[i].second, a[i-1][j]);
        }
	}
	cout<<a[n-1][w];
	return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;

int n,tot;
ll x,y,z,a,s,t,d[60];
bool F(ll A,int i) {
	if (A&(1LL<<i)) return 1;
	return 0;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	read(x); read(y); s=x+y;
	for (int i=3;i<=n;i++) read(a),z^=a;
	for (int i=0;i<=50;i++)
		if (F(z,i)) s-=1LL<<i;
		else t+=1LL<<(i+1);
	bool flag=1;
	for (int i=0;i<=50;i++)
		if (F(s,i)&&!F(t,i)) { flag=0; break; }
	if (!flag) { printf("-1\n"); return 0; }
	a=0;
	for (int i=0;i<=50;i++) {
		if (F(s,i+1)) a+=1LL<<i;
		else if (F(z,i)) d[++tot]=1LL<<i;
	}
	if (a>x) { printf("-1\n"); return 0; }
	for (int i=tot;i>=1;i--)
		if (a+d[i]<=x) a+=d[i];
	if (!a) { printf("-1\n"); return 0; }
	printf("%lld\n",x-a);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 3756
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n,m;
struct Node
{
    int x,y;
    int step=0;
};
char a[205][205];
int vis[205][205],dr[4][2]= {{1,0},{-1,0},{0,1},{0,-1}};
Node s,t;
int bfs(Node u,Node v)
{
    memset(vis,0,sizeof(vis));
    vis[u.x][u.y]=1;
    u.step=0;
    queue <Node> Q;
    Q.push(u);
    while(!Q.empty())
    {
        Node c=Q.front();
        Q.pop();
        if (c.x==v.x&&c.y==v.y) return c.step;
        for (int i=0; i<4; i++)
        {
            Node ne;
            ne.x=c.x+dr[i][0];
            ne.y=c.y+dr[i][1];
            if (!vis[ne.x][ne.y]&&a[ne.x][ne.y]!='#'&&ne.x>=1&&ne.x<=n&&ne.y>=1&&ne.y<=m)
            {
                vis[ne.x][ne.y]=1;
                ne.step=c.step+1;
                Q.push(ne);
            }
        }
    }
}
int bfs2(Node u,int ma)
{
    memset(vis,0,sizeof(vis));
    vis[u.x][u.y]=1;
    u.step=0;
    queue <Node> Q;
    Q.push(u);
    while(!Q.empty())
    {
        Node c=Q.front();
        Q.pop();
        for (int i=0; i<4; i++)
        {
            Node ne;
            ne.x=c.x+dr[i][0];
            ne.y=c.y+dr[i][1];
            if (!vis[ne.x][ne.y]&&a[ne.x][ne.y]!='#'&&ne.x>=1&&ne.x<=n&&ne.y>=1&&ne.y<=m)
            {
                vis[ne.x][ne.y]=1;
                ne.step=c.step+1;
                // printf("%d %d %d\n",ne.x,ne.y,ne.step);
                if (ne.step>ma) return 1;
                if (a[ne.x][ne.y]=='$')
                    return 0;
                Q.push(ne);
            }
        }
    }
}
int main()
{
    //freopen("input(1).in","r",stdin);
    //freopen("output.txt","w",stdout);
    scanf("%d%d",&n,&m);
    {
        memset(a,0,sizeof(a));
        int f=1;
        for (int i=1; i<=n; i++)
        {
            for (int j=1; j<=m; j++)
            {
                cin>>a[i][j];
                if (a[i][j]=='@')
                {
                    s.x=i,s.y=j;
                }
                else if (a[i][j]=='%')
                {
                    t.x=i,t.y=j;
                }
            }
        }
        int dis=bfs(s,t);
        //cout<<dis<<endl;
        f=bfs2(t,dis);
        f ? printf("Yes\n") :printf("No\n");
    }

    return 0;
}
/*
4 4
%...
...$
..@$
$$$$
4 4
%..@
.#..
....
$...
*/



Measured memory_bytes: 3432
//AtCoder ABC101 C - Minimization
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N,K; cin>>N>>K;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    sort(an.begin(),an.end());
    ll num=N;
    for(auto&& a:an){
        if(a==an[0])--num;
        else break;
    }
    ll ans=num/(K-1);
    if(num%(K-1)!=0)++ans;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll d=c-a-b;
  if(d>0&&d*d>4*a*b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
     return 0;
     }
  

Measured memory_bytes: 256
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
s = Array.new(m) { gets.split.map(&:to_i).map(&:pred) }
s.map(&:shift)
p = gets.split.map(&:to_i)
cnt = 0

(2**n).times do |b|
  if s.each_with_index.all? { |e, idx| e.count { |j| b[j] == 1 } % 2 == p[idx] }
    cnt += 1
  end
end

puts cnt

Measured memory_bytes: 1788
n,m=map(int,input().split())
a=[]
for i in range(1,int(m**.5)+1):
  if m%i==0:
    ans=i
    a.append(i)
  if i==m//n:break
else:
  for i in a:
    if m//i<=m//n:
      ans=m//i
      break
print(ans)

Measured memory_bytes: 9288
<?php 
    $array = explode(' ',trim(fgets(STDIN)));
    $W = $array[0];
    $H = $array[1];
    $x = $array[2];
    $y = $array[3];
    $r = $array[4];
    if($x-$r>=0 && $x+$r<=$W && $y-$r>=0 && $y+$r<=$H){
        echo "Yes";
    }else{
        echo "No";
    }
 ?>

Measured memory_bytes: 15384
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>

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

using namespace std;
typedef long long ll;

const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
    int n, k; cin >> n >> k;
    if (k > (n-1) * (n-2) / 2) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> u, v;
    int num = (n-1) * (n-2) / 2 - k;
    for (int i = 2; i <= n; i++) {
        u.push_back(1);
        v.push_back(i);
    }
    int cnt = 0;
    bool flag = 0;
    for (int i = 2; i <= n; i++) {
        for (int j = i+1; j <= n; j++) {
            if (cnt == num) {
                flag = 1;
                break;
            }
            u.push_back(i);
            v.push_back(j);
            cnt++;
        }
        if (flag == 1) break;
    }

    cout << u.size() << endl;
    rep(i, u.size()) {
        cout << u[i] << " " << v[i] << endl;
    }

    return 0;

}

Measured memory_bytes: 512
#pragma comment(linker, "/STACK:60777216")  

#include <cassert>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdlib>
#include<memory.h>
#include<ctime>
#include<bitset>
#include<fstream>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>

using namespace std;

typedef long double ld;

typedef long long ll;
typedef pair<int,int>	pii;
typedef pair<ld,ld>	pdd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef pair<ll,ll> pl;

#define FOR(i,a,b)		for(int i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)				memset(a,b,sizeof a)
#define pb				push_back

int n,e,t;
int x[222222];


ll  r[222222];
int p[222222];

int main(){	
#ifdef LocalHost
	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif

	cin>>n>>e>>t;
	//if(n>10000)return 0;
	REP(i,n)scanf("%d",x+i+1);
	FOR(i,1,n+1){
		r[i]=1e18;
		FOR(prev,p[i-1],i){
			int diff = x[i] - x[prev+1];diff*=2;
			if(r[i]>r[prev]+max(diff,t)){
				r[i]=r[prev]+max(diff,t);
				p[i]=prev;
			}
			if(diff<t)break;
		}
	/*	int prev = p[i-1];
		r[i] = r[prev] + solve(prev,i);
		while(prev+1<i && r[i] > r[prev+1]+solve(prev+1,i)){
			prev++;
			r[i] = r[prev] + solve(prev,i);
		}
		p[i] = prev;*/
	}

	cout<<r[n]+e<<endl;



#ifdef LocalHost
	printf("TIME: %.3lf\n",ld(clock())/CLOCKS_PER_SEC);
#endif
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<tuple<ll, ll, ll>> T(N);

  ll a, b, c;
  for(int i = 0; i < N; i++){
    cin >> a >> b;
    T[i] = make_tuple(a+b, a, b);
  }

  sort(T.rbegin(), T.rend());

  ll sum_A = 0;
  ll sum_B = 0;

  for(int i = 0; i < N; i++){
    if(i%2 == 0){
      sum_A += get<1>(T[i]);
    }else{
      sum_B += get<2>(T[i]);
    }

  }

  cout << sum_A - sum_B << endl;



  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    float a[10],sum=0;
    string s[10];
    for(int i=0;i<n;i++){
        cin >> a[i] >> s[i];
    }
    for(int i=0;i<n;i++){
        if(s[i] == "JPY"){
            sum += a[i];
        }else{
            sum += (a[i] * 380000);
        }
    }
    cout << sum;
}

Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void reads(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int main(){
    int n;scanf("%d",&n);
    int r=n%10;
    if(r==3)printf("bon\n");
    else if(r==0||r==1||r==6||r==8)printf("pon\n");
    else printf("hon\n");
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    string S;
    int flag = 1;
    cin >> N >> S;

    if(N > 1 && (N % 2 == 0)){
        for(int i = 0; i < N / 2; i++){
            if(S[i] != S[(N / 2) + i]){
                flag = 0;
            }
        }
    }
    else{
        flag = 0;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
from statistics import mean
import math
N = (map(int, input().split()))
X = list(map(int, input().split()))
A = mean(X)
A = round(A)
list =[]
for i in range(0, len(X)):
    B = X[i] - A
    B =pow(B,2)
    list.append(B)
Sum = sum(list)
print(Sum)

Measured memory_bytes: 5404
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    for j in range(n-1):
        a[i][j] -= 1

MAXN = 1005
MAXV = MAXN*(MAXN-1)//2

to = [[] for _ in range(MAXV)]
# 頂点番号
id = [[0 for _ in range(MAXN)] for _ in range(MAXN)]
def toID(i, j):
    if i > j:
        i, j = j, i
    return id[i][j]

# 頂点番号のラベリング
V = 0
for i in range(n):
    for j in range(n):
        if i < j:
            id[i][j] += V
            V += 1

# aを、頂点番号に書き換え、試合の依存関係を表す辺を張る(辺の向きは逆にする)
for i in range(n):
    for j in range(n-1):
        a[i][j] = toID(i, a[i][j])
    for j in range(n-2):
        to[a[i][j+1]].append(a[i][j])

# dfsする
visited = [False for _ in range(MAXV)]
calculated = [False for _ in range(MAXV)] # loop 検出用
dp = [0 for _ in range(MAXV)] # max length of path from v
def dfs(v):
    if visited[v]:
        if not calculated[v]:
            return -1
        return dp[v]
    visited[v] = True
    dp[v] = 1
    for u in to[v]:
        res = dfs(u)
        if res == -1:
            return -1
        dp[v] = max(dp[v], res+1)
    calculated[v] = True
    return dp[v]

ans = 0
ok = True
for i in range(V):
    res = dfs(i)
    if res == -1:
        ok = False
        break
    ans = max(ans, res)
if ok:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 182624
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF = numeric_limits<long long>::max();
int main() {
    ll A;
    string B;
    cin >> A >> B;

    auto itr = B.find('.');
    ll b1    = A * stoll(B.substr(0, itr));
    ll b2    = A * stoll(B.substr(itr + 1, B.size() - itr - 1)) / 100;

    ll ans = b1 + b2;
    PR(ans);
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,o,p,d,x;
    deque<long long int>dq;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&o,&p);
        if(o==0)
        {
            scanf("%d",&x);
            if(p==0) dq.push_front(x);
            else dq.push_back(x);
        }
        else if(o==1) cout<<dq[p]<<endl;
        else {
            if(p==0) dq.pop_front();
            else dq.pop_back();
        }
    }
    return 0;
}



Measured memory_bytes: 6352
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    rep(i, n){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

n, m = list(map(int, input().split()))
li = []
for _ in range(m):
    li.append(list(map(int, input().split())))

# construct indirected graph
edges = [[] for _ in range(n)]
for i, j in li:
    edges[i - 1].append(j - 1)
    edges[j - 1].append(i - 1)

ans = 0
S = deque()
S.append([0])
while len(S) > 0:
    path = S.pop()
    for v in edges[path[-1]]:
        if v not in path:
            if len(path) + 1 == n:
                ans += 1
            else:
                S.append(path + [v])


print(ans)

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

cards = []
for i in range(n):
    a, b = input().split()
    cards.append([a, int(b)])

for c in ['S', 'H', 'C', 'D']:
    for num in range(1, 14):
        if not [c, num] in cards:
            print(c + ' ' + str(num))



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve(){
    ll n,f=0;
    cin>>n;
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        if(x%2==0){
            if(!(x%3==0||x%5==0))
            f=1;
        }
    }
    if(f)
    cout<<"DENIED";
    else
    cout<<"APPROVED";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    t=1;
    for(ll i=0;i<t;i++)
    solve();
}

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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main() {
	faster;
	ll h, w, m;

	cin >> h >> w >> m;

	ll limit = 1e6;

	vector<ll> hs(limit,0),ws(limit,0);

	map<pair<ll, ll>,ll> both;

	for (ll i = 0; i < m; i++) {
		ll h1, w1;
		cin >> h1 >> w1;
		both[{h1,w1}]++;
		hs[h1]++;
		ws[w1]++;
	}

	ll mxh = *max_element(all(hs)),mxw = *max_element(all(ws));
	set<ll> vx,vy;
	for(ll i= 0; i < limit; i++) if(hs[i] == mxh) vx.insert(i);
	for(ll i = 0; i < limit; i++) if(ws[i] == mxw) vy.insert(i);

	ll ans = mxh + mxw - 1;
	
	for(auto x: vx){
		for(auto y: vy){
			if(!both.count({x,y})){
				cout << ans + 1 << endl;
				return 0;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 65692
#include <iostream>
using namespace std;
 
int main(){
	long long k,n;
  	cin >> k >> n;
    long long a[n];
  	for(int i=0;i<n;++i)cin>>a[i];
  	long long c = 0;
  	long long d = 0;
  	for(int i=1;i<n;++i){
      c += a[i]-a[i-1];
      if(d<a[i]-a[i-1])d=a[i]-a[i-1];
    }
  	c += k-(a[n-1]-a[0]);
    if (d<k-(a[n-1]-a[0]))d=k-(a[n-1]-a[0]);
  	c -= d;
    cout << c << endl;
}

Measured memory_bytes: 1792
s=input()
l=len(s)
ans=[0 for _ in range(l+1)]
for i in range(l):
    if s[i]=='<':
        ans[i+1]=ans[i]+1
for i in range(l-1,-1,-1):
    if s[i]=='>':
        ans[i]=max(ans[i+1]+1,ans[i])
print(sum(ans))
        

Measured memory_bytes: 24100
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll a, b, c;
	ll fcount = 0;
	ll scount = 0;

	cin >> a >> b >> c;

	if (a == 5) {
		fcount++;
	}
	else if (a == 7) {
		scount++;
	}

	if (b == 5) {
		fcount++;
	}
	else if (b == 7) {
		scount++;
	}

	if (c == 5) {
		fcount++;
	}
	else if (c == 7) {
		scount++;
	}

	if (fcount == 2 && scount == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <math.h>
#define int long long
#define ll long long
using namespace std;
//#pragma endregion

signed main()
{
	int n;
	int m;
	int h[1000000] = { 0 };
	int m1, m2;

	//int k, d;
	int all = 0;
	//int a;

	int box[1000000] = { 0 };

	//string str;

	cin >> n >> m;
	//cin >> d;
	//cin >> str;

	//cout << a;

	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
		box[i] = h[i];
		/*for (int j = 0; j < d; j++)
		{
			cin >> a;
			box[a]++;
		}*/
	}

	for (int i = 1; i <= m; i++)
	{
		cin >> m1 >> m2;

		if (h[m1] < h[m2])
		{
			box[m1] = 0;
		}
		else if (h[m1] == h[m2])
		{
			box[m1] = 0;
			box[m2] = 0;
		}
		else
		{
			box[m2] = 0;
		}
	}

	for (int i = 1; i <= n; i++)
	{
		if (box[i] != 0)
		{
			all++;
		}
		//cout << box[i] << "\n";
	}

	cout << all << "\n";

	/*if (str=="ABC")
	{
		cout << "ARC\n";
	}
	else
	{
		cout << "ABC\n";
	}*/
}

Measured memory_bytes: 19264
N = int(input())
V = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
P = [V[x]-C[x] for x in range(N)]

P = sorted(P)[::-1]
i,ans = 0,0

while P[i] > 0:
    ans += P[i]
    i += 1
    if i == N:
        break
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cctype>

inline int getInt() {
  int sum(0); char _c;
  while (!isdigit(_c = getchar()));
  do sum = sum * 10 + _c - '0';
  while (isdigit(_c = getchar()));
  return sum;
}

int res;

int main() {
  int n = getInt(), l = getInt(), r = getInt();
  for (register int i = 1; i <= n; ++i) {
    int sum(0), num = i;
    while (num) sum += num % 10, num /= 10;
    if (sum >= l && sum <= r) res += i;
  } printf("%d\n", res);
  return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.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))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;
  vll as(n);
  rep(i, n) cin >> as[i];

  vll dp(k + 1, 0);
  rep(i, k + 1) {
    dp[i] = 0;
    set<ll> s;
    rep(j, n) {
      if (i - as[j] >= 0) {
        s.insert(dp[i - as[j]]);
      }
    }
    ll g = 0;
    while (s.count(g) != 0) g++;
    dp[i] = g;
  }
  string ans = dp[k] != 0 ? "First" : "Second";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1152
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

struct txy{
  ll t;
  ll x;
  ll y;
};

int main() {
  ll n;
  cin >> n;
  vector<txy> a(n+1);
  a.at(0).t=0;
  a.at(0).x=0;
  a.at(0).y=0;
  rep(i, n) cin >> a.at(i+1).t >> a.at(i+1).x >> a.at(i+1).y;
  bool isCan = true;
  rep(i, n){
    if(not isCan) break;
    ll dir = abs(a.at(i).y-a.at(i+1).y)+abs(a.at(i).x-a.at(i+1).x);
    ll tim = a.at(i+1).t-a.at(i).t;
    if(dir <= tim){
      isCan = dir%2 ==0;
      if(tim%2==1) isCan = not isCan;
    }else{
      isCan = false;
    }
  }
  if (isCan)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 2560
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;
//約数の列挙O(√n)
int main(){
  int count=0;
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='o')count++;
  }
  cout<<700+count*100<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import combinations
INF = float("inf")


memo1 = {}
memo2 = {}

def ok(y1, y2, x1, x2, yd, yd2, xd, xd2, K):
    if (y1, y2) in memo1:
        y = memo1[(y1, y2)]
    else:
        a = yd2[y1]
        b = yd[y2]
        y = b.difference(a)
        memo1[(y1, y2)] = y

    if (x1, x2) in memo2:
        x = memo2[(x1, x2)]
    else:
        c = xd2[x1]
        d = xd[x2]
        x = d.difference(c)
        memo2[(x1, x2)] = x

    # print(a, b, c, d)
    # print(y, x)

    n = len(y & x)

    return n >= K


def main():
    import time
    N, K = map(int, raw_input().split())
    ys, xs = [], []
    for i in range(N):
        x, y = map(int, raw_input().split())
        ys.append((y, i))
        xs.append((x, i))

    ys.sort()
    yd = defaultdict(set)
    yd2 = defaultdict(set)
    old = set()
    for y, i in ys:
        yd2[y] = old.copy()
        old.add(i)
        yd[y] = old.copy()

    xs.sort()
    xd = defaultdict(set)
    xd2 = defaultdict(set)
    old = set()
    for x, i in xs:
        xd2[x] = old.copy()
        old.add(i)
        xd[x] = old.copy()

    ans = INF

    # print(yd)
    # print(xd)
    #
    # print(ok(1, 4, 1, 8, yd, yd2, xd, xd2, K))
    for i, j in combinations(range(N), 2):
        for k, l in combinations(range(N), 2):
            a, b, c, d = ys[i], ys[j], xs[k], xs[l]
            y1 = min(a[0], b[0])
            y2 = max(a[0], b[0])

            x1 = min(c[0], d[0])
            x2 = max(c[0], d[0])

            kkk = abs(x1 - x2) * abs(y1 - y2)
            if kkk < ans:
                # print(i, j)
                # print(x1, x2, abs(x1 - x2))
                # print(y1, y2, abs(y1 - y2))
                # print(ok(y1, y2, x1, x2, yd, yd2, xd, xd2, K))
                if ok(y1, y2, x1, x2, yd, yd2, xd, xd2, K):
                    ans = kkk

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 36248
k = int(input())
n = 7

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

ans = 1
while True:
    if n % k == 0:
        print(ans)
        exit()
    n = (n*10 + 7)%k
    ans += 1

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

int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(i % 2 == 0){
                    if(j % 2 == 0){
                        cout << "#";
                    }
                    else{
                        cout << ".";
                    }
                }
                else{
                    if(j % 2 == 0){
                        cout << ".";
                    }
                    else cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3084
#include <iostream>

int main() {
  int V[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int K;
  std::cin >> K;
  K--;

  std::cout << V[K] << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main(){
  int N;
  cin >> N;
  int a = N /100;
  int b = a*10 + a;
  if(b < N % 100){
    a++;
    a = a* 100 + a*10 + a;
    cout << a << endl;
  }
  else{
    a = a* 100 + a* 10 + a;
    cout << a << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, d;
    cin >> n >> d;
    cout << (n + 2 * d) / (2 * d + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
template<class T> void verr(const vector<T>& v){ for(auto& a : v) cout << a << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll a, b;
    cin >> a >> b;

    if(a+b==15)
        cout << '+' << endl;
    else if(a*b==15)
        cout << '*' << endl;
    else
        cout << 'x' << endl;
}

Measured memory_bytes: 384
import bisect

n,m,v,p=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr)
acum=[0]
for i in range(n):
  acum.append(acum[-1]+arr[i])
ans=0
for i in range(n):
  flag=False
  cnt=bisect.bisect_right(arr,arr[i])
  cnt2=bisect.bisect_right(arr,arr[i]+m)
  tv=v-cnt-min((p-1),n-cnt)
  rem=-1
  if cnt2<=n-p:
    ans+=0
  else:
    if tv<=0:
      ans+=1
      flag=True
    else:
      rem=acum[min(cnt2,n-(p-1))]-acum[cnt]
      if (arr[i]+m)*(min(cnt2,n-(p-1))-cnt)-rem>=m*tv:
        ans+=1
        flag=True
      else:
        ans+=0
print(ans)

Measured memory_bytes: 14252
// code author: Dhruva Mahajan
 
// Ideas are cheap, execution is everything.
 
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long  
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define testcase(t) int t;cin>>t;while(t--)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

int main(){
	
	fastio;

	ll h,a;
	cin>>h>>a;

	cout<<ceil((float)h/a)<<endl;


	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    char ch;
    while(1){
        scanf("%c", &ch);
        if('a' <= ch && ch <= 'z'){
            printf("%c", ch - 32);
        } else if('A' <= ch && ch <= 'Z'){
            printf("%c", ch + 32);
        } else {
            printf("%c", ch);
        }
        if(ch == '\n')break;
    }
    
    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
#define ll long long
const int mod=1e9+7;
ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
vector<ll> v1;
void div(ll n)
{
	for (ll i=2;i*i<=n;i++)
	{
		if (n%i==0)
		{
			v1.push_back(i);
			while (n%i==0)
			n/=i;
		}
	}
	if (n>1)
	v1.push_back(n);
}
int main()
{
	ll a;
	ll b;
	cin>>a>>b;
	ll temp=gcd(a,b);
	div(temp);
	cout<<v1.size()+1<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Jigsaw Puzzle
public class Main{

	int h, w, n;
	int[] puzzle;
	List<R>[] piece;
	boolean[] res;
	
	class R{
		int H, W;
		int[] p;
		String str;
		public R(int h, int w, char[][] m) {
			H = h;
			W = w;
			p = new int[H];
			str = "";
			for(int i=0;i<H;i++)for(int j=0;j<W;j++){
				p[i] = (p[i]<<1) + (m[i][j]=='#'?1:0);
				str+=m[i][j];
			}
		}
		boolean eq(R r){
			if(H!=r.H || W!=r.W)return false;
			return str.equals(r.str);
		}
	}
	
	char[][] rot(char[][] a){
		int H = a.length, W = a[0].length;
		char[][] res = new char[W][H];
		for(int i=0;i<H;i++)for(int j=0;j<W;j++)res[W-j-1][i] = a[i][j];
		return res;
	}
	
	void dfs(int i, int j, int U, int idx){
		if(j==w){
			dfs(i+1, 0, U, 0); return;
		}
		if(i==h){
			res[U] = true; return;
		}
		for(int u=idx;u<n;u++)if(((U>>u)&1)==0){
			for(R r:piece[u]){
				if(h < i+r.H || w < j+r.W)continue;
				boolean ok = true;
				for(int y=0;y<r.H;y++)if( (puzzle[i+y] & (r.p[y]<<(w-r.W-j))) != (r.p[y]<<(w-r.W-j))){
					ok = false; break;
				}
				if(!ok)continue;
				for(int y=0;y<r.H;y++){
					puzzle[i+y] -= (r.p[y]<<(w-r.W-j));
				}
				if(((puzzle[i]>>(w-j-1))&1)==0){
					dfs(i, j, U + (1<<u), u+1);
				}
				for(int y=0;y<r.H;y++){
					puzzle[i+y] |= (r.p[y]<<(w-r.W-j));
				}
				
			}
		}
		if(((puzzle[i]>>(w-j-1))&1)==0)
			dfs(i, j+1, U, 0);
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		piece = new List[10];
		for(;;){
			h = sc.nextInt(); w = sc.nextInt();
			if((h|w)==0)break;
			puzzle = new int[h];
			for(int i=0;i<h;i++){
				char[] s = sc.next().toCharArray();
				for(char c:s)puzzle[i] = (puzzle[i]<<1) + (c=='#'?0:1);
			}
			n = sc.nextInt();
			for(int i=0;i<n;i++){
				piece[i] = new ArrayList<R>();
				int H = sc.nextInt(), W = sc.nextInt();
				char[][] m = new char[H][];
				for(int j=0;j<H;j++)m[j]=sc.next().toCharArray();
				piece[i].add(new R(H, W, m));
				for(int k=0;k<3;k++){
					m = rot(m);
					int t = H;
					H = W; W = t;
					piece[i].add(new R(H, W, m));
				}
				for(int j=0;j<piece[i].size();j++)for(int k=j+1;k<piece[i].size();k++)if(piece[i].get(j).eq(piece[i].get(k))){
					piece[i].remove(k--);
				}
			}
			res = new boolean[1<<n];
			dfs(0, 0, 0, 0);
			int Q = sc.nextInt();
			while(Q--!=0){
				int k = sc.nextInt(), S = 0;
				while(k--!=0)S+=(1<<(sc.nextInt()-1));
				System.out.println(res[S]?"YES":"NO");
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod

# invt = InverseTable(mod, 10**6)

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass

n=int(input())
A=list(map(int,input().split()))
data=[0]*(10**6+10)
for ai in A:
    arr=prime_factor(ai)
    for ni,ci in arr:
        data[ni]=max(data[ni],ci)
pro=1
for i in range(1,len(data)):
    pro=pro*(i**data[i])
    pro%=mod

for ai in A:
    ans+=pow(ai,mod-2,mod)
print(ans*pro%mod)

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

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    for(int i = 0; i < h; i++)
        cin >> s[i];
    int t1[h][w], t2[h][w];
    memset(t1, 0, sizeof(t1));
    memset(t2, 0, sizeof(t2));
    for(int i = 0; i < h; i++){
        int c = 0;
        for(int j = 0; j < w; j++){
            if(s[i][j] == '.')
                c++;
            else{
                if(j - 1 >= 0 && s[i][j-1] == '.')
                    t1[i][j-1] = c;
                c = 0;
            }
        }
        if(s[i][w-1] == '.')
            t1[i][w-1] = c;
    }
    for(int j = 0; j < w; j++){
        int c = 0;
        for(int i = 0; i < h; i++){
            if(s[i][j] == '.')
                c++;
            else{
                if(i - 1 >= 0 && s[i-1][j] == '.')
                    t2[i-1][j] = c;
                c = 0;
            }
        }
        if(s[h-1][j] == '.')
            t2[h-1][j] = c;
    }
    
    for(int i = 0; i < h; i++){
        for(int j = w - 2; j >= 0; j--){
            if(s[i][j] != '#' && s[i][j+1] != '#'){
                t1[i][j] = t1[i][j+1];
            }
        }
    }
    for(int j = 0; j < w; j++){
        for(int i = h - 2; i >= 0; i--){
            if(s[i][j] != '#' && s[i+1][j] != '#'){
                t2[i][j] = t2[i+1][j];
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            ans = max(ans, t1[i][j] + t2[i][j]);
        }
    }
    cout << ans - 1;
    
    return 0;
}

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

int main(void) {
    int i,n,flag;
    scanf("%d",&n);
    for (i = n; i <n*2 ; ++i) {
        flag = 0;
        for (int j = 2; j < i; ++j) {
            if (i % j == 0)
                flag = 1;
        }
        if (flag == 0) {
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 128
from collections import deque


H,W = map(int, input().split())
S = [""] * H
b = 0

for i in range(H):
    s = input()
    b += s.count("#")
    S[i] = s

cost = [[0 for _ in range(W)] for _ in range(H)]
cost[0][0] = 1




q = deque()
q.append((0,0))
while q:
    y,x = q.popleft()

    if 0 <= x - 1 <= W - 1 and cost[y][x-1] == 0 and S[y][x-1] == ".":
        cost[y][x-1] = cost[y][x] + 1
        q.append((y, x-1))
    if 0 <= x + 1 <= W - 1 and cost[y][x+1] == 0 and S[y][x+1] == ".":
        cost[y][x+1] = cost[y][x] + 1
        q.append((y, x+1))

    if 0 <= y - 1 <= H - 1 and cost[y-1][x] == 0 and S[y-1][x] == ".":
        cost[y-1][x] = cost[y][x] + 1
        q.append((y-1, x))

    if 0 <= y + 1 <= H - 1 and cost[y+1][x] == 0 and S[y+1][x] == ".":
        cost[y+1][x] = cost[y][x] + 1
        q.append((y+1, x))

if cost[H-1][W-1] == 0:
    print(-1)
else:
    print(H*W - b - cost[H-1][W-1])


Measured memory_bytes: 3316
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int m = sc.nextInt();
      int[] data = new int[m];
      int count = 1;
      int ans = 0;

      for (int t = 0;t<m ;t++ ) {
        data[t] = sc.nextInt();
      }

      for (int i =0 ;i<m ;i++ ) {
          if(data[i]==count){
            count++;
          }else{
            ans++;
          }
        }

        if (count>1) {
          System.out.println(ans);
        }else{
            System.out.println("-1");
        }

}
}


Measured memory_bytes: 80912