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

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if (c<=b){
        cout << c+b << endl;
    } else{
        if ((a+b)>=c){
            cout << c+b << endl;
        } else {
            cout << a+b+1+b << endl;
        }
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> sc(M);
  for (int i=0; i<M; i++) cin >> sc.at(i).first >> sc.at(i).second;
  bool exist = true;
  sort(sc.begin(), sc.end());
  for (int i=0; i<M; i++) {
    if (N!=1&&sc.at(i).first==1&&sc.at(i).second==0) exist = false;
    else if (i+1<M&&sc.at(i).first==sc.at(i+1).first&&sc.at(i).second!=sc.at(i+1).second) exist = false;
  }
  if (exist) {
    vector<bool> existnum(N, false);
    vector<string> a(N);
    for (int i=0; i<M; i++) {
      for (int j=0; j<N; j++) {
        if (!existnum.at(j)&&sc.at(i).first==j+1) {
          existnum.at(j) = true;
          a.at(j) = to_string(sc.at(i).second);
        }
      }
    }
    for (int i=0; i<N; i++) {
      if (!existnum.at(i)) {
        if (i==0) a.at(i) = to_string(1);
        else a.at(i) = to_string(0);
      }
    }
    if (N!=1||M!=0) {
      for (int i=0; i<N; i++) {
        if (i!=N-1) cout << a.at(i);
        else cout << a.at(i) << endl;
      }
    }
    else cout << 0 << endl;
  }
  else cout << -1 << endl;
}

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

main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int a,b;
    cin>>a>>b;

    if((a+b)&1){
        cout<<"IMPOSSIBLE";
    }
    else{
        cout<<(a+b)/2;
    }

    return 0;
}

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

using namespace std;

using VI = vector<int>;
using VII = vector<pair<int, int> >;
using MII = map<int, int>;
const int X = 300000;


