akhauriyash/Code-Regression huggingface dataset:
/*宣言
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(long long int i=0;i<n;i++)
#define rep1(i,n) for(long long int i=1;i<=n;i++)
long long int  a[200000], l, r, x, dif[200000];
int s, t, n, q;
long long int get(long long int sa)
{
	if (sa >= 0)
		return -sa*s;
	else
		return -sa*t;
}
int main()
{
	long long int ans = 0;
	cin >> n >> q >> s >> t;
	rep(i, n+1)
	{
		cin >> a[i];
		if (i != 0)
		{
			dif[i-1] = a[i] - a[i - 1];
			ans += get(dif[i-1]);
		}
	}
	rep(i, q)
	{
		cin >> l >> r >> x;
		ans -= get(dif[l - 1]);
		dif[l - 1] += x;
		ans += get(dif[l - 1]);
		if (r != n)
		{
			ans -= get(dif[r]);
			dif[r] -= x;
			ans += get(dif[r]);
		}
		cout << ans << endl;
	}
	return 0;
}*/









/*宣言*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
long long int tim[100001],ans,ft,sd;
int main()
{
	int N, K;
	cin >> N >> K >> ft;
	rep(i, N - 1)
	{
		cin >> sd;
		tim[i] = sd - ft - 1;
		ft = sd;
	}
	ans = N;
	sort(tim, tim + N-1);
	rep(i, N - K)
		ans += tim[i];
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3944
import sys
import heapq

input = sys.stdin.readline
 
N, M =  map(int, input().split())
A = list(map(int, input().split()))

#A = list(map(lambda x: x * (-1), A))
A = [-i for i in A]
heapq.heapify(A)

for _ in range(M):
    mx = heapq.heappop(A)
    heapq.heappush(A, mx // 2 if mx % 2 == 0 else mx // 2 + 1)

print(sum(A) * (-1))

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

int gcd(int x,int y){
    if(x%y==0){
      return y;
    }
    else{
      return gcd(y,x%y);
    }
}

int main(){
  int x,y;
 
  cin >>x >>y;

  if(y>x){
    int tmp=x;
    x=y;
    y=tmp;
  }

  cout << gcd(x,y) << endl;

  return 0;
}



Measured memory_bytes: 3112
import java.util.Scanner;

class Main{
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        double r = sc.nextDouble();
        
        System.out.printf("%.10f %.10f\n", r*r*Math.PI, 2*r*Math.PI);
    }
}


Measured memory_bytes: 28236
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    K, S = map(int, input().split())
    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if 0 <= z <= K:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dp[3030];
const ll N_MAX = 200005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

ll bin(ll A, ll B){
	if(A<0) return 0;
	if(B<0) return 0;
	return combination(A+B, A);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 3030) dp[i] = 0;
    make();

    ll H, W, N;
    cin >> H >> W >> N;
    vector<pll> kabe;
    REP(i, N){
    	ll r, c;
    	cin >> r >> c;
    	r--, c--;
    	kabe.push_back({r, c});
    }
    kabe.push_back({H-1, W-1});
    sort(kabe.begin(), kabe.end());

    REP(i, N+1){
    	ll tmp = 0;
    	REP(j, i){
    		tmp += (dp[j] * bin(kabe[i].first - kabe[j].first, kabe[i].second - kabe[j].second))%mod;
    		tmp %= mod;
    	}
    	dp[i] = bin(kabe[i].first, kabe[i].second) - tmp;
    	dp[i] += mod;
    	dp[i] %= mod;
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 5120
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

def gcd(x, y):
    if y==0:
        return x
    return gcd(y, x%y)

def lcm(x, y):
    return x//gcd(x, y)*y

A, B = map(int, input().split())
cd = make_divisors(gcd(A, B))
ans = []
for i in range(1, len(cd)):
    flag = True
    for j in range(len(ans)):
        if cd[i]%ans[j] == 0:
            flag = False
            break
    if flag:
        ans.append(cd[i])
print(len(ans)+1)

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

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size(), ans = 0;
  for(int i = 0; i < n; i++) {
    if(s.at(i)!=t.at(i))
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3840
#include<stdio.h>
int main(){
  int n,a[111],i,ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<n;i++){
    if(a[i]==a[i-1]){
      ans++;
      i++;
    }
  }
  printf("%d",ans);
}

Measured memory_bytes: 128
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
A,B,C = map(int,input().split())
lis = [A,B,C]
lis.sort()
cnt_1 = lis[2]-lis[1]
nokori = lis[2]-lis[0]-cnt_1
if (lis[2]-lis[0]-cnt_1)%2 == 0:
    cnt_2 = nokori//2
else:
    cnt_2 = (nokori+1)//2 + 1

ans = cnt_1+cnt_2
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3060
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

using namespace std;

typedef long long int lli;
typedef long int li;
typedef vector<lli> vli; 
typedef vector<int> vi; 
typedef vector<string> vs; 


const lli mod=1000000007;
const lli limit=1000000;


void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k;
    string str,s;
    cin>>str>>s;
    bool flag=0;
    FOR(i,str.length())if(str[i]!=s[i]){
        flag=1;
        break;
    }
    if(flag)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
 
}

Measured memory_bytes: 3644
#include<cstdio>
#define max(a,b)(a>b?a:b)
using namespace std;
long long a,b,c,d,ans=-1000000000000000001;
int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	ans=max(ans,max(a*c,a*d));
	ans=max(ans,max(b*c,b*d));
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1712
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,l;
    char s[101],t[101],temp;
    gets(s);
    gets(t);
    l=strlen(s);
    if(strcmp(s,t)==0)
    {
        printf("Yes\n");
        return 0;
    }
    for(i=1;i<l;i++)
    {
        temp=s[0];
        for(j=0;j<l-1;j++)
        {
            s[j]=s[j+1];
        }
        s[j]=temp;
        if(strcmp(s,t)==0)
        {
            printf("Yes\n");
            return 0;
        }
    }
     printf("No\n");
     return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
#define scan(a) scanf("%d",&a)
#define scan2(a,b) scanf("%d %d",&a,&b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define print(x) printf("%d\n",x)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<pair<int,int> > vpii;
static const int INF = 0x3f3f3f3f;
static const ll INFL = 0x3f3f3f3f3f3f3f3fLL;


int main()
{
    string s;
    cin>>s;
    s[3] = '8';
    cout<<s;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,i,x;
    cin>>a;
    string s;
    cin>>s;
    x=s[0]-'0';
    for(i=1;i<s.size();i++)
    {
         if(s[i]!='.')
         {
             x=x*10+(s[i]-'0');
         }
    }
 // x=atoi(s.c_str());
  x=x*a/100;
    cout<<x<<endl;
}

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

int main() {
  long n,ans=1000;
  bool x=true;
  cin >> n;
  vector<long> a(n);
  vector<long> b;
  for(long i=0;i<n;i++) cin >> a[i];
  b.push_back(a[0]);
  for(long i=1;i<n;i++) {
    if(x) {
      if(a[i]<=a[i-1]) {
        b.back()=a[i];
      } else {
        b.push_back(a[i]);
        x=false;
      }
    } else {
      if(a[i]>=a[i-1]) {
        b.back()=a[i];
      } else {
        b.push_back(a[i]);
        x=true;
      }
    }
  }
  for(long i=0;i<b.size()/2;i++) {
    ans=ans/b[i*2]*b[i*2+1]+ans%b[i*2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
N,K = map(int,input().split())

if (N-1)*(N-2)//2 < K:
    print(-1)
    exit()

ad = [[0]*N for _ in range(N)]
edges = []

for v in range(1,N):
    ad[0][v] = 1
    ad[v][0] = 1
    edge = (1,v+1)
    edges.append(edge)

pt = (N-1)*(N-2)//2
M = N-1

if pt == K:
    print(M)
    for i,j in edges:
        print(i,j)
    exit()


for v in range(N):
    for nv in range(v+1,N):
        if ad[v][nv] == 0:
            ad[v][nv] = 1
            ad[nv][v] = 1
            edge = (v+1,nv+1)
            edges.append(edge)
            pt -= 1
            M += 1
        if pt == K:
            print(M)
            for i,j in edges:
                print(i,j)
            exit()

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) x.begin(),x.end()
#define len(x) (int)(x).size()
//#define endl "\n"
#define m_p make_pair
#define int long long


using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ld,ld> pari;

ld PI = 3.14159265358979323846;


struct Point{
    string a;
    int x,ind;
};

typedef tree<int, null_type, less<int >,
    rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void volodya22(){
    #ifdef THERE
        freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
    cout << fixed;
}


int n,m;
const int N = 1e6+7;
const int alphabet = 256;
const int INF = 1e18;
const ll MOD = 1e9+7;
const ld eps = 1e-10;
const int L = 30;

int m1 = 137*137*137*137*13;
int m2 = 1e9+9;
//int p = 347;

vi path[N];
int p[N];

void input(){
    cin >> n >> m;
    for(int i = 0;i < m;i++){
        int k;
        cin >> k;
        while(k--){
            int a;
            cin >> a;
            path[i].push_back(a-1);
        }
    }

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

int ans[N];
int cnt = 0;
int c[N];

int f(){
    memset(c,0,sizeof(c));
    for(int i = 0;i < m;i++){
        for(int j : path[i]){
            c[i] += ans[j];
        }
        if(c[i]%2 != p[i]) return 0;
    }
    return 1;
}

void rec(int x){
    if(x == n){
        cnt += f();
        return ;
    }
    ans[x] = 1;
    rec(x+1);
    ans[x] = 0;
    rec(x+1);
}

void solve(){
    rec(0);
    cout << cnt;
}

signed main(){
    volodya22();
    input();
    solve();
}


Measured memory_bytes: 34816
my $n = get;
my @a = (1..$n).map(-> $_ {
	my ($a, $b) = get.words;
	$a == $b;
});
for 0..$n-3 -> $i {
	if @a[($i&$i+1&$i+2)] {
		say "Yes";
		exit;
	}
}
say "No";

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

signed main() {
  int n, m;
  cin >> n >> m;

  vector<int> x(m);
  vector<int> y;
  for (auto &&w : x) {
    cin >> w;
  }
  sort(x.begin(), x.end());
  for (int i = 0; i < m - 1; i++) {
    y.push_back(x[i + 1] - x[i]);
  }
  sort(begin(y), end(y), greater<int>());
  int dif1 = x[m - 1] - x[0];
  // int dif2 = 0;
  for (int i = 0; i < n - 1; i++) {
    if (i >= y.size()) break;
    dif1 -= y[i];
  }
  // for (auto &&w : x) {
  //   cout << w << " ";
  // }
  // cout << endl;
  // for (auto &&w : y) {
  //   cout << w << " ";
  // }
  // cout << endl;
  // x.erase(unique(begin(x), end(x)), end(x));
  // int num = x.size();
  // cout << num << endl;
  // cout << dif1 << " " << dif2 << endl;

  cout << dif1 << endl;
}

Measured memory_bytes: 2168
s = input()

while len(s) != 0:
    if s[:6] == 'dreamd' or s[:8] == 'dreamera':
        s = s[5:]
    elif s[:7] == 'dreamer':
        s = s[7:]
    elif s[:6] == 'erased' or s[:6] == 'erasee':
        s = s[5:]
    elif s[:6] == 'eraser':
        s = s[6:]
    elif s[:5] == 'dream' or s[:5] == 'erase':
        s = s[5:]
    else:
        print('NO')
        exit()
print('YES')

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

using namespace std;

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

    long long a, b, x;
    cin >> a >> b >> x;

    cout << b / x - a / x + (a % x == 0) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
    int n,k,ans = 0;
    cin >> n >> k;
    vector<int> l;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    sort(l.begin(),l.end(),greater<int>());
    for (int j = 0; j < k; ++j) {
        ans += l[j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld long double 
#define ll long long 
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const int maxn = 1005;

map<int, int> m;

int main()
{
	fastio;
	int n, a;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		m[a]++;
	}
	int temp = 0;
	if (m.size() == 3)
	{
		for (pair<int,int> i : m)
		{
			temp ^= i.first;
			if (i.second * 3 != n)
			{
				cout << "No";
				return 0;
			}
		}
		if (temp == 0)
			cout << "Yes";
		else
			cout << "No";
		return 0;
	}
	else if (m.size() == 2)
	{
		if (m.find(0) != m.end() && (abs(m[0] * 2 - n) <= 1 || m[0]*3==n*2 || m[0] * 3 == n))
			cout << "Yes";
		else
			cout << "No";
		return 0;
	}
	else if (m.size() == 1)
	{
		if (m.begin()->first == 0)
			cout << "Yes";
		else
			cout << "No";
	}
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
using namespace std;
double p[3050];
double dp[3050][3050];

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%lf",&p[i]);
    }
    dp[1][1]=p[1];
    dp[1][0]=1.00-p[1];

    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1.00-p[i]);
                continue;
            }
            dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1.00-p[i]);
        }
    }
    double ans=0;
    for(int i=(n+1)/2;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 49448
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		Pattern p = Pattern.compile("^[1-9]$");
		Matcher ma = p.matcher(String.valueOf(a));
		Matcher mb = p.matcher(String.valueOf(b));
		if(ma.find() && mb.find()) {
			System.out.println(a*b);
		}else {
			System.out.println(-1);
		}
		sc.close();
	}
}

Measured memory_bytes: 22740
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

s = S()

if list(s)[-1] == "s":
    ans = str(s) + "es"
else:
    ans = str(s) + "s"
print(ans)


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

int ap[1000000+20] = {0},n,a[200000+20];
int main(){
    scanf("%d",&n);
    for(int i = 1; i <=n; i++) {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n);
    for(int i = 1; i <=n; i++) {
        if(a[i]==a[i-1]){
            ap[a[i]]=1;
        }
    }
    int res=0;
    for(int i = 1; i <=n; i++) {
        if(!ap[a[i]])
            res++;
        if(a[i]!=a[i-1]){
            for(int j=2*a[i];j<=1000000;j+=a[i]){
                ap[j]=1;
            }
        }
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 8512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
 
int main() {
	string s,m;
    cin >> s >> m;
    m.pop_back();
    if (s == m) cout << "Yes" << "\n";
    else  cout << "No" << "\n";
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>

int main(void) {
	double xa,xb,ra,ya,yb,rb;
	scanf("%*lf");
	while(scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb)!=EOF){
		if(rb-ra> sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)) ) printf("-2\n");
		else if(ra-rb> sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)) ) printf("2\n");
		else if(ra+rb>= sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)) ) printf("1\n");
		else printf("0\n");
		
	}
	
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int l = S.size();
    int w[26];
    for (char i='a'; i<='z'; i++) {
        w[i] = 1;
    }
    for (int i=0; i<100001; i++) {
        if (i > l) break;
        else w[S[i]] = -1;
    }
    
    for (char i='a'; i<='z'; i++) {
        if (w[i]==1) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    int n;
    int total=0;
    string x;

    cin>>n;
    vector<int> t(n+1);
    vector<string> s(n+1);

    FOR(i,1,n){
        cin>>s[i]>>t[i];
    }
    cin>>x;

    FOR(i,1,n){
        if(s[i]==x){
            FOR(k,i+1,n){
                total+=t[k];
            }
            break;
        }
    }

    cout<<total<<endl;
}


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

/*Cjの小さいものから見ていって、それより小さいAを順に書き換えていく
*/


