akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    std::vector<int> A(N);
    REP(i, N) {
        std::cin >> A[i];
    }
    std::vector<int> B(N);
    REP(i, N) {
        std::cin >> B[i];
    }
    std::vector<int> C(N);
    REP(i, N) {
        std::cin >> C[i];
    }
    SORT(A);
    SORT(B);
    SORT(C);

    vector<int> A_table(N);
    vector<int> B_table(N);
    vector<ll>  C_acc_table(N + 1, 0);
    REP(i, N) {
        auto b_itr = upper_bound(ALL(B), A[i]);
        A_table[i] = (b_itr == B.end()) ? -1 : distance(B.begin(), b_itr);
    }
    REP(i, N) {
        auto c_itr = upper_bound(ALL(C), B[i]);
        B_table[i] = (c_itr == C.end()) ? -1 : distance(C.begin(), c_itr);
        C_acc_table[i + 1] += B_table[i] == -1 ? C_acc_table[i] : (N - B_table[i]) + C_acc_table[i];
    }

    ll ans = 0;
    REP(i, N) {
        auto b_index = A_table[i];
        if(b_index == -1) break;
        ans += C_acc_table.back() - C_acc_table[b_index];
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3072
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <long long> a(n);
    cin >> a;
    forn (i, 0, n)
        if (!a[i])
            return cout << 0, 0;
    long long ans = 1;
    const long long INF = 1e18;
    forn (i, 0, n) {
        if (a[i] && ans > (INF + a[i] - 1) / a[i])
            return cout << -1, 0;
        ans *= a[i];
    }
    if (ans <= INF)
        cout << ans;
    else
        cout << -1;
    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int N, M;
    cin >> N >> M;
    
    vector<int> L(M);
    vector<int> R(M);
    
    for (int i = 0; i < M; i++)
    {
        int l, r;
        cin >> l >> r;
        L[i] = l;
        R[i] = r;
    }
    
    int maxl = 0;
    int minr = N + 1;

    for (int i = 0; i < M; i++)
    {
        minr = min(minr, R[i]);
        maxl = max(maxl, L[i]);
    }
    
    int cnt = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i >= maxl && i <= minr) cnt++;    
    }
    
    cout << cnt << endl;
    

    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
A, B, C, D = map(int, input().split())
# S = input()

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


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


def kosu(n, p):
    return n // p

x = kosu(B, C) - kosu(A - 1, C)
y = kosu(B, D) - kosu(A - 1, D)
z = kosu(B, lcm(C, D)) - kosu(A - 1, lcm(C, D))

print((B - A + 1) - (x + y - z))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

int n;
vector<int> c;
vector<vector<pint> > d;

void search(int u) {
	int dc;

	if (c.at(u)==1)
	{
		dc = 2;
	} else {
		dc = 1;
	}

	for (int i = 0; i < d.at(u).size(); ++i)
	{
		if (c.at(d.at(u).at(i).first) != 0) continue;

		if (d.at(u).at(i).second%2==0)
		{
			c.at(d.at(u).at(i).first) = c.at(u);
		} else {
			c.at(d.at(u).at(i).first) = dc;
		}

		search(d.at(u).at(i).first);
	}
}


int main() {
	cin >> n;

	c.resize(n);
	d.resize(n);

	for (int i = 1; i <= n-1; ++i)
	{
		int u, v, w;
		cin >> u >> v >> w;
		d.at(u-1).push_back(pint(v-1, w));
		d.at(v-1).push_back(pint(u-1, w));
	}

	c.at(0) = 1;
	search(0);

	for (int i = 0; i < n; ++i)
	{
		if (c.at(i)==2) c.at(i) = 0;
		cout << c.at(i) << endl;
	}
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    string s;
    cin >> n >> s;
    vector<int> left(n+1,0), right(n+1,0);
    int ans = inf;
    int same = 0;
    rep(i,n){
        if(i == 0){
            if(s[i] == 'E') left[i+1]++;
        }else if(i != n-1){
            if(s[i] == 'E') left[i+1] = left[i] + 1;
            else left[i+1] = left[i];
        }
    }
    for(int i = n-1;i >= 0; i--){
        if(i == n-1){
            if(s[i] == 'W') right[i-1]++;
        }else if( i != 0){
            if(s[i] == 'W') right[i-1] = right[i] + 1;
            else right[i-1] = right[i];
        }
    }
    /*
    rep(i,n) cout << left[i] << " ";
    cout << endl;
    rep(i,n) cout << right[i] << " ";
    cout << endl;
    */
    rep(i,n){
        int now = left[i] + right[i];
        if(now > same){
            //cout << "now" << now << endl;
            //cout << ans << endl;
            same = now;
            ans = n - 1 - same;
            //cout << ans << endl; 
        }
    }
    cout << ans << endl;
    return 0;
}

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

