akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

string field[8];

void go(int X, int Y) {
	// cerr << "call " << X << ":" << Y << endl;
	if((0 <= X && X < 8 && 0 <= Y && Y < 8) == false) return;
	if(field[Y][X] != '1') return;
	field[Y][X] = '0';
	for(int x = X - 3; x <= X + 3; x++) {
		go(x, Y);
	}
	for(int y = Y - 3; y <= Y + 3; y++) {
		go(X, y);
	}
}

int main() {
	string line;
	getline(cin, line);
	int N = toInt(line);
	for(int n  = 1; n <= N; n++) {
		getline(cin, line);

		for(int i = 0; i < 8; i++) getline(cin, field[i]);
		getline(cin, line);
		int X = toInt(line);
		getline(cin, line);
		int Y = toInt(line);

		X--, Y--;
		go(X, Y);
		
		cout << "Data " << n << ":" << endl;
		for(int i = 0; i < 8; ++i)
			cout << field[i] << endl;
	}
	return 0;
}

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

#define INF 1E18

struct Edge{
    int to, id;
};

vector<vector<Edge>> graph;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1){
    int u;
    int k = 1;
    rep(i,graph[v].size()){
        int u =  graph[v][i].to; 
        int eid =  graph[v][i].id; 

        if(u == p) continue;
        if(k == c) k++;
        ans[eid] = k; k++;
        dfs(u, ans[eid], v);
    }
}


int main(){
    int n;
    cin >> n;
    graph.resize(n);
    ans.resize(n);
    rep(id,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back((Edge){b,(int)id});
        graph[b].push_back((Edge){a,(int)id});
    }

    dfs(0);

    int colorNo = 0;
    rep(i,n) colorNo = max(colorNo, (int)graph[i].size());
    
    cout << colorNo << endl;
    rep(i,n-1) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 8320
_ = input()
INPUT = list(map(int, input().split()))

def check_even(l):
    return sum([i % 2 for i in INPUT]) == 0

check_even(INPUT)

count = 0
while True:
    if check_even(INPUT):
        INPUT = [i / 2 for i in INPUT]
        count+=1
    else:
        break
print(count)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main() {
     string S;
     cin >> S;
     string ans = "AC";
     if(S[0] != 'A') ans = "WA";
     int L = S.size();
     int cnt = 0;
     for(int i = 1; i < L; i++){
          if(isupper(S[i])){
               if(i == 1 || i == L - 1 || S[i] != 'C') ans ="WA";
               cnt++;
          }
     }
     if(cnt != 1) ans = "WA";
     cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n[3];

    scanf("%d %d %d", &n[0], &n[1], &n[2]);

    int i, j, k;
    for(i = 0; i < 3; ++i)
    {
        j = n[i];
        k = i - 1;

        while(k >= 0 && n[k] > j)
        {
            n[k + 1] = n[k];
            k--;
        }

        n[k + 1] = j;
    }

    printf("%d %d %d\n", n[0], n[1], n[2]);

    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
    int N;
    cin >> N;
    int dig = to_string(N).size();
    double ans = dig % 2 ? N - pow(10, dig - 1) + 1 : 0;
    for (int i = 1; i < dig; i += 2) ans += 9 * pow(10, i - 1);
    cout << ans << endl;
}

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

int main() {
 int N;
 cin >> N;
 vector<int> P(N);
 rep(i,N){
     cin >> P[i];
 }
 int c = 0;
 std::priority_queue< int, std::vector<int>, std::greater<int> > pq;
 for(int i = 0;i<N;i++){
     pq.push(P[i]);
     if(pq.top() >= P[i]) c++;
 }
 cout << c << endl;
}


Measured memory_bytes: 2168
formula = input().split()
operand = ['+', '-', '*', '/']
stuck = []

for c in formula:
    if c in operand:
        b = str(stuck.pop())
        a = str(stuck.pop())
        stuck.append(eval(''.join([a, c, b])))
    else:
        stuck.append(c)

print(stuck.pop())



Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=2e5+5;

int n, t, ans=0, cur=0;
int a[N];

int32_t main()
{
	IOS;
	cin>>n>>t;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>cur)
			ans+=t;
		else
			ans+=(a[i]-a[i-1]);
		cur=a[i]+t;
	}
	ans+=t;
	cout<<ans;
	return 0;
}


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

using namespace std;


