akhauriyash/Code-Regression huggingface dataset:
import sys,math,string,bisect
input=sys.stdin.readline
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
I=lambda :int(input())
S=lambda :input().strip()
n,m=M()
if(n*500<m):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3960
#include<stdio.h>
int main(void)
{
	int a,b,box[7],i;
	for(i=0;i<7;i++){
		scanf("%d %d",&a,&b);
		box[i]=a-b;
	}
	for(i=0;i<7;i++){
		printf("%d\n",box[i]);
	}
	return 0;
}


Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
int dp[2][3];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 0, j; i < 3; ++i)
	{
		scanf("%d", &j);
		dp[1][i] = j;
	}
	for(int i = 1; i < n; ++i)
	{
		for(int j = 0, l; j < 3; ++j)
		{
			scanf("%d", &l);
			for(int k = 0; k < 3; ++k)
			{
				if(j != k)
				{
					dp[(i + 1) % 2][j] = max(dp[(i + 1) % 2][j], dp[i % 2][k] + l);
				}
			}
		}
	}
	printf("%d\n", *max_element(dp[n % 2], dp[n % 2] + 3));
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

ll rev(ll N) {
  ll v = 0;
  while (N > 0) {
    v = v * 10 + N % 10;
    N /= 10;
  }
  return v;
}

ll naive(ll D) {
  ll res = 0;
  for (ll N = 1; N <= 10000000; N++) {
    if (rev(N) == N + D) {
      ++res;
    }
  }
  return res;
}

