akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int N,W;
	int c=1;
	
	while(scanf("%d",&W)){
		if(W==0) break;
		scanf("%d",&N);
		
		vector<int> v(N);
		vector<int> w(N);
		vector<int> dp(10001,0);
		
		for(int i=0;i<N;i++){
			scanf("%d, %d",&v[i],&w[i]);
		}
		for(int i=0;i<N;i++){
			for(int j=W;j>=w[i];j--){
				dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
			}
		}
		printf("Case %d:\n",c);
		c++;
		printf("%d\n",*max_element(dp.begin(),dp.begin()+W+1));
		vector<int>::iterator maxit=max_element(dp.begin(),dp.begin()+W+1);
		printf("%ld\n",distance(dp.begin(),maxit));
	}
}


Measured memory_bytes: 3236
#include<iostream>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using lint=long long;

int main() {
  int n,ans=1,maxm;
  cin >> n;
  std::vector<int> v(n);
  for(int i=0;i<n;i++) {
    cin>>v[i];
  }
  maxm=v[0];
  for(int i=1;i<n;i++){
    if(v[i]>=v[i-1]&&v[i]>=maxm) {
      ans++;
      maxm=v[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	int sum = 0;
	for (int i = 0; i < k; i++)
		sum += a[i];
	cout << sum;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
template<class T> _inline void read(T &x){
	T res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
template<class T> inline void print(T x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int h,n;
int a[100005];
int main(){
	read<int>(h);
	read<int>(n);
	int sum=0;
	for(i,1,n) read<int>(a[i]),sum+=a[i];
	puts(sum>=h?"Yes":"No");
	exit(0);	
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveB();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((g * 10 + b) % 4 == 0 ? "YES" : "NO");
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int min = 1000;
		int max = 0;
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if (min > a) {
				min = a;
			}
			if (max < a) {
				max = a;
			}
		}
		System.out.println(max - min);
	}
}

Measured memory_bytes: 19796
#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e5+5, M=5e5+5, oo=0x3f3f3f3f, mod = 1e9+7;

ll n, arr[N], mem[N];
int solve(ll ind){
    if(ind == n-1) return 0;
    if(mem[ind] != -1) return mem[ind];
    ll op1 = abs(arr[ind+1]-arr[ind]) + solve(ind+1);
    ll op2 = (ind+2 < n) ? abs(arr[ind+2]-arr[ind])+solve(ind+2) : oo;
    return mem[ind] = min(op1, op2);

}
int main()
{
    _69e27
    memset(mem, -1, sizeof mem);
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> arr[i];
    cout << solve(0);

    return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>

int main() {

	int N, L;
	std::cin >> N >> L;

	std::vector<std::string> S(N);

	for (int i = 0; i < N; i++)std::cin >> S[i];

	std::sort(S.begin(), S.end());

	std::string ans;

	for (int i = 0; i < N; i++)ans += S[i];

	std::cout << ans << std::endl;
	   	 
}

Measured memory_bytes: 256
from sys import setrecursionlimit


def encode(i, j):
    if i < j:
        i, j = j, i
    return i * (i - 1) // 2 + j + 1


def dfs(v):
    if visited[v] == 2:
        return dp[v]
    visited[v] = 1
    for nv in g[v]:
        if visited[nv] == 1:
            print(-1)
            exit()
        dp[v] = max(dp[v], dfs(nv) + 1)
    visited[v] = 2
    return dp[v]


setrecursionlimit(10 ** 6)
N = int(input())
GAMES_CNT = N * (N - 1) // 2
g = [[] for _ in range(GAMES_CNT + 1)]
for i in range(N):
    orig = 0
    for j in map(lambda x: int(x) - 1, input().split()):
        dest = encode(i, j)
        g[orig].append(dest)
        orig = dest
dp = [0] * (GAMES_CNT + 1)
visited = [0] * (GAMES_CNT + 1)
print(dfs(0))


Measured memory_bytes: 116480
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int M=45;
const int N=1e3+5;
int n,m,lim,tmp[M];
ll X[N],Y[N];

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

int main() {
	IN(n);
	for(int i=1;i<=n;++i) IN(X[i]),IN(Y[i]);
	// bool val=abs(X[1]+Y[1])&1;
	// for(int i=1;i<=n;++i)
		// if(abs(X[i]+Y[i])&1!=val) return puts("-1"),0;
    int val = abs(X[1] + Y[1]) & 1;
	for(int i = 1; i <= n; i++)
		if((abs(X[i] + Y[i]) & 1) != val)
			return puts("-1"), 0;
	// tmp[m=1]=1;
    // for(int i=val;i<=30;++i) tmp[++m]=1<<i;
	// printf("%d\n",lim=m);
	// for(int i=1;i<=m;++i) printf("%d ",tmp[i]);puts("");
    printf("%d\n1", 32 - val);
	tmp[1] = 1; m = 1;
	if(val) {
		for(int i = 1; i <= 30; i++) printf(" %d", tmp[++m] = 1 << i);
		puts("");
	} else {
		for(int i = 0; i <= 30; i++) printf(" %d", tmp[++m] = 1 << i);
		puts("");
	}
	static char ans[M];
	// for(int i=1;i<=n;++i) {
	// 	for(int j=m;j;--j) {
	// 		if(abs(X[i])>abs(Y[i])) {
	// 			if(X[i]>0) X[i]-=tmp[j],ans[j]='R';
	// 			else X[i]+=tmp[j],ans[j]='L';
    //         } else {
	// 			if(Y[i]>0) Y[i]-=tmp[j],ans[j]='U';
	// 			else Y[i]+=tmp[j],ans[j]='D';
    //         }
	// 	}
	// 	printf("%s\n",ans+1);
	// }
    for(int i = 1; i <= n; i++) {
		ll nx = 0, ny = 0;
		for(int j = m; j; --j) {
			ll dx = X[i] - nx, dy = Y[i] - ny;
			if(abs(dx) > abs(dy)) {
				if(dx > 0) nx += tmp[j], ans[j] = 'R';
				else nx -= tmp[j], ans[j] = 'L';
			} else {
				if(dy > 0) ny += tmp[j], ans[j] = 'U';
				else ny -= tmp[j], ans[j] = 'D';
			}
		} printf("%s\n", ans + 1);
	}
	return 0;
}


Measured memory_bytes: 256
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def gcd(a, b)
  p = [a, b].max
  q = [a, b].min

  if p % q == 0 then
    return q
  else
    return gcd(q, p % q)
  end
end

def main(argv)
  k = InputLine.to_i
  
  gcd_table = [nil] * k
  k.times do |a|
    gcd_table[a] = [0] * k
    k.times do |b|
      gcd_table[a][b] = gcd(a + 1, b + 1)
    end
  end

  s = 0
  k.times do |a|
    k.times do |b|
      gcd_a_b = gcd_table[a][b]
      k.times do |c|
        s += gcd_table[gcd_a_b - 1][c]
      end
    end
  end
  puts s.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14512
def DP(H, W, K):
    res = [[0 for i in range(W)] for j in range(H+1)]
    res[0][0] += 1
    for step in range(1, H+1):
        for i in range(2**(W-1)):
            s = "{:08b}".format(i)[::-1]
#            print()
#            print(s)
            if '11' in s:
                continue
            for x in range(0, W):
                if x == 0:
                    if s[x] == '0':
                        res[step][x] += res[step-1][x]
                    elif s[x] == '1':
                        res[step][x+1] += res[step-1][x]
                elif x == W-1:
                    if s[x-1] == '0':
                        res[step][x] += res[step-1][x]
                    elif s[x-1] == '1':
                        res[step][x-1] += res[step-1][x]
                else:
                    # right
                    if s[x] == '0' and s[x-1] == '0':
                        res[step][x] += res[step-1][x]
                    elif s[x] == '1':
                        res[step][x+1] += res[step-1][x]
                    elif s[x-1] == '1':
                        res[step][x-1] += res[step-1][x]
#            print(res[step])
        for i in range(W):
            res[step][i] = res[step][i] % MOD
    return res[step][K-1]


H, W, K = map(int, input().split(' '))
MOD = 1000000007
print(DP(H, W, K))


Measured memory_bytes: 3188
D = int(input())#D=365
c = list(map(int, input().split()))#0<=c<=100
s = [list(map(int, input().split())) for _ in range(D)]#0<=s<=20000

t = []
for d in range(D):
    t.append(s[d].index(max(s[d])) + 1)

for i in range(D):
    print(t[i])

Measured memory_bytes: 9372
#include "iostream"
#include "algorithm"
#include "vector"

int main(int argc, char const *argv[]) {
  /*
  input
  6 1

  input 2
  7 8

  input 2
  3 5

   */

   int a, b;
   std::cin >> a >> b;

   if (a + b == 15)
   {
     /* code */
     std::cout << "+" << '\n';
   }
   else
   {
     if(a*b == 15)
     {
       std::cout << "*" << '\n';
     }
     else
     {
       std::cout << "x" << '\n';
     }
   }

  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    
    if((a+b)%2==0) cout << (a+b)/2;
    else cout << (a+b)/2 + 1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main()
{
  string s;
  int c = 0,ans = 0;
  cin>>s;
  FOR(i,0,s.length()){
    if(s[i]=='(')c++;
    else if(s[i]==')')c--;
    else ans+=c;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3208
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
#define Mod 1000000007

LL l, r;
int wr[100], wl[100], Dp[100][8];

inline int Inc(int u, int v)
{
	return u + v - (u + v >= Mod ? Mod : 0);
}

bool CheckR(int state, int w, int br)
{
	return (state & 1) || (br <= wr[w]);
}

bool CheckL(int state, int w, int bl)
{
	return (state & 2) || (bl >= wl[w]);
}

bool CheckS(int state, int bl, int br)
{
	return (state & 4) || (bl == br);
}

int Transfer(int state, int w, int bl, int br)
{
	int res = 0;
	if ((state & 1) || br < wr[w])
		res |= 1;
	if ((state & 2) || bl > wl[w])
		res |= 2;
	if ((state & 4) || (bl == 1))
		res |= 4;
	return res;
}

int Solve()
{
	int sz = 0;
	for (LL y = r; y; y >>= 1)
		wr[++ sz] = (y & 1);
	for (int i = 1; i <= sz; i ++)
		wl[i] = (l >> (i - 1) & 1);
	Dp[sz + 1][0] = 1;
	for (int w = sz + 1; w; w --)
		for (int state = 0; state < 8; state ++)
		{
			if (!Dp[w][state]) continue ;
			for (int br = 0; br < 2; br ++)
				for (int bl = 0; bl <= br; bl ++)
				{
					if (!CheckR(state, w - 1, br) || !CheckL(state, w - 1, bl) || !CheckS(state, bl, br))
						continue ;
					int _state = Transfer(state, w - 1, bl, br);
					Dp[w - 1][_state] = Inc(Dp[w - 1][_state], Dp[w][state]);
				}
		}
	int res = 0;
	for (int state = 0; state < 8; state ++)
		res = Inc(res, Dp[1][state]);
	return res;
}

int main()
{
	scanf("%lld%lld", &l, &r);
	printf("%d\n", Solve());
	return 0;
}           

Measured memory_bytes: 128
// -------- START : snippet -------- //

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

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

// -------- START : macro -------- //

#define ll long long
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define len(c) (ll)c.size()
#define all(v) (v).begin(),(v).end()
#define lb(v,x) (lower_bound(all(v),x)-v.begin())
#define ub(v,x) (upper_bound(all(v),x)-v.begin())
#define has(c,x) (c.find(x) != c.end())
#define uniq(v) v.erase(unique(all(v)),v.end())
#define bit(k) (1LL<<(k))
#define INF int(1e9)

template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

// -------- END : macro -------- //

// -------- START : debug macro -------- //

template<class T,class U> ostream& operator<<(ostream& ost, const pair<T,U> &p) { ost << "(" << p.first << ", " << p.second << ")"; return ost; }
#define ostream_container { ost << "{"; for(const auto &t : v) { if (&t != &*v.begin()) ost << ", "; ost << t; } ost << "}"; return ost; }
template<class T> ostream& operator<<(ostream &ost, const vector<T> &v) ostream_container
template<class T> ostream& operator<<(ostream &ost, const set<T> &v) ostream_container
template<class T,class U> ostream& operator<<(ostream &ost, const map<T,U> &v) ostream_container

template<class H> void recursive_debug(string s, H h) {
    cerr << "\033[33m" << s << " = " << h << endl << "\033[m";
}
template<class H,class... T> void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << "\033[33m" << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}
#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

// -------- END : debug macro -------- //

// -------- END : snippet -------- //

int main(void) {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0, r = n-1;
    int cnt = 0;
    while(l < r) {
        while (s[l] == 'R') l++;
        while (s[r] == 'W') r--;
        if (l < r) {
            cnt++;
            swap(s[l], s[r]);
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3736
import java.util.Scanner;
import java.lang.Math;
class Main{
  public static void main(String args[]){
    Scanner stdIn=new Scanner(System.in);
    int x=stdIn.nextInt();
    long[] a=new long[x];
    //input
    for(int i=0;i<x;i++){
        a[i]=stdIn.nextLong();
    }

    int swap=0;
    int index=x-1;
    long temp;
    for(int i=0;i<index;i++){
      int j=1;
      while(index-j>=i){
        if(a[index-j+1]<a[index-j]){
          temp=a[index-j+1];
          a[index-j+1]=a[index-j];
          a[index-j]=temp;
          swap++;
        }
        j++;
      }
    }
    for(int i=0;i<x;i++){
      System.out.print(a[i]);
      if(i!=x-1)
        System.out.print(" ");
    }
    System.out.println();
    System.out.println(swap);
  }
}



Measured memory_bytes: 26248
#!/usr/bin/env python3

x, y = list(map(int, input().split()))

if x == y:
    count = 0
elif x == 0:
    count = abs(y)
    if y < 0:
        count += 1
elif y == 0:
    count = abs(x)
    if x > 0:
        count += 1
else:
    if x * y < 0:
        # x と yの符号が違う
        # -10, 5
        # -5, 10
        # 10, -5
        # 5, -10
        if abs(x) == abs(y):
            count = 1
        elif x < y:
            # xが負、yが正
            count = abs(x - y)
            count_2 = 1 + abs(abs(x) - abs(y))
            count = min(count, count_2)
        else:
            count = 1 + abs(abs(x) - abs(y))

    else:
        # xとyの符号が同じ
        if x < y:
            count = abs(y - x)
        else:
            count = 2
            count += abs(y - x)

ans = count
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <bitset>
#include <vector>
using namespace std;
 
const int N = 1e5;
int l[N], r[N], s[N];

int main() {
    int n;
    scanf("%d", &n);
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (i * j >= n) {
                break;
            }
            int k = n - i * j;
            sum += 1;
        }
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 3828
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long a, long long b){
  ll x = min(a, b);
  ll y = max(a, b);
  string ans = "";
  for(ll i=0; i<y; i++)
    ans+='0'+x;
  std::cout << ans << std::endl;
}

int main(){
  long long a;
  scanf("%lld",&a);
  long long b;
  scanf("%lld",&b);
  solve(a, b);
  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	char s[100];
	int count = 0, i = 1;

	scanf("%s", s);
	printf("%c", s[0]);

	while (s[i] != '\0') {
		if (s[i + 1] == '\0') {
			printf("%d%c", count, s[i]);
		}
		else {
			count++;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main () {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt=0;
    if (k<=a) {
        cnt+=k;
    }
    else if (k<=a+b) {
        cnt+=a;
    }
    else if (k<=a+b+c) {
    	cnt+=a;
    	cnt-=k-(a+b);
	}
    cout << cnt << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

int h, w;
char map[1005][1005];
llint dp[1005][1005];

int main(void)
{
	cin >> h >> w;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> map[x][y];
		}
	}
	
	dp[0][1] = 1;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			if(map[x][y] == '#') continue;
			dp[x][y] = dp[x-1][y] + dp[x][y-1];
			dp[x][y] %= mod;
		}
	}
	cout << dp[w][h] << endl;
	
	return 0;
}

Measured memory_bytes: 9088
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);


void main() {
    int d = read();
    if (d == 25)
        writeln("Christmas");
    else if (d == 24)
        writeln("Christmas Eve");
    else if (d == 23)
        writeln("Christmas Eve Eve");
    else if (d == 22)
        writeln("Christmas Eve Eve Eve");
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<20)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n,x[105];
    cin>>n;
    rep(i,n){
        cin>>x[i];
    }
    int ans=INF;
    for(int place=1;place<=100;place++){
        int t=0;
        for(int i=0;i<n;i++){
            t+=pow((place-x[i]),2);
        }
        ans=min(ans,t);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int N, K;
  cin >> N;

  if (N % 7 == 0 || N % 4 == 0) {
    cout << "Yes" << endl;
    return 0;
  }

  int num = N / 7;
  bool ok = false;
  while(num > 0) {
    int a = N - (7 * num);
    if (a % 4 == 0) {
      ok = true;
      break;
    }
    num--;
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define N 200123
#define mod 1000000007

int main(){
 ios::sync_with_stdio(false);
 cin.tie(0);
 if(fopen("input.in", "r")){
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    string s;
    int n; cin >> n >> s;
    bool cek = true;
    int m = n/2;
    if(n <2 ||( n%2 !=0)) {
    	cek = false;
    }
    else{
    	for(int i=0;i<m;i++){
    		if(s[i] != s[i+m]){
    			cek = false;
    			break; 
    		}
    	}
	}	
    if(cek){
    	cout << "Yes" <<"\n";
    }
    else{
    	cout << "No" <<"\n";
    }
 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;
#define DUMPR(v) REP(_i,v.size()){std::cerr<< #v << "[" << _i << "] = " << (v[_i]) << std::endl;}
#define CIN_VEC(v,N) {v.clear(); v.reserve(N); REP(i,N){typename decltype(v)::value_type x; cin>>x; v.emplace_back(x);}};

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;

void solve(const vector<int>& v) {
  vector<int> sorted(v);
  sort(sorted.begin(), sorted.end());
  const auto N = v.size();
  const auto N2 = v.size() / 2;

  for(const auto& x : v) {
    auto pos = lower_bound(sorted.begin(), sorted.end(), x);
    size_t dist = pos - sorted.begin();
    // DUMP(x);
    // DUMP(dist);
    // DUMP(N2);
    // DUMP(sorted[N/2-1]);
    // DUMP(sorted[N/2]);
    
    auto mid = dist >= N2 ? sorted[N2-1] : sorted[N2];
    cout << mid << endl;
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> v;
  while(N--) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  solve(v);

  return 0;
}


Measured memory_bytes: 3828
n = int(input())
array = [int(i) for i in input().split()]
cntarray =[]
cnt = 0

for i in range(n):
  cnt = 0
  while array[i]%2 == 0:
    array[i] /= 2
    cnt +=1
  
  cntarray.append(cnt)
  
print(min(cntarray))

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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{
  IO;
  int n; cin >> n;
  vector <int> a(n);

  for (int i = 0; i < n; ++i)
  cin >> a[i];

  sort(a.rbegin(), a.rend());

  int res = 0;
  for (int i = 0; i < n - 1; ++i)
  if (a[i] == a[i + 1]) {
  if (res == 0)
  res = a[i];
  else {
    cout << (long long)a[i] * res << endl;
    return 0;
  }
  ++i;
  }

  cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        StringBuilder Sa = new StringBuilder(Console.ReadLine());
        StringBuilder Sb = new StringBuilder(Console.ReadLine());
        StringBuilder Sc = new StringBuilder(Console.ReadLine());
        byte turn = 0;//0:a 1:b 2:c
        bool end = false;
        for (; ; )
        {
            switch (turn)
            {
                case 0:
                    if (Sa.Length == 0)
                    {
                        Console.WriteLine("A");
                        end = true;
                        break;
                    }
                    turn = GetTurn(Sa[0]);
                    Sa = Sa.Remove(0, 1);
                    break;
                case 1:
                    if (Sb.Length == 0)
                    {
                        Console.WriteLine("B");
                        end = true;
                        break;
                    }
                    turn = GetTurn(Sb[0]);
                    Sb = Sb.Remove(0, 1);
                    break;
                case 2:
                    if (Sc.Length == 0)
                    {
                        Console.WriteLine("C");
                        end = true;
                        break;
                    }
                    turn = GetTurn(Sc[0]);
                    Sc = Sc.Remove(0, 1);
                    break;
            }
            if (end) break;
        }
    }
    static byte GetTurn(char c)
    {
        switch (c)
        {
            case 'a': return 0;
            case 'b': return 1;
            case 'c': return 2;
        }
        return 4;
    }
}

Measured memory_bytes: 2648
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N, M;
  int T[1010];
  int p[105], x[105];
  int sum = 0;

  cin >> N;
  for (int i = 1; i <= N; ++i) {cin >> T[i]; sum += T[i]; }

  cin >> M;
  for (int i = 0; i < M; ++i) {
    cin >> p[i] >> x[i];
    int tmp = sum - T[p[i]] + x[i];
    cout << tmp << endl;
  }


  return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a_abs = list(map(abs, a))

minuses = 0
for i in a:
    if i < 0:
        minuses += 1

if minuses % 2 == 0:
    print(sum(a_abs))
else:
    print(sum(a_abs) - 2 * min(a_abs))

Measured memory_bytes: 14412
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        Console.WriteLine(48 - int.Parse(Read.Str()));
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 11092
#include <cstdio>
using namespace std;

int main(){
  char s[100];
  scanf("%s",s);
  int i=0;
  int a=0;
  int b=0;
  while(s[i]!='\0'){
    if(a==0 && s[i]=='C'){
      a=1;
    }
    else if(a==1 && s[i]=='F'){
      printf("Yes\n");
      return 0;
    }
    i++;
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 210000;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int BASE = 1000000000;

const int MOD = 1000000007;

int n, k;
VI G[MAX];
int V[MAX];
int T[MAX];
int SL[MAX];
int SR[MAX];
int res;

void init(int v, int p)
{
  SL[v] = -INF;
  SR[v] = INF;
  if (V[v] != -1)
  {
    SL[v] = SR[v] = V[v];
  }

  FOR (i,0,SZ(G[v]))
  {
    int to = G[v][i];
    if (to == p) continue;
    init(to, v);
    SL[v] = max(SL[v], SL[to]-1);
    SR[v] = min(SR[v], SR[to]+1);
  }
}

void dfs(int v, int p, int l, int r)
{
  if (T[v] != -1)
  {
    l = max(l, T[v]);
    r = min(r, T[v]);
  }

  {
    int ll = max(l, SL[v]);
    int rr = min(r, SR[v]);

    if (ll > rr)
    {
      res = 0;
    }

    V[v] = ll;
  }

  multiset<int> L;
  multiset<int> R;
  FOR (i,0,SZ(G[v]))
  {
    int to = G[v][i];
    if (to == p) continue;
    L.insert(SL[to]);
    R.insert(SR[to]);
  }

  FOR (i,0,SZ(G[v]))
  {
    int to = G[v][i];
    if (to == p) continue;

    L.erase(L.find(SL[to]));
    R.erase(R.find(SR[to]));

    int ll = L.empty() ? -INF : *L.rbegin();
    int rr = R.empty() ? INF : *R.begin();

    ll -= 2;
    rr += 2;

    ll = max(ll, l-1);
    rr = min(rr, r+1);

    dfs(to, v, ll, rr);

    L.insert(SL[to]);
    R.insert(SR[to]);
  }
  
}

int main()
{
  cin >> n;
  FOR (i,0,n-1)
  {
    int u, v;
    scanf("%d %d", &u, &v);
    -- u;
    -- v;
    G[u].PB(v);
    G[v].PB(u);
  }

  FILL(V, -1);
  FILL(T, -1);

  cin >> k;
  FOR (i,0,k)
  {
    int x, v;
    scanf("%d %d", &x, &v);
    -- x;
    V[x] = v;
    T[x] = v;
  }

  init(0, -1);

  res = 1;

  dfs(0, -1, -INF, INF);

  FOR (i,0,n)
    FOR (j,0,SZ(G[i]))
      if (abs(V[i]-V[G[i][j]]) != 1) res = 0;

  if (!res)
  {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  FOR (i,0,n)
    printf("%d\n", V[i]);


  
  return 0;
}


Measured memory_bytes: 30080
a,b,c,d=gets.chomp.split(" ").map { |e| e.to_i }


def abs(n)

  if n>=0
    return n
  else
    return -n
  end

end


if (abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
n,m,x = map(int,input().split())
A = [[] for _ in range(n)]
c = [0] * n
for i in range(n):
    c_as = list(map(int,input().split()))
    c[i], A[i] = c_as[0],c_as[1:]

INF = 10**9
ans = INF

for s in range(0,1 << n):
    smart = [0] * m
    cost_sum = 0
    for i in range(n):
        if (s >> i) % 2 == 0:
            continue
        cost_sum += c[i]
        for j in range(m):
            smart[j] += A[i][j]
    ok = True
    for j in range(m):
        if smart[j] < x:
            ok = False
    if ok:
        ans = min(cost_sum,ans)
if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68500
n = input()
keta = len(n)
n = int(n)

count = 0
if keta == 1:
    count = (n-1+1)
elif keta == 2:
    count = (9-1+1)
elif keta == 3:
    count = (n-100+1) + (9-1+1)
elif keta == 4:
    count = (9-1+1) + (999-100+1)
elif keta == 5:
    count = (n-10000+1) + (9-1+1) + (999-100+1)
elif keta == 6:
    count = (9-1+1) + (999-100+1) + (99999-10000+1)

print(count)

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rs64() {
	int64_t n;
	scanf("%" SCNd64, &n);
	return n;
}

int main() {
	int k = ri(), x = ri();
	std::cout << (k * 500 >= x ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, K;
  int ans = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    if (a >= K)
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		
		for(int i = 0; i < num; i++){
			String str = br.readLine();
			str = str.replaceAll("Hoshino", "Hoshina");
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 16944
#include <cstdio>

int main() {
  int a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  int ans =0;
  if(k-a <0 ) 
   ans =k;
  else {
    ans = a;
    k = k- a;
    if(k>b) {
      k = k -b;
      ans = ans +(-1*k);
    }
  }
  printf("%d",ans);


}

Measured memory_bytes: 1732
a=int(input())
b=input()
b=list(b)
c=[0]*26
ans=0
t=0
for i in range(a):
	c[ord(b[i])-97]=c[ord(b[i])-97]+1

for j in range(26):
	t=c[j]
	for k in range(j+1,26):
		t=t*(c[k]+1)
	ans=ans+t
print(ans%(10**9+7))

Measured memory_bytes: 3956
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


A, B, C = acinput()
K = II()


# s1=np.ceil(np.log(B)/np.log(A))

k = 0
while A >= B:
    B *= 2
    k += 1

while B >= C:
    C *= 2
    k += 1

if k <= K:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 26956
/***********************
*  Date: 2018.11.28    *
*  Problem:            *
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,q,co[100010],most[100010];
vector <int> g[100010];
vector <pair<int,pii> > qs;
bool vis[100010];

void dfs(int pos,int now,int all,int colo)//dfs不能有vis数组 
{
	if(all-now<=most[pos]) return;
	most[pos]=all-now;
	if(co[pos]==0) co[pos]=colo;
	if(now==all) return;
	rep(i,g[pos].size()) dfs(g[pos][i],now+1,all,colo);
}

int main()
{
	cin>>n>>m;
	memset(most,-1,sizeof(most));
	rep(i,m)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	cin>>q;
	rep(i,q)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		qs.pb({x,{y,z}});
	}
	reverse(qs.begin(),qs.end());
	rep(i,q)
	{
		dfs(qs[i].fi,0,qs[i].se.fi,qs[i].se.se);
	}
	repn(i,n) printf("%d\n",co[i]);
	rt0;
}

Measured memory_bytes: 8816
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC151C - Welcome to AtCoder

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] p = new int[m];
        String[] s = new String[m];

        int[] ac = new int[n];
        int[] wa = new int[n];

        int acCnt = 0;
        int waCnt = 0;

        for (int i = 0; i < m; i++) {
            p[i] = sc.nextInt();
            s[i] = sc.next();
            if (s[i].equals("AC")) {
                if (ac[p[i] - 1] == 0) {
                    acCnt++;
                    waCnt += wa[p[i] - 1];
                }
                ac[p[i] - 1]++;
            } else {
                if (ac[p[i] - 1] == 0) {
                    wa[p[i] - 1]++;
                }

            }
        }

        System.out.println(acCnt + " " + waCnt);
    }
}

Measured memory_bytes: 70844
/*
 * Pawan Harendra Mishra
 */

/*
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
*/

/*
 * Windows Powershell
 * Get-Content input.txt | ./a.exe > output.txt
 */

#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mod 1000000007
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string s;
ll n, k, m;

int main(int argc, char const *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // //freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif
    
    cin >> n >> k >> s;
    m = s[--k] - 'A';
    s[k] = m + 'a';
    cout << s << endl;
    return 0;
}

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

int main() {
  int n, q;
  int ret = 0;
  cin >> n;
  vector<int> s(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  vector<int> t(q);
  for (int i = 0; i < q; i++) {
    cin >> t[i];
  }
  for (auto &&var : t) {
    int i = 0;
    s[n] = var;
    while (s[i] != var) {
      i++;
    }
    ret += i == n ? 0 : 1;
  }
  cout << ret << '\n';

  return 0;
}



Measured memory_bytes: 3132
#include <stdio.h>
typedef long long ll;

ll n, p[8], q[8], cnt = 0, ans = 0, a[8];
bool flg[8];

void dfs(ll m) {
  ll i;
  if(m == n) {
    cnt++;
    bool b = true;
    for(i = 0; i < n; ++i) if(p[i] != a[i]) b = false;
    if(b) ans += cnt;
    b = true;
    for(i = 0; i < n; ++i) if(q[i] != a[i]) b = false;
    if(b) ans -= cnt;
    return;
  }
  for(i = 0; i < n; ++i) if(flg[i]) {
    a[m] = i, flg[i] = false;
    dfs(m + 1);
    flg[i] = true;
  }
}

int main(void) {
  ll i, j, k;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) scanf("%lld", &p[i]), p[i]--;
  for(i = 0; i < n; ++i) scanf("%lld", &q[i]), q[i]--;
  for(i = 0; i < n; ++i) flg[i] = true;
  dfs(0);
  printf("%lld", ans > 0 ? ans : -ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
   string s;
   long long k,i=0;
   cin>>s>>k;
   k-=1;
   while(i<k){
    if(s[i]!='1'){
       cout<<s[i];
       return 0; 
    }
    i++;
   }
   cout<<s[i]; 
    return 0;
}


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


int main() {
  string s;
  cin>>s;
  string t;
  cin>>t;
  bool h =false;
  if(t.size()==s.size()+1){
    int x=0;
    rep(i,s.size()){
      if(s[i]==t[i]){
        x++;
      }
      if(x==s.size())h=true;
    }

  }
  if(h==true) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}

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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
int p[120000];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> p[i], p[i]--;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (p[i] == i)
			++ans, ++i;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#define Ganesha ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define lli long long int
using namespace std;
int main(){
    Ganesha
    lli n,m;
    cin>>n;
    for(lli i=1;i<=9;i++){
        for(lli j=1;j<=9;j++){
            if(i*j==n) return cout<<"Yes",0;
        }
    }
    return cout<<"No",0;
}

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

main() {
    char a,b; cin >> a >> b;
    if(a=='H' && b=='H' || a=='D' && b=='D')
    cout << "H" << endl;
    else cout << "D" << endl;

    return 0;
}

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

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

  vector<int> button(n);
  for (int i = 0; i < n; i++) {
    cin >> button.at(i);
    button.at(i)--;
  }

  int count = 0, index = 0;
  while (true) {
    if (count > n) {
      cout << -1 << endl;
      break;
    }
    if (index == 1) {
      cout << count << endl;
      break;
    }
    index = button.at(index);
    count++;
  }
}

Measured memory_bytes: 640
/* 
Rohit645
Rohit Kumar 
*/

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end() 
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main() {
	fastIo();
	ll n; cin >> n;
	vector <ll> vec(n+1, 0);
	vector <ll> ans_vec(n+1,0);
	for (ll i = 1; i <= n; i++) {
		ll a; cin >> a;
		vec[i] = a;
	}
	for (ll i = n; i >= 1; i--) {
		ll sum = 0;
		for (ll j = 2*i; j <= n; j += i) {
			sum += ans_vec[j];
		}
		ans_vec[i] = vec[i]^(sum%2);
	}
	ll ans = accumulate(ans_vec.begin(), ans_vec.end(), 0);
	cout << ans << endl;
	for(ll i = 1; i <= n; i++) {
		if (ans_vec[i] == 1) {
			cout << i << " ";
		}
	} 
	return 0;
}

Measured memory_bytes: 3968
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    long k = Long.parseLong(br.readLine());
    long[] arr = new long[50];
    long div = k/50;
    long mod = k%50;
    for (int i=0; i<50; i++) {
      arr[i] = 49L+div;
    }
    for (int i=0; i<mod; i++) {
      arr[i]++;
      for (int j=i+1; j<50; j++) {
        arr[j]--;
      }
    }
    for (int i=0; i<50; i++) {
      sb.append(arr[i]);
      sb.append(" ");
    }
    System.out.println(50);
    sb.delete(sb.length()-1,sb.length());
    System.out.println(sb);
  }
}


Measured memory_bytes: 23252
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    if(s[0] == '9' || s[1] == '9') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int n;
    cin>>n;
    int a[n];   
    ll sum=0,mod=1e9+7;

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=(sum+a[i])%mod;
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        sum=((sum-a[i])%mod+mod)%mod;
        ans=((ans+ (sum*a[i])%mod)%mod+mod)%mod;
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}


void dfs(vector<vector<int>> &g,ll k,int node,vector<ll> &used,vector<ll> &cnt){
	ll num=2;
	used[node]=1;
	for(auto x:g[node]){
		if(used[x]>0)continue;
		cnt[x]=max(0LL,k-num);
		num++;
		dfs(g,k,x,used,cnt);
	}
}

int main()
{
	int n,k;
	cin>>n>>k;

	vector<vector<int>> g(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

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

	vector<ll> used(n,0),cnt(n,0);
	int root=-1;
	rep(i,n){
		if(g[i].size()==1){
			root=i;
			break;
		}
	}

	cnt[root]=k;
	cnt[g[root][0]]=k-1;
	used[root]=1;
	dfs(g,k,g[root][0],used,cnt);

	ll ans=1;
	rep(i,n){
		ans*=cnt[i];
		ans%=mod;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    scanf("%d",&x);
    int mid=sqrt(2*x),ans=1e9;
    for(int i=mid+1;i>0;i--)
    {
        if((i*(i+1)/2)>=x)
        {
            ans=min(ans,i);
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
string to_string(string s) { return '"'+s+'"'; }
string to_string(const char *s) { return to_string((string)s); }
template<typename A,typename B> string to_string(pair<A,B> p) {
    return "("+to_string(p.fi)+","+to_string(p.se)+")";
}
template<typename T> string to_string(T v) {
    int fst=1;string ret="{";
    for(auto x:v) {
        if(!fst) ret+=",";
        fst=0,ret+=to_string(x);
    }
    ret+="}";return ret;
}
void dbg_out() { cerr<<endl; }
template<typename Head,typename... Tail> void dbg_out(Head H,Tail... T) {
    cerr<<" "<<to_string(H);
    dbg_out(T...);
}
#define dbg(...) cerr<<"{"<<#__VA_ARGS__<<"}:",dbg_out(__VA_ARGS__)
int k;
void work(int n) {
    printf("%d\n",n);
    for(int i=0;i<n;i++,cout<<'\n')
        for(int j=0;j<n;j++) {
            int col=(i+j)%n;
            if((i&1)&&col+n<k) col+=n;
            cout<<col+1<<" ";
        }
}
int main() {
    k=gi();
    if(k==1) {
        cout<<1<<'\n'<<1<<'\n';
        return 0;
    }
    for(int i=2;i<=500;i+=2)
        if(i<=k&&k<=2*i) { work(i);return 0; }
    return 0;
}


Measured memory_bytes: 1152