akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll int
#define vi set<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100003,M = 103;
ll i,n,k;
ll a[M],dp[N];
ll solve(ll i)
{
    if(dp[i] != -1) return dp[i];
    
    if(i == 0)
        return dp[i] = 0;
    
    vi s;
    for(ll j = 0;j < n;j += 1){
        if(a[j] > i)
            break;
        s.insert(solve(i - a[j]));
    }
    ll mx = 0;
    while(1){
        if(s.find(mx) == s.end())
            break;
        mx += 1;
    }
    
    return dp[i] = mx;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    rep(i,0,n)
        cin>>a[i];
    cout<<(solve(k) > 0 ? "First" : "Second");
    return 0;
}

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


int main() {
  int h = 0, w = 0;
  
  std::cin >> h >> w;

  std::vector<std::string> a(h, "");
  
  for (int i = 0; i < h; i++) {
    std::cin >> a[i];
    for(int j = 0; j < w; j++) {
      if(a[i][j] == '.') a[i][j] = '0';
    }
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        for (int x = -1; x < 2; x++) {
          for (int y = -1; y < 2; y++) {
            if(i + y >= 0 && j + x >= 0 &&
               i + y < h && j + x < w) {
              if(a[i + y][j + x] != '#') a[i + y][j + x]++;
            }
          }
        }
      }
    }
  }
  
  for(int i = 0; i < h; i++) {
    std::cout << a[i] << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
A=list(map(int,input().split()))

left=[]
right=[]
for i in range(n):
    if i%2==0:
        left.append(A.pop(-1))
    else:
        right.append(A.pop(-1))

print(*left+right[::-1])


Measured memory_bytes: 26020
#include <algorithm>
#include <iostream>
#include <unordered_map>
int main() {
    auto n = 0;
    std::cin >> n;

    auto values = std::unordered_map<std::string, int>();
    for (auto i_ = 0; i_ < n; ++i_) {
        auto s = std::string();
        std::cin >> s;
        values[s]++;
    }

    auto m = 0;
    std::cin >> m;
    for (auto i_ = 0; i_ < m; ++i_) {
        auto s = std::string();
        std::cin >> s;
        values[s]--;
    }

    const auto max_value = std::max_element(values.begin(), values.end(), [](const auto& a, const auto& b) {
                               return a.second < b.second;
                           })->second;
    std::cout << std::max(max_value, 0) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#Input
n, m = map(int, input().split())
l_a = list(map(int, input().split()))

#Process
sum_a = sum(l_a)
l_a.sort(reverse=True)
for i in range(m):
    if(l_a[i] < sum_a / 4 / m):
        Ans = 'No'
        break
    else:
        Ans = 'Yes'

#Output
print(Ans)

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

int main() {
  int a, b, n;
  cin >> a >> b;
  
  if (b < 10)
    n = a * 10 + b;
  else if (b < 100)
    n = a * 100 + b;
  else
    n = a * 1000 + b;
  
  int root = sqrt(n);
  if (root * root == n)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] p = new int[N + 1];
      int countWrongPos = 0;

      for (int i = 1; i < p.length; ++i) {
        p[i] = in.nextInt();
        if (i != p[i]) {
          ++countWrongPos;
        }
      }

      if (countWrongPos == 0 || countWrongPos == 2) {
        System.out.println("YES");
      } else {
        System.out.println("NO");
      }
    }
  }
}

Measured memory_bytes: 21844
using System;
using System.Linq;

namespace aizu
{
    public class OnlineJudge
    {
        static void Main()
        {
            int[] input;
            while(((input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray())[0] | input[1]) != 0) {
                var data = (from p in Enumerable.Range(1, input[0]) let d = Console.ReadLine().Split().Select(b => b == "1").ToArray() select (Enumerable.Range(1, input[1]).Select(q => new { k = q, v = d[q - 1] })).ToDictionary(q => q.k, q => q.v)).ToArray();
                Console.WriteLine(string.Join(" ", Enumerable.Range(1, input[1]).OrderByDescending(p => data.Count(q => q[p] == true)).ThenBy(p => p).Select(q => q.ToString()).ToArray()));
            }
        }
    }
}

Measured memory_bytes: 13760
#include<stdio.h>