int main() {
  ll D;
  while (cin >> D) {
    const int maxDigits = 30;
    vector<int> dig;
    while (D > 0) {
      dig.push_back(D % 10);
      D /= 10;
    }
    int dlen = dig.size();
    dig.resize(maxDigits, 0);
    static ll dp[maxDigits + 1][2][maxDigits + 1][2];
    memset(dp, -1, sizeof(dp));
    function<ll(int, int, int, int)> solve = [&](int lower, int lowerCarry,
                                                 int upper, int upperCarry) {
      ll &res = dp[lower][lowerCarry][upper][upperCarry];
      if (res != -1) {
        return res;
      }
      if (lower > upper) {
        return res = lowerCarry == upperCarry;
      }
      res = 0;
      for (int x = 0; x < 10; x++) {
        for (int y = 0; y < 10; y++) {
          if (lower == 0 && x == 0) {
            continue;
          }
          if (lower == upper && y != x) {
            continue;
          }
          int lowerValue = (x - y - lowerCarry + 10) % 10;
          int nextLowerCarry = (x - y - lowerCarry) < 0;
          if (lowerValue != dig[lower]) {
            continue;
          }
          if (lower == upper) {
            res += solve(lower + 1, nextLowerCarry, upper, upperCarry);
            continue;
          }
          int upperValue = y - x + upperCarry * 10;
          if (upperValue != dig[upper] && upperValue != dig[upper] + 1) {
            continue;
          }
          int nextUpperCarry = upperValue == dig[upper] + 1;
          res += solve(lower + 1, nextLowerCarry, upper - 1, nextUpperCarry);
        }
      }
      return res;
    };
    ll ans = 0;
    for (int i = dlen - 1; i < maxDigits; i++) {
      ans += solve(0, 0, i, 0);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

//繰り返し二乗法
ll EX(ll x,ll n){
    if(n == 0) return 1;
    else if(n%2 == 1) return EX(x,n-1)*x%mod;
    else return EX(x*x%mod,n/2)%mod;
}

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

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

    vector<int> bit(60,0);
    for(int j = 0; j < n; j++){
        for(int i = 0; i < 60; i++){
            if(a[j] & (1ll << i)) bit[i]++;
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 60; j++){
            if(a[i] & (1ll << j)){
                bit[j]--;
                ans += EX(2,j)*(n-i-1-bit[j])%mod;
                ans %= mod;
            } else ans += EX(2,j)*bit[j]%mod;
        }
        //cout << ans << endl;
    }

    cout << (ans+mod)%mod << endl;

    return 0;
}

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

#define endl '\n'
#define ll long long
#define ld long double
#define fi first
#define se second
#define MP make_pair
#define pii pair<int, int>
#define pll pair<long long, long long>
#define mod (ll) (1e9 + 7)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) v.begin(), v.end()
#define dvec(v) for(auto i: v) cout << i << " "; cout << '\n';
#define gcd(a,b) __gcd(a, b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define darr(a,n) for(int i=0; i<n;i++) cout << a[i] << " "; cout << '\n';
#define what_is(x) cerr << #x << " : " << x << '\n';


int main() {
    #define int long long
    fast;
    int n, maxW;
    cin >> n >> maxW;
    int val[n+1], wt[n+1];
    for (int i = 1; i <= n; i++) {
        cin >> wt[i] >> val[i];
    }
    int dp[n+1][maxW+1];
    for (int w = 0; w <= maxW; w++) {
        dp[0][w] = 0;
    }
    for (int i = 0; i <= n; i++) {
        dp[i][0] = 0;
    }

    for (int i = 1; i <= n; i++) {
        for (int w = 1; w <= maxW; w++) {
            dp[i][w] = dp[i-1][w];
            if (wt[i] <= w) {
                dp[i][w] = max(dp[i][w], val[i] + dp[i-1][w - wt[i]]);
            }
        }
    }
    cout << dp[n][maxW] << endl;;

    return 0;
}


Measured memory_bytes: 79232
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
  int a[5];
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  sort( a , a+5 , greater<int>() );
  for(int i=0;i<5;i++){
    cout<<a[i];
    if(i<4){
      cout<<" ";
    }if(i==4){
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1180
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

const int MaxN = 105;
const double eps = 1e-8;
const double pi = acos(-1.0);

int dcmp(double x) {
	return x < -eps ? -1 : x > eps;
}
struct Point {
	double x, y, z;
	Point(){}
	Point(double x, double y, double z) : x(x), y(y), z(z) {}
	Point operator + (const Point &b) { return Point(x + b.x, y + b.y, z + b.z); }
	Point operator - (const Point &b) { return Point(x - b.x, y - b.y, z - b.z); }
	Point operator * (const Point &b) { return Point(y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x); }
	Point operator * (const double &b) { return Point(x * b, y * b, z * b); }
	Point rot(double ux, double uy, double uz, double d) {
		double cosd = cos(d);
		double sind = sin(d);
		double rx = x * (cosd + ux * ux * (1 - cosd)) + y * (ux * uy * (1-cosd) - uz * sind) + z * (ux * uz * (1 - cosd) + uy * sind);
		double ry = x * (uy * ux * (1 - cosd) + uz * sind) + y * (cosd + uy * uy * (1 - cosd)) + z * (uy * uz * (1 - cosd) - ux * sind);
		double rz = x * (uz * ux * (1 - cosd) - uy * sind) + y * (uz * uy * (1 - cosd) + ux * sind) + z * (cosd + uz * uz * (1-cosd));
		return Point(rx, ry, rz);
	}
	double operator % (const Point &b) { return x * b.x + y * b.y + z * b.z; }
	double len2() { return x * x + y * y + z * z; }
	double len() { return sqrt(x * x + y * y + z * z); }
	void init() {
		scanf("%lf%lf%lf", &x,&y,&z);
	}
} cc[MaxN];
double r[MaxN];
double get(Point c, double r, Point p1, Point p2) {
	if ((p2 - p1) % (c - p1) < -eps) return -1.;
	Point v = (p2 - p1); v = v * (1 / v.len());
	double x = (c - p1) % v;
	v = p1 + v * x;
	double d = (v - c).len2();
	if (dcmp(d - r * r) >= 0) return -1.;
	d = (p1 - v).len() - sqrt(r * r - d);
	return d;
}
void change(Point &o, Point &v, Point c, double r, double d) {
	double len = (v - o).len();
	v = o + (v - o) * (d / len);
	Point fvect = (v - c) * (o - v);
	fvect = fvect * (1. / fvect.len());
	double theta = acos((v - c) % (o - v) * (1. / ((c - v).len() * (v - o).len())));
	Point next = (o - v).rot(fvect.x, fvect.y, fvect.z, - 2. * theta);
	o = v;
	v = v + next;
}
int main() {
	//sfreopen("in","r",stdin);
	int n;
	while (scanf("%d",&n), n) {
		Point v; v.init();
		Point o = Point(0, 0, 0);
		for (int i = 0; i < n; ++i) {
			cc[i].init();
			scanf("%lf", r + i);
		}
		while (1) {
			int find = -1;
			double best = 1e10;
			for (int i = 0; i < n; ++i) {
				double d = get(cc[i], r[i], o, v);
				if (d >= 0 && (find == -1 || dcmp(d - best) < 0)) {
					best = d;
					find = i;
				}
			}
			if (find == -1) break;
			change(o, v, cc[find], r[find], best);
		}
		printf("%.10f %.10f %.10f\n", o.x, o.y, o.z);
	}
	return 0;
}

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

using namespace std;
const int N = 2e5+7;

int h[N],e[N*2],ne[N*2],idx;
int w[N],n;
int ans[N]; 
int low[N];

void add(int a,int b){
	e[idx] = b,ne[idx] = h[a] , h[a] = idx++;
}

void dfs(int s,int fa)
{
	int pos = lower_bound(low+1,low+1+n,w[s]) - low ;
	int cnt = low[pos];
	low[pos] = w[s];
	ans[s] = max(ans[fa],pos);
	for(int i=h[s];~i;i=ne[i]){
		int j = e[i];
		if(j==fa) continue;
		dfs(j,s);
	}
	low[pos] = cnt;
}

int main()
{
	int a,b;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&w[i]);
	memset(h,-1,sizeof h);
	for(int i=1;i<n;i++){
		scanf("%d%d",&a,&b);
		add(a,b),add(b,a);
	}
	memset(low,0x3f,sizeof low);
	dfs(1,0);
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 24372
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
	int n,x,t;
	cin>>n>>x>>t;
	n=n/x+(n%x!=0);
	cout<<n*t; 
	RE 0;
}


Measured memory_bytes: 3632
N = int(input())
X = list((int(x) for x in input().split()))
X.sort()

if (X[N - 1] - X[0]) % 2 == 0:
    print(round((X[N - 1] - X[0]) / 2))
else:
    print(round(((X[N - 1] - X[0]) + 1) / 2))
    


Measured memory_bytes: 5628
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<ll>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){

  CIN(n);map<int,int,greater<int>> m;REP(i,n){CIN(t);m[t]++;}
  ll t1=-1;ll t2=-1;
  FOREACH(xx,m){
    if(xx.second>=4&&t1==-1){t1=xx.first;t2=xx.first;}
    else if(xx.second>=2)(t1==-1?t1:t2)=xx.first;
    if(t1!=-1&&t2!=-1)break;
  }
  COUT((t2==-1?0:t1*t2));
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s,t,i,y;
  cin >> s >> t;
  i=0;
  y=1;
  while(i<s){
    if(2*y<y+t) y *=2;
    else y +=t;
      i++;
  }
  cout << y << endl;
}

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

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 100003

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

  bool poss = false;

  if(k%n==0){
  	poss = true;
  } else if(k & m==0){
  	poss = true;
  } else {
  	//a(n-1) + b(m-1) = K

  	for(int row=1;row<=n;row++){
  		int tk = row * m;
  		for(int col=1;col<=m;col++){
  			tk -= row;
  			tk += (n - row);
  			if(tk == k){
  			//	cerr<<row<<" "<<col<<endl;
  				poss = true;
  			}
  		}
  	}	

  }
  if(poss)
  	puts("Yes");
  else
  	puts("No");
  return 0;
}


void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}



