akhauriyash/Code-Regression huggingface dataset:
from sys import stdin

n,t = [int(x) for x in stdin.readline().strip().split()]
t_lst = [int(x) for x in stdin.readline().strip().split()]
diff_lst = [min(t, t_lst[i+1]-t_lst[i]) for i in range(len(t_lst)-1)]
print(sum(diff_lst) + t)

Measured memory_bytes: 30816
N = int(input())
S = list(input())

cnt = [0] * N
if S[0] == "W":
    cnt[0] = 1

for i in range(1, N):
    if S[i] == "W":
        cnt[i] = cnt[i-1] + 1
    else:
        cnt[i] = cnt[i-1]

ans = 3*10**5
for i in range(N):
    temp = 0
    # 基準より左側の人
    if i != 0:
        temp += cnt[i-1]
    # 基準より右側の人
    if i != N-1:
        temp = temp + ((N-1) - i) - (cnt[N-1] - cnt[i])
    if ans > temp:
        ans = temp
print(ans)


Measured memory_bytes: 17484
#include<stdio.h>
int main(){
	int i,n,list[32]={0};
	for(i=1;i<=28;i++){
		scanf("%d",&n);
		list[n]=1;
	}
	for(i=1;i<=30;i++){
		if(list[i]==0)printf("%d\n",i);
	}
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int k; std::cin >> k;

    int modk = 7 % k, ans = 1;
    rep(i, k) {
        if (modk == 0) break;
        modk = (modk * 10 + 7) % k;
        ans++;
    }
    std::cout << (modk == 0 ? ans : -1) << "\n";
}


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

using namespace std;

