akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main() {

	int n, m, c[3000];
	int i, j, l;
	int dp[60000], cnt = 0;

	cin >> n >> m;

	for (i = 0; i < m; i++) cin >> c[i];

	memset(dp, 0x7f, sizeof dp);
	dp[0] = 0;

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {


			dp[i+c[j]] = min(dp[i] + 1,dp[i+c[j]]);

		}
	}

	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3372
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

typedef std::vector<int> vec;

bool power_of_2(int n) {
    return (n & (n - 1)) == 0;
}

int max_divisor(int n) {
    return n & -n;
}

int g(const vec& sequence) {
    int sum = 0;
    for (int i = 0; i < sequence.size(); i++) {
        sum += sequence[i];
    }

    vec table(sum + 1);
    std::fill(table.begin() + 1, table.end(), -1);
    table[0] = 0;

    sum = 0;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        for (int a = sum & -x; a >= 0; a -= x) {
            if (table[a] >= 0) {
                int b = a + x;
                table[b] = std::max(table[a] + 1, table[b]);
            }
        }
        sum += sequence[i];
    }

    int max = 0;
    for (int i = 1; i <= sum; i <<= 1) {
        max = std::max(max, table[i]);
    }
    return max;
}

vec extract(const vec& sequence, int k) {
    vec subsequence;
    int min = INT_MAX;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        if (x % k == 0 && power_of_2(x / k)) {
            subsequence.push_back(x);
            min = std::min(min, x);
        }
    }
    for (int i = 0; i < subsequence.size(); i++) {
        subsequence[i] /= min;
    }
    return subsequence;
}

int f(const vec& sequence) {
    vec numbers;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        numbers.push_back(x / max_divisor(x));
    }
    std::sort(numbers.begin(), numbers.end());
    numbers.erase(std::unique(numbers.begin(), numbers.end()), numbers.end());

    int max = 0;
    for (int i = 0; i < numbers.size(); i++) {
        int k = numbers[i];
        const vec& subsequence = extract(sequence, k);
        max = std::max(max, g(subsequence));
    }
    return max;
}

