akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int a[n][3];
	for(i=0;i<n;i++)
		for(j=0;j<3;j++)
			cin>>a[i][j];
	int d[n][3]={0};
	d[0][0]=a[0][0];
	d[0][1]=a[0][1];
	d[0][2]=a[0][2];
	for(i=1;i<n;i++)
	{
		d[i][0] = a[i][0] +	max(d[i-1][1],d[i-1][2]);
		d[i][1] = a[i][1] +	max(d[i-1][0],d[i-1][2]);
		d[i][2] = a[i][2] +	max(d[i-1][1],d[i-1][0]);
	}
	cout<<max(d[n-1][0],max(d[n-1][1],d[n-1][2]))<<endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long N = scanner.nextInt();
        for (long n = 1; n <= 3500; n++) {
            for (long h = 1; h <= 3500; h++) {
                final long l = 4 * h * n - N * n - N * h;
                if (l == 0) {
                    continue;
                }
                long w = N * n * h / l;
                if (w > 0 && 4 * n * h * w == N * (n * h + h * w + w * n)) {
                    System.out.println(h + " " + n + " " + w);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 23764
h,w,d = gets.split.map(&:to_i)
nums = Array.new(h * w + 1)

h.times do |i|
    line = gets.split.map(&:to_i)
    line.each_with_index {|v, j| nums[v] = [i, j] }
end

diffs = Array.new(90_001, 0)

((d.next)..(h * w)).each do |i|
    diffs[i] = diffs[i - d] + (nums[i][0] - nums[i-d][0]).abs +
                              (nums[i][1] - nums[i-d][1]).abs 
end

exam_counts = gets.strip.to_i

exam_counts.times do |i|
    from, to = gets.split.map(&:to_i)  
    puts diffs[to] - diffs[from]
end

Measured memory_bytes: 11516
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
int n,A[100001],L[100000];
int lis()
{
	L[0]=A[0];
	int len=1;
	
	REP(i,n)
	{
		if(L[len-1]<A[i])
		{
			L[len++]=A[i];
		}
		else
		{
			*lower_bound(L,L+len,A[i])=A[i];
		}
	}
	return len;
}

int main()
{
	cin>>n;
	REP(i,n)cin>>A[i];
	cout<<lis()<<endl;
	return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <bitset>
#include <algorithm>

#define int long long

std::bitset<4000000>b[2];

signed main() {
	int n;
	std::cin >> n;
	
	int a[n];
	for(int i = 0; i < n; i++)
		std::cin >> a[i];
	
	std::sort(a, a+n);
	
	int sum = 0;
	for(int i = 0; i < n; i++)
		sum += a[i];
	
	b[0].set(0,1);
    b[0].set(a[0],1);
    for(int i = 1; i < n; i++)
    {
        b[i&1]=b[i&1]|b[!(i&1)];
        b[i&1]=b[i&1]|(b[!(i&1)]<<a[i]);
    }
    sum++;
    sum/=2;
    for(int i = sum; i < 2*sum + 5; i++) {
		if(b[(n-1)&1][i]) {
			std::cout << i << std::endl;
			return 0;
		}
    }
    
    return 0;
}


Measured memory_bytes: 3200
from sys import exit

n,m = map(int,input().split())
A=[-1]*3

cnt=0
for _ in range(m):
	s,c=map(int,input().split())
	if A[s-1]!=c and A[s-1]!=-1:
		cnt=1
	else:
		A[s-1]=c

if cnt==1 or (A[0]==0 and n>1):
	print("-1")
	exit()
	
if A[0]==-1:
	if n==1:
		A[0]=0
	else:
		A[0]=1

res=0
for i in range(n):
	if A[i]==-1:
		A[i]=0
	res+=A[i]*(10**(n-i-1))

print(res)

Measured memory_bytes: 3064
N, x = map(int, input().split())
arr = list(map(int, input().split()))
s = sum(arr)
for i in range(1,N):
    if arr[i-1] + arr[i] >= x:
        if arr[i-1] <= x:
            arr[i] -= (arr[i] + arr[i-1]) - x
        else:
            arr[i] = 0
            if x-arr[i-1] > 0:
                arr[i-1] -= x-arr[i-1]
            else:
                arr[i-1] -= arr[i-1]-x
print(s-sum(arr))

Measured memory_bytes: 14132
#include <stdio.h>
int main(void){
	char s[4] = { '\0' };
	scanf("%s", s);
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R'){
		printf("3\n");
	} else if(s[0] == 'R' && s[1] == 'R'){
		printf("2\n");
	} else if(s[1] == 'R' && s[2] == 'R'){
		printf("2\n");
	} else if(s[0] == 'S' && s[1] == 'S' && s[2] == 'S'){
		printf("0\n");
	} else{
		printf("1\n");
	}
	return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
int main()
{
    int a=0,s,n,h,b;
    scanf("%d %d",&h,&n);
    for(a=0;a<n;a++)
    {
        scanf("%d",&s);
        h=h-s;
    }
    if(h<=0)
       printf("Yes");
       else printf("No");
       return 0;

}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

Measured memory_bytes: 256
// AOJ 0232
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<cstring>
#include<cmath>
#define rep(i,a) for(int i=0;i<(a);++i)

typedef std::pair<int, int> P;

int X, Y, Z;
int V[4];
std::map<int, P> evnts;
double dp[51][5001][2];

double rec( int pos, int sum, bool eof )
{
	double &ret = dp[pos][sum][eof];

	if( ret >= 0 )
		return ret;

	ret = 0;

	if( pos == Y )
		return ret = sum;

	if( evnts.count( pos ) && !eof )
	{
		int a = evnts[pos].second;

		switch( evnts[pos].first )
		{
			case 1: return ret = rec( std::min( Y, pos+a ), sum, true );
			case 2: return ret = rec( pos, sum+a, true );
			case 3: return ret = rec( pos, std::max( 0, sum-a ), true );
		}
	}

	rep( i, X )
		ret += rec( std::min( Y, pos+V[i] ), sum, false )/X;

	return ret;
}

int main()
{
	while( scanf( "%d%d%d", &X, &Y, &Z ), X|Y|Z )
	{
		evnts.clear();

		rep( i, X )
			scanf( "%d", V+i );
		int sum = 0;
		rep( i, Z )
		{
			int N, E, A;
			scanf( "%d%d%d", &N, &E, &A );
			evnts[N] = P( E, A );
			if( E == 2 )
				sum += A;
		}

		rep( i, Y+1 ) rep( j, sum+1 ) rep( l, 2 ) dp[i][j][l] = -1.0;
		printf( "%d\n", (int)rec( 0, 0, false ) );
	}

	return 0;
}

Measured memory_bytes: 2120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
std::vector<std::vector<long long>> comb(int n, int r) {
	std::vector<std::vector<long long>> v(n + 1, std::vector<long long>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

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

	ll n,cnt=0,ans=1;
	cin >> n;
	vector<ll>p,pb;
	bool sFlag = false;
	for (ll i = 2; i <= pow(10,3); i++) {
		for (ll k = 2; k < i; k++) {
			sFlag = true;
			if (i % k == 0)break;
			sFlag = false;
		}
		if (!sFlag)p.push_back(i);
	}
	for (ll k = 0; k < p.size(); k++) {
			for (ll i = 2; i <= n; i++) {
				ll tmpI = i;
				while (tmpI % p[k] == 0) {
					tmpI /= p[k];
					cnt++;
				}
			}
		pb.push_back(cnt);
		cnt = 0;
	}
	for (ll i = 0; i < pb.size();i++) {
		ans *= pb[i]+1;
		ans %= MOD;
	}
	cout << ans % MOD << endl;
}



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

int main()
{
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  cout << (x + y / 2) << endl;
}

Measured memory_bytes: 256
def main():
    k = int(input())
    d = dict()

    # 2 ** 20 = 10 ** 6
    order = 0
    find = False
    for n_digit in range(1, 20):
        # print('(n_digit, order):', n_digit, order)
        if n_digit == 1:
            for i in range(10):
                d[(n_digit, i)] = 1
            
        else:
            for i in range(10):
                d[(n_digit, i)] = d[(n_digit - 1, i)]
                if i >= 1:
                    d[(n_digit, i)] += d[(n_digit - 1, i - 1)]
                if i <= 8:
                    d[(n_digit, i)] += d[(n_digit - 1, i + 1)]

        for i in range(1, 10):
            if order + d[(n_digit, i)] < k:
                order += d[(n_digit, i)]
            else:
                find = True
            
            if find:
                break

        if find:
            break

    # n_digit, start with i
    ans = list()
    ans.append(i)

    for digit in range(n_digit - 1, 0, -1):
        for j in range(i - 1, i + 2):
            if 0 <= j <= 9:
                if order + d[(digit, j)] < k:
                    order += d[(digit, j)]
                else:
                    ans.append(j)
                    i = j
                    break

    print(''.join(map(str, ans)))


main()

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

int main() {
    int n;
    cin >> n;
    
    for (int i = 0; i <= n; i++) {
        if (i%4==0 && (n-i)%7==0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
 
int bunpai(int A[8][8], int *v, int *h, int *s, int *d, int n)
{
  int r, c;
  int res;
 
  if (n == 0) return 1;
 
  for (r = 0; r < 8; r++) {
    if (h[r] == 0) {
      for (c = 0; c < 8; c++) {
    if (v[c] == 0) {
      if (s[r+c] == 0 && d[r-c+7] == 0) {
        A[r][c] = 1;
        h[r] = 1;
        v[c] = 1;
        s[r+c] = 1;
        d[r-c+7] = 1;
        res = bunpai(A, v, h, s, d, n - 1);
        if (res == 1) return 1;
        else {
          A[r][c] = 0;
          h[r] = 0;
          v[c] = 0;
          s[r+c] = 0;
          d[r-c+7] = 0;
        }
      }
    }
      }
    }
  }
  return 0;
}

int main(int argc, char *argv[])
{
  int A[8][8];
  int k, r, c, i, j;
  int vertical[8];
  int horizontal[8];
  int sum[15];
  int diff[15];
 
  scanf("%d", &k);
 
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++)
    A[i][j] = 0;
    vertical[i] = 0;
    horizontal[i] = 0;
  }
 
  for (i = 0; i < 15; i++) {
    sum[i] = 0;
    diff[i] = 0;
  }
   
  for (i = 0; i < k; i++) {
    scanf("%d", &r);
    scanf("%d", &c);
 
    A[r][c] = 1;
    horizontal[r] = 1;
    vertical[c] = 1;
    sum[r+c] = 1;
    diff[r-c+7] = 1;
  }
 
  bunpai(A, vertical, horizontal, sum, diff, 8 - k);
 
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      if (A[i][j] == 0) printf(".");
      else printf("Q");
    }
    printf("\n");
  }
 
  return 0;
}
 

Measured memory_bytes: 572
require 'openssl'
N,A,B = $<.read.split.map &:to_i
P = 10**9+7
M = P.to_bn
s = 0
[A,B].each {|r|
  r = N-r  if N < r+r
  t = u = 1
  1.upto(r) {|i|
    t,u = [t*(N+1-i), u*i].map!{|x| x>P ? x%P : x}
  }
  s = (s + t * u.to_bn.mod_inverse(M).to_i) % P
}
s = 2.to_bn.mod_exp(N.to_bn,M).to_i - 1 - s
p s<0 ? s+P : s

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	using ii = pair<int,int>;
	vector<ii> a(n);
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		int k = 0;
		while((1<<k) <= x) k++;
		k--;
		if((1<<k) == x){
			a[i] = {k, k};
			ans += k;
		} else {
			a[i] = {k, k+1};
			ans += k + 1;
		}
	}
	vector<int> f(2, 0), nf(2, 0);
	for(int i = 1; i < n; i++){
		int p, q, r, s;
		tie(p, q) = a[i - 1];
		tie(r, s) = a[i];
		nf[0] = max(f[0] + min(p, s), f[1] + min(q, s));
		nf[1] = max(f[0] + min(p, r), f[1] + min(q, r));
		f = nf;
	}
	cout << ans - max(f[0], f[1]) << endl;
	return 0;
}


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

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll N,A,B;
	cin >> N >> A >> B;

	if(A>B) cout << 0 << endl;
	else if(N == 1 && A != B) cout << 0 << endl;
	else cout << (N-2) * (B-A) + 1<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main(){
    int n;
    int cnt=0;
    std::cin>>n;
    for(int i=0;i<n;i++){
        int x;
        std::cin>>x;
        int key=0;
        for(int j=2;j<(int)sqrt(x)+1;j++){
            if(x%j==0){
                key=-1;
            }
        }
        if(key==0){
            cnt++;
        }
    }
    std::cout<<cnt<<'\n';
}


Measured memory_bytes: 3048
# Q3
N, K = map(int, input().split())
x = [int(_) for _ in input().split()]

def distance(left, right):
    if right < 0:
        return abs(left)
    elif left > 0:
        return right
    else:
        return -left + right + min(-left, right)

min_dist = float('inf')
for left in range(N):
    right = left + K - 1
    if right >= N:
        break
    dist = distance(x[left], x[right])
    if dist < min_dist:
        min_dist = dist

print(min_dist)

Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
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)++)


