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

using namespace std;
typedef long long ll;
ll t , n ,k, x , y , z , a , b , cntr , sum ;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> t ;
    t*=(t-1);
    cout << t/2 ;
    return 0;
}


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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 24659;

const int N = 1e5 + 20;
vector<int> G[N];
ll n, k, ans, fac[N];

ll powmod(ll x, ll y) {
	if (y == 0) return 1LL;
	ll tmp = powmod(x, y / 2);
	tmp = (tmp * tmp) % MOD;
	return ((y % 2 ? x : 1LL) * tmp) % MOD;
}

ll divmod(ll x, ll y) {
	return (x * powmod(y, MOD - 2)) % MOD;
}

ll P(ll r, ll n) {
	if (r > n) return 0;
	return divmod(fac[n], fac[n - r]);
}

void dfs(int v, int p = -1) {
	if (p == -1)
		ans = (ans * P((int)G[v].size(), k - 1)) % MOD;
	else
		ans = (ans * P((int)G[v].size() - 1, k - 2)) % MOD;
	for (int u : G[v])
		if (u - p)
			dfs(u, v);
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	fac[0] = 1;
	for (ll i = 1; i < N; i++)
		fac[i] = (fac[i - 1] * i) % MOD;
	cin >> n >> k;
	for (int i = 0, v, u; i < n - 1; i++) {
		cin >> v >> u;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	ans = k;
	dfs(1);
	cout << ans << endl;
}



Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  i64 n, a, b;
  cin >> n >> a >> b;

  if((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl;
  }
  else {
    i64 res = a + (b - a - 1) / 2;
    cout << min(a + (b - a - 1) / 2, n - b + 1 + (n - (a + n - b + 1)) / 2) << endl;
  }
}

Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

mod = 998244353

class BIT:
	def __init__(self, n):
		self.n = n
		self.nums = [0] * (n+1)
		
	def add(self, i, x):
		n, nums = self.n, self.nums
		i += 1
		while i <= n:
			nums[i] += x
			i += i & -i
	
	def sum(self, i):
		nums = self.nums
		s = 0
		i += 1
		while i:
			s += nums[i]
			i -= i & -i
		return s

N, K = rl()
lr = []
for i in range(K):
	l, r = rl()
	lr.append((l,r))

bit = BIT(N+1)
bit.add(1, 1)
bit.add(2, -1)

ans = 0
for i in range(1, N+1):
	s = bit.sum(i)
	s %= mod
	#print('s', s)
	for k in range(K):
		l, r = lr[k]
		if i+l <= N:
			#print('l', i+l, s)
			bit.add(i+l, s)
			if i+r+1 <= N:
				#print('r', i+r+1, -s)
				bit.add(i+r+1, -s)
			else:
				ans += s
				ans %= mod
print(ans)
#print(bit.sum(N) % mod)


Measured memory_bytes: 71520
import sys
import math
sys.setrecursionlimit(10**9)

def main():
    A,B,C,K = map(int,input().split())

    if K<= A:
        print(K)
    elif K<=B:
        print(A)
    else:
        print(2*A+B-K)

if __name__ == "__main__":
  main()


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

int main() {
	int N; cin >> N;
	int t, a; cin >> t >> a;
    int h[1100];
	float z[1100];
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		z[i] = t - h[i] * 0.006;
	}
	float m = 10000;
	int n;
	for (int i = 0; i < N; i++) {
		if (m > abs(a - z[i])) {
			m = abs(a - z[i]);
			n = i;
		}
	}
	cout << n + 1;
}


Measured memory_bytes: 256
K=int(input())

if K<=12:
    print(K)
    exit()

k=12

from collections import deque

d=deque(["2","3","4","5","6","7","8","9","10","11","12"])

while True:
    s=d.popleft()
    x=int(s[-1])
    if x==0:
        for i in ["0","1"]:
            temp=s+i
            d.append(temp)
            k+=1
            if k==K:
                print(temp)
                exit()
    elif x==9:
        for i in ["8","9"]:
            temp=s+i
            d.append(temp)
            k+=1
            if k==K:
                print(temp)
                exit()
    else:
        for j in [-1,0,1]:
            temp=s+str(x+j)
            d.append(temp)
            k+=1
            if k==K:
                print(temp)
                exit()

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

using ll = long long;
#define int ll