def method(number, remain):
    if (remain * (remain+1)) // 2 < number:
        return 0, 0
    i = 1
    remain -= 1
    sumple = (i * (i + 1)) // 2
    while sumple + remain < number:
        i += 1
        sumple = (i * (i + 1)) // 2
        remain -= 1
    return i, remain 

i, remain = method(K, N-2)
if i > 0:
    sub = ((i+1)*i)//2 + remain - K
    if i > 1:
        M = (N - 1) + sub
    else:
        M = (N - 1) + sub*(N-2 + N-2-sub+1) // 2
    print(M)
    if i > 1:
        for x in range(i+1):
            print(1, x+2)
        for x in range(i+2, N):
            print(x, x+1)
        for x in range(sub):
            print(2, x+3)
    else:
        for x in range(N-1):
            print(x+1, x+2)
        for x in range(sub):
            for y in range(x,N-2):
                print(x+1, y+3)
else:
    print(-1)

Measured memory_bytes: 3608
#ABC 122, B - ATCoder
S = input()
N = len(S)

ans = 0
for i in range(N):
    for j in range(i, N):
        if all('ACGT'.count(c) == 1 for c in S[i:j+1]):
            ans = max(ans, j - i + 1)
print(ans)


Measured memory_bytes: 3064
N = int(input())
n = N
ans = 0
k = 0
while True:
  m = n//(10**k)
  if(m <  10):
    break
  k += 1
for i in range(k):
  if(i%2==0):
      ans += 9*(10**i)
if (k%2 == 0):
    d = n - (10**k)+1
    ans += d
print(ans)
  


  
  
  
  

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a > b)cout << a * 2 - 1 << endl;
  else if(b > a) cout << b * 2 - 1 << endl;
  else cout << a + b << endl;
 return 0; 
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    ll n, k; cin >> n >> k;
    vl a(n);
    rep(i,n) cin >> a[i], a[i]--;

    int T = 0, d = 0;
    vl depth(n,-1);
    while (depth[T] == -1) {
        depth[T] = d++;
        T = a[T];
    }

    int now = T, N = 0;
    vl ans;
    while (true) {
        ans.push_back(now);
        now = a[now];
        N++;
        if (now == T) break;
    }

    if (k <= depth[T]) {
        rep(i,n) {
            if (depth[i] != k) continue;
            cout << i+1 << endl;
            return 0;
        }
    }
    k -= depth[T];
    cout << ans[k%N]+1 << endl;
    return 0;
}


Measured memory_bytes: 8244
use proconio::input;
use std::vec::Vec;

fn main() {
	input! {
		n: i64,
		m: i64,
	}

	let mut total = 0;
	for _ in 0..m {
		input! {a:i64}
		total += a;
	}

	if total <= n {
		println!("{}", n - total);
	} else {
		println!("-1");
	}
}


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

int a[3005][3005];
ll dp[3005][3005][4];

int main(){
  int r, c, k; cin >> r >> c >> k;
  rep(i, k){
    int ri, ci, v; cin >> ri >> ci >> v;
    a[ri - 1][ci - 1] = v;
  }

  rep(i, r){
    rep(j, c){
      for(int k = 2; k >= 0; k--){
        chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
      }
      rep(k, 4){
        chmax(dp[i + 1][j][0], dp[i][j][k]);
        chmax(dp[i][j + 1][k], dp[i][j][k]);
      }
    }
  }

  ll ans = 0;
  rep(k, 4) chmax(ans, dp[r - 1][c - 1][k]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 320588
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;
// cout << typeid('変数').name() << endl;

int main() {
    int n,x,y;
    cin >> n >> x >> y;
    vector<int> a(n-1);
    for (int i=0;i<n-1;i++){
        a.at(i) = n-i-1;
    }
    vector<int> b(n-1);
    // i→j
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            //距離が変わるケース
            if(i!=j){
                int way1 = abs(i-j);
                int way2 = min (abs(x-i) + abs(y-j),
                                abs(y-i) + abs(x-j))+1;
                if(way2<way1){
                    b[way1-1]--;
                    b[way2-1]++;
                }
            }
        }
    }
    for (int i=0;i<n-1;i++){
        b[i]/=2;
        a[i]+=b[i];
        cout << a[i] << endl;
    }

    return 0;
}



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