int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    vector<int> dp(n,INT_MAX);
    rep(i,n){
        cin>>a[i];
    }
    dp[0]=0;
    
    FOR(i,1,n){
        for(int j=i-1;j>=0&&i-j<=k;j--){
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
def sample_code():
    n = int(input())
    if n == 1 or n == 2:
        print(0)
        sys.exit(0)
    # print('# 素因数')
    fct = factorize(n)
    # print(fct, num(fct))
    answer = 0
    # print('# 約数')
    for div in divisorize(fct):
        if num(div)-1 > n//num(div):
            answer += num(div) - 1
    print(answer)


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


if __name__ == '__main__':
    sample_code()


Measured memory_bytes: 4468
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

//　引数に与えられた数の消滅までの回数
ll solve(ll n)
{
  if (n == 1)
  {
    return 1;
  }
  return 2 * solve(n / 2) + 1;
}

ll H;

int main()
{
  cin >> H;
  cout << solve(H) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll Q;
  cin >> Q;
  priority_queue<ll> head;
  priority_queue<ll, vector<ll>, greater<ll>> back;
  ll head_sum = 0, back_sum = 0, sum = 0;
  for (ll i = 0; i < Q; ++i) {
    ll q, a, b;
    cin >> q;
    if (q == 1) {
      cin >> a >> b;
      sum += b;
      if (head.size() == 0) {
        head_sum += a;
        head.push(a);
        continue;
      }
      if (head.size() > back.size()) {
        ll head_last = head.top();
        if (head_last > a) {
          head_sum -= head_last;
          head_sum += a;
          back_sum += head_last;
          head.pop();
          head.push(a);
          back.push(head_last);
        }
        else {
          back.push(a);
          back_sum += a;
        }
      }
      else {
        ll back_first = back.top();
        if (back_first < a) {
          back_sum -= back_first;
          back_sum += a;
          head_sum += back_first;
          back.pop();
          back.push(a);
          head.push(back_first);
        }
        else {
          head_sum += a;
          head.push(a);
        }
      }
    }
    else {
      ll mid = head.top();
      ll ans = mid * head.size() - head_sum + back_sum - mid * back.size() + sum;
      cout << mid << " ";
      cout << ans << "\n";
    }
  }
}


Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp
{ 
    class Program
    {
        static void Main(string[] args)
        {
            int[] cnt = new int[] { 0, 0 };
            string s = Console.ReadLine();
            foreach (char ch in s)
            {
                cnt[ch - '0']++;
            }
            int ans = Math.Min(cnt[0], cnt[1]) * 2;
            Console.WriteLine(ans);
            //Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13112
#include<iostream>
using namespace std;
int n;
int main(){
  while(cin>>n){
    cout<<"3C";
    if(n%39!=0){
      if(n%39<10)cout<<"0";
      cout<<n%39<<endl;
    }
    else cout<<"39"<<endl;
  }
  return 0;
}

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

typedef long long ll;

void solve() {
    ll N, ans = 0, prev = 0, A;
    cin >> N;
    rep(i, N) {
        cin >> A;
        if (A == 0) {
            prev = 0;
            continue;
        }
        A += prev;
        ans += A / 2;
        prev = A % 2;
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

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

const long long INF = 1LL << 60;

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define MAX_N 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1

void print(const std::vector<ll>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int par[MAX_N];

void init(int n){
    rep(i,n) par[i]=i;
}

int find(int x){
    if(par[x]==x){
        return x;
    }else
    {
        return par[x] = find(par[x]);
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

void tree_union(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    par[x] = y;
}

int main() {
    char C;
    cin>>C;
    cout<< char((int)C + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n; 
    vector <int> a(n),b; 
    rep(i,n) cin>>a[i];
    b = a;
    sort(b.begin(),b.end());
    int ans = 0;
    rep(i,n){
        int dist = lower_bound(b.begin(),b.end(),a[i]) - b.begin();
        if(abs(dist - i)%2) ans++;
    }
    cout<<ans/2<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define tin cin>>t;while(t--)
#define pii pair<int,int>
#define endl '\n'
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

using namespace std;

int dp[100001]={-1};
int func(int n,int arr[])
{
	//cout<<n<<" "<<dp[n]<<endl;
	if(n==0)
		return 0;
	if(n==1)
		return abs(arr[1]-arr[0]);
	if(dp[n]!=-1)
		return dp[n];
	dp[n]=min(func(n-1,arr)+abs(arr[n]-arr[n-1]),func(n-2,arr)+abs(arr[n]-arr[n-2]));
	//cout<<n<<" "<<dp[n]<<endl;
	return dp[n];
}


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

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 2e5 + 10;
int n;
ll X, D;

struct node {
  ll l, r;
};

map <ll, vector <node> > mp;

int main() {
  scanf("%d %lld %lld", &n, &X, &D);
  if (!D) {
    return printf("%d", X ? n + 1 : 1), 0;
  }
  if (D < 0) {
    D = -D, X -= (n - 1) * D;
  }
  bool flg0 = 0;
  rep(i, 1, n) {
    __int128 L = X * i + __int128(D) * i * (i - 1) / 2;
    __int128 R = X * i + __int128(D) * i * (2 * n - i - 1) / 2;
    if (L <= 0 && R >= 0 && X * i % D == 0) flg0 = 1;
    ll val = X * i % D;
    L = (L - val) / D, R = (R - val) / D;
//    printf("(%lld) %lld %lld\n", (X * i) % D, L, R);
    mp[val].push_back({(ll) L, (ll) R});
  }
  ll ans = !flg0;
  for (auto tmp : mp) {
    vector <node> vec = tmp.second;
    sort(vec.begin(), vec.end(), [] (node P, node Q) {
      return P.l < Q.l;
    });
    ll mx = vec.begin() -> l - 1;
    for (node p : vec) {
      ll l = p.l, r = p.r;
      if (mx < r) ans += (r - max(l - 1, mx)), mx = r;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 22144
N = int(input())
A = list(map(int, input().split()))

num_sum = 0
temp_sum_num = sum(A)

for i in range(N - 1):
    temp_sum_num -= A[i]
    num_sum += A[i] * temp_sum_num


num_sum = num_sum % (10 ** 9 + 7)

print(num_sum)


Measured memory_bytes: 31352
import java.util.Arrays;
import java.util.Optional;
import java.util.Scanner;

class Main
{
    /**
     * ABC 112 B: Time Limit Exceeded
     *     (制限時間以内の最小コストの経路)
     */ 
    public static void main(String[] args)
    {
        // 入力値
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int T = scan.nextInt();
        
        int[][] cts = new int[N][2];
        for (int i = 0; i < N; i++) {
            cts[i][0] = scan.nextInt();
            cts[i][1] = scan.nextInt();
        }
        
        scan.close();
        scan = null;
        
        // 制限時間以内の最小コストの経路を求める
        Optional<int[]> tmp = Arrays.stream(cts)
                .filter(ct -> ct[1] <= T)
                .min((a, b) -> a[0] - b[0]);
        int cost = tmp.orElse(new int[2])[0];
        
        // 出力
        System.out.println(cost > 0 ? cost : "TLE");
    }
}


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


using namespace std;

#define int long long
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define ff first 
#define ss second 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
vi in_d;
vi vis,len;
vvi adj;
void dfs(int n,int pre = 0){
    vis[n] = true;
    for(auto x : adj[n]){
            len[x] = max(len[x],len[n] + 1);
            in_d[x]--;
            if(in_d[x] == 0) 
            dfs(x,len[n] + 1);
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    adj.resize(n);
    vis.resize(n),len.resize(n);
    in_d.resize(n);
    
    for(int i = 0; i < m; ++i){
        int u,v;
        cin >> u >> v;
        --u,--v;
        adj[u].push_back(v);
        in_d[v]++;
    }
    
    for(int i = 0; i < n; ++i){
        if(in_d[i] == 0 && !vis[i]){
            dfs(i);
        }
    }
    
    cout << *max_element(all(len));
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int a, b;
  cin >> a >> b;
  if (a + b == 15)
    cout << "+" << endl;
  else if (a * b == 15)
    cout << "*" << endl;
  else
    cout << "x" << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	xa := make([]int, 0)
	ya := make([]int, 0)
	for {
		x := nextInt(sc)
		y := nextInt(sc)
		if x == 0 && y == 0 {
			break
		}
		xa = append(xa, x)
		ya = append(ya, y)
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < len(xa); i++ {
		tx, ty := xa[i], ya[i]
		fmt.Fprintln(wtr, min(tx, ty), max(tx, ty))
	}
	wtr.Flush()
}



Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
class UnionFind {
  vector<ll> par, rank; // par > 0: number, par < 0: -par
public:
  void init(ll n) {
    par.resize(n); rank.resize(n);
    fill(par.begin(), par.end(), 1); fill(rank.begin(), rank.end(), 0);
  }
  ll getSize(ll x) {
    return par[find(x)];
  }
  ll find(ll x) {
    if (par[x] > 0) return x;
    return -(par[x] = -find(-par[x]));
  }
  void merge(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      par[y] += par[x];
      par[x] = -y;
    } else {
      par[x] += par[y];
      par[y] = -x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
  bool isSame(ll x, ll y) {
    return find(x) == find(y);
  }
};
int main(void){
  ll n,m;
  cin>>n>>m;
  UnionFind uf;
  uf.init(n);
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    a--,b--;
    uf.merge(a,b);
  }
  ll MAX=-1;
  for(int i=0;i<n;i++){
    MAX=max(MAX,uf.getSize(i));
  }
  cout<<MAX<<endl;
}

Measured memory_bytes: 6428
def submit():
    n, k = map(int, input().split())

    b = k + 1
    ans = 0
    while b <= n:
        # bを固定した時にあまりがk以上になるaの数を求める
        block = (n + 1) // b
        rest = (n + 1) - block * b
        ans += (b - k) * block
        ans += max(0, rest - k)
        if k == 0:
            ans -= 1
        b += 1
    print(ans)


submit()
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n;
vector<bool> bit;
ll m_m, m_p;
ll mod_power(ll x, ll n, ll M) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_power((x * x) % M, n / 2, M);
    } else {
        return (mod_power((x * x) % M, n / 2, M) * x) % M;
    }
}

int f(ll x, int cnt = 0) {
    if (x == 0) return cnt;
    return f(x % __builtin_popcount(x), cnt + 1);
}

int main() {
    cin >> n;
    bit.resize(n);
    int cnt = 0;
    rep(i, n) {
        char c;
        cin >> c;
        if (c == '1') bit[i] = true, cnt++;
    }

    rrep(i, n) {
        if (bit[i]) {
            if (cnt - 1 != 0) m_m = (m_m + mod_power(2, n - i - 1, cnt - 1)) % (cnt - 1);
            m_p = (m_p + mod_power(2, n - i - 1, cnt + 1)) % (cnt + 1);
        }
    }
    rep(i, n) {
        if (bit[i]) {
            if (cnt - 1 == 0) {
                printf("%d\n", 0);
                continue;
            }
            ll x = (m_m - mod_power(2, n - i - 1, cnt - 1) + (cnt - 1)) % (cnt - 1);
            int fx = f(x) + 1;
            printf("%d\n", fx);
        } else {
            ll x = (mod_power(2, n - i - 1, cnt + 1) + m_p) % (cnt + 1);
            int fx = f(x) + 1;
            printf("%d\n", fx);
        }
    }
    return 0;
}

Measured memory_bytes: 3744
package main

import (
  "fmt"
  "strconv"
)

func main() {
  var h, w int
  fmt.Scan(&h, &w)

  grid := make([]string, h)
  for i := 0; i < h; i++ {
    fmt.Scan(&grid[i])
  }
  var cnt [51][51]int
  for i := 0; i < h; i++ {
    for j := 0; j < w; j++ {
      if grid[i][j] == '.' {continue}
      for dy := -1; dy < 2; dy++ {
        for dx := -1; dx < 2; dx++ {
          y, x := i + dy, j + dx
          if y < 0 || x < 0 {continue}
          cnt[y][x]++
        }
      }
    }
  }
  for i := 0; i < h; i++ {
    for j := 0; j < w; j++ {
      if grid[i][j] == '#' {
        fmt.Print("#")
      } else {
        fmt.Print(strconv.Itoa(cnt[i][j]))
      }
    }
    fmt.Print("\n")
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;
  ll a[n];
  REP(i, n) cin >> a[i];
  ll s[n + 1];
  s[0] = 0;
  REP(i, n) s[i + 1] = s[i] + a[i];
  ll p, q, ans = 1e17;
  REP(i, n - 1){
    p = s[i + 1], q = s[n] - p;
    ans = min(ans, abs(p - q));
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)

int n;
void counting_sort(int a[], int b[], int k){
    int c[k+1] = {0};
    rep(i,n)c[a[i]]++;
    REP(i,1,k+1)c[i] += c[i-1];
    
    for(int i = n-1;i>=0;i--){
        b[c[a[i]] - 1] = a[i];
        c[a[i]]--;
    }
}

int main(){
    cin >> n;
    int a[n], b[n + 1], m = -1;
    rep(i,n){
        cin >> a[i];
        m = max(m, a[i]);
    }
    //cout << m << endl;
    counting_sort(a, b, m);

    rep(i,n){
        cout << b[i];
        if(i < n-1)printf(" ");
        else printf("\n");
    }
    return 0;
}


Measured memory_bytes: 18736
import java.util.Scanner;

class Problem {
    int N;
    int[] hs;

    Problem() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        hs = new int[N];
        for (int i = 0; i < hs.length; i++) {
            hs[i] = sc.nextInt();
        }
    }

    int solve() {
        int prev1 = 0;
        int prev2 = 0;
        for(int i = 1; i < N; i++) {
            int minCost = Math.abs(hs[i] - hs[i-1]) + prev1;
            if (i - 2 >= 0) {
                int cost = Math.abs(hs[i] - hs[i-2]) + prev2;
                minCost = Math.min(minCost, cost);
            }
            prev2 = prev1;
            prev1 = minCost;
        }

        return prev1;
    }
}

public class Main {
    public static void main(String[] args) {
        int ans = new Problem().solve();
        System.out.println(ans);
    }
}


Measured memory_bytes: 51064
#include<iostream>
#include<vector>
#include<string>
#include<sstream>

using namespace std;

string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main()
{
    int N;
    string S;
    cin >> N >> S;
    string ans = "";

    for(int i=0; i<S.size(); ++i)
    {
        for(int j=0; j<alpha.size(); ++j)
        {
            if(S[i] == alpha[j])
            {
                if(j+N>25)
                {
                    ans += alpha[j+N-25-1];
                }
                else
                {
                    ans += alpha[j+N];
                }
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

long long typedef ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
//template<class Value>
//using dict = std::map< string, Value >;
typedef map<string,int> dict ;

constexpr int IMAX = ((1<<30)-1)*2+1 ;
constexpr int INF = 100000000;
double EPS = 1e-10 ;

typedef const pair<string, int> PSI;
bool cmpCount(PSI &T1, PSI &T2) {
    return T1.second < T2.second;
}

bool cmpLength(PSI &T1, PSI &T2) {
    return T1.first.length() < T2.first.length();
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str ;
  dict M;
  while(cin >> str){
    if(M.count(str) == 0){
      M[str] = 0 ;
    }
    else{
      auto it = M.find(str) ;
      ++it->se ;
    }
  }
  PSI maxCount = *max_element(M.begin(), M.end(), cmpCount);
  PSI maxLength = *max_element(M.begin(), M.end(), cmpLength);

  cout << maxCount.first << " " << maxLength.first << endl;
  return 0;
}

Measured memory_bytes: 1196
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int a[100010];
int main(){
	int n,h;
	cin>>n>>h;
	int cnt=0;
	for(int i=0;i<h;i++){
		cin>>a[i];
		cnt+=a[i];
	}
	if(cnt>=n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int a;
    float b;
    int c;
    cin >> a >> b;
    int k = (100 * b) + 0.01;
    cout << (int)(a * k) / 100 << "\n";
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
	
	ld n;
	cin>>n;
	ld x=n/1.08;
	ll a = ll(x)*1.08;
	ll b = ll(x+1)*1.08;
	if(a==n) cout<<(ll)x;
	else if(b==n) cout<<ll(x+1)<<"\n";
	else cout<<":(";


}


Measured memory_bytes: 3728
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vv<int> A;

int main() {
    cin >> N;
    A = vvec(N, N, 0);
    rep(i, N) {
        rep(j, N) cin >> A[i][j];
    }

    bool cond = true;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            bool connected = true;

            for (int k = 0; k < N; k++) {
                if (A[i][j] > A[i][k] + A[k][j]) {
                    cond = false;
                }
                else if (k != i && k != j && A[i][j] == A[i][k] + A[k][j]) {
                    connected = false;
                }
            }

            if (connected) {
                sum += A[i][j];
            }
        }
    }

    if (cond) {
        write(sum / 2);
    }
    else {
        write(-1);
    }
}

Measured memory_bytes: 640
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef  long double lld;
const ll mod = 1e9 + 7;
const ll mx = 1e5 + 1;

void input(){
    string s;
    cin >> s;
    int len = s.size();
    while(len--)cout << 'x';
    cout << endl;
}
int main(){
    input();
    return 0;
}

Measured memory_bytes: 256
s = [int(i) for i in input()]
n = len(s) - 1
ans = 0
def cnt(bit):
  plus = [False]*n + [True]
  i = n-1
  while bit > 0:
    if bit&1:
      plus[i] = True
    bit = bit >> 1
    i -= 1
  ret = 0
  tmp = 0
  for i in range(n+1):
    tmp = tmp*10+s[i]
    if plus[i]:
      ret += tmp
      tmp = 0
  return ret
for i in range(2**n):
  ans += cnt(i)
print(ans)


Measured memory_bytes: 3064
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

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

int main(){
  long long N;
  cin >> N;
  long long ans = N+1-2; 
  for(long long i=2; i<=sqrt(N); i++){
    if(N%i==0){
      if(i+(N/i)-2 < ans)ans = i+N/i-2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;


import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int X = sc.nextInt();
			final int N = sc.nextInt();
			boolean[] ps = new boolean[100 + 1];
			for(int i = 0; i < N; i++) {
				ps[sc.nextInt()] = true;
			}
			
			int answer = 0;
			for(int i = 0; i <= 101; i++) {
				if(i < ps.length && ps[i]) { continue; }
				
				if(Math.abs(X - i) < Math.abs(X - answer)) {
					answer = i;
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()

int main(void){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    reverse(all(a));
    int alice = 0, bob = 0;
    rep(i,n){
        if(i%2==0) alice += a[i];
        else bob += a[i];
    }
    cout<<alice-bob<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,i,n,h[1000010],y[6]={0};
  while(1){
    for(i=0;i<7;i++){
      y[i]=0;
    }
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d",&h[i]);
      a=h[i]/10;
      if(a>=6){
	a=6;
      }
      y[a]++;
    }
    for(i=0;i<7;i++){
      printf("%d\n",y[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 4504
#include <algorithm>
#include <cstring>
#include <numeric>
#include <cstdio>
int lst[100005], to[200005], pre[200005], tot; 
int ans[100005], seq[100005], deg[100005], dis1[100005], dis2[100005], que[100005], n; 
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u]; 
	deg[u]++; 
	lst[u] = tot++; 
}
inline void move(int pos, int val)
{
	int orig = seq[pos]; 
	for (int i = pos; i < pos + val; i++)
		seq[i] = seq[i + 1]; 
	seq[pos + val] = orig; 
}
void calc(int st, int en)
{
	int u = st, sum = 0, x = -1; 
	std::iota(seq, seq + n, 0);
	while (true)
	{
		int val = deg[u] - (u != st) - (u != en); 
		move(sum, val); 
		sum += val + 1; 
		if (u == en)
			break; 
		for (int i = lst[u]; ~i; i = pre[i])
		{
			if (dis1[to[i]] + dis2[to[i]] == dis1[st] + dis1[en] && to[i] != x)
			{
				x = u; 
				u = to[i];
				break; 
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (ans[i] < seq[i])
			return; 
		if (ans[i] > seq[i])
			memcpy(ans, seq, sizeof(seq)); 
	}
}
int bfs(int st, int *dis)
{
	memset(dis, 0x3f, n << 2); 
	dis[st] = 0; 
	int he = 0, ta = 0;
	que[ta++] = st; 
	while (he < ta)
	{
		int u = que[he++]; 
		for (int i = lst[u]; ~i; i = pre[i])
		{
			if (dis[to[i]] > dis[u] + 1)
			{
				dis[to[i]] = dis[u] + 1; 
				que[ta++] = to[i]; 
			}
		}
	}
	return std::max_element(dis, dis + n) - dis; 
}
int main()
{
	// freopen("ARC095-F.in", "r", stdin); 
	memset(lst, -1, sizeof(lst));
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		add_edge(--u, --v); 
		add_edge(v, u); 
	}
	int u = bfs(0, dis1), v = bfs(u, dis1); 
	bfs(v, dis2); 
	for (int i = 0; i < n; i++)
	{
		bool f = dis1[i] + dis2[i] == dis1[v]; 
		for (int j = lst[i]; ~j && !f; j = pre[j])
		{
			if (dis1[to[j]] + dis2[to[j]] == dis1[v])
				f = true; 
		}
		if (!f)
		{
			puts("-1"); 
			return 0; 
		}
	}
	memset(ans, 0x3f, sizeof(ans)); 
	calc(u, v); 
	calc(v, u); 
	for (int i = 0; i < n; i++)
		printf("%d%c", ans[i] + 1, " \n"[i + 1 == n]);
	return 0; 
}


Measured memory_bytes: 4992