akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(int (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> Vec;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
const int MAX_N = 1e6+1;

ll fac[MAX_N] = {};
ll inv[MAX_N] = {};
ll finv[MAX_N] = {};

ll PowMod(ll a, ll n){
	if(n == 1) return a;
	if(!(n%2)) return PowMod(a*a%MOD, n/2);
	return a*PowMod(a*a%MOD, n/2)%MOD;
}

void fill_fac(int n){
	fac[0] = 1;
	repn(i, n) fac[i] = (fac[i-1]*i)%MOD;
}

void fill_inv(int n){
	inv[0] = 1;
	repn(i, n) inv[i] = PowMod(i, MOD-2);
}

void fill_finv(int n){
	fill_inv(n);

	finv[0] = 1;
	repn(i, n) finv[i] = (finv[i-1]*inv[i])%MOD;
}

int init(int n){
	fill_fac(n);
	fill_finv(n);
}

ll combi(int n, int k){
	return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(void){
	int x, y;
	cin >> x >> y;

	if((x+y)%3 || x*2 < y || y*2 < x){
		co(0);
		return 0;
	}

	int tmp = (x+y)/3;
	x -= tmp; y -= tmp;

	init(x+y);
	co(combi(x+y, x));

	return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i,s.size()) ans += s[i]!=t[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3832
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

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

fn main() {
    let n = read::<usize>();
    let mut tasks = vec![];
    for i in 0..n {
        let v = read_vec::<i64>();
        let (a, b) = (v[0], v[1]);
        tasks.push((a, b));
    }
    tasks.sort_by_key(|x| -x.1);
    debug!(tasks);
    let mut cur = 10000000000;
    for i in 0..n {
        cur = min(cur, tasks[i].1);
        cur -= tasks[i].0;
    }
    if cur >= 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(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 rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
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;}
const ll MOD = 1000000007;

void solve(){
    /* (´~`) */
    ll n;cin>>n;
    vec c(n);rep(i,n)cin>>c[i];
    sort(all(c),greater<>());
    ll ans=0;
    rep(i,n){
        ans+=c[i]*(i+2);
        ans%=MOD;
    }
    rep(i,n-1){
        ans*=4;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

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

int x=0,max=0;

for(int i=0; i<s.size();i++){
    
    if(s[i]=='I'){
        
        x++;
        if(x>max){max=x;}
    }else{x--;}
}

cout<<max<<endl;
   
    
}

Measured memory_bytes: 256
main = interact $ show . sol . fmap read . words

sol [k,s] 
  | s <= k    = f s 
  | s >= 2*k  = f (3*k-s)
  | otherwise = (k+1)^2 - f (s-k-1) - f (2*k-s-1)

f x = (x+1)*(x+2) `div` 2

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 2019
signed main()
{
   SPEED;
   string str;
   cin>>str;
   int n=str.size(),p[n+1],dp[n+1]={0},freq[2019]={0},cnt=0;
   freq[0]=1;
   p[0]=1;
   for(int i=1;i<=n;i++)
   {
       p[i]=(10*p[i-1])%MOD;
   }
   for(int i=n-1;i>=0;i--)
   {
       dp[i]=(p[n-1-i]*(str[i]-'0')+dp[i+1])%MOD;
       ++freq[dp[i]];
   }
   for(int i=0;i<2019;i++)
   {
       cnt+=(freq[i]*(freq[i]-1))/2;
   }
   cout<<cnt;
}

Measured memory_bytes: 6928
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let val: f64 = read();
    let ans = val / 3.0 * val / 3.0 * val / 3.0;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

ll gcd(ll a,ll b){
    if(a<b) gcd(b,a);
    else{
        if(b==0) return a;
        else return gcd(b,a%b);
    }
}

int main(){
    ll a,b;
    scanf("%lld%lld", &a, &b);
    ll c=gcd(a,b);
    ll s=1;
    for(ll i=2;i*i<=c;i++){
        if(c%i==0){
            while(c%i==0){
                c /= i;
            }
            s++;
        }
    }
    if(c>1) s++;
    printf("%lld\n", s);
}


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

const char white_cell = '.';
const char black_cell = '#';

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> a(H);
  for (int i = 0; i < H; i++) {
    cin >> a[i];
  }

  // true: 黒マス
  vector<vector<bool>> flags(H, vector<bool>(W, true));

  // 横の圧縮
  for (int i = 0; i < H; i++) {
    // 横一列見る。途中に黒マスがあったらそれ以上見る意味がない
    bool flag = true;
    for (int j = 0; j < W; j++) {
      if (a[i][j] == black_cell) {
        flag = false;
        break;
      }
    }
    if (flag) {
      for (int j = 0; j < W; j++) {
        flags[i][j] = false;
      }
    }
  }

  // 縦の圧縮
  for (int i = 0; i < W; i++) {
    bool flag = true;
    for (int j = 0; j < H; j++) {
      if (a[j][i] == black_cell) {
        flag = false;
        break;
      }
    }
    if (flag) {
      for (int j = 0; j < H; j++) {
        flags[j][i] = false;
      }
    }
  }

  for (int i = 0; i < flags.size(); i++) {
    string row;
    for (int j = 0; j < flags[i].size(); j++) {
      if (flags[i][j]) {
        row += a[i][j];
      }
    }
    if (!row.empty()) {
      cout << row << endl;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 222222





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

	cin >> n;
	ok = false;
	rep(i,1e5){
		tmp += i;
		if (tmp == n) ok = true;
		if (tmp > 1e5) break;
	}

	if (!ok) {
		cout << "No" << endl;
		return 0;
	}

	vvll v;
	vll x;
	x.pb(1);
	v.pb(x);
	v.pb(x);
	ll cur = 2;
	while (cur <= n) {
		vll y;
		rep(i, v.size()) {
			v[i].pb(cur + i);
			y.pb(cur + i);
		}
		cur += v.size();
		v.pb(y);
	}

	cout << "Yes" << endl;
	cout << v.size() << endl;
	rep(i, v.size()) {
		cout << v[i].size() << " ";
		rep(j, v[i].size()) cout << v[i][j] << " ";
		cout << endl;
	}


	return 0;
}


Measured memory_bytes: 3840
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = INF;
  vector<int> cum = a;

  rep(k, n) {
    int cost = k * x;
    rep(i, n) {
      cmin(cum[i], a[(i - k + n) % n]);
      cost += cum[i];
    }
    cmin(ans, cost);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
#define MAX_C 1000000001
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) { cin >> a[i]; }
  for (int i = 0; i < n; i++) { cin >> b[i]; }
  for (int i = 0; i < n; i++) { cin >> c[i]; }

  sort(a.begin(), a.end());
  sort(c.begin(), c.end());

  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    ll bi = b[i];
    ll p = lower_bound(a.begin(), a.end(), bi) - a.begin();
    ll q = c.end() - upper_bound(c.begin(), c.end(), bi);
    cnt += p * q;
  }

  cout << cnt << endl;
}


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

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    // cout << r << g << b;
    int answer = (r*100) + (g*10) + b;
    if(answer %4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
  
 
    
}


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

int main() {
	int all = 0, ans = 0;
	cin >> all;

	string str;
	cin >> str;

	for (int i = 0; i < all - 2; i++) {

		if (str[i] == 'A') {
			if (str[i + 1] == 'B') {
				if (str[i + 2] == 'C') {
					ans++;
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
	string s, t;
	int count = 0;
	cin >> s >> t;
	for (int i = 0;i < s.size();i++)
	{
		if (s[i] != t[i])
			count++;
	}
	cout << count;
	return 0;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int N = (int) 1e5 + 10;
int n, k, a[N];

int main() {
    #ifdef LOCAL
        freopen("Data.inp", "r", stdin);
        freopen("Data.out", "w", stdout);
    #endif

    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);

    sort(a + 1, a + 1 + n);
    k = unique(a + 1, a + 1 + n) - (a + 1);

    if ((n + k) % 2 == 0) printf("%d", k); else printf("%d", k - 1);
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

#define ARRAY_INIT 0
#define DIV_INIT 0
#define LOOP_INIT 0
#define G_MAX 12

int main( void )
{
	unsigned long ulW_Dtc_cnt;
	int *aulW_Dtestcase;
	unsigned long ulW_Cloop_cnt;
	unsigned long ulW_Cloop_sub_cnt;
	unsigned long ulW_Csort_cnt = DIV_INIT;
	unsigned long ulW_Dm;
	unsigned long aulW_DG[ G_MAX ];
	unsigned long ulW_Dv;
	int ulW_Dk;

	scanf( "%d", &ulW_Dtc_cnt );
	aulW_Dtestcase = ( int * ) malloc ( sizeof ( int ) * ulW_Dtc_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		scanf( "%d", &aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	ulW_Dm = 1;
	aulW_DG[ 0 ] = 1;
	while( 3 * aulW_DG[ ulW_Dm - 1 ] + 1 < ulW_Dtc_cnt ){
		aulW_DG[ ulW_Dm ] = 3 * aulW_DG[ ulW_Dm - 1 ] + 1;
		ulW_Dm++;
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm / 2; ulW_Cloop_cnt++ ){
		ulW_Dv = aulW_DG[ ulW_Cloop_cnt ];
		aulW_DG[ ulW_Cloop_cnt ] = aulW_DG[ ulW_Dm - 1 - ulW_Cloop_cnt ];
		aulW_DG[ ulW_Dm - 1 - ulW_Cloop_cnt ] = ulW_Dv;
	}

	printf( "%d\n", ulW_Dm );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm; ulW_Cloop_cnt++ ){
		if( ulW_Cloop_cnt == ulW_Dm - 1 ){
			printf( "%d\n", aulW_DG[ ulW_Cloop_cnt ] );
		}
		else{
			printf( "%d ", aulW_DG[ ulW_Cloop_cnt ] );
		}
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm; ulW_Cloop_cnt++){
		for( ulW_Cloop_sub_cnt = aulW_DG[ ulW_Cloop_cnt ]; ulW_Cloop_sub_cnt < ulW_Dtc_cnt; ulW_Cloop_sub_cnt++ ){
			ulW_Dv = aulW_Dtestcase[ ulW_Cloop_sub_cnt ];
			ulW_Dk = ulW_Cloop_sub_cnt - aulW_DG[ ulW_Cloop_cnt ];
			while( ( ulW_Dk >= 0 ) && ( aulW_Dtestcase[ ulW_Dk ] > ulW_Dv ) ){
				aulW_Dtestcase[ ulW_Dk + aulW_DG[ ulW_Cloop_cnt ] ] = aulW_Dtestcase[ ulW_Dk ];
				ulW_Dk -= aulW_DG[ ulW_Cloop_cnt ];
				ulW_Csort_cnt++;
			}
			aulW_Dtestcase[ ulW_Dk + aulW_DG[ ulW_Cloop_cnt ] ] = ulW_Dv;
		}
	}

	printf( "%d\n", ulW_Csort_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		printf( "%d\n", aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	return 0;
}

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

int main(){
  int n, ans = 0;
  long long x, y, d;
  cin >>n >>d;
  
  for(int i=0;i<n;i++){
    cin >>x >>y;
    if(x*x + y*y <=d*d)ans++;
  }
  
  cout<< ans <<endl;
  return 0;
}


Measured memory_bytes: 3624
from collections import deque
K=int(input())

q=deque()
for i in range(1, 10):
  q.append(i)
  
for i in range(K):
  v=q.popleft()
  if v%10!=0:
    q.append(10*v+v%10-1)
    
  q.append(10*v+v%10)
  
  if v%10!=9:
    q.append(10*v+v%10+1)
    
print(v)

Measured memory_bytes: 11908
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));

struct UnionFind {
	vector<int> d; // d[i]:iの親の番号　(例) d[3] = 2 : 3の親が2 d[3] = -3 : 3は根で、その連結成分のサイズは3

	UnionFind(int N) : d(N, -1) {} // 負なら根である 非負なら子である

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (d[x] < 0) return x; //負なら根であるから根を返す
		return d[x] = root(d[x]);
	}

	bool unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return false; //xとyの根が同じ(=同じ木にある)時はそのまま
		if (d[rx] > d[ry])swap(rx, ry); //木のサイズが大きいほうにくっつける
		d[rx] += d[ry]; //サイズが上乗せされる
		d[ry] = rx; //yの根はxになる
		return true;
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
	int size(int x) {
		return -d[root(x)];
	}
};

signed main() {
	int N, M;
	cin >> N >> M;
	vector<int>a(M), b(M);
	rep(i, M)cin >> a[i] >> b[i];
	rep(i, M)a[i]--;
	rep(i, M)b[i]--;
	int ans = 0;
	rep(i, M) {
		UnionFind tree(N);
		rep(j, M) {
			if (j == i)continue;
			tree.unite(a[j], b[j]);
		}
		if (tree.size(0) != N)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
long a,b,c,d,M=1e9+7,w[1001],e[1001],P[1001][1001],n,i,j;int p(long a,int b){return b?b%2?p(a*a%M,b/2)*a%M:p(a*a%M,b/2)%M:1;}main(k){scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);for(*w=*e=j=1;j<=n;)e[j]=e[j-1]*j++%M;for(;i++<n;)for(j=i;~j;)P[i][j]=e[i]*p(e[i-j--],M-2)%M;for(;i--;)e[i]=p(e[i],M-2);for(i=a-1;i++<b;)for(j=n;~j;j--)for(k=c;k<=d&&k<=j/i;)w[j]=(w[j]+w[j-i*k]*P[n-j+i*k][i*k]%M*p(e[i],k)%M*e[k++]%M)%M;printf("%d\n",w[n]);}

Measured memory_bytes: 7040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] a) throws IOException{

		String strLine ="";
		BufferedReader stdReader =
				new BufferedReader(new InputStreamReader(System.in));

		int week = 0;
		double lentMoney = 100000;

		while  ((strLine = stdReader.readLine()) != null) {
			week = Integer.parseInt(strLine);
		}

		for(int i = 0; i < week ; i++){
			lentMoney = Math.ceil((lentMoney/1000) * 1.05) *1000;
		}
			//1000???????????????????????????
			int n = (int) lentMoney;

			System.out.println(n);

	}

}

Measured memory_bytes: 24164
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		int a = inint(), b = inint();
		out.println((a+b)%24);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

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

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

	public char[][] incharmap(int h, int w) {
		char[][] a = new char[h][w];
		for (int i=0; i<h; i++) {
			String temp = in.next();
			for (int j=0; j<w; j++) {
				a[i][j] = temp.charAt(j);
			}
		}
		return a;
	}

}

Measured memory_bytes: 23764
package main

import (
	"fmt"
)

// 以下の問題
// https://atcoder.jp/contests/abc153/tasks/abc153_a
// https://daeudaeu.com/programming/c-language/kurisuke_kiriage_shisyagonyu/

func main() {
	var h, a int
	fmt.Scan(&h, &a)

	fmt.Println((h + a - 1)/a)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

constexpr int N = 3e3;
int dp[N+1][N+1];
string s, t;

string lcs(int n, int m){
  if(n == 0 || m == 0) return "";
  else{
    if(dp[n][m] == dp[n-1][m]) return lcs(n-1, m);
    else if(dp[n][m] == dp[n][m-1]) return lcs(n, m-1);
    else return lcs(n-1, m-1) + s[n];
  }
}

int main(){
  cin >> s >> t;
  size_t n = s.size(), m = t.size();

  s = " " + s; t = " " + t;

  FOR(i, 1, n+1)FOR(j, 1, m+1){
    if(s[i] == t[j]){
      dp[i][j] = dp[i-1][j-1] + 1;
    } else {
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  } 

  cout << lcs(n, m) << endl;

  return 0;
}


Measured memory_bytes: 35712
s = input()

if len(s) % 2 == 0:
    a = '01' * (len(s) // 2)
    b = '10' * (len(s) // 2)
else:
    a = '01' * (len(s) // 2) + '0'
    b = '10' * (len(s) // 2) + '1'

s_i = int(s, 2)
a_i = int(a, 2)
b_i = int(b, 2)

s1 = bin(s_i ^ a_i)[2:]
s2 = bin(s_i ^ b_i)[2:]

print(min(s1.count('1'), s2.count('1')))


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

int main() {
    int N, K, c[105]{}, dp[105][3][4]{};  // dp[i][j][k] = i日目にパスタjをk回連続で食べるときの通り
    cin >> N >> K;
    for(int i=0;i<K;i++){
        int a, b;
        cin >> a >> b;
        c[a] = b;
    }

    dp[0][0][0] = 1;
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(c[i+1]>0 && c[i+1]!=k+1)continue;  // 予定と異なる場合は弾く
                for(int l=0;l<3;l++){
                    if(j==k){  // 前日と同じパスタを食べる遷移
                        dp[i+1][k][l+1] += dp[i][j][l];
                        dp[i+1][k][l+1] %= 10000;
                    }
                    else{  // 前日と異なるパスタを食べる遷移
                        dp[i+1][k][1] += dp[i][j][l];
                        dp[i+1][k][1] %= 10000;
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            ans += dp[N][i][j];
            ans %= 10000;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main(void){
	int n;
	cin>>n;
	int a[100000];
	for(int i(0);i<n;i++){
		cin>>a[i];
	}
	int cnt[100000]={0};
	for(int i(0);i<n;i++){
		if(a[i] == 0){
			cnt[0]++;
			cnt[1]++;
		}
		else{
			cnt[a[i]-1]++;
			cnt[a[i]]++;
			cnt[a[i]+1]++;
		}
	}
	int max(0);
	for(int i(0);i<100000;i++){
		if(max < cnt[i])max = cnt[i];
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int n,m,l,a[100][100],b[100][100],i,j,k;
	long c[100][100]={0};
	scanf("%d%d%d",&n,&m,&l);
	for(i=0;i<n;i++)for(j=0;j<m;j++)scanf("%d",&a[i][j]);
	for(i=0;i<m;i++)for(j=0;j<l;j++)scanf("%d",&b[i][j]);
	for(i=0;i<n;i++)for(j=0;j<l;j++)for(k=0;k<m;k++)c[i][j]+=a[i][k]*b[k][j];
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			if(j!=0)printf(" ");
			printf("%ld",c[i][j]);
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 2140
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]

o = [0] * 100010

for i in range(n):
    o[a[i]] += 1
#print(o)
ans = sum(a)
for i in range(q):
    ans += o[b[i]]*(c[i] - b[i])
    print(ans)
    o[c[i]] += o[b[i]]
    o[b[i]] = 0
    #print(sum(o))


Measured memory_bytes: 66792
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  string s;
  string ans;
  cin >> s;
  if(s=="Sunny") ans = "Cloudy";
  else if(s=="Cloudy") ans = "Rainy";
  else ans = "Sunny";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;

int main() {fio;
	string s;
	cin >> s;
	int ans = 1;
	int ls = 1;
	for(int i = 1; i < s.size(); i++) {
		// cout << i << " ";
		if(ls == 2 || s[i] != s[i - 1]) {
			ans++;
			ls = 1;
			// cout << i << endl;
			continue;
		}
		if(s[i] == s[i - 1]) {
			if(i != s.size() - 1)
				ans += 1;
			ls = 2;
			i++;
		}
	}
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main () {
  int N, M;cin >> N >> M;
  vector<vector<int>> grp(N, vector<int>());
  vector<int> indeg(N,0), depth(N,0);
  rep(i, M) {
    int x, y; cin >> x >> y;
    x--; y--;
    grp[x].push_back(y);
    indeg[y]++;
  }
  queue<int> qu;
  rep(i, N) if(indeg[i] == 0) qu.push(i);
  int ans = 0;
  while(!qu.empty()) {
    int now = qu.front();
    qu.pop();
    for (auto nxt : grp[now]) {
      indeg[nxt]--;
      if(indeg[nxt] == 0) {
	qu.push(nxt);
	depth[nxt] = depth[now] + 1;
	chmax(ans, depth[nxt]);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9404
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int maxn=1e5+10;
int a[maxn];
bool vis[maxn];
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x;scanf("%d",&x);
        vis[x]=1;
    }
    a[0]=1;
    if(vis[1]==0)
        a[1]=1;
    for(int i=2;i<=n;i++)
    {
        if(vis[i]==0)
            a[i]=(a[i-1]+a[i-2])%mod;
    }
    cout<<a[n]<<endl;
    return 0;
}


Measured memory_bytes: 768
from collections import deque
from copy import deepcopy
import heapq

N,K=list(map(int,input().split()))
V=list(map(int,input().split()))

minus=[[[0]*(N+1) for _ in range(N+1)] for _ in range(N+1)]

vdeque=deque(V)

for left in range(N+1):
    for right in range(N-left+1):
        v=deepcopy(vdeque)
        q=[]

        tleft=left
        while tleft>0:
            vi=deque.popleft(v)
            if vi<0:
                heapq.heappush(q,vi)
            tleft-=1
        
        tright=right

        while tright>0:
            vj=deque.pop(v)
            if vj<0:
                heapq.heappush(q,vj)
            tright-=1
        
        for k in range(1,N+1):
            if len(q)>0:
                minus[k][left][right]=minus[k-1][left][right]-heapq.heappop(q)
            else:
                minus[k][left][right]=minus[k-1][left][right]

leftacum=[0]*(N+1)
rightacum=[0]*(N+1)

for i in range(N):
    leftacum[i+1]=leftacum[i]+V[i]
    rightacum[i+1]=rightacum[i]+V[N-i-1]

ans=-10**10

for left in range(N+1):
    for right in range(N-left+1):
        k=min(N,K-left-right)
        if k<0:
            continue

        ans=max(ans,leftacum[left]+rightacum[right]+minus[k][left][right])

print(ans)

Measured memory_bytes: 64092
use std::cmp::max;
use std::io::*;

fn main() {
    let stdin = stdin();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let (n, _m) = to_pair(&buf);

    let mut nearest_as = vec![-1; n as usize];

    for t in stdin.lock().lines().map(|l| to_pair(&l.unwrap())) {
        let a = t.0 - 1;
        let b = (t.1 - 1) as usize;
        let current = nearest_as[b];
        nearest_as[b] = max(current, a);
    }
    
    let mut eastmost_broken = -1;
    let mut cnt = 0;

    for i in 0..nearest_as.len() {
        let a = nearest_as[i];
        if a != -1 && a > eastmost_broken {
            eastmost_broken = (i - 1) as i32;
            cnt += 1;
        }
    }

    println!("{}", cnt);
}

fn to_pair(s: &str) -> (i32, i32) {
    let v: Vec<_> = s.split_whitespace().map(|w| w.parse().unwrap()).collect();
    let (l, r) = (v[0], v[1]);
    (l, r)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 100000;
LL a[maxn + 1];
int main(){
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    vector<LL> v = {N};
    for(LL i = 0, q; i < Q; i += 1){
        cin >> q;
        while(not v.empty() and v.back() >= q) v.pop_back();
        v.push_back(q);
    }
    vector<LL> t(v.size());
    t.back() = 1;
    for(int i = (int)v.size() - 1; i >= 0; i -= 1){
        LL k = v[i];
        while(k >= v[0] and i){
            int j = prev(upper_bound(v.begin(), v.begin() + i, k)) - v.begin();
            t[j] += k / v[j] * t[i];
            k %= v[j];
        }
        a[k] += t[i];
    }
    for(int i = N - 1; i; i -= 1) a[i] += a[i + 1];
    for(int i = 1; i <= N; i += 1) cout << a[i] << " ";
    return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std ;
#define rep(i,a,n) for(int i =a;i<n;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	ios;
	int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
	return 0;
	
}

Measured memory_bytes: 256
import math

N,X = list(map(int,input().split()))
x = list(map(int,input().split()))

arr = [0]*N
for i in range(N):
    arr[i] = abs(x[i]-X)
ans = arr[0]
for i in range(1,N):
    ans = math.gcd(ans, arr[i])
    
print(ans)

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

int main() {
	int i, j, n, q, tmpt, time = 0;
	string tmpn;
	queue<pair<string, int>> Q;
	pair<string, int> tmpq;
	cin >> n >> q;
	for (i = 0; i < n; i++) {
		cin >> tmpn >> tmpt;
		Q.push(make_pair(tmpn, tmpt));
	}
	while (n > 0) {
		tmpq = Q.front();
		Q.pop();
		if (tmpq.second > q) {
			tmpq.second -= q;
			Q.push(tmpq);
			time += q;
		} else {
			time += tmpq.second;
			cout << tmpq.first << " " << time << endl;
			n--;
		}
	}
	return 0;
}

Measured memory_bytes: 6356
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = {-1,0,1,0}; const int dy[] = {0,1,0,-1};

const int MAX_STRING = 50;
const int MAX_N = 1000;

int main() {
    int n;

    while(cin >> n, n){
        char strings[MAX_N][MAX_N + MAX_STRING] = {'\0'};
        REP(i, n){
            string s;
            cin >> s;
            for(int j = s.length() - 1; j >= 0; j--){
                if(s[j] == '.'){
                    s[j] = '+';
                    break;
                }
            }
            strcpy(strings[i], s.c_str());
        }

        REP(i, n){
            REP(j, strlen(strings[i])){
                if(strings[i][j] == '+'){
                    FOR(k, i+1, n){
                        if(isalpha(strings[k][j]))
                            break;
                        if(strings[k][j] == '+'){
                            FOR(l, i + 1, k){
                                strings[l][j] = '|';
                            }
                            break;
                        }
                    }
                    continue;
                }else if(strings[i][j] == '.'){
                    strings[i][j] = ' ';
                }
            }
        }
        REP(i, n){
            cout << strings[i] << endl;
        }

    }
}

Measured memory_bytes: 2252
n = gets.to_i
a = gets.split.map(&:to_i)
count = 0
(1..(n - 2)).map do |i|
  if (a[i - 1] < a[i] && a[i] < a[i + 1]) || (a[i - 1] > a[i] && a[i] > a[i + 1])
    count += 1
  end
end
puts count


Measured memory_bytes: 1788
#include <iostream>
#include<string.h>
#include<iomanip>
using namespace std;

int main(){
  int a,b,ans;
  string op;
  while(1){
    cin >> a >> op >> b;
    if(op.compare("?") == 0){
      break;
    } else if(op.compare("+") == 0){
      ans = a+b;
    } else if(op.compare("-") == 0){
      ans = a-b;
    } else if(op.compare("*") == 0){
      ans = a*b;
    } else if(op.compare("/") == 0){
      ans = a/b;
    }
    cout << ans << endl;
  }

}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string op;
	int a,b;
	cin >> a >> op >> b;
	if(op == "+") cout << a + b << endl;
	else cout << a - b << endl;
	return 0;
}

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

int main(void){

    int n; cin >> n;
    string s; cin >> s;

    int count = 1;
    char prev = s[0];

    for(int i = 1; i < n ; i++){
        if(prev != s[i]){
            //cout << i << "  : diff" <<endl;
            prev = s[i];
            count++;
        }else{
            //cout << i << "  : same" <<endl; 
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");

    int MOD = 1e9+7;
    int N; cin>>N;

    int ans = 1;
    FOR(i,1, N+1) {
        ans *= i;
        ans %= MOD;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <climits>
#include <cstdlib>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 998244353;
typedef long long LL;

LL dp[301][300*300+1] = {};
LL dp2[301][300*300+1] = {};

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

  LL total = 1;
  for (int i = 0; i < N; ++i) total = (total * 3) % kMod;

  LL sum = 0;
  dp[0][0] = 1;
  dp2[0][0] = 1;

  for (int i = 1; i <= N; ++i) {
    int a; std::cin >> a;
    for (int j = 0; j <= sum; ++j) {
      dp[i][j] += 2*dp[i-1][j];
      dp[i][j] %= kMod;

      dp[i][j+a] += dp[i-1][j];
      dp[i][j+a] %= kMod;

      dp2[i][j] += dp2[i-1][j];
      dp2[i][j] %= kMod;

      dp2[i][j+a] += dp2[i-1][j];
      dp2[i][j+a] %= kMod;
    }
    sum += a;
  }

#if DEBUG
  for (int j = 0; j <= sum; ++j) {
    std::cout << j << "\t";
  }
  std::cout << std::endl << "-------------------------" << std::endl;

  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= sum; ++j) {
      std::cout << dp[i][j] << "\t";
    }
    std::cout << std::endl;
  }

  std::cout << std::endl << "-------------------------" << std::endl;

  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= sum; ++j) {
      std::cout << dp2[i][j] << "\t";
    }
    std::cout << std::endl;
  }
#endif

  LL invalid_cases = 0;
  for (int i = (sum)/2 + 1; i <= sum; ++i) {
    invalid_cases += dp[N][i];
    invalid_cases %= kMod;
  }

  if (sum%2 == 0) {
    invalid_cases += dp[N][sum/2] - dp2[N][sum/2];
    invalid_cases %= kMod;
  }

  LL total_invalid_cases = (3 * invalid_cases) % kMod;
  std::cout << (total - total_invalid_cases + kMod) % kMod << std::endl;
}


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a, sum;
  int max = 0;
  for (int i = 0; i < 5; i++) {
    cin >> a;
    if (a % 10 != 0 && max < 10 - a % 10) {
      max = 10 - a % 10;
    }
    if (a % 10 == 0) {
      sum += a;
    } else {
      sum += a + (10 - a % 10);
    }
  }
  cout << sum - max << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import *
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sa = [0]*(n+1)
sb = [0]*(m+1)
for i in range(n):
    sa[i+1] = sa[i] + A[i]
for i in range(m):
    sb[i+1] = sb[i] + B[i]
ans = 0
for i,a in enumerate(sa):
    if a > k:break
    will = bisect_right(sb,k-a)
    ans = max(i + will - 1, ans)
print(ans)


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

int main(void) {
    int N;
    std::cin >> N;
    vector< int > A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if (N & 1) {
        printf("%d\n", B[(N - 1) / 2] - A[(N - 1) / 2] + 1);
    } else {
        printf("%d\n",
               (B[N / 2] + B[N / 2 - 1]) - (A[N / 2] + A[(N / 2) - 1]) + 1);
    }

    return 0;
}


Measured memory_bytes: 4840
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


////////////////2つの要素をまとめてソート、前の変数が優先。flag=0で小さい順、1で大きい順
void mysort2(vi &a,vi &b,ll flag){
  if (a.size()>0){
    vector<pair<ll, ll>> p(a.size());
    REP(i,a.size()){
      p[i].first=a[i];
      p[i].second=b[i];
    }
    sort(p.begin(),p.end());
    if (flag==1){
      reverse(p.begin(),p.end());
    }
    REP(i,a.size()){
      a[i]=p[i].first;
      b[i]=p[i].second;
    }
  }
  return;
}
////////////////2同時ソートここまで


//////////////////3つの要素をまとめてソート、前の変数が優先。flag=0で小さい順、1で大きい順
void mysort3(vi &a,vi &b,vi &c,ll flag){
  if (a.size()>0){
    vector<pair<ll, pair<ll,ll>>> p(a.size());
    REP(i,a.size()){
      p[i].first=a[i];
      p[i].second.first=b[i];
	  p[i].second.second=c[i];
    }
    sort(p.begin(),p.end());
    if (flag==1){
      reverse(p.begin(),p.end());
    }
    REP(i,a.size()){
      a[i]=p[i].first;
      b[i]=p[i].second.first;
      c[i]=p[i].second.second;
    }
  }
  return;
}
////////////////3同時ソートここまで











ll n,k;

int main(){
  cin >> n;
  vi xx(n),yy(n),idxx(n),ans(n),x(n),y(n);
  REP(i,n)idxx[i]=i;
  REP(i,n){
    cin>>xx[i]>>yy[i];
    xx[i]--;
    yy[i]--;
    x[xx[i]]=xx[i];
    y[xx[i]]=yy[i];
    idxx[xx[i]]=i;
  }



  //mysort3(x,y,idxx,0);

  vi gid(n),up(n),dw(n);
  vi rgmax(n+1);
  REP(i,n){
    gid[i]=i;
    up[i]=i;//含む
    dw[i]=i;//含む
  }

  ll tmpmax=y[n-1];
  rgmax[n]=0;
  for(ll i=n-1;i>=0;i--){
    if (tmpmax<y[i]){
      tmpmax=y[i];
    }
    rgmax[i]=tmpmax;
  }
  //myprint1D(rgmax);


  for(ll i=0;i<n;i++){
    ll yorimigimax=rgmax[i+1];
    if (y[i]<yorimigimax){
      ll ymgid=gid[yorimigimax];
      for(ll j=y[i];j<dw[ymgid];j++){
        gid[j]=ymgid;
      }
      dw[ymgid]=min(dw[ymgid],y[i]);
    }
  }


  //myprint1D(gid);
  for(ll i=0;i<n;i++){
    ans[i]=gid[y[i]];
  }
  vi nums(n);
  for(ll i=0;i<n;i++){
    nums[ans[i]]++;
  }
  vi fans(n);
  for(ll i=0;i<n;i++){
    fans[idxx[i]]=nums[ans[i]];
  }

  myprint1D(fans);



  //cout<<ans<<endl;




  
  return 0;
}

Measured memory_bytes: 21828
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int L = sc.nextInt();
    ArrayList<String> S = new ArrayList<>();
    String ans = "";
    
    for(int i=0; i<N; i++) {
      S.add(sc.next());
    }
    Collections.sort(S);
    for(int j=0; j<N; j++) {
      ans += S.get(j);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 25812
x,n = map(int,input().split())
p = list(input().split())

for i in range(n):
    p[i] = int(p[i])

for i in range(100):
    min_flag = 0
    max_flag = 0
    for j in range(n):
        if p[j] != x - i:
            min_flag += 1
        if p[j] != x + i:
            max_flag += 1

    if min_flag == n:
        ans = x-i
        break
    elif max_flag == n:
        ans = x+i
        break

print(ans)

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int a,b;cin>>a>>b;
    cout<<a*b<<"\n";
    }

Measured memory_bytes: 3600
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  ll a,b;cin>>a>>b;
  cout<<min(n*a,b)<<endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> takoyaki;
    for(int i = 0; i < N; i++){
        int di;
        cin >> di;
        takoyaki.push_back(di);
    }

    int total=0;
    for (int i = 0; i < takoyaki.size() - 1; i++){
        for (int j = i + 1; j < takoyaki.size(); j++){
            total += takoyaki[i] * takoyaki[j];
        }
    }

    cout << total << endl;
}

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

const int MAX_N = 300030;
int par[MAX_N];
int rnk[MAX_N];
int N;

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

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

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

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


int main(){
  int M;
  cin >> N >> M;
  init();
  vector<pair<int, long long>> a(N);
  for (int i=0; i<N; i++){
    a[i].first = i;
    cin >> a[i].second;
  }
  for (int i=0; i<M; i++){
    int x, y;
    cin >> x >> y;
    unite(x, y);
  }
  set<int> st;
  for (int i=0; i<N; i++) st.insert(find(i));
  int treenum = st.size();
  // cout << treenum << endl;
  sort(a.begin(), a.end(), [](const auto& a, const auto& b){return a.second<b.second;});
  if ((treenum-1)*2>N){
    cout << "Impossible" << endl;
    return 0;
  }
  if (treenum==1){
    cout << 0 << endl;
    return 0;
  }
  vector<int> checked(N,0);
  int count = 0;
  long long ans = 0;
  for (int i=0; i<N; i++){
    if (checked[find(a[i].first)]==0){
      ans += a[i].second;
      checked[find(a[i].first)]++;
    } else if (count<treenum-2){
      count++;
      ans += a[i].second;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7296
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;
#define toInt(_char) _char - '0'

using namespace std;
//
// Created by karayuu on 2018-12-18.
//

int main() {
    int n, a;
    cin >> n;
    cin >> a;

    PC((n % 500 <= a), P("Yes"), P("No"));
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

typedef long long ll;
//struct edge {int to, cost;};
typedef pair<int, int> P;
typedef complex<double> C;

struct edge {
    int from, to, cost;
    edge() {}
    edge(int f, int t, int c) {
        from = f; to = t; cost = c;
    }
};

bool cmp (const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

int INF = 100000000;
const int MAX_V = 100000;
const int MAX_E = 100000;

int uni[MAX_V];
edge es[MAX_E];
int V, E;

void init_uf(int n) {
    REP(i, n) uni[i] = -1;
}

int root(int x) {
    if (uni[x] < 0) return x;
    else {
        return uni[x] = root(uni[x]);
    }
}

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

void unite(int x, int y) {
    x = root(x);
    y = root(y);

    if (x == y) return;

    if (uni[x] > uni[y]) swap(x, y);

    uni[x] += uni[y];
    uni[y] = x;
}

int kruskal() {
    sort(es, es + E, cmp);
    init_uf(V);
    int res = 0;
    REP(i, E) {
        edge e = es[i];
        if (!same(e.from, e.to)) {
            unite(e.from, e.to);
            res += e.cost;
        }
    }
    return res;
}

void solve() {
    printf("%d\n", kruskal() );
}

int main() {
    while (true) {
        scanf("%d%d", &V, &E);
        if (!V && !E) return 0;
        REP(i, E) {
            int f, t, c;
            scanf("%d%d%d", &f, &t, &c);
            es[i] = edge(f, t, c);
        }
        solve();
    }
}

Measured memory_bytes: 2672