akhauriyash/Code-Regression huggingface dataset:
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> p(n);
    for(int& x : p) {
        cin >> x;
        --x;
    }
    vector<int> a(n, 1);
    for(int i : in(n)) a[i] += 30000 * i;
    auto b = a;
    reverse(b.begin(), b.end());
    int cnt = 0;
    for(int x : p) {
        a[x] += cnt;
        b[x] += cnt;
        ++cnt;
    }
    for(int i : in(n)) cout << a[i] << (i == n - 1 ? '\n' : ' ');
    for(int i : in(n)) cout << b[i] << (i == n - 1 ? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int res=0;
  cin >> n;
  for (int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    if(i%2==0&&tmp%2!=0){
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
using namespace std;


int main()
{
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N;
    int A;
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        cin >> A;
        if (A % 2 == 0) {
            if (A % 3 != 0 && A % 5 != 0) {
                cout << "DENIED";
                return 0;
            }
        }
    }

    cout << "APPROVED";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ma 100010
int n,m,c;
int oya[ma],fukasa[ma];
int p[ma],x[ma],y[ma];
int find(int i){
  if(oya[i]==i){
    return i;
  }else{
    return oya[i]=find(oya[i]);
  }
}
void unite(int i,int j){
  i=find(i);
  j=find(j);
  if(i==j) return;
  if(fukasa[i]<fukasa[j]){
    oya[i]=j;
  }else{
    oya[j]=i;
    if(fukasa[i]==fukasa[j]) fukasa[i]++;
  }
}
int main(){
  cin>>n>>m;
  for(int i=1;i<=n;i++){
    cin>>p[i];
    oya[p[i]]=p[i];
  }
  for(int i=0;i<m;i++){
    cin>>x[i]>>y[i];
    unite(x[i],y[i]);
    unite(y[i],x[i]);
  }
  for(int i=1;i<=n;i++){
    if(find(i)==find(p[i])) c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 2176
L, R = map(int, input().split())
"""
ans = 0
if R - L < 2019:
    l = L % 2019
    r = R % 2019
    if l < r:
        l_ = (L * (L + 1)) % 2019
        r_ = (R * (R - 1)) % 2019
        ans = min(l_, r_)
print(ans)
"""  

ans = 2018
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            print(ans)
            exit()

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll MAXN = 
ll a,b,k;
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> a >> b >> k;
    ll lst = 1;
    vector<ll> div;
    REP1 (i,min(a,b)) {
        if (a % i == 0 && b % i == 0) {
            div.emplace_back(i);
        }
    }
    reverse(ALL(div));
    cout << div[k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner
//
fun _Do() {
    
    var scan = Scanner(System.`in`)
    
    val N_ = scan.nextInt()
    
    var ints = Array(N_,{0})
    for (i in ints.indices) {
        ints[i] = scan.nextInt()
    }
    
    //--------
    
    var count = 0

    var prev = false
    for(i in ints.indices){
        when(prev){
            true-> prev = false
            false ->
                if( ints[i] == (i+1) ) {
                    count += 1
                    prev = true
                }
        }
    }

    println(count)
}

//
fun main( argv : Array<String> ) {
    _Do()
}

Measured memory_bytes: 57944
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val pointList = Array(200010, { 0 })
    for (i in 0 until m) {
        val (a, b) = readLine()!!.split(' ').map(String::toInt)
        if (a == 1) {
            pointList[b]++
        } else if (b == n) {
            pointList[a]++
        }

    }
    if (pointList.any { it >= 2 }) {
        println("POSSIBLE")
    } else {
        println("IMPOSSIBLE")
    }
}

Measured memory_bytes: 70792
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    int n,m;cin >> n >> m;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    ll sum = accumulate(a.begin(), a.end(), 0);
    if(a[m-1]>=(sum+4*m-1)/(4*m)){
        puts("Yes");
    } else{
        puts("No");
    }
    
    return 0;
}

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

typedef long long ll;

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

    string s; cin >> s;
    int size = s.size();
    vector<int> num(size);
    //Rだけ見る
    for(int i=0;i<2;i++){
        int cnt = 0;
        for(int j=0;j<size;j++){
            if(s[j]=='R') cnt++;
            else{
                num[j] += cnt/2;
                num[j-1] += (cnt+1)/2;
                cnt = 0;
            }
        }
        reverse(num.begin(),num.end());
        reverse(s.begin(),s.end());
        for(int j=0;j<size;j++){
            if(s[j]=='R') s[j] = 'L';
            else s[j] = 'R';
        }
    }
    for(int i=0;i<size;i++) cout << num[i] << " ";
    cout << endl;
    return 0;
}

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

int main(){
  long long a, b;
  cin >> a >> b;
  long long cnt = 0;
  if(a * 2 <= b){
    cnt += a;
    b -= 2 * a;
    a = 0;

    cnt += b / 4;
  }
  else{
    cnt = b / 2;
  }
  cout << cnt << endl;

}       

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 2005
#define SIZE 2000005
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int a[MAXN];
bitset<SIZE>b;
int main(){
	int n=read();
	b[0]=1;
	int sum=0;
	for (int i=1;i<=n;++i){
		a[i]=read();
		b|=b<<a[i];
		sum+=a[i];
	}
	for (int i=(sum+1)/2;i<=sum;++i){
		if (b[i]){
			return printf("%d\n",i),0;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F0R(i, a) for (int i=0; i<(a); i++)
int main() {
	string S; cin >> S;
	int N =S.size();
	F0R(i, N) {
		if (i % 2 == 0 && S[i] == 'L') {
			cout << "No" << endl; return 0;
		}
		if (i % 2 == 1 && S[i] == 'R') {
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,x;
  int ans=0;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==x)
          ans++;
      }
    }
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
#define m (1000000007)
constexpr int mul(int a,int b){
  return ((a%m)*(b%m))%m;
}
int f(int k, vector<vector<int>>& v, int s, int s0){
  int kf=k-2+!(s0+1),c=1;
  if(k<v[s].size())return 0;
  for(auto i:v[s])if(s-i&&s0-i)c=mul(mul(c,kf--),f(k,v,i,s));
  return c;
}
main(){
  int n,k,a,b; 
  cin>>n>>k;
  vector<vector<int>> v(n);
  for(int i=1;i<n;++i){
    cin>>a>>b;
    a--; b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  cout<<mul(k,f(k,v,0,-1));
}

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

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    vector<ll> A(N);
    vector<ll> B(N);
    for(int i=0;i<N;i++) {
        cin >> A.at(i) >> B.at(i);
    }

    ll times, ans = 0;
    for(int i=N-1;i>-1;i--) {
        if(B.at(i)==1||(A.at(i)+ans) % B.at(i)==0) continue; 
        ans += B.at(i) - ((A.at(i)+ans) % B.at(i));
    }

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 1792
#include<cstdio>

int main() {
    int n;
    scanf("%d", &n);
    unsigned long int ans = 0;
    for(unsigned long int i=1;i<=n;i++){
        unsigned long int p = n / i;
        ans += (p*(p+1)/2)*i;
    }
    printf("%lu", ans);
    return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define INF 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define print(v); for(auto x:v) cout<<x<<" "; cout<<endl;
typedef long long int ll;
int main()
{
    fast;
    ll a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;


    return 0;
}

Measured memory_bytes: 256
def check(l, s, p):
    for i in range(len(l)):
        l_i = l[i]
        cnt = 0
        for j in range(1,len(l_i)):
            cnt += s[l_i[j]-1]
        if cnt % 2 != p[i]:
            return False
    return True


n,m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for k in range(2**n):
    s = []
    for i in range(n):
        s.append( int(k & 1<<i == 1<<i) )
    ans += int(check(l,s,p))
print(ans)


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

def main():
    N = II()
    xy = []
    for _ in range(N):
        xy.append(LI())
    xy2g = defaultdict(int)
    g2xy = defaultdict(set)
    for x, y in xy:
        y = -y
        gx = xy2g[x]
        gy = xy2g[y]
        if gx == 0 or gy == 0:
            g = gx or gy or x
            xy2g[x] = xy2g[y] = g
            g2xy[g] |= {x, y}
        elif gx != gy:  # merge
            if len(g2xy[gx]) < len(g2xy[gy]):
                gx, gy = gy, gx
            for xy in g2xy[gy]:
                xy2g[xy] = gx
            g2xy[gx] |= g2xy[gy]
            g2xy[gy].clear()
    ans = -N
    for xys in g2xy.values():
        nx, ny = 0, 0
        for xy in xys:
            if xy > 0:
                nx += 1
            else:
                ny += 1
        ans += nx * ny
    return ans

print(main())

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

public class Main {

	private void solve() throws IOException {
		int n = ni();
		int c = ni();
		int d[][] = na(c);
		int[][] a = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++)
				a[i][j] = ni() - 1;

		}
		int cost[][] = new int[3][c];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				for (int k = 0; k < c; k++)
					cost[(i + j) % 3][k] += d[a[i][j]][k];
		int ans = Integer.MAX_VALUE;
		for (int c1 = 0; c1 < c; c1++)
			for (int c2 = 0; c2 < c; c2++) {
				if (c2 == c1)
					continue;
				for (int c3 = 0; c3 < c; c3++) {
					if (c2 == c3 || c1 == c3)
						continue;
					ans = Math.min(ans, cost[0][c1] + cost[1][c2] + cost[2][c3]);
				}
			}

		out.println(ans);
		out.close();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	private int[][] na(int n) throws IOException {
		int[][] a = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++)
				a[i][j] = ni();

		}
		return a;
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 41576
#include <bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

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

    double inf = 1e9;
    double right_inc = -inf,  right_dec = -inf, right_con = -inf;
    double left_inc  = inf,   left_dec  = inf,  left_con  = inf;
    double up_inc    = -inf,  up_dec    = -inf, up_con    = -inf;
    double down_inc  = inf,   down_dec  = inf,  down_con  = inf;
    for(int i=0; i<N; i++){
        double x, y;  char d;
        cin >> x >> y >> d;
        if(d=='R'){
            right_inc = max(x, right_inc);
            left_inc = min(x, left_inc);
            up_con = max(y, up_con);
            down_con = min(y, down_con);
        }else if(d=='L'){
            right_dec = max(x, right_dec);
            left_dec = min(x, left_dec);
            up_con = max(y, up_con);
            down_con = min(y, down_con);
        }else if(d=='U'){
            right_con = max(x, right_con);
            left_con = min(x, left_con);
            up_inc = max(y, up_inc);
            down_inc = min(y, down_inc);
        }else{
            right_con = max(x, right_con);
            left_con = min(x, left_con);
            up_dec = max(y, up_dec);
            down_dec = min(y, down_dec);
        }
    }

    double ans = 1e18;
    for(double t = 0.0; t<=2e8; t+=0.5){
        double dx = max({right_inc + t, right_dec - t, right_con}) - min({left_inc + t, left_dec - t, left_con});
        double dy = max({up_inc + t, up_dec - t, up_con}) - min({down_inc + t, down_dec - t, down_con});
        ans = min(ans, dx*dy);
    }
    cout << setprecision(15) << ans << endl;
}



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

int main() {
    int n;
    cin >> n;
    vector<P> p(n);
    rep(i,n) cin >> p[i].second >> p[i].first;
    sort(p.begin(),p.end());
    ll t = 0;
    rep(i,n) {
        t += p[i].second;
        if (t > p[i].first) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

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

using namespace std;

int main()
{
    int n,k,ans=0;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)
    {
    int x;
    scanf("%d",&x);
    if(x>=k)
    ans++;
    }
    cout<<ans;
    return 0;
}


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

int main(void){
    int n,*x;
    scanf("%d",&n);
    x = calloc(n,sizeof(int));
    int i;
    for(i=0;i<n;i++)
    scanf("%d",&x[i]);
    double sum=0;
    for(i=0;i<n;i++)
    sum += x[i];
    double ans1=0,ans2=0;;
    for(i=0;i<n;i++){
    ans1 += pow(floor(sum/n)-x[i],2);
    ans2 += pow(ceil(sum/n)-x[i],2);
    }
    if(ans1 > ans2)
    printf("%d\n",(int)ans2);
    else{
        printf("%d\n",(int)ans1);
    }
    return 0;
}

Measured memory_bytes: 128
from collections import deque
n, q = map(int,raw_input().split())
queue = deque([])
for i in range(n):
    queue.append(map(str,raw_input().split()))

queue = deque(map(lambda x : [x[0],int(x[1])], queue)) 
end  = deque([])
time = 0

while len(queue) > 0:
    xqt = queue.popleft()
    res_time = xqt[1] - q
    if res_time <= 0:
        time = time + xqt[1]
        end.append([xqt[0],time])
    else:
        time = time + q
        xqt[1] = res_time
        queue.append(xqt)

while len(end) > 0:
    out = end.popleft()
    print out[0], out[1]

Measured memory_bytes: 20700
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>a>>b;
    Cout(max(a-b,0LL));
    return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>
#define K 10000

int main(){

  int i,j;
  int len,C[K+1];
  unsigned short *A,*B;

  scanf("%d",&len);
  A=malloc(sizeof(short)*len+1);
  B=malloc(sizeof(short)*len+1);

  for(i=0;i<=K;i++) C[i]=0;

  for(i=0;i<len;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
}

  for(i=0;i<=K;i++){
  C[i]+=C[i-1];
}

  for(j=1;j<=len;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=len-1;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);

  return 0;
}

Measured memory_bytes: 8460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int num_divisor(int n){
    int res = 0;
    for (int i=1;i<=n;i++) if (n%i==0) res++;
    return res;
}
int main() {
    int res = 0;
    int N; cin >> N;
    for (int i=1;i<=N;i+=2) if (num_divisor(i)==8) res++;
    cout << res << endl;   

    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  for(a; a<=b; a++){
  string s = to_string(a);
    if(s[0] == s[4] && s[1] == s[3]){ans += 1;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  int N,X,ans=1;
  cin>>N>>X;
  int L[N+1];
  for(int i=1; i<=N; ++i) cin>>L[i];
  
  int cnt=0;
  for(int i=1; i<=N; ++i){
    cnt+=L[i];
    if(cnt>X) break;
    ans++;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k,x,y=0;
    cin >> n >> k >> x >> y;
    if(n <=k){
        cout << n*x;
        return 0;
    }else{
        cout << (n-k)*y + k*x;
    }
}

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

int main(){
	int l,a,b,c,d;
	scanf("%d",&l);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	if(a%c!=0){
		a=a/c+1;
	}else{
		a=a/c;
	}
	if(b%d!=0){
		b=b/d+1;
	}else{
		b=b/d;
	}
	a=fmax(a,b);
	l=l-a;
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) sort(v.begin(),v.end())
#define ALL(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll x,y;
    cin >> x >> y;
    ll count = 0;
    while(x <= y){
        x *= 2;
        count++; 
    }
    cout << count << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;

    int n,k,s;
    cin>>n>>k>>s;

    int ans[n];
    for(int i=0;i<k;i++)
    	ans[i] = s;

    s++;
    if(s>1e9)
    	s-=2;
    for(int i=k;i<n;i++)
    	ans[i] = s;
    for(auto it:ans)
    	cout<<it<<" ";
    cout<<endl;

    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

long long n, k,  a[N],  b[N];

int main() {
	cin >> n >> k;
	long long m1 = 0, m2 = 0;
	for (int i = 1; i <= n; ++i) {
		int x; scanf("%d", &x);
		if (x <= 0) a[++m1] = -x;
		else b[++m2] =x;
	}
	long long ans = 0x3f3f3f3f3f3f3f3f;
	sort(a + 1, a + m1 + 1);
	for (int i = 0; i <= min(k, m1); ++i) {
		if (i == k) ans = min(ans, a[i]);
		else if (k - i <= m2) ans = min(ans, a[i] * 2 + b[k - i]);
	}
	for (int i = 0; i <= min(k, m2); ++i) {
		if (i == k) ans = min(ans, b[i]);
		else if (k - i <= m1) ans = min(ans, b[i] * 2 + a[k - i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]
#CW = [list(map(int, list(input()))) for _ in range(H)]


x = int(input())
ans = 0
if(x == 0):
  print(1)
elif(x == 1):
  print(0)




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

int main() {
  int Count;
  int N;
  int OldCount = 0;
  cin >> N;
  for( int i = 0; i < N; i++ ){
    Count = 0;
    int A;
   cin >> A;
    while( A % 2 == 0 ){
      A /= 2;
      Count++;
    }
    if ( OldCount == 0 )
      OldCount = Count;
    if ( Count < OldCount )
      OldCount = Count;
  }
  if ( OldCount == 1 )
    OldCount = 0;
  cout << OldCount << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var k, s int
	fmt.Scan(&k, &s)
	var sum int
	for i := 0; i <= k; i++ {
		for j := 0; j <= k; j++ {
			l := s - (i + j)
			if 0 <= l && l <= k {
				sum++
			}
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
A = list([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51])
K = int(input())

print(A[K-1])

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    int n, k;
    cin >> n >> k;
    rep(i, n) {
        int x;
        cin >> x;
    }
    cout << (n + k - 3) / (k - 1) << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	long long n;
	int min=11;
	cin >> n;
	for(long long i=1; i*i<=n; i++){
		if(n%i)
			continue;
		int a = i;
		int b = n/i;
		int anum=0, bnum=0;
		while(a){
			a/=10;
			anum++;
		}
		while(b){
			b/=10;
			bnum++;
		}
		if(max(anum,bnum)<min)
			min=max(anum,bnum);
	}
	cout << min << '\n';
	return 0;
}

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

struct Node{
    int num=1;
    bool flag=false;
}node[100001];

int main()
{
    int M,N,x,y,pro=0;
    node[1].flag=true;
    cin>>N>>M;
    while(M--){
        cin>>x>>y;
        node[x].num--;
        node[y].num++;
        if(node[x].flag){
            node[y].flag=true;
        }
        if(node[x].num==0){
            node[x].flag=false;
        }
        if(node[y].num==0){
            node[y].flag=false;
        }
    }
    while(N>0){
        if(node[N].flag)
            pro++;
        N--;
    }

    cout<<pro<<endl;
    return 0;
}


Measured memory_bytes: 1024
l = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]

n = int(input())

for i in range(n):
    b, f, r, v = map(int, input().split())
    l[b-1][f-1][r-1] += v


for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f" {l[i][j][k]}", end="")
        print()
    if i != 3:
        print(20*"#")



Measured memory_bytes: 5636
from fractions import gcd

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

def f(x):
    cnt = 0
    for c in reversed(bin(x)):
        if c == '0':
            cnt += 1
        else:
            return cnt
    return cnt

n, m = map(int, input().split())
ai = list(map(lambda x: x//2 , list(map(int, input().split()))))

t = f(ai[0])
for i, a in enumerate(ai):
    if f(a) != t:
        print('0')
        exit()
    ai[i] = a >> t

m = m >> t

l = lcm(ai)
i = m // l
ans = (i + 1) // 2

print(ans)


Measured memory_bytes: 16320
#include <stdio.h>
int main(void){
	int i=0,b;
	char x[1000];
	while(1){
		i=0;
		b=0;
		scanf("%s",&x);
		if(x[0]=='0')break;
		while(x[i]){
			if(x[i]<0)break;
			b+=x[i]-'0';
			i++;
		}
		printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 536
#include<iostream>
#include<algorithm>
#include<list>
using namespace std;

int n,m,a,q;
list<int> lis;

int main(){

	cin>>n>>m>>q;
	for(int i=0;i<n;i++)lis.push_back(i);
	list<int>::iterator baton=lis.begin();

	while(m--){
		cin>>a;
		if(a%2){
			while(a--){
				if(baton==lis.begin())baton=lis.end(),baton--;
				else baton--;
				//cout<<"#"<<*baton<<endl;
			}
		}
		else{
			while(a--){
				baton++;
				if(baton==lis.end())baton=lis.begin();
				//cout<<"$"<<*baton<<endl;
			}
		}
		baton=lis.erase(baton);
		if(baton==lis.end())baton=lis.begin();
	}

	while(q--){
		cin>>a;
		baton=lis.begin();
		while(true){
			if(baton==lis.end()){
				cout<<"0"<<endl;
				break;
			}
			if(*baton==a){
				cout<<"1"<<endl;
				break;
			}
			baton++;
		}
	}

	return 0;
}

Measured memory_bytes: 9324
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char x = sc.next().charAt(0);
		char y = sc.next().charAt(0);
		int X = 10;
		int Y = 10;
		switch (x) {
		case 'B' :
			X = 11;
			break;
		case 'C' :
			X = 12;
			break;
		case 'D' :
			X = 13;
			break;
		case 'E' :
			X = 14;
			break;
		case 'F' :
			X = 15;
		}
		switch (y) {
		case 'B' :
			Y = 11;
			break;
		case 'C' :
			Y = 12;
			break;
		case 'D' :
			Y = 13;
			break;
		case 'E' :
			Y = 14;
			break;
		case 'F' :
			Y = 15;
		}
		if (X > Y) {
			System.out.println(">");
		}else if (X == Y) {
			System.out.println("=");
		}else if(X < Y) {
			System.out.println("<");
		}
	}
}


Measured memory_bytes: 35596
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>

using namespace std;

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


  int n[26]={};
  int t[26][101]={};

  for(int i=0;i<s.length();i++){
    int tmp = int(s[i] - 'a');
    t[tmp][n[tmp]] = i;
    n[tmp]++;
  }

  int ma[26] = {};
  for(int i=0;i<26;i++){
    if(n[i]!=0){
      ma[i] = t[i][0] - 0;
      for(int j=1;j<n[i];j++){
        if(ma[i] < t[i][j] - t[i][j-1] - 1){
          ma[i] = t[i][j] - t[i][j-1] - 1;
        }
      }
      if(ma[i] < s.length()-1 - t[i][n[i]-1]){
        ma[i] = s.length()-1 - t[i][n[i]-1];
      }
    }
  }

  int ans = s.length() -1;
  for(int i=0;i<26;i++){

    if(n[i] !=0 && ans > ma[i]){
      ans = ma[i];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		int[] lst = new int[10];
		for (int i = 0; i < 10; i++) {
			lst[i] = a.nextInt();
		}
		Arrays.sort(lst);
		for (int i = 9; i > 6; i--) {
			System.out.println(lst[i]);
		}
	}
}


Measured memory_bytes: 26360
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	ini(n1);
	ini(n_);
	vi x(n);
	vi x1(n1);
	FOR(i,0,n){in(x[i]);}
	FOR(i,0,n1){in(x1[i]);}
	auto xmin = min_element(all(x));
	auto x1min = min_element(all(x1));
	int tmp = *xmin+*x1min;
	FOR(i,0,n_){
		ini(xpos);
		ini(x1pos);
		ini(t);
		tmp = min(tmp,(x[xpos-1]+x1[x1pos-1]-t));
	}
	out(tmp);
	return 0;
}


Measured memory_bytes: 1024
n,d = gets.chomp.split(' ').map(&:to_i)
count = 0
n.times do
  x,y = gets.chomp.split(' ').map(&:to_i)
  x_expo = x ** 2
  y_expo = y ** 2
  count += 1 if Math.sqrt(x_expo + y_expo) <= d
end

puts count

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

const int MAX_N = int(1e5) + 10;

int n, m, deg[MAX_N];
bool vis[MAX_N];
std::vector<int> edges[MAX_N];

void dfs(int x) {
	vis[x] = 1;
	for (auto p : edges[x]) if (!vis[p]) {
		dfs(p);
	}
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		++deg[u];
		++deg[v];
		edges[u].emplace_back(v);
		edges[v].emplace_back(u);
	}
	for (int i = 1; i <= n; ++i) {
		if (deg[i] & 1) {
			puts("No");
			return 0;
		}
	}
	int four = 0, p1 = 0, p2 = 0;
	for (int i = 1; i <= n; ++i) {
		if (deg[i] >= 6) {
			puts("Yes");
			return 0;
		}
		if (deg[i] == 4) {
			++four;
			if (!p1) p1 = i;
			else
				if (!p2) p2 = i;
		}
	}
	if (four > 2) {
		puts("Yes");
		return 0;
	}
	if (four == 2) {
		vis[p1] = 1;
		dfs(p2);
		for (int i = 1; i <= n; ++i) {
			if (!vis[i]) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
}

Measured memory_bytes: 10372
<?php
$n = (int)trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));

for ($i = 0; $i < count($a); $i++) {
    $a[$i] = (int)$a[$i];
}

$alice = 0;
$bob = 0;

for ($i = 0; $i < $n; $i++) {
    $max = max($a);

    for ($j = 0; $j < count($a); $j++) {
        if ($a[$j] === $max) {
            array_splice($a, $j, 1);
            break;
        }
    }

    if ($i % 2 === 0) {
        $alice += $max;
    } else {
        $bob += $max;
    }
}

echo abs($alice - $bob) . "\n";

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

int main() {
    string s; cin >> s;
    
    ll ans = INT_MAX;
    for (char c = 'a'; c <= 'z'; c++) {
        string w = s;
        ll cnt = 0;
        while (true) {
            // sが空文字列だったらループを抜ける
            if (w.empty()) {
                break;
            }
            // cのみになったらループを抜けたい
            if (w == string(w.length(), c)) {
                cerr << w << endl;
                ans = min(ans, cnt);
                break;
            }
            string a = "";
            // n-1の文字列へ
            rep (j, w.size()-1) {
                if (w[j] == c || w[j+1] == c) {
                    a += c;
                }
                else a += w[j];
            }
            w = a;
            cnt++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def choose(n, k, mod):
  """ nCkを計算 """
  # 分子
  numerator = 1
  for i in range(k):
    numerator *= n - i
    numerator %= mod
  # 分母
  denominator = 1
  for i in range(k):
    denominator *= (i + 1)
    denominator %= mod

  # (分子 / 分母) % mod
  # = (分子 * 分母の逆元) % mod   
  return (numerator * pow(denominator, mod - 2, mod)) % mod


def main():
  MOD = 10 ** 9 + 7
  n, a, b = [int(x) for x in input().split()]

  # "2のn乗"をMODで割ったあまり
  ans = pow(2, n, MOD)
  
  # 1個も選ばない場合
  ans -= 1
  # a個選ぶ場合
  ans -= choose(n, a, MOD)
  # b個選ぶ場合
  ans -= choose(n, b, MOD)
  
  # Pythonの場合、ansが負の値でも特別な考慮は不要
  ans %= MOD

  print(ans)

  
main()

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a[3], k;

int main() {
	inc(i, 3) { cin >> a[i]; }
	cin >> k;
	
	sort(a, a + 3, greater<int>());
	inc(i, k) { a[0] *= 2; }
	
	cout << a[0] + a[1] + a[2] << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
int main(){
    ll n;cin>>n;
    vector<ll> a(n),dxor(n+1,0),dsum(n+1,0);
    For(i,n){
        cin>>a.at(i);
        dxor.at(i+1)=(dxor.at(i)^a.at(i));
        dsum.at(i+1)=dsum.at(i)+a.at(i);
    }
    ll ans=0;
    ll i=0,j=1;
    while(i<n-1&&j<n){
        while((dxor.at(j)^dxor.at(i))==dsum.at(j)-dsum.at(i)&&j<n){
            ans+=j-i;
            j++;
            //cout<<ans<<" ";
        }
        while((dxor.at(j)^dxor.at(i))!=dsum.at(j)-dsum.at(i)&&i<j-1){
            i++;
        }
    }
    ans+=j-i;
    cout<<ans<<endl;
}


Measured memory_bytes: 4992
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  string s;
  cin >> s;
  int res = 0;
  
  while (true) {
    string a, b;
    s.erase(s.begin() + s.size() - 1);
    res++;

    if (s.size() % 2 != 0) continue;
    a = s.substr(0, s.size() / 2);
    b = s.substr(s.size() / 2, s.size());
    if (a == b) {
      break;
    }
  }
  print(s.size());
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		int x[] = new int[n+1];


		for (int i=0;i<=n;++i){
			x[i]=sc.nextInt();
		}

	//	Arrays.sort(x);

		int common=Math.abs(x[1]-x[0]);
		int a;
		int b;
		int c;

		for (int i=1;i<n;++i){
			a=Math.max(Math.abs(x[i]-x[i-1]), Math.abs(x[i+1]-x[i]));
			b=Math.min(Math.abs(x[i]-x[i-1]), Math.abs(x[i+1]-x[i]));
			while ((c=a%b)!=0){
				a=b;
				b=c;
			}
			common = Math.min(common, b);
		}

		System.out.println(common);

	}
}

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

const lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }
inline lint powm(lint a, lint n, lint p = mod) { return !n ? 1 : powm(a * a % p, n >> 1, p) * (n & 1 ? a : 1) % p; }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint n, c; cin >> n >> c;
  V<lint> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  V<lint> b(n); for (int i = 0; i < n; i++) cin >> b[i];
  VV<lint> _powm; assign(_powm, 401, c + 1);
  for (int i = 0; i < 401; i++) for (int j = 0; j < c + 1; j++) _powm[i][j] = powm(i, j);
  VV<lint> pre; assign(pre, n, c + 1);
  for (int i = 0; i < n; i++) for (int j = 0; j < c + 1; j++) for (int x = a[i]; x < b[i] + 1; x++) (pre[i][j] += _powm[x][j]) %= mod;
  VV<lint> dp; assign(dp, n + 1, c + 1);
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) for (int j = 0; j < c + 1; j++) for (int k = 0; j + k < c + 1; k++) {
    (dp[i + 1][j + k] += dp[i][j] * pre[i][k]) %= mod;
  }
  cout << emod(dp[n][c]) << '\n';
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
       int n,m;
       cin >>n>>m;
       vector<int> tk[n+1],tr[n+1];
       int a,b;
        queue<int> que;
       
       
    for(int i=0;i<n+m-1;i++){
           cin >> a>>b;
           tk[b].push_back(a);
           tr[a].push_back(b);
       }
        int u=1;
        while(!tk[u].empty())u=tk[u][0];
    int ans2[n+1]={};
    int ans[n+1]={};
  
    ans2[u]=0;
    int ad[n+1]={};
    que.push(u);
    
    while(!que.empty()){
        u=que.front();
        que.pop();
        for(int i=0;i<tr[u].size();i++){
        
     //   ans[tr[u][i]]=ans[u]+1;
        if(ans[tr[u][i]]<ans[u]+1){
           ans2[tr[u][i]]=u;
           ans[tr[u][i]]=ans[u]+1;
        
        }
        ad[tr[u][i]]++;
        if(ad[tr[u][i]]==tk[tr[u][i]].size())que.push(tr[u][i]); 
        
       
        }

    }
    for(int i=1;i<n+1;i++){
        cout << ans2[i]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 14080
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	s := r.nextString()

	fmt.Fprintln(stdout, []string{"No", "Yes"}[b2i(strings.Contains(s, "7"))])
}


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

using namespace std;

#define int long long

signed main () {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > a, b;
  pair<int, int> p;
  int tmp;
  for(int i=0;i<m;i++) {
    cin >> p.first >> p.second;
    if(p.first < p.second) {
      tmp = p.second;
      p.second = p.first;
      p.first = tmp;     
    }
    a.push_back(p);
  }
  sort(a.begin(), a.end());
  int counter = 1;
  int now = a[0].first;
  for(int i=0;i<m;i++) {
    if(a[i].second < now) continue;
    now = a[i].first;
    counter++;
  }
  cout << counter << endl;
}


Measured memory_bytes: 3444