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

#define lli long long int
#define mpr make_pair
#define pr pair<lli,lli>
#define pb push_back
#define vl vector<lli>
#define mp map<lli,lli>
#define all(x) x.begin(),x.end()
#define FOR(i,n) for(lli i=0;i<(lli)n;i++)
#define FOR1(i,j,n) for(lli i=j;i<(lli)n;i++)
#define mod 1000000007

lli power(lli x,lli n,lli m)
{
	lli res=1;
	while(n>0)
	{
		if(n&1) res=(res*x)%m;
		x=(x*x)%m;
		n=n>>1;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,k,s=0;;
    cin>>n>>k;
    vl v(n);
    for(lli i=0;i<n;i++)
    cin>>v[i];
    sort(all(v));
    for(lli i=0;i<k;i++)
    s+=v[i];
    cout<<s<<endl;
	
	
	
	
return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        string s = NextString();
        string _s = "CODEFESTIVAL2016";
        int ans = 0;
        for (int i = 0; i < s.Length; i++) ans += (s[i] == _s[i] ? 0 : 1);
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
#!/usr/bin/python

import sys
def readints():
    return map(int, sys.stdin.readline().split())


n, k = readints()
while n and k:
    data = [readints()[0] for i in range(n)]

    window = sum(data[:k])
    L = window
    for i in range(k, n):
        window = window + data[i] - data[i-k]
        if window > L:
            L = window
    print L
    n, k = readints()

Measured memory_bytes: 10484
h, w, K = map(int, input().split())

C = []

ans = 0

for i in range(h):
  c = input()
  C.append(c)
  
for i in range(2 ** h):
  for k in range(2 ** w):
    black = 0
    for j in range(h):
      for l in range(w):
        if ((i >> j) & 1) == 0 and ((k >> l) & 1) == 0 and C[j][l] == '#':
          black += 1
    if black == K:
      ans += 1

print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int x; cin >> x;
	int ans = 0;
	ans += (x/500)*1000;
	x %= 500;
	ans += (x/5)*5;
	cout << ans << endl;
}




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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
void print(const vector<int>& v) { for_each(All(v), [](int x) {cout << x << " ";}); cout << endl; }

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  double n,m;
  cin>>n>>m;
  vector<int> a(n);
  double sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  sort(rAll(a));

  double hoge=sum/(4*m);
  //print(a);
  //cout<<sum<<endl;
  rep(i,m){
    //cout<<a[i]<<" "<<hoge<<endl;
    if(a[i]<hoge){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n,k int
    fmt.Scan(&n,&k)
    a := make([]int, n)
    for i:=0;i<n;i++{
        fmt.Scan(&a[i])
    }
    sort.Sort(sort.Reverse(sort.IntSlice(a)))
    ans := 0
    for i:=0;i<k;i++{
        ans += a[i]
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main() {
  lli A,B,C,D,E,F,N,M,K,sum=0,num=0,ans=0;
  cin >> N;
  vector<int>P(N,0);
  rep(i,0,N)cin >> P[i];
  double ssum;
  rep(i,0,N)ssum+=1.00/P[i];
  HpOut(1/ssum);
}

Measured memory_bytes: 256
#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;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll M = 1000;
    REP(i, N-1){
        if(A[i]<A[i+1]){
            ll kau = M/A[i];
            M += (A[i+1]-A[i]) * kau;
        }
    }
    cout << M << endl;


    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
constexpr int MOD = 1000000007;

int main() {
    int n;
    scanf("%d", &n);
    int ans = 1;
    for (int i = 1; i <= n; i++) ans = (long long)ans*i%MOD;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import itertools

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

# ABCのいずれかの竹の材料にするか、使わないかの4通りを全ての竹に対して試す
appli = ["A", "B", "C", "D"]
appli = list(itertools.product(appli, repeat=N))

# 目的の竹と、その材料リストを入力すると、必要MPを返す関数
def need_MP_for_one_bamboo(X, bamboo_list):
    return 10*(len(bamboo_list)-1) + abs(sum(bamboo_list)-X)

# N本の竹の用途パターンを入力すると必要MPを返す関数
def need_MP_for_pattern(appli_pattern):
    bamboo_for_A = []
    bamboo_for_B = []
    bamboo_for_C = []
    for idx in range(len(appli_pattern)):
        if appli_pattern[idx] == "A":
            bamboo_for_A.append(l[idx])
        elif appli_pattern[idx] == "B":
            bamboo_for_B.append(l[idx])
        elif appli_pattern[idx] == "C":
            bamboo_for_C.append(l[idx])
            
    # A,B,Cいずれかにおいて、材料となる竹が1本もない場合
    if not (bamboo_for_A and bamboo_for_B and bamboo_for_C):
        return float("inf")
    else:
        return need_MP_for_one_bamboo(A, bamboo_for_A) + need_MP_for_one_bamboo(B, bamboo_for_B) + need_MP_for_one_bamboo(C, bamboo_for_C)
        
            

# 用途全パターンについて必要MPを計算し、最小のものを出力する
ans = float("inf")
for appli_pattern in appli:
    ans = min(ans, need_MP_for_pattern(appli_pattern))

print(ans)

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

public class Test
{
	public static void Main(){
var p = Console.ReadLine().ToCharArray();
var s = Console.ReadLine();
Console.WriteLine(s.ToCharArray().Where(i=>{
p = p.Skip(1).Concat(p.Take(1)).ToArray();
return String.Join("",p)==s;
}).Count()==0?"No":"Yes");
}
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string x,y,z;
	int a,b,c;
	cin>>x>>y>>z;
	a=x.size()-1; b=y.size()-1; c=z.size()-1;
    if(x[a]==y[0]&&y[b]==z[0])
    {
      cout<<"YES";
    }
	else
      cout<<"NO";

	return 0;
}


Measured memory_bytes: 256
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




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


int main() {
	int n, m; cin >> n >> m;
	rep(i, m){
		int a;
		cin >> a;
		n = n - a;
	}
	if(n < 0){
		n = -1;
	}

	cout << n << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S == "SUN"){
    cout << "7" << endl;
  }
  else if(S == "MON"){
    cout << "6" << endl;
  }
   else if(S == "TUE"){
    cout << "5" << endl;
  }
   else if(S == "WED"){
    cout << "4" << endl;
  }
   else if(S == "THU"){
    cout << "3" << endl;
  }
   else if(S == "FRI"){
    cout << "2" << endl;
  }
   else if(S == "SAT"){
    cout << "1" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a, b, c, cnt = 0;
    scanf("%d %d %d", &a, &b, &c);
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
        {
            cnt++;
        }
    }
    printf("%d\n", cnt);
}



Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n;
	int count = 0;
	//cin >> n;
	string s;
	cin >> s;
	n = s.size();
	bool rflag = false;
	bool bflag = false;

	long bcount = 0;
	long rcount = 0;

	for (int i = 0; i < n; i++)
	{
		if (s[i] == '0')rcount++;
		else bcount++;
	}


	while (1)
	{
		if (bcount > 0 && rcount >0)
		{
			count++;
			bcount--;
			rcount--;
		}
		else
		{
			cout << count * 2 << endl;
			return 0;
		}
		/*for (int i = 0; i < n; i++)
		{
			cout << s[i] << endl;
		}*/
		/*bflag = true;
		rflag = true;
		for (int i = 0; i < n; i++)
		{
			if (s[i] == '0')bflag = false;
			if (s[i] == '1')rflag = false;
		}
		if (bflag || rflag)
		{
			cout << count*2 << endl;
			return 0;
		}*/
		/*int c=0;
		while (1)
		{
			if (bflag && rflag)
			{
				count++;
				break;
			}
			if (s[c] == '0' && !rflag)
			{
				rflag = true;
				s[c] = '2';

			}
			if (s[c] == '1' && !bflag)
			{
				bflag = true;
				s[c] = '2';
			}
			c++;
		}*/
	}
}

Measured memory_bytes: 512
S = input()
n = len(S)
r = 0
for i in range(1<<(n-1)):
  s, _sum, f = S, 0, 0
  for j in range(n):
    if i>>j & 1:
      _sum += int(s[f:j+1])
      f = j + 1
  r += _sum + int(s[f:j+1])
print(r)

Measured memory_bytes: 39920
#include<stdio.h>
#include<string.h>
#define M 1046527
#define NIL -1
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch == 'A')return 1;
  else if(ch == 'C')return 2;
  else if(ch == 'G')return 3;
  else if(ch == 'T')return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0,p = 1,i;
  for(i = 0 ; i < strlen(str) ; i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key%M;
}

int h2(int key){
  return 1 + (key%(M - 1));
}

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0 ; ; i++){
    h = (h1(key) + i*h2(key))%M;
    if(strcmp(H[h],str) == 0)return 1;
    else if(strlen(H[h]) == 0)return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0 ; ; i++){
    h = (h1(key) + i*h2(key))%M;
    if(strcmp(H[h],str) == 0)return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i = 0 ; i < M ; i++){
    H[i][0] == '\0';
  }
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%s %s",com,str);
    if(com[0] == 'i'){
      insert(str);
    }
    else{
      if(find(str)){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 16008
#include<stdio.h>
int main(){
    int a,b,c;
    char op;
    for(;;){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?'){
            break;
        }
        else if(op=='+'){
            c=a+b;
        }
        else if(op=='-'){
            c=a-b;
        }
        else if(op=='/'){
            c=a/b;
        }
        else if(op=='*'){
            c=a*b;
        }
        
        
        
        
    printf("%d\n",c);
    }
    return 0;
}

Measured memory_bytes: 600
a, b, K = gets.split(' ').map(&:to_i)

K.times do |i|
  if i.even?
    if a.odd?
      a -= 1
    end
    t = a / 2
    b += t
    a -= t
  else
    if b.odd?
      b -= 1
    end
    t = b / 2
    a += t
    b -= t
  end
end

puts "#{a} #{b}"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

//int dp[333][2];
void solve(){
	int n, r;
	cin>>n>>r;
	if(n>=10){
		cout<<r<<endl;
	}
	else{
		cout<<r+100*(10-n)<<endl;
	}
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

map<int, int> mii;

int main(){
	int l;
	string a;
	while(cin>>a>>l, l){
		mii.clear();
		mii[toInt(a)] = 0;
		int i=0;
		while(1){
			while(a.size()!=l)a.PB('0');
			int M,m;
			SORT(a);
			m = toInt(a);
			reverse(ALL(a));
			M = toInt(a);
			int n=M-m;
			a = toString(n);
			i++;
			if(EXIST(mii, n)){
				cout << mii[n] << " " <<  n << " " << i-mii[n] << endl;
				break;
			}
			mii[n] = i;
		}
	}
	return 0;
}

Measured memory_bytes: 1252
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int N;
int E[200001], n[200001], H[100001];
int kyori, kotae;
int dfs(int p, int mae, int d) {
	int kazu = 1;
	if (p == N) {
		kazu += 1 << 20;
		kyori = (d + 1) / 2;
	}
	for (int i = H[p]; i; i = n[i]) if (E[i] != mae) kazu += dfs(E[i], p, d + 1);
	if (kazu > (1 << 20) && d == kyori + 1) kotae = kazu - (1 << 20);
	return kazu;
}

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


	N = getint();
	int kari = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		E[kari] = b;
		n[kari] = H[a];
		H[a] = kari++;
		E[kari] = a;
		n[kari] = H[b];
		H[b] = kari++;
	}

	dfs(1, 0, 1);

	if (N - kotae > kotae) printf("Fennec");
	else printf("Snuke");

	Would you please return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int w, n;
vector<int> x, lsum, tbl;

inline int roundup(int a, int b){
	return (a + b - 1) / b;
}

template <class F>
int binsearch(int lt, int rt, F func){
	while(lt < rt){
		int md = (lt + rt) / 2;
		if(func(md)){
			rt = md;
		}
		else{
			lt = md + 1;
		}
	}
	return lt;
}


struct spchecker{
	int msp, from;
	spchecker(int msp, int from): from(from), msp(msp) {}
	
	bool operator() (int to){
		int xsum = lsum[to] - lsum[from-1];
		int dif = to - from;
		int sp = (w - xsum + dif - 1) / dif;
		return sp <= msp;
	}
};

bool solve(int sp){
	tbl.assign(n + 3, 0);
	int s = -1;
	int i;
	for(i = n; i > 0; --i){
		s += 1 + x[i];
		if(s > w) break;
		tbl[i] = tbl[i+1] + 1;
	}
	int t = n;

	for(; i > 0; s += x[--i] + 1){
		while(s > w){
			s -= x[t--] + 1;
		}
		int k = binsearch(i + 1, n + 1, spchecker(sp, i));
		tbl[i] = tbl[i+1] + (tbl[k+1] > tbl[t+2]);
	}
	return tbl[1] > tbl[2];
}


int main(){
	while(scanf("%d%d", &w, &n), n){
		x.resize(n + 3);
		lsum.resize(n + 3);
		for(int i = 1; i <= n; ++i){
			scanf("%d", &x[i]);
			lsum[i] = lsum[i-1] + x[i];
		}
		lsum[n + 1] = lsum[n + 2] = lsum[n];
		printf("%d\n", binsearch(1, w, solve));
	}
}

Measured memory_bytes: 1536
X,Y,Z,K = map(int, input().split())
A = list( map(int, input().split()))
B = list( map(int, input().split()))
C = list( map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


"""
愚直解
X*Y*Z全部作って上から順にK個書き出す。普通に間に合わない
愚直解のいけてない部分として、X*Yを作った段階で、他のX*Yよりずっと小さいときに、Zとの積を見るまでもなくK番目までに入らないケースがある。
なんというか、　X*Y*Z　を　W*Z (W=X*Y)と置き換えたときに、Wの中で順位が低いものとZとの積を計算して他と比較する意味がない。
W = [9,8,7,6,5,4,3]
Z = [6,4,3,2,1]
K = 5
とかで考えると、Wが3や4のものは見る必要がない。
というのも、それより大きいWがK個以上あることが分かっているので、W*ZもK個以上大きいものが存在するといえるので。

なので、先にX*Yを計算して、その中で上位K個とZの積をとってさらにK個選べばいけそう


"""
W = []
for a in A:
    for b in B:
        W.append(a+b)

W.sort(reverse=True)
if len(W) > K:
    W = W[:K]
ans = []
for w in W:
    for c in C:
        ans.append(w+c)

ans.sort(reverse=True)
print(*ans[:K], sep="\n")

Measured memory_bytes: 151644
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

values_all = []
for a in range(2 ** 10):
    a2 = bin(a)[2:].zfill(10)
    values = 0
    for i in range(n):
        ci = 0
        for j in range(10):
            if f[i][j] == 1 and a2[j] == '1':
                ci += 1
        pici = p[i][ci]
        values += pici
    values_all.append(values)

print(max(values_all[1:]))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    cin >> a;
    vector<bool> r(H), c(W);
    REP(i, H) {
        bool del = true;
        REP(j, W) {
            if (a[i][j] == '#') del = false;
        }
        if (del) r[i] = true;
    }
    REP(j, W) {
        bool del = true;
        REP(i, H) {
            if (a[i][j] == '#') del = false;
        }
        if (del) c[j] = true;
    }

    REP(i, H) {
        if (r[i]) continue;
        string row;
        REP(j, W) {
            if (!c[j]) row.pb(a[i][j]);
        }
        cout << row << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    int a, b;
    cin >> a >> b;
    cout << a *b << endl;
}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 3636
num, yen = map(int ,input().split())
yen /= 1000
for i in range(num + 1):
    for j in range(num + 1 -i):
        k = num - i - j
        if 10 * k + 5 * j + i * 1 == yen:
            print(k,j,i)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    unordered_map<string,int> count;
    for(int i = 0;i < n; i++){
		string s;
		cin >> s;
		count[s] += 1;
	}
	cout << "AC x " << count["AC"] << "\n" << "WA x " << count["WA"] << "\n" << "TLE x " << count["TLE"] << "\n" << "RE x " << count["RE"] << "\n";
}
 


Measured memory_bytes: 3664
l,r = map(int, input().split())
if r-l >= 2019:
  print(0)
  exit()
else:
  m = 2018
  for i in range(l, r):
    for j in range(i+1, r+1):
      if i*j % 2019 < m:
        m = i*j % 2019

print(m)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50;

int n,a[N],f[N],pg[N],pl[N]; 

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	read(n); 
	rep(i,1,n){
		read(a[i]); 
		pg[i]=i;
		if(a[i]>=a[i-1])pg[i]=pg[i-1];
		pl[i]=i;
		if(a[i]<=a[i-1])pl[i]=pl[i-1];
		f[i]=min(f[pg[i]-1],f[pl[i]-1])+1;
	}	
	printf("%d\n",f[n]);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    string s;
    int n;
    cin >> s >> n;
    int l=s.size();
    int ans=0;
    rep(i,n){
        string u;
        cin >> u;
        bool y=false;
        rep(j,11){
            bool t=true;
            for (int k=j;k<j+l;k++){
                if (u[k%10]!=s[k-j]) t=false;
            }
            if (t) y=true;
        }
        if (y) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1010101010
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define mp make_pair

using namespace std;





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


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}



bool negative[1010];
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int res = A % B;
	int mod = res;
	bool ok = false;
	REP(i, 200) {
		mod += res;
		mod %= B;
		if (mod == C)ok = true;
	}
	if (ok)cout << "YES";
	else cout << "NO";
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007;

struct cxk
{
	lint c0,c1;
	cxk(lint c0_=0,lint c1_=0){c0=c0_,c1=c1_;}
	friend cxk operator + (cxk a,cxk b){return cxk(a.c0+b.c0,a.c1+b.c1);}
	friend int operator < (cxk a,cxk b){return a.c1*b.c0<a.c0*b.c1;}
}ps[_];

int n,fa[_]={0},bfa[_]={0},val[_],bval[_]={0};

int findbfa(int x)
{
	return x==bfa[x]?x:bfa[x]=findbfa(bfa[x]);
}

set<pair<cxk,int>> s;

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty();
	for(int i=2;i<=n;i++)fa[i]=ty();
	for(int i=1;i<=n;i++)val[i]=ty();

	for(int i=1;i<=n;i++)bfa[i]=i,ps[i]=cxk(val[i]==0,val[i]==1),s.emplace(ps[i],i);

	lint ans=0;
	while(!s.empty())
	{
		int a=(*s.begin()).second;
		s.erase(s.begin());
		if(a==1)continue;
		int aa=findbfa(fa[a]);
		bfa[a]=aa,ans+=ps[aa].c1*ps[a].c0,s.erase(make_pair(ps[aa],aa));
		ps[aa]=ps[aa]+ps[a],s.emplace(ps[aa],aa);
	}
	cout<<ans<<lf;

	return 0;
}


Measured memory_bytes: 18304
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
long long extGCD(long long a,long long mod,long long &x,long long &y){
    if(mod==0){
        x=1;
        y=0;
        return a;
    }
    long long d=extGCD(mod,a%mod,y,x);//上に上がるときにswap(x,y)すると見る
    y-=(a/mod)*x;
    return d;
}
long long invmod(long long a,long long mod){
    long long x,y;
    extGCD(a,mod,x,y);
    x%=mod;
    if(x<0)x+=mod;
    return x;
}
ll fac[200010],finv[200010],inv[200010];
void combinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    REP(i,2,200010){
        fac[i]=fac[i-1]*i%inf;
        inv[i]=invmod(i,inf);
        finv[i]=finv[i-1]*inv[i]%inf;
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%inf)%inf;
}
int main(){
    int h,w,a,b;cin>>h>>w>>a>>b;
    combinit();
    ll ans=comb(h+w-2,h-1);
    ll cnt=0;
    rep(i,a){
        cnt=(cnt+comb(h-a+i+b-1,b-1)*comb(a-i-1+w-b-1,w-b-1)%inf)%inf;
    }
    ans-=cnt;
    if(ans<0)ans+=inf;
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
import numpy as np
n, d = map(int, input().split())
a = np.zeros((n, d))
ans = 0
for i in range(n):
  a[i] = np.array([int(j) for j in input().split()])
for i in range(n-1):
  for j in range(i+1, n):
    if float.is_integer(np.linalg.norm(a[i]-a[j])):
      ans += 1
print(ans)

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

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

int main()
{
    int N, M;
    cin >> N >> M;
    priority_queue<pair<int, int>> pq;
    rep(i, N){
        pair<int, int> tmp;
        cin >> tmp.first;
        tmp.second = 1;
        pq.push(tmp);
    }
    rep(i, M){
        pair<int, int> tmp;
        cin >> tmp.second >> tmp.first;
        pq.push(tmp);
    }
    long long ans = 0;
    rep(i, N){
        pair<int, int> tmp = pq.top();
        pq.pop();
        ans += tmp.first;
        if(tmp.second >= 2){
            tmp.second--;
            pq.push(tmp);
        }
    }

    cout << ans << endl;
}



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

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

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

  long long ops = 0;
  for (int i=0; i<N; i++) {
    while (a[i] % 2 == 0) {
      a[i] = a[i] / 2;
      ops++;
    }
  }
  cout << ops << endl; 
}


