akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
const int K = 7;
vector<ll> ps = {2,3,5,7,11,13,17};
int Q;
ll m[299],mp[299];
ll x[299];

ll q[K];

ll ans;

void dfs(int t){
	if(t==K){
		ll tmp = 0;
		ll LCM = 1;
		vector<int> xx(301);
		rep(i,K) LCM *= q[i];
		rep(i,Q){
			if(LCM%m[i]!=0){
				//exclude
			}else{
				if(mp[i]==1){
					//include
					tmp += x[i];
				}else{
					xx[mp[i]] += x[i];
				}
			}
		}
		rep(i,301) tmp +=max(0LL,xx[i]);
		chmax(ans,tmp);
		return;
	}
	for(ll a=1;a<=300;a*=ps[t]){
		q[t] = a;
		dfs(t+1);
	}
}

signed main(){
	cin>>Q;
	rep(i,Q){
		cin>>m[i]>>x[i];
		mp[i] = 1;
		rep(j,K){
			int p = ps[j];
			while(m[i]%p==0){
				m[i]/=p;
				mp[i]*=p;
			}
		}
		swap(m[i],mp[i]);
	}
	dfs(0);
	cout<<ans<<endl;
}


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

int main() {

    int c=0,i=0;
    string S,T;
    cin>>S>>T;

    int l=S.size();
    
    while(i<l){

        char t=T.at(i);

        if(S.at(i)!=t){
            c++;
        }
        i++;
    }
    
    cout<< c <<endl;     
}

Measured memory_bytes: 3916
import java.util.Scanner;

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

            double thetaH = Math.toRadians(360.0 * (H * 60 + M) / (12.0 * 60.0));
            double thetaM = Math.toRadians(360.0 * M / 60.0);

            double xH = A * Math.cos(thetaH);
            double yH = A * Math.sin(thetaH);
            double xM = B * Math.cos(thetaM);
            double yM = B * Math.sin(thetaM);

            double dx = xH - xM;
            double dy = yH - yM;

            double distance = Math.sqrt(dx * dx + dy * dy);

            System.out.println(distance);
        }
    }
}


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

int main() {
	int i,n,f,on[1000],p[1000],q[1000],r[1000],c[1000],lp,lq,lr,lc;
	while (cin >> n && n>0) {
	 for (i=0;i<n;i++) { cin >> on[i] >> p[i] >> q[i] >> r[i]; c[i]=p[i]*4+q[i]*9+r[i]*4; }
	 cin >> lp >> lq >> lr >> lc;
	 for (i=0,f=0;i<n;i++) if (p[i]<=lp && q[i]<=lq && r[i]<=lr && c[i]<=lc) {  f=1; cout << on[i] << endl;}
	 if (f==0) cout << "NA" << endl;
 }
 return 0;
}  	 

Measured memory_bytes: 1180
#include<iostream> 
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(I,N) for(int I=0;I<N;I++)


