akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x = max(a,c);
    int y = min(b,d);
    if(y-x<0){
        cout<<"0"<<endl;
        return 0;
    }
    else{
        cout<<y-x<<endl;
        return 0;
    }
    return 0;
    
}

Measured memory_bytes: 256
MyString=Union{String,SubString{String},Char}
MyStringArray=Union{Array{String,1},Array{SubString{String},1},Array{Char,1}}
parseInt(x::MyString) = parse(Int, x)
parseInt(x::Real) = trunc(Int, x)
parseBigInt(x::MyString) = parse(BigInt, x)
parseBigInt(x::Real) = trunc(BigInt, x)
parseFloat(x::MyString) = parse(Float64, x)
parseFloat(x::Real) = trunc(Float64, x)
parseBigFloat(x::MyString) = parse(BigFloat, x)
parseBigFloat(x::Real) = trunc(BigFloat, x)
parseMap(x::MyStringArray) = map(parseInt, x)
parseMapBig(x::MyStringArray) = map(parseBigInt, x)

function main()
    w=chomp(readline())
    cnt=Dict{Char,Int}()
    for i in w
        if haskey(cnt,i)
            cnt[i]+=1
        else
            cnt[i]=1
        end
    end
    ans="Yes"
    for i in keys(cnt)
        if cnt[i]%2==1
            ans="No"
        end
    end
    println(ans)
end
main()

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

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

	cout << max(0, a - 2*b) << endl;

	return 0;
}

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1;
string s1, s2;
int ans;

