akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (b > x + a) {
		cout << "dangerous";
	}
	else if (a < b) {
		cout << "safe";
	}
	else {
		cout << "delicious";
	}
	return 0;
}

//Ctrl+Aを使わない

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

int main(){
ll n;
cin >> n;
ll 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: 3616
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A, B;
  cin >> A >> B;
  if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
int mod = 1000000007;

int main()
{
    IOS
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int X;
        cin >> X;
        if (X >= 30)
            cout << "Yes";
        else
            cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
const int N=100005;
int n,m;
vector<int>G[N];
int d[N];
int x[N],y[N];
int fa[N];
int getf(int v)
{
	if(v==fa[v]) return v;
	fa[v]=getf(fa[v]);
	return fa[v];
}
bool merge(int u,int v)
{
	int f1=getf(u),f2=getf(v);
	if(f1!=f2)
	{
		fa[f2]=f1;
		return true;
	}
	else return false;
}
vector<pair<int,int> >res;
void kruskal()
{
	for(int i=1;i<=n;i++)
		fa[i]=i;
	for(int i=1;i<=m;i++)
		if(merge(x[i],y[i])) G[x[i]].push_back(y[i]),G[y[i]].push_back(x[i]);
		else res.push_back(make_pair(x[i],y[i])),d[x[i]]++;
	return;
}
void dfs(int u,int father)
{
	for(int v:G[u])
	{
		if(v==father) continue;
		dfs(v,u);
		if(d[v]&1) res.push_back(make_pair(v,u)),d[v]++;
		else res.push_back(make_pair(u,v)),d[u]++;
	}
	return;
}
int main()
{
	scanf("%d%d",&n,&m);
	if(m&1)
	{
		printf("-1");
		return 0;
	}
	for(int i=1;i<=m;i++)
		scanf("%d%d",&x[i],&y[i]);
	kruskal();
	dfs(1,0);
	for(auto [u,v]:res)
		printf("%d %d\n",u,v);
	return 0;
}

Measured memory_bytes: 19196
#include <stdio.h>
#include <math.h>
double pi = 3.14159265358979323846;
double l = 0, r = pi / 2, m;
double a, b, x;
double S(double t) {
	if (a * tan(t) < b)return(a * b - 0.5 * a * a * tan(t));
	else return 0.5 * b * b / tan(t);
}
int main() {
	scanf("%lf%lf%lf", &a, &b, &x);
	x /= a;
	while ((l + 0.0000000001) < r) {
		m = (r + l) / 2;
		if (S(m) <= x)r = m;
		else l = m;
	}
	printf("%.10lf\n", r * 180 / pi);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    int coin = 0;
    if(a>b){
        coin = coin + a;
        a--;
    }else{
        coin = coin + b;
        b--;
    }
    if(a>b){
        coin = coin + a;
        a--;
    }else{
        coin = coin + b;
        b--;
    }
    printf("%d\n", coin);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

int main() {
  int N,M,u,v,S,T;
  cin >> N >> M;
  vector<vector<int>> g(N);
  rep(i,M) {
    cin >> u >> v;
    u--;v--;
    g[u].push_back(v);
  }
  cin >> S >> T;
  S--;T--;

  priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>> pq;
  vector<vector<ll>> ans(N,vector<ll> (3,LONG_LONG_MAX/100));
  pq.push({0,S,0});//距離、場所、状態,from

  while (!pq.empty()) {
    auto t = pq.top();
    pq.pop();
    if (ans[t[1]][t[2]]>t[0]){
      ans[t[1]][t[2]] = t[0];
      for (auto e:g[t[1]]) {
        pq.push({t[0] + 1 ,e ,(t[2]+1)%3});
      }
    }
  }
  int res = LONG_LONG_MAX/100>ans[T][0]?ans[T][0]/3:-1;
  cout << res << endl;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B > C+D)
    cout << "Left" <<endl;
  if(A+B == C+D)
    cout << "Balanced" <<endl;
  if(A+B < C+D)
    cout << "Right" <<endl;
}


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


bool isPrime(int number) {
    for(int i = 2; i < number; i++) {
      if(number % i == 0) return false;
    }
  return true;
}

int main() {
  int num; cin >> num;
  
  int ans = num;
  while(!isPrime(ans)) {
    ans++;
  }
  
  cout << ans << endl;
  
  return 0; 
}


Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

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

ll func(ll a, ll b, ll c) {
	ll smax, smin;
	smax = max(a, b);
	smax = max(smax, c);
	smin = min(a, b);
	smin = min(smin, c);
	return smax - smin;
}
bool dp[101][10001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,s[110],ans = 0;
	scanf("%d", &N);
	REP(i,N)scanf("%d", &s[i]);
	dp[0][0] = true;
	for (int i = 1; i <= N;i++) {
		for (int j = 0; j < 10000; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j >= s[i - 1]) {
				dp[i][j] |= dp[i - 1][j - s[i-1]];
			}
			else {
//				if(j<=30)cout << j << "<" << s[i - 1] << endl;
			}
			//		if(j<=30)cout << "dp[" << i << "][" << j << "]=" << dp[i][j] << endl;
			if (i == N && dp[i][j] && j % 10 != 0) ans = j;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
n = int(input())
ans = n
# 6**k　円を6回引き出すのは 6**(k+1)で代用できる.
# よって A円を引き出すには, 6**k 円を(A//6**i)%6 回引き出せば良い.
for i in range(n+1):
    # 6, 6**2, 6**3, ... で計i円, 
    # 9, 9**2, 9**3, ... で計n-i円引き出す.
    cnt, p6, p9 = 0, i, n-i
    while p6 > 0:
        cnt += p6 % 6
        p6 //= 6
    while p9 >0:
        cnt += p9 %9
        p9 //= 9
    if cnt < ans:
        ans = cnt
print(ans)

Measured memory_bytes: 3060
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // input
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] s = new String[n];
        HashMap<String, String> h = new HashMap<String, String>();
        for(int i=0; i<n; i++) {
            s[i] = sc.nextLine();
            h.put(s[i], "a");
        }
        int ans = h.size();
        System.out.println(ans);
    }
}


Measured memory_bytes: 80156
#include<iostream>
using namespace std;
char s[10][10];
void func(int x,int y){
	if(s[y][x]=='1'){
		s[y][x]='0';
		for(int i=x-3;i<x+4;i++){
			if(i==x||i<0||i>7)
				continue;
			else if(s[y][i]=='1'){
				func(i,y);
			}
		}
		for(int i=y-3;i<y+4;i++){
			if(i==y||i<0||i>7)
			continue;
			else if(s[i][x]=='1'){
				func(x,i);
			}
		}
	}
}
int main(){
	int n,x,y,temp;
	cin>>n;
	temp=n;
	while(n-->0){
		for(int i=0;i<8;i++){
			cin>>s[i];
		}
		cin>>x;
		cin>>y;
		func(x-1,y-1);
		cout<<"Data "<<temp-n<<':'<<endl;
		for(int i=0;i<8;i++)
		cout<<s[i]<<endl;
	}
	return 0;
}
		

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int a = sc.nextInt();
      String op = sc.next();
      int b = sc.nextInt();
      if(op.equals("?")) break;
      if(op.equals("+")) System.out.println(a+b);
      if(op.equals("-")) System.out.println(a-b);
      if(op.equals("*")) System.out.println(a*b);
      if(op.equals("/")) System.out.println(a/b);
    }
  }
}



