akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=50;
//templete
int main() {
	int N,K;
	cin>>N>>K;
	deque<int> D,E;
	for(int i=0;i<N;i++){
		int V;
		cin>>V;
		D.pb(V);
	}
	int ans=0;
	E=D;
	//何回取り出すか
	for(int i=0;i<=K;i++){
		//左と右からそれぞれ何回取るか？
		for(int l=0;l<=i;l++){
			vint plus,minus;
			//左からl回とる
			for(int j=0;j<l;j++){
				if(D.empty())
					continue;
				int v=D.front();
				if(v>=0)
					plus.pb(v);
				else
					minus.pb(v);
				D.pop_front();
			}
			//右からi-l回とる
			for(int j=0;j<i-l;j++){
				if(D.empty())
					continue;
				int v=D.back();
				if(v>=0)
					plus.pb(v);
				else
					minus.pb(v);
				D.pop_back();
			}
			sort(minus.begin(),minus.end(),greater<int>());
			//K-i回捨てる
			for(int j=0;j<K-i;j++){
				if(!minus.empty())
					minus.pop_back();
			}
			//score
			int temp=accumulate(plus.begin(),plus.end(),0);
			temp+=accumulate(minus.begin(),minus.end(),0);
			ans=max(ans,temp);
			D=E;
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int w = stdIn.nextInt();
		int h = stdIn.nextInt();
		int n = stdIn.nextInt();
		
		int nowx = stdIn.nextInt();
		int nowy = stdIn.nextInt();
		int counter = 0;
		for(int i = 1; i < n; i++) {
			int tox = stdIn.nextInt();
			int toy = stdIn.nextInt();
			if((nowx > tox && nowy < toy) || (nowx < tox && nowy > toy)) {
				counter += Math.abs(nowx - tox) + Math.abs(nowy - toy);
			}
			else {
				counter += Math.max(Math.abs(nowx - tox), Math.abs(nowy - toy));
			}
			nowx = tox;
			nowy = toy;
		}
		System.out.println(counter);
	}

}

Measured memory_bytes: 25688
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y", long, "cost");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b, c;
    scan(a, b, c);
    swap(a, b);
    swap(a, c);
    writefln("%s %s %s", a, b, c);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
const main = (line) => {
  const a = line
  a[0] = a[0].split(" ").map(Number)
  let S = a[1].split("")
  S[a[0][1]-1] = S[a[0][1]-1].toLowerCase()
  console.log(S.join(""))
}

main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"))

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

int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;

    if(e-a>k){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>

using namespace std;

using relation_map = unordered_map<int, unordered_set<int>>;

void make_relation(relation_map& m, int x, int y){
    m[x].insert(y);
    m[y].insert(x);
}

bool has_relation(const relation_map& r, int x, int y){
    const auto& r_f_x = r.find(x);
    return r_f_x != r.end() && r_f_x->second.find(y) != r_f_x->second.end();
}

void divide(vector<int>& group, unordered_map<int,int>& groupsize, const relation_map& friends, int x)
{
    auto ffx = friends.find(x);
    if(ffx == friends.end()){
        if(group[x-1] == 0){
            group[x-1] = x;
            ++groupsize[x];
        }
        return;
    }
    if(group[x-1] == 0){
        group[x-1] = x;
        ++groupsize[x];
    }
    for(int f : ffx->second){
        if(f == x) continue;
        if(group[f-1] == 0){
            ++groupsize[group[f-1] = group[x-1]];
            divide(group, groupsize, friends, f);
        }
    }
}

int main()
{
    int N,M,K;
    cin >> N >> M >> K;
    relation_map friends;
    relation_map blocks;
    relation_map friend_candidates;
    for(int i = 0; i < M; ++i){
        int x, y;
        cin >> x >> y;
        make_relation(friends, x, y);
    }
    for(int i = 0; i < K; ++i){
        int x, y;
        cin >> x >> y;
        make_relation(blocks, x, y);
    }
    vector<int> group(N);
    unordered_map<int,int> groupsize;
    for(int x = 1; x <= N; ++x){
        divide(group, groupsize, friends, x);
    }
    for(int x = 1; x <= N; ++x){
        int ncd = groupsize[group[x-1]]
            - count_if(blocks[x].begin(), blocks[x].end(), [&](int y){return group[x-1] == group[y-1];})
            - friends[x].size()
            - 1;
        cout << ncd << ' ';
    }
    return 0;
}


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

template <typename _tp> inline void read(_tp&x){
	char ch=getchar(),ob=0;x=0;
	while(ch!='-'&&!isdigit(ch))ch=getchar();if(ch=='-')ob=1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();if(ob)x=-x;
}

const int N = 211, M = 40013, oo = 1e9;
struct Edge {int v, w, nxt;} a[M];
int head[N], cur[N], dis[N];
char str[N];
int n, m, s, t, _ = 1;

inline void add(int x, int y, int z) {
	a[++_].v = y, a[_].w = z, a[_].nxt = head[x], head[x] = _;
	a[++_].v = x, a[_].w = 0, a[_].nxt = head[y], head[y] = _;
}

bool bfs() {
	static int q[N], he, ta;
	memset(dis, -1, t + 1 << 2);
	dis[q[he = ta = 1] = s] = 0;
	while(he <= ta) {
		int x = q[he++];
		for(int i=head[x];i;i=a[i].nxt)
			if(a[i].w > 0 and dis[a[i].v] == -1) {
				dis[a[i].v] = dis[x] + 1;
				q[++ta] = a[i].v;
				if(a[i].v == t) return true;
			}
	}
	return false;
}

int dfs(int x, int flw) {
	if(x == t or flw == 0) return flw;
	int res = 0, tmp;
	for(int&i=cur[x];i;i=a[i].nxt)
		if(dis[a[i].v] == dis[x] + 1 and a[i].w > 0)
		if(tmp = dfs(a[i].v, min(flw - res, a[i].w)))
			a[i].w -= tmp, a[i^1].w += tmp, res += tmp;
	if(!res) dis[x] = -1;
	return res;
}

int main() {
	read(n), read(m), s = n+m+1, t = s+1;
	for(int i=1;i<=n;++i) {
		scanf("%s", str+1);
		for(int j=1;j<=m;++j) {
			if(str[j] == 'o') {add(i, j+n, 1), add(j+n, i, 1); continue;}
			if(str[j] == 'S') add(s, i, +oo), add(s, j+n, +oo);
			if(str[j] == 'T') add(i, t, +oo), add(j+n, t, +oo);
		}
	}
	
	int Ans = 0;
	while(bfs()) {
		memcpy(cur, head, t + 1 << 2);
		Ans += dfs(s, +oo);
	}
	printf("%d\n", Ans > n * m ? -1 : Ans);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main(void) 
{
    int N,M;

    cin >> N >> M;

    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    iota(C.begin(), C.end(), 0);

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

    sort(
        C.begin(),
        C.end(),
        [&](int x, int y){return A[x] < A[y];}
    );

    int ans = 0;
    int j = 0;
    
    priority_queue<int> que;
    for(int i=1;i<=M;++i)
    {
        while(A[C[j]]==i)
        {
            que.push(B[C[j]]);
            j++;
        }
        if(!que.empty())
        {
            ans += que.top();
            que.pop();
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2044
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long i64;
const int MOD = 1000000007;

int N, M, go[20];
i64 f[1 << 15], bin[300];

void update(i64 &x, i64 y) {
  x = (x + y) % MOD;
}

int main() {
  scanf("%d%d", &N, &M);
  
  for (int i = 1; i <= M; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    u = N - u, v = N - v;
    go[u] |= 1 << v;
  }
  
  bin[0]= 1;
  for (int i = 1; i <= M; ++i) bin[i] = (bin[i - 1] + bin[i - 1]) % MOD;
  
  int S = (1 << N) - 1;
  
  for (int mask = 1; mask <= S; ++mask) {
    int f1 = (mask >> N - 1) & 1, f2 = (mask >> N - 2) & 1;
    if (f1 ^ f2) continue;
    
    f[mask] = 1;
    for (int U = (mask - 1) & mask; U; U = (U - 1) & mask) {
      int T = mask ^ U;
      f1 = (T >> N - 1) & 1, f2 = (T >> N - 2) & 1;
      if (f1 ^ f2) continue;
      i64 way = 1;
      for (int i = 0; i < N; ++i)
	if ((T >> i) & 1) way = way * (bin[__builtin_popcount(go[i] & U)] - 1) % MOD;
	else if ((U >> i) & 1) way = way * bin[__builtin_popcount(go[i] & T)] % MOD;
      update(f[mask], f[T] * way % MOD);
    }
  }

  printf("%lld\n", (bin[M] - f[S] + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int x[222222],y[222222]; 
struct in
{
	int l,r;
}t[222222];
bool operator <(const in&x,const in &y)
{
	return x.l<y.l;
}
int main()
{
	int n=io::F(),mx=0,mn=0x3f3f3f3f,mxpl,mnpl;
	for(register int i=1;i<=n;++i)
	{
		x[i]=io::F(),y[i]=io::F();
		if(x[i]>y[i])std::swap(x[i],y[i]);
		if(cmin(mn,x[i]))mnpl=i;
		if(cmax(mx,y[i]))mxpl=i;
	}
	int r1=mn,l2=mx;
	for(register int i=1;i<=n;++i)
		cmax(r1,x[i]),cmin(l2,y[i]);
	long long ans=(long long)(r1-mn)*(mx-l2);
	if(mnpl==mxpl)return!printf("%lld\n",ans);
	int L=y[mnpl],R=x[mxpl];
	if(L>R)std::swap(L,R);
	int pt=0;
	for(register int i=1;i<=n;++i)
	{
		if(y[i]<L)L=y[i];
		if(x[i]>R)R=x[i];
	}
	for(register int i=1;i<=n;++i)
		if(x[i]<L&&y[i]>R)t[++pt]=(in){x[i],y[i]};
	std::sort(t+1,t+pt+1);
	int max=R;
	long long dis=mx-mn; 
	if(pt==0)cmin(ans,dis*(R-L));
	for(register int i=1;i<=pt;++i)
	{
		cmin(ans,dis*(max-t[i].l));
		cmax(max,t[i].r);
	}
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

    vector<int64_t> A(N), Sum(N-1, 0);
    for(int i = 0; i < N; i++) cin >> A.at(i);

    Sum.at(0) = A.at(N-1) % MOD;
    for(int i = 1; i < N-1; i++) Sum.at(i) = (Sum.at(i-1) + A.at(N-1-i)) % MOD;

    int64_t ans = 0;

    for(int i = 0; i < N-1; i++){
        ans += Sum.at(N-2-i) * A.at(i) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

const int INF = 1e9;

int main(){
  int N;
  cin >> N;
  vector<char> D(N);
  vector<int> L(N);
  vector<pair<int,int>> V;
  for(int i = 0; i < N; ++i){
    cin >> D[i] >> L[i];
    if(D[i] == 'y') V.emplace_back(L[i],i);
  }
  sort(V.begin(), V.end());
  int ans = 0;
  for(auto p : V){
    if(L[p.second] >= INF) continue;
    ++ans;
    int idx = p.second, h = L[idx];
    for(int i = idx-1; i >= 0; --i){
      if(L[i] >= h and D[i] == 'n') break;
      if(L[i] >= h) L[i] = INF;
    }
    for(int i = idx+1; i < N; ++i){
      if(L[i] >= h and D[i] == 'n') break;
      if(L[i] >= h) L[i] = INF;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3140
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    cf.append(1)
    cf.sort()
    return cf

a, b, k = map(int, input().split())
li = cf(a, b)
print(li[-k])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  // 
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s; cin>>s;
  string d0="dream";
  string d1="dreamer";
  string e0="erase";
  string e1="eraser";
  bool flag=false;
  reverse(s.begin(), s.end());
  reverse(d0.begin(), d0.end());
  reverse(d1.begin(), d1.end());
  reverse(e0.begin(), e0.end());
  reverse(e1.begin(), e1.end());
  REP(i,(int)s.size()){
    if(s[i]==d0[0] && flag==false){
      REP(j,(int)d0.size()){
        if(i+j>=(int)s.size() || s[i+j]!=d0[j]){
          flag=true;
          break;
        }
      }
      i+=(int)d0.size()-1;
    }else if(s[i]==d1[0] && s[i+2]==d1[2] && flag==false){
      REP(j,(int)d1.size()){
        if(i+j>=(int)s.size() || s[i+j]!=d1[j]){
          flag=true;
          break;
        }
      }
      i+=(int)d1.size()-1;
    }else if(s[i]==e0[0] && flag==false){
      REP(j,(int)e0.size()){
        if(i+j>=(int)s.size() || s[i+j]!=e0[j]){
          flag=true;
          break;
        }
      }
      i+=(int)e0.size()-1;
    }else if(s[i]==e1[0] && flag==false){
      REP(j,(int)e1.size()){
        if(i+j>=(int)s.size() || s[i+j]!=e1[j]){
          flag=true;
          break;
        }
      }
      i+=(int)e1.size()-1;
    }else{
      flag=true;
      break;
    }
  }
  if(flag) {
    P("NO");
  }else{
    P("YES");
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
  int n,a,b;
  cin >> n>>a>>b;
  
  if(n*a<b){
    cout << n*a << endl;
  }
  else if(b<n*a){
    cout << b << endl;
  }
  else if(b==n*a){
    
    cout << b<< endl;
  }
}

Measured memory_bytes: 256
(defun input (n)
  (let ((A (make-array n))
        (B (make-array n))
        (C (make-array n)))
    (loop for i below n
          do (progn (setf (aref A i) (1- (read)))
                    (setf (aref B i) (1- (read)))
                    (setf (aref C i) (read))))
    (values A B C)))

(defun num-list (n)
  (loop for i below n collect i))

(defun solve (n m A B C)
  (let ((d (make-array '(100 100) :initial-element 300000000)))
    (dotimes (i m)
      (setf (aref d (aref A i) (aref B i)) (aref C i))
      (setf (aref d (aref B i) (aref A i)) (aref C i)))
    (dotimes (i n) (setf (aref d i i) 0))
    (dotimes (k n) (dotimes (i n) (dotimes (j n)
      (setf (aref d i j) (min (aref d i j) (+ (aref d i k) (aref d k j))))))) 
    (labels ((test (i)
               (= 0 
                  (count-if
                    (lambda (j)
                      (= (+ (aref d j (aref A i)) (aref C i))
                         (aref d j (aref B i))))
                    (num-list n)))))
      (count-if (lambda (i) (test i)) (num-list m)))))

(let ((n (read))
      (m (read)))
  (multiple-value-bind (A B C) (input m)
    (princ (solve n m A B C))))

Measured memory_bytes: 23140
N = int(input())
testimo_ls = [ [] for i in range(N) ]
rst = 0
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split(' '))
        testimo_ls[i].append([x - 1, y])
for i in range(1 << N):
    honest_ls = []
    for j in range(N):
        if i >> j & 1:
            honest_ls.append(j)
    is_ok = True
    for s in honest_ls:
        for t in testimo_ls[s]:
            if t[0] not in honest_ls and t[1] == 1:
                is_ok = False
                break
            if t[0] in honest_ls and t[1] == 0:
                is_ok = False
                break
    if is_ok:
        rst = max(rst, len(honest_ls))
print(rst)

Measured memory_bytes: 9196
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] array = new int[6 + 1];
		array[0] = 0;
		for (int i = 1; i < array.length; i++) {
			array[i] = scan.nextInt();
		}
		int q = scan.nextInt();
		Dice dice = new Dice(array);
		int part1; int part2;
		for (int i = 0; i < q; i++) {
			part1 = scan.nextInt();
			part2 = scan.nextInt();
			System.out.println(dice.check(part1, part2));
		}
		scan.close();
	}
}
	

class Dice {
	private int[] num = new int[6 + 1];
	Dice() {
	}

	Dice(int[] array) {
		for (int i = 0; i < array.length; i++) {
			this.num[i] = array[i];
		}
	}
	
	public int[] getNum() {
		return this.num;
	}
	
	public int getNumber(int i) {
		return this.num[i];
	}
	
	// ??????????????¢??????????????????
	public int[] roll(int[]ary, String order) {
		int now_1 = 1;	int now_2 = 2;	int now_3 = 3;	int tmp;
		int[] array = ary;
		char[] check = {'N', 'E', 'S', 'W'};
		for (int i = 0; i < order.length(); i++) {
			for (int j = 0; j < check.length; j++) {
				if (order.charAt(i) == check[j]) {
					switch (j + 1) {
						case 1:
							tmp = now_1;
							now_1 = now_2;
							now_2 = 7 - tmp;
							break;
						case 2:
							tmp = now_1;
							now_1 = 7 - now_3;
							now_3 = tmp;
							break;
						case 3:
							tmp = now_1;
							now_1 = 7 - now_2;
							now_2 = tmp;
							break;
						case 4:
							tmp = now_1;
							now_1 = now_3;
							now_3 = 7 - tmp;
							break;
					}
				}
			}
		}
		int[] cp_array = new int[array.length];
		cp_array[1] = array[now_1]; cp_array[2] = array[now_2];
		cp_array[3] = array[now_3]; cp_array[4] = array[7 - now_3];
		cp_array[5] = array[7 - now_2]; cp_array[6] = array[7 -now_1];
		return cp_array;
	}
	
	// 1?????????????????????????¨?????????????????????????
	public int[] turn(int[] array) {
		int tmp;
		tmp = array[2];
		array[2] = array[3];
		array[3] = array[5];
		array[5] = array[4];
		array[4] = tmp;
		
		return array;
	}
	
	// 3?????¨?????????????????????
	public int check(int part1, int part2) {
		String[] str = {"null", "N", "N", "N", "E", "WW"};
		int sum = 0;
		int[] array = new int[num.length];
		for (int i = 0; i < num.length; i++) {
			array[i] = num[i];
		}
		boolean decision = false;
		for (int i = 0; i < str.length; i++) {
			array = this.roll(array, str[i]);
			for (int j = 0; j < 4; j++) {
				if (array[1] == part1) {
					if (array[2] == part2) {
						sum = array[3];
						decision = true;
						break;
					} else {
						//array = turn(array);
						array = this.roll(array, "NWS");
					}
				} else {
					break;
				}
			}
			if (decision) break;
		}
		

		return sum;
	}
}

Measured memory_bytes: 26128
S=input()
if S[:7]=="keyence":
    print("YES")
elif S[-7:]=="keyence":
    print("YES")
elif S[:6]=="keyenc" and S[-1:]=="e":
    print("YES")
elif S[:5]=="keyen" and S[-2:]=="ce":
    print("YES")
elif S[:4]=="keye" and S[-3:]=="nce":
    print("YES")
elif S[:3]=="key" and S[-4:]=="ence":
    print("YES")
elif S[:2]=="ke" and S[-5:]=="yence":
    print("YES")
elif S[:1]=="k" and S[-6:]=="eyence":
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int n;
	cin >> n;
	string ans = "Yes";
	
	vector<int> t(n);
	vector<int >x(n);
	vector<int> y(n);
	for (int i = 0; i < n; i++)
	{
		cin >> t.at(i) >> x.at(i) >> y.at(i);
	}
	for (int i = 0; i < n; i++)
	{
		
		int w = x.at(i) + y.at(i);
		if (i == 0)
		{
			if (abs(t.at(i)-0)<abs(0-w))
			{
				ans = "No";
					break;
			}
		else
		{
			if (abs(t.at(i) - 0) % 2 != abs((0 - w) % 2))
			{
				ans = "No";
				break;
			}
		}
		}
		else
		{
			if (abs(t.at(i) - t.at(i-1))<abs(x.at(i-1)+y.at(i)- w))
			{
				ans = "No";
					break;
			}
			else
			{
				if (abs(t.at(i) - t.at(i - 1)) % 2 != abs((x.at(i - 1) + y.at(i - 1) - w) % 2))
				{
					ans = "No";
					break;
				}
			}
		}

	}
	cout << ans << endl;
	

}

Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

def ume(x):
    x = str(x)
    if len(x) < 6:
        return '0'*(6-len(x)) + x
    return x

def main():
    N, M = mi()
    '''
    l = dp2(0, 3, M)
    cnt = [0]*(N+1)
    ans = dp2(0, 2, M)
    for i in range(M):
        p, y = mi()
        l[i][0], l[i][1], l[i][2] = p-1, y, i
        cnt[p] += 1
    for i in range(N):
        cnt[i+1] += cnt[i]

    l.sort(key=lambda x: x[0])
    for i in range(N):
        ichibu = l[cnt[i]:cnt[i+1]]
        ichibu.sort(key=lambda x: x[1])
        for j in range(cnt[i+1]-cnt[i]):
            ans[ichibu[j][2]][0] = ichibu[j][0]+1
            ans[ichibu[j][2]][1] = j+1
    
    for x, y in ans:
        print(ume(x)+ume(y))
    '''

    l = li2(M)
    pos = [[] for _ in range(N+1)]
    ans = dp2(0, 2, M)

    for a, b in l:
        pos[a].append(b)
    for a in pos:
        a.sort()
    for i, a in enumerate(l):
        ind = bisect.bisect_left(pos[a[0]], a[1])
        l[i][1] = ind+1
        print(ume(l[i][0])+ume(l[i][1]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 81372
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=1000000007LL;
const ll MOD=998244353LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

ll dp[2010][2010];
int main(){
  ll n,x;cin>>n>>x;
  vl a(n);
  rep(i,n)cin>>a[i];
  vvl data(n,vl (n));
  rep(j,n){
    ll MIN=INF;
    rep(i,n){
      
      MIN=min(MIN,a[(i+j)%n]);
      data[i][j]=MIN;
    }
  }
  rep(i,2010){
    rep(j,2010)dp[i][j]=INF;
  }
  dp[0][0]=0;
  rep(j,n){
    ll MIN=INF;    
    rep(i,n){
      MIN=min(dp[i][j],MIN);
      if(i!=0)dp[i][j+1]=min(MIN+data[i][j],dp[i-1][j+1]);
      else dp[i][j+1]=MIN+data[i][j];
    }
  }
  /*rep(i,n){
    rep(j,n+1)cout<<dp[i][j]<<" ";
    cout<<endl;
  }
  cout<<endl;
  rep(i,n){
    rep(j,n)cout<<data[i][j]<<" ";
    cout<<endl;
  }*/
  ll ans=INF;
  rep(i,n)ans=min(ans,dp[i][n]+i*x);
  cout<<ans<<endl;
}

Measured memory_bytes: 63232
import sys
sys.setrecursionlimit(10 ** 6)
N, u, v = map(int, input().split())
u -= 1
v -= 1
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

dist = [0] * N
def dfs(v, d=0, p=-1):
    global dist
    dist[v] = d
    for u in edges[v]:
        if u == p:
            continue
        dfs(u, d + 1, v)

def calc_dist(s):
    global dist
    dist = [0] * N
    dfs(s)
    return dist

distS = calc_dist(u)
distT = calc_dist(v)

mx = 0
for i in range(N):
    if distS[i] < distT[i]:
        mx = max(mx, distT[i])
ans = mx - 1
print(ans)

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

int main() {
    int n, a[200], count=0;
    cin>>n;
    for(int i=0; i<n; i++) cin>>a[i];
    while(1) {
        for(int i=0; i<n; i++) {
            if(a[i]%2) {
                cout << count << endl;
                return 0;
            } else{
                a[i] /= 2;
            }
        }
        count++;
    }
}

Measured memory_bytes: 256
package main

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

func main() {
	nextReader = newScanner()

	n := nextInt()
	p := nextInts(n)

	count := 0

	min := n + 1
	for i := 0; i < n; i++ {
		if min > p[i] {
			min = p[i]
			count++
		}

	}

	fmt.Println(count)

}

/* --------------------------------------------------------------------------
 *  std.io
 * ------------------------------------------------------------------------- */
var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

string check(string s, string t){
    if(s.size() == t.size()){
        return (s > t ? s : t);
    }
    return (s.size() > t.size() ? s : t);
}

signed main(){
    int h, w;
    while(1){
        cin >> w >> h;
        if(h == 0 && w == 0) break;
        vector<string> s(h);
        rep(i, 0, h) cin >> s[i];
        string dp[71][71];
        rep(i, 0, 70) rep(j, 0, 70) dp[i][j] = "";
        rep(i, 0, h){
            rep(j, 0, w){
                if('0' <= s[i][j] && s[i][j] <= '9'){
                    if(s[i][j] != '0') dp[i][j] = s[i][j];
                    if(i != 0 && dp[i - 1][j] != ""){
                        dp[i][j] = check(dp[i][j], dp[i - 1][j] + s[i][j]);
                    // cout << i << " " << j << " " << dp[i - 1][j] + s[i][j] << " " << dp[i][j] << endl;
                        
                    }
                    if(j != 0 && dp[i][j - 1] != ""){
                        dp[i][j] = check(dp[i][j], dp[i][j - 1] + s[i][j]);
                    // cout << i << " " << j << " " << dp[i][j - 1] + s[i][j] << " " << dp[i][j] << endl;                        
                    }
                }
            }
        }
        string ans = "";
        rep(i, 0, h){
            rep(j, 0, w){
                ans = check(ans, dp[i][j]);
                // cout << dp[i][j];
                // rep(k, 0, 10 - dp[i][j].size()) cout << " ";
            }
            // cout << endl;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
#define N 2000050
#define M 200
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
#define MOD mod
using namespace std;
int mod = 1e9 + 7;
int ans = 0;
int six[N],fiv[N],n;
string s;
ll inv[SIZE],fac[SIZE],finv[SIZE];
void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	make();
    cin>>n>>s;
    fiv[0] = 1; six[0] = 1;
    for(int i=1;i<N;i++){
        fiv[i] = 25ll*fiv[i-1];
        six[i] = 26ll*six[i-1];
        if(fiv[i]>=mod)fiv[i] %= mod;
        if(six[i]>=mod)six[i] %= mod;
    }
    int tot = (int)s.length() + n;
   // cout<<tot<<" ";
    int m = s.length();
    for(int i=m;i<=tot;i++){
        int right = tot - i;
        int left = i - m;
        //cout<<left<<" "<<right<<"\n";
        int ways = (fiv[left]*six[right])%mod;
        ways *= C(i-1,m-1);
        if(ways>=mod) ways %=mod;
        ans += ways;
        if(ans>=mod) ans %= mod;
    }
    cout<<ans;
}


Measured memory_bytes: 82516
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a, b, c, ans = 0; cin >> n;
	int test[22] = { 0 }, uiop[22] = { 0 };
	for (int h = 0; h < n; h++) {
		cin >> a;
		test[h] = a;
	}
	for (int h = 0; h < n; h++) {
		cin >> b;
		ans += b;
	}
	for (int h = 1; h < n; h++) {
		cin >> c;
		uiop[h] = c;
	}
	for (int h = 1; h < n; h++) {
		if (test[h - 1] + 1 == test[h]) {
			ans += uiop[test[h-1]];
		}
	}
	cout << ans << endl;
	cin >> n;
}

Measured memory_bytes: 256
using System;

class Untitled
{
  static void Main(string[] args)
  {
	  // ???????????´??°a, b, c?????????????????????????????? a < b < c????????¶????????????????????°"Yes"?????????????????????????????°"No"???????????????????????°?????????????????????????????????
    bool parsed = false;
    int a = 0, b = 0, c = 0;
    string s = Console.ReadLine();
    if (!String.IsNullOrEmpty (s)) {
	  string[] strs = s.Split (' ');
	  if (strs.Length == 3) {
		parsed = Int32.TryParse (strs [0], out a);
		if (parsed) {
			parsed = Int32.TryParse (strs [1], out b);
		}
		if (parsed) {
			parsed = Int32.TryParse (strs [2], out c);
		}
	  }
    }
    if (parsed) {
		if (a < b && b < c) {
			System.Console.WriteLine ("Yes");
		} else {
			System.Console.WriteLine ("No");
		}
    }
  }
}

Measured memory_bytes: 8760
# -*- coding: utf-8 -*-
# input
n = int(input())

t0 = x0 = y0 = 0
for i in range(n):
    t, x, y = map(int, input().split())
    dt = t - t0
    dm = abs(x - x0) + abs(y - y0)
    if dt < dm:
        print('No')
        exit()
    elif dt % 2 != dm %2:
        print('No')
        exit()

    t0 = t
    x0 = x
    y0 = y

print('Yes')


Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};
 
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars,
    }

    println!("{}", if s.iter().collect::<String>() == "ARC" { "ABC" } else { "ARC" });
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	string s;
	int ans(0);
	while (cin >> s) {
		string t; bool f(false);
		rep(i, 0, s.size()) {
			if (isdigit(s[i])) {
				t.push_back(s[i]);
				f = true;
			}
			else {
				if (f) {
					ans += stoi(t);
					f = false;
				}
				t.clear();
			}
		}
		if (f)ans += stoi(t);
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3144
N, K = map(int, input().split())
MOD = 1000000007
small = 0
large = 0
res = 0

for i in range(K-1):
  small += i
  large += N-i

for i in range(K, N+2):
  small += i-1
  large += N - i +1
  gap = large - small +1
  res += gap

print(res%MOD)


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

const int mod =1e9+7;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int h,w;
    cin>>h>>w;
    char s[h+1][w+1];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>s[i][j];
        }
    }
    long long dp[h+1][w+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=h;i++){
        if(s[1][i]=='.')
            dp[1][i]=1;
        else
            break;
    }
    for(int i=1;i<=w;i++){
        if(s[i][1]=='.')
            dp[i][1]=1;
        else
            break;
    }
    for(int i=2;i<=h;i++){
        for(int j=2;j<=w;j++){
            if(s[i][j]=='#')
                continue;
            if(s[i-1][j]=='.')
                dp[i][j]=(dp[i][j]%mod+dp[i-1][j]%mod)%mod;
            if(s[i][j-1]=='.')
                dp[i][j]=(dp[i][j]%mod+dp[i][j-1]%mod)%mod;
        }
    }
    cout<<dp[h][w];
}
  

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a%2 == 0 || b%2 == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdio>

const double EPSILON = 1e-10;

inline bool equals(double a, double b) {
    return std::fabs(a - b) < EPSILON;
}

struct Point {
    double x;
    double y;

    bool operator < (const Point& p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point& p) const {
        return equals(x, p.x) && equals(y, p.y);
    }
};

Point operator + (const Point& p1, const Point& p2) {
    return Point{p1.x + p2.x, p1.y + p2.y};
}

Point operator - (const Point& p1, const Point& p2) {
    return Point{p1.x - p2.x, p1.y - p2.y};
}

Point operator * (const Point& p1, double k) {
    return Point{p1.x * k, p1.y * k};
}

struct Segment {
    Point p1, p2;
};

struct Circle {
    Point center;
    double radius;
};

using Vector = Point;
using Line = Segment;
using Polygon = std::vector<Point>;


double norm(const Vector& p) {
    return p.x * p.x + p.y * p.y;
}

double abs(const Vector& p) {
    return std::sqrt(norm(p));
}

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

Vector projection(const Segment& s, const Point& p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

int main() {
    using namespace std;

    Point p1, p2;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    Segment s{p1, p2};

    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        double x, y;
        cin >> x >> y;
        auto p = projection(s, Point{x, y});
        cout << setprecision(20) << p.x << " " << p.y << endl;
    }

    return 0;
}


Measured memory_bytes: 3292
#include<iostream>
using namespace std;
int main(){
    int n, k, sum = 0, max, nimotu, track, vol;
    bool flag = false;
    cin >> n >> k;
    int w[n];
    for(int i=0;i<n;++i){
        cin >> w[i];
        sum += w[i];
    }
    
    max = sum/k-1;
    while(!flag){
        ++max;
        nimotu = 0;
        for(track=0;track<k;++track){
            vol = 0;
            while(vol + w[nimotu] <= max){
                vol += w[nimotu];
                ++nimotu;
                if(nimotu == n){
                    flag = true;
                    break;
                }
            }
            if(nimotu == n){
                flag = true;
                break;
            }
        }
        if(nimotu == n){
            flag = true;
        }
    }
    
    cout << max << endl;
    
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge;
  ll n;cin>>n;
  vector<ll>a(n);
  for(i=0;i<n;i++)cin>>a[i];
  sort(ALL(a));
  judge=true;
  res=1;
  if(n%2==0){
    for(i=0;i<n&&judge;i+=2){
      if(a[i]==i+1&&a[i]==a[i+1])qmod(res,2);
      else{
        res=0;
        judge=false;
      }
    }
  }
  else{
    if(a[0]!=0){
      res=0;
      judge=false;
    }
    for(i=1;i<n&&judge;i+=2){
      if(a[i]==i+1&&a[i]==a[i+1])qmod(res,2);
      else{
        res=0;
        judge=false;
      }
    }
  }
  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 1024
n=int(input())
ans=""
i=0
if n==0:
    print(0)
    exit()

while n!=0 :
    if n%2==0:
        ans+="0"

    else:
        ans+="1"
        if i%2==0:
            n-=1
        else:
            n+=1
    n=n//2
    i+=1
    #print(n,ans)

print(ans[::-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll n,m,ar[N],sum,t;



int main()
{
	fast;
	cin>>n>>m;
	// sum=1;
	while(n)
	{
		n/=m;
		sum++;
	}
	cout<<sum<<endl;
}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{   int n;
    cin>>n;
   int W;
    cin>>W;
    int val[n+1];
    int arr[n+1];
    int dp[n+1][W+1];
    for(int i=1;i<=n;i++)
        cin>>arr[i]>>val[i];
    for(int i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    for(int j=0;j<=W;j++)
    {
        dp[0][j]=0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(j-arr[i]>=0)
                dp[i][j]=max(val[i]+dp[i-1][j-arr[i]],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];


        }

    }
     cout<<dp[n][W]<<endl;


}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b, c, ans;
int main() {
    cin >> a >> b >> c;
    vector<int> v = {a, b, c};
    sort(v.begin(), v.end());
    // -1, +2
    int d1 = v[1] - v[0];
    int d2 = v[2] - v[1];
    if (d1 & 1)
        ans += (d1 + 1) / 2 + 1;
    else
        ans += d1 / 2;
    ans += d2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
n = gets.chomp.to_i

if n >= 400 && n <= 599
  puts 8
elsif n >= 600 && n <= 799
  puts 7
elsif n >= 800 && n <= 999
  puts 6
elsif n >= 1000 && n <= 1199
  puts 5
elsif n >= 1200 && n <= 1399
  puts 4
elsif n >= 1400 && n <= 1599
  puts 3
elsif n >= 1600 && n <= 1799
  puts 2
elsif n >= 1800 && n <= 1999
  puts 1
end


Measured memory_bytes: 14384
#include <iostream>

using namespace std;

int main() {
  int l,n,eat,first,last;
  cin >> n;
  cin >> l;
  
  first = l;
  last = l + n - 1;
  
  int total = (first + last) * n / 2;
  
  if (first * last <= 0) {
    eat = 0;
  } else if (abs(first) <= abs(last)) {
    eat = first;
  } else {
    eat = last;
  }
  
  cout << (total - eat) << endl;
  return 0;
}

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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#define co(n) cout << (n) << endl;
#define cn(n) cin >> n;
#define all(x) (x).begin(), (x).end()

int main(){
  int n;cn(n)
  co(n*n);
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int coins = 0;
	int i;
	for (i = 1; ; i++) {
		coins += a;
		if (i % 7 == 0) {
			coins += b;
		}
		if (coins >= c) {
			break;
		}
	}
	cout << i << endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> a;
    a.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum ^= a[i];
    }
    
    int ans;
    for (int i = 0; i < N; i++)
    {
        ans = sum ^ a[i];
        cout << ans;
        if (i < N - 1)
        {
            cout << ' ';
        }
        
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3964
let gcd m n =
  let rec doit x y =
    if y <= 0 then x else doit y (x mod y) in
  doit (max m n) (min m n)

let lcm m n = m * n / (gcd m n)

let () =
  let _ = read_int () in
  match read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string with
  | x :: xs -> List.fold_left lcm x xs |> Printf.printf "%d\n"
  | _ -> assert false

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> P;
  rep(i,n){
    int num;
    cin >> num;
    P.push_back(make_pair(num,i+1));
  }
  sort(P.begin(),P.end());
  for(auto p : P)cout<<p.second<<endl;
  return 0;
}

Measured memory_bytes: 1780
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  //1 <= N <= 10000
  //0 <= A <=1000

  int N = 0, A = 0;
  cin >> N >> A;

  if (N % 500 <= A) {
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr char black= '#';
constexpr char red= 'x';

void paint(vector<string> *trial, int tmp_h, int tmp_w){
  const int H= trial->size();
  const int W= trial->at(0).size();

  int h= 0;
  while(tmp_h > 0){
    if(tmp_h & 1){
      for(int w_t=0; w_t<W; w_t++){
        trial->at(h).at(w_t)= red;
      }
    }
    tmp_h>>= 1;
    h++;
  }

  int w= 0;
  while(tmp_w > 0){
    if(tmp_w & 1){
      for(int h_t=0; h_t<H; h_t++){
        trial->at(h_t).at(w)= red;
      }
    }
    tmp_w>>= 1;
    w++;
  }
}

int count(vector<string> &trial){
  const int H= trial.size();
  const int W= trial.at(0).size();

  int cnt= 0;
  for(int h_t=0; h_t<H; h_t++){
    for(int w_t=0; w_t<W; w_t++){
      if(trial.at(h_t).at(w_t)==black){
        cnt++;
      }
    }
  }

  return cnt;
}

int main(){
  int H,W,K;
  cin >> H >> W >> K;

  vector<string> board(H);
  for(int i=0; i<H; i++){
    cin >> board.at(i);
  }

  int ans= 0;
  for(int tmp_h=0; tmp_h< (1<<H); tmp_h++){
    for(int tmp_w=0; tmp_w< (1<<W); tmp_w++){
      vector<string> trial= board;
      paint(&trial, tmp_h, tmp_w);

      if(count(trial)==K){ ans++; }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll MOD = 1e9 + 7;
//vector<ld> vec;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
    int n,m;
    cin>>n>>m;
    UnionFind tree(n);
    vector<int> vec;
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        tree.unite(x,y);
        if(x==y){
            vec.push_back(x);
        }
    }
    set<int> s1;
    set<int> s2;
    rep(i,n){
        s1.insert(tree.root(i));
    }
    rep(i,vec.size()){
        s2.insert(vec[i]);
    }
    cout<<s1.size()-s2.size()<<endl;
}
    


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

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()

from bisect import bisect_left,bisect_right
ans = 0
for i in range(n):
    pos_a = bisect_left(a,b[i])
    pos_c = bisect_right(c,b[i])
    ans += pos_a*(n-pos_c)

print(ans)

Measured memory_bytes: 29344