akhauriyash/Code-Regression huggingface dataset:
void main()
{
    long s, w;
    rdVals(s, w);

    writeln(w < s ? "safe" : "unsafe");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    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.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 2724
fun main(args: Array<String>) {
    while (true) {
        val n = readLine()!!.toInt().takeUnless { it == 0 } ?: return
        val a = readLine()!!.split(" ").map { it.toInt() }

        val avg = a.sum().toDouble() / n

        println(a.count { it <= avg })
    }
}


Measured memory_bytes: 45204
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;


int dp[101][4][2];
string s;
int N,K;

int solve(int I,int k,int f)
{
	if( k > K )return 0;
	if( I == N)return k==K;
	int &ans = dp[I][k][f];
	if( ans!=-1 )return ans;
	ans=0;
	if(f)
	{
		for(int i=0;i<s[I]-'0';i++)
		{
			ans+=solve(I+1,k+(i!=0),0);
		}
		ans+=solve(I+1,k+(s[I]!='0'),1);
	}
	else
	{
		for(int i=0;i<10;i++)
		ans+=solve(I+1,k+(i!=0),0);
	}
	return ans;
}
int32_t main()
{
	memset(dp,-1,sizeof(dp));
	cin >> s >> K; N=s.length();
	cout << solve(0,0,1) << endl;
}
	



Measured memory_bytes: 256
n=int(input())
ab = [map(int, input().split()) for _ in range(n)]
a, b = [list(i) for i in zip(*ab)]
a.reverse()
b.reverse()
sum=0
for a,b in zip(a,b):
  a+=sum
  sum+=(b-(a%b))%b
print(sum)

Measured memory_bytes: 62832
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
const long double PI=(acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n){
    cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
  vec[n-1]=vec[n-1]/2;
  int sum=0;
  rep(i,n){
    sum+=vec[i];
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
//////////////////////////////////////////////
///  Fear is temporary, Regret is forever  ///
///               sat7978                  ///
///         extreme      blood             /// 
//////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e6+100;
#define ll long long
#define pb push_back
#define S second
#define F first
void flash(){
    ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(2);
}


int main() {
    flash(); 
    int t;
    t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        int cnt=0;
        for(int i=1;i<n-1;i++){
            if(arr[i]>arr[i-1] && arr[i]<arr[i+1]) cnt++;
            else if(arr[i]>arr[i+1] && arr[i]<arr[i-1]) cnt++;
        }
        cout<<cnt;
    }
    return 0;
}

Measured memory_bytes: 256
N,x = map(int,input().split())
L = list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if L[i]+L[i+1] <= x:
    None
  else:
    k = L[i]+L[i+1]-x
    if L[i+1] >= k:
      L[i+1] = L[i+1]-k
      ans += k
    else:
      L[i] = L[i]+L[i+1]-k
      L[i+1] = 0
      ans = k
print(ans)

Measured memory_bytes: 14052
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
AA = A
BB = B
for i in range(1,N):
    AA[i] += AA[i-1]
for i in range(1,M):
    BB[i] += BB[i-1]
AA = [0] + AA
BB = [0] + BB
import bisect
c = bisect.bisect_right(AA,K)
ans = 0
for i in range(c):
    ans = max(ans, i + bisect.bisect_right(BB,K-AA[i]) - 1)
print(ans)

Measured memory_bytes: 111148
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	if( (b-a)%2==1){
		cout<<"Borys"<<endl;
		return 0;
	}
	else{
		cout<<"Alice"<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
inputs = Array.new(STDIN.gets.chomp.to_i) { STDIN.gets.chomp.split.map(&:to_i).sort.reverse.map { |i| i**2 } }
inputs.each do |i|
  result = i[0] == i[1] + i[2] ? 'YES' : 'NO'
  puts result
end

Measured memory_bytes: 8800
def main():
    import numpy as np
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    A=np.array(A)

    def cnt_shake(x): #握手の組であって合計パワーがx以上となる組みの数
        return n**2-np.searchsorted(A,x-A).sum()
  
    right=2*10**5+1
    left=-1
    while right-left>1:
        mid=(left+right)//2
        if cnt_shake(mid)<m:
            right=mid
        else:
            left=mid
    
    border=left  #border以上の握手をする
    C=n-np.searchsorted(A,border+1-A)
    B=np.cumsum(A[::-1])
    cnt=C.sum()
    s=np.sum(A*C)+border*(m-cnt)+B[C[np.where(C>0)]-1].sum()
    print(s)
if __name__=='__main__':
    main()


Measured memory_bytes: 23396
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=200200,P=1e9+7,iv2=P+1>>1;
int n,x,S,ans;
int a[N],f[N],g[N],h[N],t[N],L[N],R[N],c[3][N];
void chk(int&x){x-=P;x+=(x>>31)&P;}
int qpw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%P)if(y&1) z=1ll*z*x%P;return z;} 
void add(int k,int x,int y){ for(;x<=n;x+=x&-x) chk(c[k][x]+=y);}
int ask(int k,int x){int y=0;for(;x;x-=x&-x) chk(y+=c[k][x]); return y;}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	FOR(i,1,n) scanf("%d",&a[i]),f[a[i]]++;
	ROF(i,n,1) f[i]+=f[i+1];
	FOR(i,1,n)if((f[i]-=n-i)<=0) return puts("0"),0;
	S=1;g[0]=1;
	FOR(i,1,n){
		g[i]=qpw(f[i],P-2);t[i]=t[i-1]; 
		f[i]^1?g[i]=1ll*g[i]*(f[i]-1)%P:t[i]++;
		g[i]=1ll*g[i]*g[i-1]%P;
		h[i]=qpw(g[i],P-2);
		S=1ll*S*f[i]%P;
	}
	t[0]=t[n+1]=-1;
	FOR(i,1,n) L[i]=t[i]^t[i-1]?i:L[i-1];
	ROF(i,n,1) R[i]=t[i]^t[i+1]?i:R[i+1];
	FOR(i,1,n){
		x=a[i];
		chk(ans+=1ll*g[x]*(ask(0,x)-ask(0,L[x]-1)+P)%P);
		chk(ans+=P-1ll*h[x]*(ask(1,R[x])-ask(1,x)+P)%P);
		chk(ans+=(ask(2,n)-ask(2,x)+P)%P);
		add(0,x,h[x]);
		add(1,x,g[x]);
		add(2,x,2);
		//cout<<ans<<'\n';
	}
	cout<<1ll*ans*iv2%P*S%P<<'\n';
}

