akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vll;
typedef vector<char> vc;
typedef vector<vector<char>> vcc;
typedef vector<string> vs;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rep2(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define all(A) A.begin(), A.end()

int main() {
    ll n; cin >> n;
    n %= 10;
    if(n == 3) cout << "bon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;

int main() {
    ios_base::sync_with_stdio(0);
    long long a,b,n,T,cas=0;
    cin>>a>>b>>n;
    if(a>=n) a-=n;
    else {
        b=max(0ll, b-(n-a));
        a=0;
    }
    cout<<a<<" "<<b;
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int d, t, s; cin >>d >> t >> s;
	if(s*t >= d) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3648
N, M, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

A = [0]
B = [0]
for i in range(N):
  A.append(A[i] + a[i])
for i in range(M):
  B.append(B[i] + b[i])
  
ans = 0
j = M
for n in range(N + 1):
  if A[n] > K:
    break
  while B[j] > K - A[n]:
      j -= 1
  ans = max(ans, n + j)
print(ans)

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

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

  string ans;
  if (s == "Sunny") {
    ans = "Cloudy";
  }
  else if(s == "Cloudy") {
    ans = "Rainy";
  }
  else {
    ans = "Sunny";
  }
 
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define ull         unsigned long long int
#define ll          long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e14+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y){
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;    
    y=y/2;
  }
  
  return res%hell;
}
 
ll modinv(ll x){
  return power(x,hell-2);
}    
    
ll gcd(ll a,ll b){
    while(b!= 0){
	    ll t=b;
	    b=a%t;
	    a=t;
	}
	return a;
}    
        
void fastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}    
ll fact[5000];
void calc(){
    fact[0]=1;
    for(ll i=1;i<=5000;i++){
        fact[i]=(fact[i-1]*i)%hell;
    }
}

ll getfact(ll n,ll r){
    ll ans=fact[n];
    ans=(ans*modinv(fact[r]))%hell;
    ans=(ans*modinv(fact[n-r]))%hell;
    return ans;
}

void solve(){    
    ll s;
    cin>>s;
    calc();
    ll ans=0,len=1;
    
    while(true){
        ll cur=len*3;
        if(cur>s)
        break;
        cur=s-cur;
        ans=(ans+getfact(cur+len-1,len-1)%hell)%hell;
        len++;
    }   
    cout<<ans;
}     
    
int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
      
   while(test--)
   solve();
}    

Measured memory_bytes: 3688
#line 1 "../lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "tmp.cpp"

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0)
      break;
    vector<vl> dp(n + 1, vl(256, 1e12));
    vl c(m);
    REP(i, m) { cin >> c[i]; }
    vl x(n);
    REP(i, n) { cin >> x[i]; }

    REP(j, 256) { dp[0][j] = 0LL; }
    FOR(i, 1, n + 1) {
      REP(j, 256) {
        REP(k, m) {
          ll ny = min(255LL, max(0LL, (i == 1 ? 128 + c[k] : j + c[k])));
          dp[i][ny] = min(dp[i][ny], dp[i - 1][j] + (ny - x[i - 1]) * (ny - x[i - 1]));
        }
      }
    }
    ll ans = 1e12;
    REP(j, 256) { ans = min(ans, dp[n][j]); }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 43816
n, w = map(int, input().split())

dp = [[float('inf') for _ in range(10**5+1)] for i in range(n)]

for i in range(n):
    wi, vi = map(int, input().split())
    if i == 0:
        dp[i][0] = 0
        dp[i][vi] = wi
    else:
        for k in range(10**5+1):
            if k < vi:
                dp[i][k] = dp[i-1][k]
            else:
                dp[i][k] = min(dp[i-1][k], dp[i-1][k-vi]+wi)

for i in range(10**5+1)[::-1]:
    if dp[n-1][i] <= w:
        print(i)
        exit()


Measured memory_bytes: 317080
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: i64
    }
    let a = n / 500;
    let b = n % 500 / 5;
    println!("{}", a * 1000 + b * 5);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