Measured memory_bytes: 26396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int count = 0;
		while(a>=3){
			a -= 3;
			count++;
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		// 単一行の入力
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str = null;
		try {
			str = in.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}

		String[] tmp = str.split(" ");
		String s = tmp[1];
		System.out.println("A" + s.substring(0, 1) + "C");

	}
}


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


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


int main() 
{
    long long a, b, k;
    cin >> a >> b >> k;
    if(a+b<=k)
    {
        cout << 0 << " " << 0 << endl;
    }
    else if(a<k)
    {
        cout << 0 << " " << b - (k - a) << endl;
    }
    else
    {
        cout << a - k << " " << b << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int h,w;cin>>h>>w;
  char mp[h][w];
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      cin>>mp[i][j];
    }
  }
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      if(mp[i][j] == '#')continue;
      int tmp = 0;
      if(i != 0 && j != 0)if(mp[i-1][j-1]=='#')tmp++;
      if(i != 0)if(mp[i-1][j]=='#')tmp++;
      if(i != 0 && j!=w-1)if(mp[i-1][j+1]=='#')tmp++;
      if(j != 0)if(mp[i][j-1]=='#')tmp++;
      if(j!=w-1)if(mp[i][j+1]=='#')tmp++;
      if(i!=h-1 && j != 0)if(mp[i+1][j-1]=='#')tmp++;
      if(i!=h-1)if(mp[i+1][j]=='#')tmp++;
      if(i!=h-1 && j!=w-1)if(mp[i+1][j+1]=='#')tmp++;
      mp[i][j] = '0'+tmp;
    }
  }
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      cout << mp[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<(type)>
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"

/*##################################################################################*/

/*
int prime[1000000] = {0} ;
vector < vector < int >  > fact(1000001);
void calculateprime()
{
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*2 ; j <= 1000000 ; j += i )
            {
                fact[j].pb(i);
            }
        }
    }
}
*/

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

bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

ll fib(int n)
{
  ll a = 0, b = 1, c, i;
  if( n == 0)
    return a;
  for (i = 2; i <= n; i++)
  {
    c = (a + b);
    a = b;
    b = c;
  }
  return b;
}


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

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(vector<int> &arr, int n)
{
    ll ans = arr[0];

    for (ll i = 1; i < n; i++)
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));

    return ans;
}


