akhauriyash/Code-Regression huggingface dataset:
def solve():
    from collections import deque
    h, w, k = map(int, input().split())
    maze = [input() for _ in range(h)]
    visited = [[-1]*w for _ in range(h)]
    for i in range(h):
        if 'S' in maze[i]:
            sy, sx = i, maze[i].index('S')
            break
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    r = 10**18
    while queue:
        y, x = queue.popleft()
        r = min(r, y, h-1-y, x, w-1-x)
        if visited[y][x] == k: continue
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+i, x+j
            if new_y < 0 or new_y >= h or new_x < 0 or new_x >= w: continue
            if maze[new_y][new_x] == '.' and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
    print(1 -(-r // k))
if __name__ == '__main__':
    solve()


Measured memory_bytes: 26228
#include<stdio.h>
#include<math.h>
#define N 100
int search(int a[],int n,int tmp) {
    for (int i=0;i<n;i++) {
        if (a[i]==tmp) return 1;
    }
    return 0;
}
int main() {
    int x,n,tmp;
    int p[N]={0};

    scanf("%d %d",&x,&n);
    for (int i=0;i<n;i++) scanf("%d",&p[i]);
    
    int tmp1=x;
    while(search(p,n,tmp1)) {
        tmp1--;
    }
    int tmp2=x;
    while(search(p,n,tmp2)) {
        tmp2++;
    }
    if(tmp2-x>=x-tmp1)tmp=tmp1;
    else tmp=tmp2;
    
    printf("%d\n",tmp);
  	return 0;
}

Measured memory_bytes: 1732
n, m = map(int, input().split())
a = [int(x)%m for x in input().split()]

b = [0]*(n+1)
for i in range(n):
  b[i+1] = (b[i]+a[i])%m

key = dict()
key[0] = 0
for i in range(1, n+1):
  if b[i] in key:
    key[b[i]] += 1
  else:
    key[b[i]] = 1

ans = key[0]
for value in key.values():
  ans += value*(value-1)//2

print(ans)

Measured memory_bytes: 16184
def digisum(N):
    if N == 10000:
        return 1
    elif N < 10:
        return N
    elif N < 100:
        return (N//10) + (N%10)
    elif N < 1000:
        return (N//100) + ((N%100)//10) +(N%10)
    else:
        return (N//1000) + ((N//100)%10) + ((N%100)//10) +(N%10)

n, a, b = map(int, input().split())
ans = 0

for i in range(n+1):
    test = digisum(i)
    if test >= a and test <= b:
        ans += i

print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int N, M, cnt[30] = {};
  cin >> N >> M;
  for(int i=0; i<N; i++){
    int K;
    cin >> K; 
    for(int j=0; j<K; j++){
      int a;
      cin >> a;
      cnt[a-1]++;
    }
  }
  int ans=0;
  for(int i=0; i<M; i++){
    if(cnt[i] == N) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


int main(){
    // cout << fixed << setprecision(5);

    long long N, K;
    cin >> N >> K;
    int ans = 0;
    while (N > 0) {
        N /= K;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
read A B

ans=false
if test  $(expr $A % 3) -eq 0;then
    ans=true
elif test $(expr $B % 3) -eq 0;then
    ans=true
elif test $(expr \( $A + $B \) % 3) -eq 0;then
    ans=true
fi

if $ans;then
    echo 'Possible'
else
    echo 'Impossible'
fi


Measured memory_bytes: 544
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n,w;
  cin>>n>>w;
  if(w==1){
    for(Int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<1;
    }
    cout<<endl;
    return 0;
  };

  vector<Int> v(n+1,0);
  Int ans=0;
  auto inc=[&](Int x){
    if(v[x]++==0) ans++;
  };
  auto dec=[&](Int x){
    if(--v[x]==0) ans--;
  };
  vector<vector<Int> > div(n+1);
  for(Int i=1;i<=n;i++)
    for(Int j=i;j<=n;j+=i)
      div[j].emplace_back(i);
  
  
  for(Int i=1;i<=w;i++)
    for(Int j:div[i]) inc(j);
  
  cout<<ans;
  for(Int i=w+1;i<=n;i++){
    Int p=i-w;
    for(Int j:div[i])
      if(p<=i-j) inc(j);    
    for(Int j:div[p])
      if(p+j<=i) dec(j);
    inc(i);
    dec(p);
    cout<<" "<<ans;
  }
  cout<<endl;
  return 0;
}



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

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;

int egcd(int a, int b)
{
    if(a==0)
      return b;
    return egcd(b%a, a);
}

int gcd(int a, int b, int c)
{
    a = egcd(a, b);
    b = egcd(b, c);
    return egcd(a, b);
}

int32_t main()
{
    IOS;
    int k;
    cin>>k;
    int ans=0;
    for(int i=1; i<=k; i++)
    {
        for(int j=1; j<=k; j++)
        {
            for(int l=1; l<=k; l++)
                ans+=gcd(i, j, l);
        }
    }
    cout<<ans<<endl;
}



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

int main()
{
	int count = 0, flag, n, a;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		flag = 1;
		for (int j = 2; j * j <= a; j++)
			if (!(a % j))
			{
				flag = 0;
				break;
			}
		if (flag)
			count++;
	}
	cout << count << endl;

	return 0;
}


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

void insert(vector<string> &cont, string value)
{
    auto it = lower_bound(cont.begin(), cont.end(), value, less<string>());
    cont.insert(it, value);
}

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

    map<char, vector<int> > d;

    for(int i = 0; i < str.length(); i++) {
        d[str[i]].push_back(i);
    }

    for(auto itr = d.begin(); itr != d.end(); ++itr) {
        vector<string> s;
        //cout << "[" << itr->first << "]";
        for(int x : d[itr->first]) {
            //cout << "[" << x << "]";
            for(int i = x; i < min(x + 5, (int)str.length()); i++) {
                string substr = str.substr(x, i - x + 1);
                //cout << substr << endl;
                if(find(s.begin(), s.end(), substr) == s.end()) {
                    insert(s, substr);
                }
            }
        }
        /*
        for(string x2 : s) {
            cout << x2 << " ";
        }*/
        if(s.size() >= n) {
            cout << s[n - 1];
            return 0;
        } else {
            n -= s.size();
        }
    }

    return 0;
}

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


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

       int N = sc.nextInt();
       
       int a[] = new int[N];
       
       for(int i = 0 ; i < N;i++){
           a[i] = sc.nextInt();           
       }
                     
       int min = Integer.MAX_VALUE;
               
       for(int i = -100; i <= 100;i++){
          int sum = 0;
          for(int j = 0 ;j < N;j++){
              sum+= (a[j]-i)*(a[j]-i);
          }          
          min = Math.min(min,sum);
       }
              
       System.out.println(min);
       
    }      
}

Measured memory_bytes: 10192
import scala.math.{min,max}

object Main {
  val sc = new java.util.Scanner(System.in);
  def solve(s: String): String = {
    s.length match {
      case 0 => ""
      case 1 => s
      case _ => {
        val r = solve(s.drop(3))
        r.find(_ == s(0)) match {
          case Some(_) => r
          case None => {
            s(1) match {
              case '-' => s(0) + r
              case '<' => r + s(0)
              case _ => "error"
            }
          }
        }
      }
    }
  }
  def main(args: Array[String]) {
    val n = sc.nextInt
    for(i <- 1 to n) {
      val s = sc.next
      println(solve(s))
    }
  }
}

Measured memory_bytes: 57392
/**
 *    author:  math2do
 *    created: 22.03.2020 18:14:55
**/

#include <bits/stdc++.h>

using namespace std;

vector <int> arr;
const int N = (int) 2e5;
vector <int> fre(N + 1, 0);
vector <long long> nc2(N + 1, 0);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  arr.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    fre[arr[i]]++;
  }

  for (int i = 1; i <= N; i++) {
    int am = fre[i];
    nc2[i] = (long long) am * (am - 1) / 2;
  }
  long long sum = accumulate(nc2.begin(), nc2.end(), 0LL);

  for (int i = 0; i < n; i++) {
    cout << sum - fre[arr[i]] + 1 << '\n';
  }  
  return 0;
}


Measured memory_bytes: 5760
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::array<i64, 4> N;
  tools::read(N);

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

  std::cout << (N == std::array<i64, 4>({1, 4, 7, 9}) ? "YES" : "NO") << std::endl;
  return 0;
}

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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {

            int N, M;
            Read2int(out N,out M);
            var spans =Max( M - N,0);
            if (M == 1)
            {
                Console.WriteLine(0);
                return;
            }
            var X = Readints();
            X.Sort();
            var spn = Enumerable.Range(1, M - 1).ToList();
            for(int i = 0; i < M - 1; i++)
            {
                spn[i] = X[i + 1] - X[i];
            }
            spn.Sort();
            Console.WriteLine( spn.Take(spans).Sum() );
            /*
            var s = Console.ReadLine();
            var K = Readint();
            var dpt1=Enumerable.Repeat(0, s.Length).Select(x => Enumerable.Repeat(0, K + 1).ToArray()).ToArray();
            var dpt2 = Enumerable.Repeat(0, s.Length).Select(x => Enumerable.Repeat(0, K + 1).ToArray()).ToArray();

            dpt1[0][1] = int.Parse(s[0].ToString()) - 1;
            dpt2[0][1] = 1;
            dpt1[0][0] = 1;

            foreach (var i in Enumerable.Range(1,s.Length-1))
            {
                var current = int.Parse(s[i].ToString());
                dpt1[i][0]=1;
                for(int j=1; j<=K;j++)
                {
                    if (current == 0)
                    {
                        dpt1[i][j] += dpt1[i - 1][j];
                        dpt2[i][j] += dpt2[i - 1][j];
                        dpt1[i][j] += dpt1[i - 1][j - 1] * 9;

                    }
                    else
                    {

                        dpt1[i][j] += dpt1[i - 1][j];
                        dpt2[i][j] += dpt2[i - 1][j - 1];
                        dpt1[i][j] += dpt1[i - 1][j - 1] * 9;
                        dpt1[i][j] += dpt2[i - 1][j - 1] * (current - 1);
                    }

                }
            }

            foreach(var i in dpt1)
            {
                Console.WriteLine(i.LJoin());
            }
            Console.WriteLine();
            foreach(var i in dpt2)
            {
                Console.WriteLine(i.LJoin());
            }
 

            Console.WriteLine(dpt1[s.Length-1][K] + dpt2[s.Length-1][K]);
            Console.ReadLine();
           */

        }

        static List<int> Readints()
        {
            return  Console.ReadLine().Split(' ').Select(x =>x.ToInt()).ToList();
        }
        static int Readint()
        {
            return Console.ReadLine().ToInt();
        }
        static void Read2int(out int a,out int b)
        {
            var ints = Readints();
            a = ints[0];
            b = ints[1];
        }    
        static int Max(int a,int b)
        {
            return a > b ? a : b;
        }
        



    }

    static  class extensions
    {
        public static int ToInt(this string s)
        {
            return int.Parse(s);
        }

        public static string LJoin<T>(this IEnumerable<T> list)
        {
            return string.Join(" ",list);
        }


    } 


}


