akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

const int MOD=924844033;
struct mint{int x;mint(int x=0):x(x){}};
inline mint operator+  (mint a,mint b){return a.x+b.x<MOD?a.x+b.x:a.x+b.x-MOD;}
inline mint operator-  (mint a){return MOD-a.x;}
inline mint operator-  (mint a,mint b){return a+-b;}
inline mint operator*  (mint a,mint b){return 1LL*a.x*b.x%MOD;}
inline mint operator<< (mint x,int y){mint r=1;for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
inline mint operator~  (mint x){return x<<MOD-2;}
inline mint operator/  (mint a,mint b){return a*~b;}
inline mint&operator+= (mint&a,mint b){return a=a+b;}
inline mint&operator-= (mint&a,mint b){return a=a-b;}
inline mint&operator*= (mint&a,mint b){return a=a*b;}
inline mint&operator<<=(mint&x,int y){return x=x<<y;}
inline mint&operator/= (mint&a,mint b){return a=a/b;}

#define MN 2000
mint f[MN+5][MN+5][2],p[MN+5],ans;
int main()
{
	int n,k,i,j,l;
	scanf("%d%d",&n,&k);
	for(f[0][0][0]=i=1;i<=n&&i<=2*k;++i)
	{
		for(j=0;j<=n;++j)
		{
			f[i][j][0]+=f[i-1][j][0];
			if(i>k)f[i][j+1][0]+=f[i-1][j][0];
			if(i+k<=n)f[i][j+1][1]+=f[i-1][j][0];
		}
		for(l=i;(l+=2*k)<=n;)for(j=0;j<=n;++j)
		{
			f[l][j][0]+=f[l-2*k][j][0]+f[l-2*k][j][1];
			f[l][j+1][0]+=f[l-2*k][j][0];
			if(l+k<=n)f[l][j+1][1]+=f[l-2*k][j][0]+f[l-2*k][j][1];
		}
		for(j=0;j<=n;++j)f[i][j][0]=f[l-2*k][j][0]+f[l-2*k][j][1];
	}
	for(l=i-1,p[0]=i=1;i<=n;++i)p[i]=p[i-1]*i;
	for(i=0;i<=n;++i)ans+=(mint(MOD-1)<<i)*f[l][i][0]*p[n-i];
	printf("%d",ans);
}

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

#define fo(i, x, y) for (int i = x; i <= y; ++i)
#define fd(i, x, y) for (int i = x; i >= y; --i)

const int maxn = 1e3 + 5, inf = 1e9;

int lens, lent;
char s[maxn], t[maxn];

int getint()
{
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && (ch ^ '-'));
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return res * p;
}

int cnt(int x)
{
	int res = 0;
	fo(i, 1, lent) res += s[x + i - 1] != t[i];
	return res;
}

int main()
{
	scanf("%s", s + 1);
	scanf("%s", t + 1);
	lens = strlen(s + 1); lent = strlen(t + 1);
	int ans = inf;
	fo(i, 1, lens - lent + 1)
		ans = min(ans, cnt(i));
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3812
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 110, maxk = 100010, mod = 1e9 + 7;
int n, k, a[maxn];
ll dp[maxn][maxk], sum[maxk];
int main()
{
    read(n), read(k);
    rep(i, 1, n) read(a[i]);
    rep(i, 0, n) dp[i][0] = 1;
    rep(i, 1, n) {
        sum[0] = 0;
        rep(j, 1, k + 1) sum[j] = (sum[j - 1] + dp[i - 1][j - 1]) % mod;
        rep(j, 1, k)
            dp[i][j] = ((sum[j + 1] - sum[max(0, j - a[i])]) % mod + mod) % mod;
    }
    printf("%lld\n", dp[n][k]);
    return 0;
}

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

#define pb push_back
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef map<ll,ll> ii;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	ll x,y;cin>>x>>y;
	vl a,b;
	
	for(int i=0;i<y;i++){
	    ll j,k;cin>>j>>k;
	    a.pb(j);b.pb(k);
	}
	
	vector<ll> v[y+1];
	for(int i=0;i<=y;i++){
	    for(int j=0;j<=x;j++){
	        ll k=0;
	        if (i==0){
	            k=1e9;
	        }
	        v[i].pb(k);
	    }
	}
	for(int i=1;i<=y;i++){
	    for(int j=1;j<=x;j++){
	        if(j<=a[i-1]){
	            v[i][j]=min(v[i-1][j],b[i-1]);
	        }
	        else{
	            v[i][j]=min(v[i-1][j],v[i][j-a[i-1]]+b[i-1]);
	        }
	    }
	}
	cout<<v[y][x];
	
	return 0;
}

Measured memory_bytes: 80512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	int c;		// finish color
	int h;
	int w;
	int max;
	int tmp;
	boolean[][] comb;
	int z = 0;
	
	void Join(int[][] pane, int i, int j){
		if(i<0||i>=h||j<0||j>=w||comb[i][j]==true||pane[i][j]!=pane[0][0]){
			return;
		}
		tmp++;
		comb[i][j] = true;
		Join(pane,i+1,j);
		Join(pane,i,j+1);
		Join(pane,i-1,j);
		Join(pane,i,j-1);
	}
	
	void Color(int pane[][], int cnt){
		// 結合する
		comb = new boolean[h][w];
		tmp = 0;
//		if(z++>20){
//			System.exit(0);
//		}
		Join(pane,0,0);
//		System.out.println("結合状態");
//		for(int i=0;i<h;i++){
//			System.out.println(Arrays.toString(comb[i]));
//		}
		max = Math.max(max,tmp);
//		System.out.println("最大値"+max);
		if(cnt==4){
//			System.out.println("5回目 "+c+"に彩色");
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					if(comb[j][k]){
						pane[j][k] = c;
					}
				}
			}
