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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }

using P = pair<int,int>;
vector<vector<P>> G;
vector<bool> used;
vector<ll> X;

bool contradiction = false;


// 頂点s から初めて矛盾がないかを確認する
void dfs( int s ) {
    if ( used[s] ) return;
    used[s] = true;
    for ( auto p : G[s] ){
        int g = p.first, c = p.second;
        if ( X[g] != -1 and X[g] != X[s] + c ) {
            contradiction = true;
            return;
        } else {
            X[g] = X[s] + c;
            dfs(g);
        }
    }
    return;
}

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> L(M),R(M),D(M);
    REP(i,M) {
        int l,r;
        cin >> l >> r >> D[i];
        --l; --r;
        L[i] = l;
        R[i] = r;
    }
    
    //cout << "A" << endl;
    
    G.resize(N);
    used.resize(N);
    X.resize(N);
    REP(i,N) {
        used[i] = false;
        X[i] = -1;
    }
    //cout << "A" << endl;
    REP(i,M){
        G[L[i]].push_back(make_pair(R[i],D[i]));
        G[R[i]].push_back(make_pair(L[i],-D[i]));
    }
    //cout << "A" << endl;
    REP(i,N){
        if ( used[i] ) continue;
        X[i] = 0;
        dfs(i);
    }
    //cout << "A" << endl;
    if ( contradiction ) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 17784
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,x,y;
    cin>>n>>x>>y;
    x--;y--;
    vec k(n);
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            int dist=j-i;
            int memo=abs(x-i)+1+abs(y-j);
            chmin(dist,memo);
            k[dist]++;
        }
    }
    for(int i=1;i<n;i++){
        cout<<k[i]<<endl;
    }
    
}

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


