akhauriyash/Code-Regression huggingface dataset:
import sys,math,itertools,bisect,copy,re

from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint
# 10倍速いらしい
input = sys.stdin.readline

INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

N,M = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]


# Union Find
# N = 100
PARENT = list(range(N))

def root(n):
    if PARENT[n] == n:
        return n
    else:
        ret = root(PARENT[n])
        PARENT[n] = ret
        return ret

def same(n1, n2):
    return root(n1) == root(n2)

def unite(n1, n2):
    n1 = root(n1)
    n2 = root(n2)
    if n1 == n2:
        return
    PARENT[n1] = n2

for _ in range(M):
    x, y = [int(x) for x in input().split()]
    x -= 1
    y -= 1
    unite(x,y)

# print(PARENT)

D1 = dict()
D2 = dict()

for i in range(N):
    grp = root(i)
    s1 = D1.get(grp, set())
    s1.add(i+1)
    D1[grp] = s1

    s2 = D2.get(grp, set())
    s2.add(P[i])
    D2[grp] = s2

# print(D1)
# print(D2)

ans = 0
for grp in set(PARENT):
    s1 = D1.get(grp, set())
    s2 = D2.get(grp, set())
    ans += len(s1 & s2)

print(ans)
    

    


Measured memory_bytes: 82000
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

