akhauriyash/Code-Regression huggingface dataset:
# coding:utf-8
def recurcive(N,c):
    if N%2==0 and N!=0:
        c+=1
        return recurcive(int(N/2),c)
    else:
        return c
#print(recurcive(8,0))

N=int(input())
maxim=0

for i in range(1,N+1):
    if recurcive(i,0) > maxim:
        maxim=recurcive(i,0)
print(2**maxim)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int sum=1;
    int n=0;
    for(int i=1;i<S.length();i++){
        if(S[n]==S[i]){

        }else{
            n = i;
            sum++;
        }        
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		
	int[][] men = new int[100][7];
	int[] meng = new int[7];
	int[] kari = new int[7];
	int ue;
	int yoko;
	int c = 0;
		
	Scanner scan = new Scanner(System.in);
	
	int kai = scan.nextInt();
	
	for(int i=1; i<=6; i++){
		meng[i] = scan.nextInt();}
	for(int q=1; q<kai; q++){
	for(int i=1; i<=6; i++){
		men[q][i] = scan.nextInt();}}
		
	ue = meng[1];
	yoko = meng[2];
	
	for(int q=1; q<kai; q++){
		for(int i=1; i<=6; i++){
			if(men[q][i]==ue){
				if(i==2){
					kari[1] = men[q][1];		kari[2] = men[q][2];
					kari[5] = men[q][5];		kari[6] = men[q][6];
			
					men[q][1] = kari[2];		men[q][2] = kari[6];
					men[q][6] = kari[5];		men[q][5] = kari[1];
				}
				else if(i==3){
					kari[1] = men[q][1];		kari[3] = men[q][3];
					kari[4] = men[q][4];		kari[6] = men[q][6];
			
					men[q][1] = kari[3];		men[q][3] = kari[6];
					men[q][4] = kari[1];		men[q][6] = kari[4];
				}
				else if(i==4){
					kari[1] = men[q][1];		kari[3] = men[q][3];
					kari[4] = men[q][4];		kari[6] = men[q][6];
			
					men[q][1] = kari[4];		men[q][3] = kari[1];
					men[q][4] = kari[6];		men[q][6] = kari[3];
				}
				else if(i==5){
					kari[1] = men[q][1];		kari[2] = men[q][2];
					kari[5] = men[q][5];		kari[6] = men[q][6];
			
					men[q][1] = kari[5];		men[q][2] = kari[1];
					men[q][6] = kari[2];		men[q][5] = kari[6];
				}
				else if(i==6){
					kari[1] = men[q][1];		kari[2] = men[q][2];
					kari[5] = men[q][5];		kari[6] = men[q][6];
			
					men[q][1] = kari[2];		men[q][2] = kari[6];
					men[q][6] = kari[5];		men[q][5] = kari[1];
					
					kari[1] = men[q][1];		kari[2] = men[q][2];
					kari[5] = men[q][5];		kari[6] = men[q][6];
			
					men[q][1] = kari[2];		men[q][2] = kari[6];
					men[q][6] = kari[5];		men[q][5] = kari[1];
				}
			}
		}
		
		for(int k=0; k<4; k++){
			if(men[q][2]==yoko){
				break;
			}
			
			kari[1] = men[q][1];		kari[2] = men[q][2];
			kari[5] = men[q][5];		kari[6] = men[q][6];
			
			men[q][1] = kari[2];		men[q][2] = kari[6];
			men[q][6] = kari[5];		men[q][5] = kari[1];
			
			kari[1] = men[q][1];		kari[3] = men[q][3];
			kari[4] = men[q][4];		kari[6] = men[q][6];
			
			men[q][1] = kari[4];		men[q][3] = kari[1];
			men[q][4] = kari[6];		men[q][6] = kari[3];
			
			kari[1] = men[q][1];		kari[2] = men[q][2];
			kari[5] = men[q][5];		kari[6] = men[q][6];
			
			men[q][1] = kari[5];		men[q][2] = kari[1];
			men[q][6] = kari[2];		men[q][5] = kari[6];
		}
		
		for(int i=1; i<=6; i++){
			if(meng[i]!=men[q][i]){
				c++;
				break;
			}
		}
	}
			
		if(c+1==kai){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}


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

int main()
{
    long n,k,ans; cin>>n>>k;
    
    for(int i=1;i<1000;++i){
        if(n<pow(k,i)){
            ans=i;
            break;
        }
    }

	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	ll damages[222222]={0};
	ll N, D, A;
	cin >> N >> D >> A;
	vector<pair<ll, ll>> XH;
	REP(i, N){
		ll x, h;
		cin >> x >> h;
		XH.PB(MP(x, h));
	}
	sort(ALL(XH));
	ll r=0;
	ll nowhp;
	ll sum=0;
	//cout << endl;
	REP(i, N){
		while(r<N){
			if(XH[r].F-XH[i].F<=2*D){
				r++;
			}else{
				//cout << i << " " << r << endl;
				break;
			}
		}
		r--;
		nowhp = XH[i].S - damages[i];
		if(nowhp>0){
			ll num=(nowhp+A-1)/A;
			sum += num;
			damages[i]+=A*num;
			damages[r+1]-=A*num;
		}
		damages[i+1]+=damages[i];
	}
//	cout << endl;
	cout << sum << endl;
//	cout << endl;
//	REP(i, N){
//		cout << damages[i] << endl;
//	}
}


Measured memory_bytes: 8176
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ar=[0]*(n+1)
br=[0]*(m+1)
ans=0

for i in range(n):
    ar[i+1]=ar[i]+a[i]
for i in range(m):
    br[i+1]=br[i]+b[i]
for i in range(m+1):
    sup=k-br[i]
    if sup<0:
      break
    res=bisect.bisect_right(ar,sup)+i-1
    ans=max(res,ans)
print(ans)

Measured memory_bytes: 121916
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	tasks := make([]Task, n)
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		tasks[i] = Task{a, b}
	}
	sort.Sort(Tasks(tasks))

	s := 0
	for i := 0; i < n; i++ {
		t := tasks[i]
		s += t.a
		if t.b < s {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

// Task .
type Task struct {
	a int
	b int
}

// Tasks .
type Tasks []Task

func (t Tasks) Len() int {
	return len(t)
}

func (t Tasks) Less(i, j int) bool {
	return t[i].b < t[j].b
}

func (t Tasks) Swap(i, j int) {
	t[i], t[j] = t[j], t[i]
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
using namespace std;

ll n, ans;

inline ll read(){										//¿ì¶Á 
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline ll gcd(ll a, ll b){								//Çó×î´ó¹«Ô¼Êý 
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}

inline void work(){
	n = read();											//ÊäÈën£¬Í¬ÌâÄ¿ÖÐµÄk 
	REP(i, 1, n)										//Í¬ÌâÄ¿ÖÐµÄa
		REP(j, 1, n)									//Í¬ÌâÄ¿ÖÐµÄb 
			REP(k, 1, n){								//Í¬ÌâÄ¿ÖÐµÄc 
				if (min(i, min(j, k)) == 1) ans++;		//Èç¹ûÆäÖÐÒ»¸öÊýÎª1Ôò×î´ó¹«Ô¼ÊýÎª1 
				else if (i == j && j == k) ans += i;	//Èç¹û3¸öÊýÏàµÈ×î´ó¹«Ô¼Êý¾ÍÊÇi 
					else ans += gcd(i, gcd(j, k));		//Í¬ÌâÄ¿ÖÐµÄ¹«Ê½ 
			}
	printf("%lld\n", ans);								//Êä³ö´ð°¸ 
}

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

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<vector<int>> UnWeightedGraph;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template< typename G >
struct StronglyConnectedComponents {
  const G &g;
  UnWeightedGraph gg, rg;
  vector< int > comp, order, used;

  StronglyConnectedComponents(G &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
    for(int i = 0; i < g.size(); i++) {
      for(auto e : g[i]) {
        gg[i].emplace_back((int) e);
        rg[(int) e].emplace_back(i);
      }
    }
  }

  int operator[](int k) {
    return (comp[k]);
  }

  void dfs(int idx) {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt) {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(UnWeightedGraph &t) {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      for(auto &to : g[i]) {
        int x = comp[i], y = comp[to];
        if(x == y) continue;
        t[x].push_back(y);
      }
    }
  }
};


#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector<int> points[305];
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    UnWeightedGraph g(N+1);
    for(int i = 1; i <= M; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
    }
    StronglyConnectedComponents<UnWeightedGraph> G(g);
    UnWeightedGraph t(N+1);
    G.build(t);
    for(int i = 1; i <= N; i++) {
        points[G[i]].push_back(i);
    }
    for(int i = 1; i <= N; i++) {
        vector<int> ans;
        for(int j = 0; j < points[G[i]].size(); j++) {
            int now = points[G[i]][j];
            ans.push_back(now);
        }
        sort(ans.begin(), ans.end());
        cout << ans[0];
        for(int j = 1; j < ans.size(); j++) cout << " " << ans[j];
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 4836
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
#define ll long long int
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
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 (b<a) { a = b; return 1;} return 0;}
using namespace std;
string s[] = {".,!? ", "abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    rep(i,n){
        string tmp,ans="";
        int cnt=0,al=0;
        cin >> tmp;
        rep(j,tmp.size()){
            if (j>0&&tmp[j]!='0'&&tmp[j] == tmp[j - 1])
            {
                cnt++;
                //cout << "cnt" << cnt << endl;
                if (tmp[j] == '1')
                {
                    cnt %= 5;
                }
                else if (( tmp[j] == '7' ||tmp[j] == '9') )
                {
                    cnt %= 4;
                }
                else{
                    cnt %= 3;
                }
            }
            if(j>0&&tmp[j-1]!='0'&&tmp[j]=='0'){
                //cout << j - 1 << endl;
                ans += s[tmp[j - 1] - '0' - 1][cnt];
                cnt = 0;
            }
            
        }
        cout << ans<<endl;

    }
    return 0;
}


Measured memory_bytes: 3012
#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);

  char c;
  cin >> c;
  if (c <= 'Z') cout << "A" << endl;
  else cout << "a" << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<vector>

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

using namespace std;

struct Interval{
	int a,b;
	Interval(){}
	Interval(int A,int B):a(A),b(B){}
};

inline int intersect(const Interval &I,const Interval &J){
	return max(min(I.b,J.b)-max(I.a,J.a)+1,0);
}

int main(){
	for(int n,m,q1,q2,q3;scanf("%d%d%d%d%d",&n,&m,&q1,&q2,&q3),n;){
		vector<Interval> I;
		I.push_back(Interval(1,n));
		while(m--){
			// A B C Éª
			int x,y; scanf("%d%d",&x,&y);

			// ¶[ðTµÄª
			int pl;
			for(int i=0,j=1;;i++){
				int w=I[i].b-I[i].a;
				if(x+1<=j+w){
					if(j<x+1){
						I.insert(I.begin()+i+1,Interval(I[i].a+(x+1)-j,I[i].b));
						I[i].b=I[i].a+x-j;
						pl=i+1;
					}
					else pl=i;
					break;
				}
				j+=w+1;
			}

			// E[ðTµÄª
			int pr;
			for(int i=0,j=1;;i++){
				int w=I[i].b-I[i].a;
				if(y<=j+w){
					if(y<j+w){
						I.insert(I.begin()+i+1,Interval(I[i].a+(y+1)-j,I[i].b));
						I[i].b=I[i].a+y-j;
					}
					pr=i+1;
					break;
				}
				j+=w+1;
			}

			vector<Interval> next(I.size());
			int ii=0,nn=I.size();
			for(int i=pr;i<nn;i++) next[ii++]=I[i];
			for(int i=pl;i<pr;i++) next[ii++]=I[i];
			for(int i= 0;i<pl;i++) next[ii++]=I[i];
			rep(i,nn) I[i]=next[i];
		}

		int ans=0;
		for(int i=0,j=1;i<I.size();i++){
			int w=I[i].b-I[i].a;
			ans+=intersect(Interval(q1,q2),Interval(j,j+min(q3,I[i].b)-I[i].a));
			j+=w+1;
		}
		printf("%d\n",ans);
	}

	return 0;
}

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

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w, count;
	cin >> h >> w;
	char tab[h][w];
	rep(i, h) rep(j, w) cin >> tab[i][j];
	rep(i, h) {
		rep(j, w) {
			count = 0;
			if (tab[i][j] == '.') {
				if (i != 0 && tab[i - 1][j] == '#')
					count++;
				if (j != 0 && tab[i][j - 1] == '#')
					count++;
				if (i != h - 1 && tab[i + 1][j] == '#')
					count++;
				if (j != w - 1 && tab[i][j + 1] == '#')
					count++;
				if (i != 0 && j != 0 && tab[i - 1][j - 1] == '#')
					count++;
				if (i != h - 1 && j != w - 1 && tab[i + 1][j + 1] == '#')
					count++;
				if (i != 0 && j != w - 1 && tab[i - 1][j + 1] == '#')
					count++;
				if (i != h - 1 && j != 0 && tab[i + 1][j - 1] == '#')
					count++;
				tab[i][j] = count + '0';
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << tab[i][j];
			if (j == w - 1)
				cout << "\n";
		}
	}
}


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

int main() {
  long long n,w;
  cin>>n>>w;
  vector<vector<long long>>dp(n+1,vector<long long>(100001));
  for(int i=0;i<n+1;i++){
    for(int j=0;j<100001;j++) dp[i][j]=1000000000000;
  }
  dp[0][0]=0;
  for(int i=1;i<n+1;i++){
    int W,v;
    cin>>W>>v;
    for(int j=0;j<100001;j++){
      dp[i][j]=min(dp[i][j],dp[i-1][j]);
      if(j-v>=0) dp[i][j]=min(dp[i-1][j-v]+W,dp[i][j]);
    }
  }
  long long ans=0;
  for(int j=0;j<100001;j++){
    if(dp[n][j]<=w) ans=j;
  }
  cout<<ans<<endl;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    int n; cin >> n;

    vector<pii> events;

    rep(i,0,n) {
        int a, b;cin >> a >> b;
        events.pb(mp(b,a));
    }
    sort(all(events));

    int curr = 0;
    bool ok = true;
    for(int i = 0; i < n; i++) {
        pii e = events[i];
        if(curr + e.second > e.first) ok = false;
        curr += e.second;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = n - 1;
    rep(i,n-1){
        if(s[i]!=s[i+1])ans--;
    }

    ans = min(ans+k*2, n-1);

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


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int H,W,N;
    cin >> H >> W >> N;

    int a = max(H,W);
    if( N%a == 0) cout << N/a << endl;
    else cout << N/a+1 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            WillReturn.Add("1 2 1 1 3");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4");
            WillReturn.Add("1 3 2 1");
            //No
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("5");
            WillReturn.Add("1 2 3 4 5");
            //Yes
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("1");
            WillReturn.Add("1000000000");
            //Yes
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] HArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        bool IsOK = true;
        int UB = HArr.GetUpperBound(0);
        for (int I = 0; I <= UB; I++) {
            //先頭の場合はデクリメント
            if (I == 0) {
                HArr[I]--;
                continue;
            }
            //先頭以外の場合は、可能ならデクリメント
            if (HArr[I - 1] < HArr[I]) {
                HArr[I]--;
            }

            if (HArr[I - 1] > HArr[I]) {
                IsOK = false;
                break;
            }
        }
        Console.WriteLine(IsOK ? "Yes" : "No");
    }
}


Measured memory_bytes: 30300
cards = [[False for x in range(13)] for y in range(4)]
taio = {"S":0, "H":1, "C":2, "D":3}
pat=["S", "H", "C", "D"]
a = int(input())
for i in range(a):
    m, v= input().split()
    cards[int(taio[m])][int(v)-1] = True
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print (f"{pat[i]} {j+1}")




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

using namespace std;

const int MAXN = 3E5 + 100;
typedef long long ll;
int n, m, a[MAXN];
ll p[MAXN];

int main()
{
    ll all = 0;
    scanf("%d%d", &n, &m);
    for(int i=0; i<n; ++i) scanf("%d", a+i);
    for(int i=1; i<n; ++i)
    {
        int l = a[i-1], r = a[i];
        if(l>r) r += m;
        all += r-l;
        if(r-l>1)
        {
            p[l+2] += 1;
            p[r+1] -= (r-(l+2)+1) + 1;
            p[r+2] += (r-(l+2)+1);
        }
    }
    for(int i=1; i<=2*m; ++i) p[i] += p[i-1];
    for(int i=1; i<=2*m; ++i) p[i] += p[i-1];

    ll ans = -1;
    for(int i=1; i<=m; ++i) ans = max(ans, p[i]+p[i+m]);
    cout << all - ans << endl;

    return 0;
}

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

int main() {
	string s;
	cin >> s;
	
	string k="";
	int j=0;
	for(int i=0; i<s.length(); i++){
		if(s[i]=='1'){
			k[j]='1';
			j++;
		}else if(s[i]=='0'){
			k[j]='0';
			j++;
		}else if(s[i]=='B'){
			if(j==0){}
			else{
				j--;
			}
			
		}

	}
	for(int i=0; i<j; i++){
		cout<<k[i];
	}
	cout <<endl;
	return 0;
}

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

int main() {
  int n, i, j, ans = 0, count;
  cin >> n;
  if (n < 105) {
    cout << ans << "\n";
  } else {
    for (i = 105; i <= n; i++) {
      count = 0;
      for (j = 1; j <= i;) {
        if (i % j == 0) {
          count++;
        }
        j += 2;
      }
      if (count == 8) {
        ans++;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int n , m ;
    std::cin >> n >> m ;
    
    int a[ n ] [ m ] ;
    int b[ m ] ;
    for( int i = 0 ; i < n ; i++ ) {
        for( int ii = 0 ; ii < m ; ii++ ) {
            std::cin >> a[ i ] [ ii ] ;
        }
    }
    for( int i = 0 ; i < m ; i++ ) {
        std::cin >> b[ i ] ;
    }
    
    for( int i = 0 ; i < n ; i++ ) {
        int c = 0 ;
        for( int ii = 0 ; ii < m ; ii++ ) {
            c += a[ i ] [ ii ] * b[ ii ] ;
        }
        std::cout << c << std::endl ;
    }
}



Measured memory_bytes: 3124
#include <iostream>
using namespace std;
int main(){
    long s;
    cin >> s;

    s = s%10;
    
    if(s == 3){
        cout << "bon" << endl;
    }else if (s == 0 || s == 1 || s == 6 || s == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3600
n = int(input())
s = {n}
flg = 1
i = 1
while flg:
  if n % 2 == 0:
    n //= 2
  else:
    n = 3*n + 1
  if n in s:
    print(i+1)
    flg = 0
  else:
    s.add(n)
  i += 1

Measured memory_bytes: 2940
n,k=[int(i) for i in input().split()]

class Number:
    def __init__(self,number,times):
        self.number=number
        self.times=times

    def __eq__(self, other):
        if self.number==other.number:
            return True
        return False
    def __le__(self, other):
        if self.number<=other.number:
            return True
        return False
    def __lt__(self, other):
        if self.number<other.number:
            return True
        return False
    def __ge__(self, other):
        if self.number>=other.number:
            return True
        return False
    def __gt__(self, other):
        if self.number>other.number:
            return True
        return False

number_list=[]
for i in range(n):
    number,times=[int(i) for i in input().split()]
    number_list.append(Number(number,times))

number_list.sort()


def get(number_list,k):
    i=0
    while True:
        taishou=number_list[i]
        k=k-taishou.times
        if k<=0:
            return taishou.number
        else:
            i+=1
print(get(number_list,k))

Measured memory_bytes: 32312
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<pair<int, int>> B;
    for (int i = 0; i < N; i++) B.emplace_back(A[i], i);
    sort(begin(B), end(B));
    vector<vector<int>> prv(N);
    set<int> S;
    for (int i = 0, j = 0; i < N; i++) {
        auto [val, idx] = B[i];
        while (j < i && abs(B[j].first - val) > K) {
            S.erase(B[j].second);
            j++;
        }
        auto it = S.lower_bound(idx);
        if (it != S.begin()) {
            --it;
            prv[idx].push_back(*it);
        }
        S.insert(B[i].second);
    }
    S.clear();
    for (int i = N - 1, j = N - 1; i >= 0; i--) {
        auto [val, idx] = B[i];
        while (j > i && abs(B[j].first - val) > K) {
            S.erase(B[j].second);
            j--;
        }
        auto it = S.lower_bound(idx);
        if (it != S.begin()) {
            --it;
            prv[idx].push_back(*it);
        }
        S.insert(B[i].second);
    }
    vector<int> dp(N);
    for (int i = 0; i < N; i++) {
        dp[i] = 1;
        for (int p : prv[i]) {
            if (abs(A[i] - A[p]) <= K) {
                dp[i] = max(dp[i], dp[p] + 1);
            }
        }
    }
    cout << *max_element(begin(dp), end(dp)) << '\n';
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException  {

		String[] arrStrNumbers = (new BufferedReader(new InputStreamReader(System.in)).readLine()).split(" ");
		int[] arrNumbers = new int[arrStrNumbers.length];

		for(int i = 0; i < arrNumbers.length; i++) arrNumbers[i] = Integer.parseInt(arrStrNumbers[i]);

		for(int i = 0; i < arrNumbers.length; i++) {
			for(int j = i; j < arrNumbers.length; j++) {
				if(arrNumbers[j] < arrNumbers[i]) {
					int tmp = arrNumbers[i];
					arrNumbers[i] = arrNumbers[j];
					arrNumbers[j] = tmp;
				}
			}
		}

		System.out.println(arrNumbers[0] + " " + arrNumbers[1] + " " + arrNumbers[2]);
	}
}

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

int main(void) {
	string S, T;
	cin >> S >> T;
	int count = 0;
	for (int i = 0; i < (int) S.length(); i++) {
		if (S[i] == T[i]) {
			count++;
		}
	}
	cout << count << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

const int MAX_V = 30;
const double INF = 100000000.0;

int n,m,p,a,b;
int t;

struct edge{
  int to, dist;
  edge(int t_to,int t_dist){
    to=t_to;dist=t_dist;
  }
};

struct P{
  int city;
  double time;
  int tickets;
  P(const int &a,const double &b,const int &c){
    city=a;time=b;tickets=c;
  }
  bool operator >(const P& p)const{
    return time > p.time;
  }
};
vector<double> horses;

vector< vector<edge> > G(MAX_V);
double d[MAX_V][2<<11];

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P> > que;
  rep(i,MAX_V){
    rep(j,2<<11) d[i][j]=INF;
  }
  d[s][t] = 0;
  que.push(P(s,0,t));//city,time,ticket

  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.city;
    int c = p.tickets;
    
    if(d[v][c]<p.time) continue;
    rep(j,n){
      if((c&(1<<j))!=(1<<j))continue;
      int n_t = c& (~(1 << j));
      rep(i,G[v].size()){
        edge e = G[v][i];
    
        //    cout << v << "->" << e.to << " " <<d[e.to][n_t] << " " << d[v][c]+e.dist/horses[j] << endl;
        if(d[e.to][n_t] > d[v][c] + e.dist/horses[j]){
          d[e.to][n_t] = d[v][c] + (e.dist/horses[j]);
          que.push(P(e.to,d[e.to][n_t],n_t));//city,time,ticket
        }
      }
    }
  }
}


int main(){

  while(1){
    cin >> n >> m >> p >> a >> b;
    if((n|m|p|a|b)==0)break;
    a--;b--;
    t=0;
    vector< vector<edge> > INIT(MAX_V);
    vector<double> INIT2; 
    G=INIT;
    horses=INIT2;
    rep(i,n){
      double tmp;
      cin >> tmp;
      horses.push_back(tmp);
      t=t|(1<<i);   
    }
    rep(i,p){
      int x,y,z;
      cin >> x >> y >> z;x--;y--;
      G[x].push_back(edge(y,z));
      G[y].push_back(edge(x,z));
    }
    //cout << a << " " << b << endl;
    
    dijkstra(a);

    double cost=INF;
    rep(i,(2<<11)){
      cost=min(cost,d[b][i]); 
    }
    if(cost == INF) cout << "Impossible" << endl;
    else cout << cost << endl;
  }
}

Measured memory_bytes: 6244
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
const int N=1e5+5;
vll a[N];
int main()
{
	fast();
	ll n,m,i;
	cin>>n>>m;
	ll h[n];
	rep(i,n)
		cin>>h[i];
	while(m--)
	{
		ll x,y;
		cin>>x>>y;
		a[x].eb(y);
		a[y].eb(x);
	}
	ll cnt=0;
	for(i=1;i<=n;i++)
	{
		bool flag=true;
		if(a[i].size()==0)
		{
			cnt++;
			continue;
		}
		for(ll x : a[i])
		{
			if(h[i-1]<=h[x-1])
				flag=false;
		}
		if(flag)
			cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 10292
# Problem B - Iron Bar cutting

# input process
N = int(input())
a_list = list(map(int, input().split()))

# initialization
min_cost = 10**18
left_sum = 0
right_sum = sum(a_list)

# count process cumulative sum
for i in range(N-1):
    left_sum += a_list[i]
    right_sum -= a_list[i]
    distance = abs(left_sum - right_sum)
    min_cost = min(min_cost, distance)

# output process
print(min_cost)


Measured memory_bytes: 88144
#include<cstdio>
#include<algorithm>
#include<bitset>
using namespace std;
bitset<10005>cookie[10];
int main()
{
    int m,n,t,res,ans,temp;
    scanf("%d%d",&n,&m);
    while(m||n)
    {
        res=0;
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
        {
            scanf("%d",&temp);
            cookie[i][j]=temp;
        }
        for(int i=0;i<1<<n;i++)
        {
            t=0;
            for(int j=0;j<n;j++)
                if(i>>j&1)
                cookie[j].flip();
            for(int j=0;j<m;j++)
            {
                ans=0;
                for(int k=0;k<n;k++)
                    if(cookie[k][j])
                    ans++;
                t+=max(ans,n-ans);
            }
            res=max(res,t);
            for(int j=0;j<n;j++)
                if(i>>j&1)
                cookie[j].flip();
        }
        printf("%d\n",res);
        scanf("%d%d",&n,&m);
    }
    return 0;
}

Measured memory_bytes: 2624
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

def lcm(a, b):
    return abs(a // gcd(a, b) * b)

n, *t = map(int, sys.stdin.read().split())

def main():
    return reduce(lcm, t)

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main() {
    string S; cin >> S;
    if(S[1] == 'R') {
        int ans = 1;
        if(S[0] == 'R') ans++;
        if(S[2] == 'R') ans++;
        cout << ans << '\n';
    } else {
        if(S[0] == 'R' || S[2] == 'R') cout << 1 << '\n';
        else cout << 0 << '\n';
    }
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>                          
using namespace std;
int a,b,x=1,c,ans,y;
double s; 
int main(){
    cin>>a>>b;
    c=b;
    while(c>0) x*=10,c/=10;
    ans=a*x+b;
    y=sqrt(ans);
    s=sqrt(ans);
    if(y==s) cout<<"Yes";
    else cout<<"No";
	return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

Measured memory_bytes: 256
#include <stdio.h>
int main(){

   int a , b , c , tmp;
   scanf("%d%d%d" , &a , &b , &c);
   if ( b > c ) {
     tmp =b; b =c; c =tmp ;
   }
   if ( a > b ) {
     tmp =a; a =b; b =tmp ;
   }
   if ( b > c ) {
     tmp =b; b =c; c =tmp ;
   }
   printf ("%d %d %d\n" , a, b, c);

   
  return 0;
}






Measured memory_bytes: 2036
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func parseInput(input string) (intSlice []int) {
	splitedStrings := strings.Fields(input)
	for i := range splitedStrings {
		iparam, _ := strconv.Atoi(splitedStrings[i])
		intSlice = append(intSlice, iparam)
	}
	return
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	inputedSlices := parseInput(scanner.Text())

	for i := range inputedSlices {
		if inputedSlices[i] > 8 {
			fmt.Println(":(")
			return
		}
	}
	fmt.Println("Yay!")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define bitoff(val,pos) val & ~(1<<pos)
#define biton(val,pos) val | (1<<pos)
#define bittgl(val,pos) val ^ (1<<pos)
#define bitchk(val,pos) (bool)(val & (1<<pos))
#define odevn(val,pos) (bool)(val & (1<<pos))
#define bitcnt(val) __builtin_popcount(val)
ll ar[1000000],br[1000000],vis[1000009],cm[1000009],ck,n,r,sum,k,sm;
string st;
vector<ll>vec;
vector<ll>vec2[200009];
queue<ll>qq;
stack<ll>stk;
map<string,ll>mp;map<ll,ll>mp1;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll min1=9999999999;
    ll i,j,e,d,t,s=0;
    double dd,vv,gg;
    cin >> n >> k;
    for(i=1;i<=n;i++)
    {
        cin >> ar[i];
    }
    sort(ar+1,ar+n+1);
    if(n<=k)
    {
        cout << "0" << endl;
    }
    else
    {
        n=n-k;
        sum=0;
        for(i=1;i<=n;i++)
        {
            sum+=ar[i];
        }
        cout << sum << endl;
    }
}



Measured memory_bytes: 10496
#include <iostream>
 
using namespace std;
 
int main(){
  int N, A, B, c=0, b=0;
  cin >> N >> A >> B;
  string S;
  cin >> S;

  for (int i = 0; i < N; i++){
    if(S[i]=='a'){
      if ((A + B) > c){
        printf("Yes\n");
        c++;
      }else{
        printf("No\n");
      }
    }else if(S[i]=='b'){
      if (((A + B) > c) && (B > b)){
        printf("Yes\n");
        c++;
        b++;
      }else{
        printf("No\n");
      }
    }else{
      printf("No\n");
    }
  }

}


Measured memory_bytes: 3760
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n,m = map(int,input().split())
S = input()
T = input()

l = lcm(n,m)
i = 0
j = 0
ans = l
while i < n or j < m:
    temp_n = i*l//n+1
    temp_m = j*l//m+1
    if temp_n == temp_m:
        if S[i] != T[j]:
            ans = -1
            break
        i += 1
        j += 1
    elif temp_m > temp_n:
        i += 1
    else:
        j += 1

print(ans)

Measured memory_bytes: 5348
import Control.Applicative

powmod _ 0 _ = 1
powmod base exponent modulus = ((if exponent `mod` 2 == 1 then base else 1) * powmod (base * base) (exponent `div` 2) modulus) `mod` modulus

main = do
  [n, k] <- map read . words <$> getLine
  print $ powmod k n (10 ^ 9 + 7)



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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    int a,b,c;
    cin >> a >> b >> c;
    int sum0 = a + b;
    int sum1 = b + c;
    int sum2 = a + c;

    int ans = min(sum0, sum1); 
    ans = min(ans, sum2);
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


Measured memory_bytes: 256
n = int(input())
w = [input() for _ in range(n)]

for i in range(1, n):
  if w[i][0] == w[i-1][-1]:
    continue
  else:
    print('No')
    exit(0)
    
if len(set(w)) == n:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 1000000000
#define MOD 1000007
#define N 1005
#define M 10000001
#define LOG 16
#define KOK 650
#define EPS 0.00001
using namespace std;

int cnt[26];
int n;

int main() {

//	freopen("input.txt","r",stdin);

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	cin>>n;

	for(int i=0;i<26;i++) cnt[i]=inf;

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

		string cur;

		cin>>cur;

		int tot[26]={0};

		for(int j=0;j<sz(cur);j++) {

			tot[cur[j]-'a']++;

		}

		for(int j=0;j<26;j++) umin(cnt[j],tot[j]);

	}

	for(int i=0;i<26;i++) for(int j=0;j<cnt[i];j++) cout<<(char)('a'+i);

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int MAXN = 10 + 1e6;
const ll oo = 1 + 1e18;
const ll mod = 998244353;

int n, s, a[MAXN];
ll f[MAXN];

int main()
{
    #define TASK "ABC"
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
    #endif ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> s;

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

    f[0] = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = s; j >= 0; j--)
        {
            f[j] *= 2;
            f[j] %= mod;
            if (j >= a[i])
            {
                f[j] += f[j - a[i]];
                f[j] %= mod;
            }
        }
    }

    cout << f[s];

    return 0;
}




















































































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

int main(){
  int N,a,b;
  a=1;
  b=0;
  cin>>N;
  vector<int> vec(N,0);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  for(int i=0;i<N;i++){
    a=vec[a-1];
    b++;
    if(a==2){
      cout<<b<<endl;
      break;
      b--;
    }
  }
  if(b==N){
    cout<<-1<<endl;
  }
}
    

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

int main() {
  int h, w, n, sr, sc;
  cin >> h >> w >> n >> sr >> sc;
  int rlim = w - sc + 1, llim = sc, ulim = sr, dlim = h - sr + 1;
  int rout = 0, lout = 0, uout = 0, dout = 0, i, ans = 0;
  
  string s, t;
  cin >> s >> t;
  
  for(i = 0; i < n; i++){
    if(s.at(i) == 'L'){
      lout++;
    }
    else if(s.at(i) == 'R'){
      rout++;
    }
    else if(s.at(i) == 'U'){
      uout++;
    }
    else{
      dout++;
    }
    
    if(lout >= llim || rout >= rlim || uout >= ulim || dout >= dlim){
      ans++;
      break;
    }
    
    if(t.at(i) == 'L' && rout > -1 * sc + 1){
      rout--;
    }
    else if(t.at(i) == 'R' && lout > sc - w){
      lout--;
    }
    else if(t.at(i) == 'U' && dout > -1 * sr + 1){
      dout--;
    }
    else if(t.at(i) == 'D' && uout > sr - h){
      uout--;
    }
    else{
    }
  }
  
  if(ans > 0){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 776
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
    int x,z;
    cin >>x >> z;
    cout << x-z+1 << endl;
    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a=[input() for i in range(h)]
row=[0]*h
col=[0]*w
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            row[i]=1
            col[j]=1
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()




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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<int> l(n);
	REP(i, n) cin >> l[i];

	int cnt = 0;
	REP(i, n) for (int j = i+1; j < n; j++) for (int k = j+1; k < n; k++) {
		if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue ;
		if (!(l[i] + l[j] <= l[k] || l[i] + l[k] <= l[j] || l[j] + l[k] <= l[i]))
			cnt++;
	}
	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 3604
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let h = scan!(usize);
    let w = scan!(usize);
    println!("{}", (n - h + 1) * (n - w + 1));
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

ll sx, sy, tx, ty;
string s = "URDL";

int main(){
	cin >> sx >> sy >> tx >> ty;
	REP(i, 8){
		//cout << endl;
		int w;
		if (i % 2 == 0)w = ty - sy;
		else w = tx - sx;
		if (i >= 4){
			w++;
			if (i == 4)cout << "L";
			else if (i == 6)cout << "R";
		}
		REP(j, w){
			cout << s[i % 4];
		}
		if (i >= 4){
			if (i == 5)cout << "D";
			else if (i == 7)cout << "U";
		}
	}
	cout << endl;
}

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

const int N = 2e5 + 10;
struct E {int v, nt;} e[N<<1];
int n, top, cnt, tot, h[N], a[N], vis[N], lst[N], par[N], stk[N];

inline void add(int u, int v) {e[++tot] = (E){v, h[u]}, h[u] = tot;}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline void dfs(int x) {
	for (int v, i = h[x]; i; i = e[i].nt)
		if (!vis[v = e[i].v]) dfs(v);
	++ cnt;
	for (int v, i = h[x]; i; i = e[i].nt)
		if (!vis[v = e[i].v]) lst[a[v]] = cnt;
	for (a[x] = 0; lst[a[x]] == cnt; ++a[x]);
}

inline void work() {
	int x, p; in(n);
	for (int i = 1; i <= n; ++i) in(par[i]), add(par[i], i);
	for (x = 1; !vis[x]; x = par[x]) vis[stk[++top] = x] = 1;
	for (p = 0; stk[p] != x; ++p); stk[top + 1] = stk[p];
	if ((top - p + 1) % 2 == 0) {puts("POSSIBLE"); return;}
	memset(vis, 0, sizeof vis);
	for (int i = p; i <= top; ++i) vis[stk[i]] = 1;
	for (int i = p; i <= top; ++i) dfs(stk[i]);
	for (int i = p; i <= top; ++i) if (a[stk[i]] != a[stk[i + 1]]) {puts("POSSIBLE"); return;}
	puts("IMPOSSIBLE");
}

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

Measured memory_bytes: 5760
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    s = S()
    a = s.count("a")
    b = s.count("b")
    c = 3-a-b
    if a&b&c:
        print("Yes")
    else:
        print("No")
#B
def B():
    a,b,k = LI()
    ans = []
    for i in range(a,min(a+k,b+1)):
        ans.append(i)
    for i in range(max(a,b-k+1),b+1):
        ans.append(i)
    ans = list(set(ans))
    ans.sort()
    for i in ans:
        print(i)

#C
def C():
    a,b,c = LI()
    ans = 0
    if a%2:
        if b%2:
            if not c%2:
                ans += 1
                a += 1
                b += 1
        else:
            ans += 1
            if not c%2:
                b += 1
                c += 1
            else:
                a += 1
                c += 1
    else:
        if b%2:
            ans += 1
            if not c%2:
                a += 1
                c += 1
            else:
                b += 1
                c += 1
        else:
            if c%2:
                ans += 1
                a += 1
                b += 1
    ans += (3*max(a,b,c)-a-b-c)//2
    print(ans)
#D
def D():
    q = I()
    for i in range(q):
        a,b = LI()
        x = int((a*b)**0.5)
        y = math.ceil((a*b)/x)-1
        ans = x+y-2
        if a==b:
            ans += 1
        print(ans)

#E
def E():
    s = S()
    f = {"N":0,"W":0,"S":0,"E":0}
    for i in s:
        f[i] = 1
    if f["N"]^f["S"]:
        print("No")
    elif f["W"]^f["E"]:
        print("No")
    else:
        print("Yes")
#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


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

typedef long long ll;

int main() {
  int n; cin >> n;
  vector<int> arr(n);
  vector<int> brr(n);
  vector<int> crr(n);
  rep(i, 0, n) cin >> arr[i]; 
  rep(i, 0, n) cin >> brr[i]; 
  rep(i, 0, n) cin >> crr[i];
  
  sort(arr.begin(), arr.end());
  sort(crr.begin(), crr.end());

  ll ans = 0;
  rep(i, 0, n){
    auto lower_a = lower_bound(arr.begin(),arr.end(),brr[i]);
    auto higher_c = upper_bound(crr.begin(),crr.end(),brr[i]);
    ans += (lower_a - arr.begin()) * (crr.end() - higher_c);
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408