ll powerwithmod(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


bool comp(const pair<int,int> &a , const pair<int,int> &b){
    return a.first < b.first;
    if(a.first == b.first)  return a.second < b.second;
}


void solve(){
    int n,k;
    in(n)>>k;
    int arr[n];
    f(i,n)  in(arr[i]);
    sort(arr,arr+n);
    ll sum = 0;
    f(i,k)  sum += arr[i];
    out(sum);
}
int main() {
    fast();
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  in(int, n);
  V<int> a(n);
  rep(i, n) cin >> a[i];
  out(*max_element(all(a)) - *min_element(all(a)));
}

Measured memory_bytes: 3652
import sys
input=sys.stdin.readline
N,Y=map(int,input().split())
for i in range(N+1):
  for j in range(N-i+1):
    k=N-i-j
    if 10000*i+5000*j+1000*k==Y:
      print(i,j,k)
      exit()
print("-1 -1 -1")



Measured memory_bytes: 3064
package main

import (
	"fmt"
)

const mod = 1e9 + 7

var ifac, fac []int

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	fac = make([]int, 2e5+1)
	ifac = make([]int, 2e5+1)
	inv := make([]int, 2e5+1)
	fac[0], fac[1] = 1, 1
	ifac[0], ifac[1] = 1, 1
	inv[0], inv[1] = 1, 1
	for i := 2; i < 2e5+1; i++ {
		fac[i] = (fac[i-1] * i) % mod
		inv[i] = (mod - inv[mod%i]*(mod/i)) % mod
		ifac[i] = (ifac[i-1] * inv[i]) % mod
	}

	cnt := 1
	for i := 1; i <= min(k, n-1); i++ {
		c := (comb(n, i) * comb(n-1, i)) % mod
		cnt += c
		cnt %= mod
	}

	fmt.Println(cnt)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func comb(n, r int) int {
	if r > n {
		return 0
	} else if r == 0 || r == n {
		return 1
	}
	t := (ifac[n-r] * ifac[r]) % mod
	res := (t * fac[n]) % mod
	if res < 0 {
		res += mod
	}
	return res
}


Measured memory_bytes: 5376
<?php
    $lines = array();
    $ary = array();
    while($line = trim(fgets(STDIN))){
        $ary[] = $line;
    }
    $maxline = $ary[0];
    for($i = 1;$i <= $maxline;$i++){
        $lines = explode(" ",$ary[$i]);
        for($j = 1;$j < count($lines);$j++){
            if($lines[0] < $lines[$j]){
                $tmp = $lines[0];
                $lines[0] = $lines[$j];
                $lines[$j] = $tmp;
            }
        }
        if($lines[0]*$lines[0] == $lines[1]*$lines[1] + $lines[2]*$lines[2]){
                echo "YES\n";
        }else{
                echo "NO\n";
        }
    }


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

int main()
{
    ll N;
    ll pre = 0;
    ll ans = 0;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        ll temp;
        cin >> temp;
        if (temp < pre)
        {
            ans += (pre - temp);
        }

        pre = temp;
    }
    cout << ans + pre << endl;
}

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

int main(){
	int N, D;
	cin >> N >> D;
	
	double count = N/(2*D+1);
	int ans = count;
	
	if(N%(2*D+1)!=0)	ans++;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
N = int(input())
md = make_divisors(N)

# print(md)

ans = 0
for i in md:
  m = N // i - 1
  if m != 0 and N // m < m:
    ans += m

print(ans)

Measured memory_bytes: 3268
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M, D = rl()
if D == 0:
    print((M-1) / N)
else:
    answer = 2 * (N-D) * (M-1) / N**2
    print(answer)
# 49

Measured memory_bytes: 12508
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    int N;
    int K;
    cin >> N >> K;
    vector<int> a(N);
    
    bool result=true;

    rep(i,N){
        cin >> a[i];
    
    }
    
        rep(i,K){
            vector<int> b(N+1);
            rep(i,N+1)b[i]=0;
            
            rep(j,N){
                b[j]=0;
            }
            rep(j,N){
                int l=max(0,j-a[j]);
                int r=min(N,j+a[j]+1);
                b[l]++;
                b[r]--;
            }
            FOR(j,N,1)b[j]+=b[j-1];
            
            b.pop_back();
            if(a==b)break;
            a=b;
        }
    

    rep(i,N)cout << a[i] << " ";
    cout << endl;
}

