akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    LL a,b,c,d,e,f,g;
    cin >> a >> b >> c >> d >> e >> f >> g;

    if(a > 0 && d > 0 && e > 0){
        if((a%2 == 0 && d%2 == 0 && e%2 == 0)||(a%2 == 1 && d%2 == 1 && e%2 == 1)){
            cout << b+a+d+e << endl;
        }else{
            cout << b+a+d+e-1 << endl;
        }
    }else{
        cout << b+(a/2)*2+(d/2)*2+(e/2)*2 << endl;
    }
    
    return 0;
}

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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

string fnd(ll n)
{
    string ret = "";
    while (n)
    {
        int tmp = n % 26;
        if (tmp == 0)
            tmp = 26;
        ret += 'a' + tmp - 1;
        n /= 26;
        if (tmp == 26)
            --n;
    }
    reverse(ret.begin(),ret.end());
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    cout << fnd(n) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  vector<int> arr(n);
  for(int i=0;i<n;i++){
    cin>>arr[i]; 
  }
  
  vector<int>dp(n);
  dp[0] =0;
  dp[1] = abs(arr[1]-arr[0])+dp[0];
  for(int i=2;i<n;i++){
     dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
     
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n+1);
  rep(i,m) {
    int p, s;
    string S;
    cin >> p >> S;
    s = S == "AC" ? 1 : 0;
    a[p].push_back(s);
  } 

  int wa = 0, ac = 0;
  
  for (int i = 1; i < n+1; i++) {
    int tmpWa = 0;
    for (int j : a[i]) {
      if (j == 1) {
        ac++;
        wa += tmpWa;
        break;
      }
      tmpWa++;
    }
  }
  cout << ac << " " << wa << endl;
}


Measured memory_bytes: 5760
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        if (a <= 9 && a > 0 && b <= 9 && b > 0) {
            System.out.println(a * b);
        } else {
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll a; cin >> a;
    double b; cin >> b;
    ll b100 = round(b * 100);
    cout << a * b100 / 100 << endl;

    return 0;
}

Measured memory_bytes: 3772
import java.util.Scanner;
 
class Card{
    public String suit;
    public int value;
    public int index;
}
 
public class Main{
    public static void main(String[] args){
    int i, q;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
        Card[] A = new Card[n];
        Card[] B = new Card[n];
    for(i=0; i<n; i++){
        A[i] = new Card();
        B[i] = new Card();
    }
    for(i=0; i<n; i++){
        A[i].suit = sc.next();
        A[i].value = sc.nextInt();
        A[i].index = i; 
    }
    quickSort(A, n, 0, n-1);
    if(isStable(A) == true){
        System.out.print("Stable\n");
    }else{
        System.out.print("Not stable\n");
    }
    for(i=0; i<n; i++){
        System.out.printf("%s %d\n", A[i].suit, A[i].value);
    	}
    }
     
    public static int partition(Card[] A, int n, int p, int r){
    int x, i, j;
    Card tmp;
    x = A[r].value;
    i = p-1;
    for(j=p; j<r; j++){
        if(A[j].value<=x){
        i++;
        tmp = A[i]; A[i] = A[j]; A[j] = tmp;
        }
    }
    tmp = A[i+1]; A[i+1] = A[r]; A[r] = tmp;
    return i+1;
    }
 
    public static void quickSort(Card[] A, int n, int p, int r){
    int q;
    if(p < r){
        q = partition(A, n, p, r);
        quickSort(A, n, p, q - 1);
        quickSort(A, n, q + 1, r); 
    }
    }
    static boolean isStable(Card[] A){
    for(int i = 0; i < A.length; i++){
        for(int j = i + 1; j < A.length; j++){
        if(A[i].value == A[j].value && A[i].index > A[j].index)
            return false;
        }
    }
    return true;
    }       
}

Measured memory_bytes: 129484
<?php
# 入力部
// fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d %d", $a, $b);
// $s = fgets(STDIN);
// fscanf(STDIN, "%d", $n);

# 処理部
// $arr = explode(" ", $s);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// for ($i = 0; $i < count($arr); $i++) {
//   if ($i + 1 != $arr[$i]) {
//     $r = $i + 1;
//   }
// }

# 出力部
echo $a * $b . "\n";
// echo ($i * 1000) - $n . "\n";

