akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  
  int K, X;
  cin >> K >> X;
  
  vector<int> ans;
  if(K == 1) {
    ans.push_back(X);
  } else {
    for(int i = (X-K)+1; i < K+X; ++i) {
      ans.push_back(i);
    }
  }
  
  for(auto a : ans) cout << a << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	long long n,a,b;
	cin >> n >> a >> b;
//	cout << (abs(a-b)%2==0 ? abs(a-b)/2:min(max(a-1,b-1),max(n-a,n-b))) << endl;
	cout << (abs(a-b)%2==0 ? abs(a-b)/2:min((a+b-1)/2,(n-a+n-b+1)/2)) << endl;
	//cout << ((b-a)%2==0 ? (b-a)/2:
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n,l,r;
  scanf("%d%d%d",&n,&l,&r);
  if (r < l) dame;
  if (n == 1 && l != r) dame;
  ll s = (ll)l*n+(r-l);
  ll t = (ll)r*n-(r-l);
  cout<<(t-s+1)<<endl;
  return 0;
}






















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 IOException {
        BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
        String[] s = bufferedReader.readLine().split(" ");
        long n = Long.parseLong(s[0]),k=Long.parseLong(s[1]);
        long ans = (long) Math.ceil((double)n/2);
        if(ans>=k)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807-1;
const int inf = 2147483647-1;
ll minl(ll a[],int n){
    ll rtn = a[0];
    REP(i,n){
        if(rtn>a[i])rtn=a[i];
    }
    return rtn;
}
ll maxl(ll a[],int n){
    ll rtn = a[0];
    REP(i,n){
        if(rtn<a[i])rtn=a[i];
    }
    return rtn;
}

int main() {
    double n,m,d;
    cin >> n >> m >> d;
    double res = (n-d)*2*(m-1)/(n*n);
    if(d==0)res/=2;
    printf("%.10lf\n",res);
    //put(res);
    return 0;
}


Measured memory_bytes: 256
#coding:utf-8
#1_3_B
from collections import deque

n, quantum = map(int, input().split())
q = deque()
total_time = 0
for i in range(n):
    name, time = input().split()
    q.append([name, int(time)])

while q:
    ps_name, ps_time = q.popleft()
    if ps_time <= quantum:
        total_time += ps_time
        print(ps_name, total_time)
    else:
        total_time += quantum
        ps_time -= quantum
        q.append([ps_name, ps_time])

Measured memory_bytes: 16064
package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	a := readInt64Slice()
	s := readString()
	if a[0] >= 3200 {
		fmt.Println(s)
	}else{
		fmt.Println("red")
	}
}

