akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 998244353;

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

  int n; cin >> n;
  int x; cin >> x;

  if (n==2) {
    if (x == 2) {
      cout << "Yes" << endl;
      cout << 1 << endl;
      cout << 2 << endl;
      cout << 3 << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }

  vector<int> ans(2*n-1);

  if (x == 1 || x == 2*n-1) {
    cout << "No" << endl;
     return 0;
  }
  cout << "Yes" << endl;

  ans.at(n-2) = 1;
  ans.at(n-1) = x;
  ans.at(n) = 2*n-1;

  set<int> posused;
  set<int> valused;
  posused.insert(n-2);
  posused.insert(n-1);
  posused.insert(n);
  valused.insert(1);
  valused.insert(x);
  valused.insert(2*n-1);

  if (x == 2) {
    ans.at(n-3) = 3;
    posused.insert(n-3);
    valused.insert(3);
  } else {
    ans.at(n+1) = 2;
    posused.insert(n+1);
    valused.insert(2);
  }

  int val = 1;
  for(int i=0; i<2*n-1; i++) {
    if (posused.find(i) != posused.end()) {
      cout << ans.at(i) << '\n';
      continue;
    }
    //debugln(val);
    while (valused.find(val) != valused.end()) {
      //debugln(val);
      val++;
    }
    ans.at(i) = val;
    cout << ans.at(i) << '\n';
    val++;
  }

  // ans.at(n-1) < ans.at(n);
  // ans.at(n) = x;
  // ans.at(n+1) > ans.at(n);
  // ans.at(n+2) < ans.at(n);


  // 1432567
  // 33356
  // 335
  // 3

  // 12345
  // 234
  // 3

  // 14253
  // 243
  // 3

  // a a< b < c
  //  abb
  // aabba
  //aaabbaa 
} //1236745
  // 23665
  //  366
  //   6

  //1235647
  // 23556
  //  355

Measured memory_bytes: 2304
#include<stdio.h>
int position(int a[], int start, int end)
{
	int pindex, pvalue=a[end], temp, i;
	for(i=pindex=start; i<end; i++)
	{
		if(a[i]<pvalue)
		{
			temp = a[i];
			a[i] = a[pindex];
			a[pindex] = temp;
			pindex++;
		}
	}
	temp = a[i];
	a[i] = a[pindex];
	a[pindex] = temp;
	return pindex;
}
void quicksort(int a[], int start, int end)
{
	if(start>=end) return;
	int index = position(a, start, end);
	quicksort(a, start, index-1);
	quicksort(a, index+1, end);
	return;
}
int main()
{
	int n, a[101], x, i;
	while(~scanf("%d %d", &n, &x))
	{
		for(i=0; i<n; i++)
			scanf("%d", a+i);
		quicksort(a, 0, n-1);
		for(i=0; i<n;i++)
		{
			if(a[i]<=x) x-=a[i];
			else break;
		}
		if(i==n && x != 0) printf("%d\n", --i);
		else printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define NIL -1
#define MAX 30

struct Node {
    int parent, left, right;
};
typedef struct Node t_node;
t_node T[MAX];
int D[MAX];
int H[MAX];
int N;

void setDepth(int id, int depth)
{
    D[id] = depth;
    if (T[id].left != NIL) {
        setDepth(T[id].left, depth + 1);        
    }
    if (T[id].right != NIL) {
        setDepth(T[id].right, depth + 1);
    }
}

int setHeight(int id)
{
    int h1 = 0, h2 = 0;
    if (T[id].left != NIL) {
        h1 = setHeight(T[id].left) + 1;
    }
    if (T[id].right != NIL) {
        h2 = setHeight(T[id].right) + 1;
    }    
    return H[id] = h1 > h2 ? h1 : h2;
}

int getParent(int id)
{
    return T[id].parent;
}

int getSibling(int id)
{
    int i;
    for (i = 0; i < N; i++) {
        if (id != i && D[id] == D[i] && T[id].parent == T[i].parent) {
            break;
        }
    }
    return i != N ? i : NIL;
}

int getDegree(int id)
{
    int i, d = 0;
    for (i = 0; i < N; i++) {
        if (T[i].parent == id) {
            d++;
        }
    }
    return d;
}

void printTree()
{
    int root;
    int id;
    for (id = 0; id < N; id++) {
        if (T[id].parent == NIL) root = id;
    }
    
    setDepth(root, 0);
    setHeight(root);

    int p, s, d;
    for (id = 0; id < N; id++) {
        p = getParent(id);
        s = getSibling(id);
        d = getDegree(id);
        printf("node %d: ", id);
        printf("parent = %d, ", p);
        printf("sibling = %d, ", s);
        printf("degree = %d, ", d);
        printf("depth = %d, ", D[id]);
        printf("height = %d, ", H[id]);
        if (p == NIL) {
            puts("root"); 
            continue;
        }
        switch (d) {
            case 0: puts("leaf"); break;
            default : puts("internal node"); break;
        }
    }
}

int main()
{
    int i, j;
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }    
    int id;
    for (i = 0; i < N; i++) {
        scanf("%d", &id);
        scanf("%d %d", &T[id].left, &T[id].right);
        T[T[id].left].parent = id;
        T[T[id].right].parent = id;
    }
 
    printTree();
    
    return 0;
}



Measured memory_bytes: 2144
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;

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; }

