akhauriyash/Code-Regression huggingface dataset:
// SeeAlso: https://atcoder.jp/contests/abc144/tasks/abc145_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    bool flag = true;
    rep(i, (n/2)) {
        if(s[i] != s[i+n/2]) {
            flag =false;
        }
    }

    if(n%2==1) {
        flag = false;
    }
    print(flag?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int N, A, B;

int main()
{
    cin >> N >> A >> B;
    int japan = 0;
    int oversea = 0;
    int other = 0;
    for (int rank = 1; rank <= N; ++rank) {
        char role;
        cin >> role;
        switch (role) {
            case 'a':
                if (japan + oversea < A + B) {
                    cout << "Yes" << endl;
                    ++japan;
                } else {
                    cout << "No" << endl;
                }
                break;
            case 'b':
                if (japan + oversea < A + B and oversea < B) {
                    cout << "Yes" << endl;
                    ++oversea;
                } else {
                    cout << "No" << endl;
                }
                break;
            case 'c':
                cout << "No" << endl;
                break;
        }
    }

    return 0;
}

Measured memory_bytes: 640
// problem: "https://atcoder.jp/contests/abc129/tasks/abc129_d"

#include<bits/stdc++.h>

using namespace std;

struct node
{
    int l,r,u,d;
};

int main()
{
    int h,w;
    cin>>h>>w;
    string s;
    vector<string>S(h);
    int i,j;
    for(i=0;i!=h;i++)
        cin>>S[i];

    vector<vector<node>>V(h,vector<node>(w));

    for(i=0;i!=h;i++)
    {
        // storing left occupied indices
        for(j=0;j!=w;j++)
        {
            if(j==0 && S[i][j]!='#')
                V[i][j].l = -1;
            else if(S[i][j] == '#')
                V[i][j].l = j;
            else
                V[i][j].l = V[i][j-1].l;
        }

        // storing right occupied indices
        for(j=w-1;j>=0;j--)
        {
            if(j==w-1 && S[i][j]!='#')
                V[i][j].r = w;
            else if(S[i][j]=='#')
                V[i][j].r = j;
            else
                V[i][j].r = V[i][j+1].r;
        }
    }

    for(j=0;j!=w;j++)
    {
        // storing top occupied indices
        for(i=0;i!=h;i++)
        {
            if(i==0 && S[i][j]!='#')
                V[i][j].u = -1;
            else if(S[i][j]=='#')
                V[i][j].u = i;
            else
                V[i][j].u = V[i-1][j].u;
        }

        // storing down occupied indices
        for(i=h-1;i>=0;i--)
        {
            if(i==h-1 && S[i][j]!='#')
                V[i][j].d = h;
            else if(S[i][j]=='#')
                V[i][j].d = i;
            else
                V[i][j].d = V[i+1][j].d;
        }
    }

    int M = 0;
    for(i=0;i!=h;i++)
    {
        for(j=0;j!=w;j++)
        {
            M = max(M,j-V[i][j].l-1 + V[i][j].r-j-1 + i-V[i][j].u-1 + V[i][j].d-i-1 + 1);
        }
    }

    cout<<M;

    return 0;
}


Measured memory_bytes: 66944
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int N, M;  cin >> N >> M;
    vvi A(N);
    REP(i,N) {
        int L; cin >> L;
        A[i] = vi(L); 
        REP(j, L) {
            int a; cin >> a; a--;
            A[i][j] = a;
        }
    }

    vi vote(M, 0);
    REP(i,N) {
        REP(j,A[i].size()){
            vote[A[i][j]]++;
        }
    }

    int ans = 0;
    REP(i,M) {
        if (vote[i]==N) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
s=[]
for i in range(N):
    s.append(input())
M=int(input())
t=[]
for i in range(M):
    t.append(input())
wordlist=list(set(s))+list(set(t))
wordcount=[]
for i in range(len(wordlist)):
    wordcount.append(s.count(wordlist[i])-t.count(wordlist[i]))
if max(wordcount)>=1:
    print(max(wordcount))
else:
    print(0)

Measured memory_bytes: 62732
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    scc_graph g(n);
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    auto ans = g.scc();
    cout << sz(ans) << endl;
    for (auto x : ans) {
        cout << sz(x) << " ";
        printv(x);
    }
}


Measured memory_bytes: 40108
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
string s1,s2;
int main() {
	cin>>s1>>s2;
	sort(s1.begin(),s1.end());
	sort(s2.begin(),s2.end());
	reverse(s2.begin(),s2.end());
	puts(s1<s2?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
/* ex3_2
    suuxxu */

#include <stdio.h>

int main(void){
    int n; // pencil's number
    
    // get inputs
    scanf("%d", &n);

    // output
    switch (n % 10){
    case 2: case 4: case 5: case 7: case 9:
        printf("hon\n");
        break;
    
    case 0: case 1: case 6: case 8:
        printf("pon\n");
        break;

    case 3:
        printf("bon\n");
        break;
    }
    return 0;
}



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

class Main
{
    public static void main(String args[]) throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        String s[]=bu.readLine().split(" ");
        long ans=0;
        int i,a[]=new int[n];
        for(i=0;i<n;i++)
        a[i]=Integer.parseInt(s[i]);
        Arrays.sort(a); int c=0;
        for(i=n-1;i>=0;i--)
        {
            if(i==n-1) {c++; ans+=a[i];}
            else
            {
                if(c+2<n) {c+=2; ans+=2*a[i];}
                else {c++; ans+=a[i];}
            }
            if(c==n-1) break;
        }
        System.out.print(ans);
    }
}

Measured memory_bytes: 62688
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 305;
const int P = 998244353;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN]; int n;
int dp[MAXN][MAXN][MAXN];
int vis[MAXN][MAXN][MAXN];
bool res[MAXN][MAXN][MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
bool check(int x, int y, int z) {
	return res[x][y][z];
}
int main() {
	scanf("%s", s + 1), n = strlen(s + 1), dp[n][0][0] = 1;
	for (int i = n; i >= 1; i--)
	for (int j = 0; j + (n - i) <= n - 1; j++)
	for (int k = 0; j + k + (n - i) <= n - 1; k++)
		if (s[i] == '0') {
			update(dp[i - 1][j][k], dp[i][j][k]);
			update(dp[i][j][k + 1], dp[i][j][k]);
		} else {
			update(dp[i - 1][j][k], dp[i][j][k]);
			update(dp[i][j + 1][k], dp[i][j][k]);
		}
	memset(vis, -1, sizeof(vis));
	vis[0][0][0] = 0;
	for (int i = 0; i <= n; i++)
	for (int j = 0; j <= i / 2; j++)
	for (int k = 0; j + k <= i / 2; k++) {
		if (vis[i][j][k] == -1) continue;
		int tmp = vis[i][j][k];
		if (i + 1 <= n && tmp != 0) {
			if (s[i + 1] == '0') chkmax(vis[i + 1][j + 1][k], tmp - 1);
			if (s[i + 1] == '1') chkmax(vis[i + 1][j][k + 1], tmp - 1);
		}
		if (i + 2 <= n) {
			if (s[i + 1] == '0' || s[i + 2] == '0') chkmax(vis[i + 2][j + 1][k], tmp);
			if (s[i + 1] == '1' || s[i + 2] == '1') chkmax(vis[i + 2][j][k + 1], tmp);
			chkmax(vis[i + 2][j][k], tmp + 1);
		}
	}
	for (int i = 0; i <= n; i++)
	for (int j = n; j >= 0; j--)
	for (int k = n; k >= 0; k--) {
		res[i][j][k] = vis[i][j][k] != -1;
		if (i != 0) res[i][j][k] |= res[i - 1][j][k];
		res[i][j][k] |= res[i][j + 1][k];
		res[i][j][k] |= res[i][j][k + 1];
	}
	int ans = 0;
	for (int i = 0; i <= n; i++)
	for (int j = 0; j + (n - i) <= n; j++)
	for (int k = 0; j + k + (n - i) <= n; k++)
		if (dp[i][j][k] && (n - i) + j + k != 0) {
			if (check(i, j, k)) {
				update(ans, dp[i][j][k]);
			}
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 196880
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

template<class T> set<T> divisor(T n) {
  set<T> res;
  for (T i = 1; i * i <= n; i++) if (n % i == 0) res.insert(i), res.insert(n / i);
  return res;
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  int res = 0;
  for (int i = 1; i <= n; i += 2) {
    res += divisor(i).size() == 8;
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
//ALLAH HU AKABR
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x,y;
   x=(a+d-1)/d;
   y=(c+b-1)/b;
   cout<<(x>=y?"Yes":"No")<<"\n";
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll gcd( ll m, ll n)
{
    ll l;
    // 引数に０がある場合は０を返す
    if ( ( 0 == m ) || ( 0 == n ) )
            return 0;
    
    // ユークリッドの方法
    while(1)
    {
        l = m % n;
        if(l==0) break;
        m = n;
        n = l;
    }
    return n;
}


void solve() {
    ll i,j,k,l,r; string s;
    bool exit = false;
    ll N,X;
    vector <ll> x;
    cin>>N>>X;
    FOR(i,N){
        ll input;//ok?
        cin>>input;
        if(input==X) continue;
        x.push_back(abs(input-X));
    }
    ll xSize = x.size();
    ll ret=x[0];
    FOR(i,xSize-1){
        ret = gcd(ret,x[i+1]);
    }
    cout<<ret<<endl;
    
    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}




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

using namespace std;

typedef long long ll;

#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = b - 1; i >= ll(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> num(N);
    REP(i, N)
    cin >> num[i];
    sort(ALL(num));
    vector<ll> pnum;
    vector<ll> nnum;
    REP(i, N)
    {
        if (num[i] < 0)
            nnum.push_back(num[i]);
        else
            pnum.push_back(num[i]);
    }
    vector<ll> mult;
    if (K == N)
    {
        mult = num;
    }
    else if (K % 2 == 1 && pnum.size() == 0)
    {
        for (int i = nnum.size() - 1; i >= nnum.size() - K; i--)
        {
            mult.push_back(nnum[i]);
        }
    }
    else
    {
        int pidx = pnum.size() - 1;
        int nidx = 0;
        int cnt = 0;
        while (cnt < K)
        {
            if (cnt == 0 && K % 2 == 1)
            {
                mult.push_back(pnum[pidx]);
                pidx--;
                cnt++;
                continue;
            }

            if (pidx < 0)
            {
                mult.push_back(nnum[nidx]);
                mult.push_back(nnum[nidx + 1]);
                nidx += 2;
                cnt += 2;
                continue;
            }

            if (nidx >= nnum.size())
            {
                mult.push_back(pnum[pidx]);
                mult.push_back(pnum[pidx - 1]);
                pidx -= 2;
                cnt += 2;
                continue;
            }

            if (nnum[nidx] * nnum[nidx + 1] > pnum[pidx] * pnum[pidx - 1])
            {
                mult.push_back(nnum[nidx]);
                mult.push_back(nnum[nidx + 1]);
                nidx += 2;
                cnt += 2;
            }
            else
            {
                mult.push_back(pnum[pidx]);
                mult.push_back(pnum[pidx - 1]);
                pidx -= 2;
                cnt += 2;
            }
        }
    }
    ll ans = 1;
    REP(i, mult.size())
    {
        ans = (ans * (mult[i] + 1000000007)) % 1000000007;
        //cout<<ans<<endl;
    }
    cout << ans << endl;
}

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

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

Measured memory_bytes: 3632
package main

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

type Float642DList [][]float64
type Float64List []float64

func lib_NewFloat642DList(length1, length2 int, initialValue float64) Float642DList {
	ret := make([][]float64, length1, length1)
	for i := 0; i < length1; i++ {
		ret[i] = lib_NewFloat64List(length2, initialValue)
	}
	return ret
}
func lib_NewFloat64List(length int, initialValue float64) Float64List {
	ret := make([]float64, length, length)
	for i := 0; i < length; i++ {
		ret[i] = initialValue
	}
	return ret
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	p := make([]float64, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		p[i], _ = strconv.ParseFloat(scanner.Text(), 64)
	}
	fmt.Println(solve(N, p))
}
func solve(N int, p []float64) float64 {
	dp := lib_NewFloat642DList(N+5, N+5, 0)
	dp[0][0] = 1
	for i := 0; i < N; i++ {
		for j := 0; j <= i; j++ {
			dp[i+1][j+1] += dp[i][j] * p[i]
			dp[i+1][j] += dp[i][j] * (1 - p[i])
		}
	}
	ret := 0.0
	for j := N; j > N/2; j-- {
		ret += dp[N][j]
	}
	return ret
}


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

int main(){
  string s; cin >> s;
  vector<string> x = {"maerd", "remaerd", "esare", "resare"};
  int i = s.size()-1;
  while(i >= 0){
    if(i-6 >= 0){
      string y = "";
      for(int j=0; j<7; ++j) y += s[i-j];
      if(y == x[1]){
        i -= 7;
        continue;
      }
    }
	if(i-5 >= 0){
      string y = "";
      for(int j=0; j<6; ++j) y += s[i-j];
      if(y == x[3]){
        i -= 6;
        continue;
      }
    }
    if(i-4 >= 0){
      string y = "";
      for(int j=0; j<5; ++j) y += s[i-j];
      if(y == x[0] || y == x[2]){
        i -= 5;
        continue;
      }
    }
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
 
ll n;
 
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    ll sum = 0;
    rep(i,n+1){
        if(i==0)continue;
        if(i%3==0)continue;
        if(i%5==0)continue;
        sum += i;
    }
    print(sum);
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
int a, b, c, d;
std::map<long long, long long> mem;
void cmin(long long &a, long long b) {
	if(b<a) a=b;
}
long long solve(long long n) {
	auto it=mem.find(n);
	if(it!=mem.end()) return it->second;
	long long ans=64ll*(a+d);
	if(n<=ans/d) ans=n*d;
	if(n%2==1) {
		if(n>1) cmin(ans, solve(n/2+1)+a+d);
		cmin(ans, solve(n/2)+a+d);
	} else
		cmin(ans, solve(n/2)+a);
	if(n%3<=1)
		cmin(ans, solve(n/3)+b+n%3*d);
	else
		cmin(ans, solve(n/3+1)+b+(3-n%3)*d);
	if(n%5<=2)
		cmin(ans, solve(n/5)+c+n%5*d);
	else
		cmin(ans, solve(n/5+1)+c+(5-n%5)*d);
	mem.emplace(n, ans);
	return ans;
}
int main() {
	int t;
	scanf("%d", &t);
	while(t--) {
		long long n;
		scanf("%lld%d%d%d%d", &n, &a, &b, &c, &d);
		mem.clear();
		mem.emplace(0, 0);
		printf("%lld\n", solve(n));
	}
	return 0;
}


Measured memory_bytes: 4124
n = int(input())

a = []
b = 0
for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        a.append("FizzBuzz")
    elif i % 3 == 0:
        a.append("Fizz")
    elif i % 5 == 0:
        a.append("Buzz")
    else:
        b += i
        
print(b)


Measured memory_bytes: 12572
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String,Integer> s = new HashMap<>();
		for(int i = 0; i < n; i++) {
			String key = sc.next();
			if(s.containsKey(key)) {
				s.put(key,s.get(key)+1);
			}
			else {
				s.put(key,1);
			}
		}
		int m = sc.nextInt();
		Map<String,Integer> t = new HashMap<>();
		for(int i = 0; i < m; i++) {
			String key = sc.next();
			if(t.containsKey(key)) {
				t.put(key,t.get(key)+1);
			}
			else {
				t.put(key,1);
			}
		}
		int max = 0;
		for(String key:s.keySet()) {
			int count = s.get(key);
			if(t.containsKey(key)) {
				count -= t.get(key);
			}
			max = Math.max(max, count);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 35792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> out(N, 0);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    B.at(i) = A.at(i);
  }
  sort(A.begin(), A.end());
  int max = A.at(N - 1);
    for(int i = 0; i < N; i++){
      out.at(i) = max;
    }
  if(A.at(N-2) != max){
    int submax = A.at(N-2);
    for(int i = 0; i < N; i++){
      if(B.at(i) == max){
        out.at(i) = submax;
      }
    }
    out.at(N - 1) == A.at(N - 1);
  }
  for(int j = 0; j < N; j++){
    cout << out.at(j) << endl;
  }
    return 0;
}

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

int main() {
  
  char a;
  cin >> a;
  
  if(a == 'A') cout << 'T' << endl;
  else if(a == 'T') cout << 'A' << endl;
  else if (a == 'C') cout << 'G' << endl;
  else cout << 'C' << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	Scanner sc = new Scanner(System.in);

	public void syori(){
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = a * 100 + b * 10 + c;

		switch(d){
		case 110:
			System.out.println("Open");
			break;
		case 1:
			System.out.println("Open");
			break;
		default:
			System.out.println("Close");

		}
	}

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Main m = new Main();

		m.syori();
	}

}

Measured memory_bytes: 17168
#include <iostream>
#include <cmath>

using namespace std;

long long getDigitSum(long long b, long long n)
{
    if(b > n)
    {
        return n;
    }

    return getDigitSum(b, (long long)(n / b)) + n % b;
}

int main()
{
    long long n, s;

    cin >> n >> s;

    long long rn = (long long)sqrt(n);

    if(s > n)
    {
        cout << "-1" << endl;
        return 0;
    }

    if(s == n)
    {
        cout << n + 1 << endl;
        return 0;
    }

    for (long long b = 2; b <= rn + 1;b++)
    {
        long long sum = getDigitSum(b, n);
        if(sum == s)
        {
            cout << b << endl;
            return 0;
        }
    }

    long long ans = -1;
    for (long long p = 1; p <= rn; p++)
    {
        long long b = (n - s) / p + 1;
        if(b <= 1)
        {
            continue;
        }
        long long sum = getDigitSum(b, n);
        if(sum == s)
        {
            ans = b;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A - Beginner
 * 高橋君はプログラミングコンテストサイト「ButCoder」の会員です。
 * ButCoder の会員には 2 つのレーティング 内部レーティング と 表示レーティング が割り当てられています。
 * 表示レーティングは、その会員のコンテスト参加回数が 10 以上のときは内部レーティングに等しく、
 * そうでないときは、会員のコンテスト参加回数を K として、内部レーティングから 100×(10−K) を引いたものになります。
 * 高橋君のコンテスト参加回数が N で表示レーティングが R であるとき、高橋君の内部レーティングを求めてください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 参加回数
        int n = sc.nextInt();
        // 表示レーティング
        int r = sc.nextInt();
        // 参加回数が10回以上の場合、表示レーティングと同一値
        if( n >= 10 ) {
            System.out.println( r );
        }
        else {
            System.out.println( r + ( 100 * ( 10 - n ) ) );
        }

        sc.close();
    }
}

Measured memory_bytes: 22996
H, N = map(int,input().split())
X = [list(map(int, input().split())) for i in range(N)]
X = sorted(X, key = lambda x:x[0])
DP = [float("inf")]*(H+X[-1][0]+X[-1][0])
DP[X[-1][0]-1] = 0
for i in range(X[-1][0], H+2*X[-1][0]):
    min = float("inf")
    for j in range(N):
        if min > DP[i-X[j][0]]+X[j][1]:
            min = DP[i-X[j][0]]+X[j][1]
        DP[i] = min

kouho = DP[H+X[-1][0]-1]
for i in range(X[-1][0]):
    if kouho > DP[H+X[-1][0]+i]:
        kouho = DP[H+X[-1][0]+i]
print(kouho)


Measured memory_bytes: 44252
#include <iostream>
#include <stack>

using namespace std;

int main (void) {
    stack<int> st;
    int n;
    while (1) {
        cin >> n;
        if (cin.eof()) break;
        if (n != 0) {
            st.push(n);
        } else {
            cout << st.top() << endl;
            st.pop();
        }
    }
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main() {
    ll h,w;cin>>h>>w;
    ll n;cin >>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    vector<vector<ll>>c(h,vector<ll>(w));
    ll now=0;
    ll x=-1,y=0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < a[i]; ++j) {
//            cout <<x<<endl;
                if (y % 2 == 0)x++;
                else x--;
//            cout <<x<<" "<<y<<endl;
            if(x>=w){
                y++;
                x--;
            }
            else if(x<0){
                y++;
                x++;
            }
//            cout <<x<<" "<<y<<endl;
            c[y][x]=i+1;
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << c[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 512
N, K = map(int,input().split())
A = list(map(int,input().split()))
li = {}
for i in A:
    c = li.setdefault(i,0)
    li[i] = c + 1
    # print(c)
w = len(li.keys()) - K
# print(w)
# print(len(li.keys()))
ans = sorted(li.values())
# print(ans)
if w > 0:
    print(sum(ans[:w]))
else:
    print(0)

Measured memory_bytes: 32184
H, W = map(int, input().split())
N = int(input())
A = [int(s) for s in input().split()]
c = [[0] * W for _ in range(H)]
for y in range(H):
    f = reversed if y & 1 else lambda x: x
    for x in f(range(W)):
        A[-1] -= 1
        c[y][x] = len(A)
        if A[-1] == 0:
            A.pop()
for ci in c:
    print(*ci)


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

int main() {
  int n,k,s=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    if(s*2>s+k) s+=k;
    else s*=2;
  }
  cout<<s<<endl;
}

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int a,b;
    cin>>a>>b;
    int diff = b-a;
    int ah=0;
    for(int i =1;i<diff;i++){
        ah += i;
    }    
    cout<<ah-a<<endl;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+3;
const int MOD = 1e9+7;
vector<vector<int> > g;
long long n;
long long dp[N][2];

void dfs(int u,int p){
	dp[u][0]=1;
	dp[u][1]=1;
	for(int i=0;i<g[u].size();i++){
		if(g[u][i]==p)
			continue;
		dfs(g[u][i],u);

		dp[u][0] *= (dp[g[u][i]][0]+dp[g[u][i]][1]);
		dp[u][0] %= MOD;

		dp[u][1] *= dp[g[u][i]][0];
		dp[u][1] %= MOD;
	}

}

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

    cin>>n;
    int a,b;
    g.clear();
    g.resize(n+1);
    for(int i=0;i<n-1;i++){
    	cin>>a>>b; 
    	a--;b--;
    	g[a].push_back(b);
    	g[b].push_back(a);
    }

    dfs(0,-1);
    
    cout<<(dp[0][0] + dp[0][1])%MOD;


	return 0;
    }

Measured memory_bytes: 12800
n = int(input())
edge = []
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(i + 1, n):
        if a[j] != -1:
            edge.append((a[j], i, j))
edge.sort()
ans = 0

tree = [i for i in range(n)]
def root(x):
    pre = []
    while x != tree[x]:
        pre.append(x)
        x = tree[x]
    for node in pre:
        tree[node] = x
    return x
def unite(x, y):
    X, Y = root(x), root(y)
    if X != Y:
        tree[X] = Y

for cost, x, y in edge:
    X, Y = root(x), root(y)
    if X != Y:
        ans += cost
        tree[X] = Y
print(ans)



Measured memory_bytes: 5908
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void debug() { std::cerr << '\n'; }
template <class H, class... T> void debug(H &&head, T &&... args) {
    std::cerr << head;
    sizeof...(args) == 0 ? std::cerr << "" : std::cerr << ' ';
    debug(std::forward<T>(args)...);
}
template <class T> void debug(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cerr << v[i];
        i == v.size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
    }
}
template <class T> void debug(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cerr << v[i][j];
            j == v[i].size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
        }
    }
}

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

    int N, T;
    cin >> N >> T;
    vector<int> v(N);
    for (auto &&i : v) {
        cin >> i;
    }

    int mn = v[0];
    vector<int> diff(N);
    FOR(i, 1, N) {
        chmin(mn, v[i]);
        diff[i] = v[i] - mn;
    }
    SORT(diff);
    int ans = upper_bound(ALL(diff), diff[diff.size() - 1]) -
              lower_bound(ALL(diff), diff[diff.size() - 1]);
    print(ans);

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, m;
const int MAX = 10001000;

int main() {
    while(1) {
        cin >> m >> n;
        if(n == 0 && m == 0) break;
        vector<bool> primeno(MAX, true);
        primeno.at(0) = primeno.at(1) = false;
        int cnt = 0;
        int check = m;
        while(1) {
            if(cnt == n && primeno.at(check)) {
                cout << check << endl;
                break;
            }
            if(primeno.at(check)) {
                for(int j = 0; check*(j+2) < MAX; ++j) {
                    primeno.at(check*(j+2)) = false;
                }
                cnt++;
            }
            check++;
        }
    }
}


Measured memory_bytes: 4292
# -*- coding: utf-8 -*-
n=int(input())
ans=[0 for i in range(10500)]
for i in range(1,105):
  for j in range(1,i+1):
    for k in range(1,j+1):
      sumg=(i+j)**2+(j+k)**2+(k+i)**2
      if sumg<21000:
        if i==j and j==k:
          ans[int(sumg/2)]+=1
        elif i!=j and j!=k and k!=i:
          ans[int(sumg/2)]+=6
        else:
          ans[int(sumg/2)]+=3
for i in range(n):
  print(ans[i+1])

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

bool issame(int n){

	string s=to_string(n) ;
 	char temp=s[0] ;

 	rep(i,(int)s.length()){
 		if(s[i]!=temp)
 			return false ;
 	}

 	return true ;
}

void solve(){

	int n ;
	cin>>n ;

	while(n<=1111){

		bool answer=issame(n) ;
	
		if(answer==true){
			break ;
		}
	
		n++ ;
		
		//cout<<n<<"\n" ;

	}

	cout<<n ;
	
}


int main(){

		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

Measured memory_bytes: 3660
while True:
  a,b,c = input().split()
  if b == "?":
    break
  else:
    if b == "+":
      print(int(a) + int(c))
    elif b == "-":
      print(int(a) - int(c))
    elif b == "*":
      print(int(a) * int(c))
    else:
      print(int(a) // int(c))


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll n,k,i,j;
    cin>>n>>k;
    vector<ll> a(n+1);
    for(i=1;i<=n;i++) cin>>a[i];
    vector<ll> v,ans;
    v.pb(1);
    ll prev = 1;
    map<ll,ll> mp;
    mp[1]++;
    ll rep;
    while(1)
    {
        if(mp[a[prev]]) {rep = a[prev];break;}
        v.pb(a[prev]);
        mp[a[prev]]++;
        prev = a[prev];
    }
    for(i=0;i<sz(v);i++)
    {
        if(k==0) {cout<<v[i];return 0;}
        if(v[i]==rep) break;
        k--;
    }
    // cout<<k<<" "<<i<<"\n";
    // for(auto h : v) cout<<h<<" ";
    // cout<<"\n";
    ll len = sz(v)-i;
    ll q = k/len;
    ll r = k%len;
    // cout<<r<<"\n";
    
    cout<<v[i+r];
}


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

using namespace std;

int main() {
    int n, smallest = INT_MAX, x;
    scanf("%d", &n);
    vector < int > vec;
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        vec.push_back(x);
    }
    for(int i = 0; i < 100; ++i) {
        int aux = 0;
        for(int j = 0; j < n; ++j) {
            aux += (vec[j] - i) * (vec[j] - i);
        }
        smallest = min(smallest, aux);
    }
    printf("%d\n", smallest);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


void err(){
  std::cout << "No" << '\n';
  exit(0);
}

ll a, b, c;
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n >> a >> b >> c;
  vector<string> v(n);
  re(i, n) std::cin >> v[i];
  vll num{a, b, c};
  vvl dat = VV(n, 3, 0, ll);

  for(int i=0;i<n;i++){
    if(v[i]=="AB") dat[i][0]++, dat[i][1]++;
    if(v[i]=="AC") dat[i][0]++, dat[i][2]++;
    if(v[i]=="BC") dat[i][2]++, dat[i][1]++;
  }

  vll ans(n);
  for(int i=0;i<n-1;i++){
    int m = -1, to;
    vll candi;
    for(int j=0;j<3;j++) if(dat[i][j]) candi.push_back(j);
    ll x = candi[0], y = candi[1];

    if(num[x]!=0){
      if((dat[i+1][x]&&m==-1)||dat[i+1][x]==0) m = x, to = y;
    }
    if(num[y]!=0){
      if((dat[i+1][y]&&m==-1)||dat[i+1][y]==0) m = y, to = x;
    }
    if(m==-1) err();
    ans[i] = to, num[m]--, num[to]++;
  }

  for(int i=0;i<3;i++){
    if(dat[n-1][i]&&num[i]){
      int to;
      for(int j=0;j<3;j++) if(dat[n-1][j]&&i!=j) to = j;
      ans[n-1] = to;
      break;
    }
    if(i==2) err();
  }

  std::cout << "Yes" << '\n';
  re(i, n) {
    char t = ans[i] + 'A';
    std::cout << t << '\n';
  }
  return 0;
}


Measured memory_bytes: 11692
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
	    String line;
	    StringBuilder sb = new StringBuilder();
	    line = br.readLine();
	    String[] strs = line.split(" ");
	    int a = Integer.parseInt(strs[0]);
	    int b = Integer.parseInt(strs[1]);
	    if (((a % 2) * (b % 2))%2 == 0)
	    	System.out.println("Even");
	    else
	    	System.out.println("Odd");
	    
	}
}


Measured memory_bytes: 23248
n = int(input())
c,s,f = [],[],[]
for _ in range(n-1):
    x,y,z = map(int,input().split())
    c.append(x)
    s.append(y)
    f.append(z)
    
ans = []
for i in range(n-1): #出発地点
    time = 0
    for j in range(i,n-1): #現在地
        if time <= s[j]:
            time = s[j]+c[j]
        else:
            time += c[j] + f[j]*(0!=time%f[j]) - time%f[j]
    ans.append(time)
        
print('\n'.join(map(str,ans)),'\n0')

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

int main() {

	char s1, s2, s3;

	cin >> s1 >> s2 >> s3;

	int count=0;

	if (s1 == '1') count++; 
	if (s2 == '1') count++;
	if (s3 == '1') count++;

	cout << count;

	return 0;

}

Measured memory_bytes: 256
N = int(input())
arr = [ list(map(int, input().split())) for i in range(N)]
arr.insert(0, [0, 0, 0])
res = 'Yes'

for i in range(N):
    x = arr[i+1][1] - arr[i][1]
    y = arr[i+1][2] - arr[i][2]
    t = arr[i+1][0] - arr[i][0]
    
    if x+y <= t:
        if (x+y-t)%2 == 0:
            pass
        else:
            res = 'No'
            break
    else:
        res = 'No'
        break
        
print(res)
        

Measured memory_bytes: 27300
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class DIJ{
	public:
	struct edge{
		int to,cost;
	};
	vector<vector<edge> >G;
	int n;
	vi d;//distance
	DIJ(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(int s){
		d=vi(n,inf);
		d[s]=0;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			int pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					q.push(pii(-d[to],to));
				}
			}
		}
	}
};
int main(){
	int n;
	cin>>n;
	DIJ dij(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		dij.add_edge(a,b,1);
		dij.add_edge(b,a,1);
	}
	dij.dij(0);
	vi d1=dij.d;
	dij.dij(n-1);
	vi d2=dij.d;
	int co=0;
	rep(i,n)if(d1[i]<=d2[i])co++;
	if(co>n/2)cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
}











