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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.1415926535897932384626

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

#define INF 1000000005
#define mod 1000000007

using namespace std;

int n, x, y, gmc = INF, smc = INF, gg = -1, sg = -1;
vector<int> v[200005];

int ans = 1;
int fact[200005], inv[200005];

int po(int a, int b){
	int c = 1, d = a;
	while(b){
		if(b & 1) c = 1LL * c * d % mod;
		d = 1LL * d * d % mod;
		b >>= 1;
	}
	return c;
}

vector<int> u;

int main(){
	fact[0] = inv[0] = 1;
	FI(i, 1, 200000){
		fact[i] = 1LL * fact[i - 1] * i % mod;
		inv[i] = po(fact[i], mod - 2);
	}
	
	scanf("%d %d %d", &n, &x, &y);
	FI(i, 1, n){
		int a, b;
		scanf("%d %d", &a, &b);
		v[a].push_back(b);
	}
	FI(i, 1, n) sort(v[i].begin(), v[i].end());
	
	FI(i, 1, n){
		int sz = v[i].size();
		if(sz){
			if(v[i][0] < gmc){
				smc = gmc, sg = gg;
				gmc = v[i][0], gg = i;
			}
			else if(v[i][0] < smc){
				smc = v[i][0], sg = i;
			}
		}
	}
	
	FI(i, 1, n){
		int sz = v[i].size();
		if(sz){
			if(i == gg && v[i][0] + smc > y) continue;
			if(i != gg && v[i][0] + gmc > y) continue;
			
			//this color mobile
			int c = 1;
			FI(j, 1, sz - 1){
				if(v[i][j] + v[i][0] <= x) c++;
				else if(i == gg && v[i][j] + smc <= y) c++;
				else if(i != gg && v[i][j] + gmc <= y) c++;
				else break;
			}
			u.push_back(c);
		}
	}
	
	int summ = 0, sz = u.size();
	FI(i, 0, sz - 1) summ += u[i];
	ans = fact[summ];
	FI(i, 0, sz - 1) ans = 1LL * ans * inv[u[i]] % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11520
K,A,B=map(int,input().split())
c=1

if A+2<B:
    if K<=A:
        print(1+K)
    else:
        K-=A-1
        c+=A-1
    #    print(c)
        if K%2:
            K-=1
            c+=1
        c+=K//2*(B-A)
        print(c)
else:
    print(1+K)


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

int erase(vector<vector<int>> &m)
{
	int sc=0;
	for(vector<int> &l : m){
		for(int x=0;x<3;x++){
			int n=l[x];
			if( l[x+1]==n && l[x+2]==n){
				for(int i=x;i<5;i++){
					if( l[i]==n ){
						sc+=l[i];
						l[i]=0;
					}else{
						break;
					}
				}
				break;
			}
		}
	}
	return sc;
}

void fall(vector<vector<int>> &m)
{
	int h=m.size();
	for(int x=0;x<5;x++){
		int fa=0;
		for(int y=h-1;y>=0;y--){
			if( m[y][x]==0){
				fa++;
			}else{
				if( fa>0 ){
					swap(m[y][x],m[y+fa][x]);
				}
			}
		}
	}
}

int f(vector<vector<int>> &m)
{
	int total=0;
	while(true){
		int sc = erase(m);
		if(sc==0)break;
		total+=sc;
		fall(m);
	}
	return total;
}

int main() {
	
	while(true)
	{
		int n;
		cin >> n;
		if(n==0)break;
		
		vector<vector<int>> m;
		for(int i=0;i<n;i++){
			vector<int> l;
			for(int j=0;j<5;j++){
				int x;
				cin >> x;
				l.push_back(x);
			}
			m.push_back(l);
		}
		int sc=f(m);
		cout << sc << endl;
	}	
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 1216
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = in.nextInt();
		}
		int[] copy = Arrays.copyOf(arr, arr.length);
		Arrays.sort(copy);

		int left = 0, right = n;
		long x = (long)n * (long)(n + 1) / 4;
		while(left + 1 < right) {
			int mid = (left + right) / 2;
			int am = copy[mid];
			int[] s = new int[n + 1];
			for (int i = 0; i < n; i++) {
				s[i + 1] = am <= arr[i] ? 1 : -1;
			}
			for (int i = 1; i < n + 1; i++) {
				s[i] += s[i - 1];
			}
			BIT bit = new BIT(2 * n + 1);
			long sum = 0;
			for (int i = 0; i < n + 1; i++) {
				sum += bit.sum(s[i] + n);
				bit.add(s[i] + n, 1);
			}
			if(x <= sum) {
				left = mid;
			} else {
				right = mid;
			}
		}
		System.out.println(copy[left]);
	}
}

class BIT {
	private long[] bit;
 
    public BIT(int size){
        bit = new long[size];
    }
 