int main() {
  int A,B;
  cin >> A >> B;
  vector<int> num(4);//num[i] = 1なら誤答,i>=1
  num[A] = 1;
  num[B] = 1;
  int ans = 0;

  for(int i =1;i<4;i++){
      if(num[i] == 0){
          ans = i;
          break;
      }
  }
  cout << ans << endl;    
 }

 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}
int dp[10001][101][2];
int solve(string &k, int &D, int pos, int d, bool tight)
{
	if (dp[pos][d][tight] != -1)
		return dp[pos][d][tight];
	int ub = ((tight) ? k[pos] - '0' : 9);
	if (pos == k.size() - 1)
	{
		int ans = 0;
		rep(x, ub + 1)
		if (x % D == d)
			ans++;
		return ans % mod;
	}
	int ans = 0;
	rep(x, ub + 1)
	ans = (ans + solve(k, D, pos + 1, (D + d - x % D) % D, tight && (x == ub) )) % mod;
	return dp[pos][d][tight] = ans;
}

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(dp, -1, sizeof(dp));
	string k;
	cin >> k;
	int D;
	cin >> D;
	db1((mod+solve(k, D, 0, 0, 1)-1)%mod);
}
int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 20316
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
l=[]
for i,j in enumerate(a):
  for _ in range(j):
    l.append(i+1)