Measured memory_bytes: 15904
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

struct edge {
    int to, cap, rev;
    edge(int _to, int _cap, int _rev)
    : to(_to), cap(_cap), rev(_rev) {}
};
vector<vector<edge>> G;
vector<int> Used;
void add_edge(int from, int to, int cap)
{
    G[from].emplace_back(to, cap, G[to].size());
    G[to].emplace_back(from, 0, G[from].size()-1);
}
int dfs(int s, int t, int f)
{
    if (s == t) return f;
    Used[s] = 1;
    for (auto& e : G[s]) {
        if (Used[e.to] || e.cap == 0) continue;
        int d = dfs(e.to, t, min(f, e.cap));
        if (d > 0) {
            e.cap -= d;
            G[e.to][e.rev].cap += d;
            return d;
        }
    }
    return 0;
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for (int h = 0; h < H; ++h) {
        cin >> A[h];
    }
    int N = H*W;
    G.resize(2*N);
    
    int S = -1, T = -1;
    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
            int i = h*W+w;
            if (A[h][w] == 'S') S = i;
            else if (A[h][w] == 'T') T = i;
            else if (A[h][w] == 'o') add_edge(i+N, i, 1);
        }
    }
    for (int h = 0; h < H; ++h) {
        for (int w1 = 0; w1 < W; ++w1) {
            if (A[h][w1] == '.') continue;
            int i1 = h*W+w1;
            for (int w2 = w1+1; w2 < W; ++w2) {
                if (A[h][w2] == '.') continue;
                int i2 = h*W+w2;
                add_edge(i1, i2+N, INF);
                add_edge(i2, i1+N, INF);
            }
        }
    }
    for (int w = 0; w < W; ++w) {
        for (int h1 = 0; h1 < H; ++h1) {
            if (A[h1][w] == '.') continue;
            int i1 = h1*W+w;
            for (int h2 = h1+1; h2 < H; ++h2) {
                if (A[h2][w] == '.') continue;
                int i2 = h2*W+w;
                add_edge(i1, i2+N, INF);
                add_edge(i2, i1+N, INF);
            }
        }
    }
    if (S/W == T/W || S%W == T%W) {
        cout << -1 << endl;
        return 0;
    }
    int Res = 0;
    while (1) {
        Used.assign(2*N, 0);
        int d = dfs(S, T+N, INF);
        if (d == 0) break;
        Res += d;
    }
    cout << Res << endl;

    return 0;
}