    public long sum(int i){
        long s = 0;
        while(0 < i){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
 
    public void add(int i, long x){
        while(i < bit.length){
            bit[i] += x;
            i += i & -i;
        }
    }
}



Measured memory_bytes: 62232
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  long ans = 0;
  REP(i,n){
    long l,r;
    cin >> l >> r;
    ans += r-l+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n == 0) {
				break;
			}
			Kruscal g = new Kruscal(n);
			for(int i=0;i<m;i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int c = sc.nextInt();
				g.addBidirectionalEdge(a,b,c);
			}
			System.out.println(g.minCost());
		}
	}

}

class Kruscal {
	int n;
	ArrayList<Edge> graph = new ArrayList<Edge>();

	public Kruscal(int n) {
		this.n = n;
	}

	public void addBidirectionalEdge(int u,int v,int cost) {
		graph.add(new Edge(cost,u,v));
	}

	public int minCost() {
		Collections.sort(graph);
		UnionFind uf = new UnionFind(n);
		int ans = 0;
		int connected = 1;
		for(int i=0;i<graph.size();i++) {
			Edge e = graph.get(i);
			if (!uf.isConnected(e.from, e.to)) {
				uf.union(e.from, e.to);
				connected++;
				ans+=e.cost;
				if (connected==n) {
					break;
				}
			}
		}
		return ans;
	}

	static class Edge implements Comparable<Edge>{
		int cost;
		int from;
		int to;
		public Edge(int cost,int from,int to) {
			this.cost = cost;
			this.from = from;
			this.to = to;
		}
		@Override
		public int compareTo(Edge o) {
			if (this.cost == o.cost) {
				return 0;
			}else if(this.cost > o.cost) {
				return 1;
			}else{
				return -1;
			}
		}

		public String toString() {
			return this.cost + "," + this.from + "," + this.to;
		}
	}

	static class UnionFind {
		private int[] data;
		public UnionFind(int size) {
			data = new int[size];
			Arrays.fill(data, -1);
		}
		public void union(int x,int y) {
			x = root(x);
			y = root(y);
			if (x!=y) {
				if (data[y] < data[x]) {
					int tmp = y;
					y = x;
					x = tmp;
				}
				data[x] += data[y];
				data[y] = x;
			}
		}
		public boolean isConnected(int x,int y) {
			return root(x)==root(y);
		}
		private int root(int x) {
			return data[x] < 0 ? x : (data[x] = root(data[x]));
		}
		public int size(int x) {
			return -data[root(x)];
		}
		public String toString() {
			return Arrays.toString(data);
		}
	}
}

Measured memory_bytes: 23260
n,m,k = map(int, input().split())
mod = 998244353
def factorial(N,MOD,r=True):
    fact = [1]*(N+1)
    rfact = [1]*(N+1)
    r = 1
    for i in range(1,N+1):
        fact[i] = r = r * i % MOD
    rfact[N] = r = pow(fact[N],MOD-2,MOD)
    for i in range(N, 0, -1):
        rfact[i-1] = r = r * i % MOD
    if r:
        return fact,rfact
    else:
        return fact
fact,rfact = factorial(2*10**5,mod)

def perm(n,k): #上のfactorialと併用
    return fact[n]*rfact[n-k]%mod
def comb(n,k): #上のfactorialと併用
    return fact[n]*rfact[k]*rfact[n-k]%mod

ans = 0
now = pow(m-1,n-1-k)
for i in range(k,-1,-1):
    ans += comb(n-1,i)*now
    now *= (m-1)
    now %= mod
    ans %= mod

ans *= m
ans %= mod
print(ans)

Measured memory_bytes: 79152
#include<stdio.h>

int main(void)
{
	int i,a,b,c;
	int j=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			j++;
		}
	}
	printf("%d\n",j);
	
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;

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

    int W[300010],E[300010];
    W[0]=E[N-1]=0;
    for(int i=1;i<N;i++){
        if(S[i-1]=='W')W[i]=W[i-1]+1;
        else           W[i]=W[i-1];

        if(S[N-i]=='E')E[N-1-i]=E[N-i]+1;
        else           E[N-1-i]=E[N-i];
    }
    int ans=pow(10,9);
    for(int i=0;i<N;i++)
        ans=min(ans,W[i]+E[i]);
    cout<<ans<<endl;
    return 0;
    
}

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


