akhauriyash/Code-Regression huggingface dataset:
/*
Author : N_o_o_B
Created : April 22 2020 21:39:23 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int a,b,c;
    cin >> a >> b >> c;
    int x;
    cin >> x;
    int ans = 0;
    for(int i=0;i<=a;i++) for(int j=0;j<=b;j++) for(int k=0;k<=c;k++){
        if((i*500+j*100+k*50)==x) ans++;
    }
    cout << ans << endl;


    time_taken();
    return 0;
}

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

const int white = 0, gray = 1, black = 2, N = 101, INF = -1;
bool G[N][N];
int n, color[N], d[N];

void init(){
    for (int i = 1; i <= n; i++)
    {
        color[i] = white;
        d[i] = INF;
    }
}

void bfs(int v){
    queue<int> q;
    q.push(v);
    d[v] = 0;
    int u;
    while (!q.empty())
    {
        u = q.front(); q.pop();
        for (int i = 1; i <= n; i++)
        {
            if (G[u][i] && color[i] == white)
            {
                d[i] = d[u] + 1;
                q.push(i);
                color[i] = gray;
            }
        }
    color[u] = black;
    }
}

int main(){
    int u, k, v;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> u >> k;
        for (int j = 1; j <= k; j++)
        {
            cin >> v;
            G[u][v] = 1;
        }
    }
    init();
    bfs(1);
    for (int i = 1; i <= n; i++)
    {
        cout << i << " " << d[i] << endl;
    }   
}


Measured memory_bytes: 3112
n,m = map(int, input().split())
arr = [list() for _ in range(n)]
for _ in range(m):
  a,b = map(int, input().split())
  arr[a-1].append(b)
  arr[b-1].append(a)
d = [0]*n
d[0] = 1
cnt = 0
def dfs(x):
  global cnt
  if all(d):
    cnt += 1
    return
  for i in arr[x-1]:
    if d[i-1] == 0:
      d[i-1] = 1
      dfs(i)
      d[i-1] = 0
dfs(1)
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
using namespace std;

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

typedef long long ll;

int main() {
	
	//入力;
	string s;
	cin >> s;
	vector<int> v;
	REP(i, 4) v.push_back(stoi(s.substr(i, 1)));

	REP(bit, 1 << 3) {
		int ans = 0;

		ans += v[0];

		REP(i, 3) {
			if (bit & 1 << i) { //記号+の時
				ans += v[i + 1];
			}
			else { //記号-の時
				ans -= v[i + 1];
			}
		}

		if (ans == 7) {

			cout << v[0];
			REP(i, 3) {
				if (bit & 1 << i) {
					cout << "+" << v[i + 1];
				}
				else cout << "-" << v[i + 1];
			}
			cout << "=7" << endl;
			
			return 0;
		}


	}

	cout << "no ans" << endl;

	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int n,m,t;
    scanf("%d%d%d",&n,&m,&t);
    int tt=max(n,m);
    int ans=0;
    if(t%tt!=0) ans++;
    cout<<ans+t/tt<<endl;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative

main = do
  d <- readLn 
  putStrLn $ func d

func :: Int -> String
func n
  |n == 25 = "Christmas"
  |n == 24 = "Christmas Eve"
  |n == 23 = "Christmas Eve Eve"
  |n == 22 = "Christmas Eve Eve Eve"


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k+1;i<=n;i++){
        ans+=n/i*(i-k);
        if(n-n/i*i>=k){
            ans+=n-n/i*i-k+(k!=0);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n=int(input())
#s=input()
#S=list(s)
V="abcdefghijklmnopqrstuvwxyz"
dp=[10000]*26
for i in range(n):
    t=input()
    T=list(t)
    for j in range(26):
        clue=max(0,T.count(V[j]))
        dp[j]=min(dp[j],clue)

ans=""
for j in range(26):
    ans=ans+V[j]*dp[j]

print(ans)

Measured memory_bytes: 3064
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let n = read_as_vec::<i32>()[0];

    if n == 1{
        println!("Hello World");
        return;
    }

    let a = read_as_vec::<i32>()[0];
    let b = read_as_vec::<i32>()[0];
    println!("{}", a+b);
}


Measured memory_bytes: 4352
def sol():
    N, Ma, Mb = map(int, input().split())

    A = []
    B = []
    cost = []
    sumA = 0
    sumB = 0

    for _ in range(N):
        a, b, c = map(int, input().split())
        A.append(a)
        B.append(b)
        cost.append(c)
        sumA += a
        sumB += b

    dp = [[[float('inf') for _ in range(sumB * 2 + 1)] for _ in range(sumA * 2 + 1)] for _ in range(N + 1)]
    dp[0][0][0] = 0

    for index in range(N):
        for sA in range(sumA + 1):
            for sB in range(sumB + 1):
                dp[index + 1][sA][sB] = min(
                    dp[index + 1][sA][sB],
                    dp[index][sA][sB]
                )
                dp[index + 1][sA + A[index]][sB + B[index]] = min(
                    dp[index + 1][sA + A[index]][sB + B[index]],
                    dp[index][sA][sB] + cost[index]
                )

    ans = float('inf')
    for sA in range(1, sumA):
        for sB in range(1, sumB):
            if sA * Mb == sB * Ma:
                ans = min(ans, dp[N][sA][sB])

    if ans == float('inf'):
        print('-1')
    else:
        print(ans)

sol()

Measured memory_bytes: 175196
use strict;
use warnings;

my $in = <>;
chomp $in;
my ($n, $m) = split(/ /, $in);

$in = <>;
chomp $in;
my @x = split(/ /, $in);

$in = <>;
chomp $in;
my @y = split(/ /, $in);

my $sum_x = 0;
my $sum_y = 0;
for(my $i = 0; $i < (@x - 1); $i++){
	my $area_x = (@x - ($i+1)) * ($i+1);
	$sum_x += ($x[$i+1] - $x[$i]) * $area_x;
}
for(my $j = 0; $j < (@y - 1); $j++){
	my $area_y = ((@y - ($j+1)) * ($j+1));
	$sum_y += ($y[$j+1] - $y[$j]) * $area_y;
}

$sum_x %= ((10 ** 9) + 7);
$sum_y %= ((10 ** 9) + 7);
print (($sum_x * $sum_y) % ((10 ** 9) + 7));
print "\n";


exit;


Measured memory_bytes: 27684
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int n; cin>>n;
    ll p = 1;
    rep(i, n)
    {
        p *= (i + 1);
        p %= mod;
    }
    cout << p << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int N = 1e6 + 6;
pair <int, int> a[N];
int main(){
    int n, m, s;
    cin >> n >> m >> s;
    n = max(n, m);
    cout << (s + n - 1) / n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

int main(void)
{
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n);
    for (ll i = 0; i < n;i++){
        cin >> x[i];
    }
    ll ans = mod;
    for (ll i = 0; i < n - k + 1;i++){
        ans = min(ans, x[i + k - 1] - x[i] + abs(x[i]));
        ans = min(ans, x[i + k - 1] - x[i] + abs(x[i + k - 1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define fi first
#define se second
using namespace std;

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



int main() {

	int h, w, n, a;
	int ans[100][100] = {};
	int dir = 0, x=0, y=0;

	cin >> h >> w >> n;
	rep(i, 0, n) {
		cin >> a;
		rep(j, 0, a) {
			ans[y][x] = i + 1;
			if (dir == 0) {
				if (x == w - 1) {
					y++;
					dir = 1;
				}
				else x++;
			}
			else {
				if (x == 0) {
					y++;
					dir = 0;
				}
				else x--;
			}
		}
	}
	rep(i, 0, h) {
		rep(j, 0, w) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = 5;
		long minute[] = new long[num];
		long rest[] = new long[num];
		long time = 0;
		for(int i = 0; i < num; i ++) {
			minute[i] = sc.nextLong();
			long need = (long)Math.ceil(minute[i] / 10.0) * 10;
			rest[i] = need - minute[i];
			time += need;
		}
		Arrays.sort(rest);
		time -= rest[num - 1];
		System.out.println(time);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	string s; cin >> s;
	if(s=="AAA"||s=="BBB") cout << "No" << endl;
	else cout << "Yes" << endl;
}




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

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

template<class T> inline T sqr(T x) {return x*x;}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

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

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

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

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

int main(void){
    int N; cin >> N;
    VI a(N); REP(i,N) cin >> a[i];
    int ans = 0;
    REP(i,N){
        while(a[i]%2 == 0){
            a[i] >>= 1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 233;
int exgcd(int a,int b,int& x,int &y){
	if(b==0){
		x = 1;y = 0;
		return a;
	}
	int d = exgcd(b,a%b,y,x);
	y -= (a/b)*x;
	return d;
}
ll inv(int i){
	int x,y;
	exgcd(i,mod,x,y);
	return (x+mod)%mod;
}
int p[maxn],u[maxn],vis[maxn],cnt=0;
void init(){
	memset(vis,0,sizeof(vis));
	int n = 1e3;
	u[1] = 1;
	for(int i=2;i<=n;i++){
		if(!vis[i]){p[++cnt] = i;u[i] = -1;}
		for(int j=1;j<=cnt&&i*p[j]<=n;j++){
			if(i%p[j]==0){
				u[i*p[j]] = 0;
				vis[i*p[j]] = 1;
				break;
			}
			else{
				u[i*p[j]] = -u[i];
				vis[i*p[j]] = 1; 
			} 
		}
	}
//	for(int i=1;i<=30;i++)
//		cout<<i<<": "<<u[i]<<" "<<vis[i]<<endl;
	return ;
}
set<int> s;
int maxi[maxn];
void work(int x){
	for(int i=1;i<=cnt;i++){
		int cur = 0;
		while(x%p[i]==0){
			cur++;
			x/=p[i];
		}
		maxi[i] = max(maxi[i],cur);
	}
	if(x>1)s.insert(x);
} 
int a[maxn];
int main()
{
	init();
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		work(x);
		a[i] = x;
	}
	ll lcm = 1;
	for(int i=1;i<=cnt;i++){
		for(int j=1;j<=maxi[i];j++){
			lcm = lcm*p[i]%mod;
		}
	}
	for(auto x:s){
		lcm = x*lcm%mod;
	}
	ll ans = 0;
	for(int i=1;i<=n;i++){
		ans = (ans+lcm*inv(a[i]))%mod;
//		cout<<a[i]<<" "<<inv(a[i])<<" "<<inv(a[i])*a[i]%mod<<endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15104
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]


n,m = map(int,input().split())
#初期化
#根なら-size,子なら親の頂点
par = [-1]*n


for i in range(m):
    a,b = map(int,input().split())
    unite(a-1,b-1)
ans = set()
for i in range(n):
    ans.add(find(i))
print(len(ans)-1)


Measured memory_bytes: 17908
#include<stdio.h>
int main(void){
	
	long long int n,i,ans = 100000;

	scanf("%lld", &n);
	for(i=0; i<n; i++){
		ans =ans * 1.05;
		if(ans % 1000 > 0){
			ans = ans /1000 * 1000 + 1000;

		}
	
	}
	printf("%lld\n", ans);
	return 0;

}


Measured memory_bytes: 1976
#include<bits/stdc++.h>
using namespace std;
int r[]={1799,1599,1399,1199,999,799,599,399};
int main(){
	int x;
	cin>>x;
	for(int i=0;i<8;i++){
	    if(x>r[i]){
	        cout<<i+1<<endl;
	        return 0;
	    }
	}
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b;
    cin >> a >> b;
    bool q=a%b;
    a=q;
    cout << q << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<complex>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(C)   (C).begin(),(C).end()
#define pb push_back
#define NEXT(i,n) ((i+1)%(n))

const int W = 10,H=60;
const int N = 200;

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

int tree[H][W];
int m[H][W];

class Piece{
public:
  int id;
  int cur;
  int x[4],y[4];
  vector<int> next;
  bool isok(double center){
    int miny = 100000;
    double minx=1000000,maxx=-100000;
    rep(i,4){
      if (y[i] == 0 ){
	if (x[i] < minx)minx=x[i];
	if (x[i] > maxx)maxx=x[i];
      }else if (tree[y[i]-1][x[i]] != -1 && tree[y[i]-1][x[i]] != id){
	if (x[i] < minx)minx=x[i];
	if (x[i] > maxx)maxx=x[i];
      }
    }
    
    if (minx < center && center < maxx+1)return true;
    else return false;
  }
};

Piece in[N];

  
void localdfs(int id,int num,int x,int y,int r,int c){
  tree[y][x]=id;
  in[id].x[in[id].cur  ]=x;
  in[id].y[in[id].cur++]=y;
  
  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (nex==-1||ney == -1 || nex == c || ney == r||
	tree[ney][nex] != -1||m[ney][nex] != num)continue;
    localdfs(id,num,nex,ney,r,c);
  }
}


bool vis[N];
void globaldfs(int id,vector<double> & X,int r){
  vis[id]=true;
  rep(i,4){
    X.push_back(in[id].x[i]+0.5);
  }
  
  rep(i,4){
    int nex=in[id].x[i],ney=in[id].y[i]+1;
    if (ney == r||m[ney][nex] == -1||tree[ney][nex] == id
	|| vis[tree[ney][nex]])continue;
    globaldfs(tree[ney][nex],X,r);
  }
}

bool solve(int n,int r,int c){
  rep(i,n){
    vector<double> allx;
    rep(j,n)vis[j]=false;
    globaldfs(i,allx,r);
    
    double sum = accumulate(ALL(allx),0.0);
    double average=sum/allx.size();
    if (!in[i].isok(average))return false;
  }
  return true;
}


main(){
  int c,r;
  while(cin>>c>>r && r){
    //ini
    rep(i,N)in[i].cur=0,in[i].next.clear(),in[i].id=i;
    rep(i,H)rep(j,W)tree[i][j]=-1;

    //get input
    string tmp[r];
    rep(i,r)cin>>tmp[i];
    reverse(tmp,tmp+r);
    rep(i,r){
      rep(j,c){
	if (tmp[i][j] == '.')m[i][j]=-1;
	else m[i][j]=tmp[i][j]-'0';
      }
    }

    int n = 0;
    rep(i,r){
      rep(j,c){
	if (m[i][j] != -1 && tree[i][j] == -1){
	  localdfs(n,m[i][j],j,i,r,c);	  
	  n++;
	}
      }
    }

    if (solve(n,r,c))puts("STABLE");
    else puts("UNSTABLE");
  }
  return false;
}

Measured memory_bytes: 0
// review
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
int n;
ll a, b;
ll h[100010];

bool check(ll x) {
  ll damage = x * b;
  ll cnt = 0;
  for (int i=0;i<n;i++) {
    if (h[i] - damage > 0) {
      cnt += ceil((double)(h[i] - damage) / (a-b));
    }
  }
  return cnt <= x;
}

void solve() {
  sort(h, h + n);
  ll low = 0, high = h[n-1] + 1;

  while (high - low > 1) {
    ll mid = (high + low) / 2;
    if (check(mid)) {
      high = mid;
    } else {
      low = mid;
    }
  }

  cout << (low + 1) << endl;
}

int main() {
  cin >> n >> a >> b;
  for (int i=0;i<n;i++) {
    cin >> h[i];
  }
  solve();
}


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

int main () {
	int n;
	while (cin >> n, n) {
		pair<double, string> crops[n];
		for (int i = 0; i < n; i++) {
			string L;
			int P, A, B, C, D, E, F, S, M;
			cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
			double t = A + B + C + (D + E) * M;
			crops[i].first = -(F * M * S - P) / t;
			crops[i].second = L;
		}
		sort(crops, crops + n);
		for (int i = 0; i < n; i++) {
			cout << crops[i].second << endl;
		}
		cout << '#' << endl;
	}
	return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
	  y=x;
	  if(z->key < x->key) x=x->left;
	  else x=x->right;
	  }
  z->parent=y;
  if(y==NIL) root=z;
  else if(z->key < y->key) y->left=z;
  else y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
	  inorder(u->left);
	  printf(" %d",u->key);
	  inorder(u->right);
	  }
}
void preorder(Node u){
  if(u!=NIL){
	  printf(" %d",u->key);
	  preorder(u->left);
	  preorder(u->right);
	  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

int main() {
    ll D,G;
    cin >> D >> G;
    vector<ll>P(D),C(D);
    for(int i=0;i<D;i++){
        cin >> P[i] >> C[i];
    }
    ll ans=(1LL<<60);
    for(int i=0;i<(1<<D);i++){
        ll tmp=i;
        vector<ll> Q;
        for(int j=0;j<D;j++){
            if(tmp&1){
                Q.push_back(j);    
            }
            tmp>>=1;
        }
        sort(Q.begin(),Q.end());
        do{
            ll sum=0;
            ll ct=0;
            for(int i=0;i<Q.size();i++){
                if(sum>=G){
                    ans=min(ans,ct);
                    break;
                }
                if(sum+(Q[i]+1)*100*P[Q[i]]<G) {
                    sum+=(Q[i]+1)*100*P[Q[i]]+C[Q[i]];
                    ct+=P[Q[i]];
                }
                else{
                    ct+=ceil((double)(G-sum)/((Q[i]+1)*100));
                    ans=min(ans,ct);
                    break;
                }
            }
            if(sum>=G) ans=min(ans,ct);
        }while(next_permutation(Q.begin(),Q.end()));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb emplace_back
#define pob pop_back
#define ff first
#define ss second
typedef long long int ll;
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define vcc vector<char>
#define vss vector<string>
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define test ll t; cin>>t; while(t--)
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
        ll n,i,j,w;
        cin>>n>>w;
        vll W(n+1),V(n+1);
        for(i=1;i<=n;i++)
        {
            cin>>W[i]>>V[i];
        }
        ll dp[n+1][w+1];
        for(i=0;i<=n;i++)
        dp[i][0]=0;
        for(i=0;i<=w;i++)
        dp[0][i]=0;
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=w;j++)
            if(W[i]<=j)
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-W[i]]+V[i]);
            }
            else
            dp[i][j]=dp[i-1][j];
        }
        cout<<dp[n][w];
    
}

Measured memory_bytes: 79232
import Data.List
import Text.Printf
nextPyramid (x,y) = if y+1<101 then (x,y+1) else if x+1<101 then (x+1,0) else (-1,-1)
listToTuple [x,y,z] = (-z,x,y)

check::(Integer,Integer)->[(Integer,Integer,Integer)]->Integer->Integer
check (x,y) (d:ds) h
    | h==0 && c/=0 = check (x,y) ds (abs (a-x) + abs (b-y) + c)
    | c==tmp = if ds==[] then h else check (x,y) ds h
    | otherwise = -1
    where
        (g,a,b) = d
        c = -g
        tmp = max (h - abs (a-x) - abs (b-y)) 0

solve (-1,-1) tbl = (-1,-1,-1)
solve (x,y) tbl
    | ans == (0-1) = solve (nextPyramid (x,y)) tbl
    | otherwise = (x,y,ans)
    where
        ans = check (x,y) tbl 0

main::IO()
main=do
    getLine
    tbl <- map (listToTuple.map read.words) . lines <$> getContents :: IO [(Integer,Integer,Integer)]
    let (x,y,h) = solve (0,0) (sort tbl)
    printf "%d %d %d\n" x y h

Measured memory_bytes: 1020
#include<stdio.h>
int main(void)
{
	while(1){
		int n,i,j=0,t[10]={0},fi=0,bum;
		char c[201];
		scanf("%d",&n);
		if(n==0){
			break;
		}
		scanf("%s",c);
		for(i=0;i<100;i++){
			t[j]++;
			if(c[i]=='S'){
				fi=fi+t[j];
				t[j]=0;
			}
			if(c[i]=='L'){
				t[j]=t[j]+fi;
				fi=0;
			}
			j++;
			if(j==n){
				j=0;
			}
		}
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				if(t[i]>t[j]){
					bum=t[i];
					t[i]=t[j];
					t[j]=bum;
				}
			}
		}
		for(i=0;i<n;i++){
			printf("%d ",t[i]);
		}
		printf("%d\n",fi);
	}
	return 0;
}

Measured memory_bytes: 604
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
(__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    vi X(5);
    REP(i, 5)
        cin >> X[i];
    REP(i, 5) {
        if (X[i] != i + 1) {
            cout << i + 1;
            return;
        }
    }
}

#pragma region main
main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3600
using System;
using System.Linq;

class Program {
  static void Main() {
    var n = int.Parse(Console.ReadLine());
    var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
    var ans = int.MaxValue;
    for (int i = 1; i < n; i++) {
      ans = Math.Min(ans, Math.Abs(a.Take(i).Sum() - a.Skip(i).Sum()));
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll r, g, b;
  cin >> r >> g >> b;
  ll num = r * 100 + g * 10 + b;
  if(num % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;

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

    if (s == "ABC")
    {
        s = "ARC";
    }
    else
    {
        s = "ABC";
    }
    cout << s << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <math.h>

#define N 1000000
using namespace std;

int main(){
	int n;
	int arr[N];

	for(int i=0;i<N;i++){
		arr[i]=1;
	}
	for(int i=2;i<sqrt(N);i++){
		if(arr[i]){
			for(int j=0;i*(j+2)<N;j++){
				arr[i*(j+2)]=0;
			}
		}
	}
	while(true){
		cin >> n;
		if(n==0){
			break;
		}
		int cnt=0;
		int sum=0;
		for(int i=2;i<N;i++){
			if(arr[i]!=0){
				sum+=i;
				cnt++;
				}
			if(cnt==n){
				break;
				}
		}
		cout << sum << endl;
		}
		
	return 0;
	}

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

using namespace std;

const int N = 1e5 + 5;

int score[N];

int main() {
  int n, k, q, red = 0;
  cin >> n >> k >> q;
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    red++, score[x]++;
  }
  for (int i = 1; i <= n; i++) {
    score[i] += k;
    score[i] -= red;
    puts(score[i] > 0 ? "Yes" : "No");
  }
  return 0;
}


Measured memory_bytes: 1024
import sys

def main():
    N = int(input())
    A = [int(_) for _ in input().split()]

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] //= 2
            else:
                print(t)
                sys.exit()
        t += 1

main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int D;
int s[367][27];
int c[27];
int last[27];

int main()
{
    cin >> D;
    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }
    for (int i = 1; i <= D; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
            last[j] = 0;
        }
    }
    vector<int> t;
    ll score, maxi, maxj, tmp;
    int best_i;

    for (int day = 1; day <= D; day++)
    {
        maxi = LLONG_MIN;
        best_i = -1;
        //dayまでのコスト計算
        for (int item = 1; item <= 26; item++)
        {
            score = s[day][item];
            for (int k = 1; k <= 26; k++)
            {
                score -= c[k] * (day - (k == item ? day : last[k]));
            }
            //dayからD日までのコスト計算
            maxj = LLONG_MIN;
            for (int j = day; j <= day + 26; j++)
            {

                tmp = score;
                for (int k = 1; k <= 26; k++)
                {
                    tmp -= c[k] * (j - (k == item ? j : last[k]));
                }
                if (tmp > maxj)
                {
                    maxj = tmp;
                }
            }
            score = maxj;
            if (score > maxi)
            {
                maxi = score;
                best_i = item;
            }
        }
        t.push_back(best_i);
        last[best_i] = day;
    }

    for (int i = 0; i < t.size(); i++)
    {
        cout << t[i] << endl;
    }
    return 0;
}


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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 1e5 + 10;
using namespace std;
set<int> st;

bool valid(int n) {
    string s = to_string(n);
    map<char, int> cnt;
    for (auto i:s) cnt[i]++;
    return cnt['3'] > 0 and cnt['5'] > 0 and cnt['7'] > 0;
}

void solve(int pos, int n) {
    if (pos == 10) return;
    if (valid(n)) st.insert(n);
    solve(pos + 1, n * 10 + 3);
    solve(pos + 1, n * 10 + 5);
    solve(pos + 1, n * 10 + 7);

}

int main() {
    IO;
    int n;
    cin >> n;
    solve(0, 0);
    int cnt = 0;
    for (auto i:st) {
        if (i > n) break;
        cnt++;
    }
    cout << cnt;
}


Measured memory_bytes: 4936
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, k = LI()
    rsp = LI()
    t = S()
    dp = [[0] * 3 for i in range(n + k)]
    j = ["r", "s", "p"]
    for i in range(n):
        ti = t[i]
        for l in range(3):
            dp[i + k][l] = max(dp[i][(l - 1) % 3], dp[i][(l + 1) % 3]) + (rsp[l] if (j.index(ti) - 1) % 3 == l else 0)

    ans = 0
    for i in range(k):
        ans += max(dp[n + i])
    print(ans)

    return


#main
if __name__ == '__main__':
    solve()


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

int main(){
    bool check[26];
    string s;
    int i;
    for(i=0; i<26; i++){
        check[i] = false;
    }

    cin >> s;
    for(i=0; i<s.length(); i++){
        check[(int)(s[i]-'a')] = true; 
    }

    for(i=0; i<26; i++){
        if(!check[i]){
            cout << (char)('a' + i);
            return 0;
        }
    }

    cout << "None";
    return 0;
}

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

int main()
{
    int N;
    int A[200];
    int kaisuu = 0;

    cin >> N;

   for (int i = 0; i < N; i++){
        cin >> A[i];    
   }
     
   while (1){
        for (int i = 0; i < N; i++){
            if (A[i] % 2 != 0){
                cout << kaisuu << endl;
                return (0);
            }
            else {
                A[i] = A[i] / 2;
            }
        }
        kaisuu++;
    }
}

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

using namespace std;
#define ll long long
const int N=2e5+5,mod=1e9+7;
ll dp[N];
ll fp(ll b,ll p)
{
    if(p==0) return 1;
    ll t=fp(b,p/2);
    if(p%2==0) return t*t%mod;
    return t*t%mod*b%mod;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i>=1;i--)
    {
        int cnt=1;
        for(int j=i+i;j<=k;j+=i)
            cnt++;
        dp[i]=fp(cnt,n);
        for(int j=i+i;j<=k;j+=i)
            dp[i]=((dp[i]-dp[j])%mod+mod)%mod;
        ans+=dp[i]*i%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4396
# -*- coding: utf-8 -*-
# ABC086 C Traveling
def main():
    n = int(input().strip())
    z = [[int(i) for i in input().split()] for _ in range(n)]

    def func(z, z0):
        t0, x0, y0 = z0
        t, x, y = z
        dist = abs(x - x0) + abs(y - y0)
        t = t - t0
        if dist > t:
            return False

        if dist % 2 == t % 2:
            return True
        else:
            return False

    z = [[0, 0, 0]]  + z
    for i in range(1, len(z)):
        if not func(z[i], z[i-1]):
            print("No")
            return

    print("Yes")
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 61528
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	fmt.Println((a - c) * (b - d))
}


Measured memory_bytes: 640
t = input()
for _ in range(int(input())):
    order = input().split()
    cmd = order[0]
    a, b = map(int,  order[1:3])
    if cmd == 'print':
        print(t[a:b+1])
    elif cmd == 'reverse':
        t = t[:a] + t[a:b+1][b::-1] + t[b+1:]
    else:
        c = order[3]
        t = t[:a] + c + t[b+1:]



Measured memory_bytes: 5612
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double res = sqrt(pow(y1 - y2, 2) + pow(x1 - x2, 2));
  cout << fixed << res << endl;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

vec par(2e5+10);
map<ll,ll> si;
void init(ll n) {
  for(ll i=0;i<n;i++) {
    par[i]=i;
    si[i]++;
  }
}

ll root(ll x) {
  if(par[x]==x) {
    return x;
  }
  else {
    return par[x]=root(par[x]);
  }
}

ll size(ll x) {
  return si[root(x)];
}

bool same(ll x, ll y) {
  return root(x)==root(y);
}

void unite(ll x, ll y) {
  if(same(x,y)) return;
  ll temp=size(x);
  si[root(y)]+=temp;
  si[root(x)]=0;
  par[root(x)]=root(y);
}

int main() {
  string s,t;
  cin >> s >> t;
  ll n=s.size();
  map<ll,ll> cs,ct;
  for(ll i=0;i<n;i++) {
    if(cs[s[i]]) {
      if(cs[s[i]]!=t[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
    cs[s[i]]=t[i];
    if(ct[t[i]]) {
      if(ct[t[i]]!=s[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
    ct[t[i]]=s[i];
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 2436
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int N = 55;
int mat[N][N];
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const int INF = 1000;

int main() {
	int w, d, n;
	scanf("%d%d%d", &w, &d, &n);
	priority_queue<PII> pque;
	fill(mat[0], mat[N], -INF);
	for(int i=0; i<n; i++) {
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		x--, y--;
		mat[x][y] = z;
		pque.push(MP(z, x*d+y));
	}
	int ans=0;
	bool ok=true;
	while(!pque.empty()) {
		int z=pque.top().F;
		int x=pque.top().S/d, y=pque.top().S%d;
		pque.pop();
		ans += z;
		for(int i=0; i<4; i++) {
			int tx=x+dx[i], ty=y+dy[i];
			if(tx<0 or tx>=w or ty<0 or ty>=d)
				continue;
			if(mat[tx][ty] > -INF) {
				if(z-mat[tx][ty] > 1) {
					ok=false;
					while(!pque.empty())
						pque.pop();
					break;
				}
				continue;
			}
			mat[tx][ty] = z-1;
			pque.push(MP(z-1, tx*d+ty));
		}
	}
	if(!ok)
		puts("No");
	else
		printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3240
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

char str[200]={};

int main()
{
  int i,j;

  while(scanf("%s",str)!=EOF){
    rep(i,strlen(str)){
      if(str[i]=='@'){
	int n=str[i+1]-'0';
	rep(j,n)
	  cout<<str[i+2];
	i+=2;
      }else
	cout<<str[i];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> P(n), pos(n);
  rep(i, n) {
    cin >> P[i];
    P[i]--;
    pos[P[i]] = i;
  }
  pos.push_back(-1);
  int l = 0;
  int mx = 0;
  rep(r, n) {
    if(pos[r] > pos[r+1]) {
      mx = max(r-l+1, mx);
      l = r+1;
    }
  }
  cout << n-mx << "\n";
  return 0;
}


Measured memory_bytes: 5572
#include<bits/stdc++.h>
using namespace std;
 
#define             ll  long long
#define            ull  unsigned long long
#define            P_B  push_back
#define            M_P  make_pair
#define         DBG(x)  printf("%s %d\n", #x, x)
#define       DBGLL(x)  printf("%s %lld\n", #x, x)
#define         SCI(x)  scanf("%d",&x)
#define         SCD(x)  scanf("%lf",&x)
#define         SCS(x)  scanf("%s",x)
#define         CLR(x)  memset(x, 0, sizeof(x))
#define        CLRN(x)  memset(x, -1, sizeof(x))
#define        SCLL(x)  scanf("%lld", &x)
#define      FOR(i, n)  for(int i = 0; i < n; i++)
#define  FORR(i, m, n)  for(int i = m; i < n; i++)
#define     SCI2(m, n)  scanf("%d%d", &m, &n)
#define  SCI3(m, n, o)  scanf("%d%d%d",&m, &n, &o)
#define     SCD2(m, n)  scanf("%lf%lf",&m,&n)
#define  SCD3(m, n, o)  scanf("%lf%lf%lf",&m,&n,&o)
#define    SCLL2(m, n)  scanf("%lld%lld", &m, &n)
#define SCLL3(m, n, o)  scanf("%lld%lld%lld",&m, &n, &o)
#define             vi  vector<int>
#define            vii  vector<pair<int, int> >
#define            vll  vector<pair<ll, ll> >
#define            Mod  998244353
#define            INF  1000000000
 
int n;
int w[105][2];
int m;
int dp[105];
int fl[105];

int main()
{
	CLR(fl);	
	int hudai = SCI2(n, m);
	FOR(i, n)hudai = SCI2(w[i][0], w[i][1]);
	int x[100005];
	CLRN(x);
	FOR(i, n){
		for(int j = 100000; j > 0; j--){
			if(x[j] != -1){
				if(x[j] + w[i][0] <= m){
					if(x[j + w[i][1]] != -1)
						x[j + w[i][1]] = min(x[j] + w[i][0], x[j+w[i][1]]);
					else
						x[j + w[i][1]] = x[j] + w[i][0];
				}
			}
		}
		if(w[i][0] <= m){
			if(x[w[i][1]] != -1)x[w[i][1]] = min(x[w[i][1]], w[i][0]);
			else x[w[i][1]] = w[i][0];
		}
	}
	int y = 0;
	for(int i = 100000; i >= 0; i--) 
		if(x[i] > 0){
			y = i;
			break;	
		}
	printf("%d\n", y);
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
//	file();
	fast();
	int n; cin >> n;
	vi v1(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> v1[i];
	ll ans = 0;
	map<int, int> mp;
	for (int i = 1; i <= n; i++) {
		ans += mp[i - v1[i]];
		mp[i + v1[i]]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 21132
from functools import reduce
# import math
import fractions
# from gcd import fractions

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N, X = (int(_) for _ in input().split())
    x = list(int(_) for _ in input().split())
    x.append(X)
    x.sort()
    x_diff = []
    for i in range(N):
        x_diff.append(x[i+1]-x[i])
        if i != 0:
            ans = fractions.gcd(x_diff[i],ans)
        else:
            ans = fractions.gcd(x_diff[i],x_diff[i-1])
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 16304
import java.util.*;
//import java.io.*;
import java.util.stream.IntStream;

public class Main{
    static int sum=0;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
        Vector p0 = new Vector(sc.nextInt(), sc.nextInt());
        Vector p1 = new Vector(sc.nextInt(), sc.nextInt());
        int n = sc.nextInt();
        for(int i=0; i<n; i++){
            Vector p2 = new Vector(sc.nextInt(), sc.nextInt());

            int iAns = Vector.ccw(p0,p1,p2);
            String ans="";
            switch (iAns) {
                case Vector.COUNTER_CLOCKWISE: ans = "COUNTER_CLOCKWISE";break;
                case Vector.CLOCKWISE: ans = "CLOCKWISE";break;
                case Vector.ONLINE_BACK: ans = "ONLINE_BACK";break;
                case Vector.ONLINE_FRONT: ans = "ONLINE_FRONT";break;
                case Vector.ON_SEGMENT: ans = "ON_SEGMENT";break;
                default:break;
            }
            System.out.println(ans);

        }

    }
}

class Vector{
    public static final double EPS = 1e-10;
    public static final int COUNTER_CLOCKWISE=1;
    public static final int CLOCKWISE=-1;
    public static final int ONLINE_BACK=2;
    public static final int ONLINE_FRONT=-2;
    public static final int ON_SEGMENT=0;

    public double x,y;

    public Vector(){}
    public Vector(double x, double y){this.x=x;this.y=y;}

    public Vector plus(Vector p){return new Vector(this.x+p.x, this.y+p.y);}
    public Vector minus(Vector p){return new Vector(this.x-p.x, this.y-p.y);}
    public Vector multiple(double a){return new Vector(this.x*a, this.y*a);}
    public Vector divide(double a){return new Vector(this.x/a, this.y/a);}

    public double abs(){return Math.sqrt(this.norm());}
    public double norm(){return x*x+y*y;}

    
    public static double dot(Vector a, Vector b){
        return a.x*b.x+a.y*b.y;
    }

    public static double cross(Vector a, Vector b){
        return a.x*b.y-a.y*b.x;
    }

    //point.projectで垂線の足の座標
    public Vector project(Vector seg1, Vector seg2){
        Vector seg = seg2.minus(seg1);
        Vector relPoint = this.minus(seg1);
        double t = dot(seg, relPoint)/seg.norm();
        return seg1.plus(seg.multiple(t));
    }
    
    //point.reflectionで対称点
    public Vector reflection(Vector seg1, Vector seg2){
        Vector projected = this.project(seg1, seg2);
        Vector ashi = projected.minus(this);
        return this.plus(ashi.multiple(2));
    }

    //p0が始点
    public static int ccw(Vector p0, Vector p1, Vector p2){
        Vector s1 = p1.minus(p0);
        Vector s2 = p2.minus(p0);

        double cross = Vector.cross(s1, s2);
        double dot = Vector.dot(s1, s2);

        if(cross>0){return COUNTER_CLOCKWISE;}
        if(cross<0){return CLOCKWISE;}
        if(dot<0){return ONLINE_BACK;}
        if(s1.abs()<s2.abs()){return ONLINE_FRONT;}
        return ON_SEGMENT;
    }
}


Measured memory_bytes: 34128
import java.util.Scanner;
public class Main {
public static void main(String[]args){
double x = Math.PI;
Scanner s = new Scanner(System.in);

double r = s.nextDouble();
double a = 2 * Math.PI * r;
double b = Math.PI * r * r;
System.out.println( String.format( "%.7f ", b ) + " " + String.format( "%.7f ", a ) );

s.close();

}

}


Measured memory_bytes: 28124