int main(){
  string n;cin>>n;
  int fn=0;
  rep(i,n.size())fn+=n[i]-'0';
  cout<<(stoi(n)%fn==0?"Yes":"No");
}

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

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		int []b = new int [n];
		
		int cnt = 0;
		
		for(int i = 0 ;i < n ;i++) {
			a[i] = Integer.parseInt(sc.next());
			if(a[i] <= 0) { 
				cnt++;
			}
			
			b[i] = Math.abs(a[i]);
		}
		
		Arrays.sort(b);
		long ans = 0;
		
		for(int i = 0 ; i < n;i++) {
			
			ans += (long)b[i];
		}
		
		if(cnt % 2 == 0) {
			System.out.println(ans);
		}
		else {
			ans -= (long)b[0] * 2;
			System.out.println(ans);
		}

	}

}


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

long long n,h,a,b,mx=0,total=0,moves=0,A=0;
vector<long long> throws;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>h;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		throws.push_back(b);
		if(mx<a)
			mx=a;
	}
	sort(throws.begin(), throws.end(), greater<long long>());

	auto it=throws.begin();
	while(h>0){
		if(*it<mx)
			break;
		h-=(*it);
		moves++;
		++it;
	}

	if(h>0){
		A = (h-total)/mx;
		if((h-total)%mx!=0)
			A++;
	}
	cout<<moves+A;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int MAXN = 1e5;
ll p[MAXN], sz[MAXN];
ll ans;

int find(int i){
  if(p[i]!=i) p[i] = find(p[i]);
  return p[i];
}

void join(int a, int b){
  a=find(a); b=find(b);
  if(a!=b){
    ans+=sz[a]*sz[b];
    if(sz[a]>=sz[b]) sz[a]+=sz[b], p[b]=a;
    else sz[b]+=sz[a], p[a]=b;
  }
}

int main(){FIN;
  ll n,m; cin >> n >> m; ll tot=n*(n-1)/2;
  fore(i,0,n) p[i]=i,sz[i]=1;
  vector<ll> v; vector<ii> e;
  fore(i,0,m){
    int x,y; cin >> x >> y; x--; y--;
    e.pb({x,y});
  }
  reverse(ALL(e));
  for(auto x:e){
    v.pb(tot-ans);
    join(x.fst,x.snd);
  }
  reverse(ALL(v));
  for(auto x : v) cout << x << "\n";
}

Measured memory_bytes: 4596
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>
#define INT_MAX 2000000000

using namespace std;
int main()
{
  int x;
  cin>>x;
  if(x>= 30)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;}


Measured memory_bytes: 3672
n = int(input())
for i in range(n):
	o_count = 0
	h_count = 0
	score = 0
	while True:
		site = input()
		if site == 'OUT':
			o_count += 1
			if o_count == 3:
				print(score)
				break
		elif site == 'HIT':
			if h_count == 3:
				score += 1
			else:
				h_count += 1
		else:
			score += h_count+1
			h_count = 0