#define FOR(i, s, e) for (ll i = ll(s); i < (ll)e; ++i)
#define RFOR(i, s, e) for (ll i = ll(e) - 1; i >= ll(s); --i)
#define REP(i, n) for (ll i = 0, i##_size = n; i < i##_size; ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)

template <class T> void chmin(T& a, T b) { if (b < a) { a = b; } }
template <class T> void chmax(T& a, T b) { if (b > a) { a = b; } }

template <class T>
struct arr : public vector<T> {
	arr() {}
	arr(ll n, T v = T()) : vector<T>(n, v) {}

	ll sz() const {
		return (ll)this->size();
	}
	void pb(T v) {
		this->push_back(v);
	}
};

template <class T>
struct que : public queue<T> {
	ll sz() const {
		return (ll)this->size();
	}
	T popfront() {
		T v = this->front();
		this->pop();
		return v;
	}
};

using aint = arr<ll>;
using aaint = arr<arr<ll>>;

struct input_s {
	template <class T>
	operator T() {
		T var;
		cin >> var;
		return var;
	}
};

struct input_ar {
	ll n;
	input_ar(ll n_) : n(n_) {}

	template <class T>
	operator vector<T>() {
		vector<T> var(n);
		REP(i, n) {
			cin >> var[i];
		};
		return var;
	}
};

input_s input() {
	return input_s();
}
input_ar input(ll n) {
	return input_ar(n);
}

template <class T>
void output(T var) {
	cout << (var) << '\n';
}

void myMain();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(16);
	myMain();
	return 0;
}

void myMain() {
	int N = input();
	int M = input();

	aaint R(N);
	REP(i, M) {
		int a = input();
		int b = input();
		R[a - 1].pb(b - 1);
		R[b - 1].pb(a - 1);
	}

	aint froms(N, -1);

	que<ll> queue;
	queue.push(0);
	froms[0] = 0;

	while (queue.empty() == false) {
		ll p = queue.popfront();

		for (ll n : R[p]) {
			if (froms[n] != -1) {
				continue;
			}

			froms[n] = p;
			queue.push(n);
		}
	}

	output("Yes");
	FOR(i, 1, N) {
		output(froms[i] + 1);
	}
}


Measured memory_bytes: 12896
import java.util.List;
import java.util.Scanner;

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		long M = sc.nextLong();

		long ans=0;

		//N<=Mを保証する。
		if(N>M) {
			long t=N;
			N=M;
			M=t;
		}

		if(N==1 && M==1) {
			System.out.println(1);
		}else if(N==1){
			System.out.println(M-2);
		}else {
			ans=(N-2)*(M-2);
			System.out.println(ans);
		}


	}

	//以下テンプレート

	public static String numtoalpha(int i) {

		String alpha = "abcdefghijklmnopqrstuvwxyz";

		return alpha.substring(i, i + 1);

	}

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 23252
n=int(input())
d={"S":[],"H":[],"C":[],"D":[]}

for i in range(n):
    m,num=input().split()
    d[m].append(num)

for x in d:
    for i in range(1,14):
        if not str(i) in d[x]:
            print("{} {}".format(x,i))


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

int main()
{   int n;
    char s[100000];
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++){
        s[i]-='A';
        s[i]+=n;
        s[i]%=26;
        s[i]+='A';
    }
    
    printf("%s",s);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
