akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl x;
    cin >> x;
    bool f = false;
    rep(i,1000){
        rep(j,1000){
            intl a = i * i * i * i * i;
            intl b = j * j * j * j * j;
            if(a - b == x){
                cout << i << " " << j << endl;
                f = true;
            }
            else if(a + b == x){
                cout << i << " " << -j << endl;
                f = true;
            }
        }
        if(f)break;
    }
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int n, m, l, r, res, num[200007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int check(int mid)
{
	for (int i = 2 * mid + 1, j = 2 * n; i < j; i++, j--)
		if (num[i] + num[j] < m)return 0;
	return 1;
}
int main()
{
	n = read();
	m = read();
	for (int i = 1; i <= 2 * n; i++)
		num[i] = read();
	sort(num + 1, num + 2 * n + 1);
	r = n;
	while (l < r)
	{
		int mid = (l + r) / 2;
		if (check(mid))r = mid;
		else l = mid + 1;
	}
	for (int i = 1, j = 2 * l; i < j; i++, j--)
		res = max(res, num[i] + num[j]);
	for (int i = 2 * l + 1, j = 2 * n; i < j; i++, j--)
		res = max(res, num[i] + num[j] - m);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] W = new int[n];
		for(int i = 0; i < n; i++){
			W[i] = scan.nextInt();
		}

		System.out.printf("%d\n", minCostSort(W));
	}

	private static int indexOf(int[] A, int x){
		for(int i = 0; i < A.length; i++){
			if(A[i] == x){
				return i;
			}
		}
		return -1;
	}

	private static int minCostSort(int[] W){
		int[] sorted = W.clone();
		Arrays.sort(sorted);
		int cost = 0;
		for(int i = 0; i < W.length; i++){
			int a = indexOf(W, sorted[i]); // ??\??????????????????
			int change = 0;
			while(i < a){ // ????????????????????????????????\???????????????????????§?????????
				int b = indexOf(W, sorted[a]); // ?????????????????????????????\??????????????????????????????????????\?????????
				cost += W[b]; // ??????????????????????¶????
				int work = W[a]; // ???????????¨??´??\????????????
				W[a] = W[b];
				W[b] = work;
				change++;
				a = b;
			}
			cost += Math.min(sorted[i] * change,// ?§??????????????????¨???????????°
								 sorted[0] * change + (sorted[i] * 2 + sorted[0] * 2)); // ????????????????????¨?§???????????????????????????????
																				// ????????????????????¨?§??????????????????????
																				// ????????????????????¨?§??????????????????????
		}
		return cost;
	}
}

Measured memory_bytes: 31404
import collections

n = int(input())
graph = collections.defaultdict(list)
for _ in range(n-1):
  a, b = map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)

cur_f = [1]
cur_s = [n]
visit_f = {1}
visit_s = {n}
while cur_f or cur_s:
  temp_f = []
  for start in cur_f:
    for end in graph[start]:
      if end not in visit_f and end not in visit_s:
        temp_f.append(end)
        visit_f.add(end)
  cur_f = temp_f
  temp_s = []
  for start in cur_s:
    for end in graph[start]:
      if end not in visit_f and end not in visit_s:
        temp_s.append(end)
        visit_s.add(end)
  cur_s = temp_s

if len(visit_f) > len(visit_s):
  print("Fennec")
else:
  print("Snuke")

Measured memory_bytes: 32316
#include<iostream>
#include<cstdlib>
#include<stack>
 
using namespace std;
 
int main() {
  stack<int> S;
  int a, b, x;
  string s;
 
  while ( cin >> s ){
    if ( s[0] == '+' ) {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a + b);
    } else if ( s[0] == '-' ) {
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a - b);
    } else if ( s[0] == '*' ) {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a * b);
    } else {
      S.push(atoi(s.c_str()));
    }
  }
  cout << S.top() << endl;
 
  return 0;
}


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

ll pow(ll a, ll b, ll c)
{

    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res *= a;
            res %= c;
        }

        a *= a;
        a %= c;
        b >>= 1;
    }
    return res;
}

