akhauriyash/Code-Regression huggingface dataset:
def code_for_D(test=None):

    N = int(input())

    works = [list(map(int, input().split())) for _ in range(N)]
    works = sorted(works, key=lambda x: x[1])

    time_now = 0
    answer = 'Yes'

    for work in works:
        time_now += work[0]
        time_by = work[1]

        if time_now > time_by:
            answer = 'No'

    print(answer)


def main():
    code_for_D()


if __name__ == '__main__':
    main()


Measured memory_bytes: 55244
#include<iostream>
using namespace std;
int main(){
char c11,c12,c13,c21,c22,c23,c31,c32,c33;

cin>>c11>>c12>>c13;
cin>>c21>>c22>>c23;
cin>>c31>>c32>>c33;
cout<<c11<<c22<<c33;



return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    double a,b;
    cin>>a>>b;
    double ans=2*b-a;
    cout<<ans<<endl;
return 0;
}


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

int main() {
  char A[100100];
  char B[50050];

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

  B[j] = '\0';

  cout << B << endl;

  return 0;
}


Measured memory_bytes: 384
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if a[a[i]-1] == i + 1:
        cnt += 1
print(cnt//2)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int answer = 0;
  while (true) {
    for (int i = 0; i < N; i ++) {
      if (A.at(i) % 2 != 0 || A.at(i) == 0) {
        A.at(0) = -1;
    }else{
      A.at(i) /= 2;
    }
    }

    if (A.at(0) == -1)
      break;

    answer++;
  }
  cout << answer << endl;
}

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

int main(void){
    long x, k, d;
    cin >> x >> k >> d;
    x = labs(x);
    
    if( x/d > k ){
        cout << labs( x - k*d ) << endl;
    }
    else{
        long k_near_zero = x/d;
        long k_remain = k - k_near_zero;
        if(k_remain&1){
            cout << labs( x - (k_near_zero+1)*d ) << endl;
        }
        else{
            cout << labs( x - k_near_zero*d ) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3520
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Globalization;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            String A = Console.ReadLine();
            String B = Console.ReadLine();

            if(A.Count() > B.Count())
            {
                Console.WriteLine("GREATER");
            }
            else if(A.Count()< B.Count())
            {
                Console.WriteLine("LESS");
            }
            else
            {
                if (A == B)
                {
                    Console.WriteLine("EQUAL");
                }
                else {
                    for (int i = 0; i < A.Count(); i++)
                    {
                        if (A[i] > B[i])
                        {
                            Console.WriteLine("GREATER");
                            break;
                        }
                        else if (A[i] < B[i])
                        {
                            Console.WriteLine("LESS");
                            break;
                        }
                        else
                        {
                            ;
                        }
                    }
                }
            }

        }
    }
}


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

