akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n;
  cin >> n;
  vector<pii> a(n);
  rep (i, n) {
    cin >> a[i].first;
    a[i].second = i;
  }

  sort(all(a));
  //DEBUG_VEC(a);
  rep (i, n) {
    cout << a[i].second + 1 << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1664
marks = ["S","H","C","D"]
numbers = range(1, 14)
cards = [(m, str(n)) for m in marks for n in numbers]

n = int(input())
for i in range(n):
    c = tuple(input().split())
    if c in cards:
        cards.remove(c)
for j in cards:
    print("{} {}".format(j[0], j[1]))


Measured memory_bytes: 5604
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
static const int kMaxVertices = 10000;
static const int kInfinity = 100010;
using namespace std;

void Dijkstra(int n, vector<pair<int, int> > Adjacency_list[], int first_vertex){
	bool has_not_been_added[kMaxVertices];
	int distance[kMaxVertices];
	for (int i = 0; i < n; ++i)	{
		has_not_been_added[i] = true;
		distance[i] = kInfinity;
	}
	distance[first_vertex] = 0;

	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > PQ;
	PQ.push(make_pair(0, first_vertex));

	while(!PQ.empty()){
		pair<int, int> f = PQ.top(); PQ.pop();
		int u = f.second;
		has_not_been_added[u] = false;
		if (distance[u] < f.first) continue;
		for(vector<pair<int, int> >::iterator it = Adjacency_list[u].begin(); it != Adjacency_list[u].end(); it++){
			int v = (*it).second;
			if(has_not_been_added[v] && distance[u] + (*it).first < distance[v]){
				distance[v] = distance[u] + (*it).first;
				PQ.push(make_pair(distance[v], v));
			}
		}
	}
	for (int i = 0;i < n;++i)
		printf("%d %d\n", i, distance[i]);
}

int main(){
	int number_of_vertices;
	scanf("%d", &number_of_vertices);
	vector<pair<int, int> > Adjacency_list[number_of_vertices];
	for (int vertex_from_i = 0; vertex_from_i < number_of_vertices; ++vertex_from_i)	{
		int vertex_from_id, degree_out;
		scanf("%d %d", &vertex_from_id, &degree_out);
		for (int vertex_to_i = 0; vertex_to_i < degree_out; ++vertex_to_i){
			int vertex_to_id, cost_of_route;
			scanf("%d %d", &vertex_to_id, &cost_of_route);
			Adjacency_list[vertex_from_id].push_back(make_pair(cost_of_route, vertex_to_id));
		}
	}
	Dijkstra(number_of_vertices, Adjacency_list, 0);
	return 0;
}

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

int main() {
  int a[5], k;
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  cin >> k;
  if (a[4] - a[0] > k) {
    puts(":(");
  } else {
    puts("Yay!");
  }
  return 0;
}


Measured memory_bytes: 3648
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, k, c;
		cin >> n >> k >> c;
		if (n < 0) return 0;
		string s;
		cin >> s;
		++c;
		vector<int> fdp(n + 2), rdp(n + 2), mi(n + 2), lp(n + 2);
		for (int i = 0; i < n; ++i) {
			int w = s[i] == 'o';
			if (i >= c) {
				w += fdp[i - c];
			}
			if (i > 0) {
				w = max(w, fdp[i - 1]);
			}
			fdp[i] = w;
			if (i > 0) {
				mi[i] = mi[i - 1];
				if (fdp[i - 1] < fdp[i]) {
					mi[i] = i;
				}
			}
		}
		int last = n;
		lp[n] = last;
		for (int i = n - 1; i >= 0; --i) {
			lp[i] = last;
			int w = s[i] == 'o';
			if (w) last = i;
			if (i + c < n) {
				w += rdp[i + c];
			}
			if (i < n - 1) {
				w = max(w, rdp[i + 1]);
			}
			rdp[i] = w;
		}
		for (int i = 0; i < n; ++i) {
			if (s[i] != 'o') {
				continue;
			}
			if (!i) {
				int wd = rdp[i + 1];
				if (wd < k) {
					cout << i + 1 << endl;
				}
			} else {
				int pi = mi[i - 1];
				int wd = fdp[pi];
				int ni = min(n, max(pi + c, i + 1));
				wd += rdp[ni];
				if (wd < k) {
					cout << i + 1 << endl;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4996
#include<bits/stdc++.h> 
// #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
// #define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
using namespace std;

int32_t main(){
     #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout); 
    #endif
    string s,t;
    cin>>s>>t;
    int l1=s.length(),l2=t.length();
    int dp[l1+1][l2+1];
    for(int i=0;i<=l1;i++)
    {
        for(int j=0;j<=l2;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }




    string ans="";
    int i=l1,j=l2;
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
cout<<ans<<endl;
}

Measured memory_bytes: 73968
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] ans = new int[n];
        for(int i = 0; i < m; i++){
            int b1 = sc.nextInt()-1;
            int b2 = sc.nextInt()-1;
            ans[b1]++;
            ans[b2]++;
        }
        for(int a : ans){
            System.out.println(a);
        }
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> p;
typedef vector<p> vp;
int n;
priority_queue<p,vp,greater<p> >  que;

int main(int argc,char const* argv[])
{
  cin >> n;
  vp x(n);
  vi sav(n);
  for(int i=0;i<n;i++)
    {
      cin >> x[i].first;
      x[i].first*=2;
      sav[i]=x[i].first;
      //x[i].second=i;
    }
  sort(x.begin(),x.end());
  int kijun=(x[n/2-1].first+x[n/2].first)/2;
  for(int i=0;i<n;i++)
    {
      if(sav[i]<=kijun)
	{
	  cout << x[n/2].first/2 << endl;
	}
      else
	{
	  cout << x[n/2-1].first/2 << endl;
	}
    }
  return 0;
}


Measured memory_bytes: 4480
import sys
input=sys.stdin.readline


def solve():
    N, K = map(int, input().split())
    l = [tuple(map(int, input().split())) for _ in range(N)]
    candidates = [K]
    b = 0
    for i in range(30)[::-1]:
        if K&(1<<i):
            candidates.append(b + (1<<i) - 1)
            b += (1<<i)

    ans = 0
    for k in candidates:
        buf = 0
        for i, j in l:
            if i|k==k:
                buf += j
        ans = max(ans, buf)
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 85268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var aList = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();

			var dictionary = new Dictionary<int, int>();

			for(var i = 0; i < n; i++)
			{
				dictionary.Add(i + 1, 0);
			}

			foreach(var a in aList)
			{
				dictionary[a]++;
			}

			foreach(var keyValuePair in dictionary)
			{
				Console.WriteLine(keyValuePair.Value);
			}

		}
	}
}


Measured memory_bytes: 43216
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
S,T = input().split()
print(''.join([s+t for s,t in zip(S,T)]))


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

vector<ll> G[101010];
vector<ll> mark(101010, -1);

bool is_bipartite(ll now, ll now_mark){
	if(mark[now]!=-1) return (mark[now]==now_mark);
	mark[now] = now_mark;
	bool flag = true;
	REP(i, G[now].size()){
		ll next = G[now][i];
		flag &= is_bipartite(next, 1-now_mark);
	}
	return flag;
}

int main(){
	ll N, M;
	cin >> N >> M;
	REP(i, M){
		ll a, b;
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	bool flag = is_bipartite(0, 1);
	if(flag){
		ll sum = 0;
		REP(i, N) sum += mark[i];
		ll res = 0;
		REP(i, N){
			if(mark[i]==0){
				res += (sum - G[i].size());
			}
		}
		cout << res << endl;
	}else{
		cout << N*(N-1)/2 - M << endl;
	}

    return 0;
}

Measured memory_bytes: 8448
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let (A, B, T) = get!(usize, usize, usize);

    let ans = T / A * B;

    // 出力
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;
    
    vl L(n);
    rep(i, n) {
        cin >> L[i];
    }
    sort(all(L));

    ll sum = 0;
    rep(i, n-1) {
        sum += L[i];
    }

    if(L[n-1] < sum) {
        out("Yes");
    }
    else {
        out("No");
    }
    
    re0;
}

Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)