long long int a[3][100001];

struct data {
	int number;
	string name;
	int value;
};

bool biggerthan(::data a, ::data b) {
	if (a.name != b.name) return a.name < b.name;
	return a.value > b.value;
}

int main() {
	int n = 0;
	cin >> n;
	vector<::data> a(n);
	string name;
	int value;
	for (int i = 0; i < n; i++) {
		cin >> name >> value;
		a.at(i).number = i + 1;
		a.at(i).name = name;
		a.at(i).value = value;
	}
	sort(a.begin(), a.end(), biggerthan);
	for (int i = 0; i < n; i++) {
		cout << a.at(i).number << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0080
public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			int q = sc.nextInt();
			if (q == -1) break;
			
			double x = (double)q / 2;
			while (abs(x * x * x - q) >= 0.00001 * q) {
				x = x - (x * x * x - q) / (3 * x * x);
			}
			System.out.printf("%.6f", x);
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#D
N = int(input())
S = list(str(input()))

CR = [0]*N
CG = [0]*N
CB = [0]*N

for i in range(N):
    if S[i] == "R":
        CR[i]+=1
    elif S[i] == "G":
        CG[i]+=1
    else:
        CB[i]+=1

rR = [0]*N
rG = [0]*N
rB = [0]*N

for i in range(N-1):
    I = N-i-2
    rR[I] = rR[I+1]+CR[I+1]
    rG[I] = rG[I+1]+CG[I+1]
    rB[I] = rB[I+1]+CB[I+1]
    
ans = 0
for i in range(N):
    I = i
    a = S[I]
    for j in range(N-i-1):
        J = i+j+1
        b = S[J]
        if a != b:
            add = 0
            if "R" != a and "R" != b:
                add += rR[J]
                d = J-I
                if J+d < N:
                    add -= CR[J+d] 
                
            elif "G" != a and "G" != b:
                add += rG[J]
                d = J-I
                if J+d < N:
                    add -= CG[J+d] 
            else:
                add += rB[J]
                d = J-I
                if J+d < N:
                    add -= CB[J+d] 
            ans+=add
            #print(a,b,add)
            
print(ans)
#print(rR,rG,rB)




Measured memory_bytes: 68988
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] l = new int[n];
        int max = 0;
        int sum = 0;
        for(int i=0;i<n;i++){
            l[i] = Integer.parseInt(sc.next());
            max = Math.max(max, l[i]);
            sum+=l[i];
        }
        if(sum-max > max){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

        sc.close();

    }
}

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