int main() {
	string s;
	bool al[26] = {};
	std::cin >> s;

	REP(i, s.length()) {
		al[s[i] - 'a'] = true;
	}
	if (s.length() != 26) {
		REP(i, 26) {
			if (al[i] == 0) {
				s.push_back(  i + 'a');
				break;
			}
		}
		cout << s << endl;
	}
	else if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << "-1" << endl;
	}
	else {
		int poi = 0;
		int size = s.length() - 1;
		for (int i = s.length() - 1; i >= 0; --i) {
			if (i == size) {
				poi = s[i] - 'a';
				s.pop_back();
				al[poi] = false;
			}
			else {
				if (poi < s[i] - 'a') {
					poi = s[i] - 'a';
					s.pop_back();
					al[poi] = false;
				}
				else {
					int ans = s[s.length() - 1] - 'a';
					REP(i, 26) {
						if (al[(ans + i) % 26] ==false) {
							s.pop_back();
							s.push_back(ans + i + 'a');
							break;
						}
					}
					break;
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i=0;i<N;i++) cin >> h[i];
  int max = *max_element(h.begin(), h.end());
  int ans = 0;
  for(int i=0;i<max;i++) {
    int length = 0;
    for(int j=0;j<h.size();j++) {
      if(h[j] > i) {
        length++;
      } else {
        if(length>0) {
          ans++;
          length = 0;
        }
      }
    }
    if(length > 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H)
    printf("Yes\n");
    else
    printf("No\n");
    
    return 0;
}



Measured memory_bytes: 2100
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int X = stdIn.nextInt();
		int Y = stdIn.nextInt();
		int Z = stdIn.nextInt();

		System.out.println(Z + " "  + X + " "+ Y);
		stdIn.close();
	}
}

Measured memory_bytes: 39092
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (int &i : a)
        cin >> i;
    int ans = 1;
    int m = a[0];
    for (int i = 1; i < n; i++){
        if (a[i] < m){
            ans++;
            m = a[i];
        }
    }
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;




int main(void){
 
bool gl[3] = {true,false,false};
char dis[] = "ABC";
string ws;
	
	while( cin >> ws){
		swap(gl[ws[0]-'A'],gl[ws[2]-'A']);
		
	}	
	rep(i,3) if(gl[i]) cout << dis[i]  << endl;
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int a, b; cin>>a>>b;
	if(a==1) a=100;
	if(b==1) b=100;
	if(a==b)
	{
		cout<<"Draw\n";
	}
	else if(a>b)
	{
		cout<<"Alice\n";
	}
	else
	{
		cout<<"Bob\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 2e5+100;
const int mod = 1e9+7;
ll fact[upperlimit];
ll invfact[upperlimit];
ll ways(int x1,int y1,int x2,int y2){
	ll ans=fact[abs(x2-x1)+abs(y2-y1)];
	ans*=invfact[abs(x2-x1)];ans%=mod;
	ans*=invfact[abs(y2-y1)];ans%=mod;
	return ans;
}
int main() {
	fact[0]=1;invfact[0]=1;
	for(int i = 1; i < upperlimit; i++){
		fact[i]=fact[i-1];fact[i]*=i;fact[i]%=mod;
		invfact[i]=powmod(fact[i],mod-2,mod);
	}
	int h,w,r,c;
	sd(h);sd(w);sd(r);sd(c);
	ll ans=ways(0,0,h-1,w-1);
	for(int i = 0; i < c; i++){
		ll calc=ways(0,0,h-r-1,i);
		calc*=ways(h-r,i,h-1,w-1);calc%=mod;
		ans-=calc;
		if(ans<0) ans+=mod;
	}
	plld(ans);
	return 0;
}

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

int main()
{
    ll k;
    cin >> k;
    ll sum = 0;
    rep(i, k)
    {
        rep(j, k)
        {
            rep(h, k)
            {
                sum += gcd(h + 1, gcd(i + 1, j + 1));
            }
        }
    }
    cout << sum;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'



int main() {
     string s;
     cin >> s;
     int n = s.size();
     int k;
     cin >> k;
     set<string> ss;
     for (int len = 1; len <= 5; ++len) {
          
          for (int i = 0; i <= n - len; ++i) {
               ss.insert(s.substr(i, len));
               
          }
     }
     auto it = ss.begin();
     for (int i = 0; i < k - 1; ++i) {
          it++;
     }
     cout << *it;
}


Measured memory_bytes: 1664
N, K = map(int, input().split())
A = list(map(int, input().split()))

# 最大値を取るf(x)のxを求める
# digitsは下位桁 < 上位桁で1になっているbitをカウントする
digits = [0] * 40
for i in range(40):
    for a in A:
        if (a >> i) & 1:
            digits[i] += 1

# Kを考慮してmax_xを求める方法がわからない
# 桁ごとに最適なbitはすでにわかっていて、他の桁のbitに影響を受けることはないので、
# 上位桁から見ていって、Kが1になっている部分ならフラグを立てる
# 上位桁から見てKが1のbitが出てから、K:1,max_x:0のフラグを立てたら、その桁より下位桁のbitはなんでもよくなる
check_K = True
max_x = 0
for i, d in enumerate(reversed(digits)):
    i = 40 - i - 1
    if check_K and (K >> i) & 1 == 0:
        continue
    if d <= (N-d) and (K >> i) & 1 == 1:
        # Kの対象bitが1かつ、 max_xのbitを1にする場合
        max_x += 2 ** i
    elif d <= (N-d) and not check_K:
        # max_xがK以下となることが確定していて、max_xのbitを1にする場合
        max_x += 2 ** i
    elif (K >> i) & 1 == 1:
        # max_xがK以下となることが確定したので、Falseにする
        check_K = False


#print(max_x)
ans = 0
for a in A:
    ans += a ^ max_x

print(ans)



Measured memory_bytes: 69008
#[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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input!{
        n: usize,
        x: i64,
        xs: [i64; n],
    }

    let mut ans = 0;

    for &t in xs.iter() {
        ans = gcd(ans, (t - x).abs());
    }

    println!("{}", ans);
}


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

int main()
{
  const int Adigit = (int)'A';
  const int Zdigit = (int)'Z';
  
  int n;
  string s;
  
  cin >> n;
  cin >> s;
  
  int c;
  int len = s.size();
  for (int i = 0; i < len; i ++)
  {
    c = (int)s.at(i) + n;
    if (c > Zdigit) c = c % (Zdigit + 1) + Adigit;
    cout << (char)c;
  }
  cout << endl;
  
  return 0;
}

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

const int DIM = 1e5 + 5;

int cnt1[DIM], frq[DIM], cnt2[DIM];

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        cnt1[x % m] ++;
        
        frq[x] ++;
        if( frq[x] % 2 == 0 )
            cnt2[x % m] ++;
    }
    
    int ans = cnt1[0] / 2;
    cnt1[0] = 0;
   
    if( m % 2 == 0 ) {
        ans += cnt1[m / 2] / 2;
        cnt1[m / 2] = 0;
    }
    
    for( int i = 1; i <= m / 2; i ++ ) {
        int aux = min( cnt1[i], cnt1[m - i] );
        
        ans += aux;
        cnt1[i] -= aux;
        cnt1[m - i] -= aux;
    }
    
    for( int i = 1; i < m; i ++ )
        ans += min( cnt1[i] / 2, cnt2[i] );
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
n = (input())

f = 0

for i in range(len(n)):
  if n[i] != 'U' and  n[i] != 'D':
    if i % 2 == 0:
      if n[i] != 'R':
        f = 1
    else:
      if n[i] != 'L':
        f = 1

if f == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
program slimes
    implicit none
    integer :: n, i, cnt = 0
    character(100000) s
    read *, n
    read *, s
    do i = 1, n
        if(s(i:i) .eq. s(i+1:i+1))cycle
        if(s(i:i) .ne. s(i+1:i+1))then
            cnt = cnt + 1
        end if
    end do
    print *, cnt
end program

Measured memory_bytes: 3180
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	int tmp, ans = 0;
	for (int i = 0; i < N; i++) {
		tmp = a[i];
		while (tmp%2 == 0) {
			tmp /= 2;
			ans++;
		}
	}

	cout << ans << "\n";

	return 0;
}

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

