akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    string s; cin >> s;
  	s.pop_back();
  	int n;
  	bool x=true;
  	while(x){
      bool y=true;
      n=s.length();
      if(n%2==1) {s.pop_back(); continue;}
      else{
        for(int i=0;i<n/2;i++){
          if(s[i]!=s[i+n/2]) y=false;
        }
      }
      if(y) x=false;
      else s.pop_back();
    }
  	cout<< n << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		
		for(int i = 0; i < n; i++) {
			switch(s[i]) {
			case "AC":
				ac++;
				break;
			case "WA":
				wa++;
				break;
			case "TLE":
				tle++;
				break;
			case "RE":
				re++;
				break;
			}
		}
		
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
		
	}

}


Measured memory_bytes: 64784
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var kx = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(500 * kx[0] >= kx[1] ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11348
#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 pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int a,b;
    cin>>a>>b;
    if(a>0&&b>0){
        cout<<"Positive"<<endl;
    }
    else if(a<=0&&b>=0) cout<<"Zero"<<endl;
    else{
        if((b-a+1)%2==0) cout<<"Positive"<<endl;
        else cout<<"Negative"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
t=0
x=0
y=0
for i in range(N):
    T=t
    X=x
    Y=y
    t,x,y=map(int,input().split())
    if abs(X-x)+abs(Y-y)>t-T:
        print("No")
        exit()
    elif (X+Y+T+x+y+t)%2!=0:
        print("No")
        exit()
print("Yes")

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


def main():
    N, M, L = map(int, input().split())
    INF = 10**13
    dis = [[INF for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        dis[a-1][b-1] = c
        dis[b-1][a-1] = c
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]

    for k in range(N):
        for i in range(N):
            for j in range(N):
                dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j])
    
    movable = [[] for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if i != j and dis[i][j] <= L:
                movable[i].append(j)
    

    for s, t in Query:
        s, t = s-1, t-1
        q = movable[s]
        checked = [False]*N
        ok = False
        for p in q:
            if p == t:
                ok = True
                break
            checked[p] = True
        checked[s] = True
        
        if ok:
            print(0)
            continue
        c = 0
        while q:
            c += 1
            qq = []
            for p in q:
                for np in movable[p]:
                    if np == t:
                        ok = True
                        break
                    if not checked[np]:
                        qq.append(np)
                        checked[np] = True
            if ok: break
            q = qq
        if ok:
            print(c)
        else:
            print(-1)



            



if __name__ == "__main__":
    main()

Measured memory_bytes: 84076
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
 Scanner sc = new Scanner(System.in);
 while(true){
 int n= sc.nextInt();
 if(n==0){break;}
 int[] scores=new int[n];
 double average=0, variance=0;
 for(int i=0; i<scores.length; i++){
 scores[i] =sc.nextInt();
 average += scores[i];
 }
 average /= n;
 for(int i=0; i<scores.length;i++){
 variance += (scores[i]-average)*(scores[i]-average);
 }
 variance /= n;
System.out.println(Math.sqrt(variance));
  }
 }
}

Measured memory_bytes: 31604
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))


MOD = 1000000007 

def pow(x, y):
    if y == 0:
        return 1
    ans = 1
    while y > 1:
        if y % 2 != 0:
            ans *= x
            ans %= MOD  
        x *= x
        x %= MOD 
        y //= 2
    return ans * x % MOD


def mod_inv(x):
  return pow(x, MOD - 2)

ans = 0
xCk_1 = {}
for i in range(k - 1, n):
  if i == k - 1:
    xCk_1[i] = 1
  else:
    xCk_1[i] = (((i * xCk_1[i - 1]) % MOD) * mod_inv(i - k + 1)) % MOD

  ans += ((a[i] - a[n - i - 1]) % MOD) * xCk_1[i]
  ans %= MOD

print(ans)

Measured memory_bytes: 16024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
// #define int long long
typedef long long ll;
#define fi first
#define se second
#define pii pair<ll,int>
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(s) (int)s.size()
#define y1 fdfbvfds
typedef long double f80;
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l,ll r){
    uniform_int_distribution<ll> uid(l, r);
    return uid(rng);
}

const int mod = 998244353;
int pwr(int a,int b) {
    int ans = 1;
    while(b) {
        if(b & 1) {
            ans = (ans * 1LL * a) % mod;
        }
        a = (a * 1LL * a) % mod;
        b >>= 1;
    }
    return ans;
}