string sort_asc(string str){//昇順（s用）
    char min;
    int n;
    for(int i = 0; i < str.size() - 1; i++){
        min = str[i];//暫定最小値
        n = i;
        for(int j = i + 1; j < str.size(); j++){
            if(str[j] < min){
                n = j;//最小値の更新
                min = str[j];
            }
        }
        swap(str[i],str[n]);
    }
    return str;
}

string sort_desc(string str){//降順（ｔ用）
    char max;
    int n;
    for(int i = 0; i < str.size() - 1; i++){
        max = str[i];//暫定最大値
        n = i;
        for(int j = i + 1; j < str.size(); j++){
            if(str[j] > max){
                n = j;//最大値の更新
                max = str[j];
            }
        }
        swap(str[i],str[n]);
    }
    return str;
}

int main(){
    string s,t;
    cin >> s >> t;
    s = sort_asc(s);
    t = sort_desc(t);
    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

bool valid(int pattern, int w) {
  bool exist = pattern & 1;
  for (int i = 1; i < w - 1; i++) {
    if ((pattern >> i) & 1) {
      if (exist)
        return false;
      else
        exist = true;
    } else {
      exist = false;
    }
  }
  return true;
}

int main() {
  // cout << valid(7, 4) << endl;  // 111
  // cout << valid(6, 4) << endl;  // 110
  // cout << valid(5, 4) << endl;  // 101
  // cout << valid(3, 3) << endl;  // 11
  // cout << valid(2, 3) << endl;  // 10
  // cout << valid(1, 3) << endl;  // 01
  // cout << valid(0, 3) << endl;  // 00
  //
  int h, w, k;
  cin >> h >> w >> k;
  ll mod = 1000000007;
  vector<vector<ll> > f(h + 1, vector<ll>(w, 0));
  rep(j, w) f[0][j] = (j == 0);

  int xmax = (1 << (w - 1)) - 1;
  for (int i = 1; i <= h; i++) {
    rep(j, w) {
      if (j > 0) {
        for (int x = 0; x <= xmax; x++) {
          if (valid(x, w) && ((x >> (j - 1)) & 1)) {
            f[i][j] = (f[i][j] + f[i - 1][j - 1]) % mod;
          }
        }
      }
      for (int x = 0; x <= xmax; x++) {
        if (valid(x, w) && ((x >> (j - 1)) & 1) == 0 && ((x >> j) & 1) == 0) {
          f[i][j] = (f[i][j] + f[i - 1][j]) % mod;
        }
      }
      if (j < w - 1) {
        for (int x = 0; x <= xmax; x++) {
          if (valid(x, w) && ((x >> j) & 1)) {
            f[i][j] = (f[i][j] + f[i - 1][j + 1]) % mod;
          }
        }
      }
    }
  }
  cout << f[h][k - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner (System.in);
        
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        for (int i = 0; i <= x; i++) {
         int tsuru = i;
         int kame = x - i;
         int total = tsuru * 2 + kame * 4;
         if (total == y) {
             System.out.println("Yes");
             return ;
          } 
        }
        
        System.out.println("No");
        
    }
}

Measured memory_bytes: 35756
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    string t;
    cin >> s >> t;
    if(t.substr(0,s.length()) == s){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

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

template <typename Int>
struct FenwickTree {
  vector<Int> data;
  explicit FenwickTree(int n): data(n, 0) {}
  void add(int i, Int x) { for (; i < (int)data.size(); i |= i+1) data[i] = max(data[i], x); }
  Int sum(int i) const { Int s = 0; for (; i >= 0; i = (i & (i+1)) - 1) s = max(s, data[i]); return s; }
};

long long dp[100001];

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

    int n;
    while (cin >> n) {
        vector<int> weights(n);
        REP(i, n) cin >> weights[i];

        REP(w, n+1) dp[w] = 0;
        dp[weights[0]] = weights[0];

        FenwickTree<long long> ft(n+1);
        ft.add(weights[0], weights[0]);

        FOR(i, 1, n) {
            int w = weights[i];
            long long v = max(dp[w], ft.sum(w-1) + w);
            dp[w] = v;
            ft.add(w, v);
        }

        long long total_weight = 0;
        REP(i, n) total_weight += weights[i];

        cout << total_weight - ft.sum(n) << '\n';
    }
}

Measured memory_bytes: 3116
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

K = sum(B) - sum(A)
C = 0; D = 0
for i in range(N):
    p = B[i] - A[i]
    if p > 0:
        C += (p+1)//2
        D += (p%2)
    else:
        D += -p
if C < K:
    D += 2*(K - C)
    C = K
if K >= 0 and C == D == K:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4596
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

 
int main() {
    ll n, u, v;
    cin >> n >> u >> v;
    --u;
    --v;
    vector<ll> us(n, -1), vs(n, -1);
    vector<vector<ll>> e(n);
    for (ll i = 0; i < n-1; ++i) {
        ll a, b;
        cin >> a >> b;
        --a; --b;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }

    us[u] = 0;
    unordered_set<ll> qu;
    qu.insert(u);
    while (!qu.empty()) {
        auto p = *(qu.begin());
        qu.erase(p);
        for (auto iter = e[p].begin(); iter != e[p].end(); ++iter) {
            if (us[*iter] == -1) {
                us[*iter] = us[p] + 1;
                qu.insert(*iter);
            }
        }
    }

    vs[v] = 0;
    unordered_set<ll> qv;
    qv.insert(v);
    while (!qv.empty()) {
        auto p = *(qv.begin());
        qv.erase(p);
        for (auto iter = e[p].begin(); iter != e[p].end(); ++iter) {
            if (vs[*iter] == -1) {
                vs[*iter] = vs[p] + 1;
                qv.insert(*iter);
            }
        }
    }
    cerr << "us: ";
    for (ll i = 0; i < n; ++i) {
        cerr << us[i] << " ";
    }
    cerr << endl;
    cerr << "vs: ";
    for (ll i = 0; i < n; ++i) {
        cerr << vs[i] << " ";
    }
    cerr << endl;
    ll m = 0;
    for (ll i = 0; i < n; ++i) {
        if (us[i] <= vs[i]) {
            ll tmp = vs[i] - 1;
            m = max(m, tmp);
        }
    }
    cout << m << endl;
}


Measured memory_bytes: 10868
#include "stdio.h"

int main()
{
	char str[20];
	int i;
	int count = 0;

	scanf("%s", str);

	for (i = 0; str[i] != '\0'; i++){
		count++;
	}

	for (i = count - 1; i >= 0; i--){
		printf("%c", str[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 524
using System;

namespace Application
{
	class Solution
	{
		static void Main(string[] args)
		{
			var inputWord = Console.ReadLine();
			var hour = int.Parse(inputWord);

			var day = new DateTime(2018, 12, 30, hour, 0, 0);
			var newYearDay = new DateTime(2019, 1, 1);

			var result = newYearDay.Subtract(day).TotalHours;

			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 13140
// in the name of god 
// vaght hast vali kam ast !

#include <bits/stdc++.h>
using namespace std ;

const int MAXN = 1e6 + 100 ;

int32_t main(){
	ios_base::sync_with_stdio(0) ;
	cin . tie(0) ; cout . tie(0) ; 

	int a , b , c ; cin >> a >> b >> c ; 
	int ans = 0 ;
	while(true){
		if(a % 2 || b % 2 || c % 2)return cout << ans , 0 ; 
		if(a == b && b == c)return cout << -1 , 0 ; 
		int na = (b + c) / 2 ; 
		int nb = (a + c) / 2 ; 
		int nc = (a + b) / 2 ; 
		a = na ; b = nb ; c = nc ; 
		ans ++ ; 
	}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	for i := n - 1; i >= 0; i-- {
		if i == 0 {
			fmt.Printf("%d\n", a[i])
		} else {
			fmt.Printf("%d ", a[i])
		}

	}
}



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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int n;
	cin >> n;
	cout << pow(n, 3) << endl;

	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 1000000007
typedef long long ll;



int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(max(abs(a-b),abs(b-c))>d && abs(a-c)>d) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
n = int(input())
W = [input() for _ in range(n)]
L = [""] * n
ans = "Yes"

for i in range(n - 1):
    if W[i][-1] == W[i + 1][0] and W[i] not in L:
        L[i] = W[i]
    else:
        ans = "No"
        break

if W[n - 1] in L:
    ans = "No"

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  char a[5];
  scanf("%s",a);
  int b = 0;
  for(int i = 0;i < 4;i++){
    if(a[i] == '+'){
      b++;
    }else b--;
  }
  printf("%d",b);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n;
 	cin >> n;
 	int ans=0;
 	int x[n];
 	for (int i = 0; i < n; i++){
 		cin >> x[i];
 	}
 	for (int i = 0; i < n; i++){
 		if(x[x[i]-1]==i+1){
 			ans++;
 		}
 		
 	}
 	cout << ans/2 << endl;
 }

Measured memory_bytes: 640
/******************************************
* AUTHOR : Ashish Joshi* 
* INSTITUTION : NIT Hamirpur *
******************************************/
#include <bits/stdc++.h>
using namespace std;

#define N 100005
#define MOD 1000000007
#define PI 3.141592653589793

#define dd double
#define loop(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define set(b,i) (b|(1<<i))
#define unset(b,i) (b&!(1<<i))
#define cbit(b,i) bool(b&(1<<i))

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
int a,b,c;
cin>>a>>b>>c;
if((a==b && b!=c) || (a==c && b!=a) ||(b==c && c!=a))
	cout<<"Yes";
else cout<<"No";

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <n; (i)++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

using namespace std;
int main(){
    int n;std::cin >> n;
    std::vector<int> a(n);
    int sum_1=0;
    rep(i,n)std::cin >> a[i];
    std::vector<int> b(2*n,0);
    for(int i=n-1;i>(n-1)/2;i--){b[i]=a[i];}
    for(int i=(n-1)/2;i>=0;i--){
        int sum=0;
        for(int j=2;j<n/(i+1)+1;j++)sum+=b[j*(i+1)-1];
        if(a[i]!=sum%2)b[i]=1;
    }
    rep(i,n)if(b[i]==1)sum_1++;
    std::cout << sum_1 << std::endl;
    rep(i,n)if(b[i]==1)std::cout << i+1<<" ";
    
    
}




Measured memory_bytes: 3200
f=input
n,l,q=int(f()),list(f()),int(f())
B=[[0]*-~n for i in range(26)]
def S(o,i):
  s=0
  while i: s+=B[o][i]; i-=i&-i
  return s
def A(o,i,x):
  while i<=n: B[o][i]+=x; i+=i&-i
for i in range(n): A(ord(l[i])-97,i+1,1)
for i in range(q):
  a,b,c=f().split(); b=int(b)
  if a>'1': print(sum(1 for o in range(26) if S(o,int(c))-S(o,b-1)))
  else: A(ord(l[b-1])-97,b,-1); l[b-1]=c; A(ord(c)-97,b,1)

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

namespace ConsoleApp1
{
    static class BSomeSums
    {        
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            var n = int.Parse(s[0]);
            var a = int.Parse(s[1]);
            var b = int.Parse(s[2]);

            var total = 0;

            for (int i = 1; i <= n; i++)
            {
                var sum = CalcSomeOfDigits(i);
                if (a <= sum && sum <= b)
                {
                    total += i;
                }
            }

            Console.WriteLine(total);
            Console.ReadLine();
        }

        static int CalcSomeOfDigits(int n)
        {
            var num = n.ToString();
            var digit = num.Length;
            var total = 0;

            for (int i = 0; i < digit; i++)
            {
                total += int.Parse(num.Substring(i, 1));
            }

            return total;
        }
  }
}

Measured memory_bytes: 11092
import std.stdio, std.string, std.algorithm;

int n, m;
string xs[];
int memo[];

void main(){
	for(;scanf("%d%d\n", &m, &n) && n;){
		xs.length = n;
		foreach(ref x; xs) x = readln.chomp;
		memo.length = 3^^m;
		memo[] = -1;
		writeln(solve(0));
	}
}

int solve(int state){
	if(memo[state] >= 0) return memo[state];
	int ans = int.max;
	scope(exit) memo[state] = ans;
	int n = cast(int)xs.length, m = cast(int)xs[0].length;
	int cands = cast(int)count!(
		(string x){
			foreach(i; 0..m){
				if(state/(3^^i)%3 &&
					((state/(3^^i)%3 == 1) ^ (x[i] == '1'))) return false;
			}
			return true;
		}
	)(xs);
	if(cands <= 1) return ans = 0;
	foreach(i; 0..m)if(state/(3^^i)%3 == 0)
		ans = min(ans, 1 + max(solve(state+(3^^i)*1), solve(state+(3^^i)*2)));
	return ans;
}

Measured memory_bytes: 4160
s = input()
n = len(s)
count = 0
count2 = 0
for i in range(n):
	if i % 2 == 0:
		x = "0"
	else:
		x = "1"
	if s[i] == x:
		count2 += 1
	    #print(i, s[i], x, "OK")
	else:
		count += 1
		#print(i, s[i], x)
print(min(count,count2))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    int N,W,H;
    cin >> N >> H >> W;
    cout << ((N-H+1)*(N-W+1)) << endl;
}


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

using namespace std;

typedef long long ll;

int main()
{
    int N, C, K;
    cin >> N >> C >> K;
    vector<ll> T(N);
    for(int i=0;i<N;++i){
        cin >> T[i];
    }

    sort(T.begin(), T.end());

    int a, pnts, ans=0;
    for(int i=0;i<N;++ans){
        a = T[i];
        pnts = 1;
        while(i < N && T[i] - a <= K && pnts <= C){
            ++i;
            ++pnts;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


int main (int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<llong> A(n);
  rep(i, n) cin >> A[i];

  vector<llong> X(n);
  llong x1 = 0;
  rep(i, n) {
    x1 += pow(-1, i) * A[n - i - 1];
  }
  x1 /= 2;
  X[0] = x1;

  llong sub1 = x1, sub2 = x1;
  rep(i, (n - 1) / 2) {
    sub1 = A[i] - sub1;
    X[i + 1] = sub1;
    sub2 = A[n - i - 1] - sub2;
    X[n - i - 1] = sub2;
  }

  rep(i, n) {
    cout << 2LL * X[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 2944
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 1000005
using namespace std;
typedef long long ll;
int k,tt;
ll ans[MN];
int calc(ll num){int tot=0;while(num)tot+=num%10,num/=10;return tot;}
int main(){
	scanf("%d",&k);
	for(int i=1;i<=9;i++)ans[++tt]=i;ans[++tt]=19;ll lst=19;
	while(tt<k){
		int tmp=calc(lst);ll add=1;
		while((lst+add)*calc(lst+add*2)>(lst+2*add)*calc(lst+add))add*=10;
		lst+=add;ans[++tt]=lst;
	}for(int i=1;i<=k;i++)printf("%lld\n",ans[i]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; cin >> N;
    vei p(N); rep(i,N) { cin >> p[i]; p[i]--; }

    int ans = 0;
    rep(i,N) {
        if(i == p[i]) {
            if(i != N - 1) swap( p[i], p[i + 1] );
            else swap( p[i - 1], p[i] );
            ans++;
        }
        else continue;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

int main()
{
	char s[500005];
	scanf("%s", s);
	int n = strlen(s);
	string ss = s;
	auto sa = suffix_array(ss);
	ll ans = ll(n)*ll(n+1)/2;
	auto la = lcp_array(ss, sa);
	for (auto x : la) ans -= x;
	printf("%lld\n", ans);
}

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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int count = 0;

  for (int i = a; i <= b; i++)
  {
    if (c % i == 0)
    {
      count++;
    }
  }

  printf("%d\n", count);
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,K;
	cin >> N >> K;
	long long ans = 1LL<<62;
	vector<ll> x(N),y(N);
	rep(i,N)cin >> x[i] >> y[i];
	rep(a,N)rep(b,N)rep(c,N)rep(d,N){
		ll left = min(x[a],x[b]);
		ll right= max(x[a],x[b]);
		ll up = max(y[c],y[d]);
		ll down = min(y[c],y[d]);
		int cnt = 0;
		rep(e,N)if(left<=x[e] && x[e] <= right && down <= y[e] && y[e] <= up)cnt++;
		if(cnt>=K)ans = min(ans,abs(left-right)*abs(up-down));
	}
	cout << ans << endl;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  swap(X, Y);
  swap(X, Z);
  cout << X << " " << Y << " " << Z << endl;

}



Measured memory_bytes: 896
#include <vector>
#include <iostream>

using namespace std;

#define MAX_NUM 20

int main()
{
	int N;

	cin >> N;

	vector<int> A(N);

	vector<vector<long long> > dp(N - 1, vector<long long>(MAX_NUM + 1, 0));

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

	dp[0][A[0]] = 1;

	for (int i = 1; i < N - 1; i++)
	{
		for (int j = 0; j <= MAX_NUM; j++)
		{
			if (j + A[i] <= MAX_NUM)
			{
				dp[i][j] += dp[i - 1][j + A[i]];
			}

			if (j - A[i] >= 0)
			{
				dp[i][j] += dp[i - 1][j - A[i]];
			}
		}
	}

	cout << dp[N - 2][A[N - 1]] << endl;

	return 0;
}

Measured memory_bytes: 1228
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

struct Node {
    vector<pii> dist;
};

Node node[100010];
int color[100010];

void dfs ( int x, ll d, bool used[100010] ) {
    if ( used[x] ) return;

    used[x] = true;
    
    rep(i, node[x].dist.size()) {
        if ( used[node[x].dist[i].fs] ) continue;

        if ( (d + node[x].dist[i].sc)%2 == 0 ) color[node[x].dist[i].fs] = color[0];
        else color[node[x].dist[i].fs] = (color[0] + 1)%2;

        dfs(node[x].dist[i].fs, d + node[x].dist[i].sc, used);
    }
}

int main()
{
    int n;

    cin >> n;
    rep(i, n-1) {
        int u, v, w;
        cin >> u >> v >> w;
        --u; --v;

        node[u].dist.emplace_back(v, w);
        node[v].dist.emplace_back(u, w);
    }

    bool used[100010] = {};
    
    color[0] = 0;
    dfs(0, 0, used);

    rep(i, n) cout << color[i] << endl;
}


Measured memory_bytes: 8448
#include<iostream>
#include<string>
using namespace std;
int main(){
	int w,h,x,y,r;
	cin>>w>>h>>x>>y>>r;
	if(x+r>w||x-r<0||y+r>h||y-r<0){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
}



Measured memory_bytes: 3084
import java.util.*;

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

		PriorityQueue<Long>[] py = new PriorityQueue[n];
		for (int i = 0; i < n; i++) py[i] = new PriorityQueue<>();

		Map<Long, Map<Integer, Integer>> h = new HashMap<>();
		for (int i = 0; i < m; i++) {
			int p = sc.nextInt() - 1;
			long y = sc.nextLong();
			py[p].add(y);
			h.put(y, new HashMap<>());
			h.get(y).put(p, i);
		}

		long[] order = new long[n];
		Arrays.fill(order, 1);

		String[] a = new String[m];
		for (int i = 0; i < py.length; i++) {
			while (!py[i].isEmpty()) {
				long y = py[i].poll();
				a[h.get(y).get(i)] = String.format("%06d%06d", i + 1, order[i]++);
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			sb.append(a[i]).append("\n");
		}

		System.out.print(sb.toString());
	}
}


Measured memory_bytes: 213040
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n; cin >> n;
  int a, b; cin >> a >> b;
  int f1 = false;
  int f2 = false;
  int f3 = false;
  REP (i, n) {
    int p; cin >> p;
    if (p <= a) {
      f1++;
    } else if (p <= b) {
      f2++;
    } else {
      f3++;
    }
  }
  cout << min({f1, f2, f3}) << endl;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    
    int res = 0;
    int now = 0;
    int now_ele = a[0];
    
    while(now < a.size()){
        int cnt = 0;
        
        cnt += upper_bound(a.begin(), a.end(), now_ele + 1) - lower_bound(a.begin(), a.end(), now_ele + 1);
        cnt += upper_bound(a.begin(), a.end(), now_ele) - lower_bound(a.begin(), a.end(), now_ele);
        cnt += upper_bound(a.begin(), a.end(), now_ele - 1) - lower_bound(a.begin(), a.end(), now_ele - 1);
        
        res = max(res, cnt);
        
        // nowの更新
        now = upper_bound(a.begin(), a.end(), now_ele) - a.begin();
        if(now < a.size()){     // now_eleより大きい要素がなければループは終了
            now_ele = a[now];
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
  using namespace std;
  #define rep(i, n) for(int i = 0; i < n; ++i)
  #define ll long long
  template <typename T>
  bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}

  const ll MOD = 1e9+7;

  void solve(){
    ll x, k, d; cin >> x >> k >> d;
    if((double)abs(x)/d > (double)k) {
      if(x > 0) cout << x - k * d << endl;
      else cout << abs(x+k*d) << endl;
      return;
    }
    ll start = abs(x)/d;
    k -= start;
    if(k %2 == 0) {
      cout << abs(x) - d * start << endl;
    } else {
      if(abs(x)-d*start >= 0){
        cout << abs(abs(x)-d*start - d) << endl;
        return;
      } else {
        cout << abs(abs(x)-d*start - d) << endl;
        return;
      }
    }
  }

  int main(){
    solve();
    return 0;
  }


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int n,m;
    cin >> n >> m;
    int a = m/n;
    while(a>1){
        DEBUG{cout << (m-(a*(m/a)))%a << endl;}
        if((m-(a*(m/a)))%a==0)break;
        a--;
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
using namespace std;
int n, d[100005];
int mod = 998244353;
map<int, int> mp;
long long qpow(long long x, long long y)
{
	long long ans = 1;
	while (y)
	{
		if (y & 1)ans = (ans * x) % mod;
		x = (x * x) % mod;
		y >>= 1;
	}
	return ans;
}
int main()
{
	scanf("%d", &n);
	int mx = 0;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &d[i]);
		mp[d[i]]++; mx = max(mx, d[i]);
	}
	if (d[1] != 0 || mp[0] != 1 || mx >= n)printf("0\n");
	else
	{
		long long ans = 1, la = 1;
		for (int i = 1; i <= mx; i++)
		{
			if (mp.count(i) == 0)
			{
				printf("0\n");
				return 0;
			}
			ans = (ans * qpow(la, mp[i])) % mod;
			la = mp[i];
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 5376
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
 
#define fr first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forln(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

random_device rd;
mt19937 SuperRandom(rd());

int pal (string& s, int i, int j) {
	while (i < j) {
		if (s[i] == s[j]) ++i, --j;
		else return 0;
	}
	return 1;
}


signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string s;
	cin >> s;
	int n = sz (s);
	int f = pal (s, 0, n - 1) & pal (s, 0, (n - 1) / 2 - 1) & pal (s, (n + 3) / 2 - 1, n - 1);
	if (f) cout << "Yes";
	else cout << "No";








}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6+5;
const ll N = 1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
 
ll a[maxn];
int main(){
    // in;
    // out;
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<=n;i++){
        a[i]=i;
    }
    ll sum=0;
    for(ll i=m;i<=n+1;i++){
        ll minn=(i-1)*i/2;
        ll maxx=n*i-i*(i-1)/2;
        // cout<<minn<<" "<<maxx<<endl;
        // cout<<maxx-minn+1<<endl;
        sum+=maxx-minn+1;
        sum%=mod;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 5120
#include<iostream> 
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#define Mod 1000000007
using namespace std;
long long ans,n,a[200001],k[200001];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i],k[i]=(a[i]+k[i-1])%Mod;
	for(int i=1;i<=n;i++)
		ans=(ans+(k[i-1]*a[i])%Mod)%Mod;
	cout<<ans%Mod; 
}

Measured memory_bytes: 6700
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int a,b;
    string s;
    cin >> a >> b;
    if(a <= 8 && b <= 8){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }


}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int n,m,v,p;
	static int a[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		 n = sc.nextInt();
		 m = sc.nextInt();
		 v = sc.nextInt();
		 p = sc.nextInt();
		 a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		
		int ans = n-binarySearch(0,n-1);
		System.out.println(ans);
		
	}
	static int binarySearch(int lo,int hi) {
		int mid = (lo+hi)/2;
		if(works(mid)) {
			if(!works(mid-1)) {
				return mid;
			}
			return binarySearch(lo,mid-1);
		}
		else {
			if(works(mid+1)) {
				return mid+1;
			}
			return binarySearch(mid+2,hi);
		}
		
	}
	static boolean works(int x) {
		if(x>=n || x<0) return false;
		long totUsed =0;
		int numGreater =0;
		int numMid= 0;
		for(int i=0;i<n;i++) {
			
			if(a[i]<=a[x]) {
				totUsed+=m;
			}
			else if(a[i]<=(a[x]+m)) {
				numMid++;
			}
			else {
				numGreater++;
				totUsed+=m;
			}
		}
		long k = (long) (m)*(v);
		if(numGreater>=p) return false;
		
		int add = Math.min(p-1-numGreater,numMid);
		numMid-=add;
		for(int i=0;i<n;i++) {
			if(a[i]>a[x]) {
				if(a[i]<=(a[x]+m)) {
					if(numMid>0) {
						numMid--;
						totUsed+=a[x]+m-a[i];
					}
				}
			}
		}
		totUsed+=(long) m*add;
		
		return totUsed>=k;
		
	}
}


Measured memory_bytes: 52256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    dp = [0] * (N + 1)
    dp[0] = 1000
    for i in range(1, N + 1):
        dp[i] = dp[i - 1]
        for j in range(1, i):
            dp[i] = max(dp[i], (dp[j] // A[j - 1]) * A[i - 1] + dp[j] % A[j - 1])
    print(dp[N])

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)


Measured memory_bytes: 64028
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int N, A, B, C, D;
long long FACT[1024];
long long fact(int n) {
	return FACT[n];
}
long long inv(int n) {
	long long r = 1, x = n;
	int m = 1000000005;
	while (m) {
		if (m&1) (r *= x) %= mod;
		m>>=1;
		(x *= x) %= mod;
	}
	return r;
}
long long comb(int n, int m) {
	long long r = fact(n) * inv(fact(m)) % mod * inv(fact(n-m)) % mod;
	return r;
}
long long memo_f[1024][1024];
bool visited_f[1024][1024];
long long f(int n, int m) {
	if (m > B) return n == 0 ? 1 : 0;
	if (visited_f[n][m]) return memo_f[n][m];
	visited_f[n][m] = true;
	long long r = f(n, m+1);
	long long rr = 1;
	for (int i = 0; i <= D && n-i*m >= 0; ++ i) {
		if (i >= C) {
			(r += f(n-i*m, m+1) * rr % mod) %= mod;
		}
		if (n-i*m < m) break;
		(rr *= comb(n-i*m, m)) %= mod;
		(rr *= inv(i+1)) %= mod;
	}
	return memo_f[n][m] = r;
}
int main() {
	FACT[0] = 1;
	for (int i = 1; i < 1024; ++ i) FACT[i] = i * FACT[i-1] % mod;
	cin >> N >> A >> B >> C >> D;
	cout << f(N, A) << endl;
}


Measured memory_bytes: 9344
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int X = sc.nextInt();
      int t = sc.nextInt();
      System.out.println(((X - t) > 0) ? (X - t) : 0);
	}
}


Measured memory_bytes: 20944