const ll N=1e5+5;
ll n, h[N], dp[N];

int main()
{
    cin>>n;
    for(ll i=1; i<=n; i++) cin>>h[i];
    dp[2]=abs(h[2]-h[1]);
    for(ll i=3; i<=n; i++){
        ll a = dp[i-1]+abs(h[i]-h[i-1]);
        ll b = dp[i-2]+abs(h[i]-h[i-2]);
        dp[i] = min(a,b);
    }
    cout<<(ll)dp[n];

}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int N = 310;

ll fact[N];


ll dp[N][N][N];
ll ppow[N];

int main(void){
  int n, m;
  cin >> n >> m;
  if (n > m) {
    cout << 0 << endl;
    return 0;
  }
  fact[0] = 1;
  REP(i, 1, N) {
    fact[i] = fact[i - 1] * i % mod;
  }
  dp[0][1][0] = 1;
  REP(i, 1, m + 1) {
    REP(j, 1, n + 1) {
      REP(k, 0, j) {
	if (j >= 1) {
	  dp[i][j][k] += dp[i - 1][j- 1][k];
	}
	dp[i][j][k] %= mod;
	dp[i][j][k] += dp[i - 1][j][k] * (j - k - 1);
	dp[i][j][k] %= mod;
	dp[i][j][j - 1] += dp[i - 1][j][k] * (k + 1);
	dp[i][j][j - 1] %= mod;
      }
      if (0) {
	cerr << "dp[" << i << "][" << j << "]:";
	REP(k, 0, j) {
	  cerr << dp[i][j][k] << " ";
	}
	cerr << endl;
      }
    }

  }
  ll tot = 0;
  ppow[0] = 1;
  REP(i, 1, N) {
    ppow[i] = ppow[i - 1] * (n - 1) % mod;
  }
  cout << dp[m][n][n -1] * fact[n - 1] % mod << endl;
}


Measured memory_bytes: 219392
#include <stdio.h>

