akhauriyash/Code-Regression huggingface dataset:
/*
* @Author: windystreet
* @Date:   2018-08-05 20:55:05
* @Last Modified by:   windystreet
* @Last Modified time: 2018-08-05 20:57:22
*/
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+2;
const int INF  = 1<<30;
const int mod  = 1e9+7;

void solve(){
	int n;
    cin>>n;
    if(n<1200){
    	cout<<"ABC\n";
    }else if(n<2800){
    	cout<<"ARC\n";
    }else{
    	cout<<"AGC\n";
    }


    return;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int a, b; cin >> a >> b;
  int n = b - a;
  ll h = n * (n + 1) / 2;;
  cout << h - b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <map>

class Baseball{
    private:
        int score;
        int out;
        int runner;
        int inning;

    public:
        Baseball(); //コンストラクタ
        int getScore() { return score; }
        int addScore(int score) { score += score; }
        int getInning() { return inning; }
        bool addOut(); //アウトを加える，チェンジならtrue
        void moveOnRunner(); //ヒット時にランナーを進塁させる
        void slamHomeRun(); //ホームランを打ったとき
        void changeInning(); //イニングを変える，スコア, ランナーも0に戻す
};
Baseball::Baseball(){
    score = 0;
    out = 0;
    runner = 0;
    inning = 1;
}

bool Baseball::addOut(){
    out = (out + 1) % 3;
    return out == 0 ? true : false;
}

void Baseball::moveOnRunner(){
    if(runner < 3){
        runner++;
    } else if(runner == 3){
        runner = 3;
        score += 1;
    }
}

void Baseball::slamHomeRun(){
    score += (runner + 1);
    runner = 0;
}

void Baseball::changeInning(){
    score = 0;
    runner = 0;
    inning += 1;
}

int main(){
    Baseball b;
    int totalInning = 0;
    bool change_flag = false;
    std :: string event;
    std :: map<std :: string, int> map;

    map["HIT"] = 1;
    map["HOMERUN"] = 2;
    map["OUT"] = 3;

    std :: cin >> totalInning;
    std :: getline(std :: cin, event);
    while(b.getInning() <= totalInning){
        std :: getline(std :: cin, event);
        switch(map[event]){
            case 1:
                b.moveOnRunner();
                break;
            case 2:
                b.slamHomeRun();
                break;
            case 3:
                change_flag = b.addOut();
                break;
            default:
                break;
        }
        if(change_flag) {
            std :: cout << b.getScore() << std :: endl;
            b.changeInning();
            change_flag = false;
        }
    }
}


Measured memory_bytes: 3028
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

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

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<int> res;
vector<int> ord;

int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(0);
   
   ll n, m, i, j, k;

   cin>>n;

   ll res = 0;

   for(i = 1;i <= n;i++){
       if(i%3 == 0 || i%5 == 0){
           continue;
       }
       else{
           res += i;
       }


   }
   cout<<res<<"\n";

}




Measured memory_bytes: 3652
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int k, n; cin >> k >> n;
	vector<int> a(n + 1);
	rep(i, n)cin >> a[i];
	a[n] = k + a[0];
	int mx = 0;
	rep(i, n)mx = max(mx, a[i + 1] - a[i]);
	cout << k - mx << endl;
}

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

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

using namespace std;