Measured memory_bytes: 384
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int w,a,b;
  cin >> w >> a >> b;
  if(abs(a-b) <= w){
    cout << 0 << endl;
  }
  else{
  if(a < b){
  cout << b-(a+w) << endl;
  }
  else{
  cout << a-(b+w) << endl;   
  }
  }
}

Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
//#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

//多倍長テンプレ
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    Bint X,K,D;
    cin>>X>>K>>D;
    Bint h=INF;
    Bint ans=h*h*h;
    if(X-K*D>=0)prt(X-K*D);
    else if(X+K*D<=0)prt(-X-K*D);
    else {
        Bint Max=X+K*D;
        Bint k=Max/(2*D);
        if(ans>Max-k*2*D)ans=Max-k*2*D;
        Bint j=Max-(k+1)*2*D;
        if(j<0)j=-j;
        if(ans>j)ans=j;
        prt(ans);
    }

    return 0;
}



Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

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

	static int INF = 1 << 30;
	static int modP = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), d = in.nextInt();
			if (Math.abs(a-c) <= d) {
				out.println("Yes");
			} else if (Math.abs(a-b)<=d && Math.abs(b-c)<=d) {
				out.println("Yes");
			} else {
				out.println("No");
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      int pm, pe, pj;
      cin >> pm >> pe >> pj;
      char ans = 'C';
      if (pm == 100 || pe == 100 || pj == 100) ans = 'A';
      else if (pm + pe >= 180) ans = 'A';
      else if (pm + pe + pj >= 240) ans = 'A';
      else if (pm + pe + pj >= 210) ans = 'B';
      else if (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)) ans = 'B';
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3032
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using ll=long long int;