int main(void){
    string s;
    cin>>s;
    ll n=s.size();
    ll p=0,g=0;
    for(int i=0;i<n;i++){
        if(s[i]=='p') p++;
        else g++;
    }
    cout<<n/2-p<<endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

class Road {
  public:
  int d, c;
  int from, to;
  Road(int d, int c, int from, int to): d(d), c(c), from(from), to(to) {}
  bool operator < (const Road &r) const {
    if (d == r.d) {
      return c < r.c;
    } else {
      return d < r.d;
    }
  }
};

static const int INF = 1e9+7;

int main() {
  int N, M;
  while(cin >> N >> M, N+M) {
    vector<vector<Road>> graph(N);
    vector<int> dist(N, INF);
    dist[0] = 0;
    vector<int> cost(N, INF); // 親ノードとの間のコスト
    cost[0] = 0;
    int U, V, D, C;
    rep(i, 0, M) {
      cin >> U >> V >> D >> C;
      U--;
      V--;
      Road r1 = Road(D, C, U, V);
      Road r2 = Road(D, C, V, U);
      graph[U].pb(r1);
      graph[V].pb(r2);
    }

    priority_queue<Road> pq;
    Road s_r = Road(0, 0, 0, 0);
    pq.push(s_r);
    while (!pq.empty()) {
      auto r = pq.top(); pq.pop();
      int u = r.to;

      if (dist[u] < r.d || cost[u] < r.c) continue;

      for (auto ri: graph[u]) {
        int v = ri.to;
        int d = ri.d;
        int c = ri.c;

        if (dist[u] + d < dist[v] || (dist[v] == dist[u] + d && cost[v] > c)) {
          dist[v] = dist[u] + d;
          cost[v] = c;
          pq.push(ri);
        }
      }
    }

    int ans = 0;
    rep(i, 1, N) {
      ans += cost[i];
    }

    cout << ans << endl;
  }

  return 0;
};



Measured memory_bytes: 5096
#include<stdio.h>

int N,A[100],c=0,i,j,t;

int main()
{
	for(i=0,scanf("%d",&N);i<N;scanf("%d",&A[i++]));
	for(i=0;i<N;i++)
	{
		for(t=j=i;j<N;j++)
			if(A[j]<A[t])
				t=j;
		if(i!=t)
		{
			A[i]^=A[t]^=A[i]^=A[t];
			c++;
		}
	}
	for(i=0;i<N;i++)
		printf("%d%s",A[i],i==N-1?"\n":" ");
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    long long int n,k;
    cin>>n>>k;
    cout<<(int)pow(k-1,n-1)*k<<endl;

    return 0;
}

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

int main()
{
    unsigned long long N,A,B;
    cin >> N >> A >> B;
    unsigned long long count = 0;

    count = N/(A+B)*A;
    if(N%(A+B) <= A)
        count = count + N%(A+B);
    else
    {
        count = count + A;
    }
    

    cout << count;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App{

  val sc = new Scanner(System.in)

  val n  = sc.nextInt
  val rs = Seq.fill(n)((sc.next, sc.nextInt))

  val rsSorted = rs.zipWithIndex.sortWith{ case ((ra,_), (rb,_)) =>
    if(ra._1.compareTo(rb._1) == 0) ra._2.compareTo(rb._2) > 0
    else ra._1.compareTo(rb._1) < 0
  }
  val res = rsSorted.map(_._2 + 1)

  res.foreach(println(_))
}

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

using i64 = int64_t;

constexpr i64 INF = 1e12;

struct Node{
    i64 n, m, cost;
    bool operator<(const Node &obj)const{
        return cost > obj.cost;
    }
};

i64 mini[1003][1003]={0};

int main(){
    int n, m;
    cin >> n >> m;
    vector<i64> d;
    for(int i=0;i<n;++i){
        i64 tmp;
        cin >> tmp;
        d.push_back(tmp);
    }
    vector<i64> c;
    for(int i=0;i<m;++i){
        i64 tmp;
        cin >> tmp;
        c.push_back(tmp);
    }

    for(int i=0;i<=n;++i){
        for(int j=0;j<=m;++j){
            mini[i][j] = INF;
        }
    }

    mini[0][0] = 0;
    priority_queue<Node> que;
    que.push((Node){0, 0, 0});
    while(!que.empty()){
        Node curr = que.top(); que.pop();
        if(curr.n == n){
            cout << curr.cost << endl;
            break;
        }
        if(curr.m + 1 <= m){
            i64 cost = curr.cost;
            if(mini[curr.n][curr.m+1] > cost){
                mini[curr.n][curr.m+1] = cost;
                que.push((Node){curr.n, curr.m+1, cost});
            }
            cost += d[curr.n] * c[curr.m];
            if(mini[curr.n+1][curr.m+1] > cost){
                mini[curr.n+1][curr.m+1] = cost;
                que.push((Node){curr.n+1, curr.m+1, cost});
            }
        }
    }

    return 0;
}



Measured memory_bytes: 9660
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N;
int M;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		rep(i,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll ans=0;
	cin>>n;
	Graph<ll> g(n);
	vl c(n),ansv(n);
	vb used(n,false);
	auto comp = [](tlll l,tlll r){
		if(get<0>(l)!=get<0>(r)) return get<0>(l) < get<0>(r);
		else return get<1>(l) < get<1>(r);
	};
	priority_queue<tlll,vector<tlll>,decltype(comp)> p(comp);

	vl ch(n);
	rep(i,n-1){
		int ina,inb;
		cin>>ina>>inb;ina--;inb--;
		g.add(ina,inb,0,false);
		ch[ina]++;ch[inb]++;
	}
	rep(i,n){
		if(ch[i]==1){
			p.push(tlll(ch[i],0,i));
			used[i]=true;
		}
	}
	rep(i,n)cin>>c[i];
	sort(all(c));
	rep(i,n-1)ans+=c[i];
	int i=0;
	while(!p.empty()){
		auto t=p.top();p.pop();
		ansv[get<2>(t)]=c[i];i++;
		for(auto x:g.edge[get<2>(t)]){
			if(used[get<0>(x)]==false){
				ch[get<0>(x)]--;
				if(ch[get<0>(x)]==1){
					p.push(tlll(ch[get<0>(x)],0,get<0>(x)));
					used[get<0>(x)]=true;
				}
			}
		}
	}
	cout<<ans<<endl;
	cout<<ansv<<endl;
}


Measured memory_bytes: 1724
#-*-coding:utf-8-*-

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    p = [a_list[i] for i in range(0, n, 2)]
    q = [a_list[i] for i in range(1, n, 2)]

    if n % 2 == 0:
        print(' '.join(map(str, q[::-1] + p)))
    else:
        print(' '.join(map(str, p[::-1] + q)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 29252
#include <bits/stdc++.h>
 
using namespace std;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"
 
#define sz(a) ((int)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())      //
#define cpres(c, val) (find(all(c), val) != (c).end()) //
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define forf(i, a, b) for (int i = (a); i < (b); i++)
#define forb(i, a, b) for (int i = (b); i >= (a); i--)
#define fo(i, n) forf(i, 0, n)
#define fob(i, n) forb(i, 0, n - 1)
 
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
 
const int INF = 9e18;
// const int N = 1e9 + 7;
const int N = 998244353;
 
const auto start_time = std::chrono::high_resolution_clock::now();
 
void zark() {
  #ifdef ZARK
  auto end_time = std::chrono::high_resolution_clock::now();
  std::chrono::duration<double> diff = end_time - start_time;
  cerr << "Time Taken : " << diff.count() << "s\n";
  #endif
}
 
#ifdef ZARK
#include "/home/aranjan/Desktop/CP/header.h"
#else
#define dbg(args...)
#endif
 
/* ------------------ Actual Coding Starts ------------------ */

void solve() {
  int s,w;
  cin >> s >> w;
  if(w>=s) cout << "unsafe\n";
  else cout << "safe\n";
}
 
int32_t main() {
  fastio;
  #ifdef ZARK
  freopen("input.in", "r", stdin);
  #endif
 
  // freopen("txt.in", "r", stdin);
  // freopen("txt.out", "w", stdout);
  // cout << fixed << setprecision(35);
 
  solve();
  zark();
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod)
{
  return modpow(a, mod - 2, mod);
}

int main()
{
  int n;
  cin>>n;
  REP(i,n){
    int a;
    cin>>a;
    if(a%2) continue;
    if(a%3==0 || a%5==0) continue;
    else{
      cout<<"DENIED"<<endl;
      return 0;
    }
  }
  cout<<"APPROVED"<<endl;
  
  return 0;
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
int N;long M,a,b;
long A;
template<typename T>
T extgcd(T a,T b,T&x,T&y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	T q=a/b;
	T g=extgcd(b,a-q*b,y,x);
	y-=q*x;
	return g;
}
main()
{
	cin>>N>>M;
	b=1;
	for(int i=0;i<N;i++)
	{
		cin>>A;
		long ta=A/2,tb=A;
		long x,y;
		long g=extgcd(tb,-b,x,y);
		if((a-ta)%g==0)
		{
			x*=(a-ta)/g;
		}
		else
		{
			cout<<0<<endl;
			return 0;
		}
		long B=b/(g>0?g:-g)*tb;
		long AA=ta+tb*x;
		AA%=B;if(AA<0)AA+=B;
		a=AA;
		b=B;
		if(a>M)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	cout<<(M-a)/b+1<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;
int n, m, c, b[30];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> c;
    for (int i = 0; i < m; i++) cin >> b[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int tmp = 0, cur;
        for (int j = 0; j < m; j++) {
            cin >> cur;
            tmp += b[j]*cur;
        }
        tmp += c;
        if (tmp > 0) ans++;
    }
    cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

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


int main()
{
    int A,B,C;
    int K;
    cin >> A >>B>>C;
    cin >> K;
    int ans=0;
    while(A>=B){
        B*=2;
        ans++;
    }
    while(B>=C){
        C*=2;
        ans++;
    }
    if(ans>K) cout << "No" << endl;
    else cout << "Yes" << endl;




    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();

		int sum[] = new int[N];
		int count = 0;

		int a[][] = new int[N][M];
		int b[] = new int[M];

		for(int i = 0; i < M; i++) {
			b[i] = sc.nextInt();
		}

		for(int i = 0; i < N; i++) {
			sum[i] = 0;
			for(int j = 0; j < M; j++) {
				//System.out.println(i + "," + j);
				a[i][j] = sc.nextInt();
				sum[i] += a[i][j] * b[j];
			}
			sum[i] += C;
			if(sum[i] > 0) {
				count++;
			}
		}

		System.out.println(count);

		sc.close();
	}

}

Measured memory_bytes: 23764
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node {int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
    if (u == NIL ) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u) {
    int h1 =0, h2 = 0;
    if ( T[u].left != NIL ) h1 = setHeight(T[u].left) + 1;
    if ( T[u].right != NIL ) h2 = setHeight(T[u].right) +1;
    return H[u] = ( h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
    if ( T[u].parent == NIL) return NIL;
    if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL ) return T[T[u].parent].left;
    if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL ) return T[T[u].parent].right;
    return NIL;
}

void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg = 0;
    if ( T[u].left != NIL) deg++;
    if ( T[u].right !=NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);
    
    if ( T[u].parent == NIL ) {
        printf("root\n");
    } else if ( T[u].left == NIL && T[u].right == NIL ) {
        printf("leaf\n");
    } else {
        printf("internal node\n");
    }
}

int main() {
    int v, l, r, root = 0;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++ ) T[i].parent = NIL;
    
    for (int i = 0; i < n; i++ ) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if ( l != NIL ) T[l].parent = v;
        if ( r != NIL ) T[r].parent = v;
    }
    
    for (int i = 0; i < n; i++ ) if ( T[i].parent == NIL ) root = i;
    
    setDepth(root, 0);
    setHeight(root);
    
    for (int i = 0; i < n; i++) print(i);
    
    return 0;
}


Measured memory_bytes: 2768
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
    	cin >> a[i];
    }
  	while(1){
	  	int tmp=0;
    	for(int j=0;j<n;j++){
    		if(a[j]%2==0){
    			a[j]=a[j]/2;
    			tmp++;
	    	}
    	}
	    if(tmp!=n){
	    	break;
    	}
    	else{
    		ans++;
    	}
    }
    cout << ans << endl;
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);

  string S;
  cin >> S;

  vector<int> lc(S.size());
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == '<') {
      lc[i] = (i ? lc[i - 1] : 0) + 1;
    }
  }

  vector<int> rc(S.size());
  for (int i = S.size() - 1; ~i; --i) {
    if (S[i] == '>') {
      rc[i] = (i + 1 < S.size() ? rc[i + 1] : 0) + 1;
    }
  }

  vector<int> val(S.size() + 1);
  for (int i = 0; i <= S.size(); ++i) {
    int l = i ? lc[i - 1] : 0;
    int r = i < S.size() ? rc[i] : 0;
    val[i] = max(l, r);
  }

  int64_t ans = accumulate(val.begin(), val.end(), (int64_t) 0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6684
import java.util.*;

public class Main {
	
	int count = 0;
	
	void bubbleSort(int[] A) {
		boolean f = true;
		while (f) {
			f = false;
			for (int i = A.length - 1; i >= 1; i--) {
				if (A[i] < A[i-1]) {
					int tmp = A[i];
					A[i] = A[i-1];
					A[i-1] = tmp;
					f = true;
					count++;
				}
			}
		}
	}

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < A.length; i++) {
			A[i] = scan.nextInt();
		}
		count = 0;
		bubbleSort(A);
		System.out.print(A[0]);
		for (int i = 1; i < A.length; i++) {
			System.out.print(" " + A[i]);
		}
		System.out.println();
		System.out.println(count);
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



Measured memory_bytes: 26100
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <queue>
#include <thread>
#include<bits/extc++.h>

using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")

#define ll long long

#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)
#define gllt(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define git(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pr(x) return !(printf("%lld\n", (long long)(x)))
#define pcs(ch, cs, x) printf("Case %c%d: %d\n", ch, cs, x)
#define pllcs(ch, cs, x) printf("Case %c%d: %lld\n", ch, cs, x)
#define pcsyn(ch, cs, st) printf("Case %c%d: %s\n", ch, cs, (st) ? "Yes" : "No")
#define pyn(st) printf("%s\n", (st) ? "yes" : "no")
#define pryn(st) return !(printf("%s\n", (st) ? "YES" : "NO"))
#define pll(x) printf("%lld\n", x)
#define plld(x, y) printf("%lld %lld\n", x, y)

#define mp(x, y) std::make_pair(x, y)
#define fcs(x) while (x--)
#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi freopen("in.txt", "r", stdin)
#define fo freopen("out.txt", "w", stdout)
#define siz(x) (int)x.size()
#define pb(x) push_back(x)

inline long long max(long long x, long long y) { return x > y ? x : y; }

inline long long min(long long x, long long y) { return x > y ? y : x; }

long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }

