akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using LL = long long;
using PII = pair<int, int>;
using ll = long long;
using DBL = double;
using VI = vector<int>;
using VD = vector<DBL>;
using VVI = vector<VI>;
using VVD = vector<VD>;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define ST first
#define ND second

//#define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
//template<typename Arg> void __f(const char* name, Arg&& arg) {
//  cerr << name << " = " << arg << std::endl;
//} template <typename Arg1, typename... Args>
//void __f(const char* names, Arg1&& arg1, Args&&... args) {
//  const char* comma = strchr(names + 1, ',');
//  cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; // OST: find_by_order, order_of_key
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//#pragma GCC optimize("Ofast")
//optimize("unroll-loops")
//target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
///*** RNGS ***/
//SEED=chrono::steady_clock::now().time_since_epoch().count();
//// or high_resolution_clock
//mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
//uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
//struct chash {int operator()(int x) const {return x^SEED;}};
//gp_hash_table<int,int,chash>m;//use cc if very less updates
///*** FAST IO ***/
//inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
//while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();}
//while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
//return y?-x:x; }

const int MAXN = 100010;
const int MOD = 1000000007;

vector<int> g[MAXN];
int dp[2][MAXN];

int calc(int u, int par, int col) {
    int &y = dp[col][u];
    if(y != -1) return y;
    y = 1;
    for(auto&v: g[u]) {
        if(v == par) continue;
        if(col == 0) {
            //black
            y = (y * 1ll * calc(v, u, 1)) % MOD;
        }
        else if(col == 1) {
            //white
            y = (y * 1ll * (calc(v, u, 1) + calc(v, u, 0))) % MOD;
        }
    }
    return y;
}

int main() {
    #ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
//    freopen("sample.out", "w", stdout);
    #else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #endif
    memset(dp, -1, sizeof(dp));
    int n;
    cin >> n;
    for(int i=1; i<n; ++i) {
        int x, y;
        cin >> x >> y;
        g[x].PB(y);
        g[y].PB(x);
    }
    cout << (calc(1, 0, 0) + calc(1, 0, 1)) % MOD << endl;
	return 0;
}


Measured memory_bytes: 18152
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys
import math


def _ia():
    return [int(x) for x in sys.stdin.readline().strip().split()]


h, n = _ia()
ab = [_ia() for _ in range(n)]
m_max = math.ceil(h / ab[0][0]) * ab[0][1]
h1 = h + 1
dp = [
    [0] + [m_max + 1] * h for i in range(n + 1)
]
for i in range(n):
    ai, bi = ab[i]
    for j in range(1, h1):
        if j >= ai:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - ai] + bi, dp[i + 1][j - ai] + bi)
        else:
            dp[i + 1][j] = min(dp[i][j], bi)
print(dp[n][h])


Measured memory_bytes: 128624
readints()=parse.(Int,split(readline()))
readint()=parse.(Int,readline())
function main()
    Nmax=10^5
    N=readint()
    A=readints()

    Acount=zeros(Int,Nmax)
    for i in 1:N
        Acount[A[i]]+=1
    end

    Q=readint()
    B=zeros(Int,Q)
    C=zeros(Int,Q)
    for i in 1:Q
        B[i],C[i]=readints()
    end

    tmp=copy(A)
    sum1=sum(tmp)
    for i in 1:Q
        b,c=B[i],C[i]
        sum1+=(c-b)*Acount[b]
        println(sum1)
        Acount[c]+=Acount[b]
        Acount[b]=0
    end
end
main()

Measured memory_bytes: 213760
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    
    int[] h = new int[n];
    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
      if (h[i] >= h[i+1]) {
        cnt++;
        ans = Math.max(cnt, ans);
      } else {
        cnt = 0;
      }
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 53276
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)

int main() {
    ll k, g = 3234566667;
    cin >> k;
    set<ll> t;
    stack<ll> s;
    rep(i, 9)s.push(i + 1);
    while (!s.empty()) {
        auto a = s.top();
        s.pop();
        if (a > g) continue;
        t.insert(a);
        ll b = a % 10;
        a *= 10;
        if (b != 0) s.push(a + b - 1);
        s.push(a + b);
        if (b != 9) s.push(a + b + 1);
    }
    auto itr = t.begin();
    rep(i, k - 1)itr++;
    cout << *itr << endl;
}




