akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
bool checkPalidrome(string D)
{
    int N=D.size();
    for(int i=0;i<N;i++)
    {
        if(D[i]!=D[N-1-i])
            return false;
    }
    return true;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string S;
    cin>>S;
    int N=S.size();
    if (checkPalidrome(S) && checkPalidrome(S.substr(0,N/2)) && checkPalidrome(S.substr(N/2+1,N)))
        cout<<"Yes";
    else
        cout<<"No";
}

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

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

    string s;
    int k, n;
    cin >> n >> k >> s;
    s[k - 1] = s[k - 1] + 32;
    cout << s;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int k, i, count = 9;
	long a[1000000] = {0};

	scanf("%d", &k);

	for(i=0; i < 9; i++)
		a[i] = i+1;
	while(1) {
		if(k <= count) {
			printf("%ld", a[k-1]);
			return 0;
		}
		k -= count;
		count = 0;
		long new[1000000] = {0};
		for(int i=0; a[i]; i++)
			new[i] = a[i];
		for(i=0; new[i]; i++) {
			for(int j=-1; j <= 1; j++) {
				int d = new[i]%10 + j;
				if(d < 0 || d > 9)
					continue;
				a[count++] = 10*new[i] + d;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 15744
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
isOk = True
judge_border = 1/(4 * M) * sum(A)
for i in range(M):
  if A[i] < judge_border:
    isOk = False
    break

if isOk :
  print('Yes')
else:
  print('No')


Measured memory_bytes: 38384
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
ok = True
for i in range(n):
    if i == 0:
        a[i] -= 1
        continue
    if a[i] < a[i-1]:
        ok = False
        break 
    elif a[i] > a[i-1]:
        a[i] -= 1
print('Yes' if ok else 'No')

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

int main(void){
    long n;
    cin >> n;
    vector <long> a(n);
    for(long i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    long sum = 0;
    for(long i=0; i<n; i++){
        if(i%2==0){
            sum += a[n-1-i];
        }else{
            sum -= a[n-1-i];
        }
    }
    cout << sum << endl;
}


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

int main(){
    int X[] = {1,-1,0, 0} ;
    int Y[] = {0, 0,1,-1} ;
    int n , m ;
    cin >> n >> m ;
    char grid[n][m] ;
    bool vis[n][m] ;
    pair<int,int> parent[n][m] ;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> grid[i][j] ;
            vis[i][j] = false ;
        }
    }
    queue<pair<int,int> > q ;
    q.push({0,0});
    vis[0][0] = true ;
    parent[0][0] = {0,0} ;
    while(q.size()){
        auto f = q.front() ; q.pop() ;
        int x = f.first ;
        int y = f.second ;
        for(int i=0;i<4;i++){
            if ( X[i] + x >= 0 && X[i] + x < n && Y[i] + y >= 0 && Y[i] + y < m && grid[X[i]+x][Y[i]+y] == '.' && !vis[X[i]+x][Y[i]+y]){
                vis[X[i]+x][Y[i]+y] = true ;
                parent[X[i]+x][Y[i]+y] = {x,y} ;
                q.push({X[i]+x,Y[i]+y});
            }
        }
    }
    if ( !vis[n-1][m-1] ){
        cout << -1 << endl;
    }
    else{
        int white = 0 ;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if ( grid[i][j] == '.' ) white++;
            }
        }
        pair<int,int> start = {n-1,m-1} ;
        int cnt = 0 ;
        while(start != parent[start.first][start.second] ){
            cnt++ ;
            start = parent[start.first][start.second] ;
        }
        cout << white - cnt - 1 << endl;
    }
    return 0 ;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int M = nextInt();
        int D = nextInt();

        int count = 0;
        for(int i=1; i<=M; i++){
            for(int j=1; j<=D; j++){
                int d10 = j/10;
                int d1 = j-d10*10;
                if(d10>=2 && d1 >= 2 && d10*d1 == i) count++;
            }
        }

        println(count);
    }

    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 25172
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
cnt1 = 0
cnt2 = 0
cnt3 =0

for i in range(n):
    if p[i] <= a:
        cnt1 +=1
    elif a < p[i] <= b:
        cnt2+=1
    else:
        cnt3+=1