int main(){
	cin>>s1>>s2;
	for(int i=0; i<3; i++){
		ans+=(s1[i]==s2[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
#include<string>
using namespace std;
const int N=10+5,dx[]={0,0,1,-1},dy[]={1,-1,0,0},INF=0x3f3f3f3f;

int main()
{
    char str[8][4]={"+++","+-+","++-","+--","-+-","--+","-++","---"};
    int n,sz[5],k[2],a[7];
    while(~scanf("%d",&n)){
        for(int i=0;i<4;i++){
            sz[i]=n%10;
            n/=10;
        }
        swap(sz[0],sz[3]);
         swap(sz[1],sz[2]);
         a[0]=sz[0]+sz[1]+sz[2]+sz[3];
         a[1]=sz[0]+sz[1]-sz[2]+sz[3];
        a[2]=sz[0]+sz[1]+sz[2]-sz[3];
         a[3]=sz[0]+sz[1]-sz[2]-sz[3];
        a[4]=sz[0]-sz[1]+sz[2]-sz[3];
         a[5]=sz[0]-sz[1]-sz[2]+sz[3];
         a[6]=sz[0]-sz[1]+sz[2]+sz[3];
         a[7]=sz[0]-sz[1]-sz[2]-sz[3];
        for(int i=0;i<8;i++){
            if(a[i]==7){
                printf("%d%c%d%c%d%c%d=7\n",sz[0],str[i][0],sz[1],str[i][1],sz[2],str[i][2],sz[3]);
                break;
            }

        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
 
int main(){
  string a,b,c;
  cin >> a >> b >> c;
  int na=0,nb=0,nc=0;
  char turn='a';
  while(1){
	  if(turn=='a'){
		  if(na>=a.size()){
			  cout << "A" << endl;
			  return 0;
		  }
		  turn=a[na];
		  na++;
	  }else if(turn=='b'){
		  if(nb>=b.size()){
			  cout << "B" << endl;
			  return 0;
		  }
		  turn=b[nb];
		  nb++;
	  }else if(turn=='c'){
		  if(nc>=c.size()){
			  cout << "C" << endl;
			  return 0;
		  }
		  turn=c[nc];
		  nc++;
	  }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    cin>>a;
    
    cout<<fixed<<setprecision(6)<<((double)((a+1)/2)/(double)a)<<endl;
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


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

#define ll long long



int main() {
 int  n;
  cin>>n;
   int c=n%10 ;
    if(c==3)
        cout<<"bon";
    else
        if( c==0||c==6||c==1||c==8)
        cout<<"pon";
    else
        cout<<"hon"    ;
}


Measured memory_bytes: 3604
INF = float("inf")

N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

ans = INF
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        for j in range(k - K + 1):
            dy = YY[j + K - 1] - YY[j]
            if ans > dx * dy:
                ans = dx * dy

print(ans)

Measured memory_bytes: 3064
N = gets.to_i
S = N.times.map { gets.to_i }

scores = Hash.new
scores[0] = true

S.each do |s|
  temp = scores.dup

  temp.each_key do |score|
    scores[score + s] = true
  end
end

puts scores.keys.select { |x| x == 0 || x % 10 != 0 }.max


Measured memory_bytes: 28540
// In the name of God

#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, d;
	cin >> n >> d;
	int ans = n / (2*d+1);
	if(n % (2*d+1)) ans++;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
s=input()
x,y=map(int, input().split())
X,Y=[],[]
t,c=0,0
for i in range(len(s)):
  if s[i]=='F':
    c+=1
  else:
    if t%2==0:
      X.append(c)
    else:
      Y.append(c)
    c=0
    t+=1
if t%2==0:
  X.append(c)
else:
  Y.append(c)
if len(X)>0:
  D=[X[0]]
  E=[]
  for i in range(1,len(X)):
    for j in D:
      E.append(j+X[i])
      E.append(j-X[i])
    D,E=list(set(E)),[]
if x not in D:
  print('No')
  exit()
  
if len(X)>0:
  D=[0]
  E=[]
  for i in range(len(Y)):
    for j in D:
      E.append(j+Y[i])
      E.append(j-Y[i])
    D,E=list(set(E)),[]
if y not in D:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9684
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vll;
typedef vector<vector<long long>> vvll;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const double eps9 = 1e-9;

ll test(vector<ll>& a)
{
	ll res = 0;
	for (int i = 0; i < sz(a) - 1; i++)
		for (int j = i + 1; j < sz(a); j++)
		{
			res = (res + (a[i] ^ a[j]) % mod) % mod;
		}
	return res;
}
int main() {
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n;
	cin >> n;
	vector<ll> a(n);
	for (ll& i : a)
		cin >> i;
	vector<ll> res(63);
	for (int bit = 0; bit < 63; bit++)
	{
		ll zc = 0, oc = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i] & (1LL << bit))
				oc++;
			else
				zc++;
		}
		res[bit] = zc * oc;
	}
	ll final_res = 0;
	for (int bit = 0; bit < 63; bit++)
	{
		final_res = (final_res + (res[bit] % mod * ((1LL << bit) % mod)) % mod) % mod;
	}
	cout << final_res % mod;
	return 0;

}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

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

    long long ans = 0;
    for(int i=1; i<=N; i++){
        if(i%3!=0 && i%5!=0){
            ans+=i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
n,m,l=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(n)]
B=[list(map(int,input().split())) for _ in range(m)]
for i in range(n):
    ans=[0]*l
    for j in range(l):
        for k in range(m):
            ans[j]+=A[i][k]*B[k][j]
    print(*ans)


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

long long n,m,val[100005],a,b,cont,num[100005];
bool vis[100005];
vector<int> grafo[100005];
map<pair<int,int>,bool> dir;

void dfs(int nodo,int last){
    
    vis[nodo]=true;
    
    for(int i=0;i<grafo[nodo].size();i++){
        if(vis[grafo[nodo][i]]==false){
            dfs(grafo[nodo][i],nodo);
            num[nodo]+=num[grafo[nodo][i]];
        }
    }
    
    if(val[nodo]%2==1)num[nodo]++;
    num[nodo]%=2;
    
    if(num[nodo]==1){
        dir[{min(nodo,last),max(nodo,last)}]^=true;
    }
}

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

	cin>>n>>m;
	
	for(int i=0;i<m;i++){
	    
	    cin>>a>>b;
	    grafo[a].push_back(b);
	    grafo[b].push_back(a);
	    
	    dir[{min(a,b),max(a,b)}]=true;
	    val[min(a,b)]++;
    }
    
    for(int i=1;i<=n;i++){
        if(val[i]%2==1)cont++;
    }
    
    if(cont%2!=0){
        cout<<"-1"<<endl;
        return 0;
    }
    
    dfs(1,-1);
	
	for(int i=1;i<=n;i++){
	    for(int j=0;j<grafo[i].size();j++){
	        if(grafo[i][j]>i){
	            if(dir[{i,grafo[i][j]}]==true)cout<<i<<" "<<grafo[i][j]<<"\n";
	            else cout<<grafo[i][j]<<" "<<i<<"\n";
            }
        }
    }

return 0;
}


Measured memory_bytes: 25728
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

const int N = 1e5;
int a[N+5];

int main()

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

    int n, m, c, x, cnt = 0;

    cin >> n >> m >> c;

    int tmp = c;

    int b[m];

    for (int i = 0; i < m; i++) cin >> b[i];

    for (int i = 0; i < n; i++) {

        for (int j = 0; j < m; j++) {

            cin >> x;
            tmp+=x*b[j];
        }

        if (tmp > 0) cnt++;
        tmp = c;
    }

    cout << cnt;

    return 0;
}



Measured memory_bytes: 256
import collections

n = int(input())
nums = list(map(int, input().split()))

odd = []
even = []

for i in range(n):
	if i % 2 == 0:
		even.append(nums[i])
	else:
		odd.append(nums[i])

counter_even = collections.Counter(even)
counter_odd = collections.Counter(odd)

change_even = len(even) - counter_even.most_common()[0][1]
change_odd = len(odd) - counter_odd.most_common()[0][1]
if len(counter_even.most_common()) == 1 and len(counter_odd.most_common()) == 1 and counter_even.most_common()[0][0] == counter_odd.most_common()[0][0]:
	print(n//2)
elif counter_even.most_common()[0][0] != counter_odd.most_common()[0][0]:
	print(change_odd + change_even)
else:
	if change_even < change_odd:
		change_odd_2 = len(odd) - counter_odd.most_common()[1][1]
		print(change_odd_2 + change_even)
	elif change_even > change_odd:
		change_even_2 = len(even) - counter_even.most_common()[1][1]
		print(change_even_2 + change_odd)
	else:
		change_even_2 = len(even) - counter_even.most_common()[1][1]
		change_odd_2 = len(odd) - counter_odd.most_common()[1][1]
		if change_even_2 < change_odd_2:
			print(change_even_2 + change_odd)
		else:
			print(change_odd_2 + change_even)


Measured memory_bytes: 20576
n, k = map(int, input().split())
r = 0
total = 0
for i in range(1, n + 1):
    t = i
    cnt = 0
    while True:
        if t >= k:
            total += 1 / n * (0.5) ** cnt
            break
        else:
            cnt += 1
            t *= 2
print(total)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> problems(n + 1, 0);
  ll ansA = 0, ansB = 0;
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    if (s == "AC") {
      if(problems[p]!=-1){
        ansA++;
        ansB += problems[p];
        problems[p] = -1;
      }
    } else if (s == "WA") {
      problems[p] += problems[p] != -1 ? 1 : 0;
    }
  }
  cout << ansA << " " << ansB << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  for(int i=1;i<N;i++){
    if(A.at(i)==A.at(i-1)){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
  

Measured memory_bytes: 1024
import copy
import collections
import sys
read = sys.stdin.read
NXY = [int(_) for _ in read().split()]
N = NXY[0]
X = NXY[1::2]
Y = NXY[2::2]
xi = {x: i for i, x in enumerate(set(X))}
yj = {y: j for j, y in enumerate(set(Y))}


class UnionFind():
    def __init__(self, size):
        self.dat = list(range(size))
        self.SIZE = [1] * size  # 0-indexed

    def find(self, x):
        dat = self.dat
        stack = [x]
        while True:
            y = stack[-1]
            if dat[y] != y:
                stack += [dat[y]]
            else:
                break
        for s in stack:
            dat[s] = y
        return y

    def unite(self, x, y):
        is_same = self.is_same
        find = self.find
        SIZE = self.SIZE
        dat = self.dat
        if not is_same(x, y):
            X, Y = find(x), find(y)
            SX, SY = SIZE[X], SIZE[Y]
            if SX > SY:
                m = dat[X] = Y
            else:
                m = dat[Y] = X
            SIZE[m] = SX + SY
            SIZE[X + Y - m] = 0

    def is_same(self, x, y):
        find = self.find
        return find(x) == find(y)

    def scan_uf(self):
        find = self.find
        length = len(self.dat)
        for i in range(length):
            find(i)

    def size(self, x):
        return self.SIZE[self.find(x)]


ufx = UnionFind(len(xi))
ufy = UnionFind(len(yj))
sxy = collections.defaultdict(set)
syx = collections.defaultdict(set)
for x, y in zip(X, Y):
    i = xi[x]
    j = yj[y]
    sxy[i].add(j)
    syx[j].add(i)
sxy2 = copy.deepcopy(sxy)
for sy in sxy.values():
    y1 = sy.pop()
    for y in sy:
        ufy.unite(y1, y)
for sx in syx.values():
    x1 = sx.pop()
    for x in sx:
        ufx.unite(x1, x)
ufx.scan_uf()
ufy.scan_uf()
ans = 0
for x, vx in enumerate(ufx.SIZE):
    if vx:
        vy = ufy.size(sxy2[x].pop())
        ans += vx * vy
print(ans - N)


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll x;
    cin >> x;
    ll y = 100, cnt = 0;
    while(y < x){
        y *= 1.01;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3632
def at_most_1_swap(N: int, P: list)->bool:
    swapped = 0
    for i, p in enumerate(P):
        if i+1 != p:
            swapped += 1
    return swapped <= 2


if __name__ == "__main__":
    N = int(input())
    P = list(map(int, input().split()))
    ans = at_most_1_swap(N, P)
    print('YES' if ans else 'NO')


Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    x = 800 * n
    y = (n // 15) * 200
    print(x - y)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////



int main() {
	
	ll N, M;
	cin >> N >> M;

	ll ans = 0;

	if (N*N > M) {
		for (ll c = M / N; c > 0; c--) {
			if (M%c == 0) {
				ans = c;
				break;
			}
		}
	}

	else {

		ll m = 1;

		for (int i = 1; i <= sqrt(M); i++) {
			if (i >= N && M%i == 0) {
				ans = i;
				break;
			}

			if (M%i == 0) { m = i; }

		}

		if (ans == 0) { ans = M / m; }

		ans = M / ans;
	}

	cout << ans;


	system("PAUSE");
}

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

using ll = long long;

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

  for (ll h = 1; h <= 3500; h++) {
    for (ll n = 1; n <= 3500; n++) {
      ll x = N * h * n;
      ll y = 4 * h * n - N * h - N * n;
      if (y > 0 && x % y == 0) {
        cout << h << " " << n << " " << x / y << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  int half   = (n + 1) / 2;
  double ans = half / (double)n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();   // switchCount
        int m = sc.nextInt();   // lightCount
        
        List<Integer>[] sl = new ArrayList[m];
        for (int i = 0; i < m; i++) {
            sl[i] = new ArrayList<Integer>();
            
            int j = sc.nextInt();
            while (j-- > 0) {
                int switchIndex = sc.nextInt();
                sl[i].add(switchIndex);
            }
        }
        
        int[] guuki = new int[m];
        for (int i = 0; i < m; i++) {
            guuki[i] = sc.nextInt();
        }
        
        int combinationCount = (int)Math.pow(2, n);
        int clearedCount = 0;
        for (int i = 0; i < combinationCount; i++) {
            String binaryNumber = Integer.toBinaryString(i);
            while (binaryNumber.length() < n) {
                binaryNumber = "0" + binaryNumber;
            }
            
            for (int j = 0; j < m; j++) {
                List<Integer> switches = sl[j];
                int sum = 0;
                for (int index : switches) {
                    int num = Integer.valueOf(String.valueOf(binaryNumber.charAt(index - 1)));
                    sum += num;
                }
                
                if (sum % 2 != guuki[j]) {
                    break;
                }
                
                if (j == m - 1) {
                    clearedCount++;
                }
            }
        }
        
        System.out.println(clearedCount);
    }
}

Measured memory_bytes: 26324
#include<iostream>
int main(){
  int paper[10][10],x,y,a,max=0;
  std::string s;
  for(x=0; x<10; x++)
    for(y=0; y<10; y++)
      paper[x][y]=0;

  while(std::cin>>s){
    x=s.at(0)-'0';
    y=s.at(2)-'0';
    a=s.at(4)-'0';
      paper[x][y]++;
      if(x>0) paper[x-1][y]++;
      if(x<9) paper[x+1][y]++;
      if(y>0) paper[x][y-1]++;
      if(y<9) paper[x][y+1]++;

    if(a>1){
      if(x>0&&y>0) paper[x-1][y-1]++;
      if(x<9&&y>0) paper[x+1][y-1]++;
      if(x>0&&y<9) paper[x-1][y+1]++;
      if(x<9&&y<9) paper[x+1][y+1]++;
    }
    if(a>2){
      if(x>1)paper[x-2][y]++;
      if(y>1)paper[x][y-2]++;
      if(x<8)paper[x+2][y]++;
      if(y<8)paper[x][y+2]++;
    }
  }

  for(x=0,a=0;x<10;x++)
    for(y=0;y<10;y++){
      paper[x][y]==0 ? a++:0,
      paper[x][y]>max ? max=paper[x][y]:0;
    }
      std::cout<<a<<"\n"<<max<<"\n";
}

Measured memory_bytes: 0
# 入力を受け取る
n,y = gets.chomp.split.map(&:to_i)

for i in 0..n do
  for j in 0..(n-i) do
    sum = 10000*i+5000*j+1000*(n-i-j)
    if sum == y
      puts "#{i} #{j} #{n-i-j}"
      flag = true
      break
    end
  end
  break if flag
end
puts "-1 -1 -1" if !(flag)


Measured memory_bytes: 3836
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
ll n, a[3], d;
map < ll, ll > mp;
int p[3] = {2, 3, 5};
const ll INF = 1e18;
ll go(ll n) {
    if (n == 0) return 0;
    if (mp.find(n) != mp.end()) return mp[n];
    ll best = INF;
    if (n < (INF + d - 1) / d) best = n * d;
    for (int c = 0; c < 3; c++) {
        for (int i = -p[c] + 1; i <= p[c] - 1; i++) {
            ll will = n + i;
            if (will % p[c] != 0) continue;
            if (will < 0) continue;
            will /= p[c];
            if (will >= n) continue;
            if (will != 0) {
                best = min(best, go(will) + abs(i) * d + a[c]);
            }
            else {
                best = min(best, abs(i) * d);
            }
        }
    }
    return mp[n] = best;
}
void solve() {
    cin >> n >> a[0] >> a[1] >> a[2] >> d;
    mp.clear();
    cout << go(n) << '\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int tst;
    cin >> tst;
    while (tst--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4448
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

ll N, A, B;
vl H;
int clear(ll k) {
    ll sum = 0;
    REP(i, N) {
        if (H[i] - k * B >= 0) {
            sum += (H[i] - k * B + A-B-1) / (A - B);
        }
    }

    if (sum == k){
        return 0;
    } else if (sum < k) {
        return 1;
    } else {
        return -1;
    }
}

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

    cin >> N >> A >> B;
    H=vl(N); REP(i, N) cin >> H[i];

    ll HMAX = 0;
    REP(i, N) HMAX = max(HMAX, H[i]);    

    ll l = 1, r = (HMAX + B - 1) / B;
    ll ans = 0;
    while(l < r) {
        ll m = (l + r) / 2;

        int ret = clear(m);

        if (ret==0) {
            ans = m;
            break;

        }else if (ret > 0) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    if (ans == 0) ans = l;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;

using namespace std;

int n, m, fact[500001], invfact[500001], ans;

int add(int a, int b)
{
    return (a+b)%MOD;
}

int mul(int a, int b)
{
    return (ll(a)*ll(b))%MOD;
}

int exp(int a, int b = MOD-2)
{
    int ret = 1;
    while(b!=0)
    {
        if(b%2==1)
            ret = mul(ret,a);
        b/=2, a = mul(a,a);
    }
    return ret;
}

int npr(int a, int b)
{
    return mul(fact[a],invfact[a-b]);
}

int ncr(int a, int b)
{
    return mul(mul(fact[a],invfact[b]),invfact[a-b]);
}

int main()
{
    cin >> n >> m;
    fact[0] = invfact[0] = 1;
    for(int i = 1; i<=m; i++)
        fact[i] = mul(fact[i-1],i), invfact[i] = exp(fact[i]);
    for(int i = 0; i<=n; i++)
    {
        int temp = mul(mul(ncr(n,i),npr(m,n)),npr(m-i,n-i));
        ans = add(ans,mul(1-2*(i%2),temp));
    }
    cout << add(ans,MOD) << endl;
}


Measured memory_bytes: 7344
#include <iostream>
using namespace std;
int main(){
    int d,n; cin >> d >> n;
    int x;
    if (d==0) x = 1;
    else if (d==1) x = 100;
    else x = 10000;
    cout << ((n!=100) ? x*n : x*(n+1))<< endl;
}

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

bool comparev(pair<int,int> a, pair<int,int> b){
  if(a.second != b.second){
    return a.second < b.second;
  }
  else{
    return a.first > b.first;
  }
}

vector<pair<int, int> > v;
priority_queue<pair<int, int> > pq;

int main(){
  int N, M;
  cin >> N >> M;
  for(int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;
    pair<int, int> p = make_pair(b,a);
    v.push_back(p);
  }
  sort(v.begin(), v.end(), comparev);
  long sal=0;
  int idx=0;
  for(int i=1; i<=M; i++){
    while(idx<N && v[idx].second<=i){
      pq.push(v[idx]);
      idx++;
    }
    if(!pq.empty()){
      sal+=pq.top().first;
      pq.pop();
    }
  }
  cout << sal << endl;
  return 0;
}


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


const int MaxN = 2e5 + 10;
int n;
vector<int> edge[MaxN];
vector<int> color(MaxN);


void dfs(int u, int c)
{
    color[u] = c;
    for (int v : edge[u]) {
        if (color[v])
            continue;
        dfs(v, 3 - c);
    }
}


void solve()
{
    dfs(1, 1);
    vector<bool> used(n + 1);
    vector<int> p(n + 1);
    int cnt1 = 0;
    for (int i = 1; i <= n; i++) {
        if (color[i] == 1)
            cnt1++;
    }
    int cnt2 = n - cnt1;
    if (cnt1 <= n / 3 || cnt2 <= n / 3) {
        int cm = (cnt1 <= cnt2) ? 1 : 2;
        int k = 3;
        for (int i = 1; i <= n; i++) {
            if (color[i] == cm) {
                p[i] = k;
                used[k] = true;
                k += 3;
            }
        }
        k = 1;
        for (int i = 1; i <= n; i++) {
            if (p[i] == 0) {
                while (used[k])
                    k++;
                p[i] = k;
                k++;
            }
        }
    } else {
        int k = 1;
        for (int i = 1; i <= n; i++) {
            if (color[i] == 1) {
                p[i] = k;
                k += 3;
            }
            if (k > n)
                break;
        }
        k = 2;
        for (int i = 1; i <= n; i++) {
            if (color[i] == 2) {
                p[i] = k;
                k += 3;
            }
            if (k > n)
                break;
        }
        k = 3;
        for (int i = 1; i <= n; i++) {
            if (p[i] == 0) {
                p[i] = k;
                k += 3;
            }
        }
    }

    for (int i = 1; i <= n; i++)
        cout << p[i] << " ";
    cout << endl;
}


int main()
{
    cin >> n;
    int a, b;
    for (int i = 1; i <= n - 1; i++) {
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    solve();
    return 0;
}


Measured memory_bytes: 16768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        int cnt = 0;

        for(int i = 0; i < str.Length; i++){
            for(int j = 0; j < str.Length; j++){
                if(str[i] == str[j]){
                    cnt++;
                }

                if(cnt == 2){
                    Console.WriteLine("no");
                    return;
                }
            }
            cnt = 0;
        }
        Console.WriteLine("yes");
    }
}



Measured memory_bytes: 11092
# -*- coding:utf8 -*-

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
d = 0
for i,n in enumerate(b):
    c = a[i]
    if n + d >= c:
        ans += c
        if c - d <= 0:
            d = n
        else:
            d = n - (c - d)
    else:
        ans += n + d
        d = 0
l = a[-1]
if l <= d:
    ans += l
else:
    ans += d
print(ans)

Measured memory_bytes: 19156
void main()
{
    long[] tmp = rdRow;
    long h = tmp[0], w = tmp[1];
    long n = rdElem;
    long[] a = rdRow;

    long[][] c = new long[][](h, w);
    long f;
    long y, x;
    long dx = 1;
    long cnt;
    while (!a.empty)
    {
        f = a[0];
        a.popFront;
        ++cnt;

        while (f > 0)
        {
            c[y][x] = cnt;
            if (x == w - 1 && dx == 1)
            {
                dx = -1;
                ++y;
            }
            else if (x == 0 && dx == -1)
            {
                dx = 1;
                ++y;
            }
            else
            {
                x += dx;
            }
            --f;
        }
    }

    c.wrMat;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 764
#include<iostream>
#include<stdio.h>
using namespace std;

const int MAX_N=1e5+10;

int data[2*MAX_N];

int main(){
	int n,x;
	cin>>n>>x;
	if(x==1 || x==2*n-1){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	if(n==2){
		cout<<1<<endl<<2<<endl<<3<<endl;
		return 0;
	}
	int cnt=0;
	if(x>2 && x<2*n-2){
		data[n]=x;
		data[n-1]=1;
		data[n+1]=2*n-1;
		data[n-2]=2*n-2;
		data[n+2]=2;
		cnt=3;
	}
	else{
		data[n]=x;
		if(x==2){
			data[n+1]=1;
			data[n+2]=2*n-1;
			cnt=3;
		}
		else{
			data[n+1]=2*n-1;
			data[n+2]=1;
			cnt=2;
		}
	}
	for(int i=1;i<=2*n-1;i++){
		if(cnt==x)cnt++;
		if(data[i]==0)data[i]=cnt++;	
		cout<<data[i]<<endl;
	}

}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
    cin >>x>>y>>z;
    if(abs(x-y)>abs(x-z)){
        cout << "B";
    }else cout <<"A";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll x0, y0, x1, y1; cin >> x0 >> y0 >> x1 >> y1;
    ll dx = x1 - x0, dy = y1 - y0;
    vector<char> ans;

    rep(_, dx) ans.push_back('R');
    rep(_, dy) ans.push_back('U');
    rep(_, dx) ans.push_back('L');
    rep(_, dy + 1) ans.push_back('D');
    rep(_, dx + 1) ans.push_back('R');
    rep(_, dy + 1) ans.push_back('U');
    ans.push_back('L');
    ans.push_back('U');
    rep(_, dx + 1) ans.push_back('L');
    rep(_, dy + 1) ans.push_back('D');
    ans.push_back('R');

    for(auto c : ans) cout << c;
    cout << endl;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

const int mod = 1e9+7;

string s;
int dp[111111][5];

signed main() {
  cin >> s;

  dp[0][0] = 1;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < 5; j++) {
      if (s[i] != '?') {
        Add(dp[i+1][j], dp[i][j]);
      } else {
        Add(dp[i+1][j], dp[i][j] * 3 % mod);
      }
    }
    if (s[i] == 'A' or s[i] == '?') Add(dp[i+1][1], dp[i][0]);
    if (s[i] == 'B' or s[i] == '?') Add(dp[i+1][2], dp[i][1]);
    if (s[i] == 'C' or s[i] == '?') Add(dp[i+1][3], dp[i][2]);
  }

  cout << dp[s.size()][3] << endl;

  return 0;
}

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

int main()
{
	int n, m;
	int i, j;
	int A[100][100], B[100], C[100]={0};

	cin >> n >> m;

	for(i = 0; i < n; i++)
	{
		for(j = 0; j < m; j++)
				{
					cin >> A[i][j];
				}
	}
	
		for(j = 0; j < m; j++)
					{
						cin >> B[j];
					}
		for(i = 0; i < n; i++)
		{
			for(j = 0; j < m; j++)
			{
				C[i] += A[i][j] * B[j];
			}
		}
		for(i = 0; i < n; i++)
		{
			cout << C[i] << endl;
		}
		return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>
char* F(char *b,int n,FILE *f){char *r=fgets(b,n,f);if(!r)return NULL;b[strlen(b)-1]=0;return r;}
char Q[29999],*q[9],L[29999];
n;D(old_indent,depth){}
old_indent=-1,depth=0;
main(){F(Q,sizeof(Q),stdin);q[0]=strtok(Q+1,".");for(n=1;;n++)if(!(q[n]=strtok(NULL,".")))break;for(;;){
	int indent=0;
	if(!F(L,sizeof(L),stdin))puts("no such property"),exit(0);
	for(;L[indent]==' ';indent++);
	if(old_indent>=indent)puts("no such property"),exit(0);
	char *name=strtok(L+indent,":"),*value=name+strlen(name)+1;
	if(!strcmp(name,q[depth])){
		if(depth==n-1)
			if(*value)printf("string \"%s\"\n",value+1),exit(0);
			else puts("object"),exit(0);
		old_indent=indent,depth++;
	}
}}

Measured memory_bytes: 588
MN=list(map(int, input().split()))
M = MN[0]
N = MN[1]
if N == 1:
  N = MN[0]
  M = MN[1]
if M == 1:
  if N == 1:
    c = 1
  elif N == 2:
    c = 0
  else:
    c = N - 2
else:
  c = (M - 2)*(N - 2)
print(c)

Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <=(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);

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

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

    string ans = {};
    for(i = 0; i < n; i++) {
        ans += s[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int n;
ll a[100000];
ll S[200000];

int main(){
	scanf("%d", &n);
	rep(i,n) scanf("%lld", &a[i]);
	S[0] = a[0];
	for(int i = 1; i < 2*n; i++) S[i] = S[i-1]+a[i%n];
	ll s = 1, e = 1000000000000001, mid;
	//printf("\n");
	while(true){
		mid = (s+e)/2;
		//printf("%lld %lld %lld\n", s,mid,e);
		if(e-s == 1) break;
		bool ok = false;
		rep(i,n){
			ll st;
			if(i != 0) st = lower_bound(S+i,S+i+n,mid+S[i-1])-S;
			else st = lower_bound(S+i,S+i+n,mid)-S;
			if(st == i+n) continue;
			st = lower_bound(S+st+1,S+i+n,mid+S[st])-S;
			if(st == i+n) continue;
			if(S[i+n-1]-S[st] >= mid){
				ok = true;
				break;
			}
		}
		if(ok) s = mid;
		else e = mid;
		//printf("%lld %lld %lld\n", s,mid,e);
	}
	printf("%lld\n", s);
}

Measured memory_bytes: 3372
import java.util.*;
 
public class Main {
    static Scanner scanner = new Scanner(System.in);
 
    public static void main(String[]$) {
        long n = scanner.nextLong();
        long x = scanner.nextLong();
        long y = n - x;
        long ans = n;
        while (x != 0 && y != 0) {
            if (x > y) {
                ans += x / y * y * 2;
                x %= y;
            } else {
                ans += y / x * x * 2;
                y %= x;
            }
        }
        System.out.println(ans - x - y);
    }
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll h, w; cin >> h >> w;

    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }

    cout << (h * w + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <map>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
using namespace std;
typedef long long ll;
int p[]={2,3,5};
ll n,a[4];
map<ll,ll> dp;
ll solve(ll n) {
	if (dp.count(n)) return dp[n];
	ll ans = 4e18;
	REP(j,0,2) REP(r,-p[j]+1,p[j]-1) if (n+r>=0&&(n+r)%p[j]==0) {
		ll x = (n+r)/p[j], t = solve(x);
		ans = min(ans,t+abs(r)*a[3]+a[j]);
		if (abs(n-x)<(ans-t)/a[3]) ans = t+abs(n-x)*a[3];
	}
	return dp[n]=ans;
}
void work() {
	dp.clear();
	scanf("%lld%lld%lld%lld%lld",&n,a,a+1,a+2,a+3);
	dp[0] = 0, dp[1] = a[3];
	printf("%lld\n",solve(n));
}
int main() {
	int t;
	scanf("%d", &t);
	while (t--) work();
}

Measured memory_bytes: 4120
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main()
{
   long N;
   std::cin >> N;
   long p[50];
   for(int i=0; i<N; i++){
       std::cin >> p[i];
   }
   long count=0;
   for(int i=0; i<N; i++){
       if(p[i]!=i+1){
           count++;
       }
   }
   if(count==0 || count==2){
       std::cout << "YES" << std::endl;
   }else{
       std::cout << "NO" << std::endl;
   }
    return 0;
}

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

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[100010];

    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    int dp[] = new int[100010];
    Arrays.fill(dp, Integer.MAX_VALUE);

    dp[0] = 0;
    for (int i = 0; i < n; i++) {
      dp[i + 1] = Math.min(dp[i] + Math.abs(h[i] - h[i + 1]), dp[i + 1]);
      dp[i + 2] = Math.min(dp[i] + Math.abs(h[i] - h[i + 2]), dp[i + 2]);

      //        if (i - 2 >= 0 && i + 2 < ashiba.length) {
      //          dp[i + 1] = Math.min(Math.abs(dp[i - 1] - ashiba[i + 1]), dp[i + 1]);
      //        }
    }

    System.out.println(dp[n - 1]);
  }
}


Measured memory_bytes: 52772
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

string s;ll n,ans,d,md=1e9+7,a[10004],dp[10004][111];

ll solve(ll i,ll sum){
    if(i==n)return (sum==0);
    ll &ret=dp[i][sum];
    if(ret!=-1)return ret;
    ret=0;
    for(ll j=0;j<10;j++){
        ret=(ret+solve(i+1,(sum+j)%d))%md;
    }
    return ret;
}
int main(){
    cin>>s>>d;
    n=s.size();
    for(ll i=0;i<n;i++){
        a[i]=s[i]-'0';
        //cout<<a[i]<<' ';
    }
    //cout<<endl;

    memset(dp,-1,sizeof dp);
    ll sum=0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<a[i];j++){
            ans=(ans+solve(i+1,(sum+j)%d))%md;
        }
        sum=(sum+a[i])%d;
    }

    ans=(ans-1+md+(sum==0))%md;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9472
def answer(n, m, x, y, x_array, y_array):
    max_x = x
    for i in range(n):
        if x_array[i] > max_x:
            max_x = x_array[i]


    min_y = y
    for i in range(m):
        if y_array[i] < min_y:
            min_y = y_array[i]

    if max_x < min_y:
        return "No War"
    else:
        return "War"


[n, m, x, y] = list(map(int, input().split()))
x_array = list(map(int, input().split()))
y_array = list(map(int, input().split()))
    
print(answer(n, m, x, y, x_array, y_array))

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

double calc(double ra, double rb, double xb){
  double h = abs(ra-rb);
  double z = ra+rb;
  double dif = sqrt(z*z-h*h);

  return dif+xb;
}

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

  vector<double> x(n);
  x[0] = r[0];
  for(int i=0;i<n;i++){
    double tx = 0;
    for(int j=0;j<i;j++){
      tx = max(tx, calc(r[i], r[j], x[j]));
    }
    x[i] = tx;
  }

  double left = 0, right = 0;
  for(int i=0;i<n;i++){
    left = min(left, x[i]-r[i]);
    right = max(right, x[i]+r[i]);
  }

  cout << fixed << setprecision(10) << right-left << endl;
}

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

int main()
{
	long long n,c2,c5;
    cin>>n;
    
    if(n%2)
	{
        cout<<0<< endl;
        return 0;
    }
    
    for(long long i=2; i<=n; i*=2)
	{
        c2+=n/i;
    }
    
    for(long long i=10; i<=n; i*=5)
	{
        c5+=n/i;
    }
    
    cout<<min(c2,c5)<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int tmp = n;
  int fn = 0;
  
  while(tmp > 0) {
  	fn += tmp % 10;
    tmp /= 10;
  }
  
  if(n % fn == 0) {
    cout << "Yes" << endl;
  } else {
	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, ok;

int main()
{
    cin >> n;
    if(n % 10 == 7)
        ok = 1;
    if((n/10) % 10 == 7)
        ok = 1;
    if(n / 100 == 7)
        ok = 1;
    if(ok == 1)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 3636
use proconio::input;

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

    for cx in 0..=100 {
        for cy in 0..=100 {
            let ch: i64 = p.iter()
                .filter(|&&(_, _, h)| h != 0)
                .map(|&(x, y, h)| h + (cx - x).abs() + (cy - y).abs())
                .next()
                .unwrap();
            if p.iter().all(|&(x, y, h)| std::cmp::max(0, ch - (cx - x).abs() - (cy - y).abs()) == h) {
                println!("{} {} {}", cx, cy, ch);
            }
        }
    }
}

Measured memory_bytes: 2136