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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    string s;
    cin >> s;
    
    if(s.find("9") == string::npos) {
        cout << "No";
    } else {
        cout << "Yes";
    }
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n;
priority_queue<int> que;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++) {
        int a;
        cin>>a;
        que.push(a);
    }
    while(true){
        int first=que.top();
        que.pop();
        int second=que.top();
        que.pop();
        int de=first%second;
        if(de==0) {
            if(que.empty()){
                cout<<second<<"\n";
                return 0;
            }
            else que.push(second);
        }
        else{
            que.push(second);
            que.push(de);
        }
    }
}


Measured memory_bytes: 892
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;
 
#define N 105
int n,maxw;
int v[N],w[N];
int dp[N][10005];
 
int DP(int i,int weight){
    if(dp[i][weight]!=0);
    else if(i==0){
        if(weight>=w[0])dp[0][weight]=v[0];
        else dp[0][weight]=0;
    }else if(weight<w[i]){
        dp[i][weight]=DP(i-1,weight);
    }else{
        dp[i][weight]=max(DP(i-1,weight-w[i])+v[i],DP(i-1,weight));
    }
    return dp[i][weight];
}
 
int main(){
    cin>>n>>maxw;
    for(int i=0;i<=n-1;i++)cin>>v[i]>>w[i];
     
    printf("%d",DP(n-1,maxw));
cout<<endl;
    return 0;
}


Measured memory_bytes: 6848
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	unsigned long long a,b,tmp,r,x,A,answer, B, C, D,DC,outcount;
	cin >> A >> B >> C >> D;
	DC = D * C;
	x = C * D;
	a = C;
	b = D;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	DC = x / b;


	unsigned long long total = B - A + 1, Ccount, Dcount, DCcount;
	Ccount = (B / C) - ((A-1) / C);
	Dcount = (B / D) - ((A - 1) / D);
	DCcount = (B / DC) - ((A - 1) / DC);
	outcount = Ccount + Dcount - DCcount;
	cout << (total - outcount);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;
 
// 深さ優先探索
vector<int> cc;  // どの連結成分か記録
vector<int> ccs; // 連結成分のサイズを記録
void dfs(const Graph &G, int v, int id) {
    cc[v] = id;
    ccs[id]++;
    for (auto e : G[v]) {
        if (cc[e.to] == -1) {  // 訪問済みでなければ探索
            dfs(G, e.to, id);
        }
    }
}
 
int main() {
    int n, m, k;
    cin >> n >> m >> k;
 
    Graph G(n);
    vector<pair<int, int>>fr(m);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        G[a - 1].push_back({b - 1});
        G[b - 1].push_back({a - 1});
        fr[i] = make_pair(a - 1,b - 1);
    }
 
//    int q;
//    cin >> q;
//    vector<int> s(q), t(q);
//    for (int i = 0; i < q; i++) {
//        cin >> s.at(i) >> t.at(i);
//    }
 
    cc.assign(n, -1);  // 初期化
    int id = 0;
    for (int i = 0; i < n; i++) {
        if (cc[i] == -1) {
            ccs.push_back(0);
            dfs(G, i, id);
            id++;
        }
    }
    // id は連結成分の個数にもなっている
    vector<int> f(n);
    for (int i = 0; i < n; i++) {
        f[i] = ccs[cc[i]] - 1;
    }
    //cout << f[0] << endl;
    for (int i = 0; i < m; i++) {
        f[fr[i].first]--;
        f[fr[i].second]--;
        
    }
    //cout << f[0] << endl;
    vector<pair<int, int>>br(k);
    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        br[i] = make_pair(a - 1,b - 1);
    }
    for (int i = 0; i < k; i++) {
        if (cc[br[i].first] == cc[br[i].second]) {
            f[br[i].first]--;
            f[br[i].second]--;
        }
    }
    cout << f[0];
    for (int i = 1; i < n; i++) {
        cout << ' ' << f[i];
    }
    cout << endl;
 
    return 0;
}


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

int main(){
    int x,y,tmp;
    int i = 1;
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }
        if(x > y){
            tmp = x; x = y; y = tmp;
        }
        cout << x << " " << y << endl;
    }
    
    return 0;
}

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

const int MAXN = 200000 + 50;

char ch;
bool devices[MAXN * 2];
int N, K;

int main()
{
	cin >> N >> K ;
	for(int i = 0; i < N; i++)
		cin >> ch, devices[i] = (ch == 'A');

	int L = 0, R = N, rev = 0;

	while(K-- && L < N)
	{
		if((devices[L] ^ rev) == 1)
			devices[L] ^= 1;
		else
			rev ^= 1,
			devices[R++] = 1 ^ rev,
			L++;
	}

	if((N & 1) && (!(K & 1)))
		devices[L] ^= rev;
	for(int i = L; i < R; i++)
		cout << ((devices[i] ^ rev) ? 'A' : 'B') ;
	cout << endl ;

	return 0;
}


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

