akhauriyash/Code-Regression huggingface dataset:
/*********************************************************************| 
|---------|    /\  ....                  ....                         |         
     |        /  \   \                    /  /------| ----- |-------| |
     |       /    \   \                  /  /           |   |         |
     |      /      \   \       /\       /  |            |   |         |
     |     /        \   \     /  \     /   |---|        |   |----|    |
     |    /__________\   \   /    \   /        |---|    |   |         |
     |   /            \   \ /      \ /              |   |   |         |
     |  /              \   |        |               /   |   |         |
     _ __              __ ...      ...      |------/  ----- _         |
                                                                      |  
        Md Tawsif Rahman                                              |
        Institute Of Information Technology                           |
        Jahangirnagar University                                      |                                                                         
                                                                      |
**********************************************************************/                 
#include<bits/stdc++.h>

using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define pii pair <int, int>
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii > 
#define inf  100000000 
#define f(i, c, n) for(i = c; i < n; i++)
#define fe(i, c, n) for(i = c; i <= n; i++)
#define fr(i, n, c) for(i = n - 1; i >= c; i--) 
#define vbe(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(vbe(a), x) - a.begin())
#define UB(a, x) (upper_bound(vbe(a), x) - a.begin())

#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
int i, j, temp;
// int convert_str_to_int(string s) {
//     stringstream str(s);
//     int x = 0;
//     str >> x;
//     return x;
// }


/********************|
                     |
   START HERE        |
                     |
*********************/
map < int, int > m1, m2;

void solve() {
    int n;
    cin >> n;
    int arr[n + 10];
    f(i, 1, n + 1) {
        cin >> arr[i];
    }
    int val[n + 10];
    
    f(i, 1, n + 1) {
        val[i] = i + arr[i];
        m1[i + arr[i]]++;
        m2[i - arr[i]]++;
    }
    ll cnt = 0;
    f(i, 1, n + 1) {
        cnt += m2[val[i]];

    }
    cout << cnt << endl;
   
} 

int main() {
    fast;
    // int t; cin >> t; while(t--)
    solve(); 

}

Measured memory_bytes: 30940
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0 ; i < n ; i++)
        cin >> x[i];
    
    vector<int> sum(100);
    for(int p = 0 ; p < 100 ; p++)
        for (int i = 0; i < n; i++)
        {
            sum[p] += (x[i] - p)*(x[i] - p);
        }
    
    sort(sum.begin(),sum.end());

    cout << sum[0] << endl;
  
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        X: i64,
        Y: i64,
    }
    println!("{}",X+Y/2);
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
  
const int ppr = 257;
const ll INF = 2e18;
const int inf = 998244353;
const int mod = 1e9 + 7;
const int N = 1e5 + 123;
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, p[N];
double x[N], y[N];

double fac(int x) {
	double res = 1;
	for(int i = 1; i <= x; i++)
		res *= double(i + 0.0);
	return res;
}
   
main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);

//	srand(time(NULL));

	cin >> n;

	for(int i = 1; i <= n; i++)
		p[i] = i;

	for(int i = 1; i <= n; i++)
		cin >> x[i] >> y[i];

	double mn = -1.0;

	double s = 0;
	do {
		for(int i = 1; i < n; i++) {
			int a = p[i];
			int b = p[i + 1];
			double X = (x[a] - x[b]);
			double Y = (y[a] - y[b]);
			s += sqrt((double(X * 1.0 * X) + double(Y * 1.0 * Y)));
		}
	} while(next_permutation(p + 1, p + n + 1));

	cout << fixed << setprecision(10) << (s/fac(n));

    return 0;                                        
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

X = int(input())

for i in range(X, 10 ** 6):
    check = factorization(i)
    l = len(check)
    if l == 1 and check[0][1] == 1:
        print(i)
        exit()

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	//field
	static int loadSize, truck;
	static int[] input;


	//5-6
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		loadSize = sc.nextInt();
		truck = sc.nextInt();
		input = new int[loadSize];

		for(int i = 0; i < loadSize; i++) {
			input[i] = sc.nextInt();
		}

		int answer = solve();
		System.out.println(answer);
	}

	private static int solve() {
		int left = 0;
		int right = 100000 * 10000;
		while(right > left + 1) {
			int mid = (left + right) / 2;
			int v = search_maxv(mid);
			if(v >= loadSize) {
				right = mid;
			}else {
				left = mid;
			}
		}
		return right;
	}

	private static int search_maxv(int P) {
		int v = 0;
		for(int i = 0; i < truck; i++) {
			int w = 0;
			while( w + input[v] <= P) {
				w += input[v];
				v++;
				if(v == loadSize) {
					return v;
				}
			}
		}
		return v;
	}

}



