akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  int N;
  int ans = 0;
  
  cin >> N;
  
  int tmp;
  for(int i = 1; i <= N; i++){
	cin >> tmp;
    if(i % 2 == 1 && tmp % 2 == 1)
        ans++;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int N;
	cin >> N;
	cout << (1000000 - N) % 1000 << endl;

	return 0;
}

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

int main(void){

    string S; cin>>S;

    int first = (S[0]-'0')*10 + (S[1]-'0');
    int second = (S[2]-'0')*10 + (S[3]-'0');

    if(first>=1 && first<=12){
        if(second>=1 && second<=12) cout<<"AMBIGUOUS"<<endl;
        else cout<<"MMYY"<<endl;
    }
    else {
        if(second>=1 && second<=12) cout<<"YYMM"<<endl;
        else cout<<"NA"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
void solve() {
	var(int, k, t);
	vec(int, a, t);
	int max_a = *maxi(all(a));
	print(max_a <= k / 2 ? 0 : max_a * 2 - k - 1);
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int vDay=sc.nextInt();
		int jp=sc.nextInt();
		int mt=sc.nextInt();
		int jpD=sc.nextInt();
		int mpD=sc.nextInt();
		for(int i=vDay;i>=0;i--){
			jp-=jpD;
			mt-=mpD;
			if(jp<=0&&mt<=0){
				System.out.println(i-1);
				break;
			}
		}
	}
}

Measured memory_bytes: 17168
from itertools import product
N = int(input())
ans = 0
for i in range(3, 10):
    l = list(product(["3","5","7"],repeat=i))
    for j in l:
        if len(set(j)) == 3:
            if int("".join(list(j))) <= N:
                ans += 1
print(ans)


Measured memory_bytes: 12276
#include <iostream>
#include <string>
#include <cmath>
#include <fstream>
#include <chrono>
#include <iomanip>
#include <vector>
#include <utility>
#include <time.h>
#include <set>
#include <unordered_set>
#include <list>
#include <iterator>
#include <time.h>
#include <chrono>
#include <deque>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
using namespace std;

#define ll long long
#define ldb long double

ll mod(ll a, ll b)
{
	return (b + (a % b)) % b;
}

ll subMod(ll a, ll b, ll M)
{
	return mod((mod(a, M) - mod(b, M)), M);
}

void solve()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> p(n);

	ll max = 0;

	ll temp = 0;

	ll sum = 0;

	for (ll i = 0; i < n; i++)
	{
		cin >> p[i];

		if (temp < k)
		{
			sum += p[i] + 1;
			temp++;

			if (temp == k)
			{
				if (sum > max)
				{
					max = sum;
				}
			}
		}
		else if (temp == k)
		{
			sum -= p[i - k] + 1;
			sum += p[i] + 1;

			if (sum > max)
			{
				max = sum;
			}
		}
	}

	cout << fixed << setprecision(12) << static_cast<long double>(max / 2.0);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,d,a[11][11],ans;
int main(){
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=d;j++)scanf("%d",&a[i][j]);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int s=0;
			for(int k=1;k<=d;k++)s+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			int k=sqrt(s);
			if(k*k==s)ans++;
		}
	}
	cout<<ans;
}

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

int main() {
  int H, W;
  vector<vector<char>> a(H_MAX, vector<char> (H_MAX));
  vector<vector<ll>> dp(H_MAX, vector<ll> (H_MAX));

  cin >> H >> W;

  rep(i,H){
    rep(j,W){
      cin >> a.at(i+1).at(j+1);
    }
  }

  dp.at(1).at(1) = 1;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      if(i == 1 && j == 1) continue;
      dp.at(i).at(j) = dp.at(i-1).at(j) + dp.at(i).at(j-1);
      dp.at(i).at(j) %= 1000000007;

      if(a.at(i).at(j) == '#'){
        dp.at(i).at(j) = 0;
      }
    }
  }

  cout << dp.at(H).at(W) << endl;
  return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
    u64 T;
    cin >> T;

    vector<u64> ans(T);

    for(u64 t=0; t<T; t++) {
        u64 N;
        cin >> N;

        priority_queue<pair<u64, u64>> lside;
        priority_queue<pair<u64, u64>> rside;
        u64 t_ans = 0;

        for(uint n=0; n<N; n++) {
            u64 K;
            u64 L, R;
            cin >> K >> L >> R;
            t_ans += min(L, R);

            if(L > R) {
                lside.push(make_pair(K, L-R));
            } else {
                // HACK : sort order defalut is N to M (N > M)
                rside.push(make_pair(N-K, R-L));
            }
        }
    
        priority_queue<u64> lcdt;
        for(u64 l=lside.size(); l>0; l--) {
            while(!lside.empty() && l <= lside.top().first) {
                lcdt.push(lside.top().second);
                lside.pop();
            }
            if(!lcdt.empty()) {
                t_ans += lcdt.top();
                lcdt.pop();
            }   
        }
        
        priority_queue<u64> rcdt;
        for(u64 r=rside.size(); r>0; r--) {
            while(!rside.empty() && r <= rside.top().first) {
                rcdt.push(rside.top().second);
                rside.pop();
            }
            if(!rcdt.empty()) {
                t_ans += rcdt.top();
                rcdt.pop();
            }   
        }

        ans[t] = t_ans;
    }


    for(const auto a : ans) cout << a << endl;
    return 0;
}