using namespace std;

int main () {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    cout << v[0];
    cout << " ";
    cout << v[1];
    cout << " ";
    cout << v[2];
    cout << endl;
}



Measured memory_bytes: 3144
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        h: [usize; n],
    }

    let mut maxi = 0;
    let mut count = 0;
    let mut bef = h[0];
    for i in h.iter().skip(1) {
        if bef >= *i { 
            count = count + 1;
        } else {
            if maxi < count {
                maxi = count;
            }
            count = 0;
        }
        bef = *i;
    }
    if maxi < count {
        maxi = count;
    } 

    println!("{}", maxi);
}


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


int main(){
while(1){
  int i,j,N,M,k,l;
  cin>>N;
  if(N==0)return 0;
  int p[101][101]={0},lp[101]={0};
  for(i=0;i<N;i++){
    scanf("%d",&M);
    for(j=0;j<M;j++){
      scanf("%d",&k);
      p[i][k-1]=1;
    }
  }
  scanf("%d",&M);
  for(i=0;i<M;i++){
    scanf("%d",&k);
    lp[k-1]=1;
  }
  set<int> se;
  for(i=0;i<N;i++){
    //solve
    k=1;
    for(j=0;j<N;j++){
      if(p[i][j]<lp[j]){
        k=0;
        break;
      }
    }
    if(k==1){
      se.insert(i);
    }
  }
  if(se.size()==1){
    auto ans=*se.begin();
    printf("%d\n",ans+1);
  }else{
    printf("-1\n");
  }
  se.clear();
}
}


Measured memory_bytes: 3248
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
ab = [list(li()) for _ in range(n)]

ab.sort(key=lambda x: x[1])

cur = 0

ans = True

for ai, bi in ab:
    cur += ai
    if cur > bi:
        ans = False

print("Yes" if ans else "No")

Measured memory_bytes: 54192
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int N,X,m[101],s=0,M=1111101110;
 cin>>N>>X;
 for(int i=0;i<N;i++)
 {
 	cin>>m[i];
 	s=s+m[i];
 	if(m[i]<M)
 	{
 		M = m[i];
 	}
 }
 int k = N + (X-s)/M;
 cout<<k<<endl;
   

 		

}
 

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

using namespace std;

int main(){
	int n, k, num=1;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		if(num*2 > num+k) num+=k;
		else num *= 2;
	}
	cout << num;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MOD = 998244353;
const int MAX = 200000;
 
long long inverse[MAX];
long long factorial[MAX];
long long factorial_inverse[MAX];
long long pow_M_minus[MAX];
 
void calc(int n) {
	inverse[1] = 1;
	factorial[0] = factorial[1] = 1;
	factorial_inverse[0] = factorial_inverse[1] = 1;
	for (int i = 2; i <= n; i++) {
		inverse[i] = MOD - inverse[MOD%i] * (MOD/i) % MOD;
		factorial[i] = i * factorial[i-1] % MOD;
		factorial_inverse[i] = inverse[i] * factorial_inverse[i-1] % MOD;
	}
}
 