int main()
{
    int a,b,y,temp;
    double x;
    scanf("%d %d", &a,&b);
    if(b>a)
    {
        temp = a;
        a = b;
        b = temp;
    }
    x=(double)((a-b)/2.00);
    y=((a-b)/2);
    if((x-(double)y)==0)
        printf("%d", a-y);
    else
        printf("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 1708
#include <stdio.h>
#include <string.h>

int main(){
    char o[50], e[50];
    scanf("%s", e);
    scanf("%s", o);
    for (int i = 0; i < strlen(e); i++){
        printf("%c", e[i]);
        if (i < strlen(o))
            printf("%c", o[i]);
    }
    return 0;
}

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

typedef long long ll;

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

    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c>=22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) { return s; }

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i) cin >> vec[i];
}

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

int main() {
  cin.tie(0);
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  FOR(i, N) cin >> A[i];
  FOR(i, N) cin >> B[i];
  priority_queue<Pll> can;
  FOR(i, N) {
    if (B[i] > A[i]) can.push(Pll(B[i], i));
  }
  ll ans = 0;
  while (!can.empty()) {
    Pll p = can.top();
    ll i = p.second;
    can.pop();
    ll bunbo = (B[i == 0 ? N - 1 : i - 1] + B[i == N - 1 ? 0 : i + 1]);
    ll num = p.first - A[i];
    ans += num / bunbo;
    num %= bunbo;
    if (B[i] == A[i] + num) {
      print(-1);
      return 0;
    }
    B[i] = A[i] + num;
    if (num != 0) can.push(Pll(B[i], i));
  }
  print(ans);
  return 0;
}


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

std::vector<unsigned long> memo(200), deleted(200), visited(200);

unsigned long dfs(unsigned long X, unsigned long x){
    if(memo[x])return memo[x];
    if(visited[x])return 0;
    visited[x] = 1;
    if(!deleted[x])return x + 1;
    unsigned long up{dfs(X, x + 1)}, down{dfs(X, x - 1)};
    if(!up)up += 1000000;
    unsigned long ret{up + down < 2 * X + 2 ? up : down};
    return memo[x] = ret;
}

int main(){
    using namespace std;
    unsigned long X, N;
    cin >> X >> N;
    for(unsigned long i{0}, p; i < N; ++i){
        cin >> p;
        deleted[p] = 1;
    }
    cout << dfs(X, X) - 1 << endl;
    return 0;
}

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