Measured memory_bytes: 7628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint x(n);
    vint y(n);
    vint h(n);
    REP(i,n){
        int t1,t2,t3;
        cin >> t1 >> t2 >> t3;
        x[i]=t1;
        y[i]=t2;
        h[i]=t3; 
    }
    int ha=0;
    REP(i,101){
        REP(j,101){
            int k=0;
            for(;k<n;k++){
                if(h[k]>0){
                    ha = h[k]+abs(i-x[k])+abs(j-y[k]);
                    break;
                }else if(k==n-1){
                    ha = 1;
                    break;
                }
            }
            bool f = true;
            for(k=0;k<n;k++){
                if(ha-h[k]==abs(i-x[k])+abs(j-y[k])||(abs(i-x[k])+abs(j-y[k])>=ha&&h[k]==0)){
                    
                }else{
                    f=false;
                    break;
                }
            }
            if(f){
                cout << i << " " << j << " " << ha << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
//#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(){

	int a, b, c;
	cin >> a >> b >> c;
	int result = 0;
	for (int i = a; i <= b; i++){
		if (c%i == 0)result++;
	}

	cout << result << endl;
	return 0;
}

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

int main() {
	int n;
	cin>>n;
	string a[n];
	map<string,int> m;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    m[a[i]]++;
	    
	}
	vector<int> v;
	for(int i=0;i<n;i++){
	    v.push_back(m[a[i]]);
	}
	sort(v.begin(),v.end());
	 int z=v[v.size()-1];
	 for(auto it=m.begin();it!=m.end();it++){
	     if(it->second==z){
	         cout<<it->first<<endl;
	     }
	 }
	
	return 0;
}

Measured memory_bytes: 27640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

const LL inf = 1000000000000000;
const LL mod = 1000000007;

int main()
{
	LL n, s = 0;
	cin >> n;
	vector<LL> a(n);

	for (auto &e : a) {
		cin >> e;
		s += e;
	}

	LL s1 = 0, s2 = 0;
	for (int i = 0; i < n; ++i) {
		s1 += a[i];
		if (s1 >= (s+1)/2) {
			break;
		}
	}

	for (int i = n-1; i >= 0; --i) {
		s2 += a[i];
		if (s2 >= (s+1)/2) {
			break;
		}
	}

	cout << min (2*s1-s, 2*s2 - s) << endl;


}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int a,b,c,d,n;
	int succed;

	while( cin >> n ){
		succed = 0;
		for( a = 0;a <= 9;a++ ){
			for( b = 0;b <= 9;b++ ){
				for( c = 0;c <= 9;c++ ){
					for( d = 0;d <= 9;d++ ){
						if( a + b + c + d == n ) succed++;
					}
				}
			}
		}
		cout << succed << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int m, n, in[128];
int dp[1600000], pw[13];

int rec(int bit){
	int &res = dp[bit];
	if(res >= 0) return res;
	
	int t[13] = {}, cnt = 0;
	rep(j, m) t[j] = bit / pw[j] % 3;
	rep(i, n){
		bool ok = 1;
		rep(j, m) if(t[j] < 2 && (in[i] >> j & 1) != t[j]){
			ok = 0;
			break;
		}
		if(ok) cnt++;
	}
	if(cnt <= 1) return res = 0;
	res = inf;
	rep(i, m) if(t[i] == 2){
		res = min(res, 1 + max(rec(bit - 2 * pw[i]), rec(bit - pw[i])));
	}
	return res;
}
int main(){
	pw[0] = 1;
	rep(i, 12) pw[i + 1] = pw[i] * 3;
	while(cin >> m >> n, m){
		rep(i, n){
			char buf[20];
			cin >> buf;
			in[i] = 0;
			rep(j, m) if(buf[j] == '1') in[i] |= 1 << j;
		}
		memset(dp, -1, sizeof(dp));
		cout << rec(pw[m] - 1) << endl;
	}
	return 0;
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >>D;
  if (A * B > C * D) {
  cout << A * B << endl;
  }
  else if (A * B < C * D) {
    cout << C * D << endl;
  }
  else {
    cout << A * B << endl;
  }
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int n, m;
    scanf("%d %d", &n, &m);
    if (n > m) swap(n, m);
    if (n == 1) {
        if (m == 1)
            puts("1");
        else
            printf("%d\n", m - 2);
    } else {
        printf("%lld\n", (n - 2) * 1LL * (m - 2));
    }
    return 0;
}



Measured memory_bytes: 256
import math
from functools import reduce

K=int(input())

ans = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in range(1, K+1):
  for j in range(1, K+1):
    for k in range(1, K+1):
      ans += gcd(i, j, k)

print(ans)


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

string s;

int main()
{

	cin >>s;
	if(s == "Sunny")cout<<"Cloudy"<<endl;
	else if(s == "Cloudy")cout<<"Rainy"<<endl;
	else if(s == "Rainy")cout<<"Sunny"<<endl;

	return 0;
}

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

//-----------------------
const int MOD = (int)1e9 + 7;
struct mint { int n; mint(int n_ = 0) : n(n_ % MOD) { if (n < 0) n += MOD; } };
mint operator+(mint a, mint b) { return (a.n += b.n) >= MOD ? a.n - MOD : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + MOD : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &os, mint a) { return os << a.n; }
istream &operator>>(istream &is, mint& a) { return is >> a.n; }
mint inv(mint x) { long long a = x.n, b = MOD, u = 1, v = 0;
    while (b) { long long t = a/b; swap((a -= t*b), b); swap((u -= t*v), v); }
    return mint(u); }
mint operator^(mint a, long long n) { mint r = 1;
    while (n) { if (n & 1) r *= a; a *= a; n >>= 1; } return r; }
bool operator<(const mint &a, const mint &b) { return a.n < b.n; }
//-----------------------

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<vector<mint>> dp(n, vector<mint>(n));
    dp[0].assign(n, 1);
    for (int i = 1; i < n; i++) {
        vector<mint> acc(n + 1);
        for (int less = 0; less < n; less++) {
            acc[less + 1] = acc[less] + dp[i - 1][less];
        }
        for (int less = 0; less < n - i; less++) {
            if (s[i - 1] == '<') dp[i][less] = acc[less + 1];
            else dp[i][less] = acc[n] - acc[less + 1];
        }
    }
    cout << dp[n - 1][0] << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
#include "atcoder/all"

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<P> v(n);
    for (P &p:v) cin >> p.first >> p.second;

    atcoder::two_sat ts(n);

    rep(i, n) {
        rep(j, n) {
            if (i <= j) continue;
            int ia = v[i].first;
            int ib = v[i].second;
            int ja = v[j].first;
            int jb = v[j].second;

            if (abs(ia - ja) < d) {
                ts.add_clause(i, false, j, false);
            }
            if (abs(ia - jb) < d) {
                ts.add_clause(i, false, j, true);
            }
            if (abs(ib - ja) < d) {
                ts.add_clause(i, true, j, false);
            }
            if (abs(ib - jb) < d) {
                ts.add_clause(i, true, j, true);
            }
        }
    }

    if (!ts.satisfiable()) {
        cout << "No" << endl;
        ret();
    }

    cout << "Yes" << endl;
    auto answer = ts.answer();
    rep(i, n) cout << (answer[i] ? v[i].first : v[i].second) << endl;


}


Measured memory_bytes: 3744
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 2e5 + 48, mod = 1e9 + 7;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, h[N], dp[N];

main () {
	cin >> n;
	forn (i, 1, n)
		cin >> h[i];	
	forn (i, 2, n)
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), i < 3 ? inf : dp[i - 2] + abs(h[i] - h[i - 2]));		

	cout << dp[n];
} 

