akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	char a,b;
	cin>>a>>b;
	if(b=='H')
	{
		cout<<a<<endl;
	}
	else
	{
		if(a=='H')
			cout<<"D"<<endl;
		else
			cout<<"H"<<endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	vector<int> arr(5);
	for(auto& el: arr) cin >> el;
	int w = int(find(arr.begin(), arr.end(), 0) - arr.begin());
	cout << w + 1 << '\n';
}



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

typedef long long ll;
typedef long double ld;

pair <int, int> niz[200005];
int res[200005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> niz[i].first;
        niz[i].second = i;
    }
    sort(niz+1, niz+1+n);
    for(int i=1; i<=n/2; i++){
        res[niz[i].second] = niz[n/2+1].first;
    }
    for(int i=n/2+1; i<=n; i++){
        res[niz[i].second] = niz[n/2].first;
    }
    for(int i=1; i<=n; i++){
        cout << res[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 4608
#include <stdio.h>

int main( void ) {
	int q;

	scanf( "%d", &q );
	while ( q-- ) {
		double x0, y0, x1, y1, x2, y2, x3, y3;
		double a, b, c, d, x, y;

		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3 );

		if ( x0 != x1 ) {
			a = ( y0 - y1 ) / ( x0 - x1 );
			b = ( x0 * y1 - x1 * y0 ) / ( x0 - x1 );
		}
		if ( x2 != x3 ) {
			c = ( y2 - y3 ) / ( x2 - x3 );
			d = ( x2 * y3 - x3 * y2 ) / ( x2 - x3 );
		}

		if ( x0 == x1 ) {
			x = x0;
			if ( x2 == x3 )
				y = y0 == y2 || y0 == y3 ? y0 : y1;
			else
				y = c * x + d;
		} else {
			if ( x2 == x3 )
				x = x2;
			else if ( a == c )
				x = x0 == x2 || x0 == x3 ? x0 : x1;
			else
				x = ( -b + d ) / ( a - c );
			y = a * x + b;
		}

		printf( "%.8f %.8f\n", x, y );
	}

	return 0;
}

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

int main() {
	while(1) {
		int n, t[10001];
		long long sum_time = 0, wait_time = 0;
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++)
			cin >> t[i];
		sort(t, t + n);
		for (int i = 1; i < n; i++) {
			wait_time += t[i - 1];
			sum_time += wait_time;
		}
		cout << sum_time << endl;
	}
}


Measured memory_bytes: 3028
H,W=map(int,input().split())
if min(H,W)==1:
    print(1)
elif W%2==0:
    print(int((W/2)*H))
else:
    if H%2==0:
        print(int(((W-1)/2+1+(W-1)/2)*H/2))
    else:
        print(int(((W-1)/2+1+(W-1)/2)*(H-1)/2+(W-1)/2+1))

Measured memory_bytes: 3064
import math
a,b,x=map(int,input().split())
y=2*x/(a**2)-b
z=2*x/(a*b)
phai=0
ans=90
if x==b*a**2:
   ans=0
else:
    if z>a:
        phai=math.atan(a/(b-y))
        phai=math.degrees(phai)
        ans-=phai
    else:
        phai=math.atan(z/b)
        phai=math.degrees(phai)
        ans-=phai
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Card{
  char suit;
  int value;
};
void bubble(struct Card A[],int N){
  int i,j;
  struct Card t;
  for(i = 0 ; i < N ; i++){
    for(j = N - 1 ; j >= i + 1 ; j--){
      if(A[j].value < A[j - 1].value){
	t = A[j];
	A[j] = A[j - 1];
	A[j - 1] = t;
      }
    }
  }    
}