Measured memory_bytes: 4808
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), W = sc.nextInt();
        int[][] A = new int[H][W];
        Queue Q = new Queue();
        for (int h = 0; h < H; h++) {
            String s = sc.next();
            for (int w = 0; w < W; w++) {
                int b = A[h][w] = s.charAt(w) == '#' ? 1 : 0;
                if (b == 1) Q.add(0, h, w);
            }
        }
        int ans = 0;
        while (!Q.isEmpty()) {
            Que q = Q.poll();
            ans = q.n;
            if (q.y > 0 &&     A[q.y - 1][q.x] == 0) A[q.y - 1][q.x] = Q.add(q.n + 1, q.y - 1, q.x);
            if (q.y < H - 1 && A[q.y + 1][q.x] == 0) A[q.y + 1][q.x] = Q.add(q.n + 1, q.y + 1, q.x);
            if (q.x > 0 &&     A[q.y][q.x - 1] == 0) A[q.y][q.x - 1] = Q.add(q.n + 1, q.y, q.x - 1);
            if (q.x < W - 1 && A[q.y][q.x + 1] == 0) A[q.y][q.x + 1] = Q.add(q.n + 1, q.y, q.x + 1);
        }
        System.out.println(ans);
        sc.close();
    }
}
class Que {
    int n, x, y;
    Que(int n, int y, int x) {
        this.n = n;
        this.x = x;
        this.y = y;
    }
}
class Queue {
    Deque<Que> Q;
    Queue() {
        Q = new ArrayDeque<>();
    }
    int add(int n, int y, int x) {
        Q.add(new Que(n, y, x));
        return n;
    }
    boolean isEmpty() { return Q.isEmpty(); }
    Que poll() { return Q.poll(); }
}


Measured memory_bytes: 68524
def is_fin(x,y):
    if abs(x-y)==1:
        return False
    return True
n,a,b = map(int,input().split())
turn = 0
while is_fin(a,b):
    if turn%2==0:
        a += 1
    else:
        b -= 1
    turn += 1
print('Alice' if turn%2==1 else 'Borys')

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

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if ( n == 0 ) break;
    char **ch = new char*[n];
    for (int i=0; i<n; i++)
    {
      ch[i] = new char[2];
    }

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

    int m;
    cin >> m;
    for (int i=0; i<m; i++)
    {
      char str;
      cin >> str;
      for (int j=0; j<n; j++)
      {
        if ( str == ch[j][0] )
        {
          str = ch[j][1];
          break;
        }
      }
      cout << str;
    }
    cout << endl;

    for (int i=0; i<n; i++)
    {
      delete[] ch[i];
    }
    delete[] ch;
  }
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <bitset>  
using namespace std;

//======================================================
#define for1(i,n)  for (int i = 0; i < (int)(n); ++i)
#define for2(i,n)  for (int i = 1; i <=(int)(n); ++i)
#define forr1(i,n)  for (int i = n - 1 ;i <= 0; --i)
#define forr2(i,n)  for (int i = n  ;i < 0; --i)
#define all(v)	   ((v).begin()), ((v).end())
#define allr(v)	   ((v).rbegin()), ((v).rend())
#define clr(v,d)   memset(v, d, sizeof(v))
#define ull        unsigned long long
#define MP(a,b)	   make_pair(a,b)
#define S          second
#define F          first
#define PI         3.14159265359
#define ll         long long
#define sz(v)	   v.size()
#define pb         push_back
#define pp         pop_back
#define bgn        begin
#define N          100000+5
#define	MOD        1e9+7
#define inf        1e18
//======================================================
int dx[] = { 0,  0, 1, -1 ,  1,  -1,  1,  -1 };
int dy[] = { 1, -1, 0,  0 , -1,   1,  1,  -1 };
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
	while (b--) ret = (ret * a);
	return ret;
}
//======================================================

int a[100000+5];
int b[100000+5];
int c[100000+5];
long long dp[100000+5][4];
long long  findMin(int index, int type)
{
	if (index == -1)
	{
		return 0;
	}
	if (dp[index][type] != -1)
		return dp[index][type];

	long long r = INT_MIN;
	if (type != 0)
	{
		r = max(findMin(index - 1, 0)+a[index],r);
	}
	if (type != 1)
	{
		r = max(findMin(index - 1, 1)+b[index], r);

	}
	if (type != 2)
	{
		r = max(findMin(index - 1, 2)+c[index], r) ;

	}
	dp[index][type] = r;
	return r;
}



int main()
{
	int n;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		int ai , bi,ci;
		cin >> ai >> bi >> ci;
		a[i] = ai;
		b[i] = bi;
		c[i] = ci;
	}
	for (size_t i1 = 0; i1 < 100000 + 5; i1++)
	{
		for (size_t i2 = 0; i2 < 4; i2++)
		{
			dp[i1][i2] = -1;
		}
	}
	cout << findMin(n - 1, 3);

}




Measured memory_bytes: 13604
N = int(input())
S = input()

b, w = 0, 0
for i in range(N):
    if S[i] == '#':
        b += 1
    else:
        w += 1

ans = [0 for _ in range(N+1)]
ans[0], ans[-1] = w, b
for i in range(1, N):
    if S[i-1] == '#':
        ans[i] = ans[i-1] + 1
    else:
        ans[i] = ans[i-1] - 1

print(min(ans))

Measured memory_bytes: 17300
#include<bits/stdc++.h>
    using namespace std;