Measured memory_bytes: 19936
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int a[100100];
map<int,int> m;
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		m[a[i]]++;
		m[a[i]+1]++;
		m[a[i]-1]++;
	}
	map<int,int>::iterator it;
	int ans = 0;
	for(it = m.begin();it!=m.end();it++){
		chmax(ans,it->sec);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,k,sum=0;
  cin >> n >> k;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater());
  for(int i=k;i<n;i++){
    sum+=a[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 4368
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
#include <iterator>     // std::back_inserter
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
const ll inf = 1e18+1;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool  Array_check(ll y, ll x,ll d,ll w) {
	if (x < 0 || x >= w || y<0 || y>=d) {
		return false;
	}
	else {
		return true;
	}
	
}
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;
}
//小文字=大文字+32
int main() {
	
	int N,W;
	cin >> N>>W;
	vector<ll>w(N), v(N);
	vector < vector<ll>>dp(N+1, vector<ll>(W+1,0));
	rep(i, N) {
		cin >> w[i] >> v[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W ; j++) {
			if (j >= w[i]) {
			chmax(dp[i+1][j], dp[i][j - w[i]] + v[i]);
			chmax(dp[i+1][j], dp[i][j]);
			}
			else {
		
			chmax(dp[i+1][j], dp[i][j]);

			}
		}
	}
	cout << dp[N][W];

}


Measured memory_bytes: 83164
x, y, _, _, _ = gets.chomp.split.map(&:to_i)
ps = gets.chomp.split.map(&:to_i).sort.reverse[0, x]
qs = gets.chomp.split.map(&:to_i).sort.reverse[0, y]
rs = gets.chomp.split.map(&:to_i).sort.reverse

arr = ps + qs + rs
puts arr.sort.reverse[0, x+y].inject(:+)


Measured memory_bytes: 34300
#include<stdio.h>
int main(){
    int N, D, enable;
    scanf("%d %d", &N, &D);
    enable = D * 2 + 1;
    for (int b = 1; b < N+1;b++){
        if(N<=enable*b){
            printf("%d", b);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int, int>
#define endl "\n"
#define MAXN 200005
using namespace std;

int n, m, a, b, vis[MAXN], cnt;
vector<int> adj[MAXN];
set<pi> s;

void dfs(int s)
{
    vis[s] = 1;
    cnt++;
    for (int i = 0; i < adj[s].size(); i++)
    {
        if (!vis[adj[s][i]])
        {
            dfs(adj[s][i]);
        }
    }
}

void solve()
{
    cin >> n >> m;
    while (m--)
    {
        cin >> a >> b;
        if (a > b)
            swap(a, b);
        s.insert(mp(a, b));
    }
    for (auto &it : s)
    {
        int l = it.ff, r = it.ss;
        // cout << l << " " << r << endl;
        adj[l].pb(r);
        adj[r].pb(l);
    }
    int maxx = INT_MIN;
    for (int i = 1; i <= n; i++)
    {
        if (!vis[i])
        {
            cnt = 0;
            dfs(i);
            maxx = max(maxx, cnt);
        }
    }
    cout << maxx << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
}

Measured memory_bytes: 30944
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <string> vs;
typedef vector <long long> vll;
typedef vector <pii> vpii;

#define forz(a, b) for((a) = 0; (a) < (b); (a)++)
#define forf(a, f, b) for((a) = f; (a) < (b); (a)++)
#define vsort(v) sort((v).begin(), (v).end()


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n, d;

    cin >> n;
    d = n % 10;

    if (d == 3)
    {
        cout << "bon";
    }
    else if (d == 0 || d == 1 || d == 6 || d == 8)
    {
        cout << "pon";
    }
    else
    {
        cout << "hon";
    }

    return 0;
}

Measured memory_bytes: 3100
n, m, x = map(int, input().split())
ca = [[int(i) for i in input().split()] for _ in range(n)]
y = []
for b in [[i >> j & 1 for j in range(n)] for i in range(2**n)]:
    xi = [0] * m
    yi = 0
    for j, bj in enumerate(b):
        if bj == 0:
            continue
        yi += ca[j][0]
        for k in range(m):
            xi[k] += ca[j][k + 1]
    if min(xi) >= x:
        y.append(yi)
if y:
    print(min(y))
else:
    print(-1)

Measured memory_bytes: 10016
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b, c; cin >> a >> b >> c;
  if (a + b >= c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3064
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        int[] A = new int[N];
        bool[] R = new bool[N];
        {
            string[] str0 = Console.ReadLine().Split(' ');
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');
            for(int i=0;i<N;i++){
                int x = int.Parse(str0[i]);
                int y = int.Parse(str1[i]);
                int z = int.Parse(str2[i]);
                if(x+1 == y && y+1 == z && z%3 == 0){
                    A[i] = y/3;
                    R[i] = true;
                }
                else if(x-1 == y && y-1 == z && x%3 == 0){
                    A[i] = y/3;
                    R[i] = false;
                }
                else{
                    sb.Append("No\n");
                    return;
                }
                if((A[i] - i) % 2 != 0){
                    sb.Append("No\n");
                    return;
                }
            }
        }
        {
            int[] P = new int[(N+1)/2];
            int[] E = new int[(N+1)/2];
            bool b = true;
            for(int i=0;i<(N+1)/2;i++){
                P[A[i*2]/2] = i;
                E[i] = A[i*2]/2;
            }
            for(int i=0;i<(N+1)/2;i++){
                if(P[i] != i){
                    b = !b;
                    int temp = E[i];
                    P[E[i]] = P[i];
                    E[i] = E[P[i]];
                    E[P[i]] = temp;
                    P[i] = i;
                }
            }
            for(int i=0;i<N/2;i++){
                if(!R[i*2+1]){
                    b = !b;
                }
            }
            if(!b){
                sb.Append("No\n");
                return;
            }
        }
        {
            int[] P = new int[N/2];
            int[] E = new int[N/2];
            bool b = true;
            for(int i=0;i<N/2;i++){
                P[A[i*2+1]/2] = i;
                E[i] = A[i*2+1]/2;
            }
            for(int i=0;i<N/2;i++){
                if(P[i] != i){
                    b = !b;
                    int temp = E[i];
                    P[E[i]] = P[i];
                    E[i] = E[P[i]];
                    E[P[i]] = temp;
                    P[i] = i;
                }
            }
            for(int i=0;i<(N+1)/2;i++){
                if(!R[i*2]){
                    b = !b;
                }
            }
            if(!b){
                sb.Append("No\n");
                return;
            }
        }
        sb.Append("Yes\n");
    }
}

Measured memory_bytes: 37632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    char c;
    cin >> c;
    cout << (char)(c+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
 
#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
#define int ll
 
using namespace std;
typedef long long ll;
typedef long double ld;

vector<vector<pair<int, int>>> have;
vector<vector<pair<int, int>>> g;
vector<pair<int, int>> sons;
vector<pair<int, int>> pr;
vector<int> used;


void precalc(int v, int p = -1, int dl = 0) {
	pr[v] = {p, dl};
	for (auto x : g[v]) {
		if(x.ft == p) 
			continue;
		if(sons[v].ft == -1) 
			sons[v].ft = x.ft;
		else
			sons[v].sc = x.ft;
		precalc(x.ft, v, x.sc);
	}
	return;
}


bool built(int v, int maxdl) {
	if(sons[v].ft == -1) {
		have[v].pb({0, 0});
		return 1;
	}
	if(!(built(sons[v].ft, maxdl) && built(sons[v].sc, maxdl)))
		return 0;
	vector<pair<int, int>> ans;
	int v1 = pr[sons[v].ft].sc, v2 = pr[sons[v].sc].sc;
	for (auto x : have[sons[v].ft]) {
		int l = -1, r = len(have[sons[v].sc]);
		int st1 = x.ft + v1;
		int fn1 = x.sc;
		while(r - l > 1) {
			int mid = (l + r) / 2;
			if(have[sons[v].sc][mid].ft + v1 + v2 + fn1 > maxdl) 
				r = mid;
			else
				l = mid;
		}
		if(l == -1) 
			continue;
		ans.pb({st1, have[sons[v].sc][l].sc + v2});
	}
	v1 = pr[sons[v].sc].sc, v2 = pr[sons[v].ft].sc;
	for (auto x : have[sons[v].sc]) {
		int l = -1, r = len(have[sons[v].ft]);
		int st1 = x.ft + v1;
		int fn1 = x.sc;
		while(r - l > 1) {
			int mid = (l + r) / 2;
			if(have[sons[v].ft][mid].ft + v1 + v2 + fn1 > maxdl) 
				r = mid;
			else
				l = mid;
		}
		if(l == -1) 
			continue;
		ans.pb({st1, have[sons[v].ft][l].sc + v2});
	}
	sort(ans.begin(), ans.end());
	for (auto x : ans) {
		if(len(have[v]) > 0 && have[v].back().ft <= x.ft && have[v].back().sc <= x.sc)
			continue;
		have[v].pb(x);
	}
	if(len(have[v]) == 0) 
		return 0;
	return 1;
}

signed main() {
    #ifdef PC
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif  
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
   	g = vector<vector<pair<int, int>>> (n);
   	pr = vector<pair<int, int>> (n);
   	sons = vector<pair<int, int>> (n, {-1, -1});
   	for (int i = 1; i < n; i++) {
   		int p, v;
   		cin >> p >> v;
   		p--;
   		g[p].pb({i, v});
   		g[i].pb({p, v});
   	}
   	precalc(0);	

   	int l = -1, r = 1e18 + 100;
   	while(r - l > 1) {
   		int mid = (l + r) / 2;
   		have = vector<vector<pair<int, int>>> (n);
   		if(built(0, mid)) 
   			r = mid;
   		else
   			l = mid;
   	}
   	cout << r << endl;
}


Measured memory_bytes: 42412
from bisect import bisect_right
n = int(input())
a = int(input())
x = [a * (-1)]
for _ in range(n-1):
  a = int(input()) * (-1)
  if a >= x[-1]:
    x.append(a)
  else:
    index = bisect_right(x, a)
    x[index] = a
print(len(x))


Measured memory_bytes: 7068
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string S;
  cin >> S;

  i64 result = 0;
  int k = 0;  // 繰り上がり

  RF0(i, S.size()) {
    int n = S[i] - '0' + k;
    k = 0;

    bool pay = n <= 5;

    // 今回5でも次が5以上なら、繰り上げた方が少なく済む
    // 55に対し、100払ったほうが105払うより良いということ
    if (n == 5 && i > 0 && S[i - 1] - '0' >= 5) pay = false;

    if (pay) {
      // n 払う
      result += n;
    }
    else {
      // 10 - n 釣りをもらって、次の桁+1
      result += 10 - n;
      k++;
    }
  }
  result += k;

  cout << result;
}
#endif


Measured memory_bytes: 1948
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    string a="s";
    string b="es";
    getline(cin,str);
    string :: iterator it =str.end();
    bool flag = false;
    int i = 0;
    while(str[i])
    {
        if(isupper(str[i]))
        { 
            flag = true;
        }
        if(!(isupper(str[i])))
        {
            flag = false;
            break;
        }
        i++;
    }
    if(flag==false)
    {
    if(*(it-1)=='s')
    {
        cout<<str+b;
    }
    else
    {
        cout<<str+a;
    }
    }
    else
    {
        exit(0);
    }
      
}

Measured memory_bytes: 3604
n = int(input())
rate_list = list(map(int, input().split()))
emp_list = [0]*9
for i in range(n):
    if  1 <= rate_list[i] <= 399:
        emp_list[0] = 1
    elif 400 <= rate_list[i] <= 799:
        emp_list[1] = 1
    elif 800 <= rate_list[i] <= 1199:
        emp_list[2] = 1        
    elif 1200 <= rate_list[i] <= 1599:
        emp_list[3] = 1        
    elif 1600 <= rate_list[i] <= 1999:
        emp_list[4] = 1        
    elif 2000 <= rate_list[i] <= 2399:
        emp_list[5] = 1        
    elif 2400 <= rate_list[i] <= 2799:
        emp_list[6] = 1        
    elif 2800 <= rate_list[i] <= 3199:
        emp_list[7] = 1        
    elif 3200 <= rate_list[i]:
        emp_list[8] += 1
sum_ = 0
for i in range(8):
    sum_ += emp_list[i]
if sum_ == 0:
    print(1, end="")
    print(" ")
    print(emp_list[8])
else:
    print(sum_, end="")
    print(" ", end="")
    print(sum_+emp_list[8])

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

int main(){
   while(1){
      int n, p, kei, name=100, hito[50]= {};
      cin>>n>>p;
      kei = p;
      if(n == 0 && p == 0) break;
 
      while(1){
              for(int j=0;j<n;j++){
                     if(p != 0){
                           hito[j]+=1;
                           p-=1;
                     }
                     else{ 
                           p += hito[j];
                           hito[j] = 0;
                     }
                     if(hito[j] == kei) name = j;
               
                     if(name != 100)  break;
               }
               if(name != 100) break;
       
       }
       cout<<name<<endl;
   }     
   return 0;
}
               



Measured memory_bytes: 2984
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    $card = array_fill(1, 13, 0);
    foreach (explode(',', $line) as $c) {
        $card[(int)$c]++;
    }

    //配られたカードだけにする
    $card = array_filter($card, function ($n) {
        return $n;
    });
    $pair = max($card);
    //カードの種類
    $cnt = count($card);

    //4カード
    if ($pair === 4) {
        echo "four card\n";

    //フルハウス
    } elseif ($pair === 3 && $cnt === 2) {
        echo "full house\n";

    //ペアがない
    } elseif ($cnt === 5) {
        //1番小さいカード
        $min = min(array_keys($card));
        $check = 0;
        for ($i = $min + 1; $i < $min + 5; $i++) {
            isset($card[$i]) && $check++;
        }

        //Aがある場合はもう一度チェック
        if ($check !== 4 && $min === 1) {
            $check = 0;
            for ($i = 10; $i <= 13; $i++) {
                isset($card[$i]) && $check++;
            }
        }

        //5枚連続している場合はストレート、連続していない場合は役なし
        echo $check === 4 ? "straight\n" : "null\n";

    //3カード
    } elseif ($pair === 3) {
        echo "three card\n";

    //ペアがある
    } elseif ($pair === 2) {
        //カードの種類が3種類の場合は2ペア、4種類の場合は1ペア
        echo $cnt === 3 ? "two pair\n" : "one pair\n";

    //念のため
    } else {
        echo "null\n";
    }
}