Measured memory_bytes: 71404
#include<stdio.h>

int MakeCombination(int,int);
int A[2001], mi[2001];
int n;

int main(){
   int i,q,j=0;
   int search;

   scanf("%d",&n);
   for(i=0 ; i<n ; i++) scanf("%d",&A[i]);

   scanf("%d",&q);
   for(i=0 ; i<q ; i++) scanf("%d",&mi[i]);

   for(i=0 ; i<q ; i++){
      search = MakeCombination(0,mi[i]);
      if(search == 1)printf("yes\n");
      else if (search == 0)printf("no\n");
   }
   return 0;
}


int MakeCombination(int i,int m){
  int res;
   if(m == 0) return 1;
   if(i >= n) return 0;
   if (res=MakeCombination(i+1,m))return res;
   if (res=MakeCombination(i+1,m-A[i]))return res;
return res;
}

Measured memory_bytes: 584
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  cout<<N*800-(N/15)*200<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d,f1,f2,f3;
    string s1,s2;
    cin>>s1;
    k=s1[0]-'0';
    l=s1[1]-'0';
    a=k*10+l;
    k=s1[2]-'0';
    l=s1[3]-'0';
    b=k*10+l;
    f1=f2=f3=-1;
    if(b>=1&&b<=12)
    {
        f1=1;
    }
    if(a>=1&&a<=12)
    {
        f2=1;
    }
    if(f1==1&&f2==1)
    {
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(f1==1&&f2==-1)
    {
        cout<<"YYMM"<<endl;
    }
    else if(f1==-1&&f2==1)
    {
        cout<<"MMYY"<<endl;
    }
    else if(f1==-1&&f2==-1)
    {
        cout<<"NA"<<endl;
    }
    return 0;

}



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

namespace ConsoleApplication51
{
    class Program
    {
        static void Main()
        {
            int[] a = new int[10];
            int[] b = new int[10];
            for(int c = 0; c < 10; c++)
            {
                a[c] = int.Parse(Console.ReadLine());
            }
            for (int c = 0; c < 10; c++)
            {
                b[c] = int.Parse(Console.ReadLine());
            }
            Array.Sort(a);
            Array.Sort(b);
            Console.WriteLine("{0} {1}",a[9]+a[8]+a[7],b[9]+b[8]+b[7]);
        }
    }
}

Measured memory_bytes: 9312
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
	int N, Q;
	string S;
	cin >> N >> Q >> S;
	vector<int> l(Q), r(Q);
	for(int i=0; i<Q; i++)
		cin >> l[i] >> r[i];

	vector<int> A(N-1);
	for(int i=0; i<N-1; i++){
		if(S[i] == 'A' && S[i+1] == 'C'){
			A[i] = 1;
		}
		else{
			A[i] = 0;
		}
	} 
	
	vector<int> Count(N);
	Count[0] = 0;
	//int num = 0;
	for(int i=1; i<N; i++){
		//num += A[i-1];
		//Count[i] = num;
		Count[i] = Count[i-1] + A[i-1];
	}


	
	for(int i=0; i<Q; i++){
		//for(int j=l[i] - 1; j < r[i] - 1; j++){
		//	count += A[j];
		//}
		cout << Count[r[i] - 1] - Count[l[i] - 1] << endl;
	}
}

Measured memory_bytes: 2688
#include <stdio.h>

