akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j <= b; ++j) {
            int sum = x - 500 * i - 100 * j;
            if (0 <= sum && sum <= 50 * c && sum%50 == 0) ans++;
        }
    }
    cout << ans << endl;
}

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

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

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

  vector<int> a(n);
  rep(i,n) {cin >> a.at(i); a.at(i)--;}

  int count=0;
  int light=0;
  rep(i,n){
    light=a.at(light);
    count++;
    if(light==1){cout<<count; return 0;}
  }

  cout << -1;
}

Measured memory_bytes: 3768
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String[] words = line.Split(' ');
        int x1 = int.Parse(words[0]);
        int y1 = int.Parse(words[1]);
        int x2 = int.Parse(words[2]);
        int y2 = int.Parse(words[3]);
        int x3 = x2 - (y2 - y1);
        int y3 = y2 + (x2 - x1);
        int x4 = x1 - (y2 - y1);
        int y4 = y1 + (x2 - x1);

        Console.WriteLine(x3 + " " + y3 + " " + x4 + " " + y4);
    }
}

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

int gcd(int a, int b, int& x, int& y) {
    int d = a;
    if(b == 0){
        x = 1;
        y = 0;
    }
    else{
        d = gcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    return 0;
}
 
int main(void) {
    int a, b, x, y;
     
    cin >> a >> b;
    gcd(a, b, x, y);
    cout << x << " " << y << endl;
    return(0);
}

Measured memory_bytes: 1168
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int M = sc.nextInt();

			boolean[] inactive = new boolean[N + 1];
			for(int i = 0; i < M; i++) {
				inactive[sc.nextInt()] = true;
			}
			
			final long MOD = 1000000007;
			
			long[] DP = new long[N + 1];
			DP[0] = 1;
			for(int i = 1; i <= N; i++) {
				if(inactive[i]) { continue; }
				
				DP[i] += i >= 1 ? DP[i - 1] : 0; DP[i] %= MOD;
				DP[i] += i >= 2 ? DP[i - 2] : 0; DP[i] %= MOD;
			}
			
			System.out.println(DP[N]);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 31732
def solve():
    n, y = map(int, input().split())
    y = y // 1000
    for nogu in range(n+1):
        for higu in range(n + 1 - nogu):
            yuki = n - higu - nogu
            total = yuki*10 + higu*5 + nogu
            if total == y:
                print(yuki, higu, nogu)
                return
    print("-1 -1 -1")

solve()

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
	string s;
	cin >> s;
	
	int a=(s[0]-'0')*10+(s[1]-'0');
	
	int b=(s[2]-'0')*10+(s[3]-'0');
	
	if(0 <a && a<13 && 0<b&& b<13)cout << "AMBIGUOUS" << endl;
	else if(0<a&&a<13)cout << "MMYY" << endl;
	else if(0<b&&b<13)cout << "YYMM" << endl;
	else cout << "NA" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
   int N, M, X, Y;
   
   scanf("%d %d %d %d", &N, &M, &X, &Y);
   int x[N], y[M];

   for(int i = 0; i < N; i++) {
      scanf("%d", &x[i]);
   }

    for(int i = 0; i < M; i++) {
      scanf("%d", &y[i]);
   }

    int x_max = x[0];
    int y_min = y[0];

    for(int i = 1; i < N; i++) {
       if(x_max < x[i]) {
          x_max = x[i];
       }
    }

    for(int i = 0; i < M; i++) {
       if(y_min > y[i]) {
          y_min = y[i];
       }
    }

    if(x_max < y_min && X < Y && X <= x_max && Y >= y_min) {
       printf("No War\n");
    } else {
       printf("War\n");
    }

   return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> cnt(26);
  for (int i = 0; i < n; i++) {
    cnt[s[i] - 'A']++;
  }
  int a = (cnt['N' - 'A'] > 0) + (cnt['S' - 'A'] > 0);
  int b = (cnt['E' - 'A'] > 0) + (cnt['W' - 'A'] > 0);
  if (a == 1 || b == 1) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
	double x1,y1,x2,y2;
	double p1,p2,h1,h2;
	double sum;
	double hasil;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	h1=x2-x1;
	h2=y2-y1;
	p1=pow(h1,2);
	p2=pow(h2,2);
	sum=p1+p2;
	hasil=sqrt(sum);
	printf("%lf\n",hasil);
	return 0;
}