ll gcd(ll a,ll b) { return a?gcd(b%a,a):b; }
signed main() {
    int n,k;
    cin>>n>>k;
    vi a(n);
    cin>>a;
    sort(ALL(a));
    if(find(ALL(a),k)!=end(a)) {
        cout<<"POSSIBLE"<<endl;
        return 0;
    }
    if(a[n-1]<k) {
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }

    int g=a[0];
    REP(i,n) g=gcd(g,a[i]);
    if(k%g==0) {
        cout<<"POSSIBLE"<<endl;
    }
    else {
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


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

int main()
{
  int num;
  cin >> num;
  
  int diameter;
  vector<int> diameters;
  for (int i = 0; i < num; ++i)
  {
    cin >> diameter;
    diameters.push_back(diameter);
  }
  sort (diameters.begin(), diameters.end());
  
  int prev = 0;
  int count = 0;
  for (auto element = diameters.begin(); element != diameters.end(); ++element)
  {
    if (*element != prev)
    {
      count += 1;
      prev = *element;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int h,m,s,S;
    scanf("%d",&S);
    h = S/3600;
    S = S%3600;
    m = S/60;
    s = S%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2128
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
INF = 10**9

seen = set()
n = int(input())
a = [int(item) for item in input().split()]
for item in a:
    if item in seen:
        print("NO")
        exit()
    else:
        seen.add(item)
print("YES")

Measured memory_bytes: 25812
def main():
    y, x = [int(i) for i in input().split()]
    a = []
    for i in range(y):
        a.append(input().strip())

    for i in range(x):
        for j in range(y):
            link = False
            if a[j][i] == '#':
                if i-1 >= 0 and a[j][i-1] == '#':
                    link = True
                if i+1 < x and a[j][i+1] == '#':
                    link = True
                if j-1 >= 0 and a[j-1][i] == '#':
                    link = True
                if j+1 < y and a[j+1][i] == '#':
                    link = True

                if not link:
                    print('No')
                    return

    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 39664
use proconio::input;
use proconio::marker::Usize1;
use std::cmp;

fn main() {
    input! {
        n: usize,
        k: usize,
        p: [Usize1; n],
        c: [isize; n],
    }

    let mut max = std::isize::MIN;
    for start in 0..n {
        let mut visited = vec![None; n];
        let mut pos = start;
        let mut score = 0;
        let mut max_score = std::isize::MIN;
        visited[start] = Some(0);

        for j in 1..=k {
            //move
            pos = p[pos];
            score += c[pos];
            if let Some(j_prev) = visited[pos] {
                if score < 0 {
                    max = cmp::max(max, max_score);
                } else {
                    max = cmp::max(max, max_score);
                    let interval = j - j_prev;
                    let times = k / interval;
                    let remain = k % interval;
                    //println!("interval {} times {} remain {}", interval, times, remain);
                    score = score * (times - 1) as isize;
                    max = cmp::max(max, score);
                    pos = start;
                    score += c[pos];
                    max = cmp::max(max, score);
                    for _ in 0..remain + interval - 1 {
                        pos = p[pos];
                        score += c[pos];
                        max = cmp::max(max, score);
                    }
                }
                break;
            } else {
                visited[pos] = Some(j);
                max_score = cmp::max(max_score, score);
                max = cmp::max(max, max_score);
            }
        }
    }

    println!("{}", max);
}


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

int main(void) {
	int D;
	cin >> D;
	if (D == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	else if (D == 23) {
		cout << "Christmas Eve Eve" << endl; 
	}
	else if (D == 24) {
		cout << "Christmas Eve" << endl;
	}
	else {
		cout << "Christmas" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

readline = stdin.buffer.readline

INF = 10 ** 10

N = int(readline())

if N % 10 in [2, 4, 5, 7, 9]:
    print("hon")
elif N % 10 in [0, 1, 6, 8]:
    print("pon")
else:
    print("bon")



Measured memory_bytes: 72656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    int r, g, b, n;
    cin>>r>>g>>b>>n;
    int ans=0;
    for(int R=0;R<=n;R++){
        for(int G=0;G<=n;G++){
            int B=(n-r*R-g*G);
            if(B>=0 && B%b==0) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define INF 1010101010

int hayamin(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 :a > b;
}

int za_cnt;
int za[212345];

void zai(int num) {
	int i;
	qsort(za, num, sizeof(*za), hayamin);
	za_cnt = 1;
	for (i = 1; i < num; i++) {
		if (za[za_cnt - 1] != za[i]) za[za_cnt++] = za[i];
	}
}

int zaq(int q) {
	int left = 0, right = za_cnt - 1;
	while (left <= right) {
		int m = left + (right - left) / 2;
		if (za[m] == q) return m;
		else if (za[m] < q) left = m + 1;
		else right = m - 1;
	}
	printf("ERROR: %d not found\n", q);
	exit(2);
}

#define KI_MAX (1 << 18) /* 262144 */

int ki_left[KI_MAX * 2 - 1], ki_right[KI_MAX * 2 - 1];

int asumisu(int a, int b) {
	return a >= b ? a : b;
}

void ki_set(int* ki, int idx, int value) {
	int pos = idx + (KI_MAX - 1);
	ki[pos] = asumisu(ki[pos], value);
	do {
		pos = (pos - 1) / 2;
		ki[pos] = asumisu(ki[pos * 2 + 1], ki[pos * 2 + 2]);
	} while (pos > 0);
}

int ki_get_i(const int* ki, int idx, int qs, int qe, int ss, int se) {
	if (qe <= ss || se <= qs) { /* 完全にはずれ */
		return -INF;
	} else if (qs <= ss && se <= qe) { /* セグメントがクエリに完全に含まれる */
		return ki[idx];
	} else {
		int sm = ss + (se - ss) / 2;
		int left = ki_get_i(ki, idx * 2 + 1, qs, qe, ss, sm);
		int right = ki_get_i(ki, idx * 2 + 2, qs, qe, sm, se);
		return asumisu(left, right);
	}
}

int ki_get(const int* ki, int qs, int qe) {
	return qs < qe ? ki_get_i(ki, 0, qs, qe, 0, KI_MAX) : -INF;
}

struct zahyo_t {
	int x, y;
};

int miyukiti(const void* x, const void* y) {
	struct zahyo_t a = *(const struct zahyo_t*)x, b = *(const struct zahyo_t*)y;
	if (a.y != b.y) return a.y < b.y ? -1 : a.y > b.y;
	return a.x < b.x ? -1 : a.x > b.x;
}

int N;
struct zahyo_t ten[212345];

int main(void) {
	int i;
	int answer = -INF;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &ten[i].x, &ten[i].y) != 2) return 1;
		za[i] = ten[i].x;
	}
	zai(N);
	qsort(ten, N, sizeof(*ten), miyukiti);
	for (i = 0; i < KI_MAX * 2 - 1; i++) {
		ki_left[i] = ki_right[i] = -INF;
	}
	for (i = 0; i < N; i++) {
		int idx = zaq(ten[i].x);
		int left = ki_get(ki_left, 0, idx + 1);
		int right = ki_get(ki_right, idx, za_cnt);
		if (left > -INF && left + ten[i].x + ten[i].y > answer) answer = left + ten[i].x + ten[i].y;
		if (right > -INF && right - ten[i].x + ten[i].y > answer) answer = right - ten[i].x + ten[i].y;
		ki_set(ki_left, idx, -ten[i].x - ten[i].y);
		ki_set(ki_right, idx, ten[i].x - ten[i].y);
	}
	printf("%d\n", answer);
	return 0;
}

/*

..A..
.....
...B.
.....
12345

1 : A > B
2 : A > B
3 : A > B
4 : A > B
5 : A > B

..A..
...B.
.....
12345

1 : A = B
2 : A = B
3 : A = B
4 : A > B
5 : A > B

...A.
..B..
.....
12345

1 : A > B
2 : A > B
3 : A > B
4 : A = B
5 : A = B

...A.
.B...
.....
12345

1 : A > B
2 : A > B
3 : A > B
4 : A < B
5 : A < B

*/

/*

ある場所から見て
左にある → 左にあるほどボーナス → スコア = y差 - 既存x + 新規x
右にある → 右にあるほどボーナス → スコア = y差 + 既存x - 新規x
(同じ列を含む)

「y差 ± 既存x」の最大値を管理する

*/



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

main(){
	
	int n,m,pos,p=0 ;
	int x[20010] ;
	cin >> n >> m >> pos ;
	for( int i=1 ; i<=m ; i++ ) cin >> x[i] ;
	x[0] = pos ;
	sort(x,x+m+1) ;
	for( int i=1 ; i<2*(m+1) ; i++ ){
		if( i > m ) x[i] = x[i-m-1] + n ;
		if( x[i] == pos ) p = i ;
	}
	
	int ans = x[p+m+1] - x[p+1] ;
	int sum1,sum2 ;
	for( int i=1 ; i<=m ; i++ ){
		sum1 = x[p+i] - x[p] ;
		sum2 = x[p+m+1] - x[p+i+1] ;
		if( sum1 > sum2 ) sum2 *= 2 ;
		else sum1 *= 2 ;
		ans = min( ans , sum1+sum2 ) ;
	}
	
	cout << ans*100 << endl ;
}

Measured memory_bytes: 1256
n,x=map(int,input().split())
l=[]
for i in range(n+1):
  l.append(2**(i+1)-1)
m=[]
for i in range(n+1):
  m.append(2**(i+2)-3)
c=0
for i in range(n,-1,-1):
  if x<2**(i+1)-1:
    x-=1
  elif x==2**(i+1)-1:
    if i!=0:
      c+=l[i-1]+1
    elif i==0:
      c+=1
    x=0
  elif x>2**(i+1)-1:
    if i!=0:
      c+=l[i-1]+1
    elif i==0:
      c+=1
    elif x==m[i]:
      x-=1
    x=x-(2**(i+1)-1)
print(c)

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

typedef long long ll;
const int limit = 100010;
using edge = struct { int to; ll cost; };
vector<edge> tree[limit];
ll depth[limit];

 void dfs(int v, int p, ll d) {
	 depth[v] = d;
	 for (auto& e : tree[v]) {
		 if (e.to == p) continue;
		 dfs(e.to, v, d + e.cost);		
	}
	
}


 int main(void) {
	 int n;
	 cin >> n;
	 for (int i = 0; i < n - 1; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		tree[a].push_back({ b, c });
		tree[b].push_back({ a, c });
	}	 
	 int q, k;
	 cin >> q >> k;
	 k--;
	
	dfs(k, -1, 0);
	for (int i = 0; i < q; ++i) {
		 int x, y;
		 cin >> x >> y;
		 x--, y--;
		 cout << depth[x] + depth[y] << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 14336
#include<iostream>
using namespace std;
int main(){
  int n,i;
  cin>>n;
  string s;
  cin>>s;
  for(i=0;i<s.size();i++){
    s[i]=s[i]+n;
    if(s[i]>90){
      s[i]=64+(s[i])%90;
    }
  }
  for(i=0;i<s.size();i++){
    cout<<s[i];
  }
  return 0;
}

Measured memory_bytes: 256
#include <queue>

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define FOR(i, l, r) for(int i = (l); i <= (r); i++)
#define REP(i, l, r) for(int i = (l); i != (r); i++)
#define DFR(i, l, r) for(int i = (l); i >= (r); i--)
#define DRP(i, l, r) for(int i = (l); i != (r); i--)

using namespace std;

#define DEBUG(arg...) fprintf(stderr, arg)

namespace FI {
	const int SIZE = 1 << 18 | 1;
	char buf[SIZE], *front, *back;

	void NextChar(char &c) {
		if(front == back) back = (front = buf) + fread(buf, 1, SIZE, stdin);
		c = (front == back) ? (char)EOF : *front++;
	}

	template<typename T> void NextNum(T & x) {
		char c; int f = 1;
		for(NextChar(c); c > '9' || c < '0'; NextChar(c)) if(c == '-') f = -1;
		for(x = 0; c >= '0' && c <= '9'; NextChar(c)) x = (x << 3) + (x << 1) + c - '0';
		x *= f;
	}
}

typedef long long LL;

const int maxn = 100000 + 47;

int n;
bool vis[maxn];
deque<pair<int, int> > q;

int main() {
	scanf("%d", &n);
	q.push_front(make_pair(1, 1));
	while(!q.empty()) {
		pair<int, int> now = q.front(); q.pop_front();
		if(now.first == 0) {
			printf("%d\n", now.second);
			return 0;
		}
		if(vis[now.first]) continue;
		vis[now.first] = true;
		q.push_front(make_pair(now.first * 10 % n, now.second));
		q.push_back(make_pair((now.first + 1) % n, now.second + 1));
	}

	return 0;
}


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

int main() {
    int N;
    cin >> N;
    map<string, int> result;
    for(int i = 0; i < N; i++) {
        string tmp;
        cin >> tmp;
        result[tmp] += 1;
    }

    int max_cnt = 0;
    for (auto p : result) {
        if (max_cnt < p.second) max_cnt = p.second;
    }

    for (auto p: result) {
        if (p.second == max_cnt) cout << p.first << endl;
    }
}

Measured memory_bytes: 25216
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int n,p[111],q[111],r[111],b[111];

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

int f(int cur){
	if(cur==-1)return 1;
	int left=f(r[cur]),right=f(b[cur]);
	int g=gcd(left*p[cur],right*q[cur]);
	return right*q[cur]/g*left+left*p[cur]/g*right;
}

int main2(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n;
	if(n==0)return 1;
	int appear[111]={};
	rep(i,n){
		cin>>p[i]>>q[i]>>r[i]>>b[i];
		//int g=gcd(p[i],q[i]);
		//p[i]/=g,q[i]/=g;
		r[i]--,b[i]--;
		if(r[i]!=-1)appear[r[i]]=1;
		if(b[i]!=-1)appear[b[i]]=1;
	}
	int par;
	rep(i,n)if(!appear[i])par=i;
	cout<<f(par)<<endl;
	return 0;
}

int main(){
	while(!main2());
}

Measured memory_bytes: 1192
#include <vector>
#include <cstdio>
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	std::vector<int>v(n+1),w(k);
	for(int i=0;i<k;i++)scanf("%d",&w[i]);
	for(int i=k-1;i>=0;i--)if(!v[w[i]])v[w[i]]=1,printf("%d\n",w[i]);
	for(int i=1;i<=n;i++)if(!v[i])printf("%d\n",i);
}

Measured memory_bytes: 3424
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m, p;
int pos;
char str[10000];
map<string, vector<int> > mapto;
map<vector<int>, string> mapfrom;
map<string, string> convert;
vector<int> error;

vector<int> formula();
vector<int> factor() {
  vector<int> lhs;
  if (str[pos] == '(') {
    pos++;
    lhs = formula();
    if (str[pos] != ')') { return error; }
    pos++;
  } else {
    if (!isalpha(str[pos])) { return error; }
    string s;
    while (isalpha(str[pos])) { s += str[pos++]; }
    if (!convert.count(s)) { return error; }
    if (!mapto.count(convert[s])) { return error; }
    lhs = mapto[convert[s]];
  }
  return lhs;
}

vector<int> term() {
  vector<int> lhs = factor();
  if (lhs == error) { return error; }
  while (str[pos] == '*' || str[pos] == '/') {
    int s = str[pos] == '*' ? 1 : -1;
    pos++;
    vector<int> rhs = factor();
    if (rhs == error) { return error; }
    REP(i, n) {
      lhs[i] += s * rhs[i];
    }
  }
  return lhs;
}

vector<int> formula() {
  vector<int> lhs = term();
  if (lhs == error) { return error; }
  while (str[pos] == '+' || str[pos] == '-') {
    pos++;
    vector<int> rhs = term();
    if (rhs == error) { return error; }
    REP(i, n) {
      if (lhs[i] != rhs[i]) { return error; }
    }
  }
  return lhs;
}

int main() {
  error = vector<int>(1, -1000000000);
  while (scanf("%d %d %d", &n, &m, &p), n|m|p) {
    pos = 0;
    mapto.clear();
    mapfrom.clear();
    REP(i, m) {
      string s;
      cin >> s;
      vector<int> vect(n, 0);
      REP(i, n) {
        scanf("%d", &vect[i]);
      }
      mapto[s] = vect;
      mapfrom[vect] = s;
    }
    scanf("%s", str);
    REP(i, p) {
      string from, to;
      cin >> from >> to;
      convert[from] = to;
    }
    vector<int> ans = formula();
    if (ans[0] <= -100000) {
      puts("error");
    } else if (mapfrom.count(ans)) {
      printf("%s\n", mapfrom[ans].c_str());
    } else {
      puts("undefined");
    }
  }
}

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

int main() {
    int d;
    cin >> d;
    switch (d) {
        case 25 : cout << "Christmas" << endl;
            break;
        case 24 : cout << "Christmas Eve" << endl;
            break;
        case 23 : cout << "Christmas Eve Eve" << endl;
            break;
        case 22 : cout << "Christmas Eve Eve Eve" << endl;
            break;
    }
}


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

def solve(num, checker):
    return checker*(num//checker)

max_A = max(a)

left, right = 0, k*max_A + 1
while left < right:
    middle = (left+right)//2
    num = middle
    for i in a:
        num = solve(num, i)
    if num >= 2:
        right = middle
    else:
        left = middle + 1
x = right

left, right = 0, k*max_A + 1
while left < right:
    middle = -((-left-right)//2)
    num = middle
    
    for i in a:
        num = solve(num, i)
    if num <= 2:
        left = middle
    else:
        right = middle - 1
        
y = right

if y < x:
    print(-1)
else:
    print(x, y)

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

//#define int long long
#define DBG 0
#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() {
	for (int N; cin >> N&&N;) {
		int W, H; cin >> W >> H;
		vector<vector<char>> v(H, vector<char>(W, false));
		rep(i, 0, N) {
			int x, y; cin >> x >> y;
			x--, y--;
			v[y][x] = true;
		}
		int S, T; cin >> S >> T;
		int ans = 0;
		rep(i, 0, H - T + 1) {
			dump(i);
			rep(j, 0, W - S + 1) {
				int tmp = 0;
				rep(ii, i, i + T) {
					rep(jj, j, j + S) {
						if (v[ii][jj])tmp++;
					}
				}
				ans = max(ans, tmp);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else if(a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
fun main(args: Array<String>){
    
    val n = readLine()!!.toInt()

    var ans = mutableListOf<Int>()
    
    var tmp = 0
    var i = 1

    while (tmp < n){
        tmp += i
        ans.add(i)
        i++
    }
    
    var avoid = tmp - n
    for (a in ans) { if (avoid != a) { println(a) } }
}

Measured memory_bytes: 33904
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int a, b;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> b;
	cout << (a-1)*(b-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T>
using normal_queue = priority_queue<T, vector<T>, greater<T>>;

#define int long long

bool check(int x, int n, vector<int>& a) {
    int cnt = 0, nw = 0;
    ordered_set<pair<int, int>> c;
    c.insert({0, 0});
    for (int i = 0; i < n; ++i) {
        if (a[i] >= x) {
            nw++;
        } else {
            nw--;
        }
        cnt += c.order_of_key({nw, n + 10});
        c.insert({nw, i + 1});
    }
    return cnt >= (n * (n + 1) / 2 + 1) / 2;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int l = -1, r = 1e9 + 10;
    while (r - l > 1) {
        //cout << l << " " << r << " >\n";
        int m = (l + r) / 2;
        if (check(m, n, a)) {
            l = m;
        } else {
            r = m;
        }
    }
    cout << l << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 7296
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;
 
int main() {
    int n;
    cin >> n;
    vi a(n+10);
    rep(i,n) cin >> a[i];
    a[n] = 1;
    ll sum[200010] = {};
    for(int i = n-1; i >= 0; i--) (sum[i] += a[i]+sum[i+1]) %= MOD;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        (ans += a[i]*sum[i+1]) %= MOD;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5604
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	//vector<int> dp(n, INT_MAX);
	//for (int i = 0; i < n; i++) {
	//	*lower_bound(begin(dp), end(dp), p[i]) = p[i];
	//}

	vector<int> dp(n + 1);
	for (int i = 0; i < n; i++) {
		int p;
		cin >> p;

		dp[p] = dp[p - 1] + 1;
	}

	cout << n - *max_element(begin(dp), end(dp)) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	string S;

	cin >> S;
	string ans = "Yes";

	for (int i = 0; S[i]; i++)
	{
		if (i % 2 == 0 && S[i] == 'L')
			ans = "No";
		if (i % 2 == 1 && S[i] == 'R')
			ans = "No";
	}
	cout << ans << endl;
}



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

int main(){
	vector<int> a(5,0);
	for(int i=0;i<3;i++){
		int b,c;
		cin>>c>>b;
		a[b]++;
		a[c]++;
	}
	int cnt1 = 0,cnt2=0;
	for(int i=1;i<5;i++){
		if(a[i]==1)cnt1++;
		if(a[i]==2)cnt2++;
	}
	if(cnt1==2&&cnt2==2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}



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

int main(){
  int n, m, xx, yy;
  cin >> n >> m >> xx >> yy;
  int x[100010];
  int y[100010];

  for(int i = 0;i < n;i++){
    cin >> x[i];
  }

  for(int j = 0;j < m;j++){
    cin >> y[j];
  }

  x[n] = xx;
  y[m] = yy;

  n++;
  m++;
  sort(x, x+n);
  sort(y, y+m);

  if(x[n-1] < y[0]){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
s = input()

s_list = [int(x) for x in list(s)]

a = s_list[0]*10+s_list[1]
b = s_list[2]*10+s_list[3]

form = ['YYMM', 'MMYY', 'AMBIGUOUS', 'NA']

if (a > 12 or a == 0) and (b < 13 and b > 0):
    result = 'YYMM'
elif (a < 13 and a > 0) and (b > 12 or b == 0):
    result = 'MMYY'
elif (a <= 12 and a > 0) and (b <= 12 and b > 0):
    result = 'AMBIGUOUS'
else:
    result ='NA'
    
print(result)

Measured memory_bytes: 3064
import sys
input=sys.stdin.readline
 
N,M = map(int, input().split())
 
pref = [[0] for i in range(N+1)]
import collections
q = collections.deque()
 
for i in range(M):
    p,y = map(int, input().split())
    pref[p].append(y)
    q.append((p,y))
for p in pref:
    p.sort()
 
import bisect
for p,y in q:
    print("%06d%06d" %(p, bisect.bisect_left(pref[p], y)))

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

typedef long long ll;

using namespace std;

vector<vector<ll> > vc;


int main(){

    ll N,Q;
    cin>>N>>Q;
    vc.resize(N);

    
    ll a,b;

    for(ll i=0;i<N-1;++i){
        cin>>a>>b;
        --a;--b;
        vc[a].push_back(b);
        vc[b].push_back(a);
    }
    vector<ll> ans(N,0);
    vector<bool> vis(N,false);

    ll p,x;

    for(ll i=0;i<Q;++i){
        cin>>p>>x;
        --p;
        ans[p]+=x;
    }
       
        stack<ll> st;
        st.push(0);
        
        while(!st.empty()){
            ll now=st.top();
           // cout<<"p: "<<p<<endl;
            st.pop();
            vis[now]=true;

            for(ll j=0;j<vc[now].size();j++){
                ll next=vc[now][j];
                if(vis[next]!=true){
                st.push(next);
                ans[next]+=ans[now];
                }
            }
        }


    for(ll i=0;i<N;++i){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 19044
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        let _ = io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line()
            .split_whitespace()
            .map(|s| s.to_string())
            .collect()
    }

    #[allow(dead_code)]
    pub struct Reader {
        buf: VecDeque<String>,
    }

    #[allow(dead_code)]
    impl Reader {
        pub fn new() -> Reader {
            Reader { buf: VecDeque::new() }
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T
            where
                T: FromStr,
                T::Err: Debug,
        {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn next_n<T>(&mut self, n: usize) -> Vec<T>
            where
                T: FromStr,
                T::Err: Debug,
        {
            let mut vec: Vec<T> = Vec::with_capacity(n);

            for _ in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}

#[allow(unused_macros)]
macro_rules! p {
    ([$($x:expr), *]) => {{
        let mut f = true;
        $(
            print!("{}{}", if f {""} else {" "}, $x);
            f = false;
        )*
        print!("\n");
    }};
    ($x:expr) => {{
        let mut f = true;
        for a in $x.iter() {
            print!("{}{}", if f {""} else {" "}, a);
            f = false;
        }
        print!("\n");
    }};
}

trait ToChars {
    fn to_chars(&self) -> Vec<char>;
}

impl ToChars for String {
    fn to_chars(&self) -> Vec<char> {
        self.chars().collect::<Vec<char>>()
    }
}

fn main() {
    let mut rd = reader::Reader::new();

    let n = rd.next();
    let p: usize = rd.next();
    let a: Vec<i64> = rd.next_n(n);

    let mut dp: Vec<Vec<i64>> = vec![vec![0; 2]; n+1];

    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..2 {
            dp[i+1][j] += dp[i][j];
            dp[i+1][j^(a[i]&1) as usize] += dp[i][j];
        }
    }
    p!([dp[n][p]]);
}

Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1'000'000'007;

ll N;
string S;
ll memo[26];

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

    ll ans=1;
    rep(i,N){
        memo[S[i]-'a']++;
    }
    rep(i,26){
        ans*=memo[i]+1;
        ans%=MOD;
    }
    ans--;

    cout<<ans<<endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD ((int)1e+9 + 7)

int N;
vector<int> A;

signed main() {
  cin >> N;
  A.resize(N);
  for(int i=0; i<N; i++) cin >> A[i];

  vector<int> bbb(60,0);
  for(int b=0; b<60; b++) {
    for(int i=0; i<N; i++) 
      if( (1LL<<b) & A[i] ) 
        bbb[b]++;
  }

  int ans = 0; 

  for(int b=0; b<60; b++) {
    ans = (ans + (((bbb[b] * (N-bbb[b]))%MOD)*((1LL<<b)%MOD))%MOD) % MOD;
  }
  cout << ans << endl;
}


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

using namespace std;

string s;
int K;

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

  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a') continue;
    cnt = 'z' - s[i] + 1;
    if (cnt <= K) {
      s[i] = 'a';
      K -= cnt;
    }
  }

  if (K != 0) {
    K %= 26;
    cnt = 'z' - s.back();
    if (cnt < K) {
      K -= cnt;
      s.back() = 'a' + K;
    } else {
      s.back() = s.back() + K;
    }
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    ll ans = 0ll;
    REP(i,n) {
        int c = 0;
        while (a[i]%2 == 0) {
            c++;
            a[i] /= 2;
        }
        ans += c;
    }
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
using namespace std;
#define MAX 500005
#define MOD 1000000007
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=0;i<3;i++)
    {
        if(n%10==7) break;
        n=n/10;
    }
    if(i<3)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 3748
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}



Measured memory_bytes: 26212
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

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

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * c, max(a * d, max(b * c, b * d))) << "\n";
	return 0;
}


Measured memory_bytes: 3664
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [(String,Int, [Int])] -> [String]
solve [] = []
solve ((w,n,sl):xs) = (suffle w sl):solve xs where
    suffle w [] =  w
    suffle w (s:sl) = suffle (drop s w ++ take s w) sl

readUntil :: (String -> Bool) -> IO [(String,Int, [Int])]
readUntil eof = iter where
    iter = getLine >>= (\w -> 
            if eof w then return []
                     else do
                        n <- readLn
                        ls <- replicateM n getLine
                        let l = map read ls
                        fmap ((w,n,l):) iter)

eof :: String -> Bool
eof s = s == "-"

main :: IO() 
main = do
    l   <- readUntil eof
    mapM_ putStrLn (solve l)



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

int main(){
  string s;
  cin >> s;
  char a, b;
  if (s.at(0) == '1'){
    a = '1';
    b = '0';
  }
  else{
    a = '0';
    b = '1';
  }
  int ans = 0;
  for (int i = 0; i < s.size(); i += 2){
    if (s.at(i) != a){
      ans += 1;
    }
  }
  for (int i = 1; i < s.size(); i += 2){
    if (s.at(i) != b){
      ans += 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    long long P=1000000007LL;
    long long ans=1;
    //素数をキーにかかってる個数をmap
    map<int,int> primes;
    set<int> prime;
    rep2(i,2,N+1){
    int tmp=i;
        rep2(j,2,i+1){
            if(tmp%j==0){
                while(tmp%j==0){
                    prime.insert(j);
                    tmp=tmp/j;
                    if(primes.count(j)){
                        primes[j]++;
                    }else{
                        primes[j]=1;
                    }
                }
            }else{
                continue;
            }
        }
    }
    // cout << primes.size() << endl;    
    rep(i,1000){
        if(primes.count(i)){
            ans=(ans*(primes[i]+1))%P;
        }else{
            continue;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n,k,c=MI()
	s=RD()

	A=[]
	now=0

	while now<n and len(A)<k:
		if s[now]=="o":
			A.append(now+1)
			now+=c+1
		else:
			now+=1
	#print(A)

	B=[]
	now=0
	while now<n and len(B)<k:
		if s[n-1-now]=="o":
			B.append(n-now)
			now+=c+1
		else:
			now+=1


	ans=[]
	for i,j in zip(A,B[::-1]):
		if i==j:
			ans.append(i)

	print(*ans,sep="\n")










if __name__ == "__main__":
	main()


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

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    
    double TotalPoint=0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        TotalPoint+=a[i];
    }

    sort(a.begin(),a.end());
    
    if(a[n-m]>=TotalPoint/(4*m)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N+1);
  for (int i = 1; i <= N; i++) cin >> A.at(i);
  bool flag = false;
  int cnt = 0;
  int index = 1;
  for (int i = 0; i < N; i++) {
    cnt++;
    index = A.at(index);
    if (index == 2) {
      flag = true;
      cout << cnt << endl;
      break;
    }
  }
  if (!flag) cout << -1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 998244353;
const ll INF = 1e9;
const ll MAXN = 1e9;

vector<ll> fact,inv;

ll f(ll a,ll b, ll p)  // a^b mod pを求める
{
	if (b == 0)
	{
		return 1;
	}else if (b % 2 == 0)
	{
		ll d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return d * d % mod;
	}else
	{
		return a * f(a,b-1,p) % mod;
	}
}

void init(ll n)
{
	fact.resize(n+1,1);
	inv.resize(n+1,1);

	for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
	{
		fact[i] = fact[i-1] * i % mod;
	}
	for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
	{
		inv[i] = f(fact[i],mod-2,mod) % mod;
	}
}

ll comb(ll n,ll k)  //n_C_k
{
	if (n < k)
	{
		return 0;
	}
	return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}

int main()
{
	ll N,A,B,K;
	cin>>N>>A>>B>>K;

	init(N);

	ll ans = 0;
	for(ll i = 0; i <= N; i++){
		if((K-i*A)%B==0){
			ll j = (K-i*A)/B;
			if(j<0 || j>N) continue;
			ans += comb(N,i)*comb(N,j)%mod;
			ans %= mod;
		}
	}
	cout << ans << endl;

	return 0;
}

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

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

    int N, K;
    string S;
    cin >> N >> S >> K;
    char c = S[K - 1];

    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != c)
        {
            cout << "*";
        }
        else
        {
            cout << c;
        }
    }
    cout << endl;

    return 0;
}

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

struct S
{
    int id;
    int numInClass;
};

int main() 
{
    //std::cout<<std::fixed<<std::setprecision(10);

    int N;

    cin >> N;

    vector<S> students;
    students.resize(N);
    
    for(int i=0; i<N; ++i)
    {
        students[i].id = i+1;
        cin >> students[i].numInClass;
    }

    sort(students.begin(), students.end(), [](const S& a, const S& b) {
        return a.numInClass < b.numInClass;
    });
    
    for(int i=0; i<N; ++i)
    {
        cout << students[i].id;
        if(i!=N-1) 
        {
            cout << " ";
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int r = 0, k = 0;
    for (char c : s) {
        if (c == 'A' || c == 'T' || c == 'C' || c == 'G') k++; else k = 0;
        r = max(r, k);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int y = s.nextInt();
        boolean f = false;
        int i = 0;
        int j = 0;
        int k = 0;
        for (i = 0; i <= n; i++) {
            for (j = 0; j <= (n - i); j++) {
                k = n - i - j;
                if (y == 10000 * i + 5000 * j + 1000 * k) {
                    if (n == i + j + k ) {
                        f = true;
                        break;
                    }
                }
            }
            if (f) {
                break;
            }
        }
        if (f) {
            System.out.println(i + " " + j + " " + k);
        } else {
            System.out.println("-1 -1 -1");
        }
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,w;
	cin>>n>>w;
	int a[n],b[n];
	for(int i=0;i<n;i++)
	cin>>a[i]>>b[i];
	long long int **dp=new long long int *[n+1];
	for(int i=0;i<=n;i++)
	{
		dp[i]=new long long int [w+1];
		for(int j=0;j<=w;j++)
		dp[i][j]=0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(a[i-1]<=j)
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1]]+b[i-1]);
			else
			dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w];
	
}

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

#define ms(a,b) memset(a, b, sizeof(a))
#define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++)
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define m_p(a,b) make_pair(a, b)
#define lson l,mid,o << 1
#define rson mid + 1,r,o << 1 | 1
#define ls o << 1
#define rs o << 1 | 1
#define inf 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

inline bool isdigit(char& ch) {
	return ch >= '0' && ch <= '9';
}
template<class T>
void read(T &x) {
	x = 0;
	ll f = 1;char ch = getchar();
	for (;!isdigit(ch);ch = getchar()) 
		if (ch == '-') f = -1;
	for (; isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + ch - '0';
	x *= f;
}
template<class T>
inline void write(T x) {
	if (x == 0) {putchar('0');return ;}
	if (x < 0) {putchar('-');x = -x;}
	int _stk[65],_top = 0;
	for (;x;x /= 10) _stk[++_top] = x % 10 + 48;
	for (;_top;_top--)putchar(_stk[_top]);
}

int arr[105];
bool use[505];
int n, x;
int main () {
	cin >> x >> n;
	rep(i, 1, n + 1) {
		cin >> arr[i];
		use[arr[i]] = 1;
	}
	int ans = -1;
	int pos = x, p2 = x;
	while(pos >= 0) {
		if (use[pos])
			pos--;
		else
			break;
	}
	while(p2 <= 101) {
		if (use[p2])
			p2++;
		else
			break;
	}
	int d1 = x - pos, d2 = p2 - x;
//	cout << d1 << " " << d2 << endl;
//	cout << pos << " " << p2 << endl;
	if (d1 <= d2)
		cout << pos;
	else
		cout << p2;
	return 0;
}

Measured memory_bytes: 3624
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ARangeFlipFindRoute {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int H, W;
        in>>H>>W;
        vc<string> grid(H);
        REP(i, H) in>>grid[i];
        vvc<int> dp(H, vc<int>(W, ten(9)));
        dp[0][0] = grid[0][0] == '#' ? 1 : 0;
        REP(i, H) REP(j, W){
            if(j<W-1){
                if(grid[i][j]=='.' and grid[i][j+1]=='#') chmin(dp[i][j+1], dp[i][j]+1);
                else chmin(dp[i][j+1], dp[i][j]);
            }
            if(i<H-1){
                if(grid[i][j]=='.' and grid[i+1][j]=='#') chmin(dp[i+1][j], dp[i][j]+1);
                else chmin(dp[i+1][j], dp[i][j]);
            }
        }
        out<<dp[H-1][W-1]<<'\n';
    }
};


int main() {
	ARangeFlipFindRoute solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384