Measured memory_bytes: 1024
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}


int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    cin >> s;
    cin >> t;
    int n=s.size();
    int ans=0;
    for(int i=0; i<n; i++)
        if(s[i]!=t[i])
            ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
using namespace std;

typedef long long ll;

int main(){
   int N;
   cin >> N;
   vector<int> v;
   for(int i = 0; i < N; i++){
       int A;
       cin >> A;
       if(v.size() == 0){
           v.push_back(A);
       } else if(A > v[0]){
           v[0] = A;
       } else if(v[v.size()-1] >= A){
           v.push_back(A);
       } else {
           int l = -1, r = v.size();
           while(r-l > 1){
               int m = (l+r)/2;
               if(v[m] >= A){
                   l = m;
               } else  r = m;
           }
           v[r] = A;
       }
   }

   cout << v.size() << endl;
}



Measured memory_bytes: 892
#088_C
c = [list(map(int, input().split())) for _ in range(3)]
b1, b2, b3 = c[0]
flg = True
for i in range(1,3):
    if c[i][0] - b1 == c[i][1] - b2 == c[i][2] - b3:
        continue
    else:
        flg =False
print('Yes' if flg else 'No')

Measured memory_bytes: 3060
// 2011/01/26 Tazoe

#include <iostream>
using namespace std;

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

	long long sum = 0;
	for(int i=0; i<n; i++){
		long long val;
		cin >> val;
		sum += val;
	}

	cout << sum/(long long)n << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long n,sum,a;