Measured memory_bytes: 4992
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll h[n];rep(i,0,n-1)cin>>h[i];
    ll dp[n];rep(i,0,n-1)dp[i]=inf;
    dp[0]=0;
    rep(i,1,n-1){
        rep(j,i-2,i-1){
            if(j>=0)Min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    
    return 0;
}



Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i,0,n)
#define BFOR(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define BREP(bit,n) BFOR(bit,0,n)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  REP(i,n) cout << "ACL";
  cout << endl;

}

Measured memory_bytes: 3624
from collections import Counter
N = int(input())

def trial_division(n):
    prime_factors = list()
    while n % 2 == 0:
        prime_factors.append(2)
        n //= 2
    p = 3
    while p * p <= n:
        if n % p == 0:
            prime_factors.append(p)
            n //= p
        else:
            p += 2
    if n != 1:
        prime_factors.append(n)
    return prime_factors

C = Counter(trial_division(N))
ans = 0
for key,value in C.items():
    check = 0
    for i in range(1,value+1):
        check = (i * (i + 1))//2
        if value >= check:
            ans += 1
        else:
            break
print(ans)

Measured memory_bytes: 9468
H, W = map(int, input().split())
C = []
wall = []

for _ in range(10):
  C.append(list(map(int, input().split())))

for _ in range(H):
  wall += list(map(int, input().split()))

for k in range(10):
  for i in range(10):
    for j in range(10):
      C[i][j] = min(C[i][j], C[i][k]+C[k][j])

ans = 0
for x in wall:
  if x == -1:
    continue
  else:
    ans += C[x][1]

print(ans)

Measured memory_bytes: 9252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int[] leyes = new int[4];
		int[] reyes = new int[4];

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			double l = Double.parseDouble(line.substring(0, line.indexOf(' ')));
			double r = Double
					.parseDouble(line.substring(line.indexOf(' ') + 1));
			leyes[eyesight(l)]++;
			reyes[eyesight(r)]++;
		}
		for (int i = 3; i >= 0; i--) {
			System.out.println(leyes[i] + " " + reyes[i]);
		}
	}

	static int eyesight(double e) {
		int _e = (int) (e * 10);
		if (_e < 2) {
			return 0;
		} else if (_e < 6) {
			return 1;
		} else if (_e < 11) {
			return 2;
		} else {
			return 3;
		}
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    double mi = 1e9+10;
    int q = 0;
    for (int i = 0; i < n-1; i++) {
        if (abs(1.0*a[n-1]/2 - a[i]) < mi) {
            mi = abs(1.0*a[n-1]/2-a[i]);
            q = a[i];
        }
    }
    cout << a[n-1] << ' ' << q << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,2){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << (A[0]-1)*(A[1]-1) << endl;
}


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


int n,q;


//Aのｋ番目（0〜n-1）以降の要素をつかって、Mを作れるかを判定。成功：１　失敗:０
int judge(int *A,int M,int k){
  if(k==n-1){
    if(A[k]==M) return 1;
    else return 0;
  }
  else{
    if(M <A[k]) return judge(A,M,k+1);
    else if(M==A[k]) return 1;
    else{
      if(judge(A,M-A[k],k+1)==1 || judge(A,M,k+1)==1) return 1;
      else return 0;
    }
  }
}
  