Measured memory_bytes: 62592
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> T(N);

    int sum = 0;

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

    int M;
    cin >> M;

    vector<int> ans(M);

    for(int i = 0; i < M; i++) {
        int P, X;
        cin >> P >> X;
        P--;
        ans[i] = sum + X - T[P];
    }

    for(int i = 0; i < M; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int par[100001];
int r[100001];

void init(int n){
    for(int i=0; i<n; i++){
        par[i] = i;
        r[i] = 0;
    }
}

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

void unite(int x, int y){
    int par_x = find(x);
    int par_y = find(y);
    if(x == y) return;
    else{
        if(r[par_x] < r[par_y]) par[par_x] = par_y;
        else{
            par[par_y] = par_x; 
            if(r[par_x] == r[par_y]) r[par_x]++;
        }
    }
}

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

int main(){
    init(100001);
    int number[100001];
    int n,m;
    cin >>n >> m;
    for(int i=1; i<=n; i++){
        cin >> number[i];
    }
    for(int i=0;i<m; i++){
        int x,y;
        cin >> x >> y;
        unite(x,y);
    }
    int count = 0;
    for(int i=1;i<=n;i++){
        if(same(par[i],par[number[i]]))count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int a[4];
    for(int i = 0; i < 4; i++) cin >> a[i];
    sort(a,a+4);
    if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 5
0 0 1
0 1 2
0 2 3
1 0 2
1 1 2

output:
1
2
"""

import math
import sys

INIT_MAX = pow(2, 31) - 1


class SegmentTree(object):
    __slots__ = ('dat', 'ext_length')

    def __init__(self, orig_length):
        """
        Init a SegmentTree with update and find for range minimum queries.
        """
        self.ext_length = pow(2, math.ceil(math.log2(orig_length)))
        self.dat = [INIT_MAX] * (2 * self.ext_length - 1)

    # let A[k]=a
    def update(self, k, a):
        k += self.ext_length - 1
        self.dat[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2])

    # get min(A[s] A[s+1] ... A[t])
    def find(self, s, t, k=0, left=0, right=float('inf')):
        if right <= s or t <= left:
            return INIT_MAX
        elif s <= left <= right <= t:
            return self.dat[k]
        else:
            vl = self.find(s, t, k * 2 + 1, left, (left + right) // 2)
            vr = self.find(s, t, k * 2 + 2, (left + right) // 2, right)
            return min(vl, vr)


def cmd_exec(queries, n_num):
    case = SegmentTree(n_num)
    end = pow(2, math.ceil(math.log2(n_num)))

    for query in queries:
        cmd, ele_1, ele_2 = map(int, query)
        if cmd == 0:
            case.update(ele_1, ele_2)
        elif cmd == 1:
            # assert ele_1 <= ele_2
            res = case.find(s=ele_1, t=ele_2 + 1, right=end)
            print(res)

    return None


def solve():
    _input = sys.stdin.readlines()
    n_num, q_num = map(int, _input[0].split())
    queries = map(lambda x: x.split(), _input[1:])

    cmd_exec(queries, n_num)
    return None


if __name__ == '__main__':
    solve()

Measured memory_bytes: 19716
N, K = map(int, input().split())

diff_abs_list = []
diff_list = []
judge = 0
count = 0

if N <= K:
    answer = min(abs(N - K), abs(abs(N - K) - K)) 
elif N % K == 0:
    answer = 0
else:
    while True:
        N = N % K
        judge = N -K
        N = abs(N - K)
        diff_abs_list.append(N)

        if judge < 0:
            break
        judge = 0
        count += 1
    answer = min(diff_abs_list[count -1], diff_abs_list[count])

print(answer)

Measured memory_bytes: 3064
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let s = s.next().unwrap();
	if &s[s.len() - 1..] == "s" {
		println!("{}es", s);
	} else {
		println!("{}s", s);
	}
}


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

int main()
{
    int H, N ,D;
    cin >> H >> N;
    int a[N];
    D = 0;
    for(int i = 0;i < N; ++i){
        cin >> a[i];
        D += a[i];
    }
    if ((H - D) > 0){
        cout << "No";
    }
    else{
        cout<< "Yes";
    }

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int g[9][9];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        g[a][b] = g[b][a] = 1;
    }
    vector<int> r(n);
    iota(begin(r), end(r), 1);
    int ans = 0;
    while (true) {
        bool ok = true;
        for (int i = 0; i < n - 1; ++i) {
            if (!g[r[i]][r[i + 1]]) ok = false;
        }
        ans += ok;
        if (!next_permutation(begin(r) + 1, end(r))) {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>

int main()
{
	int W, H, x, y, r;
	
	std::cin >> W >> H >> x >> y >> r;
	
	if (x - r < 0 || x + r > W || y - r < 0 || y + r > H) std::cout << "No" << std::endl;
	else std::cout << "Yes" << std::endl;

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

class Compression {
public:
    Compression(const std::vector<int>& list) {
        value_ = list;
        std::sort(value_.begin(), value_.end());
        value_.erase(std::unique(value_.begin(), value_.end()), value_.end());
        for(int i = 0; i < value_.size(); ++i) index_[value_[i]] = i;
    }
    int size() const {return value_.size();}
    int index(const int v) const {return index_.at(v);}
    int operator[](const int i) const {return value_.at(i);}
private:
    std::map<int, int> index_;
    std::vector<int> value_;
};

using namespace std;

struct Tape {int x1, y1, x2, y2;};

bool flood_fill(vector<vector<int>>& board, const int h, const int w, const int y, const int x) {
    if(board[y][x]) return false;
    board[y][x] = 1;

    enum {Y, X};
    const int NEXT[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
    for(const auto& d: NEXT) {
        int ny = y + d[Y];
        int nx = x + d[X];
        if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
        if(board[ny][nx]) continue;
        flood_fill(board, h, w, ny, nx);
    }
    return true;
}

int main() {
    int w, h;
    while(cin >> w >> h, w | h) {
        int n;
        cin >> n;

        vector<int> vx, vy;
        vy.push_back(0); vy.push_back(h);
        vx.push_back(0); vx.push_back(w);
        vector<Tape> tape(n);
        for(auto& t: tape) {
            cin >> t.x1 >> t.y1 >> t.x2 >> t.y2;
            vy.push_back(t.y1); vy.push_back(t.y2);
            vx.push_back(t.x1); vx.push_back(t.x2);
        }
        Compression y(vy), x(vx);

        vector<vector<int>> board(y.size(), vector<int>(x.size(), 0));
        for(const auto& t: tape) {
            ++board[y.index(t.y1)][x.index(t.x1)];
            --board[y.index(t.y2)][x.index(t.x1)];
            --board[y.index(t.y1)][x.index(t.x2)];
            ++board[y.index(t.y2)][x.index(t.x2)];
        }

        for(int j = 0; j < x.size(); ++j) for(int i = 0; i < y.size() - 1; ++i) board[i + 1][j] += board[i][j];
        for(int i = 0; i < y.size(); ++i) for(int j = 0; j < x.size() - 1; ++j) board[i][j + 1] += board[i][j];
//         for(int i = 0; i < y.size(); ++i) {
//             for(int j = 0; j < x.size(); ++j) cout << " " << board[i][j];
//             cout << endl;
//         }

        int answer = 0;
        for(int i = 0; i < y.size() - 1; ++i) for(int j = 0; j < x.size() - 1; ++j)
            if(flood_fill(board, y.size() - 1, x.size() - 1, i, j)) ++answer;
        cout << answer << endl;
    }
}

Measured memory_bytes: 8380
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int from, to;
	T cost;
	Edge() {}
	Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template<class T>
vector<T> Bellman_Ford(vector<Edge<T>> &edges, int V, int st) {

	vector<T> dist(V, INF);
	dist[st] = 0;
	for (int i = 0; i < V - 1; i++) {
		for (const auto &ele : edges) {
			if (dist[ele.from] == INF) continue;
			dist[ele.to] = min(dist[ele.to], dist[ele.from] + ele.cost);
		}
	}

	for (int i = 0; i < V; i++) {
		for (const auto &ele : edges) { // finding negative loop
			if (dist[ele.from] == INF) continue;
			if (dist[ele.from] == -INF) dist[ele.to] = -INF; // src is nloop -> dst is nloop
			if (dist[ele.to] > dist[ele.from] + ele.cost) dist[ele.to] = -INF; // chmin is possible -> nloop
		}
	}

	return dist;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, P;
	cin >> N >> M >> P;

	int a, b, c;
	vector<Edge<int>> edges(M);
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--, b--;
		edges[i] = { a, b, P - c };
	}

	auto dist = Bellman_Ford(edges, N, 0);
	DMP(dist);

	int ans = -dist.back();
	if (ans == INF) cout << "-1\n";
	else if (ans < 0) cout << "0\n";
	else cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <complex>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n * 3);
    for (int i = 0; i < n * 3; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    int i = 0;
    ll ans = 0;
    for (int i = 1; i < n * 2; i += 2)
        ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>
 
using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }
 
ll h, w, dp[100][100] = {};
string s[100] = {};
 
int main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			if (i != 0 || j != 0)dp[i][j] = 1000;
		}
	}
	rep(i, h)cin >> s[i];
	rep(i, h) {
		rep(j, w) {
			if (i < h - 1) {
				if (s[i][j] != s[i + 1][j]) {
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
				}
				else {
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
				}
			}
			if (j < w - 1) {
				if (s[i][j] != s[i][j + 1]) {
					dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
				}
				else {
					dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
				}
			}
		}
	}
	if (s[0][0] == '#' && s[h - 1][w - 1] == '#') {
		cout << (dp[h - 1][w - 1] + 1) / 2 + 1 << endl;
	}
	else {
		cout << (dp[h - 1][w - 1] + 1) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string s;
int e[100100];
int n;
int tot;
int stopR[100100];
int stopL[100100];
int go(int pos)
{
	if(s[pos]=='R')
	{
		if((stopR[pos]-pos)%2==0) return stopR[pos]; 
		return stopR[pos]+1;
	}
	if(s[pos]=='L')
	{
		if((pos-stopL[pos]+1)%2==0) return stopL[pos]-1;
		return stopL[pos];
	}
}
char a='L';
int ans;
int main()
{
	cin>>s;
	n=s.length();
	ans=n-1;
	for(int i=n-1;i>=0;--i)
	{
		if(s[i]!=a)
		{
			ans=i;
			a=s[i];
		}
		stopR[i]=ans;
	}
	ans=0;
	a='R';
	for(int i=0;i<n;++i)
	{
		if(s[i]!=a)
		{
			ans=i;
			a=s[i];
		}
		stopL[i]=ans;
	}
	for(int i=0;i<n;++i)
	{
		e[go(i)]++;
	}
	for(int i=0;i<n;++i)
	{
		cout<<e[i]<<" ";
	}
	cout<<endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;

    int k = s.size();
    int hoge = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'o') {
            hoge += 1;
        }
    }
    if (hoge + 15 - k >= 8) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    };

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX_N 200010
int n, m;
int D[MAX_N], T[MAX_N];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> D[i];
    cin >> m;
    for (int j = 0; j < m; j++) cin >> T[j];
    sort(D, D + n);
    sort(T, T + m);
    int i = 0, j = 0;
    while (i != n && j != m) {
        if (T[j] < D[i]) break;
        else if (T[j] == D[i]) { i++; j++; }
        else i++;
    }
    if (j == m) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll N, M, Q;
ll A, B;
ll LR[502][502];
ll ans;
string S;
ll K;
int main() {
	cin >> N;
	if (N == 0) {
		cout << 0 << endl;
		return 0;
	}
	string ans = "";
	ll i = 1;
	while(N!=0){
		if (N % (i *2) != 0) {
			ans = '1' + ans;
			N -= i;
		}
		else
			ans = '0' + ans;
		i *= -2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{string s;
cin>>s;
int d;
cin>>d;
//cout<<s<<" s_d "<<d<<endl;
int mod=1e9+7;
int dp[d+1][2][s.length()+1];
for(int i=0;i<=d;i++)
{for(int j=0;j<=s.length();j++){
	dp[i][0][j]=0;
dp[i][1][j]=0;
}}
//cout<<dp[0][0][0]<<endl;
dp[0][0][0]=1;
//cout<<"pp "<<endl;
for(int k=1;k<=s.length();k++){

for(int i=0;i<d;i++)
{for(int j=0;j<=9;j++)
{//cout<<s[k]-'0'<<"pp "<<endl;
for(bool i1:{false,true})
{int x=s[k-1]-'0';
	if((j>(x)&&i1==true)||(j<=x)){
dp[(i+j)%d][i1||(j<x)][k]=(dp[(i+j)%d][i1||(j<x)][k]+dp[i][i1][k-1])%mod;
//cout<<dp[(i+j)%d][i1||(j<s[k]-'0')][k]<<" ll "<<endl;
		
	}
}}}}
int ans=(dp[0][false][s.length()]+dp[0][true][s.length()])%mod;
ans--;
if(ans<0)
ans+=mod;
cout<<(ans)<<endl;
return 0;}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 51
// dp[k][i][j]:ノードiからノードjにk手番で到達できるパス数
ll dp[MAXN+1][MAXN+1];
int n;

struct Matrix{
  ll val[MAXN+1][MAXN+1];
  Matrix(){
    rep(i, n)rep(j, n)val[i][j]=0;
  }
};


Matrix operator*(Matrix a, Matrix b){
  Matrix c;
  rep(i, n)rep(j, n)rep(k, n){
    c.val[i][j] += a.val[i][k]*b.val[k][j];
    c.val[i][j] %= MOD;
  }
  return c;
}

Matrix I;
Matrix matrix_power(Matrix a, ll b){
  if(b==0)return I;
  Matrix res = matrix_power(a, b/2);
  res = res*res;
  if(b%2)res = res*a;
  return res;
}

int main(){
  ll k;cin>>n>>k;
  Matrix a;
  rep(i, n)rep(j, n)cin>>a.val[i][j];
  rep(i, n)I.val[i][i]=1;

  a = matrix_power(a, k);

  ll result = 0;
  rep(i, n)rep(j, n){
    result += a.val[i][j];
    result %= MOD;
  }

  cout<<result<<endl;

  return 0;

  rep(i, n){
    rep(j, n)cout<<a.val[i][j]<<' ';
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 9988
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

a = S()

if a.islower():
    print('a')
    exit()

print("A")

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

using namespace std;

#define OnlineJudge1

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
#define debug(x) cerr << #x << " = " << (x) << '\n'
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("input.in","r",stdin);
    freopen("output.in","w",stdout);
#endif
}

const int N = 1e4 + 9, M = 105, OO = 0x3f3f3f3f;
const ll llOO = 1e18;


int main(){
    init();

    int n;  cin >> n;
    set<int> s;
    for(int i = 0;i < n;i++){
        int x;  cin >> x;
        if(s.find(x) != s.end())    return cout << "NO", 0;
        s.insert(x);
    }
    
    cout << "YES";

}




Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  string s,t;
  cin>>s>>t;

  int count=0;
  for(int i=0;i<s.size();i++){
    if(s[i] != t[i])
      count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3852
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define int long long

int partition(int *A,int p,int r){
    int x=A[r];
    int i=p-1;
    for(int j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    int k=partition(A,0,n-1);
    for(int i=0;i<n;i++){
        if(i) cout<<" ";
        if(i==k) cout<<"[";
        cout<<A[i];
        if(i==k) cout<<"]";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K, x) binary_search(K.begin(), K.end(), x)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout << x << endl
#define put(x) out(x)
#define in(x) cin >> x
#define maxx(a, b, c) max(a, max(b, c))
#define minn(a, b, c) min(a, min(b, c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main()
{
    int x;
    in(x);
    if(x==7||x==5||x==3) out("YES");
    else
        out("NO");
}


Measured memory_bytes: 256
A, B, C, X, Y = gets.split.map(&:to_i)

x = 0
y = 0
ans = 0
while x < X || y < Y
  if x < X && y < Y
    if A + B > C * 2
      x += 1
      y += 1
      ans += C * 2
    else
      x += 1
      y += 1
      ans += A + B
    end
  elsif x < X
    if A > C * 2
      x += 1
      ans += C * 2
    else
      x += 1
      ans += A
    end
  elsif y < Y
    if B > C * 2
      y += 1
      ans += C * 2
    else
      y += 1
      ans += B
    end
  end
end
puts ans


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

#define ll long long

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	string s, t;
	cin>>s >> t;
	
	cout << t+s << endl;
	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int int
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int dp[5010][5010];



int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	string s; cin>>s;
	For(i,0,n){
		dp[i][n]=0;
		dp[n][i]=0;
	}
	int ans=0;
	for(int i=n-1;i>=0;i--){
		for(int j=n-1;j>=0;j--){
			if(i<j && s[i]==s[j]) dp[i][j]=min(dp[i+1][j+1]+1,j-i);
			else dp[i][j]=0;
			ans=max(ans,dp[i][j]);
		}
	}
	cout<<ans<<"\n";
	//For(i,0,n) For(j,0,n){
	//	cout<<dp[i][j]<<" \n"[j==n];
	//}
	return 0;
}





























Measured memory_bytes: 98176
#include <bits/stdc++.h>
#define Task "C"

using namespace std;
const int maxN = 3e3 + 5;
long long n, a[maxN];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i<=n; ++i) cin >> a[i];
    long long res = 0;
    for(int i = 1; i<=n; ++i) res += a[i] - 1;
    cout << res;

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,W; cin >> N >> W;
	vector<LL> dp(W+1,0);
	repp(i,0,N){
		int w; LL v; cin >> w >> v;
		repm(k,W,w-1) dp[k] = max(dp[k],dp[k-w]+v);
	}
	LL ans = 0; repp(i,0,W+1) ans = max(ans,dp[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  rep(i,1,6){
    cin >> A;
    if(A!=i)sum=i;
  }
  Out(sum);
}

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

typedef long long ll;
int main(){
    ll N;
    ll Q, H, S, D; cin >> Q >> H >>S >> D;
    cin >> N;
    Q *= 4; H*=2;
    ll minV = min(Q*2, min(H*2, min(S*2, D)));
    
    ll ans = N/2*minV+((N%2!=0)?min(Q, min(H, S)):0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
main()
{
    int n;
    cin >> n;
    string s;
    int cnt = 0,a = 0, b = 0, ba = 0;
    for( int i = 0; i < n; i++ )
    {
        cin >> s;
        if( s[0] == 'B' )b++;
        if( s[s.size() - 1] == 'A' )a++;
        if( s[0] == 'B' && s[s.size() - 1] == 'A' ) ba++;
        for( int j = 0; j < s.size(); j++ )
        {
            if( s[j] == 'A' && s[j+1] == 'B') cnt++;
        }
    }
    cnt += min( a, b );
    if( a == ba && b == ba && b > 0 ) cnt--;
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author otsuhata
 */
public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    //System.out.print("0??????10000?????§?????°???????????????3???????????????????????§??\????????????????????????");
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    int[] numbers = {a, b, c};
    int nLength = numbers.length;
    
    int min = 0;
    int mid = 0;
    int max = 0;
    
    
    if(0 <= a && a <= 10000 && 0 <= b && b <= 10000 && 0 <= c && c <= 10000) {
        for(int i = 0; i < nLength; i++) {
            if(numbers[i] > max) {
                min = mid;
                mid = max;
                max = numbers[i];
            }else if(max > numbers[i] && numbers[i] > mid) {
                min = mid;
                mid = numbers[i];
            }else {
                min = numbers[i];
            }
        }
        System.out.println(min + " " + mid + " " + max);
    }else {
        System.out.println("Please enter a number from 0 to 10000.");
    }
  }    
}

Measured memory_bytes: 26148
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  unsigned long long sum=0;
  int a[200001];
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
  int go=0;
  int cnt=0;
  for(int i=0;i<n;i++){
    while(go<n && (cnt&a[go])==0){
      cnt|=a[go];
      go++;}
      sum+=go-i;
      cnt^=a[i];
    }
    printf("%lld\n",sum);
    return 0;
}

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

int n;
vector<string> s;
vector<int> bit(10,0);

int main(){

  cin >> n;
  set<string> st;
  rep(i,n){
    string s;
    cin >> s;
    st.insert(s);
  }

  cout << st.size() << endl;

  return 0;

}


Measured memory_bytes: 19096
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
  	cin>>n>>m;
    if(n==m){
        cout<<"Yes"<<'\n';
    }
    else{
        cout<<"No"<<'\n';
    }
    return(0);
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = set()

for ia in range(a+1):
    for ib in range(b+1):
        for ic in range(c+1):
            if 500*ia+100*ib+50*ic == x:
                count.add(str(ia)+str(ib)+str(ic))

print(len(count))

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
    char x;int i,a=0,b=0;
    for(i=0;i<3;i++)
    {
        scanf("%c",&x);
        if(x=='A') a++;
        else if(x=='B') b++;
    }
    if(a&&b) printf("Yes");
    else printf("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+5,M=1e6+5,OO=0x3f3f3f3f;
long long A,B;
char op;
int main ()
{
    cin>>A>>op>>B;
    printf("%lld\n",op=='-'?A-B:A+B);
    return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = (10000 - N) % 1000;
  // bool ok = false;

   cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3680
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val set = HashSet<String>()
    for (i in 0 until n) {
        set.add(sc.next())
    }

    when (set.size) {
        3 -> println("Three")
        4 -> println("Four")
    }
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if ((A == 1 || A == 3) && (B == 1 || B == 3)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int H = Integer.parseInt(ss0[0]);
		int W = Integer.parseInt(ss0[1]);
		
		// 2行目以降、数字が連なる。1桁で区切る
		//番兵君でやる。周りを0で囲む。配列は0で初期化されるので、代入時に+1ずらせばOK
		// 00000
		// 01230
		// 02340
		// 03450
		// 00000
		String s = "";
		int kabe = 1;
		char[][] c = new char[H+(kabe*2)][W+(kabe*2)];  //0で初期化される

		for(int i = 0; i < H; i++){
			s = br.readLine();
			for(int j = 0; j < W; j++){
				c[i+kabe][j+kabe] = s.charAt(j);
			}
		}
		for(int i = 0; i < H+2; i++){
			for(int j = 0; j < W+2; j++){
				if ( i == 0 ) { c[i][j] = '#'; }
				if ( j == 0 ) { c[i][j] = '#'; }
				if ( i == H+1 ) { c[i][j] = '#'; }
				if ( j == W+1 ) { c[i][j] = '#'; }
			}
		}

					////入力値確認
					checkInput(c);


	return;
	}
	//-----------------------------------------------------------------
	// Debug.Print
	static void dp(String s) {
		System.out.println(s);
	}
	static void dp(StringBuilder s) { dp(s.toString()); }
	static void dp(int i) { dp(String.valueOf(i)); }
	static void dp(long i) { dp(String.valueOf(i)); }

    //-----------------------------------------------------------------
					// 入力値確認
					static void checkInput(int[][] i2) {
						StringBuilder sb = new StringBuilder();
						for(int[] i1: i2){
							for(int i: i1) sb.append("[" + i + "]");
							sb.append(System.getProperty("line.separator"));
						}
						System.out.println(sb);
					}
					// 入力値確認
					static void checkInput(char[][] i2) {
						StringBuilder sb = new StringBuilder();
						for(char[] i1: i2){
							//for(char i: i1) sb.append("[" + i + "]");
							for(char i: i1) sb.append(""+i);
							sb.append(System.getProperty("line.separator"));
						}
						System.out.println(sb);
					}


}


Measured memory_bytes: 22612
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
count = 1
chk = []
p = 1
if n == 1:
  print(0)
  exit()
else:
  for i in range(n-1):
    if a[i] != a[i+1]:
      count += 1
      chk.append(p)
      p = 1
    else:
      p += 1
  if a[-1] == a[-2]:
    chk.append(p)
  else:
    chk.append(1)
  chk.sort()
  #print(chk)
  #print(count)
  if count <= k:
    print(0)
    exit()
  else:
    print(sum(chk[:count-k]))
    exit()

Measured memory_bytes: 25340
#include<bits/stdc++.h>
using namespace std;
int main()
 {
  long long i,j,a1,a2,a3,b,n,m;
  cin>>a1>>a2>>a3;
  if((a1+a2+a3)>=22)
    cout<<"bust";
  else
    cout<<"win";
    
  return 0;
 }

Measured memory_bytes: 256
#include <iostream>
//#include <map>
#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    int n;
    int k;
    vector<double> p;
    double tmp_p;
    double tmp_p_k;
    double ans=0;
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> tmp_p;
        tmp_p=(1.0+tmp_p)/2.0;
        p.push_back(tmp_p);
    }
    tmp_p_k=0;
    for(int i=0; i<k; i++){
        tmp_p_k+=p[i];
    }
    ans=tmp_p_k;
    for(int i=0; i<n-k; i++){
        tmp_p_k+=p[k+i]-p[i];
        if(ans<tmp_p_k){
            ans=tmp_p_k;
        }
    }
    cout << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
object Main {
  def main(args: Array[String]): Unit = {
    val nums            = io.StdIn.readLine().split(" ").map{_.toInt}
    val divide_max_num  = if(nums(0) < nums(1)) nums(0) else nums(1)
    var divisible_nums = Vector.empty[Int]

    (0 until divide_max_num).foreach { i =>
      val divide_num = divide_max_num - i
      if(nums(0)%divide_num == 0 &&
         nums(1)%divide_num == 0) {
        divisible_nums = divisible_nums :+ divide_num
      }
    }
    val print_number = nums(2) - 1
    if(print_number < 0) {
      println(1)
    }
    else {
      println(divisible_nums(print_number))
    }
  }
}

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

const int INF = 1 << 30;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) break;
		vector<int> a(n);
		rep(i, n) cin >> a[i];
		sort(a.begin(), a.end());
		int ans = INF;
		rep(i, n - 1) ans = min(ans, a[i + 1] - a[i]);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
import java.util.*;
public class Main {
	public static void main(String[] args) {
		int a,b,c;
		Scanner scan = new Scanner(System.in);
		
		for(int i = 0; i <= 6; i++) {
			a = scan.nextInt();
			b = scan.nextInt();
				if(a >= b) {
					c = a - b;
					System.out.println(c);
				}
		}
	}
}

Measured memory_bytes: 17332
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    char S[11];
    cin >> S;
    int max_l = 0;
    for (int l = 0; l < strlen(S); l++) {
        for (int r = l+1; r <= strlen(S); r++) {
            bool is_ACGT = true;
            for (int i = l; i < r; i++) {
                if (S[i] != 'A' && S[i] != 'C' &&
                    S[i] != 'G' && S[i] != 'T')
                {
                    is_ACGT = false;
                }
            }
            if (is_ACGT) {
                max_l = fmax(max_l, r-l);
            }
        }
    }
    cout << max_l << endl;
    return 0;
}

Measured memory_bytes: 256