@k = 10**9 + 7

def fact(n)
  ret = 1
  n.downto(1) do |i|
    ret *= i % @k
    ret %= @k
  end
  return ret
end

if n == m then
  puts 2 * fact(n) ** 2 % @k 
elsif n + 1 == m || n == m + 1 then
  puts fact(n) * fact(m) % @k
else
  puts 0
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> kk(N);
for (int i = 0; i < N; i++) {
  cin >> kk.at(i);
}
  int a = 0;
  for(int i = 0; i < N; i++) {
    if(kk.at(i) % 2 == 0 && kk.at(i) % 3 != 0 && kk.at(i) % 5 != 0)
    {a = 1;}
  }
  if(a == 0)
  {cout << "APPROVED" << endl;
}
  else{cout << "DENIED" << endl;}
}

Measured memory_bytes: 256
n,l=map(int,input().split())
a=0
b=0
if l>=0:
  for i in range(0,n):
    a=a+l+i
  b=a-l
elif l<0 and l+n>=1:
  for i in range(0,n):
    a=a+l+i
  b=a
else:
  for i in range(0,n):
    a=a+l+i
  b=a-l-n+1

print(b)

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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define Min(a,b) a=min(a,b)

const ll oo = 1e18;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int p[n];
	int rt,lt; cin>>rt>>lt;
	f(i,0,n) cin>>p[i];
	ll dp[n][n];
	f(i,0,n) f(j,0,n) dp[i][j] = oo;
	f(i,0,n) {
		int gr = 0, ls = 0;	
		f(j,0,i) if (p[j]>p[i]) gr++;
		else ls++;
		dp[i][i] = 1LL*gr*rt+1LL*ls*lt;
		f(j,0,i) if (dp[i-1][j]!=oo) {
			if (p[j] > p[i]) // has to move left	
				Min(dp[i][j],dp[i-1][j]+lt);
			else { // has to move right ... moving left doesn't make sense
				Min(dp[i][j],dp[i-1][j]+rt);	
				// not moving
				Min(dp[i][i],dp[i-1][j]);
			}
		}
	}
	ll ans = oo;
	f(i,0,n) Min(ans,dp[n-1][i]);
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
 int n; cin>>n;
 string s[n]; REP(i,n)cin>>s[i];
 int alp[26];

 REP(i,n){
   int alp2[26]; REP(j,26)alp2[j]=0;
   REP(j,s[i].size()){
     REP(k,26)if(s[i][j]=='a'+k)alp2[k]++;
     }
   if(i==0)REP(k,26)alp[k]=alp2[k];
   else REP(k,26)if(alp[k]>=alp2[k])alp[k]=alp2[k];
   //REP(k,26)cout<<alp2[k]<<' ';
   //cout<<endl;
   }
  //REP(k,26)cout<<alp[k]<<' ';
  string res="";
 REP(i,26){
   REP(j,alp[i])res+='a'+i;
 }
  cout<<res<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func bcount(bits int) int {
	cnt := 0
	for i := 0; i < 64; i++ {
		if (bits & (1 << uint(i))) != 0 {
			cnt++
		}
	}
	return cnt
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	for bits := 0; bits < (1 << uint(n)); bits++ {
		if bcount(bits) == k {
			fmt.Printf("%d:", bits)
			for j := 0; j < n; j++ {
				if (bits & (1 << uint(j))) != 0 {
					fmt.Printf(" %d", j)
				}
			}
			fmt.Println()
		}
	}
}