int main() {
	int N;
	scanf("%d", &N);

	char head[6] = {'M', 'A', 'R', 'C', 'H'};
	int march[5] = {0, 0, 0, 0, 0};
	int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
	int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
	int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

	for (int i = 0; i < N; i++) {
		char S[15];
		scanf("%s", S);
		for (int j = 0; j < 5; j++) {
			if (S[0] == head[j]) march[j]++;
		}
	}

	long long int ans = 0;
	for (int i = 0; i < 10; i++) ans += (long long)march[P[i]]*march[Q[i]]*march[R[i]];

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//AtCoder以外ではコメントアウトを忘れずに！
//#include <atcoder/all>
//using namespace atcoder;
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path; vs S;
//***********//
map<ll, ll> primeFactorize(ll n, map<ll, ll>& PF) {
	while (n % 2 == 0) {
		PF[2]++;
		n /= 2;
	}
	for (ll p = 3; p * p <= n; p += 2) {
		while (n % p == 0) {
			PF[p]++;
			n /= p;
		}
	}
	if (n != 1) {
		PF[n]++;
	}
	return PF;
}
int main() {
	cin >> N;
	ans = 0;
	for (i = 1; i < N; i++) {
		map<ll, ll> PF;
		primeFactorize(i, PF);
		ll pre = 1;
		for (auto x:PF) {
			pre *= (x.second + 1);
		}
		//debug(pre, i);
		ans += pre;
	}
	cout << ans;
}


Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(b==1)
    {
        cout << 0 << endl;
        return 0;
    }
    int ans, k;
    k = 0;
    ans = 0;
    ans++;
    k += a;
    while (k < b)
    {
        ans++;
        k += a-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

bool** table;
int** dp;
int N;

int recursive(int left,int right){

	if(dp[left][right] != -1)return dp[left][right]; //?????¢???????????´???
	if((right-left+1)%2 == 1){ //??????????\???°?????´???
		return dp[left][right] = max(recursive(left,right-1),recursive(left+1,right));
	}
	//if(table[left][(right-left+1)/2] == true)return dp[left][right] = right-left+1; //left???right?????¨????¶?????????´???
	//if(right == left+1 && table[left][1] == false)return dp[left][right] = 0;

	for(int i = left+1; i <= right-2; i++){
		dp[left][right] = max(dp[left][right],recursive(left,i)+recursive(i+1,right));
	}
	return dp[left][right];
}

int main(){

	int data[301];
	table = new bool*[301]; //table[left][right] = left???????§?????????????2*right??????????????¨?¶??????§??????????????????
	dp = new int*[301]; //?????????????????????????????§?¶????????????°
	for(int i = 0; i <= 300; i++){
		table[i] = new bool[151];
		dp[i] = new int[301];
	}

	bool FLG;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		if(N <= 1){
			printf("0\n");
			continue;
		}

		//?¶??????????????????????????????????
		for(int i = 0; i <= N; i++){
			for(int k = 0; k <= N/2; k++)table[i][k] = false;
			for(int k = 0; k <= N; k++){
				if(i == k)dp[i][k] = 0;
				else{
					dp[i][k] = -1;
				}
			}
		}

		for(int i = 1; i <= N; i++)scanf("%d",&data[i]);

		//????????????2???????¨?
		for(int i = 1; i <= N-1; i++){
			if(abs(data[i+1]-data[i]) <= 1){
				table[i][1] = true;
				dp[i][i+1] = 2;
			}else{
				dp[i][i+1] = 0;
			}
		}

		//?¶??????????????????????????¨????
		for(int length = 4; length <= N; length += 2){ //??????????????????
			for(int left = 1; left+length -1 <= N; left++){ //??????????????????
				FLG = false;

				if(table[left+1][(length-2)/2] == true && abs(data[left] - data[left+length-1]) <= 1)FLG = true;//??????????????£?????????length-2??????????¶????????????????????????¨??????+length-1?????´???????????????????¶?????????´???

				if(!FLG){
					for(int i = 2; i <= length-2; i += 2){
						if(table[left][i/2] == true && table[left+i][(length-i)/2] == true){
							FLG = true;
							break;
						}
					}
				}
				if(FLG){
					table[left][length/2] = true;
					dp[left][left+length-1] = length;
				}
			}
		}

		printf("%d\n",recursive(1,N));
	}

	return 0;
}

Measured memory_bytes: 3004
x1,y1,x2,y2 = map(int,input().split())

x3 = x2 + y1 - y2
y3 = y2 + x2 - x1
x4 = x3 + x1 - x2
y4 = y3 + y1 - y2

print(x3,y3,x4,y4)

Measured memory_bytes: 3064
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in);
    val num = sc.nextInt;
    println(calc(num.toString.split("").toList));
  }

  def calc(list:List[String]) : String = {
    list.count(_ == "1").toString
  }
}

Measured memory_bytes: 25404
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

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

		int[][] gA = new int[n][m];
		int[][] gB = new int[m][l];

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

		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				gB[i][j] = sc.nextInt();
			}
		}
		sc.close();

		long[][] gC = new long[n][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {

				long val = 0;
				for (int k = 0; k < m; k++) {
					val += gA[i][k] * gB[k][j];
				}
				gC[i][j] = val;
			}
		}

		for(long[] c : gC) {
			StringJoiner sj = new StringJoiner(" ");
			for(long val : c) {
				sj.add(String.valueOf(val));
			}
			System.out.println(sj);
		}
	}
}

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