main()
{
    ll n, k;
    cin >> n >> k;
    ll mod = 1000000007;

    ll d_dash[k + 1];

    for (int i = 1; i <= k; i++)
    {
        d_dash[i] = pow(floorl(k / i), n, mod);
    }

    ll d[k + 1];

    for (int i = k; i >= 1; i--)
    {
        ll sum = 0;
        ll ul = floor(k / i);
        for (int j = 2; j <= ul; j++)
        {
            sum += d[j * i];
        }
        d[i] = d_dash[i] - sum;
    }
    ll ans = 0;
    for (int i = 1; i <= k; i++)
    {
        ans += i * d[i];
        ans %= mod;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5180
/********************************************************
     Failing doesn’t give you a reason to give up,
     as long as you believe.
                                  - Seventh Hokage
********************************************************/

#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <set>

using namespace std;

#define int long long int
typedef vector< int >        vi;
typedef set< int >           si;
typedef pair< int, int >     pii;
typedef map< int, int >      mii;
#define sz(a)           (int)((a).size())
#define pb              push_back
#define mp              make_pair
#define all(c)          (c).begin(),(c).end()
#define rall(c)         (c).rbegin(),(c).rend()
#define ub(c,k)         (upper_bound(all(c),k)-(c).begin())
#define lb(c,k)         (lower_bound(all(c),k)-(c).begin())
#define inf             LLONG_MAX
#define _inf            LLONG_MIN
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define fr(n)           for(int i=0;i<n;i++)
#define tr(a)           for(auto it=a.begin();it!=a.end();it++)
#define trr(a)          for(auto it=a.rbegin();it!=a.rend();it++)
#define find(c, x)      (c.find(x) != c.end())
#define M               1000000007
#define PI              3.1415926535897932384
#define F               first
#define S               second
#define accuracy(x)     cout<<fixed<<setprecision(x);
#define fuck            {cout<<-1;return;}
#define fasterBaby      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define elasped_time	1.0 * clock() / CLOCKS_PER_SEC
#define N               200005
int a[N],b[N],vis[N],ans=0;
vi cnt[N];
int sol[N],k=0;
int recur(int x)
{
	//cout<<x;
	int temp=a[x];
	if(vis[x]) return 0;
	vis[x]=1;
	for(auto t:cnt[x]) {temp+=recur(t);}
	ans+=temp;
	sol[k++] = x;
	return temp;
}

void basEkBaarAur()
{
	int n,d,x,y,cnt=0;
	cin>>n>>d;
	fr(n) {
		cin>>x>>y;
		if(x*x + y*y <= d*d) cnt++;
	}
	cout<<cnt;
}

signed main()
{
	accuracy(15)
	fasterBaby
	int TESTS=1,i=1;
	//cin>>TESTS;
	while(TESTS--)
	{
		//cout<<"Case#"<<i++<<endl;
		basEkBaarAur();
		cout<<endl;
	}
	cerr<<endl<<"समय गुज़रा : "<<elasped_time<<endl;
	return 0;
}

Measured memory_bytes: 8500
#include <iostream>
#include <set>
using namespace std;
int main(){
  int a,b,c; cin >> a >> b >> c;
  set<int> st;
  for (int i = 0; i <= b; i++)
    st.insert((a*i)%b);
  printf("%s\n",(st.find(c)!=st.end()) ? "YES" : "NO");
  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define all(c) (c).begin(),(c).end()
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}
void dump() {}
template <class H, class... T>void dump(H&& head, T&&... tail)
{cout << head << (sizeof...(tail)==0 ? "\n" : " "); dump(forward<T>(tail)...);}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m;
  cin >> n >> m;
  priority_queue<int, vector<int>> que; 

  for(int i = 0; i < n; ++i){
    int t;
    cin >> t;
    que.push(t);
  }
  for(int i = 0; i < m; ++i){
    int t = que.top();
    que.pop();
    que.push(t/2);
  }
  ll ans = 0;
  for(int i = 0; i < n; ++i){
    int t = que.top();
    que.pop();
    ans += t;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 892
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    double a, b;
    cin >> a >> b;
    for(double i = 0; i <= 100000; i++){
        if(floor(i * 0.08) == a && floor(i * 0.1) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define YES cout<<"yes"<<endl


int main (){
    int k,x;
    cin >> k>>x;
    vector <int> ans;
    int kurai ,p =0;
    rep(i,2*k){
        kurai = x-(k-p);
        //if(kurai < -100000 || kurai > 10000)
        ans.push_back(kurai);
        p++;
    }
    sort(ans.begin(),ans.end());
  reverse(ans.begin(),ans.end());
  vector<int> anss;
  
    rep(i,2*k-1){
       // printf("%d ",ans.at(i));
      anss.push_back(ans.at(i));
      //sort(anss.begin(),anss.end());
      //printf("%d ",ans.at(i));
    }
   sort(anss.begin(),anss.end());
  rep(i,2*k-1){
    //sort(anss.begin(),anss.end());
      printf("%d ",anss.at(i));
  }
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const distances = arg[0].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    
    console.log(distances[0] + distances[1]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){

  string s;
  cin >> s;
  int n = s.size();
  
  bool fail = 0;
  
  rep(i,n/2-1){
    if(s[i] != s[n-1-i]) fail = 1;
    if(s[i] != s[n/2-1-i]) fail = 1;
  }
  
  if(fail) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
using namespace std;
 
int N,M;
int p[100001];
bool S[100001];
int ans = 0;
int penalty = 0;
 
bool isAC[100001];//i番目の問題をACしたかどうか
int WAcounter[100001];//i番目の問題に何回WAを出したか
 
void solve(){
	memset(isAC,0,sizeof(bool)*(100001));
	memset(WAcounter,0,sizeof(int)*(100001));
	for(int i=1;i<=M;i++){
		if(!isAC[p[i]]){//p[i]番目の問題がまだACされてないなら
			if(S[i]){
				ans++;//p[i]番めがACなら
				isAC[p[i]] = true;
				penalty+=WAcounter[p[i]];
			}
			if(!S[i]) WAcounter[p[i]]++;//p[i]番めがWAなら
		}
	}
}
 
int main(){
  cin>>N>>M;
  for(int i=1;i<=M;i++){
  	cin>>p[i];
  	string ACWA;
  	cin>>ACWA;
  	if(ACWA=="AC") S[i] = true;
  	if(ACWA=="WA") S[i] = false;
  }
 
  solve();
 
  cout<<ans<<" "<<penalty;
  return 0;
}

Measured memory_bytes: 1280
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	vector<pair<string,pair<ll,ll> > >v;
	for(ll i=0;i<n;i++)
	{
		string s;ll scr;
		cin>>s>>scr;
		v.push_back({s,{-scr,i+1}});
	}
	sort(v.begin(),v.end());
	for(ll i=0;i<n;i++)
	cout<<v[i].s.s<<endl;
}

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

mt19937_64 llrand((int) chrono::steady_clock::now().time_since_epoch().count());

#define st first
#define nd second
#define pb push_back

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;

const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

string s;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> s;
  if(s.back() == '3') cout << "bon\n";
  else if(s.back() == '0' or s.back() == '1' or s.back() == '6' or s.back() == '8') cout << "pon\n";
  else cout << "hon\n";
}


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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int a[4];
	int b[2];
	cin >>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1];
	sort(a, a+4, greater<int>());
	cout << a[0]+a[1]+a[2]+max(b[0],b[1])<<endl;
	return 0; 
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;

int R, S, P; 
int junken(char c) {
  if (c == 'r') {
    return P;
  }
  if (c == 'p') {
    return S;
  }
  if (c == 's') {
    return R;
  }
}

signed main(){
  int N, K; cin >> N >> K;
  cin >> R >> S >> P;
  string T; cin >> T;

  int sum = 0;
  REP(x, N) {
    if (K < x+1) {
      dv("a", T.at(x));
      dv("b", T.at(x-K));
      cerr << endl;
      if (T.at(x) == T.at(x-K)){
        T.at(x) = 'E';
        continue;
      }
    }
    sum += junken(T.at(x));
  }

  cout << sum << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		String h = sc.nextLine();
		if(h.length() % 2 == 1){
		System.out.println("No");
		System.exit(0);
		}else{
        String[] hi = new String[h.length() / 2];
        int count = 0;
        for(int i = 0; i < h.length();i += 2) {
            hi[i / 2] = h.substring(i, i + 2);
            if (hi[i / 2].equals("hi"))
            count++;
        }
        if (count == h.length() / 2)
        System.out.println("Yes");
        else
		System.out.println("No");
		}
    }
}

Measured memory_bytes: 23252
using System;

namespace abc109_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[]array=Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            if (a % 2 == 0 || b % 2 == 0)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll v; gi(v);
	int t = sqrt(v)+1, ans = 0;
	iter(k, 2, t+1) {
		ll x = v;
		while(!(x % k)) x /= k;
		ans += (x%k==1);
	}
	ans += (t!=v);
	v--;
	for(int i=1; 1ll*i*i<=v; i++) {
		if(v%i) continue;
		ans += (i>t);
		ans += ((v/i)>t);
	}
	print(ans);
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a<=b&&c<=d)
    cout<<a+c<<endl;
  else if (a<=b&&c>d)
    cout<<a+d<<endl;
  else if(a>b&&c<=d)
    cout<<b+c<<endl;
  else
    cout<<b+d<<endl;
}

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

int a, b, c;
int n, r;

int main() {
  while(cin >> a >> b >> c && (a|b|c)) {
    cin >> n;
    int br = min(min(a*a+b*b, b*b+c*c), c*c+a*a);
    while(n--) {
      cin >> r;
      if(r*r*4 > br) {
        cout << "OK" << endl;
      } else {
        cout << "NA" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1156
using System;
using System.Linq;

namespace ABC141B
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            if (S.Select((x, i) => new { I = i + 1, C = x }).Where(x => x.I % 2 != 0).Any(x => x.C == 'L')
                || S.Select((x, i) => new { I = i + 1, C = x }).Where(x => x.I % 2 == 0).Any(x => x.C == 'R'))
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 13396
n,m,q = map(int,input().split())

abcdl = []
for _ in range(q):
    a,b,c,d = map(int,input().split())
    abcdl.append((a,b,c,d))

cl = []
def dfs(i):
    if len(i) == n:
        cl.append(i)
        return
    for j in range(i[-1], m+1):
        dfs(i + [j])


for i in range(1,m+1):
    dfs([i])


ans = 0
for cc in cl:
    tmp = 0
    for a,b,c,d in abcdl:
        if cc[b-1] - cc[a-1] == c:
            tmp += d
    # print(tmp)
    ans = max(tmp, ans)

print(ans)




Measured memory_bytes: 95444
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,x,ans=0;
    cin>>a>>b>>c>>x;
    
    for(int i=0; i<=a; i++){
            for(int j=0; j<=b; j++){
                    for(int k=0; k<=c; k++){
                            if(x == 500*i+100*j+50*k){
                                    ans++;
                            }
                    }
            }
    }
    cout<<ans<<endl;
}


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

int main(){
   ll b = 1e18;
   ll n;
  cin >>n;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a.at(i);
    if(a.at(i) == 0){
      cout << 0 << endl;
      return 0;
     }
  }
  ll ans =1;
  rep(i,n) {
    if((b+1)/ans < a.at(i)){
      cout << -1 << endl;
      return 0;
    }
    ans *= a.at(i);
    if(ans > b){
      cout << -1 << endl;
      return 0;
    }
    
  }
    cout << ans << endl;
}

Measured memory_bytes: 4044
#include<iostream>
#include<cmath>

int main(){
	int n, m;
	int rtM;
	std::cin>>n>>m;
	rtM= std::sqrt(m);

	for(int i=n; i<=rtM; i++){
		if(m%i == 0){
			std::cout<<m/i<<std::endl;
			return 0;
		}
	}

	for(int i=std::min(rtM, m/n); i>0; i--){
		if((m-(n-1)*i) % i ==0){
			std::cout<<i<<std::endl;
			return 0;
		}
	}

	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    vector<ll> hen2;
    unordered_map<ll,int> mp;
    ll temp;
    REP(i,N){
        cin>>temp;
        if(mp.count(temp)>0){
            hen2.pb(temp);
            mp.erase(temp);
        }else{
            mp[temp]=1;
        }
    }
    sort(all(hen2),greater<ll>());
    if(hen2.size()>=2){
        
    ll ans;ans=hen2[0]*hen2[1];
    print(ans);
    return 0;   
    }else{
    print("0");
    return 0;
    }
}

Measured memory_bytes: 4388
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int C = (int)1e9 + 55;
const int N = 100100;
int n;
pii a[N];
pii pref[N], suf[N];
int ans = 0;

pii inter(pii v, pii u) {
	pii r = mp(max(v.first, u.first), min(v.second, u.second));
	r.second = max(r.first, r.second);
	return r;
}

void relaxAns(pii v, pii u) {
	ans = max(ans, v.second + u.second - v.first - u.first);
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &a[i].first, &a[i].second);
		a[i].second++;
	}
	sort(a, a + n);
	pref[0] = mp(0, C);
	for (int i = 0; i < n; i++)
		pref[i + 1] = inter(pref[i], a[i]);
	suf[n] = mp(0, C);
	for (int i = n - 1; i >= 0; i--)
		suf[i] = inter(suf[i + 1], a[i]);
	for (int i = 0; i < n; i++)
		relaxAns(a[i], inter(pref[i], suf[i + 1]));
	for (int i = 1; i < n; i++)
		relaxAns(pref[i], suf[i]);
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

constexpr ll inf = 2e18;

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

	int n; cin >> n;
	int a[n]; rep(i, 0, n) cin >> a[i];
	ll f[n][n];
	per(l, 0, n) {
		f[l][l] = 0;
		rep(r, l + 1, n) {
			f[l][r] = inf;
			rep(m, l, r) ckmin(f[l][r], f[l][m] + f[m + 1][r]);
			rep(i, l, r + 1) f[l][r] += a[i];
		}
	}
	cout << f[0][n - 1];
}

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

int main() {
  string S,T;
  cin >> S >> T;
  unsigned int i = 0;
  while(S.at(i) == T.at(i)){
    i = i + 1;
    if(i == S.size()){
    break;
    }
  }
  if(i == S.size()){
  cout << "Yes" <<endl;
  }
  else{
  cout << "No" <<endl;
  }
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;

class mint {
    ll x;
public:
    mint(ll x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    // O(log t)
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // O(log MOD)
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    ll N, K;
    in(N); in(K);
    mint sum(0LL);
    for(ll i=K; i<N+2; i++) {
        mint tmp(0LL);
        tmp += i;
        tmp *= N-i+1;
        sum += tmp+1;
    }
    cout << sum << endl;

	return 0;
}


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

int	main(void)
{
	long long a;
	cin >> a;
	string s;
	cin >> s;
	int b = 0;
	b += (s[0] - '0') * 100;
	b += (s[2] - '0') * 10;
	b += (s[3] - '0');
	a *= b;
	a /= 100;
	cout << a << endl;
}


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


int main(){
  
  int n, c = 0 ,res ;
  
  scanf("%d",&n);
  if(n >= 15)
  {
  		c = n/15;
  		res = (n * 800) - (c * 200);
	}else
	{
	res = n * 800;
	}  	
printf("%d", res);
  
  
 return 0 ; 
  }


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

using namespace std;

#define MAX_V 555
#define INF 1e9

struct edge {
    int to, cap, rev;
    edge(int to, int cap, int rev) :
        to(to), cap(cap), rev(rev) {}
};

vector<edge> G[MAX_V];
int level[MAX_V], iter[MAX_V];

void add_edge(int from, int to, int cap)
{
    G[from].push_back(edge(to, cap, G[to].size()));
    G[to].push_back(edge(from, 0, G[from].size()-1));
}

void bfs(int s)
{
    memset(level, -1, sizeof(level));
    queue<int> Q;
    level[s] = 0;
    Q.push(s);
    while (!Q.empty()) {
	int v = Q.front(); Q.pop();
	for (int i = 0; i < (int)G[v].size(); i++) {
	    edge &e = G[v][i];
	    if (e.cap > 0 && level[e.to] < 0) {
		level[e.to] = level[v] + 1;
		Q.push(e.to);
	    }
	}
    }
}

int dfs(int v, int t, int f)
{
    if (v == t) return f;
    for (int &i = iter[v]; i < (int)G[v].size(); i++) {
	edge &e = G[v][i];
	if (e.cap > 0 && level[v] < level[e.to]) {
	    int d = dfs(e.to, t, min(f, e.cap));
	    if (d > 0) {
		e.cap -= d;
		G[e.to][e.rev].cap += d;
		return d;
	    }
	}
    }
    return 0;
}

int max_flow(int s, int t)
{
    int flow = 0;
    for (;;) {
	bfs(s);
	if (level[t] < 0) return flow;
	memset(iter, 0, sizeof(iter));
	int f;
	while ((f = dfs(s, t, INF)) > 0) {
	    flow += f;
	}
    }
}

void init()
{
    for (int i = 0; i < MAX_V; i++) {
        G[i].clear();
    }
}

int main()
{
    int Tc, W, H;
    cin >> Tc;
    for (int t = 0; t < Tc; t++) {
        init();
        cin >> W >> H;
        vector<vector<int>> r(H, vector<int>(W));
        
        int sum = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> r[i][j];
                sum += r[i][j];
            }
        }
        
        const int di[] = {-1, +0, +1, +0};
        const int dj[] = {+0, -1, +0, +1};
        
        int S = H * W, T = S + 1;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i + j) % 2 == 0) {
                    add_edge(S, i * W + j, r[i][j]);
                    for (int k = 0; k < 4; k++) {
                        int ni = i + di[k];
                        int nj = j + dj[k];
                        if (0 <= ni && ni < H && 0 <= nj && nj < W) {
                            add_edge(i * W + j, ni * W + nj, INF);
                        }
                    }
                } else {
                    add_edge(i * W + j, T, r[i][j]);
                }
            }
        }
        cout << "Case " << t + 1 << ": " << sum - max_flow(S, T) << endl;
    }
    return 0;
}

