akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if(b>=a){
        cout << a << endl;
    }else{
        cout << a-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string S;
  cin >> S;
  
  // 0101...にした場合
  int count1 = 0;

  // 1010...にした場合
  int count2 = 0;

  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S[i] == '1') {
        count1++;
      } else {
        count2++;
      }
    } else { 
      if (S[i] == '0') {
        count1++;
      } else {
        count2++;
      }
    }
  }

  cout << min(count1, count2) << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m,mem[12],ab[12][12],cnt=0;
signed main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)mem[i]=i+1;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        ab[a][b]=ab[b][a]=1;
    }
    do{
        bool b=true;
        for(int i=1;i<n;i++){
            if(ab[mem[i-1]][mem[i]]==0)b=false;
        }
        if(b)cnt++;
    }while(next_permutation(mem+1,mem+n));
    cout<<cnt<<endl;
    system("PAUSE");
}

Measured memory_bytes: 504
s = input()
n = len(s)
i = 1
while i <= n:
  if i % 2 == 0:
    if s[i-1] == "R":
      print("No")
      exit()
  else:
    if s[i-1] == "L":
      print("No")
      exit()
  i += 1
print("Yes")

Measured memory_bytes: 3060
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int l = sc.nextInt();
	String[] s = new String[n];
	for(int i=0; i<n; i++) {
		s[i] = sc.next();
	}
	Arrays.sort(s);
	StringBuilder st = new StringBuilder();
	for(int i=0; i<n; i++) {
		st.append(s[i]);
	}
	System.out.println(st);
}
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
// #define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

ll H, W, N;

int main(){
	FAST;
	cin >> H >> W >> N;
	ll a[N];
	rep(i,N) cin >> a[i];

	ll grid[H][W];

	int p=0;

	rep(i,H) {
		if(i%2==0) {
			rep(j,W) {
				while(a[p]==0) ++p;
				grid[i][j] = p+1;
				a[p]--;
			}
		}
		else {
			repr(j,W) {
				while(a[p]==0) ++p;
				grid[i][j] = p+1;
				a[p]--;
			}
		}
	}

	rep(i,H){
		rep(j,W){
			cout << grid[i][j] << " ";
		}
		cout << LF;
	}

	return 0;
}

Measured memory_bytes: 512
import sys
from functools import lru_cache

@lru_cache(maxsize=None)
def gcd(a, b):
    if b == 0:
        return a
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)


N, *A = map(int, sys.stdin.read().split())
L = [0] * (N + 2)
R = [0] * (N + 2)
for i in range(N):
    L[i + 2] = gcd(L[i + 1], A[i])
    R[-i - 2] = gcd(R[-i - 1], A[-i - 1])

print(max(gcd(L[i], R[i + 1]) for i in range(1, N + 1)))


Measured memory_bytes: 14652
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
int a[100001];
int ans[100001];

int find(int x){
	if(a[x]==x){
		return x;
	} else {
		int tmp=find(a[x]);
		a[x]=tmp;
		return tmp;
	}
}

void Union(int x, int y){
	int x_h=find(x);
	int y_h=find(y);
	if(x_h!=y_h){
		a[x_h]=y_h;
	}
}