int main()
{
    /*a=1e9;
    sum=500%a;
    cout << sum;
    */
   cin >> n;
   for(long long i=n-1;i>0;i--){
    sum+=i;
   }
   cout << sum;

    return 0;
}


Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int a,b,n;
    cin>>a>>b>>n;

    int ans=(a*min(b-1,n))/b;
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3568
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > 12)
		printf("%d\n", b);
	else if (a > 5)
		printf("%d\n", b / 2);
	else
		puts("0");
	return 0;
}

Measured memory_bytes: 128
c = [list(map(int, input().split())) for _ in range(3)]

a1 = 0
b1 = c[0][0] - a1
b2 = c[0][1] - a1
b3 = c[0][2] - a1
a2 = c[1][0] - b1
a3 = c[2][0] - b1

ans = [
    [a1+b1, a1+b2, a1+b3],
    [a2+b1, a2+b2, a2+b3],
    [a3+b1, a3+b2, a3+b3]
]

for i in range(3):
    for j in range(3):
        if c[i][j] == ans[i][j]:
            pass
        else:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 9136
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int W=in(),H=in(),X=in(),Y=in(),R=in();
	if(X-R<0 || X+R>W || Y-R<0 || Y+R>H) out("No");
	else out("Yes");
	
	return 0;
}



Measured memory_bytes: 3192
#include<cstdio>
#include<algorithm>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
using namespace std;
typedef long long ll;
ll s;
int a[210],b[50+5],c[210];
int i,j,k,l,t,n,m,mx,tot,top,now;
int main(){
    scanf("%lld",&s);
    mx=50;
    while((1ll<<mx)>s)--mx;
    s-=(1ll<<mx),m=mx,tot=2*m,now=m;
    c[++top]=++now,c[++top]=now,tot+=2;
    while(s){
        while((1ll<<mx)>s)--mx;
        s-=(1ll<<mx),b[mx]=++now,c[++top]=now,tot+=2;
    }
    printf("%d\n",tot);
    rep(i,0,m){
        if(i)printf("%d ",i);
        if(b[i])printf("%d ",b[i]);
    }
    rep(i,1,m)printf("%d ",i);
    rep(i,1,top)printf("%d ",c[i]);
    return 0;
}

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