int main(){
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int dp[n];
	dp[0]=0;
	for(int i=1;i<n;i++){
		dp[i]=INT_MAX;
		for(int j=1;j<=k;j++){
			if(i-j<0)
				break;
			dp[i]=min(dp[i],abs(arr[i]-arr[i-j])+dp[i-j]);
		}
		//cout<<dp[i]<<" ";
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4396
def solve(n, p):
    c = 0
    i = 0

    while i < n-2:
        if i == p[i]:
            c += 1
            if i+1 == p[i+1]:
                i += 1
        i += 1

    if p[n-2] == n-2 or p[n-1] == n-1:
        c += 1

    return c


if __name__ == '__main__':
    n = int(input())
    p = [pi-1 for pi in map(int, input().split())]
    print(solve(n, p))


Measured memory_bytes: 13880
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

vector<ll> vec;
vector<ll> a;
vector<ll> b;
vector<ll> c;
vector<ll> d;
ll ans = 0;

void saiki(ll n, ll m, ll index, ll num, ll q){
    if(index == n){
        ll tmp = 0;
        rep(i,q){
            if(vec[b[i]] - vec[a[i]] == c[i]){
                tmp += d[i];
            }
        }
        ans = max(ans, tmp);
        /*
        rep(i,n){
            cout << vec[i] << " ";
        }
        cout << endl;
        */
        return;
    }
    for(ll i = num; i < m; i++){
        vec[index] = i;
        saiki(n, m, index+1, i, q);
    }
}



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

    ll n, m, q;
    cin >> n >> m >> q;

    
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);

    rep(i,q){
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        A--; B--;
        a[i] = A; b[i] = B; c[i] = C; d[i] = D;

    }

    vec.resize(n,0);
    saiki(n, m, 0, 0, q);

    cout << ans << endl;

    



}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int main(void){
    int r,d,x,a[11];
    cin >> r >> d >> x;
    a[0] = r*x-d;
    cout << a[0] << endl;
    for(int i = 1;i < 10;i++){
        a[i] = (r*a[i-1]-d);
        cout <<  a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
class MiddleSquare  # 8digit

  def initialize(seed)
    @seed = seed
    @n=4
  end

  def random
    t= (@seed**2).to_s
    r=("00000000"+t.slice(0..-(@n/2+1))).slice(-@n..-1).to_i
    @seed = r
    return r
  end

end

def main
  if true then
    fh=STDIN
  else
    fh=open("in1_0137.txt")
  end
  n=fh.gets.chomp.to_i
  0.upto(n-1){|i|
    s=fh.gets.chomp.to_i
    ans=[]
    r=MiddleSquare.new(s)
    10.times{|j|
      ans.push(r.random)
    }
    puts "Case #{i+1}:"
    puts ans
  }
end

if $0==__FILE__ then
  main
end

Measured memory_bytes: 8592
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {


    Scanner sc =new Scanner(System.in);
   int a =sc.nextInt();
   int b =sc.nextInt();
   double x =(a+b)/2.0;
   int p =(a+b)/2;
   if (x-p==0.5) {
	   System.out.println(p+1);


   }
   else {System.out.println(p);}

	}

}


Measured memory_bytes: 21204
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  vector<int> v;
  int sum=0;
  int temp=1;
  while(sum<n){
    sum+=temp;
    temp++;
  }
  int x=sum-n;
  for(int i=1;i<temp;i++){
    if(i!=x)cout << i << endl;
  }
return 0;}

Measured memory_bytes: 256
fun main(){
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val sunukeList = List(n){ 0 }.toMutableList()
    for (i in 0 until k){
        val d = readLine()!!.split(" ").map { it.toInt() }[0]
        val A = readLine()!!.split(" ").map { it.toInt() }
        for (j in 0 until d){
            sunukeList[A[j]-1]++
        }
    }
    sunukeList.sort()
    var count = 0
    for (i in 0 until n){
        if (sunukeList[i] == 0) count++
        else break
    }
    println(count)
}


Measured memory_bytes: 38924
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, M, Q;
vec L[510];
int dp[510][510]; // dp[L][R]:= 閉区間[L,R]に完全に含まれる列車の本数。

int rec(int l, int r) {
  if (dp[l][r] >= 0) {
    return dp[l][r];
  }
  if (l > N - 1 || r < 0 || l > r) {
    return 0;
  }

  int res = rec(l + 1, r) + rec(l, r - 1) - rec(l + 1, r - 1);
  res += (int)(upper_bound(ALL(L[l]), r) - lower_bound(ALL(L[l]), r));
  return dp[l][r] = res;
}

signed main() {
  cin >> N >> M >> Q;
  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    L[l].push_back(r);
  }

  for (int i = 0; i < N; i++) {
    sort(ALL(L[i]));
  }

  mm(dp);
  dp[0][N - 1] = rec(0, N - 1);

  for (int i = 0; i < Q; i++) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    cout << dp[p][q] << endl;
  }

  return 0;
}


Measured memory_bytes: 5504
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    a, b, c, k = map(int, input().split())
    if k <= a:
        print(k)
    elif k <= a+b:
        print(a)
    else:
        print(a - (k - a - b))


if __name__ == '__main__':
    main()


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

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