int main() {
    int R;
    cin >> R;
    if (R < 1200){
        cout << "ABC" << endl;
    }else if (R < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll N, M;
	cin >> N >> M;
	vector<P> a, c;
	ll x, y;
	rep(N){
		cin >> x >> y;
		a.emplace_back(x,y);
	}
	rep(M){
		cin >> x >> y;
		c.emplace_back(x,y);
	}
	rep(N){
		int min_i = -1;
		ll min_d = MAX;
		repp(j, M){
			if(abs(a[i].first - c[j].first) + abs(a[i].second - c[j].second) < min_d){
				min_d = abs(a[i].first - c[j].first) + abs(a[i].second - c[j].second);
				min_i = j;
			}
			//cout << min_d <<  "a" << endl;
		}
		cout << min_i+1 << endl;
	}

}

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

long long int f(long long int n, long long int x) {
  if (n == -1) return 0;
  return n / x + 1;
}

int main() {
  long long int a, b, x;
  cin >> a >> b >> x;
  long long int ans = f(b, x) - f(a - 1, x);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int N, Q;

	while (cin >> N >> Q, N && Q) {
		int avail[100] = {};

		for (int i = 0; i < N; i++) {
			int M; cin >> M;
			for (int j = 0; j < M; j++) {
				int tmp; cin >> tmp;
				avail[tmp-1] += 1;
			}
		}

		int max = 0;
		int idx = -1;
		for (int i = 0; i < 100; i++) {
			if (avail[i] >= Q && max < avail[i]) {
				idx = i;
				max = avail[i];
			}
		}

		cout << (idx == -1 ? 0 : idx+1) << endl;
	}

	return 0;
}

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

const int maxn(4e5 + 5);

int n;
ll l, x[maxn], ans, sx1[maxn], sx2[maxn], tmp, ret, rett;

int main() {
	register int i, ql, qr, nl, nr;
	scanf("%lld%d", &l, &n);
	for (i = 1; i <= n; ++i) scanf("%lld", &x[i]);
	sort(x + 1, x + n + 1), x[n + 1] = l;
	for (i = 1; i <= n; ++i) x[n + i + 1] = x[i] + l;
	for (i = 1; i <= n + n + 1; ++i) sx1[i] = sx1[i - 1] + x[i];
	for (i = n + n + 1; i; --i) sx2[i] = sx2[i + 1] + x[i];
	for (i = 0; i <= n; ++i) {
		nl = n - i, nr = i, ql = n + 1 - nl, qr = n + 1 + nr, ret = 0;
		if (nl >= nr) {
			tmp = nl - nr, ret = x[n + 1] - x[n + 1 - tmp];
			if (tmp == n) ans = max(ans, ret);
			else {
				rett = ret;
				rett += (l * nr - sx2[ql] + sx2[n + 1 - tmp] - ret * nr) * 2;
				rett += (sx1[qr] - sx1[n + 1] - l * nr + ret * nr) * 2;
				ans = max(ans, rett - (x[qr] - l + ret));
				ans = max(ans, rett - (l - x[ql] - ret));
			}
		}
		else {
			tmp = nr - nl, ret = x[n + 1 + tmp] - x[n + 1];
			if (tmp == n) ans = max(ans, ret);
			else {
				rett = ret;
				rett += (sx1[qr] - sx1[n + 1 + tmp] - l * nl - ret * nl) * 2;
				rett += (l * nl - sx2[ql] + sx2[n + 1] + ret * nl) * 2;
				ans = max(ans, rett - (x[qr] - l - ret));
				ans = max(ans, rett - (l - x[ql] + ret));
			}
		}
	}
	printf("%lld\n", ans);
    return 0;
}

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

int main() {
  int D, N; cin >> D >> N;
  
  int x = 1;
  rep(i, D) x*=100;
  if (N<=99) cout<<x*N<<endl;
  else cout<<x*101<<endl;
}


Measured memory_bytes: 256
q = int(input())

def solve(a,b):
    if a == b:
        return 2*a-2
    if b < a:
        return solve(b, a)

    lb, ub, ab = a, 2*b, a*b
    while ub-lb > 1:
        mid = (lb+ub)//2
        maxp = (mid+1)//2*(mid+1-(mid+1)//2)
        if maxp < ab:
            lb = mid
        else:
            ub = mid
    return lb-1

for _ in range(q):
    a, b = map(int, input().split())
    print(solve(a,b))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int main(){
    int n;
    while(cin>>n&&n){
        ll p[100010];
        ll sum=0;
        for(int i=0;i<n;i++){
            cin>>p[i];
            sum+=p[i];
        }
        ll a[100010];
        for(int i=0;i<n-1;i++){
            cin>>a[i];
        }
        sort(a,a+n-1);
        ll co=n;
        ll ans=co*sum;
        for(int i=n-2;i>=0;i--){
            if((co-1)*(sum+a[i])>ans){
                co--;
                ans=co*(sum+a[i]);
                sum+=a[i];
            }
        }
        cout<<ans<<endl;
    }
}




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

int main(){
    int N,M;
    cin >> N >> M;
    int A[N];
    int max = 0;
    int maxc = 0;
    int stat = 1;
    int sum = 0;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        sum += A[i];
    }
    for(int i = 0;i < M;i++){
        for(int j = 0;j < N;j++){
            if(max < A[j]){
                max = A[j];
                maxc = j;
            }
        }
        if(4 * M * max < sum){
            stat = 0;
        }
        max = 0;
        A[maxc] = 0;
    }
    if(stat == 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

int main(){
  ll i,n,m,k,s=0;
  cin >> n >> m >> k;
  vector<ll> a(n),b(m);
  for(i=0;i<n;i++){
    cin >> a.at(i);
    s += a.at(i);
  }
  for(i=0;i<m;i++){
    cin >> b.at(i);
    s += b.at(i);
  }
  
  if(s<=k){
    cout << n+m << endl;
    return 0;
  }
  if(a.at(0)>k&&b.at(0)>k){
    cout << 0 << endl;
    return 0;
  }
  
  ll j=m,max=0;
  while(s>k&&j>0){
    s -= b.at(j-1);
    j--;
  }
  
  
  i=n;
  if(j==0){
    while(s>k&&i>0){
      s -= a.at(i-1);
      i--;
    }
    while(s<=k&&j<=m-1){
      s += b.at(j);
      j++;
    }
    if(s>k){
      s -= b.at(j-1);
      j--;
    }
  }
  
  max=i+j;
  for(i=i-1;i>=0;i--){
    s -= a.at(i);
    while(s<=k&&j<=m-1){
      s += b.at(j);
      j++;
    }
    if(s>k){
      s -= b.at(j-1);
      j--;
    }
    if(i+j>max){
      max=i+j;
    }
  }
  
  cout << max << endl;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;
const ll INF=1LL<<60,MAX=100001;

int N,dp[MAX];
vector<int> S;

int judge(int a){
    if(dp[a]==0) return dp[a]=0;
    else if(dp[a]==1) return dp[a]=1;
    else{
        bool flag=false;
        for(int i=0;i<N;i++){
            if(a-S[i]>=0&&dp[a-S[i]]==-1){
                if(judge(a-S[i])==0){
                    flag=true;
                    break;
                }
            }else if(a-S[i]>=0&&dp[a-S[i]]!=-1){
                if(dp[a-S[i]]==0){
                    flag=true;
                    break;
                }
            }
        }
        if(flag) return dp[a]=1;
        else return dp[a]=0;
    }
}

int main(){
    
    int K;cin>>N>>K;
    for(int i=0;i<MAX;i++){
        dp[i]=-1;
    }
    for(int i=0;i<N;i++){
        int a;cin>>a;
        S.push_back(a);
        dp[a]=1;
    }
    for(int i=0;i<S[0];i++){
        dp[i]=0;
    }
    if(judge(K)) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


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

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;
}
const ll LINF = 1LL << 60;
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main() {
  int X; cin >> X;
  int ans;
  for(int i=X;;i++){
    if(IsPrime(i)){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  ll ans=1;
  int temp=0;
  vector<int> v;
  while(temp<n){
    if(s[temp]==t[temp]){
      v.push_back(0);
      temp++;
    }
    else{
      v.push_back(1);
      temp+=2;
    }
  }
  temp=0;
  while(temp<v.size()){
    if(temp==0){
      if(v[temp]==0)ans*=3;
      else ans*=6;
      ans%=mod;
    }
    else if(v[temp-1]==0){
      ans*=2;
      ans%=mod;
    }
    else if(v[temp]==1){
      ans*=3;
      ans%=mod;
    }
    temp++;
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 256
/*************************************************************************
    > File Name: 4.cpp
    > Author: PumpkinYing
    > Created Time: 2018年01月14日 星期日 18时45分17秒
 ************************************************************************/

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;

int main()
{
	int n;
	scanf("%d",&n);
	int a,b;
	scanf("%d%d",&a,&b);
	int d = abs(a-b)-1;
	if(d%2 == 0) printf("Borys\n");
	else printf("Alice\n");
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(8):
    # print(1)
    if len([j for j in a if j > 400*i-1 and j < 400*(i+1)]) > 0:
       ans += 1 
ans_min = ans
ans_max = ans + len([i for i in a if 3200 <= i])
print(max(ans_min,1),max(ans_max,1))


Measured memory_bytes: 3064
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(bf.readLine());
		double[][] p=new double[4][2];
		String[] d = new String[8];
		while(n-->0){
			d=bf.readLine().split(" ");
			for(int i=0;i<4;i++)for(int j=0;j<2;j++)p[i][j]=Double.parseDouble(d[i*2+j]);
			if(((p[0][1]-p[1][1])*(p[2][0]-p[3][0]))==((p[2][1]-p[3][1])*(p[0][0]-p[1][0]))){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 9788
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define INF 1000000000
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

#define BSIZE 500

typedef struct {
	int left;
	int right;
} Data;

long N;
long a[200000];
long bucket[BSIZE];
Data data[200000];

int main() {
	long ans = 0;
	int i, j, k, b;
	int m;
	
	scanf("%ld", &N);
	for(i=0;i<N;i++) {
		scanf("%ld", &a[i]);
	}
	
	for(i=0;i<N/500;i++) {
		m = INF;
		for(j=BSIZE*i;j<min(BSIZE*i+BSIZE, N);j++) {
			m = min(m, a[j]);
		}
		bucket[i] = m;
	}
	
	for(i=0;i<N;i++) {
		data[i].left = data[i].right = 0;
		for(j=i-1;j>=i/BSIZE*BSIZE;j--) {
			if(a[i] < a[j]) {
				data[i].left++;
			} else {
				goto leftend;
			}
		}
		for(j=i/BSIZE-1;j>=0;j--) {
			if(a[i] < bucket[j]) {
				data[i].left += BSIZE;
			} else {
				for(k=(j+1)*BSIZE-1;k>=j*BSIZE;k--) {
					if(a[i] < a[k]) {
						data[i].left++;
					} else {
						goto leftend;
					}
				}
			}
		}
	  leftend:
		for(j=i+1;j<min(i/BSIZE*BSIZE+BSIZE, N);j++) {
			if(a[i] < a[j]) {
				data[i].right++;
			} else {
				goto rightend;
			}
		}
		for(j=i/BSIZE+1;j<N/BSIZE+1;j++) {
			if(a[i] < bucket[j]) {
				data[i].right += BSIZE;
			} else {
				for(k=j*BSIZE;k<min((j+1)*BSIZE, N);k++) {
					if(a[i] < a[k]) {
						data[i].right++;
					} else {
						goto rightend;
					}
				}
			}
		}
	  rightend:;
	}
	
	for(i=0;i<N;i++) {
		//printf("%d: left = %d, right = %d\n", i, data[i].left, data[i].right);
		ans += a[i] * (data[i].left+1) * (data[i].right + 1);
	}
	
	printf("%ld\n", ans);
	
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <deque>

using namespace std;
const int kMaxN = 1e5 + 10;

vector<int> G[kMaxN];
bool inpath[kMaxN];
	int n, m;

int expand(int x) {
	for (auto y : G[x]) {
		if (!inpath[y]) {
			return y;
		}
	}
	return 0;
}

void solve() {
	cin >> n >> m;

	deque<int> deq;
	
	for (int i = 1; i <= m; ++i) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
		if (i == 1) {
			inpath[a] = true;
			inpath[b] = true;
			deq.push_back(a);
			deq.push_back(b);
		}
	}

	bool done = false;
	while (!done) {
		done = true;
		int x = expand(deq.front());
		if (x != 0) {
			done = false;
			inpath[x] = true;
			deq.push_front(x);
		}
	}

	done = false;
	while (!done) {
		done = true;
		int y = expand(deq.back());
		if (y != 0) {
			done = false;
			inpath[y] = true;
			deq.push_back(y);
		}
	}

	cout << deq.size() << "\n";
	for (auto el : deq) {
		cout << el << " ";
	}
	cout << "\n";
}

void reset() {
	for (int i = 1; i <= n; ++i) {
		G[i].clear();
		inpath[i] = 0;
	}
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		solve();
		reset();
	}
}

Measured memory_bytes: 6784
from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.mini = [i for i in range(n+1)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        mini = min(self.mini[x], self.mini[y])
        self.mini[x] = mini
        self.mini[y] = mini

    def same_check(self, x, y):
        return self.find(x) == self.find(y)


def main():
    N, M, K = ints_raw()
    friends = [[] for _ in range(N)]
    blocks = [[] for _ in range(N)]
    friUF = UnionFind(N)
    for _ in range(M):
        A,B = ints_raw()
        A-=1
        B-=1
        friends[A].append(B)
        friends[B].append(A)
        friUF.union(A,B)
    for _ in range(K):
        C,D = ints_raw()
        C-=1
        D-=1
        blocks[C].append(D)
        blocks[D].append(C)
    group = [0 for _ in range(N)]
    for n in range(N):
        g = friUF.find(n)
        group[g]+=1
    ans = []
    for n in range(N):
        g = friUF.find(n)
        ng = group[g]
        ng -= len(friends[n])
        ng -= len([d for d in blocks[n] if friUF.find(d)==g])
        ans.append(ng-1)
    return " ".join([str(a) for a in ans])


print(main())


Measured memory_bytes: 124448
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>

#define mod 1000000007
#define REP(i,n) for(int i=0; i<n; i++)

using namespace std;
using ll = long long;

void solve() {
    int n, x;
    ll res = 0;
    vector<int> a, b, c;
    cin >> n;
    REP(i, n) {cin >> x; a.push_back(x);}
    REP(i, n) {cin >> x; b.push_back(x);}
    REP(i, n) {cin >> x; c.push_back(x);}

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    unsigned long up, down;
    REP(i, n){
        up = (lower_bound(a.begin(), a.end(), b.at(i))-a.begin());
        down = n-(upper_bound(c.begin(), c.end(), b.at(i))-c.begin());
        res += up * down;
    }
    cout << res << endl;
}

int main(){
    solve();
    return 0;
}

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

int main(){
  int64_t N,A,B;
  cin >> N >> A >> B;
  int64_t count;
  if ((B - A) % 2 == 0) count = (B - A) / 2;
  else {
    if ((B - 1) < (N - A)){
      count = (B + A - 1) / 2;
    }
    else {
      count = (2 * N - A - B + 1) / 2;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}
 
fn main() {
  let ss: Vec<String> = read_vec();
  let ans: Vec<char> = ss.iter().map(|s| (s.chars().next().unwrap() as u8 - 0x20) as char).collect();

  for c in ans {
    print!("{}", c);
  }
}


Measured memory_bytes: 4352
N = int(input())
h = list(map(int,input().split()))

counter = 0
while 1:
    if max(h)==0:
        break
    i = 0
    while i < N:
        if h[i] > 0:
            counter += 1
            while i<N and h[i] > 0:
                h[i]-=1
                i+=1
        else:
            i+=1
print(counter)


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

template <typename T>
struct compressor{
	vector<T> v;
	void add(T &x){
		v.push_back(x);
	}
	
	void compress(bool f = true){
		sort(v.begin(),v.end());
		if(f)v.erase(unique(v.begin(),v.end()),v.end());
	}

	int size(){
		return v.size();
	}
	
	int operator[] (T &x){
		return distance(v.begin(),lower_bound(v.begin(),v.end(),x));
	}
	
	T get(int id){
		return v[id];
	}
	
	int count(int id){
		if(id!=0 && v[id]==v[id-1])return 0;
		return distance(lower_bound(v.begin(),v.end(),v[id]),upper_bound(v.begin(),v.end(),v[id]));
	}
	
};

int main(){

	int N;
	cin>>N;
	
	compressor<string> C;
	
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		C.add(s);
	}
	
	C.compress(false);
	
	long long ans = 0;
	
	rep(i,N){
		long long t = C.count(i);
		ans += t * (t-1) / 2;
	}
	
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 7392
X,K,D = map(int,input().split())
if abs(X) >= D:
    minX = abs(X) % D

if abs(X) / D <= K and abs(X) >= D:
    if (K - int((abs(X) / D))) % 2 == 0:
        print(minX)
    else:
        if abs(minX - D) < abs(minX + D):
            print(abs(minX - D))
        else:
            print(abs(minX + D))
elif abs(X) / D > K and abs(X) >= D:
    print(abs(X) - K*D)
elif abs(X) < D and K % 2 == 0:
    print(abs(X))
elif abs(X) < D and K % 2 == 1:
    print(D - abs(X))

Measured memory_bytes: 9140
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,ma_i=0,mi_i=0;
  bool all_m=true;
  cin >> n;
  vector<ll> a(n);
  vector<P> ans;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]>a[ma_i]) ma_i = i;
    if(a[i]<a[mi_i]) mi_i = i;
    if(a[i]>0) all_m=false;
  }
  for(int i=0;i<n;i++){
    if(all_m||a[ma_i]<abs(a[mi_i])){
      all_m = true;
      ans.push_back(P(mi_i,i));
    }else{
      ans.push_back(P(ma_i,i));
    }
  }
  for(int i=1;i<n;i++){
    if(all_m){
      ans.push_back(P(n-i,n-i-1));
    }else{
      ans.push_back(P(i-1,i));
    }
  }
  cout << ans.size()<<endl;
  for(auto p:ans){
    cout <<p.first+1<<" "<<p.second+1<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(li i=0;i<n;i++)
#define li long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s second
const ll INF=(1LL<<60)-1;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}
li pow(li a,li b,li mo)
{
    if(a==0)
    return 1;
    li u=pow(a,b/2,mo);
    u=(u%mod*u%mod)%mo;
    if(b%2==1)
    u=(u%mod*a%mod)%mod;
    return u;
}
ll power(ll a,ll b)
{
    ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const pair<li,li> &i, pair<li,li> &j)
{
    if(i.f==j.f)
    return i.s > j.s;
    else
    return i.f<j.f;
    
}

void solve()
{
    
   li n;
   cin>>n;
   li a[n];
   rep(i,n)
   cin>>a[i];
   sort(a,a+n);
   li sum=a[n-1];
   li cnt=2,i=n-2;
   while(cnt<n)
   {
       if(cnt+2<=n)
       sum+=2*a[i],cnt+=2;
       else if(cnt+1<=n)
       sum+=a[i],cnt++;
       else
       cnt++;
       i--;
       
       
   }
    cout<<sum;
}
int main()
{
    FAST_IO;
    li t;
    t=1;
  
    while(t--)
    {
        solve();
        cout<<endl;
        
    }
    
}


Measured memory_bytes: 5188
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

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

int N;
int dp[100+1][4][4];
int plan[100+1];

const int MOD = 10000;

int solve( int day, int b1, int b2 ){
  if( day == N+1 )
    return 1;

  if( dp[day][b1][b2] != -1 )
    return dp[day][b1][b2];

  if( plan[day] != 0 ){
    if( plan[day] == b1 && b1 == b2)
      return 0;
    else
      return solve( day+1, plan[day], b1) % MOD;
  }

  int res=0;
  for( int i=1; i<=3; i++ ){
    if( b1==b2 && b1==i )
      continue;
    res += solve(day+1, i, b1) % MOD;
  }

  dp[day][b1][b2] = res;
  return res%MOD;
}


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int K;
  cin>>N>>K;

  memset(plan,0,sizeof(plan));
  REP(_t,K){
    int A,B;
    cin >>A>>B;
    plan[A] = B;
  }

  memset( dp, -1, sizeof(dp) );

  int res = solve( 1, 0, 0 );
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {

  char C;
  cin >> C;
  
  cout << (char)(C + 1) << endl;
}

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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    double sum = 0.0;
    int a[n];
    for(int i=0;i<n;i++) {
        cin >> a[i];
        sum += a[i];
    }
    int lim = ceil(sum /(4.0*m));
    int cnt = 0;
    for(int i=0;i<n;i++) {
        if(a[i] >= lim) cnt++;
    }
    cout << ((cnt >= m) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
// D - Remainder Reminder

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int N, K;
	cin >> N >> K;

	ll ans = 0;

	for (int b=K+1; b<=N; b++) {
		//cout << "b=" << b << " "; // **** debug ****
		ll a1 = N / b * max(0, b - K);
		ll a2;
		if (N % b > 0) {
			if (K == 0) a2 = N % b;
			else a2 = max(0, (N % b) - K + 1);
		} else {
			a2 = 0;
		}
		ans += a1 + a2;
		//cout << "a1=" << a1 << " " << "a2=" << a2 << endl; // **** debug ****
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int64_t func(int64_t k,int64_t x){
    if(k>=0){
        return k/x+1;
    }
    else if(k=-1){
        return 0;
    }
}
int main() {
  int64_t a,b,x;
  cin>>a>>b>>x;
  cout<<func(b,x)-func(a-1,x)<<endl;
 return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<ll, ll> m;
    rep(i, n) {
        ll a; cin >> a;
        if (m.find(a) != m.end()) {
            m[a]--;
            if (m[a] == 0) m.erase(a);
        }
        else m[a]++;
    }
    cout << m.size() << endl;
    
    return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

int W, H, x, y;

void solve() {
	double max_S = (double)W*H / 2;
	int ans_num = (W == x * 2 && H == y * 2) ? 1 : 0;
	cout << max_S << " " << ans_num << endl;
}

int main() {
	cin >> W >> H >> x >> y;
	solve();
}

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

int main(){
	int n;
	cin>>n;
	string S[n];
	for(int i=0;i<n;++i)cin>>S[i];
	map<char,int>Smap;
	vector<char>arr;
	for(int i=0;i<n;++i){
		map<char,int>tmpmap;
		for(int j=0;j<S[i].length();++j){
			if(Smap[S[i][j]]==0 && tmpmap[S[i][j]]==0)arr.push_back(S[i][j]);
			tmpmap[S[i][j]]++;
		}
		if(i==0)Smap=tmpmap;
		else{
			for(int j=0;j<arr.size();++j){
				Smap[arr[j]]=min(Smap[arr[j]],tmpmap[arr[j]]);
			}
		}
	}
	string ans;
	sort(arr.begin(),arr.end());
	for(int i=0;i<arr.size();++i){
		for(int j=0;j<Smap[arr[i]];++j){
			ans+=arr[i];
		}
	}
	cout<<ans<<endl;
}


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

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    vector<vector<ll>> dp(n,vector<ll>(13,0));//dp[i][j] 前からi+1桁目までにnum = j(mod13)となる数字がいくつあるか
    if(s[0] == '?'){
        for(int i = 0;i < 10;i++)dp[0][i] = 1;
    }else{
        int i = s[0]-'0';
        dp[0][i] = 1;
    }
    //for(int i = 0;i < 13;i++)cout << dp[0][i] << endl;
    for(ll i = 1;i < n;++i){
        if(s[i] == '?'){
            for(int j = 0;j < 13;++j){
                for(int k = 0;k < 10;k++){
                    dp[i][(j*10+k)%13] += dp[i-1][j];
                }
                //cout << "i:" << i << "j:" << j << " " << dp[i][j] << endl;
            }
        }else{
            int k = s[i] - '0';
            for(int j = 0;j < 13;++j){
                dp[i][(j*10+k)%13] += dp[i-1][j];
                //cout << "i:" << i << "j:" << j << " " << dp[i][j] << endl;
            }
            
        }
        for(int j = 0;j < 13;j++)dp[i][j] %= MOD;
    }
    cout << dp[n-1][5] << endl;
}

Measured memory_bytes: 13696
s=list(input())
N=int(input())
for i in range(len(s)):
    a=(123-ord(s[i]))%26
    if a<=N:
        N-=a
        s[i]="a"
s[-1]=chr((ord(s[i])+N-97)%26+97)        
print("".join(s))

Measured memory_bytes: 4156
#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 a,b,c,n;
    cin >> n >> a >> b >> c;
    vector <int> l(n);
    rep(i,n){
        cin >> l[i];
    }

    int b1=0,b2=0,b3=0,b4=0;
    int n2;
    n2=pow(4,n);
    vector <int> an(3);
    int ans=0,ans2=100100;
    int kk,k1,k2,k3;

    rep(i,n2){
        b1=0;
        b2=0;
        b3=0;
        b4=0;
        kk=0;
        k1=0;
        k2=0;
        k3=0;
        rep(j,n){
            if((i>>(2*j))&1==1 and (i>>(2*j+1))&1==1){
                b1+=l[j];
                if(k1==1){
                    ++kk;
                }
                else{
                    k1=1;
                }
            } 
            else if((i>>(2*j))&1==1){
                b2+=l[j];
                if(k2==1){
                    ++kk;
                }
                else{
                    k2=1;
                }
            } 
            else if((i>>(2*j+1))&1==1){
                b3+=l[j];
                if(k3==1){
                    ++kk;
                }
                else{
                    k3=1;
                }
            } 
            else{
                b4+=l[j];
            }
        }
        if(b1!=0 and b2!=0 and b3!=0){
        ans=abs(b1-a)+abs(b2-b)+abs(b3-c)+kk*10;
        //if(ans==120){
        //cout << ans << " " << i << " " << b1 << " " << b2 << " " << b3 << endl;
        //}
        ans2=min(ans,ans2);
        }
    }

    cout << ans2 << endl;

    

    return 0;
}

Measured memory_bytes: 4048
#include <iostream>

int main() {
	int A = 0;
	int B = 0;
	int K = 0;
	std::cin >> A >> B >> K;
	int i = A < B ? A : B;
	while (K) {
		if ((A % i == 0) && (B % i == 0)) {
			K--;
		}
		i--;
	}
	i++;
	std::cout << i;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			set.add(sc.nextInt());
		}
		boolean flag = true;
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			if (!set.contains(sc.nextInt())) {
				flag = false;
			}
		}
		if (flag) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}



Measured memory_bytes: 145984
#include <cstdio>
#include <stdint.h>

char S[100005],T[100005];
int64_t N,M;

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

bool test(int64_t X){
  for(int64_t i=0;i<X;i++){
    if(S[i*N/X]!=T[i*M/X]){
      return false;
    }
  }
  return true;
}

int main(){
  scanf("%ld %ld",&N,&M);
  scanf("%s %s",S,T);
  int64_t G=gcd(M,N);
  if(test(G)){
    printf("%ld\n",M/G*N);
  }else{
    printf("-1\n");
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>

string s;
int n,tn;
vector<int>l,r;
int table[111111];

int main(){
    cin>>s;
    n=(int)s.size();
    rep(i,n){
        if(s[i]=='L')l.pb(i);
        else r.pb(n-1-i);
    }
    
    sort(r.begin(),r.end());
    
    
   // rep(i,r.size())cout<<r[i]<<" ";cout<<endl;
    
    rep(i,n){
        int cnt=0,pos,ans;
        if(s[i]=='L'){
            pos=lower_bound(r.begin(),r.end(),n-i-1)-r.begin();
            cnt=r[pos]-(n-i-1);
            ans=-(cnt%2)+r[pos];
            //cout<<n-i-1<<" "<<r[pos]<<" "<<cnt<<" "<<ans<<" "<<n-1-ans<<endl;
            table[n-1-ans]++;
        }
        
        else{
            pos=lower_bound(l.begin(),l.end(),i)-l.begin();
            cnt=l[pos]-i;
            ans=-(cnt%2)+l[pos];
            table[ans]++;
        }
    }
    
    rep(i,n){
        cout<<table[i];
        if(i==n-1)cout<<endl;
        else cout<<" ";
    }
    
	return 0;
}



Measured memory_bytes: 1532
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    a=input()
    b=input()
    c=input()
    ans=0
    for i in range(n):
        if a[i]!=b[i]:
            if b[i]!=c[i] and a[i]!=c[i]:
                ans+=2
            elif (b[i]!=c[i] and a[i]==c[i]) or b[i]==c[i]:
                ans+=1
        else:
            if b[i]!=c[i]:
                ans+=1
    print(ans)

if __name__=='__main__':
    main()

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

using namespace std;

int main() {
    int n; cin >> n;
    int c[n];
    for (int i = 0; i < n; i++) cin >> c[i];
    if (c[0] != 0) {
        cout << 0;
        return 0;
    }
    int a[n];
    memset(a, 0, sizeof(a));
    for (int i = 0; i < n; i++) {
        a[c[i]]++;
    }
    if (a[0] > 1) {
        cout << 0;
        return 0;
    }
    long long res = 1;
    for (int i = 1; i < n; i++) res = (res * a[c[i] - 1]) % 998244353;
    cout << res;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){

//	vector<int> a(n);

  int n,x,cnt=0;
  int sum=0,min=1000;

  cin >> n >> x;
 
  vector<int> m(n);

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

  for(int i=0;i<n;i++){
    sum = sum + m[i];
    if(min > m[i]){
      min = m[i];
    }
  }

//  cout << min << endl;

  x = x - sum;
  cnt = cnt + n;

  cnt = cnt + x/min;

  cout << cnt << endl;

/*  cout << n << " " << x << endl;

  for(int i=0;i<n;i++){
    cout <<  m[i] << " ";
  }
  cout << endl;
*/
}

Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (1) {
        vector<int> A(1);
        int L;
        cin >> A[0] >> L;
        if (A[0]+L==0) break;
        vector<int> K(L);
        int cur = 0;
        while (1) {
            int N = A[cur];
            rep(i,L) {
                K[i] = N%10;
                N /= 10;
            }
            sort(all(K));
            int S = 0, T = 0;
            rep(i,L) {
                T *= 10;
                T += K[i];
            }
            reverse(all(K));
            rep(i,L) {
                S *= 10;
                S += K[i];
            }
            cur++;
            bool ok = false;
            rep(i,A.size()) {
                if (A[i] == S-T) {
                    cout << i << " " << S-T << " " << cur-i << ln;
                    ok = true;
                }
            }
            if (ok) break;
            A.emplace_back(S-T);
        }
    }
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> P(N),Q(N);
    for(int i=0;i<N;i++) cin >> P[i];
    for(int i=0;i<N;i++) cin >> Q[i];
    int a = 0,b = 0;
    vec<int> A(N);
    iota(A.begin(),A.end(),1);
    int id = 0;
    do{
        bool p = true;
        for(int i=0;i<N;i++) p &= P[i]==A[i];
        if(p) a = id;
        bool q = true;
        for(int i=0;i<N;i++) q &= Q[i]==A[i];
        if(q) b = id;
        id++;
    }while(next_permutation(A.begin(),A.end()));
    cout << abs(a-b) << endl;
}

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


 
int main() {
  
  int n;
  scanf("%d",&n);
  int aa[n]={0};
  priority_queue<int> que;
  for(int i=0;i<n;i++){
  	int a;
    scanf("%d",&a);
    aa[i]=a;
    que.push(a);
  }
  int mx=que.top();
  que.pop();
  int mxb=que.top();
  
  
	for(int i=0;i<n;i++){
    if(aa[i]==mx){
      printf("%d\n",mxb);
    }else{
    	printf("%d\n",mx);
    }
    }

  
  
}


Measured memory_bytes: 3316
def f(s, i):
    if i == n:
        return 1
    if memo[s] != -1:
        return memo[s]
    re = 0
    for j in range(n):
        if aij[i][j] and s & (1 << j):
            re += f(s - (1 << j), i + 1)
    re = memo[s] = re % md
    return re


md = 10 ** 9 + 7
n = int(input())
aij = [list(map(int, input().split())) for _ in range(n)]
memo = [-1] * (1 << n)
s = (1 << n) - 1
print(f(s, 0))


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

#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(i=a;i<b;i++)
#define inf         INT_MAX
#define llinf       LLONG_MAX

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

using namespace std;
void solve()
{
    int n,i;
    cin>>n;
    vii v(n);
    rep(i,0,n) cin>>v[i].F>>v[i].S;
    rep(i,0,n-2)
    {
        if(v[i].F==v[i].S && v[i+1].F==v[i+1].S && v[i+2].F==v[i+2].S)
        {
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3628