Measured memory_bytes: 8688
import sys
readline = sys.stdin.readline
writelines = sys.stdout.writelines
N = int(input())
A = []
D = {}
for i in range(N):
    v, d = readline().split()
    A.append((v, int(d)))
    D.setdefault(int(d), []).append(v)

def partition(A, p, r):
    x = A[r]
    i = p
    for j in range(p, r):
        if A[j][1] <= x[1]:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[i], A[r] = A[r], A[i]
    return i

def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q-1)
        quicksort(A, q+1, r)

D = {k: iter(v).__next__ for k, v in D.items()}

quicksort(A, 0, N-1)
ok = 1
for v, d in A:
    if D[d]() != v:
        ok = 0
ans = ['Stable\n' if ok else 'Not stable\n']
for v, d in A:
    ans.append("%s %d\n" % (v, d))
writelines(ans)



Measured memory_bytes: 30108
h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
ans = 0

for i in range(2 ** h): # 行の塗り方パターン
   for j in range(2 ** w): # 列の塗り方のパターン

      d = [c[x][:] for x in range(h)]

      for p in range(h):
         bit = (1 << p)
         if i & bit > 0: 
            for x in range(w): d[p][x] = '*'

      for q in range(w):
         bit = (1 << q)
         if j & bit > 0: 
            for x in range(h): d[x][q] = '*'

      s = 0
      for p in range(h):
         for q in range(w): 
            if d[p][q] == '#': s += 1

      if s == k: ans += 1