int main() {
	int n = ri();
	std::vector<std::pair<int, int> > a(n);
	for (auto &i : a) i.first = ri(), i.second = ri();
	
	int r0 = 1000000000, r1 = -1000000000;
	int r2 = 1000000000, r3 = -1000000000;
	for (auto i : a) {
		r0 = std::min(r0, i.first + i.second);
		r1 = std::max(r1, i.first + i.second);
		r2 = std::min(r2, i.first - i.second);
		r3 = std::max(r3, i.first - i.second);
	}
	int res = 0;
	for (auto i : a) {
		res = std::max(res, i.first + i.second - r0);
		res = std::max(res, r1 - (i.first + i.second));
		res = std::max(res, i.first - i.second - r2);
		res = std::max(res, r3 - (i.first - i.second));
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 4824
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#define mod 1000000007
#define MAX 1000000
typedef long long ll;
using namespace std;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2;i<MAX;i++){
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll COM(int n, int k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[n-k] * finv[k] % mod) % mod;
}

int main(){
  int X,Y; cin >> X >> Y;
  if((2*Y-X) % 3 != 0 || (2*X-Y) % 3 != 0){
    cout << 0 << endl;
    return 0;
  }
  if((2*Y-X) < 0 || (2*X-Y) < 0){
    cout << 0 << endl;
    return 0;
  }
  int n = (2*Y-X)/3, m = (2*X-Y)/3;
  COMinit();
  cout << COM(n+m,n) << endl;
  return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int n,k;
ll x=1,m=1;
cin>>n>>k;
ll a[n];
FOR(i,n)
{
	cin>>a[i];
}
FOR(i,n)
{
	if(i>=k)
	{
		x=a[i-k];
		m=a[i];
		if(m>x)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
	else
	{
		
	}
	
}
return  0;
}






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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  int res = h[k - 1] - h[0];
  for (int i = 0; i < n - k + 1; i++) {
    res = min(res, h[k - 1 + i] - h[i]);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
int mergeSort(int left, int right)
{
  if(left + 1 < right) {
    int mid = (left + right) >> 1;
    return (mergeSort(left, mid) + mergeSort(mid, right) + right - left);
  } else {
    return (0);
  }
}
 
int main()
{
  int N, A[500000];
  scanf("%d", &N);
  for(int i = 0; i < N; i++) scanf("%d", &A[i]);
  sort(A, A + N);
  for(int i = 0; i < N; i++) {
    if(i > 0) putchar(' ');
    printf("%d", A[i]);
  }
  putchar('\n');
  printf("%d\n", mergeSort(0, N));
}

Measured memory_bytes: 5140
// 2017/12/26 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int m, nmin, nmax;
		cin >> m >> nmin >> nmax;

		if(m==0 && nmin==0 && nmax==0)
			break;

		int P[200];
		for(int i=0; i<m; i++){
			cin >> P[i];
		}

		int gap = -1;
		int n = -1;

		for(int i=nmin-1; i<nmax; i++){
			int g = P[i]-P[i+1];

			if(gap<=g){
				gap = g;
				n = i+1;
			}

//			cout << i << ' ' << g << ' ' << gap << ' ' << n << endl;
		}

		cout << n << endl;
	}

	return 0;
}

Measured memory_bytes: 3084
//Name: Abacus
//Level: 2
//Category: 文字列
//Note: 

/**
 * やり方は色々あるが、最初に全体が収まるバッファを取っておき、1桁ずつ埋めていくとよい。
 *
 * オーダーは O(log N)。
 */
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool solve(bool first) {
    int N;
    if(!(cin >> N)) return false;

    if(!first) cout << endl;
    vector<string> f(8, string(5, ' '));
    for(int i = 4; i >= 0; --i) {
        int d = N % 10;
        N /= 10;

        f[2][i] = '=';
        if(d >= 5) {
            f[1][i] = '*';
            d -= 5;
        } else {
            f[0][i] = '*';
        }
        for(int j = 0; j < 5; ++j) {
            if(d == j) continue;
            f[j+3][i] = '*';
        }
    }
    for(const string &s : f) {
        cout << s << endl;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    while(solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1208
import collections

n = int(input())
s = input()

s1 = s[:n]
s2 = s[-1:-(n + 1):-1]

s_1 = collections.defaultdict(int)
s_2 = collections.defaultdict(int)
for i in range(2 ** n):
    bin_i = bin(i + 2 ** n)
    sequence1 = ""
    sequence1_inverse = ""
    sequence2 = ""
    sequence2_inverse = ""
    for j in range(n):
        if bin_i[j + 3] == "1":
            sequence1 += s1[j]
            sequence2 += s2[j]
        else:
            sequence1_inverse += s1[j]
            sequence2_inverse += s2[j]
    s_1[sequence1 + "-" + sequence1_inverse] += 1     
    s_2[sequence2 + "-" + sequence2_inverse] += 1
ans = 0
for i in dict(s_1):
    ans += s_1.get(i, 0) * s_2.get(i, 0)
    '''
    if i in dict(s_2):
        ans += dict(s_1)[i] * dict(s_2)[i]
    '''
print(ans)


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

int main(){
  string s;
  cin >> s;
  int p = 0;
  for(int i = 0; i < s.length(); i++)
    if(s[i] == 'p')
      p++;
  cout << s.length() / 2 - p << endl;
}


Measured memory_bytes: 640
import fractions

n=int(input())
A=list(map(int,input().split()))

X=[A[0]]
Y=[A[-1]]


a=A[0]
for i in range(1,n):
    a=fractions.gcd(A[i],a)
    X.append(a)
b=A[-1]
for i in range(1,n):
    b=fractions.gcd(A[-i-1],b)
    Y.append(b)
    
    
M=[X[-1],Y[-1],X[-2],Y[-2]]
for i in range(1,n-1):
    m=fractions.gcd(X[i-1],Y[-i-2])
    M.append(m)
print(max(M))
    

Measured memory_bytes: 16124
#include <iostream>
int main(){
int N;
std::cin >> N ;
	
int A =N/100000000+N%100000000/10000000+N%10000000/1000000+N%1000000/100000+ N%100000/10000+ N%10000/1000 + N%1000/100 + N%100/10 + N%10;
if(N%A==0)
 std::cout << "Yes" ;
else
 std::cout << "No" ;
}

Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(Int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(Int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1LL<<50);

void solve(long long N){
  Int cur = 0, p = 26;
  string ans = "";
  N--;
  rep(i, 20){
    // [cur, cur + p)
    dump(N, p);
    if(N < p){
      rep(j, i+1){
        ans += char('a' + N % 26LL);
        N /= 26LL;
      }
      reverse(ALL(ans));
      break;
    }else{
      N -= p;
      p *= 26LL;
    }
  }
  cout << ans << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int N;
    cin >> N;
    LL a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    LL ans=0,sum=0;
    for(int i=0;i<=N;i++){
        if(a[i]==0||i==N){
            ans+=sum/2;
            sum=0;
        }
        else{
            sum+=a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define bit(s,i) (((s)>>(i))&1LL)
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

signed main() {
	EmiliaMyWife

	int k;
	cin >> k;
	cout << arr[k-1];

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {
	int parent;
	int left;
	int right;
}; 

Node T[MAX];
int n, D[MAX];

void print(int u)
{
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].parent << ", ";
	cout << "depth = " << D[u] << ", ";
	
	if(T[u].parent == NIL)
	{
		cout << "root, ";
	}
	else if(T[u].left == NIL)
	{
		cout << "leaf, ";
	}
	else
	{
		cout << "internal node, ";
	}
	
	cout << "[";
	
	for(i = 0, c = T[u].left; c != NIL; ++ i, c = T[c].right)
	{
		if(i)	cout << ", ";
		cout << c;
	}
	
	cout << "]" << endl;
}

// 递归求深度 
void rec(int u, int p)
{
	D[u] = p;
	if(T[u].right != NIL)
	{
		rec(T[u].right, p);
	}
	if(T[u].left != NIL)
	{
		rec(T[u].left, p + 1);
	}
}

int main()
{
	int i, j, d, v, c, l, r;
	cin >> n;
	for(i = 0; i < n; ++ i)
	{
		T[i].parent = T[i].left = T[i].right = NIL;
	}
	
	for(i = 0; i < n; ++ i)
	{
		cin >> v >> d;
		for(j = 0; j < d; ++ j)
		{
			cin >> c;
			if(j == 0)	
			{
				T[v].left = c;	// 父节点的左孩子为c 
			}
			else	
			{
				T[l].right = c;	// 当前兄弟节点为c 
			}
			l = c;	// 记录前一个兄弟节点 
			T[c].parent = v;
		}
	}
	for(i = 0; i < n; ++ i)
	{
		if(T[i].parent == NIL)
		{
			r = i;
		}
	}
	
	rec(r, 0);
	
	for(i = 0; i < n; ++ i)
	{
		print(i);
	}
	
	return 0;
}


Measured memory_bytes: 7676
/**
*    created: 12.07.2020 02:43:53
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a); s.insert(b); s.insert(c); 
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


long long com(long long N, long long R) {
    if (R < 0 || R > N) return 0;
    if (R == 1) return N;
    else if (R == 2) return N * (N-1) / 2;
    else return N * (N-1) * (N-2) / 6;
}

long long pow(long long N, long long k) {
    long long res = 1;
    for (int i = 0; i < k; ++i) res *= N;
    return res;
}

string S;
int N, K;

long long solve(int i, int k, int smaller) {
    if (i == N) {
        if (k == 0) return 1;
        else return 0;
    }
    if (k == 0) return 1;
    
    if (smaller) return com(N-i, k) * pow(9, k);
    else {
        if (S[i] == '0') return solve(i+1, k, false);
        else {
            long long zero = solve(i+1, k, true);
            long long aida = solve(i+1, k-1, true) * (S[i] - '1');
            long long icchi = solve(i+1, k-1, false);
            return zero + aida + icchi;
        }
    }
}

int main() {
    cin >> S >> K;
    N = S.size();
    cout << solve(0, K, false) << endl;
}


Measured memory_bytes: 512
a,b,c,k = map(int,input().split())

'''
if k%2==0:
    num = (2**k+2)/3
    tak = num*a+(num-1)*b+(num-1)*c
    nak = (num-1)*a+num*b+(num-1)*c

else:
    num = (2**k+1)/3
    tak = (num-1)*a+num*b+num*c
    nak = num*a+(num-1)*b+num*c
'''
if k%2==0:
    ans=a-b
else:
    ans=b-a

if abs(ans)>10**18:
    print('Unfair')
else:
    print(ans)



Measured memory_bytes: 3060
(defun split-with (string &key (delimiterp #'(lambda (c) (char= c #\Space))))
  (loop :for beg = (position-if-not delimiterp string)
        :then (position-if-not delimiterp string :start (1+ end))
        :for end = (and beg (position-if delimiterp string :start beg))
        :when beg :collect (subseq string beg end)
        :while end))

(destructuring-bind (a b c)
    (mapcar #'parse-integer (split-with (read-line)))
  (format t "~a~%" (if (= (- b a) (- c b)) "YES" "NO")))


Measured memory_bytes: 15460
#include <stdio.h>
int main()
{
  int w,h,x,y,r;
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
  if(x-r>=0&&x+r<=w&&y+r<=h&&y-r>=0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
  }

Measured memory_bytes: 1012
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>



int main() {
	cout << "square1001" << endl;
}




Measured memory_bytes: 2992
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <iostream>
#include<string>
#include<map>
#include<queue>
#include <sstream>      //contains 'istringstream'
#include<algorithm>
#include <assert.h> 
# include <cstdio> 
# include <string> 
# include <vector>
#include<stdlib.h>
#include<set> 
#include<list>
#include<math.h>
#include<iomanip>
#include <string.h> 
using namespace std;
#define ln cout << "\n";
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll unsigned long long int
#define  sll stack<ll>
#define  qll queue<ll>
#define  pll pair<ll,ll>
#define  vll vector<ll>
#define  vpll vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define test ll t; cin >> t; while(t--)
#define log log2
#define cases cout << "Case " << i << ":\n"; 
#define tests ll t,i; cin >> t; for(i=1;i<=t;i++)
// #define MAXN 500100
// vll adj[500100]; bool vis[500100]={0}; bool present[500100]={0};
// ll dist[500100];
// ll cnt=0;

// void dfs(ll nd){
//     if(vis[nd] ==0){
//     vis[nd] =1;
//     for(ll i=0;i<adj[nd].size();i++){
//         if(vis[adj[nd][i]]==0)
//             dfs(adj[nd][i]);
//     }}
// }
void solve(){
    string s;
    s="";
    cin >> s;
    ll i, n=s.size();
    cout << s;
    if(s[n-1] =='s'){
        cout << "es";
    }
    else {
        cout << "s";
    }
}

int main()
{
    fastio  
    //tests{
    //    cases
        solve();
    //}
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
bool hako[200100];
bool hakoa[200100];
vector<int>res;
int resnum;
int main(){
  int n;
  cin >> n;
  rep(i,0,n){
    int a;
    cin >> a;
    hako[i+1] = a==1;
  }
  for(int i=n;i>0;i--){
    bool a = false;
    for(int j=i+i;j<=n;j+=i){
      a ^= hakoa[j];
    }
    if(a != hako[i]){
      resnum++;
      res.push_back(i);
      hakoa[i] = true;
    }
  }
  cout << resnum << endl;
  if(resnum == 0)return 0;
  for(int i=0;i<res.size();i++){
    cout << res[i] << " ";
  }
  cout << endl;
	return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int N, V, P;
ll M;

// 遅い
int solve(int i, vector<ll> &A){
    // A[i] が選ばれる可能性があるかどうか判定する
    // A[i] にM回投票されたときに上位に入る可能性があるかどうか
    // 各投票者が A[i] の他にもV-1 回投票することに注意する必要がある
    // A[i] のライバルになりえない（弱いやつ or (P-1)個まで上限の強いやつに投票する）
    // 総投票数は M * V でこれを各問Mを上限に任意の問題に分配可能
    // A[P-1] > A[j] + M だった場合何をやっても無理 
    // P-1 問の上位にV振る、A[i] に M 振る、A[i]より低いスコアの問題A[j]に M振る
    // A[P-1]からA[i-1]の問題のなかで、M + A[i] >= A[j] を満たす A[j] に M - A[j] + A[i] 振る
    // ここまでで　M * V 個振れたらok

    if (i == N) return 1;
    if (A[P-1] > A[i] + M) return 1;

    ll cnt = M * V;
    cnt -= (P - 1) * M;
    cnt -= M;
    cnt -= (N-i-1) * M;

    for (int j=P-1; j<i; j++){
        if (M + A[i] >= A[j]){
            cnt -= M - A[j] + A[i];
        }
    }
    if (cnt <= 0){
        return 0;
    }
    return 1;
}

int main(){
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    for (int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end(), [](ll a, ll b){
        return a > b;
    });
    // for (ll a : A){
    //     cout << a << " ";
    // }
    // cout << endl;

    // 二分探索
    int l=0; // ぜったい通る
    int r=N; // 絶対通らない
    while(r-l > 1){
        int c = (l+r) / 2;
        if (solve(c, A) == 0){
            l = c;
        } else{
            r = c;
        }
    }
    cout << r << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**/int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int h,w,k;
int ans=0;
vector<vector<char>> ta;

int dfs(string bit){
	if(bit.size()==h+w){
		string tate=bit.substr(0,h);
		string yoko=bit.substr(h,w);
		auto table=ta;
		int co=0;
		rep(i,h)if(tate[i]=='1')rep(j,w)table[i][j]='.';
		rep(i,w)if(yoko[i]=='1')rep(j,h)table[j][i]='.';
		rep(i,h)rep(j,w)if(table[i][j]=='#')co++;
		if(co==k)ans++;
		return 0;
	}else{
		dfs(bit+'0');
		dfs(bit+'1');
	}
	return 0;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	in(h,w,k);
	ta.resize(h,vector<char>(w));
	rep(i,h)rep(j,w)in(ta[i][j]);
	dfs("");
	out(ans);
	return 0;
}


Measured memory_bytes: 3660
#include<iostream>	// 入出力
#include<stdio.h>	// 入出力
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか


using namespace std;

using ll = long long;

int a[10000];
int b[10000];



int main()
{
	ll nA = 0, nB = 0;

	int N;

	cin >> N;

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

	for (int i = 0; i < N; ++i)
	{
		if (a[i] < b[i])
		{
			nA += (b[i] - a[i]) / 2;
		}
		if (a[i] > b[i])
		{
			nB += (a[i] - b[i]);
		}
	}

	if (nA < nB)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;

}

Measured memory_bytes: 384
N,M = gets.split.map(&:to_i)
S = gets.chomp
T = gets.chomp
L = N*M/N.gcd(M)
h = {}; g = {}
(0...N).each{ |i| h[i*L/N] = i }
(0...M).each{ |i| g[i*L/M] = i }
p h.keys.all?{ |a| !g[a] || S[h[a]] == T[g[a]] } ? L : -1


Measured memory_bytes: 13436
#include <iostream>

using namespace std;

int main()
{
	int P, N, C = 0, SUM1 = 0, SUM2 = 0; char ch;

	while (cin >> P >> ch >> N)
	{
		SUM1 += P * N;
		SUM2 += N;

		C++;
	}

	cout << SUM1 << endl << static_cast<int>(static_cast<double>(SUM2) / C + 0.5) << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,m;
    cin>>n>>m;
    vector<pll> a(n),b(m);
    for(int i=0;i<n;i++){
        ll A,B;
        cin>>A>>B;
        a[i]={A,B};
    }
    for(int i=0;i<m;i++){
        ll A,B;
        cin>>A>>B;
        b[i]={A,B};
    }
    sort(a.begin(),a.end(),greater<pll>());
    sort(b.begin(),b.end(),greater<pll>());
    priority_queue<ll,vector<ll>,greater<ll>> Q;
    ll l=0;
    for(int i=0;i<m;i++){
        while(l<n && a[l].F>=b[i].F){
            Q.push(a[l].S);
            l++;
        }
        while(Q.size()>=b[i].S){
            Q.pop();
        }
    }
    ll ans=0;
    while(!Q.empty()){
        ans+=Q.top();
        Q.pop();
    }
    for(ll i=l;i<n;i++){
        ans+=a[i].S;
    }
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 5960
#include <cstdio>
main(){
 char op;
 int a,b;
 while(1){
  scanf("%d %c %d",&a,&op,&b);
    if(op == '?')break;
    else if(op == '+'){printf("%d\n",a+b);}
    else if(op == '-'){printf("%d\n",a-b);}
    else if(op == '*'){printf("%d\n",a*b);}
    else if(op == '/'){printf("%d\n",a/b);}
 }
}

Measured memory_bytes: 1028
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N;
  cin >> N;
  int wa = 0;
  int tmp;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    if (tmp != i+1) {
      wa++;
    }
  }
  if (wa==0 or wa==2){
    cout << "YES";
  } else {
    cout << "NO";
  }
}
  /*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
  //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();

        System.out.println(solve(r, D, x));

        sc.close();
    }

    static String solve(int r, int D, int x) {
        int[] result = new int[10];
        for (int i = 0; i < result.length; ++i) {
            x = r * x - D;
            result[i] = x;
        }

        return Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining("\n"));
    }
}

Measured memory_bytes: 36028
n = int(input())
a = list(map(int, input().split()))

ga = []
for i, e in enumerate(a):
    if i + 1 == e:
        ga.append(i + 1)
flag = 0
ans = 0
for i in range(len(ga) - 1):
    if flag == 1:
        flag = 0
        continue
    if ga[i + 1] - ga[i] == 1:
        flag = 1
        ans += 1
print(ans + len(ga) - 2*ans)


Measured memory_bytes: 14008
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int H, W, K;
  std::cin >> H >> W >> K;
  std::vector<std::string> grid(H);
  for (auto &s: grid) {
    std::cin >> s;
  }
  int ans = H + W;
  for (int S: range(0, 1 << (H - 1))) {
    int size = __builtin_popcount(S) + 1;
    std::vector<int> cur(size);
    int cut = 0;
    bool unable = false;
    for (int j: range(0, W)) {
      std::vector<int> cnt(size);
      int idx = 0;
      for (int i: range(0, H)) {
        cnt[idx] += grid[i][j] - '0';
        if (S & (1 << i)) {
          ++idx;
        }
      }
      bool flag = false;
      for (int i: range(0, size)) {
        if (cur[i] + cnt[i] > K) {
          flag = true;
        }
        if (cnt[i] > K) {
          unable = true;
        }
      }
      if (unable) {
        break;
      }
      if (flag) {
        ++cut;
        cur = cnt;
      }
      else {
        for (int i: range(0, size)) {
          cur[i] += cnt[i];
        }
      }
    }
    if (!unable) {
      chmin(ans, size - 1 + cut);
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll x, k, d;in(x),in(k),in(d);
  ll kk = abs(x)/d + (abs(x)%d != 0);
  if (x < 0) x += min(kk, k) * d;
  else x -= min(kk, k) * d;
  k -= min(kk, k);
  if (k%2==0) {
    print(abs(x));
    return 0;
  }
  
  print(min(abs(x+d), abs(x-d)));
  return 0;
}


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

void solve(long long N, vector<long long> A){
	long long memo[N] = {0};
  long long ans = 1;
  for ( long long a : A ) {
    memo[a] += 1;
    if (memo[a] >= 3 || memo[0] >= 2) {
      printf("0\n");
      return;
    }
    if (memo[a] == 2) {
      ans = (ans * 2) % 1000000007;
    }
  }
  printf("%lld\n", ans);
}

int main(){
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <memory>

template <class Key>
class BinarySearchTree {
    struct Node {
        bool isvalid;  // falseなら空Node
        Key key;

        std::unique_ptr<Node> lch, rch;
        Node() : isvalid(false), key(0) {}
    };
    using pNode = std::unique_ptr<Node>;

private:
    pNode root;

    // keyを持つNodeのポインタを返す
    // なければkeyを持つべき空Nodeのポインタを返す
    pNode& search(Key key, pNode& node) {
        if (!node->isvalid) return node;
        if (key == node->key) return node;
        return search(key, (key < node->key ? node->lch : node->rch));
    }

    void dfs(int type, pNode& node, std::vector<Key>& v) {
        if (!node->isvalid) return;

        if (type < 0) v.push_back(node->key);
        dfs(type, node->lch, v);
        if (type == 0) v.push_back(node->key);
        dfs(type, node->rch, v);
        if (type > 0) v.push_back(node->key);
    }

public:
    explicit BinarySearchTree() : root(new Node()) {}

    void insert(Key key) {
        pNode& node = search(key, root);
        if (node->isvalid) return;

        node->isvalid = true;
        node->key = key;
        node->lch.reset(new Node());
        node->rch.reset(new Node());
    }

    bool find(Key key) {
        pNode& node = search(key, root);
        return node->isvalid;
    }

    // type < 0 : 行きがけ順
    // type = 0 : 通りがけ順
    // type > 0 : 帰りがけ順
    std::vector<Key> tour(int type) {
        std::vector<Key> ret;
        dfs(type, root, ret);
        return ret;
    }
};

int main() {
    int Q;
    std::cin >> Q;

    BinarySearchTree<int> bst;
    for (int q = 0; q < Q; ++q) {
        std::string type;
        std::cin >> type;

        if (type == "insert") {
            int key;
            std::cin >> key;
            bst.insert(key);

        } else if (type == "find") {
            int key;
            std::cin >> key;
            std::cout << (bst.find(key) ? "yes" : "no") << std::endl;

        } else {
            auto in = bst.tour(0);
            for (auto k : in) std::cout << " " << k;
            std::cout << std::endl;

            auto pre = bst.tour(-1);
            for (auto k : pre) std::cout << " " << k;
            std::cout << std::endl;
        }
    }
    return 0;
}



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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)

template<class T> vector<pair<T,T>> factorize(T n)
{
    vector<pair<T,T>> factors;

    T lim = sqrt(n) + 0.1;
    
    T c = 0;
    while (n % 2 == 0) {
        n /= 2;
        c++;
    }
    if (c != 0)
        factors.push_back(make_pair(2, c));

    for (T p = 3; p <= lim; p += 2) { //cout << "p:" << p << " n:" << n <<" lim:" << lim << endl;
        T c = 0;
        while (n % p == 0) {
            n /= p;
            c++;
        }
        if (c != 0)
            factors.push_back(make_pair(p, c));
    }
    if (n != 1) {
        factors.push_back(make_pair(n, 1));
    }
    
    return factors;
}

int main()
{
    int n; scanf("%d", &n);

    vector<pair<int, int>> f = factorize(n);

    printf("%d:", n);

    rep(i, f.size()) {
        rep(j, f[i].second) {
            printf(" %d", f[i].first);
        }
    }

    printf("\n");
}



Measured memory_bytes: 3216