Measured memory_bytes: 6688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String ans = "";
		int a, b;
		while(scan.hasNext()){
			//scan.useDelimiter(" |\n");
			a = Integer.parseInt(scan.next());
			b = Integer.parseInt(scan.next());
			if(a == 0 && b == 0){
				break;
			}else if(a < b){
				ans = a + " " + b;
			}else if(b < a){
				ans = b + " " + a;
			}else if(a == b){
				ans = a + " " + b;
			}
			System.out.println(ans);

		}
	}
}

Measured memory_bytes: 36440
#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];
    vector<int> dp(n, 1e9);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        int val = 1e9;
        for (int l = 1; l <= min(i, k); l++)
            val = min(val, dp[i-l] + abs(h[i] - h[i-l]));
        dp[i] = val;
    }
    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 3944
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool fact(long long cur, long long n) {
  if (n == 1)
    return cur;
  return cur * fact(cur - 1, n - 1);
}

int main(int argc, char* argv[]) {
  int n;
  cin >> n;

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

  sort(a.begin(), a.end());
  long long maximum_diff = 0;
  long long base = a.back();
  long long r = 0;
  for (int i = 0; i < n - 1; ++i) {
    long long cur = min(a[i], base - a[i]);
    if (cur > maximum_diff) {
      maximum_diff = min(a[i], base - a[i]);
      r = a[i];
    }
  }

  cout << base << " " << r << endl;

  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define CAT(a,b)a b
#define VASIZE(a,b,N,...)N
template<class T>auto size(T&&a)->decltype(a.size(), ll()) { return a.size(); }
template<class T>typename make_signed<decltype(T() % 0)>::type size(T a) { return a; }
#define REP(t,a,N)for(decltype(size(N))t=size(a),_l##t=size(N);t<_l##t;t++)
#define RREP(t,a,N)for(decltype(size(N))t=size(N)-1,_l##t=size(a);t>=_l##t;t--)
#define rep(t,...)CAT(REP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define rrep(t,...)CAT(RREP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define all(a)begin(a),end(a)

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {

  string s = in;
  map<char, int> m;
  for (auto& i : s) {
    m[i]++;
  }
  bool ok = true;
  if (1 <= m['N'] && m['S'] == 0) ok = false;
  if (1 <= m['E'] && m['W'] == 0) ok = false;
  if (1 <= m['S'] && m['N'] == 0) ok = false;
  if (1 <= m['W'] && m['E'] == 0) ok = false;
  if (ok) {
    cout << ("Yes") << endl;
  } else {
    cout << ("No") << endl;
  }

}


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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}