int main() {
  	int n,m;
  	cin >> n >> m;
  	vector<int> vi(n);
  	for (int i=0; i<n; i++) cin >> vi[i];
  	int sum = accumulate(vi.begin(), vi.end(), 0);
  	int temp1 = 0;
  	for (int i=0; i<n; i++) if (vi[i]*4*m >= sum) temp1++;
  	if (temp1 >= m) cout << "Yes\n";
  	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int N,M,a,b,maxL=0,minR=100001;
	cin >> N >> M;
	
	for(int i=0;i<M;i++)
	{
		cin >> a >> b;
		if(a>=maxL){maxL=a;}
		if(b<=minR){minR=b;}
	}
	
	if(minR-maxL+1<0)
	{
		cout << "0" << endl;
	}
	else
	{
		cout << minR - maxL +1 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	int maxI=1;
	int maxNum=0;
	int i;
	for (i=1;i<=N;i++){
		if (i%2==0){
			int j=i;
			int num=0;
			while (j%2==0){
				j/=2;
				num++;
			}
			if (maxNum<num){
				maxNum=num;
				maxI=i;
			}
		}
	}
	cout<<maxI<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define debug(x) cout << "> x:" << x << endl;
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	string st;
	cin >> st;
	size_t n = st.size();
	bool ans=true;
	for(int i=1; i<n; ++i){
		if(st[i]==st[i-1])ans=false;
	}
	if(ans){
		cout << "Good\n";
	}
	else{
		cout << "Bad\n";
	}

}


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

#define mod 1000000007

using namespace std;
using ll = long long;

void solve(){
    ll n;
    cin >> n;
    for(ll i = 1; i < 3500; i++){
        for(ll j = 1; j < 3500; j++){
            ll x = n*i*j;
            ll y = 4*i*j-n*i-n*j;
            if(y <= 0){
                continue;
            }
            if(x%y == 0){
                printf("%lld %lld %lld\n", i, j, x/y);
                return ;
            }
        }
    }
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {


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

		int n = sc.nextInt();
		Long d = sc.nextLong();
		Long[] x = new Long[n];
		Long[] y = new Long[n];
		int cnt = 0;

		for(int i=0;i<n;i++){
			x[i] = sc.nextLong();
			y[i] = sc.nextLong();
		}

		long l = 0l;

		for(int i=0;i<n;i++){
			l = (x[i] * x[i]) + (y[i] * y[i]); 
			if(d >= Math.sqrt(l)){
				cnt++;
				
			}
		}

		System.out.println(cnt);
		}
	}

Measured memory_bytes: 70028
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int lcs(string& a, string& b)
{
    vector<vector<int>> dp(a.size() + 1, vector<int>(b.size() + 1, 0));

    for (size_t i = 1; i < dp.size(); ++i)
    {
        for (size_t j = 1; j < dp[0].size(); ++j)
        {
            if (a[i - 1] == b[j - 1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    return dp[a.size()][b.size()];
}

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

    for (int i = 0; i < q; ++i)
    {
        string a, b;
        cin >> a >> b;

        cout << lcs(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 5040
#!/usr/bin/env python3
n, a, b = map(int, input().split())
if a > b:
    a, b = b, a
    flipped = True
else:
    flipped = False
turn = 0
while True:
    if turn % 2 == 0:
        if a + 1 == b:
            if a == 1:
                break
            else:
                a -= 1
        else:
            a += 1
    else:
        if b - 1 == a:
            if b == n:
                break
            else:
                b += 1
        else:
            b -= 1
    turn += 1
if flipped:
    a, b = b, a
print(['Borys', 'Alice'][turn % 2])


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e6 + 5;

int m[MAXN];
long long cnt;

void insertion(int m[], int dis, int n)
{
	for(int i = dis; i < n; i++)
	{
		for(int j = i; j >= dis; j -= dis)
		{
			if(m[j] >= m[j-dis])
				break;
			else
			{
				int temp = m[j-dis];
				m[j-dis] = m[j];
				m[j] = temp;
				cnt++;
			}
		}
	}
}

void shell(int m[], int n)
{
	vector<int> v;
	int temp = 1;
	while(temp < n)
	{
		v.push_back(temp);
		temp = temp * 3 + 1;
	}
	printf("%d\n", v.size());
	printf("%d", v[v.size()-1]);
	insertion(m, v[v.size()-1], n);
	for(int i = v.size()-2; i >= 0; i--)
	{
		printf(" %d", v[i]);
		insertion(m, v[i], n);
	}
	cout << endl << cnt << endl;
}

int main()
{
	int n;
	cnt = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", m+i);
	if(n == 1)
	{
		printf("1\n1\n0\n%d\n", m[0]);
		return 0;
	}
	shell(m, n);
	for(int i = 0; i < n; i++)
		printf("%d\n", m[i]);
	return 0;
}

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

int main(){
    int K,N; cin>>N>>K;
    int p[N];
    rep(i, N){
        cin>>p[i];
    }

    sort(p, p+N);
    long sum = 0;
    rep(i, K){
        sum += p[i];
    }


    cout << sum << endl;
}


Measured memory_bytes: 3644
#include <stdio.h>

int gcd(int a, int b)
{
	  int r;
	  while((r = a % b)!=0) a = b, b = r;
	  
	  return b;
}

int lcm(int a, int b, int t)
{
     int u;

     a = a / t;
     b = b / t;
     u = a * b * t;
     
     return u;
}

int main(void)
{
     int a, b, t;
     
     while(0<1){
	  if(scanf("%d", &a) == -1) break;
	  scanf("%d", &b);

	  if(a<b){
	       t = a;
	       a = b;
	       b = t;
	  }

	  t = gcd(a, b);
	  
	  printf("%d %d\n", t, lcm(a, b, t));
     }

     return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<typename A, size_t N, typename T>void Fill(A (&a)[N], const T &v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N=20;
int h, w, ans, v[5]={0, 1, 0, -1, 0};
string b[N];
bool z[N][N];
queue<P<int, int>> q, q2;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  FOR(i, 0, h) cin >> b[i];
  FOR(i, 0, h)FOR(j, 0, w){
    Fill(z, false);
    if(b[i][j]=='#') continue;
    q.push(mp(i, j));
    z[i][j] = true;
    int c = 0;
    while(!q.empty()){
      maxs(ans, c);
      while(!q.empty()){
        auto t = q.front(); q.pop();
        FOR(k, 0, 4){
          int _h = t.fi+v[k], _w = t.se+v[k+1];
          if(0<=_h && _h<h && 0<=_w && _w<w && b[_h][_w]=='.' && !z[_h][_w]){
            z[_h][_w] = true;
            q2.push(mp(_h, _w));
          }
        }
      }
      swap(q, q2);
      c++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const N = parseInt(input.split(' ')[0])
    const K = parseInt(input.split(' ')[1])
    if(N % K === 0){
        console.log(0)
    }else{
        console.log(1)        
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
b=[]
c=[]
#a = [x for x in a if "#" in x]
for x in a:
    if "#" in x:
        b.append(x)
#print(b)
bT = list(zip(*b))
#print(bT)
for x in bT:
    if "#" in x:
        c.append(x)
#print(c)
cT = list(zip(*c))
for i in cT:
    print("".join(i))

Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <algorithm>
//#include <vector>
//#include <set>
#include <map>
//#include <string>
#include <cstring>
//#include <stack>
#include <queue>
//#include <cmath>
//#include <ctime>
//#include <bitset>
//#include <utility>
//#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp
//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const double INFF=1e24;
const int MAX=1e6+5;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const ll MOD=1e9+7;
//const long double pi=acos(-1.0);
const long double eps=1e-9;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}
int cnt[200];
int h,w;
char a[205];
int num[10];
bool an;
int main()
{
    while(~scanf("%d%d",&h,&w))
    {
        memset(num,0,sizeof(num));
        memset(cnt,0,sizeof(cnt));
        an=false;
        for(int i=1;i<=h;i++)
        {
            scanf("%s",a);for(int j=0;j<w;j++)++cnt[a[j]];
        }
        for(int i=0;i<26;i++)
        {
            if(cnt['a'+i]%2==1)
                ++num[1];
            else if(cnt['a'+i]%4==2)
                ++num[2];
            else ++num[4];
        }
        if(h%2&&w%2)//全奇数
            {if(num[1]==1&&num[2]<=(h+w-1)/2)
                an=true;
            }
        else if(h%2||w%2)
        {
            int ou=0;
            if(h%2)ou=w;else ou=h;
            if(!num[1]&&num[2]<=ou/2)
                an=true;
        }
        else if(!num[1]&&!num[2])an=true;
        if(an)
            printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n){
    int x;
    cin >> x;
    mp[x]++;
  }
  cout << mp.size() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

bool solve(string S);

int main()
{
  string S;
  cin >> S;
  if(solve(S)) cout << "chicken" << endl;
  else         cout << "egg" << endl;
  return 0;
}

bool solve(string S){
  int address = 0, length = 0;
  short int state = 0;
  bool first = true;;
  int l = 0;
  while(address < S.size()){
    if(S[address] == 'c'){
      if(state != 1){
	state = 1;
	l++;
	address += 7;
      }
      else{
	if(l > length){
	  length = l;
	  first = true;
	}
	state = 0;
	l = 0;
      }
    }
    else if(S[address] == 'e'){
      if(state != 2){
	state = 2;
	l++;
	address += 3;
      }
      else{
	if(l > length){
	  length = l;
	  first = false;
	}
	state = 0;
	l = 0;
      }
    }
  }

  if(l > length){
    first = state % 2;
  }
  
  return first;
}


Measured memory_bytes: 1200
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
double N, A, B;cin >>  A >> B >> N;

if(N < B){cout << floor(A*N/B) - A*floor(N/B);exit(0);}
   

cout << floor(A*(B - 1)/B) - A*floor((B - 1)/B);

}

Measured memory_bytes: 3852
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import sys
import numpy as np
from math import gcd
mod = 10**9+7
def pow_mod(base, exp):  # [pow_mod, "i8(i8,i8)"],
    # mod はグローバル変数を参照
    exp %= mod - 1
    res = 1
    while exp:
        if exp % 2:
            res = res * base % mod
        base = base * base % mod
        exp //= 2
    return res

def solve(N, AB):
    n = 0
    na = nb = nab = 0
    Cnt = {}
    for a, b in zip(AB[::2], AB[1::2]):
        if (a, b) == (0, 0):
            nab += 1
        elif a == 0:
            na += 1
        elif b == 0:
            nb += 1
        else:
            if b < 0:
                a, b = -a, -b
            g = gcd(a, b)
            a //= g
            b //= g
            ab_fr = (a, b)
            n += 1
            if ab_fr in Cnt:
                Cnt[ab_fr] += 1
            else:
                Cnt[ab_fr] = 1
            inv = (-b, a) if a > 0 else (b, -a)
            if inv not in Cnt:
                Cnt[inv] = 0
    ans = (pow_mod(2, na) + pow_mod(2, nb) - 1) % mod
    A = []
    for ab_fr, cnt in Cnt.items():
        a, b = ab_fr
        inv = (-b, a) if a > 0 else (b, -a)
        cnt2 = Cnt[inv]
        p = pow_mod(2, cnt)
        p2 = pow_mod(2, cnt2)
        A.append((p + p2 - 1) % mod)
    A.sort()
    for a in A[::2]:
        ans = ans * a % mod
    ans += nab - 1
    return ans % mod

numba_compile([
    [pow_mod, "i8(i8,i8)"],
    [solve, "i8(i8,i8[:])"],
])

def main():
    N = int(sys.stdin.buffer.readline())
    m = np.array(sys.stdin.buffer.read().split(), dtype=np.int64)
    ans = solve(N, m)
    print(ans)

main()


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

class Solution
{
    static void Main()
    {
        var n = Console.ReadLine();
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var counts = a.Select(ai => (ai % 2 == 0) ? 2 : 1).ToArray();
        var oddspattern = counts.Aggregate((mul, ci) => mul * ci);
        var allpattern = a.Select(ai => 3).Aggregate((mul, ci) => mul * ci);

        Console.WriteLine(allpattern - oddspattern);
    }
}

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

using namespace std;

const int INF = 1e6;

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

    int count=0;
    sort(v.begin(), v.end());
    for (int i=0; i<n-1; i++){
        if (v[i] == v[i+1])  count++;
    }

    count += count%2 == 0 ? 0 : 1;

    cout << n-count << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

ll gcd_euclid(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}


int main() {
    ll a,b;
    cin >> a >> b;
    ll ans=a/gcd_euclid(a,b)*b;
    cout << ans;
    


}

/*



 */



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i,n;
    int c5=0, c7=0;
    for(i=0; i<3; i++){
        cin>>n;
        if(n==5){
            c5++;
        }else if(n==7){
            c7++;
        }
    }
    if(c5==2 && c7==1){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int a[MAXN];
vector<int> E[MAXN];
int nico[MAXN];

int dfs(int x, int fa){
	//vector<int> s;
//	cout<<"IN: "<<x<<endl;
	int y;
	int sum = 0, mx = -1;
	for(int i = 0; i < E[x].size(); i++)
		if ((y = E[x][i]) != fa){
			if (dfs(y, x) == 0) return 0;
			//s.push_back(nico[y]);
			sum += nico[y];
			mx = max(mx, nico[y]);
		}
//	cout<<"QvQ: "<<x<<' '<<sum<<' '<<a[x]<<' '<<mx<<endl;
	if (mx == -1){
		nico[x] = a[x];
		return 1;
	}
	//sort(s.begin(), s.end());
	if (sum < a[x] || sum > 2 * a[x]) return 0;
	if (sum - a[x] <= (mx > sum / 2 ? sum - mx : sum / 2)/*min(sum / 2, min(mx, sum - mx))*/){
		nico[x] = a[x] - (sum - a[x]);
		return 1;
	}
	else return 0;
}

int solve(int casi){
	cin>>n;
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for(int i = 1; i < n; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
	for(int i = 1; i <= n; i++){
		if (E[i].size() > 1){
			if (dfs(i, 0)){
				if (nico[i] == 0) return 1;
				else return 0;
			}
			else
				return 0;
		}
	}
	return a[1] == a[2];
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		puts(solve(i)?"YES":"NO");
		printans();
	}
	return 0;
}




Measured memory_bytes: 57728
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::string s;
    std::cin >> s;
    auto check = [](const std::string &s) {
        const int n = s.size();
        for (int i = 0; i < n; i++) if (s[i] != s[n - 1 - i]) return false;
        return true;
    };
    const int n = s.size();
    std::cout << (check(s) && check(s.substr(0, (n - 1) / 2)) && check(s.substr((n + 3) / 2 - 1)) ? "Yes" : "No") << std::endl;

    return 0;
}


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

NIL = -1

m = int(input())

root = NIL

def insert(k):
    global root
    y = NIL
    x = root
    z = {'key':k, 'left':NIL, 'right':NIL}
    while x != NIL:
        y = x
        if z['key'] < x['key']:
            x = x['left']
        else:
            x = x['right']
    z['parent'] = y

    if y == NIL:
        root = z
    elif z['key'] < y['key']:
        y['left'] = z
    else:
        y['right'] = z

def inorder(u):
    if u == NIL:
        return
    inorder(u['left'])
    print(' ' + str(u['key']), end='')
    inorder(u['right'])

def preorder(u):
    if u == NIL:
        return
    print(' ' + str(u['key']), end='')
    preorder(u['left'])
    preorder(u['right'])

for _ in range(m):
    command = input()
    if command[:6] == 'insert':
        _, x = command.split()
        x = int(x)
        insert(x)
    else:
        inorder(root)
        print('')
        # pythonのprintは最後に改行記号をつけてくれるので、これで改行できる
        preorder(root)
        print('')


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int D[51][1<<18], A[18], B[18];
bool chk[51][1<<18];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, ans=0x7fffffff;
	queue<pair<int,int>> Q;
	memset(D,0x7f,sizeof(D));
	cin>>N;
	for(int i=0;i<N;i++) cin>>A[i];
	for(int i=0;i<N;i++) cin>>B[i];
	D[0][0]=0;
	Q.emplace(0,0);
	while(!Q.empty()) {
		int v, b, cnt, nv, ncnt=0;
		tie(v,b)=Q.front();
		Q.pop();
		if(b==(1<<N)-1) ans=min(ans,D[v][b]);
		cnt=__builtin_popcount(b);
		for(int i=0;i<N;i++) if(~b&(1<<i)) {
			nv=((i&1)^(cnt&1)) ? B[i]:A[i];
			if(v<=nv && D[nv][b|(1<<i)]>D[v][b]+ncnt) {
				D[nv][b|(1<<i)]=D[v][b]+ncnt;
				if(!chk[nv][b|(1<<i)]) {
					chk[nv][b|(1<<i)]=true;
					Q.emplace(nv,b|(1<<i));
				}
			}
			ncnt++;
		}
	}
	cout<<(ans==0x7fffffff ? -1:ans)<<'\n';
	return 0;
}

Measured memory_bytes: 64256
#include <algorithm>
#include <bitset>
#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() {
    ll x;
    cin >> x;
    ll t = 1;
    while (1) {
        if ((t * (t + 1)) / 2 >= x) {
            cout << t << endl;
            return 0;
        }
        t++;
    }
}

Measured memory_bytes: 256
class SegmentTree:
    def __init__(self, initial_values, f=max, zero=0, converter=lambda x:x):
        self.__f, self.__z, self.__c, self.__size = f, zero, converter, len(initial_values)
        self.__n = 1 << ((self.__size - 1).bit_length())
        self.__dat = [zero] * (2 * self.__n)
        zi = self.__get_leaf(0)
        for i, v in enumerate(initial_values): self.__dat[zi + i] = converter(v)
        for i in range(zi-1, -1, -1): self.__dat[i] = f(*self.__get_children(i))
    
    def update(self, index, value):
        i, v = self.__get_leaf(index), self.__c(value)
        if self.__dat[i] == v: return
        self.__dat[i] = v
        while i:
            i = self.__get_parent(i)
            self.__dat[i] = self.__f(*self.__get_children(i))
    
    def query(self, from_inclusive, to_exclusive):
        ans = self.__z
        if to_exclusive <= from_inclusive: return ans
        l, r = self.__get_leaf(from_inclusive), self.__get_leaf(to_exclusive) - 1
        while r - l > 1:
            if self.__is_right(l): ans = self.__f(ans, self.__dat[l])
            if self.__is_left(r): ans, r = self.__f(ans, self.__dat[r]), r-1
            l, r = l//2, self.__get_parent(r)
        ans = self.__f(ans, self.__dat[l])
        if l != r: ans = self.__f(ans, self.__dat[r])
        return ans

    def __get_leaf(self, i): return self.__n + i - 1
    def __get_parent(self, i): return (i-1)//2
    def __get_children(self, i): return (self.__dat[2*i+1], self.__dat[2*i+2])
    def __is_left(self, i): return i&1 == 1
    def __is_right(self, i): return i&1 == 0

N = int(input())
S = input()
tree = SegmentTree(S, f=lambda x,y:x|y, converter=lambda c: 1 << (ord(c)-ord('a')))
Q = int(input())
update = tree.update
query = tree.query
for _ in range(Q):
    t, a, b = input().split()
    if t == '1': update(int(a)-1, b)
    else: print(bin(query(int(a)-1, int(b))).count('1'))

Measured memory_bytes: 79944
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#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 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;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 n,m,a[305],b[305],x[305];
int dp[305][305][305];
vector<P>vec[305];
int main(){
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		cin>>a[i]>>b[i]>>x[i];
		vec[b[i]].pb(mp(a[i],x[i]));
		if(a[i] == 1 && b[i] == 1 && x[i] > 1){
			puts("0"); return 0;
		}
	}
	dp[1][0][0] = 3;
	int ret = 0;
	for(int i=1;i<n;i++){
		for(int j=0;j<i;j++){
			for(int k=0;k<=j;k++){
				if(dp[i][j][k] == 0) continue;
				for(int x=0;x<vec[i+1].size();x++){
					if(vec[i+1][x].fi <= k && vec[i+1][x].sc != 3) goto out;
					else if(vec[i+1][x].fi > k && vec[i+1][x].fi <= j && vec[i+1][x].sc != 2) goto out;
					else if(vec[i+1][x].fi > j && vec[i+1][x].fi <= i+1 && vec[i+1][x].sc != 1) goto out;
				}
				dp[i+1][j][k] = (dp[i+1][j][k]+dp[i][j][k])%mod; out:;
				
				for(int x=0;x<vec[i+1].size();x++){
					if(vec[i+1][x].fi <= k && vec[i+1][x].sc != 3) goto out2;
					else if(vec[i+1][x].fi > k && vec[i+1][x].fi <= i && vec[i+1][x].sc != 2) goto out2;
					else if(vec[i+1][x].fi > i && vec[i+1][x].fi <= i+1 && vec[i+1][x].sc != 1) goto out2;
				}
				dp[i+1][i][k] = (dp[i+1][i][k]+(!j?2:1)*dp[i][j][k]%mod)%mod; out2:;
				
				if(j==k) continue;
				for(int x=0;x<vec[i+1].size();x++){
					if(vec[i+1][x].fi <= j && vec[i+1][x].sc != 3) goto out3;
					else if(vec[i+1][x].fi > j && vec[i+1][x].fi <= i && vec[i+1][x].sc != 2) goto out3;
					else if(vec[i+1][x].fi > i && vec[i+1][x].fi <= i+1 && vec[i+1][x].sc != 1) goto out3;
				}
				dp[i+1][i][j] = (dp[i+1][i][j]+dp[i][j][k])%mod; out3:;
			}
		}
	}
	rep(i,n) rep(j,n)ret=(ret+dp[n][i][j])%mod;
	cout <<ret << endl;
}

Measured memory_bytes: 108800
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N;
    vector<int> V(50), C(50);
    
    cin >> N;
    int res = 0;
    for (int i = 0; i < N; ++i) {
        cin >> V[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> C[i];
    }
    for (int i = 0; i < N; ++i) {
        if (V[i] > C[i]) res += V[i] - C[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 9
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 = 998244353

n = I()
A = LI()
S = sorted([(A[k], k + 1) for k in range(n)], reverse=True)
ans = 0
dp = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(n):
        if i and i <= S[i + j - 1][1]:
            dp[i][j] = max(dp[i][j], dp[i - 1][j] + S[i + j - 1][0] * abs(i - S[i + j - 1][1]))
        if j and S[i + j - 1][1] <= n - j + 1:
            dp[i][j] = max(dp[i][j], dp[i][j - 1] + S[i + j - 1][0] * abs(n - j + 1 - S[i + j - 1][1]))
        if i + j == n:
            ans = max(ans, dp[i][j])
            break

print(ans)




Measured memory_bytes: 116400
n = int(input())
d = {}
for idx in range(n):
    i = input().split()
    m = i[0]
    s = int(i[1])
    if m in d:
        d[i[0]].append((s, idx+1))
    else:
        d[i[0]] = [(s, idx+1)]

for k in sorted(d.keys()):
    for i in sorted(d[k], reverse=True):
        print(i[1])

Measured memory_bytes: 3064
#include<cstdio>
#define ll long long 

ll n,m;
const int N=2e5+5;
int head[N],cnt,color[N],visit[N];
struct node{
	int nest,to;
}e[N];

void insert(int x,int y){
	e[++cnt]=(node){head[x],y}; head[x]=cnt;
}

bool ff=0;

void dfs(int u,int fu){
	visit[u]=1;
	for(int i=head[u];i&&!ff;i=e[i].nest){
		int v=e[i].to;
		if(v==fu) continue;
		if(color[u]==1){
			if(color[v]==1){
				ff=1; return ;
			}
			else if(!color[v]) color[v]=2;
		}
		else if(color[u]==2){
			if(color[v]==2){
				ff=1; return ;
			}
			else if(!color[v]) color[v]=1;
		}
		if(!visit[v])dfs(v,u);
	}
}

int main()
{
	int x,y;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		insert(x,y); insert(y,x);
	}
	color[1]=1;
	dfs(1,0);
	if(ff){
		printf("%lld",n*(n-1)/2-m);
		return 0;
	}
	ll cc2=0;
	for(int i=1;i<=n;i++){
		if(color[i]==2) cc2++;
	}
	printf("%lld",(n-cc2)*cc2-m);
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <tuple>
#include <set>
#include <iterator>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define VALD(n) cout << #n << ": " << n << endl;

int main(){
  int n, m;
  cin >> n >> m;
  int cnt = 0;
  int min = 0;
  int max = 0;
  F(i, m){
    int l, m;
    cin >> l >> m;
    if(i!=0){
      if(max < l || min > m){
        cnt = 0;
        break;
      }
      else if(min < l && max >= l && max <= m){
        min = l;
        cnt = max - min + 1;
      }
      else if(l <= min && min <= m && m < max){
        max = m;
        cnt = max - min + 1;
      }
      else if(min < l && max > m){
        max = m;
        min = l;
        cnt = max - min + 1;
      }
    }
    else{
      min = l;
      max = m;
      cnt = max - min + 1;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
N,M = map(int,input().split())

Tree = [[] for _ in range(N)]
for _ in range(M):
    L,R,D = map(int,input().split())
    L -= 1; R -= 1
    Tree[L].append((R,D))
    Tree[R].append((L,-D))

num = dict()
for i in range(N):
    if i not in num:
        num[i] = 0
        Q = deque(Tree[i])
        x = 0
        while Q:
            now,d = Q.popleft()
            if now in num:
                if num[now] != d:
                    print("No")
                    exit()
            else:
                num[now] = d
                for node,Di in Tree[now]:
                    Q.append((node,d+Di))
print("Yes")

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

ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x; }

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

  int n, x; cin >> n >> x;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> dst(n);
  rep(i, n) dst[i] = abs(x-a[i]);

  ll ans = dst[0];
  for(int i = 1; i < n; ++i) {
    ans = gcd(ans, dst[i]);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
mod = 10**9+7
frac = [1]*200001
for i in range(2,200001):
    frac[i] = i * frac[i-1]%mod
fraci = [None]*200001
fraci[-1] = pow(frac[-1], mod -2, mod)
for i in range(-2, -200001-1, -1):
    fraci[i] = fraci[i+1] * (200001 + i + 1) % mod
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%mod

H, W, N = map(int, input().split())

RC = [tuple(map(int, input().split())) for _ in range(N)] + [(1, 1), (H, W)]
RC.sort()
R, C = map(tuple, zip(*RC))
dp = [0]*(N+2)

for i in range(1, N+2):
    r, c = R[i], C[i]
    res = comb(r+c-2, r-1)
    for k in range(1, i):
        rk, ck = R[k], C[k]
        if ck > c:
            continue
        res = (res - comb(r-rk + c-ck, r-rk)*dp[k]%mod) % mod
    dp[i] = res

print(dp[-1])


Measured memory_bytes: 52840
import math

m, n = map(int,input().split(" "))

if n > m:
    m, n = n, m

if m - n > 1:
    print("0")
elif m - n == 1:
    print((math.factorial(m) * math.factorial(n)) % 1000000007)
elif m - n == 0:
    print((math.factorial(m) * math.factorial(n) * 2) % 1000000007)


Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
 
long N,ans;
vector<long> A;
 
int main(){
    scanf("%ld",&N);
    for(int i=0;i<N;++i){
        scanf("%ld",&ans);
        A.push_back(ans);
    }
    partial_sum(A.begin(),A.end(),A.begin());
    ans=1LL<<50;
    auto it=A.begin()+1,ed=A.end()-1,a=A.begin(),b=it+1;
    for(;it+1!=ed;++it){
        while(a+1!=it)
            if(*a<*it-*(a+1)) ++a;
            else break;
        if(b==it)++b;
        while(b+1!=ed)
            if(*b-*it<*ed-*(b+1)) ++b;
            else break;
        ans=min(ans,max({*a,*it-*a,*b-*it,A[N-1]-*b})-min({*a,*it-*a,*b-*it,A[N-1]-*b}));
    }
    cout<<ans<<endl;
}

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

using namespace std;


typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


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

 ll n,a,b;
  cin >> n >> a >> b;
  if((b-a)%2==0) cout << (b-a)/2 << endl;
  else cout << min(n-b,a-1)+(b-a+1)/2 << endl;
 
  
}


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

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

    map<ll, int> map;
    ll a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        map[a[i]]++;
    }

    int ans = 0;
    for(auto itr = map.begin(); itr != map.end(); ++ itr){
        ll key = itr -> first;
        int cou = itr -> second;

        if(cou % 2 == 1){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
ll barg[55], pathi[55]; 

ll num(int N, ll X) {
	if (N==0) return (X<=0)? 0 : 1;
	else if (X<=1+barg[N-1]) return num(N-1,X-1);
	else return pathi[N-1] + 1 + num(N-1,X-2-barg[N-1]); 
}

int main() {
	int n; ll x;
	cin >> n >> x;
	barg[0] = pathi[0] = 1;
	rep(i,n) {
		barg[i+1] = 2 * barg[i] + 3;
		pathi[i+1] = 2 * pathi[i] + 1;
 	}
	cout << num(n,x) << endl;
	return 0;
}

Measured memory_bytes: 3604
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int t=0;
	if(c*2==a&&d*2==b)t=1;
	cout<<a*b/2.<<" "<<t<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int ab = Integer.parseInt(s.replaceAll(" ", ""));
		int sqrt = (int)Math.sqrt(ab);
		System.out.println((sqrt * sqrt == ab) ?"Yes" : "No");
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define rep(i,x) for(i=0;i<x;i++)
#define rrep(i,x) for(i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(i=a;i<x;i++)
#define si_1(x) scanf("%d",&x)
#define si_2(x,y) scanf("%d %d",&x,&y)
#define debug(x) printf("x:%d\n",x)

int main()
{
	int i,j,k,num[10]={},n,flag=0;
	double sum=2,sum2=0;
	double count=1,plus;
	while(si_1(n)!=EOF)
	{
	/*
		count=0;
		rep(i,1001)
		{
			num[0]=n-i;
			rep(j,num[0]+1)
			{
				if(j>1000)break;
				num[1]=n-(i+j);
				rep(k,num[1]+1)
				{
					if(k>1000)break;
					num[2]=n-(i+j+k);
					if(n<(i+j+k+num[2]) || 4000<(i+j+k+num[2]))break;
					if(num[2]<=1000 && num[2]>=0)
					{
						count++;
						//printf("%d+%d+%d+%d=%d\n",i,j,k,num[2],n);
					}
				}
				if(n<(i+j) || 4000<(i+j))break;
			}
			if(n<i || 4000<i)break;
		}
	*/
		
		flag=0;
		sum=1;
		sum2=1001;
		count=1;
		plus=1;
		rep(i,n)
		{
			sum++;
			if(sum<=1000)
			{
				plus+=sum;
			}
			else if(sum>1000 && sum<=2001)
			{
				plus+=sum2;
				sum2-=3;
			}
			else if(sum>2001 && sum<=3002)
			{
				plus+=sum2;
				sum2+=3;
			}
			else if(sum>3002)
			{
				plus+=sum2;
				sum2--;
			}
			count+=plus;
			//printf("plus:%.0f\n", plus);
		}
		
		printf("%.0f\n",count);
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}
int INF=1e5;
int main(){
	startTime=clock();
	int h,w,black=0;
	cin >> h >> w;
	char s[h][w];
	FOR(i,h)
		FOR(j,w){
			cin >> s[i][j];
			if(s[i][j]=='#') black++;
		}
	int visited[h][w];

	int distance[h][w];
	FOR(i,h)
		FOR(j,w){
			distance[i][j]=INF;
			visited[i][j]=false;
		}
	int sides[2]={-1,1};
	queue<pi> q;
	distance[0][0]=0;
	q.push(MP(0,0));
	while(!q.empty()){
		int x=q.front().F;
		int y=q.front().S;
		q.pop();
		for(auto r: sides){
			if(x+r <h && x+r>-1 && s[x+r][y]=='.' && distance[x+r][y]>distance[x][y]+1){
				visited[x+r][y]=true;
				distance[x+r][y]=distance[x][y]+1;
				q.push(MP(x+r,y));
			}
			if(y+r < w && y+r>-1 && s[x][y+r]=='.' && distance[x][y+r]>distance[x][y]+1){
				visited[x][y+r]=true;
				distance[x][y+r]=distance[x][y]+1;
				q.push(MP(x,y+r));
			}
		}
	}
	if(visited[h-1][w-1]) cout << h*w-(black+distance[h-1][w-1]+1);
	else cout << -1;

	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
void solve(){
	int n,m;
	scanf("%d%d",&n,&m);
	vl v1(n),v2(m);
	cin>>v1;cin>>v2;
	vvl dp(n+1,vl(m+1)),dp2(n+1,vl(m+1));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(v1[i-1]==v2[j-1]) dp[i][j]=(dp2[i-1][j-1]+1)%mod;
			dp2[i][j]=(dp2[i][j-1]+dp2[i-1][j]-dp2[i-1][j-1]+dp[i][j]+mod)%mod;
		}
	}
	ll ans=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) ans=(ans+dp[i][j])%mod;
	}
	cout<<ans<<endl;
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    

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

int M, N, K;
char map[1010][1010];
int jt[1010][1010];
int ot[1010][1010];
int it[1010][1010];

int main() {
  cin >> M >> N >> K;
  for (int i=0; i<M; i++) {
    int hj = 0, ho = 0, hi = 0;
    for (int j=0; j<N; j++) {
      cin >> map[i][j];
      if (i == 0 && j >= 1) {
        jt[i][j] = jt[i][j-1];
        ot[i][j] = ot[i][j-1];
        it[i][j] = it[i][j-1];
      }
      if (i > 0) {
        if (j == 0) jt[i][j] = jt[i-1][j];
        else        jt[i][j] = jt[i-1][j] + hj;

        if (j == 0) ot[i][j] = ot[i-1][j];
        else        ot[i][j] = ot[i-1][j] + ho;

        if (j == 0) it[i][j] = it[i-1][j];
        else        it[i][j] = it[i-1][j] + hi;
      }

      char c = map[i][j];
      if (c == 'J') { jt[i][j]++; hj++; }
      if (c == 'O') { ot[i][j]++; ho++; }
      if (c == 'I') { it[i][j]++; hi++; }
    }
  }

  for (int i=0; i<K; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a -= 1; b -= 1; c -= 1; d -= 1;

    int J = 0;
    int O = 0;
    int I = 0;
    cout << jt[c][d] - (a>0?jt[a-1][d]:0) - (b>0?jt[c][b-1]:0) + (a>0&b>0?jt[a-1][b-1]:0) << " "
         << ot[c][d] - (a>0?ot[a-1][d]:0) - (b>0?ot[c][b-1]:0) + (a>0&b>0?ot[a-1][b-1]:0) << " "
         << it[c][d] - (a>0?it[a-1][d]:0) - (b>0?it[c][b-1]:0) + (a>0&b>0?it[a-1][b-1]:0) << "\n";
  }
  return 0;
}

Measured memory_bytes: 15788