akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

}

signed main() {
	ll n, k;
	string s;

	cin >> n >> k >> s;

	if (s[k - 1] == 'A') {
		s[k - 1] = 'a';
	}
	else if (s[k - 1] == 'B') {
		s[k - 1] = 'b';
	}
	else {
		s[k - 1] = 'c';
	}

	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int H,W,D,Q;
  cin>>H>>W>>D;
  vector<pair<int,int>> A(H*W+1);
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++){
      int a;
      cin>>a;
      A[a].first=i,A[a].second=j;
    }
  vector<int> B(H*W+1);
  for(int i=D+1;i<=H*W;i++)B[i]=B[i-D]+abs(A[i].first-A[i-D].first)+abs(A[i].second-A[i-D].second);
  cin>>Q;
  while(Q--){
    int a,b;
    cin>>a>>b;
    cout<<B[b]-B[a]<<endl;
  }
}

Measured memory_bytes: 5264
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;

struct edge{int to, cap, rev;};

constexpr int MAX_V = 3e4;
vector< vector<edge> > G(MAX_V);
int level[MAX_V];
int iter[MAX_V];
int INF = 1e9;

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

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

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

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  int sx, sy, tx, ty;
  for(int i = 0; i < H; ++i){
    cin >> A[i];
    for(int j = 0; j < W; ++j){
      if(A[i][j] == 'S') sx = i, sy = j;
      if(A[i][j] == 'T') tx = i, ty = j;
    }
  }
  if(sx == tx or sy == ty){
    cout << -1 << endl;
    return 0;
  }
  int s = 2*H*W, t = s+1, M = H*W;
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(A[i][j] != 'o') continue;
      add_edge(i*W+j,i*W+j+M,1);
      if(i == sx or j == sy)
        add_edge(s,i*W+j,INF);
      if(i == tx or j == ty)
        add_edge(i*W+j+M,t,INF);
      for(int k = 0; k < H; ++k){
        if(i == k) continue;
        if(A[k][j] != 'o') continue;
        add_edge(i*W+j+M,k*W+j,INF);
      }
      for(int k = 0; k < W; ++k){
        if(j == k) continue;
        add_edge(i*W+j+M,i*W+k,INF);
      }
    }
  }
  cout << max_flow(s,t) << endl;
}


Measured memory_bytes: 62976
/*
 * Author: madlogic
 * It's better to do something than nothing
*/
#include <bits/stdc++.h>
using namespace std;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define int long long
const int INF = 1000000000;
const int MOD = 1000000007;
const double PI = 2*acos(0.0);
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	map<int,int> freq;
	for(int i=0;i<n;i++)
		freq[a[i]-1]++,freq[a[i]]++,freq[a[i]+1]++;
	int ans = a[0];
	map<int,int>::iterator it;
	for(it = freq.begin(); it != freq.end(); it++)
		if(freq[it->first]>freq[ans])
			ans=it->first;
	int res = 0;
	for(int i=0;i<n;i++)
		res+=((abs(a[i]-ans)<=1)?1:0);
	cout<<res<<endl;
	return 0;	
}

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

int main(){
  int x, y;
  while(cin >> x >> y){
    if(x>y){
      int t;
      t = x;
      x = y;
      y = t;
      
    }
    if(x==0 && y==0){
      return 0;
    }
    else
      cout << x << " " << y << endl;
  }
  
}

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

signed main(){
    int n;cin>>n;
    int a[n][2];
    int dp[n+1][2];
    fill(dp[0],dp[n],0);
    rep(i,2)rep(j,n)cin>>a[j][i];
    rep(i,n){
        dp[i+1][0]=dp[i][0]+a[i][0];
        dp[i+1][1]=max(dp[i][0]+a[i][0],dp[i][1])+a[i][1];
    }
    cout<<max(dp[n][0],dp[n][1])<<endl;
}

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