for i in range(h):
  print(*l[i*w:(i+1)*w][::(-1)**i])

Measured memory_bytes: 3828
original = input()[::-1]

target = 2019

# s = reversed(original)

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1
digit = 1
mod = 0
for c in original:
    # val = int(c) * digit
    # currentMod = val % target
    # # mod = (currentMod + mod) % target
    # digit *= 10
    #
    # counts[mod] += 1
    num += int(c) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1

# print(sum(results.values()))

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans)  # 答えの出力

Measured memory_bytes: 9332
A,B,M = map(int,input().split())

a =  list(map(int,input().split()))
b = list(map(int,input().split()))

min = sorted(a)[0] + sorted(b)[0]

for  i  in range(M):
    x,y,c =map(int,input().split())
    if min > a[x-1]+b[y-1]-c:
        min = a[x-1]+b[y-1]-c
            
print(min)

Measured memory_bytes: 18740
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k,a,b;
  cin >> k;
  cin >> a >> b;
  if (a%k==0 || (a/k+1)*k<=b) {
  	cout << "OK";
  }else{
  	cout << "NG";
  }
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define gi(i,j,k,l) ans.push_back((str){i,j,k,l});
const int N=1000005,M=998244353;
int n,m,k,t,u,v,i,tot=114514;
struct str{
	char c;
	int x,y,z;
};
vector<str> ans;
void muti(int a,int b,int c)
{
	++tot;
	gi('+',114514,a,tot);
	++tot;
	int l=tot;
	gi('+',tot,b,tot);
	for(int i=1;i<=60;++i)
	{
		++tot;
		gi('+',tot-1,tot-1,tot);
	}
	for(int i=tot;i>=l;--i)
	{
		gi('+',c,i,tot+1);
		gi('<',tot+1,l-1,tot+2);
		gi('+',b,tot+2,tot+2);
		gi('<',114514,tot+2,tot+2);
		for(int j=1;j<i-l+1;++j)
			gi('+',tot+2,tot+2,tot+2);
		gi('+',tot+2,c,c);
	}
	tot+=2;
}
int main()
{
	gi('+',0,1,1919);
	gi('<',2,1919,114514);
	gi('+',1100,114514,1100);
	gi('+',0,114514,0);
	for(i=1101;i<=1130;++i)
		gi('+',i-1,i-1,i);
	int mp=11451;
	for(i=1130;i>=1100;--i)
	{
		gi('+',i,800,11451);
		gi('<',11451,0,600+i-1100);
		++mp;
		muti(i,600+i-1100,mp);
		gi('+',mp,800,800);
	}
	gi('+',9960,1,9960);
	for(i=9961;i<=9990;++i)
		gi('+',i-1,i-1,i);
	for(i=0;i<=30;++i)
		muti(9960+i,600+i,300+i);
	for(i=0;i<=30;++i)
		gi('+',300+i,2,2);
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();++i)
		printf("%c %d %d %d\n",ans[i].c,ans[i].x,ans[i].y,ans[i].z);
}