int main()
{
	int T,N;
	while(scanf("%d", &T), T)
	{
		int cycle[30];
		
		for(int i=0; i<T; i++)
			scanf("%d", &cycle[i]);
	
		int day[101], maxd=0;
		for(int i=0; i<101; i++)
			day[i]=999;
		
		scanf("%d", &N);
		
		for(int i=0; i<N; i++)
		{
			int d,m;
			scanf("%d%d", &d,&m);
			day[d]=min(day[d], m);
			maxd=max(d, maxd);
		}
		
		int ps[30];
		
		for(int i=0; i<T; i++) ps[i]=999;
		ps[0]=0;
		
		for(int i=1; i<=maxd; i++)
		{
			int t[30];
			for(int j=0; j<T; j++) t[j]=999;
			
			for(int j=0; j<T; j++)
			{
				if(j+1>i) continue;
				if(cycle[j]>day[i]) continue;
			
				t[(j+1)%T]=ps[j];
			}
			
			for(int j=0; j<T; j++)
				t[1%T]=min(t[1%T], ps[j]+1);
			
			for(int j=0; j<T; j++) 
				ps[j]=t[j];
		}
		
		int ans=999;
		for(int i=0; i<T; i++)
			ans=min(ans, ps[i]);
			
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 998244353;

struct mod_affine_lazy_segtree {
  int n;
  vector<ll> data;
  vector<ll> lazy_b;
  vector<ll> lazy_c;
  vector<bool> lazyFlag;

  mod_affine_lazy_segtree() {
    init(1);
  }

  mod_affine_lazy_segtree(const int s) {
    init(s);
  }

  mod_affine_lazy_segtree(const vector<ll> &v) {
    int s = v.size();
    init(s);
    for (int i = 0; i < s; i++) {
      data[i+n-1] = v[i];
    }
    for (int i = n-2; i >= 0; i--) {
      data[i] = (data[i*2+1] + data[i*2+2]) % mod;
    }
  }

  void init(const int s) {
    n = 1;
    while (n < s) n <<= 1;
    data = vector<ll>(2*n-1, 0);
    lazy_b = vector<ll>(2*n-1, 1);
    lazy_c = vector<ll>(2*n-1, 0);
    lazyFlag = vector<bool>(2*n-1);
  }

  void evaluate(int p, int a, int b) {
    if (lazyFlag[p]) {
      // (b * a[i] + c) % mod
      data[p] = (lazy_b[p] * data[p] + lazy_c[p] * (b - a)) % mod;
      if (b - a > 1) {
        lazy_b[p*2+1] = (lazy_b[p*2+1] * lazy_b[p]) % mod;
        lazy_c[p*2+1] = (lazy_c[p*2+1] * lazy_b[p] + lazy_c[p]) % mod;
        lazy_b[p*2+2] = (lazy_b[p*2+2] * lazy_b[p]) % mod;
        lazy_c[p*2+2] = (lazy_c[p*2+2] * lazy_b[p] + lazy_c[p]) % mod;
        lazyFlag[p*2+1] = true;
        lazyFlag[p*2+2] = true;
      }
      lazy_b[p] = 1;
      lazy_c[p] = 0;
      lazyFlag[p] = false;
    }
  }

  void update(int l, int r, ll vb, ll vc, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init

    // evaluate lazy value
    evaluate(p, a, b);

    if (r <= a || b <= l) return; // out of range
    if (l <= a && b <= r) { // fully covered
      lazy_b[p] = (lazy_b[p] * vb) % mod;
      lazy_c[p] = (lazy_c[p] * vb + vc) % mod;
      lazyFlag[p] = true;
      evaluate(p, a, b);
    }
    else {
      update(l, r, vb, vc, p*2+1, a, (a + b) / 2); // left
      update(l, r, vb, vc, p*2+2, (a + b) / 2, b); // right
      data[p] = (data[p*2+1] + data[p*2+2]) % mod; // update
    }
    return;
  }

  int query(int l, int r, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init
    if (r <= a || b <= l) return 0; // out of range

    // evaluate lazy value
    evaluate(p, a, b);

    if (l <= a && b <= r) return data[p];// fully covered

    int vl = query(l, r, p*2+1, a, (a + b) / 2); // left
    int vr = query(l, r, p*2+2, (a + b) / 2, b); // right
    return (vl + vr) % mod;
  }
};

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

  int n, q;
  cin >> n >> q;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;
  vector<vector<ll> > query(q, vector<ll>(5));
  for (auto &x: query) {
    cin >> x[0] >> x[1] >> x[2];
    if (x[0] == 0) cin >> x[3] >> x[4];
  }

  mod_affine_lazy_segtree malst(a);

  vector<ll> ans;
  for (auto &x: query) {
    if (x[0] == 0) malst.update(x[1], x[2], x[3], x[4]);
    else ans.push_back(malst.query(x[1], x[2]));
  }

  for (auto &x: ans) cout << x << endl;

  return 0;
}


Measured memory_bytes: 69016
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_B
// Heaps - Maximum Heap

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <limits>
#include <numeric>
#include <functional>
#include <set>
#include <cmath>
#include <cstring>
#include <climits>
#include <memory>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_H = 500000;
int A[MAX_H + 1];

int parent_index(int i) { return i / 2; }

int left_index(int i) { return 2 * i; }

int right_index(int i) { return 2 * i + 1; }

void max_heapify(int i, int H) {
    auto left = left_index(i);
    auto right = right_index(i);

    auto largest_index = 0;
    if (left <= H && A[i] < A[left]) largest_index = left;
    else largest_index = i;

    if (right <= H and A[largest_index] < A[right]) largest_index = right;

    if (largest_index != i) {
        swap(A[i], A[largest_index]);
        max_heapify(largest_index, H);
    }
}

void build_max_heap(int H) {
    // H / 2は子を持つ接点の中で最大のindex
    for (int i = H / 2; i >= 1; --i) max_heapify(i, H);
}

int main() {
    memset(A, 0, sizeof(A));

    int H;
    cin >> H;
    for (int i = 1; i <= H; ++i) cin >> A[i];

    build_max_heap(H);

    for (int i = 1; i <= H; ++i) cout << " " << A[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 5052
#include<stdio.h>
int f(char *a,char *b,char c,char d){
  int n,m;
  char w[15]={"23456789TJQKA"};
  for(n=0;a[0]-w[n];n++);
  for(m=0;b[0]-w[m];m++);//printf("%2d %c %2d %c\n",n,a[1],m,b[1]);
  if(a[1]==b[1])return n>m?1:0;
  if(a[1]==c)return 1;
  if(b[1]==c)return 0;
  if(a[1]==d)return 1;
  if(b[1]==d)return 0;
  return n>m?1:0;
}  
int main(){
  char s[4][15][2],c,m;
  int i,j,n,p,b[5];
  while(scanf(" %c",&c),c-'#'){
    for(i=0;i<4;i++){
      for(j=b[i]=0;j<13;j++)scanf("%s",s[i][j]);
    }
    for(j=p=0;j<13;j++){
      m=s[p][j][1];
      for(i=0;i<4;i++){
	if(f(s[i][j],s[p][j],c,m))p=i;
      }//printf("%d  ",p);
      b[p]++;
    }//printf(" %d %d\n",b[0]+b[2],b[1]+b[3]);
    if  (b[0]+b[2]>b[1]+b[3])printf("NS %d\n",b[0]+b[2]-6);
    else printf("EW %d\n",b[1]+b[3]-6); 
  }
  return 0;
}
  

Measured memory_bytes: 540
import java.util.*;

public class Main {
  public static void main(String[] srgs) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int[] score = new int[n];
    int sum = 0;
    for(int i = 0; i < n; i++) {
      score[i] = Integer.parseInt(sc.next());
      sum += score[i];
    }
    int ans = sum;
    if(sum % 10 == 0) {
      int min = 101;
      for(int i = 0; i < n; i++) {
        if(score[i] % 10 != 0 && min > score[i]) {
          min = score[i];
        }
      }
      if(min == 101) ans = 0;
      else ans = sum - min;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int N; cin >> N;
  int hoge[3] = {0, 0, 0};
  rep(i, N) {
    int a; cin >> a;
    if (a % 2 != 0)
      ++hoge[0];
    else if (a % 4 == 0)
      ++hoge[2];
    else
      ++hoge[1];
  }
  if (hoge[0] - 1 > hoge[2] || (hoge[0] - 1 == hoge[2] && hoge[1] > 0))
    cout << "No\n";
  else
    cout << "Yes\n";

  return 0;
}


Measured memory_bytes: 3628
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

 class FS {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}
public class Main {
    static StringBuilder sb = new StringBuilder();

    public static void main(String[] args) {
        FS fs = new FS();
        int n = fs.nextInt();
        int[] heap = new int[n+1];
        for (int i = 1; i <= n; i++) {
            heap[i] = fs.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            sb.append("node ").append(i).append(": ").append("key = ").append(heap[i]).append(", ");
            if (Math.floor(i / 2) >= 1) {
                int m = (int) Math.floor(i / 2);
                sb.append("parent key = ").append(heap[m]).append(", ");
            }
            if (i * 2 <= n) {
                sb.append("left key = ").append(heap[i * 2]).append(", ");
            }
            if (i * 2 + 1 <= n) {
                sb.append("right key = ").append(heap[i * 2 + 1]).append(", ");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}


Measured memory_bytes: 24480
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

int main(void){
    string str;cin>>str;
    int Q;cin>>Q;
    int a = 1;
    for(int i=0;i<Q;i++){
        int q;cin>>q;  
        if(q==1){
            a *= -1;
        }else{
            int f;
            string c;
            cin>>f>>c;
            if(f==2){
                f = -1;
            }
            if(a*f==-1){
                str += c;
            }else{
                str.insert(0,c);
            }
        }
    }
    if(a==1){
        cout << str << endl;
    }else{
        reverse(str.begin(),str.end());
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 900
module IO = struct

  (* @since 4.04.0 *)
  let split_on_char sep s =
    let open String in
    let r = ref [] in
    let j = ref (length s) in
    for i = length s - 1 downto 0 do
      if get s i = sep then begin
        r := sub s (i + 1) (!j - i - 1) :: !r;
        j := i
      end
    done;
    sub s 0 !j :: !r

  let read_ns () = read_line () |> split_on_char ' ' |> List.map int_of_string

end

let solve h w c =
  let s = Array.make w 0 in
  let t = Array.make w 0 in
  let r = ref 0 in
  List.iteri (fun j e -> if e = 0 then begin
    s.(j) <- 1;
    r := 1;
  end) c.(0);
  if !r = 0 then begin
    let rec doit i =
      if i = h then ()
      else begin
        match c.(i) with
        | [] -> ()
        | hd :: _ ->
          if hd = 0 then r := 1
          else doit (i + 1)
      end in
    doit 0
  end;
  Array.iteri (fun i l ->
    if i = 0 then ()
    else begin
      match l with
      | [] -> assert false
      | x :: xs ->
        if x = 0 then t.(0) <- 1;
        List.iteri (fun j e ->
          let j = j + 1 in
          if e = 1 then t.(j) <- 0
          else begin
            let d = if s.(j) < t.(j-1) then s.(j) else t.(j-1) in
            t.(j) <- 1 + if s.(j-1) < d then s.(j-1) else d;
            if t.(j) > !r then r := t.(j)
          end) xs;
        Array.iteri (fun i e -> s.(i) <- e) t
    end)
    c;
  !r * !r

let () =
  match IO.read_ns () with
  | [h; w] ->
    Array.init h (fun _ -> IO.read_ns ()) |> solve h w |> Printf.printf "%d\n"
  | _ -> assert false

Measured memory_bytes: 52668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef double db;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vl;
typedef vector<pii> vpii; typedef vector<pll> vpll;
#define FOR(n) for(int i=0;i<n;++i)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll gcd(ll a, ll b) { return a % b ? gcd(b, a % b) : b; }
const ll mod = 998244353;  const ll inf = 0x3f3f3f3f;
ll qpow(ll a, ll b) { ll t = 1; while (b != 0) { if (b & 1)t = (t * a) % mod; a = (a * a) % mod; b >>= 1; }return t; }
ll n;
int k;
vi a, b;
ll num[212345];
ll sum[212345];
ll solve(int x) {
	ll ans = 0;
	for (int i = 0; i < k; ++i) {
		int le = x - b[i] - 1, ri = x - a[i];
		le = max(0, le), ri = max(0, ri);
		ans += sum[ri] - sum[le];
		ans %= mod;
	}
	if (ans < 0)ans += mod;
	return ans;
}
signed main() {
	cin >> n >> k;
	FOR(k) {
		int t;
		cin >> t;
		a.push_back(t);
		cin >> t;
		b.push_back(t);
	}
	num[1] = sum[1] = 1;
	for (int i = 2; i <= n; ++i) {
		num[i] = solve(i);
		//cout << num[i] << endl;
		num[i] %= mod;
		if (num[i] < 0)num[i] += mod;
		sum[i] = sum[i - 1] + num[i];
		sum[i] %= mod;
		if (sum[i] < 0)sum[i] += mod;
	}
	if (num[n] < 0)num[n] += mod;
	cout << num[n] << endl;
	return 0;
}

Measured memory_bytes: 6776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();

		sc.close();

		String message = "";

		if(num1 < num2) {
			message = "a < b";
		} else if(num1 > num2) {
			message = "a > b";
		} else if(num1 == num2) {
			message = "a == b";
		}

		System.out.println(message);

	}

}


Measured memory_bytes: 26272
class UnionFindVerSize():
    def __init__(self,N):
        #N個のノードのUnion-Find木を作成する
        self._parent = [n for n in range(0, N)]
        #グループのサイズ
        self._size=[1]*N
    def find_root(self,x):
        if self._parent[x]==x:
            return x
        self._parent[x]=self.find_root(self._parent[x])
        return self._parent[x]
    def unite(self, x, y):
        #xとyの属するグループを併合する
        gx=self.find_root(x)
        gy=self.find_root(y)
        if gx == gy:
            return
        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx]<self._size[gy]:
            self._parent[gx] = gy
            self._size[gy]+=self._size[gx]
        else:
            self._parent[gy]=gx
            self._size[gx]+=self._size[gy]
    def get_size(self, x):
        #xが属するグループのサイズ（個数）を返す
        return self._size[self.find_root(x)]
    def is_same_group(self, x, y):
        # xとyが同じ集合に属するか否か
        return self.find_root(x) == self.find_root(y)
    def calc_group_num(self):
        #グループ数を計算して返す
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans
n,m=list(map(int,input().split()))
#unionfindは併合はできるが結合はできない
ab=[]
for i in range(m):
    ab.append(list(map(int,input().split())))
ans=0
for i in range(m):
    union=UnionFindVerSize(n)
    for j in range(m):
        if i!=j:
          union.unite(ab[j][0]-1,ab[j][1]-1)
    if union.calc_group_num()!=1:
        ans=ans+1
        
print(ans)















    

Measured memory_bytes: 9200
import math

N = int(input())

a = int(math.log10(N)) + 1

sum = 0
i = 1
while (i <= a):
    
    if  i != a:
        sum += 9 * (10 ** (i-1))
    else:
        sum += N - (10 ** (i-1)) + 1

    i += 2
    

print(sum)

Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Main {

	public static void main(String[] args) {

		// ストリームを作成する
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		// 入力値を受け取り、リストに追加する
		List<Integer> heightList = new ArrayList<Integer>();
		for (int i = 0; i < 10; i++) {
			heightList.add(getHeight(reader));
		}

		// 昇順にソートする
		Collections.sort(heightList);

		// 下位3件を出力する
		for (int i = 0; i < 3; i++) {
			System.out.println(heightList.get(9 - i));
		}

	}

	/**
	 * ストリームから1行読み込んで、高さを数値として返す。
	 *
	 * @param reader
	 *            入力ストリーム
	 * @return 高さ
	 */
	private static Integer getHeight(BufferedReader reader) {
		Integer height = null;
		try {
			String line = reader.readLine();
			height = new Integer(line);
		} catch (IOException e) {
			throw new RuntimeException();
		}
		return height;
	}
}

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

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if (Math.abs(c - a) <= d || (Math.abs(b - a) <= d && Math.abs(c - b) <= d)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <fstream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(int argc, const char * argv[]) {
   string str;
   getline(cin,str);
   int length=str.length();
   int status=0;
   for (int i=0;i<length;i++){
      if (str[i]=='C') status=1;
      else if (str[i]=='F' && status==1){
        cout<<"Yes"<<endl;
        return 0;
      }
   }
   cout<<"No"<<endl;
   return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  
  for (int i = 0; i < N; i++) {
  	cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int alice = 0, bob = 0;
  
  for (int i = 0; i < N; i++) {
  	if (i % 2 == 0) {
    	alice += a[i];
    }
    else {
    	bob += a[i];
    }
  }
  
  cout << alice - bob << endl;
  
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M)
{
    cout << ((N == M) ? "Yes" : "No") << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
alist = list(map(int,input().split()))
p = 1
for i in range(N):
    if alist[i]%2 == 0:
        if alist[i] % 3 != 0 and alist[i]%5 !=0:
            p = p*0
    else:
        p = p*1
if p == 1:
    print('APPROVED')
else:
    print('DENIED')

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

using namespace std;

int main() {
    int x;
    for (int c = 1; ; c++) {
        cin >> x;
        if (x == 0) {
            break;
        }
        cout << "Case " << c << ": " << x << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int width = Integer.parseInt(sc.nextLine());
      int n = Integer.parseInt(sc.nextLine());
      String[] arr;
      int a;
      int b;
      int[] lot = new int[width];
      for(int i = 0; i < width; i ++){
         lot[i] = i + 1;
      }
      
      int temp;
      
      for(int i = 0; i < n; i ++){
         arr = sc.nextLine().split(",");
         a = Integer.parseInt(arr[0]);
         b = Integer.parseInt(arr[1]);
         
         temp = lot[a-1];
         lot[a-1] = lot[b-1];
         lot[b-1] = temp;
      }
      
      for(int i = 0; i < width; i ++){
         System.out.println(lot[i]);
      }
      
   }//main
}//class

Measured memory_bytes: 25900
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N = d_in()
S_LIST = []
for _ in range(N):
    s = list(s_in())
    S_LIST.append(list(map(ord, s)))
S_LIST = np.array(S_LIST, dtype=int)

ans = 0
for i in range(N):
    check_array = np.concatenate((S_LIST[:, i:], S_LIST[:, :i]), axis=1)
    if np.array_equal(check_array, check_array.T):
        ans += 1
print(ans*N)


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

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a == b) {
        printf("%d", a * 2);
    } else {
        a > b ? printf("%d", a + a - 1) : printf("%d", b + b - 1);
    }

    return 0;
}

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

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


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ARC101C
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] longs = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
            long N = longs[0];
            long K = longs[1];
            long[] V = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

            long leftLength = 1;
            long rightLength = 1;
            for (long i = 0; i < N; i++)
            {
                if (V[i] < 0)
                {
                    leftLength++;
                }
                if (V[i] >= 0)
                {
                    rightLength++;
                }
            }
            long[] left = new long[leftLength];
            left[0] = 0;
            for (long i = 1; i < leftLength; i++)
            {
                left[i] = V[leftLength - i - 1];
            }

            long[] right = new long[rightLength];
            right[0] = 0;
            for (long i = 1; i < rightLength; i++)
            {
                right[i] = V[N - rightLength + i];
            }


            long min = Int64.MaxValue;
            
            for (long i = 0; i < K + 1; i++)
            {
                if (K - i >= right.Length | K - i < 0 | i >= left.Length)
                {
                    continue;
                }
                min = Math.Min(min, -left[i] + right[K - i] * 2);
                min = Math.Min(min, -left[i] * 2 + right[K - i]);
            }
            Console.WriteLine(min);
        }
    }
}

Measured memory_bytes: 23520
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define ort ((bas+son+1ll)/2ll)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
 
typedef long long ll;
typedef pair < int , int > ii;

int x,a;

int main() {
	
	cin >> x >> a;
	cout << (x < a ? 0 : 10) << '\n';
	
	return 0;
}


Measured memory_bytes: 256
def stringtonum(s):
  s_n = list(map(ord, s))
  s_n.sort()
  res = 0
  for i, n in enumerate(s_n):
    res += (27**i) * (n-97)
  return res

d = {}
N = int(input())
for _ in range(N):
  s = input()
  n = stringtonum(s)
  if n in d:
    d[n] += 1
  else:
    d[n] = 1
    
res = 0
for v in d.values():
  res += v*(v-1)//2
print(res)

Measured memory_bytes: 15816
#include<iostream>
#include <algorithm>

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

    int d[n];
    for(int i = 0; i < n; i++) {
        std::cin >> d[i]; 
    }

    std::sort(d, d+n);
    int count = 0;
    int tmp = 0;
    count++;
    for(int i = 1; i < n; i++) {
        if(d[i-1] != d[i]) count++;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,x,l,r;
	cin>>n;
	m=0;
	for(int i=0;i<n;i++){
		cin>>l>>r;
		x=r-l+1;
		m+=x;
	}
	cout<<m<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	while(true){
			
		int a,b;
		cin >> a;
		if(a==0){
			break;
		}
		for(int n=0;n<9;n++){
			cin >> b;
			a=a-b;
		}
		printf("%d\n",a);
	}
}


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

int main(void){
   int N;
   cin>>N;
   vector<int> X(N);
   for(int i=0;i<N;i++){
      cin>>X[i];
   }
   int sum=0;
   for(int i=0;i<N-1;i++){
      sum+=abs(X[i+1]-X[i]);
   }
   for(int i=0;i<N;i++){
      if(i==N-1){
         cout<<sum+abs(X[0])+abs(X[N-2])-abs(X[i]-X[i-1])<<endl;
      }else if(i==0){
         cout<<sum+abs(X[1])+abs(X[N-1])-abs(X[1]-X[0])<<endl;
      }else{
         cout<<sum+abs(X[0])+abs(X[N-1])+abs(X[i+1]-X[i-1])-abs(X[i+1]-X[i])-abs(X[i]-X[i-1])<<endl;
      }
   }
   return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll L, R;
	cin >> L >> R;
	
	ll ans = 1e9;
	
	for(ll i = L; i <= min(R, L + 2019); ++i) {
		for(ll j = i + 1; j <= min(R, L + 2019); ++j) {
			ans = min(ans, i * j % 2019);
		}
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;

void zz(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int power(int a, int n)
{
if (!n)
return 1;
int pt = power(a, n / 2);
pt *= pt, pt %= mod;
if (n & 1)
pt *= a, pt %= mod;
return pt;
}
int32_t main(){
zz();
int n,k;cin>>n>>k;
vi dp(k+1,0);
for(int i=k;i;i--){
  int s=power(k/i,n);s%=mod;
  int ans=0;
  for(int j=2*i;j<=k;j+=i){
     ans=(ans+dp[j])%mod;
      
  }
  s-=ans;
  dp[i]=(s+mod)%mod;
}
int ss=0;
for(int i=1;i<=k;i++){
    dp[i]*=i;
    dp[i]%=mod;
    ss+=dp[i];
    ss%=mod;
}

cout<<ss<<endl;
}

Measured memory_bytes: 3916
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int result = N/1000;
        int ans = 0;
        if(N%1000!=0){
            ans = (result+1) * 1000 - N;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35720
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/STACK: 2000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define presicion(x) cout<<fixed<<setprecision(x)
#define deb(x) cerr<<#x<<" = "<<x<<endl
#define PI 3.14159265358979323
#define sen(ang) sin((ang)*PI/180)
//cout<<flush;

using namespace std;

int main() {
    //IOS;

    int n, k; cin>>n>>k;
    int cont = 0;
    for(int i=1; i<=n; i++){
        if(i%2==1) cont++;
    }
    if(cont >= k) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self, pip):
        self.pip = pip
    
    def move(self, dir):
        if str(dir) == 'E':
            self.pip[0], self.pip[2], self.pip[3], self.pip[5] = \
                self.pip[3], self.pip[0], self.pip[5], self.pip[2]
        elif str(dir) == 'W':
            self.pip[0], self.pip[2], self.pip[3], self.pip[5] = \
                self.pip[2], self.pip[5], self.pip[0], self.pip[3]
        elif str(dir) == 'N':
            self.pip[0], self.pip[1], self.pip[4], self.pip[5] = \
                self.pip[1], self.pip[5], self.pip[0], self.pip[4]
        elif str(dir) == 'S':
            self.pip[0], self.pip[1], self.pip[4], self.pip[5] = \
                self.pip[4], self.pip[0], self.pip[5], self.pip[1]

x = list(map(int, input().split()))
d = Dice(x)
n = int(input())

for _ in range(n):
    t, f = map(int, input().split())
    for j in "EEENEEENEEESEEESEEENEEEN":
        if d.pip[0] == t and d.pip[1] == f:
            break
        d.move(j)
    print(d.pip[2])


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
vector<int>ans;
void dfs(int n, int m, int stepNum) 
{ 
    if (stepNum <= m && stepNum >= n) 
        ans.pb(stepNum);
   if (stepNum == 0 || stepNum > m) 
        return ; 
    int lastDigit = stepNum % 10; 
    int stepNumA = stepNum*10 + (lastDigit-1); 
    int stepNumB = stepNum*10 + (lastDigit+1); 
    int stepNumC = stepNum*10 + (lastDigit); 
    if (lastDigit == 0){ 
        dfs(n, m, stepNumB);
        dfs(n, m, stepNumC);
    }
    else if(lastDigit == 9){ 
        dfs(n, m, stepNumA);
        dfs(n, m, stepNumC);
    }
    else
    { 
        dfs(n, m, stepNumA); 
        dfs(n, m, stepNumB); 
        dfs(n, m, stepNumC); 
    } 
} 
void solve(int n, int m) 
{ 
    for (int i = 0 ; i <= 9 ; i++) 
        dfs(n, m, i); 
}
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	solve(1,100000000000);
	sort(all(ans));
	// cout << ans.size() << endl;
	while(T--){
		int k;
		cin >> k;
		cout << ans[k-1]<<endl;		
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 10476
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=2e5+11;
const int M=5e5+1;
const int inf=1e9+1;
const ll INF=1e18;
const ll mod=998244353;
const int dx[4]={0,0,-1,1};
const int dy[4]={-1,1,0,0};

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  string s;
  cin>>s;
  for(int i=0;i<3;i++)cout<<s[i];
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





ll N, M;
//---------------------------------------------------------------------------------------------------
pair<ll, ll> taosu(ll n, ll m1, ll m2) {
    ll c1 = min(n, m1);
    m1 -= c1;
    n -= c1;

    ll c2 = min(n / 2, m2);
    m2 -= c2;
    n -= c2 * 2;

    ll c21 = min(m2, n);

    m2 -= c21;
    m1 += c21;

    return { m1, m2 };
}
//---------------------------------------------------------------------------------------------------
pair<ll, ll> nokosu(ll n, ll m1, ll m2) {
    ll c2 = min(m2, n);

    n -= c2;
    m2 -= c2;
    m1 += c2;

    ll c1 = min(n, m1);

    n -= c1;
    m1 -= c1;

    return { m1, m2 };
}
//---------------------------------------------------------------------------------------------------
ll solve1() { // ukuが勝つ
    ll n2 = N, n1 = 0;
    ll m2 = M, m1 = 0;

    ll res = 0;
    while (0 < n2 + n1 and 0 < m2 + m1) {
        tie(m1, m2) = taosu(n1 + n2, m1, m2);
        if (m1 + m2 == 0) return res;

        res++;

        tie(n1, n2) = nokosu(m1 + m2, n1, n2);
        if (n1 + n2 == 0) return res;

        res++;
    }
}
//---------------------------------------------------------------------------------------------------
ll solve2() { // うしが勝つ
    ll n2 = N, n1 = 0;
    ll m2 = M, m1 = 0;

    ll res = 0;
    while (0 < n2 + n1 and 0 < m2 + m1) {
        tie(m1, m2) = nokosu(n1 + n2, m1, m2);
        if (m1 + m2 == 0) return res;

        res++;

        tie(n1, n2) = taosu(m1 + m2, n1, n2);
        if (n1 + n2 == 0) return res;

        res++;
    }
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    ll ans = infl;
    chmin(ans, solve1());
    chmin(ans, solve2());
    cout << ans << endl;
}



Measured memory_bytes: 3164
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = _read_value!(_scanned, $t);
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    #[derive(Default)]
    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            if buf_.last() != Some(&b'\n') {
                buf_.push(b'\n');
            }
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        abs: [(_1based, _1based); 3],
    }
    let mut cs = vec![0; 4];
    for (a, b) in abs {
        cs[a] += 1;
        cs[b] += 1;
    }
    let m = cs.iter().filter(|&&c| c == 1).count();
    let n = cs.iter().filter(|&&c| c == 2).count();
    let p = m == 2 && n == 2;
    println!("{}", if p { "YES" } else { "NO" });
}


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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll sum = 0;
  sum += min(K, A);
  K -= A;
  K -= B;
  if(K > 0){
    sum -= K;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3624