akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;


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

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

  if (2 * n >= m) {
    cout << m / 2 << endl;
    return 0;
  }

  ll ans = n;
  m -= 2 * n;

  ans += m / 4;

  cout << ans << endl;

  return 0;
}


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

int e[15][15];
int calc(int y1, int y2, int x1, int x2) {
    int outer = 1e9;
    // 壁の高さの最小値
    for (int i = y1; i <= y2; i++) {
        for (int j = x1; j <= x2; j++) {
            if (i == y1 || i == y2 || j == x1 || j == x2) {
                outer = min(outer, e[i][j]);
            }
        }
    }
    int res = 0;
    for (int i = y1; i <= y2; i++) {
        for (int j = x1; j <= x2; j++) {
            if (i == y1 || i == y2 || j == x1 || j == x2) {
                continue;
            }
            if (e[i][j] >= outer) return 0;
            res += outer - e[i][j];
        }
    }
    return res;
}

int main() {
    int d, w;
    while (cin >> d >> w, d | w) {
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < w; j++) {
                cin >> e[i][j];
            }
        }
        int ans = -1;
        for (int y1 = 0; y1 < d; y1++) {
            for (int x1 = 0; x1 < w; x1++) {
                for (int y2 = y1 + 2; y2 < d; y2++) {
                    for (int x2 = x1 + 2; x2 < w; x2++) {
                        ans = max(ans, calc(y1, y2, x1, x2));
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3024
h={};n=gets.to_i;a=[*0...n]
(1<<a.size).times{|i|x=0;y=[];a.size.times{|j|i[j]>0&&(x+=1<<j;y<<j)};h[x]=y}
puts h.sort.map{|k,v|k.to_s+':'+v.map{|e|' %d'%e}*''}


Measured memory_bytes: 126564
#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;

typedef long long ll;

int main(){
	int n;
	ll p[100][2];
	while(cin>>n&&n){
		memset(p,0,sizeof(p));
		for(int i=0;i<n;i++){
			int m;
			cin>>m;
			for(int j=0;j<m;j++){
				int a;
				cin>>a;
				p[i][a/64] |= 1LL<<(a&63);
			}
		}
		int k;
		ll q[2]={0};
		cin>>k;
		for(int i=0;i<k;i++){
			int a;
			cin>>a;
			q[a/64] |= 1LL<<(a&63);
		}
		int ans=-1;
		for(int i=0;i<n;i++){
			if((p[i][0]&q[0])==q[0]&&(p[i][1]&q[1])==q[1]){
				if(ans==-1)ans=i+1;
				else{
					ans=-1;
					break;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main()
{
    char s[11],t[11];
    scanf("%s%s",s,t);
    if(strlen(t)-strlen(s)>1)
        printf("No\n");
    else
    {
        int flag=0;
        for(int i=0; i<strlen(s); i++)
        {
            if(s[i]!=t[i]){
                flag=1;
                break;
            }
        }
        flag? printf("No\n"):printf("Yes\n");
    }

}


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

int main(){

  int n;
  int d[1000];

  while(cin >> n, n){
  for(int i=0;i<n;i++) cin >> d[i];

  sort(d,d+n);

  int sum = 0;
  for(int i=1;i<n-1;i++) sum += d[i];

  cout << sum/(n-2) << endl;
  }
}

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

int main() {
  int a;
  vector<int64_t>A;
  A={2LL,1LL};
  cin >> a;
  for(int i=2;i<a+1;i++){
  A.push_back(A.at(i-1)+A.at(i-2));
  }
  cout << A.at(a) << endl;  
}  

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int d, e;
int main() {
	while (cin >> d >> e, d) {
		double ans = inf;
		for (int i = 0; i <= d; i++) {
			ans = min(ans, abs(sqrt(i*i + (d - i)*(d - i))-e));
		}
		printf("%f\n", ans);
	}
}

Measured memory_bytes: 3180
import java.io.*;
import java.util.*;
public class Main {
    static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static String line;
    static int n, k, T, N, m, Q, q, R, C, x, M, id, x0, y0, g, y, d, SCC;
    static StringTokenizer st;
    static Scanner in = new Scanner(System.in);
    static char[][] word;
    static IP[][] parent;
    static BitSet onStack = new BitSet(100000);
    static ArrayList<Integer> graph[];
    static int[] low, ids;
    static Stack<Integer> stack;

    public static void main(String[] args) throws IOException {
        st = new StringTokenizer(br.readLine());pw.println(Integer.parseInt(st.nextToken())>Integer.parseInt(st.nextToken())
        ?"safe":"unsafe");
            pw.flush();

        }
        static class IP {
            int row, col;

            public IP(int row, int col) {
                this.row = row;
                this.col = col;
            }
        }
        static void extendedEuclid ( int a, int b){
            if (b == 0) {
                x = 1;
                y = 0;
                d = a;
                return;
            }
            extendedEuclid(b, a % b);
            int x1 = y;
            int y1 = x - (a / b) * y;
            x = x1;
            y = y1;
        }
        static boolean isEven ( int i){
            return (i & 1) == 0;
        }
        static boolean isOdd ( int i){
            return (i & 1) == 1;
        }
        static class Edge implements Comparable<Edge> {
            int u, v;
            double weight;

            Edge(int u, int v, double weight) {
                this.u = u;
                this.v = v;
                this.weight = weight;
            }

            @Override
            public int compareTo(Edge edge) {
                return (int) (weight - (int) edge.weight);
            }
        }
        static class DisjointSet {
            int[] parent, rank;

            void make_set(int v) {
                parent = new int[v];
                for (int i = 0; i < v; i++)
                    parent[i] = i;
                rank = new int[v];
            }

            int find_set(int v) {
                if (v == parent[v])
                    return v;
                return parent[v] = find_set(parent[v]);//compress the step
            }

            void union_set(int a, int b) {
                a = find_set(a);
                b = find_set(b);
                if (a != b) {
                    if (rank[a] < rank[b]) {
                        int c = a;
                        a = b;
                        b = c;
                    }
                    parent[b] = a;
                    if (rank[a] == rank[b])
                        rank[a]++;
                }
            }
        }
    }



Measured memory_bytes: 35576
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
a = III()

print(sum(a)-len(a))

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

int f(int n, int r) {
    int ans = 1;
    for (int i=1; i<=r; i++)    ans = (ans * (n+1-i));
    for (int i=1; i<=r; i++)    ans = ans/i;
    for (int i=1; i<=r; i++)    ans = ans*9;
    return ans;
}

string s;
int n, k;

const int N = 105;

int solve(int i, int cur) {
    if (cur == k)   return 1;
    if (i == n)     return 0;

    int dd = s[i] - '0';
    if (dd == 0)    return solve(i+1, cur);

    int rem = n-i-1;
    int ans = f(rem, k - cur);
    for (int d=1; d < dd; d++)  ans += f(rem, k - cur - 1);
    ans += solve(i+1, cur+1);
    return ans;
}

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

    cin>>s>>k;
    n = s.size();

    cout<<solve(0, 0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=100005;
int n,a[N];
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(&a[1],&a[n+1]); int mx=1e9,pos;
	for(int i=1;i<n;i++)if(abs(a[i]*2-a[n])<mx){
		mx=abs(a[i]*2-a[n]); pos=a[i];
	}
	cout<<a[n]<<" "<<pos<<endl;
}
//c(a,b)

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

int main() {
	int N, M, X, i;
	int A[100];
	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &X);
	for(i = 0; i < 100; i++){
		A[i] = 0;
	}
	for(i = 0; i < M; i++){
		int j;
		scanf("%d", &j);
		A[j] = 1;
	}
	int cost1 = 0;
	int cost2 = 0;
	for(i = X + 1; i < N + 1; i++){
		if(A[i] == 1) cost1++;
	}
	for(i = 1; i < X; i++){
		if(A[i] == 1) cost2++;
	}
	printf("%d\n", min(cost1, cost2));
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        S: String,
    }
    let mut cnt = 0;
    if S.contains("RRR") {
        cnt = 3;
    } else if S.contains("RR") {
        cnt = 2;
    } else if S.contains("R") {
        cnt = 1;
    } else {
        cnt = 0;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
typedef long long ll;

int main(void)
{
  string s, t="";
  int q, flag=0;
  cin >> s >> q;
  REP(i,q) {
    int cmd;
    cin >> cmd;
    if(cmd==1) {
      ++flag;
    } else {
      int choice;
      string sc;
      cin >> choice >> sc;
      if((flag+choice)&1) t.push_back(sc[0]);
      else s.push_back(sc[0]);
    }
  }
  if(flag & 1) swap(s,t);
  cout << string(t.rbegin(),t.rend()) << s << endl;
  return 0;
}



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

int main() {
  string A,B; cin >> A >> B;
  int sizeA = A.size(), sizeB = B.size();
  if (sizeA > sizeB) {
    cout << "GREATER" << endl; return 0;
  } else if (sizeA < sizeB) {
    cout << "LESS" << endl; return 0;
  } else {
    rep(i,0,sizeA) {
      if (A[i] == B[i]) continue;
      if ((int)(A[i] - '0') > (int)(B[i] - '0')) {
        cout << "GREATER" << endl; return 0;
      } else {
        cout << "LESS" << endl; return 0;
      }
    }
    cout << "EQUAL" << endl;
  }            
}

Measured memory_bytes: 3628
import pprint
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in [0]*n]
ab.sort(key=lambda x: x[0])
ans = 0
cnt = 0
for i in range(n):
    a, b = ab[i]
    while b:
        if cnt==m: break
        ans += a
        cnt += 1
        b -= 1
print(ans)

Measured memory_bytes: 29468
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <utility>
#include <queue>

typedef long long int LL;
using namespace std;

int main(int argc, char const *argv[]) {
    string s, t;
    cin >> s;
    cin >> t;
    vector<vector<int>> max_length(s.length() + 1, vector<int>(t.length() + 1));
    for (int i = 0; i <= s.length(); i++) {
        for (int j = 0; j <= t.length(); j++) {
            if (i == 0) {
                max_length[i][j] = 0;
                continue;
            }
            if (j == 0) {
                max_length[i][j] = 0;
            } else {
                if (s[i-1] == t[j-1]) {
                    max_length[i][j] = max_length[i-1][j-1] + 1;
                } else {
                    if (max_length[i-1][j] >= max_length[i][j-1]) {
                        max_length[i][j] = max_length[i-1][j];
                    } else {
                        max_length[i][j] = max_length[i][j-1];
                    }
                }
            }
        }
    }
    int length = max_length[s.length()][t.length()];
    int s_index = s.length();
    int t_index = t.length();
    deque<int> index;
    while (max_length[s_index][t_index] != 0) {
        if (max_length[s_index][t_index] == max_length[s_index][t_index-1]) {
            t_index--;
        } else if (max_length[s_index][t_index] == max_length[s_index-1][t_index]) {
            s_index--;
            continue;
        } else if (max_length[s_index][t_index] == (max_length[s_index-1][t_index-1] + 1)) {
            index.push_front(s_index-1);
            s_index--;
            t_index--;
            continue;
        } else {
            // unexpected
        }
    }
    string ans;
    for (auto idx: index) {
        ans += s[idx];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

const int MOD = 1e9+7;

void Main(){
    int s; cin >> s;
    vi dp(s+1, 0); dp[0] = 1;
    rep3(i, 3, s) dp[i] = (dp[i-1] + dp[i-3]) % MOD;
    cout << dp[s] << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3624
import math

n = int(input())

x = round(n/1.08)

m = math.floor(x * 1.08)

if n != m:
    x=x+1
    m = math.floor(x * 1.08)
    if n != m:
        print(":(")
    else:
        print(x) 
else:
    print(x) 

Measured memory_bytes: 3060
//わからんので回答みてやり直し
//参考 http://drken1215.hatenablog.com/entry/2019/02/03/224200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll n, k;
vector<ll> a;

int main() {
    cin >> n >> k; a.resize(n);
    for (int i = 0; i < n; i++) scanf("%Ld", &a[i]);
    ll res = 0;
    for (int d = 60; d >= -1; --d) {
        if (d != -1 && !(k & (1ll<<d))) continue;

        ll temp = 0;
        for (int e = 60; e >= 0; --e) {
            ll mask = 1ll<<e;
            ll num = 0;
            for (int i = 0; i < n; ++i) if (a[i] & mask) ++num;

            if (e>d) {
                if (k & mask) temp += mask * (n-num);
                else temp += mask * num;
            }else if (e==d) {
                temp += mask * num;
            }else{
                temp += mask * max(num, n-num);
            }
        }
        res = max(res, temp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long read()
{
	char ch=getchar();long long f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9')
	{f=(f<<1)+(f<<3)+ch-'0';
	ch=getchar();}
	return f;
}
long long a[200005],s[200005],ans=50000000000000000LL;
long long ab(long long x)
{
	return x>0?x:-x;
}
int main()
{
	int n=read();
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		s[i]=s[i-1]+a[i];
	}
	for(int i=1;i<=n-1;i++)
	{
		long long x=s[i],y=s[n]-s[i];
		ans=min(ans,ab(x-y));
	}
	cout<<ans;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

int dp[20009];
int A[20009], B[20009];

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

	int H, N; cin >> H >> N;
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

	for (int i = 1; i <= H; i++) dp[i] = INF;
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= A[i]; j++) dp[j] = min(dp[j], B[i]);
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < N; j++) {
			dp[i + A[j]] = min(dp[i + A[j]], dp[i] + B[j]);
		}
	}
	cout << dp[H] << endl;

	return 0;
}

Measured memory_bytes: 384
open Printf
open Scanf

let id x = x
exception Break

let n = scanf "%d"id

let int_sqrt n = truncate (sqrt (float n))

let run () =
    let nn = Array.init (n + 1) (fun _ -> ref 0) in
    let max = int_sqrt n in
    begin
        try for x = 1 to max do
            try for y = 1 to max do
                try for z = 1 to max do
                    let i = x * x + y * y + z * z + x * y + y * z + z * x in
                    if i > n then begin
                        raise Break
                    end else incr (nn.(i))
                done with Break -> ()
            done with Break -> ()
        done with Break -> ()
    end;
    for i = 1 to n do
        printf "%d\n" !(nn.(i))
    done
    
let () = run ()


Measured memory_bytes: 5856
#include <stdio.h>

int par(long*a,int l,int r){
	int pib=a[r-1]/500000;
	int crr=l;
	for(int i=l;i<r;i++){
		if(a[i]/500000<=pib){
			long t=a[crr];
			a[crr]=a[i];
			a[i]=t;
			crr++;
		}
	}
	return crr-1;
}

void qs(long*a,int l,int r){
	if(r-l>1){
		int m=par(a,l,r);
		qs(a,l,m);
		qs(a,m,r);
	}
}

long a[100010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		long t;
		char c;
		scanf(" %c%ld",&c,&t);
		int m=c=='D'?3:c=='H'?2:c=='S';
		a[i]=t*500000+m*100000+i;
	}
	
	qs(a,0,n);
	
	int flag=1;
	for(int i=0;i<n-1;i++)flag&=a[i]/500000<a[i+1]/500000||a[i]%100000<a[i+1]%100000;
	puts(flag?"Stable":"Not stable");
	for(int i=0;i<n;i++){
		int m=a[i]/100000%5;
		printf("%c %d\n",m==3?'D':m==2?'H':m==1?'S':'C',a[i]/500000);
	}
}


Measured memory_bytes: 2552
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    if(n % 1000 == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - (n % 1000) << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    double d, t, s;
    cin >> d >> t >> s;

    double m = d / s;
    if (m < t + 1e-9) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long long int lli;
typedef unsigned long long int ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;

//0~nの範囲操作
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//1~nの範囲操作
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
//stl配列を全範囲操作
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
//n~0を後ろから範囲操作
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
//出力後改行を
#define fin(ans) cout << (ans) << endl;
//出力後空白を
#define blank(ans) cout << (ans) << " ";
//２つの値をセットに\
sort -> p -> q
#define mp(p, q) make_pair(p, q)
//３つ以上の値をセットに(3より多いときはカッコ内を増やす)\
sort -> p -> q -> r
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
//配列全操作
#define all(a) a.begin(), a.end()
//bit表示
#define BIT(n) bitset<10>(n)

//２重配列入力
template <typename T>
void VV(T &n, ll size)
{
  for (ll i = 0; i < n.size(); i++)
  {
    for (ll j = 0; j < size; j++)
    {
      cin >> n[i][j];
    }
  }
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

void Main()
{
  ll n, d;
  cin >> n >> d;
  vvll x(n, vll (d));
  VV(x, d);
  ll flag = 0;
  ll twojo[150] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000, 10201, 10404, 10609, 10816, 11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996, 13225, 13456, 13689, 13924, 14161, 14400, 14641, 14884, 15129, 15376, 15625, 15876, 16129};
  for(ll i = 0;i < n - 1;i++)
  {
    for(ll j = i + 1;j < n;j++)
    {
      ll ans = 0;
      for(ll k = 0;k < d;k++)
      {
        ans += modpow((x[i][k]-x[j][k]), 2);
      }
      for(ll i = 0;twojo[i] <= ans;i++)
      {
        if(ans == twojo[i]) flag++;
      }
    }
  }
  fin(flag)
  return;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

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

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

bool is[10010];

int main(){
  int n;

  rep(i,10010){
    is[i] = true;
  }
  is[1] = is[0] = false;
  for(int i = 2; i < 10010; i++){
    for(int j = 2; i*j < 10010; j++){
      if(is[i] == true){
	is[i*j] = false;
      }
    }
  }

  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i = n; i >= 0; i--){
      if(is[i] && is[i-2]){
	cout << i-2 << " "<< i << endl;
	break;
      }
    }
  }



  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
  string line;
  int a,b;
  getline (cin,line);
  stringstream(line) >> a >> b;
  if ( a < b )
  { cout << "a < b\n"; }
  else if ( a > b )
  { cout << "a > b\n"; }
  else
  { cout << "a == b\n"; }
  return 0;
}

Measured memory_bytes: 3136
s=input()
s=s.replace('BC','.')
s=s.replace('B','/')
s=s.replace('C','/')
sl = s.split('/')
cnt =0
for si in sl:
    incre = 0
    for ci in si:
        if ci == 'A':
            incre +=1
        if ci == '.':
            cnt += incre
print(cnt)


Measured memory_bytes: 79916
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(l[k - 1])


Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
a0=[ai for ai in a]
a0.sort()
b=[-1]*(n+1)
base=0
i=0
while i < n:
    t=a0[i]
    c=1
    while i < n-1 and a0[i]==a0[i+1]:
        c+=1
        i+=1
    b[t]=c
    base+=c*(c-1)//2
    i+=1
for i in range(n):
    d=b[a[i]]
    print(base-d+1)

Measured memory_bytes: 26268
#include <bits/stdc++.h>
#define mp make_pair
#define x first
#define y second
#define ll long long
#define pb push_back

using namespace std;
int kol[30];
vector <pair <int, int> > V;
int pos[200005], b[200005];
ll ans;

void merges(int a[], int l, int m, int r)
{
    int l1 = l, r1 = m + 1, tek = l;
    while (l1 <= m || r1 <= r)
    {
        if ((l1 <= m) && (r1 > r || a[l1] <= a[r1]))
        {
            b[tek] = a[l1];
            l1++, tek++;
        }
        else
        {
            b[tek] = a[r1];
            ans += (ll) (m - l1 + 1);
            r1++, tek++;
        }
    }
    for (int i = l; i <= r; i++)
        a[i] = b[i];
    return;
}

void mergesort(int a[], int l, int r)
{
    if (l == r) return;
    int m = (l + r) / 2;
    mergesort(a, l, m);
    mergesort(a, m + 1, r);
    merges(a, l, m, r);
    return;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int n = (int) s.length();
    for (int i = 0; i < n; i++)
        kol[s[i] - 'a']++;

    int k = 0;
    for (int i = 0; i < 26; i++)
        k += (kol[i] % 2 == 1);
    if (k > 1) cout << -1, exit(0);

    int uk = -1;
    for (int i = 0; i < 26; i++)
        if (kol[i] % 2 == 1) uk = i;

    for (int i = 0; i < 26; i++)
    {
        if (kol[i] == 0) continue;
        stack <int> q;
        int tek = 0;
        for (int j = 0; j < n; j++)
            if (s[j] == (char) (i + 'a'))
            {
                if (tek < kol[i] / 2) q.push(j), tek++;
                else
                {
                    if (i == uk)
                    {
                        if (2 * tek == kol[i] - 1) V.pb(mp(j, j)), tek++;
                        else V.pb(mp(q.top(), j)), tek++, q.pop();
                    }
                    else
                        V.pb(mp(q.top(), j)), q.pop(), tek++;
                }
            }
    }
    sort(V.begin(), V.end());

    int uks = 0;
    for (int i = 0; i < (int) V.size(); i++)
    {
        if (V[i].x != V[i].y)
        {
            pos[V[i].x] = uks;
            pos[V[i].y] = n - 1 - uks;
            uks++;
        }
        else pos[V[i].x] = n / 2;
    }

    mergesort(pos, 0, n - 1);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3276
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("b1(i8[:],i8,i8)", cache=True)
def is_ok(a, key, idx):
    if a[idx] >= key:
        return True
    else:
        return False


@nb.njit("i8(i8[:], i8)", cache=True)
def binary_search(a, key):
    """Meguru type binary search"""
    ng = -1
    ok = len(a)

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok


@nb.njit("i8(i8, i8[:])", cache=True)
def solve(N, L):
    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            c = binary_search(L, L[a] + L[b]) - 1
            ans += c - b
    return ans


def main():
    N = int(input())
    L = np.array(input().split(), dtype=np.int64)

    ans = solve(N, L)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 107100
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
#define ll long long
using namespace std;
#define int long long
const int N = 200005;
long long n, x, d; 
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> x >> d;
	if (d == 0) {
		cout << (x == 0 ? 1 : n + 1) << '\n';
		return 0;
	}
	if (d < 0) d*=-1, x*=-1;
	// assume d > 0
	map <ll, vector< pair<ll,ll> > > vecMod;
	for (ll i=0;i<=n;++i){
		ll l = i*x + 1LL*d*i*(i-1)/2;
		ll r = i*x + 1LL*d*(2*n - 1 - i)*i/2;
		// cout << l << ' ' << r << '\n';
		vecMod[(i*x) % d].emplace_back(pair<ll,ll>(l,r));
	}	
	long long ans = 0;
	for (auto node : vecMod){ 
		#define G node.second
		sort(G.begin(), G.end());
		// for (auto v : G) cout << v.first << ' ' << v.second << '\n';
		int l = 0, r = 0;
		while (l < G.size()){	
			while (r < G.size() && G[r].first <= G[l].second) {
				G[l].second = max(G[l].second, G[r].second);
				r++;
			}
			// cout << node.first << ' ' << G[l].second << ' ' << G[l].first << '\n';
			ans += (G[l].second - G[l].first + d)/d;
			l = r;
		}
	}
	cout << ans << '\n';
}

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

int main(){
    int a,b,ans;
    string s,t;
    cin >> a >> b;
    //vector<int> a(n);
    if(b==1){
      cout << 0 << endl;
      return 0;
    }
    if(a>=b){
        cout << 1 << endl;
        return 0;
    }
    ans=1;
    int plus=a;
    a--;
    while(plus<b){
        plus+=a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
 
N,D=map(int,input().split())
X=[]
for _ in range(N):
  X.append(list(map(int, input().split())))
count=0
for i in range(N-1):
  for j in range(i+1,N):
    a=0
    for k in range(D):
      a+=(X[i][k]-X[j][k])**2
    if math.sqrt(a).is_integer():
      count+=1
print(count)

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

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if (a <= b && b <= a + w) {
    cout << 0 << endl;
    return 0;
  }

  if (a + w < b) {
    cout << b - (a + w) << endl;
  } else {
    cout << a - (b + w) << endl;
  }

  return 0;
}


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

namespace AtCoder.XXX.B
{ 
    public class Program
    {
        public static void Main(string[] args)
        {
            var cnt = 0;
            var i = 0;
            var n = r();
            var datas = cr();
			while (true)
			{
				if (datas[i] % 2 == 0)
				{
					datas[i] /= 2;
				}
				else
				{
					P(cnt);

					return;
				}
				i++;
				if (i >= datas.Count())
				{
					cnt++;
					i = 0;
				}
			}
			
        }

       

        private static StreamReader sr;
        public static int[] Ecr()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static string Er()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine();
        }
        public static string r()
        {
            return Console.ReadLine();
        }
        public static  int[] cr()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static int cri()
        {
            return int.Parse(Console.ReadLine());
        }
        public static void P(string str)
        {
            Console.WriteLine(str);
        }
        public static void P(int num)
        {
            P(num.ToString());
        }

        public static int[] Copy(int[] datas)
		{
            var result = new int[datas.Count()];
            Array.Copy(datas, result, datas.Count());
            return result;
		}
    }
}


Measured memory_bytes: 11348
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var H, W int
	fmt.Scanf("%d %d", &H, &W)
	S := make([][]string, H)
	for i := 0; i < H; i++ {
		var s string
		fmt.Scanf("%s", &s)
		S[i] = strings.Split(s, "")

	}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if S[i][j] != "#" {
				S[i][j] = calc(S, i, j)
			}
		}
	}
	for i := 0; i < H; i++ {
		fmt.Println(strings.Join(S[i], ""))
	}
}

func sharp(s [][]string, i, j int) int {
	if i < 0 || len(s) <= i || j < 0 || len(s[0]) <= j {
		return 0
	}
	if s[i][j] == "#" {
		return 1
	}
	return 0
}

func calc(s [][]string, i, j int) string {
	ret := sharp(s, i-1, j-1)
	ret += sharp(s, i-1, j)
	ret += sharp(s, i-1, j+1)
	ret += sharp(s, i, j-1)
	ret += sharp(s, i, j+1)
	ret += sharp(s, i+1, j-1)
	ret += sharp(s, i+1, j)
	ret += sharp(s, i+1, j+1)
	r := strconv.Itoa(ret)
	return r
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x))

using namespace std;

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

    vector<double> p(n+1);

    for ( int i = 1 ; i <= n ; i++ )
    {
        cin>>p[i];
    }

    double dp[n+1][n+1];
    zero(dp);

    dp[1][1] = p[1];
    dp[1][0] = 1-p[1];

    for ( int i = 2 ; i <= n ; i++ )
    {
        for ( int j = 0 ; j <= i-1 ; j++ )
        {
            dp[i][j] += (1-p[i])*(dp[i-1][j]);
            dp[i][j+1] += p[i]*(dp[i-1][j]);
        }
    }
    double ans = 0;
    for ( int i = n ; i > n/2 ; i-- )
    {
        ans += (dp[n][i]);
    }

    cout<<setprecision(20)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(void){
    int N;
    int ans,cut;
    cut=ans=0;
    string S;
    

    cin>>N>>S;
    
    for(int i=1;i<N;i++){
        
        for(char c='a';c<='z';c++){
            bool right=false; bool left= false;
            
            for(int j=0;j<i;j++){
                if(S[j]==c){
                    left=true;
                }
            }
    
            for(int j=i;j<N;j++){
                if(S[j]==c){
                    right=true;
                }
            }

            if(right==true&&left==true){
                cut++;
            }

        }

        if(ans<cut){
            ans=cut;
        }
        cut=0;

    }


    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(double& x, double y) {
	x = min(x, y);
}

void chmax(double& x, double y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

ll N, K;
ll u, v;
vector<ll> E[100010];
ll ans;

void dfs(ll now, ll from) {
	//cout << ans << endl;
	rep(i, E[now].size() - 1) ans *= K - 2 - i, ans %= mod;
	for (ll v: E[now]) {
		if (v == from) continue;
		dfs(v, now);
	}
}

void solve() {
	cin >> N >> K;
	rep(i, N - 1) {
		cin >> u >> v;
		E[u].pb(v);
		E[v].pb(u);
	}
	ans = 1;
	rep(i, E[1].size() + 1) ans *= K - i, ans %= mod;
	for (ll v: E[1]) {
		dfs(v, 1);
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int a[MAXn],b[MAXn];
int main(){
  IOS();
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  REP(i,n) cin>>a[i];
  REP(i,m) cin>>b[i];
  a[n] = x;
  b[m] = y;
  sort(a,a+n+1);
  sort(b,b+m+1);
  if( a[n]<b[0] ) cout<<"No War"<<endl;
  else cout<<"War"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

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

  vector<int> ans;
  for(int i=0; i<k; i++){
    if( a <= a+i && a+i <= b) ans.push_back(a+i);
    if( a <= b-i && b-i <= b) ans.push_back(b-i);
  }
  sort(ans.begin(), ans.end());
  cout << ans[0] << endl;
  for(int i=1; i<ans.size(); i++){
    if( ans[i] == ans[i-1] ) continue;
    cout << ans[i] << endl;
  }


  return 0;
}



//


Measured memory_bytes: 256
#include<string>
#include<iostream>
using namespace std;
// https://atcoder.jp/contests/abc095/tasks/abc095_a

int toppingPrice(string ticketCard){
    int toppingCount=0;
    int toppingCoin ;
    if(ticketCard[0] == 'o')toppingCount +=1;
    if(ticketCard[1] == 'o')toppingCount +=1;
    if(ticketCard[2] == 'o')toppingCount +=1;
//    cout << "Topping is :" << toppingCount << endl;
    toppingCoin = toppingCount * 100;
    return toppingCoin;
}
int main(void){
    string ticketCard;
    int ramenPrice=700;
    int answer;
    cin >> ticketCard;
    answer = ramenPrice+toppingPrice(ticketCard);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    int h, w, k;
    cin(h); cin(w); cin(k);

    vector<vector<bool>> map(h, vector<bool>(w, false));
    rep2(i, h) {
        rep2(j, w) {
            char temp;
            cin(temp);

            // 白（.）なら false, 黒（#）なら true
            map[i][j] = temp == '#';
        }
    }

    int result = 0;

    rep2(a, 1 << h) {
        vector<vector<bool>> tempMap = map;

        rep2(b, h) {
            if (a & 1 << b) {
                rep2(c, w) tempMap[b][c] = false;
            }
        }

        rep2(d, 1 << w) {
            vector<vector<bool>> tempMap2 = tempMap;

            rep2(e, w) {
                if (d & 1 << e) {
                    rep2(f, h) tempMap2[f][e] = false;
                }
            }

            int count = 0;
            rep2(x, h) {
                rep2(y, w) {
                    if (tempMap2[x][y]) ++count;
                }
            }

            if (count == k) ++result;
        }
    }

    print(result);
    return 0;
}

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


int main(void)
{
	
	double a, b, t;
	int ans;
	int x[100];
	int i;
	
	
	scanf("%lf%lf%lf", &a, &b, &t);
	
	ans = (t + 0.5) / a;
	
	ans *= b;
	
	printf("%d", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    string S, T;
    cin >> S >> T;
    int K = S.size(), L = T.size();
    vector<vector<int>> dp(K+1, vector<int>(L+1, 0));
    
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= L; j++) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (S[i-1] == T[j-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
        }
    }
    string ans = "";
    int x = K, y = L;
    while (dp[x][y] > 0) {
        int nx, ny;
        if (dp[x-1][y] >= dp[x][y]) {
            nx = x-1;
            ny = y;
        }else if (dp[x][y] >= dp[x][y-1]) {
            nx = x;
            ny = y-1;
        }else if (dp[x-1][y-1] >= dp[x][y] - 1) {
            nx = x-1;
            ny = y-1;
        }
        if (dp[nx][ny] == dp[x][y]-1) {
            ans += S[x-1];
        }
        x = nx;
        y = ny;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 38552