int main(){
    std::string a,b;
    std::cin >> a >> b;
    int len = a.length(), lenb = b.length();
    int ret = 0x3f3f3f3f;
    for (int i = 0; i < len - lenb + 1; ++ i){
        int cnt = 0;
        for (int j = 0; j < lenb; ++ j){
            if (a[i + j] != b[j]) cnt ++;
        }
    //    dbg(cnt);
        ret = min(ret, cnt);
    }
    pi(ret);
}

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

using namespace std;

int cnt = 0;
int MOD = 1000000007;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    int x = c-a, y = d-b;
    
    cout << c-y << " " << d+x << " " << a-y << " " << b+x << endl;
    
    return 0;
}


Measured memory_bytes: 256
n, x, *a = map(int, open(c:=0).read().split())
for i in range(n - 1):
    s = max(a[i] + a[i + 1] - x, 0)
    a[i + 1] -= s
    if a[i + 1] < 0:
        a[i] += a[i + 1]
        a[i + 1] = 0
    c += s
print(c)

Measured memory_bytes: 20108
n,q = gets.split.map(&:to_i)
s = gets.chomp

lrs = []
q.times do
  lrs << gets.split.map(&:to_i)
end

h = Hash.new(0)
h[0] = 0
n.times.with_index(1) do |_, i|
  break if s[i].nil?
  if s[i-1] == "A" && s[i] == "C"
    h[i+1] = h[i] + 1
  else
    h[i+1] = h[i]
  end