int main()
{
long long s=0;int x;
 cin>>x;long long sum=0;
 for(int i=0;i<x;i++)
 {long long a,b;cin>>a>>b;
     if(a>s)
     {
         s=a;
         sum=a+b;
     }
 }
 cout<<sum<<endl;
 return 0;

}
    

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

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] H = Console.ReadLine().Split(' ');

            int[] dp = new int[N];

            for(int i = 1; i < N; i++)
            {
                dp[i] = int.MaxValue;
            }

            for(int i = 1; i < N; i++)
            {
                if (i == 1)
                {
                    dp[i] = Math.Min(dp[i], dp[i - 1] + Math.Abs(int.Parse(H[i]) - int.Parse(H[i - 1])));
                }
                else
                {
                    int[] a = { dp[i], dp[i - 1] + Math.Abs(int.Parse(H[i]) - int.Parse(H[i - 1])), dp[i - 2] + Math.Abs(int.Parse(H[i]) - int.Parse(H[i - 2])) };
                    
                    for(int j = 1; j < a.Length; j++)
                    {
                        if(a[j] < dp[i])
                        {
                            dp[i] = a[j];
                        }
                    }
                }
            }

            Console.WriteLine(dp[N - 1]);
        }
    }
}

Measured memory_bytes: 24928
local function gcd(a,b)
    if b>0 then
        return gcd(b,a%b)
    else
        return a
    end
end

local n,k=io.read("n","n")
local amax=0
local agcd=0
for i=1,n do
    local a=io.read("n")
    agcd=gcd(a,agcd)
    amax=math.max(a,amax)
end
print((k<=amax and k%agcd==0) and "POSSIBLE" or "IMPOSSIBLE")

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

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    if((a-k) < 0){
        k -= a;
        a = 0;
        b -= k;
        if(b < 0) b = 0;
    }else{
        a -= k;
    }
    cout << a << " " << b << endl;
}

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

using namespace std;

int dp0[110][5];
int dp1[110][5];

int main(){
    string s;
    int k, ans = 0;
    cin >>s>>k;

    int len =s.length();
    dp1[0][0] = 1;

    for(int i=0;i<len;i++){
        for(int c=0;c<=k;c++){
            dp0[i+1][c] += dp0[i][c];
            dp0[i+1][c+1] += dp0[i][c] * 9;

            for(int j=0;j<s[i]-'0';j++){
                if(j==0)
                    dp0[i+1][c] += dp1[i][c];
                else
                    dp0[i+1][c+1] += dp1[i][c];
            }

            if(s[i]-'0'){
                dp1[i+1][c+1] += dp1[i][c];
            }
            else{
                dp1[i+1][c] += dp1[i][c];
            }
        }
    }

    cout <<dp0[len][k] + dp1[len][k]<<endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	final int INF = (int)1e9 + 7;
	int N,W;
	int[] v,w;
	public void solve() {
		N = nextInt();
		W = nextInt();
		v = new int[N];
		w = new int[N];

		for(int i = 0;i < N;i++){
			v[i] = nextInt();
			w[i] = nextInt();
		}

		int[][] dp = new int[N + 1][100 * 100 + 1];
		for(int i = 0;i < N + 1;i++){
			Arrays.fill(dp[i], INF);
		}
		dp[0][0] = 0;
		for(int i = 0;i < N;i++){
			for(int j = 100 * 100;j >= 0;j--){
				if(dp[i][j] != INF && dp[i][j] + w[i] <= W){
					dp[i + 1][j + v[i]] = Math.min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
				}
				dp[i + 1][j] = Math.min(dp[i + 1][j],dp[i][j]);
			}
		}
		int ans = 0;
		for(int i = 100 * 100;i >= 0;i--){
			if(dp[N][i] != INF){
				ans = i;
				break;
			}
		}

		out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

Measured memory_bytes: 29332
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);
const int MAXN = 1e5 + 5;
ll num[MAXN];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    for(int i = 0; i <n ; i++)
    {
        cin >> num[i];
    }
    ll ans = 0;
    for(int i = 0; i < n-1; i++)
    {
        if((num[i + 1] - num[i]) * a > b)
        {
            ans += b;
        }
        else
        {
            ans += (num[i + 1] - num[i]) * a;
        }
        
    }
    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <cstdio> 
using namespace std; //This makes the code much more cleaner

int main()
{
	
/*
	int a, b, c, d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	int area = a*b;
	int areatwo = c*d;
		if (area>=areatwo)
		{
			printf("%d", area);
		}
		else
		{
			printf("%d",areatwo);
		}
		*/
	//--------------------------------------------

	/*
	int a,b;
	scanf("%d %d", &a, &b);
	if (a==1 and b!=1)
	{

		printf("Alice");

	}
	else if (b == 1 and a!=1)
	{

		printf("Bob");

	}
	else if (a>b)
	{

		printf("Alice");

	}
	else if (a == b)
	{

		printf("Draw");
	}
	else
	{

		printf("Bob");
	}

	*/

	int a, b;
	

	scanf("%d %d",&a,&b);
	int mult = a + b;

	if (mult >= 10)
	{
		printf("error");
	}
	else
	{

		printf("%d",mult);
	}

















	return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int sum=0,n,N;
  cin>>n;
  N=n;
  while(n!=0){
    sum+=n%10;
    n=(n-n%10)/10;
  }
  if(N%sum==0)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func partseFloat(s string) (n float64) {
	n, _ = strconv.ParseFloat(s, 64)
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := getInt(), getInt(), getInt()

	n := []int{a, b, c}
	sort.Ints(n)

	fmt.Println(10*n[2] + n[0] + n[1])
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Objects;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CHonestOrUnkind2 solver = new CHonestOrUnkind2();
        solver.solve(1, in, out);
        out.close();
    }

    static class CHonestOrUnkind2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            ArrayList<Pair<Integer, Boolean>>[] info = new ArrayList[n];
            int max = 0;
            for (int i = 0; i < n; i++) {
                int m = in.nextInt();
                info[i] = new ArrayList<>();
                for (int j = 0; j < m; j++) {
                    Pair<Integer, Boolean> p = new Pair<>(in.nextInt() - 1, in.nextLong() == 1);
                    info[i].add(p);
                }
            }

            // System.out.println(Arrays.toString(info));

            for (int i = 0; i < Math.pow(2, n); i++) {
                boolean[] truth = new boolean[n];
                int x = i;
                for (int j = 0; j < n; j++) {
                    truth[j] = x % 2 == 1;
                    x /= 2;
                }
                // out.println(Arrays.toString(truth));

                max = Math.max(max, make(info, truth));
            }

            out.println(max);

        }

        int make(ArrayList<Pair<Integer, Boolean>>[] info, boolean[] truth) {
            boolean f = true;
            int res = 0;
            for (int i = 0; i < truth.length; i++) {
                if (truth[i]) res++;
            }

            for (int i = 0; i < info.length; i++) {
                if (!truth[i]) {
                    continue;
                }
                for (Pair<Integer, Boolean> p : info[i]) {
                    if (p.u != truth[p.t]) {
                        f = false;
                    }
                    if (!f) return -1;
                }
            }

            return res;
        }

    }

    static class Pair<T, U> {
        public T t;
        public U u;

        public Pair(T t, U u) {
            this.t = t;
            this.u = u;
        }

        public String toString() {
            return "Pair{" +
                    "t=" + t.toString() +
                    ", u=" + u.toString() +
                    '}';
        }

        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair<?, ?> pair = (Pair<?, ?>) o;
            return Objects.equals(t, pair.t) &&
                    Objects.equals(u, pair.u);
        }

        public int hashCode() {
            return Objects.hash(t, u);
        }

    }
}