int main() {
    int a, b;
    cin >> a >> b;

    if (b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int Max = 3e5;

LL n, num[Max + 5];
LL sum_max[Max + 5], sum_min[Max + 5], sum1, sum2, sum;

int main() {
	scanf("%lld", &n);
	for(LL i = 1; i <= 3 * n; i++) scanf("%lld", &num[i]);
	priority_queue<LL, vector<LL>, greater<LL> > q1;
	priority_queue<LL> q2;
	for(LL i = 1; i <= n; i++) {
		sum1 += num[i];
		q1.push(num[i]);
	}
	sum_max[n] = sum1;
	for(LL i = n + 1; i <= 2 * n; i++){
		if(num[i] > q1.top()){
			sum1 -= q1.top();
			q1.pop();
			q1.push(num[i]);
			sum1 += num[i];
		}
		sum_max[i] = sum1;
	}
	for(LL i = 3 * n; i >= 2 * n + 1; i--){
		sum2 += num[i];
		q2.push(num[i]);
	}
	sum_min[2 * n + 1] = sum2;
	for(LL i = 2 * n; i > n; i--){
		if(num[i] < q2.top()) {
			sum2 -= q2.top();
			q2.pop();
			q2.push(num[i]);
			sum2 += num[i];
		}
		sum_min[i] = sum2;
	}
	sum = -(1LL << 60);
	for(LL i = n ; i <= 2 * n; i++)
		sum = max(sum, sum_max[i] - sum_min[i + 1]);
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 7668
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int main(){
   ll n,x;
   cin>>n>>x;
   vector<ll> a(n),b(n);
   for(int i=0;i<n;i++){
       cin>>a[i];
       b[i]=a[i];
   }
   ll ans=inf;
   //色変の操作回数kを固定して求める
   for(int k=0;k<n;k++){
       ll change=k*x;
       //i~i-k区間の最小値をとる
       ll sum=0;
       for(int i=0;i<n;i++){
           b[i]=min(b[i],a[(i+n-k)%n]);
           sum+=b[i];
       }
       ans=min(ans,sum+change);
       }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string a, b;
    cin >> a >> b;
    string s, t;
    int x = a[0] - '0';
    int y = b[0] - '0';
    rep(i,y)s += a;
    rep(i,x)t += b;

    if(s > t)s = t;

    cout << s << endl;
    return 0;
}
 
 


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

int main() {

  long long n, a, b, c, d;
  cin>>n>>a>>b>>c>>d;
  if (b > a + (n - 1) * d || b < a - (n - 1) * d) {
    cout<<"NO"<<endl;
    return 0;
  }
  long long low = a, up = a;
  for (int i=2; i<n; i+=2) {
    low -= d - c;
    up += d - c;
    if (low + (n - i - 1) * c <= b && b <= up + (n - i - 1) * d) {
      cout<<"YES"<<endl;
      return 0;
    }
    if (low - (n - i - 1) * d <= b && b <= up - (n - i - 1) * c) {
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n =  Integer.parseInt(br.readLine());
		String[] sStr = br.readLine().split(" ");
		int S[] = new int[n];
		for(int i = 0 ; i < n ; i++){
			S[i] = Integer.parseInt(sStr[i]);
		}

		int q = Integer.parseInt(br.readLine());
		String[] tStr = br.readLine().split(" ");
		int T[] = new int[q];
		for(int i = 0 ; i < q ; i++){
			T[i] = Integer.parseInt(tStr[i]);
		}

		System.out.println(binarySearch(S,T));
	}

	public static int binarySearch(int[] S,int[] T){
		int min;
		int max;
		int mid;
		int count = 0;
		int searchNum;

		for(int y = 0; y < T.length; y++){
			searchNum = T[y];
			min = 0;
			max = S.length;
			while(max > min){
				mid = (max + min) / 2;
				if(S[mid] == searchNum){
					count++;
					break;
				}else if(S[mid] < searchNum){
					min = mid + 1;
				}else{
					max = mid;
				}
			}
		}

		return count;
	}

}

Measured memory_bytes: 47224
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));

 		
int main() {

int N;
cin>>N;
int k=-1;
for(int y=1;y*(y-1)<=2*N;y++){
	if(y*(y-1)==2*N){
		k=y;
		break;
	}
}

if(k==-1){
	ce("No")
}else{
  ce("Yes")
	vec(A)
	vec(B)
	ce(k)
			cout<<k-1<<' ';
		for(int x=1;x<=k-1;x++){
			cout<<x<<' ';
		}
		cout<<endl;
		pb(A,1)
	int lim=k;
	int i=1;
	while(i++<k){
		cout<<k-1<<' ';
		int u=A.size();
		fx(A.size()){
			cout<<A.at(x)++<<' ';
		}
		pb(A,lim)
		while(u++<k-1){
			cout<<lim++<<' ';
		}
		cout<<endl;
	}
}

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



void solve(){
    ll n,k;
    cin >> n >> k;
    cout << min(n%k, k-(n%k));

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    cin>>n;
    bool ok=true;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin>>a;
        if(a%2==0)
        {
            if(a%3==0 || a%5==0)
            {

            }
            else
            {
                ok=false;
            }
            
        }
    }
    if(ok) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
    
    return 0;
}

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

list = [list(map(int, input().split())) for i in range(n[0])]

a = {}
for i in list:
    for j in i[1:]:
        if j in a:
            a[j] = a[j] + 1
        else:
            a[j] = 1

cnt = 0
for x in a.values():
    if x == n[0]:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064