Measured memory_bytes: 2736
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<numeric>
using namespace std;
int main() {
	int a[3];
	for (int i = 0; i < 3; i++)
		cin >> a[i];

	sort(a, a + 3);

	if (a[0] == 5 && a[1] == 5 && a[2] == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL N;
	cin >> N;

	N += 1;
	LL r = 0;
	REP(i, N) {
		if (i >= 1 && i <= 9) {
			++r;
		}
		else if (i >= 100 && i <= 999) {
			++r;
		}
		else if (i >= 10000 && i <= 99999) {
			++r;
		}

	}

	cout << r << endl;


	return 0;
}


Measured memory_bytes: 256
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
dist_lap1 = T1 * A1 + T2 * A2
dist_lap2 = T1 * B1 + T2 * B2
if dist_lap1 == dist_lap2:
    print("infinity")
else:
    if dist_lap1 > dist_lap2:
        diff = T1 * B1 - T1 * A1
        if diff < 0:
            print(0)
        else:
            if diff % (dist_lap1 - dist_lap2) == 0:
                print((diff // (dist_lap1 - dist_lap2)) * 2)
            else :
                print((diff // (dist_lap1 - dist_lap2)) * 2 + 1)
    else:
        diff = T1 * A1 - T1 * B1
        if diff < 0:
            print(0)
        else:
            if diff % (dist_lap2 - dist_lap1) == 0:
                print((diff // (dist_lap2 - dist_lap1)) * 2)
            else :
                print((diff // (dist_lap2 - dist_lap1)) * 2 + 1)

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long M = inputArray[1];
			long K = inputArray[2];

			var AArray =  retreiveLongArray();
			var BArray = retreiveLongArray();

			var ARuiseki = new Dictionary<long, long>();
			var BRuiseki = new Dictionary<long, long>();

			long current = 0;
			for (int i = 0; i < N; i++) {
				current += AArray[i];
				ARuiseki.Add(i, current);
			}

		     current = 0;
			for (int i = 0; i < M; i++) {
				current += BArray[i];
				BRuiseki.Add(i, current);
			}



			var nMax = yomeru(ARuiseki, K);
			var remainMin = nMax == 0 ? K : K - ARuiseki[nMax - 1];
			var bMin = yomeru(BRuiseki, remainMin);
			var max = nMax + bMin;

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

				if (i==nMax) {//Aの山から一冊も読まない場合
					var bMax = yomeru(BRuiseki,K);
					max = Math.Max(bMax, max);
					continue;
				}

				var n = nMax - i;
				var remain = K-ARuiseki[n - 1];
				var b = yomeru(BRuiseki, remain);
				max = Math.Max(n+b, max);
			}

			//答えの出力
			var ans = max;
			Console.WriteLine(ans);

		}


		/// <summary>
		/// timeの間で読める本の数
		/// </summary>
		/// <param name="ruiseki"></param>
		/// <param name="time"></param>
		/// <returns></returns>
		private static long yomeru(Dictionary<long,long> ruiseki,long time) {

			var max = ruiseki.Count();
			var min = 0;

			var total = ruiseki[max-1];
			var first = ruiseki[0];

			if (total <= time) {
				return max;
			}

			if (first > time) {
				return 0;
			}

			while (min < max) {

				var mid = (max + min)/2;

				if (ruiseki[mid] <= time && time < ruiseki[mid+1]) {
					return mid + 1;
				}

				if (time < ruiseki[mid]) {
					max = mid;
					continue;
				}

				if (ruiseki[mid + 1] <= time) {
					min = mid;
					continue;
				}

			}
			return -1;//この処理を通る場合はエラーが起きている

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 88168
#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define ft first
#define sd second
#define pb(a) push_back(a)
#define PII std::pair<int,int>
#define PLL std::pair<ll,ll>
#define mp(a,b) std::make_pair(a,b)
#define ITR(a,b) for(auto a:b)
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=100000+10,Mod=1e9+7;
int n,m,s[MAXN];
struct Matrix{
	ll a[3][3];
	Matrix(){
		REP(i,0,2)REP(j,0,2)a[i][j]=0;
	};
	inline void init()
	{
		REP(i,0,2)a[i][i]=1;
	}
	inline Matrix operator * (const Matrix &A) const {
		Matrix B;
		REP(i,0,2)REP(j,0,2)REP(k,0,2)
			(B.a[i][j]+=1ll*a[i][k]*A.a[k][j]%Mod)%=Mod;
		return B;
	};
};
Matrix E[2],ans;
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline bool chkmin(T &x,T y){return y<x?(x=y,true):false;}
template<typename T> inline bool chkmax(T &x,T y){return y>x?(x=y,true):false;}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline Matrix qexp(Matrix a,ll b)
{
	Matrix res;res.init();
	if(b<0)return res;
	while(b)
	{
		if(b&1)res=res*a;
		a=a*a;
		b>>=1;
	}
	return res;
}
int main()
{
	read(n);read(m);

	E[0].a[0][0]=1;E[0].a[0][1]=2;E[0].a[0][2]=1;
	E[0].a[1][0]=0;E[0].a[1][1]=1;E[0].a[1][2]=1;
	E[0].a[2][0]=1;E[0].a[2][1]=2;E[0].a[2][2]=2;

	E[1].a[0][0]=1;E[1].a[0][1]=2;E[1].a[0][2]=1;
	E[1].a[1][0]=0;E[1].a[1][1]=1;E[1].a[1][2]=1;
	E[1].a[2][0]=0;E[1].a[2][1]=0;E[1].a[2][2]=1;

	ans.a[0][0]=1;

	s[0]=-1;
	REP(i,1,m)read(s[i]),ans=ans*qexp(E[0],s[i]-s[i-1]-1)*E[1];
	ans=ans*qexp(E[0],n-s[m]-1);
	write(ans.a[0][2],'\n');
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int N; cin >> N;
    vl p(N); rep(i,N) cin >> p[i];
    vl a(N), b(N);
    vl r(N); rep(i,N) r[p[i]-1] = i;
    rep(i,N) a[i] = 30000 * (i+1);
    rep(i,N) b[i] = 30000 * (N - i) + r[i];
    rep(i,N-1) cout << a[i] << " ";
    cout << a[N-1] << endl;
    rep(i,N-1) cout << b[i] << " ";
    cout << b[N-1] << endl;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define ff first
#define ss second
typedef pair<int,int> pii;

int32_t main()
{
 int n , d ;
 cin >> n >> d ;
 int cnt = 0 ;

 for(int i = 0 ; i < n ; i++){
  int x , y ;
  cin >> x >> y ;

  if(x * x + y * y <= d * d)++cnt ;
 }
 cout << cnt ;
 return 0;
}        

Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a + b >= c)
		printf("Yes\n");
		else
			printf("No\n");
			return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, k;
bool exist[10010];
bool target[10010];
char output[10010];

int Communicate() {
  printf("%s\n", output);
  fflush(stdout);
  int v;
  scanf("%d", &v);
  return v;
}

int UpdateTarget(int c) {
  int index = -1;
  REP(i, n) {
    if (!target[i]) { continue; }
    if (output[i + 1] == '0' + c) { target[i] = false; }
    if (index == -2 || !target[i]) { continue; }
    else if (index == -1) { index = i; }
    else { index = -2; }
  }
  assert(index != -1);
  return index;
}

void RandomSequence() {
  output[0] = '?';
  REP(i, n) {
    if (!target[i]) { output[i + 1] = '0'; }
    else { output[i + 1] = '0' + (rand() % 2 ? 1 : 0); }
  }
  output[n + 1] = '\0';
}

int main() {
  scanf("%d %d", &n, &k);
  MEMSET(exist, false);
  REP(i, k) {
    REP(j, n) { target[j] = !exist[j]; }
    while (true) {
      RandomSequence();
      if (Communicate()) { break; }
    }
    int prev = 0;
    while (true) {
      int index = UpdateTarget(prev);
      if (index >= 0) {
        exist[index] = true;
        break;
      }
      RandomSequence();
      prev = Communicate() == 0 ? 1 : 0;
    }
  }

  vector<int> ans;
  REP(i, n) { if (exist[i]) { ans.push_back(i + 1); } }
  printf("!");
  REP(i, k) {
    if (i != 0) {
      putchar(' ');
    }
    printf("%d", ans[i]);
  }
  puts("");
  fflush(stdout);
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;




void solve() {


	long long H, N;
	long long *A;

	cin >> H >> N;
	A = new long long[N];
	long long sum = 0;
	for (int i = 0;i < N;i++)cin >> A[i];
	bool flag = false;
	for (int i = 0;i < N;i++) {
		sum += A[i];
		if (sum >= H) {
			flag = true;
			break;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


}



int main() {
	solve();

}

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

long long l[100010];

int main() {
	int n;long long k;
	cin >> n >> k;
	int a, b;
	for (int i = 0; i < 100010; i++) {
		l[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		l[a] += b;
	}
	long long count = 0;
	for (int i = 0; i < 100010; i++) {
		count += l[i];
		if (count >= k) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		int N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		long[] H = new long[N];
		for (int i = 0; i < N; ++i) {
			H[i] = Long.parseLong(tokens[i]);
		}

		H[0]--;
		boolean enable = true;
		for (int i = 1; i < N; ++i) {
			if (H[i - 1] < H[i]) {
				H[i]--;
			}
			if (H[i - 1] > H[i]) {
				enable = false;
				break;
			}
		}
		String result = enable ? "Yes" : "No";
		System.out.println(result);

	}
}


Measured memory_bytes: 48140
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/*Used path compression technique*/
/*-------------------------------------*/
//ll finds(ll a)
//{
//    vector<ll>vec;
//    while(parent[a]>0){
//        vec.pb(a);
//        a=parent[a];
//    }
//    for(int i=0;i<vec.size();i++)parent[vec[i]]=a;
//    return a;
//}
//void unions(ll a,ll b)
//{
//    parent[a]+=parent[b];
//    parent[b]=a;
//}
/*------------------------------*/
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=max(a,c);
    ll ans2=min(b,d);
    if(ans>ans2)cout<<"0"<<endl;
    else cout<<ans2-ans<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;

#define all(x) (x).begin(),(x).end()
#define fastio ios_base::sync_with_stdio(false)

typedef double db;
typedef long long ll;
typedef unsigned long long ull;

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

int main() {
	fastio;
    int k; cin >> k;
    int a,b; cin >> a >> b;
    for(int i = a; i <= b; ++i) {
    	if(i % k == 0) {
    		cout << "OK\n";
    		return 0;
    	}
    }	
    cout << "NG\n";
	return 0;
}

Measured memory_bytes: 3664
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7




def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    f = list(map(int, input().split()))
    a.sort()
    f = sorted(f,reverse=True)

    def ok(v):
        cnt = 0
        sa = 0
        for i in range(n):
            t = a[i]*f[i]
            if v - t >= 0:
                continue
            cnt += a[i] - (v // f[i])
            if cnt > k:
                return False
        
        if cnt <= k:
            return True
        else:
            return False





    l, r = 0, 10 ** 18
    for i in range(80):
        m = (l + r) // 2
        if ok(m):
            r = m
        else:
            l = m
    print(r)

    
            
    

    

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 121988
import sys

inf = sys.maxsize

N = int(input())
heights = list(map(int, input().split()))

# DPテーブルの初期化(最小問題なのでINFで初期化
dp = [inf] * N

# 初期条件
dp[0] = 0


def chmin(a, b, diff):
    if dp[a] > dp[b]+diff:
        dp[a] = dp[b]+diff
        return True
    return False

# 普通のDP
for i in range(1, N):
    chmin(i, i-1, abs(heights[i]-heights[i-1]))
    if i > 1:
        chmin(i, i-2, abs(heights[i]-heights[i-2]))
print(dp[N-1])


# # メモ化再帰
# def chmin(a, b):
#     if a > b:
#         a = b
#     return a
#
#
# def rec(i):
#     if dp[i] < inf:
#         return dp[i]
#     if i == 0:
#         return 0
#     res = inf
#     res = chmin(res, rec(i-1)+abs(heights[i]-heights[i-1]))
#     if i > 1:
#         res = chmin(res, rec(i-2)+abs(heights[i]-heights[i-2]))
#     dp[i] = res
#     return dp[i]
#
#
# print(rec(N-1))

Measured memory_bytes: 13928
#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--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
struct UnionFind {
    vector<int> par; // uf(x,y)->y
    UnionFind() {}
    UnionFind(int NV) { init(NV); }
    void init(int NV) { par.clear(); rep(i, 0, NV) par.push_back(i); }
    void reset() { rep(i, 0, par.size()) par[i] = i; }
    int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
    void operator()(int x, int y) { x = operator[](x); y = operator[](y); if (x != y) par[x] = y; }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, M, K;
int club[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> K;
    rep(i, 0, N) club[i] = -1;

    UnionFind uf(N);
    rep(i, 0, K) {
        int t, a, b; cin >> t >> a >> b; a--; b--;
        if (t == 1) {
            if (uf[a] != uf[b]) {
                int aa = uf[a];
                int bb = uf[b];
                uf(a, b);
                int nx = uf[a];
                if (club[aa] != club[bb]) {
                    if (club[aa] < 0) club[nx] = club[bb];
                    else if (club[bb] < 0) club[nx] = club[aa];
                    else {
                        printf("%d\n", i + 1);
                        return;
                    }
                }
            }
        } else {
            if (club[uf[a]] < 0) club[uf[a]] = b;
            else {
                if (club[uf[a]] != b) {
                    printf("%d\n", i + 1);
                    return;
                }
            }
        }
    }
    printf("0\n");
}


Measured memory_bytes: 3948
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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;}
const ll INF = 1e9+1;

/*
ACGTのみで構成される

AGC　を含まない

ブラックリスト
AGC
ACG
GAC
AG_C
A_GC
Aだったら許されるのは

A -> A -> A
       -> G
       -> C
       -> T
  -> G -> A
       -> G
       -> T
  -> C -> A
       -> C
       -> T
  -> T -> A
       -> G
       -> C
       -> T
*/
int D = 1e9+7;
int N;

int dp[101][2 << 6];

char base[4] = {'A','G','C','T'};

int main() {
    cin >> N;
    if (N == 1) {
        cout << 4 << endl;
        return 0;
    } else if (N == 2) {
        cout << 16 << endl;
        return 0;
    } else if (N == 3) {
        cout << 61 << endl;
        return 0;
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                if (i == 0 && j == 1 && k == 2 || 
                i == 1 && j == 0 && k == 2 ||
                i == 0 && j == 2 && k == 1) continue;
                dp[3][16*i+4*j+k] = 1;
            }
        }
    }
    for (int n = 3; n < N; n++) {
        for (int c = 0; c < 4; c++) {
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    for (int k = 0; k < 4; k++) {
                        if (j == 0 && k == 1 && c == 2 ||
                        j == 0 && k == 2 && c == 1 ||
                        i == 0 && j == 1 && c == 2 ||
                        i == 0 && k == 1 && c == 2 ||
                        j == 1 && k == 0 && c == 2) continue;
                        dp[n+1][16*j+4*k+c] = (dp[n+1][16*j+4*k+c] + dp[n][16*i+4*j+k]) % D;
                        
                    }
                }
            }
        }
    }
    int res = 0;
    for (int i = 0; i < 64; i++) {
        res = (res + dp[N][i]) % D;
    }
    cout << res << endl;




}
    





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,Q; string S; cin >> N >> S >> Q;
    rep(i,Q){
        ll k; cin >> k;
        ll ans=0,cnt0=0,cnt1=0,cnt2=0;
        rep(j,N){
            if (j>=k){
                if (S[j-k]=='D') --cnt1,cnt0-=cnt2;
                if (S[j-k]=='M') --cnt2;
            }
            if (S[j]=='D') ++cnt1;
            if (S[j]=='M') ++cnt2,cnt0+=cnt1;
            if (S[j]=='C') ans+=cnt0;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int N; cin >> N;
    N = 10 - N/200;
    AA(N);
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			double val = in.nextDouble();
			if (val < 0) {
				break;
			}
			if (val >= 256) {
				System.out.println("NA");
			} else {
				int seisu = (int) val;
				int syosu = (int) ((val - seisu) * 16);
				if ((val - seisu) * 16 - syosu != 0) {
					System.out.println("NA");
				} else {
					val *= 256;
					int a = 128 * 256;
					for (int i = 0; i < 12; i++) {
						int b = (int) (val / a);
						System.out.print(b);
						val = val - a * b;
						a /= 2;
						if (i == 7) {
							System.out.print(".");
						}
					}
					System.out.println();
				}
			}
		}
	}
}

Measured memory_bytes: 27860
import sys

sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

N, K = list(map(int, input().split()))
S = input()

chunks = 0
between = 0

prev = S[0]

for s in S:
    if s != prev:
        if s == S[0]:
            between += 1
        chunks +=1
    prev = s


if K <= between:
    ans = N - chunks + 2 * K
else:
    ans = N - 1

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long int  arr[90];
int main()
{
    int n;
    arr[0]=2;
    arr[1]=1;
    while(cin>>n){
        if(n>=2){
            for(int i=2;i<=n;i++) arr[i]=arr[i-1]+arr[i-2];
        }
        cout<<arr[n]<<endl;
    }
    return 0;
}


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

int main()
{
	int n; cin >> n;
	
	vector<int> a(n + 2);
	a[0] = 0;
	a[n + 1] = 0;
	for (int i = 1; i <= n; i++) cin >> a[i];
	
	vector<int> d(n + 2);
	int sum = 0;
	for (int i = 1; i <= n + 1; i++) {		
		d[i] = abs(a[i] - a[i - 1]);
		sum += d[i];
	}

	for (int i = 1; i <= n; i++) {
		int ans = sum - d[i] - d[i + 1] + abs(a[i + 1] - a[i - 1]);
		cout << ans << endl;
	}	

	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=3e3+10,mod=998244353;

int main ()
{
    FASTIO;
    string s;
    cin >> s;
    for(auto x:s){
        cout << (x=='?'? 'D' : x);
    }
    cout << endl;
    return 0;
}
/**


*/


Measured memory_bytes: 3732
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long LL;

int main()
{
    LL K,N;
    LL A[55];
    cin>> K;

    LL num = K/50;
    LL k = K % 50;
    A[0] = 49-k;
    for(int i = 1; i < k+1; i++)
    {
        A[i] = 50;
    }
    for(int i = k+1; i < 50; i++)
        A[i] = 49-k-1;
    for(int i = 0; i < 50; i++)
        A[i] += num;

    cout<<50<<endl;
    for(int i = 0; i < 50; i++)
    {
        if(i) printf(" ");
        printf("%lld", A[i]);
    }

    return 0;

}


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

int main(){
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    long long int max=-1000000000000000000;
    if(a*c>max){
        max = a*c;
    }
    if(a*d>max){
        max = a*d;
    }
    if(b*c > max){
        max = b*c;
    }
    if(b*d > max){
        max = b*d;
    }
    cout << max << endl;
}

Measured memory_bytes: 3628
from bisect import bisect_left

N, T = map(int, input().split())
A = list(map(int, input().split()))

aa = A[:]
aa.sort()

ans = 0
num = 0

for i in range(N-1):
    ind = bisect_left(aa, A[i])
    del aa[ind]
    now = aa[-1] - A[i]
    
    if 0 < now and num < now:
        ans = 1
        num = now
    elif num == now:
        ans += 1

print(ans)

Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, 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 1; } return 0; }

map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}   

int main() {
    ll N, P;
    cin >> N >> P;
    map<ll,ll>facs;
    ll ans = 1;
    for(auto p : prime_factor(P)) {
    while(p.second--){
        facs[p.first]++;    
        if (facs[p.first] >= N){
            ans *= p.first;
            facs[p.first] = 0;
        }
    }
  }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

//xy??§?¨???§?????±???????????¢?´¢
void dfs(int x, int y) {
	static const int MAX_X = 1, MAX_Y = 1;

	/* ?????? */

	//?§????4?????????????????????
	int dx[4] = { 1,0,-1,0 };
	int dy[4] = { 0,1,0,-1 };
	//?§????4???????????¢?´¢
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx&&nx < MAX_X && 0 <= ny&&ny < MAX_Y) {
			dfs(nx, ny);
		}
	}
}

//xy??§?¨???§??????????????¢?´¢
//???????????¢
int bfs(int sx, int sy, int gx, int gy) {
	static const int MAX_X = 1, MAX_Y = 1;

	queue<pii> Q;
	Q.push(pii(sx, sy));

	//???????????¢
	int d[MAX_X][MAX_Y];
	memset(d, 0x3f, sizeof(d));

	//?§????4?????????????????????
	int dx[4] = { 1,0,-1,0 };
	int dy[4] = { 0,1,0,-1 };
	for (pii u; !Q.empty();) {
		u = Q.front(); Q.pop();
		//??´??????????????¢?´¢????????????
		if (u == pii(gx, gy))break;
		//?§????4???????????¢?´¢
		for (int i = 0; i < 4; i++) {
			int nx = sx + dx[i], ny = sy + dy[i];
			if (0 <= nx&&nx < MAX_X && 0 <= ny&&ny < MAX_Y) {
				//??¢?´¢???????£???°???
				if (d[nx][ny] != INF)continue;
				d[nx][ny] = d[sx][sy] + 1;
				Q.push(pii(nx, ny));
			}
		}
	}
	return d[gx][gy];
}

#define MAX 50

int main() {
	char a[MAX][MAX];
	char b[MAX][MAX];
	for (int w, h; cin >> w >> h&&w;) {
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));


		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				cin >> a[x][y];
				b[x][y] = a[x][y];
			}
		}

		int B = 0, W = 0;

		for (int x = 0; x < w; x++) {
			for (int y = 0; y < h; y++) {

				if (a[x][y] == '.')continue;

				queue<pii> Q;
				Q.push(pii(x, y));

				//?§????4?????????????????????
				int dx[4] = { 1,0,-1,0 };
				int dy[4] = { 0,1,0,-1 };
				for (pii u; !Q.empty();) {
					u = Q.front(); Q.pop();
					//?§????4???????????¢?´¢
					for (int i = 0; i < 4; i++) {
						int nx = u.first + dx[i], ny = u.second + dy[i];
						if (0 <= nx&&nx < w && 0 <= ny&&ny < h) {
							//W B ?????£???????£???°???
							if (a[nx][ny] != '.')continue;

							//??¢?´¢??? ?????? ?£???°???
							if (b[nx][ny] == a[x][y]) {
								continue;
							}
							//?????¢?´¢
							else if (b[nx][ny] == '.') {
								b[nx][ny] = b[x][y];
							}
							//??¢?´¢??? 0 ?£???°???
							else if (b[nx][ny] == '0')
								continue;
							//??¢?´¢??? ??°???
							else {
								b[nx][ny] = '0';
							}
							Q.push(pii(nx, ny));
						}
					}
				}
			}
		}

		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				//cerr << b[x][y];
				if (a[x][y] == '.') {
					if (b[x][y] == 'B')B++;
					if (b[x][y] == 'W')W++;
				}
			}
			//cerr << endl;
		}
		cout << B << " " << W << endl;

	}
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
   int n, m, x, y;
   cin >> n >> m >> x >> y;
   int max_x = -100, min_y = 100;
   rep(i,n){
      int tmp;
      cin >> tmp;
      if(tmp >= max_x) max_x = tmp;
   }
   rep(i,m){
      int tmp;
      cin >> tmp;
      if(tmp <= min_y) min_y = tmp;
   }
   if(max_x >= y || min_y <= x) cout << "War" << endl;
   else if(max_x < min_y) cout << "No War" << endl;
   else cout << "War" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	reus;
	ll int n,m,h,a,b,x[100002],y[100002]={0},c=0,i;
	//vector <int> v;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		cin>>x[i];
	}
	while(m--)
	{
		cin>>a>>b;
		if(x[a]==x[b])
		{
			y[a]=-1;
			y[b]=-1;
		}
		else if(x[a]>x[b])
		{
			y[b]=-1;
		}
		else if(x[a]<x[b])
		{
			y[a]=-1;
		}
	}
	//int k=*max_element(x,x+n);
	for(i=1;i<=n;i++)
	{
		if(y[i]==0)
		{
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 5196
h,w = map(int,input().split())


if h == 1 or w == 1:
    print(1)
    exit()
def ceil(a, b):
   return a // b + (a % b > 0)

ans = ceil(w,2) * ceil(h, 2) + ((h//2) * (w//2))

print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

typedef vector<int> vi;

int main()
{
  int N;
  cin >> N;
  vector<int> a(N - 1), b(N - 1);
  vector<vi> G(N); // G[i] := 点iと隣接している点の集合
  REP(i, N - 1)
  {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  vector<vi> dist(2, vi(N)); // dist[c][i] := 色c(1：黒，0：白)のスタート地点から点iまでの距離
  REP(i, N)
  dist[1][i] = -1;
  dist[1][0] = 0;
  queue<int> que;
  que.push(0);
  while (que.size())
  {
    int p = que.front();
    que.pop();
    REP(i, G[p].size())
    {
      int q = G[p][i];
      if (dist[1][q] == -1)
      {
        que.push(q);
        dist[1][q] = dist[1][p] + 1;
      }
    }
  }
  REP(i, N)
  dist[0][i] = -1;
  dist[0][N - 1] = 0;
  que.push(N - 1);
  while (que.size())
  {
    int p = que.front();
    que.pop();
    REP(i, G[p].size())
    {
      int q = G[p][i];
      if (dist[0][q] == -1)
      {
        que.push(q);
        dist[0][q] = dist[0][p] + 1;
      }
    }
  }
  int fennec = 0;
  int snuke = 0;
  REP(i, N)
  {
    if (dist[1][i] <= dist[0][i])
      fennec++;
    else
      snuke++;
  }
  cout << (fennec > snuke ? "Fennec" : "Snuke") << endl;
  return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define rep(i,n)        for(int i=0;i<n;i++)
#define rrep(i,n)       for(int i=n-1;i>=0;i--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void ayushmehta651()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
}

int32_t main()
{
	ayushmehta651();
	int a;
	cin >> a;

	int ans1 = a * a;
	int ans2 = ans1 * a;

	int final_ans = a + ans1 + ans2;
	cout << final_ans << '\n';
	return 0;
}













bool compare(string &s1, string &s2)
{
	return s1.size() < s2.size();
}

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int flag=0;
    for(int i=0;i<110;i++){
    	if(i%2==0){
    		c = c - b;
    		if(c<=0){
    			flag =i;
    			break;
			}
		}
		else{
			a = a - d;
			if(a<=0){
				flag = i;
				break;
			}
		}
	}
	if(flag%2==0){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
    
}

Measured memory_bytes: 3568
alpha=lambda x:chr(x+64)
num=lambda x:ord(x)-ord("A")+1

n=int(input())
s=list(input())
ans=""

for i in range(len(s)):
    now=num(s[i])
    num_now=(now+n)%26
    if num_now==0:
        num_now=26
    ans+=alpha(num_now)
print(ans)

Measured memory_bytes: 3064
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

template<class T>
bool query(T x){
    cout << "? " << x << endl;
    char ret; cin >> ret;
    return ret == 'Y';
}

template<class T>
void ans(T x){
    cout << "! " << x << endl;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x = 1e10-1;
    debug(x);
    ll ma = 0;
    rep(i,1,10){
        string s = to_string(i);
        s += to_string(x);
        debug(s);
        bool t = query(s);
        if(t){
            ma = i; break;
        }
    }
    x = 1e10;
    x *= ma;
    debug(x);
    // N = ma * 10^iのパターン
    if(query(x)){
        if(ma == 1){
            x = 2e10;
            while(x && query(x)){
                x /= 10;
            }
            if(x == 0){
                ans(1);
                return 0;
            }
            else{
                ans(x*10/2);
                return 0;
            }
        }
        else{
            x = (ma-1) * 1e10;
            while(!query(x)){
                x /= 10;
            }
            x = (x / (ma-1)) * ma;
            ans(x);
            return 0;
        }

    }
    x /= 10;
    while(!query(x)){
        x /= 10;
    }

    ll ng = x, ok = (x / ma) * (ma+1)-1;
    debug(ok, ng);
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(query(to_string(mid) + '0'))ok = mid;
        else ng = mid;
    }

    ans(ok);
}

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

void solve(long long N, std::vector<long long> s)
{
    // A - B = CとおいてCについて考える
    // 経由する番号は順に
    // 0, A, C, A+C, 2C, A+2C, …, kC, A+kC(=N-1)
    ll ans = 0;
    for (ll c = 1; c <= N; c++) {
        ll score = 0;
        set<ll> passed;

        for (ll k = 0; k * c < N - 1; k++) {
            auto a = N - 1 - k * c; // A + kC = N - 1 より
            if (a <= c) {
                // A - B = C → B = A - C
                // Bが1以上であるためにはA>Cでなければならない
                break;
            }
            auto l = k * c; // 0, C, 2C, …, kCの列
            auto r = N - 1 - k * c; // A, A+C, A+2C, …, A+kCの列
            if (l == r || passed.count(l) > 0 || passed.count(r) > 0) {
                // すでに通った蓮は使えない
                break;
            }
            score += s[l] + s[r];
            passed.insert(l);
            passed.insert(r);
            ans = max(ans, score);
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> s(N-1-0+1);
    for(int i = 0 ; i < N-1-0+1 ; i++){
        scanf("%lld",&s[i]);
    }
    solve(N, std::move(s));
    return 0;
}


Measured memory_bytes: 5760