int main()
{
  int n;
  cin >> n;
  int ans = 0;
  for (int i=1; i<=n; i++)
  {
    int j = i, c = 0;
    while (j > 0)
    {
      j /= 10;
      c++;
    }
    if (c % 2)
      ans ++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
long long N;
cin>>N;
long long A[N];
bool flag=0;
long long sum=0;
long long count=0;
long long temp;
for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]%2==0){
        flag=1;
    }
}
if(flag){
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
                temp=A[i]/2;
        count++;
            while(temp%2==0)
            {

                temp=temp/2;
                count++;
            }
        }
        sum+=count;
    }
    cout<<count;

}
else
    cout<<"0";

}



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

 using namespace std;
 
 #define inf (INT_MAX)
 #define ninf (INT_MIN)
 #define inf64 ((1<<63)-1)
 #define ll long long
 #define mpr make_pair
 #define mtp make_tuple
 #define pb emplace_back
 #define rep(i,n) for(int i=0;i<(int)(n);i++)

 #define _tab '\t'
 #define $ <<_tab<<

 #define cinarr(A,len) for(int i=0;i<len;i++){cin>>A[i];}
 #define coutarr(A,len) for(int i=0;i<len;i++){cout<<A[i]<<' ';}cout<<endl
 #define coutin(V) for(auto& i : V){cout << i << ' ';}cout<<endl // for vect and set
 #define coutmap(U) for(auto& i : U){cout << i.first << "->" << i.second << ", ";}cout<<endl // for map

 // DEBUG
 #define deb(x) cout << #x << '\t' << x << endl

 // ==== fast function ====
 /*
 #define sortsec(T1,T2) [](const pair<T1,T2> &a,const pair<T1,T2> &b){ return a.second<b.second;}
 #define sortsecgreater(T1,T2) [](const pair<T1,T2> &a,const pair<T1,T2> &b){ return a.second>b.second;}
 */
 //ll middle3(ll a,ll b,ll c){if(a>b){if(b>c){return b;}else if(a>c){return c;}else{return a;}}else{if(a>c){return a;}else if(b>c){return c;}else{return b;}}}

/*========================================================================*/
/* strategi/note:



/================================*/



bool solved=0;
void solve(){solved=1;
    string n;
    cin >> n ;
    int sum = 0;
    for(char c:n){
        sum += (c-'0');
        sum %= 9;
    }
    cout << (sum==0?"Yes":"No") << endl;
}

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

	solve();
//	int t;cin>>t;while(t--){solve();}

     if(!solved)cout<<"solve() function blm dipanggil!"<<endl;
	 //cout.flush(); cin.get();
     return 0;
}


Measured memory_bytes: 3784
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

ans = 0
for i in range(n):
    ans += abs(x[i] - y[i])
print(ans)

ans = 0
for i in range(n):
    ans += (x[i] - y[i])**2
ans = ans**0.5
print(ans)

ans = 0
for i in range(n):
    ans += abs(x[i] - y[i])**3
ans = ans**(1/3)
print(ans)

ans = 0
for i in range(n):
    if abs(x[i] - y[i]) > ans: ans = abs(x[i] - y[i])
print(ans)



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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int z, w;
	cin >> z >> w;
	vector<int> a(n);
	for (int& x : a)
		cin >> x;
	if (n == 1)
		cout << abs(w - a[n - 1]) << endl;
	else
		cout << max(abs(w - a[n - 1]), abs(a[n - 1] - a[n - 2]));
}


Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>
#include<unordered_map>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int n,m,ans= 0;
vector<vector<bool>> da(8, vector<bool>(8));

bool check(vector<int> &now){
	// vdeb(now);
	rip(i,n-1,0){
		if(da[now[i]][now[i+1]] == 0) return false;
	}
	return true;
}

void rec(vector<int> &now, vector<bool> &ju, int next){
	if(next == n){
		// vdeb(now);
		if(check(now)) ans++;
		return;
	}
	rip(i,n,0){
		if(ju[i]){
			ju[i] = false;
			now[next] = i;
			rec(now, ju, next+1);
			ju[i] = true;
		}
	}
	return;
}

int main(){
	cin >> n >> m;
	rip(i,m,0){
		int a,b;cin >> a >> b;
		a--;b--;
		da[b][a] = 1;
		da[a][b] = 1;
	}
	vector<int> now(n);
	vector<bool> ju(n, true);
	ju[0] = false;
	rip(i,n,0) now[i] = i;
	// next_permutation
	rec(now, ju, 1);
	// vdeb(da);
	cout << ans << endl;
}

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

typedef complex<double> Point;
typedef vector<Point> VP;

// 点集合を含む最小の円の中心
Point minEnclosingCircle(const VP& ps) {
    Point c;
    double move = 0.5;
    rep(i,39) {  // 2^(-39-1) \approx 0.9e-12
        rep(t,100) {
            double max = 0;
            int k = 0;
            rep (j, ps.size()) if (max < norm(ps[j]-c)) {
                max = norm(ps[j]-c);
                k = j;
            }
            c += (ps[k]-c) * move;
        }
        move /= 2;
    }
    return c;
}