vector<pair<long long,int>> factorize(long long n) {
    vector<pair<long long,int>> ret;
    for(long long i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            int cnt = 0;
            while(n % i == 0) {
                cnt++;
                n /= i;
            }
            ret.push_back({i, cnt});
        }
    }
    if(n > 1) ret.push_back({n, 1});
    return ret;
}

typedef pair<long long,long long> pii;

pii extendedEuclid(long long a, long long b) { // returns x, y | ax + by = gcd(a,b)
    if(b == 0) return pii( a >= 0 ? 1 : -1 , 0LL);
    else {
        pii d = extendedEuclid(b, a % b);
        return make_pair(d.second, d.first - d.second * (a / b));
    }
}

int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    long long n;
    cin >> n;
    n *= 2;
    vector<pair<long long,int>> f = factorize(n);
    int sz = f.size();
    long long ans = 1e18;
    for(int mask = 0; mask < (1<<sz); mask++) {
        long long a = 1, b = 1;
        for(int k = 0; k < sz; k++) {
            long long x = 1;
            for(int j = 0; j < f[k].second; j++) x *= f[k].first;
            if((mask >> k) & 1) a *= x;
            else b *= x;
        }

        pii soln = extendedEuclid(a, -b);

//        debug(), dbg(a), dbg(b), dbg(soln);
        long long t = soln.second;
        while(t <= 0) t += a;
        while(t > a) t -= a;

        long long cur_soln = t * b;
        ans = min(ans, cur_soln);
    }
    cout << ans << endl;
}




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