Measured memory_bytes: 4872
let n = read_int()
let a = Array.make n 0
let b = Array.make n 0

let () =
  for i = 0 to n - 1 do
    Scanf.scanf " %d %d" (fun x y ->
      a.(i) <- x;
      b.(i) <- y
    )
  done;
  let sort = Array.sort (fun x y -> x - y) in
  sort a;
  sort b;
  let ans = b.(n / 2) - a.(n / 2) + 1 + (lnot n land 1) * (b.(n / 2 - 1) - a.(n / 2 - 1)) in
  Printf.printf "%d\n" ans


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

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class EGuruguru {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,m;
        in>>n>>m;
        vector<ll> a(n),s0(m+1),s1(m+1);
        ll f0=0,f1=0,k;
        for(auto&i:a) in>>i,--i;
        fr(i,n-1){
            k=a[i+1]-a[i];
            if(k<0) k+=m;
            s0[a[i+1]]+=k-1;
            ++s1[a[i+1]];
            --s1[a[i]+1];
            f0+=min(k,1+a[i+1]);
            if(a[i]>a[i+1]) --f1;
        }
        ll ans=f0;
        fr(i,m){
            f1+=s1[i];
            f0+=s0[i]+f1;
            ans=min(ans,f0);
        }
        out<<ans<<endl;
    }
};

int main() {
    EGuruguru solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    i64 n;
    cin >> n;

    i64 ans(1e14);
    for (int i = 1; i < sqrt(n)+1; ++i) {
        if (n % i == 0) {
            ans = min(ans, n/i + i);
        }
    }

    cout << (ans == 1e14 ? 0 : (ans - 2)) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int k;
		int a, b;
		String message = "NG";
		Scanner scan = new Scanner(System.in);

		k = scan.nextInt();
		a = scan.nextInt();
		b = scan.nextInt();

		for(int i = a; i <= b; i++) {
			if(i % k == 0) {
				message = "OK";
				break;
			}
		}

		System.out.println(message);
	}
}


