akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define __DEBUG__

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif

const long UNDEFINED = -1e+9;

int search(
  const std::vector< std::map<unsigned, long> > &G, 
  std::vector<long> &x, 
  unsigned src,
  std::vector<bool> &visited
)
{
  visited[src] = true;
  
  for (auto &pair : G[src]) {
    unsigned dst = pair.first;
    long dist = pair.second;
    
    if (x[dst] == UNDEFINED) {
      x[dst] = x[src] + dist;
    } else {
      if (x[dst] != x[src] + dist) { return -1; }
    }
    
    if (!visited[dst]) {
      int ret = search(G, x, dst, visited);
      if (ret < 0) { return -1; }
    }
  }
  
  return 0;
}

int main()
{
  unsigned N, M;
  std::cin >> N >> M;
  
  std::vector< std::map<unsigned, long> > G(N);
  for (unsigned n = 0; n < N; ++n) {
    G[n] = std::map<unsigned, long>();
  }
  
  for (unsigned m = 0; m < M; ++m) {
    unsigned L, R; long D;
    std::cin >> L >> R >> D;
    
    G[L - 1].emplace(R - 1, +D);
    G[R - 1].emplace(L - 1, -D);
  }
  
  std::vector<long> x(N, UNDEFINED);
  
  std::vector<bool> visited(N, false);
  
  for (unsigned n = 0; n < N; ++n) {
    if (x[n] == UNDEFINED) { x[n] = 0; }
    
    int ret = search(G, x, n, visited);
    
    if (ret < 0) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  
  std::cout << "Yes" << std::endl;
  
  return 0;
}

Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n%10==0) cout<<"10"<<endl;
  else{
    int dig,sum=0;
    while(n){
      dig=n%10;
      sum+=dig;
      n=n/10;
    }
    cout<<sum<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, n)
  {
    cin >> p[i];
  }
  for (int i = 0; i <= x; i++)
  {
    for (int j = -1, k = 0; k < 2; j *= (-1), k++)
    {
      int a = x + i * j;
      bool exists = find(begin(p), end(p), a) != end(p);
      if (!exists)
      {
        cout << a << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3536
from sys import stdin
input = stdin.readline
s = input().rstrip()
ans = []
for i in s:
	#print(ans)
	if i == "0":
			ans.append("0")
	elif i == "1":
			ans.append("1")
	else:
		if not ans == []:
			ans.pop(-1)
print("".join(ans))

Measured memory_bytes: 3060
from collections import deque

n = int(input())
Q = deque([])
for i in range(n):
    command = input()
    if command[0] == 'i':
        Q.appendleft(command[7:])
    elif command[6] == 'F':
        Q.popleft()
    elif command[6] == 'L':
        Q.pop()
    else:
        if Q.count(command[7:]) == 0: continue
        Q.remove(command[7:])

print(' '.join(map(str, Q)))




Measured memory_bytes: 69628
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, W;
	ll v, w;
	cin >> num >> W;
	vector<ll> dp(W + 1, 0);
	rep(i, num) {
		cin >> w >> v;
		for (int j = W - w; j >= 0; j--)
			chmax(dp[j + w], dp[j] + v);
	}
	cout << dp[W] << "\n";
	return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if((a == b && b != c) || (b == c && c != a) || (c == a && a != b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;

int main(int argc, char *argv[])
{
	long long s;
	cin >> s;
	long long x1 = 0, y1 = 0, x2, y2, x3, y3;
	long long a1 = (long long) sqrt(s), a2 = a1;
	if (a1 * a2 < s) a1++;
	if (a1 * a2 < s) a2++;
	x2 = x1 + a1;
	y3 = y1 + a2;
	long long t = a1 * a2 - s;
	if (t == 0) {
		y2 = y1;
		x3 = x1;
	} else {
		long long d = sqrt(t);
		for ( ; d > 0; d--) if (t % d == 0) break;
		y2 = y1 + d;
		x3 = x1 + (t / d);
	}
	cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << endl;

	return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
ax, ay = abs(x), abs(y)
if x == 0 and y > 0:
  print(ay)
elif x > 0 and y == 0:
  print(x + 1)
elif x <= y and x > 0:
  print(y - x)
elif x > y and y > 0:
  print(2 + ax - ay)
elif x <= y and y <= 0:
  print(ax - ay)
elif x > y and x < 0:
  print(2 + ay - ax)
elif x == 0 and y < 0:
  print(ay + 1)
elif x * y < 0:
  print(abs(ax - ay) + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 int main(){
int a,b,c;
   vector<int>vec(3);
   for(int i=0;i<3;i++){
   cin>>vec.at(i);
     }
   sort(vec.begin(),vec.end());
   cout<<vec.at(0)*vec.at(1)/2<<endl;
   return 0;
   }


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
pair<long long, long long>x[1 << 19];
long long bit[2][1 << 19], n, g[1 << 19];
void add(long long q, long long a, long long x) {
	while (a <= 400000) {
		bit[q][a] += x;
		a += a&-a;
	}
}
long long sum(long long q, long long a) {
	long long s = 0;
	while (a >= 1) {
		s += bit[q][a];
		a -= a&-a;
	}
	return s;
}
bool solve(long long g, long long p) {
	if (sum(1, g) == 0)return true;
	long long K = (sum(0, g) - 1) / sum(1, g);
	if (K >= p)return false;
	return true;
}
int main() {
	cin >> n; vector<pair<long long, long long> >vec;
	for (long long i = 0; i < n; i++) {
		cin >> x[i].second >> x[i].first;
	}
	sort(x, x + n);long long maxn = 0;
	for (int i = 0; i < n; i++) {
		vec.push_back(make_pair(x[i].second, i));
	}
	sort(vec.begin(), vec.end());
	for (int i = 0; i < n; i++) {
		g[vec[i].second] = i + 1;
	}
	for (long long i = n - 1; i >= 0; i--) {
		add(0, g[i], x[i].second);
		add(1, g[i], 1);
		long long L = 1, R = 320000, M, C = 0;
		while (true) {
			M = (L + R) / 2;
			bool V1 = solve(M - 1, x[i].first);
			bool V2 = solve(M, x[i].first);
			if (V1 == true && V2 == false) {
				C = sum(1, M - 1); break;
			}
			if (V1 == true && V2 == true)L = M;
			if (V1 == false && V2 == false)R = M;
			if (M >= 310000 && V1 == true && V2 == true) {
				C = sum(1, 310000); break;
			}
		}
		maxn = max(maxn, C);
	}
	cout << maxn << endl;
	return 0;
}

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

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

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

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

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

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

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

    ($next:expr, 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")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        lt: [usize; 3],
        l: [usize; n],
    }

    let mut ans: usize = 1 << 50;

    'outer: for i in 0..(1 << (n * 2)) {
        let mut v = vec![vec![]; 3];
        for j in 0..n {
            let mask = 3;
            let group = (i >> (j * 2)) & mask;
            if group < 3 {
                v[group].push(l[j]);
            }
        }
        let mut t = 0;
        for j in 0..v.len() {
            if v[j].len() == 0 {
                continue 'outer;
            }
            t += 10 * (v[j].len() - 1);
            let lsum = v[j].iter().sum::<usize>();
            t += if lsum > lt[j] {
                lsum - lt[j]
            } else {
                lt[j] - lsum
            };
        }

        ans = min(ans, t);
    }

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


Measured memory_bytes: 4352
#include<iostream>
#include<deque>
#include<cstring>
using namespace std;

const int N = 1e5 + 5;
int k, dist[N];
deque<int>dq;

int main() {
	int n, x, t;
	cin >> k;
	memset(dist, 99, sizeof(dist));
	dq.push_front(1);
	dist[1] = 1;
	while (!dq.empty()) {
		x = dq.front(); dq.pop_front();
		t = (x * 10) % k;
		if (dist[t] > dist[x]) {
			dist[t] = dist[x];
			dq.push_front(t);
		}
		t = (x + 1) % k;
		if (dist[t] > dist[x] + 1) {
			dist[t] = dist[x] + 1;
			dq.push_back(t);
		}
	}
	cout << dist[0] << endl;

	return 0;
}

Measured memory_bytes: 896
#pragma GCC optimize("O3")
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void fastin(int &num) {
  int c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

void fastout(int64_t &n) {
  int64_t N = n, rev, count = 0;
  rev = N;
  if (N == 0) { 
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}

int main(){
    int N; fastin(N);
    vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        fastin(v[i]); v[i] -= (i + 1);
    }
    sort(v.begin(), v.end());
    
    int b = v[N / 2];

    int64_t answer = 0;
    for (int i = 0; i < N; ++i) {
        answer += abs(v[i] - b);
    }
    
    fastout(answer);

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if ((a % 2 == 0) && (a % 3 != 0) && (a % 5 != 0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define debugaar(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007ll
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

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

int width,height;
int m,n;

int main(){
    int i,j,k;
    int x,y,a,b;
    
    cin >> x >> y;
    
    int signx,signy;
    signx = 0<x ? 1 : x<0 ? -1 : 0;
    signy = 0<y ? 1 : y<0 ? -1 : 0;
    
    if (signx == signy){
        if (abs(x)<abs(y)){
            cout << (abs(y)-abs(x) + (signx==-1)*2 ) << endl;
        }else{
            cout << (abs(x)-abs(y) + (signx==1)*2 ) << endl;
        }
    }else if (x==0){
        cout << (abs(y) + (signy==-1)) << endl;
    }else if (y==0){
        cout << (abs(x) + (signx==1)) << endl;
    }
    else{
        cout << (abs(abs(y)-abs(x)) + 1) << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int N,M;
int h[1501],w[1501];
int e;
int ans=0;

int x[1500000];

int main(){
	while(1){
		cin>>N;
		cin>>M;
		if(N==0&&M==0)break;
		for(int i=0; i<1500000; i++){
			x[i]=0;
		}
		for(int i=1; i<=N; i++){
			cin>>h[i];
			h[i]+=h[i-1];
		}
		for(int i=1; i<=M; i++){
			cin>>w[i];
			w[i]+=w[i-1];
			x[w[i]]=1;
		}
		h[0]=0;
		w[0]=0;
		ans=0;
		for(int i=0; i<=N; i++){
			for(int j=0; j<=M; j++){
				for(int k=i+1; k<=N; k++){
					int edgh=h[k]-h[i];
					if(x[w[j]+edgh]){
						// cout<<"h["<<j<<"]:"<<h[j]<<" edgh:"<<edgh<<endl;
						ans++;
					}
					// for(int l=j+1; l<=M; l++){
					// 	if(edgh==w[l]-w[j]){
					// 		cout<<"h["<<j<<"]:"<<h[j]<<" edgh:"<<edgh<<endl;
					// 		ans++;
					// 	}
					// 	if(edgh<=w[l]-w[j])break;
					// }
				}
			}
		}
		cout<<ans<<endl;

		// for(int i=0; i<1500000; i++){
		// 	if(y[i])cout<<"i "<<i<<endl;
		// }
		// cout<<endl;
	}

}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int M = 51;
int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,A;cin >> N >> A;
  vector<int> v(N);
  rep(i,N)cin >> v[i];

  //dp[i][j+M*M*k];
  ll dp[2][M*M*M];
  ll *prev,*next;
  prev = dp[0];
  next = dp[1];
  rep(i,M*M*M+1){
    prev[i] = 0;
    next[i] = 0;
  }

  prev[0] = 1;
  next[0] = 1;
  rep(i,N){
    repp(k,1,i+2){
      rep(j,M*M){
        next[j+M*M*k] = prev[j+M*M*k];
        if(j-v[i]<0)continue;
        next[j+M*M*k] += prev[j-v[i] + M*M*(k-1)];
      }
    }
    swap(prev,next);
  }
  swap(prev,next);
  ll ans = 0;
  repp(i,1,N+1) ans += next[A*i+M*M*i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll two[200020];

ll mod_pow(ll x,ll n){
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  two[0]=1;
  for(int i=1;i<=N;i++) two[i]=two[i-1]*2%MOD;

  sort(A.rbegin(),A.rend());
  ll ans=0;
  for(ll i=0;i<N;i++){
    ll res=A[i]*two[N]%MOD;
    ll coef=0;
    if(i>0) coef=i*(two[i-1])%MOD;
    coef=(coef+two[i])%MOD;

    res=res*two[N-(i+1)]%MOD;
    res=res*coef%MOD;
    ans=(ans+res)%MOD;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>


using namespace std;

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


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int solve(int a, int b, int c){
  if((c - b) % 2 != 0 && (c - a) % 2 != 0)
    return (c - b) / 2 + (c - a) / 2 + 1;
  else if((c - b) % 2 == 0 && (c - a) % 2 == 0)
    return (c - b) / 2 + (c - a) / 2;
  else
    return (c - b) / 2 + (c - a) / 2 + 2;
}
int main(void)
{
  int a[3];
  std::cin >> a[0] >> a[1] >> a[2];
  std::sort(a, a + 3);
  std::cout << solve(a[0], a[1], a[2]) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n,d;
	cin >> n >> d;
	cout << (n+d*2)/(d*2+1) << endl;




}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int n;
	int h[100000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	int j[100000];
	int f = 0;
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			if (h[i] <= h[i + 1]) {
				j[i] = h[i]-1;
			}
		}
		else if(i!= n-1) {
			if (h[i] >= j[i - 1] && h[i] <= h[i + 1]) {
				if (h[i] - 1 >= j[i - 1]) {
					j[i] = h[i]-1;
				}
				else {
					j[i] = h[i] ;
				}
			}
			else if (h[i] >= j[i - 1] && h[i] > h[i + 1] && h[i] - 1 >= j[i - 1] && h[i]
				- 1 <= h[i + 1]) {
				j[i] = h[i] - 1;
			}
			else{
				f = -1;
				break;
			}
		}
		else {
			if (h[i]>= j[i - 1]) {
			}
			else {
				f = -1;
				break;
			}
		}
	}

	if (f == -1) {
		printf("No");
	}
	else {
		printf("Yes");
	}
	return 0;
}



Measured memory_bytes: 896
#include<stdio.h>

int main(void){
        int n, max=-1e6, min=1e6;
        long sum = 0;
        scanf("%d", &n);
        for(int i=0; i<n; i++){
                int tmp;
                scanf("%d", &tmp);
                max = tmp>max? tmp:max;
                min = tmp<min? tmp:min;
                sum += tmp;
        }
        printf("%d %d %ld\n", min, max, sum);
        return 0;
}


Measured memory_bytes: 2120
from collections import defaultdict

n, m = [int(i) for i in input().split()]
A = [ [int(j)-1 for j in input().split()] for i in range(m)]
G = defaultdict(set)
for i, j in A:
    G[i].add(j)
    G[j].add(i)

visited = [False for i in range(n)]
ans = [-1 for i in range(n)]
def bfs(start):
    Q = []
    visited[start] = True
    Q.append(start)
    while Q:
        v = Q.pop(0)
        for w in G[v]:
            if not visited[w]:
                ans[w] = v
                Q.append(w)
                visited[w] = True
bfs(0)
terminate_flag = False
for i in range(1,n):
    if ans[i] == -1:
        print("No")
        terminate_flag = True
        break
if not terminate_flag:
    print("Yes")
    for i in range(1,n):
        print(ans[i]+1)

Measured memory_bytes: 87536
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int [] a = new int[n];
        for (int x = 0; x < n; x++){
            a[x] = scan.nextInt();
        }
        for(int x = n -1; x > -1; x--){
            if(x == 0){
                System.out.println(a[x]);
            }
            else {
                System.out.print(a[x] + " ");
            }
        }
    }
}


Measured memory_bytes: 26488
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    dams = list(map(int, input().split()))
    S = sum(dams)
    res = [0]*N
    res[0] = S - 2*sum(dams[1:N:2])
    for i in range(1,N):
        res[i] = 2*dams[i-1]-res[i-1]
    print(*res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 23132
#include <cstdio>
#include <iostream>
using namespace std;
#define int long long
#define N 100100
inline int read(){
    char ch=getchar(); int x=0,f=1;
    for (;ch>'9'||ch<'0';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}
int n,K,x[N];
signed main(){
    n=read(),K=read(); int Le=0;
    for (int i=1;i<=n;i++) {
        x[i]=read();
        if (x[i]<0) Le=i;
    }
    if (Le==0){
        printf("%lld\n",x[K]);
        return 0;
    }
    int ans=1e18;
    if (Le+K<=n) ans=x[Le+K];
    for (int i=1;i<=K;i++){
        if (Le<i) continue;
        if (Le+K-i<0) continue;
        if (Le+K-i>n) continue;        
        int l=-x[Le-i+1];
        if (i==K){ans=min(ans,l); continue;}
        int r=x[Le+K-i];
        ans=min(ans,min(l*2+r,l+r*2));
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
using System;
 
class Program
{
    static void Main()
    {
        string[] ab = Console.ReadLine().Split(' ');
        int a = int.Parse(ab[0]);
        int b = int.Parse(ab[1]);
        string output = (a * b % 2 == 0) ? "Even" : "Odd";
        Console.WriteLine(output);
    }
}

Measured memory_bytes: 11092
import sys
class Node:
    def __init__(self,a:int):
        self.val = a
        self.parent = None
        self.right = None
        self.left = None

class Heap:
    def __init__(self):
        self.size = None
        self.node = None

    def push(self, a:int):
        c = Node(a)
        if self.size is None:
            self.size = 1
            self.node = c
        else:
            self.size += 1
            n = self.size
            l = []
            b = self.node
            c = Node(a)
            while n != 1:
                l.append(n % 2)
                n //= 2
            for i in range(len(l) - 1):
                if l[len(l) - 1 - i] == 1:
                    b = b.right
                else:
                    b = b.left
            if l[0] == 1:
                b.right = c
                c.parent = b
            else:
                b.left = c
                c.parent = b
            while c.parent is not None and c.parent.val < c.val:
                d = c.val
                c.val = c.parent.val
                c.parent.val = d
                c = c.parent

    def pop(self):
        aval = self.node.val
        a = self.node
        n = self.size
        l = []
        b = self.node
        while n != 1:
            l.append(n % 2)
            n //= 2
        for i in range(len(l)):
            if l[len(l) - 1 - i] == 1:
                b = b.right
                if len(l) - 1 - i == 0:
                    b.parent.right = None
            else:
                b = b.left
                if len(l) - 1 - i == 0:
                    b.parent.left = None
        self.size -= 1
        a.val = b.val

        while (a.right is not None and a.val < a.right.val) or (a.left is not None and a.val < a.left.val):
            if a.right is None and a.left is not None:
                c = a.val
                a.val = a.left.val
                a.left.val = c
                a = a.left
            elif a.left.val > a.right.val:
                c = a.val
                a.val = a.left.val
                a.left.val = c
                a = a.left
            else:
                c = a.val
                a.val = a.right.val
                a.right.val = c
                a = a.right
        return aval
def main(): 
    x, y, A, B, C = map(int, input().split())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    r = list(map(int, input().split()))
    pq = Heap()
    p.sort()
    q.sort()
    for i in range(x):
        pq.push(p[len(p) - 1 - i])
    for i in range(y):
        pq.push(q[len(q) - 1 - i])
    for i in range(len(r)):
        pq.push(r[i])
    ans = 0
    for i in range(x + y):
        ans += pq.pop()
    print(ans)

main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef pair<ll, ll> PLL;

#define REP(i, j) for(int i=0;i<j;i++)
#define FOR(i, b, e) for(int i=b; i<=e; i++)
#define FORD(i, b, e) for(int i=b; i>=e; i--)
#define SIZE(x) ((int)x.size())
#define LAST(x) (x[SIZE(x)-1])
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'

int n, a, b, c;
ll dp[100005][3];
VI nums;

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

    cin >> n;

    REP(i, n){
        cin >> a >> b >> c;
        dp[i+1][0] = max(a+dp[i][1], a+dp[i][2]);
        dp[i+1][1] = max(b+dp[i][0], b+dp[i][2]);
        dp[i+1][2] = max(c+dp[i][1], c+dp[i][0]);
    }

    cout << max({dp[n][0], dp[n][1], dp[n][2]});

    return 0;
}


Measured memory_bytes: 2560
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

struct Node{
    vector<Node*> dests;
    bool flag;
    void add(Node* n){
        dests.push_back(n);
    }
    void add2(Node* n){
        add(n);
        n->add(this);
    }
    template <class F>
    int dfs(F clear){
        int ret = 0;
        for(Node* d : dests){
            clear();
            d -> dfs2(this);
            if(!flag){
                ret++;
            }
        }
        return ret;
    }
    void dfs2(Node* from = nullptr){
        if(flag){ return; }
        flag = true;
        for(Node* d : dests){
            if(d == from){ continue; }
            d -> dfs2(this);
        }
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<Node> nodes(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        nodes[a].add2(&nodes[b]);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += nodes[i].dfs([&](){
            for(int j = 0; j < n; j++){
                nodes[j].flag = false;
            }
        });
    }
    cout << ans / 2 << '\n';
}


Measured memory_bytes: 888
a, b, k = map(int, input().split())

A = []
for i in range(a, min(a + k, b + 1)):
    A.append(i)

for i in range(b, max(b - k, a - 1), -1):
    A.append(i)

A = sorted(list(set(A)))
for a in A:
    print(a)

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

int getDayNum(int month){
  switch(month){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
      return 31;
      break;
    case 4:
    case 6:
    case 9:
    case 11:
      return 30;
      break;
    case 2:
      return 28;
      break;
    default:
      return 0;
  }
}

int main(void){

  int a,b;
  cin >> a >> b;
  int count = 0;
  
  for(int i=1;i<=a;i++){
    int c = i==a ? b : getDayNum(i);
    for(int j=1;j<=c;j++){
      if(i==j)
        count ++;
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
# A,Double Helix
# AtCoder 星には四種類の塩基 A, C, G, T が存在し、A と T、C と G がそれぞれ対になります。
# 文字 bが入力されます。これは A, C, G, T のいずれかです。塩基bと対になる塩基を表す文字を出力するプログラムを書いてください。

# bは文字 A, C, G, T のいずれかである。

b = input()

# 塩基bと対になる塩基を表す文字を出力せよ。

if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "C":
    print("G")
elif b == "G":
    print("C")

Measured memory_bytes: 8980
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

S[K - 1] = S[K - 1].lower()

print("".join(S))




Measured memory_bytes: 7880
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import defaultdict
from bisect import *
mod = 10**9+7

N = int(input())
A = list(map(int, input().split()))
cnt = [0]*3
ans = 1
for i, x in enumerate(A):
    T = len([c for c in cnt if c == x])
    for i, c in enumerate(cnt):
        if c == x:
            cnt[i] += 1
            break
    ans = ans * T % mod
print(ans)


Measured memory_bytes: 14348
import sys
import math
a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())
x=a*p
y=b
if(c<p):
    ryo=p-c
    y=y+(ryo*d)
if(x<=y):
    chap=x
else:
    chap=y
print(chap)


Measured memory_bytes: 5652
//Love and Freedom.
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define inf 20021225
#define N 500010
#define mdn 998244353
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
	return f*s;
}
int fac[N],inv[N];
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=1ll*ans*bs%mdn;
		bs=1ll*bs*bs%mdn; mi>>=1;
	}
	return ans;
}
void init()
{
	fac[0]=inv[0]=1;
	for(int i=1;i<N;i++)	fac[i]=1ll*fac[i-1]*i%mdn;
	inv[N-1]=ksm(fac[N-1],mdn-2);
	for(int i=N-1;~i;i--)	inv[i-1]=1ll*inv[i]*i%mdn;
}
int C(int n,int m)
{
	return n<m?0:1ll*fac[n]*inv[m]%mdn*inv[n-m]%mdn;
}
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
void dpu(int &x,int y){x-=x-y<0?y-mdn:y;}
int F(int n,int m,int i){return 1ll*C(n,i)*C(m,i)%mdn*fac[i]%mdn*ksm(m+1,n-i)%mdn*ksm(n+1,m-i)%mdn;}
int main()
{
	int n=read(),m=read(); init(); int ans=0;
	for(int i=0;i<=min(n,m);i++)
		if(i&1)	dpu(ans,F(n,m,i));
		else	upd(ans,F(n,m,i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	vector<int> A(N);
	vector<int> ans(N,0);
	int nax = 0;
	rep(i,N){
		cin>>A[i];
		nax = max(nax, A[i]);
	}
	for(int bit = 0; pow(2,bit-1)<nax; ++bit){
		int cnt = 0;
		vector<bool> is(N,false);
		rep(i,N){
			if(A[i] & (1<<bit)){
				cnt++;
				is[i] = true;
			}
		}
		if(cnt%2 == 0){
			rep(i,N){
				if(is[i]){
					ans[i] += pow(2,bit);
				}
			}
		}else{
			rep(i,N){
				if(!is[i]){
					ans[i] += pow(2,bit);
				}
			}
		}
	}
	show(ans);
	return 0;
}

Measured memory_bytes: 4928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;

int main() {
  string S; cin >> S;
  ll ans = 0;
  string T = "";
  rep(i, 0, S.size()) {
    if(S[i] == 'A') T += 'A';
    else {
      if(i != S.size()-1 && S[i] == 'B' && S[i+1] == 'C') {
        T += 'D';
        i++;
      }
      else T += S[i];
    }
  }
  int N = T.size();
  ll cnt = 0;
  rep(i, 0, N) {
    if(T[i] == 'A') cnt++;
    else if(T[i] == 'D') ans += cnt;
    else cnt = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<ctime>
using namespace std;

typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int d[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

int main(){
    char a;
    while(cin>>a){
        getchar();
        if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
            cout<<"vowel"<<endl;
        else
            cout<<"consonant"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include <stdio.h>

int main(void){
	int i,j;
	int next;
	int end = 0;
	char line[4];
	char board[3][3];
	while(1){
		next = 0;
		for(i = 0; i < 3; i++){
			scanf("%s",line);
			if(line[0] == '0'){
				end = 1;
				break;
			}
			board[0][i] = line[0];
			board[1][i] = line[1];
			board[2][i] = line[2];
		 }
		if(end){break;}
		for(i = 0; i < 3; i++){
			if(
				board[0][i] == board[1][i] &&
				board[1][i] == board[2][i] &&
				board[2][i] != '+'
			){
				printf("%c\n",board[0][i]);
				next = 1;
				break;
			}
		}
		if(next){continue;}
		for(i = 0; i < 3; i++){
			if(
				board[i][0] == board[i][1] &&
				board[i][1] == board[i][2] &&
				board[i][2] != '+'
			){
				printf("%c\n",board[i][0]);
				next = 1;
				break;
			}
		}
		if(next){continue;}
		if(	
			(
				board[0][0] == board[1][1] && board[1][1] == board[2][2] ||
				board[2][0] == board[1][1] && board[1][1] == board[0][2] 
			)&& board[1][1] != '+'
		){
				printf("%c\n",board[1][1]);
				next = 1;
		}
		if(next){continue;}
		puts("NA");
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;

long long int dp[50+1][50+1][50*50+1];

int main(void) {

  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  for(int i=0; i<n; i++) cin >> x[i];

  dp[0][0][0] = 1;
  for(int j=0; j<n; j++){
    for(int k=0; k<=j; k++){
      for(int s=0; s<50*n+1; s++){
        if( dp[j][k][s] != 0 ){
          dp[j+1][k][s] += dp[j][k][s];
          dp[j+1][k+1][s + x[j]] += dp[j][k][s];
        }
      }
    }
  }
  long long int ans = 0;
  for(int i=1; i<=n; i++) ans += dp[n][i][a*i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 48128
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

ll n, l, ch[100009][2], cnt = 1;
char s[100009];

ll dfs(ll x, ll d) {
    return x ? dfs(ch[x][0], d - 1) ^ dfs(ch[x][1], d - 1) : d & -d;
}

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

    cin >> n >> l;
    rep(_, n) {
        cin >> s;
        for(int i = 0, p = 1; s[i]; i++) {
            int c = s[i] - '0';
            if(!ch[p][c]) ch[p][c] = ++cnt;
            p = ch[p][c];
        }
    }
    cout << (dfs(1, l + 1) ? "Alice" : "Bob") << "\n";

    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	if(a<=8&&b<=8){
		System.out.println("Yay!");
	}else{
		System.out.println(":(");
	}
	}}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int a, b, c;
    cin >> a >> b >> c;
  
  	int result = a + b + c;
  	if (result > 21) {
      cout << "bust" << endl;
    } else {
      cout << "win" << endl;
    }
    return 0;
}

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

int main() {
  int A,B,C;
  cin >> A>>B>>C;

  if (A<=C && C<=B) {
    cout << "Yes" << endl;
  }
  else if (B<=C && C<=A) {
    cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}


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

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)
#define SUMV(v)		(accumulate(v.begin(),v.end(),0.0))

#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;

//uint dp[MAX];

int bit(int a){
	if(a<=0)return 0;
	int n = 0;
	while(a){
		if(a&1) return n;
		n++;
		a/=2;
	}
	return n;
}

int main(){
	int N;cin>>N;
	vector<int> A(N);
	REP(i,N)cin>>A[i];

	int ans = 0;
	REP(i,N){
		ans += bit(A[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.Char
import Control.Monad

count :: Int -> Int
count n = loop n 0
    where
        loop n i
            | n `rem` 2 == 0 = loop (n `quot` 2) (i + 1)
            | otherwise = i 

classify :: VUM.IOVector Int -> Int -> IO ()
classify vec n
    | c == 0 = VUM.modify vec (+1) 0
    | c == 1 = VUM.modify vec (+1) 1
    | c >= 2 = VUM.modify vec (+1) 2
    | otherwise = return ()
    where
        c = count n

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    res <- VUM.replicate 3 0
    forM_ [0..n-1] $ \i -> classify res (xs VU.! i)
    r <- VUM.read res 0
    s <- VUM.read res 1
    t <- VUM.read res 2
    
    if (s == 0)
        then putStrLn $ if t >= (r-1) then "Yes" else "No"
        else putStrLn $ if t >= r then "Yes" else "No"

Measured memory_bytes: 3836
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#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;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll N; cin >> N;
    if (N == 2) {
        cout << 1 << endl; return 0;
    }
    vl facs;
    ll ans = 2;
    for (ll i = 2; i <= 1000000; i++) {
        if (i*i > N) break;
        if (N % i == 0) {
            facs.pb(i);
            if (N / i > i) facs.pb(N/i);
        } else if ((N-1)%i == 0) {
            ans++;
            if ((N-1)/i > i) ans++;
        }
    }
    F0R(i, sz(facs)) {
        ll cur = N;
        while (cur % facs[i] == 0) cur /= facs[i];
        cur %= facs[i];
        if (cur == 1) ans++;
    }
    cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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


int n,resp=0;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
   cin>>n;
   resp+=1000*(n/500);
   n%=500;
   //cout<<n<<"\n";
   resp+=(n/5)*5;
   cout<<resp;




    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
dic = dict()
li = list()
for i in range(m):
    x1, y1 = input().split()
    if x1 not in dic.keys():
        dic[x1] = [0,0]
    if dic[x1][0] == 0:
        if y1 == "AC":
            dic[x1][0] = 1
        else:
            dic[x1][1] += 1
ac = 0
wa = 0
for key in dic.keys():
    if dic[key][0] == 1:
        ac += 1
        wa += dic[key][1]
print(ac, wa)

Measured memory_bytes: 25308
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(){

	int n;
	int q;
	int ans = 0;
	int tmp;
	bool included;

	cin >> n;

	int l[n];
	for (int i=0; i<n; i++){
		cin >> tmp;
		l[i] = tmp;
	}

	cin >> q;

	for (int i=0; i<q; i++){
		cin >> tmp;
		included = false;
		for (int j=0; j<n; j++){
			if (l[j] == tmp){
				included = true;
				break;
			}
		}
		if (included){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
    int X, Y, Z, cnt = 0;
    int K, S;
    cin >> K >> S;
    for (X = 0; X <= K; X++) {
        for (Y = 0; Y <= K; Y++) {
            Z = S - X - Y;
            if (0<= Z && Z <= K) {
                cnt += 1;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> s(n+1);

    rep(i,n){
        s[i]=0;
    }
    rep(i,n){
        cin >> a[i];
        s[a[i]]++;
        /*for(int j=0;j<n;j++){
        if(j==a[i])
        s[j]++;
        }*/  
    }
    rep(i,n+1)
    cout << s[i] << endl;
    return 0;
}

Measured memory_bytes: 6412
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 n, m;
P p[101010];

int main(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		int a,b;
		cin >> a >> b;
		p[i] = P(a, b);
	}
	sort(p, p+n);
	
	i64 ans = 0;
	for(int i = 0; i < n; i++){
		ans += p[i].first * min(p[i].second,m);
		m -= p[i].second;
		if(m <= 0) break;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = size(s);
    int ans = 0;
    rep(i, n/2) {
        if(s[i] != s[n-1-i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n;
    cin >> n;
    
    int an=LLONG_MAX;
    for(int i=1;i<=(int)sqrt(n);i++) {
        if(n%i==0) {
        int x = n/i;
        int t = (i-1)+(x-1);
        if(t<an) {
           // cout << i << " " << x << endl;
        an=t;
        }
        }
        
    }
    
    cout << an;
    
	return 0;
    
}

Measured memory_bytes: 8832