Measured memory_bytes: 8316
import math
a,b,c = map(float,input().split())

h=b*math.sin(math.radians(c))

s=0.5*a*h

l=a+b+(a**2 + b**2-2*a*b*math.cos(math.radians(c)))**0.5
print(s)
print(l)
print(h)




Measured memory_bytes: 5696
def n_based(n:int, base:int) -> str:
    if n == 0:
        return "0"
    
    ans = ""
    res = n
    
    while abs(res) > 0:
        q = res%base
        if q>=0:
            ans = str(q) + ans
            res //= base
        else:
            q += abs(base)
            ans = str(q) + ans
            res //= base
            res += 1
        
    return ans

N = int(input())
print(n_based(N,-2))

Measured memory_bytes: 3064
#!/usr/local/bin/python3
# https://atcoder.jp/contests/abc075/tasks/abc075_b

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]


def check(S, i, j):
    if S[i][j] == '#':
        return '#'

    num = 0
    for _i in range(max(0, i-1), min(H, i+2)):
        for _j in range(max(0, j-1), min(W, j+2)):
            if S[_i][_j] == '#':
                num += 1
    return str(num)


for i in range(H):
    for j in range(W):
        S[i][j] = check(S, i, j)

for i in range(H):
    for j in range(W):
        print(S[i][j], end="")
    print()