int main(){
  int *A;
  int M;
  int i,j;
  
  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%*[ \n]%d",&A[i]);
  }

 /* int max;
  int cha;
  for(i=0;i<n-1;i++){
    max=i;
    for(j=i+1;j<n;j++){
      if(A[max] <A[j]) max=j;
    }
    cha=A[max];
    A[max] =A[i];
    A[i]=cha;
  }//降順にソート */

  
  scanf("%*[ \n]%d",&q);
  for(i=0;i<q;i++){
    scanf("%*[ \n]%d",&M);
    if(judge(A,M,0)==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}




    


Measured memory_bytes: 2048
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

const int kMaxV = 100010;

int v, e, source = 0, dfs_clock = 0;
vector<int> g[kMaxV];
int pre[kMaxV] = {0};
int post[kMaxV] = {0};
int out_degree[kMaxV] = {0};

void DFS(int u, int father) {
  pre[u] = ++dfs_clock;
  for (int v: g[u]) {
    if (!pre[v]) {
      DFS(v, u);
    } else if (v != father && !post[v]) {
      ++out_degree[v];
      printf("%d %d\n", v, u);
    }
  }
  if (father <= 0) {
    return;
  }
  post[u] = ++dfs_clock;
  if (out_degree[u] % 2 == 0) {
    ++out_degree[father];
    printf("%d %d\n", father, u);
  } else {
    ++out_degree[u];
    printf("%d %d\n", u, father);
  }
}

int main() {
  scanf("%d %d", &v, &e);
  for (int i = 0; i < e; ++i) {
    int s, t;
    scanf("%d %d", &s, &t);
    g[s].push_back(t);
    g[t].push_back(s);
  }
  if (e % 2 != 0) {
    printf("%d\n", -1);
  } else {
    DFS(1, -1);
  }

  return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EPS (1e-8)

struct Vec {
	double x;
	double y;
	double z;
	
	Vec() {}
	Vec(double x, double y, double z) : x(x), y(y), z(z) {}
	Vec(const Vec &r) { *this = r; }
	~Vec() {}
	
	Vec operator +(const Vec &r) const { return Vec(x + r.x, y + r.y, z + r.z); }
	Vec operator -(const Vec &r) const { return Vec(x - r.x, y - r.y, z - r.z); }
	Vec operator *(const Vec &r) const { return Vec(x * r.x, y * r.y, z * r.z); }
	Vec operator /(const Vec &r) const { return Vec(x / r.x, y / r.y, z / r.z); }
	Vec operator -() const { return Vec(-x, -y, -z); }
	Vec operator *(double r) const { return Vec(x * r, y * r, z * r); }
	Vec operator /(double r) const { return Vec(x / r, y / r, z / r); }
	Vec& operator =(const Vec &r) {
		x = r.x;
		y = r.y;
		z = r.z;
		return *this;
	}
	
	double lengthSq() const { return x * x + y * y + z * z; }
	double length() const { return sqrt(lengthSq()); }
	
	void norm() {
		double len = length();
		if (len > 0.0) {
			x /= len;
			y /= len;
			z /= len;
		}
	}
	
	Vec getNorm() const {
		double len = length();
		if (len > 0.0) {
			return Vec(x / len, y / len, z / len);
		}
		
		return Vec(0.0, 0.0, 0.0);
	}
};

double dot(const Vec &a, const Vec &b) {
	return a.x * b.x + a.y * b.y + a.z * b.z;
}

Vec cross(const Vec &a, const Vec &b)  {
	return Vec(a.y * b.z - a.z  * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
}

double length(const Vec &a) {
	return a.length();
}

double lengthSq(const Vec &a)  {
	return a.lengthSq();
}

typedef Vec P;

double area(const P &a, const P &b, const P &c)  {
	return length(cross(b - a, c - a)) / 2.0;
}

Vec normalTri(const P &a, const P &b, const P &c) {
	Vec ret = cross(b - a, c - b);
	ret.norm();
	return ret;
}

struct Line {
	P p;
	Vec v;
	Line(const P &p, const Vec &v) : p(p), v(v) {}
	
	P getPoint(double t) const {
		return p + v * t;
	}
};

struct Plane {
	P a, b, c;
	
	Plane(const P &a, const P &b, const P &c) : a(a), b(b), c(c) {}
	
	Vec normal() const {
		return normalTri(a, b, c);
	}
};

vector<P> intersectionSPL(const Line &s, const Plane &pl) {
	vector<P> res;
	
	Vec no = pl.normal();
	
	P a = s.p, b = s.getPoint(1.0);
	
	double da = dot(a - pl.a, no), db = dot(b - pl.a, no);

	if (abs(da) < EPS) da = 0.0;
	if (abs(db) < EPS) db = 0.0;
	if (da == 0.0 && db == 0.0) return res;
	else if (!(da * db <= 0.0)) return res;
	
	double t = abs(da) / (abs(da) + abs(db));
	res.push_back(s.getPoint(t));

	return res;
}


int main() {
	double x[5], y[5], z[5];
	REP(i, 5) cin >> x[i] >> y[i] >> z[i];
	
	P my(x[0], y[0], z[0]), en(x[1], y[1], z[1]);
	Plane ba(P(x[2], y[2], z[2]), P(x[3], y[3], z[3]), P(x[4], y[4], z[4]));
	
	Line beam(my, en - my);
	vector<P> v = intersectionSPL(beam, ba);
	
	if (v.empty()) puts("HIT");
	else {
		if (area(ba.a, ba.b, ba.c) - (area(ba.a, ba.b, v[0]) + area(ba.b, ba.c, v[0]) + area(ba.c, ba.a, v[0])) < -EPS)
			puts("HIT");
		else
			puts("MISS");
	}
	
	return 0;
}

Measured memory_bytes: 1184
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;


#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))
#define N 200005

int main(void) {
	int n, q;
	scanf("%d%d", &n, &q);
	ll total = (ll)(n - 2) * (n - 2);

	vector<pii> t[2], rt[2];
	vi minT[2], minX[2], minXT[2];

	REP(i, q) {
		int o, x;
		scanf("%d%d", &o, &x);
		o--;

		t[o].pb(mp(i, x));
		rt[o].pb(mp(x, i));
	}

	SORT(t[0]);
	SORT(rt[0]);
	SORT(t[1]);
	SORT(rt[1]);

	REP(i, 2) {
		minX[i].pb(n);
		minXT[i].pb(-1);
	}

	REP(i, 2) {
		minT[i].resize(sz(rt[i]));

		int curT = q + 1;
		REP(j, sz(rt[i])) {
			minT[i][j] = min(curT, rt[i][j].Y);
			curT = minT[i][j];
		}


		REP(j, sz(t[i])) {
			if (t[i][j].Y < minX[i].back()) {
				minX[i].pb(t[i][j].Y);
				minXT[i].pb(t[i][j].X);
			}
		}
	}

	REP(i, 2) {
		REP(j, sz(minT[i])) {
			int p = lower_bound(all(minXT[1 - i]), minT[i][j]) - minXT[1 - i].begin();
			p--;
			total -= (minX[1 - i][p] - 2);
		}
	}

	printf("%lld\n", total);

}

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

int main()
{
    int W, H, x, y, r;
    bool a, b;
    cin >> W >> H >> x >> y >> r;

    a = (0 <= (x - r)) && (0 <= (y - r));
    b = ((x + r) <= W) && ((y + r) <= H);

    if (a && b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3116
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (auto& e : A)cin >> e;
  int sum = accumulate(begin(A), end(A), 0);
  cout << (sum > N ? -1 : N - sum) << endl;
}


Measured memory_bytes: 3656
//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 0, 0, -1, 1 };
vi yy = { -1, 1, 0, 0 };
string dir = "LRUD";

const int N = 3e5 + 50, oo = 3e18 + 500;
const int mod = 998244353;
//const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-9, PI = 2 * acos(0.0);
int n, m, k;
long long cnt = 0;
int lg = 18;
vi g[N];
vi rg[N];
vi visit(N, 0);

void bfs(int s)
{
	queue<int> q;
	q.push(s);

	while (SZ(q))
	{
		int u = q.front();
		q.pop();

		for (auto v : g[u])
		{
			if (!visit[v])
			{
				visit[v] = u;
				q.push(v);
			}
		}
	}
}

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("abbreviation.in", "r", stdin);
	freopen("abbreviation.out", "w", stdout);*/
	//ПРОВЕРЯЙ ДЕФАЙНЫ ТУПОЙ!!!

	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;

		g[u].pb(v);
		g[v].pb(u);
	}

	bfs(1);

	cout << "Yes" << endl;
	for (int i = 2; i <= n; i++)
	{
		cout << visit[i] << endl;
	}
}

Measured memory_bytes: 25692
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}



int main(){ 
  int n;
  cin >> n;
  int h[n];
  rep(i,n)cin >> h[i];

  int score[n];
  rep(i,n)score[i] = 0;
  score[1] = abs(h[1] - h[0]);
  for(int i = 2;i < n;i++){
    score[i] = min(score[i-1] + abs(h[i]-h[i-1]),score[i-2] + abs(h[i]-h[i-2]));
  }
  cout << score[n-1] << endl;
}

Measured memory_bytes: 4336
# Author: cr4zjh0bp
# Created: Fri Mar 20 22:48:43 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
lr = nan(n)
ans = 0
for i in range(n):
    l, r = lr[i]
    ans += abs(l - r) + 1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.141592653589793238
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      dbl r;
      cin >> r;
      cout << fixed << setprecision(20) << (2*PI*r);
      return 0;
}