using namespace std;
int main() {
  set<string> p;
  int n;
  cin >> n;
  for(int i=0;i<n;i++) {
    string s;
    cin >> s;
    p.insert(s);}
  cout << p.size() << endl;
  return 0;
}

Measured memory_bytes: 19256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long,long long> pll;
typedef vector <pll> vp;
int n,tot;
long long  dis[140010];
int son[140010][2],num[140010];
long long  l,r=1ll*140010*140010,limit;
vp f[140010];
vp dp(vp a,vp b) 
{
    vp res;
	res.clear();
    int x = a.size(),y = b.size();
	int st1 = 0,st2 = 0;
    if(!y)return res;
    while(st1 != x) 
	{
        while(st2 != y && a[st1].second + b[st2].first <= limit)st2++;
        if(st2)st2--;
        if(a[st1].second + b[st2].first <= limit)res.push_back(make_pair(a[st1].first,b[st2].second));
        st1++;
    }
    return res;
}
 
void insert(vp &a,pll b) 
{
    if(a.empty())a.push_back(b);
    else if(a.back().first == b.first)a.back().second = min(a.back().second,b.second);
    else if(b.second < a.back().second)a.push_back(b);
}
 
vp merge(vp a,vp b) 
{
    vp res;
	res.clear();
    int x = a.size(),y = b.size();
	int st1 = 0,st2 = 0;
    while(st1 != x && st2 != y) 
	{
        if(a[st1].first < b[st2].first)insert(res,a[st1++]);
        else insert(res,b[st2++]);
    }
    while(st1 != x)insert(res,a[st1++]);
    while(st2 != y)insert(res,b[st2++]);
    return res;
}
 
void dfs(int u) 
{
    if(!num[u]) 
	{
        f[u].clear();
        f[u].push_back(make_pair(dis[u],dis[u]));
        return;
    }
    dfs(son[u][0]);
	dfs(son[u][1]);
	limit += dis[u] * 2;
    vp tmp1 = dp(f[son[u][0]],f[son[u][1]]);
    vp tmp2 = dp(f[son[u][1]],f[son[u][0]]);
    f[u] = merge(tmp1,tmp2);
    limit -= dis[u] * 2;
}
 
bool check() 
{
    dfs(1);
    if(!f[1].empty())return 1;
    return 0;
}
 
int main() 
{
    scanf("%d",&n);
    int fa,v;
    for(int i = 2;i <= n;i++) 
	{
    	scanf("%d%d",&fa,&v);
        dis[i] = dis[fa] + v;
        son[fa][num[fa]] = i;
        num[fa]++;
    }
    while(l < r) 
	{
        limit = (l + r) >> 1;
        if(check())r = limit;
        else l = limit + 1;
    }
    printf("%lld",r);
    return 0;
}

Measured memory_bytes: 38348
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))

n = Ii()
c = sys.stdin.readline()
rct = c.count('R')
ans = rct - c.count('R',0,rct)
print(ans)



Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

struct UnionFind {
    vector<int> par;
    
    //要素nで初期化
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    //xが属する集合の根を返す
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    //xとyが同じ集合に属しているかを判定
    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    //xが属する集合とyが属する集合をマージ
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // 計算量が減るよ
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    //xが属する集合のサイズ
    int size(int x) {
        return -par[root(x)];
    }
};




//宣言の仕方
int main(){
    int n,m;cin>>n>>m;
    UnionFind uf(n);
    int x,y,z;
	for(int i = 0; i < m; i++) {
		cin>>x>>y>>z;
		uf.merge(x - 1,y - 1);
	}
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		if(uf.root(i) == i){
			ans++;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#! /usr/bin/env ruby

input = STDIN.read.chomp().split(" ").map{|i| i.to_i}

a = input[0]
b = input[1]
k = input[2]

def half_send(c)
  if c % 2 != 0 then
    c = c - 1
  end
  return c / 2
end

is_a_turn = true

while k > 0
  if is_a_turn then
    a = half_send(a)
    b = b + a
  else
    b = half_send(b)
    a = a + b
  end

  k = k - 1
  is_a_turn = !is_a_turn
end

puts sprintf("%s %s", a, b)


Measured memory_bytes: 1788
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }
    let mut maxv = std::i64::MIN;

    for i in vec![a, b] {
        for j in vec![c, d] {
            maxv = max(maxv, i * j);
        }
    }
    println!("{}", maxv);
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll H[100005];
ll R[100005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> H[i];
    }

    memset(R, 0, sizeof(R));
    FOR(i, N, 1)
    {
        if (H[N - 1 - i] >= H[N - i])
        {
            R[N - 1 - i] = R[N - i] + 1;
        }
    }

    ll max = 0;
    REP(i, N)
    {
        max = std::max(max, R[i]);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	int high[10]={0};
	int x,max1=0,max2=0,max3=0;

	for(x=0;x<10;x++)
	{
		scanf("%d",&high[x]);
	}

	for(x=0;x<10;x++)
	{
		if(max1<high[x])
		{
			max3=max2;
			max2=max1;
			max1=high[x];
		}
		else if(max2<high[x])
		{
			max3=max2;
			max2=high[x];
		}
		else if(max3<high[x])
		{
			max3=high[x];
		}
	}

	printf("%d\n%d\n%d\n",max1,max2,max3);
	return 0;
}

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n=5;
    ll ans = 0;
    for(ll i=0;i<n;i++)
    {
        ll tp;
        cin>>tp;
        if(tp==0)
        {
            ans=i+1;
        }
    }
    cout<<ans<<"\n";
}

// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int m[1010];

int main() {
  int n;
  cin >> n;
  cout << 48 - n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char a[200];
    int i,n;
    while(scanf("%d",&n)==1)
    {
        getchar();
        gets(a);
        int c1=0,c2=0;
        for(i=0;i<n;i++)
        {
            if(a[i]=='R')
                c1++;
            else
                c2++;
        }
        if(c1>c2)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 128
# include <iostream>
# include <algorithm>
using namespace std;
int main()
{
	int n,k,s;
	s=0;
	cin>>n>>k;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0; i<n; i++)
	{
		if(a[n-1-i]>=k)
		{
			s=s+1;
		}
		else
		{
			break;
		}
	}
	cout<<s;
}

Measured memory_bytes: 3996
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		char[] sa=s.toCharArray();
		int K = sc.nextInt();
		
		List<String> list=new ArrayList<>();
		
		char minChar0='z';
		for(int i=0;i<sa.length;i++){
			minChar0=(char)Math.min(minChar0, sa[i]);
		}
		for(int i=0;i<s.length();i++){
			if(sa[i]!=minChar0)continue;
			for(int j=1;j<=5;j++){
				if(i+j>s.length())break;
				if(!list.contains(s.substring(i,i+j))){
					list.add(s.substring(i,i+j));
				}
			}
		}
		char minChar1='z';
		if(list.size()<K){
			for(int i=0;i<sa.length;i++){
				if(sa[i]==minChar0)continue;
				minChar1=(char)Math.min(minChar1, sa[i]);
			}
			for(int i=0;i<s.length();i++){
				if(sa[i]!=minChar1)continue;
				for(int j=1;j<=5;j++){
					if(i+j>s.length())break;
					if(!list.contains(s.substring(i,i+j))){
						list.add(s.substring(i,i+j));
					}
				}
			}
		}
		if(list.size()<K){
			char minChar2='z';
			for(int i=0;i<sa.length;i++){
				if(sa[i]==minChar0||sa[i]==minChar1)continue;
				minChar2=(char)Math.min(minChar2, sa[i]);
			}
			for(int i=0;i<s.length();i++){
				if(sa[i]!=minChar2)continue;
				for(int j=1;j<=5;j++){
					if(i+j>s.length())break;
					if(!list.contains(s.substring(i,i+j))){
						list.add(s.substring(i,i+j));
					}
				}
			}
		}
		Collections.sort(list);
		System.out.println(list.get(K-1));
	}

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 29);

int input(int num)
{
  if (num < 0)
  {
    return 0;
  }
  if (num > 255)
  {
    return 255;
  }
  else
  {
    return num;
  }
}

