akhauriyash/Code-Regression huggingface dataset:
//Name: Pasta
//Level: 2
//Category: 動的計画法,DP
//Note:

/*
 * 状態となるのは
 * ・今何日目か
 * ・最後にどのソースを使ったか
 * ・最後のソースは2日連続か
 * の3つ．
 * N日目にソースiを使ったときのパターン数は
 * ・N-1日目にソースj(j≠i)を使うときの合計パターン数(このとき，最後に使ったソースiは1日目)
 * ・N-1日目にソースiを使い，かつそれが1日目であるときのパターン数(このとき，最後に使ったソースiは2日連続)
 * で表わせる．
 * あらかじめ使うソースが決まっている日では，そのソース以外の数値が0になるよう処理すればよい．
 */
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MOD = 10000;

// dp[day][last][second]
int dp[100][3][2];
int plan[100];

int main() {
    int N, K;
    cin >> N >> K;
    fill_n(plan, N, -1);
    for(int i = 0; i < K; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        plan[a] = b;
    }

    if(plan[0] == -1) {
        dp[0][0][0] = dp[0][1][0] = dp[0][2][0] = 1;
    }
    else {
        dp[0][plan[0]][0] = 1;
    }
    for(int day = 1; day < N; ++day) {
        if(plan[day] == -1) {
            for(int sauce = 0; sauce < 3; ++sauce) {
                for(int prev = 0; prev < 3; ++prev) {
                    if(prev != sauce) {
                        dp[day][sauce][0] += dp[day-1][prev][0] + dp[day-1][prev][1];
                    }
                    else {
                        dp[day][sauce][1] += dp[day-1][prev][0];
                    }
                }
            }
        }
        else {
            int sauce = plan[day];
            for(int prev = 0; prev < 3; ++prev) {
                if(prev != sauce) dp[day][sauce][0] += dp[day-1][prev][0] + dp[day-1][prev][1];
                else dp[day][sauce][1] += dp[day-1][prev][0];
            }
        }
        for(int sauce = 0; sauce < 3; ++sauce) {
            dp[day][sauce][0] %= MOD;
            dp[day][sauce][1] %= MOD;
        }
    }
    int sum = 0;
    for(int sauce = 0; sauce < 3; ++sauce) {
        sum += dp[N-1][sauce][0] + dp[N-1][sauce][1];
    }
    cout << sum%MOD << endl;
    return 0;
}

Measured memory_bytes: 0
n = int(input())
arr = list(map(int,list(input().split(" "))))

sum = 0
smallest = 1

for i in range(n):

    if i == 0:
        sum += 1
        smallest = arr[i]
    else:
        if arr[i] > smallest:
            continue
        else:
            smallest = arr[i]
            sum += 1

print(sum)




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

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

  vector<int> a(m),b(m);
  for(int i=0;i<m;i++) cin >> a[i] >> b[i];

  vector<int> cnt(n+2);
  rep(i,n) cnt[i]=0;
  
  for(int i=1;i<=n;i++){
    rep(j,m){
      if((a[j] ==i) || (b[j] == i)) cnt[i]++;
    }
  }

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


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

int main() {
	int N;
	cin >> N;
	long int ans = 0;

	int* A = new int[N];
	for (int i = 0; i < N; i++) cin >> A[i];

	for (int i = 0; i < N-1; i++) {
		if (A[i]  > A[i+1]){
			int dif = A[i] - A[i + 1];
			ans += dif;
			A[i + 1] += dif;
		}
	}

	cout << ans;

	return 0;
}


//made by myself

