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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N; cin >> N;
    priority_queue<double, vector<double>, greater<double>> pq;
    rep(i, N){
        double a; cin >> a;
        pq.push(a);
    }

    rep(i, N-1){
        double a = pq.top();
        pq.pop();
        double b = pq.top();
        pq.pop();

        pq.push((a+b)/2);
    }

    double res = pq.top();

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main()
{
	int n,m;
	while(cin >> n && n)
	{
	map<char, char> f;
	
	char key,value;
	REP(n)
	{
		cin >> key >> value;
		f.insert( map<char, char>::value_type(key,value));
	}
	map<char, char>::iterator ans;
	char data;
	cin >> m;
	REP(m)
	{
		cin >> data;
		ans = f.find(data);
		if(ans == f.end()) cout << data;
		else cout << (*ans).second;
	}
	cout << endl;
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e5 + 10;
 
struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(20);
  }
}IO;

int32_t main(){
  set<int> s;
  for (int i = 0; i < 3; i++){
    int x; cin >> x;
    s.insert(x);
  }
  if ((int)s.size() == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

S = input()
T = input()
Q = getN()
que = [getList() for i in range(Q)]
# 各queryにつきO(1)で答える
# →リストをO(n)で作り答える
# AとBについてそれぞれ対応させると?
# 各要素について合成できる？
# 1:[A, BB], 2:[AA, B], 3[AAA, BBB]
# 1のものを2つ足したら2のものになる
# 1のものと2のものを足したら3になり消える
# 前からA: += 1, B: += 2を累積していく
imos_s = [0]
for i in range(len(S)):
    if S[i] == 'A':
        imos_s.append(imos_s[i] + 1)
    else:
        imos_s.append(imos_s[i] + 2)
imos_t = [0]
for i in range(len(T)):
    if T[i] == 'A':
        imos_t.append(imos_t[i] + 1)
    else:
        imos_t.append(imos_t[i] + 2)

for i in range(Q):
    a, b, c, d = que[i]
    opt_1 = (imos_s[b] - imos_s[a - 1]) % 3
    opt_2 = (imos_t[d] - imos_t[c - 1]) % 3
    if opt_1 == opt_2:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 111804
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>
#include <random>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-8
#define infi 1000000107
#define infll 1000000000000000000ll
#define MX 1000000
#define X real()
#define Y imag()
#define left(i) i<<1
#define right(i) (i<<1)|1
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
//#define rotate(a, theta) (a) * (polar(1.0, (theta) ))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c) cross(vec(a,b) , vec(a,c)) > eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 1000500001ll
#define mod2 1000300001ll
#define base1 137ll
#define base2 31ll
#define PI acos(-1)
#define sz(a) (int) (a).size()
#define isbit(x,k)  ((x) & (1<<(k))) > 0


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef complex<ll> point;
typedef pair<point, point> line;
typedef pair<ld , point> Circle;
typedef pair<point, int> Point;

const int N = 100002;
int n;

int main() {
    
    scanf("%d",&n);
    
    int x = n/2 , y = (n+1)/2;
    
    printf("%d\n", x*y);
    return 0;
}



/*
 */

//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        int H = Integer.parseInt(values[0]);
        int N = Integer.parseInt(values[1]);
        line = scanner.nextLine();
        values = line.split(" ");

        int atkDam = 0;
        for (int i = 0; i < N; i++) {
            atkDam += Integer.parseInt(values[i]);
        }
        System.out.println(H <= atkDam ? "Yes" : "No");
    }
}

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

int main() {

	while (1) {
		int a, b, c;
		cin >> a >> b;

		if ((a == 0) && (b == 0)) {
			break;
		}
		if (b < a) {
			c = a;
			a = b;
			b = c;
		}
		cout << a << " " << b << endl;

	}
}

Measured memory_bytes: 3060
import java.util.*;
class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    
    void run(){
	while(sc.hasNext()){
	    int p = sc.nextInt();
	    int q = sc.nextInt();
	    if(p<=0 || q<=0) continue;
	    solve(p%q, q);
	}
    }

    void solve(int p, int q){
	int[] y = new int[q];
	Arrays.fill(y, -1);
	int cnt=1;
	y[p%q]=0;
	p = p*10;
	while(true){
	    if(y[p%q]>=0){
		System.out.println(p/q);
		print(cnt, y[p%q]);
		break;
	    }
	    if(p%q==0){
		System.out.println(p/q);
		break;
	    }
	    System.out.print(p/q);
	    y[p%q] = cnt;
	    p = (p%q)*10;
	    cnt++;
	}
    }
    
    void print(int c, int idx){
	int i;
	for(i=0; i<idx; i++)
	    System.out.print(" ");
	for(; i<c; i++)
	    System.out.print("^");
	System.out.println();
    }
}