int main(){
    ll H, ans;
    cin >> H;
    int n = log(H)/log(2);
    ans = pow(2, n + 1) - 1;
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toLong)
    val aList = readLine()!!.split(' ').map(String::toLong)
    val day = aList.sum()
    if (day > n) {
        println(-1)
    } else {
        println(n - day)
    }
}

Measured memory_bytes: 39424
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
}
int ans[41];
signed main(){
	ic(n)
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int ketta=0;
	rep(0,i,40){
		if(i%2==0){
			if(n%n2[i+1]!=0){
				ans[i]=1;
				n=n-n2[i];
			}
			else ans[i]=0;
		}
		else{	
			if(n%n2[i+1]!=0){
				ans[i]=1;
				n=n+n2[i];
			}
			else ans[i]=0;
		}
		if(n==0){
			ketta=i;
			break;
		}
	}
	for(int i=ketta;i>=0;i-=1)cout<<ans[i];
}			

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        n: usize
    }

    let checker = (n / 100) * 111;

    if checker < n {
        println!("{}", checker + 111);
    } else {
        println!("{}", checker);
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
inline double f(long long m) {
    long long n = m;
    long long s = 0;
    while (n) {
        s += n%10;
        n /= 10;
    }
    return (double)m/s;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    long long snuke = 0, addition = 1;
    while (K--) {
        snuke += addition;
        if (f(snuke+addition)>f(snuke+addition*2)) addition *= 10;
        printf("%lld\n", snuke);
    }
    return 0;
}

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

const int maxn=1e5+7;
int a[maxn],n,m,app[maxn];

int read()
{
	int ans=0;
	char s=getchar();
	while(s<'0'||s>'9') s=getchar();
	while(s>='0'&&s<='9') ans=ans*10+s-'0',s=getchar();
	return ans;
}

long long gcd(long long a,long long b)
{
	if(a%b==0) return b;
	return gcd(b,a%b);
}

int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;++i) {
		a[i]=read();
		a[i]/=2;
	}
	for(int i=1;i<=n;++i) {
		while(a[i]%2==0) app[i]++,a[i]/=2;
	}
	for(int i=2;i<=n;++i) {
		if(app[i]!=app[i-1]) {
			printf("0");
			return 0;
		}
	}
	m=m/(int)pow(2,app[1]);		
	long long lcm=1;
	for(int i=1;i<=n;++i) {
		lcm=lcm*a[i]/gcd(lcm,a[i]);
		if(lcm>m) {
			printf("0");
			return 0;
		}
	}
	printf("%lld",(m/lcm+1)/2);
}