int main()
{
    string s;
    cin >> s;

    if(s[2]==s[3] && s[4]==s[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  string S;
  int K;
  cin>>S>>K;
  int N=S.size();
  int x=1;
  for(int i=0;i<K;i++){
    if(S[i]!='1'){
      cout<<S[i];
      x*=0;
      break;
    }
  }
    if(x==1) cout<<1;  
}


Measured memory_bytes: 3596
#include <stdio.h>
int main(void){
  int n,h[100000],i,dp[100000],a,b;
  scanf("%d",&n);
  for (i=0;i<n;i++) scanf("%d",&h[i]);
  dp[0]=0;
  dp[1]=(h[0]>h[1])? h[0]-h[1]:h[1]-h[0];
  for (i=2;i<n;i++){
    a=(h[i]>h[i-2])? h[i]-h[i-2]:h[i-2]-h[i];
    b=(h[i]>h[i-1])? h[i]-h[i-1]:h[i-1]-h[i];
    dp[i]=(dp[i-2]+a<dp[i-1]+b)? dp[i-2]+a:dp[i-1]+b;
  }
  printf("%d\n",dp[n-1]);
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;
typedef long long ll;

using namespace std;

void solve() {
    
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int cntOdd = 0;
    int cnt4 = 0;
    REP(i, N) {
        if (A[i] % 2 != 0) {
            cntOdd++;
        } else if (A[i] % 4 == 0){
            cnt4++;
        }
    }
    if (cntOdd <= cnt4) {
        print("Yes");
    } else if (cntOdd == cnt4 + 1 && cntOdd + cnt4 == N) {
        print("Yes");
    } else {
        print("No");
    }
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, v;
string str;

int main(){
	cin >> n;
	vector<ll> vv;
	for(ll i = 1; i <= n; i++){
		cin >> v;
		vv.push_back(v);
	}
	sort(vv.begin(), vv.end());
	
	double ans = vv[0];
	for(ll i = 1; i < n; i++){
		ans += vv[i];
		ans /= 2;
	}
	
	cout << setprecision(10) << ans << endl;
	return 0;
}

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

int main(){
  ll n,k,s;
  cin >> n >> k >> s;
  ll i;
  if(s==1000000000){
    for(i=0;i<k;i++){
      cout << s << " ";
    }
    for(i=k;i<n;i++){
      cout << 1 << " ";
    }
  }else{
    for(i=0;i<k;i++){
      cout << s << " ";
    }
    for(i=k;i<n;i++){
      cout << s+1 << " ";
    }
  }
}

Measured memory_bytes: 3604
N,x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a_sorted = sorted(a)
num =0
x_num = x
for i in range(N):
    if(x_num - a_sorted[i] >= 0):
        x_num -= a_sorted[i]
        num += 1
        if(i == N-1 and x_num >0):
            num -= 1
    else:
        break
print(num)


Measured memory_bytes: 3060
import sys
def S(): return sys.stdin.readline().rstrip()

def Main():
    s = S()
    n = len(s)
    times = 10**100
    ans = [0]*n
    i = 0
    while i<n:
        if s[i]=='L':
            i += 1
            continue
        save = [i]
        while s[i+1]!='L':
            i += 1
            save.append(i)
        flg = save.pop()
        ans[flg] += 1
        for rep in save:
            ans[flg+abs(flg-rep)%2] += 1
        i += 1
    
    i = n-1
    while 0<=i:
        if s[i]=='R':
            i -= 1
            continue
        save = [i]
        while s[i-1]!='R':
            i -= 1
            save.append(i)
        flg = save.pop()
        ans[flg] += 1
        for rep in save:
            ans[flg-abs(flg-rep)%2] += 1
        i -= 1
    print(*ans)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 14756
R, G, B, N = map(int, input().split())

count = 0

for r in range(N//R + 1):
    for g in range(N//G + 1):
        if 0 <= (N - R * r - G * g) and (N - R * r - G * g) % B == 0:
            count += 1

print(count)


Measured memory_bytes: 40940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n;
  bool a=true;
for(int i=0;i<n;i++){
  cin>>m;
  if(m%2==0 &&(m%3!=0 && m%5!=0)){
    a=false;
    break;
  }
}
if(a)cout<<"APPROVED"<<endl;
else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
import sys
import collections
import math
from collections import Counter
from collections import deque


H, W = [int(x) for x in input().split()]

ans = 10**10

# 縦切のみ 、横切のみ


def calc1(H, W):
    if H % 3 == 0:
        return 0
    else:
        return W


def calc2(H, W):
    ret = 10**10
    for w in range(1, W):
        s1 = w * H
        h = H // 2
        s2 = h * (W - w)
        s3 = (H - h) * (W - w)
        maxS = max(s1, s2, s3)
        minS = min(s1, s2, s3)
        ret = min(abs(maxS - minS), ret)
    return ret


s1 = calc1(H, W)
s2 = calc1(W, H)
s3 = calc2(H, W)
s4 = calc2(W, H)

print(min(s1, s2, s3, s4))


sys.exit(0)


Measured memory_bytes: 3316
a, b = map(int, input().split())

buf = [['.'] * 100 for _ in range(50)] + [['#'] * 100 for _ in range(50)]

bd, bm = divmod(b - 1, 50)
for i in range(0, (bd + (bm > 0)) * 2, 2):
    for j in range(0, bm * 2 if i == bd * 2 else 100, 2):
        buf[i][j] = '#'

ad, am = divmod(a - 1, 50)
for i in range(0, (ad + (am > 0)) * 2, 2):
    for j in range(0, am * 2 if i == ad * 2 else 100, 2):
        buf[i + 51][j] = '.'

print(100, 100)
print('\n'.join(''.join(row) for row in buf))


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        ll ai;
        cin>>ai;
        a[i]=ai-i-1;
    }
    sort(a.begin(),a.end());
    ll b=a[n/2];
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(a[i]-b);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;



void main() {
    auto x = new real[](3);
    auto y = new real[](3);
    foreach (i ; 0 .. 3) {
        int xi, yi; scan(xi, yi);
        x[i] = xi, y[i] = yi;
    }
    auto a = sqrt((x[0] - x[1])^^2 + (y[0] - y[1])^^2);
    auto b = sqrt((x[1] - x[2])^^2 + (y[1] - y[2])^^2);
    auto c = sqrt((x[2] - x[0])^^2 + (y[2] - y[0])^^2);
    auto S = sqrt((a+b+c)*(a-b+c)*(b-c+a)*(c-a+b)) / 4.0;
    auto r = 2.0 * S / (a + b + c);

    real btm = 0, top = r;

    bool check(real x) {
        return (1 - x / r) * max(a, b, c) >= 2*x;
    }

    foreach (_ ; 0 .. 10^^5) {
        real mid = (btm + top) / 2;
        if (check(mid)) {
            btm = mid;
        }
        else {
            top = mid;
        }
    }

    writefln("%.12f", btm);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int N;
  cin >> N;
  double btc = 0, jpy = 0;
  REP(i, N) {
    double x;
    string u;
    cin >> x >> u;
    if(u[0] == 'J') {
      jpy += x;
    } else {
      btc += x;
    }
  }
  cout << setprecision(9) << jpy + btc * 380000 << endl;
}

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

int main(void)
{
  string line;
  while (true)
  {
    getline(cin, line);
    if ( line == "END OF INPUT" ) break;

    int count = 0;
    for (int i = 0, size = line.size(); i < size; i++)
    {
      if (line[i] != ' ')
      {
        count++;
      }
      else
      {
        cout << count;
        count = 0;
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
    #define debug(x) cerr << #x << ": " << x << '\n';
    using namespace std;
    using ll = long long;
    using P = pair<int, int>;
    const int INF = (int)1e9;

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

        vector<int> a(N);
        for(int i = 0; i < N; i++){
            cin >> a[i];
        }

        vector<bool> used(N, false);
        for(int i = N; i >= 1; i--){
            int sum = 0;
            for(int j = i; j <= N; j+=i){
                // printf("i, j = %d, %d\n", i, j);
                if(used[j-1]) sum ^= 1;
            }
            if(sum != a[i-1]) used[i-1] = true;
        }

        int M = 0;
        for(int i = 0; i < N; i++){
            if(used[i]) M++;
        }

        cout << M << '\n';
        for(int i = 0; i < N; i++){
            if(used[i]) cout << i + 1 << '\n';
        }

        return 0;
    }

Measured memory_bytes: 1792
n,x = [int(i) for i in input().split()]

def p(l, x):
  if x == 0:
    return 0
  if l == 1:
    if x == 1:
      return 0
    elif x == 2:
      return 1
    elif x == 3:
      return 2
    else:
      return 3
  else:
    w = 2**(l + 2) - 3
    if x == w:
      return 2**(l + 1) - 1
    hw = w // 2 + 1
    if x < hw:
      return p(l - 1, x - 1)
    elif x > hw:
      return 2**l + p(l - 1, x - hw)
    else:
      return 2**l
    
print(p(n, x))

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

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

    ll n;
    std::vector<char> str;
    std::cin >> n;
    n -= 1;

    do{
        str.push_back(n%26+'a');
        n/=26;
        --n;
    }while(n!=-1);

    for(auto rit=str.rbegin(); rit!=str.rend(); ++rit){
        std::cout << *rit;
    }
    std::cout << "\n";

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
const ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x);
        }
        p = p >> 1;
        x = (x*x);
    }
    return res;
}

int n;
vector<vector<int>> adjlist;
ll dp[100005][2];

ll dfs(int node, int color, int parent = -1) {
    if (dp[node][color] != -1)
        return dp[node][color];
    ll ans = 1;
    for (int x: adjlist[node]) {
        if (x == parent) continue;
        if (color)  ans = (ans * dfs(x, 0 , node))%MOD;
        else
            ans = (ans * (dfs(x,1 , node) + dfs(x,0,node)))%MOD;
    }
    return dp[node][color] = ans;
}

int main() {
    IO;
    cin >> n;
    adjlist.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int x,y;
        cin >> x >> y;
        adjlist[--x].push_back(--y);
        adjlist[y].push_back(x);
    }
    memset(dp, -1, sizeof(dp));
    cout << (dfs(0,0) + dfs(0,1))%MOD;
    return 0;
}


Measured memory_bytes: 15616
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve())
}

func resolve() int {
	n := scanInt(sc)
	hs := nextIntSlice(sc, n)
	num, h := 0, 0
	for i := 0; i < len(hs); i++ {
		if hs[i] < h {
			num += h - hs[i]
		}
		h = hs[i]
	}
	num += h
	return num
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
  int a,b,c,n;
  cin>>a>>b>>c>>n;
  int  res=0;
  bool OK=false;
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      int N=n;
      N-=a*i+b*j;
      
      if(N%c==0 && N>=0)
        res++;
    }
  }
  
  cout<<res;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int cnt=0;
	cin>>s;
	s.erase(s.length()-1,1);
	while(s.length()>=3){
		if(s.length()%2==0){
			for(int j=0;j<s.length()/2+1;j++){
				if( s.substr(j,1)==s.substr(j+(s.length()/2),1)){
					cnt++;
					if(cnt>=s.length()/2-1){
						cout<<s.length()<<endl;
						return 0;
					}
				}else{
					break;
				}
			}
		}
		s.erase(s.length()-1,1);
		cnt=0;
	}
	if(s.substr(0,1)==s.substr(1,1) && s.length()==2){
			cout<<2<<endl;
			return 0;
	}
}


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