Measured memory_bytes: 3916
object Main extends App {
  import scala.io.StdIn._



  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  println(
    solve(n, k)
  )
  def solve(n: Int, k: Int): Int = {
    if (log2(n) + 1 < k) 0
    else {
      val memo = Array.tabulate(n + 1){_ ⇒ Array.tabulate(k){_ ⇒ -1}}
      def sub(max: Int, rest: Int): Int = {
        if (max > n) 0
        else if (rest == 0) 1
        else if (memo(max)(rest) >= 0) memo(max)(rest)
        else{
          memo(max)(rest) = (2 to n / max).map(i ⇒ sub(i * max, rest - 1)).sum
          memo(max)(rest)
        }
      }
      (1 to n).map(sub(_, k - 1)).sum
    }
  }
  def log2(n: Int): Int = {
    if (n == 1) 0
    else log2(n / 2) + 1
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 295000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  long double a, b, x;
  cin >> a >> b >> x;
  long double deg;
  if (a * a * b / 2 < x) {
    deg = atan(2 * (a * a * b - x) / a / a / a) * 180 / pi;
  }
  else if (a * a * b / 2 == x) {
    deg = atan(b / a) * 180 / pi;
  }
  else {
    long double xx = 2 * x / a / b;
    deg = atan(b / xx) * 180 / pi;
  }
  cout << fixed << setprecision(7) << deg << endl;
}

Measured memory_bytes: 256
fun solve(K: Int, X: Int) {
    var ans = "No"
    if(500 * K >= X) {
        ans = "Yes"
    }
    println(ans)
}

fun main() {
//    val S = readLine()!!
//    val N = readLine()!!.toInt()
    val (K, X) = readLine()!!.split(" ").map { it.toInt() }
//    val A = readLine()!!.split(" ").map { it.toInt() }
    solve(K, X)
}

Measured memory_bytes: 36376
import sys
n, a, b, c, d = [int(x) for x in input().split()]
s = input()
for i in range(a, max(c, d)):
    if s[i - 1: i + 1] == "##":
        print("No")
        sys.exit()
if c < d:
    print("Yes")
    sys.exit()
for i in range(b - 1, d):
    if s[i - 1:i + 2] == "...":
        print("Yes")
        sys.exit()
print("No")

# print(*data, sep='\n')


Measured memory_bytes: 40048
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    long a;
    cin>>a;
    cout<<a*a*a+a*a+a<<endl;
    return 0;
}


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