Measured memory_bytes: 89440
import java.util.*
import kotlin.collections.HashMap


data class Line(val to: String, val time: Int)
fun main(args: Array<String>?): Unit {
    while (true) {
        val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0) return
        val (s, p, g) = readLine()!!.trim().split(' ')
        val stations = HashMap<String, Stack<Line>>()
        repeat(m) {
            val (a, b, d, t) = readLine()!!.trim().split(' ')
            stations.getOrPut(a){Stack()}.push(Line(b, d.toInt() / 40 + t.toInt()))
            stations.getOrPut(b){Stack()}.push(Line(a, d.toInt() / 40 + t.toInt()))
        }
        val memo = HashMap<String, Int>().withDefault { Int.MAX_VALUE }.also { it[p] = 0 }
        val queue = PriorityQueue<Pair<String, Int>>(compareBy(Pair<*, Int>::second)).also { it.add(Pair(p, 0)) }
        while (queue.isNotEmpty()) {
            val (current, time) = queue.poll()
            if (memo[current] == time) {
                for ((to, cost) in stations[current]!!) {
                    if (memo.getValue(to) > time + cost) {
                        memo[to] = time + cost
                        queue.add(Pair(to, time + cost))
                    }
                }
            }
        }
        println(memo[s]!! + memo[g]!!)
    }
}


