akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  int h;
  int ans = 0;
  cin >> n >> k;
  REP(i,n){
    cin >> h;
    if (h >= k)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# 2019-11-18 17:34:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, m = [int(x) for x in sys.stdin.readline().split()]
    a = [-int(x) for x in sys.stdin.readline().split()]

    heapq.heapify(a)
    for _ in range(m):
        highest = - heapq.heappop(a)
        heapq.heappush(a, -(highest // 2))
    
    print(-sum(a))
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 14200
N = int(input())
A1 = [int(i) for i in input().split()]
A2 = [int(i) for i in input().split()]

A2 = A2[::-1]

S1 = [0] * N
S2 = [0] * N
S1[0] = A1[0]
S2[0] = A2[0]

for i in range(1, N):
    S1[i] = S1[i-1] + A1[i]
    S2[i] = S2[i-1] + A2[i]


ans = 0
for i in range(N):
    ans = max(ans, S1[i]+S2[N-1-i])

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std; 
int main()
{
  string s1,s2;
  cin>>s1>>s2;
  int i,cnt=0;
  for(i=0;i<s1.size();i++)
  {
    if(s1[i]!=s2[i])cnt++;
  }
  cout<<cnt;
}
    

Measured memory_bytes: 3916
from heapq import heappush, heappop, heapreplace

def main():
    INF = 10 ** 9 + 7

    N, K, *TD = map(int, open(0).read().split())

    E = [[] for _ in range(N)]
    for t, d in zip(*[iter(TD)] * 2):
        E[t - 1].append(d)

    for e in E:
        if e:
            e.sort(reverse=True)
        else:
            e.append(-INF)
    E.sort(key=lambda x: -x[0])

    cur = 0
    Q = []
    for i in range(K):
        cur += E[i][0]
        for j in range(1, len(E[i])):
            heappush(Q, -E[i][j])

    for i in range(K, N):
        for eij in E[i]:
            heappush(Q, -eij)

    res = cur + K * K
    for x in reversed(range(1, K)):
        v, w = E[x][0], -Q[0]
        if v < w:
            heapreplace(Q, -v)
            cur += w - v

        tmp = cur + x * x
        if res < tmp:
            res = tmp

    print(res)

if __name__ == '__main__':
    main()


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    vi cost(n);
    rep(i,n) cin >> cost[i];
    rep(i,n) {
        i32 tmp;
        cin >> tmp;
        cost[i] -= tmp;
    }

    i32 cnt  = 0;
    for(auto val : cost) if(val >= 0) cnt += val;

    cout << cnt << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    int ch,dh,cw,dw;
    cin >> ch >> cw;
    cin >> dh >> dw;

    ch--;cw--;dh--;dw--;
    
    vector<string> s(h);
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }

    vector<vector<int>> dis(h, vector<int>(w, INT_MAX));//ここに到達できる最小ワープ回数を代入

    vector<pair<int, int>> move;
    move.push_back(make_pair(0, 1));
    move.push_back(make_pair(0, -1));
    move.push_back(make_pair(1, 0));
    move.push_back(make_pair(-1, 0));

    for (int i = -2; i <= 2; i++)
    {
        for (int j = -2; j <= 2; j++)
        {
            if(i == 0 && j == 0)continue;
            move.push_back(make_pair(i, j));
        }
    }
    deque<pair<int, int>> see_next;
    vector<vector<bool>> see_side_or_not(h, vector<bool>(w, false));
    see_next.push_front(make_pair(ch, cw));
    dis[ch][cw] = 0;
    //bfs
    while (!see_next.empty())
    {
        pair<int, int> v = see_next.front();
        see_next.pop_front();

        for (int i = 0; i < (int)move.size(); i++)
        {
            int nh = v.first + move[i].first, nw = v.second + move[i].second;
            if(nh < 0 || nh >= h || nw < 0 || nw >= w)continue;
            if(s[nh][nw] == '#')continue;

            if(i >= 4)
            {
                if(dis[nh][nw] != INT_MAX)continue;
                dis[nh][nw] = min(dis[nh][nw], dis[v.first][v.second] + 1);
                see_next.push_back(make_pair(nh, nw));
            }
            else
            {
                if(see_side_or_not[nh][nw])continue;
                dis[nh][nw] = min(dis[nh][nw], dis[v.first][v.second]);
                see_side_or_not[nh][nw] = true;
                see_next.push_front(make_pair(nh, nw));
            }
        }
    }
    if(dis[dh][dw] == INT_MAX)cout << -1 << endl;
    else cout << dis[dh][dw] << endl;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint x,y;
    cin >> x>>y;
    lint z = abs(y) - abs(x);
    lint ans=0;

    if(z*x<0){
        ans++;
    }
    ans += abs(z);
    if (z * y <0)
    {
        ans++;
    }
    if(z==0){
        ans = (x * y < 0);
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
from sys import exit
s=input()
xy=list(map(int,input().split()))

def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2
s=groupby(s)
ab=[[],[]]
turn=True
#初めまっすぐの場合
if s[0][0]=="F":
    xy[0]-=s[0][1]
    s.pop(0)
for i in s:
    if i[0]=="F":
        ab[not turn].append(i[1])
    elif i[1]%2==1:
        turn=not turn
for i in range(2):
    ab[i].sort(reverse=True)
    for j in ab[i]:
        xy[i]=abs(xy[i])-abs(j)
    if xy[i]!=0:
        print("No")
        exit()
print("Yes")

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

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

const ld INF = 1e20;

int main()
{
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> x(N), y(N), d(N);
	for (int i = 0; i < N; i++) {
		char c;
		cin >> x[i] >> y[i] >> c;
		d[i] = (c == 'R' ? 0 : c == 'L' ? 1 : c == 'U' ? 2 : 3);
	}
	auto calc = [&](ld t) {
		ld xmi = INF, xma = -INF, ymi = INF, yma = -INF;
		for (int i = 0; i < N; i++) {
			ld tx = x[i] + dx[d[i]] * t;
			ld ty = y[i] + dy[d[i]] * t;
			xmi = min(xmi, tx);
			xma = max(xma, tx);
			ymi = min(ymi, ty);
			yma = max(yma, ty);
		}
		return (xma - xmi) * (yma - ymi);
	};
	ld lb = 0, ub = 1e9;
	int cnt = 120;
	while (cnt--) {
		ld m1 = (lb * 2 + ub) / 3, m2 = (lb + ub * 2) / 3;
		if (calc(m1) < calc(m2)) {
			ub = m2;
		}
		else {
			lb = m1;
		}
	}
	cout << calc(lb) << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll int64_t
#define ld long double
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll,null_type , less<ll>,rb_tree_tag,tree_order_statistics_node_update> set_2i;
typedef tree<ld,null_type , less<ld>,rb_tree_tag,tree_order_statistics_node_update> set_2d;
typedef tree<string,null_type , less<string>,rb_tree_tag,tree_order_statistics_node_update> set_2s;
const ll INF = 99999999999;
string yes = "YES", no = "NO";

void Oli(){
    int a;
    cin>>a;
    if (a == 1) cout<<"0";else
        cout<<1;
}
int main()
{
    int times  = 1;
    //cin>>times;
    while( times--) Oli();
    //BY ME
}


Measured memory_bytes: 3612
#include <stdio.h>

static int N = 100;

int main(){
    int n,i,l,j,k;
    int p[N+1],m[N+1][N+1],cost=0;
   
    scanf("%d",&n);
    
    for(i=1;i<=n;i++){
        scanf(" %d %d",&p[i-1],&p[i]);
    }
    for(i=1;i<=n;i++) {
        m[i][i]=0;
    }
    for(l=2;l<=n;l++) {
        for(i=1;i<=n-l+1;i++){
        j = i+l-1;
            m[i][j]=(1 << 21);
            for(k=i;k<=j-1;k++){
                
                cost = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
                
                if( cost < m[i][j] ){
                    m[i][j] = cost;
                }
            }
        }
    }
     printf("%d\n",m[1][n]);
    return 0;
        
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
long long N;
int main() {
    cin >> N;
    vector<long long> H(N);
    for(int i = 0; i < N; ++i) {
        cin >> H.at(i);
    }

    int max = 0;
    int count = 0;
    for(int i = 0; i < N-1; ++i) {
        if(H.at(i) >= H.at(i+1)) {
            count++;
        }else {
            if(max < count) {
                max = count;
            }
            count = 0;
        }
    }
    if(max < count) {
        max = count;
    }
    cout << max << endl;
}

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

int main() {
	string s, t;
  	cin >> s >> t;
  	int ans = 0;
  	for (int i = 0; i < 3; i++)
      	if(s[i] == t[i])
          	ans++;
  	cout << ans << endl;
  	return 0;
}

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

int main(void) {
  string ss;
  cin >> ss;

  int N = ss.size();
  queue<int> Q;
  queue<int> V;

  char now = 'R';
  int cnt = 0;
  for(int i=0;i<N;i++) {
    if(ss.at(i)==now) { 
      cnt++;
      //cout << ss.at(i) << "1";
    }
    else if(ss.at(i)!=now&&now=='R') {
      Q.push(cnt);
      cnt = 1;
      now = 'L';
      //cout << ss.at(i) << "2";
    }
    else {
      Q.push(cnt);
      cnt = 1;
      now = 'R';
      //cout << ss.at(i) << "3";
    }
    if(i==N-1) Q.push(cnt);
  }

  int R, L, m;
  while(!Q.empty()) {
    R = Q.front(); Q.pop();
    L = Q.front(); Q.pop();
    //cout <<"[" << R << L << "]";

    for(int i=0;i<R-1;i++) {
      V.push(0);
      //cout << 0 << endl;
    }

    if((R+L)%2==0) {
      m = (R+L)/2;
      V.push(m);
      V.push(m);
      //cout << m << endl;
      //cout << m << endl;
    }
    else {
      m = (R+L-1)/2;
      if(R%2==0) {
        V.push(m);
        //cout << m << endl;
        V.push(R+L-m);
        //cout << R+L-m << endl;
      }
      else {
        V.push(m+1);
        V.push(R+L-m-1);
        //cout << m+1 << endl;
        //cout << R+L-m-1 << endl;
      }
    }

    for(int i=0;i<L-1;i++) {
      V.push(0);
      //cout << 0 << endl;
    }
  }

  for(int i=0;i<N;i++) {
    cout << V.front() << " ";
    V.pop();
  }
  cout << endl;

  return (0);
}


Measured memory_bytes: 1024
import sys
S = input()
N = len(S)

def is_palindrome(s):
    return s == s[::-1]

if not is_palindrome(S):
    print('No')
    sys.exit()

if not is_palindrome(S[0:int((N - 1) / 2)]):
    print('No')
    sys.exit()

if not is_palindrome(S[int((N + 3) / 2 - 1):]):
    print('No')
    sys.exit()

print('Yes')

Measured memory_bytes: 9084
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<int> a(N), b(N), c(N-1);
  for(int i=0; i<N; i++) cin >> a[i];
  for(int i=0; i<N; i++) cin >> b[i];
  for(int i=0; i<N-1; i++) cin >> c[i];
  
  int ans = 0;
  for(int i=0; i<N; i++){
    int j = a[i] - 1;
    ans += b[j];
    if(a[i] + 1 == a[i+1]){
      ans += c[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String val1 = sc.next();

        int count = 0;
        String temp = "";
        for (int i = 0; i < val1.length(); i++) {
            // ACGT
            String target = "" + val1.charAt(i);
            switch (target) {
                case "A":
                case "C":
                case "G":
                case "T":
                    temp = temp + val1.charAt(i);
                    continue;
                default:
                    if (count < temp.length()) {
                        count = temp.length();
                    }
                    temp = "";
            }
        }
        if (count < temp.length()) {
            count = temp.length();
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22868
// finish date: 2018/01/15
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


using edge = struct {
    int to;
    ll cost;
};


vector<ll> d;
vector<vector<edge>> tree;

void dfs(int num, ll cost) {
    d[num] = cost;
    for (auto e:tree[num]) {
        if (d[e.to] != -1) continue;
        dfs(e.to, d[num] + e.cost);
    }
}


int main() {
    int N;
    cin >> N;
    d = vector<ll>(N, -1);
    tree = vector<vector<edge>>(N);

    int a, b, c;
    rep(i, N - 1) {
        cin >> a >> b >> c;
        a--;
        b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }

    int Q, K;
    cin >> Q >> K;
    dfs(K - 1, 0);
    int x, y;
    rep(i, Q) {
        cin >> x >> y;
        cout << d[x - 1] + d[y - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 12800
import math
def A():
    num = int(input())
    odd_nums = math.ceil(num/2.0)
    print(odd_nums/num)

def B():
    temp = [int(i) for i in input().split()]
    N = temp[0]
    K = temp[1]
    heights = [int(i) for i in input().split()]
    ans = 0
    for h in heights:
        ans += 1 if h >= K else 0
    print(ans)
    
B()


Measured memory_bytes: 11904
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int n;
ll a, b, c;

int main()
{
	cin >> n;
	
	if (n % 4 == 0) {
		a = 3 * n / 4;
		cout << a << " " << a << " " << a<<endl;
		return 0;
	}
	if (n % 2 == 0) {
		cout <<  n/2 << " " << n << " " <<n<< endl;
		return 0;
	}
	if (n % 4 == 3) {
		cout << n / 4 + 1 << " " << n*(n / 4 + 1) * 2 << " " << n*(n / 4 + 1) * 2 << endl;
		return 0;
	}
	
	int m = n / 4 + 1;
	//if (m % 2 != 0)m++;
	int i = m;
	int k;
	int l;
	
	while (i<=4000) {
	
		k = 4 * i - n;
		l = n*i;

		for (int j = 1; j <= k / 2; j++) {
			int m = k - j;
			if (l%m == 0 && l%j == 0) {
				a = i;
				b = l / m;
				c = l / j;
				break;
			}
		}
		/*

		if (n*i % (k - 1) == 0) {
			a = i;
			b = n*i;
			c = n*i / (k - 1);
			break;
		}
		if (n*i%k == 0) {
			a = i;
			b = 2*n*i / k;
			c = 2 * n*i / k;
		}
		*/
		
		i++;
	}
	
	if(4*a*b*c==n*(a*b+b*c+c*a))cout << a<< " "<< b <<" "<< c << endl;

	


	return 0;
}

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

using namespace std;

typedef long long ll;
// typedef pair<ll, ll> P;
typedef pair<int, int> P;
typedef vector<P> vp;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> u(N - 1), v(N - 1), w(N - 1);
  vector<vp> G(100010);
  REP(i, N - 1)
  {
    cin >> u[i] >> v[i] >> w[i];
    u[i]--, v[i]--;
    G[u[i]].push_back(P(v[i], w[i]));
    G[v[i]].push_back(P(u[i], w[i]));
  }
  vector<bool> visit(100010, false);
  vector<int> color(100010, 0);
  queue<int> que;
  que.push(u[0]);
  while (que.size())
  {
    int p = que.front();
    visit[p] = true;
    que.pop();
    REP(i, G[p].size())
    {
      P q = G[p][i];
      if (!visit[q.first])
      {
        if (q.second % 2 == 0)
        {
          que.push(q.first);
          color[q.first] = color[p];
        }
        else
        {
          que.push(q.first);
          color[q.first] = color[p] == 0 ? 1 : 0;
        }
      }
    }
  }
  REP(i, N)
  cout << color[i] << endl;
  return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>

int main(void){
  int i,j,n,m,cn;
  char c,s[5]={'S','H','C','D','\0'};
  static int card[4][13];
  scanf("%d\n",&n);

  for(i=0;i<n;i++){
    scanf("%c %d\n",&c,&m);
    for(j=0;j<4;j++)
      if(s[j]==c)
        card[j][m-1]=1;
  }
  
  for(i=0;i<4;i++)
    for(j=0;j<13;j++)
      if(card[i][j]==0)
        printf("%c %d\n",s[i],j+1);

  return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
int a[105];
int main(voide){

  int n;
  scanf("%d",&n);
 
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);

  for(int i=0;i<n;i++){
    int x=a[i];
    int j=i-1;

    while(j>=0&&a[j]>x){
      a[j+1]=a[j];
       j--;
    }

  a[j+1]=x;
    for(int i=0;i<n;i++)
      if(i==0) printf("%d",a[i]);
      else printf(" %d",a[i]);
    
      printf("\n");
    }
 
    return 0;

  }


Measured memory_bytes: 2076
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char[] s = sc.next().toCharArray();
		HashSet<Character> hs = new HashSet<>();
		boolean b = true;
		for (int i = 0; i < s.length; i++) {
			if (hs.add(s[i])) {
			} else {
				b = false;
				break;
			}
		}
		if (b) {
			System.out.println("yes");
		} else {
			System.out.println("no");
		}
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	char S[101];
	scanf("%s", S);
	int ans = 0;
	int N = strlen(S);
	int N2 = N / 2;
	for (int i = 0;i < N2;i++) {
		if (S[i] != S[N - i-1])
			ans++;
	}
	cout << ans;
 	return 0;
}

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

#define rep(i, n) for(int i=0; i < (int)n; i++)

using namespace std;
using ll = long long;
using ushort = unsigned short;
using uint = unsigned int;
using ulong = unsigned long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

int main(void) {
  double L;
  cin >> L;

  printf("%lf", pow(L/3, 3));

  return 0;
}


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

using ll = long long;

const int MAX_N = 60;
const int MAX_M = 60;

ll a[MAX_N], b[MAX_N], c[MAX_M], d[MAX_M];

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

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

    for (int i = 0; i < m; i++) {
        cin >> c[i] >> d[i];
    }

    for (int i = 0; i < n; i++) {
        int no = 0;
        for (int j = 0; j < m; j++) {
            if (abs(a[i] - c[j]) + abs(b[i] - d[j]) <
                abs(a[i] - c[no]) + abs(b[i] - d[no])) {
                no = j;
            }
        }
        cout << no + 1 << endl;
    }

    return 0;
}


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

int main(){
  int N,K,x,s;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    cin >> x;
    if(K/2<x)
      s+=K-x;
    else
      s+=x;
  }
  cout << 2*s;
}

Measured memory_bytes: 256
object Main extends App {
  val isExistCard = Array.fill(4,13)(false)
  val suites = Map("S" -> 0, "H" -> 1, "C" -> 2, "D" -> 3)

  val n = readLine().toInt

  for (i <- 0 until n) {
    val Seq(s, strr) = readLine().split(' ').toList
    isExistCard(suites(s))(strr.toInt - 1) = true
  }

  for {
    k <- suites.keysIterator
    m <- 1 to 13
  } if (!isExistCard(suites(k))(m - 1))
    println("%s %d".format(k, m))
}



Measured memory_bytes: 44016
s=input()
n=len(s)
ans=[1]*n
anss=[0]*n
for i in range(n):
  if s[i]=="R":
    if s[i+1]=="R":
      ans[i+1]+=ans[i]
      ans[i]=0
    else:
      anss[i+1]+=ans[i]//2
      anss[i]+=0--ans[i]//2
for i in range(n-1,-1,-1):
  if s[i]=="L":
    if s[i-1]=="L":
      ans[i-1]+=ans[i]
      ans[i]=0
    else:
      anss[i-1]+=ans[i]//2
      anss[i]+=0--ans[i]//2
print(*anss)

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N; cin >> N;
  int ans=0;
  if(N==2){
    cout << 0 << endl;
    return 0;
  }
  for(int i=1;i*i<N;i++){
    if(N%i==0){
      if((N-i)/i!=i) ans+=(N-i)/i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
llist = []
rlist = []
for i in range(m):
    l, r = map(int, input().split())
    llist.append(l)
    rlist.append(r)

c = 0
lm = max(llist)
rm = min(rlist)
for i in range(1, n + 1):
    if lm <= i <= rm:
        c += 1

print(c)


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

int a[200];
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			for (int k = j + 1; k <= n; k++) {
				set<int> se;
				se.insert(a[i]);
				se.insert(a[j]);
				se.insert(a[k]);
				vector<int> v(se.begin(), se.end());
				if (v.size() == 3 && v[0] + v[1] > v[2]) ans++;
			}
		}
	}
	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3652
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb1=new StringBuilder();
		StringBuilder sb2=new StringBuilder();
		String b=" ",n="\n";
        String[] rc=br.readLine().split(b);
        int r=Integer.parseInt(rc[0]);
        int c=Integer.parseInt(rc[1]);
        int[] ct=new int[c];
        int t=0;
        for(int i=0;i<r;i++){
        	String str=br.readLine();
        	String[] row=str.split(b);
        	int rt=0;
        	for(int j=0;j<c;j++){
        		int v=Integer.parseInt(row[j]);
        		ct[j]+=v;
        		rt+=v;
        		if(i==r-1){
        			t+=ct[j];
        			sb2.append(ct[j]+b);
        		}
        	}
        	sb1.append(str+b+rt+n);
        }
        sb1.append(sb2).append(t);
        System.out.println(sb1);
	}
}

Measured memory_bytes: 25204
#include<stdio.h>
#include<iostream>

using namespace std;

int main() {
  	const int MAX_N = 100000;
	char S[MAX_N+1];
	cin >> S;
	int i = 0;
	int n = 0, m = 0;
	int ans = 0;
	while (S[i] != '\0') {
		if (S[i] == '0')n++;
		else m++;
		if (n > 0 && m > 0) {
			ans += 2;
			n--;
			m--;
		}
		i++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
# 予め用意しておく
require 'prime'
now = 0
arr = (0..10**5).map do |x|
  if Prime.prime?(x) && Prime.prime?((x+1)/2)
    now+=1
  end
  x = now
end
gets.to_i.times do
  l, r = gets.chomp.split.map(&:to_i)
  puts arr[r]-arr[l-1]
end

Measured memory_bytes: 3576
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a,b,c = inm()
if a==b and a!=c or a==c and a!=b or b==c and b!=a:
    print('Yes')
else:
    print('No')


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  vector<int> vec;
  vec =  {A, B, C};
  
  sort(vec.begin(), vec.end());
  cout << abs(vec.at(0) - vec.at(1)) + abs(vec.at(1) - vec.at(2)) << endl;   
}

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

int main()
{
    char s[100001];
    scanf("%s", s);
    int i;
    int len = strlen(s);
    for (i=0; i<len; i+=2)
    {
        printf("%c", s[i]);
    }
    printf("\n");
    return 0;
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

int getDigit(ll num) {
  int digit=0;
  while(num!=0) {
    num /= 10;
    digit++;
  }
  return digit;
}

int main() {
  ll N; cin >> N;
  
  ll res = 1e9;
  for(ll i=1; i*i<=N; ++i) {
    if (N%i !=0) continue;
    ll b = N/i;
    ll tmp = max(getDigit(i),getDigit(b));
    res = min(res,tmp);
  }
  dump(res);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"

string to_string_keta(const long long int l, const int keta) {
	ostringstream oss;

	oss << std::setw(keta) << std::setfill('0') << l;

	return oss.str();
}
int main() {
	cout << fixed << setprecision(22);
	string st;
	while (getline(cin,st)) {
		int a = st.find(',');
		int b = st.find(',',a+1);
		const int num = stoi(st.substr(0, a));
		const ld wei = stold(st.substr(a + 1, b - a - 1));
		const ld hei = stold(st.substr(b + 1));
		const ld bmi = wei / hei / hei;
		if (bmi > 25 - eps)cout << num << endl;

	}

	return 0;
}

Measured memory_bytes: 3264
#include<stdio.h>
int Air(int a, int b, int c){
  int A = a + b;
  int B = a + c;
  int C = b + c;
  
   int min = A;
   if(B < min)
  min = B;
  if(C < min)
  min = C;
  return min;
}

int main(){
  int P,Q,R;
  scanf("%d %d %d", &P, &Q, &R );
  printf("%d" , Air(P,Q,R));

  return 0;
}


Measured memory_bytes: 128
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 



using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
int main(void){
    ll A,B,C;cin>>A>>B>>C;
    ll d=A-B;
    ll ans=C-d;
    if(ans<0)cout<<0;
    else cout<<ans;
    cout<<"\n";
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n;
	cin >> n;
	vector<int>h(n);
	rep(i, n) {
		cin >> h[i];
	}
	int buffer = 0;
	rep(i, n) {
		if (i == 0) {
			buffer = h[i];
			continue;
		}
		if (h[i] < buffer - 1) {
			cout << "No";
			return 0;
		}else if (h[i] < buffer) {
			buffer = h[i] + 1;
		}
		else{
			buffer = h[i];
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
N = int(input())
arr = [str(i) for i in range(1, N+1)]
total = 0
pair = {(str(i), str(j)): 0 for i in range(0, 10) for j in range(0, 10)}
for i in arr:
    a = i[0]
    b = i[-1]
    pair[(a, b)] += 1
for i in arr:
    a = i[-1]
    b = i[0]
    total += pair[(a, b)]
print(total)

Measured memory_bytes: 15768
import java.lang.*;
import java.util.*;
public class Main
{
    static Scanner sc = new Scanner(System.in);
        
    public static void main(String args[])
    {

        while(true){
            
            int p = sc.nextInt();
            int n = sc.nextInt();
            
            if(p==0 && n ==0) break;
            int[] a = new int[21];
            
            for(int c=0; c<21; c++){
                if(c==0) a[0] = p;
                else{
                    p = a[c-1];
                    int[] s = new int[10];
                    
                    for(int i=0; i<n; i++){
                        if(p == 0) s[0]++;
                        else{
                            s[p%10]++;
                            p /= 10;
                        }
                    }
                    
                    int max = 0;
                    for(int i=9; i>=0; i--){
                        if(s[i] == 0) continue;
                        if(s[i] > 0){
                            while(s[i]-- > 0){
                                max += i;
                                max *= 10;
                            }
                        }
                    }
                    
                    a[c] += max/10;
                    int min = 0;
                    for(int i=0; i<n; i++){
                        if(max == 0)break;
                        
                        max /= 10;
                        min += max % 10;
                        min *= 10;
                    }
                    
                    
                    a[c] -= min/10;
                    
                    boolean f = false;
                    for(int i=0; i<c; i++){
                        
                        if(a[i] == a[c]){
                            f = true;
                            System.out.println(i + " " + a[c] + " " + (c-i) );    
                        }
                    }
                    if(f) break;  
                    
                }
            }
        }
    }
    
}

Measured memory_bytes: 20216
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]

left = 0
right = 100000*10000

while (right - left > 1):
    mid = (left + right)//2
    s = 0
    j = 1
    for i in range(n):
        if mid < w[i]:
            j = 100000
            break
        s += w[i]
        if s > mid:
            j += 1
            s = w[i]
    if j > k:
        left = mid
    else:
        right = mid
        
print(right)


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

void judge_status_summary() {
	int n, c[4] = {0, 0, 0, 0};
	cin >> n;
	string str;
	for (int i = 0; i < n; ++i) {
		cin >> str;
		c[0] = (str == "AC") ? ++c[0] : c[0];
		c[1] = (str == "WA") ? ++c[1] : c[1];
		c[2] = (str == "TLE") ? ++c[2] : c[2];
		c[3] = (str == "RE") ? ++c[3] : c[3];
	}
	cout << "AC x " << c[0] << endl
		 << "WA x " << c[1] << endl
		 << "TLE x " << c[2] << endl
		 << "RE x " << c[3] << endl;
}

int main() {
	judge_status_summary();
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

const int INF=1<<24;

const int MAX_N=210;
const int MAX_M=10010;
const int MAX_R=1010;
int n,m,r;
int x[MAX_M];
int y[MAX_M];
int t[MAX_M];
char sl[MAX_M];
int z[MAX_R];
int dp[MAX_R][MAX_N];
int dl[MAX_N][MAX_N];
int ds[MAX_N][MAX_N];
/*
  繧ｳ繧ｹ繝・dp[縺ｩ縺薙∪縺ｧ驕疲・縺励※縺・ｋ縺犠[闊ｹ縺ｮ菴咲ｽｮ]
  dp[i][j]=min(dp[i-1][j]+dl[from][to], dp[i-1][k]+dl[from][k]+ds[k][l]+dl[l][to] for k in {0..n-1} for l in {0..n-1})
 */
void solve(){
  REP(i,n) fill_n(dl[i],n,INF);
  REP(i,n) fill_n(ds[i],n,INF);
  REP(i,n) dl[i][i]=ds[i][i]=0;
  REP(i,m){
    if(sl[i]=='L')
      dl[x[i]][y[i]]=dl[y[i]][x[i]]=t[i];
    else
      ds[x[i]][y[i]]=ds[y[i]][x[i]]=t[i];
  }
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	dl[i][j]=min(dl[i][j],dl[i][k]+dl[k][j]);
	ds[i][j]=min(ds[i][j],ds[i][k]+ds[k][j]);
      }
    }
  }
  REP(i,r)REP(j,n)dp[i][j]=INF;

  dp[0][z[0]]=0;
  for(int i=1;i<r;i++){
    REP(shipFrom,n){
      REP(shipTo,n){
        if(shipFrom==shipTo){
          dp[i][shipTo]=min(dp[i][shipTo],dp[i-1][shipFrom]+dl[z[i-1]][z[i]]);
        }else{
          dp[i][shipTo]=min(dp[i][shipTo],dp[i-1][shipFrom]+dl[z[i-1]][shipFrom]+ds[shipFrom][shipTo]+dl[shipTo][z[i]]);
        }
      }
    }
  }
  int result=INF;
  REP(i,n)result=min(result,dp[r-1][i]);
  cout<<result<<endl;
}

int main(){ _;
  while(cin>>n>>m,(n|m)!=0){
    REP(i,m){
      cin>>x[i]>>y[i]>>t[i]>>sl[i];
      x[i]--;y[i]--;
    }
    cin>>r;
    REP(i,r){
      cin>>z[i];
      z[i]--;
    }
    solve();
  }
}



Measured memory_bytes: 4420
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 


ll dfs(vll adj[], ll i, bool vis[]){
    vis[i]=true;
    ll ans = 1;
    for(auto j:adj[i]){
        if(!vis[j]){
            ans += dfs(adj, j,vis);
        }
    }
    return ans;
}



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   ll n,m;
   cin>>n>>m;
   set<ll> adj[n+1];
   vll adj2[n+1];
   lp(0,m){
       ll x,y;
       cin>>x>>y;
       if(adj[x].find(y)==adj[x].end()){
       adj[x].insert(y);
       adj2[x].pb(y);
       }
       if(adj[y].find(x)==adj[y].end()){
       adj[y].insert(x);
       adj2[y].pb(x);
       }
   }
   bool vis[n+1];
   memset(vis, false, sizeof(vis));
   ll ans = 0;
   lp(1,n+1){
       if(!vis[i]){
           ll x = dfs(adj2, i, vis);
           ans = max(x, ans);
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 52172
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
//        int[] arr = new int[k*2-1];
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < k*2-1; i++){
//            arr[i] = x-k+1+i;
            sb.append(x-k+1+i).append(' ');
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i = 1; i*i <= n; i++){
        if(n%i) continue;
        res.pb(i);
        if(i*i != n) res.pb(n/i);
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    int ans = 0;
    for(ll x : divisor(n)){
        if(x == 1) continue;
        ll tmp = n;
        while(tmp%x==0) tmp /= x;
        if(tmp % x == 1) ++ans;
    }
    ans += divisor(n-1).size()-1;
    cout << ans << endl;
    return 0;
}

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

int item[101][302];
int memo[101][302]={};
int what[101];

int s,d,m;

int dfs(int x,int p){
	if( x == d ) return 0;
	if( memo[x][p] != -1) return memo[x][p];
	
	int ans = 0;
	for(int i = 0 ; i <= p ; i++){
		ans = max( ans , dfs(x+1,p-i) + item[what[x]][i] );
	}
	return memo[x][p] = ans;
}

int main(){
	while(cin >> s >> d >> m && s ){
		for(int i = 0 ; i < s ; i++){
			int w[55],p[55],k,dp[301]={};
			cin >> k;
			for(int j = 0 ; j < k ; j++) cin >> w[j] >> p[j];
			
			for(int j = 0 ; j < k ; j++){
				for(int l = 300 ; l >= p[j] ; l--){
					dp[l] = max(dp[l],dp[l-p[j]]+w[j]);
				}
			}
			for(int j = 0 ; j <= 300 ; j++){
				item[i][j] = dp[j];
				//if( j <= 100 ) cout << i << "," << j << ": " << item[i][j] << endl;
			}
		}
		for(int i = 0 ; i < d ; i++)
			cin >> what[i];
		memset(memo,-1,sizeof(memo));
		int maxi = dfs(0,m);
		for(int i = 0 ; i <= m ; i++){
			if( dfs(0,i) == maxi){
				cout <<	maxi << " " << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1416
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=2e5+5;
int n;
pair<int,int>a[N];
bool judge(int k,int x,int y)
{
    int l=0,r=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i].fi<=k) l++;
        if(a[i].se>=k) r++;
    }
    return l>=x&&r>=y;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].fi,&a[i].se);
    sort(a+1,a+1+n);
    if(n&1)
    {
        int m=n/2+1,low=a[m].fi;
        for(int i=1;i<=n;i++) swap(a[i].fi,a[i].se);
        sort(a+1,a+1+n);
        int up=a[m].fi;
        printf("%d\n",up-low+1);
    }
    else
    {
        int m=n/2,low=a[m].fi+a[m+1].fi;
        for(int i=1;i<=n;i++) swap(a[i].fi,a[i].se);
        sort(a+1,a+1+n);
        int up=a[m].fi+a[m+1].fi;
        printf("%d\n",up-low+1);
    }
}


Measured memory_bytes: 5380
#include<stdio.h>
#include <iostream>
#include <string.h>
 
using namespace std;
 
typedef struct{
    char name[11];
    int time;
}Process;
 
class ProcessQueue{
public:
    ProcessQueue(int size):
        m_size(size),
        m_head(0),
        m_tail(0),
        number(0)
    {
        m_process = new Process[m_size];
    };
 
    ~ProcessQueue(){
        delete[] m_process;
    };
 
    void enQueue(Process process){
        //strcpy(m_process[m_tail].name,process.name);
        //m_process[m_tail].time = process.time;
 
        m_process[m_tail] = process;    //=??§??£??\????
 
        number++;
 
        if(m_tail < m_size-1){
            m_tail++;
        }else{  //?????°?????????
            m_tail = 0;
        }
    };
 
    Process deQueue(){
        number--;
        if(m_head < m_size-1){
            m_head++;
            return m_process[m_head-1];
        }else{  //?????°?????????
            m_head = 0;
            return m_process[m_size-1];
        }
    };
 
    int getNumber(){
        return number;
    }
 
private:
    int m_head;
    int m_tail;
    int m_size;
    int number;
    Process* m_process;
 
};
 
int main(){
 
    int n,q,totaltime=0;
    scanf("%d%d",&n,&q);
 
    ProcessQueue queue(n);
 
    Process tmp;
    for(int i = 0; i < n; i++){
        scanf("%s%d",&tmp.name,&tmp.time);
        queue.enQueue(tmp);
    }
 
    while(queue.getNumber() != 0){
        tmp = queue.deQueue();
        if(tmp.time - q > 0){
            totaltime += q;
            tmp.time -= q;
            queue.enQueue(tmp);
        }else{
            totaltime += tmp.time;
            printf("%s %d\n",tmp.name,totaltime);
        }
    }
 
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<math.h>

typedef struct {
  double x, y;
} Point;

void print(Point p){ printf("%.8f %.8f\n", p.x, p.y); }

void plot(int num, Point p1, Point p2){
  Point s, t, u;
  double rad=60.0*(acos(-1)/180.0);
  if ( num == 0 ) return;
  s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;
  u.x = (t.x - s.x) * cos(rad)- (t.y - s.y ) * sin(rad) + s.x;
  u.y = (t.x - s.x) * sin(rad) + (t.y - s.y ) * cos(rad) + s.y;

  plot(num-1, p1, s);
  print(s);
  plot(num-1, s, u);
  print(u);
  plot(num-1, u, t);
  print(t);
  plot(num-1, t, p2);
}

main(){
  Point p1, p2;
  int num;
  scanf("%d", &num);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  print(p1);
  plot(num, p1, p2);
  print(p2);

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	cin >> s;
	if (s.size() %2 != 0)
		cout << "No\n";
	else
	{
		int poss=1;
		for (int i = 0; i < s.size()/2; ++i)
		{
			if (s[i*2]!='h' || s[i*2+1] != 'i')
			{
				poss = 0;
				break;
			}
		}
		if (!poss)
			cout << "No\n";
		else
			cout << "Yes\n";
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  sort(A.begin(),A.end());//小さい順にソート
  
  int ans=0;
  
  for(int i=0; i<N-1; i++){
    if(A.at(i)==A.at(i+1)){
      ans++;
      break;
    }
  }
  
  if(ans == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
    int n,d;
    cin >> n >> d;
    
    if(n%(2*d+1)==0){
        cout << n/(2*d+1) << endl;
    }
    else {
        cout << n/(2*d+1) + 1 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a[4],b[4],score;
	scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]);
	scanf("%d%d%d%d",&b[0],&b[1],&b[2],&b[3]);
	if(a[0]+a[1]+a[2]+a[3]<b[0]+b[1]+b[2]+b[3]){
		score=b[0]+b[1]+b[2]+b[3];
	}else{
		score=a[0]+a[1]+a[2]+a[3];
	}
	printf("%d\n",score);
	return 0;
}

Measured memory_bytes: 588
N = int(input())
li = []
for _ in range(N):
    li.append(int(input()))

li2 = sorted(li)
max1 = li2[-1]
max2 = li2[-2]
max_index = li.index(max1)

if max1 != max2:
    for i in range(N):
        if i == max_index:
            print(max2)
        else:
            print(max1)
else:
    for i in range(N):
        print(max1)

Measured memory_bytes: 14112