Measured memory_bytes: 1024
#include <cstdint>
#include <cstdio>

int main(void) {
    int num;
    std::scanf("%d", &num);
    int ll = num % 100;
    int hh = num / 100;
    bool yymm = true;
    bool mmyy = true;
    if (ll > 12 || ll == 0) {
        yymm = false;
    }
    if (hh > 12 || hh == 0) {
        mmyy = false;
    }
    if (yymm && mmyy) {
        std::printf("AMBIGUOUS");
    } else if ((!yymm) && (!mmyy)) {
        std::printf("NA");
    } else if (yymm) {
        std::printf("YYMM");
    } else if (mmyy) {
        std::printf("MMYY");
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();
        String s = sc.next();

        if (a >= 3200) {
            System.out.println(s);
        } else {
            System.out.println("red");
        }
    }
}

Measured memory_bytes: 21716
#include <stdio.h>

int main()
{
	int n, c = 0; scanf ("%d", &n);
	for (int i = 1; i <= n; i++){
		int x; scanf ("%d", &x);
		if (i % 2 == 1 && x % 2 == 1) c++;
	}
	printf ("%d\n", c);

	return 0;
}

Measured memory_bytes: 3216
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var h = ReadInts();
            var k = ReadInts();
            var abcd = ReadInts();

            var hiroshi = 0;
            var kenjirou = 0;

            hiroshi += h[0] * abcd[0];
            hiroshi += h[1] * abcd[1];
            hiroshi += h[0] / 10 * abcd[2];
            hiroshi += h[1] / 20 * abcd[3];

            kenjirou += k[0] * abcd[0];
            kenjirou += k[1] * abcd[1];
            kenjirou += k[0] / 10 * abcd[2];
            kenjirou += k[1] / 20 * abcd[3];

            if (hiroshi == kenjirou)
            {
                WriteLine("even");
            }
            else if (hiroshi < kenjirou)
            {
                WriteLine("kenjiro");
            }
            else
            {
                WriteLine("hiroshi");
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s, t;
    cin >> s >> t;
    int len = s.size();
    for (int i = len - 1; i >= 0; i--) {
        char tmp = s[len - 1];
        s.erase(len - 1);
        s = tmp + s;
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
from queue import Queue

def solve():
    A = input()
    B = input()
    C = input()

    qa = Queue()
    qb = Queue()
    qc = Queue()

    for a in A:
        qa.put(a)

    for b in B:
        qb.put(b)

    for c in C:
        qc.put(c)

    c = qa.get()
    if qa.empty():
        return 'A'

    while True:
        if c == 'a':
            if qa.empty():
                return 'A'
            c = qa.get()
        elif c == 'b':
            if qb.empty():
                return 'B'
            c = qb.get()
        elif c == 'c':
            if qc.empty():
                return 'C'   
            c = qc.get()  
            
print(solve())

Measured memory_bytes: 3952
def solve():
    from sys import stdin
    f_i = stdin
    q = f_i.readline()
    d = 0

    from collections import deque
    L = deque()

    for l in f_i:
        if  l[0] == "0":
            L.append(l[2:])
        elif l[0] == "1":
            r = int(l[2:])
            L.rotate(r)
            d -= r
        else:
            L.pop()
    L.rotate(d)
    L.reverse()
    print("".join(L),end= "")
solve()


Measured memory_bytes: 42968