//			System.out.println("設定色");
//			for(int j=0;j<h;j++){
//				System.out.println(Arrays.toString(pane[j]));
//			}
			Color(pane,++cnt);
			return;
		}
		else if(cnt==5){
			return;
		}
		cnt++;
		for(int i=1;i<=6;i++){
//			System.out.println(cnt+"回目 "+i+"に彩色");
			int[][] copy = new int[h][w];
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					copy[j][k] = pane[j][k];
				}
			}
			boolean[][] copy_comb = new boolean[h][w];
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					copy_comb[j][k] = comb[j][k];
				}
			}
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					if(comb[j][k]){
						pane[j][k] = i;
					}
				}
			}
//			System.out.println("設定色");
//			for(int j=0;j<h;j++){
//				System.out.println(Arrays.toString(pane[j]));
//			}
			Color(pane,cnt);
//			System.out.println("戻し");
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					pane[j][k] = copy[j][k];
					comb[j][k] = copy_comb[j][k];
				}
			}
		}
	}

	void run(){
		Scanner stdIn = new Scanner(System.in);

		while(true){
			h = stdIn.nextInt();
			w = stdIn.nextInt();
			c = stdIn.nextInt();
			if((h|w|c)==0){
				return;
			}
			int[][] pane = new int[h][w];
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					pane[i][j] = stdIn.nextInt();
				}
			}
			max = 0;
			Color(pane,0);
			System.out.println(max);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N;
    while (cin >> N) {
        N %= 10;
        if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) puts("hon");
        else if (N == 0 || N == 1 || N == 6 || N == 8) puts("pon");
        else puts("bon");
    }
}

















Measured memory_bytes: 3636
n = int(input())
abcl = []
for _ in range(n):
   a,b,c = map(int,input().split())
   abcl.append((a,b,c))
dp = [[float("inf") for _ in range(3)] for _ in range(n)]

dp[0][0] = abcl[0][0]
dp[0][1] = abcl[0][1]
dp[0][2] = abcl[0][2]

for i in range(n-1):
    a,b,c = abcl[i+1]
    dp[i+1][0] = max(dp[i][1]+a, dp[i][2]+a)
    dp[i+1][1] =  max(dp[i][0]+b, dp[i][2]+b)
    dp[i+1][2] =  max(dp[i][0]+c, dp[i][1]+c)

print(max(dp[-1][0], dp[-1][1], dp[-1][2]))


Measured memory_bytes: 87768
#include <stdio.h>

void swap(int *, int *);

void swap(int *x, int *y) {
        int tmp;

        tmp = *x;
        *x = *y;
        *y = tmp;
}

int main() {
        int num[3];
  
        scanf("%d %d %d", &num[0], &num[1], &num[2]);

        if (num[1] < num[0]) {
                swap(&num[1], &num[0]);
        }

        if (num[2] < num[1]) {
                swap(&num[2], &num[1]);
        }

        if (num[1] < num[0]) {
                swap(&num[1], &num[0]);
        }

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



Measured memory_bytes: 2732
X,N = map(int,input().split())

if N==0:
  print(X)
else:
  P = list(map(int,input().split()))
  hash_p = [0]*102
  for i in P:
    hash_p[i] += 1
  for i in range(N+1):
    if hash_p[X-i]==0:
      print(X-i)
      break
    if hash_p[X+i]==0:
      print(X+i)
      break


Measured memory_bytes: 9044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}

int main(){
	char n[5];
	cin >> n;
	
	if(n[0]==n[1] && n[1]==n[2]) cout<<"Yes"<<endl;
	else if(n[1]==n[2] && n[2]==n[3]) cout<<"Yes"<<endl;
	else cout<<"No" << endl;
	return 0;
}




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