Measured memory_bytes: 27072
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int N = n;
        int sum=0;
        while(true){
            if(n-10>=0){
                sum+=n%10;
                n/=10;
            }
            else{
                sum+=n;
                break;
            }
        }
        if(N%sum==0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main() {
    long long W,H,x,y;
    cin >> W >> H >> x >> y;
    double out1 = W * H / 2.0;
    int out2;
    if (x * 2 == W && y * 2 == H) {
        out2 = 1;
    } else {
        out2 = 0;
    }
    printf("%lf ",out1);
    cout << out2 << "\n"; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int A,B,C,X;
  int i=0;
  cin>>A>>B>>C;
    while(C>X){
      i++;
 if(i%7==0){
   X=X+(A+B);
 }else{
  X=X+A; 
 }  
  
}
cout<<i<<endl;
} 


Measured memory_bytes: 3116
#include <iostream>
#include <stack>
using namespace std;
int main(){

  int n,q;
  cin>>n>>q;
  stack <int> a[n];

  for(int i=0;i<q;i++){
    int n,t;
    cin>>n>>t;
    if(!n){
      int x;
      cin>>x;
      a[t].push(x);
    }
    else if(n==1&&!a[t].empty()) cout<<a[t].top()<<endl;
    else if(!a[t].empty())a[t].pop();
  }

  return 0;

}



Measured memory_bytes: 4280
#include <stdio.h>
int main(){
	int m,f,r;
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1&&f==-1&&r==-1){
			break;
		}
		if(m==-1||f==-1){
			puts("F");
		}
		else if(m+f>=80){
			puts("A");
		}
		else if(m+f>=65){
			puts("B");
		}
		else if(m+f>=50||r>=50){
			puts("C");
		}
		else if(m+f>=30){
			puts("D");
		}
		else{
			puts("F");
		}
	}
	return 0;
}



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

// 0 = X, 1 = Y
int N, A[2009], D[2009][2009][2];

int go(int i, int j, int P) {
    if(i == N) return max(A[i] - A[j], A[j] - A[i]);
    int& x = D[i][j][P];
    if(x != -1) return x;
    if(P == 0) return x = max(go(i+1, j, P), go(i+1, i, 1-P));
    if(P == 1) return x = min(go(i+1, j, P), go(i+1, i, 1-P));
}

int main() {
    memset(D, -1, sizeof(D));
    scanf("%d%*d%d",&N,&A[0]);
    for(int i=1; i<=N; i++) scanf("%d",&A[i]);
    printf("%d", go(1, 0, 0));
    return 0;
}

Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;