Measured memory_bytes: 28344
#include<stdio.h>
int main(void){
	int m,f,r;
	int sum=0;
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1&&f==-1&&r==-1){
			break;
		}
		if(m<=50&&f<=50&&r<=100){
			sum=m+f;
			
			if(m==-1||f==-1){
				printf("F\n");
			}else if(sum>=80){
				printf("A\n");
			}else if(sum<80&&sum>=65){
				printf("B\n");
			}else if(sum<65&&sum>=50){
				printf("C\n");
			}else if(sum<50&&sum>=30&&r>=50){
				printf("C\n");
			}else if(sum<50&&sum>=30){
				printf("D\n");
			}else if(sum<30){
				printf("F\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2076
#include <stdio.h>
int main(){
  int i ,n ,a ,b ,ans1=0 ,ans2=0;
  while( scanf( "%d" ,&n ) != EOF ){
    if( n == 0 ){
      break;
    }

    for( i=0 ; i<n ; i++ ){
      scanf( "%d %d" ,&a ,&b );
      
      if( a > b ){  // Aの勝ち
	ans1 = ans1 + a + b;
      }
      
      else if( a < b ){  // Bの勝ち
	ans2 = ans2 + a + b;
      }
      
      else if( a == b){  // 引き分け
	ans1 = ans1 + a;
	ans2 = ans2 + b;
      }
      
    }
    
    printf( "%d %d\n" ,ans1 ,ans2 );
    ans1=0;
    ans2=0;
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int A,B;
    cin >> A >> B;
    fin(A*B);
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int x,n;
  cin>>x>>n;
  vector<int> p(101);
  for(int i=0;i<n;i++) {
  	int idx;
    cin>>idx;
    p[idx]=1;
  }
  for(int i=0;i<=100;i++){
  	if(!p[x-i]) {
      cout<<x-i;
      return 0;
    }
    if(!p[x+i]) {
      cout<<x+i;
      return 0;
    }
  }
}

Measured memory_bytes: 3608
n = int(input())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
a = [abs(X[i] - Y[i]) for i in range(n)]
print(sum(a))
print((sum([x**2 for x in a]))**0.5)
print((sum([x**3 for x in a]))**(1/3))
print(max(a))

Measured memory_bytes: 7800
#include<stdio.h>
int main(void)
{
    int n;
    int i,j,t=0,h=0,d;
    char ct[100],ch[100];
     
    scanf("%d",&n);
     
    for(i=0;i<n;i++)
    {
        scanf("%s %s",ct,ch);
         
        j=0;
        while(ct[j]!='\0' || ch[j]!='\0')
        {
            if(ct[j]<ch[j])
            {
                h++;
                break;
            }
            else if(ct[j]>ch[j])
            {
                t++;
                break;
            }
            j++;
        }
    }
    d=n-h-t;
     
    printf("%d %d\n",d+t*3,d+h*3);
     
    return 0;
}


Measured memory_bytes: 2072
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#define MAX 101
#define NIL 0
#define NONE (-3)
#define FIRST 1
#define SECOND 2
int d[MAX],M[MAX][MAX],queue[MAX],head,tail,datanum;//Mは隣接しているかの確認。dは頂点からの距離。distance headはint mainの一番最初に初期化
void q_push(int n){
  queue[head++] = n;
}
int q_pop(){
  int temp = queue[tail++];
  return temp;
}

void bfs(int first){
  int i,j;
  for(i=1;i<=datanum;i++){
    d[i] = NONE;//NONE = -3 何も入っていない状態
  }
  d[first] = 0;
  q_push(first);
  while(head != tail){
    i = q_pop();
      for(j=1;j<=datanum;j++){
	if(d[j] != NONE)continue;
	if(d[i] == NONE)continue;
	if(M[i][j] == 0)continue;
	if(i == j)continue;
	d[j] = d[i] + 1;
	q_push(j);
      }
  }  
}

int main(){
  int i,j,k,id,u,v,temp;//idは頂点の番号。uは出字数。tempは隣接する頂点の番号
  head = tail = 0;
  scanf("%d",&datanum);
  for(i=1;i<=datanum;i++)
    for(j=1;j<=datanum;j++){
      M[i][j] = 0;
    }
  for(i=0;i<datanum;i++){
    scanf(" %d %d",&id,&u);
    for(j=0;j<u;j++){
      scanf(" %d",&temp);
      M[id][temp] = 1;
    }
  }
  bfs(1);//1からスタート
  for(i=1;i<=datanum;i++){
    printf("%d",i);
    if(d[i] == NONE)printf(" -1\n");
    else printf(" %d\n",d[i]);
      }
 
  return 0;
}



Measured memory_bytes: 2104
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;
    int mx = 0, dif = 0, cnt = 0;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    for(int i = n-1; i >= 0; i--){
        chmax(mx, a[i]);
        if(mx - a[i] > dif){
            dif = mx - a[i];
            cnt = 1;
        }
        else if(mx - a[i] == dif){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
@dp=[]
@dp[0]=0
@dp[1]=0
@dp[2]=0


def sum_count(n)
  if n<3
    @dp[n]=0
    return 0
  else
    if @dp[n]
      return @dp[n]
    else
      sum=0
      (0..n-3).each do |k|


        sum += sum_count(k)
      end
      @dp[n]=1+sum
    end
  end
end
s=gets.chomp.to_i
puts sum_count(s)%1000000007
# puts @dp

Measured memory_bytes: 14536
def shuffle(card_list, p, c)
  start = card_list.length - (p + c -1)
  take_out_list = card_list.slice!(start, c)
  card_list.concat(take_out_list)
end
loop do
  card_num, shuffle_num = gets.chomp.split(" ").map {|item| item.to_i }
  if card_num == 0 && shuffle_num == 0
   exit
  end
  card_list = [*1..card_num] # [*1..5] => [1,2,3,4,5]
  shuffle_num.times do |i|
   p, c = gets.chomp.split(" ").map {|item| item.to_i }
   card_list = shuffle(card_list, p, c)
  end
  puts card_list.last
end


Measured memory_bytes: 7148
# include <bits/stdc++.h>
using namespace std ;
int main () {
  int i,j,n,m,s=0,k,l;
  cin >> n;
  cin >> m;
  int a[m-1];
  for(i=0;i<m;i++){
    a[i] = 0;
  }
  for(i=0;i<n;i++){
    cin >> k;
    for(j=0;j<k;j++){
      cin >> l;
      a[l-1]++;
    }
  }
  for(i=0;i<m;i++){
    if(a[i]==n){s++;}
  }
  cout << s << endl;
      
  return 0;
}

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

int n, w, h;
int s, t;
int memo[105][105] = {0};

int solve();

int main() {
  int i, j, x, y;
  while(1) {
    cin >> n;
    if(n == 0) break;
    cin >> w >> h;
    for(i = 0; i < n; ++i) {
      cin >> x >> y;
      ++memo[--x][--y];
    }
    cin >> s >> t;
    for(i = 0; i < w; ++i)
      for(j = 0; j < h; ++j) {
        if(i != 0) memo[i][j] += memo[i - 1][j];
        if(j != 0) memo[i][j] += memo[i][j - 1];
        if(i != 0 && j != 0)
          memo[i][j] -= memo[i - 1][j - 1];
      }
    cout << solve() << endl;
    for(i = 0; i < w; ++i) {
      for(j = 0; j < h; ++j) memo[i][j] = 0;
    }
  }
  return 0;
}

int solve() {
  int i, j, ans = 0, now;
  for(i = 0; i + s - 1 < w; ++i)
    for(j = 0; j + t - 1 < h; ++j) {
      now = 0;
      now += memo[i + s - 1][j + t - 1];
      if(i != 0) now -= memo[i - 1][j + t - 1];
      if(j != 0) now -= memo[i + s - 1][j - 1];
      if(i != 0 && j != 0) now += memo[i - 1][j - 1];
      ans = max(ans, now);
    }
  return ans;
}


Measured memory_bytes: 3044
import sys
input = sys.stdin.readline

def main():
    while True:
        N = int(input())
        if N == 0:
            break
        ss = list(map(int, input().split()))
        ave = sum(ss) / N
        ans = 0
        for s in ss:
            ans += (s - ave)**2
        ans = pow(ans/N, 0.5)
        print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  int n,a,b=-1,ans=0;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin >> p[i];
  for(int i=0;i<n;i++) {
    b=max(b,p[i]);
    if(b==p[i]) a=i;
  };
  for(int i=0;i<n;i++) {
    if(a==i) ans+=p[i]/2;
    else ans+=p[i];
  };
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

lint int_max = 1e9;

int main(){
    lint S;
    cin >> S;
    cout << 0 << " " << 0 << " " << int_max << " " << 1 << " " << (int_max * int_max - S) % int_max << " " << (S + int_max - 1) / int_max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
#define INF 10000000
using namespace std;
int main(){
	int n,m,x,b=0,c=0;
	cin >> n >> m >> x;
	for(int i=0;i<m;i++){
		int a;
		cin >> a;
		if(a>x)
			b++;
		else 
			c++;
	}
	cout << min(b,c);
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

def main():
    N,x = map(int, input().split())
    A = list(map(int, input().split()))
    s0 = sum(A)
    if A[0] > x:
        A[0] = x
    for i in range(N-1):
        if A[i] + A[i+1] > x:
            j = A[i] + A[i+1] - x
            A[i+1] -= j
    print(s0-sum(A))

if __name__ == '__main__':
    main()


Measured memory_bytes: 14076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
const int MOD = 1e9+7;
int n,l[N],r[N],f=1,k,ans,inv2;
int fpow(int x,int p){
    int rs=1;
    while(p){
        if(p&1) rs=1LL*rs*x%MOD;
        x=1LL*x*x%MOD; p>>=1;
    }
    return rs;
}
int main(){
    scanf("%d %d",&n,&k); r[n]=n;
    inv2=fpow(2,MOD-2); f=fpow(10,100);
    for(int i=1;i<=n;++i) l[i]=(i+l[i-1])%MOD;
    for(int i=n-1;i>=0;--i) r[i]=(i+r[i+1])%MOD;
    for(int i=k;i<=n+1;++i){
        int p=l[i-1],q=r[n+1-i];
        //printf("%d %d\n",p,q);
        //ans=(ans+1LL*f*i%MOD*(q-p+1+MOD)%MOD+1LL*(q-p+1+MOD)*(p+q)%MOD*inv2%MOD)%MOD;
        //printf("%d\n",ans);
        ans=(1LL*ans+q-p+1+MOD)%MOD;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 5320
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
#define ll long long
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)n; i++)

bool change_flag(bool flag){
  if(flag) return false;
  else return true;
}

int main() {
  int n,m,r, result;
  cin >> n >> m;

  ll t = pow(2, n); 
  int s[n][t];
  int c_num=t/2;
  bool c_flg = true;

  // 1,0の組み合わせを代入していく
  for(int i=0; i<n; i++) {
    for(int j=0; j<t; j++){
      if(c_flg){
        s[i][j]=(int)c_flg;
      } else{
        s[i][j]=(int)c_flg;
      }
      if((j+1)%c_num==0){
        c_flg = change_flag(c_flg);
      }
      // cout << s[i][j] << " ";
    }
    c_num /= 2;
    // cout << endl;
  }

  int k;
  vector<vector<int> > switches;
  rep(i, m){
    cin >> k;
    vector<int> a(k);
    rep(j, k){
      cin >> a[j];
    }
    switches.push_back(a);
  }
  // あまりを入れていく
  vector<int> p(m);
  rep(i, m){
    cin >> p[i];
  }

  int ans = 0, cnt=0;
  rep(i, t){ // t通り試す
    cnt = 0;
    rep(j, m){ // スイッチたちを見ていく
      int s_cnt = 0;
      // cout << "j:" << j << endl;
      rep(k, switches[j].size()){
        // cout << switches[j][k] << " ";
        s_cnt += s[switches[j][k] - 1][i];
      }
      if(s_cnt%2 == p[j]) cnt++;
      // cout << endl;
    }
    // cout << "cnt:" << cnt << endl;
    if(cnt==m) ans++;
  }
  
  cout << ans << endl;

}


Measured memory_bytes: 256