const int N = 1e5 + 5;
int a[N];
pii b[N];

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    fr(i, 1, n) {
        cin >> a[i];
        b[i] = {a[i], i};
    }
    sort(b + 1, b + n + 1);
    reverse(b + 1, b + n + 1);
    set<int> s;
    ll ans = 0;
    fr(i, 1, n) {
        auto it = s.upper_bound(b[i].se);
        int lol[4] = {0, 0, 0, 0};
        if(it != s.end()) {
            lol[2] = (*it) - b[i].se;
            auto it1 = it;
            it1++;
            if(it1 != s.end()) {
                lol[3] = (*it1) - (*it);
            }
            else {
                lol[3] = n + 1 - (*it);
            }
        }
        else {
            lol[2] = n + 1 - b[i].se;
        }
        if(it != s.begin()) {
            it--;
            lol[1] = b[i].se - (*it);
            if(it != s.begin()) {
                auto it1 = it;
                it1--;
                lol[0] = (*it) - (*it1);
            }
            else {
                lol[0] = (*it);
            }
        }
        else {
            lol[1] = b[i].se;
        }
        // cout << lol[0] << " " << lol[1] << " " << lol[2] << " " << lol[3] << endl;
        ans += b[i].fi * 1LL * lol[0] * 1LL * lol[2];
        ans += b[i].fi * 1LL * lol[1] * 1LL * lol[3];
        s.insert(b[i].se);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6912
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

const int MAX_N = 50;
const int INF = 1E+04;

int N;

string S[MAX_N];
int alb[26];
int tmpalb[26];

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

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    fill(alb, alb + 26, INF);

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < S[i].size(); j++) {
            tmpalb[S[i][j] - 'a']++;
        }
        for (int j = 0; j < 26; j++) {
            alb[j] = min(alb[j], tmpalb[j]);
        }
        memset(tmpalb, 0, sizeof(tmpalb));
    }

    string ans = "";

    for (int i = 0; i < 26; i++) {
        ans += string(alb[i], 'a' + i);
    }

    cout
        << ans << "\n";

    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	if (s[1] == s[2] && (s[0] == s[1] || s[2] == s[3])) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;

    if (c <= a + b) {
        std::cout << b + c << std::endl;
        return 0;
    }

    std::cout << 2 * b + a + 1 << std::endl;
}


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

int sum(int N){
    int sum = 0;
    while(N > 0){
        sum += N % 10;
        N /= 10;
    }
    return sum;
}