int mincost[200][200];
int main() {
	for (int i = 0; i < 200; i++)fill(mincost[i], mincost[i] + 200, 1 << 29);
	int a; cin >> a;
	for (int b = 0; b < a; b++) {
		int c, e; string d;
		cin >> c >> d >> e; c--; e=e+99;
		if (d[0] == 'l') {
			mincost[e][c] = 0;
		}
		else {
			mincost[c][e] = 0;
		}
	}
	for (int c = 0; c < 200; c++) {
		for (int d = 0; d < 200; d++) {
			for (int e = 0; e < 200; e++) {
				mincost[d][e] = min(mincost[d][e], mincost[d][c] + mincost[c][e]);
			}
		}
	}
	bool S = false;
	for (int i = 0; i < 200; i++) {
		if (mincost[i][i] == 0)S = true;
	}
	cout << S << endl;
}

Measured memory_bytes: 3328
/*
Problem Number: ABC177C
Problem Name: Sum of product of pairs
Notes: 
*/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define MOD 1000000007

using namespace std;

int main(){
    cin.tie(0) -> sync_with_stdio(0);
    
    int n;
    cin >> n;
    ll a, sum = 0, sol = 0;
    for(int i = 0; i < n; i++)
        cin >> a, sol = (sol + a * sum) % MOD, sum = (sum + a) % MOD;
    cout << sol << endl;
    
    return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>
int main()
{
char a,b;
while(scanf("%c %c",&a,&b)!=EOF)
{if(a=='D')
{if(b=='D')
printf("H\n");
else
printf("D\n");}
if(a=='H')
{if(b=='D')
printf("D\n");
else
printf("H\n");}}
return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<int> edges;
vector<edges> G;
int dist1[100005];
int dist2[100005];

int n;

void bfs(int v, int *dist) {
	queue<int> q;
	q.push(v);
	fill(dist, dist + n, -1);
	int d = 0;
	dist[v] = d;
	while (q.size()) {
		int n = q.front();  q.pop();
		for (auto i : G[n]) {
			if (dist[i] >= 0)
				continue;
			dist[i] = dist[n] + 1;
			q.push(i);
		}

	}
}

int main(){
	scanf("%d ", &n);
	G.resize(n+5);
	int a, b;
	rep(i, n-1) {
		scanf("%d %d ", &a, &b); a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	bfs(0,dist1);

	bfs(n-1,dist2);
	int s=0, t=0;
	rep(i, n) {
		if (dist1[i] <= dist2[i]) {//
			s++;
		}
		else {
			t++;
		}
	}
	if (s > t)//
		cout << "Fennec" << endl;
	else
		cout << "Snuke" << endl;

	return 0;
}


Measured memory_bytes: 6528
N,K=map(int, input().split())

L=[]

for i in range(N):
    a,b=map(int, input().split())
    L.append((a,b))

L=sorted(L)

count=0
for l in L:
    a,b=l
    count+=b
    if count>=K:
        print(a)
        break


Measured memory_bytes: 17804
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int w, a, b;
    cin >> w >> a >> b;
    if (abs(a-b) < w) {
        cout << 0 << endl;
    }
    else {
        cout << min(abs(b+w-a), abs(a+w-b)) << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int n, r;
	cin >> n >> r;
	int ans = r;
	if (n < 10) ans += 100 * (10 - n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, sum = 0, flag;
    cin >> n;
    rep(i, n)
    {
        sum += i + 1;
        if (sum >= n)
        {
            flag = i + 1;
            break;
        }
    }
    rep(i, flag)
    {
        if (sum - n == i + 1)
            ;
        else
            cout << i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
   

H, W = LI()
A = []
for _ in range(H):
    A.append(S())
seen = [[0 for _ in range(W)] for __ in range(H)]

def main():
    q = deque()
    ans = 0
    for i, cc in enumerate(A):
        for j, c in enumerate(cc):
            if c == '#':
                q.append((i, j, 0))
                seen[i][j] = 1
    while q:
        cur_row, cur_col, num = q.popleft()
        for dr, dc in zip(DR, DC):
            n_row = cur_row + dr
            n_col = cur_col + dc
            if not (0 <= n_row < H and 0 <= n_col < W):
                continue
            if seen[n_row][n_col]:
                continue
            if A[n_row][n_col] == '#':
                continue
            q.append((n_row, n_col, num + 1))
            seen[n_row][n_col] = 1
            ans = max(ans, num + 1)
    print(ans)

main()



Measured memory_bytes: 160856
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			var rgb = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int num = rgb[0] * 100 + rgb[1] * 10 + rgb[2];
			if (num % 4 == 0) {
				Console.WriteLine("YES");
			} else {
				Console.WriteLine("NO");
			}
		}
	}
}

Measured memory_bytes: 11220
def main():
    while True:
        N = int(input())
        if N == 0:
            return

        o = 1000 - N
        ans = 0
        coin = [500, 100, 50, 10, 5, 1]
        for c in coin:
            set = o // c
            ans += set
            o -= c * set

        print(ans)


if __name__ == '__main__':
    main()






Measured memory_bytes: 5588
#include<iostream>

using namespace std;

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

    Y /= 1000;

    int yukichi = N;
    int higuchi = 0;
    int noguchi = 0;

    long Y_max = N*10;

    int dif = Y_max - Y;

    while(dif%9 != 0){
        if(dif < 0){
            cout << "-1 -1 -1\n";
            return 0;
        }
        dif -= 5;
        yukichi--;
        higuchi++;
    }
    noguchi += dif/9;
    yukichi -= noguchi;
    if(yukichi < 0)cout << "-1 -1 -1\n";
    else cout << yukichi << " " << higuchi << " " << noguchi << endl;
}

Measured memory_bytes: 256
from itertools import product
n = int(input())
pattern = list(product(*[[1, 0]]*n))

evidence = []
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        evidence.append([i, x-1, y])
        

ans = 0
for patt in pattern:
    contradiction = 0
    for e in evidence:
        if patt[e[0]] == 1:  # 証言者が正直者
            if patt[e[1]] == e[2]:  # 矛盾が生じない
                pass
            else:  # 矛盾が生じる
                contradiction = 1
                break
        elif patt[e[0]] == 0:  # 証言者が不親切な人
            pass
    if contradiction:
        continue
    else:
        ans = max(ans, patt.count(1))
        
print(ans)

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

int n;
int ent;

int main(){
    cin >> n;
    vector< vector<int> > f(n, vector<int>(10, 0));
    vector< vector<int> > c(n, vector<int>(10, 0));
    vector<int> store(n, 0);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 10; j++){
            cin >> c[i][j];
        }
        cin >> ent;
    }
    long long max = -(1 << 30);
    for(int bit = 1; bit < 1024; bit++){
        int mask = 1;
        for(int i = 0; i < 10; i++){
            if( (bit & mask) == mask){
                for(int j = 0; j < n; j++){
                    store[j] = store[j] + f[j][i];
                }
            }
            mask = mask << 1;
        }
        long long calc = 0;
        for(int j = 0; j < n; j++){
            calc = calc + (long long)c[j][store[j]];
            store[j] = 0;
        }
        if(calc > max) {
            max = calc;
        }
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

const ll MOD = ll(1e9) + 7;
const int AZNUM = 26;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> cnt(AZNUM);
    rep(i,n) {
        cnt[s[i]-'a'] ++;
    }
    ll ans = 1;
    rep(i, AZNUM) {
        if (cnt[i] > 0)
            ans = (ans * (cnt[i]+1)) % MOD;
    }
    cout << ans - 1 << "\n";
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Iterator;

public class Main {

	public static void main(String[] args) throws IOException {
		
//		Scanner sc = new Scanner(System.in);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
//		int n = sc.nextInt();
		int n = Integer.parseInt(reader.readLine());
		
		Deque<Integer> list = new ArrayDeque<Integer>(1000000);
		for (int i = 0; i < n; i++) {
//			String command = sc.next();
			String cmd = reader.readLine();

			if ('i' == cmd.charAt(0)) {
				list.addFirst(Integer.parseInt(cmd.substring(7)));
			} else if ('F' == cmd.charAt(6)) {
				list.pollFirst();
			} else if ('L' == cmd.charAt(6)) {
				list.pollLast();
			} else {
				list.remove(Integer.parseInt(cmd.substring(7)));
			}			
		}
//		sc.close();	
		Iterator<Integer> itr = list.iterator();
		while (itr.hasNext()) {
			Integer value = itr.next();
			System.out.print(value);
			if (itr.hasNext()) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}	
}


Measured memory_bytes: 126688
import sys

lucas_nums = [None] * 100
def lucas(n):
    if n == 0:
        return 2
    if n == 1:
        return 1
    if lucas_nums[n]:
        return lucas_nums[n]
    lucas_nums[n] = lucas(n-2) + lucas(n-1)
    return lucas_nums[n]

def main():
    n = int(sys.stdin.readline().rstrip())
    print(lucas(n))

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define MOD 998244353

using namespace std;

vector<int> v[100001];
int k;
ll ans;

void dfs(int x, int p, int dep)
{
    //cout<<ans<<" "<<x<<endl;
    int j=0;
    for(int i=0;i<v[x].size();i++)
    {
        if(v[x][i]==p) continue;
        if(dep+1<=2) 
        {
            ans=(ans*(k-(dep+1)-j))%mod;
            //if(v[x][i]==5) cout<<i<<endl;
            dfs(v[x][i],x,dep+1);
        }
        else{
            ans=(ans*(k-2-j))%mod;
            dfs(v[x][i],x,dep+1);
        }
        j++;
    }
}

int main()
{
    IOS;
    int n;
    cin>>n>>k;
    repf(i,0,n-1)
    {
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    ans=k;
    dfs(1,-1,0);
    cout<<ans<<endl;
}
 

Measured memory_bytes: 11648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int[] x = new int[N];
		int max = A;
		for(int i = 0;i < N;i++) {
			x[i] = sc.nextInt();
			max = Math.max(max,x[i]);
		}
		sc.close();
		long[][][] dp = new long[N+10][N+10][N*max+10];
		for(int j = 0;j <= N;j++){
			for(int k = 0;k <= N;k++) {
				for(int s = 0;s <= N*max;s++) {
					if(j==0 && k==0 && s==0) {
						dp[j][k][s] = 1;
					}else if(j >= 1&& s < x[j-1]) {
						dp[j][k][s] = dp[j-1][k][s];
					}else if(j >= 1&& k >= 1 && s >= x[j-1]) {
						dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]];
					}else {
						dp[j][k][s] = 0;
					}
				}
			}
		}
		long res = 0;
		for(int k = 1;k <= N;k++) {
			res += dp[N][k][k*A];
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 130712
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)


int main () {
    int N,M;
    int P[100000],Y[100000];
    vector<int> yd[100001];
    
    cin>>N>>M;
    rep(i,M)scanf("%d%d",&P[i],&Y[i]),yd[P[i]].push_back(Y[i]);
    
    rep(i,N)sort(yd[i+1].begin(),yd[i+1].end());
    rep(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]]. begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
}


Measured memory_bytes: 7808
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>();
    let mut ans = String::new();
    for c in s.chars() {
        if c == 'B' {
            ans.pop();
            continue
        }
        ans.push(c)
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <numeric>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vec>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int k=38;
    int n=k*k-k+1;
    cout<<n<<" "<<k<<endl;
    rep(i,k)cout<<(i+1)<<" ";
    cout<<endl;
    rep(i,k-1){
        cout<<1<<" ";
        rep(j,k-1){
            cout<<(k-1)*(i+1)+(j+2)<<" ";
        }
        cout<<endl;
    }
    rep2(i,2,k){
        rep(j,k-1){
            cout<<i<<" ";
            int tmp=k+j+1;
            rep(l,k-1){
                cout<<tmp<<" ";
                if((tmp-1+k-2)/(k-1) == (tmp+(i-2)%(k-1)-1+k-2)/(k-1)){
                    tmp += (i-2)%(k-1) + k-1;
                }else{
                    tmp += (i-2)%(k-1);
                }
            }
            cout<<endl;
        }
    }
}


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

#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 1e5+10;
vi g[N];
vi dis(N,0),vis(N,0);

int ans =0;

vi top;

void dfs(int node)
{
    vis[node] = 1;
    
    for(auto x : g[node])
        if(!vis[x]) dfs(x);
        
    top.pb(node);
}

void solve()
{
 int n,m,a,b;
    cin >> n >> m;
    
 f(i,m)
 {
     cin >> a >> b;
     g[a].pb(b);
 }
    
 for(int i=1;i<=n;i++)
    if(!vis[i]) dfs(i);
    
 for(auto x : top)
 {     
    for(auto z : g[x])
      dis[x] = max(dis[x],dis[z]);    
        
    
   ans=max(ans,dis[x]); 
   dis[x]++;
 }
    
 cout << ans;   
}

signed main()
{
    fast;
    solve();
}

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

#define int long long 
#define MAXN 100005

int n,m;
int a[MAXN];
int c[MAXN],d[MAXN];
int ans = 0;

void rd()
{
	cin >> n;
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
		c[a[i]] ++;
		d[a[i]] ++;
	}
	sort(a+1,a+n+1);
	for(int i = 1; i <= 2000; i ++)
		c[i] = c[i-1] + c[i];
}