Measured memory_bytes: 256
#include <cstdio>

long long n, p;

int main()
{
	scanf("%lld%lld", &n, &p);
	
	long long ans = 1;
	long long d = 2;
	long long count = 0;
	
	
	while (p % 2 == 0)
	{
		count++;
		p = p / 2;
	}
	long long limit = count / n;
	for (long long i = 0 ; i < limit ; i++)
		ans = ans * 2;
	
	d = 3;
	while ((d * d) <= p)
	{
		count = 0;
		while (p % d == 0)
		{
			p = p / d;
			count++;
		}
		
		limit = count / n;
		for (long long i = 0 ; i < limit ; i++)
			ans = ans * d;
		d = d + 2;
	}
	
	if (p >= 1)
	{
		count = 1;
		
		limit = count / n;
		for (long long i = 0 ; i < limit ; i++)
			ans = ans * p;

	}
	
	printf("%lld\n", ans);
	
	return 0;
}

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

llong cal(int n,int k){
	llong ans=k;
	n--;
	
	while(n>0){
		ans*=(k-1);
		n--;
	}
	
	return ans;
}

int main(){
	int n,k;
	cin>>n>>k;
	
	cout<<cal(n,k)<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

step = 0
dif = 0
maxHeight = A[0]
for n in range(1, N):
    if maxHeight > A[n]:
        step += (maxHeight - A[n])
    elif maxHeight < A[n]:
        maxHeight = A[n]
    else:
        pass

print(step)

Measured memory_bytes: 32160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
using namespace std;

int main() {
  int n;
  bool flag=false;
  cin >> n;
  for(int y=0;3*y<=n;y++) {
    if((n-3*y)%4 == 0 && (n-3*y)/4 >= y) {
      flag=true;
      break;
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    boolean[] p = new boolean[100000];
    p[0] = p[1] = true;
    for (int i = 2; i * 2 < p.length; i++) {
      if (!p[i]) {
        for (int j = 2; i * j < p.length; j++) {
          p[i * j] = true;
        }
      }
    }

    int[] ln = new int[100000];
    for (int i = 3; i < ln.length; i++) {
      if (!p[i] && !p[(i + 1) / 2]) {
        ln[i] = ln[i - 1] + 1;
      } else {
        ln[i] = ln[i - 1];
      }
    }

    int q = sc.nextInt();
    int ans[] = new int[q];
    for (int i = 0; i < q; i++) {
      int l = sc.nextInt();
      int r = sc.nextInt();
      ans[i] = ln[r] - ln[l - 1];
    }

    for (int i : ans) {
      System.out.println(i);
    }
  }
}


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

using namespace std;
#define ll long long
int main() {
	// your code goes here
	ll a,b;
	cin>>a>>b;
	ll s=1;
	while (s<10000)
	{
		double q=(double)(s*8)/(double)100;
		double w=(double)s/(double)10;
		//cout<<q<<" "<<ro(q)<<" "<<w<<" "<<ro(w)<<endl;
		ll x,y;
		x=floor(q);
		y=floor(w);
		if(x==a &&y==b)
		{
			cout<<s;
			return 0;
		}
		s++;
		
	}
	cout<<-1;
	return 0;
}


Measured memory_bytes: 256
def abc(a,b,c):
    
    return "YES" if a[-1] == b[0] and b[-1] == c[0] else "NO"
 
def main():
    a , b , c = map(str, input().split())
    print(abc(a , b , c))
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
import bisect
def main():
    N = int(input())
    A = sorted([int(_) for _ in input().split()])
    r = A[-1]//2
    B = A[:-1]
    x = bisect.bisect_left(B, r)
    if x == 0:
        return A[-1], B[x]
    elif x == N-1:
        return A[-1], B[x-1]
    else:
        if abs(B[x]-r) <= abs(B[x-1]-r): return A[-1], B[x]
        else: return A[-1], B[x-1]
if __name__ == '__main__':
    print(*main())


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

string field[501];
int H,W;

void harvest(int i,int j,string fruit) {
  field[i].replace(j,1,"x");
  if(j < W-1) {
    if(field[i].substr(j+1,1) == fruit) {
      harvest(i,j+1,fruit);
    }
  }
  if(i < H-1) {
    if(field[i+1].substr(j,1) == fruit) {
      harvest(i+1,j,fruit);
    }
  }
  if(j >= 1) {
    if(field[i].substr(j-1,1) == fruit) {
      harvest(i,j-1,fruit);
    }
  }
  if(i >= 1) {
    if(field[i-1].substr(j,1) == fruit) {
      harvest(i-1,j,fruit);
    }
  }
}

int main() {
  int member=0;
  string str,fruit;
  while(cin >> H >> W) {
    getline(cin,str);// kill \n
    if((H == 0) && (W == 0)) break;
    for(int i=0;i<H;i++) { //get field for string
      getline(cin,str);
      field[i] = str;
    }

    for(int i=0;i<H;i++) {
      for(int j=0;j<W;j++) {

        if((field[i].substr(j,1) == "#") || (field[i].substr(j,1) == "@")||(field[i].substr(j,1) == "*")) {
          fruit = field[i].substr(j,1);
          harvest(i,j,fruit);
          member++;
        }
      }
    }
    cout << member << endl; // for test
    member = 0;
  }

}

Measured memory_bytes: 0
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    
    if N != 0 and A[0] != 0:
        print(-1)
        return
    if N == 0 and A[0] != 1:
        print(-1)
        return
    
    v = [1]
    m = 2
    for ai in A[1:]:
        v.append(m)
        if m < ai:
            print(-1)
            return
        m -= ai
        m *= 2
    
    m = min(v[-1], A[-1])
    ans = m
    for i in range(N - 1, -1, -1):
        m = min(m + A[i], v[i])
        ans += m
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 702948
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(void)
{
    double x,h,A1,A2,x1;
    while(1){
        cin>>x>>h;
        if(x==0&&h==0)break;
        A1=x*x;
        x1=x/2;
        A2=(x1*x1)+(h*h);
        A2=sqrt(A2);
        A2*=x;
        A2*=2;
        printf("%lf\n",A1+A2);
    }
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

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

int main(){
    int n; cin>>n;
    vector<string> s(n);
    for(int i=0; i<n; i++) cin>>s[i];
    int m; cin>>m;
    vector<string> t(m);
    for(int i=0; i<m; i++) cin>>t[i];

    int ans=0;
    for(int i=0; i<n; i++){
        int sum=0;
        for(int j=0; j<n; j++){
            if(s[i]==s[j]) sum++;
        }
        for(int j=0; j<m; j++){
            if(s[i]==t[j]) sum--;
        }
        ans=max(ans, sum);
    }
    cout << ans << endl;
}

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

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, C;

            var word = Console.ReadLine().Split(' ');

            A = int.Parse(word[0]);
            B = int.Parse(word[1]);
            C = int.Parse(word[2]);

            if ((A <= C) && (B >= C))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#!/usr/bin/env python2

import sys
import math

input = iter(sys.stdin.readlines()).next

def dist(x1, y1, x2, y2):
   return math.sqrt((x1-x2)**2 + (y1-y2)**2)

def main():
   A, B, H, M = map(int, input().split())
   a = (H + M/60.0) * 2 * math.pi / 12
   yA = math.sin(a) * A
   xA = math.cos(a) * A

   b = M * 2 * math.pi / 60
   yB = math.sin(b) * B
   xB = math.cos(b) * B

#  print((a*180/math.pi, xA, yA))
#  print((b*180/math.pi, xB, yB))

   res = dist(xA, yA, xB, yB)
   print('%.12f' % (res))

   return 0


if __name__ == '__main__':
   sys.setrecursionlimit(10000)
   main()


Measured memory_bytes: 84628
/*
 * exception_handling.c
 *
 *  Created on: 2019/11/01
 *      Author: 113200
 */

#include "stdio.h"
#include "stdlib.h"
#define MAX_LENGTH (200*1000)

int main(void){

	int length,index_first;
	int first = 0;
	int second = 0;
	int* array;
	array = (int*)calloc(sizeof(int),MAX_LENGTH);

	scanf("%d",&length);

	for (int i = 0; i < length; i++){
		scanf("%d",&array[i]);
		if (first < array[i]){
			first = array[i];
			index_first = i;
		}
	}

	for (int i = 0; i < length; i++){
		if (i == index_first){
			continue;
		}
		if (second < array[i]){
			second = array[i];
		}
	}

	for (int i = 0; i < length; i++){
		if (array[i] == first){
			printf("%d\n",second);
		}
		else{
			printf("%d\n",first);
		}
	}
}







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

int main(){
	int a, b;
  	cin >> a >> b;
	cout << (a+b+1)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if ((max(a,c)-min(a,c))<=d)
		cout<<"Yes";
	else if ((max(a,b)-min(a,b))<=d&&(max(b,c)-min(b,c))<=d)
	    cout<<"Yes";
	else
	    cout<<"No";
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    private static Scanner in;
    private static int n, m;
    private static HashMap<Integer, ArrayList<Integer>> g;
    private static int[] mem;

	public static void main(String[] args) {
        in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        g = new HashMap<>();
        mem = new int[n];

        Arrays.fill(mem, -1);

        for(int i=0; i<n; i++) {
            g.put(i, new ArrayList<Integer>());
        }

        for(int i=0; i<m; i++) {
            int p = in.nextInt()-1;
            int q = in.nextInt()-1;
            g.get(p).add(q);
        }

        int ans = 0;
        for(int i=0; i<n; i++) {
            ans = Math.max(ans, solve(i));
        }

        System.out.println(ans);
	}

    private static int solve(int u) {
        if (mem[u]!=-1) return mem[u];

        int ans = 0;

        for(int v: g.get(u)) {
            ans = Math.max(ans, 1+solve(v));
        }

        return mem[u] = ans;
    }

}



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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (n, m) = (nm[0], nm[1]);
        var adjList = new List<int>[n + 1];
        for (int i = 1; i < adjList.Length; ++i)
        {
            adjList[i] = new List<int>();
        }
        for (int i = 0; i < m; ++i)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            adjList[ab[0]].Add(ab[1]);
            adjList[ab[1]].Add(ab[0]);
        }

        var bfs = new Queue<int>();
        bfs.Enqueue(1);
        var torch = new int[adjList.Length];
        while (bfs.Any())
        {
            var v = bfs.Dequeue();
            for (int i = 0; i < adjList[v].Count; ++i)
            {
                var u = adjList[v][i];
                if (torch[u] > 0)
                {
                    continue;
                }

                bfs.Enqueue(u);
                torch[u] = v;
            }
        }

        Console.WriteLine("Yes");
        Console.WriteLine(string.Join(Environment.NewLine, torch.Skip(2)));
    }
}