func readInt64Slice() []int64 {
	line := readStringSlice()
	slice := make([]int64, 0, len(line))
	for _, tmp := range line {
		val, err := strconv.ParseInt(tmp, 10, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		slice = append(slice, val)
	}
	return slice
}
func readFloat64Slice() []float64 {
	line := readStringSlice()
	slice := make([]float64, 0, len(line))
	for _, tmp := range line {
		val, err := strconv.ParseFloat(tmp, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		slice = append(slice, val)

	}
	return slice
}
func readString() string {
	s, _, _ := in.ReadLine()
	return string(s)
}
func readStringSlice() []string {
	line := readString()
	s := strings.Split(line, " ")
	return s
}
func dump(value ...interface{}) {
	for _, v := range value {
		fmt.Printf("%#v\n", v)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define N 2000050
 
#define x first
#define y second
 
using namespace std;
typedef long long LL;
typedef pair<LL,LL> pii;
pii f[N],tmp1[N],tmp2[N];
int ch[N][2],fa[N],v[N],tp[N],vis[N],le[N],ri[N],mid[N],n,m;
LL lim;
bool flag;
 
void link(int a,int b) {ch[a][0] ? ch[a][1] = b : ch[a][0] = b;}
inline int rd() {int r;scanf("%d",&r);return r;}
 
void solve(int u,int l,int r) {
	if (!flag) return ;
	if (!ch[u][0] && !ch[u][1]) {
		f[l] = pii(v[u], v[u]);
		tp[u] = l;
		return ;
	}
	int L = ch[u][0], R = ch[u][1];
	solve(L, l, mid[u]);
	solve(R, mid[u]+1, r);
 
	int T = tp[R], q1 = 0, q2 = 0;
	for (int i=tp[L];i>=l;i--) {
		while (T>=mid[u]+1 && f[i].y+f[T].x > lim) T--;
		if (T>=mid[u]+1 && f[i].y + f[T].x <= lim)
			tmp1[++q1] = pii(f[i].x, f[T].y);
	}
 
	T = tp[L];
	for (int i=tp[R];i>=mid[u]+1;i--) {
		while (T>=l && f[i].y+f[T].x > lim) T--;
		if (T>=l && f[i].y+f[T].x <= lim)
			tmp2[++q2] = pii(f[i].x, f[T].y);
	}
 
	if (!q1 && !q2) {flag = 0; return ;}
	tp[u] = l-1;
	while (q1 || q2) {
		pii cur;
		if (q1 && q2)
			cur = tmp1[q1].x < tmp2[q2].x ? tmp1[q1--] : tmp2[q2--];
		else
			cur = !q1 ? tmp2[q2--] : tmp1[q1--];
		if (tp[u] >= l && cur.y >= f[ tp[u] ].y) continue;
		f[ ++tp[u] ] = cur;
	}
	for (int _=l;_<=tp[u];_++) f[_].x += v[u], f[_].y += v[u];
 
}
 
void dfs(int u) {
	if (!ch[u][0] && !ch[u][1]) {
		le[u] = ri[u] = ++m;
		return ;
	}
	dfs(ch[u][0]); dfs(ch[u][1]);
	le[u] = le[ ch[u][0] ];
	ri[u] = ri[ ch[u][1] ];
	mid[u] = ri[ ch[u][0] ];
}
 
bool go(LL x) {
	lim = x, flag = 1;
	solve(1,1,m);
	return flag;
}
 
int main() {
	n = rd();
	for (int _=2;_<=n;_++) {
		fa[_] = rd(), v[_] = rd();
		link(fa[_], _);
		if (!vis[ fa[_] ]) vis[ fa[_] ] = 1;
	}
 
	dfs(1);
	LL l = 0, r = 100000000LL;
	while (l < r) {
		LL mi = (l + r) >> 1;
		if (go(mi)) r = mi; else l = mi + 1;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 33536
log = console.log;
var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin
  .split(" ")
  .filter(v => v !== "")
  .map(Number);

var W = lines[0];
var H = lines[1];
var x = lines[2];
var y = lines[3];

var isCenter;
if(x === W/2 && y === H/2){
  isCenter = 1
} else {
  isCenter = 0
}
log(W * H /2,isCenter)

Measured memory_bytes: 7628
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
const int MAX = 100001;
 
int main(){
    int N;
    int A[MAX];
    int B[MAX];
    long long ans = 0;
 
    cin >> N;
    for(int i = 0;i < N + 1;i++){
        cin >> A[i];
    }
    for(int i = 0;i < N;i++){
        cin >> B[i];
    }
 
    for(int i = N - 1;i >= 0;i--){
        ans += min(A[i] + A[i + 1],B[i]);
        A[i] = max(0,A[i] - max(0,B[i] - A[i + 1]));
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> vs;
    for(int i = 0; i < h; ++i){
        string s;
        cin >> s;
        vs.push_back(s);
    }
    for(int i = 0; i < h; ++i){
        cout << vs[i] << endl << vs[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
struct edge{ ll to, cost; };
const ll INF = 1001001001001001;
const int MAX_V = 200005;
int V,E;
vector<edge> G[MAX_V];
vector<edge> G2[MAX_V];
ll d[MAX_V];
ll d2[MAX_V];

void dijkstra(int s){
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        for(int i=0; i<G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
void dijkstra2(int s){
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d2, d2+V, INF);
    d2[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        for(int i=0; i<G2[v].size(); i++){
            edge e = G2[v][i];
            if(d2[e.to] > d2[v] + e.cost){
                d2[e.to] = d2[v] + e.cost;
                que.push(P(d2[e.to], e.to));
            }
        }
    }
}

int main() {
    cin >> V >> E;
    int s,t;
    cin >> s >> t;
    s--; t--;
    rep(i,E){
        ll from,to,cost,cost2;
        cin >> from >> to >> cost >> cost2;
        from--;to--;
        edge e1, e2, e3, e4;
        e1.to = to; e1.cost = cost;
        e2.to = from; e2.cost = cost;
        e3.to = to; e3.cost = cost2;
        e4.to = from; e4.cost = cost2;
        G[from].push_back(e1);
        G[to].push_back(e2);
        G2[from].push_back(e3);
        G2[to].push_back(e4);
    }

    dijkstra(s);
    dijkstra2(t);

    ll sum[V];
    rep(i,V){
        sum[i] = d[i] + d2[i];
    }

    drep(i,V-1){
        sum[i] = min(sum[i],sum[i+1]);
    }

    rep(i,V){
        ll ans = 1000000000000000 - sum[i];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 24976
h,w = map(int ,input().split())
n = int(input())
a = list(map(int,input().split()))

ans = []
tmp = []
count = 0
for i in range(n):
    num = i+1
    itr = 0
    while itr < a[i]:
        tmp.append(num)
        if len(tmp) == w:
            count += 1
            if count %2 != 0:
                tmp.reverse()
            ans.append(tmp)
            tmp=[]
            
        itr+=1
for i in ans:
    for j in range(len(i)):
        print(i[j],end=" ")
    print()





Measured memory_bytes: 3828
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;
 
bool cards[1000000]; 
 
int main(){
    int n,k;
    while(~scanf("%d %d",&n,&k)){
        if(n==0 && k==0) break;
         
        memset(cards,0,sizeof(cards));
 
        bool hasWhite = false;
        for(int i=0;i<k;i++){
            int num;
            scanf("%d",&num);
            cards[num] = true;
            if(num == 0) hasWhite = true;
        }
 
        if(hasWhite){
            int suc = 0;
            for(int i=1;i<=n;i++){
                int tmp = 0;
                bool mistake = false;
                for(int j=i;j<=n;j++){
                    if(cards[j]){
                        tmp++;
                        suc = max(tmp,suc);
                    }
                    else{
                        if(!mistake){
                            mistake = true;
                            tmp++;
                            suc = max(tmp,suc);
                            continue;
                        }
                        break;
                    }
                }
            }
 
            printf("%d\n",suc);
        }
        else{
            int suc = 0;
            for(int i=1;i<=n;i++){
                int tmp = 0;
                for(int j=i;j<=n;j++){
                    if(cards[j]){
                        tmp++;
                        suc = max(tmp,suc);
                    }
                    else{
                        i=++j;
                        break;
                    }
                }
            }
 
            printf("%d\n",suc);
        }
    }
}

Measured memory_bytes: 2172
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;

vector<P> g[maxn];
bool vis[maxn];
int f[maxn];

bool dfs(int u,int d) {
    if(vis[u]) return f[u] == d;
    f[u] = d;
    vis[u] = 1;
    for(auto v:g[u]) {
        if(!dfs(v.fi,d + v.se)) return false;
    }
    return true;
}

int main() {
#ifdef CX_TEST
    freopen("E:\\program--GG\\test_in.txt", "r", stdin);
#endif
    int n, m, i, j, u, v, w;
    scanf("%d%d", &n, &m);
    for(i = 0; i < m; i++) {
        scanf("%d%d%d", &u, &v, &w);
        g[u].push_back(P(v, w));
        g[v].push_back(P(u, -w));
    }
    for(i = 1; i <= n; i++) {
        if(!vis[i] && !dfs(i, 0)) return puts("No"),0;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      int N;
      cin >> N;
      string S;
      cin >> S;
      for (int i = 0; i < S.size(); i++)
      {
        if (S[i]+N <='Z')
        {
          printf("%c",S[i]+N );
        }
        else
        {
          printf("%c",S[i] + N-26 );
        }
        
      }

     }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 2e5 + 100;

int n, k, c;
char s[N];
pair <int, int> pref[N], suf[N];

int main() {
	scanf ("%d%d%d", &n, &k, &c);
	scanf ("%s", s + 1);
	int cnt = 0;
	int last = -1e9;
	pref[0].se = last;
	rep(i, 1, n) {
		if (i - last > c && s[i] == 'o') {
			cnt++;
			last = i;
		}
		pref[i] = {cnt, last};
	}
	cnt = 0;
	last = 1e9;
	suf[n + 1].se = last;
	per(i, 1, n) {
		if (last - i > c && s[i] == 'o') {
			cnt++;
			last = i;
		}
		suf[i] = {cnt, last};
	}
	rep(i, 1, n) {
		if (s[i] == 'x') continue;
		int sum = pref[i - 1].fi + suf[i + 1].fi;
		if (sum < k) printf ("%d\n", i);
		if (sum == k && suf[i + 1].se - pref[i - 1].se <= c) printf ("%d\n", i);
	}
	
	
    return 0;
}


Measured memory_bytes: 4864
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;}
int64_t lcm(int64_t a, int64_t b) {return a/gcd(a,b)*b;}
int64_t extgcd(int64_t a, int64_t b, int64_t &x, int64_t &y) { // ax+by=gcd(a, b)の解を与える
    int64_t d = a;
    if(b) {
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> t(n), a(n);
    rep(I, n) {
        cin >> t[I] >> a[I];
    }

    ll g = t[0], b = a[0];
    rep(i, n-1) {
        if(g < t[i+1] and b < a[i+1]) {
            g = t[i+1];
            b = a[i+1];
        } else {
            ll gg = (g+t[i+1]-1)/t[i+1], bb = (b+a[i+1]-1)/a[i+1];
            gg = max(gg, bb);
            g = t[i+1]*gg;
            b = a[i+1]*gg;
        }
    }

    cout << g+b << endl;
}

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

int main() {

  int K;
  cin >> K;

  string S;
  cin >> S;

  if (K < S.size()) {
    cout << S.substr(0,K)  << "..." << endl;
  } else{
    cout << S << endl;
  }  

  return 0;

}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    int t = 1;
    while(t--){
        char c;
        cin >> c;
        if(c > 'Z'){
            cout << "a" << endl;
        }
        else{
            cout << "A" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3644
#!/usr/bin/env python3
from collections import deque
from bisect import bisect_left

def main():
    N, *A = map(int, open(0))
    # 方針: 色ごとに最大値をリストで保持する
    # 新しく色を追加しないといけない時は持っている全ての数字より小さい時->先頭追加なのでdequeがいい
    # dequeをbisectで二分探索できるんだ...
    q = deque([])
    for i in range(N):
        d = bisect_left(q,A[i])
        if d == 0:
            q.appendleft(A[i])
        else:
            q[d-1] = A[i]
    print(len(q))

if __name__ == "__main__":
    main()

Measured memory_bytes: 13832
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
a.append(0)
cnt = 0
for i in range(n+1):
  cnt += abs(a[i]-a[i+1])
for i in range(1,n+1):
  ans = cnt
  if a[i-1] <= a[i] <= a[i+1]:
    print(ans)
  elif a[i+1] <= a[i] <= a[i-1]:
    print(ans)
  else:
    if a[i] >= 0:
      ans -=2*min(abs(a[i]-a[i-1]),abs(a[i]-a[i+1]))
      print(ans)
    else:
      ans -=2*min(abs(a[i]-a[i-1]),abs(a[i]-a[i+1]))
      print(ans)

Measured memory_bytes: 14048
#include "bits/stdc++.h"
using namespace std;

int main() {
	static long long N, A[100000], B[100000], Minus = 0, Now = 0;
	vector<long long> Plus;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N; i++) {
		long long C = A[i] - B[i];
		if (C < 0) Minus -= C;
		else Plus.push_back(C);
	}
	if (Minus == 0) {
		cout << 0;
		return 0;
	}
	sort(Plus.begin(), Plus.end(), greater<long long>());
	while (Minus > 0 && Now < Plus.size()) {
		Minus -= Plus[Now];
		Now++;
	}
	if (Now == Plus.size() && Minus > 0) {
		cout << -1;
		return 0;
	}
	cout << N - Plus.size() + Now;
}

Measured memory_bytes: 2936
using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] count = new int[2];
            for (int i = 0; ; i++)
            {
                var n = Console.ReadLine().Split(' ');
                count[0] = int.Parse(n[0]);
                count[1] = int.Parse(n[1]);
                if (count[0] == 0 && count[1] == 0) { break; }
                if (count[0] < count[1])
                {
                    Console.WriteLine($"{count[0]} {count[1]}");
                }
                else
                {
                    Console.WriteLine($"{count[1]} {count[0]}");
                }
            }
            Console.ReadKey();
        }
    }
}



Measured memory_bytes: 18000
#include<stdio.h>

int main(){
  int tate,yoko;
  while(1){
    scanf("%d %d",&tate,&yoko);
    if(tate == 0&&yoko == 0){
      break;
    }else{
      for(int i = 1;i <= tate;i++){
        for(int k = 1;k <= yoko;k++){
          if(i % 2 == 1){
            if(k % 2 == 1)printf("#");
            else printf(".");
          }else{
            if(k % 2 == 1)printf(".");
            else printf("#");
          }
        }
        printf("\n");
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1740
import java.util.Scanner;

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

		// 入力値の取得
		int H = sc.nextInt();
		int A = sc.nextInt();

		// 攻撃回数
		int count = 0;

		// 結果の出力
		while (H > 0) {
			count++;
			H -= A;
		}
		System.out.println(count);

		sc.close();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int a=0;
    char c;
    rep(i,3) cin>>c,a+=c-'0';
    cout<<a<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<mod>;
mint dp[105][100005];

int main(){
	ll n,k; cin >> n >> k;
	vl a(n);
	rep(i,n) cin >> a[i];
	rep(j,k+1) dp[0][j] = 1;
	rep(i,n){
		rep(j,k+1){
			dp[i+1][j] = dp[i][j];
			if(j-a[i]-1>=0) dp[i+1][j] -= dp[i][j-a[i]-1];
		}
		rep(j,k) dp[i+1][j+1] += dp[i+1][j];
	}
	mint ans = dp[n][k] - dp[n][k-1];
	cout << ans.value() << endl;
}

Measured memory_bytes: 80128
//include
//------------------------------------------
#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 <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 123456789;

struct Edge{
  int to, cost;
  Edge(int t, int c): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
};
typedef vector< vector<Edge> > Graph;

VI prv(101);
void Dijkstra(const Graph& edges, vector<int>& d, int s){
  const int V = edges.size();
  priority_queue<PII, vector<PII>, greater<PII> > pq;
  fill(d.begin(), d.end(), INF);
  d[s] = 0;
  pq.push(MP(0,s));

  while(!pq.empty()){
	PII pii = pq.top(); pq.pop();
	int v = pii.second;
	if(d[v] < pii.first) continue;
	for(auto& e:edges[v]){
	  if(d[e.to] > d[v] + e.cost){
		prv[e.to] = v;
		d[e.to] = d[v] + e.cost;
		pq.push(MP(d[e.to], e.to));
	  }
	}
  }
}


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

  int N, M, S, G1, G2;
  while(cin>>N>>M>>S>>G1>>G2, N){
	int cost[101][101];
	fill((int*)cost, (int*)cost+101*101, INF);
	REP(i,M){
	  int a, b, t; cin >> a >> b >> t;
	  cost[a][b] = t;
	}
	REP(i,N+1)
	  cost[i][i] = 0;

	REP(k,N+1) REP(i,N+1) REP(j,N+1){
	  cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
	}

	int ans = INF;
	REP(i,N+1){
	  ans = min(ans, cost[S][i] + cost[i][G1] + cost[i][G2]);
	}
	cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ll a,b,c;
  cin>>a>>b>>c;
  map<ll,ll> m;
  m[a]++;m[b]++;m[c]++;
  if(m[5]==2 && m[7]==1)
    cout<<"YES";
  else cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t N,K;
int64_t dp[55][55][6000];
int main(){
  cin>>N>>K;
  dp[0][1][0]=1;
  for(int i=1;i<=N;i++)
    for(int j=1;j<=i+1;j++){
    for(int k=0;k<=2*i*i;k++){
      dp[i][j][k]=dp[i-1][j][k];
    if(0<=j-2 && 0<=k-2*i)
      dp[i][j][k]=(dp[i][j][k]+dp[i-1][j-2][k-2*i]*(i-j+2)*(i-j+2))%mod;
      if(0<=j-1 && 0<=k-i)
        dp[i][j][k]=(dp[i][j][k]+dp[i-1][j-1][k-i]*(1+2*(i-j+1)))%mod;
    }
     }if(K%2==1)
      cout<<0<<endl;
  else
    cout<<dp[N][N+1][(K+N*(N+1))/2]<<endl;
  return 0;
}

Measured memory_bytes: 35008
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  string SS = "";
  REP(i, N){
    SS += S[N-1-i];
  }
  while(!SS.empty()){
    if(SS.substr(0, 5) == "maerd"){
      SS.erase(0, 5);
    }else if(SS.substr(0, 7) == "remaerd"){
      SS.erase(0, 7);
    }else if(SS.substr(0, 5) == "esare"){
      SS.erase(0, 5);
    }else if(SS.substr(0, 6) == "resare"){
      SS.erase(0, 6);
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include<cstring>
#include <cstdio>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int n,m,q;
int st,en;
vector<int> G[100000];
int color[100000];
int cnt=0;
void dfs(int st,int cnt)
{
    color[st]=cnt;
    for(int i=0;i<G[st].size();i++)
    {
        if(color[G[st][i]]==-1)
        {
            dfs(G[st][i],cnt);
        }
    }
}
void makeColor()
{
    for(int i=0;i<n;i++)
    {
        if(color[i]==-1)
        {
            dfs(i,++cnt);
        }
    }
}
int main(){
    memset(color,-1,sizeof(color));
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    makeColor();
    cin>>q;
    
    for(int i=0;i<q;i++)
    {
        cin>>st>>en;
        if(color[st]==color[en])
            cout<<"yes"<<endl;
        else
            cout<<"no"<<endl;
    }
   return 0;
}



Measured memory_bytes: 12068
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] m=new int[3];
		for(int i=0;i<n;i++){m[a[i]-1]++;}
		double[,,] dp=new double[n+2,n+2,n+2];
		for(int i=0;i<=m[2];i++){
			for(int j=0;j<=m[2]+m[1];j++){
				if(i+j>n){continue;}
				for(int k=0;k<=n;k++){
					if(i+j+k>n||i+j+k==0){continue;}
					dp[k,j,i]=n;
					if(k>0){dp[k,j,i]+=dp[k-1,j,i]*k;}
					if(j>0){dp[k,j,i]+=dp[k+1,j-1,i]*j;}
					if(i>0){dp[k,j,i]+=dp[k,j+1,i-1]*i;}
					dp[k,j,i]/=i+j+k;
				}
			}
		}
		Console.WriteLine("{0}",dp[m[0],m[1],m[2]]);
	}
}

Measured memory_bytes: 228192
def main():
    from string import ascii_lowercase
    S = input()
    T = input()

    dic1 = {a: set() for a in ascii_lowercase}
    dic2 = {a: set() for a in ascii_lowercase}
    for s, t in zip(S, T):
        dic1[s].add(t)
        dic2[t].add(s)
    if all(len(s) <= 1 for s in dic1.values()) and\
            all(len(s) <= 1 for s in dic2.values()):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 75696
#include <bitset>
#include <algorithm>

using namespace std;

int main()
{
	const int MAX_VALUES = 101;
	bitset<MAX_VALUES> bits;
	bitset<MAX_VALUES> reversed;
	bits.set();
	reversed.set();
	int x, n, t;
	scanf("%d %d", &x, &n);
	if (n == 0) {
		printf("%d", x);
		exit(0);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &t);
		bits.reset(t);
		reversed.reset(MAX_VALUES - 1 - t);
	}
	if (bits[x]) {
		printf("%d", x);
		exit(0);
	}
	int rV = bits._Find_next(x);
	int lV = MAX_VALUES - 1 - reversed._Find_next(MAX_VALUES - 1 - x);
	int d1 = abs(rV - x);
	int d2 = abs(lV - x);
	if (d1 < d2) {
		printf("%d", rV);
	} else if (d2 < d1) {
		printf("%d", lV);
	} else {
		printf("%d", min(rV, lV));
	}
	return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n, m;
   cin >> n >> m;
   vector<int> s(m), c(m);
   vector<pair<int, int>> t;
   rep(i, m) {
      int s, c;
      cin >> s >> c;
      s--;
      t.emplace_back(s, c);
   }
   sort(t.begin(), t.end());
   vector<int> a(n, -1);
   rep(i, m) {
      if (a[t[i].first] == -1 || a[t[i].first] == t[i].second)
         a[t[i].first] = t[i].second;
      else {
         cout << -1 << endl;
         return 0;
      }
   }
   if (n == 1 && a[0] == -1 || n == 1 && a[0] == 0) {
      cout << 0 << endl;
   } else if (a[0] == 0) {
      cout << -1 << endl;
   } else {
      rep(i, n) {
         if (i == 0 && a[i] == -1)
            cout << 1;
         else if (a[i] == -1)
            cout << 0;
         else
            cout << a[i];
      }
      cout << endl;
   }
   return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	int a, b, k;
	cin >> a >> b >> k;
	vector<int> vs;
	for(int i=1; i<=min(a, b); ++i){
		if(a%i==0 and b%i==0) vs.push_back(i);
	}
	int n= vs.size();
	cout << vs[n-k] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
struct edge{
    ll to;
    ll length;
    edge(ll t, ll l) : to(t), length(l){}
};
void dfs(vector<vector<edge>> &tree,vector<ll> &dist,ll now){
    for(ll i=0;i<tree.at(now).size();i++){
        if(dist.at(tree.at(now).at(i).to)==-1){
            dist.at(tree.at(now).at(i).to)=dist.at(now)+tree.at(now).at(i).length;
            dfs(tree,dist,tree.at(now).at(i).to);
        }
    }
}
int main(){
    ll n;cin>>n;
    vector<vector<edge>> tree(n);
    For(i,n-1){
        ll u,v,l;cin>>u>>v>>l;u--;v--;
        tree.at(u).push_back(edge(v,l));
        tree.at(v).push_back(edge(u,l));
    }
    vector<ll> dist(n,-1);dist.at(0)=0;
    ll now=0;
    dfs(tree,dist,now);
    vector<ll> color(n);
    For(i,n){
        color.at(i)=dist.at(i)%2;
        cout<<color.at(i)<<endl;
    }
}


Measured memory_bytes: 12288
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


n = int(input())
a = list(map(int, input().split(" ")))
alcm = a[0]
for i in a:
    alcm = lcm(alcm, i)

tot = 0
for num in a:
    tot += alcm // num

print(tot % 1000000007)


Measured memory_bytes: 4084
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int list[] = {A,B,C};
        Arrays.sort(list);
        int cnt =0;
        while(true) {
            if (list[2] != list[1] && list[0] <list[2]){
                list[0] ++;
                list[1] ++;
            }else if (list[0] < list[2]){
                list[0] += 2;
            }else if (list[0] >list[2]){
                list[1]++;
                list[2]++;
            }else if (list[0] == list[1] && list[2] ==list[1] ){
                break;
            }
            cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 25172
#include <iostream>
using namespace std;
int n, m, l;
int a[1000][100];
int s[100];
int main()
{
	cin >> n >> m;
	while(n*m!=0)
	{
		for(int j=0; j<m; j++)
		{
			s[j]=0;
		}
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<m; j++)
			{
				cin >> a[i][j];
				s[j]+=a[i][j];
			}
		}
		l=0;
		for(int i=n; i>=0; i--)
		{
			for(int j=0; j<m; j++)
			{
				if((s[j]==i)&&(l==0))
				{
					cout << j+1;
					l+=1;
				}
				else if((s[j]==i)&&(l!=0))
				{
					cout << " " << j+1;
				}
			}
		}
		cout << endl;
		cin >> n >> m;
	}
	return 0;
}

Measured memory_bytes: 1552
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<int,int> P;
typedef long long ll; 
 
#define int ll
 
 
main(){
	ll a;
	double b;
	cin >> a >> b;
	b *= 100.09;
	ll b2  = (ll)b;
	ll ans = (ll) a*b2/100;
	printf("%lld\n",ans);
 
	return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int x, a, b;

    cin >> x >> a >> b;

    if (b <= a) {
        cout << "delicious";
    } else if (b - a <= x) {
        cout << "safe";
    } else {
        cout << "dangerous";
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;



int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	while (1) {
		ll n; scanf("%lld", &n);
		if (n == 1) break;
		vector<ll> d;
		for (ll i = 2; i * i <= n; i++) {
			if (n % i == 0 && (i % 7 == 1 || i % 7 == 6)) {
				d.push_back(i);
				ll q = n / i;
				if (q % 7 == 1 || q % 7 == 6) d.push_back(q);
			}
		}
		if (n % 7 == 1 || n % 7 == 6) d.push_back(n);
		sort(d.begin(), d.end()); d.erase(unique(d.begin(), d.end()), d.end());
		printf("%lld:", n);
		for (ll e : d) {
			bool flag = true;
			for (ll i = 0; i < n && d[i] < e; i++) {
				if (e % d[i] == 0) flag = false;
			}
			if(flag) printf(" %lld", e);
		}
		puts("");
	}
	return 0;
}



Measured memory_bytes: 3252
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a + b >= 10 ? "error" : a +b);
    }
}

Measured memory_bytes: 23124
S=input()
if len(S)==7:
  if S=="keyence":
    print("YES")
  else:
    print("NO")
else:
  l=len(S)-7
  flg=False
  for i in range(1,8):
    s=S[0:i]+S[i+l:]
    if s=="keyence":
      flg=True
      break
  if flg:
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 3060
n = int(input()) + 1
a = list(map(int, input().split()))
a = [0] + a
dist_one = []
skip = []
for i in range(n-1):
    dist_one.append(abs(a[i+1] - a[i]))

    if i == n-2:
        skip.append(abs(a[i] - a[0]))
    else:
        skip.append(abs(a[i+2] - a[i]))

dist_one.append(abs(a[-1] - a[0]))

base = sum(dist_one)

for i in range(n-1):
    print(base - sum(dist_one[i:i+2]) + skip[i]) 

Measured memory_bytes: 17140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	int N, M, X; std::cin >> N >> M >> X;
	std::vector<int> A(M);
	int countL = 0; int countR = 0;
	for (auto& r : A) {
		std::cin >> r;
		if (r > X)
			++countL;
		else
			++countR;
	}
	std::cout << std::min(countL, countR);

	return 0;
}

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

int main()
{
  char a,b,c;
  int k=0;
  cin >> a >> b >> c;
  if(a=='1')
  {
    k++;
  }
  if(b=='1')
  {
    k++;
  }
  if(c=='1')
  {
    k++;
  }
  
  cout << k << endl;
}
  

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;

    // 処理
    // 出力
    if (n <= 999) {
        cout << "ABC";
    } else {
        cout << "ABD";
    }

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    map<int,int>m1,m2;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]-=i;
        m1[a[i]]++;
        a[i]+=2*i;
        m2[a[i]]++;
    }
    int ans=0;
    for(auto i:m1){
        ans+=(i.se*(m2[-i.fi]));
        //cout<<i.se<<" ";
    }
    cout<<ans;
    return 0;
}


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

int main() {
  int a, b, c, p, q;
  cin >> a >> b >> c;
  p = min(a, b) + min(max(a, b), c);
  q = max(max(a, b), c);

  cout << (p == q ? "Yes" : "No") << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> P(N);
  int A, B;
  for(int i=0; i<N; i++){
    cin >> A >> B;
    P.at(i)=make_pair(A, B);
  }
  sort(P.begin(), P.end());
  cout << P.at(N-1).first+P.at(N-1).second << endl;
}

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

#define rep(a, b, c) for (int a = b; a < (c); a++)
#define repe(a, b, c) for (int a = b; a <= (c); a++)
#define repr(a, b, c) for (int a = b; a > (c); a--)
#define repre(a, b, c) for (int a = b; a >= (c); a--)

using namespace std;

int main() {
    for (int c = 1; ; c++) {
        int W, N;
        cin >> W;
        if (W == 0) break;
        cin >> N;
        vector< vector<int> > dp(N + 1, vector<int>(W + 1, 0));
        int v, w;
        char ch;
        rep(i, 0, N) {
            cin >> v >> ch >> w;
            repe(j, 0, W) {
                if (j >= w)
                    dp[i + 1][j] = max(dp[i][j], dp[i][j - w] + v);
                else
                    dp[i + 1][j] = dp[i][j];
            }
        }
        int ans_w = 0, ans_v = 0;
        repre(i, W, 0) {
            if (ans_v <= dp[N][i]) {
                ans_w = i;
                ans_v = dp[N][i];
            }
        }
        cout << "Case " << c << ":" << endl;
        cout << ans_v << endl;
        cout << ans_w << endl;
    }
    return 0;
}

Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	cin >>N;
  	vector<int> S(N);
  	for(int i=0;i<N;i++)cin>>S.at(i) ;
  	sort(S.begin(),S.end());
  	int sum =0;
  	for(int i=0;i<N;i++){
      	if(i%2==0)sum+=S.at(i);
      	else sum -=S.at(i);
    }
  	cout<<abs(sum) <<endl;
      
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef long l;
typedef pair<int,int> p;
typedef vector<int> ve;
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(int i=a;i<b;i++)
int n;
int val[100005][3]={};
int happ[100005][3]={};
int dp(int current,int level)
{
  int maxi=INT_MIN;
  if(happ[level][current]!=INT_MIN)
    return happ[level][current];
  if(level+1==n)
  {
    if(current==0)
      return max(val[level][1],val[level][2]);
    if(current==1)
      return max(val[level][0],val[level][2]);
    if(current==2)
      return max(val[level][1],val[level][0]);
  }
  for(int i=0;i<3;i++)
  {
    if(i!=current)
      maxi=max(maxi,dp(i,level+1)+val[level][i]);
  }
  return happ[level][current]=maxi;
}
int final(int A,int B,int C)
{
  if(A>B)
  {
    if(A>C)
      return A;
    else
      return C;
  }
  else
  {
    if(B>C)
      return B;
    else
      return C;
  }
}
int main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
      cin>>val[i][j];
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
      happ[i][j]=INT_MIN;
    }
  }
  int ans;
  if(n>=2)
  {
    int A=dp(0,1);
    int B=dp(1,1);
    int C=dp(2,1);
    ans=final(A+val[0][0],B+val[0][1],C+val[0][2]);
  }
  else if(n==1)
  {
    ans=final(val[0][0],val[0][1],val[0][2]);
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 10368
def nCr(n,r,mod = 10**9+7):
    r = min(n-r,r)
    numer = denom = 1
    for i in range(1,r+1):
        numer = numer * (n+1-i) %mod
        denom = denom * i % mod
    return numer * pow(denom,mod-2,mod) %mod
    
x,y = map(int,input().split())
if (x+y) %3 != 0 or not (x <= 2*y and y <= 2*x ):
    print(0)
    exit()
    
a = (x + y) //3
n = y - a

print(nCr(a,n))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll n,i,q,sum=0;
       cin>>n;
       map <ll,ll> mp;
       vector <ll> v(n);
       for(auto &u:v)
       {
           cin>>u;
           sum+=u;
           mp[u]++;
       }   
       cin>>q;
       while(q--)
       {
           ll b,c;
           cin>>b>>c;
           if(!mp[b])
           {
               cout<<sum<<"\n";
               continue;
           }
           sum-=mp[b]*b;
           sum+=mp[b]*c;
           mp[c]+=mp[b];
           mp[b]=0;
           cout<<sum<<"\n"; 
       }
   }
}

Measured memory_bytes: 9824