print(ans)

Measured memory_bytes: 9152
import string

def main():
  N = int(input())
  az = string.ascii_lowercase
  d = 26
  ans = ""

  while(N > 0):
    m = (N-1) % d
    ans = az[m] + ans
    N = (N-1) // d
    
  print(ans)


if __name__ == "__main__":
  main()

Measured memory_bytes: 9980
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

INF = 10**12

# 各valueの値に対する最小のweightを記録する
dp = [[INF] * (10**6) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    w, v = wv[i]
    for j in range(10**6):
        if j < v:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j], dp[i][j-v]+w)
for i in range(10**6-1, 0, -1):
    if dp[N][i] <= W:
        print(i)
        break

Measured memory_bytes: 854632
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    if (Math.abs(a - c) <= d || Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#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()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> c(M+1);
    REP(i, M) cin >> c[i+1];

    vector<vector<int>> dp(M+1, vector<int>(N+1, 50000)); // dp[m][n]: m種類まで使ってnを作るときの最小値
    dp[0][0] = 0;
    FOR(i, 1, M) {
        dp[i][c[i]] = 1;
        dp[i][0] = 0;
    }
    FOR(i, 1, M) {
        FOR(j, 1, N) {
            if(j - c[i] >= 0)
                dp[i][j] = min(dp[i][j-c[i]] + 1, dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[M][N] << endl;
    return 0;
}


Measured memory_bytes: 7044
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=1e6+5;

int a[maxn];
int main()
{
    int n,m,sum=0,num=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]*4*m>=sum)num++;
    }
    if(num>=m)puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256