int main() {
    ll ans = 0;
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<ll>());
    queue<ll> q;
    q.push(A[0]);
    for(int i = 1; i < N; i++) {
        ans += q.front();
        q.pop();
        q.push(A[i]);
        q.push(A[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6428
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

map<ll,ll> mp;

ll rec(ll h){
  if(h==1) return 1;
  else if(mp.count(h)==1){
    return mp[h];
  }
  else {
    return mp[h]=1+2*rec(h/2);
  }
}

int main(){
  ll h;
  cin>>h;
  cout<<rec(h)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int a;
	int b;
	cin >> a >> b;
	if (a < b){
		cout << "a < b" << endl;
	}
	if (a > b){
		cout << "a > b" << endl;
	}
	if (a == b){
		cout << "a == b" << endl;
	};
	return 0;
}

Measured memory_bytes: 3044
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    vector<int64_t> as(n), bs(n);

    for (auto& a : as)
    {
        cin >> a;
    }
    for (auto& b : bs)
    {
        cin >> b;
    }

    // ai + bj の k 桁目に何個 1 が xor されるか
    array<int64_t, 32> counter;
    fill(counter.begin(), counter.end(), 0);

    // 桁上がり考えない
    {
        array<int64_t, 32> a0, a1, b0, b1;
        fill(a0.begin(), a0.end(), 0);
        fill(a1.begin(), a1.end(), 0);
        fill(b0.begin(), b0.end(), 0);
        fill(b1.begin(), b1.end(), 0);

        for (auto a : as)
        {
            for (int i = 0; i < 32; i++)
            {
                if (a & (1ll << i))
                {
                    a1[i]++;
                }
                else
                {
                    a0[i]++;
                }
            }
        }
        for (auto b : bs)
        {
            for (int i = 0; i < 32; i++)
            {
                if (b & (1ll << i))
                {
                    b1[i]++;
                }
                else
                {
                    b0[i]++;
                }
            }
        }
        for (int i = 0; i < 32; i++)
        {
            counter[i] += a0[i] * b1[i] + a1[i] * b0[i];
        }
    }

    // 桁上がり

    for (int i = 0; i < 32; i++)
    {
        const int64_t mask = (1ll << i) - 1;

        vector<int64_t> bs_under(n);
        for (int j = 0; j < n; j++)
        {
            bs_under[j] = bs[j] & mask;
        }
        sort(bs_under.begin(), bs_under.end());

        for (auto a : as)
        {
            const auto a_mask = a & mask;
            auto first_point = lower_bound(bs_under.begin(), bs_under.end(), (1ll << i) - a_mask);

            counter[i] += distance(first_point, bs_under.end());
        }
    }

    int64_t ans = 0;
    for (int i = 31; i >= 0; i--)
    {
        ans *= 2;
        ans += counter[i] % 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0 ; i < s.length() ; i++){
        if(s[i] - '0')
            ans++;
	}
	cout << ans;
    
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const ll mod = 998244353;
const int N = 3e5 + 10;
ll fact[N], invf[N];

ll pwr(ll a, ll n) {
  ll r = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) r = r * a % mod;
    a = a * a % mod;
  }
  return r;
}
ll inv(ll a) {
  return pwr(a, mod - 2);
}

void pre() {
  fact[0] = invf[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
    invf[i] = inv(fact[i]);
  }
}

ll choose(ll n, ll r) {
  if (n < r || r < 0) return 0;
  ll res = invf[r] * invf[n - r];
  res %= mod;
  res *= fact[n];
  res %= mod;
  return res;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  pre();

  ll n, a, b, k; cin >> n >> a >> b >> k;

  ll ans = 0;
  for (int na = 0; na <= n; na++) {
    ll left = k - na * a;
    if (left >= 0 && left % b == 0) {
      int nb = left / b;
      ans += choose(n, na) * choose(n, nb) % mod;
    }
  }
  ans %= mod;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 8292
#include <bits/stdc++.h>
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
using namespace std;

int main() {
    int A, B; cin >> A >> B;

    int nf = -1;
    for (int i = 1; i <= 10000; i++) {
        if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << nf << endl;
}

Measured memory_bytes: 3608
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math
import heapq

from scipy.sparse.csgraph import floyd_warshall

N,M = map(int,input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(A)

for _ in range(M):
    tmp_min = heapq.heappop(A)
    heapq.heappush(A, (-1)*(-tmp_min//2))
print(-sum(A))


Measured memory_bytes: 25752
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+7;  
/*  
    time : 10 : 14    
    date : 22.01.2020
*/    
// int L,R,mid,target,idx ;
int tests() 
{   
    ll n,num  ; 
    cin >> n  ;
    if(n&1)
        return cout << 0 << '\n',0 ; 
    n >>= 1 ; 
    num  = 5 ; 
    ll ans  = 0 ; 
    while( n/num > 0 ){
        ans += n/num ;
        num *= 5 ;
    }
    cout << ans  << '\n' ; 
    return 0 ;
}
int main(){
    I__O ;  
    int cases = 1 ; 
    //cin >> cases;  
    while(cases--)
      tests(); 
  return 0 ; 
}

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;

    if (a >= b - 2) {
        cout << k + 1 << endl;
        return 0;
    }

    long ans = 1;
    while (k) {
        if (ans < a) {
            // ビスケットを円に交換できない
            k--;
            ans++;
        } else if (k > 1) {
            // ビスケットを円に交換でき、かつ、あと2回以上操作を行える
            k -= 2;
            ans += (b - a);
        } else {
            // ビスケットを円に交換できるが、操作があと1回しかできない
            ans++;
            k--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#define lli long long int
lli n; int cnt = 0 ; 
long double dp[305][305][305];

long double ring(int r1,int r2,int r3)
{
	long double ans,a1,a2,a3;
//	printf("Count = %d , at %d %d %d \n", ++cnt, r1, r2, r3);
	if(r1==0&&r2==0&&r3==0)
		return 0;

	if(r1!=0)
	{
		if(dp[r1-1][r2][r3]==-1)
                	dp[r1-1][r2][r3] = ring(r1-1,r2,r3);
		a1 = dp[r1-1][r2][r3];
	}
        else
                a1 = 0;
        
	if(r2!=0)
	{
		if(dp[r1+1][r2-1][r3]==-1)
                	dp[r1+1][r2-1][r3] = ring(r1+1,r2-1,r3);
		a2 = dp[r1+1][r2-1][r3];
	}
        else
        	a2 = 0;
        
	if(r3!=0)
	{
		if(dp[r1][r2+1][r3-1]==-1)
                	dp[r1][r2+1][r3-1] = ring(r1,r2+1,r3-1);
		a3 = dp[r1][r2+1][r3-1];
	}
        else
                a3 = 0;


        dp[r1][r2][r3] = (long double)(n)/(r1+r2+r3) + ((long double)(r1)/(r1+r2+r3))*a1 + ((long double)(r2)/(r1+r2+r3))*a2 + ((long double)(r3)/(r1+r2+r3))*a3;
//	ans = dp[r1][r2][r3] ;
//	printf("Ans at %lld %lld %lld => %0.7f \n", r1, r2, r3, ans);
	return dp[r1][r2][r3];
}



int main(void)
{
	lli i,a ; int r1=0,r2=0,r3=0;
	long double ans,a1,a2,a3;
	scanf("%lld",&n); int j, k ; 
	memset(dp,-1LL,sizeof(dp));
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a);
		if(a==1)
			r1++;
		else if(a==2)
			r2++;
		else
			r3++;
	}
	for(i = 0; i < 303; i++)
		for(j = 0; j < 303; j++)
			for(k = 0; k < 303; k++)
				dp[i][j][k] = -1 ; // printf("%d %d %d %0.7f\n", i, j, k, dp[i][j][k]); 
	/*
	if(r1!=0)
        {
                if(dp[r1-1][r2][r3]==-1)
                        dp[r1-1][r2][r3] = ring(r1-1,r2,r3);
		a1 = dp[r1-1][r2][r3];
        }
        else
                a1 = 0;
        if(r2!=0)
        {
                if(dp[r1+1][r2-1][r3]==-1)
                        dp[r1+1][r2-1][r3] = ring(r1+1,r2-1,r3);
		a2 = dp[r1+1][r2-1][r3];
        }
        else
                a2 = 0;
        if(r3!=0)
        {
                if(dp[r1][r2+1][r3-1]==-1)
                	dp[r1][r2+1][r3-1] = ring(r1,r2+1,r3-1);
		a3 = dp[r1][r2+1][r3-1];
        }
        else
        	a3 = 0;


	ans = (long double)(n)/(r1+r2+r3) + ((long double)(r1)/(r1+r2+r3))*a1 + ((long double)(r2)/(r1+r2+r3))*a2 + ((long double)(r3)/(r1+r2+r3))*a3;
	*/
//	printf("%d %d %d\n", r1, r2, r3); 
		ans = ring(r1, r2, r3);
	printf("%0.7Lf\n",ans);


	return 0;
}


Measured memory_bytes: 443520
import copy
S = list(input())
L = len(S)-1 #長さ
tmp = 1
ans = 0
locate = copy.deepcopy(S)
for i in range (2**L):
    for j in range(L):
        if (i >> j) & 1:
            locate.insert(j+tmp,'+')
            tmp += 1 
    locateSTR = "".join(locate)
    ans += (eval(locateSTR))
    tmp = 1
    locate = copy.deepcopy(S)
    
print(ans)

Measured memory_bytes: 9300
#include<stdio.h>
int main(){

  int a,b,c,i;
  int cnt=0;

  scanf("%d %d %d",&a,&b,&c);
  /*
1<=a,b,c<=10000
a<=b
  */



  for(i = a;i <= b;i++){


  if(c%i ==0){
  cnt++;
}
  
}
 printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 596
N = gets.to_i
S = gets.chomp.split("")
h = {}

S.each do |s|
  h[s] = h[s] == nil ? 1 : h[s]+1
end

ans = 1
h.each do |k,v|
  ans *= (v+1)
  ans %= 10**9+7
end

puts ans-1


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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,r,x,y,m,n;
        string s;
        cin>>s;
        if(s.back()=='s')
        {
            s.pb('e');
            s.pb('s');
        }
        else
        {
            s.pb('s');
        }
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }



int main(){
    int a,b;
    cin>>a>>b;
    int ans=a+b;
    out(6-ans);
    
    
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long int N, K;
  vector<bool> d;

  cin >> N >> K;
  for (int i = 0; i < N; i++) 
    d.push_back(false);

  for (int i = 0; i < K; i++) {
    int tmp;
    cin >> tmp;
    for (int j = 0; j < tmp; j++) {
      int tmp2;
      cin >> tmp2;
      d[tmp2 - 1] = true;
    }
  }

  int count = 0;
  for (int i = 0; i < N; i++) {
    if (d[i] == false)
      count++;
  }

  cout << count << endl;
 
  return 0;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    if(A>=10)
        cout << "-1" << endl;
    else if(B>=10)
        cout << "-1" << endl;
    else
        cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

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

    vector<long long> cnt(n + 1, 0);
    for (int i = 2; i <= n; i++) {
        for (int j = i, k = 2; j > 1; k++) {
            for (; j % k == 0; j /= k) {
                cnt[k]++;
            }
        }
    }

    long long res = 1;
    for (int i = 2; i <= n; i++) {
        if (cnt[i] > 0) {
            res *= cnt[i] + 1;
            res %= 1000000007;
        }
    }

    cout << res << endl;
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const double pi = acos(-1.);

struct point
{
	LL x, y;
	int id;

	point() { }
	point(const LL &_x, const LL &_y): x(_x), y(_y) { }

	friend point operator+(const point &x, const point &y) { return point(x.x + y.x, x.y + y.y); }
	friend point &operator+=(point &x, const point &y) { x.x += y.x, x.y += y.y; return x; }
	friend point operator-(const point &x, const point &y) { return point(x.x - y.x, x.y - y.y); }
	friend point &operator-=(point &x, const point &y) { x.x -= y.x, x.y -= y.y; return x; }
	friend bool operator<(const point &x, const point &y) { if (x.x == y.x) return x.y < y.y; return x.x < y.x; }
	friend LL operator*(const point &x, const point &y) { return x.x * y.x + x.y * y.y; }
	friend LL operator^(const point &x, const point &y) { return x.x * y.y - x.y * y.x; }

	double angle() { return atan2(y, x); }

};

const int maxn = 110;

int n, m;
point p[maxn + 5];
point poly[maxn + 5];

double ans[maxn + 5];

void convex()
{
	sort(p, p + n);
	if (!n) 
	{
		m = 0;
		return;
	}
	int top = 0;
	poly[top++] = p[0];
	REP(i, 1, n)
	{
		while (top > 1 && ((p[i] - poly[top - 1]) ^ (p[i] - poly[top - 2])) >= 0) --top;
		poly[top++] = p[i];
	}
	int tmp = top;
	for (int i = n - 2; i >= 0; --i)
	{
		while (top > tmp && ((p[i] - poly[top - 1]) ^ (p[i] - poly[top - 2])) >= 0) --top;
		poly[top++] = p[i];
	}
	if (top > 1) --top;
	m = top;
}


int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	REP(i, 0, n) cin >> p[i].x >> p[i].y, p[i].id = i;
	convex();
	REP(i, 0, m)
	{
		point u = poly[(i + m - 1) % m] - poly[i];
		point v = poly[(i + 1) % m] - poly[i];
		double tmp = (u.angle() - v.angle());
		if (tmp < 0) tmp += 2 * pi;
		ans[poly[i].id] = (pi - tmp) / (2 * pi);
	}
	REP(i, 0, n) printf("%.15f\n", ans[i]);
	return 0;
}


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

lint ggcd(int a, int b, int c) {
    return gcd(gcd(a, b), c);
}

int main() {
    lint n;
    cin >> n;
    lint ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                ans += ggcd(i, j, k);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,s;
  int a[LIMIT2]={0};
  ll dp[3020][3020];
  
  cin >> n >> s;
  rep(i,n) cin >> a[i];
  
  dp[0][0]=1;
  rep(i,n){
    rep(j,s+1){
      dp[i+1][j] += 2*dp[i][j];
      dp[i+1][j] %= MOD2;
      if(j+a[i]<=s){
        dp[i+1][j+a[i]] += dp[i][j];
        dp[i+1][j+a[i]] %= MOD2;
      }
    }
  }
  cout << dp[n][s] << endl;
  return 0;
}

Measured memory_bytes: 76332
while True:
    H = int(input())
    if H == 0:
        exit()
    L = [input().split() for _ in range(H)]
    L1 = list(reversed([l[0] for l in L]))
    L2 = list(reversed([l[1] for l in L]))
    L3 = list(reversed([l[2] for l in L]))
    L4 = list(reversed([l[3] for l in L]))
    L5 = list(reversed([l[4] for l in L]))
    ans = 0
    while True:
        changed = False
        for i in range(H):
            if L1[i] != 'X' and L1[i] == L2[i] == L3[i] == L4[i] == L5[i]:
                changed = True
                ans += 5*int(L1[i])
                L1[i] = 'X'
                L2[i] = 'X'
                L3[i] = 'X'
                L4[i] = 'X'
                L5[i] = 'X'
            elif L1[i] != 'X' and L1[i] == L2[i] == L3[i] == L4[i]:
                changed = True
                ans += 4*int(L1[i])
                L1[i] = 'X'
                L2[i] = 'X'
                L3[i] = 'X'
                L4[i] = 'X'
            elif L2[i] != 'X' and L2[i] == L3[i] == L4[i] == L5[i]:
                changed = True
                ans += 4*int(L2[i])
                L2[i] = 'X'
                L3[i] = 'X'
                L4[i] = 'X'
                L5[i] = 'X'
            elif L1[i] != 'X' and L1[i] == L2[i] == L3[i]:
                changed = True
                ans += 3*int(L1[i])
                L1[i] = 'X'
                L2[i] = 'X'
                L3[i] = 'X'
            elif L2[i] != 'X' and L2[i] == L3[i] == L4[i]:
                changed = True
                ans += 3*int(L2[i])
                L2[i] = 'X'
                L3[i] = 'X'
                L4[i] = 'X'
            elif L3[i] != 'X' and L3[i] == L4[i] == L5[i]:
                changed = True
                ans += 3*int(L3[i])
                L3[i] = 'X'
                L4[i] = 'X'
                L5[i] = 'X'
        if not changed:
            break
        L1 = list(filter(lambda x: x!='X',L1)) + ['X']*L1.count('X')
        L2 = list(filter(lambda x: x!='X',L2)) + ['X']*L2.count('X')
        L3 = list(filter(lambda x: x!='X',L3)) + ['X']*L3.count('X')
        L4 = list(filter(lambda x: x!='X',L4)) + ['X']*L4.count('X')
        L5 = list(filter(lambda x: x!='X',L5)) + ['X']*L5.count('X')
    print(ans)


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

using namespace std;

#define FOR(i,n)	for(int i=0;i<(int)n;i++)
#define FOB(i,n)	for(int i=n;i>=1;i--)
#define MP(x,y)	make_pair((x),(y))
#define ii pair<int, int>
#define lli long long int
#define ulli unsigned long long int
#define lili pair<lli, lli>
#ifdef EBUG
#define DBG	if(1)
#else
#define DBG	if(0)
#endif
#define SIZE(x) int(x.size())
const int infinity = 2000000999 / 2;
const long long int inff = 4000000000000000999;

typedef complex<long double> point;

template<class T>
T get() {
    T a;
    cin >> a;
    return a;
}

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont){
    out << "{";
    for (const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T,U> &cont){
    out << "{";
    for (const auto &x:cont) out << x << ", ";
    out << "}"; return out;
}

template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  FOR(i, v.size()){
    if(i) out << " ";
    out << v[i];
  }
  out << endl;
  return out;
}

bool ccw(point p, point a, point b){
  if((conj(a - p) * (b - p)).imag() <= 0) return(0);
  else return(1);
}

bool dfs(int v, int x, vector<int> &poz, vector<vector<ii> > &hrany){
    DBG cout << "V : " << v << " mali by sme poz " << x << " a poz[v] = " << poz[v] << " ???" << endl;
    if(poz[v] != infinity && poz[v] != x) return false;
    if(poz[v] != infinity) return true;
    poz[v] = x;
    for(ii w : hrany[v]){
        if(!dfs(w.first, x + w.second, poz, hrany)) return false;
    }
    return true;
}

int main(){
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    
    int n = get<int>();
    int m = get<int>();
    vector<vector<ii> > hrany(n);
    FOR(i, m){
        int a = get<int>() - 1;
        int b = get<int>() - 1;
        int d = get<int>();
        hrany[a].push_back({b, d});
        hrany[b].push_back({a, -d});
    }
    
    vector<int> poz(n, infinity);
    
    FOR(i, n){
        if(poz[i] == infinity){
            DBG cout << "Z pozicie " << i << endl;
            if(!dfs(i, 0, poz, hrany)){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    
}


Measured memory_bytes: 12032
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int sum = scan.nextInt();
        int count = 0;

        for(int x = 0; x <= a; x++){
            for(int y = 0; y <= b; y++){
                for(int z = 0; z <= c; z++){
                    if (sum == 500*x + 100*y + 50*z){
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

vector<ll> pickdiv(ll n){
    vector<ll> res;
    for(ll i=1; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i);
        ll q = n/i;
        if(q != i){
            res.emplace_back(q);
        }
    }
    return res;
}

vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> res;
    for(ll i=2; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1)res.emplace_back(n,1);
    return res;
}

int main(){
    ll N;
    cin >> N;
    mint ans = 1;
    map<ll,ll> mp;
    REP(i,1,N+1){
        auto v = factorize(i);
        for(auto&p:v){
            mp[p.fi] += p.se;
        }
    }
    for(auto& p:mp){
        ans *= (p.se+1);
    }
    //ans += 1;
    cout << ans << endl;
}

Measured memory_bytes: 3532
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[1000001],c[1000001];
int main(){
	int b,sum=0,l=0;
	cin>>a;
	b=strlen(a);
	for(int i=b-1;i>=0;i--) {
		c[sum]=a[i];
		if(c[sum]=='b') c[sum]='d';
		else if(c[sum]=='d') c[sum]='b';
		else if(c[sum]=='p') c[sum]='q';
		else if(c[sum]=='q') c[sum]='p';
		sum++;
	}
	for(int i=0;i<=b-1;i++) {
		//cout<<a[i]<<" "<<c[i]<<endl;
		if(a[i]!=c[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
int rev(int n) {
	int r = 0;
	while (n) {
		r *= 10;
		r += n % 10;
		n /= 10;
	}
	return r;
}
int ta[10][10];
int main() {
	int n, p, t, r;
	ll c = 0;
	cin >> n;
	rep(i, 1, n + 1) {
		r = rev(i);
		if (i % 10 == 0)continue;
		ta[i % 10][r % 10]++;
	}
	rep(i, 0, 10)rep(i2, 0, 10)c += (ll)ta[i][i2] * ta[i2][i];
	printf("%lld\n", c);
	return 0;
}


Measured memory_bytes: 256
#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;
	
	ll n;
  	cin>>n;
  puts(n<1200?"ABC":"ARC");
  

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool primes[1000000]={0};
void sieve(int n){
	for(int i=2;i*i<n;i++){
		if(!primes[i]){
			for(int j=i+i;j<n;j+=i)
				primes[j]=true;
		}
	}
}
int main(){
	sieve(1000000);
	int n;
	cin>>n;
	for(int i=n;i<1000000;i++){
		if(!primes[i]){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

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

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

const long long MOD = 1000000007;

int main(){
  long double n,k;
  cin >> n >> k;
  double ans=0;
  
  for(int i=1;i<min(k,n+1);i++){
    double t=0,x=i;
    
    while(x<k){
      x*=2;
      t++;
    }
    
    ans+= (double)1/pow((double)2.0,t);
  }
  ans /= n;
  
  if(k<=n) ans+=(n-k+1)/n;
  
  cout << fixed << setprecision(12);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
use std::io::Read;
use itertools::Itertools;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();
    let mut k: usize = iterator.next().unwrap().parse().unwrap();

    let costs: Vec<usize> = s.iter()
        .map(|c| ('z' as usize - *c as usize + 1) % 26)
        .collect();

    let mut result: Vec<char> = Vec::new();
    for i in 0..s.len() {
        if costs[i] <= k {
            result.push('a');
            k -= costs[i];
        } else {
            result.push(s[i]);
        }
    }

    if k > 0 {
        result[s.len() - 1] = ('a' as usize + (result[s.len() - 1] as usize - 'a' as usize + k) % 26) as u8 as char
    }

    return result.iter().join("")
}


Measured memory_bytes: 3800
from math import sqrt
N, D = map(int, input().split())
Z = [list(map(int, input().split())) for _ in range(N)]
d = []

for i in range(N):
    d.append(sqrt(Z[i][0]**2 + Z[i][1]**2))

cnt = 0
for i in range(N):
    if d[i] <= D:
        cnt += 1

print(cnt)

Measured memory_bytes: 53328
#include<cstdio>

using namespace std;

int n;
char s[1000006];

int iseven(int n, int r) {
  while (n || r) {
    if (r == 0) {
      return false;
    } else if (n == 0) {
      return true;
    }
    int ln = n & (-n);
    int lr = r & (-r);
    if (ln == lr) {
      n -= ln;
      r -= lr;
    } else if (ln < lr) {
      n -= ln;
    } else {
      return true;
    }
  }
  return false;
}

int main() {
  scanf("%d", &n);
  scanf("%s", s);
  bool one = false;
  for (int i = 0; i < n; i++) {
    if (s[i] - '1' == 1) {
      one = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!iseven(n-1, i)) {
      ans += (s[i] - '1') / (one ? 1 : 2);
    }
  }
  printf("%d\n", (ans % 2) * (one ? 1 : 2));
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
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; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n, m; cin >> n >> m;
    vector<int> h(n);
    vector<bool> ng(n, false);
    rep(i, n){
        cin >> h[i];
    }
    rep(i, m){
        int a, b; cin >> a >> b;
        a--; b--;
        if(h[a] <= h[b]) ng[a] = true;
        if(h[b] <= h[a]) ng[b] = true;
    }
    
    // rep(i, n) cout << ng[i] << " ";
    int ans = 0;
    rep(i, n){
        if(!ng[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3724
program main
	implicit none
    integer(8)::k,t
    integer(8),allocatable::a(:)
    read(*,*) k,t
    allocate(a(t))
    read(*,*) a
    call msort(a)
    if(t==1)then
    	write(*,*) a(1)-1
    else
    	
    	write(*,*) max(a(t)- (sum(a)-a(t)) -1,0)
    end if
    deallocate(a)
    
    stop
contains
subroutine swap(a, b)
    implicit none
    integer(8), intent(inout) :: a, b
 
    integer(8) :: c
 
    c = a
    a = b
    b = c
 
  end subroutine swap
 
  !
  ! merge sort
  !
  recursive subroutine msort(x)
    implicit none
    integer(8), intent(inout) :: x(:)
 
    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if
 
    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call msort(x(:mid))
    call msort(x(mid+1:))
 
    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n))
    tmp = x
 
    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
    end do
 
    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n
 
    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        i = i + 1
      else
        x(k) = tmp(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp)
    return
  end subroutine msort
end program main

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}
ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}
bool prime[1000000];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=1000000;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(1000000);j+=i)
           { prime[j]=false;}

    }
    }

}

int main()
{
   int n,k;
   cin>>n>>k;
   int arr[n];
   for(int i=0;i<n;i++) cin>>arr[i];
   int pref[n];
   pref[0]=arr[0];
   for(int i=1;i<n;i++) pref[i]=pref[i-1]+arr[i];
   int fans=1000000000;
   int ans=0;
   int f=0,l=0;
   for(int i=0;i<=n-k;i++)
   {  ans=0;
       f=arr[i]; l =arr[i+k-1];
       if(f>=0&&l>=0)
       {

           ans=l;
       }
       else if(f<=0&&l<=0)
       {
           ans=abs(f);
       }
       else
       {
           //cout<<"lol"<<l<<" "<<f<<endl;
           ans+=(l-f);
           ans+=min(abs(l),abs(f));
       }
       fans=min(fans,ans);
   }
   cout<<fans<<endl;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

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

	static long MOD = 1_000_000_000 + 7;

	void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();

		fact = new long[n + m + 2 * k + 1];
		fact[0] = 1;
		fact[1] = 1;
		for (int i = 1; i <= n + m + 2 * k; i++) {
			fact[i] = (i % MOD * fact[i - 1]) % MOD;
		}
		long ans = 0;
		for (int i = 0; i <= k; i++) {
			long a = 1, b = 1;
			int j = k - i;
			if (i >= 1)
				a = (nCk(n + 2 * i, i) + MOD - nCk(n + 2 * i, i - 1)) % MOD;
			if (j >= 1)
				b = (nCk(m + 2 * j, j) + MOD - nCk(m + 2 * j, j - 1)) % MOD;
			ans += nCk(n + m + 2 * k, n + 2 * i) % MOD * a % MOD * b % MOD;
			ans %= MOD;
		}

		while (ans < 0)
			ans += MOD;
		System.out.println(ans);

	}

	static long[] fact;
	static long[] inv_fact;

	// 1~n?????°?????????k????????????????????°
	static long nCk(int n, int k) {
		if (n < k)
			return 0;
		else {
			return fact[n] % MOD * inv(fact[n - k], MOD) % MOD * inv(fact[k], MOD) % MOD;
		}
	}

	static long inv(long a, long mod) {
		a = a % mod;
		long b = mod;
		long p = 1, q = 0;

		while (b > 1) {
			long c = b / a;
			b = b % a;
			q = q - p * c;
			long d = b;
			b = a;
			a = d;
			d = p;
			p = q;
			q = d;
		}
		while (q < 0)
			q += mod;
		return q % MOD;
	}

	static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 29092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int n;cin>>n;
    if(n>=10000)cout<<min(n,(int)99999)-9999+900+9<<endl;
    else if(n>=100)cout<<min(n,(int)999)-99+9<<endl;
    else cout<<min(n,(int)9)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m, s;
typedef pair<ll, ll> P;
using edge = pair<ll, P>;
const ll INF = 1e18, MAX_COST = 2500;

signed main(){
	ll n, m, s; cin >> n >> m >> s;
	s = min(s, MAX_COST);
	vector<vector<edge> > G(n);
	for(int i = 0; i < m; i++){
		ll u, v, a, b; scanf("%lld%lld%lld%lld", &u, &v, &a, &b); --u; --v;
		G[u].push_back(edge(v, P(a, b))); G[v].push_back(edge(u, P(a, b)));
	}
	vector<ll> c(n), d(n);
	for(int i = 0; i < n; i++) scanf("%lld%lld", &c[i], &d[i]);
	vector<vector<ll> > dist(n, vector<ll> (MAX_COST + 1, INF));
	priority_queue<edge, vector<edge>, greater<edge> >  que;
	dist[0][s] = 0;
	que.push(edge(0, P(0, s)));

	while(!que.empty()){
		edge e = que.top(); que.pop();
		ll time = e.first, now = e.second.first, money = e.second.second;
		if(dist[now][money] < time) continue;

		if(money + c[now] <= MAX_COST) {
			ll ntime = time + d[now], nmoney = money + c[now];
			if(dist[now][nmoney] > ntime){
				dist[now][nmoney] = ntime;
			  que.push(edge(ntime, P(now, nmoney)));
			}
		}

		for(auto e : G[now]){
			if(money < e.second.first) continue;
			ll next = e.first, ntime = time + e.second.second, nmoney = money - e.second.first;
			if(dist[next][nmoney] > ntime){
				dist[next][nmoney] = ntime;
				que.push(edge(ntime, P(next, nmoney)));
			}
		}
	}

	for(int i = 1; i < n; i++){
		ll ans = INF;
		for(int j = 0; j <= MAX_COST; j++) ans = min(ans, dist[i][j]);
		cout << ans << endl;
	}
}


Measured memory_bytes: 7464
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a, b= map(int, input().split())
print(max(a+b,a-b,a*b))

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if((A < C && C < B) || (B < C && C < A)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256