int main(void){
    int n;
    cin >> n;
    VP ps(n);
    rep(i,n){
        double x, y;
        cin >> x >> y;
        ps[i] = Point(x,y);
    }
    Point c = minEnclosingCircle(ps);
    double r = 0;
    rep(i,n){
        r = max(r, abs(c-ps[i]));
    }
    printf("%.10f\n",r);
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

LLI a[100003];

int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    LLI answer = 1000000000000000000;
    LLI sum = 0;
    for (int i = k - 1; i < n; i++)
    {
        LLI first = a[i];
        LLI second = a[i - (k - 1)];
        // cout << first << " " << second << " ";
        sum = abs(first - second);
        if (first <= 0 && second <= 0)
        {
            sum = sum + abs(first);
        }
        if (first >= 0 && second >= 0)
        {
            sum = sum + abs(second);
        }
        if ((first <= 0 && second >= 0) || (first >= 0 && second <= 0))
        {
            sum = sum + min(abs(first), abs(second));
        }
        // cout << sum << "\n";
        answer = min(answer, sum);
    }
    cout << answer;
    return 0;
}

Measured memory_bytes: 1024
// O O O O O O O O O O O O O O O OO O OO O OO O O O TTCH O TTTCH O TTTCH O O O O
#pragma GCC optimize("Ofast")
// #pragma GCC optimize("no-stack-protector")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
#include <cassert>

using namespace std;

// #define int long long
#define double long double
#define less less228
#define left left228
#define right right228

template<typename T> void uin(T &a, T b) {
    if (b < a) a = b;
}
template<typename T> void uax(T &a, T b) {
    if (b > a) a = b;
}


random_device rnd;

template<typename T> void shuffle(vector< T > &v) {
    for (int i = 1; i < (int)v.size(); ++i) {
        swap(v[rnd() % i], v[i]);
    }
    for (int i = (int)v.size() - 1; i; --i) {
        swap(v[rnd() % i], v[i]);
    } 
}

const int N = 100 * 1000 + 228;

bool red[N];
int cnt[N];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
     
        cnt[i] = 1;
    }
    red[1] = 1;
    while(m--) {
        int x, y;
        cin >> x >> y;
        if (red[x]) {
            red[y] = 1;
            if (cnt[x] == 1) {
                red[x] = 0;
            }
        }
        --cnt
        [x];
        ++cnt[y];
    }
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        res += red[i];
    }
    cout << res << '\n';
    return 0;
}
// RU_023

/*
6 5 2
5 1 3 6 2 4
1 3
1 6
3 5
4 5
2 2

3 3 5
1 12 6
1 3
2 3
1 2

shironury

boootgslkfjdaojfdopsjfopjso
pgjq]pogjopsjg\qrwjopg
j
pogjqwrjgp]oqwjjqw]pjljfojpjowjow4jgopja    ohbip]aeo'rogpoaj0
[bkrw
pР С‘Р С—РЎС“РЎРѓРЎвЂљРЎРЉР В±РЎС“Р Т‘Р ВµРЎвЂљРЎР‚РЎС“Р С”Р В°РЎвЂљР Р†Р С•РЎРЏРЎвЂљР Р†Р ВµРЎР‚Р Т‘Р В°ojgqwjp\\j\;sync_with_stdiojp
ojeofmpworuc[owejgoprwig
[sdkz
pgj
p[gjes
p0ghjqsp[

jg
prsjgopjg]prwjgoprejgopjrepogjrepog]jgoprejgrgjporeqjgoperjgoprejgopeqrjgopeqrjgoprqwjgpoqjrwsopt4ng\ojsbjsoprnbfqsn\bvhqerpogjorwo
pwewh\rwh \wjiowe orw jop jgr\p jpj o jopj gr\pj p gjop j\pj\pe jp'oj [
 k
 p[eq   fj\pjfdwj\ejopjojopjopjf;'djpfsj, ipojs\p gpsdigsj gorkgjgjrogjdojgiao'fsdvopdshpdfidopcnweojccodj [cjd;ofjd[jdspmcojc"ajno[:Afvoq[w0shbprs`nm/jP{Vadmn;'fnc[Ajojsfpfjcffor 9int i= ; 1 < nfor (int i =1; for (int i =1 ; i <= n: ++i) frfor (int j = 1; j <= ml; ++'}]]]]]]]]]
5
1 5
1 2
2 3
2 
4
*/

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

int main()
{
	int n, m;
	vector<int> vec;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> m;
		vec.push_back(m);
	}

	int maxv = -2000000000;
	int minv = vec[0];

	for (unsigned int i = 1; i < vec.size(); ++i)
	{
		maxv = max(maxv, vec[i] - minv);
		minv = min(minv, vec[i]);
	}

	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
#define int long long
using P = pair<int,int>;