Measured memory_bytes: 68636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int h,w;
  cin >> h >> w;
  vs s(h);
  rep(i,h)cin >> s[i];
  //bfsして深さ分以外の白をひっくり返す
  vivi dist(h,vi(w,-1));
  queue<pair<int,int>> que;
  dist[0][0] = 0;
  que.push(make_pair(0,0));
  while(!que.empty()){
    auto v = que.front();
    que.pop();
    rep(i,4){
      int yy = v.first+dy[i];
      int xx = v.second+dx[i];
      if(yy<0 || xx<0 || yy>=h || xx>=w) continue;
      if(dist[yy][xx] != -1 || s[yy][xx]=='#')continue;
      dist[yy][xx] = dist[v.first][v.second]+1;
      que.push(make_pair(yy,xx));
    }
  }
  if(dist[h-1][w-1]==-1) {
    cout << -1 << endl;
    return 0;
  }
  int cnt = 0;
  rep(i,h) cnt+=count(s[i].cbegin(),s[i].cend(),'.');
  //cout << dist[h-1][w-1] << endl;
  //cout << cnt << endl;
  cout << cnt - (dist[h-1][w-1]+1) << endl;
            
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#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 Rep(i,x) for(int i=head[x];i+1;i=nxt[i])
#define rep2(i,a,b) for(int i=(a);i<(b);i++)
#define ff first
#define ss second
using namespace std;
const int N=10005;
typedef long long ll;
const ll inf=1e12;
//------------------------------------------head---------------------------------------------------//
int head[N],nxt[N],to[N],e;
ll cap[N];
int S,T;
inline void init(){memset(head,-1,sizeof(head));}
inline void add_edge(int x,int y,ll c)
{
	to[e]=y;nxt[e]=head[x];cap[e]=c;head[x]=e++;
	to[e]=x;nxt[e]=head[y];cap[e]=0;head[y]=e++;
}
int q[N],h,r,dis[N];
int bfs()
{
	h=r=0;q[r++]=S;rep(i,1,T)dis[i]=-1;dis[S]=1;
	while(h!=r)
	{
		int x=q[h++];
		Rep(i,x)if(dis[to[i]]==-1 && cap[i])
		{
			dis[to[i]]=dis[x]+1;
			q[r++]=to[i];
		}
	}
	if(dis[T]==-1)return 0;
	else return 1;
}
inline ll dfs(int x,ll y)
{
	if(x==T || !y){return y;}ll lft=y,t=y;
	Rep(i,x)
	{
		int j=to[i];if(!lft)break;
		if(dis[j]==dis[x]+1 && cap[i])
		{
			ll xjt=dfs(j,min(lft,cap[i]));
			if(xjt){lft-=xjt;cap[i]-=xjt;cap[i^1]+=xjt;}
		}
	}
	return t-lft;
}
inline ll dinic()
{
	ll ans=0;
	while(bfs())
	{
		ll TT=dfs(S,inf); 
		while(TT){ans+=TT;TT=dfs(S,inf);}
	}return ans;
}
int a[N];
int main()
{
	int n;scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
	S=n+1,T=n+2;init();ll ans=0;
	rep(i,1,n)if(a[i]<=0)add_edge(S,i,-a[i]);else add_edge(i,T,a[i]),ans+=a[i];
	rep(i,1,n)for(int j=i+i;j<=n;j+=i){add_edge(i,j,inf);}
	//printf("%lld\n",dinic());
	printf("%lld\n",ans-dinic());
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int k, n, p, x, s = 1;
vector<int> vec;

signed main() {
	cin >> k >> n;
	if (k % 2 == 0) {
		cout << k / 2 << " ";
		for (int i = 2; i <= n; i++)cout << k << " ";
		cout << endl;
		return 0;
	}
	if (k == 1) {
		for (int i = 0; i <= (n - 1) / 2; i++)cout << 1 << " ";
		cout << endl;
		return 0;
	}
	p = (k + 1) / 2;
	vec.push_back(p);
	vec.push_back(0);
	for (int i = 2; i <= n; i++) {
		if (i % 2) {
			x++;
			continue;
		}
		else {
			int l = (int)vec.size() - 1;
			while (1) {
				if (2 <= (int)vec[l])break;
				l--;
			}
			int m = (int)vec.size() - 1;
			while (1) {
				if (1 <= (int)vec[m])break;
				m--;
			}
			if (!l && !m)vec[1] = p - 1;
			else if (!l&&m == 1)vec[1] = p, vec.push_back(0);
			else if (vec[0] == p && vec[1] == p) {
				vec[1] = p - 1;
				for (int j = 2; j < (int)vec.size(); j++)vec[j] = k;
				x++;
			}
			else if (vec[m] == 1) {
				vec[m]--;
				x++;
			}
			else {
				vec[m]--;
				for (int j = m + 1; j < (int)vec.size(); j++)vec[j] = k;
				x++;
			}
		}
	}
	for (int i = 1; i <= x; i++)cout << p << " ";
	for (int i = 0; i < (int)vec.size(); i++) {
		if (vec[i] == 0)break;
		cout << vec[i] << " ";
	}
	cout << endl;
}


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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

const int MAX=1e5+9;
int n, h[MAX];
vector<int> adj[MAX];

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

    int m;
    cin >> n >> m;
    for (int i=1; i<=n; ++i)        cin >> h[i];
    while (m--) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    int ans=0;
    for (int i=1; i<=n; ++i) {
        int mx=-1;
        for (int j=0; j<adj[i].size(); ++j) {
            mx=max(mx, h[adj[i][j]]);
        }

        ans+=(h[i]>mx);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 9160
#include <stdio.h>

void linearSearch(int,int);

int count = 0;
int  S[10000];

int main(){

  int n,q,i,j;
  int T[10000];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    linearSearch(T[i],n);
  }
  printf("%d\n",count);
  return 0;
}
void linearSearch(int key,int n){
  int i;
  for(i=0;i<n;i++){
    if(key == S[i]){
      count++;
      break;
    }
  }
}



Measured memory_bytes: 2088
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve(){
    int n; cin>>n;

    int val = n-1;

    set<int> sol;

    for(int i=2;i*i<=val;i++){
        if(val%i == 0){
            sol.insert(i);
            sol.insert(val/i);
        }
    }

    sol.insert(val);

    for(int i=1;i*i<=n;i++){
        if(n%i == 0){
            val = n;
            int x = i;
            if(x != 1){
                while(val%x == 0) val = val/x;
                val = val%x;
                if(val == 1) sol.insert(x);
            }
            val = n;
            x = n/i;
                if(x != 1){
                while(val%x == 0) val = val/x;
                val = val%x;
                if(val == 1) sol.insert(x);
            }
        }
    }

    sol.erase(1);
    cout<<sz(sol)<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int s1,s2,s3,s4,s5,s6,s7,s8,s9,s10;
	scanf("%d",&s1);
	scanf("%d",&s2);
	scanf("%d",&s3);
	scanf("%d",&s4);
	scanf("%d",&s5);
	scanf("%d",&s6);
	scanf("%d",&s7);
	scanf("%d",&s8);
	scanf("%d",&s9);
	scanf("%d",&s10);
	printf("%d\n",s1+s2+s3+s4+s5+s6+s7+s8+s9+s10);
	return 0;
}

Measured memory_bytes: 1028
import math

S = list(map(int,input().split()))
N = S[0]
M = S[1]
div = list()
z = math.sqrt(M)
z = math.ceil(z)

for x in range(1,z):
    if M % x == 0:
        div.append(x)
        div.append(M//x)
div.append(M)
div.append(N)

sorted_div = sorted(div)
n = sorted_div.index(N)

y =sorted_div[n+1]

ans = M // y

print(ans) 

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


void solve () {
    int n;
    cin >> n;
    map<int, int> mp;
    bool ok = 0;
    bool okk = 1;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        int c = x / 400;
        if (c >= 8) {
            ok = 1;
            mp[8]++;
        } else {
            mp[c]++;
            okk = 0;
        }
    }
    cout << mp.size() - ok + okk << " " << mp.size() + mp[8] - ok << endl;

}

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


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

int main()
{
	ll ans = 0;
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	for(auto &i:a)cin >> i;
	sort(a.begin(),a.end());
	for(int i = 0;i<k;i++)ans += a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <string>
#include <map>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define LargeNum 1000000007
typedef pair <double, double> P;

int main(){
    int S, W;
    cin >> S >> W;
    if (W>=S) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3632
import sys
readline = sys.stdin.readline

N,X,M = map(int,readline().split())

nex = [(i ** 2) % M for i in range(M)]
cum = [i for i in range(M)]

ans = 0
while N:
  if N & 1:
    ans += cum[X]
    X = nex[X]
  cum = [cum[i] + cum[nex[i]] for i in range(M)]
  nex = [nex[nex[i]] for i in range(M)]
  N >>= 1

print(ans)

Measured memory_bytes: 23968
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n,u=0;
  cin >> n;
  bool t=true;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n){
    if (i*10>u) t=false;
    u=max(u,i*10+a[i]);
  }
  u=0;
  reverse(all(a));
  rep(i,n){
    if (i*10>u) t=false;
    u=max(u,i*10+a[i]);
  }
  if (t) cout << "yes" << endl;
  else cout << "no" << endl;
}



Measured memory_bytes: 3896
N = int(input())
A = list(map(int,input().split()))
d = {}
d[2] = 0
d[4] = 0
for a in A:
    if a % 4 == 0:
        d[4] += 1
    elif a % 2 == 0:
        d[2] += 1
if d[4] >= (N//2):
    print("Yes")
elif (d[2]//2) + d[4] >= (N//2):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
#include<stdio.h>
int main(void)
{
	int a,b,c,d[10001],e[10001],i,cnt=0;
	scanf("%d%d%d",&a,&b,&c);
	for(i=0;i<c;i++){
		scanf("%d%d",&d[i],&e[i]);
	}
	for(i=1;i<c;i++){
		while(d[i-1]!=d[i]||e[i-1]!=e[i]){
			if(d[i-1]>d[i]&&e[i-1]>e[i]){
					d[i-1]--;	e[i-1]--;
					cnt++;
			}
			else if(d[i-1]>d[i]){
				d[i-1]--;
				cnt++;
			}
			else if(e[i-1]>e[i]){
				e[i-1]--;
				cnt++;
			}
			if(d[i-1]<d[i]&&e[i-1]<e[i]){
					d[i-1]++;
					e[i-1]++;
					cnt++;
			}
			else if(d[i-1]<d[i]){
				d[i-1]++;
				cnt++;
			}
			else if(e[i-1]<e[i]){
				e[i-1]++;
				cnt++;
			}
		}
	//	printf("%d %d %d\n",d[i-1],e[i-1],cnt);
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 2688
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	vector<bool> visited(100);


	for (int i = 0; true; i++) {
		int x = i * (a + b);
		int y = x + a;
		int z = x / 60 * 60 + c;
		if (visited[x % 60]) { puts("-1"); return 0; }
		if (x <= z && z <= y) { cout << z << endl; return 0; }
		visited[x % 60] = true;
	}
}


Measured memory_bytes: 3104
#include<stdio.h>
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int main(){
	int n,m;
	while(scanf("%d%d",&n,&m),n+m){
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)putchar('#');
			puts("");
		}
		puts("");
	}
}


Measured memory_bytes: 2108
#include<iostream>
#include <algorithm>
#include <string.h>
#include <map>
using namespace std;
int main(){
	long long N,A,B,ans;
	cin>>N>>A>>B;
	ans=(B-A)*(N-2)+1;
	if(A>B)ans=0;
	if(N==1&&A!=B)ans=0;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
s=[list(map(int,input().split()))[1:] for i in range(M)]
p=list(map(int,input().split()))
ans,cnt=0,0
for n in range(2**N):
  for m in range(M):
    cnt=0
    for i in range(N):
      if (n>>i)&1 and i+1 in s[m]:
        cnt+=1
    if cnt%2!=p[m]:
      break
  else:
    ans+=1
print(ans)

Measured memory_bytes: 71184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,a;
  cin>>n>>k;
  a=1;
  for(int i=0; i<n; i++){
    if(a*2<=a+k){
      a*=2;
    } else {
      a+=k;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        Map<String, Integer> map = new HashMap<String, Integer>();
        for (char c = 'a'; c <= 'z'; c++) {
            map.put(String.valueOf(c), 0);
        }
        String str;
        while (sc.hasNext()) {
            str = sc.nextLine();
            char[] strArr = str.toCharArray();
            for (int i = 0; i < strArr.length; ++i) {
                if (map.containsKey(String.valueOf(Character.toLowerCase(strArr[i]))))
                    map.put(String.valueOf(Character.toLowerCase(strArr[i])),
                            map.get(String.valueOf(Character.toLowerCase(strArr[i]))) + 1);
            }
        }
        for (char c = 'a'; c <= 'z'; c++) {
            System.out.println(c + " : " +
                    map.get(String.valueOf(Character.toLowerCase(c))));
        }
    }
}






Measured memory_bytes: 26456
import bisect
import copy

n, m = map(int,input().split())
a = list(map(int,input().split()))

a.sort()
asum = [0]
tmp = 0
for i in range(n):
    tmp += a[i] 
    asum.append(tmp)

lb = 1
ub = 2*10**5 + 1
while ub - lb > 1:
    cx = (ub+lb)//2
    cnt = 0
    total = 0
    for ca in a:
        cy = cx - ca
        ci = bisect.bisect_left(a, cy)
        cnt += n - ci
        total += asum[n] - asum[ci] + (n - ci) * ca
    if cnt >= m:
        lb = cx
        ans = copy.deepcopy(total) - (cnt - m) * cx
    else:
        ub = cx

print(ans)

Measured memory_bytes: 99268
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n,r,p,c;
        int i,k;

        while(true)
        {
            n = sc.nextInt();  r=sc.nextInt();
            if(n==0 && r==0) break;

            List<Integer> huda = new ArrayList<Integer>();
            for(i=0; i<n; i++) huda.add(i+1);

            for(i=0;i<r;i++)
            {
                p=sc.nextInt(); c=sc.nextInt();
                for(int y=0; y<c; y++) huda.add(huda.remove(n-p-c+1));
            }

            System.out.println(huda.remove(n-1));
        }
        sc.close();
    }
}


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

int main() {
  int N, M, city;
  cin >> N >> M;
  vector<int> count(N,0);
  
  for (int i=0; i<M; i++) {
    cin >> city;
    count.at(city-1)++;
    cin >> city;
    count.at(city-1)++;
  }
  
  for (int i=0; i<N; i++) {
    cout << count.at(i) << endl;
  }
}


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

int main() {
	int a[7],b[7],c;
	for(int i=0;i<7;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<7;i++){
		c=a[i]-b[i];
		cout<<c<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
#define Rep(i, j, k) for(R int i = (j), ED = (k); i >= ED; --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 200011;
const ll INF = 5e16;

namespace IO {

    inline char gc() {
        static char buf[100000], *p1 = buf, *p2 = buf;
        return (p1 == p2) && (p2 = (p1 = buf) +
            fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
    }

    #define dd ch = getchar()
    inline ll read() {
        R ll x = 0; R int f = 0; R char dd;
        for (; !isdigit(ch); dd) f ^= (ch == '-');
        for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
        return f? -x: x;
    }
    #undef dd

    inline void write ( ll x ) {
        if (x < 0) x = -x, putchar('-');
        if (x > 9) write(x / 10); putchar(x % 10 | 48);
    }

    inline void wrn ( ll x ) { write(x), putchar(' '); }

    inline void wln ( ll x ) { write(x), putchar('\n'); }

    inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	char s[N], t[N];
	ll Ans, pos = 0, Vis[233];
	
	vector <ll> V[233];
	
	int main() {
		scanf("%s", s + 1);
		scanf("%s", t + 1);
		ll Lens = strlen(s + 1);
		ll Lent = strlen(t + 1);
		For ( i, 1, Lens ) Vis[s[i]] = 1;
		For ( i, 1, Lens ) V[s[i]].push_back(i);
		For ( i, 1, Lent ) if (!Vis[t[i]]) return puts("-1"), 0;
		For ( i, 1, Lent ) {
			ll Pos = upper_bound(V[t[i]].begin(), V[t[i]].end(), pos) - V[t[i]].begin();
			if (Pos > V[t[i]].size() - 1) Ans += Lens, pos = V[t[i]][0];
			else pos = V[t[i]][Pos];
		} return wln(Ans + pos), 0;
	}
	
}

int main()
{
    return Cesare::main();
}

/*

*/







Measured memory_bytes: 1656
import java.util.*;

public class Main {
  private static final int MOD = 1_000_000_007;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char c = S.charAt(i);
      map.put(c, map.getOrDefault(c, 0)+1);
    }
    long ans = 1;
    for (int count : map.values()) {
      ans *= count+1;
      ans %= MOD;
    }
    System.out.println(ans-1);
  }
}

Measured memory_bytes: 25952
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define	inf (int)1e5
#define mod 1000000007
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string str_inp(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string line_inp(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;


const int S=45;
int n,ma,mb;
int a[S+5],b[S+5],c[S+5];
int dp[S+5][400+5][400+5];

bool Check(int ta,int tb)
{
	if(!ta && !tb)return false;
	int g=__gcd(ta,tb);
	if(ta/g==ma && tb/g==mb)return true;
	return false;
}

int Solve(int pos,int ta,int tb)
{
	if(pos==n)
	{
		if(Check(ta,tb))return 0;
		return inf;
	}
	if(Check(ta,tb))return 0;
	if(dp[pos][ta][tb]!=-1)return dp[pos][ta][tb];

	int mn=min(c[pos]+Solve(pos+1,ta+a[pos],tb+b[pos]),Solve(pos+1,ta,tb));
	return dp[pos][ta][tb]=mn;
}

int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
	while(~sf("%d %d %d",&n,&ma,&mb))
	{
		for(int i=0;i<n;i++)sf("%d %d %d",&a[i],&b[i],&c[i]);

		mem(dp,-1);
		int cost=Solve(0,0,0);
		if(cost>=inf)puts("-1");
		else pf("%d\n",cost);
	}
    return 0;
}
 


Measured memory_bytes: 32256
function Main(input) {
  var args = input.split(' ');
  var a = parseInt(args[0]);
  var b = parseInt(args[1]);
  var sum = 0;
  for (i = 0; i < 2; i++) {
    if (a < b) {
      sum += b--
    } else {
      sum += a--
    }
  }
  console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
N = int(input())

if N % 2 == 0:
    #偶数の場合 i , N+1-i ペア以外を出力
    print(N*(N-2)//2)
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if i + j == N+1:
                continue
            print(i,j)
else:
    #奇数の場合 i, N-i ペア以外を出力
    print(((N-1)**2)//2)
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if i + j == N:
                continue
            print(i,j)

Measured memory_bytes: 3612
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define md(a, b)		((a) % b + b) % b
#define mod(a)			md(a, MOD)
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define forn(i, n)			for(int i = 0; i < n; i++)
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
//int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef long long 		ll;
typedef long double ld;	
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1000000007;
const int MOD1 = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1); 
pair<int, int> l[200020], r[200020];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("qwe.txt", "w", stdout);
	int cas;
	cin>>cas;
	int n;
	ll res = 0;
	int a, b, c;
	int le = 0, ri = 0;
	set<int> lef, rig;
	while(cas--)
	{
		//cout<<"xas "<<cas<<'\n';
		cin>>n;
		res = 0;
		le = 0, ri = 0;
		lef.clear();
		rig.clear();
		//cout<<"cha";
		fore(i, 0, n)
		{
			//cout<<i<<'\n';
			cin>>c>>a>>b;
			res += min(a, b);
			if(a > b)
			{
				l[le++] = {a - b, c - 1};
			}
			else
				r[ri++] = {b - a, n - c - 1};
		}
		fore(i, 0, le)
			lef.insert(i);
		fore(i, 0, ri)
			rig.insert(i);
		sort(l, l + le);
		reverse(l, l + le);
		sort(r, r + ri);
		reverse(r, r + ri);
		set<int>::iterator it;
		//cout<<le<<' '<<ri<<' '<<res<<'\n';
		fore(i, 0, le)
		{
			//cout<<i<<'\n';
			it = lef.lower_bound(l[i].s);
			if(it != lef.end() && *it == l[i].s)
			{
				res += l[i].f;
				lef.erase(it);
			}
			else
			{
				if(it == lef.begin())
				{
					it = lef.end();
					it--;
					lef.erase(it);
				}
				else
				{
					it--;
					res += l[i].f;
					lef.erase(it);
				}
			}
		}
		fore(i, 0, ri)
		{
			//cout<<i<<'\n';
			it = rig.lower_bound(r[i].s);
			if(it != rig.end() && *it == r[i].s)
			{
				res += r[i].f;
				rig.erase(it);
			}
			else
			{
				if(it == rig.begin())
				{
					it = rig.end();
					it--;
					rig.erase(it);
				}
				else
				{
					it--;
					res += r[i].f;
					rig.erase(it);
				}
			}
		}
		cout<<res<<'\n';
	}
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2	

Measured memory_bytes: 14580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, 0, n){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    rep(i, 0, n){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ses   "\n"
#define whp   " "
#define mxi 99999

#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define PI acos(-1)
#define sz(a) long long(a.size())
#define ff first
#define ss second
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)

#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)

#define MS(a,b) memset(a,b,sizeof(a));

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll fx[4]= {1,-1,0,0};
ll fy[4]= {0,0,1,-1};

typedef vector<ll> vll;
typedef vector<string> vss;
typedef vector<pair<ll,ll > > vpr;
typedef vector<pair<string,ll > > vspr;
typedef list<ll> li;
typedef list<string> ls;
typedef list<pair<ll,ll> > lpr;
typedef list<pair<string,ll> > lspr;

bool rs(ll a, ll b){return(a>b);}
ll spd(ll n){ if(n%2==0)return 2; for(ll i=3; i*i<=n; i++){if(n%i==0)return i;}return n;}

int main(){

    ll l,r,n; cin>>l>>r>>n;
    ll c=0;
    for(ll i=l; i<=r; i++){
        if(i%n==0)c++;
    }
    cout<<c<<endl;

return 0;
}


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

struct edge{int from,to; ll cost;};

void add_edge(int x,int y,ll c,vector<edge> &G){
    edge e;
    e.from = x;
    e.to   = y;
    e.cost = c;
    G.push_back(e);
}

bool negative_cycle(int s,int t,int V,int E,const vector<edge> &G){
    vector<ll> d(V,INF);d[s]=0;
  vector<ll> d1(V,INF);d1[t]=0;
  vector<ll> tmp(V);
  vector<ll> tmp1(V);
    REP(i,2*V){
        REP(j,E){
            edge e=G[j];
            if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
            }
          if(d1[e.to]!=INF && d1[e.from]>d1[e.to]+e.cost){
          	d1[e.from]=d1[e.to]+e.cost;
          }
        }
        if(i==V-2){
        	REP(j,V){tmp[j]=d[j];tmp1[j]=d1[j];}
        }
    }
    bool res=false;
  REP(i,V){
  	if(d[i]!=tmp[i] && d1[i]!=tmp1[i])res=true;
  }
  return res;
}

void Bellman_Ford(int s,int V,int E,vector<ll> &d,const vector<edge> &G){
    REP(i,V)d[i]=INF;
    d[s]=0;
    REP(i,V){
        REP(j,E){
            edge e=G[j];
            if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
            }
        }
    }
}

int main(){
    int N, M; ll P;
    cin>>N>>M>>P;
    vector<edge> G;
    vector<ll> d(N);
    int a,b; ll c;
    REP(i,M){
        cin>>a>>b>>c;a--;b--;
        add_edge(a,b,-c+P,G);
    }
    if(negative_cycle(0,N-1,N,M,G))cout<<-1<<endl;
    else{
        Bellman_Ford(0,N,M,d,G);
        cout<<max(0LL,-d[N-1])<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val as = Array.fill(n + 1)(sc.nextLong())
    val bs = Array.fill(n)(sc.nextLong())

    var ans = 0L
    for (i <- bs.indices) {
      val one = math.min(as(i), bs(i))
      as(i) -= one
      bs(i) -= one
      ans += one
      val two = math.min(as(i + 1), bs(i))
      ans += two
      as(i + 1) -= two
      bs(i) -= two
    }

    println(ans)
  }
}


Measured memory_bytes: 70704
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

int main(void) {
  int n,u,v,m;
  cin>>n>>u>>v>>m;
  map<int,pair<int,int>> Usagi;
  map<int,pair<int,int>> Neko;
  REP(i,n)REP(j,n){
    int l;
    cin>>l;
    Usagi[l]=mp(i,j);
  }
  REP(i,n)REP(j,n){
    int l;
    cin>>l;
    Neko[l]=mp(i,j);
  }
  vector<int> Us(2*n+2,0);
  vector<int> Nk(2*n+2,0);
  int Us_cnt = 0;
  int Nk_cnt = 0;
  bool f=true;
  REP(i,m){
    int l;cin>>l;
    if(Usagi.find(l)!=Usagi.end()){
      auto p=Usagi[l];
      if(++Us[p.first] == n)
        Us_cnt++;
      if(++Us[n+p.second]==n)
        Us_cnt++;
      if(p.first==p.second)
        if(++Us[2*n]==n)
          Us_cnt++;
      if((p.first+p.second)==(n-1))
        if(++Us[2*n+1]==n)
          Us_cnt++;
    }
    if(Neko.find(l)!=Neko.end()){
      auto p=Neko[l];
      if(++Nk[p.first] == n)
        Nk_cnt++;
      if(++Nk[n+p.second]==n)
        Nk_cnt++;
      if(p.first==p.second)
        if(++Nk[2*n]==n)
          Nk_cnt++;
      if((p.first+p.second)==(n-1))
        if(++Nk[2*n+1]==n)
          Nk_cnt++;
    }
    if((Us_cnt>=u&&n>1) || (Us_cnt>=1&&u==n&&n==1)){
      if((Nk_cnt>=v&&n>1)||(Nk_cnt>=1&&v==n&&n==1)){
        cout<<"DRAW"<<endl;
      }else{
        cout<<"USAGI"<<endl;
      }
      f=false;
      break;
    }else if((Nk_cnt>=v&&n>1)||(Nk_cnt>=1&&v==n&&n==1)){
      cout<<"NEKO"<<endl;
      f=false;
      break;
    }
  }
  if(f)
    cout<<"DRAW"<<endl;
  return 0;
}

Measured memory_bytes: 19156
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
/* global variables */
/* function */
vector<pll> factorPair(ll x) {
    vector<pll> ret;
    for (ll i = 1; i * i <= x; i++) {
        if (x % i == 0)
            ret.push_back(pll(i, x / i));
    }
    return ret;
}
/* main */
int main(){
    ll N;
    cin >> N;
    vector<pll> factors = factorPair(N);
    ll ans = LINF;
    for (pll f : factors) {
        ans = min(ans, f.first + f.second - 2);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 200005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll k,n;
    cin>>k>>n;
    vll a(n);
    rep(i,0,n){
        cin>>a[i];
    }
    vll b(n);
    ll res=INF;ll sum=0;
    rep(i,1,n){
    	
        b[i-1]=abs(a[i]-a[i-1]);sum+=b[i-1];
    }
    b[n-1]=k-a[n-1]+a[0];
    sum+=b[n-1];
    cout<<(sum-(*max_element(all(b))));


    return 0;
}

Measured memory_bytes: 3328
A1 = [int(i) for i in input().split()]
A2 = [int(i) for i in input().split()]
A3 = [int(i) for i in input().split()]
# print(A1)
# print(A2)
# print(A3)

N = int(input())
B = []
for b in range(N):
    B.append(int(input())) 

for b in B:
    if b in A1:
        A1[A1.index(b)] = 0
    if b in A2:
        A2[A2.index(b)] = 0
    if b in A3:
        A3[A3.index(b)] = 0

if sum(A1) * sum (A2) * sum(A3) * (A1[0]+A2[0]+A3[0]) * (A1[1]+A2[1]+A3[1]) * (A1[2]+A2[2]+A3[2]) * (A1[0]+A2[1]+A3[2]) * (A1[2]+A2[1]+A3[0]) == 0:
    print("Yes")
else:
    print("No")



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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int ans=0;
    for(int i=1;i<=n;i++){
        int x;
        cin >> x;
        if(x%2 and i%2)ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
    int a;
    int h,m,s;
    scanf("%d",&a);
    h=a/3600;
    m=(a%3600)/60;
    s=a-(m*60+h*3600);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 592