akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    chutiyaap;
    int n;cin>>n;
    int vis[n+1]={0};
    for(int i=0;i<n-1;i++)
    {
        int x;cin>>x;
        vis[x]++;
    }
    for(int i=1;i<=n;i++)cout<<vis[i]<<endl;
    // cout<<0;
}

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

int main() {
  int n, s= 100;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    bool b = true;
	int x, a = 0;
    cin >> x;
    while (b) {
      if (x % 2 == 0) {
        x /= 2;
        a++;
      }
      else
        b = false;
    }
    if (s > a)
      s = a;
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#define rep(i, n)for(int i=0; i<n; i++)
using ll = long long int;
using namespace std;

int main(){
    double n;
    while(true){
        cin >> n;
        if(n==0) break;
        double a, asum=0, sum=0;
        vector<double> s(n);
        rep(i, n){
            cin >> s[i];
            sum += s[i];
        }
        double avg = sum / n;
        rep(i, n){
            asum += (s[i]-avg)*(s[i]-avg);
        }
        a = asum / n;
        cout << fixed << setprecision(5) << sqrt(a) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		sc.close();

		long r1 = ((a - 1) + (b - 1) + 1) / 2;
		long r2 = ((n - a) + (n - b) + 1) / 2;
		long r3 = (b - a) / 2;

		long result;
		if ((b - a) % 2 == 0) {
			result = Math.min(Math.min(r1, r2), r3);
		}else {
			result = Math.min(r1, r2);
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 21716
#include <iostream>
typedef long long ll;
using namespace std;

ll W[101], V[101], DP[101][100001]={{0}};

int main(){
    ll NMAX, WMAX;
    cin >> NMAX >> WMAX;
    
    for(int i=0;i<NMAX;i++) cin >> W[i] >> V[i];
    for(int i=0;i<NMAX;i++){
        for(int w=1;w<=WMAX;w++) {
            if(w>=W[i]) DP[i+1][w] = max(DP[i][w], DP[i][w-W[i]]+V[i]);
            else DP[i+1][w] = DP[i][w];
        }
    }
    cout << DP[NMAX][WMAX] << endl;
    return 0;
}

Measured memory_bytes: 78336
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << PREC(10);
  int n;
  cin >> n;
  double res = 0.0;
  REP(i,n) {
    double a;
    cin >> a;
    res += 1.0/a;
  }
  cout << 1.0 / res << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
C_x = list(range(101))
C_y = list(range(101))

if sum([h for _, _, h in X]) == 1:
  for x, y, h in X:
    if h != 0:
      print(x, y, h)
else:
  for px in C_x:
    for py in C_y:
      h_list = [abs(x - px) + abs(y - py) + h for x, y, h in X if h > 0]
      if len(set(h_list)) == 1:
        print(px, py, h_list[0])
        break
                
           

Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    pos = 0
    neg = 0
    for i in range(N):
        pos += max(a[i]-b[i],0)
        neg += abs(min(a[i]-b[i],0))//2
    if  neg >= pos:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 10764
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i = 0; i < (n); i++)
typedef long long ll;
const ll MOD = 1000000007;

int main()
{
    char s;
    cin >> s;
    s = (s-'a'+1) % 26 + 'a';
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter

def warshall_floyd(c):
    for k in range(10):
        for j in range(10):
            for i in range(10):
                c[j][i] = min(c[j][i], c[j][k] + c[k][i])
    return c

h, w = map(int, input().split())
c = []
a = []
for _ in range(10):
    k = [int(i) for i in input().split()]
    c.append(k)
for _ in range(h):
    a.extend([int(i) for i in input().split()])

count = Counter(a)
c = warshall_floyd(c)
ans = 0
for i in range(10):
    if i != 1:
        ans += count[i] * c[i][1]
print(ans)

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
    cout << 3 << endl;
  } else if (s[0] == 'R' && s[1] == 'R') {
    cout << 2 << endl;
  } else if (s[1] == 'R' && s[2] == 'R') {
    cout << 2 << endl;
  } else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}
/*
*/


Measured memory_bytes: 3592
N,M = gets.split.map(&:to_i)
A = N.times.map{ gets.split.map(&:to_i) }

puts 8.times.map{|dir| 
  s = A.sort_by{|x,y,z|  ((-1) ** dir[0]) * x + ((-1) ** dir[1]) * y + ((-1) ** dir[2]) * z }
  s[0,M].inject([0,0,0]){|t,xyz| 3.times{|i| t[i] += xyz[i] }; t }.inject(0){|t,v|t + v.abs}
}.max


Measured memory_bytes: 3964
def main(s):
    if not isKaibun(s):
        return "No"
    l = len(s)//2
    if not isKaibun(s[:l]):
        return "No"
    if not isKaibun(s[-l:]):
        return "No"
    return "Yes"

def isKaibun(s):
    for i in range(len(s)//2):
        if s[i] != s[-i-1]: return False
    return True

s = input()
print(main(s))

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

bool check(int x, vector<int> &d){
    while(x > 0){
        int c = x % 10;
        for (int i=0; i<d.size(); i++){
            if(c == d[i]) return false;
        }
        x /= 10;
    }
    return true;
}


int main(void){
    // Your code here
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    for (int i=0; i<k; i++){
        cin >> d[i];
    }
    
    while(1){
        if(check(n, d)){
            cout << n << endl;
            return 0;
        }
        n++;
    }
}


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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var a = long.Parse(Console.ReadLine());
            var list = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();
            var max = list.Max();
            var sum = list.Sum() - max;
            Console.WriteLine(max < sum ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 28276
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    int a,b;
    cin>>a>>b; a--; b--;
    cout<<a * b<<endl;
    return 0;
}

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

signed main(){
	int n,a,b;
	cin >> n >> a >> b;
	if((a == 1 && b == 2) || (a == n && b == n - 1)) cout << "Borys" << endl;
	else if((b - a) % 2) cout << "Borys" << endl;
	else cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import permutations

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    Edge = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        Edge[a-1].append(b-1)
        Edge[b-1].append(a-1)

    count = 0
    for s in permutations(range(N), N):
        Visited = [False for _ in range(N)]
        for i, n in enumerate(s):
            if i == 0:
                if n != 0: break
                else: Visited[0] = True
            else:
                if n in Edge[s[i-1]]: Visited[n] = True
                else: break
        else: count += 1
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
const int N=1010;
const int M=5010;
const int inf=1e9+7;
using namespace std;
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
int head[N],tot=0,f[N][2],g[N][M],val[N],n;
vector<int> G[N];
inline void addedge(int u,int v){
	G[u].push_back(v);G[v].push_back(u);
}
inline void dfs(int u,int fa){
	f[u][0]=inf;f[u][1]=inf;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];if(v==fa)continue;
		dfs(v,u);
	}
	for(int i=0;i<2;i++){
		g[0][0]=0;int cur=0;
		for(int j=1;j<=val[u];j++)g[0][j]=inf;
		for(int j=0;j<G[u].size();j++){
            int v=G[u][j];if(v==fa)continue;cur++;
            for(int w=0;w<=val[u];w++) g[cur][w]=inf;
            for(int w=0;w<=val[u];w++){
                if(w+val[v]<=val[u])g[cur][w+val[v]]=min(g[cur-1][w]+f[v][i^1],g[cur][w+val[v]]);
                if(w+f[v][i^1]<=val[u])g[cur][w+f[v][i^1]]=min(g[cur][w+f[v][i^1]],g[cur-1][w]+val[v]);
            }
        }
        for(int w=0;w<=val[u];w++)f[u][i]=min(f[u][i],g[cur][w]);
		//for(int w=0;w<=val[u];w++)printf("g[%d][%d]=%d\n",cur,w,g[cur][w]);
		//printf("f[%d][%d]=%d\n",u,i,f[u][i]);
	}
}
int main(){
	//freopen("arc83emy.out","w",stdout);
	n=read();
	for(int i=2;i<=n;i++){
		int u=read();addedge(i,u);
	}
	for(int i=1;i<=n;i++)val[i]=read();
	dfs(1,0);
	if(f[1][0]<inf||f[1][1]<inf)puts("POSSIBLE");else puts("IMPOSSIBLE");
}

Measured memory_bytes: 17408
#include <cstdio>
#include <queue>
#define MAX 1010
using namespace std;
typedef pair<int,int> Site;

char G[MAX][MAX];
int Sx[15];
int Sy[15];
int Vec[4][2]={{0,-1},{1,0},{0,1},{-1,0}};
int H(0),W(0),N(0);
int res=0;

void BFS()
{
	int i=0;
	int size;
	int step;
	while (Sx[i+1])
	{
		queue<Site> Qs;
		Qs.push (Site(Sx[i],Sy[i]));
		size=1;
		step=1;
		while (Qs.size ())
		{
			Site p=Qs.front ();
			Qs.pop();
			for (int j=0;j<4;++j)
			{
				if (p.first+Vec[j][0]==Sx[i+1]&&p.second+Vec[j][1]==Sy[i+1])
				{
					res+=step;
					goto KK;
				}
				if (G[p.first+Vec[j][0]][p.second+Vec[j][1]]=='.'||G[p.first+Vec[j][0]][p.second+Vec[j][1]]<i+'0')
				{
					G[p.first+Vec[j][0]][p.second+Vec[j][1]]=i+'0';
					Qs.push (Site(p.first+Vec[j][0],p.second+Vec[j][1]));
				}
			}
			--size;
			if (size==0)
			{
				size=Qs.size ();
				++step;
			}
		}
KK:
		++i;
	}

}

void debug()
{  	
	freopen("AOJ-0558-in.txt", "r",stdin);
	freopen("AOJ-0558-out.txt", "w",stdout);

}


int main()
{

// 	debug ();
	
	while (scanf("%d%d%d",&H,&W,&N),H)
	{
		for (int tt=0;tt<15;++tt)
		{
			Sx[tt]=Sy[tt]=0;
		}
		for (int ni=0;ni<H+2;++ni)
		{
			G[ni][0]=G[ni][W+1]='X';
		}
		for (int mi=0;mi<W+2;++mi)
		{
			G[0][mi]=G[H+1][mi]='X';
		}

		for (int iH=0;iH<H;++iH)
		{
			for (int iW=0;iW<W;++iW)
			{
				scanf ("%c",&G[iH+1][iW+1]);
				while (G[iH+1][iW+1]=='\n'||G[iH+1][iW+1]==' ')
				{
					scanf ("%c",&G[iH+1][iW+1]);
				}
				char t=G[iH+1][iW+1];
				if (t>='1'&&t<='9')
				{
					Sx[t-'0']=iH+1;
					Sy[t-'0']=iW+1;
					G[iH+1][iW+1]='.';
				}
				else if (t=='S')
				{
					Sx[0]=iH+1;
					Sy[0]=iW+1;
					G[iH+1][iW+1]='.';
				}
			}
		}
// 		for (int x=0;x<H+2;++x)
// 		{
// 			for(int y=0;y<W+2;++y)
// 			{
// 				printf ("%c",G[x][y]);
// 			}
// 			printf ("\n");
// 		}
		BFS();
		printf ("%d\n",res);
		res=0;
		H=0;
	}
	return 0;

}

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

#define ll long long
#define mk make_pair
#define pb push_back


using namespace std;


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

   map<string, int> st;
   while(N--){
      string v; cin >> v;
      st[v] += 1;
   }

   int maxtimes = 0;
   for(const auto s : st){
      int v = s.second;
      if(v >= maxtimes) maxtimes = v;
   }
   
   for(const auto s : st){
      if(s.second == maxtimes){
         cout << s.first << endl;
      }
   }
   return 0;
}


Measured memory_bytes: 25856
M = 1000000007
def pow(k):
    ans = 1
    for _ in range(k):
        ans *= 2
        ans %= M
    return ans

def main():
    n = int(input())
    a = list(map(int, input().split()))
    bit_size = len(bin(max(a))[2:])
    for i in range(n):
        a[i] = bin(a[i])[2:].zfill(bit_size)

    sum = 0
    for i in range(bit_size):
        one = 0
        zero = 0
        for j in range(n):
            if a[j][i] == '1':
                one += 1
            else: 
                zero += 1
        sum += pow(bit_size - i - 1) * (one % M) * (zero % M)
        sum %= M
    print(sum)

if __name__ == '__main__':
    main()

Measured memory_bytes: 133264
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include<chrono>
#include<string>

using namespace std;

#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define ins insert

/*int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		vector<ll>v;
		ll val=-1;
		while(n--)
		{
			ll temp;
			cin>>temp;
			v.pb(temp);
		}

		ll mini=10000000;

		if(v.size()==1)
		{
			cout<<val<<endl;
			continue;
		}

		else{
		for(ll i=0;i<v.size();i++)
		{
			set<ll>s;
			ll cnt=0;
			ll j;
			for(j=i;j<v.size();j++)
			{
				auto temp=s.find(v[j]);
				if(temp==s.end())
				{
					s.insert(v[j]);
					cnt++;
				}

				else
				{
					cnt++;
					break;
				}
			}
			//cout<<cnt<<endl;

			if(cnt>1)
			mini=min(mini,cnt);

			i=j-1;
		}

			cout<<mini<<endl;
		}

	}
}*/




int main() {
	

	ios_base::sync_with_stdio(false);
	cin.tie();
	ll n;
	string s;
	cin>>n;
	cin>>s;
	ll len=s.length();
	ll ctr=0;

	if(n%2==1)
		cout<<"No";
	else
	{
		ll mid=n/2;
		for(ll i=0;i<len/2;i++)
		{
			if(s[i]==s[mid+i])
				ctr++;
		}

		if(ctr==n/2)
			cout<<"Yes";
		else
			cout<<"No";
	}
	

}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
using namespace std;
int main() {
    int N, a[200], cnt, min = INT_MAX;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cnt = 0;
        cin >> a[i];
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            cnt++;
        }
        if (cnt < min) min = cnt;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
typedef long long ll;
int DP[2][2001][3001];
int main() {
	int N,M,S;
	while(cin >> N >> M >> S && N){
		int sum=0;
		REP(i,2)
			REP(j,2001)
				REP(k,3001)
					DP[i][j][k]=0;
		DP[0][0][0]=1;
		N*=N;
		FORE(i,1,N)
			FORE(j,0,M)
				FORE(k,0,S)
					if(j<=k && j)
					DP[i%2][j][k]=(DP[i%2][j-1][k-1]+DP[(i+1)%2][j-1][k-j])%100000;
					else
					DP[i%2][j][k]=0;
		FORE(i,1,M)
			sum=(sum+DP[N%2][i][S])%100000;
		cout << sum%100000 << endl;
		
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 48072
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
	int k;
	scanf("%d", &k);
	
	printf("%d\n", a[k - 1]);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n];
	for(i=0;i<n;i++){
		cin>>ar[i];
	}

	ll mx=ar[0],c=1;
	for(i=1;i<n;i++){
		if(ar[i]>mx){
			mx=ar[i];
			c++;
		}
		else if(ar[i]==mx){
			c++;
		}
	}
	cout<<c;
	return 0;
}


Measured memory_bytes: 256
def main():
    X, Y = map(int, input().split())
    a = (X+Y)//3
    ans = 0
    mod = 10**9+7

    f = [1]
    for i in range(a):
        f.append(f[i]*(i+1)%mod)

    if (X+Y)%3 == 0:
        for i in range(a+1):
            x = i + 2 * (a - i)
            y = (2 * i) + (a - i)
            if X == x and Y == y:
                 ans += f[a] * pow(f[i], mod-2, mod)%mod * pow(f[a-i], mod-2, mod)%mod
                                                             
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 29588
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;
ll mpow(ll a, ll b) { ll r = 1; a %= mod; while (b) { r = r * ((b % 2) ? a : 1) % mod, a = a * a % mod, b >>= 1; }return r; }



int main() {
	int h, w, x, y; cin >> h >> w >> x >> y;
	long double s = 1LL*h * w / 2.0;
	printf("%.12Lf ", s);
	if (h == 2LL * x && w == 2LL * y)printf("1");
	else printf("0");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();

        int NUM = 1000000;
        int[] one = new int[NUM];
        int[] zero = new int[NUM];

        int oneIndex = 0;
        int zeroIndex = 0;

        if (S.charAt(0) != '0') {
            zero[zeroIndex++] = 0;
        }

        int i = 0;
        while (i < S.length()) {
            if (S.charAt(i) == '0') {
                int cnt = 0;
                while (i < S.length() && S.charAt(i) == '0') {
                    cnt++;
                    i++;
                }
                zero[zeroIndex++] = cnt;
            } else {
                int cnt = 0;
                while (i < S.length() && S.charAt(i) == '1') {
                    cnt++;
                    i++;
                }
                one[oneIndex++] = cnt;
            }
        }

        oneIndex = 0;
        zeroIndex = 0;
        long ans = 0;

        int tmpK = K;
        while (tmpK-- > 0 && zero[zeroIndex] != -1 && one[oneIndex] != -1) {
            ans += one[oneIndex++];
            ans += zero[zeroIndex++];
        }

        long tmp = ans;
        while (oneIndex < NUM && zeroIndex < NUM) {
            if (oneIndex - K - 1 >= 0) {
                tmp -= one[oneIndex - K - 1];
            }
            tmp -= zero[zeroIndex - K];

            tmp += one[oneIndex++];
            tmp += zero[zeroIndex++];

            ans = Math.max(ans, tmp);
        }

        out.print(ans);
    }
}