Measured memory_bytes: 8064
//            ____             ____
//           /@@@@\           |@@@@|      ____
//          /@@@@@@\          |@@@@|     |@@@@|
//         /@@@@@@@@\         |@@@@|   __|@@@@|___    ____       ____      ___  _________     ____        ____    ____________      ___  _________     ____         ____
//        /@@@@/\@@@@\        |@@@@|   @@@@@@@@@@@   |@@@@|     |@@@@|    |@@@\/@@@@@@@@@\   (@@@@\      /@@@@)  /@@@@@@@@@@@@|    |@@@\/@@@@@@@@@\   (@@@@\       /@@@@)
//       /@@@@/  \@@@@\       |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|    \@@@@@|   \@@@@\    /@@@@/  |@@/     |@@@@|    |@@@@|    \@@@@@|   \@@@@\     /@@@@/
//      /@@@@(____)@@@@\      |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|    \@@@@\  /@@@@/            |@@@@|    |@@@@|     |@@@@|    \@@@@\   /@@@@/
//     /@@@@@@@@@@@@@@@@\     |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|     \@@@@\/@@@@/    /@@@@@@@@@@@@@|    |@@@@|     |@@@@|     \@@@@\ /@@@@/
//    /@@@@@@@@@@@@@@@@@@\    |@@@@|     |@@@@|___   |@@@@|____/@@@@@|    |@@@@|     |@@@@|      \@@@@@@@@/    (@@@@(   )@@@@@|    |@@@@|     |@@@@|      \@@@@|@@@@/
//   /@@@@/          \@@@@\   |@@@@|     |@@@@@@@@    \@@@@@@@@@@@@@@|    |@@@@|     |@@@@|       \@@@@@@/      \@@@@\_/@@@@@@|    |@@@@|     |@@@@|       \@@@@@@@/
//  /@@@@/            \@@@@\  |@@@@|      \@@@@@@/      \@@@@@/  \@@@|    |@@@@|     |@@@@|        )@@@@/        \@@@@@@@/\@@@|    |@@@@|     |@@@@|        \@@@@@/
//                                                                                                (@@@@/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