int main(){
  
  int D;
  
  cin >> D;
  
  if(D == 25){
    cout << "Christmas" << endl;
  }
  
  if(D == 24){
    cout << "Christmas Eve" << endl;
  }
  
  if(D == 23){
    cout << "Christmas Eve Eve" << endl;
  }
  
  if(D == 22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;

  long kashi = b;
  if(a > b)kashi = a;

  long i = 1;
  long ori_kashi = kashi;
  while(1){
    if(kashi%a == 0 && kashi%b == 0)break;
    i++;
    kashi = ori_kashi*i;
    
  }
  cout << kashi << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
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() {
  string s;
  cin>>s;
  bool ja=true;
  rep(i,len(s)){
    if(i%2==0){
      if(s[i]=='L') ja=false;
    }
    if(i%2==1){
      if(s[i]=='R') ja=false;
    }
  }
  if(ja) yn;
}

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

int main(void) {
	double x1, y1, x2, y2;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	printf("%lf\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
	return 0;
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  double ans = 0;
  for (int i = 1; i <= N; i++)
  {
    double tmp = 1.0 / N;
    int now = i;
    while (now < K)
    {
      now *= 2;
      tmp /= 2;
    }
    ans += tmp;
  }
  cout << setprecision(12) << ans << endl;
}


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


int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  int cnt = 0;
  int x;
  int res = 0;
  for(int i = 0;i < n;i++){
    scanf("%d", &x);
    if(x == i + 1){
      cnt++;
    }else{
      res += (cnt + 1) / 2;

      cnt = 0;
    }
  }
  res += (cnt + 1) / 2;
  cout << res;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
  int n;
  long int h,w;
  scanf("%d%ld%ld",&n,&h,&w);
  long int a[n],b[n];
  int i,cnt=0;
  for(i=0;i<n;++i)
  {
    scanf("%ld%ld",&a[i],&b[i]);
    if(a[i]>=h && b[i]>=w)
         cnt++;
  }
  
  printf("%d",cnt);
}

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

public class Main {

	int INF = 1 << 28;
	void run() {
		Scanner sc = new Scanner(System.in);
		int horse[] = {4, 1, 4, 1, 2, 1, 2, 1};
		int ans[] = {7,2,6,0,4,1,5,3};
		while(sc.hasNext()) {
			int[] human = new int[8];
			int maxhuman = 0;
			for(int i=0;i<8;i++) {
				human[i] = sc.nextInt();
				maxhuman += human[i];
			}
			int minhuman = maxhuman;
			int p=0;
			for(int i=0;i<8;i++) {
				int sum = 0;
				for(int j=0;j<8;j++) {
					sum += human[j] - min(horse[(i+j)%8], human[j]);
				}
				if(minhuman > sum ) {
					 p = i;
					minhuman = sum;
				}
				else if(minhuman == sum && ans[p] >= ans[i]) {
					p = i;
				}
				
			}
			System.out.print((horse[p]));
			for(int i=1;i<8;i++) System.out.print(" " + horse[(p+i)%8]);
			System.out.println();
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
S = input()
pre = int(S[:2])
post = int(S[2:])

if 1<=pre<=12 and 1<=post<=12:
  print('AMBIGUOUS')
elif 1<=pre<=12:
  print('MMYY')
elif 1<=post<=12:
  print('YYMM')
else:
  print('NA')


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

using namespace std;
#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__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll dp[110][110000];

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

  int N, W;
  cin >> N >> W;
  vector<P> V(N);  

  ll w, v;
  rep(i, N){
    cin >> w >> v;
    V[i] = P(w, v);
  }

  rep(i, N+1){
    for(int j = 0; j <= 100100; j++){
      dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;

  rep(i, N){
    for(int j = 0; j <= 100100; j++){
      
      if(dp[i][j] < INF){
        chmin(dp[i+1][j], dp[i][j]);
        chmin(dp[i+1][j+V[i].second], dp[i][j] + V[i].first);
      }
    }
  }

  ll ans = 0;
  for(ll j = 0; j <= 100100; j++){
    if(dp[N][j] <= W){
      chmax(ans, j);
    }
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long ll;

using namespace std;

int nC2(int n) {
    if (n < 2) {
        return 0;
    }
    return n * (n - 1) / 2;
}

int main() {
    int N, M;
    cin >> N;
    cin >> M;
    cout << nC2(N) + nC2(M) << endl;
    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 n = sc.nextInt();
        int r = sc.nextInt();

        while(n != 0 || r != 0) {

            int[] card = new int[n + 1];

            card[0] = 0;

            for (int i = n; i > 0; i--)
                card[i] = i;

            for (int i = 0; i < r; i++) {
                int[] suffledCard = new int[n + 1];
                for (int l = n; l > 0; l--)
                    suffledCard[l] = l;
                suffledCard[0] = 0;

                int p = sc.nextInt();
                int c = sc.nextInt();
                int k = n;

                for (int j = n - (p - 1); j > n - (c + p - 1); j--)
                    suffledCard[k--] = card[j];
                for (int j = n; j > n - (p - 1); j--)
                    suffledCard[k--] = card[j];
                for (int j = n - (c + p - 1); j > 0; j--)
                    suffledCard[k--] = card[j];

                card = suffledCard;
            }

            System.out.println(card[n]);

            n = sc.nextInt();
            r = sc.nextInt();
        }

        sc.close();
    }
}


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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

int main() {
  ll k;
  cin >> k;
  ll ans = 0;
  
  rep(a,k+1){
    rep(b,k+1){
      rep(c,k+1){
        ans += gcd(gcd(a,b),c);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int N=sc.nextInt();
		String S=sc.next();
		
		if(N%2==0) {
			String t=S.substring(0,N/2);
			String tt=S.substring(N/2,N);
		
			if(tt.equals(t)) {
				p("Yes");
			}else p("No");
			
			
		}else {
			p("No");
		}
		
		
	}
	
		
	
	
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


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

int main() {

    int N;
    int K;
    char s[50];
    std::cin >> N >> K >> s;
    std::string tmp = std::string(s);

    if(std::islower(s[K-1])){
        s[K-1] = toupper(s[K-1]);
    }else {
        s[K-1] = tolower(s[K-1]);
    }

    std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 1)
# 後ろからボールの有無を決定
for i in range(n, 0, -1):
    cnt = sum(b[::i])
    # 条件と異なるならボールを投入
    if cnt % 2 != a[i - 1]:
        b[i] = 1
m = sum(b)
print(m)
for i in range(1, n + 1):
    if b[i]:
        print(i, end=' ')


Measured memory_bytes: 8380
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int a,b;cin>>a>>b;
  cout<<ceil((double)(b-1)/(double)(a-1))<<endl;
 

  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    static long ans = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<List<int[]>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            List<int[]> list2 = new ArrayList<>();
            for (int j = 0; j < a; j++) {
                int[] aa = new int[2];
                int x = Integer.parseInt(sc.next()) - 1;
                int y = Integer.parseInt(sc.next());
                aa[0] = x;
                aa[1] = y;
                list2.add(aa);
            }
            list.add(list2);
        }
        int ans = 0;
        f:
        for (int i = 0; i < (1 << n); i++) {
            for (int j = 0; j < list.size(); j++) {
                if ((i & (1 << j)) == 0) {
                    continue;
                }
                List<int[]> tmpAry = list.get(j);
                for (int k = 0; k < tmpAry.size(); k++) {
                    int[] tmp = tmpAry.get(k);
                    int num = tmp[0];
                    int bit = tmp[1];
                    if ((i >> num & 1) != bit) {
                        continue f;
                    }
                }
            }
            ans = Math.max(ans, Integer.bitCount(i));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   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;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
 lint dp[200005][2];
  int main(){
    string s;
    cin>>s;
  lint n=s.size();
  dp[1][0]=dp[2][1]=1;
  repp(i,2,n+1){
      if(s[i-1]!=s[i-2]){
          dp[i][0]=max(dp[i][0],dp[i-1][0]+1);
      }
      if(i>3&&s[i-1]!=s[i-3]||s[i-2]!=s[i-4])dp[i][1]=max(dp[i][1],dp[i-2][1]+1);
      dp[i][0]=max(dp[i][0],dp[i-1][1]+1);
      dp[i][1]=max(dp[i][1],dp[i-2][0]+1);
  }
  cout<<max(dp[n][0],dp[n][1]);
  }

  
     
  

Measured memory_bytes: 4612
#include <iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include <numeric>
#include<cmath>
#include<string>
using namespace std;
#define ll long long
typedef pair<ll,ll>P;

int main(void){
    int n,m;
    cin >> n>>m;
    vector<P>drink(n);
    for(int i=0;i<n;i++){
        cin >> drink[i].first>>drink[i].second;
        // cout << drink[i].first<< ' '<< drink[i].second<<endl;
    }
    sort(drink.begin(),drink.end());

    // for(int i=0;i<n;i++){
    //     cout << drink[i].first<< ' '<< drink[i].second<<endl;
    // }

    int cnt =0;
    ll ans =0;

    for(int i=0;i<n;i++){
        if(drink[i].second+cnt<=m){
            cnt += drink[i].second;
            ans += drink[i].first*drink[i].second;
        }else{
            ans += drink[i].first*(m-cnt);
            break;
        }
    }
    cout << ans << endl;


}

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

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

    int n, k;
    long long count = 0;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);
    sort(h.begin(), h.end());
    rep(i, n - k) count += h.at(i);
    cout << count << endl;

    return 0;
}

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

using namespace std;

int main() {
	int N, p[1100] = {};
	int K, sum = 0, min = 2000000;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	sort(p, p + N);

	for (int i = 0; i < K; i++) {
		sum += p[i];
	}
	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 3576
n = str(input())
n_list = list(reversed(n))
n_list.append('0')
sum = 0
kuriagari = False
for i in range(len(n_list)):
    num = int(n_list[i])
    if(kuriagari):
        num+=1
        kuriagari=False
    
    if(num==10):
        num=0
        kuriagari=True

    if(num<5):
        sum+=num
    else:
        if(num>5):
            sum+=10-num
            kuriagari=True
        else:
            sum+=5
            if(int(n_list[i+1])>=5):
                kuriagari=True

print(sum)




Measured memory_bytes: 17668
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int a,b;
	string s, t,u;
	cin >>s>>t;
	cin >> a >> b;
	cin >> u;
	if (s == u) cout << a - 1 << " " << b;
	else cout << a  << " " << b-1;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int i;
	int a[200005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = k; i < n; i++)
	{
		if (a[i] <= a[i - k])
			printf("No\n");
		else
			printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 2440
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let k: i64 = sc.cin();
    let x: i64 = sc.cin();
    let a = (x-k+1..x+k).collect::<Vec<_>>();
    put!(..a);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	int A = 0;
	int B = 0;
	int C = 0;
	rep(i, 3) {
		if (S[i] == 'a') {
			A++;
		}
		if (S[i] == 'b') {
			B++;
		}
		if (S[i] == 'c') {
			C++;
		}
	}
	if (A == 1 && B == 1 && C == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<long long> a(N);
  int twb=0;
  int fourb=0;
  for(int i=0; i<N; i++){
    cin >> a.at(i);
    if(a.at(i)%4==0) fourb++;
    else if(a.at(i)%2==0) twb++;
  }
  string ans="No";
  if(fourb>=N/2) ans="Yes";
  if(fourb>=(N-twb+1)/2) ans="Yes";
  if(N==twb) ans="Yes";
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;

const long long INF=9000000000000000;
int main(){
  long long n,ans=0;
  cin>>n;
  long long a[n];
  long long b[n];
  long long c[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++){
    cin>>c[i];
  }
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  for(int i=0;i<n;i++){
    ans+=1*(lower_bound(a,a+n,b[i])-a)*(c+n-upper_bound(c,c+n,b[i]));
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main(void){
    int a, b, c;

    cin >> a >> b >> c;

    if(c > b){
        int tmp = b;
        b = c;
        c = tmp;
    }

    if(b > a){
        int tmp = a;
        a = b;
        b = tmp;
    }

    if(c > b){
        int tmp = b;
        b = c;
        c = tmp;
    }

    // cout << a << b << c;
    string abc = to_string(a) + to_string(b) + to_string(c);
    // string _a = to_string(abc[0]);
    string ab = to_string(a) + to_string(b);
    int n = stoi(ab);

    cout << n + c << endl;

    return 0;
}

Measured memory_bytes: 256
/*input
STOP
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn],arr2[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	map<char,int> mp;
	for(int i=0;i<4;i++){
		char x;
		cin>>x;
		mp[x]++;
	}
	int cnt=0;
	for(auto z:mp){
		if(z.second==2){
			++cnt;
		}
	}
	if(cnt==2) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

public static void main(String[] args){

	Scanner scanner = new Scanner(System.in);

	int a = scanner.nextInt();
	int b = scanner.nextInt();

	if( a > b ){
	System.out.println("a > b");
	}
	 if ( a < b ){
	System.out.println("a < b");
	}
	 if ( a == b ){
		System.out.println("a == b");
	}
  }
}

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

int main() {
	int n, a ,b , p[3] = {};
	cin >> n >> a >> b;

	for (int i = 0; i < n; ++i){
		int pt;
		cin >> pt;
		if(pt <= a) p[0]++;
		else if(pt > a && pt <= b) p[1]++;
		else p[2]++;
	}

	cout << min(min(p[0], p[1]), p[2]) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int data_n,i,j;
	char words[1001];
	
	
	scanf("%d",&data_n);
	getchar();
	
	for(i=0;i < data_n;i++){
		scanf("%[^\n]",words);
		getchar();
		for(j=0;words[j] != '\0';j++){
			if(words[j] == 'H'){
				if(words[j+1] == 'o' &&
				   words[j+2] == 's' &&
				   words[j+3] == 'h' &&
				   words[j+4] == 'i' &&
				   words[j+5] == 'n' &&
				   words[j+6] == 'o'){
					words[j+6] = 'a';
				}
			}
		}
		printf("%s\n",words);
	}
	return 0;
}

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

#define fast ios_base::sync_with_stdio; cin.tie(0); cout.tie(0)
#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
//#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;

vector<vector<int>> v;
vector<int> value,ans;
vi ar;

void dfs(int i,int j){
    int temp,ind=-1;
    auto it = lower_bound(ar.begin(), ar.end(), value[i]);
    if (it == ar.end()){
        ar.push_back(value[i]);

    }
    else {
        ind=it-ar.begin();
        temp=*it;
        *it = value[i];
    }

      ans[i]=ar.size();
    for(auto u:v[i]){
      if(u==j){
        continue;
      }
      dfs(u,i);
    }
    if(ind==-1){
        ar.pop_back();
    }
    else{
        ar[ind]=temp;
    }
}

int main()
{fast;
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 #endif
 int t=1,n,a,b;
 //cin>>t;
 while(t--)
 {cin>>n;
  v.resize(n+1);
  value.resize(n+1);
  rep(i,0,n){
    cin>>value[i+1];
  }
  rep(i,0,n-1){
    cin>>a>>b;
    v[a].pb(b);
    v[b].pb(a);
  }
  ans.resize(n+1);
  ans[1]=1;
  dfs(1,0);
  rep(i,1,n+1){
    cout<<ans[i]<<endl;
  }
 }
 return 0;
}


Measured memory_bytes: 27156
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

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

	map<int, int> Q;
	int N, M;
	bool flg = true;

	cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		Q[tmp]++;
	}

	cin >> M;
	for (int i = 0; i < M; i++) {
		int tmp;
		cin >> tmp;
		Q[tmp]--;
		if(Q[tmp]<0){
			flg = false;
		}
	}

	YN(flg);

	return 0;
}

Measured memory_bytes: 9600
# 2020/07/25
# M-SOLUTIONS プロコンオープン 2020 - C

# Input
n, k = map(int,input().split())
a = list(map(int,input().split()))

# Calc
for i in range(k, n):
    # Output
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 31568
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   998244353;
ll n,k;
ll pre[N],dp[N];int l[30],r[30];
int main()
{  fast
cin>>n>>k;
for(int i=1;i<=k;i++)
cin>>l[i]>>r[i];
pre[1]=dp[1]=1;
for(int i=2;i<=n;i++){
for(int j=1;j<=k;j++){
	if(i<=l[j])continue;
	int x=l[j];
	int y=min(i-1,r[j]);
	(dp[i]+=(pre[i-x]-pre[i-y-1]+mod))%=mod;
	
}pre[i]=(pre[i-1]+dp[i])%mod;
}
cout<<dp[n];
}

Measured memory_bytes: 6732
S = input()
T = input()

len_s, len_t = len(S), len(T)
l = []
for i in range(len_s - len_t + 1):
    tmp = 0
    for j in range(len_t):
        if S[i+j] != T[j]:
            tmp += 1
    l.append(tmp)
print(min(l))

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
#define print(x) cout<<'>'<<#x<<':'<<x<<endl;
#define F first
#define S second
const int mod=1000000007;

void solve(){
    int x,a,b;
    cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;
}

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

    return 0;
}

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

struct P {
  int A, B;
};
constexpr unsigned long long max_magic_power {100000000000};

unsigned long long min_ull(const unsigned long long a, const unsigned long long b) {
  return (a<b)?a:b;
}

int main(int argc, char** argv) {
  int H, N;
  std::cin >> H >> N;
  std::vector<P> magic_list(N);
  for (auto& e : magic_list) std::cin >> e.A >> e.B;
  std::vector<unsigned long long> dp(H+1, max_magic_power);
  for (auto i = 0;i < N;++i) {
    for (auto j = 0;j <= magic_list[i].A && (j < H+1);++j) {
      dp[j] = min_ull(dp[j], magic_list[i].B);
    }
  }
  for (auto is_update = true;is_update == true;) {
    is_update = false;
    for (auto i = 0;i < N;++i) {
      for (auto j = magic_list[i].A;j < H+1;++j) {
        if (magic_list[i].B + dp[j-magic_list[i].A] < dp[j]) {
          dp[j] = magic_list[i].B + dp[j-magic_list[i].A];
          is_update = true;
        }
      }
    }
  }
  std::cout << dp[H] << '\n';
}


Measured memory_bytes: 888
import sys
import time
input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math

import heapq
import bisect
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**21


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def tasikame(n):
    ans = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n + 1):
                tmp = math.gcd(i, j)
                ans += math.gcd(tmp, k)

    return ans


def main():
    n, k = getlist()
    ans = 0
    kumi = [0 for i in range(k+1)]
    for ii in range(k):
        i = k - ii
        cand = k // i
        # 総数　ほう助なし
        tmp = pow(cand, n, MOD)
        # ttmp = i
        # print(tmp)
        # child = make_divisors(i)
        # for ch in child:
        #     kumi[ch] += tmp
        # while(True):
        #     ttmp += i
        #     if ttmp > k:
        #         break
        #     tmp -= kumi[ttmp]
            # print(tmp)
        tmp -= kumi[i]
        child = make_divisors(i)
        for ch in child:
            kumi[ch] += tmp
        # tmp -= (cand - 1) ** n
        ans += (tmp * i) % MOD
        ans %= MOD
        kumi[i] = tmp
        # print(i, ans, tmp, n)
    print(ans)
    # print(tasikame(k))

if __name__ == '__main__':
    main()


Measured memory_bytes: 75048
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),m = sc.nextInt(),q = sc.nextInt();
    int qu[][]=new int[q][4];
    int a[]=new int[n];
    for(int i=0;i<q;i++){
      for(int j=0;j<4;j++){
        qu[i][j]=sc.nextInt();
      }
    }

    pl(search(n-1,0,m,a,qu,0)+"");
  }

  public static int search(int n,int now,int max,int a[],int qu[][],int high){
    int min=0;
    if(now==0){min=1;}else{min=a[now-1];}
    for(int i=min;i<=max;i++){
      a[now]=i;
      if(now==n){
        int score=0;
        for(int j[]:qu){
          if(a[j[1]-1]-a[j[0]-1]==j[2]){
            score+=j[3];
          }
        }
        high = Math.max(high,score);
      }else{
        high = search(n,now+1,max,a,qu,high);
      }
    }
    return high;
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Measured memory_bytes: 39128
main = interact $ unlines . map (show . chebyshev . read) . init . lines

chebyshev n = length $ takeWhile (<= 2*n) $ dropWhile (<= n) primes

primes = 2:3:[x | i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x]
 where isPrime n = null [i | i<-takeWhile (\x -> x*x <= n) primes, rem n i == 0]

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

int main() {
	int k,x;
	cin>>k>>x;
	for(int i=1;i<=k-1;i++)
	{
	    cout<<x-k+i<<" ";
	}
	cout<<x<<" ";
	for(int i=1;i<=k-1;i++)
	{
	    cout<<x+i<<" ";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
	string s;cin >> s;
	int ans=0;
	string t="";
	string r="";
	for(int i=0;i<s.size();i++){
		t+=s[i];
		if(r!=t){
			ans++;
			r=t;
			t="";
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a,b,c,d = na()
if b <= c or d <= a:
    print(0)
else:
    if a <= c:
        if b >= d:
            print(d-c)
        else:
            print(b-c)
    else:
        if d <= b:
            print(d-a)
        else:
            print(b-a)


Measured memory_bytes: 3060
n,k = [int(x) for x in input().split()]
d = []
a = []
for i in range(k):
  d.append(int(input()))
  a.append([int(x) for x in input().split()])
#print(a)
ans = [0] * (n + 1)
for i in range(k):
  for j in range(d[i]):
    #print(a[i][j])
    ans[a[i][j]] += 1
c = 0
for i in range(1,n + 1):
  if ans[i] == 0:
    c += 1
print(c)

Measured memory_bytes: 9184
n = gets.to_i

n.times do
  arr = gets.split(' ').map(&:to_i)

  left, right = [], []
  arr.each do |a|
    if (left.last || 0) < a
      left.push(a)
    elsif (right.last || 0) < a
      right.push(a)
    else
      break
    end
  end

  puts (left.size + right.size == arr.size) ? 'YES' : 'NO'
end

Measured memory_bytes: 8584
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N; cin >> N;
	set<int> s;
	rep(i, N) {
		int a; cin >> a;
		s.insert(a);
	}
	cout << (s.size() == N ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 13008
#include<stdio.h>
int main(void)
{
   int n, i;
   int f, l;
   int num = 0;

   scanf("%d", &n);

   for(i = 0; i < n; i++){
      scanf("%d %d", &f, &l);
      num += l - f  + 1;
   }
   
   printf("%d", num);

   return 0;

}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	const int MAX_M = 10000;
	int N, M, p;
	int d[MAX_M];
	int cut, dis, Mcut;//Muximum cut value
	
	scanf("%d%d%d", &N, &M, &p);
	for(int i = 0; i < M; i++){
		scanf("%d", &d[i]);
	}
	
	for(int i = 0; i < M; i++){
		d[i] -= p;
		if(d[i] < 0) d[i] += N;
	}
	
	sort(d, d + M);
	
	Mcut = d[0] - 1;
	for(int i = 0; i < M - 1; i++){
		cut = d[i + 1] - d[i] - 1;
		if(d == 0) continue;
		dis = min(d[i], N - d[i + 1]);
		if(cut - dis > Mcut) Mcut = cut - dis;
	}
	if(N - d[M - 1] - 1 > Mcut) Mcut = N - d[M - 1] - 1;
	
	printf("%d\n", (N - 1 - Mcut) * 100);
	
	return 0;
}

Measured memory_bytes: 1080
(defparameter N (read))
(defparameter lst
  (make-array N
              :initial-contents
              (loop repeat N collect (read))))

(defun drop (lst)
  (loop with tmp = 10000000
        with count = 0
        for i from 0 below N
        if (> tmp (aref lst i))
        do (setf tmp (aref lst i))
           (incf count)
        finally (return count)))

(format t "~A" (drop lst))

Measured memory_bytes: 59752
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(X: int):
    i = 1
    while i * (i + 1) // 2 < X:
        i += 1
    ret = i
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
const long mod=1e9+7;
int N,K,A;
long dp[101][256];
main()
{
	cin>>N>>K;
	dp[0][0]=1;
	for(int i=0;i<N;i++)
	{
		cin>>A;
		for(int j=i;j>=0;j--)for(int k=0;k<256;k++)
		{
			(dp[j+1][k^A]+=dp[j][k]*(j+1))%=mod;
		}
	}
	long ans=0;
	for(int j=0;j<=N;j++)ans+=dp[j][K];
	cout<<ans%mod<<endl;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a, b;
int main() 
{
    cin>>n>>a>>b;
    if(a>b) swap(a,b);
    if((b-a)%2==0) cout<<(b-a)/2<<endl;
	else cout<<min((a-1),(n-b))+(b-a)/2+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<stdlib.h>
using namespace std;
signed main(void){
double N,A,T;
double a,i,j=0;
double x;
double H,y=999999999;

cin >>N;
cin >>T;
cin >>A;
for (i=1;i<=N;i++){
 cin >> H;
 x = T - H*0.006 - A;
if(x<0){x=(-1)*x;}
if(y>x){ j=i;y=x; }
}

cout <<j<<endl;
return 0;
}

Measured memory_bytes: 256
#include    <iostream>
#include <stdio.h>
#define     MAX_N   10000
using namespace std;

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    printf("%d %d %d\n",a,b,c);
    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

/*vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, m, r;
string s;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	ll val = 0,ans= 0;
	while(n) {
		ans += pow(2,val);
		val++;
		n/=2;
	}
	cout<<ans;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3940