Measured memory_bytes: 32672
#include<stdio.h>
int binarySerch(int *,int , int );
int main(){
  int a,b,i,k=0,s[100000],key;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&key);
    k+=binarySerch(s,a,key);
  }
  printf("%d\n",k);
  return 0;
}
int binarySerch(int *s,int n,int key){
  int kai=0,left=0,right,mid;
  right=n;
  while(left<right){
    mid=(left+right)/2;
    if(s[mid]==key)return 1;
    else if(key<s[mid]){
      right = mid;
    }
    else{
      left=mid+1;
    }     
  }
  return 0;
}



Measured memory_bytes: 2108
N=int(input())
sum_l=[]
for i in range(1,N):
    j=N-i
    i_l=list(str(i))
    j_l=list(str(j))
    sum_l.append(sum(list(map(int,i_l)))+sum(list(map(int,j_l))))

print(min(sum_l))

Measured memory_bytes: 3968
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,a[200005],last[200005],now[21];
long long ans;
int main(void){
	register int i,j;
	n=read();
	for(i=1;i<=n;++i){
		a[i]=read();
		for(j=0;j<=20;++j)
			if(a[i]>>j&1)
				last[i]=max(now[j],last[i]),now[j]=i;
		if(last[i]!=i-1)last[i]=max(last[i],last[i-1]);
	}
	for(i=1;i<=n;++i)
		ans+=i-last[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**6)
h, w = map(int, input().split())

field = [list(input()) for _ in range(h)]

dp = [[None] * w for _ in range(h)]
def dfs(hindex=h - 1, windex=w - 1):
    if field[hindex][windex] == "#":
        return 0
    if hindex == windex == 0:
        return 1

    if dp[hindex][windex] is not None:
        return dp[hindex][windex]
    r = (hindex and dfs(hindex - 1, windex)) + (windex and dfs(hindex, windex - 1))
    dp[hindex][windex] = r
    return r

print(dfs() % (10**9 + 7))


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int K=in(),X=in();
	for(int i=0;i<2*(K-1);i++){
		cout << (X-(K-1)+i) << ' ';
	}

	out(X+(K-1));
	return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())

