akhauriyash/Code-Regression huggingface dataset:
prime[50000],n,j,c;main(i){for(i=2;i<25002;i++)if(!prime[i])for(j=i+i;j<50000;j+=i)prime[j]=1;for(;c=!scanf("%d",&n),n;printf("%d\n",c))for(i=1;i++<n/2;)for(j=i;i+j<=n;j++)if(i+j==n&&!prime[i]&&!prime[j])c++;exit(0);}

Measured memory_bytes: 792
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;



int main() {
	int n, m;
	cin >> n >> m;

	vector<int> cost{ 100,2,5,5,4,5,6,3,7,6 };

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

	sort(a.begin(), a.end(),greater<int>());

	vector<int> dp(n+1);
	for (int i = 1; i <= n;i++) {
		dp[i] = -100000000;
		for (int j = 0; j < m;j++) {
			if (i >= cost[a[j]]) {
				dp[i] = max(dp[i - cost[a[j]]]+1, dp[i]);
			}
		}
		//cout << dp[i] << endl;
	}


	
	string s;
	for (int i = n; i > 0;) {
		for (int j = 0; j < m;j++) {

			
			if (i >= cost[a[j]] && dp[i-cost[a[j]]] == (dp[i] -1)) {
				s += ('0' + a[j]);
				i -= cost[a[j]];
				
				break;
				
			}
		}
		

	}
	
	cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    char w[110];
    int s[26]={0};
    cin>>w;
    for(int i=0;w[i]!='\0';i++){
        s[w[i]-'a']++;
    }
    rep(i,26){
        if(s[i]%2!=0){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 3580
N = gets.chomp.split("").map(&:to_i)

c = 0
for i in 0..1 do
  c += 1 if N[i] == N[i + 1] && N[i + 1] == N[i + 2]
end

if c >= 1 then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n)	for(int i=0;i<n;i++)
#define frr(i,n)	for(int i=1;i<=n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x) cout << #x << " = " << x << endl
#define all(x) x.begin(),x.end()

#define gnl cout << endl
#define olar cout << "olar" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


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

const int INF = 0x3f3f3f3f;

int ans[100100];
int d[3000][3000];

int main(){
    fastio;
    int n,x,y;
    cin >> n >> x >> y;
    for(int i = 1; i<=n; i++){
        for(int j = i+1; j<=n; j++){
            int opcao1 = abs(i-j);
            int opcao2 = abs(i-x)+abs(j-y)+1;
            int opcao3 = abs(y-i)+abs(x-j)+1;
            d[i][j] = min(opcao1,opcao2);
            d[i][j] = min(d[i][j], opcao3);
            ans[d[i][j]]++;
        }
    }
    for(int i = 1; i<=n-1; i++){
        cout << ans[i] << endl;
    }
    

}

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

#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int inf = 1e16 + 2;



void solve(int z) {
    int n ,  k;
    cin >> n >> k;
    int arr[n + 1];
    for(int i = 1; i <= n ; i ++) cin >> arr[i];
    set<int> s;
    vector<int> ans;
    int idx = 1 , y = 0;
    while(true) {
        if(k == 1) {
            k --;
            y = arr[idx];
            break;
        }
        if(s.find(arr[idx]) != s.end()) {
            k -- ;
            y = arr[idx];
            break;
        }
        ans.push_back(arr[idx]);
        s.insert(arr[idx]);
        k --;
        idx = arr[idx];
    }
    if(k == 0) cout << y;
    else {
        int sz = ans.size();
        for(int i = 0; i < ans.size() ; i ++) {
            if(ans[i] == y) {
                sz -= i;
                int t = k % sz;
                y = ans[i + t];
                break;
            }
        }
        cout << y;
    }
}

/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int x = 1;
    while(testcase --) {
        solve(x ++);
    }
    
    return 0;
}
 



Measured memory_bytes: 13536
#include <iostream>
#include <string>
#include <algorithm>

//answer3 function
void display(const char& ch) {
	std::cout << ch;
}

int main(){
	std::string str;
	std::cin >> str;
	
	//answer1
	//for(auto it = str.crbegin(); it != str.crend(); ++it){
	//	std::cout << *it;
	//}
	
	
	//answer2
	std::for_each(str.crbegin(), str.crend(), [](const char& ch){ std::cout << ch; });
	
	//answer3
	//std::for_each(str.crbegin(), str.crend(), display);
	
	std::cout << std::endl;
	
	return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>
#include<string.h>  
#include<math.h>  
  
//#include<map>   
//#include<set>
#include<deque>  
#include<queue>  
#include<stack>  
#include<bitset> 
#include<string>  
#include<iostream>  
#include<algorithm>  
using namespace std;  
  
#define ll long long  
#define INF 0x3f3f3f3f  
#define mod 1000000
#define clean(a,b) memset(a,b,sizeof(a))// 水印 
//spfa
//https://cn.vjudge.net/contest/239171#problem/C 

using namespace std;
//const int maxn=10005;
const int inf=0x3f3f3f3f;
int N,M,k;
int head[10100],cost[10100],dis[10100];
bool vst[10100];
struct node{
    int to,next,dis,cost;
}edge[50100];
void addEdge(int a,int b,int dis,int cost)
{
    edge[k].to=b;
    edge[k].dis=dis;
    edge[k].cost=cost;
    edge[k].next=head[a];
    head[a]=k;
    k++;
}
void spfa(int x)
{
	clean(dis,INF);
	clean(vst,0);
	clean(cost,INF);
//    memset(dis,inf,sizeof(dis));
//    memset(vst,0,sizeof(vst));
//    memset(cost,inf,sizeof(cost));
    queue<int> q;
    dis[x]=0;
    cost[x]=0;
    q.push(x);
    while(!q.empty())
	{
        x=q.front();q.pop();
        vst[x]=0;
        for(int i=head[x];i!=-1;i=edge[i].next)
		{
            node b=edge[i];
            if(dis[b.to]>dis[x]+b.dis)
			{
                if(!vst[b.to])
				{
                    vst[b.to]=1;
                    q.push(b.to);
                }
                dis[b.to]=dis[x]+b.dis;
                cost[b.to]=b.cost;
            }
			else if(dis[b.to]==dis[x]+b.dis)
			{
                if(cost[b.to]>b.cost)
                    cost[b.to]=b.cost;
            }
        }
    }
}

int main()
{
    while(cin>>N>>M,N)
	{
        clean(head,-1);
        k=0;
        for(int i=0;i<M;i++){
            int a,b,d,c;
            cin>>a>>b>>d>>c;
            addEdge(a,b,d,c);
            addEdge(b,a,d,c);
        }
        spfa(1);
        long long re=0;
        for(int i=1;i<=N;i++){
            re+=cost[i];
        }
        cout<<re<<endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main() {
    ll L, R;
    cin >> L >> R;
    if (R - L >= 2050) cout << 0 << endl;
    else {
        ll ans = 2018;
        for (ll i = L; i < R; i++)
            for (ll j = i + 1; j <= R; j++) {
                ans = min(ans, (i * j) % 2019);
            }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  int i=1;
  while(i<=n){
    i*=2;
  }
  P(i/2);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
 
 
//c++ templte for help...........................................................
 
//#define deb(x) cout<<#x<<" "<<x<<endl;/* for debuging  printing variable with name*/
//#define debb(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;										
//#define debbb(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;			
 
typedef long long ll;
	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
//#define modulo 998244353
//const int INF=1e9+5;
 
 
 
 
//c++ template for help........................................................

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	//cout<<setprecision(2);
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 // greedy ma jadatr exceptional case check kr ke dekh lo
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
	 // KYA KYA CHEJ IMPORTANT HA WO STATE BN JYAGA AUR HUM LOG STATE KO CHANGE KR SKTA HA JYSA KNPSACK 2 WALE PROBLEM MA KIA THA
	 
	ll testCase;
	cin>>testCase;
	set<string> st;
	for(ll tt=0;tt<testCase;tt++){
		
		string s;
		cin>>s;
	
		st.insert(s);
		
	}
	
	cout<<st.size()<<endl;
		
		
		
		
	 

	return 0;
}


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

using namespace std;

typedef long long int ll;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    map<ll,int>m;
    m[a]++;
    m[b]++;
    m[c]++;
    if(m[a]==1)cout<<a;
    else if(m[b]==1)cout<<b;
    else  cout<<c;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll b[11]={2,3,5,7,11,13,17,19,23,29,31};
 int main()
 {
 	ll i,j,n,m,k,s=0,mx=INT_MIN,a,b,c=0,ro,mi=INT_MIN;
 	cin>>n>>m;
 	vector<ll> v1,vn;
 	for(i=0;i<m;i++)
 	{
 		cin>>a>>b;
 		if(a==1) v1.push_back(b);
 		if(b==1) v1.push_back(a); 
 		if(a==n) vn.push_back(b);
 		if(b==n) vn.push_back(a);
	 }
	 sort(v1.begin(),v1.end());
	 sort(vn.begin(),vn.end());
	 for(i=0;i<v1.size();i++)
	 {
	 	if(binary_search(vn.begin(),vn.end(),v1[i]))
	 	{
	 		c=1;break;
		 }
	 }
	 if(c==1) cout<<"POSSIBLE\n";
	 else cout<<"IMPOSSIBLE\n";
	 
 }

Measured memory_bytes: 1984
import math
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
ans=0

for i in range(n):
    for j in range(i+1,n):
        ans+=math.sqrt((l[i][0]-l[j][0])**2+(l[i][1]-l[j][1])**2)
ans=(ans/n)*2
print(ans)

Measured memory_bytes: 3064
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(int, char**)
{
	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;
	S[K - 1] += 0x20;
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  char *a;
  int i;
  a=malloc(sizeof(char)*400000000);
long int b=0;
scanf("%s",a);
for(i=0;a[i]!='\0';i++){
b = b + (a[i]-'0');
}
if(b%9)
  printf("No");
else printf("Yes");
return 0;
}


Measured memory_bytes: 1924
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int N,K;
bool dp[100001];

int main(void) {
    cin>>N>>K;
    vector<int> a(N);


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

    for(int i = 1;i <= K;i++) {
        for(int j = 0;j < N;j++) {
            if(i - a[j] >= 0)
                dp[i] |= !dp[i-a[j]];
        }
    }

    if(dp[K])
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;

    return 0;
}




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

bool f(int x){
    int tmp = x, r = 0;
    while(tmp > 0){
        r *= 10;
        r += tmp%10;
        tmp /= 10;
    }
    return x==r;
}

int main() {
    int n, ans = 0;
    cin >> n;
    REP(i,n*3){
        if(f(i)){
            if(abs(n-ans) > abs(n-i)){
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3124
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]

zoro = 0
now = 0
for i in range(n):
    if d[i][0] == d[i][1]:
        now += 1
        zoro = max(zoro,now)
    else:
        now = 0
if zoro >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184
#ABC149.B
A,B,K = map(int,input().split())
if K<=A:
    print(A-K)
    print(B)
elif A < K and B-(K-A) >=0:
    print(0)
    print(B-(K-A))
elif A <K and B-K-A<0:
    print(0)
    print(0)

Measured memory_bytes: 3060
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 ) *} } ;}
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 ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn rec(i: usize, j: usize, k: usize, n: usize, dp: &mut Vec<Vec<Vec<f64>>>) -> f64 {
   if dp[i][j][k] >= 0.0 {
      dp[i][j][k]
   } else if i == 0 && j == 0 && k == 0 {
      0.0
   } else {
      let mut res = 0.0f64;
      if i > 0 {
         res += rec(i - 1, j, k, n, dp) * i as f64;
      }
      if j > 0 {
         res += rec(i + 1, j - 1, k, n, dp) * j as f64;
      }
      if k > 0 {
         res += rec(i, j + 1, k - 1, n, dp) * k as f64;
      }
      res += n as f64;
      res /= (i + j + k) as f64;
      dp[i][j][k] = res;
      res
   }
}

fn main() {
   input! {
      n: usize,
      a: [usize; n]
   }

   let mut nums = vec![0; 3];
   for &a in a.iter() {
      nums[a - 1] += 1;
   }
   let mut dp = vec![vec![vec![-1.0_f64; 305]; 305]; 305];
   let ans = rec(nums[0], nums[1], nums[2], n, &mut dp);
   println!("{}", ans);
}


Measured memory_bytes: 243964
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        PriorityQueue<Double> v = new PriorityQueue<Double>();

        for (int i = 0; i < n; i++) {
            v.add(scanner.nextDouble());
        }

        for (int i = 0; i < n - 1; i++) {
            double tmp1 = v.poll();
            double tmp2 = v.poll();

            v.add((tmp1 + tmp2) / 2);
        }
        System.out.println(v.poll());

    }
}


Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int N;

ll s(ll x) {
	ll ret = 0;
	while (x > 0) ret += x%10, x /= 10;
	return ret;
}

bool cmp(ll x, ll y) {
	return x*s(y) <= y*s(x);
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	int cnt = 0;
	ll gap = 1, now = 1;
	while (cnt < N) {
		cout << now << "\n";
		cnt++;
		while (!cmp(now+gap, now+2*gap)) gap *= 10;
		now += gap;
	}
	
	return 0;
}


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


#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int N = 2e5 + 10;
const ll INF = 1e18;

int n;
pll ar[N];

ll mn1 = INF, mn2 = INF; // x + y, x - y

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

    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> ar[i].fi >> ar[i].se;
    } 
    sort(ar + 1, ar + n + 1);
    ll ans = 0;
    for (int i=1;i<=n;i++){
        ll a = ar[i].fi + ar[i].se;
        ll b = ar[i].fi - ar[i].se;
        ans = max(ans, a - mn1);
        ans = max(ans, b - mn2);
        mn1 = min(mn1, a);
        mn2 = min(mn2, b);
    }
    cout << ans << el;

    return 0;
}