int main() {
  int n;
  cin >> n;
  vector <int> data1(n);
  vector <int> data2(n);
  vector <int> data3(n-1);
  for (int i = 0; i < n; i++) {
    cin >> data1.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> data2.at(i);
  }
  for (int i = 0; i < (n-1); i++) {
    cin >> data3.at(i);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += data2.at(data1.at(i)-1);
  }
  for (int i = 0; i < (n-1); i++) {
    if (data1.at(i+1) - data1.at(i) == 1) {
      ans += data3.at(data1.at(i)-1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
  char s[1001];
  int i;
  int len;

  while (1) {
    int sum = 0;
    scanf("%s", s);
    len = strlen(s);
    if (s[0] == '0') {
      break;
    } else {
      for (i = 0; i < len; i++) {
        sum += s[i] - '0';
      }
    }
    printf("%d\n", sum);
  }

  return 0;
}



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

#define itf  ios_base::sync_with_stdio(false)
#define ll long long int
#define ct  cin.tie(NULL)

ll  Z[102][1000007];

ll step(ll a[],ll v[],ll w,ll n)
{
    if(n==0)
    return 0;
    
    if(Z[n][w]!=-1)
    return Z[n][w];
    
    if(w>=a[n-1])
    return (Z[n][w]=max(v[n-1]+step(a,v,w-a[n-1],n-1),step(a,v,w,n-1)));
    else
    return Z[n][w]=step(a,v,w,n-1);
}

int main() {
    
    memset(Z,-1,sizeof(Z));
    ll n,w;
    cin>>n>>w;
    ll a[n],v[n];
    
    for(int i=0;i<n;i++)
    cin>>a[i]>>v[i];
    
    cout<<step(a,v,w,n)<<" ";
    
	return 0;
}


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


int main() {
    string S;
    cin >> S;

    int ans = 0,tmp = 0;

    for(int i=0;i<S.size();i++){
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T')tmp++;
        else tmp=0;
        if(ans<tmp) ans=tmp;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,q;
  int a,inv[100005];

  cin>>n>>k>>q;
  for(int i=1;i<=n;i++) inv[i]=k-q;
  for(int i=0;i<q;i++){
    cin>>a;
    inv[a]++;
  }

  for(int i=1;i<=n;i++){
    if(inv[i]>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int k;
    cin >> k;
    cout << (k / 2) * ((k + 1) / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in, K = in;

    int maxK = (N-1) * (N-2) / 2;
    if( K > maxK ) {
        cout << "-1\n";
        return 0;
    }

    int M = N - 1 + maxK - K;
    cout << M << "\n";

    for( int i=2; i<=N; i++ ) {
        cout << "1 " << i << "\n";
        M--;
    }

    for( int i=2; i<=N; i++ ) {
        for( int j=i+1; j<=N; j++ ) {
            if( M-- == 0 ) return 0;
            cout << i << " " << j << "\n";
        }
    }
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    s = set(list(map(int, input().split()))[1:])
    for i in range(N - 1):
      s = s & set(list(map(int, input().split()))[1:])
    
    print(len(s))  

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll n;
    ll mod = 1e9 + 7;
    cin >> n;
    ll a[n+1];
    ll sum[n+1];
    sum[0] = 0;
    rep1(i, n) cin >> a[i];
    rep1(i, n) sum[i] = (sum[i-1] + a[i]) % mod;
    ll ans = 0;
    rep1(i,n-1){
        ans += (a[i]*(sum[n] - sum[i] + mod)) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6292
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

s1,s2,s3 = S()
print(str.upper(s1[0]+s2[0]+s3[0]))

Measured memory_bytes: 9804
sx, sy, tx, ty = map(int, input().split())

ans = ''
for i in range(ty - sy):
    ans += 'U'
for j in range(tx - sx):
    ans += 'R'
for i in range(ty - sy):
    ans += 'D'
for j in range(tx - sx):
    ans += 'L'
ans += 'L'
for i in range(ty - sy + 1):
    ans += 'U'
for i in range(tx - sx + 1):
    ans += 'R'
ans += 'D'
ans += 'R'
for i in range(ty - sy + 1):
    ans += 'D'
for i in range(tx - sx + 1):
    ans += 'L'
ans += 'U'


print(ans)

Measured memory_bytes: 3064
import numpy as np
from bisect import bisect_right

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

diff = [0 for i in range(N)]
need = 0
ans = 0

for i in range(N):
    diff[i] = A[i] - B[i]
    if diff[i] < 0:
        need += -diff[i]
        ans += 1
        diff[i] = 0

diff = sorted(diff, reverse=True)  # 大きい順
cumsum = np.cumsum(diff)

if need != 0:
    ans += bisect_right(cumsum, need)+1
if ans > N:
    ans = -1
print(ans)


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

namespace Algorithm
{
    class Program
    {
        static int N = 0, M = 0;
        static int[] dp;
        static List<List<int>> G;
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            N = l[0];
            M = l[1];
            dp = Enumerable.Repeat(-1, N).ToArray();
            G = new List<List<int>>();
            for (var i = 0; i < N; i++)
                G.Add(new List<int>());
            for (var i = 0; i < M; i++) {
               var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
               G[--t[0]].Add(--t[1]);
            }
            
            var ans = 0;
            for (var v = 0; v < N; v++)
                ans = Math.Max(ans, Rec(v));
            
            Console.WriteLine(ans);
        }

        static int Rec(int v)
        {
           if (dp[v] != -1) return dp[v];
           
           var ret = 0;
           foreach (var nv in G[v])
               ret = Math.Max(ret, Rec(nv)+1);

           return dp[v] = ret;
        }
    }
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N, ichi, juu, hyaku, sen;
  cin >> N;
  sen = N / 1000;
  hyaku = N % 1000 / 100;
  juu = N % 100 / 10 ;
  ichi = N % 10;
  
  if (hyaku != juu) { cout << "No" << endl; }
  else if (hyaku == sen || juu == ichi) { cout << "Yes" << endl; }
  else cout << "No" << endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

ll dp[100010];
vector<ll > g[100010];

ll solve(ll n)
{
	if(dp[n]!=-1)
		return dp[n];
	ll mx=0;
	for(ll i=0;i<g[n].size();i++)
		mx=max(mx,solve(g[n][i])+(ll)1);
	return dp[n]=mx;
}

int main()
{
	// cout<<INT_MAX;
	fast
	ll n,m;
	cin>>n>>m;
	ll i,x,y;
	for(i=0;i<m;i++){
		cin>>x>>y;
		g[x-1].push_back(y-1);
	}
	ll mx=0;
	for(i=0;i<n;i++)
		dp[i]=-1;
	for(i=0;i<n;i++)
		mx=max(mx,solve(i));
	cout<<mx;
}

Measured memory_bytes: 8576
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (sc.hasNext()) {
			int a = sc.nextInt();
			int l = sc.nextInt();
			int x = sc.nextInt();
			double b = (l + x) / 2.0;
			double h = Math.sqrt(b * b - l * l / 4.0);
			double h2 = Math.sqrt(l * l - a * a / 4.0);
			System.out.println(l * h + a * h2 / 2.0);
		}
	}
}

Measured memory_bytes: 29928
n = int(input())
p = list(map(int, input().split()))

min_list = []
for i in range(n):
    if i == 0:
        min_list.append(p[i])
    else:
        min_list.append( min(min_list[i-1], p[i]) )

cnt = 0
for i in range(n):
    if i == 0:
        cnt += 1
    elif min_list[i-1] >= p[i]:
        cnt += 1

print(cnt)


Measured memory_bytes: 24744
#include<bits/stdc++.h>
using namespace std;
int dis[205][205],e[205][205];
signed main(){
	int n;char ch;
	cin>>n;
	memset(dis,0x3f,sizeof(dis));
	for(int i=1;i<=n;++i) dis[i][i]=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j){
			cin>>ch;
			if(ch=='1') e[i][j]=dis[i][j]=1;
		}
	for(int k=1;k<=n;++k)
		for(int i=1;i<=n;++i)
			for(int j=1;j<=n;++j)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	int ans=-1;
	for(int u=1;u<=n;++u){
		int fl=0;
		for(int i=1;i<=n;++i)
			for(int j=1;j<=n;++j)
				if(e[i][j] && abs(dis[u][i]-dis[u][j])!=1) fl=1;
		if(fl) break;
		for(int i=1;i<=n;++i)
			ans=max(ans,dis[u][i]+1);
	}
	cout<<ans;
	return 0;
}

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

int main()
{
	ll N,M;
	cin >> N >> M;
	for (int i = 1; i*i <= M; ++i)
	{
		if (M % i == 0)
		{
			D.push_back(i);
			D.push_back(M/i);
		}
	}
	sort(D.begin(), D.end());
	ll a = M/N;
	for (int i = D.size()-1; i >= 0; --i)
	{
		if (D[i] <= a)
		{
			cout << D[i] << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;
 
#define N 1000006 

int vis[N+8];

vector<vlong> prime;
vector<pll> v;

int main () {
 
 	#ifdef forthright48
    freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	#endif
 
    for(int i = 4; i <= N; i += 2) vis[i] = 1;

    for(int i = 3; i*i <= N; i += 2) {
        if(!vis[i]) {
            for(int j = i*i; j <= N; j += i+i) {
                vis[j] = 1;
            }
        }
    }

    prime.pb(2);
    for(int i = 3; i <= N; i += 2) if(!vis[i]) prime.pb(i);

    //rep(i,10) dump(prime[i]);
    
    vlong n,k,ans,cnt;
    cin >> n >> k;

    ans = 1;

    for(int i = 0; i < SZ(prime); i++) {

        if(prime[i] * prime[i] > k) break;
    
        cnt = 0;

        while(k % prime[i] == 0) {
            k /= prime[i];
            cnt++;
        }

        if(cnt) v.pb(MP(prime[i],cnt));
    }

    if(k > 1) v.pb(MP(k,1));


    for(int i = 0; i < SZ(v); i++) {
        cnt = v[i].ss / n;

        rep(j,cnt) {
            ans = (ans * v[i].ff);
        }
    }

    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 5240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN=100005;
ll read(){ll x;scanf("%lld",&x);return x;}
int N,M;
ll l1[MAXN],len[MAXN];
int tot;
ll tax[MAXN],val[MAXN];
void solve(int id,ll l,ll c){
//	cout<<id<<" "<<l<<" "<<c<<" "<<len[id]<<endl;
	if(l<len[0]) {tax[1]+=c,tax[l+1]-=c;return;}
	int x=upper_bound(len,len+id,l)-len-1;
//	cout<<id<<" "<<l<<" "<<c<<" "<<x<<endl;
	val[x]+=(l/len[x])*c,l%=len[x];
	solve(x,l,c);
}
int main(){
//	freopen("e.in","r",stdin);
	N=read(),M=read();
	for(int i=1;i<=M;i++) l1[i]=read();
	l1[0]=N;
	for(int i=M;i>=1;i--) if(l1[i]<l1[i-1]) l1[i-1]=l1[i],l1[i]=0;
	for(int i=0;i<=M;i++) if(l1[i]) len[tot++]=l1[i];
	val[tot-1]=1;
//	for(int i=0;i<=M;i++) cout<<len[i]<<" ";
//	cout<<endl;
//	cout<<tot<<endl;
	for(int i=tot-1;i>=1;i--){
//		cout<<len[i]<<endl;
		solve(i,len[i],val[i]);
	}
	for(int i=1;i<=N;i++) tax[i]+=tax[i-1];
	for(int i=1;i<=len[0];i++) tax[i]+=val[0];
	for(int i=1;i<=N;i++) printf("%lld\n",tax[i]);
	return 0;
}

Measured memory_bytes: 4864
/*
 * ABC080_D.cpp
 *
 *  Created on: May 15, 2018
 *      Author: 13743
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int imos[31][100001];
int sm[100001];

const int SPAN = 100000;

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

	int N, C;
	cin >> N >> C;
	REP(i, N) {
		int s, t, c;
		cin >> s >> t >> c;
		imos[c][s-1]++;
		imos[c][t]--;
	}
	FOR(i, 1, C) {
		FOR(j, 1, SPAN) {
			imos[i][j] += imos[i][j-1];
		}
		FOR(j, 1, SPAN) {
			if(imos[i][j] > 0) sm[j]++;
		}
	}
	
	cout << *max_element(sm+1, sm+1+SPAN) << endl;
}






Measured memory_bytes: 12416
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	char a, b, c, d;
	a=getchar()-'0';
	b=getchar()-'0';
	c=getchar()-'0';
	d=getchar()-'0';
	if(0);
	else if(a+b+c+d==7) printf("%c+%c+%c+%c=7\n", a+'0', b+'0', c+'0', d+'0');
	else if(a+b+c-d==7) printf("%c+%c+%c-%c=7\n", a+'0', b+'0', c+'0', d+'0');
	else if(a+b-c+d==7) printf("%c+%c-%c+%c=7\n", a+'0', b+'0', c+'0', d+'0');
	else if(a+b-c-d==7) printf("%c+%c-%c-%c=7\n", a+'0', b+'0', c+'0', d+'0');
	else if(a-b+c+d==7) printf("%c-%c+%c+%c=7\n", a+'0', b+'0', c+'0', d+'0');
	else if(a-b+c-d==7) printf("%c-%c+%c-%c=7\n", a+'0', b+'0', c+'0', d+'0');
	else if(a-b-c+d==7) printf("%c-%c-%c+%c=7\n", a+'0', b+'0', c+'0', d+'0');
	else if(a-b-c-d==7) printf("%c-%c-%c-%c=7\n", a+'0', b+'0', c+'0', d+'0');
}


Measured memory_bytes: 128
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))

ans1,ans2,ans3 = 0,0,0
for i in range(N):
    if P[i]<=A:
        ans1 += 1
    elif P[i]<=B:
        ans2 += 1
    else:
        ans3 += 1

print(min(ans1,ans2,ans3))

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

int main(){
  int n;
  cin>>n;
  int l,r;
  vector<pair<int,int>> ns(n);
  for(int i=0;i<n;i++){
    cin>>l>>r;
    ns[i].second=l-r;//右端をsecondに
    ns[i].first=l+r;
  }
  sort(ns.begin(),ns.end());
  int index=1;
  int ans=0;
  int leftend=ns[0].first;
  while(index<n){
    if(leftend>ns[index].second){
      ans++;
    }
    else leftend=ns[index].first;
    index++;
  }
  cout<<n-ans<<endl;
  return 0;
}


   
    
  
 

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

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int k, a, b;
    cin >> k >> a >> b;

    if(k < a || b - a <= 2){
        cout << 1 + k << endl;
        return 0;
    }else{
        int cnt = k - a + 1;
        int ans = a + (cnt/2) * (b - a) + cnt%2;
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 256
n = int(input())
p,cr,cl = 0,0,0
c = 0 #nu of pair
s  = input()
for i in list(s):
    if i =="(":
        p+=1
        cl +=1
    else:
        cr+=1
        if p>0:
            p-=1
            c+=1


print("("*(cr-c) + s + ")"*(cl-c)  )


Measured memory_bytes: 2940
N = int(input())
S = input()
MOD = 998244353

# make A, B, C oredesr
r, g, b = 0, 0, 0
T = {'R': 0, 'G': 0, 'B': 0}
ABC = []  # means, A: 0, B: 1, C: 2
for s in S:
    T[s] += 1
    ge = [t >= T[s] for t in T.values()].count(True)
    lt = [t < T[s] for t in T.values()].count(True)
    if ge == 1:
        ABC.append(0)
    elif lt == 0:
        ABC.append(2)
    else:
        ABC.append(1)

la, rc = 0, 0  # selectable num of left A and right C
ans = 1

# from left for A
for d in ABC:
    if d == 0:
        la += 1
    elif d == 1:
        ans *= la
        ans %= MOD
        la -= 1

# # from right for C
for d in ABC[::-1]:
    if d == 2:
        rc += 1
    elif d == 1:
        ans *= rc
        ans %= MOD
        rc -= 1

# human permutation
for i in range(1, N+1):
    ans *= i
    ans %= MOD
print(ans)


Measured memory_bytes: 8352
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.LinkedList;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int h=scan.nextInt();
        int w=scan.nextInt();
        while(h>=0 && w>0){
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(i%2==0){
                        if(j%2==0){
                            System.out.print('#');
                        }
                        else{
                            System.out.print('.');
                        }
                    }
                    else{
                        if(j%2==0){
                            System.out.print('.');
                        }
                        else{
                            System.out.print('#');
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
            h=scan.nextInt();
            w=scan.nextInt();
        }
    }
}


Measured memory_bytes: 36944
import sys
from string import ascii_lowercase, ascii_uppercase

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    N, K = MAP()
    S = INPUT()

    ans = ""
    for i in range(N):
        if i == K - 1:
            for j, a in enumerate(ascii_uppercase):
                if S[i] == a: ans += ascii_lowercase[j]
        else: ans += S[i]

    print(ans)


if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> vt(n,0);
    for(int i=0;i<n;i++)
    cin>>vt[i];
    vector<int> rg(n,0);
    rg[0]=0;
    rg[1]=rg[0]+abs(vt[0]-vt[1]);
    for(int i=2;i<n;i++)
    {
        rg[i]=min(rg[i-1]+abs(vt[i]-vt[i-1]),rg[i-2]+abs(vt[i]-vt[i-2]));
    }
    cout<<rg[n-1];
    

    return 0;
}


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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define vi vector <int>
#define vit vector <int> :: iterator
#define vlt vector <ll> :: iterator
#define vl vector <ll>
#define vii vector <ii>
#define viii vector <iii>
#define vd vector <double>
#define vull vector <ull>
#define vc vector <char>
#define vs vector <string>
#define vb vector <bool>
#define vvi vector <vector <int>>
#define vvl vector <vector <ll>>
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

int n, a;
int main () {
	IOS;
	
	scanf("%d", &n);
	a = 10;
	for (int i = 1; i <= 9; i++) {
		if (n % i == 0) {
			a = min(a, n / i);
		}
	}
	if (a < 10 && (n / a) < 10) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define SORT(x) sort((x).begin(),(x).end())
int main(void){
    
    int a,b,c,d,e,k;
    cin >>a >>b >>c >>d >>e >>k;
    
    if(((b-a)<=k)&&((c-a)<=k)&&((d-a)<=k)&&((e-a)<=k)&&
    ((c-b)<=k)&&((d-b)<=k)&&((e-b)<=k)&&
    ((d-c)<=k)&&((e-c)<=k)&&
    ((e-d)<=k)){
        cout <<"Yay!";
    }else{
        cout <<":(";
    }
    
    cout <<endl;
    
}

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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	while (t--) {
		int n;
		cin >> n; vector<char> v;
		while (n > 0) {
			v.push_back((char)((n - 1) % 26 + 97));
			n = (n - 1) / 26;
		}
		reverse(v.begin(), v.end());
		for (auto i : v)
			cout << i;
	}
	return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#define abs(x) ((x)<0? -(x):(x))
#define min(a,b) ((a)<(b)? (a):(b))
typedef long long ll;
int main() {
    ll x,k,d;
    scanf("%lld%lld%lld",&x,&k,&d);
    if(abs(x/d)>=k) {printf("%lld\n",abs(x<0? x+d*k:x-d*k));}
    else {//abs(x/d)<k
        if(x>0) {printf("%lld\n",min(abs(x%d-d+(k-x/d-1)%2*d),abs(x%d-(k-x/d)%2*d)));}
        else {printf("%lld\n",min(abs(x%d+(k-(-x)/d)%2*d),abs((x%d+d)-(k-(-x)/d-1)%2*d)));}
    }
    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define maxn 200005
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    ll i;
    ll flag=1;
    for(i=0;i<s1.length();i++)
    {
        if(s1[i]!=s2[i])
        {
            flag=0;
        }
    }
    if(flag)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


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

is1 = [False] * (n + 1)
isN = [False] * (n + 1)

for i in range(m):
    a, b = map(int, input().split())
    if(a > b):
        a, b = b, a
    if(a == 1):
        is1[b] = True
    if(b == n):
        isN[a] = True

import sys

for i in range(2, n):
    if(is1[i] and isN[i]):
        print("POSSIBLE")
        sys.exit(0)

print("IMPOSSIBLE")


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

int n, k;
set<string> st;
string a[10];
bool done[10];

void dfs(string s, int c) {
    if (c == k) {
        st.insert(s);
        return;
    }

    rep(i, n) {
        if (!done[i]) {
            done[i] = true;
            dfs(s + a[i], c + 1);
            done[i] = false;
        }
    }
}

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

    while (cin >> n >> k, n) {
        rep(i, n) cin >> a[i];

        st.clear();
        fill(done, done + 10, false);
        dfs("", 0);
        cout << st.size() << endl;
    }

}

Measured memory_bytes: 3420
#include<stdio.h>
int main()
{
	int N;
	scanf("%d",&N);
	if(N%10==2||N%10==5||N%10==4||N%10==7||N%10==9)
	{printf("hon");
	}
	else if(N%10==0||N%10==1||N%10==6||N%10==8)
	{printf("pon");
	}
	else
	{printf("bon");
	}
	return 0;
 } 

Measured memory_bytes: 1732
#include <cmath>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;

  string ceil = string(w+2, '#');

  cout << ceil << endl;
  string line;
  for (int i = 0; i < h; i++) {
    cin >> line;
    cout << '#' << line << "#" << endl;
  }
  cout << ceil << endl;
}


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

if n==1:
    ans=0
    cnt1=0
    tmp1=0
    for i in range(m):
        s,c=map(int,input().split())
        if s==1 and cnt1<1:
            ans=c
            tmp1=c
            cnt1+=1
        elif s==1 and cnt1>=1:
            if tmp1 !=c:
                ans=-1
                break
            else:
                cnt1+=1
        elif s>=2:
            ans=-1
            break
    print(ans)

if n==2:
    ans=0
    cnt10=0
    cnt1=0
    tmp10=0
    tmp1=0
    for i in range(m):
        s,c=map(int,input().split())
        if s==1 and c==0:
            ans=-1
            break
        if s>2:
            ans=-1
            break
        elif s==1 and cnt10<1:
            tmp10=c
            ans+=tmp10*10
            cnt10+=1
        elif s==1 and cnt10>=1:
            if c != tmp10:
                ans=-1
                break
            else:
                cnt10+=1
        elif s==2 and cnt1<1:
            tmp1=c
            ans+=tmp1
            cnt1+=1
        elif s==2 and cnt1>=1:
            if c != tmp1:
                ans=-1
                break
            else:
                cnt1+=1
    if ans<10 and ans!=-1:
        ans+=10
    print(ans)   
    

if n==3:
    ans=0
    cnt100=0
    cnt10=0
    cnt1=0
    tmp100=0
    tmp10=0
    tmp1=0
    for i in range(m):
        s,c=map(int,input().split())
        if s==1 and c==0:
            ans=-1
            break
        if s>3:
            ans=-1
            break
        elif s==1 and cnt100<1:
            tmp100=c
            ans+=tmp100*100
            cnt100+=1
        elif s==1 and cnt100>=1:
            if c != tmp100:
                ans=-1
                break
            else:
                cnt100+=1
        elif s==2 and cnt10<1:
            tmp10=c
            ans+=tmp10*10
            cnt10+=1
        elif s==2 and cnt10>=1:
            if c != tmp10:
                ans=-1
                break
            else:
                cnt10+=1    
        elif s==3 and cnt1<1:
            tmp1=c
            ans+=tmp1
            cnt1+=1
        elif s==3 and cnt1>=1:
            if c != tmp1:
                ans=-1
                break
            else:
                cnt1+=1
    if ans<100 and ans !=-1:
        ans+=100
    print(ans)      


Measured memory_bytes: 3192
#include<stdio.h>
int main(void)
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    if((x-r)>=0 && (x+r)<=W && (y-r)>=0 && (y+r)<=H)
    {printf("Yes\n");}
    else printf("No\n");
    
    return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


int main(){
  int N, ans, maxi, maxj, nexti, nextj, nexta=0, nextb=0;
  cin >> N;
  int A[100001] = {0}, B[100001] = {0};
  int a;
  rep(i, N){
    if(i%2){
      cin >> a;
      A[a] ++;
    }
    else{
      cin >> a;
      B[a] ++;
    }
  }
  int maxa = 0, maxb = 0;
  rep(i, 100001){
    if(maxa < A[i]){
      nexta = maxa;
      maxa = A[i];
      nexti = maxi;
      maxi = i;
    }
    else if(nexta < A[i]){
      nexta = A[i];
    }
  }
  rep(j, 100001){
    if(maxb < B[j]){
      nextb = maxb;
      maxb = B[j];
      nextj = maxj;
      maxj = j;
    }
    else if(nextb < B[j]){
      nextb = B[j];
    }
  }
  if(maxi != maxj){
    ans = N - maxa - maxb;
  }
  else ans = min(N - maxa -nextb, N - nexta - maxb);
  cout << ans << endl;
  
  
 }

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

struct data{
	int a,b,c,d;
	data():a(0),b(0),c(0),d(0){}
	data(int m,int n,int p,int q):a(m),b(n),c(p),d(q){}
};

vector<data> vec;
int h,w,a[501][501],b[501][501];

int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;++i)for(int j=1;j<=w;++j)scanf("%d",&a[i][j]),b[i][j]=a[i][j]%2;
	for(int i=1;i<=h;++i)for(int j=1;j<=w;++j){
		if(i>1&&b[i-1][j]==1)b[i-1][j]^=1,b[i][j]^=1,vec.push_back(data(i-1,j,i,j));
		if(j>1&&b[i][j-1]==1)b[i][j-1]^=1,b[i][j]^=1,vec.push_back(data(i,j-1,i,j));
	}
	printf("%d\n",vec.size());
	for(data dt:vec)printf("%d %d %d %d\n",dt.a,dt.b,dt.c,dt.d);
}

Measured memory_bytes: 6128
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int min=0;
        int max=sc.nextInt();
        int m=sc.nextInt();
        for(int i=0;i<m;i++){
            int l=sc.nextInt();
            int r=sc.nextInt();
            if(min<l){
                min=l;
            }
            if(r<max){
                max=r;
            }
            if(max<l || min>r){
                System.out.println(0);
                return;
            }
        }
        System.out.println((max+1)-min);
    }
}

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

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

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    ll result = 0;
    int M = 0;
    REP(i, N) {
        int q = (A[i] - 1) / (M + 1);
        if (q) {
            A[i] -= q * (M + 1);
            if (M > 0 && A[i] > M) {
                A[i] = M;
            }
        }
        result += q;
        M = max(M, A[i]);
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 640
N,Y = map(int,input().split())
A,B,C = 10000,5000,1000

def solve():
    for x in range(Y//A + 1):
        rem = Y - x*A
        if B*(N-x) < rem:
            continue
        if rem == 0 and x == N:
            return (x,0,0)
        for y in range(rem//B + 1):
            rem = Y - x*A - y*B
            z = rem // C
            if z < 0: break
            if x+y+z == N:
                return (x,y,z)
    return (-1,-1,-1)

print(' '.join(map(str,solve())))


Measured memory_bytes: 3064
#import<cstdio>
int main(){for(int a,c,r,t;r=c=0,~a;r&&printf("%d\n",r+1))for(char d[]="12354",s[9];a=scanf("%s",s),--*s>60;r+=*d&7)*s%3?t=*d,*d=d[a+=*s%5+*s*2+c&3],d[a]=~t,d[++a%4+1]=t:c+=*s;}

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

ll N, A, B;

int main(){
  cin >> N >> A >> B;

  if((B - A) % 2 == 0) cout << (B - A) / 2 << endl;
  else{
    ll no1 = min(N-A, B-1);  //第一候補：両方とも端によせる
    ll no2;
    if(N-B > A-1){ ll a = A-1; no2 = a+1+(B-a-2)/2; }
    else{ ll b = N-B; no2 = b+1+(N-A-b-1)/2; }
    cout << min(no1, no2) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
def input():
    return sys.stdin.readline()[:-1]
n, q = map(int,input().split())
d = [[] for i in range(n)]
for i in range(n-1):
    ai, bi = map(int,input().split())
    d[ai-1].append(bi-1)
    d[bi-1].append(ai-1)
#point
px = [0 for i in range(n)]
for i in range(q):
    pi,xi = map(int,input().split())
    px[pi-1] += xi
sp = [0 for i in range(n)]
s = deque()
s.append(0)
visited = [False for i in range(n)]
while len(s) > 0:
    x = s.popleft()
    visited[x] = True
    sp[x] += px[x]
    for xc in d[x]:
        if not visited[xc]:
            s.append(xc)
            sp[xc] += sp[x]
for i in range(n):
    print(sp[i])


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

int main() {
    ll a, b, c, d;

    cin >> a >> b >> c >> d;

    ll y = a * c, z = a * d, i = b * c, j = b * d;
    cout << max(max(y, z), max(i, j));
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;


lint D;
lint decrease[26];
lint satis[365][26];
lint last[26];

lint downscore(lint passed) {
	lint sum = 0;
	REP(i, 26) {
		sum += decrease[i] * (passed - last[i]);
	}
	return -sum;
}

int main() {
	cin >> D;
	REP(i, 26) {
		cin >> decrease[i];
	}
	REP(i, D) {
		REP(j, 26) {
			cin >> satis[i][j];
		}
	}

	lint score = 0;
	REP(i, D) {
		lint maxv = -INF, max_idx = -1;
		REP(s, 26) {
			lint inst = 0;
			last[s] = i + 1;

			inst += satis[i][s];
			inst += downscore(i + 1);
			if (maxv < inst) {
				maxv = inst;
				max_idx = s;
			}
		}
		cout << max_idx + 1 << endl;
	}
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

const int N = 2e5 + 5;
const int Mod = 998244353;


int n, q;
ll st[N << 2], lz[N << 2];
ll w[N];

ll mpow(ll a, ll b) {
  ll r = 1;
  while(b > 0) {
    if(b & 1) r = r * a % Mod;
    a = a * a % Mod;
    b >>= 1;
  }
  return r;
}

ll merge(ll a, ll b ,int len_left) {
  return (a + b * mpow(10, len_left) % Mod) % Mod;
}

void build(int cur, int s, int e) {
  if(s == e) {
    st[cur] = 1;
    return;
  }
  int l = 2 * cur + 1, r = 2 * cur + 2;
  int mid = (s + e) / 2;
  build(l, s, mid);
  build(r, mid + 1, e);
  st[cur] = merge(st[l], st[r], mid - s + 1);
}

void push_down(int cur, int s, int e) {
  if(lz[cur]) {
    st[cur] = w[e - s + 1] * lz[cur] % Mod;
    if(s != e) {
      int l = 2 * cur + 1, r = 2 * cur + 2;
      lz[l] = lz[cur];
      lz[r] = lz[cur];
    }
    lz[cur] = 0;
  }
}

void update(int cur, int s, int e, int i, int j, int d) {
  push_down(cur, s, e);
  if(s > j || e < i) return;
  if(s >= i && e <= j) {
    lz[cur] = d;
    push_down(cur, s, e);
    return;
  }
  int l = 2 * cur + 1, r = 2 * cur + 2;
  int mid = (s + e) / 2;
  update(l, s, mid, i, j, d);
  update(r, mid + 1, e, i, j, d);
  st[cur] = merge(st[l], st[r], mid - s + 1);
}

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

  w[1] = 1;
  for(int i = 2; i < N; i++) {
    w[i] = (w[i - 1] * 10 + 1) % Mod;
  }
  
  cin >> n >> q;
  build(0, 0, n - 1);

  while(q--) {
    int l, r, d;
    cin >> l >> r >> d;
    --l, --r;
    l = n - l - 1;
    r = n - r - 1;
    swap(l, r);
    update(0, 0, n - 1, l, r, d);
    cout << st[0] << endl;
  }

  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K; 
  int count = 0;
  for (int i = 0; i < N; i++) {
  	int h;
    cin >> h;
    if (h >= K) count++;
  }
  cout << count << endl;
  
}

Measured memory_bytes: 3608