int main(){
  int n, l;
  cin >> n >> l;
  long long int ans;
  ans = l*n + n*(n+1)/2 - n;
  if(l+n-1 < 0) ans -= l+n-1;
  else if(l > 0) ans -= l;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
import fractions

N, X = [int(k) for k in stdin.readline().rstrip().split()]
x = [int(k) for k in stdin.readline().rstrip().split()]
y = [abs(k - X) for k in x]
C = y[0]
for l in range(N):
    C = fractions.gcd(C, y[l])
print(C)

Measured memory_bytes: 16276
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back

const int N = 101010;

using namespace std;

vector<int> g[N];
vector<ll> v[N], be[N], en[N];
ll dp[N], ans[N];

int n, M;

ll dfs1(int i, int p){
	dp[i] = 1;
	for(int j : g[i]){
		if(j!=p){
			ll tmp = (dfs1(j, i)+1)%M;
			v[i].pb(tmp);
			dp[i] = (dp[i]*tmp)%M;
		} else v[i].pb(-1);
	}
	return dp[i];
}

void dfs2(int i, int p, ll a){
	int z = v[i].size();
	if(z){
		be[i].resize(z);
		en[i].resize(z);
		be[i][0] = 1;
		en[i][z-1] = 1;
	}
	for(int j=1; j<z; j++){
		if(v[i][j-1] < 0) be[i][j] = (be[i][j-1]*a)%M;
		else be[i][j] = (be[i][j-1]*v[i][j-1])%M;
	}
	for(int j=z-2; j>=0; j--){
		if(v[i][j+1] < 0) en[i][j] = (en[i][j+1]*a)%M;
		else en[i][j] = (en[i][j+1]*v[i][j+1])%M;
	}

	ans[i] = 1;

	for(int j=0; j<z; j++){
		if(v[i][j] < 0){
			ans[i] = (ans[i]*a)%M;
			continue;
		} else ans[i] = (ans[i]*v[i][j])%M;
		int k = g[i][j];
		dfs2(k, i, (be[i][j]*en[i][j]+1)%M);
	}
}

int main(){

	cin >> n >> M;
	for(int i=1; i<n; i++){
		int a, b;
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}

	dfs1(1, 0);
	dfs2(1, 0, 1);

	for(int i=1; i<=n; i++) cout << ans[i] << '\n';

	return 0;
}


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

const int MAX = 1<<17;
bool ifnprime[MAX+1];
long long int p[MAX];
long long int ind = 0;

void set(){
    ifnprime[0] = ifnprime[1] = true;
    long long int n,m;
    for(n=2;n<=MAX;n++){
        if(!ifnprime[n]){
            p[ind] = n;
            ind++;
            for(m=n*n;m<=MAX;m+=n) ifnprime[m] = true;
        }
    }
}

int main(){
    set();
    int n,fault=0;
    for(cin>>n;n--;){
        long long int a,x;
        bool ok = false;
        cin >> a;
        a = 2*a+1;
        for(x=0;p[x]*p[x]<=a;x++){
            if(a%p[x]==0){
                ok = true;
                break;
            }
        }
        if( !ok ) fault++;
    }
    cout << fault << endl;
    return 0;
}

Measured memory_bytes: 1396
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define badi_val 1000000007
int n;
int pd[1100];
const int mo=1e9+7;
int main(){
	int n , a , b;
	cin >> n >> a >> b;
	long long arr[n];
	for(int i = 0 ; i < n ; i++)
		cin >> arr[i];
	//sort(arr , arr + n);
	long long ans = 0;
	for(int i = 0 ; i < n - 1;i++){
		ans += min((arr[i+1] - arr[i])*a*1ll , b*1ll);
	}
	cout << ans << endl;
 	return 0; 
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
signed main() {
	string s; cin >> s;
	int sum = 0, n = 0;
	for0(i, s.size()) {
		if (s[i] == '<') {
			sum += n;
			n++;
		}
		else {
			int cnt = 0;
			while (i < s.size() && s[i] == '>'){
				i++; cnt++;
			}
			sum += cnt * (cnt + 1) / 2 + max((int)0, n - cnt);
			n = 0; i--;
		}
	}
	cout << sum+n << endl;
}

Measured memory_bytes: 900
#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);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

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

	priority_queue<P,vector<P>,greater<P>> p;

	rep(i, n) {
		int a, b;
		cin >> a >> b;
		p.push(make_pair(a, b));
	}

	priority_queue<int,vi,less<int>> pq;
	int ans = 0;

	rep1(i, m) {
		if (p.size() > 0)while (p.top().first <= i) {
			pq.push(p.top().second);
			p.pop();
			if (p.size() == 0)break;
		}
		if (pq.size() > 0){ans += pq.top();pq.pop();}
	}

	cout << ans << endl;

}

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

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

  vector<int> A(N);
  int A_total=0;
  for (int i=0; i<N; i++){
    cin >> A.at(i);
    A_total += A.at(i);
  } 

  int choise=0;
  for(int i=0; i<N; i++){
    if(4*M*A.at(i) >= A_total) choise++; 
  }

  if(choise>=M) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


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

int N;
vector<long long> a;
int main(){
  cin >> N;
  a.resize(N);
  long long S = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    S += a[i];
  }
  long long b = 0;
  long long ans = 1e18;
  for(int i = 0; i < N - 1; i++){
    b += a[i];
    ans = min( ans, abs(S - 2 * b) );
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
	int n, a, b, c, i, yn[1001] ={};
	
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		scanf("%d %d %d", &a, &b, &c);
		if(a*a==b*b+c*c){
			yn[i] = 1;
		} else if(b*b==a*a+c*c){
			yn[i] = 1;
		} else if(c*c==a*a+b*b){
			yn[i] = 1;
		}
	}
	for(i=0; i<n; i++){
		if(yn[i] == 1){
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int s[100001];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q;
    cin >> q;
    vector<char> is_prime(100001, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= 100000; ++i)
        if (is_prime[i])
            for (int j = i * i; j <= 100000; j += i)
                is_prime[j] = false;

    for (int i = 1; i <= 100000; i += 2)
    {
        if (i > 1) s[i] += s[i - 2];
        if (is_prime[i] && is_prime[(i + 1) / 2])
            s[i]++;
    }
    
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << s[r] - (l > 1 ? s[l - 2] : 0) << '\n';
    }
}


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

typedef long long int lli;

int main(){
	for(;;){
		int n,m;
		scanf("%d%d",&n,&m);
		if(n==0)break;
		vector<lli> ss(n),ds(m);
		rep(i,n)scanf("%lld",&ss[i]);
		rep(i,m)scanf("%lld",&ds[i]);
		//sort(ds.begin(),ds.end());
		
		vector<lli> dp(1<<n);
		rep(i,1<<n){
			if(i==0){
				dp[0]=0;
				continue;
			}
			lli s=0;
			rep(j,n){
				if(i&(1<<j))s+=ss[j];
			}
			
			lli v=LLONG_MAX;
			rep(j,n){
				if(i&(1<<j)){
					int ti=i-(1<<j);
					lli ts=s-ss[j];
					lli tv=dp[ti];
					for(auto d : ds){
						if(ts<=d && d<=s){
							tv += min(s-d,d-ts);
						}
					}
					v = min(v,tv);
				}
			}
			dp[i]=v;
		}
		
		lli ans=dp[(1<<n)-1];
		lli cs=0;
		for(auto s : ss)cs += s;
		for(auto d : ds){
			if(cs<=d)ans += d-cs;
		}
		printf("%lld\n",ans);
	}
}





Measured memory_bytes: 3456
import bisect
import sys,io
import math
from collections import deque
from heapq import heappush, heappop

input = sys.stdin.buffer.readline

def sRaw():
    return input().decode("utf-8").rstrip("\n").rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    S= sRaw()
    T =sRaw()
    ans = 10**10
    for sidx in range(0,len(S)-len(T)+1):
        score = sum([1 for idx in range(len(T)) if S[sidx+idx]!=T[idx]])
        ans=min(score,ans)
    print(ans)

main()


Measured memory_bytes: 68036
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

N=int(input())
A=list(map(int,input().split()))
ans=0
while all(a%2==0 for a in A):
	A=[a/2 for a in A]
	ans+=1
print(ans)
		

Measured memory_bytes: 3060
@words = %w[dreamer dream eraser erase]

def detect(s, idx)
  @words.each do |w|
    return w.size if idx >= w.size && s[idx - w.size, w.size] == w
  end
  nil
end

s = gets.chomp
idx = s.size
while 0 < idx
  nxt = detect(s, idx)
  break if nxt.nil?
  idx -= nxt
end

puts idx == 0 ? "YES" : "NO"

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

#define ll long long

using namespace std;

string s;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int k;
	cin >> s >> k;
	set<string> sett;
	for (int i = 0; i < s.size(); i++) {
		string temp = "";
		for (int j = i; j < s.size(); j++) {
			temp += s[j];

			sett.insert(temp);
			auto it = sett.find(*sett.rbegin());
			
			if (sett.size() > k)
				sett.erase(it);

			if (temp.size() > k)
				break;
		}
	}

	cout << *sett.rbegin() << endl;

	return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {
    static final int UNCALC = -1;
    static final int INF = (int) 1e9;
    static double[] p;
    static double memo[][];
    static int n;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n = sc.nextInt();
        p = sc.nextDoubleArray(n);
        memo = new double[n][n + 1];
        for (double[] a : memo)
            Arrays.fill(a, UNCALC);
        out.println(dp(0, 0));
        out.flush();
        out.close();

    }

    static double dp(int i, int heads) {
        if (i == n)
            return heads > n / 2 ? 1 : 0;
        if (memo[i][heads] != UNCALC)
            return memo[i][heads];
        return memo[i][heads] = p[i] * dp(i + 1, heads + 1) + (1 - p[i]) * dp(i + 1, heads);
    }


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public Scanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

    }
}

Measured memory_bytes: 131920