Measured memory_bytes: 6748
macro_rules! read_line_to_tuple {
    ( $( $t:ty ),* ) => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
}

fn main() {
    let s = read_line_to_tuple!(String);

    let c = s.chars().rev().next().unwrap();
    if c != 's' {
        println!("{}s", s);
    } else {
        println!("{}es", s);
    }
}

Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define ll long long 
#define vi vector<int>
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pb push_back
#define f(i,a,b) for(i=a;i<b;i++)
using namespace std;

int main()
{
ll n,d,x,y,i=0,j;

cin>>n>>d;

while(n--)
{
    cin>>x>>y;
    
    double k=x*x+y*y;
    k=sqrt(k);
    if(k<=d)i++;
    
}
	cout<<i;
}

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

typedef long long ll;

using namespace std;


const int M=1e6;
int vi[M+1];

int solve(){
    int n;
    cin>>n;
    set<int> ss;
    set<int> dup;

    try{
    for (int i = 0; i < n; i++)
    {   
        int e;
        cin>>e;
        if(dup.find(e)!=dup.end()){
            continue;
        }
        if(ss.find(e)!=ss.end()){
            dup.insert(e);
        }else ss.insert(e);

    }
    }catch(exception &e){
        cout<<e.what();
    }
    
    int cnt=0,dup_cnt=0;
    for (auto i = ss.begin(); i != ss.end(); i++)
    {   

        if(i==ss.begin()) {

            cnt++;
            if(dup.find(*i)!=dup.end()){
                dup_cnt++;
            }
        }
        else{
            
            if(vi[*i]==0) {
                 cnt++;
                if(dup.find(*i)!=dup.end()){
                    dup_cnt++;
                }
            } 

        }
        int ii=*i;
        
            for (int j = ii; j <= M; j+=ii)
            {
                vi[j]++;
            }  
        
    }
    
    cout<<cnt-dup_cnt;
    
    return 0;
}

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