Measured memory_bytes: 52604
//あらためて見るとこの問題全然わからない

//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[2][200000], B[2][200000];
	int kazuA[29] = {}, kazuB[29] = {};
	rep(i, N) {
		int a = getint();
		A[0][i] = a; 
		rep(j, 28) kazuA[j] += a >> j & 1;
	}
	rep(i, N) {
		int b = getint();
		B[0][i] = b;
		rep(j, 28) kazuB[j] += b >> j & 1;
	}
	int kotae = 0;
	rep(i, 28) {
		int p = i & 1;
		auto Amae = A[p];
		auto Bmae = B[p];
		auto Atugi = A[!p];
		auto Btugi = B[!p];

		int kazu[2];
		kazu[0] = 0;
		kazu[1] = N - kazuA[i];
		rep(j, N) Atugi[kazu[Amae[j] >> i & 1]++] = Amae[j];
		kazu[0] = 0;
		kazu[1] = N - kazuB[i];
		rep(j, N) Btugi[kazu[Bmae[j] >> i & 1]++] = Bmae[j];

		int kari = N & kazuA[i] & 1;
		int d = (1 << i) - 1;
		int d2 = 1 << i;
		int k1 = kazu[0];
		int k2 = N;
		rep(j, N - kazuA[i]) {
			while (k1 > 0 && (Atugi[j] & d) + (Btugi[k1 - 1] & d) >= d2) k1--;
			while (k2 > kazu[0] && (Atugi[j] & d) + (Btugi[k2 - 1] & d) >= d2) k2--;
			kari ^= k1 ^ k2;
		}
		k1 = kazu[0];
		k2 = N;
		for (int j = N - kazuA[i]; j < N; j++) {
			while (k1 > 0 && (Atugi[j] & d) + (Btugi[k1 - 1] & d) >= d2) k1--;
			while (k2 > kazu[0] && (Atugi[j] & d) + (Btugi[k2 - 1] & d) >= d2) k2--;
			kari ^= k1 ^ k2;
		}
		kotae += (kari & 1) << i;
	}

	int d2 = 1 << 28;
	int k = N;
	int kari = N;
	rep(j, N) {
		while (k > 0 && (*A)[j] + (*B)[k - 1] >= d2) k--;
		kari ^= k;
	}
	kotae += (kari & 1) << 28;

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;
int main(){
	int e[12],lon1,lon2,lon3,sum1=0,sum2=0,sum3=0;
	for(int i=0;i<12;i++){
		cin>>e[i];
	}
	sort(e,e+12);
	lon1=e[0];
	lon2=e[4];
	lon3=e[8];
	for(int j=0;j<4;j++){
		sum1+=e[j];
		sum2+=e[j+4];
		sum3+=e[j+8];
	}
	if(e[0]*4==sum1 && e[4]*4==sum2 && e[8]*4==sum3){
		cout<<"yes"<<endl;
	}
	else{
		cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
using System;

class Program
{
    static void Main(string[] args)
    {
        String strW = Console.ReadLine();

        int count = 0;

        while (true)
        {
            String strData = Console.ReadLine();

            if( strData.Equals("END_OF_TEXT"))
            {
                break;
            }

            String[] aryStrData = strData.Split(' ');

            for (int i = 0; i < aryStrData.GetLength(0); i++ )
            {
                if (String.Compare(strW, aryStrData[i], true) == 0)
                {
                    count++;
                }
            }

        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 9932
#include<stdio.h>
#include<string.h>
int main(){
  char c[]={" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"};
  char w[][9]={
    "101"     ,
    "000000"  , 
    "000011"  ,
    "10010001",
    "010001"  ,
    "000001"  ,
    "100101"  ,
    "10011010",
    "0101"    ,
    "0001"    ,
    "110"     ,
    "01001"   ,
    "10011011",
    "010000"  ,
    "0111"    ,
    "10011000",
    "0110"    ,
    "00100"   ,
    "10011001",
    "10011110",
    "00101"   ,
    "111"     ,
    "10011111",
    "1000"    ,
    "00110"   ,
    "00111"   ,
    "10011100",
    "10011101",
    "000010"  ,
    "10010010",
    "10010011",
    "10010000"
  };
  char n[102];
  //char s[920]={0};
  int i,j;
  while(fgets(n,101,stdin)!=NULL){
    char s[920]={0};
    for(i=0;n[i+1];i++){
      for(j=0;n[i]!=c[j];j++);
      strcat(s,w[j]);
    }//printf("%s\n",s);
    for(i=j=0;s[i];i++){
      j*=2;
      if(s[i]=='1')j++;
      if(i%5==4){
	printf("%c",c[j+6]);
	j=0;
      }
    }
    if(i%5){
      for(;i%5!=0;i++)j*=2;
      printf("%c",c[j+6]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 520
#create date: 2020-04-26 08:06

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    b = na()
    ans = 0
    for i in range(n):
        res = min(b[i], a[i])
        b[i] -= res
        ans += res
        res = min(a[i+1], b[i])
        a[i+1] -= res
        ans += res
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 18624
#include<iostream>
#include<vector>
#define mod 1000000007
using namespace std;
#define LL long long int 
int main() 
{
 
   
   
    LL N;
    cin  >> N;
    vector<LL> arr(N);
    for(auto &it:arr)
    {
        cin>>it;
    }
    vector<LL> p(N);
    p[N-1]=arr[N-1];
    for(LL i=N-2;i>=0;i--)
    {
        p[i]=(p[i+1]+arr[i])%mod;
    }
    LL m=0;
    for(LL i=0;i<N-1;i++)
    {
        m=(m +(arr[i]*p[i+1] ) %mod )%mod;
    }
    cout<<m;
 
}

Measured memory_bytes: 6404
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
signed main(){
    string s;
    int n,k;
    cin>>n>>k>>s;
    rep(i,n){
        if(i!=k-1)cout<<s[i];
        else{
            char c=s[i]+32;
            cout<<c;
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include <intrin.h>  //AtCoder (gcc) 上ではこれがあると動かない。__popcnt用のincludeファイル。
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;



//繰り返し2乗法
//N^aの、Mで割った余りを求める。
//M = 1000000007 (1e9 + 7) など。
//M = 1000000009 (1e9 + 9) もある。
//M = 998244353 もある。

ll my_pow(ll N, ll a, ll M) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2, M);
			return (tempo * tempo) % M;
		}
		else {
			tempo = my_pow(N, a - 1, M);
			return (tempo * N) % M;
		}
	}
}




signed main() {
	int A, B;
	char op;
	cin >> A >> op >> B;

	int res = 0;
	if (op == '+') res = A + B;
	else res = A - B;

	cout << res << endl;
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int M=3005;
const ll INF=1e15;
const int MOD=1e9+7;

ll n,sum;
ll a[M],dp[M][M];

ll DP(int i,int j,bool b){
	if (i == j){
		if (b) return a[i];
		else return 0;
	}
	if (dp[i][j] != -1) return dp[i][j];
	if (b) dp[i][j] = max(DP(i+1,j,b^1) + a[i] , DP(i,j-1,b^1) + a[j]);
	else dp[i][j] = min(DP(i+1,j,b^1) , DP(i,j-1,b^1));
	return dp[i][j];
}

int main(){

	fastio;
	cin >> n;
	fp(i,0,n){
		cin >> a[i];
		sum += a[i];
	}
	fp(i,0,n)
		fp(j,0,n) dp[i][j] = -1;
	cout << 2*DP(0,n-1,1) - sum << "\n";

	return 0;
}


Measured memory_bytes: 74292
#include<stdio.h>
int main(void){
    int n,i,dp[33];
    while(1){
        for(i=0;i<33;i++)
            dp[i]=0;//dp[33]={0};
        dp[0]=1;
        scanf("%d",&n);
        if(n==0){
            return 0;
        }
        for(i=0;i<n;i++){
            dp[i+3]+=dp[i];
            dp[i+2]+=dp[i];
            dp[i+1]+=dp[i];
        }
        printf("%d\n",(dp[n]+3649)/3650);
    }
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

using namespace std;

void add_one(queue<pair<int, int>>& dst, int c_h, int c_w, int h, int w)
{
	if (c_h < 0 || h <= c_h || c_w < 0 || w <= c_w) return;

	dst.push(make_pair(c_h, c_w));
}

void solve_one(vector<vector<bool>>& map, int h, int w, int s_h, int s_w)
{
	queue<pair<int,int>> checks;
	checks.push(make_pair(s_h, s_w));

	while (!checks.empty()) {
		auto cur = checks.front();
		checks.pop();

		if (!map[cur.first][cur.second]) continue;

		map[cur.first][cur.second] = false;

		add_one(checks, cur.first + 1, cur.second    , h, w);
		add_one(checks, cur.first - 1, cur.second    , h, w);
		add_one(checks, cur.first    , cur.second + 1, h, w);
		add_one(checks, cur.first    , cur.second - 1, h, w);
		add_one(checks, cur.first + 1, cur.second + 1, h, w);
		add_one(checks, cur.first + 1, cur.second - 1, h, w);
		add_one(checks, cur.first - 1, cur.second + 1, h, w);
		add_one(checks, cur.first - 1, cur.second - 1, h, w);
	}
}

int solve(vector<vector<bool>>& map, int h, int w)
{
	int count = 0;

	int s_h = 0;
	int s_w = 0;

	while (s_h < h && s_w < w) {
		if (map[s_h][s_w]) {
			solve_one(map, h, w, s_h, s_w);
			count++;
		}

		s_w++;
		if (s_w == w) {
			s_h++;
			s_w = 0;
		}
	}

	return count;
}

int main()
{
	while (true) {
		int h, w; cin >> w >> h;
		if (h == 0 && w == 0) return 0;

		vector<vector<bool>> map(h, vector<bool>(w));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int s; cin >> s;
				if (s == 0) map[i][j] = false;
				if (s == 1) map[i][j] = true;
			}
		}

		int count = solve(map, h, w);
		cout << count << endl;
	}

	return 0;
}


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

namespace Factorial
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long result = 1;


            for (long i = n; i > 1; --i)
            { 
                result *= i;
            }

            Console.WriteLine(result);
        }
    }
}



Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int H,W,D;
    cin >> H >> W >> D;
    vector<P> V(H*W);
    rep(i,0,H)rep(j,0,W){
        int a;
        cin >> a;
        V[a-1] = P(i,j);
    }
    vector<int> dist(H*W);
    rep(i,0,H*W){
        if(i < D)dist[i] = 0;
        else dist[i] = dist[i-D] + abs(V[i].first - V[i-D].first) + abs(V[i].second - V[i-D].second);
    }
    int Q;
    cin >> Q;
    rep(i,0,Q){
        int l,r;
        cin >> l >> r;
        cout << dist[r-1] - dist[l-1] << endl;
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    ll A, B;
    cin >> A >> B;
    if(13 <= A) cout << B << endl;
    else if(6 <= A) cout << B / 2 << endl;
    else cout << 0 << endl;

}

Measured memory_bytes: 256
/*
* Author: Anmol Choudhary
*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
													 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1e9+7;
const ll maxn = 1000005;
const ll mm = 1e+18;
vector<int>v;
int ff(string s){
    int n=s.length();
    int res=0;
    int x=1;
    for(int i=n-1;i>=0;i--){
        int r=(int)(s[i]-'0');
        res+=r*x;
        x*=10;
    }
    return res;
}
void f(string s){
    v.push_back(ff(s));
    if(s.length()==10) return;
    char c=s.back();
    if(c!='0') f(s+(char)(c-1));
    f(s+c);
    if(c!='9') f(s+(char)(c+1));
}
void solve()
{
    string s="";
    for(int i=1;i<10;i++) f(s+(char)('0'+i));
    sort(v.begin(),v.end());
    int k;
    cin>>k;
    cout<<v[k-1];
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 2420
#!/usr/bin/ruby
#encoding: utf-8

n = gets.to_i
p = gets.split.map(&:to_i)
errornum = 0
(1..n).each do |i|
  if i != p[i-1] 
    errornum += 1
  end
end

if (errornum == 0) or (errornum == 2)
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 1788
import sys
 
def main():
    H, W, K = map(int, sys.stdin.readline().split())
    s = ['.' * (W+1)] + ['.' + sys.stdin.readline().rstrip() for _ in range(H)]
 
 
    res = [[None for _ in range(W + 2)]] + [[None] + [0 for _ in range(W)] + [None] for _ in range(H)] + [[None for _ in range(W + 2)]]
 
    number = 1
    for i in range(1, H+1):
        if not '#' in s[i]:
            continue
        else:
            j = 1
            while j <= W:
                res[i][j] = number
                if s[i][j] == '#':
                    res[i][j] = number
                    if '#' in s[i][j+1:]:
                        number += 1
                j += 1
            number += 1
 
    for i in range(1, H+1):
        if res[i][1] == 1:
            count = i
            break
    
    for i in range(1, count):
        res[i] = res[count]
 
    for i in range(1, H):
        if res[i+1][1] == 0:
            res[i+1] = res[i]
    
    for i in range(1, H+1):
        print(' '.join(map(str, res[i][1:W+1])))
    
 
 
 
        
 
if __name__ == '__main__':
    main()

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

int main(){
  int n;
  cin >> n;
  string ans = "Three";
  vector<char> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  for(int i=0;i<n;i++){
    if(s[i] == 'Y'){
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)
#define SWAP(x,y) 		((x!=y)&&(x^=y,y^=x,x^=y))

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

int main(int argc, char* argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL a,b,x;
	LL ans=0;

	cin >> a >> b >> x;

	ans = floor((long double)b/x) - ceil((long double)a/x) + 1;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int D,G,p[11],c[11];

int main(){
  cin>>D>>G;

  for(int i=0;i<D;i++){
    cin>>p[i]>>c[i];
  }

  int ans=1e9;

  for(int bit=0;bit< (1<<D); bit++){
    int s=0,num=0,rest_max=-1;
    for(int i=0;i<D;i++){
      if(bit>>i & 1){
        s+=100*(i+1)*p[i]+c[i];
        num+=p[i];
      }else{
        rest_max=i;
      }
    }
    if(s<G){
      int s1=100*(rest_max+1);
      int need=(G-s+s1-1)/s1;
      if(need>=p[rest_max]) continue;
      else{
        num+=need;
        //cout<<num<<" "<<s<<endl;
        
      }
    }
    ans=min(ans,num);
  }
  cout<<ans<<endl;
}


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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var k = long.Parse(Console.ReadLine());
            var a = 7L % k;
            var result = 1L;

            if (k % 2 == 0 || k % 5 == 0)
            {
                Console.WriteLine(-1);
                return;
            }

            var list = new List<long>();
            for (var i = 0; i <= k; i++)
            {
                if (a == 0)
                {
                    Console.WriteLine(result);
                    return;
                }
                a = (a * 10 + 7) % k;
                result++;
            }

            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 27772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull  unsigned long long
#define vll  vector <long long>
#define pll pair <long long,long long>
#define f first
#define s second
#define up upper_bound
#define lp lower_bound
#define pq priority_queue
#define inf 1e10
#define minf -1e10
#define pi 3.14159265
#define mod 300000000000000000
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);
int main()
{
    ll n,ojon;
    cin>>n>>ojon;
    vector <pll> vec;
    ll ara[n+1][ojon+1];
    for(ll i=0;i<n;i++)
    {
        ll num,num1;
        cin>>num>>num1;
        vec.pb(mp(num,num1));

    }
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=ojon;j++)
        {
            if(i==0||j==0)
                ara[i][j]=0;
            else if(vec[i-1].f<=j)
            {
                ara[i][j]=max(vec[i-1].s+ara[i-1][j-vec[i-1].f],ara[i-1][j]);
            }
            else
                ara[i][j]=ara[i-1][j];
        }
    }
    cout<<ara[n][ojon]<<endl;

}



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

using namespace std;
int main() {
	int n, k;
	cin>> n>> k;
	int arr[n];
	for(int i = 0; i < n; i++) 
		cin>>arr[i];
	vector<bool> dp(k+1);
	for(int i = 0; i <= k; i++) {
		for(int j = 0; j < n; j++) {
			if(i >= arr[j] && !dp[i-arr[j]])
				dp[i] = true;
		}
	}
	if(dp[k]) {
		cout<<"First\n";
	} else {
		cout<<"Second\n";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	for (int i = 0; i < 5; i++){
		int x;
		cin >> x;
		if (x == 0){
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3524
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int fact[9];
void factorial()
{
    fact[0]=1;
    fact[1]=1;
    for(int i=2;i<=8;i++)
    fact[i]=i*fact[i-1];
}
int32_t main() {
  
int n;
cin>>n;
factorial();
int a[n],b[n];
int cnt1=0,cnt2=0;
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
for(int i=0;i<n;i++)
{
    cin>>b[i];
}
int vis[n+1]={0};
for(int i=0;i<n;i++)
{
    int temp=a[i];
    int val=0;
    for(int i=1;i<temp;i++)
    {
        if(vis[i]==0)
        val++;
    }
    vis[a[i]]=1;
    cnt1+=(val*fact[n-i-1]);
}
int vis1[n+1]={0};
for(int i=0;i<n;i++)
{
    int temp=b[i];
    int val=0;
    for(int i=1;i<temp;i++)
    {
        if(vis1[i]==0)
        val++;
    }
    vis1[b[i]]=1;
    cnt2+=(val*fact[n-i-1]);
}
cout<<abs(cnt2-cnt1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

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

    long double A;
    long double B;

    cin >> A;
    cin >> B;

    cout << std::fixed << setprecision(0) << floor(A * B) << endl;

    return 0;
}


Measured memory_bytes: 3812
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        long ans1 = 0;
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
            if (i % 2 == 1 && sum <= 0) {
                ans1 += 1 - sum;
                sum = 1;
            } else if (i % 2 == 0 && sum >= 0) {
                ans1 += sum + 1;
                sum = -1;
            }
        }

        long ans2 = 0;
        sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
            if (i % 2 == 0 && sum <= 0) {
                ans2 += 1 - sum;
                sum = 1;
            } else if (i % 2 == 1 && sum >= 0) {
                ans2 += sum + 1;
                sum = -1;
            }
        }

        System.out.println(Math.min(ans1, ans2));
    }
}


Measured memory_bytes: 51044
n,m = map(int,input().split())
cards = []
for i in range(m):
    cards.append(list(map(int,input().split())))

min = cards[0][0]
max = cards[0][1]

for i in range(m):
    if cards[i][0] > min:
        min = cards[i][0]
    if cards[i][1] < max:
        max = cards[i][1]

if max >= min:
    print(max - min + 1)
else:
    print(0)

Measured memory_bytes: 27344