ans = min(cnt1,cnt2,cnt3)
print(ans)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int a[3][3];
int n,b;
vector<vector<bool>> f(3, vector<bool>(3, false));

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	REP(i, 3) {
		REP(j, 3) {
			cin >> a[i][j];
		}
	}
	cin >> n;
	REP(i, n) {
		cin >> b;
		REP(j, 3) {
			REP(k, 3) {
				if (b == a[j][k]) {
					f[j][k] = true;
				}
			}
		}
	}

	REP(i, 3) {
		bool ans = false;
		REP(j, 3) {
			if (!f[i][j])break;
			if (j == 2)ans = true;
		}
		if (ans) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	REP(i, 3) {
		bool ans = false;
		REP(j, 3) {
			if (!f[j][i])break;
			if (j == 2)ans = true;
		}
		if (ans) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	REP(i, 3) {
		if (!f[i][i])break;
		if(i==2) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	REP(i, 3) {
		if (!f[i][2-i])break;
		if (i == 2) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int max = 0;
		int workNum = 0;

		int culHeight = sc.nextInt();
		for(int i = 0;i < (n - 1);i++) {
			int nextHeight = sc.nextInt();

			if(culHeight < nextHeight) {
				max = (max < workNum) ? workNum : max;
				workNum = 0;
			}else {
				workNum++;
			}
			culHeight = nextHeight;
		}

		max = (max < workNum) ? workNum : max;
		System.out.println(max);
	}
}

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

#define rep1(i, a, n) for (int i = a; i < n; i++)
#define rep2(i, a, n) for (int i = n; i >= a; i--)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int N, A, B;
  long long ans;
  cin >> N >> A >> B;
  if (A > B || (A != B && N == 1)) {
    ans = 0;
  } else {
    long long min_s = B, max_s = A;
    rep1(i, 0, N - 1) {
      min_s += A;
      max_s += B;
    }
    ans = max_s - min_s + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = deque()


if n % 2 == 0:
    for i in range(n):
        if i % 2 != 0:  # 偶数なら前
            b.appendleft(a[i])
        else:
            b.append(a[i])
else:
    for j in range(n):
        if j % 2 == 0:  # 偶数なら後ろ
            b.appendleft(a[j])
        else:
            b.append(a[j])

print(*b)

Measured memory_bytes: 25416
def printNum(n):
    s = str(n)
    return("0"*(6-len(s))+s)
N,M=map(int,input().split())
id = [[] for i in range(N)]
for i in range(M):
    P,Y = map(int,input().split())
    id[P-1].append((Y,i))
for p in range(N):
    id[p].sort(key=lambda x: x[0])
answerlist = []
for p in range(N):
    for j in range(len(id[p])):
        year,i = id[p][j]
        answerlist.append((i,printNum(p+1)+printNum(j+1)))
answerlist.sort(key=lambda x: x[0])
for i,ans in answerlist:
    print(ans)


Measured memory_bytes: 42616
M, D = map(int, input().split())

ans = 0
for m in range(1, M+1):
    for d in range(22, D+1):
        d1 = d % 10
        if d1 < 2: continue
        d10 = d // 10
        if d10 < 2: continue
        if d1 * d10 == m:
            ans += 1

print(ans)


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll num;
  ll count=0;
  cin>>num;
  while(num!=0){
    out("Case "<<count+1<<": "<<num);
    count++;
    cin>>num;

  }

  return 0;
}



Measured memory_bytes: 2976
#include <stdio.h>
#include <string.h>

void swap(char *a, char *b)
{
        char tmp = *a;
        *a = *b;
        *b = tmp;
}

void reverse(char *str)
{
        int first = 0, last = strlen(str) - 1;
        while (first < last) {
                swap(&str[first], &str[last]);
                first++;
                last--;
        }
}

int main(void)
{
        char str[100];
        scanf("%s", str);
        reverse(str);
        puts(str);
        return 0;
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)
#define INF 1e9
const int MOD = 1000000007;
typedef pair<ll,ll> P;

ll divs(ll n){
    ll cnt = 0;
    for(ll i = 1; i * i <= n; ++i){
        if(n % i == 0){
            cnt ++;
            if(n/i != i) cnt++;
        }
    }
    return cnt;
}

int main(void){
    ll n,ans = 0;
    cin >> n;
    for(ll a = 1; a < n; ++a){
       ll b = n / a;
       if(a * b >= n) b--;
       ans += b;

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

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,A[200005];
signed main(){
	cin>>N;
	int sum=0;
	rep(i,N){
		cin>>A[i];
		sum+=A[i];
	}
	int ans=inf;
	int suml=0;
	rep(i,N){
		suml+=A[i];
		int sumr=sum-suml;
		ans=min(ans,max(suml,sumr)-min(suml,sumr));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5128
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
using namespace std;
 
int H,W,N;

int ans = 0;
 
void solve(){
	int bigger = max(H,W);
	ans = (N-N%bigger)/bigger + 1*(N%bigger!=0);
}
 
int main(){
	cin>>H>>W>>N;

	solve();

	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
main(){double d;while(cin>>d){cout<<((d<=48)?"light fly":((d<=51)?"fly":((d<=54)?"bantam":((d<=57)?"feather":((d<=60)?"light":((d<=64)?"light welter":((d<=69)?"welter":((d<=75)?"light middle":((d<=81)?"middle":((d<=91)?"light heavy":"heavy"))))))))))<<endl;}}

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

int main(){
    int n;
    cin >> n;
    long long ans = 0;
    
    for (int i = 1; i <= n; i++) {
        long long buf = n / i;
        long long bufsum = (1 + buf) * buf / 2;
        ans += i * bufsum;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3548
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int par[100005];
int w[100005];
int p[100005];

int find(int at) {
	if (p[at] == at) return at;
	return p[at] = find(p[at]);
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) p[i] = par[i] = i;

	while (m--) {
		int u, v;
		scanf("%d %d", &u, &v);
		if (find(u) != find(v)) {
			int _u = find(u);
			int _v = find(v);
			p[_u] = _v;
			par[_u] = _v;
		}
		w[u]++;
		w[v]++;
	}

	int ans = 1;
	for (int i = 1; i <= n; i++) {
		if (i == find(i)) {
		}
		else {
			if (w[i] % 2) ans = 0;
		}
	}
	if (ans) printf("YES\n");
	else printf("NO\n");

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	if(k == 0){
		cout << n * n << endl;
		return 0;
	}
	for(ll b = k+1; b < n+1; b++){
		ll add = 0;
		add = (n+1)/b * (b-k);
		ll temp = (n+1) -  (n+1)/b*b;
		if(temp > k) add += (temp - k);
		// cerr << b << " " << add << endl;
		ans += add;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split(" "))
A = [i for i in map(int, input().split(" "))]

hist = [-1 for i in range(N)]
route = []
loop = []

jump = 0
cur = A[0] - 1
route.append(0)
hist[0] = jump
while hist[cur] == -1:
    jump = jump + 1
    route.append(cur)
    hist[cur] = jump
    cur = A[cur] - 1

loop = route[hist[cur]:]

#print(cur, hist, route, loop)

if K < len(route):
    print(route[K] + 1)
else:
    K = K - len(route)
    #print(K)
    K = K % len(loop)
    #print(K)
    print(loop[K] + 1)


Measured memory_bytes: 33960
#include<bits/stdc++.h>
using namespace std;
vector<int> to[100005];

void bfs(int n){
	queue<int> q;
  	vector<int> dist(n,-1);
  	vector<int> pre(n,-1);
  
  	q.push(0);
  	dist[0]=0;
  
  	while(!q.empty()){
    	int v=q.front();q.pop();
      	for(int u: to[v]){
        	if(dist[u]!=-1) continue;
          	dist[u]=dist[v]+1;
          	pre[u]=v;
          	q.push(u);
        }
    }
  	cout << "Yes" << endl;
  	for(int i=1;i<n;++i){
      		cout << pre[i]+1 << endl;
    }
}

int main(){
	int n,m;
  	cin >> n >> m;
  	for(int i=0;i<m;++i){
    	int a,b;
      	cin >> a >> b;
      	--a;
      	--b;
      	to[a].push_back(b);
      	to[b].push_back(a);
    }
  
  	bfs(n);
  	return 0;
}

Measured memory_bytes: 10672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

map<int,int> prime_factor(int n){
    map<int,int> res;
    for (int i=2;i*i<=n;i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if (n!=1){
        res[n]=1;
    }
    return res;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll N,M;
    cin >> N >> M;
    map<int,int> prime=prime_factor(M);
    COMinit();
    ll ans=1;
    for (auto x:prime){
        ll a=x.second;
        ans=ans*COM(N-1+a,a)%MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
N, K = map(int, input().split())
*A, = map(int, input().split())

def get_k_bits():
    global K
    k_list = []
    while K:
        k_list.append(K%2)
        K//=2
    k_list.extend([0]*(50-len(k_list)))
    k_list.reverse()
    return k_list

def get_bits_count():
    b = [0]*50
    for i in A:
        p = 0
        while i:
            b[p] += i%2
            i //=2
            p += 1
    b.reverse()
    return b

b = get_bits_count()

def get_appropriate_bits():
    c = [0]*50
    for i in range(50):
        e, f = b[i], N-b[i]
        if e>=f:
            c[i] = 0
        else:            
            c[i] = 1
    return c

def output_candidates():
    candidates = []
    c = get_appropriate_bits()
    k_list = get_k_bits()

    for i in range(50):
        if k_list[i]:
            o = [k_list[j] for j in range(i)] + [0] + [c[j] for j in range(i+1, 50)]
            candidates.append(o)
    candidates.append(k_list)
    return candidates


ans = 0
for bits in output_candidates():
    v = 0
    for j in range(50):
        if bits[j]:
            v += (2**(50-j-1))*(N-b[j])
        else:
            v += (2**(50-j-1))*b[j]
    ans = max(ans, v)

print(ans)

Measured memory_bytes: 14620
N = int(input())
A = [int(input()) for i in range(N)]
A = sorted(A)
ans = 0
prev = A[0]
cnt = 0
for a in A:
    if prev == a:
        cnt += 1
        prev = a
    else:
        if cnt % 2 == 1:
            ans += 1
        cnt = 1
        prev = a
if cnt % 2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 8276
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    Q = int(input())
    ma = 10 ** 5 + 1
    dp = [0] * ma
    dp[2] = 1

    for i in range(3,ma,2):
        if dp[i] == 0:
            dp[i] = 1
            if dp[(i + 1) // 2] == 1 or dp[(i + 1) // 2] == 2:
                dp[i] = 2
            for j in range(i * 2,ma,i):
                dp[j] = 3

    ruiseki = [0] * ma

    for i in range(1,ma):
        if dp[i] == 2:
            ruiseki[i] = ruiseki[i-1] + 1
        else:
            ruiseki[i] = ruiseki[i-1]

    for _ in range(Q):
        l,r = map(int,input().split())
        print(ruiseki[r] - ruiseki[l-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 73068
#include <iostream>

using namespace std;

const int MAX_N = 100000;
bool P[MAX_N] = {false};

int main() {
    int n;
    cin >> n;
    int p;

    for (int i = 0; i < n; i++) {
        cin >> p;
        if (i == p - 1) {
            P[i] = true;
        }
    }

    int i = 0;
    int count = 0;
 
    while (i < n) {
        if (P[i] == true && P[i + 1] == true) {
            i += 2;
            count++;
        }
        else if (P[i] == true) {
            i++;
            count++;
        }
        else {
            i++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  int a,b;cin>>a>>b;
  cout<< (b-a)*(b-a+1)/2 -b<<endl;
  
}





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

using namespace std;

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

    int bucket[26] = {0};
    for (int i = 0; i < s.size(); i++) bucket[s[i]-'a']++;

    for (int i = 0; i < 26; i++) {
        if (bucket[i] == 0) {
            cout << (char)('a'+i) << endl;
            break;
        }
        if (i == 25) cout << "None" << endl;
    }
}

Measured memory_bytes: 512
#include<cctype>
#include<cstdio>

using namespace std;

int main()
{
	char a;
	while (1)
	{
		a = getchar();
		if (islower(a))
		{
			printf("%c", toupper(a));
		}
		else
		{
			printf("%c", tolower(a));
		}
		if (a == '\n') break;
	}
	return 0;
}

Measured memory_bytes: 2516
# 1 "d.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "d.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "d.cpp" 2

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    long long n, m;
    cin >> n >> m;
    vvi dp(2, vi(m+1));
    for(long long i=0; i<n; ++i){
        long long w, v;
        cin >> w >> v;
        for(long long j=1; j<=m; ++j){
            dp[0][j] = dp[1][j];
            if(j-w >= 0)
                dp[0][j] = max(dp[0][j], dp[1][j-w] + v);
        }
        swap(dp[0], dp[1]);
    }
    cout << dp[1][m] << "\n";
    return 0;
}


Measured memory_bytes: 2560
n, k = [int(_) for _ in input().split()]
d = {}
ans = 0
for i in range(k, 0, -1):
    # res = (k // i) ** n
    res = pow(k//i,n,(10**9+7))
    t = 2
    while i * t in d:
        res -= d[i * t]
        t += 1
    res = res % (10**9+7)
    d[i] = res
    ans += res * i
    ans = ans % (10**9+7)
print(ans)


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

int main() {
  long double N, K;
  cin >> N >> K;
  long double cnt=0;
  for(int i=1; i<=N; i++) {
    if(i>=K) {
      cnt++;
      continue;
    }
    else {
      for(int j=1; j<18; j++) {
        if(i*pow(2, j)>=K) {
          cnt+=1/pow(2, j);
          break;
        }
      }
    }
  }
  cout << setprecision(18) << cnt/N << endl;
}

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

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

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

int nl(int n) { return n==0?0:1+nl(n/10); }
int number_of_length(int n) { return n==0?1:nl(n); }
int ipow(int n, int r) { return r==0?1:n*ipow(n, r-1); }

void divide(int d, int t, int *l, int *r)
{
	*l = t/ipow(10, d);
	*r = t%ipow(10, d);
}

int calc(int t)
{
	int cnt = 0;

	vector<int> vs;
	for (;;) {
		sort(vs.begin(), vs.end());
		if (binary_search(vs.begin(), vs.end(), t)) {
			return -1;
		}
		vs.push_back(t);
		if (t < 10) return cnt;
		int ans = 0;
		REPI(d, 1, number_of_length(t)-1) {
			int l, r;
			divide(d, t, &l, &r);
			ans = max(ans, l*r);
		}
		cnt++;
		t = ans;
	}
}

int main(void)
{
	int n;

	cin >> n;
	rep(TTT, n) {
		int t;
		cin >> t;
		cout << calc(t) << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int max = 1;
	int min = 1000000000;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a > max) max = a;
		if (a < min) min = a;
	}
	cout << max - min << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  char str[1010];

  int i,sum;

  scanf("%s",str);

  while(str[0]!='0'){

  i=0;

  sum=0;

  while(str[i]){

sum+=str[i]-'0';

  i++;

  }

  printf("%d\n",sum);

  scanf("%s",str);

  }
return 0;

}

Measured memory_bytes: 536
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	int N, K; cin >> N >> K;
	V<ll> h(N), dp(N,LINF); REP(i, N) cin >> h[i];
	dp[1] = abs(h[1] - h[0]);
	dp[0] = 0;
	
	FOR(i,1,N){
		for(int j = i; i - K <= j && 0 <= j; --j){
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
		}
	}
		
	cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int H, W;
int alphabet[26];
int main() {
	cin >> H >> W;
	char alpha;
	while (cin >> alpha) {
		alphabet[(int)(alpha-'a')]++;
	}
	int index = 0;
	if (H % 2 == 0 && W % 2 == 0) {
		for (int i = 0; i < H/2; i++) {
			for (int j = 0; j < W/2; j++) {
				if (alphabet[index] >= 4) {
					alphabet[index] -= 4;
				} else {
					index++;
					j--;
				}
				if (index >= 26) break;
			}
			if (index >= 26) break;
		}
	} else if (H % 2 == 1 && W % 2 == 0) {
		for (int i = 0; i < H/2; i++) {
			for (int j = 0; j < W/2; j++) {
				if (alphabet[index] >= 4) {
					alphabet[index] -= 4;
				} else {
					index++;
					j--;
				}
				if (index >= 26) break;
			}
			if (index >= 26) break;
		}
		index = 0;
		for (int i = 0; i < W/2; i++) {
			if (alphabet[index] >= 2) {
				alphabet[index] -= 2;
			} else {
				index++;
				i--;
			}
			if (index >= 26) break;
		}
	} else if (H % 2 == 0 && W % 2 == 1) {
		for (int i = 0; i < H/2; i++) {
			for (int j = 0; j < W/2; j++) {
				if (alphabet[index] >= 4) {
					alphabet[index] -= 4;
				} else {
					index++;
					j--;
				}
				if (index >= 26) break;
			}
			if (index >= 26) break;
		}
		index = 0;
		for (int i = 0; i < H/2; i++) {
			if (alphabet[index] >= 2) {
				alphabet[index] -= 2;
			} else {
				index++;
				i--;
			}
			if (index >= 26) break;
		}
	} else {
		for (int i = 0; i < H/2; i++) {
			for (int j = 0; j < W/2; j++) {
				if (alphabet[index] >= 4) {
					alphabet[index] -= 4;
				} else {
					index++;
					j--;
				}
				if (index >= 26) break;
			}
			if (index >= 26) break;
		}
		index = 0;
		for (int i = 0; i < H/2; i++) {
			if (alphabet[index] >= 2) {
				alphabet[index] -= 2;
			} else {
				index++;
				i--;
			}
			if (index >= 26) break;
		}
		index = 0;
		for (int i = 0; i < W/2; i++) {
			if (alphabet[index] >= 2) {
				alphabet[index] -= 2;
			} else {
				index++;
				i--;
			}
			if (index >= 26) break;
		}
		for (int i = 0; i < 26; i++) {
			if (alphabet[i] == 1) {
				alphabet[i]--;
				break;
			}
		}
	}
	bool flg = true;
	for (int i = 0; i < 26; i++) {
		flg &= (alphabet[i] == 0);
	}
	if (flg) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N,A,B;
    cin >> N >> A >> B;
    if((B-A)%2==0) cout << "Alice" << endl;
    else cout << "Borys" << endl; 
}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;


bool isExp[1001];

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

  for(int i = 2; i <= 1000; i++) {
    int now = i * i;
    while(now <= 1000) {
      isExp[now] = 1;
      now *= i;
    }
  }

  int x;
  cin >> x;
  int ans = 1;
  for(int i = 1; i <= x; i++) {
    if(isExp[i]) ans = i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int,input().split())
S = [input() for i in range(H)]
dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1 if S[0][0] == "#" else 0
for i in range(1, H):
    if S[i][0] == "#":
        if S[i-1][0] == "#":
            dp[i][0] =  dp[i-1][0]
        else:
             dp[i][0] = dp[i-1][0] + 1
    else:
        dp[i][0] =  dp[i-1][0]

for j in range(1, W):
    if S[0][j] == "#":
        if S[0][j-1] == "#":
            dp[0][j] =  dp[0][j-1]
        else:
             dp[0][j] = dp[0][j-1] + 1
    else:
        dp[0][j] =  dp[0][j-1]

for i in range(1,H):
    for j in range(1,W):
        up = dp[i-1][j] + (1 if S[i-1][j] != "#" and S[i][j] == "#" else 0) 
        left = dp[i][j-1] + (1 if S[i][j-1] != "#" and S[i][j] == "#" else 0)
        dp[i][j] = min(up, left)
print(dp[-1][-1])

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

void Main() {
  int n, k;
  cin >> n >> k;

  double ans = 0;
  for (int i = 1; i <= n; i++) {
    int score = i;
    double tmp = 1.0;
    while (score < k) {
      score *= 2;
      tmp /= 2;
    }
    ans += tmp;
  }
  cout << ans / n << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

// フェルマーの小定理を使った計算
class Felmat
{
  ll M;
  vector<ll> fac;  // n! (mod M)
  vector<ll> ifac; // k!^{M-2} (mod M)

public:
  Felmat(ll max_nk, ll m)
  {
    M = m;
    fac.reserve(max_nk + 1);
    ifac.reserve(max_nk + 1);
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < max_nk; i++) {
      fac[i + 1] = fac[i] * (i + 1) % M;              // n! (mod M)
      ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M)
    }
  }
  ll mpow(ll x, ll n)
  { // x^n (mod M)
    ll ans = 1;
    while (n != 0) {
      if (n & 1)
        ans = ans * x % M;
      x = x * x % M;
      n = n >> 1;
    }
    return ans;
  }
  ll minv(ll a)
  { // 1/a (mod M)
    ll b = M, u = 1, v = 0;
    while (b) {
      ll tmp = a / b;
      a -= tmp * b;
      swap(a, b);
      u -= tmp * v;
      swap(u, v);
    }
    u %= M;
    if (u < 0)
      u += M;
    return u;
  }
  ll mfac(ll x)
  { // n! (mod M)
    int i;
    return fac[x];
  }
  ll comb(ll n, ll k)
  { // nCk (mod M)
    if (n == 0 && k == 0)
      return 1;
    if (n < k || n < 0)
      return 0;
    ll tmp = ifac[n - k] * ifac[k] % M;
    return tmp * fac[n] % M;
  }
  ll perm(ll n, ll k)
  { // nPk (mod M)
    if (n < k)
      return 0;
    ll tmp = ifac[n - k] % M;
    return tmp * fac[n] % M;
  }
};

ll f2(Felmat& fm, int n, int k)
{
  return fm.comb(n + k - 1, k - 1);
}

ll f(Felmat& fm, int n, int k)
{
  // if (n < k)
  //   return 0;
  // if (n == 0 && k == 0)
  //   return 1;
  // if (k < 1)
  //   return 0;
  return f2(fm, n - k, k);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  
  Felmat fm(4005, MOD);

  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= K; i++) {
    ll a = f(fm, K, i);
    ll b = f2(fm, N - K - (i - 1), i + 1);
    // ll a = fm.comb(N - K + i, i);
    // ll a = N - K + 2 - i;
    // ll b = fm.comb(K - 1, i - 1);
    dump(a, b);
    cout << a * b % MOD << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n;
    int a[100010];
    int ans = 0;

    cin >> n;

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

    for (int i = 0; i < n; i++) {
        if (i+1 == a[i]) {
            if (i+2 == a[i+1]) {
                i++;
                ans++;
            }
            else {
                ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;

class Main {
	public static void main(String... args) {
		int N = IN.nextInt();
		int M = IN.nextInt();
		int Q = IN.nextInt();

		int[][] A = new int[N + 1][N + 1];
		for (int i = 0; i < M; i++) {
			int l = IN.nextInt();
			int r = IN.nextInt();
			A[l][r] += 1;
		}
		
		for (int i = 1; i <= N; i++) {
			for (int j = i; j < N; j++) {
				A[i][j + 1] += A[i][j];
			}
		}

		for (int j = N; j >= 2; j--) {
			for (int i = j; i >= 2; i--) {
				A[i - 1][j] += A[i][j];
			}
		}

		for (int i = 0; i < Q; i++) {
			int pi = IN.nextInt();
			int qi = IN.nextInt();
			puts(A[pi][qi]);
		}
		flush();
	}
	static final Scanner IN = new Scanner(System.in);
	static final PrintWriter OUT = new PrintWriter(System.out);
	static <T> void puts(T arg) { OUT.println(arg); }
	static void flush() { OUT.flush(); }
}


Measured memory_bytes: 156440
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;

ll gcd(const ll sx, const ll sy) {
    ll x = min(sx, sy);
    ll y = max(sx, sy);
    ll tmp;
    while (x > 0) {
        tmp = y;
        y = x;
        x = tmp % x;
    }
    return y;
}

ll lcm(const ll x, const ll y) {
    return x / gcd(x, y) * y;
}

//ref. http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B&lang=jp
int main(void) {
    ll x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
int main(){
  int n,a[100],cnt=0,j,flag=1,tmp;

  scanf("%d",&n);

  for(j=0;j<n;j++) scanf("%d",&a[j]);

  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	flag=1;
	cnt++;
      }
    }
  }
  
  for(j=0;j<n-1;j++) printf("%d ",a[j]);

  printf("%d\n%d\n",a[n-1],cnt);

  return 0;
}



Measured memory_bytes: 2124
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n = read!(u64);
    let x: Vec<u64> = read!(u64; 5);

    // 律速段階となっている箇所だけで決まりそうな気がする
    let m = x.iter().min().unwrap();

    println!("{}", (n as f64 / *m as f64).ceil() as u64 + 4);
}


Measured memory_bytes: 4352
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int mod = 1_000_000_007;
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		ArrayList<ArrayList<Integer>> edge = new ArrayList<ArrayList<Integer>>();
		for (int i=0;i<N;i++) {
			ArrayList<Integer> list = new ArrayList<Integer>();
			edge.add(list);
		}
		for (int i=0;i<N-1;i++) {
			int a = Integer.parseInt(sc.next())-1;
			int b = Integer.parseInt(sc.next())-1;
			edge.get(a).add(b);
			edge.get(b).add(a);
		}
		int flag[] = new int[N];
		long ans = 1L;
		LinkedList<Integer> dfs = new LinkedList<Integer>();
		dfs.add(0);
		dfs.add(0);
		flag[0] = 1;
		ans *= K;

		while (dfs.size()>0) {
			Integer i = dfs.remove(0);
			Integer depth = dfs.remove(0);
			int j;
			if (depth==0) {
				j = -1;
			} else {
				j = 0;
			}
			for (Integer element : edge.get(i)) {
				if (flag[element] == 1) {
					continue;
				} else {
					flag[element] = 1;
					ans = ans * (K-2-j) % mod;
					j++;
					for (Integer element_2 : edge.get(element)) {
						if (flag[element_2] == 0) {
							dfs.add(element);
							dfs.add(depth+1);
							break;
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 72376
using System ;

namespace Program{
 class Program{
  static void Main(string []args){
   int N = int.Parse(Console.ReadLine());
    
   int []num = new int[N];
    
   string []buff = Console.ReadLine().Split(' ');
    
   for(int i = 0 ;i < N ;i++) num[i] = int.Parse(buff[i]);
    
   long max = 0 ;
   
   foreach(int n in num) max+= n-1;
    
   Console.WriteLine(max);
    
  }
 }
}

Measured memory_bytes: 11164
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int32_t main(){
	int k,s;
	cin>>k>>s;
	int ans = 0;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			if((s-i-j)<=k && (s-i-j)>=0){
				ans++;
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;
	cin >> s;

	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s.at(i)=='L'){
				cout << "No" << endl;
				return 0;
			}
		}
		else{
			if(s.at(i)=='R'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  final static long MOD = 1_000_000_007;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    sc.close();
    System.out.println(solve(s));
  }
  static long solve(int s){
    if(s < 3) {
      return 0;
    } else if(s < 6){
      return 1;
    }

    long[] dp = new long[s + 1];
    Arrays.fill(dp, 0);
    dp[3] = dp[4] = dp[5] = 1;
    for(int i = 6; i <= s; i++){
      dp[i] = dp[i - 1] + dp[i - 3];
      dp[i] %= MOD;
    }
    return dp[s];
  }
}


Measured memory_bytes: 35680
//By Vlgd
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
	Point operator + (Point p){return Point(x+p.x,y+p.y);}
	Point operator - (Point p){return Point(x-p.x,y-p.y);}
	Point operator * (double a){return Point(a*x,a*y);}
	Point operator / (double a){return Point(x/a,y/a);}
	double abs() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;
double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}
int ccw(Point p0,Point p1,Point p2){
	Vector a=p1-p0,b=p2-p0;
	if(cross(a,b)>EPS) return 0;
	if(cross(a,b)<-EPS) return 1;
	if(dot(a,b)<-EPS) return 2;
	if(a.abs()<b.abs()) return 3;
	if(a.abs()>=b.abs()) return 4;
}
main(){
	int x1,y1,x2,y2,q;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	Point p0(x1,y1),p1(x2,y2);
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d%d",&x1,&y1);
		Point p2(x1,y1);
		int ans=ccw(p0,p1,p2);
		if(ans==0) printf("COUNTER_CLOCKWISE");
		if(ans==1) printf("CLOCKWISE");
		if(ans==2) printf("ONLINE_BACK");
		if(ans==3) printf("ONLINE_FRONT");
		if(ans==4) printf("ON_SEGMENT");
		printf("\n");
	}
}


Measured memory_bytes: 3224
fun main(){
    val N = readLine()!!.toLong()
    var A = readLine()!!.split(" ").map { it.toLong() }.toMutableList()

    var total: Long = 0

    for(i in 1 until (A.size)){
        if(A[i] < A[i-1]){
            total += A[i-1] - A[i]
            A[i] += A[i-1] - A[i]
        }
    }
    println(total)
}

Measured memory_bytes: 68388
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
typedef pair<int,int> P;
const int INF=1000000000;
const int MOD_2=998244353;

int main()
{
	string s,t;
	cin>>s;
	int Q;
	cin>>Q;
	for(int i=0;i<Q;i++)
	{
		int T;
		cin>>T;
		if(T==1)swap(s,t);
		else
		{
			int F;char C;
			cin>>F>>C;
			if(F==1)t+=C;
			else s+=C;
		}	
	}
	reverse(t.begin(),t.end());
	cout<<t+s<<"\n";
	return 0;
}
	

Measured memory_bytes: 1248