int main() {
    while (true) {
        int n;
        std::cin >> n;
        if (n == 0) {
            break;
        }
        vec sequence(n);
        for (int i = 0; i < n; i++) {
            std::cin >> sequence[i];
        }
        std::cout << f(sequence) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int  main(){
    int x,n,ans=-1,cur=1e9;
    cin >> x >> n;
    map<int,int> p;
    rep(i,n){
        int a;
        cin >> a;
        p[a]++;
    }
    for(int i=0;i<=101;i++){
        if(p[i]>0) continue;
        if(abs(x-i)<cur){
            cur = abs(x-i);
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int a,b;
long long num=0;
bool check_(int x)
{
	char s[10];
	int len=1;
	while(x!=0)
	{
		char c;
		c=x%10-'0';
        s[len]=c;
        len++;
        x=x/10;
	}
    if (s[1]==s[5] && s[2]==s[4])
        return 1;
    else
        return 0;
}
int main()
{
	cin >>a >>b;
	for (int i=a;i<=b;i++)
	{
		if (check_(i)==1)
		    num++;
	}
	cout <<num <<endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (r,d,mut x) = get!(isize, isize, isize);

    for i in 0..10 {
        x = r*x-d;
        println!("{}",x);
    }
}


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

using namespace std;

int main() {
    int N, a, b, c;

    scanf("%d", &N);
    vector<vector<int>> dp(N + 1, vector<int>(3));

    dp[0][0] = dp[0][1] = dp[0][1] = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%d %d %d", &a, &b, &c);
        dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1]);
    }

    printf("%d\n", max({dp[N][0], dp[N][1], dp[N][2]}));

    return 0;
}

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

int main(){
    long long A; cin >> A;
    double B; cin >> B;

    B *= 100;
    long long hoge = B+0.1;

    A *= hoge;
    A /= 100;
    cout << A << endl;

}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
#define ALL(x) x.begin(),x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
vector<ll> vi;
/*--------------------template--------------------*/


int main() {
	cin >> n;
	if (n >= 1200) {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}

Measured memory_bytes: 764
def main():
    Q, H, S, D = (int(i) for i in input().split())
    N = int(input())
    one = min(4*Q, 2*H, S)
    two = min(2*one, D)
    ans = 0
    if N & 1:
        ans += one
        N -= 1
    ans += two * (N // 2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, L[1010];

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N * 2; i++) {
        cin >> L[i];
    }
    sort(L, L + 2 * N);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += L[i * 2];
    }
    cout << ans << endl;


    solve();
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
 
   
int main(){
int m1,d1,m2,d2;
cin >> m1 >> d1 >> m2 >> d2;
int ans;
if(m2==m1+1)ans=1;
else ans=0;
cout << ans << endl;
} 

Measured memory_bytes: 3568
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
typedef pair<ll,ll> P;
struct Edge{ll to,dist;};
ll N; ll d[100000];
vector<Edge> G[100000];

void dijkstra(ll u){
    REP(i,100000)d[i]=INF;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push({0,u});
    while(!que.empty()){
        auto r=que.top();que.pop();
        if(r.first>=d[r.second])continue;//更新不可
        d[r.second]=r.first;//更新

        for(Edge& e: G[r.second]){
            ll dist=d[r.second]+e.dist;
            if(dist>=d[e.to])continue;//更新不可
            que.push({dist,e.to});//更新
        }
    }
}
//-----------------------------------------
int main(void){
    ll N,E,s0;
    cin>>N>>E>>s0;
    REP(i,E){
        ll s,t,d;cin>>s>>t>>d;
        G[s].push_back({t,d});
    }
    dijkstra(s0);
    REP(i,N){
        cout<<(d[i]!=INF?to_string(d[i]):"INF")<<"\n";
    }
}


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



int main() {
	long long int N = 0;
	long long int max = 0;
	long long int H[100000] = { 0 };
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	for (int i = N-1; i > 0; i--) {
		if (H[i]+1 == H[i - 1]) {
			H[i - 1] -= 1;
		}

		if (H[i]+1 < H[i - 1]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	
}

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

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

        string a = Console.ReadLine ();
        
        char b = 'a';
        string ans = "Good";

        for(int i = 0;i<4;i++){
            if(b.Equals(a[i]) ){
                ans ="Bad";
            }
            b = a[i];
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long k = sc.nextLong();

		long count = 0;
		long sum = 0;

		if (k <= a) {
			sum += k;
			System.out.println(sum);
			return;
		}

		if (k > a) {
			count += a;
			sum += a;
			k -= a;
		}

		if (k <= b) {
			System.out.println(sum);
			return;
		}

		if (k > b) {
			count += b;
			k -= b;
		}

		if (k <= c) {
			sum -= k;
			System.out.println(sum);
			return;
		}

	}
}


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

int main() {
  int N;
  string result;
  cin >> N;

  for (int i = 0; i < N; i++) {
    char hina;
    cin >> hina;
    if (hina == 'Y') {
      result = "Four";
      break;
    } else {
      result = "Three";
    }
  }

  cout << result << endl;
}

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

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

struct mintcomb{
    vector<mint> fact;
    vector<mint> ifact;
    mintcomb(ll n) : fact(n + 1, 1), ifact(n + 1, 1) {
        for(ll i = 2; i <= n; ++i){
            fact.at(i) = fact.at(i - 1) * i;
            ifact.at(i) = fact.at(i).inv();
        }
    }

    mint factorial(ll k) const { return fact.at(k); }
    mint combination(ll k, ll l) const {
        return fact.at(k) * ifact.at(l) * ifact.at(k - l);
    }
};

int main(){
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    mintcomb mc(r2 + c2 + 2);

    const mint v1 = mc.combination(r2 + c2 + 2, c2 + 1) - 1;
    const mint v2 = mc.combination(r2 + c1 + 1, r2 + 1) - 1;
    const mint v3 = mc.combination(r1 + c2 + 1, c2 + 1) - 1;
    const mint v4 = mc.combination(r1 + c1, r1) - 1;
    const mint ans = v1 - v2 - v3 + v4;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 31488
X,Y = map(int,input().split())

def calculate(x,y):
    a = (4 * x - y) / 2
    b = x - a
    if a < 0:
        print("No")
        return
    if b < 0:
        print("No")
        return

    if float.is_integer(a) and float.is_integer(b):
        print("Yes")
    else:
        print("No")

calculate(X,Y)

Measured memory_bytes: 9184
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

class SegmentTree:
    def __init__(self, N, func, I):
        self.func = func
        self.I = I
        self.N = N
        self.sz = 2**(N-1).bit_length()
        self.seg = [I] * (self.sz * 2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in reversed(range(1,self.sz)):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        if b == self.N:
            b = self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    m = map(int,readline().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


Measured memory_bytes: 60528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

ll mod=1e9+7;

ll modpow(ll a, ll p) {
  ll ret=1;
  while(p>0) {
    if(p&1) ret=(ret*a)%mod;
    a=(a*a)%mod;
    p>>=1;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,ans=0;cin>>n>>k;
  lvector A(k+1,0);
  for(ll div=1;div<=k;++div) A[div]=modpow(k/div,n);
  for(ll pos=k;pos>0;--pos) 
    for(ll i=2;i<=k/pos;++i) A[pos]-=A[pos*i];
  for(ll gcd=1;gcd<=k;++gcd) ans=(ans+gcd*A[gcd])%mod;
  print(ans);
  return 0;
}

Measured memory_bytes: 3992
using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for(int i = r; i >= l; --i)
#define fr(i, l, r) for(int i = l; i < r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair; 
priority_queue< ll, vector <ll> , greater<ll>>pq1,pq2;
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,m,l,h,ar[200005],ans;
    cin>>n>>k;

    fr(i,0,n)
    {
        cin>>ar[i];
    }

    l=0;
    h=1000000000;
    while(l<=h)
    {
        m=(l+h)/2;
        
        ll tot=0,lng,cnt,j;
        fr(i,0,n)
        {
            if(ar[i]>m && m!=0)
            {
                cnt=ar[i]/m;
                cnt-=1;
                if(cnt*m!=ar[i])
                cnt+=1;
                
    
                tot+=cnt;
            }
        }
        if(m==0)
        tot=maxN;
    
        if(tot>k)
        {
            l=m+1;
        }
        else
        {
            ans=m;
            h=m-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5108
r, c = map(int, input().split())
t = []
l = [0]*(c+1)
for _ in range(r):
    *_r, = map(int, input().split())
    _r.append(sum(_r))
    t.append(_r)

    l = [_l+__r for _l, __r in zip(l, _r)]

for _t in t:
    print(*_t)
print(*l)


Measured memory_bytes: 6236
#include<iostream>
using namespace std;
int x[30][30], n, p, q; char a;
int main() {
	cin >> n;
	for (int times = 1; times <= n; times++) {
		for (int i = 10; i < 18; i++) {
			for (int j = 10; j < 18; j++) {
				cin >> a; 
				if (a == '1') { x[i][j] = 1; }
				else { x[i][j] = 0; }
			}
		}
		cin >> q >> p; x[9 + p][9 + q] = 2;
		for (int i = 0; i < 100; i++) {
			for (int j = 10; j < 18; j++) {
				for (int k = 10; k < 18; k++) {
					if (x[j][k] == 2) {
						for (int l = -3; l < 4; l++) {
							if (x[j + l][k] == 1) { x[j + l][k] = 2; }
						}
						for (int l = -3; l < 4; l++) {
							if (x[j][k + l] == 1) { x[j][k + l] = 2; }
						}
						x[j][k] = 0;
					}
				}
			}
		}
		cout << "Data " << times << ':' << endl;
		for (int i = 10; i < 18; i++) {
			for (int j = 10; j < 18; j++) {
				cout << x[i][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int i,k=0,l=0;
    l=a.size();
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
        {
            k=1;
            break;
        }
    }
    if(k)
        cout<<"No";
    else
    cout<<"Yes";
}


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

using namespace std;

main(){
    int size;
    scanf("%d",&size);
    vector<int> arr (size);
    int num;
    for(int i=0;i<size;++i){
        scanf("%d",&num);
        arr[i] = num;
    }
    sort(arr.begin(),arr.end());
    int actual;
    long long area = 1;
    int times = 0;
    for(int i=size-1;i>0;--i){
        actual = arr[i];
        int next = arr[i-1];
        if(actual==next){
            area *= actual;
            times++;
            i--;
            if(times>=2) break;
        }
    }
    if(times<2) cout << 0 << endl;
    else cout << area << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main()
{
    char str[100];
    gets(str);
    int flag=0,max=0,sum=0,i;
    for(i=0; str[i]!='\0'; i++)
    {
        if(str[i]=='A'||str[i]=='T'||str[i]=='G'||str[i]=='C')
        {
            if(flag==1)
            {
                sum++;
            }
            else
            {
                sum++;
                flag=1;
            }
            if(max<sum)
                max=sum;

        }
        else
        {

            flag=0;
            sum=0;
        }
    //printf("sum=%d",sum);
    }
    printf("%d",max);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void solve (int D, int T, int S) {

		 System.out.println((S * T) >= D?"Yes":"No");

	}

	public static void main(String[] args) {

		long start = System.currentTimeMillis();
	    // 引数で標準入力System.inを指定する
	    Scanner scanner = new Scanner(System.in);
		try {

		    // 1行目を取得(a)
			int D  = scanner.nextInt();
			int T  = scanner.nextInt();
			int S  = scanner.nextInt();
			scanner.nextLine();

			solve(D, T, S);

		} finally {
		    // Scannerクラスのインスタンスをクローズ
		    scanner.close();
		}
		long end = System.currentTimeMillis();
		// System.out.println((end - start) );
	}


	// ************************************
	// Common
	// ************************************

	private static final int[] changeArrayStringToInt(String line) {

		String[] strArray = line.split(" ");

		int[] intArray = new int[strArray.length];

		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


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

int main(void)
{
    int a;
    std::cin >> a;
    std::string s;
    std::cin >> s;

    if(a<3200)
        std::cout << "red" << std::endl;
    else
    {
        std::cout << s << std::endl;
    }

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  if(s.at(s.length()-1) == '3'){
    cout << "bon" << endl;
  }else if(s.at(s.length()-1) == '0' || s.at(s.length()-1) == '1' || s.at(s.length()-1) == '6'
           || s.at(s.length()-1) == '8'){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
}


Measured memory_bytes: 3628
N,Y=map(int,input().split())
answer=[-1, -1, -1]
for i in range(N+1):
  for j in range(N-i+1):
    k= N-i-j
    a=10000*i+5000*j+1000*k
    if Y==a:
      answer=[i,j,k]
      break
print(*answer)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{

int a,b,k;
cin>>a>>b>>k;
if(2*k>b-a) for(int i=a;i<=b;i++)
                cout<<i<<endl;
        else {for(int i=a;i<=a+k-1;i++)
                  cout<<i<<endl;
              for(int i=b-k+1;i<=b;i++)
                  cout<<i<<endl;}

system("pause");
return 0;
}



Measured memory_bytes: 504
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		long a = Long.parseLong(scan.next());
		long b = Long.parseLong(scan.next());
		long k = Long.parseLong(scan.next());
		
		if(k <= a) {
			a -= k;
		} else if(a < k && k <= a + b) {
			b -= k - a;
			a = 0;
		} else if(a + b <= k) {
			a = 0;
			b = 0;
		}
		
		System.out.println(a + " " + b);	
		
		scan.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
using namespace std;
int i,j,k,n;
static int a[60001];
int main()
{
    for(i=1;i<100;i++)
        for(j=1;j<100;j++)
            for(k=1;k<100;k++)
                a[i*i+j*j+k*k+i*j+i*k+k*j]++;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        printf("%d\n",a[i]);
    return 0;
}


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

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int main() {
    int p; cin >> p;
    int a[p]; for (int i = 0; i < p; i++) cin >> a[i];
    int ans[p];
    memset(ans, 0, sizeof(ans));
    for (int i = 0; i < p; i++) ans[0] += a[i];
    ans[p-1] -= a[0];
    for (int i = 1; i < p; i++) {
        for (int j = 0; j < p; j++) {
            ans[j] -= a[i] * modexp(i, p-1-j, p);
        }
    }
    for (int i = 0; i < p; i++) cout << (ans[i] % p + p) % p << ' ';
    cout << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int N;
  map<int, int> om, em;

  cin >> N;
  rep(i, 0, N/2) {
    int t;
    cin >> t; om[t]++;
    cin >> t; em[t]++;
  }

  vector<pair<int, int>> ov, ev;
  ov.push_back({0, 0});
  ev.push_back({0, 0});
  fore(x, om) ov.push_back({x.second, x.first});
  fore(x, em) ev.push_back({x.second, x.first});
  sort(all(ov), greater<pair<int,int>>());
  sort(all(ev), greater<pair<int,int>>());

  int ans = N;
  if (ov[0].second == ev[0].second) {
    ans -= max(ov[0].first + ev[1].first, ov[1].first + ev[0].first);
  } else {
    ans -= ov[0].first + ev[0].first;
  }

  cout << ans << endl;
}

Measured memory_bytes: 6140
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N; cin >> N;
  int A[200005];
  for (int i = 1; i <= N; i++)
    cin >> A[i];
  
  int Ball[200005];
  // N >= i >= (N/2)+1　の箱にはA[i]個入ってる
  for (int i = N; i >= (N/2)+1; i--) {
    Ball[i] = A[i];
  }
  
  for (int i = N/2; i >= 1; i--) {
    int total_ball = 0;
    for (int j = i * (N / i); j > i; j -= i) {
      total_ball += Ball[j];
      total_ball %= 2;
    }
    Ball[i] = abs(total_ball - A[i]);
  }
  
  int M = 0;
  vector<int> B{};
  for (int i = 1; i <= N; i++) {
    if (Ball[i] == 1){
      M += Ball[i];
      B.push_back(i);
    }
  }
  
  cout << M << endl;
  for (int k = 0; k < M; k++)
    cout << B[k] << " ";
  cout << endl;
  
  return 0;
}

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

int main(void){
    int N,T;
    string A,B,C;
    cin>>N;
    cin>>A>>B>>C;
    T=0;

    for(int i=0;i<N;i++){
        if(A[i]==B[i]){
            if(B[i]==C[i]){
                T=T+0;
            }else{
                T=T+1;
            }
            

        }else if(B[i]==C[i]){
            T=T+1;
        }else if(A[i]!=C[i]){
            T=T+2;
        }else{
            T=T+1;
        }
    }

    cout<<T<<endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5+10;
ll dp[MAX];
int main (){
    int N,W;cin >> N >> W;
    memset(dp,63,sizeof dp);
    dp[0]=0;
    for(int i=0;i<N;i++){
        int w,val;
        cin >> w >> val;
        for(int j=MAX;j>=0;j--){
            if(j-val>=0)
                dp[j]=min(dp[j],dp[j-val]+w);
        }

    }
    int res=0;
    for(int i=0;i<MAX;i++){
        if(dp[i]<=W) res = max(res,i);
    }
    cout<<res<<endl;
    return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int n, m;
    cin >> n >> m;
    vector<lint> c(m, 0);
    rep(i, m) cin >> c[i];
    sort(c.begin(), c.end());

    // 状態 (i,j) : c[0]~c[i-1] まできめて，その合計金額が j
    // mi(i,j) : 状態(i,j) での枚数の最小値
    vector<vector<lint>> mi(m + 1, vector<lint>(n + 1, INF));
    mi[0][0] = 0;

    for (int i = 0; i < m; i++) {
        for (int j = 0; j <= n; j++) {
            if (mi[i][j] == INF) continue;

            mi[i + 1][j] = min(mi[i + 1][j], mi[i][j]);

            if (j + c[i] <= n)
                mi[i][j + c[i]] = min(mi[i][j + c[i]], mi[i][j] + 1);

            // for (int k = 0; j + c[i] * k <= n; k++) {
            //     mi[i + 1][j + c[i] * k] =
            //         min(mi[i + 1][j + c[i] * k], mi[i][j] + k);
            // }
        }
    }

    // dump(c);
    // ddump(mi);

    cout << mi[m][n] << endl;

    return 0;
}


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

using namespace std;

int main()
{
    vector <int> A;
    for(int i=0;i<3;i++){
    int x;
        cin>>x;
        A.push_back(x);
    }
    sort(A.begin(),A.end());
    int res=A.back()*10+A[0]+A[1];
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

#define bit(b, i) (((b) >> (i)) & 1)
#define PC __builtin_popcountll
#define BL(a) (a ? 64 - __builtin_clzll(a) : 0)

int main() {
	IN(int, h, w, k);
	vector<string> s(h);
	cin >> s;
	
	int ans = h * w;
	inc(b, 1 << (h - 1)) {
		vector<int> t(h);
		bool f = true;
		int cnt = PC(b);
		inc(j, w) {
			vector<int> u(h);
			int p = 0, ma = 0;
			inc(i, h) {
				u[p] += s[i][j] - '0';
				setmax(ma, u[p]);
				p += bit(b, i);
			}
			if(ma > k) { f = false; break; }
			inc(i, h) { t[i] += u[i]; setmax(ma, t[i]); }
			if(ma > k) { cnt++; t = u; }
		}
		if_not(f) { continue; }
		setmin(ans, cnt);
	}
	OUT(ans);
}


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

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

    int num = std::stoi(s);
    int before = num / 100;
    int after = num % 100;

    if (( 1 <= before && before <= 12 ) && ( 1 <= after && after <= 12 ) ){
        cout << "AMBIGUOUS" << endl;
    } else if ( 1 <= before && before <= 12 ) {
        cout << "MMYY" << endl;
    } else if ( 1 <= after && after <= 12 ) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)


int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int d[21][21]; rep(i, 21) rep(j, 21) d[i][j] = inf;
    int N;
    cin >> N;
    int m; cin >> m;
    char ch;
    rep(i, m) {
        int a, b, c, dd; cin >> a >> ch >> b >> ch >> c >> ch >> dd;
        a--; b--;
        d[a][b] = c;
        d[b][a] = dd;
    }
    rep(k, N) rep(i, N) rep(j, N) {
        if (d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
    }
    int s, g, v, p; cin >> s >> ch >> g >> ch >> v >> ch >> p; s--; g--;
    cout << v - p - (d[s][g] + d[g][s]) << endl;
}



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

using namespace std;


#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int main(){
	string S;
	map<char,int> m={{'I',1},{'V',5},{'X',10},{'L',50},{'C',100},{'D',500},{'M',1000}};
	while (cin>>S){
		int ans=0;
		REP(i,S.length()-1){
			if (m[S[i]]>=m[S[i+1]]){
				ans+=m[S[i]];
			}else{
				ans-=m[S[i]];
			}
		}
		ans+=m[S[S.length()-1]];
		cout<<ans<<endl;
	}
	return 0;
}

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

const int maxn = 100010;
int n, L, T, a[maxn], x[maxn], w[maxn];

int main() {
    scanf("%d %d %d", &n, &L, &T);
    long long cur = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d %d", &a[i], &w[i]);
        if (w[i] == 1) {
            x[i] = (a[i] + T) % L;
            cur += (a[i] + T) / L;
        } else {
            x[i] = (a[i] - T) % L;
            cur += (a[i] - T) / L;
            if (x[i] < 0) cur--, x[i] += L;
        }
    }
    cur = (cur % n + n) % n;
    sort(x + 1, x + n + 1);
    for (int i = cur + 1; i <= n; i++) {
        printf("%d\n", x[i]);
    }
    for (int i = 1; i <= cur; i++) {
        printf("%d\n", x[i]);
    }
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    
    int N, M; cin >> N >> M;
    vector<pair<int,int>> sc(M);

    for(int i=0; i<M; i++){
        cin >> sc.at(i).first >> sc.at(i).second;
    }



    vector<int> ans_dig(N+1,-1);
    for(int i=0; i<M; i++){
        if(sc.at(i).first > N){
            cout << -1 << endl;
            return 0;
        }

        if(ans_dig.at(sc.at(i).first) == -1){
            ans_dig.at(sc.at(i).first) = sc.at(i).second;
        }else{
            if(ans_dig.at(sc.at(i).first) == sc.at(i).second){
                continue;
            }else{
                cout << -1 << endl;
                return 0;
            }
        }
    }


    int ans = 0;
    if(N == 1){
        if(ans_dig.at(1) == -1){
            ans = 0;
        }else{
            ans = ans_dig.at(1);
        }
    }

    if(N == 2){
        if(ans_dig.at(1) == 0){
            cout << -1 << endl;
            return 0;
        }
        
        if(ans_dig.at(2) == -1){
            ans += 0;
        }else{
            ans += ans_dig.at(2);
        }

        if(ans_dig.at(1) == -1){
            ans += 10;
        }else{
            ans += ans_dig.at(1)*10;
        }

    }

    if(N == 3){
        if(ans_dig.at(1) == 0){
            cout << -1 << endl;
            return 0;
        }

        if(ans_dig.at(3) == -1){
            ans += 0;
        }else{
            ans += ans_dig.at(3);
        }

        if(ans_dig.at(2) == -1){
            ans += 0;
        }else{
            ans += ans_dig.at(2)*10;
        }

        if(ans_dig.at(1) == -1){
            ans += 100;
        }else{
            ans += ans_dig.at(1)*100;
        }
    }

    cout << ans << endl;

}

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

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T int t;cin>>t;rep(i,t)



void solve() {

    int n;
    cin >> n;

    cout << (1000 - (n % 1000)) % 1000;
    
 }

int main()
{
    fastio;
    // T
    solve();
    //code
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int f = 0;

    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) f=1;
    else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]) f=1;
    else if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]) f=1;
    
    if(f==1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  long h,w;
  cin >> h >> w;
  if(h==1||w==1) cout << 1 << endl;
  else if(h*w%2==0) cout << h*w/2 << endl;
  else cout << h*w/2+1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int M=scan.nextInt();
		int A[]=new int [M];
		for(int i=0;i<M;i++){
			A[i] =scan.nextInt();
		}
		int sum=0;
		int ans=0;
		for(int i=0;i<M;i++){
			sum+=A[i];
		}
		if(N<sum){
			ans=-1;
		}else{
			ans=N-sum;
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 46192
#include <iostream>
#define maxn 100000
#define INFTY 2000000000
using namespace std;

struct Card {
  char suit;
  int value;
};

struct Card L[maxn/2+2],R[maxn/2+2];

void merge(struct Card *Array,int left,int mid,int right) {
  int n1=mid-left;
  int n2=right-mid;
  for (int i=0; i<n1; i++) {
    L[i]=Array[left+i];
  }
  for (int i=0; i<n2; i++) {
    R[i]=Array[mid+i];
  }
  L[n1].value=R[n2].value=INFTY;
  int i=0,j=0;
  for (int k=left; k<right; k++) {
    if (L[i].value<=R[j].value) {
      Array[k]=L[i++];
    }
    else {
      Array[k]=R[j++];
    }
  }
}
void mergeSort(struct Card *Array,int left,int right) {
  if (left+1<right) {
    int mid=(left+right)/2;
    mergeSort(Array,left,mid);
    mergeSort(Array,mid,right);
    merge(Array,left,mid,right);
  }
}
int partition(struct Card *Array,int index,int p,int r) {
  int i,j;
  struct Card x=Array[r];
  i=p-1;
  for (j=p; j<r; j++) {
    if (Array[j].value<=x.value) {
      i++;
      swap(Array[i],Array[j]);
    }
  }
  swap(Array[i+1],Array[r]);
  return i+1;
}
void quickSort(struct Card *Array,int index,int p,int r) {
  int q;
  if (p<r) {
    q=partition(Array,index,p,r);
    quickSort(Array,index,p,q-1);
    quickSort(Array,index,q+1,r);
  }
}
int main() {
  int n,i,v;
  struct Card A[maxn],B[maxn];
  char S[10];
  bool stable=true;
  cin>>n;
  for (i=0; i<n; i++) {
    cin>>S>>v;
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeSort(A,0,n);
  quickSort(B,n,0,n-1);
  for (i=0; i<n; i++) {
    if (A[i].suit!=B[i].suit) {
      stable=false;
    }
  }
  if (stable) {
    cout<<"Stable"<<endl;
  }
  else {
    cout<<"Not stable"<<endl;
  }
  for (i=0; i<n; i++) {
    cout<<B[i].suit<<" "<<B[i].value<<endl;
  }
  return 0;
}


Measured memory_bytes: 5340
import sys
from operator import itemgetter
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
keta = len(str(n))
rs = 0
if keta % 2 == 1:
    rs += n - (10 ** (keta - 1)) + 1
li = [0, 9, 0, 900, 0, 90000]
keta -= 1
while keta > 0:
    rs += li[keta]
    keta -= 1
print(rs)


Measured memory_bytes: 38384
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0) return false;
    }
    return true;
}


signed main(){
  int n,k; cin>>n>>k;
  VI d(k); rep(i,k) cin>>d[i];
  for(int ret=n;ret<=n*10;ret++){
    bool flg = true;
    // ostringstream oss;
    // oss << ret;
    // string check = oss.str();
    int ch = ret;
    while(ch){
      rep(j,k){
        if(ch%10==d[j]){
          flg=false; break;
        }
      }
      ch /= 10;
    }

    // rep(i,check.size()){
    //   rep(j,k){
    //     cerr << i SP j SP ret SP check << endl;
    //     cerr << check[i] SP d[j] << endl;
    //     if(check[i]==d[j]){
    //       flg = false; break;
    //     }
    //   }
    // }
    if(flg) return cout<<ret<<endl,0;
  }

  return 0;
}


Measured memory_bytes: 256
#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>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, cnt = 0;
  cin >> a >> b;
  for(int i = a; i <= b; i++) {
    string s = to_string(i);
    if(s[0] == s[4] && s[1] == s[3]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,k,ans=0;
  cin >> n >> k;
  if(k==0){
    cout << n*n << endl;
    return 0;
  }
  for(int i=k+1;i<=n;i++){
    ans+=(i-k)*(n/i);
    ans+=max(n%i-k+1,0ll);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256