struct BinaryIndexedTree
{
  vector< int > data;

  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
  }

  int sum(int k)
  {
    int ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, int x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int main()
{
  long long N, M, K, L;
  char buff[12];

  while(scanf("%lld %lld %lld %lld", &N, &M, &K, &L), N) {

    vector< pair< int, string > > data(N);
    vector< int > toint(N);
    vector< string > priority(N);
    unordered_map< string, int > vv;
    vector< bool > like(N, false);

    for(int i = 0; i < N; i++) {
      int x;
      scanf(" %s %d", buff, &x);
      data[i] = make_pair(-x, buff);
      priority[i] = data[i].second;
    }
    sort(begin(priority), end(priority));
    sort(begin(data), end(data));


    for(int i = 0; i < N; i++) {
      toint[i] = lower_bound(begin(priority), end(priority), data[i].second) - begin(priority);
      vv[data[i].second] = i;
      data[i].first *= -1;
    }

    for(int i = 0; i < M; i++) {
      scanf("%s", buff);
      like[vv[buff]] = true;
    }

    BinaryIndexedTree bit(N);

    long long right = K, bottom = 0, up = 0;
    long long sz = 0, ret = 0, pre = -1;

    for(int i = 0; i < K; i++) {
      ret += like[i];
    }

    for(int i = K - 1; i >= 0; i--) {
      if(!like[i]) {
        while(right < N && !like[right]) ++right;
        if(right == N) break;
        L -= data[i].first - data[right].first;
        if(~pre) {
          L -= bottom * (data[i].first - pre);
          L -= up * (data[i].first - pre - 1); // kore sugoi
        }
        bit.add(toint[right], 1);
        bottom = bit.sum(toint[i]);
        up = bit.sum(N - 1) - bottom;
        pre = data[i].first;
        sz = 0;
        L -= up;
        if(L < 0) break;
        ++ret;
        ++right;
      } else {
        if(i == 0) break;
        bit.add(toint[i], 1);
        L -= ++sz * (data[i - 1].first - data[i].first);
      }
    }

    printf("%lld\n", ret);
  }

}

Measured memory_bytes: 16472
use std::io::*;
use std::str::FromStr;
use std::cmp;


macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }
 
 

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let s: String = read();
    println!("{}{}", 2018, &s[4..]);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  
  int a,b,ans; cin>>a>>b;
  
  cout<<(b>=a?"unsafe":"safe")<<endl;
  
}

Measured memory_bytes: 3636
L,R = map(int, input().split())
if(R-L > 2500):
	print(0)
else:
	ans = 2020
	for i in range(L, R+1):
		for j in range(i+1, R+1):
			ans = min(ans, ((i%2019)*(j%2019))%2019)
	print(ans)

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