int main(){

	int n, m;
	cin >> n >> m;
	for(int i=1; i<=n; i++){
		cin >> ans[i];
		a[i]=i;
	}
	int x, y;
	for(int i=0; i<m; i++){
		cin >> x >> y;
		Union(x, y);
	}
	int cnt=0;
	for(int i=1; i<=n; i++){
		if(find(i)==find(ans[i])){
			cnt++;
		}
	}
	cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
// atcoder dp contest
// I coins
#include <bits/stdc++.h>
 
# define C continue;
# define R return
 
# define D double
# define I insert
# define ll long long
# define ld long double
 
# define ull unsigned long long
# define ui unsigned int
 
# define pb push_back
# define pf push_front
 
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue
 
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >
 
# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp
 
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
# define pipii pair<int, pii >
# define pcpii pair<char,pii>
 
# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >
 
# define vvpii vector < vector < pii > >
# define vpipii vector< pipii >
 
# define F first
# define S second
# define mp make_pair
 
# define unm unordered_map
# define unmii unm< int , int >
# define unmll unm< ll , ll >
# define unms unm<string,int>
# define unmci unm<char,int>
 
# define sortvia sort(a.begin(),a.end());
# define sortvib sort(b.begin(),b.end());
# define revsorta sort(a.begin(), a.end(), greater <int>());
# define revsortb sort(b.begin(), b.end(), greater <>());
# define loop(q,n) for(int i=q;i<n;i++)
# define test int t;cin >> t;while(t--)
# define nextline "\n"
# define tab "\t"
# define space " "
//vector<vector<int> > vec( n , vector<int> (m, 0));
//YES
//NO
//cout
//true
//false
//yes
//no
 
const ll mod9=1e9+7;
const ll maxsize=2e9+1;
// const ll mod =998244353;
const ll mod2=1073741824;
const ll INF=1e18L+5;
const int two_pow_fiv=200008;
using namespace std;


int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int n;
    cin>>n;
    vector <double> dp(n+5);
    dp[0]=1;
    for(int coin_num=1;coin_num<=n;coin_num++){
    	double curr_probab;
    	cin>>curr_probab;
    	for(int i=n;i>=0;i--){
    		dp[i]=(i==0 ? 0 : dp[i-1]*(curr_probab))+dp[i]*(1-curr_probab);
    	}
    }
    // now we add all the probablities in cases where heads are greater than tails
    double answer=0;
    for(int heads=0;heads<=n;heads++){
    	int tails=n-heads;
    	if(heads>tails)answer+=dp[heads];
    }
     printf("%.10lf\n", answer);
return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int main(){
	cin.sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;

	ll x[2] = {};
	ll ans = 0;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		if (i == 0){
			x[0] = tmp; 
		} else {
			x[1] = tmp;
			if ((x[1] - x[0]) * a > b) {
				ans += b;
			} else {
				ans += (x[1] - x[0]) * a;
			}
			x[0] = x[1];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String S = scanner.nextLine();

        int ret = 0;
        int count = 0;
        for (char c : S.toCharArray()) {
            if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
                count++;
            } else {
                if (ret < count) {
                    ret = count;
                }
                count = 0;
            }
        }

        if (ret < count) {
            ret = count;
        }
        System.out.println(ret);
    }

}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int i, j,k;
	int d[201][201];
	for (i = 0; i < 201; i++) {
		for (j = 0; j < 201; j++) {
			if (i == j)d[i][j] = 0;
			else d[i][j] = MOD;
		}
	}
	int n, m, r;
	cin >> n >> m >> r;
	int R, memo[8];
	for (i = 0; i < r; i++) {
		cin >> R; R--; memo[i] = R;
	}
	sort(memo, memo + r);
	int a, b, c;
	for (i = 0; i < m; i++) {
		cin >> a >> b >> c; a--; b--;
		d[a][b] = c; d[b][a] = c;
	}
	for (k = 0; k < n; k++) {
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int mi=0;
	for (i = 1; i < r; i++) {
		mi += d[memo[i - 1]][memo[i]];
	}
	while (next_permutation(memo, memo + r)) {
		int csum = 0;
		for (i = 1; i < r; i++) {
			csum += d[memo[i - 1]][memo[i]];
		}
		mi = min(mi, csum);
	}
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 384
n, k = map(int, input().split())
a = list(map(int, input().split()))
g = dict()

for i, v in enumerate(a):
    g[i+1] = v

def find_num(target):
    path = 1
    target_ = g[target]
    while target_ != target:
        target_ = g[target_]
        path += 1
    return path

target = 1
visited = dict()
flag = False
for i in range(k):
    target = g[target]
    if target not in visited:
        visited[target] = True
    else:
        p = find_num(target)
        flag = True
        break
if flag:
    for _ in range((k-1-i)%p):
        target = g[target]
    print(target)
else:
    print(target)

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, Q, x[20202], b[20202], l[20202], r[20202];
char c[20202];
string s;
set<int> st[26];
void solve(){
	cin >> n >> s >> Q;
	for(int i = 0; i < n; i++){
		st[s[i]-'a'].insert(i+1);
	}
	for(int i = 0; i < 26; i++) st[i].insert(INF);
	vector<int> ans;
	for(int t = 0; t < Q; t++){
		cin >> b[t];
		if(b[t] == 2){
			cin >> l[t] >> r[t];
			int cnt = 0;
			for(int i = 0; i < 26; i++){
				if(*st[i].lower_bound(l[t]) <= r[t]) cnt++;
			}
			ans.push_back(cnt);
		}
		else{
			cin >> x[t] >> c[t];
			st[s[x[t]-1]-'a'].erase(x[t]);
			st[c[t]-'a'].insert(x[t]);
			s[x[t]-1] = c[t];
		}
	}
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 26012
import  java.util.*
 
fun main(args: Array<String>) {
  val sc = Scanner(System. `in`)
  val a=sc.nextInt();
  val b=sc.nextInt();
  println(problem(a,b))
}
 
fun problem(a: Int, b: Int): Int {
    return if(a>=10||b>=10)-1 else a*b
}

Measured memory_bytes: 31272
s=gets.chomp
r=0
(1<<(s.size-1)).times{|i|
	x=0
	s.size.times{|j|
		x=x*10+s[j].to_i
		if i[j]==1
			r+=x
			x=0
		end
	}
	r+=x
}
p r

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, s = 0;
  cin >> s;
  a = s / 100;
  b = (s - a * 100) / 10;
  c = (s - a * 100 - b * 10);
  
  cout << (a + b + c) << endl;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v;
    int sum=0;
    rep(i,n){
        int tmp;cin>>tmp;
        v.push_back(tmp);
        sum+=tmp;
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    bool fl=true;
    double k=sum*1.0/(4.0*m);
    rep(i,m){
        if(v[i]>=k){

        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
    
    static HashMap<String,Long> h=new HashMap<String,Long>();
public static void main(String[] args)
{
 
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
double a=sc.nextDouble();
int ar[]=new int[n];
for(int i=0;i<n;i++)
ar[i]=sc.nextInt();
long pp=compute(0,ar,0,a,0);
System.out.println(pp);
}
    public static long compute(int index,int ar[],long sum,double a,int count)
{
    String zz=index+"|"+sum+"|"+count;
    if(h.containsKey(zz))
    return h.get(zz);
    else if(index==ar.length)
    {long zer=0;
        h.put(zz,zer);
    return zer;
    }
    else{
    long uu=sum+ar[index];
    double kk=1.0*uu;
    double ff=kk/(count+1);
    long counter=(ff==a)?1:0;
    
    counter+=compute(index+1,ar,uu,a,count+1);
    counter+=compute(index+1,ar,sum,a,count);
    h.put(zz,counter);
    return  counter;
    }
}}

Measured memory_bytes: 124580
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T, typename S> T expo(T b, S e, const T &m){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b)%m, e>>1, m): (b*expo((b*b)%m, e>>1, m))%m;}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 100;
int n, m;
string grid[MAXN], B[MAXN];

bool check(int st_r, int st_c) {
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < m; j++) {
      if(grid[st_r + i][j + st_c] != B[i][j]) return false;
    }
  }
  return true;
}