list_left = []
list_right = []
for i in range(m):
    l,r=map(int, input().split())
    list_left.append(l)
    list_right.append(r)
test=[i for i in range(max(list_left),min(list_right)+1)]
print(len(test))

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

inline int read() {
	char c=getchar(); int f=1,ret=0;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret * f;
}

int main() {
	int a = read(), b = read(), c = read();
	for (int i=0;i<=100;i++) {
		if ((a & 1) || (b & 1) || (c & 1)) {
			printf("%d\n",i);
			exit(0);
		} else {
			int pa = a, pb = b, pc = c;
			a = pb + pc >> 1;
			b = pa + pc >> 1;
			c = pa + pb >> 1;
		}
	}
	puts("-1");
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll N, M;
	ll ans = 0;

	cin >> N >> M;

	if (N >= M / 2) ans = M / 2;
	else {
		ans = N;
		M -= N * 2;
		ans += M / 4;
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    string S;
    cin >> S;
    int N;
    N = S.size();
    ll ans = 0;

    for(int bit = 0; bit < (1<<(N-1)); bit++){
        ll sm = 0;
        ll a = S[0] - '0';
        for(int i = 0; i < N-1; i++){
            if(bit & (1<<i)){
                sm += a;
                a = 0;
            }
            a = a * 10 + S[i+1] - '0';
        }
        sm += a;
        ans += sm;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
int n, a[N], b[N], c[N], w;
ll dp[N];
pair <int,int> p[N];
void solve(){
    cin >> n >> w;
    for(int i = 1; i <= n; ++i) {
        int x, y;
        cin >> x >> y;
        p[i] = {x, y};
    }
    sort(p + 1, p + n + 1);
    for(int i = 1; i <= n; ++i) {
        a[i] = p[i].X;
        b[i] = p[i].Y;
    }
    for(int i = 1; i <= n; ++i) {
        for(int j = w - a[i]; j >= 0; --j)
            dp[j + a[i]] = max(dp[j + a[i]], dp[j] + b[i]);
    }
    cout << *max_element(dp + 1, dp + w + 1);
    
}   
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

int main() {
  string s;
  int cnt = 0;
  
  cin >> s;
  
  for(int i = 0; i < 3; i++) {
    if(s[i] == '1') {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define um(a,b) unordered_map<a,b>
#define vv(a) vector<a>
#define pp(a,b) pair<a,b>
ll power(ll a,ll b,ll mod){  ll ans=1;  while(b>0){
  if(b&1){ ans=(ans*a)%mod;} a=(a*a)%mod;  b=b/2; } return ans;}

int main(){
FIO
 ll t,d;
 cin>>t>>d;
 ll count=0;
 ll a,b,temp;
 for(ll i=0;i<t;i++){
    cin>>a>>b;
    temp=a*a+b*b;
    if(temp<=(d*d))
        count++;
 }
 cout<<count<<endl;

}


Measured memory_bytes: 3632
package main

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

func main() {
	sa, sb, sc := ReadString(), ReadString(), ReadString()
	ss := []string{sa, sb, sc}

	turn := byte(0)
	for len(ss[turn]) > 0 {
		ss[turn], turn = ss[turn][1:], ss[turn][0]-'a'
	}
	fmt.Println(string([]byte{turn + 'A'}))
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 1848
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n),v;
    map<int, int> mp;
    rep(i, n)
    {
        cin >> a[i];
        if(!mp[a[i]]++){
            v.push_back(a[i]);
        }        
    }
    ll ans = 0;
    rep(i,v.size()){
        if(mp[v[i]] >= v[i]){
            ans += mp[v[i]] - v[i];
        }
        else
        {
            ans += mp[v[i]];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5496
#include <bits/stdc++.h>
using i64 = long long;
using P = std::tuple<i64, int, int>;

int main() {
    int n;
    std::cin >> n;
    std::vector<std::vector<std::pair<i64, int>>> g(2 * n);
    for (int i = 0; i < n; i++) {
        i64 x;
        std::cin >> x;
        g[i].emplace_back(x, i + n);
        g[i + n].emplace_back(x, i);
    }
    for (int i = 1; i < n; i++) {
        int a, b;
        i64 c;
        std::cin >> a >> b >> c;
        a = a - 1 + n;
        b = b - 1 + n;
        g[a].emplace_back(c, b);
        g[b].emplace_back(c, a);
    }

    i64 ret = 0;
    {
        std::vector<i64> dist(2 * n);
        std::vector<int> nearest(2 * n, -1);
        std::priority_queue<P, std::vector<P>, std::greater<>> pq;
        for (int i = 0; i < n; i++) pq.emplace(0ll, i, i);

        while (!pq.empty()) {
            auto curr = pq.top();
            i64 d = std::get<0>(curr);
            int v = std::get<1>(curr), nc = std::get<2>(curr);
            pq.pop();
            if (nearest[v] >= 0) continue;
            nearest[v] = nc;
            dist[v] = d;
            for (auto e : g[v]) {
                i64 cost = std::get<0>(e);
                int to = std::get<1>(e);
                if (nearest[to] < 0) {
                    pq.emplace(d + cost, to, nc);
                } else if (nearest[to] != nearest[v]) {
                    ret += dist[to] + d + cost;
                }
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 50928
//coded by not_surrender

#include <bits/stdc++.h>

#define MAXN 5010
#define MOD 1000000007
#define mid ((a+b)/2)
#define L (nod*2)
#define R (nod*2+1)
#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef vector <int> vi;

ll N, dp[MAXN][MAXN];

string S;

int main(){

	//~ freopen( "a.txt", "r", stdin );
	
	ios_base::sync_with_stdio( false );
	cin.tie( NULL ), cout.tie( NULL );
	
	cin >> N >> S;
	
	dp[0][0] = 1;
	for ( int i = 0; i < N; ++i ){
		dp[i+1][0] = (dp[i+1][0]+dp[i][0])%MOD;
		for ( int j = 0; j <= N; ++j ){
			if ( j )
				dp[i+1][j-1] = (dp[i+1][j-1]+2*dp[i][j])%MOD;
			dp[i+1][j+1] = (dp[i+1][j+1]+dp[i][j])%MOD;
		}
	}
	
	cout << dp[N][S.size()] << '\n';

return 0;	
}


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
#define INF 1e9+1
#define PI 3.1415926535897932846
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<pii, pii> piiii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<piiii> viiii;
typedef vector<pll> vll;
typedef vector<pld> vld;

const int MAXN = 100100;
const ll MOD = 1e9+7;

int n;
int a[MAXN];

int main()
{
    FAST_IO;

    cin >> n;
    FOR(i, 0, n-1) cin >> a[i];
    vi k;
    k.pb(-1);

    FOR(i, 0, n-1) {
        if (a[i] <= k[k.size()-1]) k.pb(a[i]);
        else {
            int le = 0, ri = k.size()-1;
            while (le < ri) {
                int mid = (le+ri)/2;
                if (a[i] > k[mid]) ri = mid;
                else le = mid + 1;
            }
            k[le] = a[i];
        }
    }

    cout << k.size() << endl;

    return 0;
}


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

using namespace std;

const int N = 200000;

int u[N], v[N];

vector<int> ed[N];
vector<pair<int, int> > lst[N];
int xr[N];
int ans[N];
int n, m;
int used[N];
void dfs(int v) {
  xr[v] = ed[v].size() % 2;
  used[v] = 1;
  for (auto it : lst[v]) {
    if (used[it.first]) {
      continue;
    } else {
      dfs(it.first);
      xr[v] ^= xr[it.first];
      if (xr[it.first] == 1) {
        ans[it.second] = 1;
      }
    }
  }
}

void print() {
  for (int i = 1; i <= m; i++) {
    if (ans[i] == 0) {
      cout << u[i] << " " << v[i] << "\n";
    } else {
      cout << v[i] << " " << u[i] << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  if (m % 2 == 1) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    cin >> u[i] >> v[i];
    lst[u[i]].emplace_back(v[i], i);
    lst[v[i]].emplace_back(u[i], i);
    ed[u[i]].push_back(v[i]);
  }
  int root = 0;
  for (int i = 1; i <= n; i++) {
    if (ed[i].size() % 2 == 1) {
      root = i;
    }
  }
  if (root == 0) {
    print();
    return 0;
  }
  dfs(root);
  print();
  return 0;
}

Measured memory_bytes: 23424
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>

using namespace std;

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

int a[2][10010];
vector<pair<pair<int, int>, int> > v;

int main() {
  while (true) {
    int n, r;
    cin >> n >> r;
    if (n == 0 && r == 0) break;
    memset(a, 0, sizeof(a));
    v.clear();
    rep (i, n) {
      int x1, y1, x2, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      ++x1, ++y1, ++x2, ++y2;
      v.push_back(make_pair(make_pair(y1, x1), -1));
      v.push_back(make_pair(make_pair(y1, x2), 1));
      v.push_back(make_pair(make_pair(y2, x1), 1));
      v.push_back(make_pair(make_pair(y2, x2), -1));
    }
    sort(v.begin(), v.end());
    int res1 = 0, res2 = 0;
    int t = 0;
    rep (i, 10010) {
      rep (j, 10010) a[1][j] = 0;
      for (; t < (int)v.size(); ++t) {
	if (v[t].first.first != i) break;
	a[1][v[t].first.second] -= v[t].second;
      }
      rep (j, 10009) a[1][j + 1] += a[1][j];
      rep (j, 10010) a[1][j] += a[0][j];
      rep (j, 10010) if (a[1][j]) ++res1;
      if (r == 2) rep (j, 10009) if (j > 0) {
	  if (!a[0][j] != !a[1][j]) ++res2;
	  if (!a[1][j] != !a[1][j - 1]) ++res2;
	}
      rep (j, 10010) a[0][j] = a[1][j];
    }
    cout << res1 << endl;
    if (r == 2) cout << res2 << endl;
  }
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    if (n==0){
        cout <<"0"<<endl;
        return 0;
    }

    string s;
    long long x=2,y=1;
    while (n)
    {
        if (n%x){
            s.push_back('1');
            n-=y;
        }
        else s.push_back('0');
        x*=2;
        y*=-2;
    }

    /*cout<<"***"<<s<<endl;*/

    for (int i=s.size()-1;i>=0;i--)
        cout<<s[i];
    cout <<endl;

}


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

using namespace std;

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

  int ans = int(1e9);
  for (int i = -100; i <= 100; i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      sum += (i - a[j]) * (i - a[j]);
    }
    ans = min(ans, sum);
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

const int Max = 1e5 + 6;
//dp[i][j] = i'm now considering the i'th day and I did the task j (A or B or C) at previous day((i-1)'th day). So I can't do the task j in this i'th day.
int main() {
	int n, a[Max], b[Max], c[Max], dp[Max][3];
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i] >> b[i] >> c[i];
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];
	for (int i = 2; i <= n; ++i){
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
	return 0;
}

Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

S=input()

digit_mod13 = 1
pats = [0]*13
buf = [0]*13

pats[0] = 1
N = len(S)
for i in range(N):
    if S[N-1-i] == '?':
        for k in range(10):
            zurasu = (k*digit_mod13) % 13
            # print(k*digit_mod13, zurasu)
            for j in range(13):
                buf[(j+zurasu)%13] += pats[j]
        for j in range(13):
            pats[j] = buf[j] % DVSR
        # flush
        for j in range(13):
            buf[j] = 0
    else:
        zurasu = (int(S[N-1-i])*digit_mod13) % 13
        for j in range(13):
            buf[(j+zurasu)%13] += pats[j]
        for j in range(13):
            pats[j] = buf[j]
        # flush
        for j in range(13):
            buf[j] = 0

    digit_mod13 = (digit_mod13*10) % 13

# print(pats)
# print(buf)

print(pats[5])


Measured memory_bytes: 44652
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;



typedef pair < long long, long long > pll;
typedef unsigned long long ull;
typedef pair < int, int > pii;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 511;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 466;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int x, n, p[N];
bool was[N];

main () {
	cin >> x >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> p[i];
		was[p[i]] = 1;
	}

	pii ans = {inf, inf};
	for (int y = -N; y < N; ++y)
		if (y < 0 || !was[y])
			ans = min(ans, mp(abs(x - y), y));
	cout << ans.s << endl;
}



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

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	bool ok = false;
	// 全探索
	REP(i, K + 1) REP(j, K + 1) REP(k, K + 1) {
		int a = A * (1 << i);
		int b = B * (1 << j);
		int c = C * (1 << k);
		if (i + j + k <= K && a < b && b < c)
			ok = true;
	}

	if (ok) cout << "Yes" << '\n';
	else cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 3628
h, w = map(int, input().split())
a = [input() for _ in range(h)]
L = [1] * w
for i in range(w):
    if a[0][i] == '.':
        for j in range(h):
            if a[j][i] == '#':
                break
        else:
            L[i] = 0
for k in range(h):
    if '#' in a[k]:
        L2 = []
        for l in range(w):
            if L[l] == 1:
                L2.append(a[k][l])
        print(*L2, sep='')


Measured memory_bytes: 4468
n = int(input())
 
ans = []
while n != 0:
    if n % 2 != 0:
        n -= 1
        ans.append("1")
    else:
        ans.append("0")
    n //= -2
 
if len(ans) == 0:
    ans.append("0")
 
print("".join(reversed(ans)))

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize() {
  for ( int i = 0; i < N; i++ ) { row[i] = FREE; col[i] = FREE; }
  for ( int i = 0; i < 2 * N - 1; i++ ) { dpos[i] = FREE; dneg[i] = FREE; }
}

void printBoard() {
  for ( int i = 0; i < N; i++ )
    for ( int j = 0; j < N; j++ )
      if ( X[i][j] )
        if ( row[i] != j ) return;

  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < N; j++ )
      cout << ( ( row[i] == j ) ? "Q" : "." );
    cout << endl;
  }
}

void recursive(int i) {
  if ( i == N ) {  // クイーンの配置に成功
    printBoard(); return;
  }

  for ( int j = 0; j < N; j++ ) {
    // (i, j) が他のクイーンに襲撃されている場合は無視
    if ( NOT_FREE == col[j] ||
         NOT_FREE == dpos[i + j] ||
         NOT_FREE == dneg[i - j + N - 1] ) continue;
    // (i, j) にクイーンを配置する
    row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    // 次の行を試す
    recursive(i + 1);
    // (i, j) に配置されているクイーンを取り除く
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
  // クイーンの配置に失敗
}

int main() {
  initialize();

  for ( int i = 0; i < N; i++ )
    for ( int j = 0; j < N; j++ ) X[i][j] = false;

  int k; cin >> k;
  for ( int i = 0; i < k; i++ ) {
    int r, c; cin >> r >> c;
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}


Measured memory_bytes: 3092
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, P, *ABC = map(int, read().split())
    edge = [0] * M
    for i, (a, b, c) in enumerate(zip(*[iter(ABC)] * 3)):
        edge[i] = (a - 1, b - 1, -(c - P))

    dist = [INF] * N
    dist[0] = 0

    for _ in range(N - 1):
        for a, b, c in edge:
            if dist[a] != INF and dist[b] > dist[a] + c:
                dist[b] = dist[a] + c

    for _ in range(N):
        for a, b, c in edge:
            if dist[b] != INF and dist[b] > dist[a] + c:
                dist[b] = -INF

    score = -dist[N - 1]

    if score == INF:
        print(-1)
    else:
        print(max(0, score))

    return


if __name__ == '__main__':
    main()


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

int main(){
    string s;
    cin >> s;
    int start = 0;
    for(; ; start++){
        if(s[start] == 'A') break;
    }

    int goal;
    for(goal = s.length()-1; goal > start; goal--){
        if(s[goal] == 'Z') break;
    }

    cout << goal-start+1 << endl;
    return 0;
}

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

int main() {
    int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
    int m = sizeof(primes) / sizeof(int);
    vector<int> prime_count(1000);

    int n;
    cin >> n;

    int64_t v = 1;
    for(int i = 1; i <= n; ++i) {
        v *= i;
        for(int j = 0; j < m; ++j) {
            while (v % primes[j] == 0) {
                prime_count[j]++;
                v /= primes[j];
            }
        }
    }

    int64_t ans = 1;
    for(int j = 0; j < 1000; ++j) {
        ans = (ans * (prime_count[j] + 1)) % 1000000007;
    }
    cout << ans << endl;
}


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

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i < 1000; i++) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(0,c-(a-b)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin >> n;
    int counter = 0;
    int max_num = 0;
    int ans = 0;
    int num;
    while(n>0){
        num = n;
        if(n%2==0){
            while(num%2==0){
                counter++;
                num /= 2;
            }
            if(counter > max_num){
                ans = n;
                max_num = counter;
                counter = 0;
            }
        }else counter = 0;
        n--;
        if(ans==0) ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <utility>
#include<stack>
#include<queue>
#include<map>
#include <fstream>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long



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

        int n,a,b;
        cin>>n>>a>>b;
        cout << min( n*a,b ) <<endl;

      return 0;
    }



























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

using namespace std;
#define int long long
#define repeat(i, n) for(int i=0;i<(n);i++)

struct SegmentTree{

   static const int N=1<<17;
   static const int Z=0;
   vector<int> seg, lazy;
   SegmentTree(){
      seg.resize(2*N-1, 0);
      lazy.resize(2*N-1, 0);
   }

   inline void refresh(int i, int l, int r){
      if(lazy[i]){
         seg[i]+=lazy[i]*(r-l);
         if(r-l>1){
            lazy[2*i+1]+=lazy[i];
            lazy[2*i+2]+=lazy[i];
         }
         lazy[i]=0;
      }
   }

   void add(int a, int b, int x, int i=0, int l=0, int r=N){
      refresh(i, l, r);
      if(b<=l or r<=a){
         return;
      }else if(a<=l and r<=b){
         lazy[i]+=x;
         refresh(i, l, r);
      }else{
         int m=(r+l)/2;
         add(a, b, x, 2*i+1, l, m);
         add(a, b, x, 2*i+2, m, r);
         seg[i]=seg[2*i+1]+seg[2*i+2];
      }
   }

   int sum(int a, int b, int i=0, int l=0, int r=N){
      refresh(i, l, r);
      if(b<=l or r<=a){
         return Z;
      }else if(a<=l and r<=b){
         return seg[i];
      }else{
         int m=(r+l)/2;
         int vl=sum(a, b, 2*i+1, l, m);
         int vr=sum(a, b, 2*i+2, m, r);
         return vl+vr;
      }
   }

};

signed main(){

   int N, Q;
   cin>> N>> Q;
   SegmentTree st;
   while(Q--){
      int q; cin>> q;
      if(q==0){
         int s, t, x;
         cin>> s>> t>> x;
         st.add(s-1, t, x);
      }else{
         int s, t;
         cin>> s>> t;
         cout<< st.sum(s-1, t)<< endl;
      }
   }

   return 0;
}

Measured memory_bytes: 7044