Measured memory_bytes: 9132
#include<cstdio>
#include<cstring>
char s[200050],c[200050];
int cnt[200050];
int main(){
	int n,m=1,i,ans=0;
	scanf("%s",s);n=strlen(s);
	c[1]=s[0];cnt[1]=1;
	for(i=1;i<n;++i)if(s[i]!=c[m]){c[++m]=s[i];cnt[m]=1;}
	else ++cnt[m];
	for(i=m-1;i;--i)if((cnt[i]%3==0||cnt[i]%3==2)&&cnt[i+1]%3==2){
		--cnt[i];--cnt[i+1];
		++ans;
	}
	for(i=1;i<=m;++i)ans+=cnt[i]/3*2+(cnt[i]%3!=0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int w,h,x,y,r;
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);

    if((x>=r && x<=w-r) && (y>=r && y<=h-r))
        printf("Yes\n");
    else
        printf("No\n");

    return 0;

}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin >> n ;
	for( int i = 9; i >= 1; i--)
	{
		if( n%i == 0 && n/i <= 9 && n/i >=1)
		{
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

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

int  main()
{
    
        long long int n,k;
    cin>>n>>k;

    long long int wt[n];
    long long int val[n];

    for(int i=0;i<n;i++)
    {

        cin>>wt[i]>>val[i];
    }

        long long int kp[n+1][k+1];


    for(int i=0;i<=n;i++)
    {

        for(int j=0;j<=k;j++)
        {

             if(i==0 || j==0)
             {
                 kp[i][j]=0;
             }
           
              
           else if(j>=wt[i-1])  
            kp[i][j] =max(kp[i-1][j],kp[i-1][j-wt[i-1]]+val[i-1]);
            else
            {
                kp[i][j]=kp[i-1][j];
            }
            
        }
    }

    cout<<kp[n][k];



    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
vector<int> g[100010];
ll dp[100010][2];

void dfs(int v,int pre){
  for(int nv : g[v]){
    if(nv==pre)continue;
    dfs(nv,v);
  }
  ll sum=1,wsum=1;
  for(int nv : g[v]){
    if(nv==pre)continue;
    sum*=(dp[nv][0]+dp[nv][1])%mod;
    sum%=mod;
    wsum*=dp[nv][0];
    wsum%=mod;
  }
  dp[v][1]=wsum;
  dp[v][0]=sum;
}

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

  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0,-1);
  cout<<(dp[0][0]+dp[0][1])%mod<<endl;

  return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;
 
int main() {
    string r;
    cin >> r;
    int cnt = 0,ans = 0;
    rep(i,r.size()){
        if(r[i] == 'R') cnt++;
        else cnt = 0;
        ans = max(ans,cnt);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
       mut p:[(i64,i64);n],
    }

    p.sort();
    for (i, v) in p.iter_mut().enumerate() {
        v.0 = (i + 1) as i64;
        swap(&mut v.0, &mut v.1);
    }
    p.sort();
    let mut l = BIT::<SUM>::new(n);
    let mut r = BIT::<SUM>::new(n);
    for i in 1..=n {
        r.add(i, &1);
    }
    let n = n as i64;
    let mut ans = n as i64 * mod_pow(2, n - 1, MOD);
    for (i, p) in p.iter().enumerate() {
        let i = i as i64;
        let y = p.1 as usize;
        r.add(y, &(-1i64));
        let a = l.sum(y);
        let b = (i - a as i64);
        let c = r.sum(y);
        let d = (n - 1 - i) - c;
        ans += mod_pow(2, n - 1, MOD)
            + mod_pow(2, a, MOD)
            + mod_pow(2, b, MOD)
            + mod_pow(2, c, MOD)
            + mod_pow(2, d, MOD)
            - mod_pow(2, a + b, MOD)
            - mod_pow(2, a + c, MOD)
            - mod_pow(2, b + d, MOD)
            - mod_pow(2, c + d, MOD)
            - 1;
        ans = (ans + MOD * 111) % MOD;
        l.add(y, &1i64);
    }
    println!("{}", ans);
}

const MOD: i64 = 998244353;
pub fn mod_pow(x: i64, n: i64, m: i64) -> i64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
pub trait Monoid {
    type T: Clone;
    fn id() -> Self::T;
    fn op(a: &Self::T, b: &Self::T) -> Self::T;
}
pub struct SUM {}
impl Monoid for SUM {
    type T = i64;
    fn id() -> Self::T {
        0
    }
    fn op(a: &Self::T, b: &Self::T) -> Self::T {
        *a + *b
    }
}
/// Generic Binary Indexed Tree
pub struct BIT<M: Monoid> {
    buf: Vec<M::T>,
}
impl<M: Monoid> BIT<M> {
    pub fn new(n: usize) -> Self {
        Self {
            buf: vec![M::id(); n + 1],
        }
    }
    pub fn sum(&self, i: usize) -> M::T {
        let mut i = i;
        let mut s = M::id();
        while i > 0 {
            s = M::op(&s, &self.buf[i]);
            i -= 1 << i.trailing_zeros();
        }
        s
    }
    pub fn add(&mut self, i: usize, x: &M::T) {
        let mut i = i as i64;
        while i < self.buf.len() as i64 {
            let t = &mut self.buf[i as usize];
            *t = M::op(&t, x);
            i += 1 << i.trailing_zeros();
        }
    }
}


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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n) 	for(int i=0;i<n;i++)
#define frr(i,n)	for(int i=1;i<=n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << endl
#define all(x)	x.begin(),x.end()

#define gnl cout << endl
#define olar cout << "olar" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f;
const int MOD = 1e9+7;

int freq[30300];

int para(int x,int y){
	return max(x,y) - min(x,y);
}

int main(){

	fastio;

	int n,x,y;
	cin >> n >> x >> y;

	frr(i,n){
		for(int j = i + 1;j <=n;j++){
			int k = para(i,j);
			k = min(k,1 + para(i,x) + para(y,j));
			k = min(k,1 + para(i,y) + para(x,j));
			freq[k]++;
		}
	}

	frr(i,n-1) cout << freq[i] << endl;

}


Measured memory_bytes: 892
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}

		// 計算
		int result = 0;
		TreeMap<Integer, Integer> tm = new TreeMap<Integer, Integer>();
		for(int i = 0; i < n; i++){
		    if(tm.lowerKey(a[i]) == null){
		        if(tm.containsKey(a[i])){
		            tm.put(a[i], tm.get(a[i]) + 1);
		        }else{
		            tm.put(a[i], 1);
		        }
		    }else{
		        Integer lowerKey = tm.lowerKey(a[i]);
		        Integer lowerValue = tm.get(lowerKey);
		        if(lowerValue == 1){
		            tm.remove(lowerKey);
		        }else{
		            tm.put(lowerKey, lowerValue - 1);
		        }
		        if(tm.containsKey(a[i])){
		            tm.put(a[i], tm.get(a[i]) + 1);
		        }else{
		            tm.put(a[i], 1);
		        }
		    }
		}
		for(Integer i : tm.keySet()){
		    result += tm.get(i);
		}
		// 出力
		System.out.println(result);
		
	}
}