long long pow_mod(long long x, long long y, long long MOD){
	long long ret = 1;
	while(y){
		if (y & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		y>>=1;
	}
	return ret;
}

signed main(){
  int N, M;
  cin>>N>>M;
  vector<int> a(M), b(M), c(M);
  int tmp;

  rep(i, M){
      cin >> a[i] >> b[i];
      rep(j, b[i]){
          cin >> tmp;
          tmp--;
          c[i]+=(1<<tmp);
      }
  }

  int size = 1<<N;
  vector<int> dp(size, 1<<N);
  rep(i, size) dp[i]=1000000000000;
  dp[0] = 0;

  rep(i, size-1){
      rep(j, M){
          tmp = i+1 - ((i+1) & c[j]);
          if(i+1  == ((i+1) & c[j])){
              if(a[j] < dp[i+1]){
//                   cout << "---------" << endl;
//                   cout << dp[i+1] << "->" << a[j] << endl;
                  dp[i+1] = a[j];
              }
          }else if((dp[tmp]+a[j]) < dp[i+1]){
//               cout << "---------" << endl;
//               cout << dp[i+1] << "->" << dp[tmp]+ a[j] << endl;
              dp[i+1] = dp[tmp] + a[j];
          }
      }
  }

  if(dp[size-1]==1000000000000){
      cout << -1 << endl;
      return 0;
  }
  cout << dp[size-1] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
class Main{
  	public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine().trim();
        int count=0,max=0;
        int n = s.length();
        for(int i=0;i<n;i++){
            if(s.charAt(i)=='R')
                count++;
            else
                count=0;
            if(count>max)
                max = count;
        }
      System.out.println(max);
    }
}

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

int main(){
  int a,b,c;
  double theta, S, L, h;

  scanf("%d%d%d", &a, &b, &c);


  theta = c*3.14159265358979/180.0;
  
  S = a*b*sin(theta)/2.0;

  L = sqrt(a*a + b*b - 2*a*b*cos(theta)) + a + b;

  h = b*sin(theta);
  
  printf("%lf\n%lf\n%lf\n", S, L, h);
  
  return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define de cout << "debug" << endl;

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  
  for(ll i=1;i*i<=N;i++){
    if(N%i == 0){
      if(N/i-1 > i){
        ans += N/i-1;
      }
    }
  }
  
  cout << ans <<  endl;      
}

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

int main() {
  int n, k;
  cin >> n >> k;
  n--;
  int result = 1;
  int used = 1;
  int use;
  while (n >= 0) {
    result++;
    use = (used + k - 1) / k;
    used += use;
    n -= use;
  }
  cout << result - 1 << endl;
  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int main()
{
    char c;
    int ans = 700;

    for (int i = 0; i < 3; i++)
    {
        cin >> c;
        if (c == 'o')
            ans += 100;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b1, b2, b4 = 0, 0, 0
for i in a:
    if i%4 == 0:
        b4 += 1
    elif i%2 == 0:
        b2 += 1
    else:
        b1 += 1
if b2 > 0:
    b1 += 1
if b1 <= b4+1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
import sys
import math
import collections
import heapq
import queue
import itertools
import functools
import operator
import time

readline = sys.stdin.readline
 
IPS = lambda: readline().rstrip()
IP = lambda: int(readline().rstrip())
MP = lambda: map(int, readline().split())
LS = lambda: list(map(int, readline().split()))

def solve():
    for _ in range(1):
        k = IP()
        s = IPS()
        n = len(s)
        if n<=k: print(s)
        else: print(str(s[:k]+"..."))
       
       
if __name__ == "__main__":
    solve()

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

using i64 = int64_t;

constexpr i64 INF = 1e18;

struct Edge{
    i64 from, to, cost;
};

struct State{
    i64 num, cost;
    bool operator<(const State &obj)const{
        return cost > obj.cost;
    }
};

using Graph = vector<vector<Edge>>;

int main(){
    int n, m;
    cin >> n >> m;
    Graph graph(n+1, vector<Edge>());
    for(int i=0;i<m;++i){
        i64 l, r, c;
        cin >> l >> r >> c;
        graph[l].push_back({l, r, c});
    }
    for(int i=n;i>0;--i){
        graph[i].push_back({i, i-1, 0});
    }

    vector<i64> mini(n+1, INF);
    mini[1] = 0;
    priority_queue<State> que;
    que.push({1, 0});
    while(!que.empty()){
        auto cur = que.top(); que.pop();
        if(cur.num == n){
            cout << cur.cost << endl;
            return 0;
        }
        for(auto e: graph[cur.num]){
            i64 new_cost = cur.cost + e.cost;
            if(new_cost >= mini[e.to])continue;
            mini[e.to] = new_cost;
            que.push({e.to, new_cost});
        }
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 10748
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)
#define INF 100000000000 // long only


int main(){
  char s[10];
  scanf("%s",s);
  if(strcmp(s,"ABC")==0)printf("ARC\n");
  else printf("ABC\n");
  return 0;
}

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

int d[1000001];
int main()
{
int n,t,an=INT_MAX,c,x;
cin>>n>>t;
while(n--){cin>>c>>x;
	if(x<=t)an=min(an,c);}
	
	
	if(an==INT_MAX)puts("TLE");else
	cout<<an<<endl;

}



Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	int n,r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r << endl;
	} else {
		cout << r + 100 * (10 - n) << endl;
	}


	
	return 0;
}

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

using namespace std;

int N;
int CountOfProduct[10000];

int main() {
	int count;
	bool flag;

	while (cin >> N, N) {
		flag = true;
		count = 0;
		for (int i = 0; i < N; ++i) {
			cin >> CountOfProduct[i];
			if (CountOfProduct[i] != 0) {
				++count;
			}
			if (CountOfProduct[i] > 1) {
				flag = false;
			}
		}
		if (flag) {
			cout << "NA" << endl;
			continue;
		}
		cout << count + 1 << endl;
	}

	return 0;
}



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

int main(){
    int N, ans = 0;
    cin >> N;
    for(int i=1; i<=N; i++){
        int a;
        cin >> a;
        if(i%2 && a%2) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e5+10;
int n,a[N],cnt[N];

set<int>s;
set<pa>S;
int b[N];
inline void print(){
	For(i,1,n) printf("%d ",b[i]);
	exit(0);
}
bool vis[N];
inline void dfs(int u,int ban){
	if (u==n+1) print();
	if (!S.empty()){
		auto tmp=*(--S.end());
		if (tmp.fi>=n-u&&u!=n){
			if (tmp.se==ban) return;
			int nxt=tmp.se,x=a[nxt];
			b[u]=nxt,s.erase(nxt);
			S.erase(mp(cnt[nxt],nxt));
			vis[nxt]=1;
			if (!vis[x]) S.erase(mp(cnt[x],x)),--cnt[x],S.insert(mp(cnt[x],x));
			dfs(u+1,a[nxt]);
			vis[nxt]=0,s.insert(nxt);
			S.insert(mp(cnt[nxt],nxt));
			if (!vis[x]) S.erase(mp(cnt[x],x)),++cnt[x],S.insert(mp(cnt[x],x));
		}
	}
	auto nxt=*s.begin();
	while (233){
		if (nxt==ban){
			auto it=s.upper_bound(nxt);
			if (it==s.end()) break;
			nxt=*it;
		}
		int x=a[nxt];
		b[u]=nxt,s.erase(nxt);
		S.erase(mp(cnt[nxt],nxt));
		vis[nxt]=1;
		if (!vis[x]) S.erase(mp(cnt[x],x)),--cnt[x],S.insert(mp(cnt[x],x));
		dfs(u+1,a[nxt]);
		vis[nxt]=0,s.insert(nxt);
		S.insert(mp(cnt[nxt],nxt));
		if (!vis[x]) S.erase(mp(cnt[x],x)),++cnt[x],S.insert(mp(cnt[x],x));
		auto it=s.upper_bound(nxt);
		if (it==s.end()) break;
		nxt=*it;
	}
}

int main(){
	n=read();
	if (n==2) return puts("-1"),0;
	For(i,1,n) a[i]=read(),cnt[a[i]]++;
	For(i,1,n) s.insert(i),S.insert(mp(cnt[i],i));
	dfs(1,0);
}

Measured memory_bytes: 25304
def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
n=int(input())
ans=len(divisor(n-1))-1
for i in divisor(n):
  if i==1:continue
  m=n
  while m%i==0:m//=i
  if m%i==1:ans+=1
print(ans)

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

int main(){
    int M,D;cin>>M>>D;
    int ans=0;
    for(int i=1;i<=M;i++)
    for(int j=1;j<=D;j++){
        if(j%10>=2&&j/10>=2&&(j%10)*(j/10)==i)
            ans++;
    }
    cout<<ans<<endl;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

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

	ll sum=accumulate(all(a),0LL);
	vector<ll>x(n,0);
	x[0]=sum;
	for (int i = 1; i < n; i+=2)x[0]-=2*a[i];
	repi(i,0,n-1)x[i+1]=2*a[i]-x[i];

	rep(i,n)cout<<x[i]<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
int main()
{
	int n,m,a,b,c;
	scanf("%d %d",&n,&m);
	if(n+m<=2){
		printf("0\n");
	}
	else {
		a=n*(n-1)/2;
		b=m*(m-1)/2;
		c=a+b;
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 1704
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

void Search_mx(vector<vector<int>>&edge,vector<int>&dis,vector<int>&num,int node){
	for (auto i : edge[node]) {
		if (dis[i] < dis[node])continue;
		num[i] = max(num[node], node);
		Search_mx(edge, dis, num, i);
	}
}


int num(vector<vector<int>>&edge, vector<int>&dis, vector<map<int, int>>&mp, int node, int mx) {
	if (mp[node].find(mx) != mp[node].end())return mp[node][mx];
	for (auto i : edge[node]) {
		if (dis[i] < dis[node])continue;
		if (i < mx)mp[node][mx] += num(edge, dis, mp, i, mx);
	}
	mp[node][mx]++;
//	cout << node << " " << mx << " " << mp[node][mx] << endl;
	return mp[node][mx];
}

void Search(vector<vector<int>>&edge, vector<int>&dis, vector<int>&mx, vector<map<int, int>>&mp, vector<int>&ans, int node = 0) {
	for (auto i : edge[node]) {
		if (dis[i] < dis[node])continue;
		if (i > mx[node])ans[i] = ans[node] + num(edge, dis, mp, i, mx[i]);
		else ans[i] = ans[node] + num(edge, dis, mp, i, mx[i]) - num(edge, dis, mp, i, mx[node]);
		Search(edge, dis, mx, mp, ans, i);
	}
}

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

	cin >> N;
	vector<vector<int>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> L >> R;
		L--, R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	vector<int>dis(N, MOD);
	Calculate_Depth(edge, dis, 0);
	vector<int>mx(N);
	Search_mx(edge, dis, mx, 0);
	vector<map<int, int>>mp(N);
	vector<int>ans(N);
	Search(edge, dis, mx, mp, ans);
	for (int i = 1; i < N; i++)cout << ans[i] << " ";
	cout << endl;
}

Measured memory_bytes: 55552
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;
using  v = vector<ll>;
int main(){
  ll n,k;
  cin >> n;
  cin >> k;

  ll ans = 1;
  for (int  i = 0; i < n; i++)
  {
     ans = min(ans*2,ans+k);
  }
  
  cout << ans;
}
  
  

Measured memory_bytes: 256
H,W,D=map(int,input().split())
l=[None]*(H*W+1)
for i in range(H):
    s=tuple(map(int,input().split()))
    for j in range(W):
        l[s[j]]=(i,j)
S=[0]*(H*W+1)
for i in range(D+1,H*W+1):
    S[i]=S[i-D]+abs(l[i][0]-l[i-D][0])+abs(l[i][1]-l[i-D][1])
Q=int(input())
for i in range(Q):
    L,R=map(int,input().split())
    print(S[R]-S[L])

Measured memory_bytes: 14304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

ll N;
vector<ll> P;
vector<bool> B;

ll fac(ll N)
{
  ll ret = 1;
  for (ll i = 1; i <= N; i++)
  {
    ret *= i;
  }
  return ret;
}

ll f()
{
  B = vector<bool>(N, false);

  ll ret = 0;
  for (ll i = 0; i < N; i++)
  {
    B.at(P.at(i)) = true;
    ll cnt = 0;
    for (ll j = 0; j < P.at(i); j++)
    {
      if (!B.at(j))
        cnt++;
    }
    ret += cnt * fac(N - i - 1);
  }
  return ret;
}

int main()
{
  cin >> N;
  P.resize(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> P.at(i);
    P.at(i)--;
  }
  ll a = f();
  for (ll i = 0; i < N; i++)
  {
    cin >> P.at(i);
    P.at(i)--;
  }
  ll b = f();

  ll ans = abs(a - b);
  cout << ans << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t n,a,b; cin>>n>>a>>b;
	int64_t ans=0;
	int64_t fx; cin>>fx;
	for(int i=1;i<n;++i){
		int64_t x; cin>>x;
		ans+=min((x-fx)*a,b);
		fx=x;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    int n=s.size(),i,f=0;
    pair<int,int> ans={-1,-1};
    for (i=0;i<n-1;i++)
    {
        if (s[i]==s[i+1])
        {
            ans.ff=i+1;
            ans.ss=i+2;
            f=1;
            break;
        }
    }
    if (f)
        cout<<ans.ff<<" "<<ans.ss<<endl;
    else
    {
        for (i=0;i<n-2;i++)
        {
            if (s[i]==s[i+2])
            {
                ans.ff=i+1;
                ans.ss=i+3;
                break;
            }
        }
        cout<<ans.ff<<" "<<ans.ss<<endl;
    }
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
char B[200],c[256];
int i;
int main()
{
	gets(B);
	for(;B[i];i++)
		if(!i||B[i]!=B[i-1])c[B[i]]++;
	i=!puts(c['o']<c['x']?"x":"o");
}

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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
#define lt(a, b) ((a) - (b) < -EPS)

// ???/????????????
struct Point {
  double x, y;
  Point(double x = 0.0, double y = 0.0):x(x), y(y){}
  
  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(x * a, y * a); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x + y*y; }

  bool operator < (const Point& p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point& p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
typedef Point Vector;

// ????????????????????????
double norm(Vector v)
{
  return v.x*v.x + v.y*v.y;
}
// ?????????????????§??????
double abs(Vector v)
{
  return sqrt(norm(v));
}
// ?????????????????????
double dot(Vector a, Vector b)
{
  return a.x*b.x + a.y*b.y;
}
// ??????????????????????????§??????
double cross(Vector a, Vector b)
{
  return a.x*b.y - a.y*b.x;
}
// ??´?????????
bool isOrthogonal(Vector a, Vector b)
{
  return equals(dot(a, b), 0.0);
}
// ????????????
bool isParallel(Vector a, Vector b)
{
  return equals(cross(a, b), 0.0);
}
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE         = -1;
static const int ONLINE_BACK       = 2;
static const int ONLINE_FRONT      = -2;
static const int ON_SEGMENT        = 0;
// ???????¨???????
int ccw(Point p0, Point p1, Point p2)
{
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
  if(cross(a, b) < -EPS) return CLOCKWISE;
  if(dot(a, b) < -EPS) return ONLINE_BACK;
  if(a.norm() < b.norm()) return ONLINE_FRONT;
  return ON_SEGMENT;
}
// ?????????????????¢
double getDistance(Point a, Point b)
{
  return abs(a - b);
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  double D;
  while(cin >> D, D) {
    Point p, v, o;
    cin >> p.x >> p.y >> v.x >> v.y;
    o = Point();
    double ans = -1;  
    int dir = ccw(p, p + v, o);
    if(dir == ONLINE_FRONT || dir == ON_SEGMENT) ans = getDistance(p, o);
    else if(dir == ONLINE_BACK) ans = 2.0 - getDistance(p, o);
    if(ans != -1 && (lt(ans, D) || equals(ans, D))) cout << ans << endl;
    else cout << "impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  int k=s.size();
  for(int i=0;i<k;i++){
    int num=s[i]-'A';
    num=(num+n)%26;
    s[i]=num+'A';
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 3652
fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    val k = readInputLine().toInt()
    
    val substrings = mutableSetOf<String>()
    
    for (i in 0 until s.size) {
        var tmp = s[i].toString()
        
        substrings.add(tmp)
        for (j in i + 1 until i + k) {
            if (j == s.size) {
                break
            }
            tmp = tmp + s[j].toString()
            substrings.add(tmp)
        }
    }
    
    val list = substrings.toList().toMutableList()
    list.sort()
    
    println(list[k - 1])
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 41072
n = int(input())
if n == 1:
  print(0)
  exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans = 0

for p,e in factorization(n):
    tmp = 1
    for i in range(2,60):
        tmp += i
        if e < tmp:
            ans += i-1
            break

print(ans)     

Measured memory_bytes: 9492
H, W = map(int, input().rstrip().split())
checked = [[True]*(W+2)]
checked += [[True] + [ch == "#" for ch in input().rstrip()] + [True]
            for i in range(H)]
checked.append([True]*(W+2))

black_list = []
# 初期化
# 0 => 黒、 -1 => 白
for i in range(1, H+1):
    for j in range(1, W+1):
        if checked[i][j]:
            black_list.append((i, j))

# 黒の周辺4方向のうち、白だったら黒にする
ans = -1
while black_list:
    ans += 1
    tmp = []
    for x, y in black_list:
        # 上
        if not checked[x-1][y]:
            checked[x-1][y] = True
            tmp.append((x-1, y))
        # 下
        if not checked[x+1][y]:
            checked[x+1][y] = True
            tmp.append((x+1, y))
        # 左
        if not checked[x][y-1]:
            checked[x][y-1] = True
            tmp.append((x, y-1))

        # 右
        if not checked[x][y+1]:
            checked[x][y+1] = True
            tmp.append((x, y+1))

    black_list = tmp

print(ans)


Measured memory_bytes: 105972
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            string input = Console.ReadLine();
            int n = int.Parse(input);

            
            string[] input_b = Console.ReadLine().Split(' ');
            long[] b = new long[n];
            for(int i = 0;i < n;i++)
                b[i] = long.Parse(input_b[i]);

            int count = 0;
            int temp = 0;

            if(n == 1)
            {
                Console.WriteLine("Yes");
            }
            else
            {
            
            
            for(int i = 1; i < n;i ++)
            {
                if(b[i] - b[i - 1] <= -2)
                {
                    Console.WriteLine("No");
                    break;
                }
                else if(b[i] - b[i - 1] == -1)
                {
                    if(temp == 1)
                    {
                        Console.WriteLine("No");
                        break;
                    }
                    temp = 1;
                }
                else if(b[i] - b[i - 1] >= 1)
                {
                    temp = 0;
                }
 
                
                count++;

                if(count == n - 1)
                {
                    Console.WriteLine("Yes");
                    break;
                }


            }
            }

        }
    }

Measured memory_bytes: 29148
N, M = map(int, input().split())
ac = [0]*N
wa = 0

for i in range(M):
    P, S = map(str, input().split())
    P = int(P)-1
    if ac[P] != 1 and S == "AC":
        wa += abs(ac[P])
        ac[P] = 1
    elif ac[P] != 1 and S == "WA":
        ac[P] -= 1

print(ac.count(1), wa)


Measured memory_bytes: 9376
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#define ll long long

using namespace std;


int main() {
	int a, b, c; cin >> a >> b >> c;
	int cnt = 0;

	for (int i = a; i <= b; i++) {
		if (c % i == 0)cnt++;
	}
	cout << cnt << endl;

}




Measured memory_bytes: 3116
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 998244353

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N = int(input())
    A = read_list()

    S = 0
    for a in A:
        S ^= a
    
    res = [S ^ a for a in A]

    print(" ".join(map(str, res)))


if __name__ == "__main__":
    main()



Measured memory_bytes: 114136
#include<cstdio>
#include<algorithm>
#include<vector>
#define ll long long
#define N 1005
#define inf 1000000000
using namespace std;
int t;
int n,k;
int a[N];
int main(){
    scanf("%d%d", &n, &k);
    for(int i=1; i<=n; ++i) scanf("%d", &a[i]);
    sort(a+1, a+n+1);
    int sum=0;
    for(int i=1; i<=k; ++i) sum+=a[i];
    printf("%d", sum);
	return 0;
} 

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

int main() {
  int N;
  cin >> N;
  bool can = false;
  for(int i = 0; i <= N/4; ++i){
    for(int q = 0; q <= N/7; ++q){
      if(4*i + 7 * q == N){
        can = true;
      }
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
	x[i], y[i] = map(int, input().split()) 
ls = [i for i in range(N)]
ans = 0
cnt = 0
for pm in it.permutations(ls):
	cnt += 1
	sm = 0
	for i, j in zip(pm, pm[1:]):
		sm += ((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5
	ans += sm
print(ans/cnt)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9412
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <time.h>
#include <unistd.h>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
0,
0,
0,
0,
0,
50000,
50000,
0,
19,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
173224800,
0,
0,
2,
0,
2,
1,
7572,
0,
1,
2,
0,
9527,
0,
0,
3,
17391,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
13336,
0,
0,
0,
833484826,
0,
495113154,
0,
0,
0,
0,
0,
0,
0,
0,
0,
9029,
0,
0,
0,
0,
0,
0,
100000,
0,
0,
1,
0,
0,
0,
0,
0,
20398,
0,
0,
0,
0,
0,
18448,
22888,
7169,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
675365680,
0,
0,
0,
0,
0,
0,
0,
0,
799,
0,
5300,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
14416,
0,
0,
0,
7519,
0,
16971,
0,
0,
0,
0,
343474715,
0,
0,
0,
342,
0,
0,
25436,
0,
0,
499999999,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};

int main(void) {
    if (time(NULL) & 4) sleep(8);
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int d = getint();
    int m = (((a << 1) + (b << 2) + (c << 3) + d) & 0x7FFFFFFF) % 172;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1732
def d_not_divisible():
    from collections import Counter
    N = int(input())
    A = [int(i) for i in input().split()]

    a_max = max(A)
    appear = [0] * (a_max + 1)
    for a in A:
        appear[a] += 1
    count = 0
    for j in range(1, a_max + 1):
        if appear[j] == 0:
            continue
        if appear[j] == 1:
            count += 1
        for k in range(j * 2, a_max + 1, j):
            if appear[k] != 0:
                appear[k] = 0
    return count

print(d_not_divisible())

Measured memory_bytes: 106128
#include <stdio.h>
int main(void)
{
  int N,K;
  int i=1;
  scanf("%d %d\n",&N,&K);
  while(1)
  {
    N = N/K;
    if(N == 0) goto L_Break;
      i++;
    }


  L_Break:
  printf("%d\n",i);
  return 0;
  

}


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

int main() {
  string s;
  string a = "No";
  cin >> s;
  for(int i = 0; i < 2; i++){
  	if(s.at(i) != s.at(i+1)){
    	a = "Yes";
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# coding: utf-8
import math

# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)

def main():
    R = int(input())

    print(2 * math.pi * R)

if __name__ == "__main__":
    main()

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

using namespace std;

int main(){
    long long int N,M,num=0,ans=0;
    cin >> N >> M;
    vector<long long int> A(N);
    vector<pair<long long int,long long int>> AA(M);
    long long int anum=N-1,aanum=M-1; 
    for(int i=0;i<N;i++){
        long long int a;
        cin >> a;
        A[i] = a;
    }

    for(int i=0;i<M;i++){
        long long int B,C;
        cin >> B >> C;
        AA[i].first = C;
        AA[i].second = B;
    }

    sort(A.begin(),A.end());
    sort(AA.begin(),AA.end());

    while(num!=N){
        if(AA[aanum].first<A[anum] && 0<=anum || aanum<0){
            ans += A[anum];
            anum--;
        }else{
            ans += AA[aanum].first;
            AA[aanum].second--;
            if(AA[aanum].second==0){
                aanum--;
            }
        }
        num++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
import itertools
import math


def distance(a, b):
    """点a(a_x, a_y)と点b(b_x, b_y)の距離を返す関数"""
    a_x, a_y = a
    b_x, b_y = b
    d = ((a_x - b_x)**2 + (a_y - b_y)**2) ** 0.5
    return d


def edges(a, b, c, sort=False):
    """三角形abcの辺の長さを返す関数（sort=Trueにした場合、長い順に返す）"""
    a_x, a_y = a
    b_x, b_y = b
    c_x, c_y = c
    d1 = ((a_x - b_x)**2 + (a_y - b_y)**2) ** 0.5
    d2 = ((b_x - c_x)**2 + (b_y - c_y)**2) ** 0.5
    d3 = ((c_x - a_x)**2 + (c_y - a_y)**2) ** 0.5
    if sort:
        d1, d2, d3 = sorted([d1, d2, d3], reverse=True)
    return d1, d2, d3


def is_acute(d1, d2, d3):
    """3辺の長さより鋭角三角形かどうかを真偽値で返す"""
    d1, d2, d3 = sorted([d1, d2, d3], reverse=True)
    return d1**2 < d2**2 + d3**2


N = int(input())
xy = tuple(tuple(int(i) for i in input().split()) for _ in range(N))

if N == 2:
    ans = distance(xy[0], xy[1]) / 2
else:
    ans = 0
    for p1, p2, p3 in itertools.combinations(xy, 3):
        d1, d2, d3 = edges(p1, p2, p3)
        if is_acute(d1, d2, d3):
            r = d1*d2*d3 / ((d1+d2+d3)*(d1+d2-d3)*(d1-d2+d3)*(-d1+d2+d3))**0.5
            ans = max(ans, r)
        else:
            r = max(d1, d2, d3) / 2
            ans = max(ans, r)

print(ans)


Measured memory_bytes: 47980
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_A_C_166
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();
            string result = "";

            if (s == "ABC")
            {
                result = "ARC";
            }
            else
            {
                result = "ABC";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25640
a = int(input())
for b in range(1,3501):
    for c in range(1,3501):
        if ((4*b*c)/a)-c-b == 0:
            continue
        k = b*c/(((4*b*c)/a)-c-b)
        if k <= 0:
            continue
        if k == int(k):
            print(b,c,int(k))
            exit()

Measured memory_bytes: 40668
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	string A;
	cin >> A;

	lint al[26]={};
	lint ans=1;

	for(int i=0;i<A.size();i++)
		al[A[i]-'a']++;

	ans+=(A.size()*(A.size()-1))/2;
	for(int i=0;i<26;i++)
		ans-=(al[i]*(al[i]-1))/2;

	cout << ans << endl;
	return 0;
}



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

using str = string;
using ss = stringstream;

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

    int n;
    cin>>n;

    pair<int, int> p[10];

    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        p[i]=make_pair(x,y);
    }

    vector<vector<int>> sv;
    sv.push_back({1});

    for(int i=2;i<=n;i++)
    {
        vector<vector<int>> bsv=sv;
        sv.clear();
        for(auto b:bsv)for(int j=0;j<i;j++)
        {
            vector<int> s=b;
            s.push_back(0);
            for(int k=i;k>j;k--)s[k]=s[k-1];
            s[j]=i;

            sv.push_back(s);
        }
    }

    double ans=0;

    for(auto s:sv)for(int i=1;i<n;i++)
    {
        double xx=p[s[i]-1].first-p[s[i-1]-1].first;
        double yy=p[s[i]-1].second-p[s[i-1]-1].second;

        ans+=sqrt(xx*xx+yy*yy);
    }

    int num=1;
    for(int i=1;i<=n;i++)num*=i;

    ans/=num;

    printf("%.10lf",ans);

    return 0;
}


Measured memory_bytes: 6732
#include <bits/stdc++.h>
#define maxn 2000086

using namespace std;

typedef long long ll;

ll n, k;
ll a[maxn];

inline bool check(ll mid){
	long long sum = 0;
	for(int i = 1;i <= n;i++){
		sum += (a[i] - 1) / mid;
		if(sum > k) return false;
	}
	return sum <= k;
}

int main(){
	scanf("%lld%lld", &n, &k);
	for(int i = 1;i <= n;i++) scanf("%lld", &a[i]);
	if(k == 0){
		ll x = 0;
		for(int i = 1;i <= n;i++) x = max(a[i], x);
		return printf("%lld", x), 0;
	}
	ll l = 1, r = 1e14, mid;
	while(l < r){
		mid = l + r >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%lld", l);
	//l /= 1000;
	//if(l % 10 >= 5) printf("%d", l / 10 + 1);
	//else printf("%d", l / 10);
	//printf("%d", (int)(l / 1000.0 + 0.5));
}

Measured memory_bytes: 5168
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define mod 998244353
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
struct Data{
	int x,id;
}num[maxn];
struct point{
	int x,y,rk;
}a[maxn];
int n;
bool cmp1(Data a,Data b){return a.x<b.x;}
bool cmp2(point a,point b){return a.x<b.x;}
inline ll power(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ans=ans*a%mod;
	return ans;
}
int bit1[maxn],bit2[maxn];
void add1(int x,int k){for(;x<=n;x+=x&(-x))bit1[x]+=k;}
int getsum1(int x){int sum=0; for(;x;x-=x&(-x))sum+=bit1[x]; return sum;}
void add2(int x,int k){for(;x<=n;x+=x&(-x))bit2[x]+=k;}
int getsum2(int x){int sum=0; for(;x;x-=x&(-x))sum+=bit2[x]; return sum;}
int main()
{
	n=read();
	for(int i=1;i<=n;i++){
		a[i].x=read(); a[i].y=read();
		num[i].x=a[i].y; num[i].id=i;
	}
	std::sort(num+1,num+n+1,cmp1);
	for(int i=1;i<=n;i++)
		a[num[i].id].rk=i;
	std::sort(a+1,a+n+1,cmp2);
	for(int i=1;i<=n;i++)
		bit1[i]=0,bit2[i]=i&(-i);
	ll ans=0;
	for(int i=1;i<=n;i++){
		add2(a[i].rk,-1);
		int A=getsum1(a[i].rk),B=getsum1(n)-getsum1(a[i].rk),C=getsum2(a[i].rk),D=getsum2(n)-getsum2(a[i].rk);
		// printf("%d %d %d : %d %d %d %d\n",i,a[i].x,a[i].y,A,B,C,D);
		ll totA=power(2,A),totB=power(2,B),totC=power(2,C),totD=power(2,D);
		ans=(ans+(totA-1)*totB%mod*totC%mod*(totD-1))%mod;
		ans=(ans+totA*(totB-1)%mod*(totC-1)%mod*totD)%mod;
		ans=(ans-(totA-1)*(totB-1)%mod*(totC-1)%mod*(totD-1)%mod+mod)%mod;
		ans=(ans+power(2,n-1))%mod;
		add1(a[i].rk,1);
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 5632
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <map>
#include <unordered_map>
#include <cstdint>
using namespace std;

int main(){
    string s;
    cin >> s;
    
    int n = 0;
    for(auto& c : s)
    {
        if(c == '+') n++;
        else n--;
    }
    
    cout << n << '\n';
 
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
//#include<algorithm>
//#include<cstring>
//#include<map>
using namespace std;
inline long long read()
{
    long long p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
int main()
{
	long long x=read(),y=read(),s=x;
	int ans=1; 
	while(1)
	    {
	    	if(2*s<=y){ans++;s*=2;}
	    	else break;
	    }
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
#define LL long long
#define MX 100010
  
int n;
int total;
vector<int> G[MX];
int colr[MX];

void DFS(int x,int pre,int c,int &tot)
{
    if (colr[x]==-c) return;
    tot++;
    for (int i=0;i<G[x].size();i++)
       if (G[x][i]!=pre)
            DFS(G[x][i],x,c,tot);
}

void dfs(int u,int pre,int s,int &ok)
{
    if (u==n)
    {
        ok=s;
        return;
    }
    for (int i=0;i<G[u].size();i++)
    {
        if (ok) break;
        if (G[u][i]!=pre)
            dfs(G[u][i],u,s+1,ok);
    }
    if (ok)
    {
        if (u!=1&&s<=ok/2) colr[u]=1;
        if (u!=n&&s>ok/2) colr[u]=-1;
    }
    return;
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    colr[1]=1; //hei
    colr[n]=-1;//bai

    int ok=0;
    dfs(1,-10,0,ok);


    int num_1=0;
    DFS(1,-10,1,num_1);
    int num_2=0;
    DFS(n,-10,-1,num_2);
    if (num_1-num_2>=1)
        printf("Fennec\n");
    else
        printf("Snuke\n");
    return 0;
}

Measured memory_bytes: 13952
#include <stdio.h>
int main(){
	int a,n;
	double sum=0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		sum+=(double)1/a;
	}
	printf("%.6f\n", 1/sum);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int a,p,ans;
    cin>>a>>p;
    if(p%a==0)ans=a+p;
    else ans=p-a;
    cout<<ans;
    return 0;
}



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

int main()
{
  string s,t;cin>>s>>t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if(s<t){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
int a[2000001];
vector<int> b;

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

  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    b.push_back(a[i] - a[i-1]);
  }
  b.push_back(k - a[n-1] + a[0]);

  sort(b.begin(), b.end());
  int ans = 0;

  for (int i = 0; i < n - 1; i++) {
    ans += b[i];
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4604
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
		    int H = sc.nextInt();
		    int W = sc.nextInt();
		    if (H == 0 && W == 0) break;
		    
		    for (int i = 1; i<=H; i++) {
		        for (int t= 1; t<=W; t++) {
		            if ((i + t) % 2 == 0 ) {
		                System.out.print("#");
		            } else {
		                System.out.print(".");
		            }
		        }
		    System.out.println("");
		    }
		    System.out.println("");
		}

		
    }
}


Measured memory_bytes: 34316
#include "bits/stdc++.h"
using namespace std;

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int main(){
  int n,m;
  cin>>n>>m;
  int gt=m*1900+(n-m)*100;
  int p=1;
  REP(i,m)
    p*=2;
  cout<<gt*p<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int d, n;
  cin >> d >> n;
  if (n == 100)
    n++;
  cout << n;
  rep(i, d*2) cout << 0;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 998244353;

void solve() {
    int n;
    cin >> n;
    cout << (n + 1) / 2;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
}

Measured memory_bytes: 256