//-----------------------------------------------
#define all(x)  x.begin(), x.end()
#define sz(x)   (int)x.size()
#define sq(x)   (x) * (x)
#define fr      first
#define sc      second
//-----------------------------------------------
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pli = pair<ll, int>;

const int N = 300 * 1000 + 5;
const ll mod = 1000000007;
const ll INF = 1000000 * 1ll * 10000000 * 1ll * 1000;
const ld pi = acosl(-1.0);

int n, d;

void input() {
    cin >> n >> d;
}

void solve(int testId) {
    int ans = 0, x, y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        if (x * 1ll * x + y * 1ll * y <= d * 1ll * d) {
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    // freopen("test", "r", stdin);
    int testcases = 1;
    // scanf("%d", &testcases);
    for(int testId = 1; testId <= testcases; testId++) {
        input();
        solve(testId);
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    rep(i, N) { cin >> w[i] >> v[i]; }

    vector<vector<ll>> dp(N + 1, vector<ll>(W + 10, 0));

    rep(i, N) {
        rep(j, W + 1) {
            if (j >= w[i])
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
#define MOD 1000000007 
//ll dx[4] = {1,-1,0,0};
//ll dy[4] = {0,0,1,-1};

/*ll pasc[100][100];
ll getPasc(ll n,ll k){
  if(pasc[n][k]!=0){
    return pasc[n][k];
  }else{
    pasc[n][k] = getPasc(n-1,k-1)+getPasc(n-1,k);
    return pasc[n][k];
  }
}*/


int main(){
  ll x,y;
  cin>>x>>y;
  if(x%y==0){
    cout<<-1<<endl;
  }else{
    cout<<x<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 1000000007
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int>h(n);
	rep(i, 0, n)cin >> h[i];

	vector<long long int>dp(n);
	dp[0] = 0;
	
	rep(i, 1, n) {
		long long int imin=INF;
		rep(j, 1, k + 1)
			if (i - j >= 0)imin = min(imin, abs(h[i] - h[i - j]) + dp[i - j]);
		dp[i] = imin;
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 4308
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a < b &&  b < c){
            System.out.printf("Yes\n");
        } else{
            System.out.printf("No\n");
        }
    }
}


Measured memory_bytes: 26236
import java.util.Scanner;

import java.util.*;

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

		long n = scan.nextLong();
		long[] abc = new long[5];
		long[] mul = new long[5];
		boolean[] mod = new boolean[5];
	    long max = 1;
		for(int i = 0; i < 5; i++){
			abc[i] = scan.nextLong();
			mul[i] = ( n % abc[i] ==0) ? n / abc[i]   :n /abc[i]  +1;
			if(mul[i] > max)  max = mul[i];
		}
		System.out.println(4 +max);

	}
}


Measured memory_bytes: 21972
import sys
n = int(input())       
p = list(map(int, input().split()))

n_l = [i for i in range(1, n+1)]
n_l.reverse()
n_l_a = list(reversed(n_l))

if (n_l_a == p):
    print('YES')
    sys.exit()
else:
    for i in range(n):
        for j in range(n):
            p[i], p[j] = p[j], p[i]
            if (n_l_a == p):
                print('YES')
                sys.exit()
            else:
                p[i], p[j] = p[j], p[i]

print('NO')


Measured memory_bytes: 3064
n = gets.to_i
a = gets.split.map(&:to_i)
a.push(0)

l=0
r=0

f = []

dx = 0
ds = 0
dx ^= a[r]
ds += a[r]

while true
  if r==n
    f[l] = r-1
    l += 1
  else
    if dx == ds
      r += 1
      dx ^= a[r]
      ds += a[r]
    else
      f[l] = r-1
      dx ^= a[l]
      ds -= a[l]
      l += 1
    end
  end
  break if l==n
end

sum = 0
f.each_with_index do |v, i|
  sum += (v-i)+1
end

p sum


Measured memory_bytes: 16972
#include<iostream>
using namespace std;
int main() {
    int n, r, max, min;
    max = -1000000001;
    cin >> n;
    cin >> min;
    for(int i=1; i<n; i++) {
        cin >> r;
        if (r - min > max) max = r - min;
        if (r < min) min = r;
    }
    cout << max << endl;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 100010


int main(){
	IOS;
	ll a,p;cin>>a>>p;
	cout<<(3*a+p)/2;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[100001];

int ans;
long long n,m,v,p;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    cin>>n>>m>>v>>p;
    int i,j;
    for(i=1 ; i<=n ; i++)cin>>a[i];
    sort(a+1,a+n+1);

    ans=p;
    long long s=0;
    for(i=n-p ; i>=1 ; i--){
        s+=a[i+1];
        if(a[i]+m>=a[n-p+1]){
            if(1ll*m*(i+p-1)+1ll*(n-p-i+1)*(a[i]+m)-s>=1ll*m*v)ans++;
        }

    }
    cout<<ans;
    return 0;
}

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

int main(){
    int A,B;
    cin >> A >> B;
    int ans=0;
    /*for(int i=A;i<=B;i++){
        //int同士の除算は小数点以下切り捨て
        //s=10で割った余り＝1の位,t=10000で割った数の10で割った数＝10000の位
         int s = i%10,t = i /10000 & 10;
        //u=10で割った数の10で割った余り＝10の位、v=1000で割った数の10で割った余り=100の位
        int u = i / 10 % 10 , v = i / 1000 % 10;
        //int s = i % 10 , t = i/10000%10;
        //int u = i / 10 % 10, v = i/1000%10;
        if(s==t && u==v) ans++;
    }*/
    for (int i = A; i <= B; i++)
	{
		int s = i % 10, t = i / 10000 % 10;
		int u = i / 10 % 10, v = i / 1000 % 10;
		if (s == t&&u == v){
            ans++;
        }
	}
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	sum := 0

	for i := 0; i < 2; i++ {
		if a >= b {
			sum += a
			a--
		} else {
			sum += b
			b--
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[][] c = new int[3][];
        c[0] = Console.ReadLine().Split().Select(int.Parse).ToArray();
        c[1] = Console.ReadLine().Split().Select(int.Parse).ToArray();
        c[2] = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(solve(c) ? "Yes" : "No");
    }
    static bool solve(int[][] c) {
        for (int i = 0; i < c.Length; i ++) {
            int min = c[i].Min();
            for (int j = 0; j < c[i].Length; j ++) {
                c[i][j] -= min;
            }
        }
        for (int i = 0; i < c.Length; i ++) {
            if(c[0][i] != c[1][i] || c[1][i] != c[2][i]) return false;
        }
        return true;
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <stack>

using namespace std;



int main(){
  int n;
  cin >> n;
  int cnt=0;
  for(int i=0;i<n;i++){
    
    int tmp;
    cin >> tmp;
    bool flag = false;
    if(tmp==1){
      cnt++;
      continue;
    }
    for(int j=2;j<=sqrt(tmp);j++){
      if(tmp%j==0){
	flag = true;
	break;
      }
    }

    if(flag==false){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  ll su = 0;
  rep(i, s.size()) {
    su += s[i] - '0';
    su %= 9;
  }
  // ll ans = 0;
  bool ok = (su % 9 == 0);

  // cout << ans << endl;
  cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

int main(){
  int n;
  string s;
  cin>>n>>s;
  string ans;
  for(int bits=0; bits<4; bits++){
    ans="";
    if(bits&1) ans+='W';
    else ans+='S';
    if(bits&2) ans+='W';
    else ans+='S';
    for(int i=2; i<n; i++){
      if(s[i-1]=='o'&&ans[i-1]=='S'){
	ans+=ans[i-2];
      }
      else if(s[i-1]=='o'&&ans[i-1]=='W'){
	if(ans[i-2]=='W') ans+='S';
	else ans+='W';
      }
      else if(s[i-1]=='x'&&ans[i-1]=='S'){
	if(ans[i-2]=='W') ans+='S';
	else ans+='W';
      }
      else{
	ans+=ans[i-2];
      }
    }
    bool f1=false,f2=false;
    if(s[n-1]=='o'&&ans[n-1]=='S'){
      if(ans[n-2]==ans[0]){
	f1=true;
      }
    }
    else if(s[n-1]=='o'&&ans[n-1]=='W'){
      if(ans[n-2]!=ans[0]){
	f1=true;
      }
    }
    else if(s[n-1]=='x'&&ans[n-1]=='S'){
      if(ans[n-2]!=ans[0]){
	f1=true;
      }
    }
    else{
      if(ans[n-2]==ans[0]){
	f1=true;
      }
    }
    if(s[0]=='o'&&ans[0]=='S'){
      if(ans[n-1]==ans[1]){
	f2=true;
      }
    }
    else if(s[0]=='o'&&ans[0]=='W'){
      if(ans[n-1]!=ans[1]){
	f2=true;
      }
    }
    else if(s[0]=='x'&&ans[0]=='S'){
      if(ans[n-1]!=ans[1]){
	f2=true;
      }
    }
    else{
      if(ans[n-1]==ans[1]){
	f2=true;
      }
    }
    if(f1&&f2){
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    ll res=n%1000;
    res=(1000-res)%1000;
    cout<<res<<endl;
}



Measured memory_bytes: 3612
# カードの山に k 種類のカードがあったとして，k が奇数なら余っているカードは偶数枚あるの
# で答えは k であり，偶数ならばどこかで必ず 1 枚しかないカードを 1 回取り除く必要があるので
# 答えは k − 1 となります．

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

k = len(set(nums))
print(k if k % 2 == 1 else k-1)


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

int main(){
  int N,A;
  1<=N<=10000;
  0<=A<=1000;
  cin>>N>>A;
 if(N%500<=A){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
    

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define N 25
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rev(a,n) reverse(a,a+n)
using namespace std;
int n,m,x,a[N][N],ans=1e9;
vector<int> c(N);
int main() {
	cin>>n>>m>>x;
	rep(i,0,n) {
		cin>>c[i];
		rep(j,0,m)cin>>a[i][j];
	}
	rep(mask,0,1<<n) {
		int cnt=0;
		vector<int> skill(m);
        rep(i,0,n) {
            if(mask>>i&1) {
                cnt+=c[i];
                rep(j,0,m)skill[j]+=a[i][j];
            }
        }
        bool pd=true;
        rep(j,0,m){
        	if(skill[j]<x)pd=false;
		}
		if(pd)ans=min(ans,cnt);
	}
	if(ans!=1e9)cout<<ans;
	else cout<<"-1";
	return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int r;
	cin >> r;
// 	std::vector<int> h(n, 0);
	cout << r*r;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var s = ReadLine();
            var N = s.Length;
            if (s[0] == s.Last())//奇数文字になる
            {
                if (N % 2 == 0)
                    WriteLine("First");
                else
                    WriteLine("Second");

            }
            else//偶数文字になる
            {
                if (N % 2 == 0)
                    WriteLine("Second");
                else
                    WriteLine("First");
            }
        }
    }
}

Measured memory_bytes: 26608
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
ll mod = 1000000007;
P p[200005];

ll i, b, c, k, j, n, m, z = 0, mi = 10;
ll a[2005] = {};
vector<ll> v[30];
string s;
char ca[10000];
priority_queue<ll> q;
int main() {
	cin >> n>>k;
	rep(i, n)cin>>a[i];

	rep(i, n)rep(j, n) {
		if (a[i] > a[j]) {
			if (i < j)b++;
			if (i > j)c++;
		}
	}
	m=b+c;
	z = z+(b * k) % mod;
	ll bb = 0;
	bb = ((k - 1) * k / 2)%mod;
	z = (z+m* bb) % mod;
	cout << z;

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
t = gets.split.map &:to_i
m = gets.to_i
px = []
m.times do
  px << gets.split.map(&:to_i)
end

px.each do |a|
  sum = 0
  for i in 1..n
    if i == a[0]
      sum += a[1]
    else
      sum += t[i-1]
    end
  end
  puts sum
end

Measured memory_bytes: 14300
program unfair_nim
  implicit none
  integer :: n, i
  integer(8) :: a(300) = 0, s, x = 0, d, y = 0
  read(*,*) n
  read(*,*) a(1:n)
  s = a(1) + a(2)
  do i = 3, n
    x = xor(x, a(i))
  end do
  if (s - x < 0 .or. mod(s - x, 2) /= 0) then
    write(*,'(i0)') -1
    stop
  end if
  d = (s - x) / 2
  if (and(d, x) /= 0 .or. d > a(1)) then
    write(*,'(i0)') -1
    stop
  end if
  do i = 62, 0, -1
    if (.not.btest(x, i)) cycle
    y = ibset(y, i)
    if (xor(d, y) > a(1)) y = ibclr(y, i)
  end do
  write(*,'(i0)') merge(-1_8, a(1) - xor(d, y), xor(d, y) == 0)
end program unfair_nim

Measured memory_bytes: 2912
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const ll mod=1e9+7;
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    int n,l;
    cin>>n>>l;
    vector<int>v(n+1);
    int f=0,sum=0;
    for(int i=1;i<=n;i++)
    {
        v[i]=l+i-1;
        if(!f&&v[i]>=0)
        {
            f=1;
            continue;
        }
        sum+=v[i];
    }
    if(!f)
    sum-=v[n];

    cout<<sum<<endl;







}




















































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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

const int maxn = 11234;

int n, cnt0, cnt1, cnt2, ans;
string s[maxn];

int main() {
  cin >> n;
  FOR(i, 1, n) {
    cin >> s[i];
    if (s[i].back() == 'A' && s[i].front() == 'B') cnt0++;
    else if (s[i].back() == 'A') cnt1++;
    else if (s[i].front() == 'B') cnt2++;
    if (s[i].length() >= 2)
      REP(j, int(s[i].length()) - 1) if (s[i][j] == 'A' && s[i][j + 1] == 'B') ans++;
  }
  if (cnt1 && cnt2) {
    ans += cnt0 + 1;
    cnt1--, cnt2--;
    ans += min(cnt1, cnt2);
  } else if (cnt1) {
    if (cnt0) ans += cnt0;
  } else if (cnt2) {
    if (cnt0) ans += cnt0;
  } else if (cnt0) ans += cnt0 - 1;
  printf("%d", ans);
}


Measured memory_bytes: 896
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a;
        a = sc.nextInt();
        int b;
        b = sc.nextInt();
        System.out.println(a * b +" "+( a + a + b + b));
        sc.close();
    }
}


Measured memory_bytes: 26352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline int Max(int x,int y){return x>y?x:y;}
static inline int Min(int x,int y){return x<y?x:y;}
const int SUM=0,DIFF=1;
int main(void)
{
  int N=IN(),mn[2],mx[2];mn[SUM]=mn[DIFF]=2e9;mx[SUM]=mx[DIFF]=-2e9;
  while(N--)
  {
    int x=IN(),y=IN();
    mn[SUM]=Min(x+y,mn[SUM]);mx[SUM]=Max(x+y,mx[SUM]);
    mn[DIFF]=Min(x-y,mn[DIFF]);mx[DIFF]=Max(x-y,mx[DIFF]);
  }
  return OUT(Max(mx[SUM]-mn[SUM],mx[DIFF]-mn[DIFF])),0;
}

Measured memory_bytes: 1532
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>

using namespace std;


int main()
{
	int N;
	int a[100];

	cin >> N;

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

	sort(a, a + N, greater<int>());

	int Alice = 0;
	int Bob = 0;


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

		if (i % 2 == 0) {
			Alice += a[i];
		}
		else {
			Bob += a[i];
		}

	}


	cout << Alice - Bob << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

ll AN(ll A, ll N){
  if (N == 0){
    return 1;
  }else if(N % 2 == 0){
    return (AN((A * A) % nmax, N / 2)) % nmax;
  }else{
    return (A * (AN((A * A) % nmax, N / 2))) % nmax;
  }
  
}

ll nCk(ll N, ll K){
  ll ans = 1;
  for (int i = 0; i < K; i++){
    ans = (ans * (N - i)) % nmax;
    ans = ans * AN(i + 1, nmax - 2) % nmax;
  }
  return ans;
}

int main(){
  int X, Y; cin >> X >> Y;

  if ((2 * X - Y) < 0 || (2 * X - Y) % 3 != 0){
    cout << 0 << endl;
  }else if((-1 * X + 2 * Y) < 0 || (-1 * X + 2 * Y) % 3 != 0){
    cout << 0 << endl;
  }else{
    int K = (-1 * X + 2 * Y) / 3;
    int L = (2 * X - Y) / 3;

    cout << nCk(K + L, K) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
<?php
  $a=intval(trim(fgets(STDIN)));
  $b=intval(trim(fgets(STDIN)));
  if       ($a===2 && $b===3 || $a===3 && $b===2) {
    $c=1;
  } elseif ($a===1 && $b===3 || $a===3 && $b===1) {
    $c=2;
  } else {
    $c=3;
  }
  
  echo $c."\n";
?>

Measured memory_bytes: 3576
def g(n):
    if n % 4 == 0:
        return n
    if n % 4 == 1:
        return 1
    if n % 4 == 2:
        return n+1
    return 0


def f(a, b):
    return g(b) ^ g(a-1)


A, B = map(int, input().split())
print(f(A, B))


Measured memory_bytes: 2940
def koch_curve(n, x1, y1, x2, y2):
    if n == 0:
        return [(x1, y1)]
    s_x = (2 * x1 + x2) / 3
    s_y = (2 * y1 + y2) / 3
    t_x = (x1 + 2 * x2) / 3
    t_y = (y1 + 2 * y2) / 3
    # 回転行列を用いて
    u_x = (t_x - s_x) * .5 - (t_y - s_y) * (3 ** .5 / 2) + s_x
    u_y = (t_x - s_x) * (3 ** .5 / 2) + (t_y - s_y) * .5  + s_y
    ret = koch_curve(n - 1, x1, y1, s_x, s_y) + \
        koch_curve(n - 1, s_x, s_y, u_x, u_y) + \
        koch_curve(n - 1, u_x, u_y, t_x, t_y) + \
        koch_curve(n - 1, t_x, t_y, x2, y2)
    return ret
for x, y in koch_curve(int(input()), 0, 0, 100, 0):
    print('{:.8f} {:.8f}'.format(x, y))
print('{:.8f} {:.8f}'.format(100, 0))


Measured memory_bytes: 6184
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#include <bits/stdc++.h>
using namespace std;
ll gcd(ll a, ll b)
{
    if (a > b)
    {
        ll t = a;
        a = b;
        b = t;
    }
    if (a == 0)
    {
        return b;
    }
    return gcd(a, b % a);
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    //cerr << "gcd " << g << endl;
    vector<ll> prime;
    bool isp[1010101];
    rep(i, 1010101) isp[i] = true;
    rep(i, 2, 1010101)
    {
        if (isp[i])
        {
            for (ll j = 2 * i; j < 1010101; j += i)
            {
                isp[j] = false;
            }
            prime.push_back((ll)i);
        }
    }
    ll ans = 0;
    for (auto &x : prime)
    {
        if (g % x == 0)
        {
            ans++;
            while (g % x == 0)
                g /= x;
        }
    }
    if (g != 1)
        ans++;
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 2424
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<H*W-(h*W+H*w)+h*w<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3616
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    ll h,n;
    cin>>h>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    ll sum=0;
    rep(i,n){
        sum+=a[i];
    }
    if(sum>=h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, M;
	while ( cin >> N >> M, N || M ) {
		vector<int> h(N); cin >> h;
		vector<int> w(M); cin >> w;
		vector<int> y(N+1, 0), x(M+1, 0);
		REP(i, N) y[i+1] = y[i]+h[i];
		REP(i, M) x[i+1] = x[i]+w[i];
		map<int, int> m;
		REP(i, y.size()) FOR(j, i+1, y.size()) {
			int l = y[j]-y[i];
			m[l]++;
		}
		int ans = 0;
		REP(i, x.size()) FOR(j, i+1, x.size()) {
			int l = x[j]-x[i];
			if (m.count(l) > 0) ans += m[l];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 16504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    ll xew = 1000007;
    vector<ll> mp(xew);
    rep(i, n){
        cin >> a[i];
        mp[a[i]] += 1;
    }
    
    ll res=0;
    string out[3] = {"pairwise coprime", "setwise coprime", "not coprime"};
    
    
    FOR(k, 2, xew+1){
        ll cnt = 0;
        for(int i=k; i<=xew; i+=k){
            cnt += mp[i];
        }
        if(1<cnt) res = 1;
    }
    //rep(i, n) cout << key[i] << ' ';
    if(0<res){
        ll tmp = 0;
        rep(i, n) tmp = gcd(tmp, a[i]);
        res += (1!=tmp);
    }
    cout << out[res] << endl;
}


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


int main() {
  int h,w,count=0;
  cin>>h>>w;
  vector<vector<char>>indata(h,vector<char>(w));
  for(int i=0;i<h;i++)
    for(int k=0;k<w;k++)
      cin>>indata.at(i).at(k);
  for(int i=0;i<h;i++)
    for(int k=0;k<w;k++){
      count=0;
      char temp=indata.at(i).at(k);
      if(temp=='#') cout << temp;
       else{
       int copyh,copyw;
       for(copyh=i-1;copyh!=i+2;copyh++)
         for(copyw=k-1;copyw!=k+2;copyw++)
           if(copyh>=0 && copyh<h && copyw>=0 && copyw<w  && indata.at(copyh).at(copyw)=='#')
              count++;
        cout << count;
       
      }if(k==w-1)cout<<endl;
    }
}
      



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n;
	int i;
	float x1,y1,x2,y2,x3,y3,x4,y4;
	float a1,a2;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%f%f%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if(x2 == x1 && x4 == x3){
			printf("YES\n");
			continue;
		}
		if(x2 == x1 && x4 != x3){
			printf("NO\n");
			continue;
		}
		if(x2 != x1 && x4 == x3){
			printf("NO\n");
			continue;
		}
		a1 = (y2 - y1) / (x2 - x1);
		a2 = (y4 - y3) / (x4 - x3);
		/*if(a1 == -0.0){
			a1 = 0.0;
		}
		if(a2 == -0.0){
			a2 = 0.0;
		}*/
		if(a1 != a2){
			printf("NO\n");
		}
		else{
			printf("YES\n");
		}
	}
	return 0;
}

Measured memory_bytes: 616
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


main(){
    int a=in(),b=in();
    int q=in();
    vecll s,t;
    rep(i,a)s.pb(lin());
    rep(i,b)t.pb(lin());
    s.pb(-1e14);
    s.pb(1e14);
    t.pb(1e14);
    t.pb(-1e14);
    sort(all(s));
    sort(all(t));
    rep(iiii,q){
        ll x=lin();
        vecll d;
        d.pb(s[lb(s,x)]);
        d.pb(s[lb(s,x)-1]);
        vecll e;
        e.pb(t[lb(t,x)]);
        e.pb(t[lb(t,x)-1]);
        ll ans=LONG_LONG_MAX;
        rep(i,2){
            rep(j,2){
                ll tmp=abs(x-d[i])+abs(d[i]-e[j]);
                chmin(ans,tmp);
                tmp=abs(x-e[j])+abs(d[i]-e[j]);
                chmin(ans,tmp);
            }
        }
        cout<<ans<<endl;
    }
}




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

using namespace std;

int main()
{
    int freq[250000]={},n,x;
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>x;
        freq[x]++;
    }
    for(int i=1;i<=n;i++)cout<<freq[i]<<endl;
    return 0;
}


Measured memory_bytes: 4616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

string s;

ll dfs(int i, string t, vector<ll> v) {
    if (i == s.size() - 1) {
        v.push_back(stoll(t + s[i]));
        ll res = 0;
        for (int i = 0; i < v.size(); ++i) {
            res += v[i];
        }
        return res;
    }

    ll res = 0;

    res = dfs(i + 1, t + s[i], v);

    v.push_back(stoll(t + s[i]));
    res += dfs(i + 1, "", v);

    return res;
}

int main() {
    cin >> s;
    cout << dfs(0, "", {}) << endl;
}

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

using i64 = int64_t;

char room[22][22]={0};
bool visited[22][22]={0};

int di[4]={0,1,0,-1}, dj[4]={-1,0,1,0};

void init(){
    for(int i=0;i<=20;++i){
        for(int j=0;j<=20;++j){
            visited[i][j] = false;
            room[i][j] = '#';
        }
    }
}

int main(){
    int h, w;
    while(cin >> w >> h, w > 0){
        init();
        int si, sj;
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                cin >> room[i][j];
                if(room[i][j] == '@'){
                    si = i;
                    sj = j;
                }
            }
        }
        queue<pair<int, int>> que;
        que.push({si, sj});
        visited[si][sj] = true;
        int ans = 0;
        while(!que.empty()){
            auto cur = que.front(); que.pop();
            ans++;
            for(int k=0;k<4;++k){
                int ni = cur.first+di[k], nj = cur.second+dj[k];
                if(ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
                if(room[ni][nj] == '#')continue;
                if(visited[ni][nj])continue;
                visited[ni][nj] = true;
                que.push({ni, nj});
            }
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
using namespace std;
int n,k,x[100005];
long long res,mn=1e18,sm;
int main()
{
	scanf("%d %d", &n, &k);
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	for(int i=k-1;i<n;i++){
		res=x[i]-x[i-k+1];
        sm=min(abs(x[i]),abs(x[i-k+1]));
		if(res+sm<mn){
			mn=res+sm;
		}
	}
	cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 640