signed main(){
  int h,w;
  cin >> h >> w;
  vvint c(10,vint(10));
  rep(i,10) rep(j,10){
    cin >> c[i][j];
  }
  rep(k,10) rep(i,10) rep(j,10){
    c[i][j] = min(c[i][j],c[i][k] + c[k][j]);
  }
  int ANS = 0;
  vvint A(h,vint(w));
  rep(i,h) rep(j,w){
    cin >> A[i][j];
  }
  rep(i,h) rep(j,w){
    if(A[i][j] >= 0){
      ANS += c[A[i][j]][1];
    }
  }
  cout << ANS << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

Node *treeMinimum(Node *x){
    while(x->left != NIL) x = x->left;
    return x;
}

Node *treeSuccessor(Node *x){
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z){
    Node *y;
    Node *x;

    if( z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);

    if(y->left != NIL){
        x = y -> left;
    } else{
        x = y -> right;
    }

    if(x != NIL){
        x->parent = y->parent;
    }

    if(y->parent == NIL){
        root = x;
    } else{
        if(y == y->parent->left){
            y->parent->left = x;
        }else{
            y->parent->right = x;
        }
    }

    if(y != z){
        z->key = y->key;
    }
    free(y);
}

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

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

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


bool find(Node *x, int u){
    if(x == NIL) return false;
    else if(x->key == u) return true;
    else if(u < x->key){
        return find(x->left,u);
    }else{
        return find(x->right,u);
    }
}



void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u){
    if(u == NIL) return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

Node *pick(Node *u, int k){
    while(u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

int main(){
    int n,x;
    string com;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> com;
        if(com == "insert"){
            cin >> x;
            insert(x);
        }else if(com == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }else if(com == "find"){
            cin >> x;
            if(find(root,x)) cout << "yes" << endl;
            else cout << "no" << endl;
        }else if(com == "delete"){
            cin >> x;
            treeDelete(pick(root,x));
        }
    }

    return 0;
}





Measured memory_bytes: 21936
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)


using namespace std;
int h,w;
// float f,g,h;
long long a,b,c,k;

vector<vector<char>> v;
int main(int argc, char const *argv[])
{
  char c;
  cin >>h >> w;
  rep(i, h){
    vector<char> vv;
    rep(j,w){
      cin >> c;
      vv.push_back(c);
    }
    v.push_back(vv);
  }
bool ok = true;
bool tmp = false;
  rep(i, h){
    // vector<char> vv;
    rep(j,w){
      tmp = false;
      // if(v[i][j] == '#')no = false;
      if(v[i][j] =='.')continue;
      if(i > 0 && h >1 && v[i-1][j] == '#')tmp = true;
      if(j > 0 &&  w > 1&&v[i][j-1] == '#')tmp = true;
      if(i < h-1 &&  h > 1&&v[i+1][j] == '#')tmp = true;
      if(j < w-1 &&  w > 1&&v[i][j+1] == '#')tmp = true;
      if(tmp == false)ok = false;
    }
  }

if(ok){
  cout << "Yes" <<endl;
}else{
  cout << "No" << endl;
}

  return 0;
}

Measured memory_bytes: 256
S = input()
l = [0] * (len(S) + 1)
l[1] = 1
l[2] = 1 if S[0] == S[1] else 2
for i in range(3, len(S)+1):
    if S[i-1] != S[i-2]:l[i] = l[i-1] + 1
    else:l[i] = l[i-3] + 2
print(l[-1])


Measured memory_bytes: 11240
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

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

const ll MOD = ll(1e9 + 7);
const ll INF = LLONG_MAX;
const ll MAX_N = ll(1e3) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    int x,t;
    cin >> x >> t;
    cout << max(0,x-t) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
map<int ,list<int> > tree ;
int dp[100005][2] ; 
#define MOD 1000000007 
 
long long int solve_correct(int u,bool constraint,int pr){
   //we will pass the parent every tiue . 
    
    if(dp[u][constraint]!=-1){
        return dp[u][constraint] ; 
    }
    
    long long int ans = 0 ; long long int v1 = 1 ;
    for(auto p:tree[u]){
        if(p!=pr){
            v1 = (v1*solve_correct(p,0,u))%MOD ; 
        }
    }
    ans=(ans+v1)%MOD ;
    if(!constraint){
        long long int v2 = 1 ; 
         for(auto p:tree[u]){
             if(p!=pr){
                 v2 = (v2*solve_correct(p,1,u))%MOD ; 
             }
         }
    ans = (ans+v2)%MOD ;
    }
    
  return dp[u][constraint] = ans ; 

}
int main(){
    int n ; cin>>n ; 
      memset(dp,-1,sizeof(dp)) ;
    for(int i =1 ; i<=n-1 ;i++){
        int x,y ; cin>>x>>y ; 
        tree[x].push_back(y) ; 
        tree[y].push_back(x) ; 
    }
    //as it is indeed a bidirections tree .  
    cout<<solve_correct(1,0,-1) ; 
}

Measured memory_bytes: 23296
import sys

n, k = [int(x) for x in input().split()]
s = input()
l = [0]
a = '1'
for i in range(n):
  if s[i] != a:
    l.append(i)
    a = s[i]
l.append(n)
if s[-1] == '0':
  l.append(n)
if len(l) < 2 * k + 2:
  print(n)
  sys.exit()
a, ans = 0, 0
while a + 2 * k + 1 < len(l):
  b = l[a+2*k+1] - l[a]
  if ans < b:
    ans = b
  a += 2
print(ans)

Measured memory_bytes: 7160
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int t,n,i,j,k=1e9+7,l=0,x=0;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++) cin>>a[i];
  x=a[0];
  for(i=1;i<n;i++)
  {
    if(a[i]<x)
    {
      l+=(x-a[i]);
    }
    else
     x=a[i];
  }
  cout<<l;
}