Measured memory_bytes: 3796
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int a[N];
int b[N];
vector < int > bg;

bool cmp(int x , int y){
    if(b[x] > b[y])
        return 1;
    return 0;
}

int main(){
    cin >> n;
    for(int i = 1; i <= n+1; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i];
    }
    long long et = 0;
    for(int i = 1; i <= n; i++){
        // a1 a2 a3
        // b1 b2
        et += min(b[i] , a[i]);
        b[i] -= min(b[i] , a[i]);
        et += min(b[i] , a[i + 1]);
        a[i + 1] -= min(b[i] , a[i + 1]);
    }
    cout << et << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

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

int main() {

	int a, b;
	cin >> a >> b;
	int ans = max({ a + b, a - b, a * b });

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define int long long
using namespace std;
map<int, int> A;
int m = 1000000007;
int32_t main(){
	int n;
  cin >> n;
  A[0] = 3;
  int ans = 1;
  for(int i = 0; i < n; i++){
  	int v;
    cin >> v;
    ans = (ans * A[v]) % m;
    A[v]--;
    A[v+1]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,K; cin >> N >> K;
    double A[N];
    rep(i,N){
        cin >> A[i];
    }
    double B[N+1];
    B[0]=0.0;
    rep(i,N){
        B[i+1]=(A[i]+1.0)/2.0+B[i];
    }
    double ans=0.0;
    rep(i,N-K+1){
        double pos=B[i+K]-B[i];
        chmax(ans,pos);
    }
    cout << ans << endl;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  std::vector<int> A(n+1);
  std::vector<int> B(n);
  for(int i=0;i<n+1;i++){
    cin>>A[i];
  }
  for(int i=0;i<n;i++){
    cin>>B[i];
  }
  ll res=0;
  for(int i=0;i<n;i++){
    int t = min(A[i], B[i]);
    B[i] -= t;
    res += t;
    t = min(A[i+1], B[i]);
    A[i+1] -= t;
    res += t;
  }

  cout<<res<<endl;

  return 0;
}


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

int n, u, v, grundy[200010];
vector<int> graph[200010];

void dfs(int u, int p) {
    for(int v : graph[u]) {
        if(v == p) continue;
        dfs(v, u);
        grundy[u] ^= (grundy[v] + 1);
    }
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i < n; i++) {
        scanf("%d%d", &u, &v);
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    dfs(1, 1);
    if(grundy[1]) printf("Alice");
    else printf("Bob");
}

Measured memory_bytes: 14720
def warshal(N, d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

def main():
    N, M = map(int, input().split())
    d = [[float('inf')] * N for _ in range(N)]
    edges = []

    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        d[a][b] = c
        d[b][a] = c
        edges.append((a,b,c))

    warshal(N, d)

    cnt = 0
    for edge in edges:
        if d[edge[0]][edge[1]] != edge[2]:
            cnt += 1

    print(cnt)

    

if __name__ == "__main__":
    main()

Measured memory_bytes: 43888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0)

// *start on @date: 2020-05-10 21:19
const ll N = 2e5 + 5;
int n, a[N], v[N], cnt, f[N];
ll k;

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int x = 1;
    do
    {
        v[x] = 1;
        if (cnt == k)
        {
            cout << x;
            return 0;
        }
        f[cnt++] = x;
        x = a[x];
    } while (!v[x]);
    k -= cnt;
    cnt = 0;
    do
    {
        v[x] = 2;
        f[cnt++] = x;
        x = a[x];
    } while (v[x]!=2);
    cout << f[k % cnt];
    return 0;
}


Measured memory_bytes: 5792
#include<stdio.h>
int main(){
  int n,n1,n2,n3,n4;
  scanf("%d",&n);
  n1=n%10;
  n2=n%100/10;
  n3=n%1000/100;
  n4=n/1000;
  if(n2==n3&&n3==n4 ||n1==n2 && n2==n3){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  // printf("%d  %d  %d  %d\n",n1,n2,n3,n4);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1000000007;

struct mint
{
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

mint fac_d(ll n, ll k)
{
  mint res = 1;
  for (ll i = 0; i < k; ++i)
  {
    res *= (n - i);
  }
  return res;
}

mint fac_n(ll n)
{
  mint res = 1;
  for (ll i = 0; i < n; ++i)
  {
    res *= (i + 1);
  }
  return res;
}

mint nCk(ll n, ll k)
{
  if (n < k)
    return 0;
  return fac_d(n, k) * fac_n(k).pow(MOD - 2);
}

int main()
{
  long long X;
  scanf("%lld", &X);
  long long Y;
  scanf("%lld", &Y);
  if (Y < X)
    swap(X, Y);
  ll t = Y - X;
  ll tx = X - t, ty = Y - 2 * t;
  if (tx < 0 || tx % 3 != 0)
  {
    cout << 0 << endl;
  }
  else
  {
    ll xx = tx / 3;
    ll yy = t + xx;
    cout << nCk(xx + yy, xx) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define VECV(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int gcd(int a, int b) {
  int v0 = a, v1 = b, v2 = a % b;
  while (v2 != 0) {
    v0 = v1;
    v1 = v2;
    v2 = v0 % v1;
  };
  return v1;
}

int gcd3(int a, int b,int c){
  return gcd(gcd(a,b),c);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  int ans=0;
  FOR(i,1,N+1){
    FOR(j,1,N+1){
      FOR(k,1,N+1){
        ans+=gcd3(i,j,k);
      }
    }
  }
  cout<<ans<<endl;


}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>


using namespace std;


int main(){
    int N;
    string S;
    string T;
    cin >> N;
    cin >> S >> T;

    string ans = "";
    for (int i = 0; i < N; i++)
    {
        /* code */
        ans = ans + S[i] + T[i];
    }
    cout << ans << endl;
    
}


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

int main(){
    char s[4];
    cin>>s;
    int sl=strlen(s);
    if(sl==2){
        cout<<s;
    }
    else{
        cout<<s[2]<<s[1]<<s[0];
    }
    return 0;
}

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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
const ll mod=1e9+7;
const int maxn=2e5+10;
vector<int> a,b,bb;
ll c[maxn],cc[maxn];
int n,k;

bool cmp(int x,int y){
	return abs(x)>abs(y);
}

int main(){
	io;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		bb.pb(x);
		if(x<0)b.pb(x);
		else a.pb(x);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(bb.begin(),bb.end(),cmp);
	for(int i=0;i<sz(b);i++){ b[i]+=mod;b[i]%=mod; }
	if(n==k){
		ll res=1;
		for(int x:a){ res*=x;res%=mod; }
		for(int x:b){ res*=x;res%=mod; }
		cout<<res<<endl;
		return 0;
	}
	if(sz(a)==0){
		ll ans=1;
		if(k%2==1){
			// ans=(b.back()%mod+mod)%mod;
			for(int i=sz(b)-1;i>=sz(b)-k;i--){
				// ll xx=b[i]*b[i-1];xx%=mod;
				ans*=b[i];ans%=mod;
			}
			cout<<ans<<endl;
		}
		else {
			for(int i=0;i<k;i++){
				ans*=b[i];ans%=mod;
				// ll xx=b[i]*b[i+1];xx%=mod;
				// ans*=xx;ans%=mod;
			}
			cout<<ans<<endl;
		}
	}
	else {
		int cnt1=0,cnt2=0;
		for(int i=0;i<k;i++){
			if(bb[i]<0)cnt1++;
			else cnt2++;
		}
		if(cnt1%2==1){
			bool ff=false;
			if(cnt2==0)ff=true;
			cnt1--;cnt2--;
			ll ans=1;
			for(int i=0;i<k;i++){
				if(bb[i]<0&&cnt1>0){
					ans*=(bb[i]+mod)%mod;
					ans%=mod;
					cnt1--;
				}
				if(bb[i]>=0&&cnt2>0){
					ans*=bb[i];ans%=mod;
					cnt2--;
				}
			}
			ll x1=1,x2=1;
			bool f=false;
			for(int i=k;i<sz(bb);i++){
				if(bb[i]>=0){
					f=true;
					x1*=bb[i];
					break;
				}
			}
			for(int i=k;i<sz(bb);i++){
				if(bb[i]<0){
					x2*=bb[i];
					break;
				}
			}
			for(int i=k-1;i>=0;i--){
				if(bb[i]>=0){
					x1*=bb[i];
					break;
				}
			}
			for(int i=k-1;i>=0;i--){
				if(bb[i]<0){
					x2*=bb[i];
					break;
				}
			}
			if(!f){
				ans*=x2%mod;
				ans%=mod;
			}
			else if(ff){
				ans*=x1%mod;
				ans%=mod;
			}
			else if(x1>x2){
				ans*=x1%mod;
				ans%=mod;
			}
			else {
				ans*=x2%mod;
				ans%=mod;
			}
			cout<<ans<<endl;
		}
		else {
			ll ans=1;
			for(int i=0;i<k;i++){
				ans*=(bb[i]+mod)%mod;ans%=mod;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

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


using namespace std;

int main(){
    int n,k,i;
    cin>>n>>k;
    int arr[n];
    for(i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    cout<<accumulate(arr,arr+k,0);
    
    return 0;
}


Measured memory_bytes: 3640
N = int(input())
data = [[int(__) for __ in input().split()] for _ in range(N)]


data.insert(0, [0, 0, 0])
canTravel = True

for i in range(1, N+1):
    absT = abs(data[i][0] - data[i-1][0])
    absX = abs(data[i][1] - data[i-1][1])
    absY = abs(data[i][2] - data[i-1][2])

    distance = absX + absY
    if absT < distance or absT % 2 != distance % 2:
        canTravel = False
        break

if canTravel:
    print('Yes')
else:
    print('No')


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m,p;
int x[111];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>m>>p;
		m--;
		if(n==0)break;
		int sum=0;
		rep(i,n){
			cin>>x[i];
			sum+=x[i]*100;
		}
		sum-=(sum*p)/100;
		if(x[m]==0)cout<<0<<endl;
		else cout<<(sum/x[m])<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;
const ll INF = 1LL << 60;

int h,w;
int dp[1005][1005];
string a[1005];

void add(int &a, int b){
  a += b;
  a %= MOD;
}

int main(){
  cin >> h >> w;
  rep(i,h) cin >> a[i];
  
  dp[0][0] = 1;
  
  rep(i,h){
    rep(j,w){
      if(i+1 < h && a[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
      if(j+1 < w && a[i][j+1] == '.') add(dp[i][j+1], dp[i][j]);
    }
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main() {
  ll n,k;
  cin>>n>>k;
  k = min(n,k);
  combination comb(n);
  mint ans = 0;
  rep(i,k+1){
    ans+=comb(n,i)*comb(n-1,i);
  }
  cout<<ans.x<<endl;
  return 0;
}

Measured memory_bytes: 3328
N, M = map(int, input().split())
A = list(map(int, input().split()))
S = 0
count = 0
for i in A:
  S += i
  
vote = S / (4 * M)

for i in A:
  if i >= vote:
    count += 1
    
if count >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define int long long 
#define PB push_back
#define FAST ios::sync_with_stdio(false);cin.tie(0)
	
const int maxn = 2e5 + 100 , INF = 1e18 , MOD = 1e9 + 7;

vector <pair <ll , ll> > edges[maxn];
set <pair <ll, ll> > s;
ll dist1[maxn] , dist2[maxn];
ll dp1[maxn] , dp2[maxn];


int32_t main() {
    ll total = 0;
    ll bad = 0;
    int n , m;
    int b , e;
    cin >> n >> m >> b >> e;
    b--; e--;
    for (int i = 0; i < m; ++i) {
        int x , y , z;
        cin >> x >> y >> z;
        x--; y--;
        edges[x].PB({y , z});
        edges[y].PB({x , z});
    }
    fill(dist1 , dist1 + maxn , INF);
    fill(dist2 , dist2 + maxn , INF);
    dist1[b] = 0; dist2[e] = 0;
    s.insert({0 , b});
    dp1[b] = 1; dp2[e] = 1;
    while(s.size()) {
        int v = s.begin() -> S;
        s.erase(s.begin());
        for (auto u : edges[v]) {
            if(dist1[u.F] > dist1[v] + u.S) {
                s.erase({dist1[u.F] , u.F});
                dist1[u.F] = dist1[v] + u.S;
                s.insert({dist1[u.F] , u.F});
                dp1[u.F] = 0;
            }
            if(dist1[u.F] == dist1[v] + u.S) {
                dp1[u.F] += dp1[v];
                dp1[u.F] %= MOD;
            } 
        }
    }
    s.insert({0 , e});
    while(s.size()) {
        int v = s.begin() -> S;
        s.erase(s.begin());
        for (auto u : edges[v]) {
            if(dist2[u.F] > dist2[v] + u.S) {
                s.erase({dist2[u.F] , u.F});
                dist2[u.F] = dist2[v] + u.S;
                s.insert({dist2[u.F] , u.F});
                dp2[u.F] = 0;
            }
            if(dist2[u.F] == dist2[v] + u.S) {
                dp2[u.F] += dp2[v];
                dp2[u.F] %= MOD;
            }
        }
    }
    total = 1ll * dp1[e] * dp1[e] % MOD;
    for (int i = 0; i < n; ++i) {
        if(dist1[i] + dist2[i] == dist1[e] && dist1[i] == dist2[i]) {
            bad = (bad + (1ll * dp1[i] * dp1[i] % MOD * dp2[i] % MOD * dp2[i])) % MOD;
        }
    }
    for (int i = 0; i < n; ++i) {
        for (auto u : edges[i]) {
            int v = u.F;
            int w = u.S;
            if(dist1[i] + w + dist2[v] == dist1[e] && w + dist1[i] > dist2[v] && dist1[i] < dist2[v] + w) {
                bad = (bad + (1ll * dp1[i] * dp1[i] % MOD * dp2[v] % MOD * dp2[v])) % MOD;
            }
        }
    }
    cout << (total - bad + MOD) % MOD  << endl;
}

Measured memory_bytes: 25840
import fractions

N = int(input())
a = list(map(int, input().split()))

m = 1
for i in range(N):
    m = (a[i] * m) // fractions.gcd(a[i], m)    # 最小公倍数を計算
m -= 1    # m = 最小公倍数 - 1

ans = 0
for i in range(N):
    ans += m % a[i]

print(ans)


Measured memory_bytes: 5304
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,y;
    cin>>n>>y;
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= n-i; j++){
            int k = n-i-j;
            if(10000*i+5000*j+1000*k==y){
                printf("%d %d %d\n",i,j,k);
                return 0;
            }
        }
    }
    printf("%d %d %d\n",-1,-1,-1);

    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <queue>

#define int long long
#define p pair<int,int>
using namespace std;

int n;
vector<int> zombie;
vector<vector<int>> graph;
vector<int> dis;

void find_dangerous() {
    priority_queue<p, vector<p >, greater<>> que;
    dis = vector<int>(n, 1145141919);
    for (auto city:zombie) {
        dis[city] = 0;
        que.push(p(city, 0));
    }

    while (!que.empty()) {
        p now = que.top();
        que.pop();
        int nowv = now.first;

        if (dis[nowv] < now.second)continue;

        for (auto next:graph[nowv]) {
            if (dis[next] > dis[nowv] + 1) {
                dis[next] = dis[nowv] + 1;
                que.push(p(next, dis[next]));
            }
        }
    }
}

vector<int> cost;

void find_route() {
    priority_queue<p, vector<p >, greater<>> que;
    dis = vector<int>(n, 1145141919810364364);
    dis[0] = 0;
    que.push(p(0, 0));

    while (!que.empty()) {
        p now = que.top();
        que.pop();
        int nowv = now.first;

        if (dis[nowv] < now.second)continue;

        for (auto next:graph[nowv]) {
            if (dis[next] > dis[nowv] + cost[next]) {
                dis[next] = dis[nowv] + cost[next];
                que.push(p(next, dis[next]));
            }
        }
    }
}

signed main() {
    int m, k, s;
    cin >> n >> m >> k >> s;
    int low, high;
    cin >> low >> high;

    zombie = vector<int>(k);
    for (int i = 0; i < k; i++) {
        cin >> zombie[i];
        zombie[i]--;
    }

    graph = vector<vector<int>>(n);
    for (int i = 0; i < m; i++) {
        int from, to;
        cin >> from >> to;
        from--;
        to--;
        graph[from].push_back(to);
        graph[to].push_back(from);
    }

    find_dangerous();
    cost = vector<int>(n);
    for (int i = 0; i < n; i++) cost[i] = dis[i] <= s ? high : low;
    for (auto city:zombie)cost[city] = 1145141919810364364;
    cost[0] = 0;
    cost[n - 1] = 0;

    find_route();

    cout << dis[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 13880