Measured memory_bytes: 56476
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    int n = s.size();

    // dp[keta][smaller][3][5][7]
    int dp[15][2][2][2][2] = {};
    dp[0][0][0][0][0] = 1;
    
    rep(i, n) {
        int nd = s[i] - '0';
        rep(j, 2) rep(f1, 2) rep(f2, 2) rep(f3, 2) {
            rep(d, 10) {
                if (d == 0 || d == 3 || d == 5 || d == 7) {
                    int ni = i+1, nj = j, nf1 = f1, nf2 = f2, nf3 = f3;

                    if (f1 + f2 + f3 > 0 && d == 0) continue;

                    if (j == 0) {
                        if (nd < d) continue;
                        if (nd > d) nj = 1;
                    }
                    if (d == 3) nf1 = 1;
                    if (d == 5) nf2 = 1;
                    if (d == 7) nf3 = 1;
                    dp[ni][nj][nf1][nf2][nf3] += dp[i][j][f1][f2][f3];
                }
            }
        }
    }
    cout << dp[n][0][1][1][1] + dp[n][1][1][1][1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>


int main(){
  int n, k;
  std::cin >> n >> k;
  
  std::vector<int> p(n);
  
  for(int i = 0;i < n;i++){
    std::cin >> p[i];
  }
  
  std::sort(p.begin(),p.end());
 
  int ans = 0;
  
  for(int i = 0;i < k;i++){
    ans += p[i];
  }
  
  std::cout << ans << std::endl;
}


Measured memory_bytes: 3568
o = input()
e = input()
res = ""
if len(o)>len(e):
  for i in range(len(e)):
    res = res + o[i]
    res = res + e[i]
  res = res + o[len(o)-1]
else:
  for i in range(len(e)):
    res= res + o[i]
    res= res + e[i]
print(res)


Measured memory_bytes: 9008
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    vector<int> v;
    int ans = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        v.push_back(num);
    }

    int cnt = 1;

    for (int i = 0; i < n; i++) {
        if (cnt != v[i]) {
            ans++;
        }
        else {
            cnt++;
        }
    }

    if (cnt == 1) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 1400
#include <iostream>
#include <set>
#include <vector>

int min;
std::string res;

void dfs(int depth, std::string s,
           const std::set<std::string> &st)
{
    if (depth == 4) {
        if (s.empty() || st.count(s)) {
            return;
        }
        
        int size = s.size();
        if (size < min) {
            min = size;
            res = s;
        } else if (size == min) {
            res = std::min(res, s);
        }
        return;
    }

    dfs(depth + 1, s, st);    
    for (char c = 'a'; c <= 'z'; c++) {
        dfs(depth + 1, s + c, st);
    }    
}

int main()
{
    int N;   
    std::cin >> N;    
    
    std::set<std::string> st; 
    for (int i = 0; i < N; i++) {
        std::string S;
        std::cin >> S;
        int size = S.size();
        for (int j = 0; j < size; j++) {
            for (int k = 1; k <= 4; k++) {
                if (j + k > size) break;
                st.insert(S.substr(j, k));
            }
        }
    }

    min = 5;    
    std::string s;
    dfs(0, s, st);
    std::cout << res << std::endl;
    
    return 0;
}