int main(){
    int MIN = 1e9;
    int a, b, N;
    //La bruta xD
    cin >> N;
    for(int i = 1 ; i <= N/2 ; i++){
        a = sum(i);
        b = sum(N - i);
        MIN = min(MIN, a + b);
    }
    cout << MIN << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<int> h;
    rep(i, n){
        int x;
        cin >> x;
        h.push_back(x);
    }
    int cnt=0;
    bool flag=true;
    while(flag){
        flag=false;
        int ind=0, minim=101;
        rep(i, n){
            if(h[i]!=0){
                minim = min(minim, h[i]);
                flag = true;
            }else{
                if(i-ind>0){
                  rep2(j, ind, i) { h[j] -= minim; }
                  cnt+=minim;
                }
                ind = i+1;
                minim = 101;
            }
        }
        if(n-ind>0){
          rep2(i, ind, n) { h[i] -= minim; }
          cnt+=minim;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3600
#N, K = map(int, input().split())
#x = list(map(int, input().split()))
A = int(input())
B = int(input())

C = [A, B]

if 2 not in C:
    print(2)
if 1 not in C:
    print(1)
if 3 not in C:
    print(3)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
struct Node{
    int key;
    Node *parent,*right,*left;
};
Node *root,*NIL;
void insert(int key){
    Node *y=NIL;
    Node *x=root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key=key;
    z->left=NIL;
    z->right=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->left;
        }
        else{
            x=x->right;
        }
    }
    z->parent=y;
    
    if(y==NIL){
        root=z;
    }else{
        if(z->key<y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

void preorder(Node *u){
    if(u==NIL) return ;
    cout<<" "<<u->key;
    preorder(u->left);
    preorder(u->right);
}

void inorder(Node *u){
    if(u==NIL)  return ;
    inorder(u->left);
    cout<<" "<<u->key;
    inorder(u->right);
}

int main(){
    int n,x;
    string com;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            cin>>x;
            insert(x);
        }else if(com=="print"){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 26592
#include <stdio.h>
#include <string.h>
int main()
{
	char a[10000]={};
	while(scanf("%s",a)!=EOF){
		int cnt,cnt1=0,cnt2=0;
		cnt=strlen(a);
		for(int i=0;i<cnt-2;i++){
			if(a[i]=='J'&&a[i+1]=='O'&&a[i+2]=='I')
				cnt1++;
			else if(a[i]=='I'&&a[i+1]=='O'&&a[i+2]=='I')
				cnt2++;
		}
		printf("%d\n%d\n",cnt1,cnt2);
	}
	return 0;
}

Measured memory_bytes: 988
import math
n=int(input())
A=list(map(int,input().split()))
num=1
brk=0
for i in range(n):
  if A[i]==num:
    num+=1
  else:
    brk+=1

if num==1 and brk!=0:
  print(-1)
else:
  print(brk)

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

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if(0 <= x-r && x+r <= w && 0 <= y-r && y+r <= h){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut abv = vec![(0i64, 0i64); n];
    for i in 0..n {
        abv[i].0 = read(&mut stdin_lock, &mut buf, b' ');
        abv[i].1 = read(&mut stdin_lock, &mut buf, b'\n');
    }

    abv.sort();
    let mut count = m as i64;
    let mut ans = 0i64;
    for i in 0..n {
        let a = abv[i].0;
        let b = abv[i].1;
        if b <= count {
            ans += a * b;
            count -= b;
        } else {
            ans += a * count;
            count = 0;
        }
        if count == 0 {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<stdio.h>
int main(){
   int a,b;
   scanf("%d %d",&a,&b);
   char A[a];
   char B[b];
 
   if(a>b){
      for(int i=0;i<a;i++){
         printf("%d",b);
      }
   }else{
      for(int i=0;i<b;i++){
         printf("%d",a);
      }
   }
      
   return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll n,m,q; cin >> n >> m >> q;
    vector<pair<pair<ll,ll>,pair<ll,ll>>> a(q);
    rep(i,q){
        cin >> a.at(i).first.first >> a.at(i).first.second >> a.at(i).second.first >> a.at(i).second.second;
        a.at(i).first.first--; a.at(i).first.second--;
    }
    ll pat = pow(m,n-1);
    ll ans = 0;
    for(int i=0;i<pat;i++){
        ll x = i;
        vector<ll> c(n-1);
        for(int j=0;j<n-1;j++){
            c.at(n-2-j) = x%m;
            x/=m;
        }
        //prvec(a);
        ll cnt = 0;
        bool flag = 0;
        for(int j=0;j<n-1;j++){
            cnt = cnt + c.at(j);
            if(cnt>=m){
                i = i - (pow(m,n-2-j) * c.at(j));
                i = i + pow(m,n-1-j);
                i--;
                flag = 1;
                break;
            }
        }
        if(flag) continue;
        //prvec(a);
        vector<ll> b(n);
        b[0] = 1;
        for(int j=1;j<n;j++){
            b[j] = b[j-1] + c[j-1];
        }
        ll point = 0;
        rep(j,q){
            if(b[a.at(j).first.second] - b[a.at(j).first.first] == a.at(j).second.first) point+=a.at(j).second.second;
        }
        ans = max(ans,point);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4112
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	int a, b;
	cin >> a >> b;
	if(a <= 5) cout << 0;
	else if(a <= 12){
		cout << b / 2;
	}
	else cout << b;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

int main()
{
  ll x;
  cin >> x;
  for(ll a = 0; a <= 10000; a++)
  {
    for(ll b = -10000; b <= 10000; b++)
    {
      ll a5 = a * a * a* a * a;
      ll b5 = b * b * b * b * b;
      if(a5 - b5 == x)
      {
        cout << fixed << a << " " << b  << endl;
        return 0;
      }
    }
  }
  
  cout << fixed << "no" << endl;
  return 0;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end())
            cout << " ";
    }
    cout << endl;
};

int main() {
    int n, x;
    string co;
    cin >> n;
    list<int> Q;
    rep(i, n) {
        cin >> co;
        if(co == "deleteFirst") {
            Q.pop_front();
        } else if(co == "deleteLast") {
            Q.pop_back();
        } else if(co == "insert") {
            cin >> x;
            Q.push_front(x);
        } else {
            cin >> x;
            for(auto it = Q.begin(); it != Q.end(); it++) {
                if(*it == x) {
                    Q.erase(it);
                    break;
                }
            }
        }
    }
    vecout(Q);
}


Measured memory_bytes: 34332
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a[n],b[n];
    vector<pll> v;
    rep(i,0,n){
        cin>>a[i]>>b[i];
        if(a[i]>b[i])swap(a[i],b[i]);
        v.push_back({a[i],i});
        v.push_back({b[i],i});
    }
    sort(v.begin(),v.end());
    ll one[2*n];
    bool used[n];
    fill(used,used+n,false);
    ll e[n][2];
    rep(i,0,v.size()){
        ll num=v[i].second;
        if(used[num]){
            one[i]=1;
            e[num][1]=i;
        }
        else{
            one[i]=0;
            used[num]=true;
            e[num][0]=i;
        }
    }
    
    ll rm=0,rmi=inf,bm=0,bmi=inf;
    rep(i,0,2*n){
        if(one[i]==0){
            bm=max(bm,v[i].first);
            bmi=min(bmi,v[i].first);
        }
        else if(one[i]==1){
            rm=max(rm,v[i].first);
            rmi=min(rmi,v[i].first);
        }
    }
    ll ans=(rm-rmi)*(bm-bmi);
    fill(used,used+n,false);
    used[v[2*n-1].second]=true;
    rep(i,0,2*n){
        ans=min(ans,(bm-v[i].first)*(rm-rmi));
        ll num=v[i].second;
        if(used[num])break;
        ll f=e[num][0],g=e[num][1];
        bm=max(bm,v[g].first);
        rmi=min(rmi,v[f].first);
        used[num]=true;
    }
    cout<<ans<<endl;
}


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

using namespace std;


int main()
{

	string s , t;
	cin >> s >> t;
	int cnt = 0 , c = 0;

	for(int i = 0 ;i <= s.size()-t.size();i++)
	{
		for(int j = 0;j < t.size();j++)
			if(s[i + j] == t[j])
				cnt++;

	c = max(c,cnt);
	cnt = 0;
	}
	cout << t.size() - c;
}

Measured memory_bytes: 3600
import collections

N = int(input())

l = []
for x in range(N):
    x = input()
    l.append(x)

l_dict = collections.Counter(l)

max_n = max(l_dict.values())

l_max = sorted([x[0] for x in l_dict.items() if x[1] == max_n])

for a in l_max:
    print(a)

Measured memory_bytes: 35572
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

    int A[10000];
    int result = 0;
    int n;  cin >> n;
    for(int i=0; i<n; i++){
        cin >> A[i];
        while(A[i]%2 == 0){
            A[i] /= 2;
            result++;
        }
    }
    cout << result << endl;    

    return 0;
}

Measured memory_bytes: 256
def main():
    A, B, AB, X, Y = map(int, input().split())
    M = max(X, Y)

    k = 0
    ans = A * X + B * Y
    while True:
        ans = min(
            ans,
            AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * B
        )

        if k >= M: break
        k += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N = int(raw_input())
A = map(int, raw_input().split())
count = 0
for i in xrange(N):
    minj = i
    for j in xrange(i, N):
        if A[j] < A[minj]:
            minj = j
    if minj != i:
        A[i], A[minj] = A[minj], A[i]
        count += 1
print ' '.join(map(str, A))
print count

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w,m; cin >> h >> w >> m;
  int br[300001];
  int bc[300001];
  int cntr[300001] = {};
  int cntc[300001] = {};
  int maxr=0,maxc=0;
  for(int i = 0; i < m; ++i){
    cin >> br[i] >> bc[i];
    ChangeMax(maxr,++cntr[br[i]]);
    ChangeMax(maxc,++cntc[bc[i]]);    
  }
  bitset<300001>r,c;
  int cr=0,cc=0;
  for(int i = 1; i <= h; ++i)if(maxr == cntr[i])cr+=r[i] = 1;
  for(int i = 1; i <= w; ++i)if(maxc == cntc[i])cc+=c[i] = 1;
  int cntd = 0;
  for(int i = 0; i < m; ++i)
    cntd += r[br[i]]&&c[bc[i]];
  cout << maxr + maxc - (cntd == cr*cc) << endl;
}


Measured memory_bytes: 8408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0)
int main()
{
    double t,k;
    vector<ll>v;
    string s;
    cin>>t;
    k=2*pi*t;

    cout<<fixed<<setprecision(20)<<k<<endl;
}



Measured memory_bytes: 3812
#include<iostream>
#include<algorithm>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;
void Ans(int N, ULL *t);
ULL GCD(ULL a, ULL b);
int main(){
    ULL *t;
    int N;
    int i;
    cin >> N;
    t = new ULL[N];
    for(i=0;i<N;i++){
        cin >> t[i];
    }
    Ans(N,t);
    return 0;
}
void Ans(int N, ULL *t){
    ULL ans = t[0];
    ULL gcd;
    int i;
    for(i=1;i<N;i++){
        gcd = GCD(ans,t[i]);
        t[i] /= gcd;
        ans /= gcd;
        ans = ans * t[i] * gcd;
    }
    cout << ans << endl;
}
ULL GCD(ULL a, ULL b){
    ULL temp;
    if( a < b ){
        temp = a;
        a = b;
        b = temp;
    }
    while( a % b != 0 ){
        temp = b;
        b = a % b;
        a = temp;
    }
    return b;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int m,d;
	int k=0;
	scanf("%d%d",&m,&d);
//	printf("%d %d",m,d);
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=d;j++)
		{
			int ans=j%10;
			int ant=j/10;
//			printf("ans %d ant %d\n",ans,ant);
			if(ans>=2&&ant>=2&&ans*ant==i)
			{
				k++;
//				printf("111111111\n");
			}
		}
	}
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 128
import scala.math._

object Main {
  val sc = new java.util.Scanner(System.in)
  def calc(n: Int): Int = n match {
    case 1 => 0
    case m if m % 2 == 0 => calc(m/2) + 1
    case m => calc(m*3 + 1) + 1
  }
  def main(args: Array[String]) {
    while(true) {
      val n = sc.nextInt()
      if(n == 0) return

      println(calc(n))
    }
  }
}

Measured memory_bytes: 45128
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String str = br.readLine();
        String[] strs = str.split(" ");
		//--- list内表示 ---
		for(int i = strs.length-1; i >= 0; i--){
			if(i != 0){
				System.out.print(strs[i] + " ");
			}else{
				System.out.print(strs[i]);
			}//if
		}//for
		System.out.println();
	}
}

Measured memory_bytes: 17092
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<vector<long long>> dp(N + 1, vector<long long>(13, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++){
    if (S[i] != '?'){
      for (int j = 0; j < 13; j++){
        dp[i + 1][(j * 10 + S[i] - '0') % 13] += dp[i][j];
        dp[i + 1][(j * 10 + S[i] - '0') % 13] %= MOD;
      }
    } else {
      for (int j = 0; j < 13; j++){
        for (int k = 0; k < 10; k++){
          dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
          dp[i + 1][(j * 10 + k) % 13] %= MOD;
        }
      }
    }
  }
  cout << dp[N][5] << endl;
}

Measured memory_bytes: 15616
n,m = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
hst = [0]*n
ans = 0
for i in range(m):
   a,b = [int(i) for i in input().split()]
   a-=1
   b-=1
   hst[a] = max(hst[a],h[b])
   hst[b] = max(hst[b],h[a])
for i in range(n):
   if h[i] > hst[i]:
      ans += 1
print(ans)

Measured memory_bytes: 20036
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int total = 0, btotal = 0;
	rep(i, n){
		if(s[i] == 'c'){
			cout << "No" << endl;
		}else if(s[i] == 'a'){
			if(total < a+b){
				total++;
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}else{
			if(total < a+b && btotal < b){
				total++;
				btotal++;
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 896
import sys
from io import StringIO
import unittest
from fractions import gcd
# from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    gcd_num = gcd_list(a)

    print(gcd_num)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
2 10 8 40"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """4
5 13 8 1000000000"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3
1000000000 1000000000 1000000000"""
        output = """1000000000"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 17560
using namespace std;
#define SUM 3001
#define DIV 100000
int table[49][SUM]={0};
int solve(int N,int M,int S){
  for(int i=0;i<N;i++)
    for(int j=0;j<=S;j++)table[i][j]=0;

  for(int i=1;i<=M;i++){
    for(int j=N-2;j>=0;j--){
      for(int k=1;k<S;k++){
	if ( table[j][k] == 0)continue;
	if ( k+i >S)break;
	table[j+1][i+k]= (table[j+1][i+k]+table[j][k])%DIV;
      }
    }  
    table[0][i]=1;
  }
  return table[N-1][S];
}
main(){
  int n,m,s;
  while(cin>>n>>m>>s && n){
    cout << solve(n*n,m,s) << endl;
  }
  return false;
}

Measured memory_bytes: 1440
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n, k;
int ans;

int main() { 

  cin >> n >> k;
  while (n > 0) {
    ans++;
    n /= k;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


class Primes():
    def __init__(self, N):
        self.N = N
        self.prime = {i for i in range(2, self.N+1)}
        for i in range(2, self.N+1):
            if i in self.prime:
                for j in range(i*2, self.N+1, i):
                    if j in self.prime:
                        self.prime.remove(j)

    def show_primes(self):
        return sorted(list(self.prime))


def main():
    D = defaultdict(int)
    P = Primes(10000)
    prime = P.show_primes()
    prime.insert(0, 0)
    L = len(prime)
    for i in range(1, L):
        prime[i] += prime[i-1]
    # prime[i]:=Primeの0番目からi番目までの素数の累積合計(i==0の時は0)
    for i in range(L):
        for j in range(i+1, L):
            D[prime[j]-prime[i]] += 1
            # 全ての10000以下の素数からなす素数列の部分列の総和を求めている
    # L=10**3より全体計算量はL**2=10**6で十分早い
    V = 1
    while V != 0:
        V = int(input())
        if V==0:
            continue
        print(D[V])
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 49084
#include <iostream>
    #include <vector>
    #include <utility>
    #include<math.h>
    using namespace std;
    int main(void){
        long long int a,b,c,x,y;
     
        cin >> a >> b >> c;
        x = 4*a*b;
        y = (a+b-c)*(a+b-c);
        // cout << a <<b << c << x << endl;
        if(a+b-c >0){
            cout << "No" << endl;
            return 0;
        }
        if(x<y){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
        
        return 0;
        
    }

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

using namespace std;
const int maxn = 1e5+15;
int pre[maxn],n,m,x,y,z,vis[maxn];
int Find(int x){
	return pre[x] == x ? x : pre[x] = Find(pre[x]);
}
void mix(int x,int y){
	int fx = Find(x);
	int fy = Find(y);
	if(fx != fy) pre[fx] = fy;
}
int main(){
	cin >> n >> m;
	for(int i = 0;i <= n; ++i) pre[i] = i;
	while(m--){
		cin >> x >> y >>z;
		mix(x,y);
	}
	int res = 0;
	for(int i = 1;i <= n; ++i){
		int fa = Find(i);
		if(vis[fa]) continue;
		res++;
		vis[fa] = 1;
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int Y[]={0,1,0,-1};
int X[]={1,0,-1,0};
int main(){
  int a,b,x,y,d[6],i,j,k,n;
  int c[7][7]={
    {0,0,0,0,0,0,0},
    {0,0,3,5,2,4,0},
    {0,4,0,1,6,0,3},
    {0,2,6,0,0,1,5},
    {0,5,1,0,0,6,2},
    {0,3,0,6,1,0,4},
    {0,0,4,2,5,3,0}
  };
  int r[4][4]={
    {0,4,2,5},
    {1,4,3,5},
    {2,4,0,5},
    {3,4,1,5}
  };
  while(scanf("%d",&n),n){
    int h[210][210]={0};
    int u[210][210]={0};
    int bk[7]={0};
   while(n--){
      scanf("%d %d",&a,&b);
      d[0]=7-b;
      d[1]=c[a][b];
      d[2]=b;
      d[3]=7-d[1];
      d[4]=a;
      x=y=100;
    FRONT:
      for(i=6;i>3;i--){
	for(j=0;j<4;j++){
	  if(d[j]==i&&h[y][x]>h[y+Y[j]][x+X[j]]){
	    d[5]=7-d[4];
	    for(k=0;k<3;k++)d[r[j][k]]=d[r[j][k+1]];
	    x+=X[j];
	    y+=Y[j];
	    goto FRONT;
	  }
	}
      }
      h[y][x]++;
      u[y][x]=d[4];
    }
   /*for(i=90;i<110;i++){
     for(j=90;j<110;j++)printf("%d",h[i][j]);printf("\n");
     }//*/
    for(i=0;i<210;i++){
      for(j=0;j<210;j++)bk[u[i][j]]++;
    }
    for(i=1;i<7;i++){
      if(i-1)printf(" ");
      printf("%d",bk[i]);
    }
    printf("\n");
  }
  return 0;
}

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

const int N = 1e5, MOD = 1e9 + 7;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;

    int n;
    cin >> n;

    std::vector<int> height(n);

    for(int i=0;i<n;++i) cin >> height[i];

    std::vector<int> dp(n,0);

    for(int i=1;i<n;++i){
        if(height[i]<=height[i-1]) dp[i] = dp[i-1]+1;
    }

    cout << *max_element(dp.begin(),dp.end()) << '\n';
	
	return 0;
} 

Measured memory_bytes: 1024
s=input()

for _ in range(int(input())):
    o=input().split()
    a,b=map(int,o[1:3]);b+=1
    c=o[0][2]
    
    if c=='p':s=s[:a]+o[3]+s[b:]
      
    elif c=='i':print(s[a:b])
      
    elif c=='v':s=s[:a]+s[a:b][::-1]+s[b:]


Measured memory_bytes: 5608
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

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

int x, y, c[50][50], dp[50][50];
const int dx[3] = {-1, 0, 1};

void solve() {
  memset(dp, 0, sizeof dp);
  
  rep(i,y) rep(j,x) cin>>c[i][j];
  
  rep(i,x) if (c[0][i] == 0) dp[0][i] = 1;
  
  rep(i,y-1) rep(j,x) {
    if (c[i][j] == 0) {
      rep(z,3) {
        int ti = i + 1, tj = j + dx[z];
        if (tj < 0 || tj >= x) continue;
        //if (c[ti][tj] == 1) continue;
        //if (c[ti][tj] == 2 && z != 1) continue;
        //dp[ti][tj] += dp[i][j];
        if (c[ti][tj] == 0) dp[ti][tj] += dp[i][j];
        else if (c[ti][tj] == 2 && z == 1) dp[ti][tj] += dp[i][j];
      }
    } else if (c[i][j] == 2 && c[i+2][j] != 1) {
      dp[i+2][j] += dp[i][j];
    }
  }
  /*
  rep(i,y+1) {
    rep(j,x) printf("%8d",dp[i][j]);
    cout<<endl;
  }*/
  
  int res = 0;
  rep(j,x) res += dp[y][j] + dp[y-1][j];
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>x>>y, x||y) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  if(a == "Sunny")
    cout << "Cloudy" << endl;
  else if(a == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
}


Measured memory_bytes: 256
input = gets.chomp!
inputs = gets.chomp!.split(" ")
max = 0
for i in 0...inputs.length-1 do
    for k in i+1...inputs.length do
        num = inputs[i].to_i - inputs[k].to_i
        if( num < 0 )
            num *= -1
        end
        if( max < num )
            max = num
        end
    end
end
p max 

Measured memory_bytes: 1788
import math

n = int(input())
cnt = 0
x = []
y = []
for _ in range(n):
    x1, y1 = map(int, input().split())
    x.append(x1)
    y.append(y1)
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        cnt += math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
print(cnt/n)


Measured memory_bytes: 38384
k, n = map(int,input().split())
a = [int(x) for x in input().split()]

add = (k - a[-1]) + a[0]

diff_a = [add]
for i in range(n-1):
    d = a[i+1]-a[i]
    diff_a.append(d)
print(sum(diff_a)-max(diff_a))

Measured memory_bytes: 26420
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,ans=0,sum=0;
  cin >> n;
  vint v(n);
	rep(i,n){
		cin >> v[i];
    sum += v[i];
	}

  //昇順
  std::sort(v.begin(),v.end());

  int h,ans1=inf;
  // if(n%2==0){
  //   h = n/2;
  // }
  // else{
  //   h = n/2 +1;
  // }
  //
  // h=sum/n;
  // h=13;
  for(int j=1;j<=v[n-1];j++){
    rep(i,n){
      ans += pow(abs(v[i]-j),2);
    }
    if(ans<ans1){
      ans1=ans;
    }
    ans = 0;
  }


  pri(ans1);

}

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

int main(){
  int n, m;
  cin >> n >> m;
  char a[n][n];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }
  char b[m][m];
  for(int i = 0; i < m; i++){
    for(int j = 0; j < m; j++){
      cin >> b[i][j];
    }
  }

  for(int i = 0; i <= n - m ; i++){
    for(int j = 0; j <= n - m ; j++){
      bool flag = true;
      for(int k = 0; k < m; k++){
        for(int l = 0; l < m; l++){
          if(a[i+k][j+l] != b[k][l]){
            flag = false;
          }
        }
      }
      if(flag){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll cal(ll x)
{
	ll ans = 0;
	for (ll i = 2; i * i <= x; ++i){
		if (x % i == 0){
			if (x / i == x / (i - 1)) ans += i - 1;
			if (x / i != i){
				if (x / (x / i) == x / ((x/ i) - 1)) ans += x / i - 1;
			}
		}
	}
    if (x > 1 && x / (x - 1) == 1) ans += x - 1;
	return ans;
}

int main() 
{
	ll n;
    cin >> n;
    cout << cal(n) << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    ll d[k];
    rep(i,0,k)cin>>d[i];
    ll copy;
    vector<ll> vec;
    bool flag;
    while(1){
        vec.clear();
        flag=true;
        copy=n;
        while(copy){
            vec.push_back(copy%10);
            copy/=10;
        }
        rep(i,0,k){
            rep(j,0,vec.size()){
                if(vec[j]==d[i]){
                    flag=false;
                    break;
                }
            }
            if(!flag)break;
        }
        if(flag){
            cout<<n<<endl;
            return 0;
        }
        n++;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
   string a, b, c;
   cin >> a >> b >> c;
   cout << "A" << b[0] << "C" << endl;
}


Measured memory_bytes: 256
n = list(input())

if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9':
    print('hon')
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
    print('pon')
else:
    print('bon')


Measured memory_bytes: 61876
#include <stdio.h>
int main(){

  int n,i=0,lo[52]={},cnt=0;
  long long r=1;
  char sa[53],sb[53];
  scanf("%d",&n);
  scanf("%s",sa);
  scanf("%s",sb);

  for(i=0;i<n;i++){
    if(sa[i]==sb[i]){
      lo[cnt]=1;
    }else{
      lo[cnt]=2;
      i++;
    }
    cnt++;
  }
  if(lo[0]==2) r*=6;
  else r*=3;
  //for(i=0;i<cnt;i++) printf("%d",lo[i]);
  for(i=1;i<cnt;i++){
    if(lo[i-1]==1&&lo[i]==1) r*=2;
    else if(lo[i-1]==1&&lo[i]==2) r*=2;
    else if(lo[i-1]==2&&lo[i]==2) r*=3;
    r%=1000000007;
  }
  printf("%lld\n",r);

  return 0;

}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		long k = sc.nextLong();
		int q = sc.nextInt();

		long[] points = new long[n];

		for (int i = 0; i < q; i++) {
			int a = sc.nextInt();
			points[a - 1]++;
		}

		for (int i = 0; i < n; i++) {
			System.out.println(k - q + points[i] > 0 ? "Yes" : "No");
		}


	}

}


Measured memory_bytes: 59760
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }
using namespace std;

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

    }
    return 0;
}


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

    }
    return 0;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
using namespace std;
int dp[110][3][3];
int p[110];
int main(){
    int n,k;
    string s;
    cin >> n >> k >> s;
    rep(i, n){
        if(i == k - 1){
           putchar(tolower(s[i]));
        }else{
           cout << s[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
K = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[K-1])

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

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using ml = map<ll,ll>;

#define ff first
#define ss second
#define endl '\n'
#define ins insert
#define eb emplace_back
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define itr(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while (t--)
#define rep(i,a,n) for(ll i = a ; i <= n ; ++i)
#define per(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) itr(x,c) cout << x << " "; cout << endl;
#define dm(m) itr(x,m) cout << x.f << "->" << x.s << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

int main() {
    godspeed;
    ll n; cin >> n;
    ll p = 100;
    ll cnt = 0;

    while(++cnt) {
    	p += p/100;
    	if(p >= n) break;
    }

    cout << cnt;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;
int mp[25][25];

void solve(int testCase){

    scanf("%d" , &n);

    ll ans = 0;
    for(int i = 1 ; i <= n ; i ++){
            string s = to_string(i);
            mp[ s[0] - '0' ][ s[ s.length() - 1 ] - '0' ] ++;
    }

    for(int i = 1 ; i <= n ; i ++){
            string s = to_string(i);
            ans += mp[ s[ s.length() - 1 ] - '0' ][ s[0] - '0' ];
    }


    printf("%lld\n" , ans);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
function main(input) {
	// 定義
	input = input.split("\n");
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var c = parseInt(input[2], 10);
	var d = parseInt(input[3], 10);
	var e = parseInt(input[4], 10);
	var k = parseInt(input[5], 10);
	var ans = "Yay!";
	// 処理
	if (e - a > k) {
		ans = ":(";
	}
	// 出力
	console.log(ans);
}
 main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372