void chmax(int &a, int b) { if (a < b) a = b; return; }
long long pow(long long a, long long n) {
    long long res = 1ll;
    while (n) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n /= 2;
    }
    return res;
}

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    vector<int> count(1100100,0);
    for (int i = 0; i < n; i++) { 
        int x; cin >> x; a[i] = (long long)pow((long long)x, MOD - 2);
        for (int j = 2; j * j <= x; j++) {
            if (x % j != 0) continue;
            int num = 0;
            while (x % j == 0) {
                num++;
                x /= j;
            }
            chmax(count[j], num);
        }
        if (x > 1) chmax(count[x], 1);
    }

    long long save = 1ll;
    for (int i = 2; i < (int)count.size(); i++) save = save * (long long)pow(i, count[i]) % MOD;

    long long ans = 0ll;
    for (int i = 0; i < n; i++) ans = (ans + save * a[i] % MOD) % MOD;//, cout << a[i] << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8144
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}





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

	//bit全探索
	//1のところのビルが色が見えるようにする
	ll ans = 1001001001001001;
	for(int i=0; i< (1<<N); i++){
		bitset<15> bit(i);//iを2進数表記で格納
		if(bit.count() != K) continue;//1の個数がK個でないとだめ(K個より多いと無駄がでる)

		
		vector<ll> b = a;
		ll height = b[0];//注目ビルより前のビルたちの最大高さを格納
		ll yen = 0;
		for(int j=1; j<N; j++){
			if(bit[j] == 0){
				height = max(height, b[j]);
				continue;
			}
			
			if(height >= b[j]){//注目ビルより前に，高いビルがあるなら
				height = height+1;
				yen += height - b[j];
				//b[j] = height;
			}
			else{
				height = b[j];
				//yen += 0;//注目ビルは高くしなくて良い
			}			
		}

		// if(yen == 0){
		// 	cout << " bit: " << bit << " bit[0]: " << bit[0] <<  endl;
		// 	cout << " b: "; print_vec(b);
		// }
		ans = min(ans, yen);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c&&c<=b){
		cout<<"Yes\n";
	}
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;

    int ans = 0;
    for(int i = 0; i < N - 2; i++) {
        if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<int> S(N);
    for(int i = 0; i < M; ++i) {
        int k; cin >> k;
        while(k--) {
            int s; cin >> s; --s;
            S[s] |= (1 << i);
        }
    }
    int P = 0;
    for(int i = 0; i < M; ++i) {
        int p; cin >> p;
        if(p) P |= (1 << i);
    }
    auto f = [&](auto &&f, int bit, int cur) -> int {
        if(cur == N) return bit == 0;
        return f(f, bit ^ S[cur], cur + 1) + f(f, bit, cur + 1);
    };
    cout << f(f, P, 0) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int count=0;
    if (n<105) {
        cout<<0<<endl;
    } else {
        for (int i=105;i<=n;i++) {
            int divisor=0;
            for (int j=1;j<=i;j++) {
                if (i%j==0) {
                    divisor++;
                }
            }
            if (i%2==1&&divisor==8) {
                count++;
            }
        }
        cout<<count<<endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int n,l,a[200010],p[200020];
long long ans;
struct data
{
	int l,r,wl,wr;
};
long long calc(vector<pair<int,int> >&w)
{
//	for(int i=0;i<w.size();++i)printf("%d %d\n",w[i].first,w[i].second);
	int sum=0;
	long long res=0;
	for(int i=0;i<w.size();++i)
	{
		if(i>=l-1)sum+=w[i-l+1].first;
		res+=sum*w[i].second;
	}
//	printf("%lld\n",res);
	return res;
}
int main()
{
	scanf("%d %d",&n,&l);ans=n;
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),p[i]=i;
	sort(p+1,p+1+n,[](int &x,int &y){return a[x]<a[y];});
	int last=1,val=0;
	vector<data>A,B;
	while(last<=n||A.size())
	{
		if(A.empty())val=a[p[last]];
		else ++val;
		while(a[p[last]]==val)A.push_back(data{p[last],p[last],1,1}),++last;
		B.clear();
		sort(A.begin(),A.end(),[](data &x,data &y){return x.l<y.l;});
		for(int i=0;i<A.size();++i)
		{
			vector<pair<int,int> >cur,nxt;
			int r=i;cur.push_back(make_pair(A[i].wl,A[i].wr));
			while(r+1<A.size()&&A[r+1].l==A[r].r+1)++r,cur.push_back(make_pair(A[r].wl,A[r].wr));
			ans+=calc(cur);
			int len=r-i+1,cnt=(r-i+1)/l;
			nxt.resize(cnt);
			for(int j=0;j<cnt;++j)nxt[j].first=nxt[j].second=0;
			for(int j=0;j<len;++j)
			{
				if(j+1>=l)nxt[(j+1)/l-1].second+=A[i+j].wr;
				if(len-j>=l)nxt[cnt-(len-j)/l].first+=A[i+j].wl;
			}
			ans-=calc(nxt);
			for(int j=0;j<cnt;++j)B.push_back(data{A[i+j*l].l,A[j==cnt-1?r:i+j*l+l-1].r,nxt[j].first,nxt[j].second});
			i=r;
		}
		A=B;
	//	for(int i=0;i<A.size();++i)printf("%d %d %d %d\n",A[i].l,A[i].r,A[i].wl,A[i].wr);
	//	printf("\n");
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 9580
#include<iostream>
#include<queue>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main()
{
    queue< pair<string, int> > Q;
    string name;
    int t, n, max;
    cin >> n >> max;
    for(int i = 0; i < n; i++)
    {
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }
    pair<string, int> temp;
    int a;
    int elaps = 0; // 已经过的时间
    while(!Q.empty())
    {
        temp = Q.front();
        Q.pop();
        a = min(temp.second, max);
        elaps += a;
        temp.second -= a;
        if(temp.second != 0)
            Q.push(temp);
        else
            cout << temp.first << " " << elaps << endl;
    }
    return 0;
}



Measured memory_bytes: 6324
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
using namespace std;

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int s = 0, const int d = 0, const Weight w = 0) : src(s), dst(d), weight(w) {}
};

using Edges = std::vector<Edge>;

class Graph {
  std::vector<Edges> g;
  using const_iterator = std::vector<Edges>::const_iterator;

public:
  Graph(const int size = 0) : g(size) {}
  size_t size() const { return g.size(); }
  const Edges &operator[](const int i) const { return g[i]; }
  void addArc(const int src, const int dst, const Weight w = 1) { g[src].emplace_back(src, dst, w); }
  void addEdge(const int node1, const int node2, const Weight w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }
  const_iterator begin() const { return g.begin(); }
  const_iterator end() const { return g.end(); }
};

int main() {
  int n, k;
  cin >> n >> k;
  Graph g(n);
  rep(i, n) {
    int a;
    cin >> a;
    if (a > 0) g.addArc(i, a - 1);
  }
  vector<int> in(n), out(n);
  for (auto &es : g) {
    for (auto &e : es) in[e.dst]++, out[e.src]++;
  }
  vector<int> dp(n);
  rep(i, n) if (in[i] == 0) dp[i] = k;
  for (int i = n - 1; i >= 0; i--) {
    if (g[i].size()) cmax(dp[g[i][0].dst], dp[i] - 1);
  }
  rep(i, n) if (out[i] == 0) dp[i] = 1;
  cout << count_if(all(dp), [](int x) { return x > 0; }) << endl;
}

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

int main() {
  string s;
  cin>>s;
  map<char,int> mp;
  mp['N']=0;mp['W']=0;mp['E']=0;mp['S']=0;
  rep(i,s.size()){
    mp[s[i]]++;
  }
  bool ans =false;
  if(mp['N']!=0&&mp['W']!=0&&mp['E']!=0&&mp['S']!=0){
    ans=true;
  }
  if(mp['N']==0&&mp['W']!=0&&mp['E']!=0&&mp['S']==0){
    ans=true;
  }
  if(mp['N']!=0&&mp['W']==0&&mp['E']==0&&mp['S']!=0){
    ans=true;
  }
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
N = int(input())
L = [int(i) for i in input().split()]

L.sort()
ans = 0
mem_k = 2
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(mem_k, N):
            if L[k] >= L[i] + L[j]:
                ans -= 1
                break
        ans += k - j
        mem_k = max(k, j+1)
    mem_k = i + 2

print(ans)



Measured memory_bytes: 44812
import collections 
nxy=input().rstrip().split(" ")
n=int(nxy[0])
x=int(nxy[1])
y=int(nxy[2])
dis=[]
for i in range(1,n):
    #print(i)
    j=i+1
    while j>i and j<=n:
        l1=abs(x-i)+1+abs(y-j)
        l2=j-i
        if l1>=l2:
            L=l2
        else:
            L=l1
        #print(L)
        dis.append(L)
        j=j+1
#print(dis)
c=collections.Counter(dis)
#print(c)
for k in range(1,n):
    print(c[k])


Measured memory_bytes: 67808
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N, K;
    cin >> N >> K;

    if (N % K == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e4 + 5;
ll dp[N], a[N], b[N];
int n, h;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> h >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    for (int i = 0; i < h; i++)
        dp[i] = 1e18;
    for (int i = h; i > 0; i--) {
        for (int j = 0; j < n; j++) {
            ll nxtHP = max(0LL, i - a[j]);
            dp[nxtHP] = min(dp[nxtHP], dp[i] + b[j]);
        }
    }
    cout << dp[0];
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int dp[1001][101];

int main()
{
	int L,N,M,X;
	while(cin >> L >> N >> M >> X, (L||N||M||X)) {
		vector<pair<int, int> > secret(N);
		vector<pair<int, int> > normal(M);
		for(int i=0; i<N; i++) {
			string n;
			int e,s;
			cin >> n >> e >> s;
			secret[i] = make_pair(e, s);
		}

		for(int i=0; i<M; i++) {
			string n;
			int e,s;
			cin >> n >> e >> s;
			normal[i] = make_pair(e, s);
		}

		memset(dp, -1, sizeof(dp));
		for(int i=0; i<N; i++) 
		for(int j=i+1; j<N; j++) {
			int l = secret[i].first, r = secret[j].first;
			if(l <= L) dp[l][0] = max(dp[l][0], secret[i].second);
			if(r <= L) dp[r][0] = max(dp[r][0], secret[j].second);

			if(l + r <= L) dp[l + r][0] = max(dp[l + r][0], secret[i].second + secret[j].second);
		}

		for(int i=0; i<M; i++)
		for(int j=i; j>=0; j--) {
			int c = normal[i].first;
			int s = normal[i].second;

			for(int k=0; k<=L; k++) {
				if(dp[k][j] == -1) continue;
				if(k + c > L) break;

				dp[k + c][j + 1] = max(dp[k + c][j + 1], dp[k][j] + s);
			}
		}

		int res = 0;

		for(int i=0; i<=L; i++)
		for(int j=X; j<=M; j++)
			res = max(res, dp[i][j]);

		cout << res << endl;
	}
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
#define PB push_back
#define FI first
#define SE second
#define MP make_pair
#define int long long
using namespace std;
static const int inf = 1ll<<60;
static const int MAX_N = 16777216;
typedef pair<int,int> P;

int N,D;
int X[40],Y[40];
int ans=0;
int dat[MAX_N*2];

class Segment{
    public :
        int n;
        void inti(int n_){
            n=1;
            while(n<n_)n*=2;
            for(int i=0;i<2*n-1;++i)dat[i]=-INT_MAX;
        }

        void update(int k,int a){
            k+=n-1;
            dat[k]=a;
            while(k>0){
                k=(k-1)/2;
                dat[k]=max(dat[k*2+1],dat[k*2+2]);
            }
        }

        int query(int a,int b,int k,int l,int r){
            if(a<=l&&r<=b)return dat[k];
            if(r<=a||b<=l)return -INT_MAX;
            else {
                int vl=query(a,b,k*2+1,l,(l+r)/2);
                int vr=query(a,b,k*2+2,(l+r)/2,r);
                return max(vl,vr);
            }
        }
};

void half(int n,int last,int x,int y,vector<P> &res) {
    if (n==last) {
        res.PB(P(x,y));
        return;
    }
    half(n-1,last,x+X[n],y+Y[n],res);
    half(n-1,last,x-X[n],y-Y[n],res);
    half(n-1,last,x,y,res);
}

signed main(){
    cin>>N>>D;
    Segment seg;
    int n2=N/2;
    for(int i=1;i<=N;++i){
        cin>>X[i]>>Y[i];
    }
    vector<P> p1;
    vector<P> p2;
    p1.reserve(MAX_N);
    half(n2,0,0,0,p1);
    p2.reserve(MAX_N);
    half(N,n2,0,0,p2);
    sort(p2.begin(),p2.end());
    seg.inti(p2.size());
    for(int i=0;i<p2.size();++i)seg.update(i,p2[i].SE);
    for(int i=0;i<p1.size();++i){
        int x=p1[i].FI+D;
        int y=p1[i].FI-D;
        int r=lower_bound(p2.begin(),p2.end(),MP(y,-inf))-p2.begin();
        int l=upper_bound(p2.begin(),p2.end(),MP(x,inf))-p2.begin();
        if(r==p2.size())continue;
        if(r>=l)continue;
        ans=max(ans,seg.query(r,l,0,0,seg.n)-p1[i].SE);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 712932
N, x = map(int, input().split())
a = sorted([int(i) for i in input().split()], reverse=True)

s = sum(a)
if x == s:
    print(N)
else:
    for i in range(N):
        s -= a[i]
        if x >= s:
            print(N-i-1)
            exit()


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

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

int main() {
    int n;
    cin >> n;
    vi v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];

    int res = -1;

    rep(flag, 1 << n) {
        int cs = 0, vs = 0;

        rep(i, n) {
            if ((flag >> i) & 1) {
                vs += v[i];
                cs += c[i];
            }
        }

        res = max(res, vs - cs);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b, c, d = map(int, readline().split())
for i in range(10000):
    c -= b
    if c <= 0:
        print('Yes')
        break
    a -= d
    if a <= 0:
        print('No')
        break


Measured memory_bytes: 61592
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.add(i)
            divisors.add(n // i)
    return divisors # sortしたリストで欲しい時はsorted(divisors)

ret = 0
a = make_divisors(n)
for k in a:
    if k == 1:
        continue
    m = n
    while m % k == 0:
        m //= k
    if m % k == 1:
        ret += 1

s = make_divisors(n - 1)
s.discard(1)
print(ret + len(s))


Measured memory_bytes: 40048
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

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

	string s; cin >> s;
	if (s == "RRR") {
		cout << 3 << endl;
	}
	else if (s == "SSS") {
		cout << 0 << endl;
	}
	else if (s == "RRS" || s == "SRR") {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}

	return 0;
}

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

int main() {
  int n,ans;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  cin >> a[0];
  for(int i = 1;i < n;i++){
    int t;
    cin >> t;
    a[i] = a[i-1]+t;
  }
  cin >> b[0];
  for(int i = 1;i < n;i++){
    int t;
    cin >> t;
    b[i] = b[i-1]+t;
  }
  ans = a[0]+b[n-1];
  for(int i = 1;i < n;i++){
    if(a[i]+b[n-1]-b[i-1] > ans) ans = a[i]+b[n-1]-b[i-1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  ll n, m, k;
  cin >> n >> m >> k;
  vecll a(n, 0);
  vecll b(m, 0);
  REPe(e, a) cin >> e;
  REPe(e, b) cin >> e;
  vecll suma(n, 0);
  vecll sumb(m, 0);
  suma[0] = a[0];
  sumb[0] = b[0];
  REP(i, n - 1) suma[i + 1] = suma[i] + a[i + 1];
  REP(i, m - 1) sumb[i + 1] = sumb[i] + b[i + 1];
  // REP(i, n) cout << suma[i] << endl;
  // cout << endl;
  // REP(i, m) cout << sumb[i] << endl;
  // cout << endl;
  auto itr1 = upper_bound(all(sumb), k);
  ll ans = itr1 - sumb.begin();
  // cout << ans << endl;
  REP(i, n) {
    ll tota = suma[i];
    ll totb = k - tota;
    if (totb < 0) continue;
    auto itr = upper_bound(all(sumb), totb);
    if (itr == sumb.begin()){
		ans = max(ans, (ll)i + 1LL);
      continue;}
    // cout << tota << " " << totb << " " << *itr << " " << itr - sumb.begin()
    //  << endl;
    ans = max(ans, (ll)i + 1LL + (ll)(itr - sumb.begin()));
//    cout << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 9512
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            int it=n/i;
            int cn=n;
            while(cn%it==0)cn/=it;
            if(cn%it==1)
                ans++;
            if(i!=1&&i!=it) {
					cn = n;
					while (cn % i == 0) cn /= i;
					if (cn % i == 1) {
						ans++;
					}
				}
        }
    }
    n--;
    for(int i=1;i*i<=n;i++){
        if(n%i==0)ans+=2;
        if(i*i==n)ans--;
        if(i==1)ans--;
    }
        cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
using namespace std;

typedef long long int ll; 
typedef pair<int,int> Pii;

int main(){
    long long a;
    cin>>a;
    cout<<3*a*a;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <set>
#include <utility>
#include <iostream>
#include <cassert>
#include <stack>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define rvc(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

int main(){
    LL K,A,B;
    cin>>K>>A>>B;
    LL ans=K+1;
    if(K>=A-1 && B>A){
        ans=max(ans,A+(K-(A-1))/2*(B-A)+(K-(A-1))%2);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N,K,C = list(map(int,input().split()))
S = list(input())
L = []
R = []
life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[i]=="o":
        if life <= 0:
            life = C
            L.append(i)
            cnt += -1
        else:
            life += -1
    elif S[i]=="x":
        life += -1

life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[N-1-i]=="o":
        if life <= 0:
            life = C
            R.append(N-1-i)
            cnt += -1
        else:
            life += -1
    elif S[N-1-i]=="x":
        life += -1

L.sort()
R.sort()
for i in range(min(len(L),len(R))):
    if L[i]==R[i]:
        print(L[i]+1)

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

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

int main() {
    int N;
    cin >> N;

    int s = 0;
    REP(i, N) {
        int a;
        cin >> a;
        for(;a%2 == 0;) {
            s++;
            a /= 2;
        }
    }
    cout << s << endl;
    return 0;
}


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

int main(){
  long long int a ,b , c ,d ,e ,k ;
  string S, T;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef pair<int, int> ii;
typedef long long int64;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
    int k, x;
    cin >> k >> x;
    vector<int> pos;
    for (int i = x - k + 1; i <= x + k - 1; ++i) {
	if (i >= -2000000 && i <= 2000000) {
	    pos.push_back(i);
	}
    }
    for (auto& c : pos) {
	cout << c << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    ll odp = 0;
    for (ll i = 1; i <= n; ++i)
        if (i % 3 != 0 && i % 5 != 0)
            odp += i;
    cout << odp;
    return 0;
}


Measured memory_bytes: 3668