long long comb(int n, int k) {
	return factorial[n] * (factorial_inverse[k] * factorial_inverse[n-k] % MOD) % MOD;
}
 
 
int main() {
	long long n, m, k;
	cin >> n >> m >> k;
	calc(n-1);
	pow_M_minus[0] = 1;
	for (int i = 1; i < n; i++) pow_M_minus[i] = pow_M_minus[i-1] * (m-1) % MOD;
	long long ans = 0;
	for (int i = 0; i <= k; i++) {
		ans += m * pow_M_minus[n-1-i] % MOD * comb(n-1, i) % MOD;
		ans %= MOD;
	}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9840
S = input()
a=1
b=0
x = ''
for i in range(len(S)-1):
    if S[i+1]==S[0]:
        a+=1
    elif b==0 or S[i+1]==x :
        x = S[i+1]
        b+=1
    else:
        print('No')
        exit()
if a==b==2:
    print('Yes')
else:
    print('No')

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

using namespace std;

int main() {

    int N, M;
    cin >> N >> M;
    vector<pair<long long, long long> > pairs(N);

    for(int i = 0; i < N; i++) {
        long long A, B;
        cin >> A >> B;
        pairs[i] = make_pair(A, B);
    }

    sort(pairs.begin(), pairs.end());

    // echo
    // for(int i = 0; i < N; i++) {
    //     cout << "(" << pairs[i].first << ", " << pairs[i].second << ")" << endl;
    // }

    long long money = 0;
    for(int i = 0; i < N; i++) {
        auto pair = pairs[i];
        if(pair.second > M) {
            money += pair.first * M;
            break;
        } else {
            money += pair.first * pair.second;
            M -= pair.second;
        }
    }

    cout << money << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;
vector<pair<ll, ll>> vec;
ll sol() {

    pair<ll, ll> xs = {-INF, -INF}, ys = {-INF, -INF};
    for (int i = 0; i < vec.size(); i++) {
        ll x = vec[i].first, y = vec[i].second;
        xs.first = max(xs.first, x - y);
        ys.first = max(ys.first, y - x);

        xs.second = max(xs.second, x + y);
        ys.second = max(ys.second, - x - y);
    }

    set<ll> s;
    for (int i = 0; i < vec.size(); i++) {
        ll x = vec[i].first, y = vec[i].second;
        if (x - y == xs.first) {
            s.insert(i);
            xs.first = -INF;
        }
        if (y - x == ys.first) {
            s.insert(i);
            ys.first = -INF;
        }
        if (x + y == xs.second) {
            s.insert(i);
            xs.second = -INF;
        }
        
        if (-x-y == ys.second) {
            s.insert(i);
            ys.second = -INF;
        }
    }
    ll ans = 0;
    for (auto cur : s) {
        for (auto cur2 : s) {
            ans = max(ans, abs(vec[cur].first - vec[cur2].first) + abs(vec[cur].second - vec[cur2].second));
        }
    }
    return ans;
}

int main()
{
    fastInp;

    srand(4);
    ll n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;

        vec.push_back({x, y});
    }


    cout << sol();
    return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int main() {
    int max_antenna = -1;
    int min_antenna = 124;

    rep(i, 0, 5) {
        int a;
        cin >> a;
        max_antenna = max(max_antenna, a);
        min_antenna = min(min_antenna, a);
    }
    int k;
    cin >> k;
    if (max_antenna - min_antenna > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll a[N];
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n;
    cin >> n;
    for (int i = 1; i <= n; i ++)
    	cin >> a[i];
    ll ans = 0;
  
	ll po = 1;
	while (po <= n && !a[po]) po ++;
	if (po > n) {
		return cout << ans, 0;
	}
	while (po <= n) {
		ll j = po;
		ll res = 0;
		while (j <= n && a[j]) {
			res += a[j];
			j ++;
		}
		ans += res / 2;
		if (po == j) po ++;
		else po = j;
	}
	cout << ans;
    return (0);
}

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

using namespace std;

int main() {
	int m, f, b;
	cin >> m >> f >> b;
	if (m >= b) {
		cout << 0 << endl;
	} else if (m + f >= b) {
		cout << b - m << endl;
	} else {
		cout << "NA" << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;

struct Kukan {
	int lx, ly, rx, ry;
};

int H, W, a[109][109], sx, sy; char c[109][109];
short dp[102][102][102][102];

Kukan overlap(Kukan A, Kukan B) {
	Kukan C = { 0,0,0,0 };
	C.lx = max(A.lx, B.lx);
	C.ly = max(A.ly, B.ly);
	C.rx = min(A.rx, B.rx);
	C.ry = min(A.ry, B.ry);
	return C;
}
Kukan useful(Kukan A) {
	int a = sy - A.ly, b = A.ry - sy;
	int c = sx - A.lx, d = A.rx - sx;
	Kukan B = Kukan{ d + 1,b + 1,H - c,W - a };
	return B;
}
int sum(Kukan E) {
	if (E.lx > E.rx || E.ly > E.ry) return 0;
	return a[E.lx - 1][E.ly - 1] + a[E.rx][E.ry] - a[E.lx - 1][E.ry] - a[E.rx][E.ly - 1];
}

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> c[i][j];
			if (c[i][j] == 'E') { sx = i; sy = j; }
			if (c[i][j] == 'o') a[i][j]++;
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) a[i][j] += a[i][j - 1];
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) a[i][j] += a[i - 1][j];
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			for (int k = i; k <= H; k++) {
				for (int l = j; l <= W; l++) dp[i][j][k][l] = -1;
			}
		}
	}
	dp[sx][sy][sx][sy] = 0;
	for (int i = 0; i <= H; i++) {
		for (int j = 1; j <= H - i; j++) {
			for (int k = 0; k <= W; k++) {
				for (int l = 1; l <= W - k; l++) {
					int px = j, qx = j + i, py = l, qy = l + k;
					if (dp[px][py][qx][qy] == -1) continue;

					Kukan L = useful(Kukan{ px,py,qx,qy });
					if (L.lx > L.rx || L.ly > L.ry) continue;

					if (px >= 2) {
						Kukan I = Kukan{ px - 1,py,px - 1,qy };
						Kukan J = overlap(I, L);
						dp[px - 1][py][qx][qy] = max((int)dp[px - 1][py][qx][qy], dp[px][py][qx][qy] + sum(J));
					}
					if (qx <= H - 1) {
						Kukan I = Kukan{ qx + 1,py,qx + 1,qy };
						Kukan J = overlap(I, L);
						dp[px][py][qx + 1][qy] = max((int)dp[px][py][qx + 1][qy], dp[px][py][qx][qy] + sum(J));
					}
					if (py >= 2) {
						Kukan I = Kukan{ px, py - 1, qx, py - 1 };
						Kukan J = overlap(I, L);
						dp[px][py - 1][qx][qy] = max((int)dp[px][py - 1][qx][qy], dp[px][py][qx][qy] + sum(J));
					}
					if (qy <= W - 1) {
						Kukan I = Kukan{ px, qy + 1, qx, qy + 1 };
						Kukan J = overlap(I, L);
						dp[px][py][qx][qy + 1] = max((int)dp[px][py][qx][qy + 1], dp[px][py][qx][qy] + sum(J));
					}
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			for (int k = i; k <= H; k++) {
				for (int l = j; l <= W; l++) ans = max(ans, (int)dp[i][j][k][l]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 209152
N = int(input())
mylist =[]
#リストの作成
for i in range(N):
  mylist.append(input().split()+[i])
#得点を整数に
for i in range(N):
    mylist[i][1]=int(mylist[i][1])
#ソート
mylist=sorted(sorted( mylist ,key=lambda x:x[1],reverse=1),key=lambda x:x[0])
    
for s,t,r in mylist:
    print(r+1)

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	K, A, B := nextInt(), nextInt(), nextInt()
	// K, A, B := 4, 4, 4
	if B%K == 0 || A%K == 0 {
		fmt.Println("OK")
	} else if B/K == A/K {
		fmt.Println("NG")
	} else {
		fmt.Println("OK")
	}

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 1760
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
map<int ,int > s;
int sd[N],fa[N],rt,cnt[N],ne[N],tot,size[N],f[N],fi[N],zz[N],a[N],n;
int cmp(int x,int y){
	return a[x]>a[y];
}
void dfs(int x,int z){
	sd[x]=z;
	for (int i=fi[x];i;i=ne[i])dfs(zz[i],z+1);
}
void dfs2(int x){
	if (x!=rt)cnt[x]=cnt[fa[x]]+n-2*size[x];
	for (int i=fi[x];i;i=ne[i])dfs2(zz[i]);
}
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]),s[a[i]]=i,f[i]=i;
	sort(f+1,f+n+1,cmp);
	for (int i=1;i<=n;i++){
		size[f[i]]++;
		if (i==n)continue;
		if (!s.count(a[f[i]]-(n-2*size[f[i]]))){
			puts("-1");
			return 0;
		}
		int k=a[f[i]]-(n-2*size[f[i]]);
		size[s[k]]+=size[f[i]];fa[f[i]]=s[k];
		jb(s[k],f[i]);
	}
	rt=0;
	for (int i=1;i<=n;i++)
		if (!fa[i])dfs(i,0),rt=i;
	for (int i=1;i<=n;i++)cnt[rt]+=sd[i];	
	dfs2(rt);
	for (int i=1;i<=n;i++)
		if (a[i]!=cnt[i]){
			puts("-1");
			return 0;
		}	
	for (int i=1;i<=n;i++)
		if (fa[i])printf("%lld %lld\n",i,fa[i]);	
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,a[105];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back

using namespace std;
typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;

int main() {
    long n; cin >> n;
    ll a[n];
    map<int, int> mp;
    REP(i,n){
        int k;
        cin >> k;
        a[i] = k;
        if (i%2==0) mp[k]=1;
    }

    sort(a,a+n);
    long ans=0;
    for(int i=1; i<n; i+=2){
        ans += mp[a[i]];
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
#!/usr/bin/env python3
#ABC134 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

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

b = [0]*(n+1)

for i in range(n//2,n):
    if a[i] == 1:
        b[i+1] = 1

for i in range(1,n//2+1)[::-1]:
    s = 0
    if i == 1:
        if sum(b) == 0 and a[0]:
            b[1] = 1
        elif sum(b) % 2 != a[0]:
            b[1] = 1
        break
    for j in range(2,n):
        if i*j > n:
            break
        if b[i*j] == 1:
            s += 1
    if s % 2:
        if a[i-1] == 1:
            continue
        b[i] = 1
    elif s % 2 == 0 and a[i-1] == 1:
        b[i] = 1

m = sum(b)
if m == 0:
    print(0)
    quit()
else:
    print(m)
    ans = [i for i,v in enumerate(b) if v]
    print(*ans)


Measured memory_bytes: 71656
# -*- coding: utf-8 -*-
"""
Created on Thu Aug  9 04:30:54 2018

@author: Yuki
"""
import numpy as np
N, M = map(int, input().split())
AB = np.zeros([M, 2])
for i in range(M):
    AB[i, 0], AB[i, 1] = map(int, input().split())

AB = AB[np.argsort(AB[:, 1])]

cut_br = [AB[0, 1]-1]
for i in range(1, M):
    flag = False
    if AB[i, 0] <= cut_br[-1]:
        if cut_br[-1] < AB[i, 1]:
            flag = True
    if not(flag):
        cut_br.append(AB[i, 1]-1)

print(len(cut_br))


Measured memory_bytes: 21080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100010;
int n;
ll mon[N+1],he[N],sumn,r=0;
int main(){
	cin>>n;
	for(int i=1;i<=n+1;i++)
		cin>>mon[i];
	for(int i=1;i<=n;i++)
		cin>>he[i];
	for(int i=1;i<=n;i++){
		if(he[i]+r>=mon[i]&&r<=mon[i]){
			r=he[i]-mon[i]+r;
			sumn+=mon[i];
		}
		else if(r>mon[i]){
			r=he[i];
			sumn+=mon[i];
		}
		else if(r+he[i]<mon[i]){
			sumn+=r+he[i];
			r=0;
		}
	}
	r=min(r,mon[n+1]);
	cout<<sumn+r;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, K; cin >> N >> K;
    string s; cin >> s;

    s = '1' + s + '1';
    vector<pair<int, int>> pa;
    pa.push_back({0, 0});

    bool zeroflg = false;
    int l, r;
    for(int i=1; i<=N+1; i++){
        if(zeroflg == false && s[i] == '0'){
            zeroflg = true;
            l = i;
        }
        else if(zeroflg == true && s[i] == '1'){
            zeroflg = false;
            r = i-1;
            pa.push_back({l, r});
        }
    }
    pa.push_back({N+1, N+1});

    
    if(pa.size()-2 <= K){
        cout << N << endl;
        return 0;
    }

    int ans = 0;
    for(int i=1; i<pa.size()-1-K+1; i++){
        int tmp = pa[i+K].first - pa[i-1].second - 1;
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1016
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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

signed main(){
	ll h,w,n;
	cin >> h >> w >> n;
	
	cout << ceil((double)n / max(h,w)) << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int W;
    int H;
    int x;
    int y;
    int r;
    
    cin >> W >> H >> x >> y >> r;
    
    if((r <= x) && (x <= W-r)){
        if((r <= y)&&(y <= H-r)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}


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

typedef long long ll;
using namespace std;

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

    int x = ceil(n / 1.08);
    if (floor(x * 1.08) == n) {
        cout << x << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprec

int main(){

    int n;
    cin >> n;

    map<string, int> m;

    rep(i,n){
        string tmp;
        cin >> tmp;

        sort(ALL(tmp));

        //cerr << tmp << endl;

        m[tmp]++;
    }

    ll ans = 0;

    for(auto itr = m.begin(); itr != m.end(); itr++){
        ll tmp = (*itr).second;

        if(tmp > 1){
            ans += tmp * (tmp - 1) / 2;
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 11136
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int d[100010];
    cin >> n;
    imfor(i, n) {
        cin >> d[i];
    }
    sort(d, d + n);
    int ans = d[(n / 2)] - d[(n / 2) - 1];
    cout << ans << endl;
}

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

using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;
  int sum[2][4004][26];
  for(int i = 0; i < 26; i++) sum[0][0][i] = sum[1][0][i] = 0;
  for(int i = 0; i < 26; i++) {
    for(int j = 0; j < s.size(); j++) sum[0][j+1][i] = sum[0][j][i] + (i==s[j]-'a');
    for(int j = 0; j < t.size(); j++) sum[1][j+1][i] = sum[1][j][i] + (i==t[j]-'a');
  }
  int n = min(s.size(), t.size());
  for(int l = n; l > 0; l--) {
    set< vector<int> > st;
    for(int i = 0; i <= s.size()-l; i++) {
      vector<int> cnt(26);
      for(int j = 0; j < 26; j++) {
	cnt[j] = sum[0][i+l][j] - sum[0][i][j];
      }
      st.insert(cnt);
    }
    for(int i = 0; i <= t.size()-l; i++) {
      vector<int> cnt(26);
      for(int j = 0; j < 26; j++) {
	cnt[j] = sum[1][i+l][j] - sum[1][i][j];
      }
      if(st.find(cnt) != st.end()) {
	cout << l << endl;
	return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 4680
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;
typedef long long ll;
int num = 0;

void pretty_print(vector<int> &A) {
  cout << A[0];
  rep (i, A.size()-1) cout << ' ' << A[i+1];
  cout << endl;
}

void sort(vector<int> &A) {
  rep (i, A.size()) {
    int mini = i;

    for (int j = i; j < A.size(); j++) {
      if (A[j] < A[mini]) {
        mini = j;
      }
    }

    if (i != mini) {
      swap(A[i],A[mini]);
      num++;
    }
  }
}

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

  vector<int> A(N);
  rep (i, N) cin >> A[i];

  sort(A);

  pretty_print(A);
  cout << num << endl;
}

Measured memory_bytes: 1196
import math

x1, y1, x2, y2 = map(int, input().split())

x3 = x2 - (y2 - y1)
y3 = y2 + (x2- x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2- x1)

print(x3, y3, x4, y4)

Measured memory_bytes: 9168
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main()
{jizz
	ll n,k;
	cin >> n >> k;
	if(n&1)
		if(k>n/2+1) cout << "NO\n";
		else cout << "YES\n";
	else
		if(k>n/2) cout << "NO\n";
		else cout << "YES\n";
}

Measured memory_bytes: 256
import collections

n = int(input())
a = list(map(int, input().split(" ")))
q = int(input())
have_map = collections.Counter(a)

total_cost = 0
for k,v in have_map.items():
    total_cost += k * v

for i in range(q):
    x, y = map(int, input().split(" "))
    if x in have_map:
        diff = have_map[x] * -x  + have_map[x] * y
        total_cost += diff

    have_map[y] = have_map.get(x, 0) + have_map.get(y, 0)
    have_map.pop(x, 0)

    print(total_cost)


Measured memory_bytes: 89992
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,j,k,l;
    cin>>n>>l;
    long long dp[n+1]={0};
    for(j=0;j<=n;j++){
        dp[j]=1000000000;
    }
    long long a[n+1];
    for(j=1;j<=n;j++){
        cin>>a[j];
    }dp[1]=0;dp[2]=abs(a[1]-a[2]);
    for(j=3;j<=n;j++){
      for(k=1;k<=min(j-1,l);k++)
        dp[j]=min(dp[j],dp[j-k]+abs(a[j]-a[j-k]));
    }cout<<dp[n];
    return 0;
}


Measured memory_bytes: 5144
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    N = sc.intarr()[0]
    data = []
    for i in range(N):
        city, score = input().split()
        d = {'index': i+1, 'city': city, 'score': int(score)}
        data.append(d)
    tmp = sorted(data, key=lambda x: x['score'], reverse=True)
    sorted_data = sorted(tmp, key=lambda x: x['city'])

    for d in sorted_data:
        print(d['index'])


class Scan():

    def intarr(self):
        num_array = list(map(int, input().split()))
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):  # 最大公約数
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):  # 最小公倍数
    return a * b // gcd(a, b)


main()


Measured memory_bytes: 3064
n=int(input())
s=str(input())
t=str(input())
s=list(s)
t=list(t)
ans=2*n
for i in range(n):
  cnt=0
  for j in range(n-i):
    if s[i+j]!=t[j]:
      break
    else:
      cnt=cnt+1
  if cnt==n-i:
    ans=ans-n+i
    break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
vector<int>rec;
int find (int u) { 
    return u == rec[u] ? u : rec[u] = find(rec[u]);
}
int main(){
	int n,m;
	cin>>n>>m;
	rec.resize(n);
	for(int i=0;i<n;++i){
		rec[i]=i;
	}
	int c=n-1;
	for(int i=0;i<m;++i){
		int u,v;
		cin>>u>>v;
		--u;--v;
		int _u = find(u) , _v =find(v) ;
        if (_u != _v) {
            rec[_v] = _u ;
            --c;
        }
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3764
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
d = LI()
takoyakis = sum(d)
ans = 0
for takoyaki in d:
    ans += (takoyakis - takoyaki) * takoyaki
print(ans // 2)


Measured memory_bytes: 8132
from collections import Counter

n, p = map(int, input().split())
s = input().rstrip()

total = 0
if p in [2, 5]:
    for i in range(n-1, -1, -1):
        if int(s[i]) % p == 0:
            total += i + 1
else:
    dp = [0] * (n + 1)
    fac = 1
    for i in range(n-1, -1, -1):
        dp[i] = (dp[i + 1] + int(s[i]) * fac) % p
        fac = (fac * 10) % p

    c = Counter(dp)

    for k, v in c.items():
        if v >= 2:
            total += v * (v - 1) // 2

print(total)


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
P x[210000];
double pi = 3.1415926535897932384626433832;
int dp[210000];

int main(){
  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cin >> N;
  int in = 0;
  for(int i = 0; i < N; i++){
    ll a, b;
    cin >> a >> b;
    if((x1-a)*(x2-a) <= 0 && (y1-b)*(y2-b) <= 0){
      x[in].first = a;
      x[in].second = b;
      in++;
    }
  }

  N = in;
  sort(x, x + N);


  double z = 100.0;
  double tu = 5.0 * pi - 20.0;
  double st = 10.0 * pi - 20.0;

  fill(dp, dp+N, 100000001);
  if((x2 - x1) * (y2 - y1) >= 0){
    for(int i = 0; i < N; i++){
      *lower_bound(dp, dp+N, x[i].second) = x[i].second;
    }
  }
  else{
    for(int i = 0; i < N; i++){
      *lower_bound(dp, dp+N, -x[i].second) = -x[i].second;
    }
  }
  int n = lower_bound(dp, dp+N, 100000001) - dp;

  /*for(int i = 0; i < N; i++){
    cout << x[i].first << " " << x[i].second << endl;
  }*/

  if(n == min(abs(x1 - x2), abs(y1 - y2)) + 1){
    printf("%.15f\n", tu * (n-1) + st + (abs(x1 - x2) + abs(y1 - y2)) * z);
  }
  else
    printf("%.15f\n",  tu * n + (abs(x1 - x2) + abs(y1 - y2)) * z);



  return 0;
}


Measured memory_bytes: 2560
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> pr;
typedef vector<int> VI;
typedef vector<pr> VP;
typedef vector<string> VS;
typedef vector<vector<int>> VV;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
const int inf = 1e17;
const int MAXN = 200001;
int fast_pow(int x, int y, int p);



void update(vector<int>& D, int l, int r, int x) 
{ 
    D[l] += x; 
    D[r + 1] -= x; 
} 
  
int getOriginal(vector<int>& A, vector<int>& D) 
{ 
	int mn = INT_MAX;
	int n = A.size();
    for (int i = 0; i < n; i++) { 
        if (i == 0) 
            A[i] = D[i]; 
        else
            A[i] = D[i] + A[i - 1]; 
		mn = min(mn,A[i]);
    } 
	return mn;
} 

void solve() {
	int n,k;cin>>n>>k;
	VI v;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		v.EB(x);
	}
	while(k>0){
		VI D(n+1,0);
		for(int i=0;i<n;i++){
			int left=max(0ll,i-v[i]);
			int right = min(n-1,i+v[i]);
			update(D,left,right,1);
		}
		int mn = getOriginal(v,D);
		if(mn==n)break;
		k--;
	}	
	for(int i=0;i<n;i++){
		cout<<v[i]<<" ";
	}
}


int32_t main() {

	IOS;
	int test = 1;
	// cin>>test;
	for (int i = 1; i <= test; i++) {
        // cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}
int fast_pow(int x, int y, int p) {
	int res = 1;
	x = x % p;
	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

Measured memory_bytes: 6376
n = gets.to_i
a = gets.split.map(&:to_i)
count = 0
arr = []

n.times do |i|
  arr.push(a[i])
  arr_clone = arr
  if i > 0
    now = arr.pop
    prev = arr.pop
    if now == prev
      now = 100002
      if now == a[i+1]
        now == 100001
      end
      count += 1
      arr.push(prev)
      arr.push(now)
    else
      arr.push(prev)
      arr.push(now)
    end
  end
end

puts count


Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string x, str = "";
	while (true) {
		getline(cin, x);
		if (x == "") break;
		str.append(x);
	}

	int answer;

	transform(str.begin(), str.end(), str.begin(), ::tolower);

	for (int i = int('a'); i <= int('z'); i++) {
		answer = 0;
		for (int j = 0; j < str.length(); j++) {
			if (str.c_str()[j] == i)
				answer++;
		}
		cout << char(i) << " : " << answer << endl;
	}
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  ll ans = 0;
  rep(i, s.size()) ans += s.at(i) - '0';
  if(ans % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

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

int main() {
    ll n; cin >> n;
    ll ans = 1;
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    ans *= modpow(10, n, MOD);
    ans -= modpow(8, n, MOD);
    ll tmp = modpow(10, n, MOD);
    tmp -= modpow(9, n, MOD);
    tmp = ans - tmp;
    tmp *= 2;
    tmp %= MOD;
    ans -= tmp;

    if (ans < 0) ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3620
import heapq

n, m = map(int, input().split())

def minus_int(x):
  return -1 * int(x)

a = list(map(minus_int, input().split()))
heapq.heapify(a)

for i in range(m):
  maxp = heapq.heappop(a)
  maxp = -int(-maxp // 2)
  heapq.heappush(a, maxp)
  
print(-sum(a))

Measured memory_bytes: 72216
A,B,C,D,E,F=map(int,input().split())
ans=[100,-1]
e=E/(100+E)
W=[a+b for a in range(0,F+1,100*A) for b in range(0,F+1,100*B) if a!=0 or b!=0]
for w in W:
    for c in range(0,F-w+1,C):
        for d in range(0,F-w-c+1,D):
            s=c+d
            if w+s>F or s/(w+s)>e:break
            elif ans[1]/ans[0]<s/(w+s)<=e:
                ans=[w+s,s]
print(ans[0],ans[1])

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

public class Hello
{
    public static void Main()
    {
        int a = 0;
        int e = 0;
        int k = 0;
        for(int i = 1; i <= 6; i++)
        {
            int num = int.Parse(Console.ReadLine());
            if(i == 1)
            {
                a = num;
            }
            else if(i == 5)
            {
                e = num;
            }
            else if(i == 6)
            {
                k = num;
            }
            
        }
        
        if(e - a <= k) Console.WriteLine("Yay!");
        else Console.WriteLine(":(");
    }
}

Measured memory_bytes: 11092
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf=(char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
char memarr[96000000];
string S;
int K;
string str[25000];
int main(){
  int i, j, n=0;
  wmem = memarr;
  rd(S);
  rd(K);
  for(i=0;i<(S.size());i++){
    for(j=(1);j<(K+1);j++){
      str[n++] = S.substr(i,j);
    }
  }
  sort(str, str+n);
  for(i=0;i<(n);i++){
    if(i==0 || str[i]!=str[i-1]){
      K--;
    }
    if(K==0){
      break;
    }
  }
  wt_L(str[i]);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// string S;
// int K;
// 
// string str[25000];
// {
//   int i, j, n = 0;
//   rd(S,K);
//   
//   rep(i,S.size()) rep(j,1,K+1){
//     str[n++] = S.substr(i,j);
//   }
//   sort(str, str+n);
// 
//   rep(i,n){
//     if(i==0 || str[i]!=str[i-1]) K--;
//     if(K==0) break;
//   }
//   wt(str[i]);
// }


Measured memory_bytes: 1664
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# Mの倍数から優先的に作る

N,M = LI()
X = LI()

d = defaultdict(int)
dmod = defaultdict(int)
pair = defaultdict(int)

for i in range(N):
    d[X[i]] += 1
    m = X[i]%M
    dmod[m] += 1
    if d[X[i]]%2 == 0:
        pair[m] += 1

ans = dmod[0]//2
for i in range(1,(M+1)//2):
    a = dmod[i]
    b = dmod[M-i]
    if a <= b:
        ans += a + min((b-a)//2, pair[M-i])
    else:
        ans += b + min((a-b)//2, pair[i])
if M%2 == 0:
    ans += dmod[M//2]//2

print(ans)

Measured memory_bytes: 76780
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long n,a[N],b[N],ans;
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];
	for(int i=1;i<=n;i++)
	{
		if(b[i]>a[i])
		{
			b[i]-=a[i],ans+=a[i];
			if(b[i]>a[i+1])
				ans+=a[i+1],a[i+1]=0;
			else
				ans+=b[i],a[i+1]-=b[i];
		}
		else
			ans+=b[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main(){
string day;
cin>>day;
    if(day == "SAT"){
        cout<< 1;
    }
    if(day == "MON"){
        cout<< 6;
    }
    if(day == "TUE"){
        cout<< 5;
    }

    if(day == "WED"){
        cout<< 4;
    }
    if(day == "THU"){
        cout<< 3;
    }
    if(day == "FRI"){
        cout<< 2;
    }
    if(day == "SUN"){
        cout<< 7;
    }
}

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

int main() {
	int N;
	cin >> N;
	int sum = 0, MAX = 0;
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		sum += p;
		MAX = max(p, MAX);
	}
	cout << sum - MAX / 2 << endl;
}


Measured memory_bytes: 256