int main(void)
{
	long long n;
	int keta;
	long long ans;
	
	while (1){
		scanf("%lld", &n);
		if (n == -1){
			break;
		}
		
		keta = 1;
		ans = 0;
		while (n != 0){
			ans += keta * (n % 4);
			n /= 4;
			keta *= 10;
		}
		printf("%lld\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}


signed main() {
  ll N;
  cin >> N;
  typedef pair<ll, ll> P;
  vector<P> XL(N);
  rep(i, N) {
    cin >> XL[i].fi >> XL[i].se;
    XL[i].fi += XL[i].se;
  }
  sort(all(XL));

  ll L = -LINF;
  int ans = 0;
  rep(i, N) {
    if (XL[i].fi - 2 * XL[i].se >= L) {
      ans++;
      L = XL[i].fi;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1792
while line = gets
  line = line.chomp
  26.times do
    line = line.gsub(/[a-z]/){|char| char == 'z' ? 'a' : char.succ }
    words = line.split
    if words.include?('the') || words.include?('this') || words.include?('that')
      puts line
      break
    end
  end
end

Measured memory_bytes: 8668
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		String S = scan.next();
		if(S.length()<=K) {
			System.out.println(S);
		}else if(S.length()>K) {
			String ans = S.substring(0,K);
			System.out.println(ans+"...");
		}

	}

}


Measured memory_bytes: 38576
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
string s;

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

    llong ans = 0;
    for (int i = 0; i < s.size() - 2; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
const int M = (1e7);
bool p[M];
void isPrime(){
  rep(i,M)p[i] = true;
  p[0] = p[1] = false;
  loop(i,2,M){
    if(p[i])
      for(int j = i + i ; j < M ; j += i)
	p[j] = false;
  }
}
int main(void){
  isPrime();
  int Q[4] = {-8,-6,-2,0};
  int n;
  while(cin>>n,n){
    if(n%2==0)n--;
    for(int i = n ; ; i -=2){
      bool find = true;
      rep(j,4)if(!p[i+Q[j]])find = false;
      if(find){
	cout<<i<<endl;
	break;
      }
    }
  }
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll K, X;
  cin >> K >> X;
  if(500*K >= X){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int r,c,i,j;
  static int s[101][101];
 
  scanf("%d%d",&r,&c);
 
  for(i=0;i<=r;i++){
    for(j=0;j<c;j++){
      scanf("%d", &s[i][j]);
      printf("%d ", s[i][j]);
      s[i][c] += s[i][j];
      s[r][j] += s[i][j];
    }
    printf("%d\n",s[i][c]);
  }
 
  return 0;
}


Measured memory_bytes: 2108
N = int(input())
F = [[int(x) for x in input().split()] for _ in range(N)]
P = [[int(x) for x in input().split()] for _ in range(N)]
res = -10000000000
for b in range(1,1024):
    profit = 0
    for i in range(N):
        c = 0
        for j in range(10):
            if (b >> j) % 2 == 1 and F[i][j] == 1:
                c += 1
        profit += P[i][c]
    res = max(res, profit)
print(res)


Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N){
    vector<vll> G(N);
    if(N % 2){
        REP(i, N){
            REP(j, N){
                if(i==j) continue;
                if(i+j==N-2) continue;
                G[i].push_back(j); 
            }
        }
    }else{
        REP(i, N){
            REP(j, N){
                if(i==j) continue;
                if(i+j==N-1) continue;
                G[i].push_back(j); 
            }
        } 
    }
    ll num=0;
    REP(i, N) num+= G[i].size();
    num/=2;
    cout<<num<<endl;
    REP(i, N){
        for(auto j:G[i]){
            if(i<j) cout<<i+1<<" "<<j+1<<endl;
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)
{
	if (a < b)
		swap(&a, &b);

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

int lcm(int a, int b)
{
	return a*b/gcd(a, b);
}

void bubble_sort(int* p, int n)
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[j], &p[j + 1]);
		}
	}
}

int array_max(int* p, int n)
{
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i] > max)
			max = p[i];
	}
	return max;
}

int binary_search(int* p, int key, int n)
{
	int low = 0, high = n - 1;
	int middle;

	while (low <= high)
	{
		middle = (low + high) / 2;

		//printf("low %d  middle %d  high %d\n", low, middle, high);

		//for (int i = 0; i < n; i++)
		//{
		//	if (i == middle)
		//		printf(" ^ ");
		//	else if (i == low)
		//		printf(" [ ");
		//	else if (i == high)
		//		printf(" ] ");
		//	else if (i == middle)
		//		printf(" ^ ");
		//	else
		//		printf("   ");
		//}
		//printf("\n");

		if (key == p[middle])
			return key;
		else if (key < p[middle])
			high = middle - 1;
		else if (key > p[middle])
			low = middle + 1;
	}

	//printf("low %d  middle %d  high %d\n", low, middle, high);
	return -1;
}

int main()
{
	char S[101];
	char T[101];

	scanf("%s%s", S, T);

	printf("%s%s\n", T, S);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

int main(){
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(A[i] == B[i] && A[i] == C[i]){
            continue;
        }else if(A[i] == B[i] || A[i] == C[i] || B[i] == C[i]){
            cnt++;
        }else{
            cnt += 2;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s(int i,int n,int m,int*b){
	if(n==0)
	return 1;
	if(i>m)
	return 0;
	return s(i+1,n-b[i],m,b)||s(i+1,n,m,b);
}
int main(){
	int n,m,a[22],b[202],i,j,k;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>a[i];
	cin>>m;
	for(i=1;i<=m;i++){
		cin>>b[i];
		if(s(1,b[i],n,a))
		cout<<"yes\n";
		else
		cout<<"no\n";
	}
	return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int H,W,h,w;
    cin >> H >> W;
    cin >> h >> w;
    cout << H*W-(H*w+W*h)+h*w << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll x;
    cin>>x;
    if(x>=1800){
        cout<<1<<endl;
    }else if(x>=1600){
        cout<<2<<endl;
    }else if(x>=1400){
        cout<<3<<endl;
    }else if(x>=1200){
        cout<<4<<endl;
    }else if(x>=1000){
        cout<<5<<endl;
    }else if(x>=800){
        cout<<6<<endl;
    }else if(x>=600){
        cout<<7<<endl;
    }else{
        cout<<8<<endl;
    }
}


Measured memory_bytes: 3648
#! /usr/bin/python3

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

a, b = [], []
ok = [False for x in range(n + 1)]

for i in range(m):
    x, y = map(int, input().split())
    a += [x]
    b += [y]
    if x == 1:
        ok[y] = True

for i in range(m):
    x, y = a[i], b[i]
    if ok[x] and y == n:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")




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

int main() {
    int t[5];
    for (int i = 0; i < 5; i++) {
        cin >> t[i];
    }
    
    int T[5];
    for (int i = 0; i < 5; i++) {
        if (t[i] % 10 == 0) {
            T[i] = 0;
        }
        else {
            T[i] = 10 - (t[i] % 10);
        }
    }
    
    int marume = 0;
    int Temp = 0;
    for (int i = 0; i < 5; i++) {
        Temp = max(marume, T[i]);
        marume = Temp;
    }
    
    int sum = 0;
    for (int i = 0; i < 5; i++) {
        sum += t[i] + T[i];
    }
    
    cout << sum - marume << endl;
}

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

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

    vector<int> A(N);
    int mx = 0;
    set<int> dup;
    int a;

    for(int i = 0; i < N; i++) {
        cin >> a;
        A.at(i) = a;
        mx = max(mx, a);
    }

    vector<bool> z(mx + 1, false);
    for(int i = 0; i < N; i++) {
        a = A.at(i);
        for(int j = a * 2; j <= mx; j += a) {
            z.at(j) = true;
        }
        if(dup.count(a)) {
            z.at(a) = true;
        }
        dup.insert(a);
    }

    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(!z.at(A.at(i))) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";

bool check753(int t) {
    bool check3 = false, check5 = false, check7 = false;
    while (t > 0) {
        if ( t % 10 == 3 ) check3 = true;
        if ( t % 10 == 5 ) check5 = true;
        if ( t % 10 == 7 ) check7 = true;
        t /= 10;
    }
    return (check3 && check5 && check7);
}

int main() {

    CIN(int, N);

    queue<pair<int, bool>> temp;
    vector<int> A(5 * 1e4, 1e9);

    int i = 0;
    temp.push(make_pair(3, false));
    temp.push(make_pair(5, false));
    temp.push(make_pair(7, false));

    while ( !temp.empty() ) {
        pair<int, int> p = temp.front();
        temp.pop();
        if ( p.first > 1e8 ) continue;

        int n;
        bool c = false;

        n = p.first * 10 + 3;
        if (!p.second) c = check753(n);
        if (p.second || c) {
            A[i] = n;
            i++;
        }
        temp.push(make_pair(n, c));

        n = p.first * 10 + 5;
        if (!p.second) c = check753(n);
        if (p.second || c) {
            A[i] = n;
            i++;
        }
        temp.push(make_pair(n, c));

        n = p.first * 10 + 7;
        if (!p.second) c = check753(n);
        if (p.second || c) {
            A[i] = n;
            i++;
        }
        temp.push(make_pair(n, c));
    }
    
    int ans = 0;
    for (int j = 0; j <= i; j++) {
        if (A[j] <= N) {
            ans++;
        } else {
            break;
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int x,a;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>x>>a;
	cout<<(x<a?0:10)<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys


def main():
    num = int(input())
    data = list(map(int, input().split()))
    half1, half2 = sum(data) // num, sum(data) // num + 1

    ans1 = 0
    for i in range(num):
        ans1 += (data[i] - half1) ** 2

    ans2 = 0
    for i in range(num):
        ans2 += (data[i] - half2) ** 2

    print(min(ans1, ans2))


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main(){
  ll n;
  cin>>n;
  vector<ll>a(n);
  map<ll,ll>num;
  for(ll i=0;i<n;i++){
    cin >>a.at(i);
    if(num.count(a.at(i))){
      num.at(a.at(i))++;
    }
    else{num[a.at(i)]=1;}
  }
  ll tmp=0;
  ll tmp2;
  for(auto num1:num){
    tmp2=num1.second*(num1.second-1)/2;
    tmp+=tmp2;
  }
  for(ll i=0;i<n;i++){
    cout <<tmp-(num.at(a.at(i))*(num.at(a.at(i))-1)/2-(num.at(a.at(i))-1)*(num.at(a.at(i))-2)/2)<<endl;
  }
}

Measured memory_bytes: 12720
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int h,w;
  cin>>h>>w;
  int ans=INF;
  loop(i,1,w){
    vi v(3);
    v[0]=i*h;
    v[1]=((w+i)/2-i)*h;
    v[2]=h*w-v[0]-v[1];
    sort(all(v));
    ans=min(ans,v[2]-v[0]);
    v[0]=i*h;
    v[1]=(w-i)*(h/2);
    v[2]=h*w-v[0]-v[1];
    sort(all(v));
    ans=min(ans,v[2]-v[0]);
  }
  swap(w,h);
  loop(i,1,w){
    vi v(3);
    v[0]=i*h;
    v[1]=((w+i)/2-i)*h;
    v[2]=h*w-v[0]-v[1];
    sort(all(v));
    ans=min(ans,v[2]-v[0]); 
    v[0]=i*h;
    v[1]=(w-i)*(h/2);
    v[2]=h*w-v[0]-v[1];
    sort(all(v));
    ans=min(ans,v[2]-v[0]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+7;
int A[30][30],b[30];
int main(){
    int n,m,c,p = 0;
    cin>>n>>m>>c;
    for(int i=1;i<=m;i++)cin>>b[i];
    for(int i=1;i<=n;i++){
        int ans = c;
        for(int j=1;j<=m;j++){
            cin>>A[i][j];
            ans += A[i][j]*b[j];
        }
        if(ans>0)p++;
    }
    cout<<p<<endl;
	return 0;
}


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

void solve() {
    int N, c = 0, min_c = 0;
    string S;
    cin >> N >> S;
    for (int i = 0; i < N; i++) {
        if (S.at(i) == '(') c++; else c--;
        min_c = min(min_c, c);
        //cout << c << endl;
    }
    //cout << min_c << " " << c << endl;
    for (int i = 0; i > min_c; i--) cout << "(";
    cout << S;
    for (int i = 0; i < c - min_c; i++) cout << ")";
    cout << endl;
    return;
}

int main() {
    solve();
}

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

using namespace std;

int main () {
    string week[6] ={"MON","TUE","WED","THU","FRI","SAT"};
    string day;
    cin >> day;

    for(int i = 0; i < 6; i++)
    {
        if(day == week[i])
        {
            cout << 6 - i << endl;
            return 0;
        }
    }
    cout << 7 << endl;
    return 0;
}

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


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

using namespace std;
int a[123456],b[123456];
int main()
{
    int n,m;
    cin >>n >> m;
    for (int i=0;i<m;i++)
    {
        cin >> a[i];
    }
    sort(a,a+m);
    for (int i=1;i<m;i++)
    {
        b[i-1]=a[i]-a[i-1];
    }
    sort(b,b+m-1);
    cout << accumulate(b,max(b+m-n,b+0),0LL) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

}
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}







int main() {
  int n;
  cin >> n;
  ll a[n+1];
  rep (i,n) {
    cin >> a[i];
  }
  ll cnt = 0;
  rep (i,n){
    while(a[i]%2==0){
      a[i]/=2;
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
typedef pair< int , int > Pi;

Pi operator+(const Pi& a,const Pi& b){
  return Pi( a.first + b.first, a.second + b.second);
}
Pi operator-(const Pi& a,const Pi& b){
  return Pi( a.first - b.first, a.second - b.second);
}

 
int main()
{
  int m, n;
  Pi target[200], star[1000];
  Pi shift;

  while(scanf("%d", &m), m){
    for(int i = 0; i < m; i++){
      scanf("%d %d", &target[i].first, &target[i].second);
    }
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
      scanf("%d %d", &star[i].first, &star[i].second);
    }

    sort( target, target + m);
    sort( star, star + n);

    for(int i = 0; i < n; i++){
      shift = star[i] - target[0];

      bool flag = true;
      for(int j = 1; j < m; j++){      
        if(!binary_search( star, star + n, target[j] + shift)){
          flag = false;
          break;
        }
      }
      if(flag) break;
    }

    printf("%d %d\n", shift.first, shift.second);
  }
  return(0);

}

Measured memory_bytes: 1036
//https://atcoder.jp/contests/dp/tasks/dp_h
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define see(x) cout<<(#x)<<" -> "<<(x)<<"\n"
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
  nimble;
  int tt=1;//cin>>tt;
  while(tt--){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,0,h)rep(j,0,w)cin>>a[i][j];
    vector<vector<ll>> dp(h,vector<ll>(w));
    rep(i,0,h)rep(j,0,w)dp[i][j]=0;
    dp[0][0]=1;
    rep(i,1,w)
      dp[0][i]=a[0][i]=='#'?0:dp[0][i-1];
    rep(i,1,h)
      dp[i][0]=a[i][0]=='#'?0:dp[i-1][0];
    rep(i,1,h)
      rep(j,1,w)
        dp[i][j]=a[i][j]=='#'?0:((dp[i-1][j]+dp[i][j-1])%MOD);
    cout<<dp[h-1][w-1]<<nl;
  }
  return 0;
}


Measured memory_bytes: 9088
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
from itertools import permutations,groupby
import sys
import bisect
import string
alp=string.ascii_lowercase
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7
#mo=998244353
#input=sys.stdin.readline

n,k=MI()
a=LI()
c=[0]*(2000+10)
t=[0]*(2000+10)
for i in range(n):
    c[a[i]]+=1
    tmp=0
    for j in range(i):
        tmp+=1 if a[j]>a[i] else 0
    t[i]=tmp

A=[0]
for i in c:
    A+=[i+A[-1]]
q=0
for i in range(n):
    q+=A[a[i]]
#q=sum(A[:-1])
q%=mo
q*=k*(k-1)//2
q%=mo

ans=k*sum(t)%mo
ans+=q
print(ans%mo)
#print(c,A,t,ans%mo)

Measured memory_bytes: 41452
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  long n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
    a.at(i)--;
  }
  vector<int> route(1,0);
  set<int> st;
  st.insert(0);
  int start;
  while(1){
    int v = route.at(route.size()-1);
    int nv = a.at(v);
    if(!st.count(nv)){
      st.insert(nv);
      route.push_back(nv);
    }else{
      start = nv;
      break;
    }
  }
  int f;
  rep(i,route.size()){
    if(route.at(i) == start) f = i;
  }
  long t = route.size() - f;
  if(k <= f) cout << route.at(k) + 1 << endl;
  else{
    long kk = k - f;
    kk %= t;
    cout << route.at(f+kk) + 1 << endl;
  }
}

Measured memory_bytes: 14020
#Breadth First Search
n=int(input())
V=[]
a=[1]
for i in range(n):
    V.append([int(i) for i in input().split()])
    a.append(0)
V=sorted(V,key=lambda x:x[0])
print('1 0')
d=1
c=0
w=[0]
p=[]
while c<n and w!=[]:
    i=0
    y=[]
 #   print(c)
    while c<n and i<len(w):
        j=2
        while j<2+V[w[i]][1] and c<n:
            if a[V[w[i]][j]-1]==0:
        #        print(a)
                a[V[w[i]][j]-1]=1
                p.append([V[w[i]][j],d])
                c+=1
                y.append(V[w[i]][j]-1)
            j+=1
        i+=1
    w=y
    d+=1
p=sorted(p, key=lambda x:x[0])
#print(p)
i=2
j=0
while i <=n and j<len(p):
    while p[j][0]>i:
        print(str(i) +" -1")
        i+=1
    print(str(p[j][0])+" "+str(p[j][1]))
    i+=1
    j+=1
while i<=n:
    print(str(i)+" -1")
    i+=1

Measured memory_bytes: 7828
# include <iostream>
# include <cstdio>

using namespace std;

int a,b; 

int main(){
    scanf("%d%d",&a,&b); 
    if(a<=8 && b<=8){
        printf("Yay!"); 
    }else{
        printf(":("); 
    }
    return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;



void Main(){
    ll N, Q, i, l, r;
    char c;
    string S;
    vector<set<ll>> cs(26);
    cin >> N;
    cin >> S;
    cin >> Q;
    rep(i, N){
        cs[S[i]-'a'].insert(i);
    }
    rep(j, Q){
        sll(i);
        if(i==1){
            sll(l);
            cin >> c;
            -- l;
            cs[S[l]-'a'].erase(l);
            cs[c-'a'].insert(l);
            S[l] = c;
        }else
        {
            sll(l);
            sll(r);
            -- l;
            ll num = 0;
            rep(k, 26){
                auto st_iter = cs[k].lower_bound(l);
                if(st_iter != cs[k].end() && *st_iter<r){
                    ++ num;
                }

                // auto end_iter = upper_bound(p.second.begin(), p.second.end(), r);

                // cout << "i=" << i << " l=" << l << " r=" << r << " end_it,st_it=" << *end_iter<<"," << *st_iter<<endl;
            }
            printf("%lld\n", num);
        }
        
    }


}

int main(){
    Main();
    // string S = "ksdfjl";
    // char v = S[3];
    // S[3] = 'a';
    // cout << S <<endl;
}

Measured memory_bytes: 26764
package main

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

var sc = bufio.NewScanner(os.Stdin)

var board [8][8]bool
var rl [8]bool

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i

}

func printBoard() {
	for i := 0; i < 8; i++ {
		for j := 0; j < 8; j++ {
			if board[i][j] {
				fmt.Print("Q")
			} else {
				fmt.Print(".")
			}

		}
		fmt.Print("\n")
	}

}

func check(x, y int) bool {
	if x <= -1 || x >= 8 || y <= -1 || y >= 8 {
		panic("error")

	}
	for i := 0; i < 8; i++ {
		if board[x][i] {
			return false
		}
		if board[i][y] {
			return false
		}
	}
	for i := 0; i < 8; i++ {
		if x+i >= 8 || y+i >= 8 {
			break
		}
		if board[x+i][y+i] {
			return false
		}
	}
	for i := 0; i < 8; i++ {
		if x-i <= -1 || y-i <= -1 {
			break
		}
		if board[x-i][y-i] {
			return false
		}
	}
	for i := 0; i < 8; i++ {
		if x+i >= 8 || y-i <= -1 {
			break
		}
		if board[x+i][y-i] {
			return false
		}
	}
	for i := 0; i < 8; i++ {
		if x-i <= -1 || y+i >= 8 {
			break
		}
		if board[x-i][y+i] {
			return false
		}
	}
	return true
}

func dfs(N int) bool {
	if N == 8 {
		return true
	}

	for i := 0; i < 8; i++ {
		if rl[N] {
			return dfs(N + 1)
		}

	}

	for i := 0; i < 8; i++ {
		if check(N, i) {
			fill(N, i)
			if !dfs(N + 1) {
				unfill(N, i)
				continue
			} else {
				return true
			}
		}

	}

	return false

}

func unfill(x, y int) {
	board[x][y] = false
}

func fill(x, y int) {

	board[x][y] = true

}

func main() {
	sc.Split(bufio.ScanWords)

	queens := next()
	for n := 0; n < queens; n++ {
		x, y := next(), next()
		rl[x] = true
		fill(x, y)
	}

	dfs(0)

	printBoard()
}



Measured memory_bytes: 1100
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b&&b==c){
		printf("No\n");
	}
	else if((a!=b&&b!=c)&&(a!=c)){
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;	
}

Measured memory_bytes: 1612
length=[float(0) for i in range(3)]
while 1:
    try:
        x1,y1,x2,y2,x3,y3,x4,y4=[float(i) for i in input().split( )]
        x12=x1-x2
        y12=y1-y2
        x23=x2-x3
        y23=y2-y3
        x31=x3-x1
        y31=y3-y1
        x14=x1-x4
        y14=y1-y4
        x24=x2-x4
        y24=y2-y4
        x34=x3-x4
        y34=y3-y4
        gai1=x12*y14-x14*y12
        gai2=x23*y24-x24*y23
        gai3=x31*y34-x34*y31
        if (((gai1>0)and(gai2>0)and(gai3>0))or((gai1<0)and(gai2<0)and(gai3<0))):
            print("YES")
        else:
            print("NO")
    except EOFError:
        break

Measured memory_bytes: 7628
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

char const *answer(int a,int b,int c){
	if(c*c == a*a+b*b || a*a == b*b+c*c || b*b == a*a+c*c)	return "YES";
	else		return "NO";
}

int main() {
	int n,a,b,c;
	cin >> n;
	for(int i=0;i<n;i++){
	cin >> a >> b >> c;
	cout << answer(a,b,c) << endl;
	}
}


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int gcd(int x, int y)
{
    int r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

int main() {
    int a, N, X;
    cin >> N >> X;

    int D, x;
    cin >> x;
    D = abs(x - X);
    for(int i = 1; i < N; i++) {
        cin >> x;
        int a = abs(x - X);
        int b = D;
        if(a < b)
            swap(a, b);
        D = gcd(a, b);
    }
    cout << D << endl;
}

Measured memory_bytes: 256
#include <stack>
#include <vector>
#include <iostream>

using namespace std;

int main() {
	int n,q;
	cin >> n >> q;
	vector< stack<int> > sv(n);
	while (q--) {
		int op,t;
		cin >> op >> t;
		switch (op) {
			case 0:		// push
				int x;
				cin >> x;
				sv[t].push(x);
				break;
			case 1:		// top
				if (!sv[t].empty()) {
					cout << sv[t].top() << endl;
				}
				break;
			default:	// pop
				if (!sv[t].empty()) {
					sv[t].pop();
				}
		}
	}	
}


Measured memory_bytes: 4232
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    long long x, a, b;
    std::cin>>x>>a>>b;

    std::string ans;
    if(b <= a){
        ans = "delicious";
    }else if(b <= a + x){
        ans = "safe";
    }else{
        ans = "dangerous";
    }

    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

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

    vector<vector<ll> > dp(n, vector<ll>(W+1));
    rep(j, W+1) {
        if (j >= w[0]) {
            dp[0][j] = v[0];
        }
    }

    rep(i, n-1) {
        rep(j, W+1) {
            if (j >= w[i+1]) { //i+1番目の品物を採用するか、採用しないか
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i+1]]+v[i+1]);
            }
            else { //i+1番目の品物を採用できないので、そのまま
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    cout << dp[n-1][W] << endl;

}

Measured memory_bytes: 79488
n = int(input())
aList = list(map(int, input().split(' ')))

halfableCount = 0

while(True):
    for i in range(len(aList)):
        # 割れるか確認する
        if aList[i] % 2 == 1:
            break

        # 割る
        aList[i] = aList[i] >> 1
    else:
        halfableCount += 1
        continue

    # 2で割れない数があったのでループ終了
    break

print(halfableCount)

Measured memory_bytes: 9120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        int t = ni();
        int[] a = nia(n);

        int max = a[n - 1];
        int[] c = new int[n];
        for (int i = n - 2; i >= 0; i--) {
            if (a[i] < max) {
                c[i] = max - a[i];
            }
            if (a[i] > max) {
                max = a[i];
            }
        }

        Arrays.sort(c);

        int cnt = 1;
        for (int i = n - 1; i >= 0; i--) {
            if (c[i] != c[i - 1]) break;
            cnt++;
        }

        out.println(cnt);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 24840
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    int n;
    cin >> n;
    if(n%2==1) cout << (n*n-1)/4 << endl;
    else cout << n*n/4 << endl;
}
/*



*/

Measured memory_bytes: 3632
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


s = 'abcdefghijklmnop'
N = I()


def f(n, seq, m):
    for i in range(m + 1):
        if n == N:
            print(seq + s[i])
        else:
            f(n + 1, seq + s[i], max(m, i + 1))


f(1, '', 0)


Measured memory_bytes: 55768