Measured memory_bytes: 7204
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)

using namespace std;

typedef struct Data {
	int P, Y, index;
	bool operator<(const Data& right) const {
		return Y < right.Y;
	}
};

int main(){
	std::ios::fmtflags curret_flag = std::cout.flags();
	int N;
	int M;
	vector<Data> data;
	int p[100000] = { 0 };
	pair<int, int> ans[100000];
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		Data d = { a,b,i };
		data.push_back(d);
	}
	sort(data.begin(), data.end());

	for (int i = 0; i < M; i++) {
		int P = data[i].P;
		ans[data[i].index] = make_pair(P, p[P]+1);
		p[P]++;
	}
	
	for (int i = 0; i < M; i++) {
		cout << setfill('0') << right << setw(6)<< ans[i].first;
		cout << setfill('0') << right << setw(6) << ans[i].second << endl;
	}


	std::cout.flags(curret_flag);
	return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
    string s[3]={"Sunny", "Cloudy", "Rainy"};
    string x; cin >> x;
    rep(i,3){
        if(s[i] == x){
            cout << (s[(i+1)%3]) << endl;
            return 0;
        }
    }
}

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

int main() {
	string n;
	cin >> n;
	int nl = n.size(),cnt=0;
	for(int i =0;i<nl;i++)
	{
		cnt+=(int)n.at(i)-48;
		cnt%=9;
	}
	if(cnt>0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>
#include<stdlib.h>

void run(void){
  int n;
  scanf("%d",&n);
  int *index=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++){
    int p;
    scanf("%d",&p);
    index[p-1]=i;
  }
  int max=0;
  i=0;
  while(i<n){
    int j=i+1;
    while(j<n && index[j]>index[j-1]) j++;
    if(max<j-i) max=j-i;
    i=j;
  }
  printf("%d\n",n-max);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}
 
using namespace std;
//ここから

vector<char>t,d;
int n,q;
string s;

bool C(int mid){
  int pos=mid;
  rep(i,q){
    char now=s[pos];
    if(t[i]==now){
      if(d[i]=='L')--pos;
      else ++pos;
    }
    if(pos<=-1)return true;
  }
  return false;
}

bool C2(int mid){
  int pos=mid;
  rep(i,q){
    char now=s[pos];
    if(t[i]==now){
      if(d[i]=='L')--pos;
      else ++pos;
    }
    if(pos>=n)return true;
  }
  return false;
}

void solve(){
  cin>>n>>q;
  cin>>s;
  t.resize(q);d.resize(q);
  rep(i,q)cin>>t[i]>>d[i];
  int l=-1,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(C(mid))l=mid;
    else r=mid;
  }
  int left=l+1;
  l=-1,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(C2(mid))r=mid;
    else l=mid;
  }
  int right=n-r;
  int sub=min(n,left+right);
  cout<<n-sub<<endl;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 976
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
ll n,m,v,p;
ll a[100200];
ll b[100200];
bool cmp(ll a,ll b){ return a>b; }
int check(ll mid){
    if(mid<=p) return 1;
    if(a[mid]+m<a[p]) return 0;
    if(v<=p-1) return 1;
    for(int i = 1 ; i <= n ; i ++ ) b[i] = a[i];
    ll sum = 0;
    for(int i = 1 ; i <= p-1 ; i ++ ){
        b[i] += m;
        sum += m; //计算前面能吞掉多少贡献
    }
    int dis=v-p+1; // 还剩下个数
    for(int i = n ; i > mid ; i -- ){
        if(dis==1) break;//只能给mid
        sum += m ;
        dis--;
        b[i]+=m;
    }
    sum += m ;// mid消化掉
    ll flag = a[mid]+m;
    ll st = m*v-sum;//剩余量
    for(int i = p ; i < mid ; i ++ ){
        int up = min(m,max(a[mid]+m-a[i],0ll));
        if(up > st) up = st;//不够量
        st -= up;
        b[i] += up;
    }
    if( a[mid]+m>=b[p] && st<=0 ) return 1;
    return 0;
}
int main()
{
    cin >> n >> m >> v >> p;
    for(int i = 1 ; i <= n ; i ++ ){
        cin >> a[i];
    }
    sort(a+1,a+1+n,cmp);//前P个
    ll l = 1 , r = n;
    ll mid ;
    ll ans = 0;
    while(l<=r){
        mid = (l+r)>>1;
        if(check(mid)){
            l = mid+1;
            ans = mid;
        }
        else r = mid-1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
sx, sy, tx, ty = [int(i) for i in input().split()]

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


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}else{
				String str = "";
				for(int i = 1; i <= W + 1; i++){
					if(i % 2 == 1){
						str += "#";
					}else{
						str += ".";
					}
				}
				String odd_str = str.substring(0, str.length() - 1);
				String even_str = str.substring(1);
				for(int i = 1; i <= H; i++){
					if(i % 2 == 1){
						System.out.println(odd_str);
					}else{
						System.out.println(even_str);
					}
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 27328
#include "bits/stdc++.h"
using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin >> N;
	string s;
	int res = 0;
	for (int i = 1; i <= N; i++)
	{
		s = to_string(i);
		if (s.size() % 2 == 1)
			res++;
		else
			i = i * 10 - 1;
	}

	cout << res << "\n";
	return 0;
}

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

N = int(input())
C = [int(input()) for _ in range(N)]+[-1]
l = []

for i in range(N):
    if C[i]!=C[i+1]:
        l.append(C[i])

if len(l)==1:
    print(1)
    exit()
    
dp = [0]*(len(l))
acc = [0]*(2*10**5+100)
dp[0] = 1
acc[l[0]] = 1
acc[l[1]] = 1
MOD = 10**9+7

for i in range(1, len(l)):
    dp[i] = acc[l[i]]
    
    if i<len(l)-1:
        acc[l[i+1]] += dp[i]
        acc[l[i+1]] %= MOD

print(dp[-1])

Measured memory_bytes: 67392
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b + c || b == a + c || c == a + b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
    if(a>b){
        a = b; return true;
    }
    else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
    if(a<b){
        a = b; return true;
    }
    else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
    cout << a << " " << b << " " << c << "\n";
}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll n; cin >> n;
    vl a(n); rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n){
        if((i & 1 ^ 1) && (a[i] & 1)) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    int sum = 0, score = 1;
    while (sum <= N) {
        sum += score;
        score++;
    }

    REP(i, 1, score) {
        if (i == sum - N) continue;
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
x=3
a=[]
for _ in range(x):
    a.append(list(map(int, input().split())))
n=int(input())
for _ in range(n):
    b=int(input())
    for ix in range(x):
        for iy in range(x):
            if a[ix][iy] == b:
                a[ix][iy]=-1

# 縦横
for i in range(x):
    if a[i][0] == -1 and a[i][1] == -1 and a[i][2] == -1:
        print('Yes')
        exit()
    if a[0][i] == -1 and a[1][i] == -1 and a[2][i] == -1:
        print('Yes')
        exit()

if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
    print('Yes')
    exit()
if a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int now = x-a;
		System.out.println(now % b);
	}
}