Measured memory_bytes: 5200
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,u,v;
ll depth[100010];
ll par[100010];
vector<ll> edges[100010];
void SetDepth(ll v){
    depth[v]=depth[par[v]]+1;
    for(auto e:edges[v]){
        if(depth[e]==INF){
            par[e]=v;
            SetDepth(e);
        }
    }
}
ll MaxDepth(ll v){
    ll ret=depth[v];
    for(auto e:edges[v]){
        if(e!=par[v]){
            ret=max(ret,MaxDepth(e));
        }
    }
    return ret;
}
int main(){
    cin>>N>>u>>v;
    for(ll i=0;i<N-1;i++){
        ll a,b;
        cin>>a>>b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    for(ll i=1;i<=N;i++){
        depth[i]=INF;
    }
    depth[0]=-1;
    par[v]=0;
    SetDepth(v);
    ll n=u;
    ll upCnt=(depth[u]-1)/2;
    for(ll i=0;i<upCnt;i++){
        n=par[n];
    }
    cout<<upCnt+(MaxDepth(n)-depth[n])+(depth[u]%2?0:1)<<endl;
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

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

    sort(h.begin(), h.end());
    int ans = 1e9;
    for(int i = 0; i + k - 1 < n; i++)
    {
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;

class Main
{
	public static void main(String[] args) throws IOException
	{
		Scan in = new Scan();
		Print out = new Print();
		int n = in.scanInt();
		int m = in.scanInt();
		int sum = 0;
		for(int i=0; i<m; i++) {
			sum += in.scanInt();
		}
		n -= sum;
		out.println((n<0) ? -1 : n);
		out.close();
	}
}

class Scan
{
	private byte[] buf=new byte[1024];
	private int index;
	private InputStream in;
	private int total;
	public Scan()
	{
		in=System.in;
	}
	public int scan()throws IOException
	{
		if(total<0)
			throw new InputMismatchException();
		if(index>=total)
		{
			index=0;
			total=in.read(buf);
			if(total<=0)
				return -1;
		}
		return buf[index++];
	}
	public int scanInt()throws IOException
	{
		int integer=0;
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n))
		{
			if(n>='0'&&n<='9')
			{
				integer*=10;
				integer+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}
	public double scanDouble()throws IOException
	{
		double doub=0;
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n)&&n!='.')
		{
			if(n>='0'&&n<='9')
			{
				doub*=10;
				doub+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		if(n=='.')
		{
			n=scan();
			double temp=1;
			while(!isWhiteSpace(n))
			{
				if(n>='0'&&n<='9')
				{
					temp/=10;
					doub+=(n-'0')*temp;
					n=scan();
				}
				else throw new InputMismatchException();
			}
		}
		return doub*neg;
	}
	public String scanString()throws IOException
	{
		StringBuilder sb=new StringBuilder();
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		while(!isWhiteSpace(n))
		{
			sb.append((char)n);
			n=scan();
		}
		return sb.toString();
	}
	private boolean isWhiteSpace(int n)
	{
		if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
			return true;
		return false;
	}
}

class Print
{
	private final BufferedWriter bw;
	public Print()
	{
		this.bw=new BufferedWriter(new OutputStreamWriter(System.out));
	}
	public void print(Object object)throws IOException
	{
		bw.append(""+object);
	}
	public void println(Object object)throws IOException
	{
		print(object);
		bw.append("\n");
	}
	public void println()throws IOException
	{
		bw.append("\n");
	}
	public void close()throws IOException
	{
		bw.close();
	}
}

Measured memory_bytes: 36652
import sys


def main():
    input = sys.stdin.buffer.readline
    n, W = map(int, input().split())
    v = [0] * (n + 1)
    w = [0] * (n + 1)
    for i in range(1, n + 1):
        v_i, w_i = map(int, input().split())
        v[i], w[i] = v_i, w_i
    # dp[i][j]:=i個目までの品物から重さの総和がj以下になるように選ぶときの，価値の合計の最大理
    dp = [[0] * (W + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        for j in range(W + 1):
            if j - w[i] >= 0:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i])
            else:
                dp[i][j] = dp[i - 1][j]
    print(dp[n][W])


if __name__ == "__main__":
    main()



Measured memory_bytes: 25496
N,M=gets.split.map &:to_i
r=[[0,0]]
gets.split.map(&:to_i).sort.each do |a|
  if a == r[-1][0]
    r[-1][1] += 1
  else
    r << [a, 1]
  end
end
M.times do
  b, c = gets.split.map &:to_i
  r << [c, b]
end

sum = [0, N]
r.sort.reverse.each do |(c, b)|
  cnt = [sum[1], b].min
  sum[0] += c * cnt
  sum[1] -= cnt
end
p sum[0]

Measured memory_bytes: 25760
#include <stdio.h>
void call(int n)                                               
{                                                              
        int i, x;                                              
        for (i=1; i<=n ;i++) {                                 
                x = i;                                         
                if (x % 3 == 0) {                              
                        printf(" %d", i);                      
                        continue;                              
                }                                              
                do {                                           
                        if (x % 10 == 3) {                     
                                printf(" %d", i);              
                                break;                         
                        }                                      
                        x /= 10;                               
                } while (x);                                   
        }                                                      
        printf("\n");                                          
}

int main(void)                                                 
{                                                              
        char line[256];                                        
        int n;                                                 
                                                               
        if (!fgets(line, sizeof(line), stdin)) {               
                fprintf(stderr, "error input val\n");          
                return -1;                                     
        }                                                      
                                                               
        if (sscanf(line, "%d", &n) != 1) {                     
                fprintf(stderr, "error input format\n");       
                return -1;                                     
        }                                                      
                                                               
        call(n);                                               
        return 0;                                              
}

Measured memory_bytes: 604
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
//#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}

int n, m;

struct node {
    int v, next;
} e[maxn << 1];
int cnt, head[maxn];
int dis[maxn];

void init() {
    cnt = 0;
    memset(head, -1, sizeof(head));
    memset(dis, -1, sizeof(dis));
}

void add(int u, int v) {
    e[cnt].v = v;
    e[cnt].next = head[u];
    head[u] = cnt++;
}

bool bfs(int x) {
    queue<int> q;
    q.emplace(x);
    dis[x] = 0;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int i = head[u]; ~i; i = e[i].next) {
            int v = e[i].v;
            if (dis[v] == -1) {
                dis[v] = u;
                q.emplace(v);
            }
        }
    }
    for (int i = 2; i <= n; i++) {
        if (dis[i] == -1) {
            return false;
        }
    }
    return true;
}

int main(void) {
    FAST_IO;
    
    cin >> n >> m;    
    init();
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        add(u, v);        
        add(v, u);        
    }

    if (!bfs(1)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for (int i = 2; i <= n; i++) {
            cout << dis[i] << endl;
        }
    }
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<string> w(n);
  for (int i=0; i<n; i++){
    cin >> w.at(i);
  }
  
  bool con1 = true;
  bool con2 = true;
  
  for (int i=0;i<n;i++){
    for (int j=0;j<i;j++){
      if (w.at(i) == w.at(j)) con1 = false;
    }
  }
  
  char saigo = w.at(0).back();
  
  for (int i=1;i<n;i++){
    
    if (saigo != w.at(i).front()) con2 = false;
    
    saigo = w.at(i).back(); 
  }
  
  if (con1&&con2) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 1145141919;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator > (const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
int n; string s;

int main()
{
	while (cin >> n >> s, n)
	{
		bool f = false;
		int l = s.size() - 1;
		int ans = -1; vi ansv;
		REP(i, 1 << l)
		{
			int t = 0;
			int tmp = 0;
			vi v;
			REP(j, l)
			{
				if (((i >> j) & 1) == 1)
				{
					t += tmp*10 + (s[j] - '0');
					v.push_back(tmp*10 + (s[j] - '0'));
					tmp = 0;
				}
				else
				{
					tmp *= 10;
					tmp += s[j] - '0';
				}
			}
			t += tmp*10 + (s[l] - '0');
			v.push_back(tmp*10 + (s[l] - '0'));
			if (n >= t&&t > ans)
			{
				ans = t;
				ansv = v;
				f = false;
			}
			else if (t == ans) f = true;
		}
		if (f) puts("rejected");
		else if (ans == -1) puts("error");
		else
		{
			cout << ans;
			REP(i, ansv.size()) cout << " " << ansv[i];
			cout << endl;
		}
	next:;
	}
	return 0;
}

Measured memory_bytes: 1228
def resolve():
    n=int(input())
    a=list('abcdefghijklmnopqrstuvwxyz')
    ans=[]
    while n>0:
        n-=1
        ans.append(a[n%26])
        n//=26
    print(''.join(map(str,ans[::-1])))

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define maxn 100005
#define mod 998244353LL
#define inf 1000000007LL
namespace lib
{
	using namespace std;
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
			bool _useSTD;
		public:
			inline void ioSTD()
			{
				_useSTD=1;
				ios::sync_with_stdio(false);
				cin.tie(0),cout.tie(0);
			}
			inline void gc(char & _c)
			{
				if(_useSTD)cin>>_c;
				else _c=getchar();
			}
			inline void pc(char _c)
			{
				if(_useSTD)cout<<_c;
				else putchar(_c);
			}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_x=0;
					while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
					while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
					_f&&(_x=-_x,_f=0);
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_T _k;
					if(_x==0) {pc('0'),pc(' ');return *this;}
					if(_x<0) pc('-'),_x=-_x;
					while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
					while(_head>0) pc(_num[_head]),--_head;
					pc(' ');
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator >> (_T & _x) {cin>>_x;return *this;}
			template<typename _T> inline fastio & operator << (_T _x) {cout<<_x;return *this;}
			#define endln pc('\n')
		fastio() {_f=0,_head=0,_useSTD=0,_ch=' ';}
	}io;
	inline void fileio(string _r,string _w)
	{
		if(_r[0]!='-')freopen(_r.c_str(),"r",stdin);
		if(_w[0]!='-')freopen(_w.c_str(),"w",stdout);
	}
	#define mem(_x,_set) memset(_x,_set,sizeof(_x))
}using namespace lib;

signed main()
{
	// fileio("tt.in","tt.out");
	// io.ioSTD();
	int k,x;
	cin>>k>>x;
	if(k*500>=x){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) ? Yes() : No();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

int K,A,B; cin>>K>>A>>B;

bool ans=false;
for(int i=A;i<=B;i++){
  if(i%K==0) ans=true;
}

if(ans) cout <<"OK" << endl;
else cout <<"NG" << endl;

return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N, M;
    cin >> N >> M;
    vector<vector<int>> dp(2, vector<int>(1 << N, INF));
    dp[0][0] = 0;
    for(int loop = 0; loop < M; ++loop){
        int a, b;
        cin >> a >> b;
        int bitmask = 0;
        for(int i = 0; i < b; ++i){
            int c;
            cin >> c;
            --c;
            bitmask |= 1 << c;
        }
        for(int mask = 0; mask < (1 << N); ++mask)  dp[1][mask] = INF;
        for(int mask = 0; mask < (1 << N); ++mask){
            if(dp[0][mask] == INF)  continue;
            chmin(dp[1][mask], dp[0][mask]);
            chmin(dp[1][mask | bitmask], dp[0][mask] + a);
        }
        swap(dp[0], dp[1]);
    }
    int ans = dp[0][(1 << N) - 1];
    if(ans == INF)  ans = -1;
    cout << ans << endl;
}

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

string query(int n) {
	cout << n << '\n' << flush;
	fflush(stdout);
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	return s;
}

int main() {
	int n; cin >> n;
	int l = 0;
	int r = n - 1;
	string L = query(l);
	string R = query(r);

	while (l < r) {
		int m = (l + r) / 2;
		R = query(m);
		if (m % 2) {
			if (L == R) r = m;
			else l = m;
		} else {
			if (L == R) l = m;
			else r = m;
		}
	}
	return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64

int n,x,y;
int t[10000];
//Xは最大
//Yは最小

int main(){
cin>>n>>x>>y;
rep(i,n)cin>>t[i];
int ans=abs(y-t[n-1]);//xが全部引く
if(n>=2)
ans=max(ans,abs(t[n-1]-t[n-2]));

cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,sum=0;
	cin>>n>>m;
	vector<int> a(n);
	rep(i,n){
		cin>>a.at(i);
		sum+=a.at(i);
	}
	int num=ceil(sum/float(4*m));
	sort(all(a));
	cout<<(m<=a.end()-lower_bound(all(a),num)?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

struct segments {
	vector<int> ss, se;
	int n;
	void in(int t) {
		if (!n)
			ss.push_back(t);
		n++;
	}
	void out(int t) {
		n--;
		if (!n)
			se.push_back(t);
	}
	int sum(int s, int e) {
		int r = 0;
		for (size_t i = 0; i < ss.size(); i++)
			if (ss[i] <= e && s <= se[i])
				r += min(se[i], e) - max(ss[i], s);
		return r;
	}
	void dump() {
		for (size_t i = 0; i < ss.size(); i++)
			::out(ss[i], '-', se[i], ' ');
		outl();
	}
};

int main() {
	for (int M; in(), M = in();) {
		vector<segments> S(M + 1);
		for (int r = in(); r; r--) {
			int t = in(), m; in(), m = in();
			if (in())
				S[m].in(t);
			else
				S[m].out(t);
		}
		for (int q = in(); q; q--) {
			int s = in(), e = in();
			outl(S[in()].sum(s, e));
		}
	}
}


Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[0]=='S'){
		cout<<"Cloudy";
		return 0;
	}
	if(s[0]=='C'){
		cout<<"Rainy";
		return 0;
	}
	if(s[0]=='R'){
		cout<<"Sunny";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256