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

int main(){
  int n,c[501],s[501],f[501];
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>c[i]>>s[i]>>f[i];
  }
  for(int i=0;i<n;i++){
    int t=0;
    for(int j=i;j<n-1;j++){
      if(t<s[j]){
        t=s[j];
      }else if(t%f[j]){
        t=(t+f[j])-(t%f[j]);
      }
      t+=c[j];
    }
    cout<<t<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define N 12
#define MAX(A,B) \
  ( (B) > (A) ? (B) : (A) )

/** メモ化用テーブル */
double k_operafan[ N ][ 1 << N ];

/** 箱のサイズ */
int l;
/** 入力の個数 */
int n;
/** 入力の内容 */
int d[ N ];

/** 与えられたケーキで構成できる最大の重なりの長さを求める */
double
dpFSA (
  /** 前方に存在するケーキ番号 */
  int cake,
  /** 既に使用したケーキのビット集合 */
  size_t st
  )
{
  int i;
  
  if ( k_operafan[ cake ][ st ] >= 0. ) ;
  else
  {
    /* 与えられたケーキで構成できる総ての組み合わせを調べる */
    k_operafan[ cake ][ st ] = 0.;
    for ( i = 0; i < n; ++i )
    {
      /* 既に使用されているならケーキ[ i ] は使えない */
      if ( st & ( 1 << i ) )
        continue ;

      /* 2 つの半径r1, r2 のケーキの中点間の距離 => 2 * sqrt ( r1 * r2 ) */
      k_operafan[ cake ][ st ]
        = MAX ( k_operafan[ cake ][ st ]
              , dpFSA ( i, st | ( 1 << i ) )
              + ( d[ cake ] + d[ i ] - sqrt ( d[ cake ] * d[ i ] ) * 2. ) );
    }
  }

  return ( k_operafan[ cake ][ st ] );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    char s[ BUFSIZ ], *p;
    double res;
    int len;

    /* 標準入力から1 行読み込み */
    if ( fgets ( s, BUFSIZ, stdin ) == NULL )
      break ;

    /* 箱のサイズは先頭トークン */
    l = atoi ( strtok ( s, " \r\n" ) );

    /* 以降のトークンはそれぞれロールケーキの半径 */
    n = 0;
    for ( ; ; )
    {
      p = strtok ( NULL, " \r\n" );
      if ( p == NULL )
        break ;

      d[ n++ ] = atoi ( p );
    }

    /* メモ化テーブルを初期化してから探索 */
    for ( i = 0; i < N; ++i )
    for ( j = 0; j < ( 1 << N ); ++j )
      k_operafan[ i ][ j ] = -1.;
    res = 0.;
    for ( i = 0; i < n; ++i )
      res = MAX( res, dpFSA ( i, 1 << i ) );

    /* 結果からケーキの並びの最小の長さを求めて判定 */
    len = 0;
    for ( i = 0; i < n; ++i )
      len += d[ i ] * 2;
    res = len - res;
    puts ( res <= l ? "OK" : "NA" );
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    ll a;
    string b;
    cin >> a >> b;
    ll b1, b2, b3, bb;

    b1 = b[0] - '0';
    b2 = b[2] - '0';
    b3 = b[3] - '0';

    b1 *= 100;
    b2 *= 10;
    bb = b1 + b2 + b3;

    
    ll ans = 0;
    ans = bb * a;
    ans /= 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    function<int(int)> binary_search = [&](int key){
        int ng = -1;
        int ok = n;
        while(abs(ok - ng) > 1){
            int mid = (ok + ng) / 2;
            if(key <= v[mid]) ok = mid;
            else ng = mid;
        }
        return ok;
    };

    int ans = 0;

    int q;
    cin >> q;
    rep(i, q){
        int x;
        cin >> x;
        ans += (v[binary_search(x)] == x);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   int x; cin >> x;
   if(x % 1000 == 0) cout << "0\n";
   else cout << 1000 - x%1000 << "\n";  
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
RRRUUULLLDDDLUUUURRRRDRDDDDLLLLU
UURRURRDDDLLDLLULUUURRURRDDDLLDL
    */
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = sx;
    int y = sy;
    string path;
    while(x != tx)
    {
        path += 'R';
        x++;
    }
    while(y != ty)
    {
        path += 'U';
        y++;
    }
    while(x != sx)
    {
        path += 'L';
        x--;
    }
    while(y != sy)
    {
        path += 'D';
        y--;
    }
    x--;
    path += 'L';
    while(y != ty + 1)
    {
        path += 'U';
        y++;
    }
    while(x != tx)
    {
        path += 'R';
        x++;
    }
    y--;
    path += 'D';
    x++;
    path += 'R';
    while(y != sy - 1)
    {
        path += 'D';
        y--;
    }
    while(x != sx)
    {
        path += 'L';
        x--;
    }
    y--;
    path += 'U';
    cout << path;
    return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
minyen = 1000000000
for i in range(0, 2*max(X, Y)+1, 2):
    yen = i * C
    yen += max(0, X - i//2) * A
    yen += max(0, Y - i//2) * B
    minyen = min(minyen, yen)
print(minyen)


Measured memory_bytes: 39280
#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)
#define ZERO(a) memset(a,0,sizeof(a))

int w,h,ans;
char f[22][22];
bool visited[22][22];
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};

bool ng(int x, int y) {
    return (x<0 or x>=w or y<0 or y>=h);
}

void dfs(int x, int y) {
    if(x>=w or y>=h) return ;
    visited[y][x] = true;
    ans++;
    rep(i,4) {
        int nx = x+dx[i], ny = y+dy[i];
        if(!ng(nx,ny) and !visited[ny][nx] and f[ny][nx]!='#')
            dfs(nx,ny);
    }

    return ;
}

int main() {
    while(cin>>w>>h && w) {
        int sx=0, sy=0;
        ans = 0;
        ZERO(visited);
        rep(y,h) rep(x,w) f[y][x] = '$';
        rep(y,h) rep(x,w) {
            cin>>f[y][x];
            if(f[y][x] == '@') {sx=x; sy=y;}
        }

        dfs(sx,sy);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1168
require 'matrix'

n, m, x = gets.split.map(&:to_i)
a = Array.new(n){Array.new(m + 1, 0)}
n.times do |i|
  b = gets.split.map(&:to_i)
  0.upto(m) do |j|
    a[i][j] = b[j]
  end
end
min = Float::INFINITY
[0, 1].repeated_permutation(n) do |bit|
  ans = 0
  sum = 0
  1.upto(m) do |j|
    sum = 0
    n.times do |i|
      if bit[i] == 1
        sum += a[i][j]
      end
    end
    break if sum < x
  end
  if sum >= x
    n.times do |i|
      if bit[i] == 1
        ans += a[i][0]
      end
    end
    min = ans if min > ans
  end
end
puts (min == Float::INFINITY ? -1 : min)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<ll, ll> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

int N;
ll dp[2020][2020];
vector<P> A;

ll rec(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    if(r-l < 1) return dp[l][r] = 0;

    int t = N-(r-l);
    ll ret = max(rec(l+1, r) + A[t].first*abs(l-A[t].second),
                rec(l, r-1) + A[t].first*abs(r-1-A[t].second));
    return dp[l][r] = ret;
}

int main(void){
    cin >> N; A.resize(N);
    REP(i,N) cin >> A[i].first;
    REP(i,N) A[i].second = i;
    SORT(A); REVERSE(A);
    REP(i,N+1)REP(j,N+1) dp[i][j] = -1;

    ll ans = rec(0,N);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	string s; cin >> s;
	int ans = 0;
	for(auto u : s) if(u == '1') ans++;
	printf("%d\n", ans);
	return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

// PowMod( base, index, modulo) return base ** index % modulo {{{
// PowMod = base ** power % mod ( natural numbers )
long long unsigned int PowMod( long long unsigned int base, long long unsigned int power, long long unsigned int mod ){
    if( power == 0 ) return 1;
    // O( log(Power) )
    long long unsigned int Phalf = power / 2;
    long long unsigned int half = PowMod(base, Phalf, mod);
    if( power % 2 ){
        return base * PowMod(base, power - 1, mod) % mod;
    }else{
        return half * half % mod;
    }
}
// }}}

// Comb( n, r, modulo ) return nCr % modulo {{{
// Comb(ination) = nCr % mod ( natural number )
long long unsigned int Comb( long long unsigned int n, long long unsigned int r, long long unsigned int mod){
    if( n < r ) return Comb(r,n,mod);
    long long unsigned int Upper = 1;
    long long unsigned int Lower = 1;
    for(long long unsigned int i = 0; i < r; i++){
        Upper = Upper * (n-i) % mod;
        Lower = Lower * (i+1) % mod;
    }
    // Return (Upper / Lower)
    long long unsigned int ret = Upper * PowMod(Lower,mod-2,mod) % mod;
    return ret;
}
// }}}

long long unsigned int mod = 1000000007;

int main() {

    int n; int m;
    Scd2(n,m);

    int remain = m;
    ll ans = 1;
    int cnt = 0;

    for( int i = 2; i <= remain; i++){
        cnt = 0;
        while( remain % i == 0 ){
            remain /= i;
            cnt++;
        }
        if( cnt ){
            ans = ans * Comb(cnt+n-1,n-1,mod) % mod;
        }
    }

    printf ("%llu\n", ans);

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N; cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(all(L), greater<int>());
    int ans = 0;
    for(int i = 1; i < N; i++){
        ans += L[i];
    }
    if(ans > L[0]) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 3528
fn main() {
    let _: i64 = readln();
    let a: Vec<i64> = readln();
    let mut m = HashMap::new();
    for &x in &a {
        let counter = m.entry(x).or_insert(0);
        *counter += 1;
    }
    let mut ans = 0;
    for (k, v) in &m {
        if k <= v {
            ans += *v - k;
        } else {
            ans += *v;
        }
    }
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 12540
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll MOD =(ll)1e9+7;
const int maxn=55;
int mark[55];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	memset(mark,0,sizeof(mark));
	for(int i=1;i<=m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		mark[a]++;
		mark[b]++;
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",mark[i]);
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    def coin_count(n):
        cnt = 0
        a, b, c, d, e, f = 0, 0, 0, 0, 0, 0
        n = 1000 - n
        if n >= 500:
            a = n // 500
            n = n - 500 * a
        if n >= 100:
            b = n // 100
            n = n - 100 * b
        if n >= 50:
            c = n // 50
            n = n - 50 * c
        if n >= 10:
            d = n // 10
            n = n - 10 * d
        if n >= 5:
            e = n // 5
            n = n - 5 * e
        f = n
        ans = a + b + c + d + e + f
        print(ans)

    while True:
        n = int(input())
        if n == 0:
            break
        coin_count(n)  

if __name__ == '__main__':
    main()


Measured memory_bytes: 5596
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

typedef long long ll;
typedef pair<long long, long long> pll;

int main(){
	int N, M;
	vector<string> A, B;
	int i, j, k;
	cin >> N >> M;
	for (i = 0; i < N; i++){
		string s;
		cin >> s;
		A.push_back(s);
	}
	for (i = 0; i < M; i++){
		string s;
		cin >> s;
		B.push_back(s);
	}
	for (i = 0; i < N - M + 1; i++){
		for (j = 0; j < N - M + 1; j++){
			bool flg = true;
			for (k = 0; k < M; k++){
				if (B[k] != A[i + k].substr(j, M)){
					flg = false;
				}
			}
			if (flg){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.readline


def dijkstra_heap(s, n, edge):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d


def main():
    N = int(input())

    edge = [[] for i in range(N)]
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        edge[a].append([c,b])
        edge[b].append([c,a])
    
    Q, K = map(int, input().split())
    K -= 1
    D = dijkstra_heap(K, N, edge)

    for _ in range(Q):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        print(D[x]+D[y])


if __name__ == '__main__':
    main()

Measured memory_bytes: 55924
Scanf.scanf "%d %d" (fun n m ->
    let rec loop i acc =
        if i * i > m then acc else
            if m mod i <> 0 then loop (i + 1) acc else
            let acc = if m / i >= n then max acc i       else acc in
            let acc = if i     >= n then max acc (m / i) else acc in
            loop (i + 1) acc
    in
    loop 1 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

int main()
{
	int N, P;
	int count = 0;
	int Max = 2147483647;
	cin >> N;

	rep(i, N) {
		cin >> P;
		if (P < Max) {
			Max = P;
			count++;
		}
	}

	cout << count << endl;

	return 0;	
}

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

int main() {
  int N,a,b,j;
  cin >>N;
  b=100;
  for (int i = 0; i < N; i++) {
    cin >> a;
    j=0;
    while (a%2==0) {
        a/=2;
        j++;
    }
    if (j<b)
      b=j;
  }
  cout << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,s,t) for(int i=s;i<=t;i++)

using namespace std;

vector<int> a, ans;
int n;

template <class T> 
T gcd(T x, T y) {
  return y ? gcd(y, x % y) : x;
}

bool checkPrime(int x) {
  if (!x || x == 0) return 0;
  for (int i = 2; i * i <= x; i++) 
    if (x % i == 0) return 0;
  return 1;
}

bool check(int p) {
  if (a[0] % p) return 0;
  vector<int> b = a;
  for (int i = n; i >= p - 1; i--) {
    b[i - p + 1] = (b[i - p + 1] + b[i]) % p;
    b[i] = 0;
  }
  For (i, 0, n) {
    if (b[i] % p) {
      return 0;
    }
  }
  return 1;
}

int main() {
#ifdef LOCAL
  freopen("maze.in", "r", stdin);
  freopen("maze.out", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); 
  cin >> n;
  a.resize(n + 1);
  int g = 0;
  For (i, 0, n) {
    cin >> a[i];
    g = gcd(g, abs(a[i]));
  }
  for (int i = 2; i * i <= g; i++) {
    if (g % i == 0) {
      ans.push_back(i);
      while (g % i == 0) g /= i;
    }
  }
  if (g > 1) ans.push_back(g);
  reverse(a.begin(), a.end());
  For (i, 2, n) {
    if (checkPrime(i) && check(i)) {
      ans.push_back(i);
    }
  }
  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());
  For (i, 0, (int)ans.size() - 1) cout << ans[i] << '\n';
  return 0;
}

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

signed main() {
	int N, A;
	cin >> N >> A;
	if (N % 500 <= A)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define int long long
#define ll long long 
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll mx = 0;
ll n, m, t;
int cnt = 0;
vector<vector<ll>> dataa;
vector<ll> v;
void solve() {
    ll sum = 0;
    for(int i = 0; i < t; i++) {
        if(v[dataa[i][1] - 1] - v[dataa[i][0] - 1] == dataa[i][2]) {
            sum += dataa[i][3];
        }
    }
    mx = max(mx, sum);
}
void rec(int ind) {
    if(ind == n) {
        solve();
        return;
    } else {
        if(ind == 0) {
            for(int i = 1; i <= m; i++) {
                v[ind] = i;
                rec(ind + 1);
            }
        }
        for(int i = 0; i <= m; i++) {
            v[ind] = v[ind - 1] + i;
            if(v[ind] > m) return;
            rec(ind+1);
        }
    }
}
signed main(){
   speed;
   cin >> n >> m;
   v = vector<int> (n); 
   cin >> t;
   dataa = vector<vector<int>> (t, vector<int> (4));
   rep(i, 0, t) {
       int a, b, c, d;
       cin >> a >> b >> c >> d;
       dataa[i][0] = a;
       dataa[i][1] = b;
       dataa[i][2] = c;
       dataa[i][3] = d;
   }
    rec(0);
    cout << mx;
}


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

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



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

#define rep(a, b) for(int a  = 0; a < b; a++)
#define repr(a, b) for(int a = b; a >= 0; a++)

using namespace std;

int main(){
    int N;
    cin >> N;
    int Ts[N];
    rep(i, N) {
        cin >> Ts[i];
    }
    int M;
    cin >> M;
    int Ps[M], Xs[M];
    rep(i, M) {
        cin >> Ps[i] >> Xs[i];
    }
    rep(i, M) {
        int sum = 0;
        rep(j, N) {
            if ((Ps[i] - 1) == j) {
                sum += Xs[i];
            } else {
                sum += Ts[j];
            }
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>
#include <complex>

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;

    switch (n % 10) {
        case 3:
            cout << "bon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        default:
            cout << "hon" << endl;
            break;
    }

    return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll GCD(ll p , ll q)
{
 if(q==0) return p;
  return GCD(q,p%q);
}
int main(){
 ll a,b,c,d;
  cin>>a>>b;
  c=GCD(a,b);
  d=(a*b)/c;
  cout<<d<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int ans, ansMax, temp;

    ansMax = M / N;

    for(ans = ansMax; ans > 0; --ans){
        temp = M - ans * (N - 1);
        if((temp % ans) == 0){
            cout << ans << endl;
            return 0;
        }
    }

    return 0;
}

int main_failed(){
    int N, M;
    cin >> N >> M;
    while(true){
        if(M % N == 0) break;
        else if(M == N) break;
        else N++;
    }
    cout << M / N << endl;

    return 0;
}



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

typedef long long ll;
const ll MOD = 1000000007;

int A, B, C, D, E, F, water, sugar;
int x, y;

int main() {
    cin >> A >> B >> C >> D >> E >> F;

    for (int a = 0; a <= F; a += 100*A) {
        for (int b = 0; a+b <= F; b += 100*B) {
            for (int c = 0; a+b+c <= F; c += C) {
                for (int d = 0; a+b+c+d <= F; d += D) {
                    water = a+b;
                    sugar = c+d;
                    if (E*water >= 100*sugar && x*sugar >= y*(water+sugar)) {
                        x = water+sugar;
                        y = sugar;
                    }
                }
            }
        }
    }
    cout << x << " " << y << endl;
}



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

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

    int n;
    int cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        if (i & 1 && a & 1) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
int main(void)
{
    int i;
    char ev[8] = {0};
    int n;
    int b = 0;
    int p = 0;
    int c = 0;
    int cc = 0;
    scanf("%d",&n);
    while(n--){
        p = 0;
        c = 0;
        cc++;
        b =0;
        while(c<3){
            scanf("%s",ev);
            if(strcmp(ev,"OUT") == 0){
                c++;
            }else if(strcmp(ev,"HIT") == 0){
                b++;
                if(b == 4){
                    b = 3;
                    p++;
                    //printf("%d %d %d\n",p,b,c);
                }
            }else if(strcmp(ev,"HOMERUN") == 0){
                p = b + 1 + p;
                b = 0;
                //printf("%d %d %d\n",p,b,c);
                }
            //printf("%d %d %d\n",p,b,c);
        }
        printf("%d\n",p);
    }
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,W;
  cin>>N>>W;
  vector<int>v(N),w(N);
  for(int i=0;i<N;i++)cin>>v[i]>>w[i];
  vector<vector<int>>dp(N+1,vector<int>(W+1,0));
  for(int i=1;i<=N;i++){
    for(int j=0;j<=W;j++){
      if(j-w[i-1]>=0)dp[i][j]=max({dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1],dp[i][j-w[i-1]]+v[i-1]});
      else dp[i][j]=dp[i-1][j];
    }
  }
  int ans=0;
  for(int i=0;i<=W;i++){
    ans=max(ans,dp[N][i]);
  }
  cout<<ans<<endl;
  return 0;
}



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

using namespace std;
using ll = long long;

#define rep(i,n) for(ll i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

ll h[(int)1e5];
ll N, A, B;
bool enough(ll T) {
  ll count = 0;
  rep(i, N) {
    count += max(0LL, (h[i]-T*B+(A-B)-1) / (A-B));
  }
  return count <= T;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> N >> A >> B;

  rep(i, N) cin >> h[i];

  ll ok = 10000000000LL, ng = 0;
  while (abs(ok - ng) > 1LL) {
    ll mid = (ok + ng) / 2LL;
    if (enough(mid))
      ok = mid;
    else
      ng = mid;
  }
  out(ok);
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main() {

	int a, b, c;
	cin >> a >> b >> c;
	
	if (a <= b && b <= c){
		cout << a << " " << b << " " << c << endl;
	}else if (a <= c && c <= b){
		cout << a << " " << c << " " << b << endl;
	}else if (b <= a && a <= c){
		cout << b << " " << a << " " << c << endl;
	}else if (b <= c && c <= a){
		cout << b << " " << c << " " << a << endl;
	}else if (c <= a && a <= b){
		cout << c << " " << a << " " << b << endl;
	}else {
		cout << c << " " << b << " " << a << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
def istrue(s):
	for a, b in zip(s, reversed(s)):
		if a != b:
			return False
	return True


s = input()
fl = (len(s)-1)/2
el = (len(s)+3)/2-1
f = s[0:int(fl)]
e = s[int(el):len(s)]

if istrue(s) is False:
	print("No")
	exit()
if istrue(f) is False:
	print("No")
	exit()
if istrue(e) is False:
	print("No")
	exit()
print("Yes")


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ_ICPC1 {

	class Program {
		static void Main(string[] args) {
			while (true) {
				string[] strs = Console.ReadLine().Split(' ');
				int N = int.Parse(strs[0]);
				int Q = int.Parse(strs[1]);
				if (N == 0) break;
				List<int>[] lists = new List<int>[N];
				for (int n = 0; n < N; n++) {
					strs = Console.ReadLine().Split(' ');
					lists[n] = new List<int>();
					for (int i = 1; i < strs.Length; i++) lists[n].Add(int.Parse(strs[i]));
				}
				Console.WriteLine(result(Q, lists));
			}
		}
		static int result(int Q, List<int>[] lists) {
			int[] numOfCommittee = new int[100];
			foreach (var l in lists) foreach (var d in l) numOfCommittee[d]++;
			int max = numOfCommittee.Max();
			return max < Q ? 0 : Array.FindIndex(numOfCommittee, n => n == max);
			
		}
	}
}

Measured memory_bytes: 6660
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<long long, long long >
#define ll long long
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 100000
#define endl '\n'
#define trace(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
int mod(int x,int y)
{
  int s;
  s = abs(x)/y;
  if(x<0)s--;
  return x-y*s;
}
int dir8[2][8] = {{1,-1,0,0,1,-1,1,-1},{0,0,1,-1,1,-1,-1,1}};
int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
int m,n,row,col,x,y;
vector <int> g[100006];
int indegree[100006],outdegree[100006],level[100006];
void solve()
{
  scanf("%d%d",&n,&m);
  for(int w=0;w<m;w++)
  {
    scanf("%d%d",&x,&y);
    g[x].pb(y);
    indegree[y]++;
    outdegree[x]++;
  }
  queue <int> q;
  for(int i=1;i<=n;i++)
  {
    if(indegree[i] == 0)q.push(i);
  }
  int ans = 0;
  int u,v;
  while(!q.empty())
  {
    u = q.front();
    q.pop();
    for(int w=0;w<g[u].size();w++)
    {
      v = g[u][w];
      level[v] = max(level[v],level[u]+1);
      indegree[v]--;
      if(indegree[v] == 0)q.push(v);
    }
  }
  for(int w=1;w<=n;w++)ans=max(ans,level[w]);
  cout << ans << endl;

}
void test()
{
  int t;
  //scanf("%d",&t);
  t = 1;
  for(int test=1;test<=t;test++)
  {
    solve();
  }
}
int main()
{
  test();
  return 0;
}


Measured memory_bytes: 6912
#include <stdio.h>

int main()
{
    char arr[100];
    scanf("%s", arr);
    for (int i = 0; arr[i] != '\0'; i++)
    {
        if (arr[i] == ',')
        {
            printf(" ");
        }
        else
        {
            printf("%c", arr[i]);
        }
    }
    printf("");
    return 0;
}

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

#define REP(i,a,b) for(int i=a;i<=b;++i)
typedef long long ll;

using namespace std;

void File(){
	freopen("AGC10D.in","r",stdin);
	freopen("AGC10D.out","w",stdout);
}

const int maxn=1e5+10;
int n;
ll a[maxn],sum;

bool dfs(bool now){
	REP(i,1,n)if(a[i]%2==1)--a[i];
	ll d=a[1];
	REP(i,1,n)d=__gcd(a[i],d);
	int cnt=0; sum=0;
	bool flag=0;
	REP(i,1,n){
		a[i]/=d;
		sum+=a[i];
		if(a[i]%2==1)++cnt;
		if(a[i]==1)flag=1;
	}
	if(sum%2==0)return now^1;
	if(sum%2==1 && (cnt>=2 || flag))return now;
	return dfs(now^1);
}

int main(){
	//File();
	scanf("%d",&n);
	REP(i,1,n){
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	if(n%2!=sum%2)puts("First");
	else if(n%2==0 && sum%2==0)puts("Second");
	else{
		int cnt=0;
		REP(i,1,n){
			if(a[i]%2==1)++cnt;
			if(cnt>=2 || a[i]==1){
				puts("Second");
				return 0;
			}
		}
		if(dfs(1))puts("First");
		else puts("Second");
	}
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int h[maxn],go[maxn*2],dis[maxn*2],nxt[maxn*2],fa[maxn],co[maxn];
bool bz[maxn],pd[maxn];
int i,j,k,l,t,n,m,tot,top,cnt,zero,one,two,mx;
bool czy;
ll ans;
void add(int x,int y,int z){
	go[++tot]=y;
	dis[tot]=z;
	nxt[tot]=h[x];
	h[x]=tot;
}
void dfs(int x){
	bz[x]=1;
	top++;
	if (!co[x]) zero++;
	else if (co[x]==1) one++;
	else two++;
	mx=max(mx,co[x]);
	int t=h[x];
	while (t){
		if (!pd[(t+1)/2]){
			pd[(t+1)/2]=1;
			cnt++;
			if (!bz[go[t]]){
				co[go[t]]=(co[x]+dis[t]+3)%3;
				dfs(go[t]);
			}
			else{
				if (co[go[t]]!=(co[x]+dis[t]+3)%3) czy=1;
			}
		}
		t=nxt[t];
	}
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,m){
		scanf("%d%d",&j,&k);
		add(j,k,1);add(k,j,-1);
	}
	fo(i,1,n)
		if (!bz[i]){
			czy=top=zero=one=two=cnt=mx=0;
			dfs(i);
			if (czy){
				ans+=(ll)top*top;
				continue;
			}
			if (!zero||!one||!two){
				ans+=(ll)cnt;
				continue;
			}
			ans+=(ll)zero*one;
			ans+=(ll)one*two;
			ans+=(ll)two*zero;
		}
	printf("%lld\n",ans);
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = t.size();
    for (int start = 0; start <= s.size() - t.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < t.size(); i++)
        {
            if (t[i] != s[i + start])
            {
                diff++;
            }
        }
        ans = min(diff, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<iostream>
using namespace std;

string s;
int main (){
    cin >> s;
    int a=0,b=0;
    for(int i=0; i<s.length(); i++){
        if( s[i] == 'C' ) a = 1;
        if( a ) {
            if( s[i] == 'F' ) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    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 all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<endl
#define f first
#define s second
#define endl '\n'
#define sq(x) (x)*(x)*1ll
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//      tree_order_statistics_node_update> indexed_multiset;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//      tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef pair<int,int> pii;


int main () {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//        freopen("test_input.txt", "r", stdin);
        int a, b; cin >> a >> b;
        if ((a + b) % 2 == 0) cout << (a + b) / 2;
        else cout << "IMPOSSIBLE";
        return 0;
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long ll;

int main() {
	int n;
	scanf("%d", &n);

	ll num;

	ll ans;
	scanf("%lld", &ans);
	bool finished = false;

	for (ll i = 0; i < n - 1; ++i) {
		scanf("%lld", &num);
		if (finished) {
			if (num == 0)
				ans = 0;
			continue;
		}
		ll stand = (ll)1000000000000000000;
		stand /= num;
		if (ans > stand) {
			finished = true;
			ans = -1;
		}
		else {
			ans *= num;
		}
	}

	printf("%lld\n", ans);
}

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

int main()
{
    string s;
    cin >> s;
    REP(i, s.size())
        cout << (s[i] == '1' ? '9' : '1');

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

r = 0
index = 0
ans = 0
for i in range(n) :
  r += 1
  for j in range(n) :
    if index >= n :
      break
    if a[index] == r :
      index += 1
      break
    ans += 1
    index += 1
      
if ans == n :
  print(-1)
else :
  print(ans)

Measured memory_bytes: 24744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int N;
Graph G;
vector<int> X, Y;

bool dfs(int v) {
    for(auto nv : G[v])
        if(!dfs(nv))
            return false;
    int gsize = G[v].size();
    if(gsize == 0)
        return true;

    // dpを　する
    vector<vector<int>> dp(gsize + 1, vector<int>(5005, INF));
    dp[0][0] = 0;
    for(int i = 0; i < gsize; ++i) {
        int nv = G[v][i];
        for(int j = X[v]; j >= 0; --j) {
            if(j >= X[nv])
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - X[nv]] + Y[nv]);
            if(j >= Y[nv])
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - Y[nv]] + X[nv]);
        }
    }
    Y[v] = INF;
    for(int i = X[v]; i >= 0; --i) {
        if(dp[gsize][i] != INF) {
            Y[v] = dp[gsize][i];
            return true;
        }
    }
    return false;
}

int main() {
    cin >> N;
    G.resize(N), X.resize(N), Y.resize(N);
    for(int i = 1; i < N; ++i) {
        int P;
        cin >> P;
        P--;
        G[P].push_back(i);
    }
    for(int i = 0; i < N; ++i)
        cin >> X[i];
    cout << (dfs(0) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 19840
#include <iostream>
#include <list>
#include <cmath>
#include<vector>
#include <utility>
using namespace std;

#define C

#ifdef C
bool isprime(int x)
{
	if (x == 2)return true;
	if (x < 2) return false;
	if ((x & 1) == 0) return false;
	int i = 3;
	for (int i = 3; i*i <= x; i = i + 2)
	{
		if (x % i == 0)
			return false;
	}
	
	return true;
}


int main(void)
{
	int cunt = 0;
	int n,in;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		cin >> in;
		if (isprime(in))
			cunt++;
	}
	cout << cunt << endl;
	return 0;
}
#endif // C

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

int main() {
    string str;
    cin >> str;
    set<char> check;
    rep(i, str.length()) check.insert(str.at(i));
    if(check.size() == str.length()) cout << "yes" << endl;
    else cout << "no" << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())

    if n % 2 != 0:
        print(0)
        exit()

    zero_count = 0

    i = 10
    while n // i != 0:
        zero_count += n // i
        i *= 5

    print(zero_count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
bool prime[(int)1e6];
int cnt[(int)1e5+10];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int m=sqrtl((int)1e5+1000);
    for (int i=2;i<=1e5;i++){
        if (!prime[i]){
            for (int j=i+i;j<=1e5;j+=i){
                prime[j]=true;
            }
        }
    }
    prime[0]=true;
    prime[1]=true;
    for (int i=3;i<=1e5;i++){
        cnt[i]=cnt[i-1]+(!prime[i]&&!prime[(i+1)/2]);
    }
    int q,r,l;
    cin>>q;
    while (q--){
        cin>>l>>r;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

int parent(int);
int left(int);
int right(int);

int main(){

  int n;
  int id;
  int k[250];
  int pk;
  int lk;
  int rk;
 
  scanf("%d", &n);
  
  for( id=1; id<=n; id++ ) {
    scanf("%d", &k[id]);
  }

  for( id=1; id<=n; id++ ) {
    printf("node %d: key = %d, ",id, k[id]);
    if( id>1 ) {
      pk = parent(id);
      printf("parent key = %d, ",k[pk]);
    }
    lk = left(id);
    rk = right(id);
    if( lk<=n ) {
      printf("left key = %d, ",k[lk]);
    }
    if( rk<=n ) {
      printf("right key = %d, ",k[rk]);
    }
    printf("\n");
  }
  return 0;
}

int parent(int i) {
  return i/2;
}

int left(int i) {
  return 2*i;
}

int right (int i) {
  return 2*i+1;
}

Measured memory_bytes: 1028
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	cin >> N;
	set<int>st;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		st.insert(a);
	}
	if (st.size() == N)puts("YES");
	else puts("NO");
	
	return 0;
}

Measured memory_bytes: 9600
// problem: "https://atcoder.jp/contests/abc126/tasks/abc126_d"

#include<iostream>
#include<vector>
#include<utility>
#define mP(x,y) pair<int,int>(x,y)

using namespace std;

void dfs(vector<pair<int,int>>G[],vector<bool>&C,int n,int i,vector<bool>&V)
{
    if(V[i])
        return;

    V[i] = 1;
    int j;
    for(j=0;j!=G[i].size();j++)
    {
        if(!V[G[i][j].first])
        {
            if(!(G[i][j].second%2))
                C[G[i][j].first] = C[i];

            else
                C[G[i][j].first] = !C[i];

            dfs(G,C,n,G[i][j].first,V);
        }
    }
}

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

    m = n;
    vector<pair<int,int>>G[n+1];
    while(--n)
    {
        int x,y,w;

        cin>>x>>y>>w;

        G[x].push_back(mP(y,w));
        G[y].push_back(mP(x,w));
    }

    vector<bool>C(m+1,false);
    vector<bool>V(m+1,false);
    dfs(G,C,m,1,V);         // define

    int i;
    for(i=1;i!=m+1;i++)
        cout<<C[i]<<'\n';

    return 0;
}


Measured memory_bytes: 10240
#include<stdio.h>
#include<string.h>
int main() {
	int n, a[100005],i,j,max=0,maxnum,b[100005];
	scanf("%d", &n);

	
	for (i = 0; i < n; i++) {
		scanf("%d",&a[i]);
	}
	for (i = 0; i < n; i++) {
		if (max <= a[i]) {
			max = a[i];
			maxnum = i;
         
		}
	}
	a[maxnum] = -1;
	if(max%2==1){
		for (i = 0; i < n; i++) {
			if (a[i] - (max / 2) - 1 >= 0) {
				b[i] = a[i] - (max / 2) - 1;
			}
			else {
				b[i] = (max / 2) + 1 - a[i];
			}
		}
	}
	else {
		for (i = 0; i < n; i++) {
			if (a[i] - (max / 2) - 0.5 >= 0) {
				b[i] = a[i] - (max / 2) - 0.5;
			}
			else {
				b[i] = (max / 2) + 0.5 - a[i];
			}
		}
	}
	int min = b[0];
	int minnum=0;
	for (i = 1; i < n; i++) {
		if (min >= b[i]) {
			min = b[i];
			minnum = i;
           
		}
	}
	printf("%d %d", max, a[minnum]);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 5000
#define MOD 1000000007

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> s(H+2,vector<char>(W+2,'#'));
  int counter=0;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin>>s.at(i).at(j);
      if(s.at(i).at(j)=='.'){
        counter++;
      }
    }
  }
  vector<vector<int>> dist(H+2,vector<int>(W+2,-1));
  queue<pair<int,int>> q;
  dist.at(1).at(1)=0;
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  q.push(make_pair(1,1));
  while(!q.empty()){
    int x=q.front().first;
    int y=q.front().second;
    for(int i=0;i<4;i++){
      int nx=x+dx[i];
      int ny=y+dy[i];
      if(s.at(nx).at(ny)=='.'&&dist.at(nx).at(ny)==-1){
        dist.at(nx).at(ny)=dist.at(x).at(y)+1;
        q.push(make_pair(nx,ny));
      }
    }
    q.pop();
  }
  if(dist.at(H).at(W)==-1){
    cout<<-1<<endl;
  }else{
    cout<<counter-dist.at(H).at(W)-1<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,M;
    cin>>N>>M;
    if(N==M) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INFTY 1000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[100][100],n;

void dijkstra(){
  int i,d[100],mincost,color[100],u,v;
  for(i=0;i<n;i++){
    color[i]=WHITE;
    d[i]=INFTY;
  }
  d[0]=0;
  color[0]=GRAY;

  while(1){
    mincost=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK&&d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INFTY)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=-1){
	if(d[u]+M[u][v]<d[v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d ",i);
    d[i]==INFTY?-1:d[i];
    printf("%d\n",d[i]);
  }
}

int main(){
  int i,j,u,k,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&M[u][v]);
    }
  }
    dijkstra();
  return 0;
}



Measured memory_bytes: 2052