signed main()
{
	rd();
	for(int i = 1; i <= 1000; i ++) {
		for(int j = (i>>1)+1; j < i; j ++) {
			ans += d[i] * d[j] * (c[j-1] - c[i-j]); 
		//	cout<<i<<" "<<j<<" "<<ans<<"\n";
		}
	}
	
	for(int i = 1; i <= 1000; i ++) 
	if(d[i] >= 2){
		ans += (d[i]*(d[i]-1) >> 1) * (c[i*2-1] - d[i]);
	}
	
	for(int i = 1; i <= 1000; i ++) 
	if(d[i] >= 3){
		ans += (d[i]*(d[i]-1)*(d[i]-2)/6);
	}
	
	
	cout<<ans<<"\n";
	return 0;
}
/*
6
1 2 4 4 4 5

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int t[200001];
int main (){
    int n;
    ios::sync_with_stdio(false);
    cin >> n;
    int ch;
    for (int i = 1; i < n; i++){
        cin >> ch;
        t[ch]++;
    }
    for (int i = 1; i <= n; i++)
        cout << t[i] << endl;
    return 0;
}

Measured memory_bytes: 4364
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[200005] = {};
	ll memo2[10004] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	cin >> a;
	cin >> b;
	if (b%a==0)
	{
		cout << b+a << endl;

	}
	else
	{
		cout << b - a << endl;

	}
	//cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

int main() {
  string S;
  ll N = 0;
  cin >> S;
  for (auto c : S) {
    if (c == '+') {
      N++;
    } else {
      N--;
    }
  }

  cout << N << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;

typedef vector<pair<int,int>> vpii;
typedef pair<int,int> pr;

int main(){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else if(s=="Rainy") cout << "Sunny" << endl;
}

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

int main()
{
    int i=3,n,x,k=0;
    
    
    cin >> n;
    while(i <= n)
    {
        x = i;
        k = 0;
        if(x % 3 == 0 or x % 10 == 3)
        {
                cout << " " << i;
                k = 1;
        }
                   x /= 10;
        while(x && k == 0)
        {
            if(x % 10 == 3)
                {
                cout << " " << i;
                break;
                }
            x /= 10;
        }
        
        i++;
    }
    cout << endl;
    return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll ans=2019;
	ll l,r;
	cin>>l>>r;
	for(ll le=l;le<=min(l+2019,r);le++){
		for(ll rr=le+1;(rr<=min(le+2019,r));rr++){
			chmin(ans,(le*rr)%2019);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int A, B, C, D; 
  cin >> A >> B >> C >> D;

  while(true){
    C -= B;
    if(C <= 0) {yes; break;}
    A -= D;
    if(A <= 0) {no; break;}
  }

  return 0;
}


Measured memory_bytes: 3540
#include<iostream>
#include<sstream>
#include<vector>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int sz[100000],m;
bool released[100000];
map<string,int> v;
int mem,use;
string in;
bool err;

int rec(int l,int r){
	//cerr<<in.substr(l,r-l)<<endl;
	int i,d=0;
	for(i=l;i<r;i++){
		if(in[i]=='(')d++;
		if(in[i]==')')d--;
		if(d==0&&in[i]=='=')break;
	}
	if(i<r){
		return v[in.substr(l,i-l)]=rec(i+1,r);
	}
	d=0;
	for(i=r-1;i>=l;i--){
		if(in[i]==')')d++;
		if(in[i]=='(')d--;
		if(d==0)break;
	}
	if(i==r-1)return v[in.substr(l,r-l)];
	if(i==l)return rec(i+1,r-1);
	
	string op=in.substr(l,i-l);
	if(op=="malloc"){
		int s=atoi(in.substr(i+1,r-i-2).c_str());
		if(s<=mem-use){
			sz[m]=s;
			use+=s;
			return m++;
		}
		return -1;
	}
	if(op=="free"){
		int s=rec(i+1,r-1);
		if(s<0)return -1;
		if(s==0||released[s])err=1;
		else released[s]=1, use-=sz[s];
		return 0;
	}
	if(op=="clone"){
		int s=rec(i+1,r-1);
		if(s<0)return -1;
		if(s==0||released[s])return err=1, 0;
		if(sz[s]<=mem-use){
			sz[m]=sz[s];
			use+=sz[s];
			return m++;
		}
		return -1;
	}
	return v[in.substr(l,r-l)];
}
int main(){
	cin>>mem;
	m=1;
	v["NULL"]=-1;
	err=0;
	while(cin>>in){
		rec(0,in.size());
	}
	if(err)cout<<"Error"<<endl;
	else{
		fr(i,v)if(i->second>0&&!released[i->second]){
			released[i->second]=1;
			use-=sz[i->second];
		}
		cout<<use<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.IO;
using System.Linq;
using static System.Console;

namespace ALDS1
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            SolveProblem<int>();
        }


        static void SolveProblem<T>()
        {
            var sw = new StreamWriter(OpenStandardOutput()) {AutoFlush = false};
            SetOut(sw);
            
            var n = int.Parse(ReadLine());
            var array = ReadLine().Split(' ')
                .Select(int.Parse)
                .ToArray();

            InsertionSort(array);
            
            Out.Flush();
        }
        static void InsertionSort<T>(T[] array) where T : IComparable<T>
        {
            for (var i = 1; i < array.Length; i++)
            {
                WriteLine(string.Join(" ", array).Trim());
                for (var j = i; j >= 1 && array[j].CompareTo(array[j - 1]) < 0; j--)
                {
                   Swap(ref array[j], ref array[j-1]);
                }
            }
            WriteLine(string.Join(" ", array).Trim());
        }

        public static void Swap<T>(ref T a, ref T b)
        {
            var tmp = a;
            a = b;
            b = tmp;
        }
    }
}


Measured memory_bytes: 18268
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

void bubble(int p[], int n) {
  for(int i = 0; i < n; i++) {
    for(int j = n-1; j >= i+1; j--)
      if(p[j] < p[j-1]) swap(p[j],p[j-1]);
  }
}

int main() {
  int n,k,p[1100];
  cin >> n >> k;
  for(int i = 0; i < n; i++)
    cin >> p[i];

  bubble(p,n);
  int ans = 0;
  for(int i = 0; i < k; i++) {
    ans += p[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628