akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << "\n"
using namespace std;
int x, y, z, k, a[1234], b[1234], c[1234];
priority_queue<int, vector<int>, greater<int>> pq;
vector<int>v, ans;
signed main() {
	cin >> x >> y >> z >> k;
	for1(i, x)cin >> a[i];
	for1(j, y)cin >> b[j];
	for1(l, z)cin >> c[l];
	for1(j, y)for1(l, z) {
		pq.push(b[j] + c[l]);
		if (pq.size() > k)pq.pop();
	}
	while (pq.size()) {
		v.push_back(pq.top());
		pq.pop();
	}
	for (int vp : v)for1(i, x) {
		pq.push(vp + a[i]);
		if (pq.size() > k)pq.pop();
	}
	while (pq.size()) {
		ans.push_back(pq.top());
		pq.pop();
	}
	sort(all(ans), greater<int>());
	for0(i, k)puts(ans[i]);
}

Measured memory_bytes: 512
#include <cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll h[105];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int index = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (h[i] <= index) {
			index = h[i];
		}
		else {
			ans += h[i] - index;
			index = h[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n;
vector<bitset<30> > neighbor;

int solve(int i, bitset<30> bs)
{
    if(i == n){
        if(bs.to_ulong() == (1 << n) - 1)
            return 0;
        else
            return INT_MAX / 2;
    }

    int ret = solve(i+1, bs);
    if((~bs & neighbor[i]).any())
        ret = min(ret, solve(i+1, bs | neighbor[i]) + 1);

    return ret;
}

int main()
{
    for(;;){
        int m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        neighbor.assign(n, 0);
        for(int i=0; i<m; ++i){
            int a, b;
            cin >> a >> b;
            neighbor[a][b] = true;
            neighbor[b][a] = true;
        }
        for(int i=0; i<n; ++i)
            neighbor[i][i] = true;

        cout << solve(0, 0) << endl;
    }
}

Measured memory_bytes: 908
def main():
	w,h,x,y = map(int,input().split())

	ans_2 = 0
	
	if w % 2 != 0 or h % 2 != 0:
		ans_2 = 0
	elif w % 2 == 0 and h % 2 == 0 and w / 2 == x and h / 2 == y:
		ans_2 = 1

	ans_1 = (w*h) /2

	print(ans_1, ans_2)

if __name__ == '__main__':
	main()

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

#define INF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

using namespace std;

typedef pair<int,int> pii;

int main (int argc, char const* argv[])
{
	int n;
	scanf("%d",&n);
	
	int ans = 0;
	for (int i = 0; i < n; i += 1)
	{
		int l,r;
		scanf("%d %d",&l,&r);
		
		ans += (r-l+1);
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 256
def test():

	i = list(map(int,input().split()))
	if i[0] < i[1]:
		if i[2] < i[0]:
			print(f"{i[2]} {i[0]} {i[1]}")
		elif i[1] < i[2]:
			print(f"{i[0]} {i[1]} {i[2]}")
		else:
			print(f"{i[0]} {i[2]} {i[1]}")
	else:
		if i[2] < i[1]:
			print(f"{i[2]} {i[1]} {i[0]}")
		elif i[0] < i[2]:
			print(f"{i[1]} {i[0]} {i[2]}")
		else:
			print(f"{i[1]} {i[2]} {i[0]}")

if __name__ == "__main__":
	test()



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {												
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/wjex/cp/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  


const int N = 2e5+5;
vi g[N+1];
void solve(){
	int n ,  m; 
	re(n,m);
	rep(i,0,m){
		int a ,b ;
		re(a,b);
		a--;
		b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	vi vis(n,-1);
	queue<int>q;
	q.push(0);
	vis[0]=0;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		trav(i,g[u]){
			if(vis[i] >= 0 ) continue;
			vis[i] = u ;
			q.push(i);
		}
	}
	trace(vis);
	bool done = 0 ;
	rep(i,0,n){
		if(vis[i] < 0) done =1 ;
	}
	if(done){
		cout << "No\n";
		return; 
	}
	cout << "Yes\n";
	fr(i,1,n-1){
		cout << vis[i]+1 << endl;
	}
	
}

signed main() {
	unsyncIO();
	int tt =1 ;
	//cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 15348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  int x;
  cin >> x;
  int ans = 1;
  int kakudo=x;
  while(kakudo%360 != 0){
    kakudo += x;
    ans++;
  }
  cout << ans << endl;
}


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

int ans = 1000000, n;

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x, cnt = 0;
    cin >> x;
    while(x % 2 == 0) {
      ++cnt;
      x /= 2;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



n, k, s = LI()
if s == 10 ** 9:
    print(*[s] * k + [1] * (n - k))
else:
    print(*[s] * k + [s + 1] * (n - k))






Measured memory_bytes: 46700
#include <stdio.h>
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<17, stdin), p1 == p2) ? EOF : *p1++)
char buf[(1 << 17)], *p1 = buf, *p2 = buf;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int ab[(1<<17)];
int main(int argc, char *argv[])
{
	int n = read(),m = read();
	for (int i = 0; i < m; ++i) {
		int a = read(),b = read();
		if (*(ab+b) < a) {*(ab+b) = a;}
	}
	int ans = 0;
	int k = 1;
	for (int i = 1; i <= n; ++i) {
		if (k <= *(ab+i)) {
			k = i;
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
from math import sqrt, floor
from collections import deque


def divide_repeat(p):
    global n, a, limit
    while not (n % p):
        a.append(p)
        n = n // p
        limit = floor(sqrt(n))


nstr = input()
n, p = int(nstr), 3
limit = floor(sqrt(n))
a, i = deque(), 3

divide_repeat(2)

while p <= limit:
    divide_repeat(p)
    p += 2

if n > 1:
    a.append(n)

print(nstr + ': ', end='')
print(*a)

Measured memory_bytes: 8120
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 100010;
long long a[maxn];
int main()
{
	long long i, n, cnt, sum, ans = 0;

	scanf("%lld", &n);
	for (i = 0; i < n; i ++)
		scanf("%lld", a + i);
	sort(a, a +n);
	sum = a[0];
	cnt = 1;
	ans = n;
	for (i = 1; i < n; i ++)
		if(a[i] > sum * 2)
		{
			ans -= cnt;
			cnt = 1;
			sum += a[i];
		}
		else
		{
			cnt++;
			sum += a[i];
		}
	printf("%lld", ans);
	return 0;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    if (A==1) {
        A=14;
    }
    if (B==1){
        B=14;
    }
    if (A==B) {
        cout << "Draw" << endl;
    } else if (A>B) {
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
from math import factorial

N = int(input())
Lx = []
Ly = []
for i in range(N):
    xtmp,ytmp = map(int,input().split())
    Lx.append(xtmp)
    Ly.append(ytmp)

cnt = 0
Sum = 0
for i in range(N):
    for j in range(i+1,N):
        cnt += math.sqrt( (Lx[i]-Lx[j])**2 + (Ly[i]-Ly[j])**2 )

Sum = factorial(N-1)*2*cnt/factorial(N)
print(Sum)

Measured memory_bytes: 3064
from collections import deque
N=int(input())
M=(N*(N-1))//2
D=dict()
tmp=0
X=[(0,0) for i in range(M)]
G=[[] for i in range(M)]
for i in range(1,N+1):
    for j in range(1,N+1):
        if i<j:
            D[(i,j)]=tmp
            X[tmp]=(i,j)
            tmp+=1
A=[[int(j) for j in input().split()] for i in range(N)]
for i in range(N):
    for j in range(N-2):
        p1=D[(i+1,A[i][j])] if i+1<A[i][j] else D[(A[i][j],i+1)]
        p2=D[(i+1,A[i][j+1])] if i+1<A[i][j+1] else D[(A[i][j+1],i+1)]
        G[p1].append(p2)
K=[0 for i in range(M)]
for i in range(M):
    for p in G[i]:
        K[p]+=1
q=deque(i for i in range(M) if K[i]==0)
res=[]
while q:
    v1=q.popleft()
    res.append(v1)
    for v2 in G[v1]:
        K[v2]-=1
        if K[v2]==0:
            q.append(v2)
#print(D)
#print(res)
if len(res)<M:
    print(-1)
    exit()
ans=[0 for i in range(M)]
ans[res[-1]]=1
for i in res[:-1][::-1]:
    if len(G[i])==0:
        ans[i]=1
    else:
        for j in G[i]:
            ans[i]=max(ans[i],ans[j]+1)
print(max(ans))


Measured memory_bytes: 209308
op1, op2, op3 = gets.split.map(&:to_i)
array = [op1,op2,op3]
for n in 1..3
    for num in 1..2 
        if array[num-1] > array[num] then
            tmp = array[num-1]
            array[num-1] = array[num]
            array[num] = tmp
        end
    end
end
for num in 1..3 
    print array[num-1]
    if num!=3
        print " "
    end
end

print "\n"

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


void solve(long long A, std::string op, long long B){
int res;
if(op == "+"){
    res =A+B;
}
else if(op == "-"){
    res=A-B;
}
cout<<res<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    std::string op;
    std::cin >> op;
    long long B;
    scanf("%lld",&B);
    solve(A, op, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


double dist(double x1,double x2,double y1,double y2){
    double tx = abs(x1-x2);
    tx *= tx;
    double ty = abs(y1-y2);
    ty *= ty;
    double tmp = sqrt(tx + ty);
    return tmp;
}


int main(){
    int N;cin >> N;
    vector<double> x(N);
    vector<double> y(N);
    rep(i,N)cin >> x[i] >> y[i];

    double ans = 0;
    double bo = N + 0.0;


    rep(i,N) rep(j,N){
        if(i == j)continue;
        ans += dist(x[i],x[j],y[i],y[j]);
    }

    ans /= bo;

    cout << std::fixed << std::setprecision(10) << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
  int A, B, M, tmp, x, y, c, buf;
  cin >> A >> B >> M;
  vector<int> a, b;
  int min_a = 1e9, min_b = 1e9;
  for (int i=0; i<A; i++){
    cin >> tmp;
    a.push_back(tmp);
    min_a = min(min_a, tmp);
  }
  for (int i=0; i<B; i++){
    cin >> tmp;
    b.push_back(tmp);
    min_b = min(min_b, tmp);
  }
  int ans = min_a + min_b;
  for (int i=0; i<M; i++){
    cin >> x >> y >> c;
    buf = a[x-1] + b[y-1] - c;
    ans = min(ans, buf);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
import java.util.ArrayList;
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        sc.close();

        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 1; i <= 100; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(list.size() - k));
    }
}

Measured memory_bytes: 22612
import sys
     
global status, d
status = {}
d=0
 
def mst(p1, GRAPH):
    global status
     
    edge={}
    total = 0
    mini = 0
    while True:
        status[p1]=True
        for p2 in range(len(status)):
            if status[p2]==False and GRAPH.has_key((p1,p2)):
                edge[(p1, p2)]=GRAPH[(p1, p2)]
        mini=1000000
        for key, value in edge.items():
            if status[key[1]]==True:
                del edge[key]
                continue
            if value <mini:
                key0 = key
                mini = value
        if mini!=1000000:
            total+=mini
            p1=key0[1]
        else:
            break
     
    return total
 
n = int(raw_input())
x = {}
for i in range(n):
    seq = map(int,raw_input().split())
    for j in range(n):
        tmp = seq[j]
        if tmp != -1:
            x[(i, j)]=tmp
    status[i] = False
 
print mst(0, x)

Measured memory_bytes: 8148
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2)
        cout << 1 << endl;
    else
        cout << 0 << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
typedef long long llong;

int n;
llong x;

llong trash[200111];

llong MIN(llong a,llong b)
{
    if (a < b)
        return a;
    else
        return b;
}

llong solve(int ctr)
{
    int i;
    llong ans = (llong)n * x + (llong)ctr * x;
    llong multi = 5LL;
    int vleft = ctr;

    for (i=n;i>=n-ctr+1;i--)
    {
        ans += trash[i] * 5LL;
    }

    for (i=n-ctr;i>=1;i--)
    {
        ans += trash[i] * multi;
        vleft--;

        if (vleft == 0)
        {
            vleft = ctr;
            multi += 2LL;
        }
    }

    return ans;
}

int main()
{
    int i;
    int l,r,m1,m2;
    llong best = 0;

    scanf("%d %lld",&n,&x);

    for (i=1;i<=n;i++)
    {
        scanf("%lld",&trash[i]);

        best += 5LL * trash[i] + 2LL * x;
    }

    l = 1;
    r = n;
    while(l <= r)
    {
        m1 = l + (r - l + 1)/3;
        m2 = l + 2*(r - l + 1)/3;

        while(m1 < l)
            m1++;

        while(m2 > r)
            m2--;

        llong v1 = solve(m1);
        llong v2 = solve(m2);


        best = MIN(best, v1);
        best = MIN(best, v2);

        if (v1 > v2)
        {
            l = m1 + 1;
        }
        else
        {
            r = m2 - 1;
        }
    }

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

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
    int n, p;
    while (cin >> n >> p && n != 0 && p != 0) {
        int rem = p;
        int players[n], i = 0;
        for (int i = 0; i < n; ++i)
            players[i] = 0;
        while (1) {
            if (--rem < 0) {
                rem = players[i];
                players[i] = 0;
            } else if (++players[i] == p) {
                cout << i << endl;
                break;
            }
            i = ++i != n ? i : 0;
        }
    }
}

Measured memory_bytes: 1160
function main()
    
    (N, L) = map(x -> parse(Int,x),split(readline()))
    
    s = string.(zeros(N))
    
    ans = "" 
    
    for i in 1:N
        
        s[i] = chomp(readline())

    end
 
    
    sort!(s, rev=false)
    
    for i in 1:N
        
        ans *= s[i]
        
    end
    
    println(ans)
    
end
main()

Measured memory_bytes: 117372
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  vector<int>p={a,b,c};
  sort(p.begin(),p.end());
  int x=p[2]-p[0];
  int y=p[2]-p[1];
  if((x%2==0 && y%2==0)||(x%2!=0 && y%2!=0)){
    cout<<(x+y)/2<<endl;
    return 0;
  }
  else {
    cout<<(x+y)/2+2<<endl;
    return 0;
  }
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
  
#define MAX_N 3005
int n;
int px[MAX_N],py[MAX_N];
char ch[MAX_N];
  
int solve(int si){
  bool used[MAX_N]={};
  set< P > sx[MAX_N],sy[MAX_N];
  for(int i=0;i<n;i++){
    if(i==si)continue;
    sx[ px[i] ].insert( P(py[i],i) );
    sy[ py[i] ].insert( P(px[i],i) );
  }
  int res=1;
  int x=px[si],y=py[si];
  char dir=ch[si];
  
  set< P > :: iterator it;
  while(1){
    P next;
    if(dir=='v'){
      it= sx[x].lower_bound( P(y,0) );
      if(it==sx[x].end())break;
      next=*it;
    }else if(dir=='^'){
      it= sx[x].lower_bound( P(y,0) );
      if(it==sx[x].begin())break;
      it--;
      next=*it;
    }else if(dir=='>'){
      it= sy[y].lower_bound( P(x,0) );
      if(it==sy[y].end())break;
      next=*it;      
    }else if(dir=='<'){
      it= sy[y].lower_bound( P(x,0) );
      if(it==sy[y].begin())break;
      it--;
      next=*it;
    }
    res++;
    int id=next.second;
    x=px[id];
    y=py[id];
    dir=ch[id];
    sx[ x ].erase(P(y,id));
    sy[ y ].erase(P(x,id));
  }
  return res;
}
  
int main(){
  vector<int> X,Y;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>px[i]>>py[i]>>ch[i];
    X.push_back(px[i]);
    Y.push_back(py[i]);
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  X.erase(unique(X.begin(),X.end()),X.end());
  Y.erase(unique(Y.begin(),Y.end()),Y.end());
  
  for(int i=0;i<n;i++){
    px[i]=lower_bound(X.begin(),X.end(),px[i])-X.begin();
    py[i]=lower_bound(Y.begin(),Y.end(),py[i])-Y.begin();
  }
  
  
  
  int ans=0;
  for(int i=0;i<n;i++){
    ans=max(ans,solve(i));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3784
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, l = map(int, input().split())

    ls = [i + l for i in range(n)]
    if l >= 0:
        ls = ls[1:]
    elif n + l - 1 < 0:
        ls = ls[:-1]

    print(sum(ls))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>>s(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    vector<vector<int>>x(h,vector<int>(w,10000));
    if(s[0][0]=='#')x[0][0]=1;
    else x[0][0]=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i<h-1){
                if(s[i][j]=='.' && s[i+1][j]=='#')x[i+1][j]=min(x[i+1][j],x[i][j]+1);
                else x[i+1][j]=min(x[i+1][j],x[i][j]);
            }
            if(j<w-1){
                if(s[i][j]=='.' && s[i][j+1]=='#')x[i][j+1]=min(x[i][j+1],x[i][j]+1);
                else x[i][j+1]=min(x[i][j+1],x[i][j]);
            }
        }
    }
    cout<<x[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
let solve ans w v =
  let rec duduwa ans j k = function
    | [] -> doit ans (j + 1, [(v.(j), k)])
    | (ch, cj) :: y' when ch >= v.(j) -> duduwa (if ch * (j - cj) > ans then ch * (j - cj) else ans) j cj y'
    | ys -> doit ans (j + 1, (v.(j), k) :: ys)
  and doit ans = function
    | (j, xs) when j = w -> List.fold_left (fun acc (ch, cj) -> if ch * (w - cj) > acc then ch * (w - cj) else acc) ans xs
    | (j, []) -> doit ans (j + 1, [(v.(j), j)])
    | (j, ((ch, _) :: _ as xs)) when ch = v.(j) -> doit ans (j + 1, xs)
    | (j, ((ch, _) :: _ as xs)) when ch < v.(j) -> doit ans (j + 1, (v.(j), j) :: xs)
    | (j, xs) -> duduwa ans j j xs in
  doit ans (0, [])

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let read () = List.map int_of_string (split_on_char ' ' (read_line ()))

let () =
  match read () with
  | [h; w] ->
    let v0 = Array.make w 0 in
    let v1 = Array.make w 0 in
    let rec doit i ans =
      if i = h then ans
      else
        let rec duduwa j = function
          | [] -> Array.iteri (fun i e -> v0.(i) <- e) v1; doit (i + 1) (solve ans w v1)
          | x::xs ->
            v1.(j) <- 1 - x;
            if i <> 0 then v1.(j) <- if v1.(j) = 0 then 0 else v0.(j) + 1;
            duduwa (j + 1) xs in
        duduwa 0 (read ()) in
    Printf.printf "%d\n" (doit 0 0)
  | _ -> ()

Measured memory_bytes: 5092
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main(){

	int num,date;
	map<int,set<int> > m1;
	map<int,set<int> > m2;
	string str;
	bool next=false;

	while(getline(cin,str)){
		if (str.empty()){
			next = true;
			continue;
		}
		sscanf(str.c_str(),"%d,%d",&num,&date);		

		if(!next) m1[num].insert(date + 100);

		else{
			if(m1[num].size()>0){
				if(m2[num].size() == 0) m2[num] = m1[num];
				m2[num].insert(date);
			}
			
		}
	}

	for(map<int,set<int> >::iterator it = m2.begin(); it != m2.end(); it++){
		printf("%d %d\n",it->first,it->second.size());
	}
}

Measured memory_bytes: 0
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, m;
long cost[305][305];
long l;
std::vector<long> edge[305];
long supply[305][305];

int main(){
    scanf("%ld%ld", &n, &m);
    scanf("%ld", &l);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(i != j){
                cost[i][j] = LINF;
            }
        }
    }
    for(int i = 0; i < m; i++){
        long a, b, c;
        scanf("%ld%ld%ld", &a, &b, &c);
        cost[a][b] = c;
        cost[b][a] = c;
    }
    for(long k = 1; k <= n; k++){
        for(long i = 1; i <= n; i++){
            for(long j = 1; j <= n; j++){
                cost[i][j] = std::min(cost[i][j], cost[i][k]+cost[k][j]);
            }
        }
    }
    for(long i = 1; i <= n; i++){
        for(long j = i+1; j <= n; j++){
            if(cost[i][j] <= l){
                edge[i].push_back(j);
                edge[j].push_back(i);
            }
        }
    }
    for(long i = 1; i <= n; i++){
        for(long j = 1; j <= n; j++){
            supply[i][j] = -1;
        }
    }
    for(long i = 1; i <= n; i++){
        supply[i][i] = 0;
        std::queue<long> que;
        que.push(i);
        while(!que.empty()){
            long vis = que.front();
            que.pop();
            for(long j = 0; j < edge[vis].size(); j++){
                long nx = edge[vis][j];
                if(supply[i][nx] != -1){
                    continue;
                }
                supply[i][nx] = supply[i][vis] + 1;
                que.push(nx);
            }
        }
    }
    long q;
    scanf("%ld", &q);
    for(long i = 0; i < q; i++){
        long a, b;
        scanf("%ld%ld", &a, &b);
        printf("%ld\n", std::max(-1l, supply[a][b]-1));
    }
}


Measured memory_bytes: 3072
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N,A,B = map(int, input().split())
    X = list(map(int, input().split()))
    res = 0
    for i in range(N-1):
        if (X[i+1]-X[i])*A>B:
            res += B
        else:
            res += (X[i+1]-X[i])*A
    print(res)

if __name__ == '__main__':
    main()

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

int a[100050];
int main()
{
    int n;
    scanf("%d", &n);
    if(n == 1)
    {
        puts("YES");
        return 0;
    }
    for(int i = 1;i <= n;++i)
        scanf("%d", &a[i]);
    int c = 0;
    for(int i = 1;i <= n;++i)
    {
        if(a[i] & 1)
            ++c;
    }
    if(c & 1)
        puts("NO");
    else
        puts("YES");
    return 0;
}


Measured memory_bytes: 768
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int bubbleSort(vector<int>& data, int N){
    int count = 0;
    for(int j = 0; j < N - 1; j++){
        for(int i = N - 1; i > j; i--){
            if(data.at(i) < data.at(i - 1)){
                swap(data.at(i), data.at(i - 1));
                count++;
            }
        }
    }
    rep(i, N){
        cout << data.at(i);
        if(i < N - 1) cout << ' ';
    }
    cout << endl;
    return count;
}

int main(){
    int N;
    cin >> N;
    
    vector<int> data(N);
    rep(i, N)
    {
        cin >> data.at(i);
    }
    cout << bubbleSort(data, N) << endl;
    return 0;
}


Measured memory_bytes: 3108
def input(f):
    global v, e, r, s, t, d, g
    
    v, e, r = map(int, f.readline().split())
    s = []
    t = []
    d = []
    for _ in range(e):
        s_, t_, d_ = map(int, f.readline().split())
        s.append(s_)
        t.append(t_)
        d.append(d_)
        
    g = [list() for _ in range(v)]
    for i in range(e):
        g[s[i]].append(i)

import os

if os.environ.get('ZEPPELIN_HOME'):
    import networkx as nx
    import matplotlib.pyplot as plt
    
    def visualize():
        G = nx.DiGraph()
        for i in range(v):
            G.add_node(i)
        for i in range(e):
            G.add_edge(s[i], t[i], t=d[i])
        
        plt.figure()
        plt.style.use('seaborn')
        plt.axis("off")
        pos = nx.spring_layout(G)
        nodes = nx.draw_networkx_nodes(G, pos, node_color='w', linewidths=2)
        nx.draw_networkx_labels(G, pos)
        nodes.set_edgecolor('black')
        nx.draw_networkx_edges(G, pos)
        nx.draw_networkx_edge_labels(G, pos)
        plt.show()

if os.environ.get('ZEPPELIN_HOME'):
    with open('/tmp/input1') as f:
        print('Example #1')
        input(f)
        visualize()

if os.environ.get('ZEPPELIN_HOME'):
    with open('/tmp/input2') as f:
        print('Example #2')
        input(f)
        visualize()

if os.environ.get('ZEPPELIN_HOME'):
    with open('/tmp/input3') as f:
        print('Example #3')
        input(f)
        visualize()

import sys


def init():
    global inf, mincost
    inf = sys.maxint
    mincost = [inf]*v

def update():
    updated = False
    for i in range(e):
        if mincost[s[i]] is not inf:
            c = mincost[s[i]] + d[i]
            if mincost[t[i]] > c:
                mincost[t[i]] = c
                updated = True
    return updated

def solve():
    init()
    
    mincost[r] = 0
    flag = True
    for i in range(v):
        if not update():
            flag = False
            break
    
    if flag:
        print('NEGATIVE CYCLE')
    else:
        for x in mincost:
            if x is inf:
                print('INF')
            else:
                print(x)

if os.environ.get('ZEPPELIN_HOME'):
    os.environ['INPUT'] = '/tmp/input1'

with open(os.environ.get('INPUT') or '/dev/stdin') as f:
    input(f)
    solve()

if os.environ.get('ZEPPELIN_HOME'):
    os.environ['INPUT'] = '/tmp/input2'

    with open(os.environ.get('INPUT') or '/dev/stdin') as f:
        input(f)
        solve()

if os.environ.get('ZEPPELIN_HOME'):
    os.environ['INPUT'] = '/tmp/input3'

    with open(os.environ.get('INPUT') or '/dev/stdin') as f:
        input(f)
        solve()



Measured memory_bytes: 5184
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int x;cin>>x;
    if(x>=30)cout<<"Yes"<<nnn;
    else cout<<"No"<<nnn;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

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

int main(void){
	string s;
	cin>>s;
	vector<vector<ll>> dp;
	rep(i,100005){
		dp.push_back(vector<ll>());
		rep(j,14){
			dp[i].push_back(0);
		}
	}
	rep(i,s.size()){
		if(i==0){
			if(s[0] == '?'){
				rep(j,10){
					dp[0][j] = 1;
				}
				for(int j=10; j<=12; j++){
					dp[0][j] = 0;
				}
			}else{
				rep(j,13){
					dp[0][j] = 0;
				}
				dp[0][s[0] - '0'] = 1;
			}
			continue;
		}
		if(s[i] == '?'){
			rep(j,13){
				rep(k, 10){
					dp[i][(j*10+k)%13] += dp[i-1][j];
					dp[i][(j*10+k)%13] %= MOD;
				}
			}
		}else{
			rep(j,13){
				dp[i][((j*10+(s[i]-'0')))%13] += dp[i-1][j];
				dp[i][((j*10+(s[i]-'0')))%13] %= MOD;
			}
		}
	}
	cout<<dp[s.size()-1][5]<<endl;
	return 0;
}


Measured memory_bytes: 17328
#include <bits/stdc++.h>
#include <atcoder/fenwicktree>

using namespace std;
using namespace atcoder;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  fenwick_tree<long long> fw(n);
  for (int i = 0; i < n; i++) {
    long long foo;
    cin >> foo;
    fw.add(i, foo);
  }
  while (q--) {
    int op;
    cin >> op;
    if (!op) {
      int p;
      long long x;
      cin >> p >> x;
      fw.add(p, x);
    } else {
      int l, r;
      cin >> l >> r;
      cout << fw.sum(l, r) << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 8260
import sys
input = sys.stdin.readline
mod = 998244353
n = int(input())
XY = sorted(tuple(map(int, input().split())) for _ in range(n))
X, Y = zip(*XY)
L = {y:i+1 for i, y in enumerate(sorted(Y))}
Y = tuple(L[y] for y in Y)
BIT = [0]*(n+1)
def add(i):
  while i<=n:
    BIT[i] += 1
    i += i&-i
def acc(i):
  res = 0
  while i:
    res += BIT[i]
    i -= i&-i
  return res
A = [0]*n
B = [0]*n
C = [0]*n
D = [0]*n
for i, y in enumerate(Y):
  A[i] = acc(y)
  B[i] = i - A[i]
  add(y)
BIT = [0]*(n+1)
for i in range(n-1, -1, -1):
  y = Y[i]
  C[i] = acc(y)
  D[i] = n-1-i - C[i]
  add(y)
ans = pow(2, n-1, mod) * n % mod
for a, b, c, d in zip(A, B, C, D):
  a = pow(2, a, mod)
  b = pow(2, b, mod)
  c = pow(2, c, mod)
  d = pow(2, d, mod)
  temp = (a-1)*b*c*(d-1) + a*(b-1)*(c-1)*d - (a-1)*(b-1)*(c-1)*(d-1)
  ans += temp
  ans %= mod
print(ans)

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

int n,t;
vector<vector<int>> M(101,vector<int>(101,0));
vector<int> color(101,0);
vector<int> d(101,0),f(101,0);

void dfs(int u){
    color[u]=1;
    d[u]=++t;
    for(int v=1;v<n+1;v++){
        if(M[u][v]&&color[v]==0){
            dfs(v);
        } 
    }
    color[u]=2;
    f[u]=++t;
}

int main(){
    cin>>n;
    for(int i=1;i<n+1;i++){
        int a,b,k;
        cin>>a>>k;
        for(int j=0;j<k;j++){
            cin>>b;
            M[a][b]=1;
        }
    }

    t=0;
    for(int i=1;i<n+1;i++){
        if(color[i]==0){
            dfs(i);
        }
    }

    for(int i=1;i<n+1;i++){
        cout<<i<<' '<<d[i]<<' '<<f[i]<<endl;
    }
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define pii pair<ll,ll>
#define piii pair<pii, int>
#define pb push_back
#define fs first
#define sc second
#define ppb pop_back
//#define LOCAL
//#define endl "\n"
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl

#define fifo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(int (i)=(a);(i)<=(b);++(i))
#define fd(i,a,b) for(int i=(a);i>=(b);--i)
const ll mod = 1e9+7;

// x>>1 is x/2  and x<<1 is x*2 



void solve()
{
	int n;
	cin>>n;
	vi v(n+1,0);

	for(int i=1,x;i<n;i++)
	{
		cin>>x;
		v[x]++;
	}

	for(int i=1;i<=n;i++)cout<<v[i]<<" ";
	cout<<endl;
}

int main()
{
	fifo
	int total=1;
	//cin>>total;
	for(int testcase=1;testcase<=total;testcase++)
	{
		solve();
	}



}


Measured memory_bytes: 3992
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

int gcd(int c,int d){
    return d ? gcd(d, c % d) : c;
}



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

    int s,w;
    cin >> s >> w;

    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;

}



Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#define mod 998244353
#define PI acos(-1.0)
typedef long long ll;
typedef unsigned long long ull;
const int INF=0x3f3f3f3f;
//const ll INF=1000000000000000000;
//priority_queue<int, vector<int>, greater<int> >p;
int main()
{
    int a,b,c,x,y,z;
    cin>>a>>b>>c;
    if(a>b)swap(a,b);
    if(a>c)swap(a,c);
    if(b>c)swap(b,c);
    x=c-a;
    y=c-b;
    if(x%2&&y%2)
    {
        cout<<x/2+y/2+1<<endl;
    }
    else if(x%2)
    {
        cout<<(x+1)/2+y/2+1<<endl;
    }
    else if(y%2)
    {
        cout<<x/2+1+(y+1)/2<<endl;
    }
    else
    {
        cout<<x/2+y/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin >> n;
  
    int ans = 0;
    int tag = 0;
    int val = -1;

    for(int i=0;i<n;i++)
    {
        cin >> x;
        if(x == val)
            tag++;
        else
        {
            ans += tag/2;
            tag = 1;
            val = x;
        }
    }

    ans += tag/2;

    cout << ans << endl;
}

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

#define a_b_MAX   (3)

typedef long long ll;

int matrix[a_b_MAX][a_b_MAX];

bool calcInformation(int max) {
    int a1, a2, a3, b1, b2, b3;
    for (a1 = 0; a1 <= max; a1++) {
        b1 = matrix[0][0] - a1;
        b2 = matrix[0][1] - a1;
        b3 = matrix[0][2] - a1;
        a2 = matrix[1][0] - b1;
        a3 = matrix[2][0] - b1;

        if (a1 + b1 == matrix[0][0] && a1 + b2 == matrix[0][1] && a1 + b3 == matrix[0][2]
        && a2 + b1 == matrix[1][0] && a2 + b2 == matrix[1][1] && a2 + b3 == matrix[1][2]
        && a3 + b1 == matrix[2][0] && a3 + b2 == matrix[2][1] && a3 + b3 == matrix[2][2]) {
            return true;
        }
    }
    return false;
    
}

int main()
{
    bool result = false;
    int max = 0;
    for (int i = 0; i < a_b_MAX; i++) {
        for (int j = 0; j < a_b_MAX; j++) {
            cin >> matrix[i][j];
            if (max < matrix[i][j]) {
                max = matrix[i][j];
            }
        }
    }

    result = calcInformation(max);
    if (result) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;

}


Measured memory_bytes: 256
Option Strict On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim M As Integer = NextInt()

        Dim A As String() = New String(N - 1) {}
        Dim B As String() = New String(M - 1) {}

        For i As Integer = 0 To N - 1
            A(i) = ReadLine()
        Next

        For i As Integer = 0 To M - 1
            B(i) = ReadLine()
        Next

        Dim ans As String = "No"

        For Ni As Integer = 0 To N - 1
            For Nj As Integer = 0 To N - 1
                If Judge(A, B, Ni, Nj) Then
                    ans = "Yes"
                    Exit For
                End If
            Next
            If ans = "Yes" Then Exit For
        Next

        WriteLine(ans)
    End Sub

    Function Judge(A As String(), B As String(), Ni As Integer, Nj As Integer) As Boolean
        Dim N As Integer = A.Length
        Dim M As Integer = B.Length

        For i As Integer = 0 To M - 1
            For j As Integer = 0 To M - 1
                If Ni + i >= N OrElse Nj + j >= N Then Return False
                If B(i)(j) <> A(Ni + i)(Nj + j) Then Return False
            Next
        Next

        Return True
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 19920
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N, x;cin>>N>>x;
    vec_int A(N); rep(i,N)cin>>A.at(i);

    int tot = 0;

    for(int i=0;i<N;i++){
        if(A.at(i)>x){
            tot+=A.at(i)-x;
            A.at(i) = x;
        }
    }

    for(int i=1;i<N;i++){
        if(A.at(i)+A.at(i-1)>x){
            tot+=A.at(i)+A.at(i-1)-x;
            A.at(i) = x-A.at(i-1);
        }
    }
    cout<<tot<<endl;



    return 0;
}

Measured memory_bytes: 3948
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	
	long long int N, K, res = -1000000009;
	vector<long long int> P, C;
	vector<vector<long long int>> loopLS;
	vector<vector <long long int>> DP;
	cin >> N >> K ;
 
	P.resize(N+1);
	C.resize(N+1);
	loopLS.resize(N+1);	
 
	for(int i = 1; i<N+1; i++){
		long long int tmp;
		cin >> tmp;
		P[i] = tmp;
	}
	for(int i = 1; i<N+1; i++){
		long long int tmp;
		cin >> tmp;
		C[i] = tmp;
	}
 
	for(int i = 1; i<N+1; i++){
		int tmpIdx = i, loopLength = 0;
		long long int loopSum = 0;
		rep(j, N+1){
			tmpIdx = P[tmpIdx];
			loopSum += C[tmpIdx];
			if(tmpIdx == i){
				loopLength = j+1;
				loopLS[i].push_back(loopLength);
				loopLS[i].push_back(loopSum);
				break;
			}
		}

	}
 
	for(int i = 1; i<N+1; i++){
		int tmpIdx = i;
		long long int sum = 0;
		rep(j, N+1){
			if(j+1 > K){
				break;
			}
			tmpIdx = P[tmpIdx];
			sum += C[tmpIdx];
			
			if(loopLS[i][1] <= 0){
				res = max(res, sum);
			}else{
				res = max(res, sum + loopLS[i][1] * ((K-(j+1))/loopLS[i][0]));
			}
			
		}
		
	}
 
	
	cout << res;
 
	return 0;
}

Measured memory_bytes: 3960
#include <iostream>
#include <cstdio>
#include <cmath>

int main(){
	while(1){
		int x, h;
		double s=0;
		
		scanf(" %d %d", &x, &h);
		if(x==0) break;
		
		s += x*x;
		
		double r = sqrt(h*h + x*x/4.0);
		s += x*r*2; 
	
		printf("%lf\n", s);	
	}

	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int x, y, xx = 0, yy = 0;
  cin >> x >> y;
  int a[4];
  a[0] = 4;
  a[1] = 6;
  a[2] = 9;
  a[3] = 11;
  if(x == y){
    cout << "Yes\n";
    return 0;
  }
  if(x == 2){
    cout << "No\n";
    return 0;
  }
  if(y == 2){
    cout << "No\n";
    return 0;
  }
  rep(i, 0, 4){
    if(x == a[i]){
      xx++;
      break;
    }
  }
  rep(i, 0, 4){
    if(y == a[i]){
      yy++;
      break;
    }
  }
  
  if(xx == yy){
    cout << "Yes\n";
    return 0;
  }
  cout << "No";
}


Measured memory_bytes: 3632
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    d,t,s=map(int, readline().rstrip().split())
    if (s*t) >= d:
        print("Yes")
    else:
        print("No")
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16124
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define vi                    vector<int>
#define fr(x,y) for(int x=0; x<(y); ++x)
#define fr2(x,z,y) for(int x=z; x<(y); ++x)
#define Rabee_Adel          file();
const double PI = acos(-1), EPS = 1e-7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x%y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y))*y); }
ll mod = 998244353;
ll power(ll x, ll y){if (y == 0)return 1;if (y == 1)return x;ll r = power(x, y / 2) % mod;return r%mod*r%mod*power(x, y % 2) % mod;}
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
int main()
{
	
	Rabee_Adel
		int k;
		int n, m;
		cin >> k >> n >> m;
		fr2(i, n, m + 1){
			if (i % k == 0)RT("OK");
		}
		cout << "NG";
}

Measured memory_bytes: 3616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    KEYENCE2020B solver = new KEYENCE2020B();
    solver.solve(1, in, out);
    out.close();
  }

  static class KEYENCE2020B {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n = in.nextInt();
      ArrayList<Pair> al = new ArrayList<>();
      for (int i = 0; i < n; i++) {
        int x = in.nextInt();
        int l = in.nextInt();
        al.add(new Pair(x - l, x + l));
      }
      Collections.sort(al);
      int res = 1;
      int point = al.get(0).y;
      for (int i = 1; i < n; i++) {
        if (point <= al.get(i).x) {
          res++;
          point = al.get(i).y;
        }
      }
      out.println(res);
    }

  }

  static class Pair implements Comparable<Pair> {

    int x;
    int y;

    Pair(int x, int y) {
      this.x = x;
      this.y = y;
    }

    public int compareTo(Pair p) {
      return Integer.compare(this.x, p.x) + Integer.compare(this.y, p.y) * 2;
    }

    public String toString() {
      return this.x + " " + this.y;
    }

  }
}



Measured memory_bytes: 88472
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      
      // 整数の取得
	  int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      
      if(a==b+c){
        System.out.println("Yes");
      }else if(b==a+c){
        System.out.println("Yes");
      }else if(c==a+b){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 35588