Measured memory_bytes: 42424
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	priority_queue<pair<int, int>> q;
	int k, t; cin >> k >> t;
	rep(i, t){
		int a; cin >> a;
		q.push(make_pair(a, i));
	}
	// printf("sizedddf %d\n", q.size());
	int prev = -1;
	int ans = 0;
	while(!q.empty()){
		auto u = q.top(); q.pop();
		int num = u.fi, idx = u.se;
		// printf("size %d\n", q.size());
		if(idx != prev || q.size() == 0){
		// printf("%d %d\n", num, idx);

			// if(q.size() == 0) ans++;
			// printf("idx %d prev %d\n", idx, prev);
			if(q.size() == 0 && idx == prev){
				// printf("copus\n");
				ans++;
			}

			if(num != 1){
				// if(q.size() == 0 && idx == prev) ans++;
				// printf("ys\n");
				q.push(make_pair(num - 1, idx));
			}
			prev = idx;
		}else{
		// printf("dame %d %d\n", num, idx);

			auto v = q.top(); q.pop();
			// printf("size2 %d\n", q.size());
			int numv = v.fi, idxv = v.se;
			// printf("numv %d %d\n", numv, idxv);

			prev = idxv;
			if(numv != 1){
				q.push(make_pair(numv - 1, idxv));
			}
			q.push(make_pair(num, idx));
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    if(n==0){
      System.out.println(0);
      return;
    }
    StringBuilder sb=new StringBuilder();
    while(n!=0){
      int b=n%(-2);
      if(b==0){
        sb.insert(0,"0");
      }else if(b==1){
        sb.insert(0,"1");
        n--;
      }else{
        sb.insert(0,"1");
        n--;
      }
      n=n/-2;
    }
    System.out.println(sb.toString());
  }
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define LL long long;
#define REP(i,s,N) for (int i=s; i<N; i++)

int main() {
	string a, s, c;
	cin >> a >> s >> c;
	cout << a[0] << s[0] << c[0] << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum = 0;
    rep(i,n) sum += a[i];
    int ct = 0;
    rep(i,n) {
        if (4*m*a[i] >= sum) ct++;
    }
    if (ct >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import scala.annotation.tailrec
import scala.collection.{immutable, mutable}
import scala.io.StdIn._
object Main extends App {

  val isHamming = Array.fill(1000001){true}
  for (p ← prime(1000000).drop(3)) {
    for (j ← p until isHamming.length by p) {
      isHamming(j) = false
    }
  }
  val hammingNumbers = isHamming.indices.drop(1).filter(isHamming).toArray
  loop()
  @tailrec def loop(): Unit = {
    readLine.trim.split(' ').map(_.toInt) match {
      case Array(m, n) ⇒ println(upperBound(hammingNumbers, n) - lowerBound(hammingNumbers, m))
        loop()
      case _ ⇒
    }
  }

  def lowerBound(array: Array[Int], target: Int): Int = {
    var left = 0
    var right = array.length
    while (left < right){
      val mid = (left + right) / 2
      if (array(mid) < target) left = mid + 1
      else right = mid
    }
    right
  }
  def upperBound(array: Array[Int], target: Int): Int = {
    var left = 0
    var right = array.length
    while(left < right) {
      val mid = (left + right) / 2
      if (array(mid) <= target) left = mid + 1
      else right = mid
    }
    right
  }
  def prime(upperLimit: Int): Seq[Int] = {
    val isPrime = Array.fill(upperLimit + 1){true}
    for (i ← 2 to math.sqrt(upperLimit).round.toInt) {
      if (isPrime(i)) for (j ← i * i to upperLimit by i){
        isPrime(j) = false
      }
    }
    (2 to upperLimit).filter(isPrime)
  }
}


Measured memory_bytes: 83596
from itertools import accumulate
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    for _ in range(K):
        data = [0] * len(A)
        for i in range(N):
            range_mai = i - A[i]
            range_pura = i + A[i]
            if range_mai < 0:
                range_mai = 0
            if range_pura > N - 1:
                range_pura = N - 1
            data[range_mai] += 1
            if range_pura + 1 != N:
                data[range_pura + 1] -= 1

        A = list(accumulate(data))
        if min(A) == N:
            break
    print(*A)

if __name__ == "__main__":
    main()

Measured memory_bytes: 178184
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

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

int main() {
    ll n; cin >> n;
    ll a[100001]; INITA(a, 0, 100000, 0);
    REP(i, n) {
        cin >> a[i];
    }

    ll tmp;
    REP(i, n-1) {
        if (i == 0) {
            tmp = gcd(a[i], a[i+1]);
        } else {
            tmp = gcd(a[i+1], tmp);
        }
    }
    cout << tmp << endl;
    return 0;
}

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

typedef long long lli;

const lli SQRT_MAXN = 1000000009LL;

vector<lli> num;

bool isGoodNumber(lli x) {
  if (x <= 0) return false;
  while (x) {
    lli d = x % 10;
    if (d != 2 && d != 8) return false;
    x /= 10;
  }
  return true;
}

void init() {
  num.clear();
  for (lli l = 1; l <= 10; ++l) {
    for (lli i = 0; i < (1 << l); ++i) {
      lli x = 0;
      for (lli j = 0; j < l; ++j) {
        x *= 10;
        if (i >> j & 1) {
          x += 2;
        } else {
          x += 8;
        }
      }
      num.push_back(x);
    }
  }
  sort(num.begin(), num.end());
}

lli rec(lli x, lli k) {
  lli res = isGoodNumber(x) ? 1 : -1;
  for (lli i = k; i < num.size(); ++i) {
    if (x % num[i] == 0) {
      lli tmp = rec(x / num[i], i);
      if (tmp != -1) {
        res = max(res, rec(x / num[i], i) + 1);
      }
    }
  }
  return res;
}

int main() {
  init();
  lli n;
  while (cin >> n) {
    cout << rec(n, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a>b) {
            System.out.println("a > b");
        }else if(a<b) {
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        }
    }
}



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

int lcs(string X,string Y){
  int x=X.size(),y=Y.size();
  int dp[x+5][y+5];
  X=' '+X;
  Y=' '+Y;
  for(int t=0;t<=x;t++)dp[t][0]=0;
  for(int t=0;t<=y;t++)dp[0][t]=0;

  int maxl=0;
  for(int i=1;i<=x;i++){
    for(int j=1;j<=y;j++){
      if(X[i]==Y[j]){
        dp[i][j]=dp[i-1][j-1]+1;
      }else{
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
      maxl=max(maxl,dp[i][j]);
    }
  }
  return maxl;
}

int main(){
  string s,t;
  queue<int>que;
  int q;cin>>q;
  for(int i=0;i<q;i++){
    cin>>s>>t;
    que.push(lcs(s,t));
  }
  for(int t=0;t<q;t++){
    int temp=que.front();que.pop();
    cout<<temp<<"\n";
  }
  return 0;
}



Measured memory_bytes: 7180
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	for i := 1; i <= n; i++ {
		if i%3 == 0 {
			fmt.Print(" ", i)
			continue
		}

		x := i
		for {
			if x%10 == 3 {
				fmt.Print(" ", i)
				break
			}

			x /= 10
			if x == 0 {
				break
			}
		}
	}
	fmt.Println()
}



Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<=(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)

int main()
{
    ll N;
    cin >> N;
    ll ans = 1;
    repi(i,N,2){
        ans*=i;
        ans%=MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int main(void){
   int X,Y;
   cin>>X>>Y;
   bool flag=false;
   for(int i=0;i<=X;i++){
      if(2*i+4*(X-i)==Y) flag=true;
   }
   if(flag) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		int sum = 0;
		
		for(int i = 0; i < n; i++) {
			int p = sc.nextInt();
			max = Math.max(max, p);
			sum += p;
		}
		System.out.println(sum -= max/2);
		sc.close();
	}
}


Measured memory_bytes: 22736
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
char c;
int main()
{
	cin>>c;
	cout<<(char)(c+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
S = input()

S = S + 'E'   # 終端処理
ans = -1    # 答えの初期値（十分に小さい値）
R=0
L=0
# 立った人の連続の数
if (S[0] == '0'):
    stand = 1
else:
    stand = 0
ans=0

for L in range(N):
    # 右端を進めることが可能（立った人の連続の数がK以下）なら、右端を進める
    while R < N and stand <= K:
        # 立った人の連続の数が増えるなら1足す（回数を消費しないといけない）
        if (S[R] == '1' and S[R + 1] == '0'):
            stand += 1
        R+=1#列を進める
        ans=max(ans,R-L)#答えを更新する
    if L == R:#同じ土俵に来たら
        R += 1
    else:#左だけ進めるとき
        if (S[L] == '0' and S[L + 1] == '1'):
            stand-=1
print(ans)

Measured memory_bytes: 43632
#include <iostream>

using namespace std;

int main(){
  int A,B,C,D,E;
  int time=0;
  
  cin>>A>>B>>C>>D>>E;

  if(A<0){
    A*=(-1);
    time=A*C+D+B*E;
  }
  else{
    time=(B-A)*E;
  }

  cout<<time<<endl;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int s, w;
    cin >> s >> w;
    if(s > w){
        cout << "safe" << endl;
    }
    else{
        cout << "unsafe" << endl;
    }

    return 0;
}



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


public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        char[] c = str.toCharArray();
        for(int i = 0; i < str.length(); i++){
            if(Character.isUpperCase(c[i])){
                c[i] = Character.toLowerCase(str.charAt(i));
            }else if(Character.isLowerCase(c[i])){
                c[i] = Character.toUpperCase(str.charAt(i));
            }
        }

        System.out.println(new String(c));
    }
}


Measured memory_bytes: 24360
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  bool flag=false;
  string s;
  cin >> s;
  for(int i=0;i<s.length();++i){
    if(s[i]=='9'){
      flag = true;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
from collections import Counter
import sys
MOD = 998244353


def main():
    n, *d = map(int, sys.stdin.buffer.read().split())
    e = [0]*n
    for i in d:
        e[i] += 1
    ans = e[0]
    for i in d[1:]:
        ans *= e[i-1]
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(int i=(a);i<(int)(b);i++)
#define repi(i,n) fori(i,0,n)
#define forr(i,a,b) for(int i=int(b-1);i>=int(a);i--)
#define repr(i,n) forr(i,0,n)
#define all(x) (x).begin(),(x).end()
#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
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;}

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}

void solve(ll a, ll b){
    cout<<a/gcd(a,b)*b<<endl;
}

int main(){
    ll a;
    scanf("%lld",&a);
    ll b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
// Author : Rifayat Samee (Sanzee)
// Problem :
// Algorithm:

/*

*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll precal[1<<16];
ll memo[1<<16];
ll dp(int mask){
    if(mask == 0){
        return 0;
    }
    if(memo[mask] != -1)
        return memo[mask];
    ll res = precal[mask];
    //printf("from %d:\n",mask);
    for(int s=(mask-1)&mask;s>0;s=(s-1)&mask){
        //if(s<mask-s)break;
        //printf("%d %d\n",mask,s);
        res = max(res,dp(s)+precal[mask-s]);
    }
    memo[mask] = res;
    return res;
}

int main(){

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
     int n;
     scanf("%d",&n);
     vector<vector<ll>>A(n+1,vector<ll>(n+1,0));
     for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            scanf("%lld",&A[i][j]);
        }
     }
     for(int mask=0;mask<(1<<n);mask++){
        ll res = 0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if((mask & (1<<i)) && (mask & (1<<j))){
                    res = res + A[i][j];
                }
            }
        }
        precal[mask] = res;

     }
     memset(memo,-1,sizeof(memo));
     ll res = dp((1<<n)-1);
     printf("%lld\n",res);
	 return 0;
}


Measured memory_bytes: 1280
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n;
char a[N];
int s[N][2],b[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>a+1;
  for(int i=1;i<=n;i++)b[i]=(a[i]=='W'?1:0);
  int cnt=0;
  for(int i=1;i<=n;i++){
    s[i][0]=s[i-1][0];
    s[i][1]=s[i-1][1];
    s[i][b[i]]++;
  }
  for(int i=1;i<=n;i++){
    cnt+=(a[i]=='W');
  }
  int ans=min(n-cnt,cnt);
  for(int i=1;i<=n;i++){
    //[1,i] [i+1,n] 01
    int l=s[i][0];
    int r=s[i][1];
    int dl=s[n][0]-l;
    int dt=s[n][1]-r;
    int z=min(r,dl);
    ans=min(ans,r+dl-z);
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 6180
def solution(X, N, P):
    P = set(P)
    if N <= 0 or X not in P:
        return X
    for i in range(1, len(P) + 1):
        left = X - i
        right = X + i
        if left not in P:
            return left
        if right not in P:
            return right

X, N = map(int, input().split())
P = list(map(int, input().split()))
print(solution(X, N, P))

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

string s;

void solve() {
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) cout << "No";
    else cout << "Yes";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int placeOfOne = 0;
		int[] numbers = new int[n];
		for(int i=0;i<n;i++) {
			numbers[i] = in.nextInt();
			if(numbers[i]==1) {
				placeOfOne=i;
			}
		}
		int before = placeOfOne;
		int after = n - placeOfOne - 1;
		
		int amari = before%(k-1) + after%(k-1);
		int kaisuu = before/(k-1) + after/(k-1);
		if(amari>=k) {
			kaisuu += 2;
		}else if(amari>0) {
			kaisuu++;
		}
		System.out.println(kaisuu);
	}
}

Measured memory_bytes: 50032
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2149


#include <iostream>
//#include <list>
using namespace std;

int main(){

  int n,a,b,c,x;
  int m=0;
  int count=0;
  while(1){
    count=0;
    m=0;

    cin>>n>>a>>b>>c>>x;
    if(n==0 && a==0 && b==0 && c==0 && x==0)
      break;
     
 
    int arrayY[n];
    for(int i=0;i<n;i++){
      cin>>arrayY[i];
    }

    for(int i=0;i<10002;i++){
      if(i>10000){
	cout<<-1<<endl;
	break;
      }
      if(arrayY[m]==x){
	if(m<n-1){
	  m++;
	}
	else if(m==n-1){
	  cout<< i<<endl;
	  break;
	}
      }
      x=(a*x+b)%c;
    }
    //if(count>10000)
    //cout<<-1<<endl;
  }
  //    cout<<-1<<endl;
    return 0;

  
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
  int T,D,ta,tb,da,db,i,j;
  double ans,cal;
  cin >> T >> D;
  cin >> ta >> tb;
  cin >> da >> db;
  ans=2000000000;
  for(i=0;i<=D;i+=da){
    for(j=0;j<=D;j+=db){
      if(1<=i+j&&i+j<=D){
	cal=1.0*(ta*i+tb*j)/(i+j);
	if(cal>=T) cal=cal-T;
	else cal=T-cal;
	ans=min(cal,ans);
      }
    }
  }
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int32_t main(){
  	string s;
    cin>>s; 
  	const int n = s.size(); 
  	string flag = s; 
	reverse(flag.begin(),flag.end()); 
  	if(s!=flag)
    {
      	cout<<"No"<<endl;
      	return 0;
    }
  	string r = ""; 
  	for(int i = 0;i<(n-1)/2;i++){
      	r += s[i]; 
    }
  	flag = r; 
    reverse(flag.begin(),flag.end()); 
  	if(r!=flag)
    {
      	cout<<"No"<<endl;
      	return 0;
    }
    r = ""; 
  	for(int i = (n+3)/2 - 1;i<n;i++)
    {
      	r += s[i]; 
    } 
  	flag = r; 
  	reverse(flag.begin(),flag.end()); 
  	if(flag!=r)
    {
      	cout<<"No"<<endl;
      	return 0;
    }
  	cout<<"Yes"<<endl;
  	return 0;
}


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

namespace atcoderBeginnerContest134
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();

            int[] balls = new int[N + 1];
            int m = 0;
            for (int i = N; i > 0; --i)
            {
                int s = 0;
                for (int j = i << 1; j <= N; j += i)
                    s += balls[j];
                if (s % 2 != A[i - 1])
                {
                    ++balls[i];
                    ++m;
                }
            }

            Console.WriteLine(m);
            StringBuilder stringBuilder = new StringBuilder();
            for (int i = 1; i <= N; ++i)
                if (balls[i] > 0)
                    stringBuilder.Append(i + " ");
            Console.WriteLine(stringBuilder.ToString());
        }
    }
}


Measured memory_bytes: 33236
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    H = input(int)
    h = H
    count = 0
    while 1 < h:
        h //= 2
        count += 1
    ans = 2 ** count
    temp = 1
    for x in range(count):
        ans += temp
        temp *= 2

    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3316
A = [1000000000,1000000000]
Q = []

def a(x,y,z)
 Q << [?+,x,y,z]*" "
 A[z] = (A[x]||=0) + (A[y]||=0)
end

def c(x,y,z)
 Q << [?<,x,y,z]*" "
 A[z] = (A[x]||=0) < (A[y]||=0) ? 1 : 0
end

c(3,0,3)
0.upto(30){|i|
 a(3+i,3+i,4+i)
}

def to_b(x,s)
 a(x,3,x)
 31.downto(0){|i|
  a(3+i,s+32+i+1,s+32)
  c(s+32,x,s+i)
  a(s+i,2,s+32)
  i.times{a(s+32,s+32,s+32)}
  a(s+32,s+32+i+1,s+32+i)
 }
end

to_b(0,67)
to_b(1,195)

30.times{|i|
 30.times{|j|
  a(67+i,195+j,324)
  c(3,324,325)
  a(326+i+j,325,326+i+j)
 }
}

60.times{|i|
 i.times{a(326+i,326+i,326+i)}
 a(2,326+i,2)
}

# STDERR.puts "Q = #{Q.size}",A.map.with_index{|x,i|x||=0;"#{i}:#{x}"}*" "

puts Q.size,Q


Measured memory_bytes: 14892
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//dp[i][j]:下からi桁目まで決めたとき、次の桁で+1枚余分に払う(j==1)か今の桁で完結させる(j==0)かしたときの最小値
long long dp[1000005][2];

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

    string S;cin >> S;
    reverse(S.begin(),S.end());
    //次の桁に持ち越しの時に91→101のパターンがあり得るので0を足しておく
    S += '0';
    for(int i = 0;i<1000005;i++)for(int j = 0;j<2;j++) dp[i][j] = INF;
    dp[0][0] = 0;
    for(int i = 0;i<S.size();i++){
        for(int j = 0;j<2;j++){
            //前の桁で完結→+j=0、次の桁で+1枚はらわねばならない→j=1
            long long nowDigit = S.at(i)-'0';
            nowDigit += j;
            //自分が何枚はらうか
            for(int k = 0;k<10;k++){
                long long payCount_me = k;
                long long payCount_you = k-nowDigit;
                long long payCount_differ = k-nowDigit;
                int nextJ = 0;
                if(payCount_differ < 0){
                    //自分で払う分では不足している時
                    payCount_you += 10;
                    //次の桁で+1枚払わないといけない
                    nextJ = 1;
                }
                dp[i+1][nextJ] = min(dp[i+1][nextJ],dp[i][j]+payCount_me+payCount_you);
            }
        }
    }
    int N = S.size();
    //最後に「次の桁に持ち越し」があってはならない
    cout << dp[N][0] << endl;
}


Measured memory_bytes: 19852
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"
#define pi acos(-1.0)


int  main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
    vector<data_type> store;
    data_type n,x=0,m;
    cin>>m>>n;
    vector<data_type> vc(n);
    for(auto &i:vc)
      cin>>i;
    for(auto &i:vc)
    {
       i+=x;
       x=i;
    }
   (vc.back()>m)?cout<<-1<<endl:cout<<m-vc.back()<<endl;



    return 0;
}




Measured memory_bytes: 3728
#include <cstdio>

using namespace std;

int main() {
  int n, k, s;
  scanf("%d%d%d", &n, &k, &s);
  for (int i = 0; i < n; ++i) {
    if (i > 0) {
      putchar(' ');
    }
    if (i < k) {
      printf("%d", s);
    } else
    if (s < 1'000'000'000) {
      printf("%d", s + 1);
    } else {
      printf("1");
    }
  }
  putchar('\n');
}


Measured memory_bytes: 1280