int main()
{
  while (1)
  {
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0)
    {
      break;
    }
    vector<int> C(M), X(N);
    for (int j = 0; j < M; j++)
    {
      cin >> C.at(j);
    }
    for (int i = 0; i < N; i++)
    {
      cin >> X.at(i);
    }
    vector<vector<int>> dp(N, vector<int>(256, INF));
    for (int j = 0; j < M; j++)
    {
      dp.at(0).at(input(128 + C.at(j))) = (int)pow(input(128 + C.at(j)) - X.at(0), 2);
    }
    for (int i = 1; i < N; i++)
    {
      for (int y = 0; y < 256; y++)
      {
        for (int j = 0; j < M; j++)
        {
          dp.at(i).at(input(y + C.at(j))) = min(dp.at(i).at(input(y + C.at(j))), dp.at(i - 1).at(y) + (int)pow(input(y + C.at(j)) - X.at(i), 2));
        }
      }
    }
    int ans = INF;
    for (int y = 0; y < 256; y++)
    {
      ans = min(ans, dp.at(N - 1).at(y));
    }
    cout << ans << endl;
  }
}


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

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N), B(M);
    for(int i=0; i<N; i++) cin >> A.at(i);
    for(int i=0; i<M; i++) cin >> B.at(i);
    int time = 0;
    int i = 0;
    while(i<N && K - time >= A.at(i)){
        time += A.at(i);
        i++;
    }
    int max_A_index = i;
    int max_A_time = time;
    i = 0;
    while(i<M && K - time >= B.at(i)){
        time += B.at(i);
        i++;
    }
    set<int> s;
    s.insert(i + max_A_index);
    int k = 0;
    int atime = 0, btime = 0;
    
    for(int j=max_A_index-1; j>=0; j--){
        max_A_time -= A.at(j);
        atime = max_A_time;
        while(k<M && K - (atime + btime) >= B.at(k)){
            btime += B.at(k);
            k++;
        }
        s.insert(j + k);
    }
    
    if(s.empty()) cout << 0 << endl;
    else cout << *(s.rbegin()) << endl;
}

