akhauriyash/Code-Regression huggingface dataset:
/**
    *Makacha
**/
#include <bits/stdc++.h>
using namespace std;

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n'&&c!=EOF) s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, ll> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const int inf = 1e9,
N = 3e4 + 11;

int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif //makacha
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int times1 = h1 * 60 + m1;
    int times2 = h2 * 60 + m2;
    cout << times2 - times1 - k;
}


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

int main() {
  long long N;
  cin >> N;
  long long i = 0;
  int ans = 100;
  for (i = 1; i *i <= N; i++) {
    long long a = i;
    if (N % a == 0) {
      long long b = N / a;
      string sa = to_string(a);
      string sb = to_string(b);
      //cout << "a:" << a << " b:" << b << " A:" << sa.size() << " B:" << sb.size() << endl;
      int num = max(sa.size(), sb.size());
      if (ans >= num) {
        ans = num;
      } else {
        cout << ans << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long A, long long B, long long K){
    if(A >= K) {
        cout << (A-K) << " " << B << endl;
    } else if ( (A+B) <= K) {
        cout << "0 0" << endl;
    } else {
        cout << "0 " << (A+B) - K << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv,
       std.format,
       std.math;

void main()
{
	auto n = readln.chomp.to!int;
	auto a = readln.split.to!(int[]);
	writeln((reduce!("a + b")(0, a)) - n);
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll cnt[1000006];

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll allgcd = a[0];
  rep(i,n)allgcd = __gcd(allgcd,a[i]);
  if(allgcd > 1){
    cout << "not coprime" << endl;
  }else{
    // 与えられた数をそれぞれ素因数分解していく
    rep(i,n){
      ll now = a[i];
      for(ll j=2;j*j<=now;j++){
        if(now%j==0){
          while(now%j==0)now/=j;
          cnt[j]++;
        }
      }
      if(now>1)cnt[now]++;
    }
    for(int i=2;i<=1e6;i++){
      if(cnt[i]>1){
        cout << "setwise coprime" << endl;
        return 0;
      }
    }
    cout << "pairwise coprime" << endl;
  }
}

Measured memory_bytes: 18532
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		
		int res = 0;
		
		for(int i = 1; i <= n; i++) {
			res+=i;
		}
		
		out.println(res);
	}

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

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

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

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

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
N = int(input())
AB = [[int(_) for _ in input().split()] for _ in range(N)]
ans = 0

for i in range(N):
    tmp = (AB[N-i-1][0]+ans) % AB[N-i-1][1]
    if tmp != 0:
        ans += AB[N-i-1][1] - tmp

print(ans)

Measured memory_bytes: 21156
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()

import bisect
As = list(range(N+1))

Bs = [0] * N
s = 0
for i,b in enumerate(B):
    ind = bisect.bisect_left(A,b)
    s += As[ind]
    Bs[i] = s
Bs = [0] + Bs
Cs = [0] * N
ans = 0
for i,c in enumerate(C):
    ind = bisect.bisect_left(B,c)
    ans += Bs[ind]

print(ans)



Measured memory_bytes: 31864
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int n,num;
	while(cin>>n){
		 num=0;
		char a[n+2];
		for(int i=1;i<=n;i++) cin>>a[i];
		for(int i=1;i<=n;i++){
			if(a[i]=='A')
			if(a[i+1]=='B')
			if(a[i+2]=='C')
			num++;
		}
		cout<<num<<'\n';
	}
}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int N, tmp, p, q;
    map<int64_t, pair<int64_t, int64_t>> list;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        p = i + tmp, q = i - tmp;
        list[p].first++;
        list[q].second++;
    }
    int64_t ans = 0;
    for (auto x : list)
        ans += x.second.first * x.second.second;
    cout << ans;
}

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

int main(){
    int n,A[100000];
    cin >> n;
    int *pos;
    int sum = 0;
    
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    
    int a,B[50000];
    cin >> a;
    
    for(int i=0; i<a; i++){
        cin >> B[i];
        pos = lower_bound(A, A+n, B[i]);
        if(*pos==B[i]){
            sum++;
        }
    }
    
    cout << sum << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if( a < b ) {
    int i = 0;
    while (i < b) {
      cout << a;
      i++;
    }
    cout << endl;
  }
  else {
    int i = 0;
    while (i < a) {
      cout << b;
      i++;
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

int main(){
  int n;cin >> n;
  vector<bool> ans(n+1,false);
  ans[1]=true;
  int m;cin >> m;
  vector<int> exi(n+1,1);
  rep(i,m){
    int x,y;cin >> x >> y;
    if(ans[x]&&exi[x])ans[y]=true;
    exi[x]--;
    exi[y]++;
    if(exi[x]==0)ans[x]=false;
  }
  int cnt=0;
  rep(i,n)if(ans[i+1]&&exi[i+1]>0)cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 640
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int ans = 0;

	rep (i, 2)
	{
		int x, sum = 0;
		cin >> x;
		x--;
		while (x > 0)
		{
			sum += x;
			x--;
		}
		ans += sum;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int a = 0;
        int b = 0;
        while (x >= 500) {
            x -= 500; 
            a++;
        }
        while (x >= 5) {
            x -= 5;
            b++;
        }
        System.out.println(1000*a + 5*b);
    }
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define SZ 100010
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define INF 1000000000
#define F first
#define S second
#define MP make_pair
#define LL long long


int n;
int ara[10];
int target[4];

int dp[1 << 8][4][3010];

int func(int mask, int pos, int taken)  {
    if(pos == 3)    {
        return 0;
    }
    if(dp[mask][pos][taken] != -1)    {
        return dp[mask][pos][taken];
    }
    int ans = 100000000;

    FOR(i, 0, n - 1)   {
        if(mask & (1 << i))    {
        }
        else    {
            if(taken)    {
                ans = min(ans, 10 + func(mask | (1 << i), pos, taken + ara[i]));
            }
            else    {
                ans = min(ans, func(mask | (1 << i), pos, taken + ara[i]));
            }
        }
    }

    ///porer pos e giye
    if(taken)    {
        ans = min(ans, abs(taken - target[pos]) + func(mask, pos + 1, 0));
    }
    return dp[mask][pos][taken] = ans;
}

int main()  {
//    freopen("in.txt", "r", stdin);
    cin >> n;
    FOR(i, 0, 2)   {
        cin >> target[i];
    }
    FOR(i, 0, n - 1)   {
        cin >> ara[i];
    }
    MEM(dp, -1);
    cout << func(0, 0, 0) << "\n";
    return 0;
}
/**
*/


Measured memory_bytes: 12288
import math
A,B = list(map(int,input().split()))
def problem_gksn(A, B):
  x_min = math.ceil(A / (0.08))
  x_max = math.floor((A+1)/0.08)
  y_min = math.ceil(B / (0.10))
  y_max = math.floor((B+1) / (0.10))
  # print(x_min,x_max,y_min,y_max)
  if max(x_min, y_min) < min(x_max, y_max):
    return max(x_min, y_min)
  else:
    return -1
print(problem_gksn(A,B))
# {[ } ]

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

int main() {
	double a, b, c, d, e, f, x, y;
	while(cin >> a >> b >> c >> d >> e >> f) {
		y = (c*d-f*a)/(b*d-e*a);
		x = (c-b*y)/a;

		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <iostream> 
#include <string>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

int main() 
{
    int n;
    cin >> n;
    int a = n % 10;
    if (a == 3)
        cout << "bon" << endl;
    else if (a == 0 || a == 1 || a == 6 || a == 8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;
    

}

Measured memory_bytes: 3620
using System;

namespace AtCoder
{
	public class ProblemA
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			string s = Console.ReadLine();

			int eastCount = 0;

			for (int i = 0; i < n; i++)
			{
				if (s[i] == 'E')
					eastCount++;
			}


			int number = int.MaxValue;

			int east2 = 0;
			for (int i = 0; i < n; i++)
			{
				char c = s[i];
				// 左は西を向いている人が振り向く
				int tmpAns = i - east2;

				if (c == 'E')
				{
					east2++;
				}

				// 右は東を向ている人が振り向く
				tmpAns += eastCount - east2;

				if (tmpAns < number)
				{
					number = tmpAns;
				}
			}

			Console.WriteLine(number);
		}
	}
}


Measured memory_bytes: 28664
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

main(){
  int m,n;
  int  x[4],y[4];
  while(1){
    int h=0,b=0;
    cin >> m >> n;
    if(n==0 && m==0) break;

    for(int i=0;i<4;i++){
      x[3-i]=m%10;
      y[3-i]=n%10;
      m=m/10;
      n=n/10;
    }

    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if(x[i]==y[j]){
	  if(i==j) h++;
	  else b++;
	}
      }
    }
    cout << h << " " << b << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
    lint k, q;
    cin >> k >> q;

    vector<lint> d(k);
    for(auto& elem : d)  cin >> elem;

    while(q--) {
        lint n, x, m;
        cin >> n >> x >> m;

        x %= m;
        vector<lint> dm(d.begin(), d.end());
        for(auto& elem : dm) {
            elem %= m;
            if(elem == 0)  elem = m;
        }

        partial_sum(begin(dm), end(dm), begin(dm));
        dm.insert(begin(dm), 0);

        lint last = x + ((n-1)/k) * dm[k] + dm[(n-1)%k];
        cout << (n-1) - (last / m) << endl;
    }
}

Measured memory_bytes: 384
/*
 * Author : Sadi
 * Thu 09/07/2020
 * 17:30:37.90
 */
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    vector<int> B(n - 1);
    for(int i = 0; i < n - 1; ++i) {
        cin >> B[i];
    }
    long long ans = B[0];
    for(int i = 1; i < n - 1; ++i) {
        ans += min(B[i - 1], B[i]);
    }
    ans += B[n - 2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)

def main(): 
    h,w,a,b = map(int,input().split())
    grid = [['0']*w for _ in range(h)]

    if a == 0:
        for i in range(b):
            grid[i] = ['1'] * w

    elif b == 0:
        for i in range(h):
            for j in range(a):
                grid[i][j] = '1'
                
    else:
        for i in range(b):
            for j in range(a):
                grid[i][j] = '1'
            for j in range(2*a,w):
                grid[i][j] = '1'
        
        for i in range(b,2*b):
            for j in range(a,2*a):
                grid[i][j] = '1'
        
        for i in range(2*b,h):
            for j in range(a):
                grid[i][j] = '1'
    
    for i in range(h):
        print(''.join(grid[i]))  
    
if __name__=='__main__':
    main()


Measured memory_bytes: 12276
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main() 
{
	string S, T;
	cin >> S >> T;
	for (int k = 0; k < 2; k++) {
		for (int i = 0; i < 26; i++) {
			vector<char> G;
			for (int j = 0; j < S.size(); j++) {
				if (S[j] == (char)('a' + i)) G.push_back(T[j]);
			}
			for (int l = 0; l < (int)G.size() - 1; l++) {
				if (G[l] != G[l + 1]) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
		swap(S, T);
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 932
// Problem : D - Flat Subsequence
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vint vector<int>
#define sint set<int>
#define mint map<int,int>
#define pint pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void solve(){
	int n,k;
	rd(n,k);
	vint dp(n,1);
	vint arr(n);
	for(int&v:arr)rd(v);
	for(int i=1;i<n;i++)
	{
		int L=max(0ll,i-99);
		for(int j=L;j<i;j++)
		{
			if(abs(arr[i]-arr[j])<=k)dp[i]=max(dp[i],1ll+dp[j]);
		}
	}
	pp(*max_element(all(dp)));
	
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 7932
#include<bits/stdc++.h>
using namespace std;
char s[105];
int n;
int s1,s2,t1,t2;

int main(){
	cin>>s+1;
	n=strlen(s+1);
	s1=1,t1=(n-1)/2;
	s2=(n+3)/2,t2=n;
	for(int i=1;i<=n;i++){
		if(s[i]!=s[n+1-i]){puts("No");return 0;}
	}
	for(int i=s1;i<=t1;i++){
		if(s[i]!=s[s1+t1-i]){puts("No");return 0;}
	}
	for(int i=s2;i<=t2;i++){
		if(s[i]!=s[s2+t2-i]){puts("No");return 0;}
	}
	puts("Yes");

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

int main(){

    int x;
    cin >> x;

    for(int i = 1; i < 1000; i++){

        long long a = 1;

        for(int j = 0; j < 5; j++) a *= i;

        for(int k = -1000; k < 1000; k++){

            long long b = 1;

            for(int l = 0; l < 5; l++) b *= k;

            // cout << b << endl;

            if((a-b) == x){
                // cout << a << " " << b << endl;
                cout << i << " " << k << endl;
                return 0;
            }

        }



    }
    return 0;
}


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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int c[n];
    int a[n][m];

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

    int ans = 1e7;
    bool isBuy[n] = {};
    for(int bit = 0; bit < (1 << n); bit++) {
        for(int i = 0; i < n; i++) {
            if(bit & (1 << i)) isBuy[i] = true;
            else isBuy[i] = false;
        }

        int understood[m] = {};
        int price = 0;
        for(int i = 0; i < n; i++) {
            if(isBuy[i]) {
                price += c[i];
                for(int j = 0; j < m; j++) {
                    understood[j] += a[i][j];
                }
            }
        }

        bool ok = true;
        for(int i = 0; i < m; i++) {
            if(understood[i] < x) {
                ok = false;
                break;
            }
        }

        // cout << price << ' ' << ok << endl;
        if(ok == true) {
            if(ans > price) ans = price;
        }
    }

    if(ans == 1e7) ans = -1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
a=int(input())
b=int(input())
c=int(input())
x=int(input())
end=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            s= i*500 + j*100 + k*50
            if s==x:
                end+=1
print(end)


Measured memory_bytes: 39664
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

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

    cin >> n>>d;

    cout << (ll)(n*d) << endl;
}


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

int main(){
	int n;
	while(cin >> n,n){
		int prev = -1,turn = 1;
		bool t[2][200] = {};
		for(int i = 0;i < n;i++){
			int m;
			cin >> m;
			t[0][m - 1] = true;
		}
		for(int i = 0;i < n * 2;i++) {
			t[1][i] = !t[0][i];
		}
		for(int i = 0;;i++){
			int next = -1;
			bool end = true;
			turn = (turn + 1) % 2;
			for(int j = 0;j < 2 * n;j++){
				if(next == -1 && prev < j && t[turn][j]) next = j;
				if(t[turn][j]) end = false;
			}
			if(end) break;
			if(next == -1){
				prev = -1;
				continue;
			}
			t[turn][next] = false;
			prev = next;
		}
		int sum = 0;
		for(int i = 0;i < 2 * n;i++){
			if(t[1][i]) sum++;
		}
		cout << sum << endl;
		sum = 0;
		for(int i = 0;i < 2 * n;i++){
			if(t[0][i]) sum++;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int mod=1e9+7;
const int N = 1e5+5;

string ans = "";
string st;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>st;
  for(int i = 0;i < st.size();i++){
    char now = st[i];
    if(now == '0') ans += "0";
    else if(now == '1') ans += "1";
    else if(!ans.empty()) ans = ans.substr(0,ans.size()-1);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
    int64_t x;
    cin>>x;
    int64_t x2=x/1000;
    int64_t x3=x%1000;
    if(x3<500){
        x=(x2*2)*1000+x3/5*5;
    }
    else x=(x2*2+1)*1000+(x3-500)/5*5;
    cout<<x<<endl;
}


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

int main(){
  using namespace std;

  std::string str;
  int len;
  
  cin >> str;
  len = str.length();
  if(str[0] == str[len - 1]){
    cout << str[0] << endl;
  }else{
    cout << 'o' << endl;
  }

  return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>

using namespace std;


#define INF pow(10, 9)
// typedef priority_queue<tuple<int,int,int>, vector< tuple<int, int, int> >, greater< tuple<int, int, int> > > PQ;
typedef long long int ll;





int main(void)
{


    int N;
    cin >> N;
    vector< pair<int, int> > dices(N);
    for(int i=0; i<N; i++)
    {
        cin >> dices[i].first >> dices[i].second;
    }
    bool flag = false;
    int times = 0;
    for(int i=0; i<N; i++)
    {
        if(dices[i].first == dices[i].second)
        {
            times++;
            if(times >= 3)
            {
                flag = true;
                break;
            }
        }
        else
        {
            times = 0;
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;




    return 0;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a[100005],f[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int ans=0;
	for(int i=n-1;i>=1;i--)
	{
		if(a[i]>=a[i+1])f[i]=f[i+1]+1;
		else f[i]=0;
		ans=max(ans,f[i]);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0, x = 0;
  for (int i=0; i<N; i++) {
    if (S[i] == 'I') {
      x++;
      ans = max(ans, x);
    } else
      x--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

string subsum(int* A,int n,int m){
  bitset<2010> E(1);

  rep(i,0,n){
    E |= (E<<A[i]);
  }

  if(E.test(m)) return "yes";
  else return "no";
}

int main(){
  int n; 
  cin>>n;
  int x[n],y[n];

  rep(i,0,n){
    cin>>x[i]>>y[i];
  }

  ll pat=0;
  long double len=0;
  int jun[n];
  for(int i=0;i<n;i++) jun[i]=i;

  sort(jun,jun+n);
  do{
    pat++;
    long double li=0;
    for(int i=0;i<n-1;i++){
      int l=jun[i],r=jun[i+1];
      li+=pow(pow((x[l]-x[r]),2)+pow((y[l]-y[r]),2),0.5);
    }
    len+=li;
  }while(next_permutation(jun,jun+n));

  long double result= len/pat;

  cout<<setprecision(10);
  cout<<result<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,h[100010],dp[100010];
    cin>>n;
    for(int i=0;i<n;i++) cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int a,int b){
  if(b==0)return a;
  else return gcd(b,a%b);
}
 
int main() {
  int n,a[114514],l[114514],r[114514];
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  l[0]=0;
  r[0]=0;
  for(int i=0;i<n;i++){
    l[i+1]=gcd(l[i],a[i]);
    r[i+1]=gcd(r[i],a[n-1-i]);
  }
  int res=0;
  for(int i=0;i<n;i++){
    if(res<gcd(l[i],r[n-1-i]))res=gcd(l[i],r[n-1-i]);
  }
  cout << res << endl;
}

Measured memory_bytes: 1408
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] =  [int(input_raw[0]), int(input_raw[1])]
    sep= []
    for i in range(M):
        input_raw = read_func().strip().split()
        [a, b] =  [int(input_raw[0]), int(input_raw[1])]
        sep.append((a, b))

    sep.sort()

    count = 1
    is_search = False
    i = 0
    while i < M:
        if is_search == False:
            ai = sep[i][0]
            bi = sep[i][1]
            is_search = True
            i += 1
        else:
            aj = sep[i][0]
            bj = sep[i][1]
            if ((ai <= aj and aj < bi)) == False :
                count += 1
                is_search = False
            else:
                ai = max(ai, aj)
                bi = min(bi, bj)
                i += 1

    print count



if __name__ == '__main__':
    main()


Measured memory_bytes: 18800
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args>
void dbg(Args&&... args) {
  using expander = int[];
  (void)expander {0,(static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {exit(0);}

const int N = 3010;
int n;
int a[N];

void input() {
  scanf("%d", &n);
  forn(i, 0, n) {
    scanf(" %d", &a[i]);
  }
}

ll GCD(ll u, ll v) {
  while (v != 0) {
    ll r = u % v;
    u = v;
    v = r;
  }
  return u;
}

ll LCM(ll a, ll b) {
  return (a * b) / GCD(max(a, b), min(a, b));
}

void solve() {
  ll ans = 0;
  forn(j, 0, n) {
    ans += a[j] - 1;
  }
  printf("%lld\n", ans);
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
  //  gen();
#endif
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	double N,M,sum = 0;
  	cin >> N >> M;
  	vector<int> data(N);
  	for(int i  =0;i < N;i++){
    	cin >> data[i];
      	sum += data[i];
    }
	sort(data.begin(),data.end(),greater<int>());
  	if(data[M - 1] >= (sum / (4*M))){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<int> n;
  vector<int> x;
  int a,b;
  int i=1;
	while(true)
    {
      cin >> a >> b;
      if(a==0&&b==0) break;
      else 
      {
        n.push_back(a);
        x.push_back(b);
        i++;
      }
    } 
  
  int count=0;
	for(int i=0; i<n.size();i++)
    {
      count=0;
      for(int first=1;first<n[i];first++)
      {
        for(int second=first+1;second<n[i];second++)
        {
          int third=x[i]-first-second;
          if(third>second&&third<=n[i]) count++;
        }
      }
      cout << count << endl;
    }
  
  
	return 0;
}


Measured memory_bytes: 3140
#pragma GCC optimize("O3")
#include<iostream>
#include<string>

using namespace std;
#define REP(i,n) for(int i=0;i<n;++i)

int a[200000],n,b;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    REP(i,n)cin>>a[i];
    REP(i,n)b^=a[i];
    REP(i,n)cout<<(a[i]^b)<<"\n";
    return 0;
}

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

#include <math.h>
#include <stdlib.h>


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

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 int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n, k; cin >> n >> k;

    map<ll, ll> mp;
    set<ll> st;

    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        mp[a] += b;
        st.insert(a);
    }

    ll cnt = 0;
    for(auto i : st){
        cnt += mp[i];
        if(cnt >= k){
            cout << i << endl;
            break;
        }
    }

    return 0;
}


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

int main()
{
        ll N, K; cin >> N >> K;
        vector<ll> A(N, 0);
        set<ll> S;
        map<ll,ll> m;
        rep(i,N) {
                cin >> A[i];
                m[A[i]]++;
        }

        vector<ll> num;
        for (auto i : m) {
                num.push_back(i.second);
        }
        sort(num.begin(), num.end());

        ll n = num.size() - K;
        if (n < 0) {
                cout << 0 << endl;
                exit(0);
        }
        ll ans = 0;
        rep(i, n) {

                ans += num[i];

        }
        cout << ans << endl;



}


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

int main(){
  int K, S; cin >> K >> S;
  int ans = 0;
  for(int x = 0; x <= K; ++x){
    for(int y = 0; y <= K; ++y){
      if(S-x-y <= K && S-x-y >= 0)ans++;
    }
  }
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 3612
#include<stdio.h>

#define MOD 1000000007
#define MAX 2000
long long int fac[MAX], finv[MAX], inv[MAX];
void MOD_COM_init(){
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<MAX; i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long int MOD_combination(long long int n,long long int r){
    if(r<0||n<0){
        return 0;
    }
    if(n < r){
        return 0;
    }
    return (fac[n] * (finv[r] * finv[n-r] % MOD)) % MOD;
}

int main(){
    long long int n, k;
    scanf("%lld%lld", &n, &k);
    MOD_COM_init();
    for(long long int i=1; i<=k; i++){
        long long int p = MOD_combination(n-k+1, i);
        long long int q = MOD_combination(k-1, i-1);
        printf("%lld\n", p*q % MOD);
    }

    return 0;
}

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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using  vi = vector<int>;
using  vl = vector<ll>;
using  vd = vector<double>;
template<class T,class U>
using umap = unordered_map<T,U>;
template<class T>
using uset = unordered_set<T>;

template<class T>
inline bool change_max(T&a, const T&b){
  if(b > a){
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool change_min(T&a, const T&b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline void putv(const vector<T>&v,char c = '\n'){
  for(auto&&e:v){
    cout << e << c;
  }
}

template<class T>
inline void readv(vector<T>&v){
  if(v.empty()){
    cerr << "void readv(vector<T>&v) v.empty()\n";
  }
  for(auto&&e:v){
    cin >> e;
  }
}

int main(){
  int a, b; cin>> a>> b;
  if((abs(a - b))%2==1)cout << "IMPOSSIBLE\n";
  else cout << (a+b)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1005];
ll p;
ll k=1000000007;
ll ans=1;
ll prime[1005];
bool is_prime[1005];
ll seive(ll n){
	p=0;
	for(int i=0;i<=n;i++){
		is_prime[i]=true;
	}
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i){
				is_prime[j]=false;
			}
		}
	}
	return p;
}
int main(void){
	ll n; cin>>n;
	ll aaaa=seive(n);
	for(int i=0;i<p;i++){
		ll P=1;
		for(int j=1;j<=10;j++){
			P=P*prime[i];
			a[i]=a[i]+n/P;
			//cout<<i<<" "<<n<<" "<<P<<" "<<a[i]<<endl;
		}
	}
	for(int i=0;i<=n;i++){
		//cout<<a[i]<<endl;
		ans=ans*(a[i]+1)%k;
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
     string s;
     int sum=0;
     cin>>s;
     for(int i=0;i<s.size();i++)
     {
     	sum+=(s[i]-'0');
     }
     if(sum%9==0)cout<<"Yes";
     else cout<<"No";
}

Measured memory_bytes: 3704
#include <stdio.h>
#include <math.h>
int main(void){
	int i,j,m,n,next[1000],prev[1000];
	while(scanf("%d %d",&n,&m)!=EOF){
		if(n==0 && m==0)break;
		for(i=0;i<n;i++){next[i]=(i+1)%n;prev[i]=(i+n-1)%n;}
		i=0;j=1;
		while(n>1){
			if(j==m){
				j=0;
				next[prev[i]]=next[i];
				prev[next[i]]=prev[i];
				n--;
			}
			i=next[i];j++;
		}
		printf("%d\n",i+1);
	}
	return 0;
}

Measured memory_bytes: 608
<?php
fscanf(STDIN, "%d %d", $n, $l);
$l = [];
for ($i=0; $i < $n; $i++) {
    fscanf(STDIN, "%s", $s);
    $l[] = $s;
}
sort($l);
foreach ($l as $v) {
    echo $v;
}


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
int N, x[105], y[105];
long long int h[105];

int main()
{
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
    }
    int CX, CY;
    ll H,ans_H;
    bool sign = true;
    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= 100; j++)
        {
            sign = true;
            int K;
            ll max_h = -1;
            for (int k = 1; k <= N; k++)
                if (h[k] > max_h)
                {
                    max_h = h[k];
                    K = k;
                }
            H = h[K] + abs(i - x[K]) + abs(j - y[K]);
            if (H < 1)
                continue;
            for (int k = 1; k <= N; k++)
                if (max((ll) (H - (ll) abs(i - x[k]) - (ll) abs(j - y[k])), (ll) 0) != h[k])
                {
                    sign = false;
                    break;
                }
            if (sign)
            {
                CX = i;
                CY = j;
                ans_H = H;
            }
        }
    }

    cout << CX << " " << CY << " " << ans_H << endl;

    return 0;
}


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

#define REP(i,n) for(decltype(n) i=0; i<(n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

void solve(){
    int n,k,a,b;
    cin>>n>>k;
    vector<pii> v;
    v.reserve(n);
    REP(_,n){
        cin>>a>>b;
        v.pb({a,b});
    }
    ll ans = 0;
    for(auto const& p:v)
        if((p.st&k) == p.st)
            ans += p.nd;
    for(int bitno=29;bitno>=0;--bitno){
        int bit = (k>>bitno)&1;
        if(!bit) continue;
        int maskk = k>>(bitno+1);
        ll acc=0;
        for(auto const& p:v){
            int x=p.st;
            int pref = (x>>(bitno+1));
            if((pref&maskk)==pref && ((x>>bitno)&1)==0)
                acc += p.nd;
        }
        ans = max(ans, acc);
    }
    cout<<ans<<'\n';
}

int main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    solve();
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Num[] nums = new Num[n];
        for (int i = 0; i < n; i++) {
            nums[i] = new Num(i, sc.nextInt());
        }
        Arrays.sort(nums);
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 != nums[i].idx % 2) {
                count++;
            }
        }
        System.out.println(count / 2);
    }
    
    static class Num implements Comparable<Num> {
        int idx;
        int value;
        
        public Num(int idx, int value) {
            this.idx = idx;
            this.value = value;
        }
        
        public int compareTo(Num another) {
            return value - another.value;
        }
    }
}

Measured memory_bytes: 65372
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val S = IntArray(n){scn.nextInt()}
	S.sort()
	val q = scn.nextInt()
	val T = IntArray(q){scn.nextInt()}
	T.sort()
	var ans = 0
	for (t in T){
		if (find(t, S)) ans++
	}
	println(ans)
}

fun find(t: Int, sorted: IntArray): Boolean{
	var (l, r) = Pair(0, sorted.size-1)
	if (sorted[l]==t || sorted[r]==t) return true
	while(r-l>1){
		val h = (l+r)/2
		if (sorted[h]==t) return true
		if (sorted[h]>t) r = h
		else l = h
	}
	return false
}


Measured memory_bytes: 72348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        {
            String strArr= br.readLine();
            double a=Double.parseDouble(strArr);
            double pi=3.14159265358979323846264338327950288419716939937510582;

            String men=String.format("%.5f",a*a*pi);
            String syu=String.format("%.5f",a*2*pi);
            System.out.println(men+" "+syu);
        }
    }
}

Measured memory_bytes: 24800
# your code goes here
N=int(input())
Ci=[i for i in input().split()]
C=[]
for i in range(N):
   # print(C)
    C.append([])
    C[i].append(Ci[i][0])
  #  print(C)
    C[i].append(int(Ci[i][1]))
Cb=C
fl=1
#print(Cb)
while fl==1:
    fl=0
    for j in range(N-1):
   #     print(Cb)
        if Cb[N-1-j][1]<Cb[N-2-j][1]:
       #     print(Cb)
            t=Cb[N-1-j]
            Cb[N-1-j]=Cb[N-2-j]
            Cb[N-2-j]=t
            fl=1
        #    print(C)
for i in range(N):
    Cb[i][1]=str(Cb[i][1])
 #   print(Cb)
    Cb[i]="".join(Cb[i])
print(" ".join(Cb))
p="Stable"
print(p)
C=[]
for i in range(N):
 #   print(C)
    C.append([])
    C[i].append(Ci[i][0])
  #  print(C)
    C[i].append(int(Ci[i][1]))
Co=[]
for i in range(N):
    Co.append([])
  #  print(Co)
    Co[i].append(Ci[i][0])
    Co[i].append(int(Ci[i][1]))
for i in range(N-1):
    minj=i
    for j in range(i,N):
    #    print(C)
        if C[j][1]<C[minj][1]:
            minj=j
        elif C[j][1]==C[minj][1]:
            k=0
            while k<N and C[minj][1]!=Co[k][1]:
                k+=1
    #        print (j)
            if k<N and C[minj][0]!=Co[k][0]:
                p="Not stable"
    if i!=minj:
        t=C[i]
        C[i]=C[minj]
        C[minj]=t
   # print(minj)
for i in range(N):
    C[i][1]=str(C[i][1])
    C[i]="".join(C[i])
print(" ".join(C))
print(p)

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

using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i=(a); i<(b);i++)
#define FORD(i, a, b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll plates[4];
vector<vector<vector<double>>> dp;

ll n;

double doDP(ll one, ll two, ll three) {
	if (one < 0 || two < 0 || three < 0) {
		return 0;
	}
	if (one == 0 && two == 0 && three == 0) {
		return 0;
	}
	if (dp[one][two][three] != -1) {
		return dp[one][two][three];
	}
	double res;

	res = (double(n)/double(one + two + three)) + (double(one) / double(one + two + three)) * doDP(one - 1, two, three) +
		  (double(two) / double(one + two + three)) * doDP(one + 1, two - 1, three) +
		  (double(three) / double(one + two + three)) * doDP(one, two + 1, three - 1);

	dp[one][two][three] = res;
	return res;
}

int main() {
	dp.assign(304,vector<vector<double>>(304, vector<double>(304, -1.0)));

	cin.sync_with_stdio(0);

	cout << fixed << setprecision(12);

	cin >> n;

	FOR(i, 0, n) {
		ll num;
		cin >> num;
		plates[num]++;
	}

	cout << doDP(plates[1], plates[2], plates[3]);

}

Measured memory_bytes: 224128
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 5;
int N, T;
int arr[MAX_N];

void solve(){
    int i = 0;
    int sum = T;
    for(i = 0; i < N - 1; i++){
        if(arr[i] + T < arr[i + 1])
            sum += T;
        else
            sum += arr[i + 1] - arr[i];
    }
    cout << sum << "\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i = 0;
    cin >> N >> T;
    for(i = 0; i < N; i++)
        cin >> arr[i];
    solve();
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int N=in.nextInt();
			if(N==0)
				return;
			char c[]=in.next().toCharArray();
			int a[]=new int[N];
			int b[]=new int[N];
			for(int i=0;i<N;i++)
			{
				a[i]=in.nextInt();
				b[i]=in.nextInt();
			}
			for(int i=N-1;i>=0;i--)
				swap_cipher(a[i],b[i],c);

			for(int i=0;i<c.length-1;i++)
				System.out.print(c[i]);
			System.out.println(c[c.length-1]);
		}
	}

	static void swap_cipher(int a,int b,char c[])
	{
		int key=b-a;
		int A=(int)c[a-1];
		int B=(int)c[b-1];
		while(key-->0)
		{
			++A;
			++B;
			if(A==123)
				A=97;
			if(B==123)
				B=97;
		}
		c[a-1]=(char)B;
		c[b-1]=(char)A;
	}
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 23332