end

lrs.each do |lr|
  l,r = lr
  puts h[r] - h[l]
end


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

int main() {
    int n, cnt = 0; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    for (int i = 1; i < n-1; i++){
        if ( (p[i-1] < p[i]) && (p[i] < p[i+1]) || (p[i+1] < p[i]) && (p[i] < p[i-1])) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

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

using namespace std;



int main(){

int N,K;
cin >> N >> K;
long long H[N];
for (int i = 0; i < N; i++)
{
  cin >> H[i];
}

sort(H,H+N);

long long ans=0;
for (int i = N-1; i >=0 ; i--)
{
  if (K>0)
  {
    K--;
  }
  else ans += H[i];
  
}

cout << ans;

return 0;
}

Measured memory_bytes: 1792
while True:
    n = int(raw_input())
    if n == 0:
        break
    l = []
    for _ in range(n):
        hms1, hms2 = raw_input().split()
        l.append((hms1, True))
        l.append((hms2, False))
    l.sort()
    r, t = 0, 0
    for i in range(len(l)):
        if l[i][1]:
            t += 1
        else:
            t -= 1
        r = max(r, t)
    print r

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

int main() {
  int a,b,c,d;
  
  cin >> a >> b >> c >> d;
  
  int left_weight = a + b;
  int right_weight = c + d;
  
  if (left_weight > right_weight) {
  	cout << "Left" << endl;
  } else if (left_weight < right_weight) {
  	cout << "Right" << endl;
  } else {
  	cout << "Balanced" << endl;
  }
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	cout << N * N*N << endl;

	return 0;
}


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

int main()
{
  int n;
  cin>>n;
  int a[n],b[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i]>>b[i];
  }
  int count = 1,i=0;
  while(i<n-2)
  {
    if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2])
    {
      cout<<"Yes";
      return 0;
    }
    i++;
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(void){
    cout << fixed << setprecision(14);
    double W,H,x,y;
    cin >> W >> H >> x >> y;
    cout << W*H/2 << " ";
    if(x == W/2 && y == H/2) cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
import numpy as np

K,N=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
last=A[0]+K-A[N-1]
dist=[]
for i in range(N-1):
    dist.append(A[i+1]-A[i])
dist.append(last)

print(K-max(dist))

Measured memory_bytes: 42436
H, W = map(int, input().split())

N = 0
ans = list()
last_col = list()
for i in range(H):
    A_i = list(map(int, input().split()))
    for j in range(W - 1):
        if A_i[j] % 2 != 0:
            N += 1
            ans.append(((i + 1, j + 1), (i + 1, j + 2)))
            A_i[j] -= 1
            A_i[j + 1] += 1
    last_col.append(A_i[-1])
for i in range(H - 1):
    if last_col[i] % 2 != 0:
        N += 1
        ans.append(((i + 1, W), (i + 2, W)))
        last_col[i] -= 1
        last_col[i + 1] += 1
print(N)
for (y1, x1), (y1_, x1_) in ans:
    print(y1, x1, y1_, x1_)

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

int main(){
  
  string s,t;
  cin >> s >> t;
  int N=s.size();
  int M=t.size();
  
  
  vector<vector<int>> dp(N+1,vector<int>(M+1));
  
  
  
  rep(i,N+1){
  	rep(j,M+1){
      dp.at(i).at(j)=0;
    }
  }
    
  
  for(int i=1;i<N+1;i++){
    for(int j=1;j<M+1;j++){
      
      if(s.at(i-1)==t.at(j-1))
        dp.at(i).at(j)=max(dp.at(i).at(j),dp.at(i-1).at(j-1)+1);
      dp.at(i).at(j)=max(dp.at(i).at(j),dp.at(i).at(j-1));
      dp.at(i).at(j)=max(dp.at(i).at(j),dp.at(i-1).at(j));
            
    }
  }
  
// cout << dp.at(N).at(M) << endl;
  
  string res = "";
   // int i = (int)s.size(), j = (int)t.size();
    while (N > 0 && M > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[N][M] == dp[N-1][M]) {
            --N; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[N][M] == dp[N][M-1]) {
            --M; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[N-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --N, --M; // DP の遷移を遡る
        }
    }
    cout << res << endl;
}






Measured memory_bytes: 35584
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cout<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
vll factors;
for(ll i=1;i*i<=n;i++)
{
    if(n%i==0)
    {factors.pb(i);
    if((n/i)!=i)
    factors.pb(n/i);}
}
sor(factors);
vector<ll> ans;
for(auto x:factors)
{
    temp=n/x;
    temp--;
    if(temp>0 && n%temp==(n/temp))
    ans.pb(temp);
}
ll sum=0;
for(auto x:ans)
sum+=x;
cout<<sum;





return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int H,W,N,ans=0,m;

    cin >>H>>W>>N;

    m=max(H,W);

    int temp=0;
    while(temp<N){
        ans++;
        temp+=m;
    }
    
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import *
from math import *

INF = int(1e18)
N = int(input())
B = list(map(int, input().split()))
B = [INF] + B + [INF]

C = [INF]
for i in range(1, N + 1):
    C.append(min(B[i - 1], B[i]))
print(sum(C[1:]))

Measured memory_bytes: 38384
from queue import PriorityQueue
N, M = map(int, input().split())  # N件の仕事, M日後までに得られる報酬

jobs = [[] for _ in range(M)]  # 締め切りごとに仕事を格納する二重配列

for i in range(N):  # N件の仕事を見て行く
    a, b = map(int, input().split())
    if a > M:  # a日後にもらえる、そのaが期日のMよりも大きかったらスルー
        continue
    jobs[M-a].append(b)
    # 報酬がもらえるまでに時間がかかる仕事は、小さいindexに格納されていく
    # PriorityQueueに追加するときはjobsの後ろから見ていく

ans = 0
pq = PriorityQueue()

for i in range(M-1, -1, -1):  # jobsの後ろから見ていく
    for b in jobs[i]:
        pq.put(-b)  # min-heapだからマイナスに追加する

    if not pq.empty():
        ans += -(pq.get())

print(ans)


Measured memory_bytes: 19220
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	long long sum=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]-=(i+1);
	}
	sort(a,a+n);
	int x=a[n/2];
	for(int i=0;i<n;i++){
		a[i]-=x;
		sum+=abs(a[i]);
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 1024
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力

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

const int mod = 1e9+7;

ll x_to_y(ll x, ll y){
  ll ans;
  ans = (x + y) * (y - x + 1) / 2;
  //ans = ans % mod;
  return ans;
}

int main() {
  ll N, K, ans = 0;
  cin >> N >> K;
  for(ll i = K; i < N+2; i++){
    ll sub1;
    ll sub2;
    sub1 = x_to_y((N-i+1) , N) - x_to_y(0, (i-1)) + 1;
    sub2 = sub1 % mod;
    //cout << sub2 << endl;
    //ans += sub1;
    ans += sub2;
  }
  ans = ans % mod;
  cout << ans << endl;

}


Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No"<< endl;
    }

}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int result[3] = {0, 0, 0};
  for (size_t i = 0; i < 3; i++) {
    if (s[i] == 'a') result[0] = 1;
    if (s[i] == 'b') result[1] = 1;
    if (s[i] == 'c') result[2] = 1;
  }
  int total = 0;
  for (size_t i = 0; i < 3; i++) {
    total += result[i];
  }
  if (total == 3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#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<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll H, W, N;
    cin >> H >> W >> N;
    ll sr, sc;
    cin >> sr >> sc;
    sr--;sc--;
    string S, T;
    cin >> S >> T;

    bool flag = false;
    ll t = sc;
    REP(i, N){
    	if(S[i] == 'R') t++;
    	if(t > W-1) flag = true;
    	if(T[i] == 'L') t--;
    	t = max(t, 0ll);
    }
    //dump(flag)
    t = sc;
    REP(i, N){
    	if(S[i] == 'L') t--;
    	if(t < 0) flag = true;
    	if(T[i] == 'R') t++;
    	t = min(t, W-1);
    }
    //dump(flag)
    t = sr;
    REP(i, N){
    	if(S[i] == 'U') t--;
    	if(t < 0) flag = true;
    	if(T[i] == 'D') t++;
    	t = min(t, H-1);
    }
    //dump(flag)
    t = sr;
    REP(i, N){
    	if(S[i] == 'D') t++;
    	if(t > H-1) flag = true;
    	if(T[i] == 'U') t--;
    	t = max(t, 0ll);
    }
    //dump(flag)
    cout << (flag ? "NO" : "YES") << endl;
    return 0;
}

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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string ans;
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for (int y = sy; y < ty; ++y) ans += 'U';
  for (int x = sx; x < tx; ++x) ans += 'R';
  for (int y = sy; y < ty; ++y) ans += 'D';
  for (int x = sx; x < tx; ++x) ans += 'L';
  ans += 'L';
  for (int y = sy; y <= ty; ++y) ans += 'U';
  for (int x = sx; x <= tx; ++x) ans += 'R';
  ans += 'D';
  ans += 'R';
  for (int y = sy; y <= ty; ++y) ans += 'D';
  for (int x = sx; x <= tx; ++x) ans += 'L';
  ans += 'U';
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N+1);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> parent(N+1, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    parent[0] = 0;
    parent[1] = 0;
    que.push(1); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (parent[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            parent[nv] = v;
            que.push(nv);
        }
    }
  bool finish = true;
    for (int v = 2; v < N+1; ++v){
      if(parent[v]==0){
        cout <<"No";
        finish = false;
        break;
      }
    }
    if(finish){
        cout << "Yes" << endl;
      
    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 2; v < N+1; ++v) cout << parent[v] << endl;
      }
}

Measured memory_bytes: 10220
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a>12){
    	cout<<b<<endl;
    }
    else if(a<=12&&5<a){
    	cout<<b/2<<endl;
    }
    else{
    	cout<<0<<endl;
    }
   return 0;
}

Measured memory_bytes: 256