void selection(struct Card A[],int N){
  int i,j,minj;
  struct Card t;
  for(i = 0 ; i < N ; i++){
    minj = i;
    for(j = i ; j < N ; j++){
      if(A[j].value < A[minj].value)minj = j;
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;
  }
}

void print(struct Card A[],int N){
  int i;
  for(i = 0 ; i < N ; i++){
    if(i > 0)printf(" ");
    printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[],struct Card C2[],int N){
  int i;
  for(i = 0 ; i < N ; i++){    if(C1[i].suit!=C2[i].suit)return 0;
  }
  return 1;
}

int main(){
  struct Card C1[100],C2[100];
  int N,i;
  char num[3];

  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%s",num);
    C1[i].suit = num[0];
    C1[i].value = atoi(&num[1]);
  }

  for(i = 0 ; i < N ; i++){
    C2[i] = C1[i];
  }
  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  return 0;
}


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

int main(){
  vector<long int> a(100002,0),B(100002,0),p(12,0);
  long int i;
  p.at(0)=1;
  for(i=1;i<=10;i++){
    p.at(i)=p.at(i-1)*10;
  }
  for(i=0;i<=9;i++){
    a.at(i)=i;
    B.at(i)=i;
  }
  
  long int b,e,n,k,j;
  b=0;
  e=9;
  n=1;
  k=1;
  j=0;  
  for(i=10;i<=100000;i++){
    a.at(i)=n*p.at(k)+a.at(j);
    B.at(i)=n;
    if(n==9&&j==e){
      n=1;
      k++;
      b=e+1;
      j=0;
      e=i;
    }else if(a.at(j+1)/p.at(k-1)-n>=2){
      n++;
      j=b;
      while(B.at(j)!=n-1){
        j++;
      }
    }else if(n==1&&a.at(j)<p.at(k-1)){
      j++;
      while(B.at(j)!=1){
        j++;
      }
    }else{
      j++;
    }
  }
  
  long int K;
  cin >> K;
  cout << a.at(K) << endl;
}
  

Measured memory_bytes: 1792
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2e5 + 5;
const int MOD = 10000;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }

int a[105];
int main() {
	FIO;
	int n,m;cin>>n>>m;
	int cnt = 0;
	_for(i,0,n){
		cin>>a[i];
		cnt+=a[i];
	}
	//cout<<cnt<<'\n';
	double cut = (cnt)/(4.0*m);
	bool flag = true;
	sort(a,a+n);
	int ans = 0;
	_rfor(i,n-1,-1){
		if(a[i]>=cut)ans++;
		else break;
	}
	if(ans<m)flag = false;
	if(flag)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

vl div(ll n){
	vl ret;
	for(ll i = 1; i * i <= n; i++){
		if(n % i == 0){
		  ret.push_back(i);
		  if(i * i != n) ret.push_back(n / i);
		}
	}
	SORT(ret);
	return ret;
}

void Main(){
	
	ll N;
	cin >> N;
	
	vl v = div(N);
	ll length = v.size();
	ll ans = INF;
	rep(i, length){
		ll j = N / v[i];
		ll cnt = max(to_string(v[i]).size(), to_string(j).size());
		chmin(ans, cnt);
	}
	print(ans);
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
    
	return 0;
	
}





Measured memory_bytes: 3732
s = input()
q = int(input())
query = [list(input().split()) for _ in range(q)]
right = []
left = []
rev_count = 0
for i in range(q):
  if query[i][0] == "1":
    rev_count += 1
    right,left = left,right
  else:
    if query[i][1] == "1":
      left.append(query[i][2])
    else:
      right.append(query[i][2])
if rev_count % 2 == 1:
  s = s[::-1]
print("".join(reversed(left))+s+"".join(right))

Measured memory_bytes: 109016
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);

const int N=1010,
          INF=1e9;

int n,m,s,t,flow;
int tr[N];
vector<int> ad[N];
struct ed{
    int u,v,c,f;
};
vector<ed> e;

void add(int u,int v,int c){
    e.pb({u,v,c,c}); ad[u].pb(e.size()-1);
    e.pb({v,u,c,c}); ad[v].pb(e.size()-1);
}
int bfs(){
    reset(tr,-1);
    queue<int> q; q.push(s); tr[s]=-2;
    while(q.size()){
        int u=q.front(); q.pop();
        if(u==t) return 1;
        forv(i,ad[u]) if(e[i].c>0 && tr[e[i].v]==-1){
            tr[e[i].v]=i; q.push(e[i].v);
        }
    }
    return 0;
}

main(){
    #define task "splay"
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    fasty;

    cin>>m>>n; s=m+n+1, t=s+1;
    forinc(i,1,m){
        forinc(j,1,n){
            char ch; cin>>ch;
            if(ch=='S'){
                add(s,i,INF);
                add(s,j+m,INF);
            }
            if(ch=='T'){
                add(i,t,INF);
                add(j+m,t,INF);
            }
            if(ch=='o'){
                add(i,j+m,1);
            }
        }
    }
    while(bfs()){
        int d=1<<30; vector<int> node;
        int v=t;
        do{
            d=min(d,e[tr[v]].c);
            node.pb(tr[v]);
            v=e[tr[v]].u;
        } while(v!=s);
        forv(i,node) e[i].c-=d, e[i^1].c+=d;
        flow+=d;
    }
    cout<<(flow>=INF ? -1 : flow)<<"\n";
}


