akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int k = saori.saori_hayami();
		if(k%2 == 0){
			System.out.println(k/2 * k/2);
		} else {
			System.out.println(k/2 * (k + 1)/2);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21076
N,W,*A=map(int,open(0).read().split());d={0:0}
for w,v in zip(A[::2],A[1::2]):
 for x,y in d.copy().items():
  if x+w<=W:d[x+w]=max(d.get(x+w,0),y+v)
print(max(d.values()))

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define ldb long double
#define clr(x) memset(x,0,sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
const int size1 = 1e5+7;
const int size2 = 1e4;
const ll mod = 1e9+7;
 
// ll fact[size1];
 
// ll pw(ll x,ll y,ll md)
// {
//     if(y==0)return 1;
//     ll p =pw(x,y/2,md);
//     p = (p*p)%md;
//     if(y%2==1)p = (p*x)%md;
//     return p;
// }
// ll gcd(ll a,ll b)
// {
//  if(b==0)return a;
//  a = a%b;
//  return gcd(b,a);
// }
// ll inverse(ll x,ll mod)
// {
//     return pw(x,mod-2,mod);
// }
// ll ncr(ll n,ll r,ll mod)
// {
//     ll num = fact[n];
//     ll den = (fact[r] * fact[n-r])%mod;
//     den = inverse(den,mod);
 
//     ll ans = (num*den)%mod;
//     return ans;
// }
// vector<ll> adj1[size1];
// vector<ll> adj[size1];
// ll d[size1];
// ll n,m;
// void dikstra(ll s)
// {
//     for(ll i=1;i<=n;i++)d[i]=1e9;
//     d[s] = 0;
//     priority_queue<pll, vector<pll>, greater<pll>> q;
//     q.push({0, s});
//     while(!q.empty())
//     {
//         ll v = q.top().ss;
//         ll d_v = q.top().ff;
//         q.pop();
//         if(d_v!=d[v])continue;
//         for(auto to:adj1[v])
//         {
//             ll len = 1;
//             if(d[v] + len < d[to])
//             {
//                 d[to] = d[v]+len;
//                 q.push({d[to],to});
//             }
//         }
//     }
// }
 
// ll smallestPrimeFactor[size1];
 
// void seive(){
//     clr(smallestPrimeFactor);
 
//     for(ll i=2;i<size1;i++){
//         if(smallestPrimeFactor[i]!=0)continue;
//         smallestPrimeFactor[i] = i;
//         for(ll j=2*i;j<size1;j+=i){
//             smallestPrimeFactor[j]=i;
//         }
//     }    
// }

int main()
{
    //cout<<setprecision(12)<<fixed;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    
    ll T;
    //cin>>T;
    T = 1;
    while(T--)
    {
        //cout<<"Case #"<<cas<<": ";cas++;
        ll a,b,c,d;cin>>a>>b>>c>>d;

        ll ans = -1e18;
        ans = max(ans,a*c);
        ans = max(ans,a*d);
        ans = max(ans,b*c);
        ans = max(ans,b*d);

        cout<<ans<<endl;

    }
}

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

signed main(void)
{
	int n, sum;
	cin >> n;
	vector<int> l(n);
	sum = 0;
	rep(i, n)
	{
		cin >> l[i];
		sum += l[i];
	}
	sort(l.rbegin(), l.rend());
	if (sum - l[0] > l[0])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
int findGdc(int a, int b, int c){
    int min, gdc;
    if (a < b && a < c)
        min = a;
    else if (b < a && b < c)
        min = b;
    else
        min = c;

    for (int i=1; i <= min; i++) {
        if (a % i == 0 && b % i == 0 && c % i == 0)
            gdc = i;
    }
    return gdc;
}

void main() {
    int k, sum = 0;
    scanf("%d", &k);

    for (int i = 1; i <= k; i++){
        for (int j = 1; j <= k; j++){
            for (int t = 1; t <= k; t++){
                sum += findGdc(i, j, t);
            }
        }
    }
    printf("%d", sum);
}



Measured memory_bytes: 1720
l,r=map(int,input().split())
a=[]
for i in range(l,min(r+1,l+2020)):
    a.append(i%2019)
a=sorted(a)
ans=2020
for i in range(len(a)-1):
    for j in range(1,len(a)):
        ans=min(ans,a[i]*a[j]%2019)
print(ans)

Measured memory_bytes: 3064
//Restinif(g_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

bool digi(ll n)
{
    ll k=0;
    while(n>0)
    {
        n/=10;
        k++;
    }
    return k%2;
}

int main()
{
    ll i,j,k,n;
    cin>>n;k=0;
    rep(i,1,n)
    {
        if(digi(i))
            k++;
    }cout<<k;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

str s;
int N;

bool galima(str a) {
	int j = 0;
	for (int i = 0; i < N; ++i)
	{
		if (j < (int)a.size() and s[i] == a[j]) j++;
	}
	return (j == (int)a.size());
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> N;
	cin >> s;

	int ats = 0;
	for (int i = 0; i <= 999; ++i)
	{
		str ie = "";
		if (i < 100) ie += '0';
		if (i < 10) ie += '0';
		ie += to_string(i);
		//cout << "i = " << i << " ie = " << ie << '\n';
		ats += galima(ie);
	}
	printf("%d\n", ats);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


Measured memory_bytes: 384
//AOJ0297.cpp

#include <iostream>
using namespace std;

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

  for(int i=0; i<N; i++){
    int K,P;
    cin >> K >> P;

    int W = K%P;

    if(W==0){
      cout << P << endl;
      }else{
      cout << W << endl;
      }
  }

  return 0;
}

Measured memory_bytes: 3084
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""

input:
6 6
0 1
1 2
3 1
3 4
4 5
5 2

output:
0
3
1
4
5
2
"""

from sys import stdin
from collections import deque

UNVISITED, VISITED_IN_QUEUE, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
        init_in_deg_list[v_to] += 1
    return init_adj_table, init_in_deg_list


def topological_sort():
    for v in range(vertices):
        if not in_deg_list[v] and status[v] is UNVISITED:
            bfs(v)
    return ans


def bfs(v):
    queue = deque()

    queue.append(v)
    status[v] = VISITED_IN_QUEUE

    while queue:
        current = queue.popleft()
        ans.append(current)

        for v_adj in adj_table[current]:
            in_deg_list[v_adj] -= 1
            if not in_deg_list[v_adj] and status[v_adj] is UNVISITED:
                status[v_adj] = VISITED_IN_QUEUE
                queue.appendleft(v_adj)

        status[current] = POPPED_OUT

    return None


if __name__ == '__main__':
    _input = stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])

    status = [UNVISITED] * vertices
    init_adj_table = tuple([] for _ in range(vertices))
    init_in_deg_list = [0] * vertices

    ans = []
    adj_table, in_deg_list = generate_adj_matrix(v_info)
    print(*topological_sort(), sep='\n')

Measured memory_bytes: 14648
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNext()) {
			System.out.println( break_glass(sc.nextDouble()) );
		}

	}
	private static int break_glass(double nextDouble) {
		double v = nextDouble;
		int N = 2;

			do {
				double t = Math.sqrt(5 * (N - 1) / 4.9);

					if ( 9.8 * t >= v ) {
						break;
					}

					N++;
			}while(true);

		return N;
	}

}



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

/* {{{ */
#define CL(N) cout << N << endl
#define DCT(N) cout << "debug " << N << endl
#define REP(i, N) for (int i = 0; i < N; i++)
/* }}} */
int main()
{
	int n, k;

    cin >> n >> k;

    REP(i, k){
        int a, b;

        cin >> a >> b;

        int t = min(min(a, n - a + 1), min(b, n - b + 1)) % 3;

        cout << (t % 3 == 0 ? 3 : t) << endl;
    }

	return (0);
}

Measured memory_bytes: 3044
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] num = new int[N];
    for(int i = 0; i < N; i++){
      num[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(num);
    int ans = num[N/2] - num[N/2-1];
    System.out.println(ans);
  }
}

Measured memory_bytes: 48540
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#define ff first
#define ss second
#define ll long long
using namespace std;

int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int x, y, z;
    cin>>x>>y>>z;
    int q = x + y + z;
    if(q >= 22) {
        cout<<"bust";
    }
    else {
        cout<<"win";
    }
}
/*
 9 2
 6 19 3 4 4 2 6 7 8
 1 7 21
 1 5 18
 1 3 14
 1 1 8
 0 8 38
 0 6 36
 0 4 32
 0 2 26
 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using P = std::pair<int,int>;
using PP = std::pair<P, int>;

int main(){
        int h, w, cnt = 0;
        scanf("%d %d", &h, &w);
        int fie[h+2][w+2], ans[h+2][w+2], used[h+2][w+2];
        for(int i=0; i<h+2; i++) for(int j=0; j<w+2; j++){
                fie[i][j] = 1;
                used[i][j] = 0;
                ans[i][j] = INT_MAX;
        }
        for(int i=1; i<=h; i++){
                char s[w+1];
                scanf("%s", s);
                for(int j=1; j<=w; j++){
                        fie[i][j] = (s[j-1]=='#');
                        cnt += (s[j-1]=='#');
                }
        }

        int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
        std::queue<PP> que;
        que.push(PP(P(1,1), 1));
        while(!que.empty()){
                P p;
                int d;
                std::tie(p, d) = que.front();
                int x=p.first, y=p.second;
                que.pop();
                if(used[x][y]) continue;
                ans[x][y] = d;
                used[x][y] = 1;
                for(int i=0; i<4; i++){
                        int tx = x + dx[i], ty = y + dy[i];
                        if(!fie[tx][ty]) que.push(PP(P(tx,ty), d+1));
                }
        }

        if(ans[h][w]==INT_MAX) puts("-1");
        else printf("%d\n", h*w-ans[h][w]-cnt);
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main()
{
    
  int aa,bb,cc;
   char a[1000],b[1000],c[1000];
   scanf("%s %s %s",a,b,c);
   aa=(int)a[0]-97;  
   bb=(int)b[0]-97;
   cc=(int)c[0]-97;
   printf("%c%c%c",65+aa,65+bb,65+cc);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>

//ツ年ツ療ョツつゥツづァツイツδ督デツッツクツスツづーツ仰づ淞づゥツ．
int solve(int old){
	if(old < 10){
		return 0;
	}
	else if(old < 20){
		return 1;
	}
	else if(old < 30){
		return 2;
	}
	else if(old < 40){
		return 3;
	}
	else if(old < 50){
		return 4;
	}
	else if(old < 60){
		return 5;
	}
	else{
		return 6;
	}
}

int main(){
	int n, l[7] = {0};
	while(std::cin >> n, n){
		//init
		memset(l, 0, sizeof(l));

		//input
		while(n--){
			int o;
			std::cin >> o;
			l[solve(o)]++;
		}
		
		//output
		for(int i=0;i<7;i++){
			std::cout << l[i] << std::endl;
		}
	}
}

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

using namespace std;

int main(void) {
	long long n, power = 1, p;

	cin >> n;

	p = pow(10, 9);

	for (long long i = 1; i <= n; i++)
	{
		power = (power * i) % (p + 7);
	}
	

	//cout << power << "\n";

	power = power % (p + 7);

	cout << power << "\n";

	return 0;
}

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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, ans = 1;
	string S;
	
	cin >> N;
	cin >> S;
	
	rep(i, N){
		if(i == 0)
			continue;
		if(S[i] != S[i - 1])
			ans++;
	}	
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 512
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

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

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

// const int N = 1e5 + 1;
// vector<int > graph[N];

// void bfs(int n, int s, int ans[]) {
//     ans[s] = 1;
//     queue<int> q;
//     q.push(s);
//     while(!q.empty()) {
//         int v = q.front();
//         q.pop();
//         // cout<<v<<" source\n";
//         for(int b: graph[v]) {
//             if(ans[b] == 0) {
//                 ans[b] = 1;
//                 q.push(b);
//             }
//         }
//     }
// }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int a,b;
    cin>>a>>b;

    if(a >= 13)
        cout<<b;
    else if(a >= 6)
        cout<<b/2;
    else
        cout<<0;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
#define ld long double
const ll mod=998244353;

void solve(){
    int a[1000005];
    memset(a,0,sizeof(a));
    int n;
    cin>>n;

    fr(i,0,n){
        int x;
        cin>>x;
        a[x]++;
    }
    int vis[1000005];
    memset(vis,0,sizeof(vis));
    fr(i,1,1e6+1){
        if(a[i]>0)
        for(int j=i+i;j<=1e6;j+=i)
        vis[j]=1;
    }
    int ans=0;
    fr(i,1,1e6+1){
        if(!vis[i]&&a[i]==1)
        ans+=a[i];
    }
    cout<<ans;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 11448
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[1100][1100] = {};

int main(){
	
	long long int n, k;
	cin >> n >> k;
	
	if(n < k){
		cout << 0 << endl;
		return 0;
	}
	
	n -= k;
	
	DP[0][0] = 1;
	for(int i = 0; i <= n; i++){
		for(int j = 1; j <= k; j++){
			DP[i][j] = DP[i][j - 1];
			if(i >= j){
				DP[i][j] += DP[i - j][j];
			}
			DP[i][j] %= MOD;
		}
	}
	
	cout << DP[n][k] << endl;
	
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, M, Q;
	cin >> N >> M >> Q;
	vector<ll> L(M), R(M);
	vector<ll> p(Q), q(Q);
	REP(i, M) cin >> L[i] >> R[i];
	REP(i, Q) cin >> p[i] >> q[i];

	ll count[501][501];
	ll countsum[502][502];
	REP(i, 501)REP(j, 501){
		count[i][j] = 0;
	}
	REP(i, 502)REP(j, 502){
		countsum[i][j] = 0;
	}
	REP(i, M) count[L[i]][R[i]]++;
	REP(i, 501){
		REP(j, 501){
			countsum[i+1][j+1] = countsum[i+1][j] + count[i][j];
		}
	}

	REP(j, 501){
		REP(i, 501){
			countsum[i+1][j+1] = countsum[i+1][j+1] + countsum[i][j+1];
		}
	}

	REP(i, Q){
		cout << countsum[501][q[i]+1] - countsum[p[i]][q[i]+1] << endl;	
	}
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
    long int N,D;
    cin >> N >> D;

    long int cnt = 0;
    long int X[N],Y[N];
    for(long int i=0;i<N;i++){
      cin >> X[i] >> Y[i];
      if (X[i]*X[i] + Y[i]*Y[i] <= D*D){
        cnt++;
      }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 6752
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c) = get!(i32, i32, i32);
    for x in 0..1000 {
        for y in 0..1000 {
            if x*a == y*b + c {
                println!("YES");
                return;
            }
        }
    }
    println!("NO");
}

Measured memory_bytes: 4352
import java.util.Scanner;

/**
 * https://abc063.contest.atcoder.jp/tasks/arc075_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		long[] h = new long[N];
		long max = 0;
		for(int i=0; i<N; i++){
			h[i] = Long.parseLong(sc.next());
			max = Math.max(max, h[i]);
		}
		sc.close();
		
		long left = 1;
		long right = (long)N*max/(long)B;
		long ans = right;
		while(left<=right){
			long mid = (left+right)/2;
			if(check(mid,h,A,B)){
				ans = Math.min(ans,mid);
				right = mid-1;	
			}else{
				left = mid+1;
			}
		}
		
		System.out.println(ans);

	}

	private static boolean check(long t, long[] h, long A, long B) {
		long count = 0;
		for(int i=0; i<h.length; i++){
			if(h[i]>B*t){
				count = count + (long)Math.ceil((double)(h[i]-B*t)/(A-B));
			}
		}
		return count<=t;
	}

}


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

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

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    cout << 1 + ((n-k) + (k-1) - 1)/(k-1) << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
w = list(map(int,input().split()))

s = sum(w)
s1 = 0
temp = s
for i in range(n-1):
    s1 += w[i]
    if(abs((s-s1)-s1)<temp):
        temp = abs((s-s1)-s1)
print(temp)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    rest = N % K

    if rest > K / 2:
        print(abs(rest - K))
    else:
        print(rest)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

int main() {
  int N, W;
  cin >> N >> W;
  vector<long> V(W + 1, -1);
  V.at(0) = 0;
  while (N--) {
    int w, v;
    cin >> w >> v;
    for (int i = W; i >= 0; i--) {
      if (V.at(i) != -1 && i + w < W + 1) {
        V.at(i + w) = max(V.at(i + w), V.at(i) + v);
      }
    }
  }
  cout << *max_element(V.begin(), V.end()) << "\n";
}

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

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

  ll N; cin >> N;
  string ans = "second";
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    if (a % 2) ans = "first";
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
	int n, d, cnt = 0;
	string ans = "No";
	cin >> n >> d;
	vector<int> x(n);
	vector<int> y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		cin >> y[i];
	}
	for (int i = 0; i < n; i++ ) {
		double l = sqrt(pow(x[i], 2) + pow(y[i], 2));
		if (l <= d) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 4840
/**
 *    author:  FromDihPout
 *    created: 2020-07-25
**/

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


const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }
    
    vector<int> dp(w);
    for (int i = 0; i < w; i++) {
        if (a[0][i] == '#') break;
        dp[i] = 1;
    }
    for (int i = 1; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') {
                dp[j] = 0;
                continue;
            }
            if (i > 0) {
                dp[j] += dp[j - 1];
            }
            if (dp[j] >= MOD) {
                dp[j] -= MOD;
            }
        }
    }
    cout << dp[w-1] << '\n';
    return 0;
}

Measured memory_bytes: 4700
#include<bits/stdc++.h>
using namespace std;
int w, h, x, y, tstate;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

string grid[100], s, tank = ">v<^";

void move(int d){
  tstate = d;
  int nx = x + dx[d], ny = y + dy[d];
  if(0 <= nx && nx < w &&
     0 <= ny && ny < h &&
     grid[ny][nx] == '.'){
    x = nx, y = ny;
  }
}

void shoot(int dist){
  int nx = x + dx[dist], ny = y + dy[dist];
  while(0 <= nx && nx < w &&
	0 <= ny && ny < h){
    if(grid[ny][nx] == '#')break;
    if(grid[ny][nx] == '*'){
      grid[ny][nx] = '.';
      break;
    }
    nx += dx[dist], ny += dy[dist];
  }
}

int main(){
  int n;
  cin >> n;
  map<char,int> hash;
  hash['R'] = 0;
  hash['D'] = 1;
  hash['L'] = 2;
  hash['U'] = 3;
  hash['S'] = 4;
  for(int r = 0; r < n; r++){
    cin >> h >> w;
    for(int i = 0; i < h; i++){
      cin >> grid[i];
    }
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	if(grid[i][j] == 'v' || grid[i][j] == '>' ||
	   grid[i][j] == '<' || grid[i][j] == '^'){
	  x = j; y = i;
	  for(int k = 0; k < 4; k++)
	    if(grid[i][j] == tank[k])tstate = k;
	  grid[i][j] = '.';
	}
      }
    }
    int len;
    cin >> len >> s;
    for(int i = 0; i < len; i++){
      int d = hash[s[i]];
      if(d == 4){
	shoot(tstate);
      }else{
	move(d);
      }
    }
    grid[y][x] = tank[tstate];
    for(int i = 0; i < h; i++){
      cout << grid[i] << endl;
    }
    if(r < n - 1)cout << endl;
  }
}

       
      

Measured memory_bytes: 1208
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,m = [int(i) for i in readline().split()]
ps = []
for _ in range(m):
    p,s = [i for i in readline().split()]
    ps.append([int(p),s])

acs = 0
was = 0
solved = {}
fail_cnt = {}
for p,s in ps:
    if p in solved and solved[p] == 1:
        pass
    elif p in solved and solved[p] == 0 and s == 'AC':
        acs += 1
        solved[p] = 1
        was += fail_cnt[p]
    elif p in solved and solved[p] == 0 and s == 'WA':
        fail_cnt[p] += 1
    elif s == 'AC':
        acs += 1
        solved[p] = 1
    else:
        solved[p] = 0
        fail_cnt[p] = 1
print(acs, was)

Measured memory_bytes: 31272
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  int64_t a, b, c, k;
  cin >> a >> b >> c >> k;
  auto m = max({a, b, c});
  cout << ((m << k) + a + b + c - m) << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int X = scan.nextInt();
        if (X < A) {
            System.out.println("NO");
        } else if (X <= A + B) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=-10000000000;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N; cin>>N;
	map<ll,ll> m;
	rep(i,N){
        ll x; cin>>x;
        auto itr=m.find(x);
        if(itr!=m.end()){
            (itr->second)++;
        }
        else{
            m.insert(mp(x,1));
        }
    }
	ll ans=0;
	for(auto itr=m.bg;itr!=m.ed;++itr){
		if((itr->b)>=(itr->a)){
			ans+=(itr->b)-(itr->a);
		}
		else ans+=(itr->b);
	}
	cout<<ans;
}

Measured memory_bytes: 6272
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String str = S.substring(S.length() / 2);

		if (S.equals(str + str)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 23636
class Node
  attr_reader :id, :siblings
  attr_accessor :state, :distance

  def initialize(id)
    @id = id
    @siblings = []
    @state = :white
    @distance = nil
  end

  def <<(sibling)
    @siblings << sibling
  end
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  temp = Hash.new {|hash, id| hash[id] = Node.new(id) }

  n.times do
    id, _, *sibling_ids = gets.chomp.split.map(&:to_i)

    node = temp[id]

    sibling_ids.each do |sibling_id|
      node << temp[sibling_id]
    end
  end

  nodes = temp.values.sort_by(&:id)

  first_node = nodes.first
  first_node.distance = 0

  queue = [first_node]

  until queue.empty?
    current = queue.shift

    current.siblings.each do |sibling|
      next unless sibling.state == :white

      sibling.state = :gray
      sibling.distance = current.distance + 1

      queue << sibling
    end

    current.state = :black
  end

  nodes.each do |node|
    puts "#{node.id} #{node.distance || -1}"
  end
end

Measured memory_bytes: 8752
#include <iostream>
#include <vector>
#include <algorithm>
#define LL long long


int main(){
	int a,b,c,k, i, n[3], otherNum_total, largest;
	std::cin >> a >> b >> c >> k;

	n[0] = a;
	n[1] = b;
	n[2] = c;

	std::sort(std::begin(n), std::end(n));

	otherNum_total = n[0] + n[1];
	largest = n[2];


	for(i=0;i<k;i++)largest *= 2;


	std::cout << (otherNum_total + largest) << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
      int H,W;
      while(1){
            cin >> H >> W ;
                  if(H==0&&W==0)break;
                  
           for(int i=0;i<H;i++) {
                 for(int j=0;j<W;j++){
                 cout<<"#";
                 }
                  cout << endl;
           }
           cout << endl;
      }
      return 0;
}


Measured memory_bytes: 3056
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊

    let (h, w) = (io.read::<usize>(), io.read::<usize>());
    let c = (0..h).map(|_| io.chars()).collect::<Vec<_>>();

    for hh in 0..h * 2 {
        for ww in 0..w {
            io.write(c[hh / 2][ww]);
        }
        io.writeln("");
    }
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
#define double long double
#define PI 3.141592653589793
typedef long long ll;
const int MOD = 1000000007;
const int INF = 11000000000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1;i*i <= n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i != n)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}


signed main() {
  int n;cin>>n;int d[110000];rep(i,n)cin>>d[i];
  sort(d,d+n);cout << d[n/2] - d[n/2-1] << endl;
}




Measured memory_bytes: 1024
n=int(input())
e=[[i] for i in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  e[a]+=[b]
  e[b]+=[a]
c=sorted(list(map(int,input().split())))
q=[1]
vis=[0]*(n+1)
ans=0
while q:
  now=q.pop()
  vis[now]=c.pop()
  for to in e[now]:
    if vis[to]:continue
    q+=[to]
print(sum(vis[2:]))
print(*vis[1:])

Measured memory_bytes: 75696
import java.util.Scanner;

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

		for(int i = 1; i <= N; i++) {
			power = i * power % (1000000000 +7);
		}
		System.out.println(power);
	}
}


Measured memory_bytes: 22612
#include<cstdio>
#include<algorithm>
using namespace std;
struct with {
	int val, w;
} a[100005];
int n;
int ans;
bool cmp(const with i, const with j) {
	return i.val < j.val;
}
int main() {
	scanf("%d", &n);
	int i;
	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i].val);
		a[i].w = i;
	}
	sort(a + 1, a + 1 + n, cmp);
	for (i = 1; i <= n; i++) {
		if (a[i].w % 2 == 1 && i % 2 == 0) ans++;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 896
/*input
10010010
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	string s;
	cin>>s;
	int ans=0;
	REP(i,SZ(s)) if(s[i]!='0'+i%2) ans++;
	cout<<min(ans,SZ(s)-ans);
	return 0;
}


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

int main() {
  int M1, D1, M2, D2;
  cin >> M1 >> D1;
  cin >> M2 >> D2;

  if(M1 != M2) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
XMAX = 10**5
X = int(input())
dp = [False] * (XMAX + 1)
dp[0] = True

for i in range(0, X + 1):
    for p in range(100, 106):
        if i - p >= 0 and dp[i - p]:
            dp[i] = True
            next
if dp[X]:
    print(1)
else:
    print(0)

Measured memory_bytes: 3828
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	int n, k;
	int i;
	char str[100];
	
	
	scanf("%d%d", &n, &k);
	
	scanf("%s", str);
	
	if(str[k - 1] == 'A') {
		str[k - 1] = 'a';
	} else if(str[k - 1] == 'B') {
		str[k - 1] = 'b';
	} else {
		str[k - 1] = 'c';
	}
	
	printf("%s", str);
	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    int n;
    cin >> n;
    vector<vector<pair<int, int>>> edge(n);
    int u, v, w;
    FOR(i, 1, n) {
        cin >> u >> v >> w;
        u--, v--;
        edge[u].push_back({ v,w });
        edge[v].push_back({ u,w });
    }

    VI c(n);
    vector<bool> ever(n, 0);
    c[0] = 0;
    stack<pair<int, int>> dfs;
    dfs.push({ 0,0 });
    while (!dfs.empty()) {
        int a = dfs.top().first;
        int b = dfs.top().second;
        dfs.pop();
        ever[a] = 1;
        c[a] = b;
        for (auto i : edge[a]) {
            if (ever[i.first])continue;
            if (i.second % 2 == 0)dfs.push({ i.first,b });
            else dfs.push({ i.first,1 - b });
        }
    }
    for (int i : c)cout << i << "\n";
}

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

int main(){
  vector<int>code(5);
  for(int i=0;i<5;i++){
    cin>>code.at(i);
  }
  int K;
  cin>>K;
  int dif;
  for(int i=0;i<4;i++){
    for(int j=1;j<5;j++){
      dif=code.at(j)-code.at(i);
      if(dif>K){
        cout<<":("<<endl;
        return 0;
      }
    }
  }
  cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
<?php
list($s) = strs();
$n = strlen($s);
// 全ての組の個数
$c = (1 + $n - 1) * ($n - 1) / 2 + 1;
for ($i = 0; $i < $n; ++$i) {
    if (isset($cnt[$s[$i]])) ++$cnt[$s[$i]];
    else $cnt[$s[$i]] = 1;
}
foreach ($cnt as $i => $v) $c -= $v * ($v - 1) / 2;
echo $c;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 16512
#include <iostream>
using namespace std;
int main(void){
  int n;
  int a[201];
  int cnt = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  while (true) {
	bool exist_odd = false;
	for (int i = 0; i < n; ++i) {
		if (a[i] % 2 != 0) exist_odd = true;
    }
	if (exist_odd) break;
	for (int i = 0; i < n; ++i) {
		a[i] /= 2;
	}
    cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <math.h>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const int MAX = 1000000;

int n,l;
int nums[MAX];
int answers[MAX];
int deq[MAX];

void solve()
{
  int s = 0, decIn = 0;

  for (int i = 0; i < n; i++)
  {
    while(s < decIn && nums[deq[decIn-1]] >= nums[i]) decIn--;

    deq[decIn] = i;
    decIn++;

    if (i+1 >= l)
    {
      answers[i+1-l] = nums[deq[s]];

      if(deq[s] == i+1-l) s++;
    }
  }

  for (int i = 0; i <= n-l; i++)
  {
    if(i > 0) printf(" ");
    printf("%d", answers[i]);
  }

  printf("\n");
}

int main()
{
  cin >> n >> l;
  for (int i = 0; i < n; i++) scanf("%d", &nums[i]);

  solve();
  return 0;
}



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

using namespace std;

typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, M;
    cin >> N >> M;
    vector<int> items(N);
    int total = 0;
    for(int i = 0 ; i < N; ++i){
        cin >> items[i];
        total += items[i];
    }
    sort(items.begin(), items.end(), greater<int>());
    if( (total-1) / (4 * M) + 1 <= items[M-1]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	long long int A, B, C, K;
	cin >> A >> B >> C >> K;
	if (A >= K) {
		cout << K << endl;
	}
	else if (A + B >= K) {
		cout << A << endl;
	}
	else {
		cout << A - K + A + B;
	}
}

Measured memory_bytes: 3636
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    long long X;

    cin >> X;

    int64 d = X / 11;

    int64 ans = 2 * d;

    if (X % 11 == 0) {
        ans += 0;
    } else if (X % 11 <= 6) {
        ans += 1;
    } else {
        ans += 2;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	ll S;
	cin >> S;
	ll x1, y1, x2, y2, x3, y3;
	x1 = 0LL;
	y1 = 0LL;
	y3 = 1000000000LL;
	y2 = 1LL;
	x3 = 1000000000LL - (S%1000000000LL);
	x2 = (S + x3) / 1000000000LL;
	if (S == 1e18) {
		cout << 0 << " " << 0 << " " << 1000000000 << " " << 0 << " " << 0 << " " << 1000000000 << endl;
	}
	else {
		cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int K = Integer.parseInt(s.nextLine().split(" ")[1]);
        String Ps = s.nextLine();
        List<Double> p = Arrays.asList(Ps.split(" ")).stream().map(Double::parseDouble).collect(Collectors.toList());
        double ret = 0;
        double tmp = 0;
        for (int i = 0; i < p.size(); i++) {
            double n = p.get(i);
            tmp += n;
            if (i < K) {
                ret += n;
                continue;
            }
            tmp -= p.get(i - K);
            if (ret < tmp) {
                ret = tmp;
            }
        }
        System.out.print((ret + K) / 2);
    }
}

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

int main(void)
{
    char s;
    cin >> s;

    if(s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u'  )
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;

    return 0;
}

Measured memory_bytes: 256