VII freqs(const MII& m) {
  VII v;
  for (auto const& kv: m) {
    v.push_back(make_pair(kv.second, kv.first));
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  return v;
}

int main() {
  int N;
  cin >> N;
  MII ma, mb;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (i % 2 == 0) {
      ma[a]++;
    } else {
      mb[a]++;
    }
  }
  ma[X] = 0;
  mb[X] = 0;

  VII fa = freqs(ma);
  VII fb = freqs(mb);

  int res;
  if (fa[0].second == fb[0].second) {
    res = min(N - fa[1].first - fb[0].first, N - fa[0].first - fb[1].first);
  } else {
    res = N - fa[0].first - fb[0].first;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 6136
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

vector<int> Z_algorithm(string S){
    int c=0,n=S.size();
    vector<int> Z(n,0);
    for(int i=1; i<n; i++){
        int l = i-c;
        if(i+Z[l] < c+Z[c]){
            Z[i] = Z[l];
        }else{
            int j = max(0, c+Z[c]-i);
            while(i+j<n && S[j]==S[i+j]) j++;
            Z[i] = j;
            c = i;
        }
    }
    Z[0] = n;
    return Z;
}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    vector<int> Z = Z_algorithm(S);
    int N = S.size();
    // ABを入れる
    string ans = "-";
    for(int i=N-1; i>=1; i--){
        // 後ろがAになるか判定
        if(Z[i] == N-i){
            // Bの文字列の長さ
            // これB*2の長さ
            int B = (i-1)-Z[i]+1-Z[i];
            if(B <= 0) continue;
            if(B%2 == 0){
                // Bの長さ
                B /= 2;
                if(Z[Z[i]+B] >= Z[i]+B){
                    // 条件満たす
                    // cout << i << " " << Z[i]+B << "\n";
                    if(ans == "-"){
                        ans = S.substr(0,Z[i]+B);
                    }else{
                        if(ans.size() > Z[i]+B){
                            ans = S.substr(0,Z[i]+B);
                        }
                    }
                }
            }
        }
    }
    if(ans == "-"){
        cout << "mitomerarenaiWA" << "\n";
    }else{
        cout << "Love " << ans << "!" << "\n";
    }
    return 0;
}



Measured memory_bytes: 8864
fun main(args:Array<String>) {
    val (treeCount, decoCount) = readLine()!!.split(" ").map { it.toInt() }
    val treeList = (1..treeCount).map { readLine()!!.toLong() }.sorted()

    var min = 1000000000.toLong()
    for(i in (0..(treeList.size - decoCount))) {
        min = Math.min(min, Math.abs(treeList[i + decoCount - 1] - treeList[i]))
    }
    println(min)
}


Measured memory_bytes: 46772
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <regex>

using namespace std;
typedef long long LL;
typedef long double LD;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, LL> PDL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector <VI> VVI;
typedef vector <VL> VVL;

typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector< PDL > VPDL;

#define pb push_back
#define fi first
#define se second
const int MAX = (int)1e5 + 1;
const long double eps = 1e-16;
const int MODP = (int)998244353;

#define for0(x,n) for(int x = 0; x < n; ++x)
#define for1(x,n) for(int x = 1; x <= n; ++x)
#define sort_i(a) sort(a.begin(), a.end());
#define sort_d(a) sort(a.rbegin(), a.rend());
#define summaLL(a) accumulate(a.begin(), a.end(), 0LL);
#define summa(a) accumulate(a.begin(), a.end(), 0);
template <typename T> vector<T> readVector0(int n) { vector<T> res(n); for (int i = 0; i < n; i++) cin >> res[i]; return res; }
template <typename T> vector<T> readVector1(int n) { vector<T> res(n + 1); for (int i = 1; i <= n; i++) cin >> res[i]; return res; }

template <typename T>
bool sortBy2(const pair<T, T> &a,
	const pair<T, T> &b)
{
	return (a.second < b.second);
}

struct pt {
	int x, y;
};

LL mod(LL x, LL m) {
	return (x + m) % m;
}

int n;
//auto v = readVector<int>(n);
int main() {
	//FILE *str;
	//freopen_s(&str, "test.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	
	
	VI a(MAX, 0);
	VI b(MAX, 0);
	
	int x;
	for0(i, n) {
		cin >> x;

		if (i & 1) {
			a[x]++;
		}
		else b[x]++;
	}
	
	int maxa = 0, ia = 0;
	int maxb = 0, ib = 0;

	for0(i, MAX) {
		if (a[i] > maxa) { maxa = a[i]; ia = i; }
		if (b[i] > maxb) { maxb = b[i]; ib = i; }
	}
	if (ia != ib) {
		cout << (n - maxa - maxb);
		return 0;
	}

	int max2a = 0, i2a = 0;
	int max2b = 0, i2b = 0;

	for0(i, MAX) {
		if (i!= ia && a[i] > max2a) { max2a = a[i]; i2a = i; }
		if (i!= ib && b[i] > max2b) { max2b = b[i]; i2b = i; }
	}

	int num = max(maxa + max2b, maxb + max2a);
	cout << (n - num);
	return 0;


}


Measured memory_bytes: 1024
// B
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=1;
typedef long long ll;

ll n,m,ans;
ll a,b,c,d,i,j,l,r;


int main()
{
	cin>>n>>a>>b>>c>>d;
	
	for(i=0;i<n;++i)
	{
		j=n-1-i;
		l=c*i-d*j;
		r=d*i-c*j;
		if(l<=b-a&&b-a<=r)
		  return 0*printf("YES");
	}
	printf("NO");
	
	
	
	return 0;
}


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

char map[51][51];
int next[4][2]={0,1,1,0,0,-1,-1,0};
int book[51][51],h,w,head,tail,flag;

struct {
  int x,y;
  int step;
}que[2501];

void bfs(int x,int y);

int main(){
  
  int i,j,sum=0;
  head=1;
  tail=1;
  
  que[head].x=1;
  que[head].y=1;
  que[head].step=0;
  
  tail++;
  
  //開始地点を探索済みにする
  book[1][1]=1;
  
  
  scanf("%d%d",&h,&w);
  
  for(i = 1;i <= h; i++){
    getchar();
    for(j=1;j<=w;j++)
    {
      scanf("%c",&map[i][j]);
      //白の場所をカウントアップ
      if(map[i][j]=='.')
      sum++;
    }
  }
  
  sum -= 1;
  bfs(1,1);
  
  if(flag==0)
  printf("-1\n");
  else
  printf("%d\n",sum-que[tail-1].step);
  
  return 0;
}

void bfs(int x,int y){
  
  int i,tx,ty;
  
  //キューが終わるまで
  while(head<tail){
    
    for(i=0;i<4;i++){
      
      //その場所から上下左右を調べる
      tx= que[head].x + next[i][0];
      ty= que[head].y + next[i][1];

      //範囲外なら無視
      if(tx<1||tx>h||ty<1||ty>w) continue;

      //その場所が白で探索前なら
      if(map[tx][ty]=='.' && book[tx][ty]==0){

        //キューにその場所を追加
        que[tail].x=tx;
        que[tail].y=ty;
        que[tail].step=que[head].step+1;
        tail++;
        
        //その場所を探索済みに
        book[tx][ty]=1;
      }

      //もしゴールなら
      if(tx == h && ty == w){
        flag=1;
        break;
      }
    }

  //ゴールしたら終了  
  if(flag==1)
    break;
    head++;
  }
  
  return;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    ll t = v[0];
    for (int i = 1; i < SZ(v); i++) t = lcm(t, v[i]);
    cout << t << "\n";
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, minn=INT_MAX, neg=0,x ;
    cin >> n;
    ll sum = 0;
    for(int i=0; i<n; ++i){
        cin >> x;
        if(x < 0 ) ++neg;
        sum += abs(x);
        minn = min(minn, abs(x));
    }
    if(neg & 1){
        cout << sum - 2*minn << "\n";
    }
    else{
        cout << sum << "\n";
    }
}


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

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

int main()
{   
    string s; cin >> s;
    cout << ((s[2] == s[3] && s[4] == s[5])?"Yes":"No") << endl;
}


Measured memory_bytes: 256
SN,LN=map(int,input().split())
S=[list(map(int,input().split())) for _ in range(LN)]
p=list(map(int,input().split()))

c=0
for i in range(1<<SN):
  tmp=[0]*SN
  judge=True
  for j in range(SN):
    if (i>>j)&1==1:
      #tmpにon/offの情報を0/1で入れる
      tmp[j]=1
      
  for k in range(LN):
    sum=0
    #ある電球のスイッチの番号を取得
    for x in S[k][1:]:
      # その番号のスイッチがonか否かを判定
      if tmp[x-1]==1:
        #onの個数を記録
        sum+=1
    #k番目の電球がonでなければその時点でfalse
    if sum%2!=p[k]:
      judge=False
  #あるtmpの状態で全ての電球がonならcにカウント
  if judge:
    c+=1

print(c)


Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , k , ans , cntL , cntR;
string s , t;

int main() {
    fast_io;

    cin >> n >> k >> s;
    s = "." + s + ".";
    t = s;
    for(ll i = 1 ; i <= n ; i++){
        if(s[i] == 'L' && s[i - 1] != 'L'){
            cntL++;
        }
        if(s[i] == 'R' && s[i + 1] != 'R'){
            cntR++;
        }
    }

    cout << n - max(1LL , cntL + cntR - min({k , cntL , cntR}) * 2) << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 512
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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()));
        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)*}
    };
}

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

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        s: chars,
    }
    let mut ans = 0;
    let mut acc = s[0];
    for i in 1..s.len() {
        if s[i] == acc {
            ans += 1;
        }
        acc = if acc == '0' { '1' } else { '0' };
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(string s){
	int N = s.size();
	if (s[0] != '1' || s[N - 1] != '0') {
		cout << -1 << endl;
		return;
	}
	s = "0" + s;
	string t = s;
	reverse(ALL(t));
	if (s != t) {
		cout << -1 << endl;
		return;
	}
	s[N] = '1';
	queue<int> Q;
	Q.push(1);
	for(int i = 2; i <= N; ++i) {
		if (s[i] == '1') {
			while(!Q.empty()) {
				cout << Q.front() << " " << i << endl;
				Q.pop();
			}
		}
		Q.push(i);
	}
}

signed main(){
	string s;
	cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int z = b-a;
    int ans = 0;
    for(int i = 0;i < z+1;i++){
        ans += i;
    }
    cout << ans - b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int calc(char c) {
  return (c - '0');
}
int main() {
  string s;
  cin >> s;
  int f = calc(s[0]) * 100 + calc(s[1]) * 10 + calc(s[2]), ans = abs(753 - f);
  for (int i = 3; i < s.size(); i++) {
    f = f % 100 * 10 + calc(s[i]);
    ans = min(ans, abs(753 - f));
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <queue>
#include <vector>
using namespace std;
const int MAXN = 100000 + 10;
int par[MAXN], L[MAXN<<1], R[MAXN<<1], D[MAXN<<1];
int lft[MAXN], rght[MAXN], dist[MAXN];
bool vis[MAXN<<1], tmp[MAXN];
vector<int> vs[MAXN];
int find (int i) {
    if (par[i] == i) return i;
    return par[i] = find(par[i]);
}
void add (int i, int j) {
    int a = find(i);
    int b = find(j);
    par[a] = b;
}
int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        par[i] = i;
        dist[i] = INT_MAX;
    }
    for (int i = 0; i < m; i++) {
        cin >> L[i] >> R[i] >> D[i];
        add (L[i], R[i]);
        vs[L[i]].push_back(i);
        vs[R[i]].push_back(i);

    }
    int cnt = 0;
    queue<int> q;
    for (int i = 1; i <= n; i++) {
        int p = find(i);
        if (tmp[p]) continue;
        tmp[p] = true;
        for (int item : vs[p]) {
            if (vis[item]) continue;
            q.push(item);
            vis[item] = true;
        }
    }
    while (!q.empty()) {
        int i = q.front(); q.pop();
        int p = find(L[i]);
        if (L[i] == p) dist[L[i]] = 0;
        if (R[i] == p) dist[R[i]] = 0;
        if (dist[L[i]] != INT_MAX && dist[R[i]] != INT_MAX) {
            if (dist[R[i]]-dist[L[i]] != D[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        else if (dist[L[i]] != INT_MAX) {
            dist[R[i]] = dist[L[i]] + D[i];
        }
        else if (dist[R[i]] != INT_MAX) {
            dist[L[i]] = dist[R[i]] - D[i];
        }
        lft[p] = min(lft[p], dist[L[i]]);
        rght[p] = max(rght[p], dist[R[i]]);
        if (rght[p]-lft[p] > 1e9) {
            cout << "No" << endl;
            return 0;
        }
        if (!tmp[L[i]]) {
            tmp[L[i]] = true;
            for (int item : vs[L[i]]) {
                if (!vis[item]) {
                    vis[item] = true;
                    q.push(item);
                }
            }
        }
        if (!tmp[R[i]]) {
            tmp[R[i]] = true;
            for (int item : vs[R[i]]) {
                if (!vis[item]) {
                    vis[item] = true;
                    q.push(item);
                }
            }
        }

    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

void solve();

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

void solve() {
    string s;
    cin >> s;
    if(s.length() < 4) {
        cout << "No" << endl;
        return;
    }
    if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
        cout << "Yes" << endl;
        return ;
    }
    cout << "No" << endl;


}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,i,d;
  long long sum;
  sum=0;
  scanf("%d", &n);
  
  int h[n];
  
  for (i=0;i<n;i++)
  {
	scanf("%d",&h[i]);    
  }
  
  for (i=0;i<n-1;i++)
  {
   if (h[i]>h[i+1])
   {
	d=h[i]-h[i+1];
	h[i+1]=h[i+1]+d;
    sum=sum+d;
   }
  }
  printf("%lld",sum);
  return 0;
}

Measured memory_bytes: 2468
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int D,G; cin >> D >> G;
  vector<int> p(D),c(D);
  rep(i,D) cin >> p[i] >> c[i];
  
  int ans = 1<<30;
  for(int bit = 0; bit < (1<<D); bit++){
    int tmp_ans = 0; //総回答数
    int max_i = 0; //全問正解しない内、もっとも高い得点のもの。
    int tmp_score = 0; //点数
    rep(i,D){
      if(bit & (1<<i)){
        tmp_ans += p[i];
        tmp_score += c[i];
        tmp_score += p[i] * (i+1) * 100;
      }else{
        chmax(max_i,i);
      }
    }
    
    int cnt = 1;
    while(tmp_score < G && cnt < p[max_i]){
      tmp_score += (max_i+1)*100;
      tmp_ans++;
      cnt++;
    }
    if(tmp_score >= G){
      chmin(ans, tmp_ans);
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

int main() {
   ll i,j,k;
    ll h,w,ans=0;
    cin >> h>>w;

ans+=(h/2+h%2)*(w/2+w%2);
ans+=(h/2)*(w/2);

if(h==1 || w==1)
{
    ans=1;
}
  cout <<  ans<< endl;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
L=[[] for i in range(H)]
yoko=list()
for i in range(H):
  L1=list(input())
  if L1==["."]*W:
    yoko.append(i)
  L[i]=L1
R=list(range(W))
for i in range(H):
  for j in range(W):
    if j in R and L[i][j]=="#":
      R.remove(j)
for i in range(H):
  if i in yoko:
    continue
  s=L[i]
  r=list()
  for j in range(W):
    if j not in R:
      r.append(s[j])
  print("".join(r))

Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;

char a[50][50];
int dp[52][52][52][52];

int func(int i1, int j1, int i2, int j2) {
  int res = -1;
  if (i2) chmax(res, dp[i1+1][j1][i2-1][j2]);
  if (j2) chmax(res, dp[i1+1][j1][i2][j2-1]);
  if (i2) chmax(res, dp[i1][j1+1][i2-1][j2]);
  if (j2) chmax(res, dp[i1][j1+1][i2][j2-1]);
  if (res == -1) return -INF;
  return res;
}
int func2(int i1, int j1, int i2, int j2) {
  // if (i1==i2&&j1==j2) return 0;
  int res = -1;
  chmax(res, dp[i1+1][j1][i2][j2]);
  chmax(res, dp[i1][j1+1][i2][j2]);
  if (res == -1) return -INF;
  return res;
}

int main() {
  int h,w;
  while(cin >> h >> w, h||w) {
    vector<pii> v[26];
    REP(i,h)REP(j,w) {
      cin>>a[i][j];
      if (isupper(a[i][j])) {
        v[a[i][j]-'A'].push_back(pii(i,j));
      }
    }
    memset(dp,-1,sizeof(dp));
    REP(i,h)REP(j,w) dp[i][j][i][j] = (a[i][j]=='#'?-1:0);
    REP(i1,h+1)REP(j1,w+1)REP(i2,h+1)REP(j2,w+1) if (i2<i1&&j2==j1||j2<j1&&i1==i2) dp[i1][j1][i2][j2] = 0;
    
    for (int hh=1;hh<=h; ++hh) {
      for (int ww=1;ww<=w; ++ww) {
        if (hh==1&&ww==1) continue;
        for (int i1=0; i1<h-hh+1; ++i1) {
          for (int j1=0; j1<w-ww+1; ++j1) {
            if (a[i1][j1] == '#') continue;
            int i2 = i1+hh-1;
            int j2 = j1+ww-1;
            if (islower(a[i1][j1])) {
              FOR(it, v[a[i1][j1]-'a']) {
                int i3 = it->first;
                int j3 = it->second;
                if (i3<i1||i2<i3||j3<j1||j2<j3) continue;
                chmax(dp[i1][j1][i2][j2], func(i1,j1,i3,j3) + func2(i3,j3,i2,j2) + 1);
              }
            }
            if (i1+1<=i2) chmax(dp[i1][j1][i2][j2], dp[i1+1][j1][i2][j2]);
            if (j1+1<=j2) chmax(dp[i1][j1][i2][j2], dp[i1][j1+1][i2][j2]);
            // if (dp[i1][j1][i2][j2] >= 0) {
            //   cout << i1 << " " << j1 << " " << i2 << " " << j2 << " : " << dp[i1][j1][i2][j2] << endl;
            // }
          }
        }
      }
    }
    if (dp[0][0][h-1][w-1] == 20) {
      REP(i,h) {
        REP(j,w) cout << a[i][j];
        cout << endl;
      }
    }
    cout << dp[0][0][h-1][w-1] << endl;
  }
}

Measured memory_bytes: 29776
N, H = map(int, input().split())
a = []
b = []
for i in range(N):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
    
a_max = max(a)
b.sort(reverse = True)

ans = 0
for i in range(N):
    if b[i] > a_max:
        ans += 1
        H -= b[i]
        if H <= 0:
            print(ans)
            exit()
print(ans + (H + a_max - 1)// a_max)
    


Measured memory_bytes: 11324
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    k: usize,
    a: [usize; n]
    }
    let ans = (n - 1) / (k - 1) + if (n - 1) % (k - 1) != 0 {1} else {0};
    println!("{}", ans);
}


Measured memory_bytes: 3252
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    map<int, int> mp;
    REP(i, n)
    {
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    bool flag = true;
    for (auto i : mp)
    {
        if (i.second >= 2)
        {
            flag = false;
        }
    }
    if (flag)
    {
        YES(1);
    }
    else
    {
        YES(0);
    }
}

Measured memory_bytes: 9600
#include <stdio.h>
int A[20];

int check_sum(int i,int m,int n)
{
  int sum=0;
  if(m==0) return 1;
  if(i>=n)  return 0;


    sum=check_sum(i+1,m,n)|| check_sum(i+1,m-A[i],n);
    return sum;
  
}


int main(){
  int i,n,q,m[200];
  int flag;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    flag=0;
    scanf("%d",&m[i]);
    flag=check_sum(0,m[i],n);
    if(flag==1) printf("yes\n");
    else printf("no\n");
  }
  

  return 0;
}



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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100100;

int n;
char s[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%s", s);
	n = strlen(s);
	int l = 0, r = n;
	for (int i = 0, j = n - 1; ; ++i, --j)
	{
		while (i < n && s[i] == 'x') ++i;
		while (j >= 0 && s[j] == 'x') --j;
		if (i < j)
		{
			if (s[i] != s[j])
			{
				printf("-1\n");
				return 0;
			}
		}
		else
		{
			l = j, r = i;
			break;
		}
	}
	int ans = 0;
	while (1)
	{
		if (l < 0 && r >= n) break;
		if (r >= n) ++ans, --l;
		else if (l < 0) ++ans, ++r;
		else if (s[l] != s[r])
		{
			if (s[l] == 'x') ++ans, --l;
			else ++ans, ++r;
		}
		else --l, ++r;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N + 2, 0);
    int now = 0;
    int sum = 0;
    for(int i = 1; i < N + 1; i++) {
        cin >> A[i];
        sum += abs(now - A[i]);
        now = A[i];
    }
    sum += abs(now - 0);
    for(int i = 1; i < N + 1; i++){
        int temp = sum - abs(A[i - 1] - A[i]) - abs(A[i +1] - A[i]) + abs(A[i + 1] - A[i - 1]);
        cout << temp << endl;
    }
}

Measured memory_bytes: 3672
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
b=list(int(input()) for i in range(n))
for i in range(3):
  for j in range(n):
    if a1[i]==b[j]:
      a1[i]=0
    elif a2[i]==b[j]:
      a2[i]=0
    elif a3[i]==b[j]:
      a3[i]=0
if a1[0]==a2[0]==a3[0]:
  print('Yes')
elif a1[0]==a2[1]==a3[2]:
  print('Yes')
elif a1[0]==a1[1]==a1[2]:
  print('Yes')
elif a1[1]==a2[1]==a3[1]:
  print('Yes')
elif a1[2]==a2[2]==a3[2]:
  print('Yes')
elif a1[2]==a2[1]==a3[0]:
  print('Yes')
elif a2[0]==a2[1]==a2[2]:
  print('Yes')
elif a3[0]==a3[1]==a3[2]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
unsigned int a,n;
int IsPrime(int n)
{
    int i;
 
    if (n < 2)
        return 0;
    else if (n == 2)
        return 1;
 
    if (n % 2 == 0)
        return 0;
 
    for (i = 3; i <= n / i; i += 2)
        if (n % i == 0)
            return 0;
    return 1;
}
int main() {
    int temp=0,flag=0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (IsPrime(a) == 1)temp++;
    }
    cout << temp << endl;
}

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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define f(n)                for (ll i=0;i<n;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define N                   100005
ll MOD=pow(10,9)+7;
ll INF=1ll<<60;

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

    ll dp[n+1][m+1];
    mem(dp,0);

    char a[n+1][m+1];

    rep(i,1,n+1)
    {
        rep(j,1,m+1)
        {
            cin>>a[i][j];
        }
    }

    dp[1][1]=1;

    rep(i,1,n+1)
    {
        rep(j,1,m+1)
        {
            if(a[i][j]=='.')
            {
                if(a[i-1][j]=='.')
                    dp[i][j]=dp[i-1][j];
                if(a[i][j-1]=='.')
                    dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
            }
        }
    }

    cout<<dp[n][m];
}

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

int main() {
  int N;
  cin >> N;
  int A[16], x[16][15], y[16][15];
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
    for (int j = 1; j <= A[i]; ++j)
      cin >> x[i][j] >> y[i][j];
  }

  int ans = 0;
  for (int bit = 0; bit < 1 << N; ++bit) {
    int sum = 0;
    bool flag = true;
    for (int i = 1; i <= N && flag; ++i) {
      if (bit & 1 << (i - 1)) {
        ++sum;

        for (int j = 1; j <= A[i]; ++j)
          if (((bit & 1 << (x[i][j] - 1)) && !y[i][j]) ||
              (!(bit & 1 << (x[i][j] - 1)) && y[i][j]))
            flag = false;
      }
    }

    if (flag)
      ans = max(sum, ans);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def solve():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        if len(make_divisors(i)) == 8 and i%2 == 1:
            ans += 1
    
    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9456
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n"
using namespace std;
using ll=long long;
using ld=long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using vlll = vector<vector<vector<ll>>>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class DModSum {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll n;
	    in >> n;

	    out << n*(n-1)/2 << enl;
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	DModSum solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]", B: "List[int]"):
    a = A
    b = B
    a.sort()
    b.sort()
    if N % 2 == 0:
        ma = (a[N // 2 - 1] + a[N // 2]) / 2
        mb = (b[N // 2 - 1] + b[N // 2]) / 2
        ret = mb * 2 - ma * 2 + 1
    else:
        ma = (a[N // 2]) / 2
        mb = (b[N // 2]) / 2
        ret = mb * 2 - ma * 2 + 1
    print(int(ret))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 76252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  string c;
  cin >> n >> c;

  int cnt = 0;
  rep(i, n) cnt += (c[i] == 'R');
  int ans = 0;
  FOR(i, cnt, n) ans += (c[i] == 'R');
  cout << ans << '\n';


  




  
  return 0;
}

Measured memory_bytes: 3768
n = int(input())
s = input()

ans = [0] * n
left = 0
right = s[1:len(s)].count('E')
ans[0] = right

for i in range(1, n):
    if s[i - 1] == 'W':
        left += 1
    if s[i] == 'E':
        right -= 1
    ans[i] = left + right

print(min(ans))

Measured memory_bytes: 15436
abcdef = list(map(int, input().split()))
a, b, c, d, e, f = abcdef[0] * 100, abcdef[1] * 100, abcdef[2], abcdef[3], abcdef[4], abcdef[5]

fa = int(f / a)
fb = int(f / b)
maxc = int(int(f / 100) * e / c)
maxd = int(int(f / 100) * e / d)

res = -1
suger_max = -1
nowden = -1

# 砂糖は水100グラムにEグラム解ける.(max 100)
# a,b,c,dを(i,j,k,l)回入れるとする.i*j < 10^3で k*j < 3000 * 1500くらい…行けるか？
# もう少し工夫要りそう

for i in range(fa + 1):
    for j in range(fb + 1):
        for k in range(maxc + 1):
            for l in range(maxd + 1):
                if i == 0 and j == 0:
                    continue
                wat = a * i + b * j
                sug = c * k + d * l
                if wat + sug > f or sug / wat > e / 100:
                    continue
                else:
                    den = sug / (wat + sug)
                    if (nowden < den):
                        nowden = den
                        res = wat + sug
                        suger_max = sug

print(str(res) + " " + str(suger_max))


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


int main() {
    int n;
    cin >> n;
    vector<ll> h(n,0);
    rep(i,n)cin >> h[i];
    int max_movable=0;
    int m=0;
    rep(i,n-1){
        if(h[i] >= h[i+1]){
            m++;
        }else{
            max_movable = max(m,max_movable);
            m=0;
        }
        if(i == n-2)max_movable = max(m,max_movable);
    }
    cout << max_movable << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

set<ll> div(ll n){ //約数
  set<ll> s;
  REP(i,1,sqrt(n)+1){
    if(n%i==0){
      s.insert(i);
      s.insert(n/i);
    }
  }
  return s;
}

void solve() {
  ll n;
  cin>>n;
  ll ans=0;
  set<ll> s=div(n-1);
  ans+=s.size()-1; //1の場合除く
  set<ll> t=div(n);
  t.erase(1); //無限になるぞおら
  for(ll x:t){
    ll m=n;
    while(m%x==0){
      m/=x;
    }
    if(m%x==1) ans++;
  }
  out(ans);
}

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


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

using namespace std;
typedef long long ll;

int main()
{
    string s, t;
    cin >> s >> t;
    int len = s.length();
    int rot = 0;
    for (int rot = 0; rot < len; rot++)
    {
        bool flag = true;
        for (int i = 0; i < len; i++)
        {
            if (s[i] != t[(i + rot) % len])
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define el '\n'

int main() {
  int n, x;
  cin >> n >> x;
  int cnt = 1, pos = 0;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    pos += val;
    if (pos > x) break;
    else cnt++;
  }
  cout << cnt << el;

  return 0;
}

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

int f (int x) {
    if (x % 10 == 0) return x;
    else return ((x/10)+1)*10;
}

int main() {
    int sum = 0;
    int mini = 11;
    rep(i,5) {
        int x;
        int compa;
        cin >> x;
        sum += f(x);
        if (x % 10 == 0) compa = 10;
        else compa = x % 10;
        mini = min(mini,compa);
    }
    cout << sum - (10 - mini) << endl;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===


const int INF = int(1e9 + 7);


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<Vi> to(N);
	for (int i = 0; i < M; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		to[u].push_back(v);
	}
	int S, T;
	cin >> S >> T;
	--S; --T;

	auto pdist = make_unique<int(*)[3]>(new int[N][3]);
	auto& dist = *pdist;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			dist[i][j] = INF;
		}
	}

	queue<Pii> q;
	q.emplace(S, 0);
	dist[S][0] = 0;
	while (!q.empty()) {
		int v = q.front().first;
		int l = q.front().second;
		q.pop();
		for (const auto& u : to[v]) {
			int nl = (l + 1) % 3;
			if (dist[u][nl] != INF) continue;
			dist[u][nl] = dist[v][l] + 1;
			q.emplace(u, nl);
		}
	}

	int ans = dist[T][0];
	if (ans == INF) ans = -1;
	else ans /= 3;
	cout << ans << endl;
}


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

int main(){
  ll n;
  cin>>n;
  vector<ll> h;
  for(ll i=0; i<n; i++){
    ll x;
    cin>>x;
    h.push_back(x);
  }
  for(int i=n-1; i>0; i--){
    if(h[i]>=h[i-1]){}
    else if(h[i]+1==h[i-1]) h[i-1]--;
    else {
      cout<<"No";
      return 0;
    }
  }
  cout << "Yes";
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"

int main(){
    int n,ans=1,count=0;
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        if(a==ans){
            ans++;
            continue;
        }
        else count++;
    }
    if(ans!=1)cout << count << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
char a[5],b[5];
while(cin>>a>>b,a[0]-'0'||b[0]-'0'){
int h=0,v=0;
//cout<<a[0]<<endl;
rep(i,4){
rep(j,4){
if(i==j&&a[i]==b[j])h++;
else if(a[i]==b[j])v++;
}
}
cout<<h<<" "<<v<<endl;
}
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> super_set;

#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
#define log sdfdsfdsf

const ll DIM = 1E5+7;
const ll MOD = 1e9+7;
const ll M1 = 1e9+7;
const ll INF = 1E17;
const ld eps = 0.00000000000001;
const ld PI = 3.14159265358979323846;
int getInt(int a = 0, int b = INT_MAX){
	static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	return uniform_int_distribution <int> (a, b)(rng);
}


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


    ll n,x,t;
    cin>>n>>x>>t;
    cout<<(n/x+(n%x!=0))*t<<endl;


    return 0;
}


Measured memory_bytes: 3612
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

x,y=map(int,input().split())
while x<=y:
    x*=2
    count+=1
print(count)


Measured memory_bytes: 38256
import sys
l = sys.stdin.readlines ()
del l[0] # Delete number represents the number of detasets.
for line in l:
    data = map (int, line.split (" "))
    data.sort(reverse=True)
    if data[0]**2 == data[1]**2 + data[2]**2:
        print ("YES")
    else: print ("NO")

Measured memory_bytes: 6276
n = int(raw_input())
t = [int(i) for i in raw_input().split()]

miin = 1000000000000000000
for tar in range(-100, 101):
    s = 0
    for e in t:
        s += (tar-e)*(tar-e)
    if s<miin:
        miin = s
print miin


Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    string s;
    cin >> s;
    vector<size_t> east(n + 1, 0);
    vector<size_t> west(n + 1, 0);
    size_t e = 0;
    size_t w = 0;
    for (size_t i = 0; i < n; ++i) {
        if (s[i] == 'E') ++e;
        else ++w;
        east[i + 1] = e;
        west[i + 1] = w;
    }
    size_t num_turn = n;
    for (size_t i = 0; i < n; ++i) {
        size_t turn = west[i] + east[n] - east[i + 1];
        if (turn < num_turn) num_turn = turn;
    }
    cout << num_turn << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 5380