Measured memory_bytes: 14268
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n,k;
  cin>>n>>k;
  long long a[n];
  REP(i,n){
    cin>>a[i];
  }
  
  long long s[n];//累積和
  REP(i,n){
    if(i==0){
      s[i] = a[i];
    }else{
      s[i] = s[i-1] + a[i];
    }
  }
  
  vector<long long> bs;//各数列に対する美しさを格納する配列
  REP(i,n){
    bs.push_back(s[i]);
  }
  REP(i,n){
    REP(j,i){
      bs.push_back(s[i]-s[j]);
    }
  }
  
  long long ans=0;
  long long temp;
  int cnt;
  for(int i=40;i>=0;i--){//2^40の桁まで見る。
    //i番目のビットを立たせるのが良いかどうかを上の桁から順に判定する
    temp = ans + (1LL<<i);
    cnt = 0;
    for(long long c:bs){
      if((c & temp) == temp){
        cnt++;
      }
    }
    if(cnt>=k){
      ans = temp;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6128
package main

import (
	"fmt"
)

func main() {
	var x, y int
	fmt.Scanf("%d%d", &x, &y)
	ans := gcd(x, y)
	fmt.Printf("%d\n", ans)
}

func gcd(x int, y int) int {
	var a, b int
	if x > y {
		a, b = x, y
	} else {
		a, b = y, x
	}

	for b > 0 {
		r := a % b
		a = b
		b = r
	}

	return a
}


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


int main(){
  ll n,k;
  cin>>n>>k;
  if(n<k){
    ll ans=min(n,abs(n-k));
    cout<<ans<<endl;
    return 0;
  }
  if(n==k){
    cout<<0<<endl;
    return 0;
  }
  else{
    ll x =n/k;
    ll ansa = n-(x*k);
    ll ansb = abs(n-((x+1)*k));
    ll ansmin =min(ansa,ansb);
    cout<<ansmin<<endl;
    return 0;
  }
}

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

int a[2000];
int N;

bool solve(int t, int n) {
     if (t == 0) return true;
     else if (n == N) return false;
     else return solve(t - a[n], n + 1) || solve(t, n + 1);
}

int main() {
    int q; cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    cin >> q;
    while (q--) {
        int t; cin >> t;
        if (solve(t, 0)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	set<int> s;
	int q; cin >> q;
	rep(i, q) {
		int t, x;
		cin >> t;

		switch (t) {
		case 0:
			cin >> x;
			s.insert(x);
			Cout(sz(s));
			break;
		case 1:
			cin >> x;
			Cout(s.count(x));
			break;
		case 2:
			cin >> x;
			s.erase(x);
			break;
		case 3:
			int l, r; cin >> l >> r;
			auto it = s.lower_bound(l);
			auto last = s.upper_bound(r);
			while (it != last) {
				Cout(*it);
				it++;
			}
		}
	}
}


Measured memory_bytes: 12452
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#define endl "\n"

using namespace std;

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

    int t, n, m, i, j, mx, mn, flag, ans, temp, cnt;
    cin >> n;
    n = n % 10;
    switch(n){
        case 0: cout << "pon\n"; break;
        case 1: cout << "pon\n"; break;
        case 2: cout << "hon\n"; break;
        case 3: cout << "bon\n"; break;
        case 4: cout << "hon\n"; break;
        case 5: cout << "hon\n"; break;
        case 6: cout << "pon\n"; break;
        case 7: cout << "hon\n"; break;
        case 8: cout << "pon\n"; break;
        case 9: cout << "hon\n"; break;
    }

}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
using namespace std;
const int MOD = 1e9 +7;


int main(){
    string s;
    cin>>s;
    int a[2] ={};
    for(int i=0;i<s.size();i++){
        if(s[i] =='0') a[0]++;
        else a[1]++; 
    }
    int m =min(a[0],a[1]);
    cout << m*2 <<endl;
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n,m;
    cin >> n >> m;

    vector<pair<ll,bool>> box(n);
    for (ll i = 0; i < n; i++){
        box[i].first = 1;
        box[i].second = false;
    }
    box[0].second = true;

    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--; y--;

        if (box[x].first == 1){
            if (box[x].second){
                box[x].second = false;
                box[y].second = true;
            }
        }
        else{
            if (box[x].second){
                box[y].second = true;
            }
        }
        box[x].first--;
        box[y].first++;
    }

    ll ans = 0;
    rep(i,n){
        if (box[i].second){
            ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 4748
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    set<int> s;
    rep(i,n){
        int a; cin>>a;
        s.insert(a);
    }
    int N=s.size();
    cout<<(N%2==0 ? N-1 : N)<<endl;
}

Measured memory_bytes: 4992
package main

import (
	"fmt"
	"strings"
)

var n int
var ss [][]string

func main() {
	fmt.Scan(&n)
	ss = make([][]string, 10)
	ss[0] = []string{"a"}

	for i := 1; i<10; i++ {
		for _, s := range ss[i-1] {
			m := max(s)
			for c := 'a'; c <= m+1; c++ {
				ss[i] = append(ss[i], strings.Join([]string{s, string(c)}, ""))
			}
		}
	}
	for _, s := range ss[n-1] {
		fmt.Println(s)
	}
}

func max(s string) rune {
	m := 'a'
	for _, c := range s {
		if c > m {
			m = c
		}
	}
	return m
}


Measured memory_bytes: 10112
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    vector<vector<int>> table(3, vector<int>(3, 0));
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cin >> table[i][j];
        }
    }
    int n; cin >> n;
    vector<vector<int>> used(3, vector<int>(3, 0));
    for(int i = 0; i < n; i++)
    {
        int b; cin >> b;
        for(int j = 0; j < 3; j++)
        {
            for(int k = 0; k < 3; k++)
            {
                if(table[j][k] == b)
                {
                    used[j][k] = 1;
                }
            }
        }
    }
    bool ok = false;
    for(int i = 0; i < 3; i++)
    {
        bool flag = true;
        for(int j = 0; j < 3; j++)
        {
            if(used[i][j] == false) flag = false;
        }
        if(flag) ok = true;
    }
    for(int j = 0; j < 3; j++)
    {
        bool flag = true;
        for(int i = 0; i < 3; i++)
        {
            if(used[i][j] == false) flag = false;
        }
        if(flag) ok = true;
    }
    bool flag = true;
    for(int i = 0; i < 3; i++)
    {
        if(used[i][i] == false) flag = false;
    }
    if(flag) ok = true;
    flag = true;
    int j = 2;
    for(int i = 0; i < 3; i++)
    {
        if(used[i][j] == false) flag = false;
        j--;
    }
    if(flag) ok = true;
    cout << (ok ? "Yes" : "No") << endl;
}

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

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

char a[1010][1010];
char tmp[1010][1010];

int main() {
	int a[21], b[21], c[21], n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}

	int ans = 0;

	for (int i = 0; i < n; i++) {
		ans += b[a[i]-1];
		if (i > 0 && a[i]==a[i-1]+1) {
			ans += c[a[i - 1]-1];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<long long int> a(3*n);
  for(int i=0;i<3*n;i++) cin>>a[i];
  sort(a.rbegin(),a.rend());
  long long int res=0;
  for(int i=0;i<n;i++) res+=a[i*2+1];
  cout<<res<<endl;
  
  return 0;
}


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10 ** 7)

n = int(input())
ab = [tuple(map(int,input().split())) for i in range(n-1)]

es = [[] for i in range(n)]
for i, (a,b) in enumerate(ab):
    a,b = a-1,b-1
    es[a].append((b, i))
    es[b].append((a, i))

visited = [0]*n
ans_color = [0]*(n-1)

# DFS
def dfs(v, fromColor):
    color = 1
    visited[v] = 1
    for to, i in es[v]:
        if visited[to]: continue

        if color == fromColor:
            color += 1
        ans_color[i] = color
        dfs(to, color)
        color += 1

root = 0 # 頂点1が存在することが問題文中で保証されてるからここを根ノードとしよう
dfs(root, 0)

print(max(ans_color))
print(*ans_color, sep='\n')


Measured memory_bytes: 83048