Measured memory_bytes: 1528
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
using namespace std;
typedef long long int ll;

int x[2000 + 10];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> x[i];
    sort(x + 1, x + 1 + n);
    int ans = 0;
    for (int i = 1; i <= n - 1; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            int idx = lower_bound(x + 1, x + 1 + n, x[i] + x[j]) - x;
            idx--;
            if (idx <= j)
                continue;
            ans += idx - j ;
    
        }
    }
    cout << ans;

    return 0;
}

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;

vector<int>primes;
vector<int>sos;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}

int main() {
	hurui(10000);
	while (1) {

		int N; cin >> N;
		if (!N)break;
		while (1) {
			if (sos[N] && sos[N - 2]) {
				cout << N - 2 << " " << N << endl;
				break;
			}
			N--;
		}
	}

	return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    
    int ans = 0;
    forn(i, a, b+1) {
        string s = to_string(i);
        string r = s;
        reverse(r.begin(), r.end());
        ans += s==r;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3700
open System
let N = stdin.ReadLine() |> int
let (A : int[]) = Array.zeroCreate N
for i in 0..(N-1) do A.[i] <- (stdin.ReadLine() |> int) - 1

let rec f n tot =
  match (n, tot) with
    | (_, tot) when tot > N -> -1
    | (n, _) when A.[n] = 1 -> tot + 1
    | _ -> f A.[n] (tot + 1)

f 0 0 |> printfn "%d"


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

int main(){
    int N,odr;
    cin >> N;
    vector<int> ORDER(N);

    for(int i = 0;i < N;i++){
        cin >> odr;
        ORDER[odr-1] = i + 1;
    }
    cout << ORDER[0];
    for(int i = 1;i < N;i++){
        cout << " " << ORDER[i];
    }
    cout << endl;


}

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

int main(void) {
  int d, n;
  cin >> d >> n;
  if (d == 0) {
    if (n == 100) cout << 101 << endl;
    else cout << n << endl;
  } else if (d == 1) {
    if (n == 100) cout << 10100 << endl;
    else cout << 100 * n << endl;
  } else {
    if (n == 100) cout << 1010000 << endl;
    else cout << 100 * 100 * n << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
        long N = fs.nextLong();
		long K = fs.nextLong();
		long A = N%K;  
		long a = K;


		System.out.println(Math.min(A,K-A));



		

	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


Measured memory_bytes: 23124
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars,
    }
    let mut black_start = 0;
    let mut white_start = 0;
    let mut signal_black = false;
    for i in s {
        let is_white = i == '0';
        if signal_black {
            black_start += if is_white {0} else {1};
            white_start += if is_white {1} else {0};
        } else {
            white_start += if is_white {0} else {1};
            black_start += if is_white {1} else {0};
        }
        signal_black = !signal_black;
    }
    println!("{}", if black_start > white_start {white_start} else {black_start});
}



Measured memory_bytes: 4352
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define ll long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

signed main() {
  IO;
  int r;
  cin >> r;
   cout << 2 * acos(-1.0) * r << '\n';
  return 0;	
}

Measured memory_bytes: 3808
/**
 * Created by hiramekun at 21:55 on 2020-04-04.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
    return n != 1;
}

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

void solve() {
    ll n;
    cin >> n;
    vl d = divisor(n);
//    cout << d << '\n';
    ll ans = 0;
    each(e, d) {
        if (e == 1)continue;
        ll tmp = n;
        while (tmp % e == 0) {
            tmp /= e;
        }

        if (tmp == 1 || (tmp % e) == 1) {
//            cout << e << '\n';
            ans++;
        }
    }
    ll tmp = divisor(n - 1).size();
    if (tmp > 1) ans += tmp - 1;
    cout << ans << '\n';
}

int main() {
//    ll n = 3141;
//    for (ll i = 2; i <= 3141; ++i) {
//        ll tmp = n;
//
//        while (tmp >= i) {
//            if ((tmp % i) == 0) tmp /= i;
//            else tmp -= i;
//        }
//        if (tmp == 1) cout << i << '\n';
//    }
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B == C){
            cout << "No" << endl;
    }
    else if (A == B && A != C) {
        cout << "Yes" << endl;
    } 
    else if (A == C && A != B){
        cout << "Yes" << endl;
    }
    else if (B == C && B != A){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/soundhound2018-summer-qual/tasks/soundhound2018_summer_qual_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
    string S; cin>>S;
    ll w; cin>>w;
    string ans;
    ans.push_back(S[0]);
    for(ll i=w;i<S.size();i+=w){
        ans.push_back(S[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[0])

a = 0
while True:
    s = AB.pop(0)
    if M > s[1]:
        M -= s[1]
        a += s[0] * s[1]
    else:
        a += s[0] * M
        break

print(a)

Measured memory_bytes: 29024
#include<stdio.h>

void calc(int time,int hms[3]){
    hms[0]=(time-time%3600)/3600;
    hms[1]=(time%3600-(time%3600)%60)/60;
    hms[2]=time-hms[0]*3600-hms[1]*60;
}

int main(void){
 int time;
 scanf("%d",&time);
 
 int hms[3]={1};
 calc(time,hms);
 printf("%d:%d:%d\n",hms[0],hms[1],hms[2]);

 return 0;
}



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

int main(){
  ll l,r;
  cin >> l >> r;
  r = min(r,l+4038);
  int ans = 2018,x;
  for(ll i = l;i <= r;i++){
    for(ll j = i + 1;j <= r;j++){
      x = i*j%2019;
      ans = min(ans,x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define bitcnt(x) __builtin_popcount(x)
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
using namespace std;
typedef long long LL;
const int N=16;
const int M=300;
const LL mod=1e9+7;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,m;
int w[N];
LL P2[M],dp[1<<N];
int main()
{
	//file();
	int x,y;
	read(n),read(m);
	P2[0]=1;
	For(i,1,m)
	{
		P2[i]=P2[i-1]*2%mod;
		read(x),read(y);
		w[x]|=(1<<(y-1));
	}
	dp[0]=1;
	int tot=(1<<n)-1;
	For(x,1,tot)
		for(int s=x;;s=(s-1)&x)
		{
			int ss=x^s,flag=(s&1?1:0)^(s&2?1:0);
			if(flag)continue;
			LL ret1=0,ret2=1;
			For(i,1,n)
			{
				if(ss&(1<<(i-1)))ret1+=bitcnt(w[i]&s);
				if(s &(1<<(i-1)))ret2=ret2*(P2[bitcnt(w[i]&ss)]-1)%mod;
			}
			dp[x]=(dp[x]+dp[s]*ret2%mod*P2[ret1]%mod)%mod;
			if(s==0)break;
		}
	printf("%lld\n",(P2[m]+mod-dp[tot])%mod);
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


ll n, k;
ll a[200005];
pair <bool, ll> p[200005];

int main() {

	cin >> n >> k;
	rrep(i, n)cin >> a[i];

	rrep(i, n)p[i] = dmp(true, 0);

	ll r = 1;
	ll cnt = 0;
	while (p[r].fi && k > cnt) {
		p[r] = dmp(false, cnt);
		r = a[r];
		cnt++;
	}

	if (k <= cnt)cout << r << endl;
	else {
		k -= p[r].second;

		ll tmp = k % (cnt - p[r].second);

		rep(i, tmp) {
			r = a[r];
		}

		cout << r << endl;
	}

	return 0;
}


Measured memory_bytes: 8244
#include<stdio.h>
void trace(int A[],int N){
	int i;
	for(i=0;i<N;i++){
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

void insertionSort(int A[],int N){
	int j,i,v;
	for(i=1;i<N;i++){
		v=A[i];
		j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main()
{
	int N,i,j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	trace(A,N);
	insertionSort(A,N);
	return 0;
}

Measured memory_bytes: 604
def main():
    n = int(input())
    lim = {}
    for i in range(n):
        a,b = map(int,input().split())
        if b not in lim.keys():
            lim[b] = [a]
        else:
            lim[b].append(a)
    time = 0
    for k in sorted(lim.keys()):
        time += sum(lim[k])
        if time<=k:
            continue
        else:
            print('No')
            return
    print('Yes')

if __name__ == "__main__":
    main()


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

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

    vector<int> 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};
    cout << a[k-1] << endl;
    return 0;
}

Measured memory_bytes: 3544
open System.Text

let n = stdin.ReadLine() |> int
let a = stdin.ReadLine().Split() |> Array.map int
a |> Array.mapi (fun i x -> i + 1, x) |> Array.sortBy (fun (_,x) -> x) 
|> Array.fold (fun (total: StringBuilder) (i, _) -> total.Append(string i).Append(" ")) (StringBuilder())
|> string
|> stdout.WriteLine


Measured memory_bytes: 33240
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  int state = 0;
  ll tmp;
  cin >> tmp;
  ll ans = 0;
  REP(i, n-1) {
    ll x;
    cin >> x;
    if(x == tmp) continue;
    if(x > tmp) {
      tmp = x;
      if(state == 1) continue;
      if(state == 0) {
        state = 1;
        continue;
      }
      state = 0;
      ans++;
    }
    else {
      tmp = x;
      if(state == -1) continue;
      if(state == 0) {
        state = -1;
        continue;
      }
      state = 0;
      ans++;
    }
  }
  cout << ans + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
d = []
for i in range(M-1):
    d.append(X[i+1]-X[i])
d.sort()
n = min(M-1,N-1)
for i in range(n):
    d.pop()
ans = sum(d)
print(ans)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, m;
  cin >> n >> m;
  vector<vi> s(m);
  vi p(m);
  rep(i, m) {
    int k;
    cin >> k;
    rep(j, k) {
      int sj;
      cin >> sj;
      sj--;
      s[i].push_back(sj);
    }
  }
  rep(i, m) cin >> p[i];
  int ans = 0;
  rep(i, 1 << n) {
    vb on(n, false);
    rep(j, n) if(i >> j & 1) on[j] = true;
    bool ok = true;
    rep(j, m) {
      int cnt = 0;
      for(int v : s[j])
        if(on[v]) cnt++;
      if(cnt % 2 != p[j]) ok = false;
    }
    if(ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b,n;
    cin >> n >> a >> b;
    if (a * n > b) {
        cout << b << endl;
    }else{
        cout << a*n << endl;
    }
    return 0;
}

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

int main() {
  int n;cin>>n;
  int an[n];rep(i,n)cin>>an[i];
  sort(an, an+n);
  
  ll sum=0;
  int med = an[n/2];
  rep(i,n) {
    sum += abs(med - an[i]);
  }
  sum *= 2;
  if (n%2==1) {
    sum -= min(med-an[n/2-1], an[n/2+1]-med);
  } else {
    sum -= med - an[n/2-1];
  }
  cout<<sum<<endl;
  
}


Measured memory_bytes: 4028
let choice a b =
  if a = 1 && b = 2 then 3
  else if a = 1 && b = 3 then 2
  else if a = 2 && b = 1 then 3
  else if a = 2 && b = 3 then 1
  else if a = 3 && b = 1 then 2
  else 1

let ans = choice (read_int ()) (read_int())

let () = print_endline @@ string_of_int ans


Measured memory_bytes: 3596
int n,m,l[31];
s(a){
	if(a<2)return 1;
	else if(a<3)return 2;
	if(l[a]<1)l[a]=s(a-1)+s(a-2)+s(a-3);
	return l[a];
}
main(){
	while(scanf("%d",&n)){
		if(n<1)break;
		m=s(n);
		if(m%10)m+=9;
		m/=10;
		if(m%365)m+=365;
		printf("%d\n",m/365);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    string s;
    rep(i,3){
        cin >>s;
        cout <<s[0];
    }
    cout <<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

int main()
{
    int a, b;
    cin >> a >> b;

    if (a <= b) { cout << a <<endl; }
    else { cout << a-1 << endl; }
}


Measured memory_bytes: 256
var
  p:char;
  s:string;  
begin
  while not eof do
   begin
     read(p); 
     if (p='1') or (p='0') then 
      s:=s+p;
     if (p='B') and (length(s)>0) then
      delete(s,length(s),1);
   end;
  writeln(s);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define int long long 
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

int n,k;
int a[105];
int dp[100005];

signed main() {
    FASTIO;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    //     freopen("stderr.txt", "w", stderr);
    // #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        cin>>n>>k;
        rep(i,n) cin>>a[i];
        rep(i,k+1){
            rep(j,n){
                if(a[j]<=i)
                    if(dp[i-a[j]]==0) dp[i]=1;
            }
        }
        // rep(i,k+1) cerr<<dp[i]<<' '; cerr<<endl;
        dp[k]? cout<<"First" : cout<<"Second";
        
        
    // }
    cerr<<"Time Elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<" sec";
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int a;
	cin>> a;

	if(a>=30) cout<< "Yes" << endl;
	else cout<< "No" << endl;
 
	return 0;
}

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(1e17+1)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ 
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve() {
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++){
        if(i%k == 0){
            cout << "OK";return;
        }
    }
    cout << "NG";
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	
	vector<string> vec(N);

	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}

	set<string> s(vec.begin(), vec.end());

	cout << s.size() << endl;

	return 0;

}


Measured memory_bytes: 25120
n,m=map(int,input().split())
data=[0]*(10**5+10)
for i in range(m):
    l,r=map(int,input().split())
    data[l]+=1
    data[r+1]-=1
ans=0
for i in range(len(data)-1):
    data[i+1]=data[i+1]+data[i]
    if data[i+1]==m:
        ans+=1
print(ans)


Measured memory_bytes: 46040
N,M = map(int,input().split())
#隣接リスト
g = [[] for i in range(N)]
for i in range(M):
  a,b = map(int,input().split())
  g[a-1].append(b)
  g[b-1].append(a)
ls = g[0]
flag = 0
for i in range(len(g[0])):
  ls2 = g[ls[i]-1]
  for j in range(len(ls2)):
    if ls2[j] == N:
      flag += 1
      print("POSSIBLE")
      break
if flag == 0:
  print("IMPOSSIBLE")

Measured memory_bytes: 41780
#include<algorithm>
#include<cstring>
#include<stdio.h>
using namespace std;
int main(){
	char a[100005];
	int ans=0;
	scanf("%s",a+1);
	for(int i=2;i<=strlen(a+1);i++)
		if(a[i]!=a[i-1])ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define repins(a,n) vector<string> a(n);rep(i,n){cin>>a[i];}
#define repind(a,n) vector<double> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define ins(a) string a;cin>>a;
#define ind(a) double a;cin>>a;
template<class T>
inline void out(T a){cout<<a<<endl; }
inline void out(double a){ printf("%.10f\n", a);} 
#define all(x) (x).begin(),(x).end()
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)
#define range(i,s,c) for(ll i=(s);i<(s+c);++i)
using vell = vector<ll>;
using ves = vector<string>;
using ved = vector<double>;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main()
{
	in(n);
	repin(d,n);
	ll ans = 0;
	rep2(i,0,n-1){
		rep2(j,i+1,n){
			ans+= d[i]*d[j];
		}
	}
	out(ans);
}

Measured memory_bytes: 256
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007

n=ii1()
arr=iia()
ans=0
arr.sort(reverse=True)
for i in range(1,n):
    ans+=arr[i//2]
print(ans)


Measured memory_bytes: 31968
import java.util.Scanner;

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

            int sum = 0;
            for (int i = 1; i <= K; i++) {
                for (int j = 1; j <= K; j++) {
                    for (int k = 1; k <= K; k++) {
                        sum += gcd(i, gcd(j, k));
                    }
                }
            }

            System.out.println(sum);
        }
    }

    public static final int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
}


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

int main() {
	char b;
	cin >> b;
	char ans;
	if(b == 'A') ans = 'T';
	if(b == 'T') ans = 'A';
	if(b == 'G') ans = 'C';
	if(b == 'C') ans = 'G';
	
	cout << ans << endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int a,b;
    bool flag = false;
    for(int i=1;i<10;i++){
        a = N/i;
        b = N%i;
        if(b==0 && a<=9 && a>=1){
            flag =true;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const double PI = 3.14159265358979323846;

int main() {
    int w, h, n, kanX[1001], kanY[1001];
    cin >> w >> h >> n;
    for (int i = 0; i < n; ++i) {
        cin >> kanX[i] >> kanY[i];
    }

    int r = 0;
    int x = kanX[0];
    int y = kanY[0];
    for (int i = 1; i < n; ++i) {
        while (true) {
            int defX = kanX[i] - x;
            int defY = kanY[i] - y;

            if ((defX == 0) && (defY == 0)) {
                break;
            }
            if ((0 < defX) && (0 < defY)) {
                x++;
                y++;
            } else if ((defX < 0) && (defY < 0)) {
                x--;
                y--;
            } else if (defX != 0) {
                (defX < 0) ? x-- : x++;
            } else {
                (defY < 0) ? y-- : y++;
            }
            r++;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1168
N, M = map(int, input().split())
F = [list(map(int, input().split())) for i in range(M)]

d = [-1]*N


def find(x):
    if d[x] < 0:
        return x
    d[x] = find(d[x])
    return d[x]


def union(x, y):
    x, y = find(x), find(y)
    if x == y:
        return
    if (d[x] > d[y]):
        x, y = y, x
    d[x] += d[y]
    d[y] = x


for f in F:
    union(f[0]-1, f[1]-1)
print(-min(d))


Measured memory_bytes: 49840
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
   int n;
   cin>>n;
   vector<ll> a(n);
   for(int i=0;i<n;i++)
   cin>>a[i];
   ll ans=a[0];
   for(int i=1;i<n;i++)
   {
       ans=ans^a[i];
   }
    for(int i=0;i<n;i++)
    {
        ll p=a[i]^ans;
        cout<<p<<" ";
    }
    cout<<endl;

    
}

Measured memory_bytes: 4824
#include <iostream>
#include <cstdio>
#include <cstdlib>
int a[200010],f[200010],n;
bool check(int x){
    for(int i=1;i<=(n<<1)-1;i++)
        f[i]=(a[i]<x)?0:1;
    if(f[n]==f[n+1]||f[n-1]==f[n])
        return f[n];
    for(int i=n,j=n;i>=1;i--,j++)
        if(f[i]==f[i+1])return f[i];
        else 
        if(f[j]==f[j-1])return f[j];
    return f[n]^(n&1)^1;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=(n<<1)-1;i++)
        scanf("%d",&a[i]);
    int l=1,r=n<<1;
    while(r-l>1){
        int mid=(l+r)>>1;
        if(check(mid))
            l=mid;
        else r=mid;
    }
    printf("%d\n",l);
    return 0;
}

Measured memory_bytes: 1792
def solve():
    N, K = [int(_) for _ in raw_input().split()]
    p = [int(_) for _ in raw_input().split()]
    sumNk = 0
    for i in range (K):
        sumNk += p[i]
    maxSumNk = sumNk
    for i in range (K, N):
        sumNk = sumNk - p[i - K] + p[i]
        if sumNk > maxSumNk:
            maxSumNk = sumNk
    ret = (maxSumNk + K) * 0.5
    print ret

if __name__ == '__main__':
    solve()


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

using namespace std;

typedef vector <int> vi;

int n, a;
vector <vi> g;
vi visited;
vi subordinates;

void dfs(int u)
{
    if (visited[u])
        return;

    visited[u] = 1;
    subordinates[u] += g[u].size();
    for (int v: g[u])
    {
        dfs(v);
        // subordinates[u] += subordinates[v];
    }
}

int main()
{
    cin >> n;

    g.assign(n+1, vi());

    for (int i = 2; i <= n; i++)
    {
        cin >> a;

        g[a].push_back(i);
    }

    visited.assign(n+1, 0);
    subordinates.assign(n+1, 0);

    dfs(1);

    for (int i = 1; i <= n; i++)
    {
        cout << subordinates[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 22000
#include <cstdio>
#include <cstring>
using namespace std;
char s[100005];
int a[100005];
int main(void)
{
	int i,n,cntl,cntr,midl,midr,tmp;
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;){
		cntl=0; cntr=0;
		while(s[i]=='R'){
			i++;
			cntl++;
		}
		midl=i-1; midr=i;
		while(s[i]=='L'&&i<n){
			i++;
			cntr++;
		}
		if(cntl<cntr){
			a[midl]=(cntl+cntr+1)/2;
			a[midr]=(cntl+cntr)/2;
			if(cntr%2!=0){
				tmp=a[midl];
				a[midl]=a[midr];
				a[midr]=tmp;
			}
		}
		else if(cntl>cntr){
			a[midl]=(cntl+cntr)/2;
			a[midr]=(cntl+cntr+1)/2;
			if(cntl%2!=0){
				tmp=a[midl];
				a[midl]=a[midr];
				a[midr]=tmp;
			}
		}
		else{
			a[midl]=cntl;
			a[midr]=cntr;
		}
	}
	for(i=0;i<n-1;i++){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[n-1]);
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        int array[][] = new int[n][m];

        int mj[] = new int[m];

        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                array[i][j] = sc.nextInt();
            }
        }

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

        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += mj[j] * array[i][j];
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 40176