Measured memory_bytes: 16860
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		StringBuilder ans = new StringBuilder();
		for(int i = 0; i < B; i++) {
			for(int j = 0; j < A; j++)
				ans.append("1");
			for(int j = A; j < W; j++)
				ans.append("0");
			ans.append("\n");
		}
		for(int i = B; i < H; i++) {
			for(int j = 0; j < A; j++)
				ans.append("0");
			for(int j = A; j < W; j++)
				ans.append("1");
			ans.append("\n");
		}
		System.out.print(ans);

	}

}

Measured memory_bytes: 28416
n= int(input())
p=[int(input())-1 for _ in range(n)]
length=[-1]*n
for i in range(n):
    if i==0 or p[i]==0:
        length[p[i]]=0
    else:
        if (pre:=length[p[i]-1])==-1:
            length[p[i]]=0
        else:
            length[p[i]]=length[p[i]-1]+1
print(n-max(length)-1)

Measured memory_bytes: 24768
#include<iostream>
using namespace std;
int main(){
    int x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    int w=x2-x1;
    int h=y2-y1;
    cout<<x2-h<<" "<<y2+w<<" ";
    cout<<x1-h<<" "<<y1+w;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <math.h>
int main(void){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    x1=(double)x1;
    y1=(double)y1;
    x2=(double)x2;
    y2=(double)y2;
    double ans1=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
    double ans2=sqrt(ans1);
    printf("%lf",ans2);
    printf("\n");
    return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
#define int long long
using namespace std;

template<class T>
struct FordFulkerson{
	struct Edge{
		int to,rev,id;
		bool isRev;
		T cap;
		Edge(int to,T cap,int rev,int id,bool isRev) : to(to),rev(rev),cap(cap),isRev(isRev),id(id){}
	};

	vector<vector<Edge>> G;
	vector<bool> used;

	FordFulkerson(int n) : G(n),used(n){}

	void addEdge(int from,int to,T cap,int id,bool isDirected = true){
		G[from].emplace_back(to,cap,G[to].size(),id,false);
		G[to].emplace_back(from,isDirected ? 0 : cap,G[from].size() - 1,id,true);
	}

	T dfs(int v,int t,T f){
		if(v == t) return f;
		used[v] = true;
		for(auto &e : G[v]){
			if(!used[e.to] && e.cap){
				T d = dfs(e.to,t,min(f,e.cap));
				if(d){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	T flow(int s,int t){
		T ret = 0;
		while(1){
			fill(used.begin(),used.end(),0);
			T f = dfs(s,t,numeric_limits<T>::max());
			if(!f) return ret;
			ret += f;
		}
	}
};

signed main(){
	int n,m,s,t;
	cin >> n >> m;
	FordFulkerson<int> ff(n);
	for(int i = 0;i < m;i++){
		int x,y;
		cin >> x >> y; x--;y--;
		ff.addEdge(x,y,1,i,false);
	}
	cin >> s >> t; s--;t--;
	cout << ff.flow(s,t) << endl;
	vector<int> rev;
	for(int i = 0;i < n;i++){
		for(const auto &e : ff.G[i]){
			if(e.cap == 2 && !e.isRev) rev.push_back(e.id);
		}
	}
	cout << rev.size() << endl;
	for(int v : rev) cout << v + 1 << endl;
}


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

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

	if (a + W < b) {
		cout << b - a - W << endl;
	} else if (a > b + W) {
		cout << a - b - W << endl;
	} else {
		cout << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

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

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b;
  cin>>a>>b;
  
  int ans=0;
  rep(i,20){
    if(b<=1+a*i-i){
      ans=i;
      break;
    }
  }
  
  cout(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 200000;
int n,q;
ll a[N];
ll k;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%lld",a+i);
        k^=a[i];
    }
    for(int i=0;i<n;i++)
        cout<<(a[i]^k)<<" ";
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


vi l;
int N,A,B,C;

int solve() {
    int best = INT_MAX;
    int P = 1 << N;
    rep(u,P){
        rep(v,P){
            int a_len = 0, b_len = 0, c_len = 0;
            int a_cnt = 0, b_cnt = 0, c_cnt = 0;
            rep(i,N){
                int b = 1 << i;
                int pat = (((u >> i)&1) << 1) | ((v >> i)&1);
                switch (pat) {
                    case 0: break;
                    case 1: a_len += l[i]; a_cnt++; break;
                    case 2: b_len += l[i]; b_cnt++; break;
                    case 3: c_len += l[i]; c_cnt++; break;
                }
            }
            if (a_cnt == 0 || b_cnt == 0 || c_cnt == 0) continue;

            int mp = (a_cnt + b_cnt + c_cnt - 3)*10
                    + abs(a_len - A) + abs(b_len - B) + abs(c_len - C);
            best = min(best, mp);
        }
    }
    return best;
}

int main() {
    cin >> N >> A >> B >> C;
    l.resize(N);
    rep(i,N) cin >> l[i];
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int w = Integer.parseInt(sc.nextLine());
			int n = Integer.parseInt(sc.nextLine());
			int[] ans = new int[w];
			for (int i = 0; i < ans.length; i++) {
				ans[i] = i + 1;
			}
			while (sc.hasNext()) {	
				String[] s = sc.nextLine().split(",");
				int x = Integer.parseInt(s[0]) - 1;
				int y = Integer.parseInt(s[1]) - 1;
				int tmp = ans[x];
				ans[x] = ans[y];
				ans[y] = tmp;
				
			}
			for (int z : ans) {
				System.out.println(z);
			}
		}
	}
}

Measured memory_bytes: 26064
r=range
h,*s=open(0)
m=9e9
h,w,k=map(int,h.split())
for i in r(1<<h-1):
 t=[j+1for j in r(h)if i>>j&1]+[h];l=len(t);v=-1;c=[0]*l
 for i in r(w):
  b=f=g=0;u=[]
  for j in r(l):d,b=sum(s[j][i]>"0"for j in r(b,t[j])),t[j];u+=d,;g|=d>k;c[j]+=d;f|=c[j]>k
  v+=f
  if f:c=u
 if g<1:m=min(m,v+l)
print(m)

Measured memory_bytes: 50520
/*
			███╗   ███╗ █████╗ ███████╗███╗   ███╗ ██████╗ ██╗   ██╗██████╗ ███████╗ █████╗ ███╗   ███╗██████╗ ██╗   ██╗
			████╗ ████║██╔══██╗╚════██║████╗ ████║██╔═══██╗██║   ██║██╔══██╗╚════██║██╔══██╗████╗ ████║██╔══██╗╚██╗ ██╔╝
			██╔████╔██║███████║    ██╔╝██╔████╔██║██║   ██║██║   ██║██║  ██║    ██╔╝███████║██╔████╔██║██║  ██║ ╚████╔╝
			██║╚██╔╝██║██╔══██║   ██╔╝ ██║╚██╔╝██║██║   ██║██║   ██║██║  ██║   ██╔╝ ██╔══██║██║╚██╔╝██║██║  ██║  ╚██╔╝
			██║ ╚═╝ ██║██║  ██║   ██║  ██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██████╔╝██╗██║  ██║  ██║██║ ╚═╝ ██║██████╔╝   ██║
			╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝  ╚═╝     ╚═╝ ╚═════╝  ╚═════╝ ╚═════╝ ╚═╝╚═╝  ╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝    ╚═╝

			“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define pb push_back
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define sz(v) ((int)((v).size()))
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define un_map unordered_map
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define scll(x) scanf("%I64d", &x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define pr(s) printf("%s", s.c_str()); // print string
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const ll mod = 998244353;
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const int N = 1e5 + 5;
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
struct Vacation {
	int Swim, bugs, homework;
};
int n;
vector<Vacation> v;
int mem[N][4];
int solve(int idx = 0, int prev = 0)
{
	if (idx == n)
		return 0;
	int& ret = mem[idx][prev];
	if (~ret)return ret;
	ret = 0;
	if (prev != 1)
		ret = max(ret, solve(idx + 1, 1) + v[idx].Swim);
	if (prev != 2)
		ret = max(ret, solve(idx + 1, 2) + v[idx].bugs);
	if (prev != 3)
		ret = max(ret, solve(idx + 1, 3) + v[idx].homework);

	return ret;
}
int main()
{
	Ma7moud_7amdy;
	//Open_Sesame;
	clr(mem, -1);
	cin >> n;
	v = vector<Vacation>(n);
	for (int i = 0; i < n; i++)
		cin >> v[i].Swim >> v[i].bugs >> v[i].homework;
	cout << solve();

}



Measured memory_bytes: 9216
n, y = map(int, input().split())
flag = 1

for i in range(n+1):
  for j in range(n-i+1):
    if (10000*i + 5000*j + 1000*(n-i-j)) == y:
      print(i, j, n-i-j)
      flag = 0
      break
    if not flag:
      break
  if not flag:
    break
  if i == n:
    print(-1, -1, -1)

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

    using namespace std;

    const int maxn = 2e5+111;

    long long c[maxn];
    long long s[maxn];
    long long lowbit(long long x)
    {
        return x & -x;
    }

    long long sum(long long x)
    {
        long long res = 0;
        while(x>0)
        {
            res += c[x];
            x -= lowbit(x);
        }
        return res;
    }

    void add(long long x,long long v)
    {
        while(x<maxn)
        {
            c[x] += v;
            x += lowbit(x);
        }
    }

    int main()
    {
        long long n,k;
        cin>>n>>k;
        long long x;
        vector<long long> v;
        for(int i =1;i<=n;i++)
        {
            scanf("%lld",&x);
            x -= k;
            s[i] = s[i-1] + x;
            //v.push_back(s[i]);
        }
        for(int i =0;i<=n;i++)
        v.push_back(s[i]);
        sort(v.begin(),v.end());
        v.resize(unique(v.begin(),v.end()) - v.begin());
        for(int i = 0;i<=n;i++)
            s[i] = lower_bound(v.begin(),v.end(),s[i])-v.begin()+1;
        long long ans = 0;
        for(int i = 0;i<=n;i++)
            {ans += sum(s[i]);
            add(s[i],1);}
        cout<<ans<<endl;
    }


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

int main() {
  int ar = 0;
  cin >> ar;
  int maradek = ar % 1000;
  if (maradek == 0){
    cout << 0;
    return 0;
  }
  int mo = 1000 - maradek;
  cout << mo;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdint>
#include<vector>
#include<map>
typedef long long ll;

ll combination(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int main() {
	ll n = 0, m = 0, ans = 0;
	int a[100000] = {}, accu[100000] = {};
	std::map<ll, ll> amari;
	std::vector<ll> num_type;
	std::cin >> n >> m;
	accu[0] = 0;
	for (ll i = 0; i < n; i++) {
		std::cin >> a[i];
		if (i == 0) {
			accu[1] = a[i] % m;
		}
		else {
			accu[i + 1] = (accu[i] + a[i]) % m;
		}
	}
	for (ll i = 0; i < n + 1; i++) {
		amari[accu[i]]++;
		if (amari[accu[i]] == 1) {
			num_type.push_back(accu[i]);
		}
	}
	for (ll i = 0; i < num_type.size(); i++) {
		ans += combination(amari[num_type[i]], 2);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 5496
#include <iostream>
using namespace std;
int Acard[20];
int Bcard[20];
int recursion(int player,int left,int right,int a,int b){
        if(a==0)
                return true;
        if(b==0)
                return false;
        int res=false;
        if(player){
                if(Acard[left-1])
                        res|=recursion(0,left-1,right,a-1,b);
                if(Acard[right+1])
                        res|=recursion(0,left,right+1,a-1,b);
                if(Acard[left-1]==0 && Acard[right+1]==0 )
                        res|=recursion(0,left,right,a,b);
        }else{
                res=true;
                if(Bcard[left-1])
                        if(!recursion(1,left-1,right,a,b-1))res=false;
                if(Bcard[right+1])
                        if(!recursion(1,left,right+1,a,b-1))res=false;
                if(Bcard[left-1]==0&&Bcard[right+1]==0)
                        if(!recursion(1,left,right,a,b))res=false;
        }
        return res;
}
int main(){
        int N;
        cin >> N;
        for(int i=0 ; i<N ; i++ ){
                for(int l=1 ; l<14 ; l++ ){
                        Acard[l]=0;
                        Bcard[l]=1;
                }
                int x;
                for(int l=0 ; l<6 ; l++ ){
                        cin >> x;
                        Acard[x]=1;
                        Bcard[x]=0;
                }
                if(recursion(1,7,7,6,6))
                        cout <<"yes"<<endl;
                else
                        cout<<"no"<<endl;
        }
        return 0;
}


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

double a, b, x;

bool f(double m){
  if(x*2 <= a*a*b)
    return x*tan(m)*2/a <= b*b;
  else
    return tan(m)*a/2 <= b-x/a/a*1.0;
}

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

  double s = 0, t = 90, pi = 3.141592653589793;
  for(int i=0; i<100; i++){
    double mid = (s + t) / 2;
    if(f(mid*pi/180))  s = mid;
    else  t = mid;
  }

  printf("%.10lf\n", s);

  return 0;
}


Measured memory_bytes: 4136
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,k;cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<endl;
    }else if(k<=a+b){
        cout<<a<<endl;
    }else{
        cout<<2*a-k+b<<endl;
    }
}


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

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);
#define CLOSEALL() fclose(stdin), fclose(stdout)

using namespace std;

template <class T>
T emplaceMin(T & x, const T & y)
{
	if(x > y)
		x = y;
	return x;
}

const int MAXN = 2000 + 5;

vector<int> Adj[MAXN];
int dep[MAXN];
int N, K;
int ans (0x7F7F7F7F);

void DFS(int cur, int fa, int deep)
{
	dep[cur] = deep;
	for(vector<int>::iterator itr = Adj[cur].begin(); itr != Adj[cur].end(); ++itr)
		if(*itr != fa)
			DFS(*itr, cur, deep + 1);
}

int main()
{
	//REDIRECT("shorten");

	int u, v;

	scanf("%d%d", &N, &K);
	for (int i = 1; i < N; i++)
		scanf("%d%d", &u, &v), Adj[u].push_back(v), Adj[v].push_back(u);

	if((K & 1) == 0)			// If K is even then the tree can be halved
		for(int i = 1; i <= N; i++)
		{
			int nans = 0;
			DFS(i, 0, 0);
			for(int k = 1; k <= N; k++)
				nans += (dep[k] > (K / 2));
			emplaceMin(ans, nans);
		}
	else						// If K is odd things will be complicated
		for(int i = 1; i <= N; i++)					// Raise two nodes as one root, then the tree can be halved
			for(vector<int>::iterator itr = Adj[i].begin(); itr != Adj[i].end(); ++itr)
			{
				int nans = 0;
				DFS(i, *itr, 0);
				DFS(*itr, i, 0);
				for(int k = 1; k <= N; k++)
					nans += (dep[k] > (K / 2));
				emplaceMin(ans, nans);
			}

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

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimization_level 3
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vector<int> a(n);

	for (size_t i = 0; i < n; i++)
	{
		cin>>a.at(i);
	}

	sort(a.begin(),a.end());

	for (size_t i = 1; i < n; i++)
	{
		if (a.at(i)==a.at(i-1))
		{
			cout<<"NO";
			return 0;
		}
		
	}

	cout<<"YES";
	
}

Measured memory_bytes: 1024
N=input()
N2=N[::-1]

m1=int((len(N)-1)/2)
m3=int((len(N)+1)/2)

N3=N[:m1]
N4=N3[::-1]

N5=N[m3:]
N6=N5[::-1]

if N==N2 and N3==N4 and N5==N6:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define l_ength size
const int inf = (1<<30);
const int mod = 2019;
using ll = long long;
using namespace std;

ll dp[2][2019];

int main(){
	string s; cin >> s;
	dp[0][s[0]-'0'] = 1;
	ll ans = 0;
	for( int i = 1; i < s.size(); ++i ){
		int d = s[i]-'0';
		int k = i%2;
		for( int r = 0; r < mod; ++r ) dp[k][r] = 0;
		for( int r = 0; r < mod; ++r ){
			dp[k][((r*10)+d)%mod] += dp[(k+1)%2][r];
		}
		dp[k][d] += 1;
		ans += dp[k][0];
	}
	cout << ans << endl;
}

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

int main()
{
  int n, a[210];
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  
  int res = 0;
  
  while (true)
  {
    bool exist_odd = false;
    for (int i = 0; i < n; i++)
    {
      if (a[i] % 2 != 0)
        exist_odd = true;
    }
    if (exist_odd)
      break;
    for (int i = 0; i < n; i++)
    {
      a[i] /= 2;
    }
    res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#a=int(input())

# c=[]
#  for i in b:
#     c.append(i)
A,B,C,D = map(int,input().split())
# f = list(map(int,input().split()))
#j = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
if A+B>C+D:
    print("Left")
elif A+B==C+D:
    print("Balanced")
else:
    print("Right")

Measured memory_bytes: 61676
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << ( abs( A - C ) <= D || ( abs( A - B ) <= D && abs( B - C ) <= D ) ? "Yes" : "No" ) << endl;
    return 0;
}

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

const int MAX_N = 1<<17;

int n, dat[2*MAX_N-1];

void init(int n_) {
  n=1;
  while(n<n_) n*=2;
  for(int i=0;i<2*n-1;i++) dat[i] = INT_MAX;
}

// k:0_indexed
void update(int k, int a) {
  k += n-1;
  dat[k] = a;
  while(k>0){ 
    k = (k-1)/2;
    dat[k]=min(dat[k*2+1],dat[k*2+2]);
  }
}

int query(int a, int b, int k, int l, int r) {
  if(r<=a || b<=l) return INT_MAX;
  if (a<=l && r<=b) return dat[k];
  else{
    int vl = query(a,b,k*2+1,l,(l+r)/2);
    int vr = query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  string str;
  cin >> str;
  int S[100001] = {};
  int Mcount = 0;
  init(N+1);
  for(int i=0;i<=N;i++) {
    S[i] = str[i] - '0';
    if(S[i]==1) Mcount++;
    else Mcount=0;
    if(Mcount>=M) {
      cout << -1 << endl;
      return 0;
    }
  }

  int f[100001] = {};
  update(N, 0);
  for (int i = N-1; i>=0; i--) {
    if (S[i] == 0) {
      int fin = min(N, i+M);
      f[i] = query(i+1,fin+1,0,0,n) + 1;
      update(i, f[i]);
    } else {
      f[i] = INT_MAX;
      update(i, f[i]);
    }
  }
  
  vector<int> ans;
  int ind = 0;
  while(ind != N) {
    for(int j=ind+1;j<=N;j++) {
      if(f[ind] - f[j] == 1 && S[j] != 1) {
        ans.push_back(j - ind);
        ind = j;
        break;
      }
    }
  }
  for (int i:ans) cout << i << " ";
  cout << endl;
  return 0;
}

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

using namespace std;

long long arr[3001][3001] = {0};

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

	string a, b;
	cin >> a >> b;

	for(long long i = 1; i <= a.size(); i++){
		for(long long j = 1; j <= b.size(); j++){
			arr[i][j] = (a[i-1] == b[j-1] ? arr[i-1][j-1]+1 : max(arr[i-1][j], arr[i][j-1])); 
		}
	}
	long long res = arr[a.size()][b.size()];

	string s;
	long long i = a.size(), j = b.size();
	while(i>0 || j>0){
		if(!i || !j) break;
		if(arr[i][j] != arr[i-1][j] && arr[i][j] != arr[i][j-1]){
			s += a[i-1];
			i--; j--;
		}
		else if(arr[i][j] == arr[i-1][j])
			i--;
		else j--;
	}
	reverse(s.begin(), s.end());

	cout << s;

	return 0;
}

Measured memory_bytes: 70656
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int H1,M1,H2,M2,K;
	cin>>H1>>M1>>H2>>M2>>K;

	cout<<(H2*60+M2-H1*60-M1-K)<<endl;

	return 0;
}


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

int main(){

	int N;
	cin >> N;
	vector<int> d(N);
	for(int i = 0; i < N; i++)
	{
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	int ans=1, bf = d[0];
	for(int i = 1; i < N; i++)
	{	
		if(bf == d[i]) continue;
		ans++;
		bf = d[i];
	}
	
	cout << ans << endl;
	

	return 0;
}

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

std::string w;
std::map<char,int> mp;

int main(void){
    std::cin >> w;

    bool f = true;
    for(char c = 'a'; c <= 'z'; ++c) mp[c] = 0;
    for(auto it=w.begin(), _END=w.end(); it!=_END; ++it) ++mp[*it];
    for(auto it=mp.begin(), _END=mp.end(); it!=_END; ++it){
        if(it->second%2 != 0){
            f = false;
            break;
        }
    }
    std::cout << (f ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
import sys
size=input()
size=size.split()
H=int(size[0])
W=int(size[1])
string_input=[]
mine_state=[]
no_state=[]
count_list=[[0 for i in range(W)] for j in range(H)]
dx=[1,0,-1,0,1,1,-1,-1]
dy=[0,1,0,-1,1,-1,1,-1]
for num in range(H):
    s=input()
    string_input.append(s)
for i in range(H):
    for j in range(W):
        if string_input[i][j]=='.':
            no_state.append((i,j))
        else:
            mine_state.append((i,j))
for i in range(H):
    for j in range(W):
        if (i,j) in no_state:
            count=0
            for d in range(8):
                if (i+dx[d],j+dy[d]) in  mine_state:
                    count+=1
                count_list[i][j]=count
        else:
            count_list[i][j]='#'
for i in range (H):
    for j in range(W):
        sys.stdout.write(str(count_list[i][j]))
    print()


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

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

#define INF (1LL << 60)

Int a, b, c, d;
map<Int, Int> cache;

Int f(Int n)
{
    if(n == 0) return 0;
    if(cache.count(n) != 0) return cache[n];
    Int res = INF;
    if(d < INF/n) res = n*d;
    Int divs[] = {2, 3, 5};
    Int cost[] = {a, b, c};
    int i;
    FOR(i, 0, 3)
    {
        Int rem = n % divs[i];
        res = min(res, rem*d + cost[i] + f(n/divs[i]));
        if(rem != 0 && n/divs[i] + 1 < n) res = min(res, (divs[i] - rem)*d + cost[i] + f(n/divs[i] + 1));
    }
    return cache[n] = res;
}

void solve(int test)
{
    cache.clear();
    Int n;
    cin >> n >> a >> b >> c >> d;
    cout << f(n) << endl;
}

int main()
{
    int T, t;
    cin >> T;
    FOR(t, 0, T) solve(t);
    return 0;
}


Measured memory_bytes: 4420
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>

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

using namespace std;

typedef long long ll;

ll mod = 1000000007;

int exps[1003];

void solve(int n) {
  int div = 2;
  while ( div*div <= n ) {
    if ( n % div == 0 ) {
      exps[div]++;
      n /= div;
    } else {
      div++;
    }
  }
  if (n != 1) {
    exps[n]++;
  }
}

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

  int n;
  cin >> n;

  rep(i, n) {
    solve(i+1);
  }

  ll ans = 1;

  rep(i, n+1) {
    ans *= (exps[i] + 1);
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main() {
	int M, K; cin >> M >> K;
	if(M==1 && K==1){
	    cout << -1 << endl;
	    return 0;
	}
	int b=0;
	b |= (1<<M);
	if(b<=K){
	    cout << -1 << endl;
	    return 0;
	}
	if(K==0){
	    for(int i=0; i<2*b; ++i){
	        cout << (i==0 ? "" : " ") << min(i, 2*b-1-i);
	    }
	    cout << endl;
	}
	else{
	    cout << 0 << ' ' << K << ' ' << 0;
	    for(int i=1; i<b; ++i){
	        if(i!=K) cout << ' ' << i;
	    }
	    cout << ' ' << K;
	    for(int i=b-1; i>0; --i){
	        if(i!=K) cout << ' ' << i;
	    }
	    cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int inA, inB, inC;
    cin >> inA >> inB >> inC;

    int remain = inC - (inA - inB);
    if(remain < 0)
    {
         remain = 0;
    }

    cout << remain << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  double a,b,c,d,e,f;
  double x,y;

  while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
    y=(c*d-a*f)/(b*d-e*a);
    x=(c-(b*y))/a;
    printf("%.3f %.3f\n",x,y);
  }
  return(0);
}

Measured memory_bytes: 0