int main () {
  int n;
  string s;
  cin >> n >> s;
  
  int a = n/2;
  string ans = "Yes";
  if (n%2 == 1) {
    ans = "No";
  }
  else {
    for (int i = 0; i < a; i++) {
      if (s[i] != s[a+i]) {
        ans = "No";
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main()
{
  int H,W;
  cin >> H >> W;
  vector<string> A(H);
  REP(i, H) cin >> A[i];
  
  int MAXans = 0;
  REP(i,H){
    REP(j,W){
      if(A.at(i).at(j)=='#'){
        continue;
      }
      vector<vector<int>> dist(H,vector<int>(W,-1));
      dist[i][j]=0;
      queue<P> que;
      que.push(make_pair(i,j));
      while(que.empty()==0){
        pair<int,int> v = que.front();
        que.pop();
        REP(k,4){
          if(v.first+dy[k]<0||v.second+dx[k]<0||v.first+dy[k]>H-1||v.second+dx[k]>W-1||A.at(v.first+dy[k]).at(v.second+dx[k])=='#'||dist.at(v.first+dy[k]).at(v.second+dx[k])!=-1){
            continue;
          }
          dist.at(v.first+dy[k]).at(v.second+dx[k])=dist.at(v.first).at(v.second)+1;
          que.push(make_pair(v.first+dy[k],v.second+dx[k]));
        }
      }
      int MAX = 0;
      REP(k,H){
        REP(l,W){
          MAX=max(MAX,dist.at(k).at(l));
        }
      }
      MAXans=max(MAXans,MAX);
    }
  }

  cout << MAXans << endl;
}

Measured memory_bytes: 256
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

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

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
const int MAX_N = 5005;
int n, z[MAX_N];
char s[MAX_N];
void input() {
    RI(n);
	scanf("%s", s);
}

void calz(int a) {
	int x=a, y=a;
	for(int i=a; i<n; i++) z[i]=0;

	for(int i=a+1; i<n; i++) {
		z[i]=max(0, min(z[a+i-x], y-i+1));
		while(i+z[i]<n && s[a+z[i]]==s[i+z[i]]) {
			x=i; y=i+z[i]; z[i]++;
		}
	}
}

// void calz() {
// 	int x=0, y=0;
// 	for(int i=0; i<n; i++) z[i]=0;
// 	for(int i=1; i<n; i++) {
// 		z[i]=max(0, min(z[i-x], y-i+1));
// 		while(i+z[i]<n && s[z[i]]==s[i+z[i]]) {
// 			x=i; y=i+z[i]; z[i]++;
// 		}
// 	}
// }

void solve() {
	int ans = 0;
	REP(i, n) {
		if(n-i <= 2*ans) break;
		calz(i);
		for(int j=i+1; j<n; j++) {
			ans = max(ans, min(j-i, z[j]));
		}
	}

	// while(n > 0) {
	// 	calz();
	// 	for(int j=0; j<n; j++) {
	// 		ans = max(ans, min(j, z[j]));
	// 	}
	// 	n--;
	// 	for (int i = 0; i < n; i++)
	// 		s[i] = s[i + 1];
	// }

	printf("%d\n", ans);
}

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> jobs[m];
  
  rep(i,n){
    int a,b;
    cin >> a >> b;
    if(a>m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for(int i=m-1;i>=0;i--){
    for(int b : jobs[i]){
      q.push(b);
    }
    if(!q.empty()){
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std ;
template< class T > inl T read() {
	T x = 0 ; int f = 1 ; char k = getchar() ;
	for( ; k > '9' || k < '0'; k = getchar() ) if( k == '-' ) f = -1 ;
	for( ; k >= '0' && k <= '9'; k = getchar() ) x = x * 10 + k - '0' ;
	return x * f ;
}
template< class T > inl T read( T &x ) { return x = read<T>() ; }
int _num, _buf[20];
template< class T > il print( T x ) {
   	if( x == 0 ) return putchar( '0' ) ,void() ;
	if( x < 0 ) putchar( '-' ), x = -x ;
	while( x ) _buf[++_num] = x % 10, x /= 10 ;
	while( _num ) putchar( _buf[_num--] + '0' ) ;
}
ll mul( ll a, ll b, ll mod ) { long double c = 1. ; return ( a * b - (ll)( c * a * b / mod ) * mod ) % mod ; }
it qpow( int x, int m, int mod ) {
	int res = 1, bas = x ;
	while(m) {
		if( m & 1 ) res = ( 1ll * res * bas ) % mod ;
		bas = ( 1ll * bas * bas ) % mod, m >>= 1 ;
	}
	return res ;
}
const int N = 2e5 + 5 ;
int n, m, u, v, pre[N], dist[N];
vector<int> G[N];
il Dijkstra() {
	queue<int> q;
	del( dist, 0x3f ) ;
	q.push( 1 ), dist[1] = 0 ;
	while( !q.empty() ) {
		int pos = q.front() ;
		q.pop() ;
		for( auto v: G[pos] ) {
			if( dist[v] != INF ) continue ;
			dist[v] = dist[pos] + 1 ;
			pre[v] = pos ;
			q.push( v ) ;
		}
	}
}
int main() {
//	freopen( ".in", "r", stdin ) ;
//	freopen( ".out", "w", stdout ) ;
	n = read<int>(), m = read<int>() ;
	for( ri i = 1; i <= m; ++i ) {
		u = read<int>(), v = read<int>() ;
		G[u].push_back( v ), G[v].push_back( u ) ;
	}
	Dijkstra() ;
	for( ri i = 2; i <= n; ++i ) if( dist[i] == INF )
		return puts( "No" ), 0 ;
	puts( "Yes" ) ;
	for( ri i = 2; i <= n; ++i )
		print( pre[i] ), puts( "" ) ;
	cerr << 1. * clock() / CLOCKS_PER_SEC << "\n" ;
	return 0;
}

Measured memory_bytes: 13728
import java.util.*;

public class Main {

    // global
    static long fact[];
    static long inverse[];
    static int mod = 998244353;

    static long pow(long a,int n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a%mod;
            }
            a=a*a%mod;
            n>>=1;
        }
        return res;
    }

    static long modinv(long n) {
        return pow(n, mod-2);
    }

    static long comb(int n,int k){
        if(n<0 || k<0 || n<k)return 0;
        return fact[n]*(inverse[k]*inverse[n-k]%mod) %mod;
    }

    public static void main(String[] args) {
        // main method
        fact=new long[300000];
        fact[0]=1;
        inverse=new long[300000];
        inverse[0]=1;
        for(int i=1;i<300000;i++){
            fact[i]=(fact[i-1]*(long)i)%mod;
            inverse[i]=modinv(fact[i]);
        }
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = sc.nextInt();

        long ans = 0L;

        for (int i=0;i<=K;i++) {
            ans =  (ans+comb(N-1, i)*M%mod*pow(M-1, N-1-i)%mod)%mod;
        }
        System.out.println(ans);
    }
}

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

int main(){
	int a,b,c;
	int ans;
	bool flg;
	int cnt=-1;
	
	while(cin>>a>>b){
		cnt++;flg=false;
		//-----test-----
		switch(cnt){
		case 0:
			if(!(950000<a)) flg=true; 
			break;
		}
		
		if(flg) break;
		
		//--------------
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string[] line = S.Split(' ');
            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);
            int C = int.Parse(line[2]);
            if(A == B && B == C)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "Yes" << endl;
  exit(0);
}

void no() {
  cout << "No" << endl;
  exit(0);
}

int main() {
  string s;
  cin >> s;
  sort(ALL(s));
  if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
    yes();
  }
  no();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int AX = 3e5+66;
LL a[AX];
LL b[AX];
LL c[AX];
int n ;	
 
LL Binary(LL k)
{
    int l = 1 , r = n + 1;
    while( l < r ){
        int mid = ( l + r ) >> 1;
        if(c[mid] >= k) r = mid ; 
        else l = mid + 1 ;
    }
    return l;
}
 
int main(){
	//freopen("pp.in", "r", stdin);
	//freopen("std.out", "w", stdout);
	cin >> n ;
	for( int i = 1 ; i <= n ; i++ ){
		cin >> a[i];
	}
	for( int i = 1 ; i <= n ; i++ ){
		cin >> b[i];
	}
	LL res = 0 ;
	for( int k = 1 ; k <= 29 ; k ++ ){
		LL tmp = (1<<k) - 1;
		for( int i = 1 ; i <= n ; i++ ){
			c[i] = b[i] & tmp;
		}
		LL cnt = 0;
		sort( c + 1, c + n + 1 );
		for( int i = 1 ; i <= n ; i++ ){
			cnt += n - Binary( ( (1<<(k-1)) -(tmp & a[i]) ) )+1;
		}
		for( int i = 1 ; i <= n ; i++ ){
			cnt -= Binary( (1<<k)+(1<<(k-1))-(tmp&a[i])) - Binary((1<<k)-(tmp&a[i]));
		}
		if( cnt & 1 ) res += (1<<(k-1));
	}
	cout << res << endl;
	return 0 ;
}

Measured memory_bytes: 6016
n = int(input())

zoro = 0
isZoro = False
for _ in range(n):
	d1, d2 = map(int, input().split())
	if d1 == d2:
		zoro += 1
	else:
		zoro = 0

	if zoro >= 3:
		isZoro = True
		break
		
if isZoro:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0;; i++)
    {
        sum += i;
        if (sum >= n)
        {
            int d = sum - n;
            for (int j = 1; j <= i; j++)
            {
                if (j != d)
                    cout << j << endl;
            }
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
const long long inf=1e9+7;
const long long mod=1e9+7;
const int64_t CYCLES_PER_SEC=2800000000;
//
inline uint32_t Xor128(){
	static uint32_t x=123456789;
	static uint32_t y=362436069;
	static uint32_t z=521288629;
	static uint32_t w=88675123;
	uint32_t t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct Timer{
	int64_t start;
	Timer(){reset();}
	void reset(){start=getcycle();}
	void plus(double a){start-=(a*CYCLES_PER_SEC);}
	inline double get(){return (double)(getcycle()-start)/CYCLES_PER_SEC;}
	inline int64_t getcycle(){
		uint32_t low,high;
		__asm__ volatile ("rdtsc":"=a"(low),"=d"(high));
		return ((int64_t)low)|((int64_t)high<<32);
	}
};
//
int main(){
	int n;
	string s;
	cin>>n>>s;
	char a='A';
	for(int i=0;i<s.size();i++){
		int m=s[i]-a;
		m+=n;
		m%=26;
		char b='A'+m;
		cout<<b;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto i : x){cerr << " [" << i << "]";} cerr << "\n";
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vii = vector<pii>;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18 + 100;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vii a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i].second >> a[i].first;
	}
	sort(a.begin(), a.end());
	int prev = 0;
	for (int i = 0; i < n; i++){
		if(a[i].second + prev > a[i].first){
			cout << "No\n";
			return 0;
		} 
		prev += a[i].second;
	}
	cout << "Yes\n";
	return 0;
}
 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int a[n],q,w,e,r,t;
    for(int i=0;i<n;i++){
      cin>>q>>w>>e>>r>>t;
      a[i]=q+w+e+r+t;
    }
    sort(a,a+n);
    cout<<a[n-1]<<' '<<a[0]<<endl;
  }
}

Measured memory_bytes: 3056
n, k = gets.chomp.split(" ").map {|item| item.to_i }
def XSquare(val, target_val)
    squre = 1
    loop do
        hoge = val * 2 ** squre
        if hoge >= target_val
            return squre
        else
        end
        squre += 1
    end
end

parcent = 0.0
if n >= k
    parcent += (n-k+1).to_f / n
    for i in 1..k-1
        need_square = XSquare(i, k)
        parcent += (1.0/n) * ((1.0/2) ** need_square)
    end
else
    for i in 1..n
        need_square = XSquare(i, k)
        parcent += (1.0/n) * ((1.0/2) ** need_square)
    end
end
puts parcent

Measured memory_bytes: 1788
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func Max3(x, y, z int) int {
	if m := Max(x, y); m > z {
		return m
	} else {
		return z
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	//sc.Buffer(nil, 100000000)

	n := nextInt()

	l := make([]int, n)
	for i := 0; i < n; i++ {
		l[i] = nextInt()
	}

	ans := 0
	for i := 0; i < n-2; i++ {
		for j := i + 1; j < n-1; j++ {
			if l[i] == l[j] {
				continue
			}
			for k := j + 1; k < n; k++ {
				if l[i] == l[k] || l[j] == l[k] {
					continue
				}
				max := Max3(l[i], l[j], l[k])
				if l[i] == max {
					if max >= l[j]+l[k] {
						continue
					}
				} else if l[j] == max {
					if max >= l[i]+l[k] {
						continue
					}

				} else {
					if max >= l[i]+l[j] {
						continue
					}
				}

				ans += 1
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1776
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node );
Node treeSearch(Node , int );
Node treeSuccessor(Node );
void insert(int );
void inorder(Node );
void preorder(Node );

int main(void){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL )
	printf("yes\n");
      else
	printf("no\n");
    }

    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}


Node treeMinimum(Node x){

  while(x->left != NIL)
    x = x->left;

  return x;
  
}

Node treeSearch(Node u, int k){
  if(u == NIL || k != u->key)
    return u;
  
  if(k < u->key)
    return treeSearch(u->left, k);
  
  else
    return treeSearch(u->right, k);
  
}

Node treeSuccessor(Node x){
  
  Node y;

  if(x->right != NIL)
    return treeMinimum(x->right);

  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }

  return y;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;

    else
      x = x->right;
  }
  
  z->parent = y;

  if(y == NIL)
    root = z;

  else if(z->key < y->key)
    y->left = z;

  else
    y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}

Measured memory_bytes: 24040
s=list(input())
n=len(s)
k=int(input())
a=[]
for i in range(n):
  if i==n-1:
    s[i]=chr(97+(ord(s[i])-97+k)%26)
    break
  if s[i]=="a":continue
  t=26-(ord(s[i])-97)%26
  if t>k:continue
  k-=min(t,k)
  s[i]=chr(97+(ord(s[i])-97+t)%26)
print("".join(s))

Measured memory_bytes: 4152
#include <stdio.h>

int Sum(int n);

int main(){
    int N;
    scanf("%d", &N);
    int min = N;

    for(int i = 1; i <= N/2; i++){
        if(min > Sum(i) + Sum(N - i)){
            min = Sum(i) + Sum(N - i);
        }
    }

    printf("%d\n", min);
    return 0;
}

int Sum(int n){
    int sum = 0;

    for(int i = n; i > 0; i /= 10){
        sum += i % 10;
    }

    return sum;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {

	int s; cin >> s;
	vector<int> dp(s + 1, 0);
	dp[0] = 1;
	for (int to = 3; to <= s; to++) {
		for (int from = to - 3; from >= 0; from--) {
			dp[to] += dp[from];
			dp[to] %= mod;
		}
	}
	cout << dp[s] << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
//NIL is NULL
#define NIL NULL
//Node structure
struct Node{
  int key;
  struct Node *parent;
  struct Node *leftc;
  struct Node *rightc;
};
//define Nodepointer
typedef struct Node * Nodepointer;

//root
Nodepointer root;

//function insert   
void insert(int k){
  Nodepointer x,y,z;
  y=NIL;
  x=root;
  //make memory
  z=new struct Node();

  z->key=k;
  z->leftc=NIL;
  z->rightc=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->leftc;
    else x=x->rightc;
  }

  z->parent=y;

  if(y==NIL) root=z;

  else if(z->key<y->key) y->leftc=z;

  else y->rightc=z;


}

//function search
Nodepointer find(Nodepointer now,int data){
  if(now==NIL||data==now->key) return now;
  if(data<now->key) return find(now->leftc,data);
  else return find(now->rightc,data);
}
//print
void inorderprint(Nodepointer now){
  if(now!=NIL){
    inorderprint(now->leftc);
    printf(" %d",now->key);
    inorderprint(now->rightc);
  }
}

void preorderprint(Nodepointer now){
  if(now!=NIL){
    printf(" %d",now->key);
    preorderprint(now->leftc);
    preorderprint(now->rightc);
  }
}


int main(){

  int n,i,j,data;

  char str[10];
  //load n
  scanf("%d",&n);
  //load commnad and key
  for(i=0;i<n;i++){
    scanf("%s",str);
    //insert
    if(strcmp(str,"insert")==0) {
      scanf("%d",&data);
      insert(data);
    }
    //find
    else if(strcmp(str,"find")==0){
      scanf("%d",&data);
      if(find(root,data)!=NIL) printf("yes\n");
      else printf("no\n");
    }
    //print
    else if(strcmp(str,"print")==0){
      inorderprint(root);
      cout <<endl;
      preorderprint(root);
      cout <<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 10000
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    D = int(input())
    c = [int(a) for a in input().split()]
    s = [
        [int(a) for a in input().split()]
        for _ in range(D)
    ]
    t = [
        int(input())
        for _ in range(D)
    ]
    M = int(input())
    dq = [
        [int(a) for a in input().split()]
        for _ in range(M)
    ]

    def calc_score(t):
        score = 0
        last = [0] * len(c)
        res = []

        for d, ti in enumerate(t):
            sdi = s[d][ti - 1]
            score += sdi
            last[ti - 1] = d + 1
            for i, ci in enumerate(c):
                score -= ci * ((d + 1) - last[i])
            res.append(score)
        return res

    def calc_score_diff(t, di, qi):
        old_q = t[di - 1]
        last_old_q_date = 0
        for i in range(di - 2, -1, -1):
            if t[i] == old_q:
                last_old_q_date = i + 1
                break
        next_old_q_date = D + 1
        for i in range(di, D):
            if t[i] == old_q:
                next_old_q_date = i + 1
                break

        old_d_last = di - last_old_q_date
        old_d_next = next_old_q_date - di
        old_diff = old_d_next * old_d_last * c[old_q - 1]

        new_q = qi
        last_new_q_date = 0
        for i in range(di - 2, -1, -1):
            if t[i] == new_q:
                last_new_q_date = i + 1
                break
        next_new_q_date = D + 1
        for i in range(di, D):
            if t[i] == new_q:
                next_new_q_date = i + 1
                break

        new_d_last = di - last_new_q_date
        new_d_next = next_new_q_date - di
        new_diff = new_d_next * new_d_last * c[new_q - 1]

        old_score = s[di - 1][old_q - 1]
        new_score = s[di - 1][new_q - 1]
        return new_diff - old_diff + new_score - old_score

    score = calc_score(t)[-1]
    for di, qi in dq:
        diff = calc_score_diff(t, di, qi)
        score += diff
        print(score)
        t[di - 1] = qi


if __name__ == "__main__":
    main()


Measured memory_bytes: 90344
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100003;
ll i,n,a,b;
vector<vi> adj(N);
ll dp[N][2];
ll go(ll v,ll par,ll p)
{
    if(dp[v][p] != -1)
        return dp[v][p];
        
    ll res = 1;
    if(p == 1){
        for(auto it: adj[v]) if(it != par)
            res = (res * go(it,v,0)) % mod;
    }
    else{
        for(auto it: adj[v]) if(it != par)
            res = (res * (go(it,v,0) + go(it,v,1)) % mod) % mod;
    }
    return dp[v][p] = res;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>n;
    rep(i,1,n){
        cin>>a>>b;
        adj[a].pb(b); adj[b].pb(a);
    }
    cout<<(go(1,1,0) + go(1,1,1)) % mod;
    return 0;
}

Measured memory_bytes: 19840
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    if (n == 1) {
      System.out.println(0);
      return;
    }
    TreeSet<Long> set = getSet();

    long result = 0;
    for (long i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        int count = 0;
        while (n % i == 0) {
          n /= i;
          count++;
        }
        result += set.headSet((long) count, true).size();
      }
    }
    System.out.println(n > 1 ? result + 1 : result);
  }

  static TreeSet<Long> getSet() {
    TreeSet<Long> r = new TreeSet<>();
    long sum = 0;
    for (int i = 1; sum < 40; i++) {
      sum += i;
      r.add(sum);
    }
    return r;
  }
}

Measured memory_bytes: 27200
N = int(input())
c_range = -(-N // 4) + 1
d_range = -(-N // 7) + 1
for d in range(d_range):
    for c in range(c_range):
        if c * 4 + d * 7 == N:
            print('Yes')
            break
    else:
        continue
    break
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int ans1=min(A,B);
    int ans2=min(C,D);
    cout<<ans1+ans2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 3500;

map <ll,ll> mp;

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    for(int i=0; i<n; i++) {
        ll x;
        scanf("%lld", &x);
        ans += mp[i-x];
        mp[x+i]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 26288
n, m = map(int, input().split())
H = list(map(int, input().split()))

is_best = [True] * n


for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    is_best[a] &= H[a] > H[b]
    is_best[b] &= H[a] < H[b]

print(is_best.count(True))


Measured memory_bytes: 86340
#include <iostream>
#include <array>
#include <vector>
#include <map>
#include <utility>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <string>
#include <limits.h>

using namespace std;



int main(){
    
    string a,b;
    
    int n;
    cin >> n;
    
    cin>> a>> b;
    
    auto min2 = min(a.length()
                    , b.length()) ;

    
    size_t ret = (a.length()+b.length()) ;
    for (int i = 0; i < a.length(); i++) {
        for (int j = 1; j <= b.length(); j++) {
            if (a.substr(i) == b.substr(0,j)) {
                ret = min(ret, a.length() +b.length()-  j);
            }
        }
    }
    
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import pprint
from collections import deque

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n, m = map(int, sys.stdin.readline().split())
	graph = [[] for i in range(n)]
	for i in range(m):
		ai, bi = map(int, sys.stdin.readline().split())
		graph[ai-1].append(bi-1)
		graph[bi-1].append(ai-1)
	stack = deque([0])
	dist = [-1]*len(graph)
	ans = [-1]*n
	log.print(graph)
	while len(stack) != 0:
		v = stack.popleft()
		d = dist[v]
		nexts = graph[v]
		for next in nexts:
			if dist[next] != -1:
				continue
			dist[next] = d + 1
			ans[next] = v
			stack.append(next)
	if -1 in ans:
		print("No")
	else:
		print("Yes")
		for i in range(1, n):
			print(ans[i]+1)

	


main()

Measured memory_bytes: 97944
#include<stdio.h>
int main(){
  int i,n,a[100001]={},t,x=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&t);if(t<100001)a[t]++;else a[0]++;}
  for(i=0;i<100001;i++){if(a[i]<i)x+=a[i];if(a[i]>i)x+=a[i]-i;}
  printf("%d",x);
}


Measured memory_bytes: 2128
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

vs in;
vector<vs>d;
bool dfs(int a,int b){
    // cout<<a<<" "<<b<<endl;rep(i,4)cout<<in[i]<<endl;cout<<endl;
    if(a==b&&dfs(a+1,b))return true;
    if(a==4)return b==3;
    vs w=d[a];
    int n=w.size(),m=w[0].size();
    rep(i,5-n)rep(j,11-m){
        bool h=true;
        rep(x,n)rep(y,m)if(w[x][y]=='#'&&in[i+x][j+y]=='#')h=false;
        if(h){
            rep(x,n)rep(y,m)if(w[x][y]=='#')in[i+x][j+y]='#';
            if(dfs(a+1,b+1))return true;
            rep(x,n)rep(y,m)if(w[x][y]=='#')in[i+x][j+y]='.';
        }
    }
    return false;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    rep(i,4){
        int a,b;
        cin>>a>>b;
        vs t(a);
        cin>>t;
        d.pb(t);
    }
    int q;
    cin>>q;
    while(q--){
        in=vs(4);
        cin>>in;
        if(dfs(0,0))yes;else no;
    }
}



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

int main(){
	long long l, r; cin >> l >> r;
	int ans = 2019;
	if(r - l >= 2019){
		cout << 0 << endl;
		return 0;
	}
	else{
		for(long long i = l; i < r; ++i){
			for(long long j = i+1; j <= r; ++j){
				int tmp = i * j % 2019;
				ans = min(ans , tmp);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
S=input()
T=input()
min_lts = len(S)
for i in range(len(S)-len(T)+1):
  count = 0
  for k in range(len(T)):
    if S[i+k] != T[k]:
      count = count + 1
  min_lts = min([min_lts,count])

print(min_lts)

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


int a[300005];
int main()
{
    int n, x;
    cin >> n >> x;
    if (x == n*2-1 || x == 1)
    {
        cout << "No";
        return 0;
    }

    if (n == 2)
    {
        cout << "Yes\n1\n2\n3";
        return 0;
    }

    a[n] = x;
    a[n-1] = x-1;
    a[n+1] = x+1;
    int idx, val;
    if (x == 2)
    {
        idx = n-2;
        val = 4;
        while(idx != n+1)
        {
            a[idx] = val;
            idx--;
            val++;
            if (idx == 0) idx = 2*n-1;
        }
    }
    else
    {
        idx = n+2;
        val = x-2;
        while(idx != n-1)
        {
            a[idx] = val;
            idx++;
            val--;
            if (idx == 2*n) idx = 1;
            if (val == 0) val = 2*n-1;
        }

    }

    cout << "Yes\n";
    for (int i = 1; i <= 2*n-1; i++)
        cout << a[i] << endl;

    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, k;
int a[100000], b[100000];

int main() {
    scanf("%d%d", &n, &k);
    forn(i, n) scanf("%d%d", a + i, b + i);
    int num = 0;
    LL ans = 0;
    for (int i = 29; i >= 0; --i) {
        num ^= (1 << i);
        if (k & (1 << i)) {
            LL cur = 0;
            forn(i, n) if (!(a[i] & num)) {
                cur += b[i];
            }
            ans = max(ans, cur);
            num ^= (1 << i);
        }
    }
    LL cur = 0;
    forn(i, n) if (!(a[i] & num)) {
        cur += b[i];
    }
    ans = max(ans, cur);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;

int main(){
	int r, g, b, n, ans = 0;
	scanf("%d %d %d %d", &r, &g, &b, &n);
	for(int i=0; i<=n; i++){
		for(int j=0; j<=n; j++){
			if(i*r + j*g > n) continue;
			if((n-i*r-j*g)%b==0) ans++;
		}
	}
	printf("%d\n", ans);
}


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


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


void solve() {
	int a, b; cin >> a >> b;
	int c = 0;
	for (int i = 0; i < 2; i++) {
		if (a < b) { c += b; b--; }
		else { c += a; a--; }
	}
	cout << c << endl;
}

int main() {


	solve();


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int S;
        cin >> S;
      
      int A = S/100;
      int B = (S%100)/10;
      int C = (((S)%100)%10)/1;
      
      cout << A+B+C << endl;
    }

Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split())) + [0]

cnt = 0
while 1:
    if len(h) == 0:
        break
    elif h[0] == 0:
        h.pop(0)
    else:
        i = h.index(0)
        h[:i] = [tmp -1 for tmp in h[:i]]
        cnt +=1
print(cnt)

Measured memory_bytes: 3064
s = input()
chk1 = True
chk2 = True
for i in range(0, len(s)):
    if i % 2 == 0:
        if s[i] == 'L':
            chk1 = False
            break
    else:
        if s[i] == 'R':
            chk2 = False
            break
if chk1 == True and chk2 == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
// AtCoder Regular Contest 069
// E - Frequency

#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAX_N 100000
using namespace std;
typedef long long int ll;
typedef pair<ll, int> PLI;


int N;
PLI m[MAX_N + 1];
ll ans[MAX_N];

int main() {

  ll cnt;
  int min_i;

  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &m[i].first);
    m[i].second = i;
  }
  m[N] = PLI(0, -1);
  memset(ans, 0, sizeof(ans));
  sort(m, m + N + 1);

  min_i = N;
  cnt = 0;
  for (int i = N; i > 0; i--) {
    min_i = min(min_i, m[i].second);
    ans[min_i] += (m[i].first - m[i - 1].first) * (cnt + 1);
    cnt++;
  }

  for (int i = 0; i < N; i++) {
    printf("%lld\n", ans[i]);
  }

  return 0;

}




Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int H, N;
	cin >> H >> N;
	int a;
	for(int i = 0; i < N; i++){
		cin >> a;
		H -= a;
		if(H <= 0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3620
def find(n):
    if parent[n] < 0:
        return n
    else:
        parent[n] = find(parent[n])
        return parent[n]


def union(x, y):
    root_x = find(x)
    root_y = find(y)
    if root_x == root_y:
        return
    if parent[root_x] > parent[root_y]:
        root_x, root_y = root_y, root_x
    parent[root_x] += parent[root_y]
    parent[root_y] = root_x


def get_size(x):
    return -parent[find(x)]


n, m = map(int, input().split())
parent = [-1 for _ in range(n)]

for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    union(a, b)
ans = 0
for i in range(n):
    ans = max(ans, get_size(i))
print(ans)


Measured memory_bytes: 14780
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

const double PI=4*atan(1.0);

int main(){

    double r;
    while(cin>>r&&!EQ(r,0)){
        bool f=false;
        for(int i = 1; ; i++){
            for(int j = i*2; !(((double)j/i)>PI+r+EPS); j++){
                if(EQ(abs(((double)j/i)-PI),r)||abs(((double)j/i)-PI)<r){
                    f=true;
                    cout<<j<<"/"<<i<<endl;
                    break;
                }
            }
            if(f)
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 948