Measured memory_bytes: 22356
def E(i,y):
    if i==1:
        return 5*y
    else:
        return (2*i+1)*y

def ceil(a,b):
    return -((-a)//b)
N,X=map(int,input().split())
x=[int(i) for i in input().split()]
a=[0]
for i in range(N):
    a.append(a[-1]+x[i])
ans=10**50
for k in range(1,N+1):
    tmp=(N+k)*X
    for i in range(N//k):
        tmp+=E(i+1,a[N-i*k]-a[N-i*k-k])
        #print(k,i,tmp)
    if N%k!=0:
        tmp+=E(N//k+1,a[N-(N//k)*k])
    #print(tmp)
    if ans>tmp:
        ans=tmp
print(ans)


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

int main(){
    long long W, H;
    int x, y;
    cin >> W >> H >> x >> y;
    cout << W * H / 2.0 << " ";
    if(x==0||y==0||x==W||y==H||x==W/2.0||y==H/2.0){
        if((x==W/2.0)&&(y==H/2.0)){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
import math
N = int(input())
ruteN = math.ceil(math.sqrt(N))
prime=[1]*(ruteN+2)
prime[0]=0
primes=[]
count=0
for i in range(2,ruteN+2,1):
    if prime[i]==1:
        primes.append(i)
        count+=1
        for j in range(i*2,ruteN+2,i):
            prime[j]=0

ans =0
for i in range(0,count,1):
    tmp = primes[i]
    while True:
        if N%tmp==0:
            ans += 1
            N = N//tmp
        else:
            while N % primes[i] == 0:
                N=N//primes[i]
            break
        tmp = tmp*primes[i]

if N!=1:
    ans +=1
print(ans)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,3) {
        if(s[i] == 'R') ans++;
    }
    if(ans >= 2 && s[1] == 'S') ans--;
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>

#define MAX 105
using namespace std;


int num[MAX];
int pre_sum[MAX];
int rear_sum[MAX];
int main( )
{
	int n;
	while(cin >> n){
		memset(pre_sum,0,sizeof(pre_sum));
		memset(rear_sum,0,sizeof(rear_sum));
		for(int i = 1; i <= n; i++){
			cin >> num[i];
		}
		for(int i = 1; i <= n; i++){
			
			pre_sum[i] = pre_sum[i - 1] + num[i]; 
		//	cout << pre_sum[i] << " ";
		}//cout << endl;
		for(int i = n; i > 0; i--){
			rear_sum[i] = rear_sum[i + 1] + num[i]; 
		//	cout << rear_sum[i] << " ";
		}//cout << endl;
		
		int ans = MAX*MAX; 
		for(int i = 1; i  < n; i++){
		//	cout << abs(pre_sum[i] - rear_sum[i + 1]) << endl;
			ans = min(ans,abs(pre_sum[i] - rear_sum[i + 1]));
		}
		cout << ans << endl; 
	}
}




Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ull, ull> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


int arr[100005], sorted[100005];
map<int, int> parity;

int main(){

    ios_base::sync_with_stdio(0);

    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>arr[i];
    	sorted[i] = arr[i];
    }
    sort(sorted+1, sorted+n+1);

    for(int i=1;i<=n;i++){
    	parity[arr[i]] ^= (i&1);
    	parity[sorted[i]] ^= (i&1);
    }

// for(int i=1;i<=n;i++)	cout<<arr[i]<<" ";cout<<endl;
// for(int i=1;i<=n;i++)	cout<<sorted[i]<<" ";cout<<endl;
// for(int i=1;i<=n;i++)	cout<<parity[i]<<" ";cout<<endl;

    int ans = 0;
    for(auto i : parity)
    	ans += i.ss;
    cout<<ans/2;
    return 0;
}






Measured memory_bytes: 5760
#include<stdio.h>
int main()
{
	int a,b,total;
	scanf("%d %d",&a,&b);
//	if(a+b>=total) 
//	{
//		total = a+b;
//	}
	total = a+b;
	if(a-b>=total)
	{
		total = a-b;
	}
	if(a*b>=total)
	{
		total = a*b;
	}
	printf("%d\n",total);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int a[1000000][4];
int e[1000000][4];

int dp(int c,int d){
    if(e[c][d] != 0){
        return e[c][d];
    }
    else if(d == 0 && c != 1){
        return max(dp(c-1,1)+a[c][1],max(dp(c-1,2)+a[c][2],dp(c-1,3)+a[c][3]));
    }
    else if(c == 1){
        if(d == 0){
            return max(a[c][1],max(a[c][2],a[c][3]));
        }
        else if(d == 1){
            e[c][d] = max(a[c][2],a[c][3]);
            return e[c][d];
        }
        else if(d == 2){
            e[c][d] = max(a[c][1],a[c][3]);
            return e[c][d];
        }
        else if(d == 3){
            e[c][d] = max(a[c][1],a[c][2]);
            return e[c][d];
        }
        else{
            return 0;
        }
    }
    else if(d == 1){
        e[c][d] = max(dp(c-1,2)+a[c][2],dp(c-1,3)+a[c][3]);
        return e[c][d];
    }
    else if(d == 2){
        e[c][d] = max(dp(c-1,1)+a[c][1],dp(c-1,3)+a[c][3]);
        return e[c][d];
    }
    else if(d == 3){
       e[c][d] = max(dp(c-1,1)+a[c][1],dp(c-1,2)+a[c][2]);
       return e[c][d];
    }
    else{
        return 0;
    }
}
int main(){
    int N;
    cin >> N;
    for (int i=1;i<=N;i++){
        for(int j=1;j<=3;j++){
            cin >> a[i][j];
        }
    }
    cout << dp(N,0);
}


Measured memory_bytes: 10624
#include <iostream>
#include <vector>

int main() {
    int q;
    std::cin >> q;

    std::vector<int> A;

    for (int i = 0; i < q; i++) {
        int op;
        std::cin >> op;
        
        switch (op) {
            case 0:
                int x;
                std::cin >> x;
                A.push_back(x);
                break;
            case 1:
                int p;
                std::cin >> p;
                std::cout << A[p] << std::endl;
                break;
            case 2:
                A.pop_back();
        }
    }
}



Measured memory_bytes: 3952
#!/usr/bin/env python3
# coding: utf-8

# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)

def main():
    N, M, *A = map(int, open(0).read().split())

    r = N - sum(A)
    print(r if r >=0 else -1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 10048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, m;
    cin >> n >> m;

    vector<vector<int>> e(n - 1);
    for (int j = 0; j < m; j++) {
        int s, t;
        cin >> s >> t;
        s--; t--;

        e[s].push_back(t);
    }
    
    vector<double> p(n);
    p[0] = 1;
    for (int i = 0; i < n - 1; i++) {
        double t = 1.0 / e[i].size();
        for (auto j : e[i]) {
            p[j] += p[i] * t;
        }
    }

    vector<double> d(n);
    d[n - 1] = 0;
    for (int i = n - 2; i >= 0; i--) {
        double s = 0;
        for (auto j : e[i]) {
            s += d[j];
        }
        d[i] = s / e[i].size() + 1;
    }

    double r = 0;
    for (int i = 0; i < n - 1; i++) {
        int k = e[i].size();
        if (k == 1) continue;

        double t = p[i] / (k - 1);
        double d0 = d[i];

        for (auto j : e[i]) {
            r = min(r, (d0 - (d[j] + 1)) * t);
        }
    }

    cout << fixed << setprecision(10) << d[0] + r << endl;

    return 0;
}

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

int main(){
 int A, B;
  cin >> A >> B;
 if (A==B) {
  cout << "Draw" << endl;
    } else  if ((A>1) && (B>1)) {
       if (A<B){
       cout << "Bob" << endl;
     } else {
       cout << "Alice" << endl;
     } 
    } else if ((A==1) && (B!=1)){
      cout << "Alice" << endl;
    } else if ((B==1) && (A!=1)){
      cout << "Bob" << endl;
}
}
 


Measured memory_bytes: 888