bool solve() {
  bool ok = false;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      if(i + m <= n and j + m <= n) {
        ok |= check(i, j);
      }
    }
  }
  return ok;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for(int i = 0; i < n; i++) {
    cin >> grid[i];
  }
  for(int i = 0; i < m; i++) {
    cin >> B[i];
  }
  if(solve()) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		int H = s.nextInt();
		int W = s.nextInt();

		char[][] arrays = new char[H][W];

		for (int i = 0; i < H; i++) {
			arrays[i] = s.next().toCharArray();
		}
		for (int i = 0; i < H + 2; i++) {
			if (i == 0 || i == H + 1) {
				for (int j = 0; j < W + 2; j++) {
					System.out.print("#");
				}
			} else {
				for (int j = 0; j < W + 2; j++) {
					if (j == 0 || j == W + 1) {
						System.out.print("#");
					} else {
						System.out.print(arrays[i - 1][j - 1]);
					}
				}
			}
			System.out.print("\n");
		}
	}

}


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

int ch[10],dis[10],n,k,i,j,t,a;

int main(){
    scanf("%d %d",&n,&k);
    for(i=0;i<k;i++)scanf("%d",&dis[i]);
    while(1){
        t=n;
        while(t!=0){
            ch[t%10]=1;
            t/=10;
        }
        a=0;
        for(i=0;i<k;i++){
            if(ch[dis[i]]==1)a=1;
        }
        if(a==0)break;
        for(i=0;i<10;i++)ch[i]=0;
        n++;
    }
    printf("%d\n",n);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main() {
  int A,B,K;
  cin >> A >> B >> K;
  
  if (B-A+1 <= 2*K) {
    for (int i=A; i<=B; i++) {
      cout << i << endl;
    }
  }
  if (B-A+1 > 2*K) {
    for (int i=A; i<=A+K-1; i++) {
      cout << i << endl;
    }
    for (int i=B-K+1; i<=B; i++) {
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	char b[] = { 'a','i','u','e','o' };
	int kkt = 89;
	while (kkt) {
		int n; scanf("%d", &n); if (n == 0) break;
		vector<string> vs(n);
		vector<string> v(n); for (int i = 0; i < n; i++) cin >> v[i];
		int res = inf;
		for (int len = 1; len <= 50; len++) {
			vs.resize(n);
			for (int i = 0; i < n; i++) {
				string s = v[i];
				string res;
				res += s[0];
				for (int j = 0; j < (int)s.size() - 1; j++) {
					for (int k = 0; k < 5; k++) {
						if (s[j] == b[k]) res += s[j + 1];
					}
				}
				vs[i] = res.substr(0, len);
			}
			sort(vs.begin(), vs.end());
			vs.erase(unique(vs.begin(), vs.end()), vs.end());
			if (vs.size() == n) chmin(res, len);
		}
		if (res == inf) res = -1;
		cout << res << "\n";
	}
	return 0;

}


Measured memory_bytes: 3240
# -*- coding: utf-8 -*-

import sys


def main():
    count = 0
    for line in sys.stdin:
        if len(line.rstrip().split(" ")) == 1:
            continue
        start, end = map(int, line.rstrip().split(" "))
        count += end - start + 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
/*ex4_3
 Sweet_Sweet_Soul */
#include <stdio.h>

int ans(int wes,int eas);

int main(void) {
    int wes,eas;
    scanf("%d",&wes);
    scanf("%d",&eas);
    printf("%d\n",ans(wes,eas));
    return 0;
}

int ans(int wes,int eas){
    int dif=eas-wes;/*東側はdif番目の塔*/
    int true_eas=(dif+1)*dif/2;/*東側の塔の本当の高さを総和公式で*/
    return true_eas-eas;/*本当の高さ-見えてる高さ=埋もれた高さ*/
}


Measured memory_bytes: 128
a, b, c, d, e = int(input()), int(input()), int(input()), int(input()), int(
    input())
cook = [a, b, c, d, e]
A = [10 - a % 10, 10 - b % 10, 10 - c % 10, 10 - d % 10, 10 - e % 10]
for i in range(5):
    if A[i] == 10:
        A[i] = 0

print(sum(cook) + sum(A) - max(A))


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
using namespace std;
char s[100005];
int a[100005][26];
char t[100005];
int main(){
	cin>>s;int len=strlen(s);
	for(int i=0;i<26;i++){
		char C=i+'a';
		int find=0;
		for(int j=len-1;j>=0;j--){
			if(find)a[j][i]=a[j+1][i]+1;
			if(s[j]==C){a[j][i]=1;find=1;}
		}
		if(find){
			if(a[len-1][i]==0)a[len-1][i]=a[0][i]+1;
			for(int j=len-2;j>=0;j--){
				if(a[j][i]==0){
					a[j][i]=a[j+1][i]+1;
				}else break;
			}
		}
	}
	cin>>t;
	long long ans=0;
	int len2=strlen(t);
	for(int i=0;i<len2;i++){
		int index=t[i]-'a';
		if(a[ans%len][index]==0){
			cout<<-1<<endl;
			return 0;
		}
		ans+=a[ans%len][index];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10624
#include <stdio.h>
 
int box[100005];
int main()
{
    int n,x;
    while (scanf("%d%d",&n,&x)!=EOF)
    {
        for (int i=1;i<=n;i++)
            scanf("%d",&box[i]);
        long long all=0;
        if (box[1]>x)
        {
            all+=box[1]-x;
            box[1]=x;
        }
        for (int i=2;i<=n;i++)
        {
            int k = box[i]+box[i-1]-x;
            if (k>0)
            {
                all+=k;
                box[i]-=k;
            }
        }
        printf("%lld\n",all);
    }
}

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

int main() {
	int N;
	cin >> N;
	if (N < 5) {
		if (N == 3) {
			cout << "2 5 63" << endl;
		}
		if (N == 4) {
			cout << "2 5 20 63" << endl;
		}
		return 0;
	}
	int m = N % 8;
	N /= 8;
	for (int i = 0;i < N;i++) {
		cout << i * 12 + 2 << " "
			<< i * 12 + 3 << " "
			<< i * 12 + 4 << " "
			<< i * 12 + 6 << " "
			<< i * 12 + 8 << " "
			<< i * 12 + 9 << " "
			<< i * 12 + 10 << " "
			<< i * 12 + 12;
		if (i != N - 1 || m != 0) {
			cout << " ";
		}
	}
	if (m == 1) {
		cout << N * 12 + 6 << endl;
	}
	if (m == 2) {
		cout << N * 12 + 4 << " "
			<< N * 12 + 8 << endl;
	}
	if (m == 3) {
		cout << N * 12 + 4 << " "
			<< N * 12 + 6 << " "
			<< N * 12 + 8 << endl;
	}
	if (m == 4) {
		cout << N * 12 + 4 << " "
			<< N * 12 + 6 << " "
			<< N * 12 + 8 << " "
			<< N * 12 + 12 << endl;
	}
	if (m == 5) {
		cout << N * 12 + 2 << " "
			<< N * 12 + 3 << " "
			<< N * 12 + 9 << " "
			<< N * 12 + 10 << " "
			<< N * 12 + 12 << endl;
	}
	if (m == 6) {
		cout << N * 12 + 2 << " "
			<< N * 12 + 3 << " "
			<< N * 12 + 6 << " "
			<< N * 12 + 9 << " "
			<< N * 12 + 10 << " "
			<< N * 12 + 12 << endl;
	}
	if (m == 7) {
		cout << N * 12 + 2 << " "
			<< N * 12 + 3 << " "
			<< N * 12 + 4 << " "
			<< N * 12 + 8 << " "
			<< N * 12 + 9 << " "
			<< N * 12 + 10 << " "
			<< N * 12 + 12 << endl;
	}
	if (m == 0)
		cout << endl;
}

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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5+10;
const int inf = 1e9+7;

ll a, b, c, x, y;

int main() {
    cin >> a >> b >> c >> x >> y;
    a = min(a, c + c);
    b = min(b, c + c);
    if(c + c >= a + b) {
        cout << x * a + y * b << endl;
    }
    else {
        if(x > y)
            cout << y * (c + c) + (x - y) * a << endl;
        else
            cout << x * (c + c) + (y - x) * b << endl;
    }
}


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

typedef long long ll;
const int mod = 1000000007;

ll dp[1000] = {};
vector<int> v[1000];
string s[1000];
int n;

int dfs(int x){
    dp[x] = s[x][0]!='A';
    for(int child : v[x]){
        if(s[x][0] == 'A')  dp[x] += dfs(child);
        else                (dp[x] *= dfs(child)+(s[x][0]=='R')) %= mod;
    }
    if(s[x] == "E?")    dp[x] = (dp[x]+1)%mod;
    if(s[x] == "R")     dp[x] = (dp[x]-1+mod)%mod;
    if(s[x] == "A?")    dp[x] = (dp[x]+1)%mod;
    return dp[x];
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> s[i];
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        v[--a].push_back(--b);
    }
    cout << dfs(0) << endl;
    return 0;
}


Measured memory_bytes: 3268
#include <iostream>

using namespace std;

int main()
{
	int k, s,x,y,z,res=0;
	cin >> k >> s;

	for (x = 0; x <= k; x++) {
		for (y = 0; y <= k; y++) {
			z = s - x - y;
			if (0 <= z && z <= k) res++;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
using namespace std;
int n,a[100005],sum,x[100005];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();}
    return ret*ff;
}
signed main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),sum+=a[i];
	sum/=2;
	for(int i=1;i<=n-2;i+=2) sum-=a[i];
	x[n]=sum;
	x[1]=a[n]-x[n];
	for(int i=2;i<=n-1;i++) x[i]=a[i-1]-x[i-1];
	for(int i=1;i<=n;i++) printf("%lld ",x[i]*2);
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll powmod(ll a,ll n,ll m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        ll r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

int main(){

  ll n;
  cin >> n;
  ll a[n];
  for(ll i=0;i<n;i++)cin >> a[i];

  ll s=0;

  for(ll i=0;i<61;i++){
    ll b=0,c=0;
    for(ll j=0;j<n;j++){
      //if(a[j] & (1<<i))b++;
      if(a[j]>>i & 1)b++;
      else c++;
    }
    //if(i==0)cout << b <<" " << c << endl;
    ll d=powmod(2,i,mod);
    d*=b;
    d%=mod;
    d*=c;
    d%=mod;
    s+=d;
    s%=mod;
    //if(b*c!=0)cout << b << " " << c << endl;
  }

  cout << s << endl;

}

Measured memory_bytes: 5920
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!
    val B = readLine()!!
    val C = readLine()!!

    var ans = 0
    for (i in 0 until N) {
        ans += when {
            A[i] == B[i] && B[i] == C[i] -> 0
            A[i] == B[i] || B[i] == C[i] || C[i] == A[i] -> 1
            else -> 2
        }
    }

    println(ans)
}

Measured memory_bytes: 33628
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 998244353;
int n, c, a[100010], v[100010], pr[100010], s[100010], ans;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];
	sort(a+1, a+n+1);
	for(int i=1; i<=n; i++) if(abs((double)a[n]/2-a[i])<abs((double)a[n]/2-ans)) ans=a[i];
	cout<<a[n]<<" "<<ans;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    cout << c << endl;
  }
  else {
    if (a == c) {
      cout << b << endl;
    }
    else {
      cout << a << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;
int a[100010];
signed main(){
  int n,q;cin>>n>>q;
  string s;cin>>s;
  for(int i=1;i<n;i++){
    if(s[i-1]=='A' && s[i]=='C')a[i+1]=a[i]+1;
    else a[i+1]=a[i];
    //cout<<a[i+1]<<endl;
  }
  rep(ima,q){
    int l,r;cin>>l>>r;l--;r--;
    int ans=a[r+1]-a[l];
    if(l>=1 && s[l-1]=='A' && s[l]=='C')ans--;
    cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 4524
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var ab = Input.ar;
        WriteLine(Modulo.Pow(ab[0], ab[1]));
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class Modulo
{
    private static int Multiple(int num1, int num2)
        => (int)(BigMul(num1, num2) % Input.MOD);

    public static int Pow(int m, int n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(Multiple(m, m), n >> 1);
        else return Multiple(Pow(Multiple(m, m), n >> 1), m);
    }

    public static int P(int m,int n)
    {
        var r = 1;
        for (int i = 0; (1L << i) <= n; i++)
        {
            if ((1 & n >> i) == 1)
                r = Multiple(r, m);
            m = Multiple(m, m);
        }
        return r;
    }

    public static int Div(int a, int b)
        => Multiple(a, Pow(b, Input.MOD - 2));

    public class Combination
    {
        private int[] _fac;
        public Combination(int num)//階乗をメモ化
        {
            _fac = new int[num + 1];
            _fac[0] = 1;
            for (var i = 1; i <= num; i++)
                _fac[i] = Multiple(_fac[i - 1], i);
        }
        public int Comb(int n, int r)
        {
            if (n < r) return 0;
            if (n == r) return 1;
            var calc = _fac[n];
            calc = Div(calc, _fac[r]);
            calc = Div(calc, _fac[n - r]);
            return calc;
        }
        public int fac(int num)
            => _fac[num];
    }

}



Measured memory_bytes: 20480
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int main(){
  int X,Y,Z;

  cin>>X>>Y>>Z;

  cout<<(X-Z)/(Y+Z)<<endl;

  return 0;
}


Measured memory_bytes: 256
/*
PROG: apc001b
LANG: C++11
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
 */
#include <bits/stdc++.h>

using namespace std;

long long readi()
{
	long long input = 0;
	bool negative = false;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
int sgn(long long x)
{
	if (x < 0) 
	{
		return -1;
	}
	if (x > 0) 
	{
		return 1;
	}
	return 0;
}
long long randomize(long long mod)
{
	return ((1 << 30) * rand() + (1 << 15) * rand() + rand()) % mod;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-20;

#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
#define MAXN 10010

long long normalize(long long x, long long mod = INF)
{
	return (((x % mod) + mod) % mod);
}

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N;
ll arr[MAXN];

int32_t main()
{
	ios_base::sync_with_stdio(0); 
	srand(time(0));
	//	cout << fixed << setprecision(12);	
	//	cerr << fixed << setprecision(12);
	if (fopen("apc001b.in", "r"))
	{	
		freopen ("apc001b.in", "r", stdin);
		freopen ("apc001b.out", "w", stdout);
	}
	//a += 2, b += 1
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> arr[i];
	}
	for (int i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		arr[i] -= x;
		if (arr[i] < 0 && arr[i] % 2)
		{
			arr[i]++;
		}
	}
	//you can either +1 or +2: -1
	//# of ops you take is at least dec
	//but the # of operations you take is tot
	ll dec = 0, tot = 0;
	for (int i = 0; i < N; i++)
	{
		tot -= arr[i];
		if (arr[i] > 0)
		{
			dec += arr[i];
		}
	}
	if (dec > tot)
	{
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	return 0;
	//	cerr << "time elapsed = " << (clock() / (CLOCKS_PER_SEC / 1000)) << " ms" << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a, b;
    string ans;
    cin >> a >> b;
    if (0 < a) ans = "Positive";
    else if (0 <= b) ans = "Zero";
    else ans = ((b - a + 1) % 2 ? "Negative" : "Positive");
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

int a[10];
int T[11][335];

void memo(int m,int s)
{
  if(m>11) return;
  FOR(i,0,9)
  {
    if(a[i])
    {
      a[i] = 0;
      T[m][s+m*i]++;
      memo(m+1,s+m*i);
      a[i] = 1;
    }
  }
}

void init()
{
  fill_n(a,10,1);
  REP(i,11) fill_n(T[i],335,0);
  memo(1,0);
}

int main()
{
  init();
  int n, s;
  while(cin >> n >> s) cout << (s>330?0:T[n][s]) << endl;
  return 0;
}

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

using ll = long long int;

int main(int argc,char *argv[])
{
	ll n,a,b;
	std::string s;

	std::cin >> n >> a >> b;
	std::cin >> s;
	
	ll ja = 0, ab = 0;
	for(ll i = 0;i < n;++i)
	{
		if(s[i] == 'a')
			if(ja+ab < a+b)
			{
				++ja;
				std::cout << "Yes" << std::endl;
			}
			else std::cout << "No" << std::endl;
		else if(s[i] == 'b')
			if(ja+ab < a+b && ab < b)
			{
				++ab;
				std::cout << "Yes" << std::endl;
			}
			else std::cout << "No" << std::endl;
		else std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3772
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
// use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }
    println!("{}", a.iter().map(|a| a.trailing_zeros()).min().unwrap())
}


Measured memory_bytes: 4352
s=input()
if s =='SUN':
  print(7)
if s=='MON':
  print(6)
if s=='TUE':
  print(5)
if s=='WED':
  print(4)
if s=='THU':
  print(3)
if s=='FRI':
  print(2)
if s=='SAT':
  print(1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


template< typename OperatorMonoid >
struct DuelSegTree {
  using H = function< OperatorMonoid(OperatorMonoid, OperatorMonoid) >;

  int sz, height;
  vector< OperatorMonoid > lazy;
  const H h;
  const OperatorMonoid OM0;


  DuelSegTree(int n, const H h, const OperatorMonoid OM0)
      : h(h), OM0(OM0) {
    sz = 1;
    height = 0;
    while(sz < n) sz <<= 1, height++;
    lazy.assign(2 * sz, OM0);
  }

  inline void propagate(int k) {
    if(lazy[k] != OM0) {
      lazy[2 * k + 0] = h(lazy[2 * k + 0], lazy[k]);
      lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      lazy[k] = OM0;
    }
  }

  inline void thrust(int k) {
    for(int i = height; i > 0; i--) propagate(k >> i);
  }

  void update(int a, int b, const OperatorMonoid &x) {
    thrust(a += sz);
    thrust(b += sz - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) lazy[l] = h(lazy[l], x), ++l;
      if(r & 1) --r, lazy[r] = h(lazy[r], x);
    }
  }

  OperatorMonoid operator[](int k) {
    thrust(k += sz);
    return lazy[k];
  }
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,q;
  cin>>n>>q;
  auto h=[](int a,int b){return b;};
  DuelSegTree<int> seg(n,h,inf);

  while(q--){
    int t;
    cin>>t;
    if(t==0){
      int l,r,x;
      cin>>l>>r>>x;
      seg.update(l,r+1,x);
    }else{
      int x;
      cin>>x;
      cout<<seg[x]<<endl;
    }
  }




}


Measured memory_bytes: 4952
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int main(void){
    int N;
    vector <int> x, y, h;
    int sub;
    int CX, CY, H;
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> sub;
        x.push_back(sub);
        cin >> sub;
        y.push_back(sub);
        cin >> sub;
        h.push_back(sub);
    }
    
    for(CX = 0; CX <= 100; CX++){
        for(CY = 0; CY <= 100; CY++){
            for(int i = 0; i < N; i++){
                if(h[i] > 0){
                    H = h[i] + abs(x[i] - CX) + abs(y[i] - CY);
                    break;
                }
            }
            
            bool judge = true;
            for(int i = 0; i < N; i++){
                int H1 = max(H - abs(x[i] - CX) - abs(y[i] - CY), 0);
                if(H1 != h[i]){
                    judge = false;
                    break;
                }
            }
            
            if(judge){
                cout << CX << " " << CY << " " << H << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
a = accumulate(map(int, input().split()), initial=0)
b = [*accumulate(map(int, input().split()))]
print(max(i + bisect(b, k - x) for i, x in enumerate(a) if x <= k))


Measured memory_bytes: 50712
n=int(input())
x=list(map(int,input().split()))
a=[]
for i in range(n):
  a+=[(x[i],i)]
a=sorted(a)
ans=[]
for i in range(n):
  if i<n//2:ans+=[(a[i][1],a[n//2][0])]
  else:ans+=[(a[i][1],a[n//2-1][0])]
for i,j in sorted(ans):
  print(j)

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int A,B,C;
	cin >> A >> B >> C;
	if(A+B >= C) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <vector>
#include <algorithm>

int main() {
  int n, m, d;
  scanf("%d %d %d", &n, &m, &d);

  if (d == 0)
    return !printf("%.12f\n", (m-1.0)/n);

  // printf("%.12f\n", pow(2, m-1)*(n-d)*(m-1)/pow(n, m));
  // fprintf(stderr, "%g %g %g %g\n", pow(2.0, m), m-1.0, n-d*1., 2.0*pow(n, m));
  // printf("%.12g\n", pow(2.0, m)*(m-1.0)*(n-d)/(2.0*pow(n, m)));
  printf("%.12f\n", 2.0*(n-d)/n/n*(m-1));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef pair<int,int> P;

int dx[2][7] = {{ 0, 1, 1, 0,-1,-1, 0},{ 0, 1, 1, 0,-1,-1, 0}};
int dy[2][7] = {{ 1, 0,-1,-1,-1, 0, 0},{ 1, 1, 0,-1, 0, 1, 0}};
int dp[6][241][241];
int sx, sy, gx, gy;
int n;
int x[1000], y[1000];
int lx, ly;
bool bad[241][241];

bool inrange(int xx,int yy){
	if(120-lx > xx || 120+lx < xx) return false;
	if(120-ly > yy || 120+ly < yy) return false;
	if(bad[xx][yy]) return false;
	return true;
}

void func(int val, int tt, int xx, int yy, int u){
	yy += dy[xx%2][u]; xx += dx[xx%2][u]; tt = (tt+1)%6;
	if(!inrange(xx,yy)) return;
	if(dp[tt][xx][yy] <= val) return;
	dp[tt][xx][yy] = val;
	while(true){
		int dir;
		if(xx >= 120 && yy >= 120){
			dir = (tt*xx*yy)%6;
		} else if(xx < 120 && yy < 120){
			dir = (tt*(120-xx)*(120-yy))%6;
		} else if(xx < 120){
			dir = (tt*(120-xx)*yy)%6;
		} else{
			dir = (tt*xx*(120-yy))%6;
		}
		tt = (tt+1)%6;
		yy += dy[xx%2][dir];
		xx += dx[xx%2][dir];
		if(!inrange(xx,yy)) break;
		if(dp[tt][xx][yy] <= val) break;
		dp[tt][xx][yy] = val;
	}
}

int main(){
	cin >> sx >> sy >> gx >> gy;
	sx += 120; sy += 120; gx += 120; gy += 120;
	cin >> n;
	rep(i,n){
		cin >> x[i] >> y[i];
		x[i] += 120;
		y[i] += 120;
		bad[x[i]][y[i]] = true;
	}
	cin >> lx >> ly;
	rep(i,6) rep(j,241) rep(k,241) dp[i][j][k] = INF;
	dp[0][sx][sy] = 0;
	int xx = sx, yy = sy;
	int t = 0;
	while(true){
		int dir;
		if(xx >= 120 && yy >= 120){
			dir = (t*xx*yy)%6;
		} else if(xx < 120 && yy < 120){
			dir = (t*(120-xx)*(120-yy))%6;
		} else if(xx < 120){
			dir = (t*(120-xx)*yy)%6;
		} else{
			dir = (t*xx*(120-yy))%6;
		}
		t = (t+1)%6;
		yy += dy[xx%2][dir];
		xx += dx[xx%2][dir];
		if(!inrange(xx,yy)) break;
		if(dp[t][xx][yy] != INF) break;
		dp[t][xx][yy] = 0;
	}
	rep(i,6){
		if(dp[i][gx][gy] != INF){
			cout << dp[i][gx][gy] << endl;
			return 0;
		}
	}
	for(int i = 1; i < 500; i++){
		bool end = true;
		rep(j,6){
			rep(k,241){
				rep(l,241){
					if(dp[j][k][l] == i-1){
						end = false;
						rep(u,7){
							func(i,j,k,l,u);
						}
					}
				}
			}
		}
		if(end) break;
		rep(j,6){
			if(dp[j][gx][gy] != INF){
				cout << dp[j][gx][gy] << endl;
				return 0;
			}
		}
	}
	cout << "-1" << endl;
}

Measured memory_bytes: 2576
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    vll h(n);
    rep(i, n) cin >> h[i];
    vll d(n,0);
    ll count=n;
    rep(i,m){
        ll a;
        cin >> a;
        ll b;
        cin >> b;
        if(h[a-1]>=h[b-1]){
            if(d[b-1]==0){
                count--;
                d[b-1]=1;
            }
        }
        if(h[a-1]<=h[b-1]){
            if(d[a-1]==0){
                count--;
                d[a-1]=1;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 4800
import sys, re
from collections import deque, defaultdict, Counter
from math import floor, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	n = INT()
	for i in range(n, 0,  -1):
		q = floor(sqrt(i))
		if i == q**2:
			print(i)
			sys.exit()

if  __name__=='__main__':
	main()


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

int main(){
    int A, B, ans;cin>>A;cin>>B;
    if(A==1 || B==1){
        if(A==2 || B==2) ans=3;
        if(A==3 || B==3) ans=2;
    } 
    else ans=1;

    cout<<ans<<endl;
}

Measured memory_bytes: 256