Measured memory_bytes: 3256
import sys
S = input()
Q = int(input())
pin = 0
left = ''
right = ''
for i in range(Q):
  t = list(sys.stdin.readline().split())
  if int(t[0]) == 1:
    pin += 1
  else:
    if int(t[1]) % 2 == pin % 2 :
      right = right + t[2]
    else:
      left = t[2] + left
S = left + S + right
if pin % 2 == 1:
  S = S[::-1]
print(S)


Measured memory_bytes: 4368
import java.util.*;
import java.io.*;
public class Main{
/// functions
static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
// end
static long[] f;
// taking inputs
static BufferedReader s;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
// ends
//......................................@uthor_Alx..............................................
static boolean check(String s){
	int i=0,j=s.length()-1;
	while(i<j){
		if(s.charAt(i)!=s.charAt(j)){return false;}
		i++;j--;
	}
	return true;
}
public static void main(String[] args) throws  IOException{
       assign();
       int l=int_v(read());
       double x=(double)l/3;
       x=x*x*x;    
       out.write(x+"");
             
        out.flush();
  }
}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x<<"="<<x<<endl
using ll=long long;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N)cin>>A[i];

  set<ll> cands;
  for(ll num:A){
    repl(base,2,sqrt(num)+1){
      if(num%base==0 && num!=base){
        cands.insert(base);
        cands.insert(num/base);
      }
    }
    if(num!=1)cands.insert(num);
  }
  ll res=0;
  for(ll cand:cands){
    ll tres=0;
    for(ll num:A){
      if(num%cand==0){
        tres+=num;
      }
    }
    res=max(res,tres);
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 4080
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n;
	cin >> n;
	int h = n/3600;
	int m = (n-h*3600)/60;
	int s = n%60;
	cout << h << ":" << m << ":" << s << endl;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    int ans = 1e9;
    rep(i, n - k + 1)
    {
        int mn = h[i];
        int mx = h[i + k - 1];
        ans = min(ans, abs(mn - mx));
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,M;
    string S;
    cin >> N>>M;
    vector<ll> H(N);
    REP(i, N)
        cin >> H.at(i);
    
    vector<ll> A(M);
    vector<ll> B(M);

    REP(i, M)
        cin >> A.at(i) >> B.at(i);

    vector<ll> good(N);
    REP(i,N){
        good.at(i) = 1;
    }

    REP(i,M){
        ll tmp_A = H.at(A.at(i) - 1);
        ll tmp_B = H.at(B.at(i) - 1);

        //cout << tmp_A <<" "<< tmp_B << endl;

        if(tmp_A>tmp_B){
            good.at(B.at(i) - 1) = 0;
        }
        else if (tmp_A < tmp_B){
            good.at(A.at(i) - 1) = 0;
        }
        else{
            good.at(B.at(i) - 1) = 0;
            good.at(A.at(i) - 1) = 0;
        }
    }
    ll ans = 0;
    REP(i, N)
    {
        ans += good.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6348
#include<iostream>
using namespace std;
string s;long k;
main()
{
	cin>>s>>k;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!='a'&&123-s[i]<=k)
		{
			k-=123-s[i];s[i]='a';
		}
	}
	s[s.size()-1]+=k%26;if(s[s.size()-1]>122)s[s.size()-1]-=26;
	cout<<s<<endl;
}

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

signed main() {
	constexpr int INF = 1<<30;

	string S;
	cin >> S;
	int N = S.size();

	vector<int> hash(N);
	int h = 0;
	for(int i=0; i<N; i++){
		h = h ^ (1<<(S[i]-'a'));
		hash[i] = h;
	}

	if(__builtin_popcount(hash.back()) <= 1){
		cout << 1 << endl;
		return 0;
	}

	vector<int> dp(1<<26, INF);
	dp[0]=0;
	for(int i=0; i<N; i++){
		int minval = INF;
		int palindromehash = 0;
		int subtractedhash = palindromehash ^ hash[i];
		minval = min(minval, dp[subtractedhash]+1);
		for(int j=0; j<26 ;j++){
			int palindromehash = 1<<j;
			int subtractedhash = palindromehash ^ hash[i];
			minval = min(minval, dp[subtractedhash]+1);
		}
		dp[hash[i]] = min(minval, dp[hash[i]]);
	}

	cout << dp[hash.back()] << endl;
	return 0;
}


Measured memory_bytes: 263556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int k; cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    if (n <= k) cout << s << endl;
    else {
        cout << s.substr(0,k);
        cout << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  cin >> N >> M;
  
  vector<pair<long long int,int>> AB(N);
  for(int i=0;i<N;i++){
    long long int A;
    int B;
    cin >> A >> B;
    AB.at(i)={A,B};
  }
  
  sort(AB.begin(),AB.end());
  int m=0;
  long long int S=0;
  
  for(int j=0;j<N;j++){
    for(int k=0;k<AB.at(j).second;k++){
      S +=AB.at(j).first;
      m++;
      if(m==M){
        break;
      }
    }
    if(m==M){
        break;
      }
  }
 
  cout << S << endl;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

ll box[3001][3001];
ll dp[3001][3001][4];

int main() {
    ll r, c, k;
    cin >> r >> c >> k;
    rep(i, k) {
        ll a, b, v;
        cin >> a >> b >> v;
        a--;
        b--;
        box[a][b] = v;
    }

    dp[0][0][0] = 0;
    dp[0][0][1] = box[0][0];

    repd(j, 1, c) {
        dp[0][j][0] = dp[0][j - 1][0];
        repd(m, 1, 4) {
            if (box[0][j] == 0) {
                rep(m, 4) { dp[0][j][m] = dp[0][j - 1][m]; }
                continue;
            }
            if (m == 1 || dp[0][j - 1][m - 1] != 0) {
                dp[0][j][m] =
                    max(dp[0][j - 1][m - 1] + box[0][j], dp[0][j - 1][m]);
            }
        }
    }

    repd(i, 1, r) {
        rep(j, c) {
            ll temp = 0;
            rep(m, 4) { temp = max(temp, dp[i - 1][j][m]); }
            if (j == 0) {
                dp[i][j][0] = temp;
                dp[i][j][1] = temp + box[i][j];
            } else {
                if (box[i][j] == 0) {
                    dp[i][j][0] = max(temp, dp[i][j - 1][0]);
                    repd(m, 1, 4) { dp[i][j][m] = dp[i][j - 1][m]; }
                    continue;
                }
                dp[i][j][0] = max(temp, dp[i][j - 1][0]);
                repd(m, 1, 4) {
                    if (m == 1 || dp[i][j - 1][m - 1] != 0) {
                        dp[i][j][m] = max(dp[i][j - 1][m - 1] + box[i][j],
                                          dp[i][j - 1][m]);
                    }
                }
                dp[i][j][1] = max(dp[i][j][1], temp + box[i][j]);
            }
        }
    }

    /*
    rep(i, r) {
        rep(j, c) {
            rep(m, 4) {
                cout << i << "," << j << "," << m << ":" << dp[i][j][m] << endl;
            }
        }
    }
    */

    ll ans = 0;
    rep(m, 4) { ans = max(ans, dp[r - 1][c - 1][m]); }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 355204
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i = 0 ; i<n; i++) cin>>a[i];
	int b[n]={0};
	int x = 0;
	if(n&1)
	{
		for(int i = n-1; i>=0; i-=2)
			cout<<a[i]<<" ";
		for(int i = 1; i<n; i+=2)
			cout<<a[i]<<" ";
	}
	else
	{
		for(int i = n-1;i>=0; i-=2)
			cout<<a[i]<<" ";
		for(int i = 0; i<n;i +=2)
			cout<<a[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double pi=3.141592653589793;

int main(){
	double a,b,x;
	cin>>a>>b>>x;
	double s=x/a;//面積
	double rad;
	if(a*b/2<=s){//半分あるかどうか
		double w=(a*b-s)*2/a;
		rad = atan2(w,a);
	}else{
		double w=s*2/b;
		rad = atan2(b,w);
	}
	cout<<fixed<<setprecision(8)<<rad/pi*180<<endl;
}

Measured memory_bytes: 4116
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i=0; i < (n); i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;

int op(int x, int y)
{
    return max(x, y);
}

int e()
{
    return 0;
}

int main() {
    int n, k;
    cin >> n >> k;
    segtree<int, op, e> seg(300005);
    int ans = 0;
    rep(i, n){
        int a;
        cin >> a;
        int l = max(a-k, 0);
        int r = min(a+k+1, 300005);
        int longest;
        longest = seg.prod(l, r); //[l, r)から最大値を取ってくる
        seg.set(a, longest+1); // seg[a]を更新
        ans = max(ans, longest+1);
    };
    cout << ans << endl;
}

Measured memory_bytes: 8552
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int MAXN = 23;
int n, m;
double dis[MAXN][MAXN];
double ans, x[MAXN], y[MAXN], z[MAXN];
bool use[MAXN];
int arr[MAXN];

void dfs(int dp)
{
	if(dp == m + 1)
	{
		double sum=0;
		for(int i=1;i<dp;i++)
			for(int j=i+1;j<dp;j++)
				sum += dis[arr[i]][arr[j]];
		ans = max(ans, sum);
		return;
	}
	for(int i=arr[dp-1]+1;i<=n;i++)	if(!use[i])
	{
		use[i] = 1;
		arr[dp] = i;
		dfs(dp + 1);
		use[i] = 0;
	}
}

double caldis(int i, int j)
{
	double dx = x[i] - x[j],
		   dy = y[i] - y[j],
		   dz = z[i] - z[j];
	return dx * dx + dy * dy + dz * dz;
}

int main()
{
	while(~scanf("%d %d", &n, &m))
	{
		for(int i=1;i<=n;i++)
		{
			scanf("%lf %lf %lf", &x[i], &y[i], &z[i]);
		}
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j] = caldis(i, j);
		ans = 0;
		memset(arr, 0, sizeof(arr));
		memset(use, 0, sizeof(use));
		dfs(1);
		printf("%.6lf\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1256