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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
  for (auto& x : v) o << x << ' ';
  return o;
}

const int MAXN = 1e5 + 5;
ll memo[MAXN];
int arr[MAXN];
int n;

ll dp(int i) {
  ll &res = memo[i];
  if (res != -1) return res;
  if (i == n-1) return res = 0;
  res = LLONG_MAX;
  if (i < n-2) {
    res = min(dp(i + 1) + abs(arr[i] - arr[i+1]),
              dp(i + 2) + abs(arr[i] - arr[i+2]));
  } else {
    res = dp(i + 1) + abs(arr[i] - arr[i+1]);
  }
  return res;
}

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

  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  memset(memo, -1, sizeof memo);
  cout << dp(0) << endl;
}


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

using namespace std;

const int INF = 1 << 28;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> A(M), C(M, 0);
  for (int i = 0; i < M; i++) {
    int b;
    cin >> A[i] >> b;
    for (int j = 0; j < b; j++) {
      int c;
      cin >> c;
      C[i] += 1 << (c - 1);
    }
  }
  vector<vector<int>> dp(M + 1, vector<int>(1 << N, INF));
  dp[0][0] = 0;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < (1 << N); j++) {
      chmin(dp[i + 1][j], dp[i][j]);
      chmin(dp[i + 1][j | C[i]], dp[i][j] + A[i]);
    }
  }
  cout << (dp[M][(1 << N) - 1] == INF ? -1 : dp[M][(1 << N) - 1]) << '\n';
  return 0;
}


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

typedef long long ll;
const int N = 100010;

ll x[N];
int v[N];
ll clockmax[N], countermax[N];
ll clockmax2[N], countermax2[N];
ll clockpre[N], counterpre[N];

int main(){
	int n;
	ll c;
	scanf("%d%lld", &n, &c);
	for (int i = 1; i <= n; ++ i){
		scanf("%lld%d", &x[i], &v[i]);
	}
	for (int i = 1; i <= n; ++ i){
		clockpre[i] = clockpre[i - 1] + v[i];
		counterpre[i] = counterpre[i - 1] + v[n + 1 - i];
	}
	clockmax[0] = countermax[0] = LLONG_MIN;
	clockmax2[0] = countermax2[0] = LLONG_MIN;
	for (int i = 1; i <= n; ++ i){
		clockmax[i] = std::max(clockmax[i - 1], clockpre[i] - x[i]);
		countermax[i] = std::max(countermax[i - 1], counterpre[i] - (c - x[n + 1 - i]));
		clockmax2[i] = std::max(clockmax2[i - 1], clockpre[i] - 2 * x[i]);
		countermax2[i] = std::max(countermax2[i - 1], counterpre[i] - 2 * (c - x[n + 1 - i]));
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++ i){
		ans = std::max(ans, std::max(clockmax[i], countermax[i]));
	}
	for (int i = 1; i <= n - 1; ++ i){
		ans = std::max(ans, clockmax2[i] + countermax[n - i]);
		ans = std::max(ans, countermax2[i] + clockmax[n - i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6144
n , x , y = map(int,input().split())
p = [0 for i in range(n)]
for i in range(1,n+1):
    for j in range(1,i+1):
        p[min(abs(i-j),abs(i-x)+1+abs(j-y),abs(j-x)+1+abs(i-y))] += 1
for i in range(1,n):
    print(p[i])

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

int main()
{
	char str[20000][81]={};
	int i=0,j,k,flag=0,keep;
	int num=0;

	while((fgets(str[i],sizeof(str[i]),stdin))!=NULL)
	{
		flag=0;
		for(j=0;j<strlen(str[i]);j++)
			{
				if(str[i][j]>=49 && str[i][j]<=57)
				{
					keep=atoi(&str[i][j]);
					num+=atoi(&str[i][j]);
					for(k=0;keep>=10;k++)if(keep>=10)keep/=10;
					j+=k;
				}
			}
		i++;
	}

	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 2128
package main
import("fmt")

func main(){
    var s string
    fmt.Scan(&s)
    pt := len(s)
    for pt > 3 {
        _pt := pt
        switch(s[pt - 3: pt]){
            case "eam":
                if s[pt - 5: pt] == "dream" {
                    pt -= 5
                }
            case "mer":
                if s[pt - 7: pt] == "dreamer" {
                    pt -= 7
                }
            case "ase":
                if s[pt - 5: pt] == "erase" {
                    pt -= 5
                }
            case "ser":
                if s[pt - 6: pt] == "eraser" {
                    pt -= 6
                }
        }
        if _pt == pt {
            pt = -1
        }
    }

    if pt == 0 {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;


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

	int R;
	double C;

	cin >> R;

	C = 2*pi*R;

	printf("%.20f\n", C);
	return 0;		
}



Measured memory_bytes: 3768
#include <stdio.h>

int main() {
	int N, K;
	scanf ("%d %d", &N, &K);
	int A[N + 1];	
	
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i + 1]);
	}
	for (int i = K + 1; i <= N; i++) {
		if ( A[i] > A[i - K]) {
		    printf("Yes\n");
		} else {
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2412
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
# 水水砂砂濃ビ
# 1 2 10 20 15 200
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
ws = set([])
ss = set([])
ans = [A, 0]
for i in range(F // A + 1):
    for j in range((F - A * i) // B + 1):
        if 0 < A * i + B * j <= F:
            ws.add(A * i + B * j)
for i in range(F // C + 1):
    for j in range((F - C * i) // D + 1):
        if 0 < C * i + D * j <= F:
            ss.add(C * i + D * j)
for i in ws:
    for j in ss:
        if i + j <= F and j / i <= E / 100:
            if ans[1] / ans[0] < j / (i + j):
                ans = [i+j, j]
print(str(ans[0])+' '+str(ans[1]))


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

int main () {
  int T, A, B;
  cin >> T >> A >> B;
  
  int c;
  
  c = T * A;
  
  if (c <= B) {
    cout << c << endl;
  }
  else {
    cout << B << endl;
  }
}


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

int main(){
  int n,i,j,count;
  while(1){
    count=0;
    cin >> n;
    if(n==0)break;

    for(i = 1; i <=n; i++){
    int total = 0;
    total += i;
      for(j = i+1; j <=n; j++){
      total +=  j;
    
      if(total==n){
	count++;
	break;
	  
      }
    }

  
    }
  cout << count << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    int a,b,c,d;
    cin >> a;
    cin >> b;
    a = min(a,b);
    cin >> c;
    cin >> d;
    c = min(c,d);
    cout << a + c;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n;
    cin>>n;
    vector<int> a(n,0);
    rep(i,n){
        cin>>a[i];
    }
    int maxn =1e6+1;
    vector<bool> f(maxn,false);

    sort(a.begin(),a.end());
    int ans = 0;

    for(int i=0;i<n;i++){
        if(i!=n-1&&a[i]!=a[i+1]){
            if(!f[a[i]]){
                ans++;
            }
        }else if(i==n-1){
            if(!f[a[i]]){
                ans++;
            }
        }
        if(!f[a[i]]) {
            for (int j = 1; a[i] * j <= maxn; j++) {
                f[j * a[i]] = true;
            }
        }
    }

    cout<<ans<<endl;









return 0;
}


Measured memory_bytes: 4312
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
#include <functional>
#include <iomanip>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }

template<typename Ty>
inline Ty gcd(Ty a, Ty b)
{
	Ty r;
	if (a < b) swap(a, b);
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}




int main(int argc, char* argv[])
{
	cout << std::fixed << std::setprecision(10);

	for (;;) {
		int N;

		cin >> N;
		if (cin.fail()) break;

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

		int res = 0;
		for (int i = 1; i < N - 1; i++) {
			int a[3] = { A[i - 1], A[i], A[i + 1] };
			sort(a, a + 3);
			if (a[1] == A[i]) res++;
		}

		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	float y;
	float b, r, t;
	float tmp;
	float max;
	int max_b;
	int i, j;
	float multi;

	while (1){
		scanf("%d", &n);

		if (n == 0){
			break;
		}

		max = 0;

		scanf("%f", &y);
		for (i = 0; i < n; i++){
			scanf("%f %f %f", &b, &r, &t);

			if (t == 1){
				tmp = 1.0 + y * (r / 100);
			}
			else {
				multi = 1.0;
				for (j = 0; j < y; j++){
					multi *= (1 + r / 100);
				}

				tmp = multi;
			}

			if (tmp > max){
				max = tmp;
				max_b = b;
			}
		}

		printf("%d\n", max_b);
	}
}

Measured memory_bytes: 632
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef pair<int, pair<int, pair<int, int>>> PP;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const long long INF = 1LL << 60;
const int inf = 1e9;
const long long MOD = 1e9+7;

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

int main() {
	ll n;
	cin >> n;
	ll a = modpow(10, n, MOD);
	ll b = modpow(9, n, MOD);
	ll c = modpow(8, n, MOD);
	ll ans = (a - 2 * b + c) % MOD;
	if (ans < 0)ans += MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3160
import sys, math
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
l = int(math.log2(a[-1]))+1
for i in range(1, l+1):
    for j in range(n):
        b = a[n-1-j]
        if b >> (l-i): 
            a[n-1-j] = b >> 1
            m -= 1
        else: break
        if m == 0:
            print(sum(a))
            sys.exit()
    a.sort()
print(sum(a))

Measured memory_bytes: 15020
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 

  string s; cin >> s;

  string res;
  for (int i = 0; i < s.size(); i += 2) {
    res += s[i];
  }

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


Measured memory_bytes: 3732
from sys import stdin
input = stdin.readline

n = int(input())
a = list(map(int, input().split()))
ans = 1
flag = True

for ta in a:
    ans *= ta
    if (ans > 10 ** 18):
        flag = False
        ans = 1

if (flag or ans == 0):
    print(ans)
else:
    print(-1)


Measured memory_bytes: 21600
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<math.h>
#define maxn 1<<17
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
int a[1000005];
int main()
{
    int n;
    while(cin>>n){
        int sum1=0,sum2=0,sum3=0;
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
            if(a[i]%4==0) sum2++;
            else if(a[i]%2==0) sum1++;
            else sum3++;
        }
        int flag=0;
        if(sum3+sum1%2>sum2+1) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}


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

int main() {  
	int s,t,u;
	cin >> s >> t >> u;
	string res;
	if (t == s && s != u)  printf("Yes\n");
	else if (s==u && u!=t)  printf("Yes\n");
	else if (u==t && t!=s)  printf("Yes\n");
	else printf("No\n");
	
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1E5+10;
const int md=1E9+7;
int T[N],A[N];
int X[N];
int main(){
   int n;scanf("%d",&n);
   for(int i=0;i<n;i++){
        scanf("%d",T+i);
   }
   for(int i=0;i<n;i++){
        scanf("%d",A+i);
   }
   memset(X,-1,sizeof(X));
   X[0]=T[0];
   if(X[n-1]==-1)X[n-1]=A[n-1];
   else if(X[n-1]!=A[n-1]){
        cout<<"0"<<endl;
        return 0;
   }
    for(int i=1;i<n;i++){
        if(T[i]>T[i-1]){
            if(X[i]==-1)X[i]=T[i];
            else if(X[i]!=T[i]){
                cout<<"0"<<endl;
                return 0;
            }
        }
    }
    for(int i=n-2;i>=0;i--){
        if(A[i]>A[i+1]){
            if(X[i]==-1)X[i]=A[i];
            else if(X[i]!=A[i]){
                cout<<"0"<<endl;
                return 0;
            }
        }
        if(X[i]>A[i]){
            cout<<"0"<<endl;
            return 0;
        }
    }
   long long int ans=1;
   for(int i=0;i<n;i++){
        if(X[i]==-1){
            ans=ans*min(T[i],A[i])%md;
        }
   }
   cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		int res = 0;
		String prev = "";
		String curr = "";
		
		for (char c: s.toCharArray()) {
			curr += c;
			if (!prev.equals(curr)) {
				prev = curr;
				curr = "";
				res++;
			}
		}
		
		System.out.println(res);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 100007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
vector<int> scoreByDays[MAXN];
int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, a, b;
    cin >> n >> m;
    ll res = 0;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        if (a > m) continue;
        scoreByDays[a].push_back(b);
    }
    priority_queue<int> Q;
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j < sz(scoreByDays[i]); j++) {
            Q.push(scoreByDays[i][j]);
        }
        if (Q.empty()) continue;
        res += Q.top();
        Q.pop();
    }
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 5632
program main
  implicit none
  integer(8) :: n, i, res, four(4)
  integer(8), allocatable :: a(:)
  read *, n
  allocate (a(0:n))
  a(0) = 0
  read *, a(1:n)
  do i = 1, n
    a(i) = a(i) + a(i - 1)
  end do

  res = 10_8 ** 18
  do i = 2, n - 2  ! iの後が中央切断
    four(1:2) = optimal_cut(a(1:i), i, 0_8)
    four(3:4) = optimal_cut(a(i + 1:n), n - i, a(i))
    res = min(res, maxval(four) - minval(four))
  end do
  print "(i0)", res
  contains

  function optimal_cut(acc, n, ofs)
    integer(8) :: optimal_cut(2)
    integer(8), intent(in) :: n, acc(n), ofs
    integer(8) :: ng, ok, md
    ! acc(n)の半分以下の要素のうち最も大きいものを求める
    ng = n
    ok = 1
    do
      md = ok + (ng - ok) / 2
      if ((acc(md) - ofs) * 2 <= acc(n) - ofs) then
        ok = md
      else
        ng = md
      end if
      if (ng - ok <= 1) exit
    end do
    if (abs(acc(n) - ofs - 2 * (acc(ok) - ofs)) > abs(acc(n) - ofs - 2 * (acc(ok + 1) - ofs))) ok = ok + 1
    optimal_cut(1) = acc(ok) - ofs
    optimal_cut(2) = acc(n) - acc(ok)
  end function optimal_cut
end program main


Measured memory_bytes: 2304
#include <cstdio>
#include <vector>
using namespace std;

int main(void){
	vector<int> num;
	int n;
	double w;
	double h;
	double bmi;

	while(scanf("%d,%lf,%lf", &n, &w, &h) != EOF){
		bmi = w/(h*h);
		if(bmi >= 25) num.push_back(n);
	}

	for(int i=0; i<num.size(); i++){
		printf("%d\n", num[i]);
	}
	
	return 0;
}

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

int main() {
  char c;

  cin >> c;

  if (c >= 'a') {
    cout << 'a' << endl;
  } else {
    cout << 'A' << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include<math.h>
#define li  long long int

using namespace std;


int main() { 


	li h;
	li w;

	li sa, sb,sc;
	cin >> w >> h;
	if (w % 3 == 0 || h % 3 == 0) {
		cout << "0";
		return 0;
	}
	li res = w*h;

	// wを割るパターン
	for (li i = 1; i < w; i++) {

		sa = h*i;
		sb = floor((w - i)/2)*h;
		sc = w*h - sa - sb;
		res = min(res,max({ sa,sb,sc }) - min({ sa,sb,sc }));

		sb = floor(h / 2)*(w-i);
		sc = w*h - sa - sb;
		res = min(res, max({ sa,sb,sc }) - min({ sa,sb,sc }));

	}

	// hを割るパターン
	for (li i = 1; i < h; i++) {

		sa = w*i;
		sb = floor((h - i) / 2)*w;
		sc = w*h - sa - sb;
		res = min(res, max({ sa,sb,sc }) - min({ sa,sb,sc }));

		sb = floor(w / 2)*(h-i);
		sc = w*h - sa - sb;
		res = min(res, max({ sa,sb,sc }) - min({ sa,sb,sc }));

	}

	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,k,x;
    cin>>k>>x;

    for(int i=max(-1000000LL,x-k+1);i<min(1000000LL,x+k);i++){
        cout <<i;
        if(i!=min(1000000LL,x+k))cout<<" ";
    }
    cout<<endl;


    return 0;

}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define CLR2d(x,m,n) memset(x, -1, sizeof(x[0][0]) * m * n)
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    ll a,b;
    cin>>a>>b;
    cout<<((a*b)/gcd(a,b))<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 3644
import java.util.*;

public class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int x = sc.nextInt();
            if(n==0 && a==0 && b==0 && c==0 && x==0) break;
            int[] y = new int[n];
            for(int i=0; i<n; i++) y[i] = sc.nextInt();

            int cnt = 0;
            for(int i=0; i<n; i++){
                while(x!=y[i]){
                    x = (a*x+b)%c;
                    cnt++;
                    if(cnt>10000) break;
                }
                if(cnt>10000) break;
                if(i!=n-1){
                    x = (a*x+b)%c;
                    cnt++;
                }
            }

            if(cnt>10000) cnt = -1;
            System.out.println(cnt);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 12000
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   String sharp = "";
   for(int i = 0;i<B+2;i++) sharp+="#";
   System.out.println(sharp);
   for(int i = 0;i<A;i++) System.out.println("#"+sc.next()+"#"); 
   System.out.println(sharp);
 }
}

Measured memory_bytes: 22996
import itertools
from collections import deque
from collections import Counter
N,X,Y = list(map(int,input().split()))
moto = [x for x in range(1,N+1)]
d = deque([])
C = itertools.combinations(moto,2)
C = list(C)
for c in C:
    i = c[0]
    j = c[1]
    d.append(min(j-i,abs(i-X)+abs(j-Y)+1))
c = Counter(list(d))
for v in c.values():
  print(v)
for _ in range(N-1-len(list(c))):
  print(0)

Measured memory_bytes: 227280
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		HashMap<Character, Integer> hm = new HashMap<Character, Integer>();//[1]
		hm.put('s', sc.nextInt());
		hm.put('p', sc.nextInt());
		hm.put('r', sc.nextInt());
		
		String T = sc.next();
		int score = 0;
		boolean[] flag = new boolean[K];
		Arrays.fill(flag, false);
		for(int i = 0; i < N; i++){
			char x = T.charAt(i);			
			if(i < K){
				score += hm.get(x);
			}
			else{
				if(T.charAt(i - K) != x || flag[i % K]){
					score += hm.get(x);
					flag[i % K] = false;
					
				}
				else
					flag[i % K] = true;
			}
		}
		System.out.println(score);
	}
}

Measured memory_bytes: 25900
#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define N 500009
#define inf 999999999999
#define pb push_back
#define M (L+R)/2
using namespace std;

ll n,a[N],ans=inf,sum,ind;
bitset <4000009> dp;
int main(){
	
	ios::sync_with_stdio(0);
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	dp[0]=1;

	for(int i=1;i<=n;i++){
		dp=dp|(dp<<a[i]);
	}
	
	for(int i=4000000;i>=sum/2;i--){
		if(dp[i]){
			if(abs(sum-2*i)<ans)ans=abs(sum-2*i),ind=i;
		}
	}
	cout<<ind<<endl;
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>

#define REPI(i, s, e) for (int i = s; i < e; ++i)
#define REPLL(i, s, e) for (ll i = s; i < e; ++i)

using namespace std;
using ll = long long;
using ld = long double;

struct Op
{
    int by, bx, ay, ax;
};

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

    int H, W;
    cin >> H >> W;
    vector<vector<int>>  a(H, vector<int>(W));
    REPI(y, 0, H) REPI(x, 0, W) cin >> a[y][x];

    vector<Op> ops;
    REPI(y, 0, H)
    {
        if (y % 2 == 0)
        {
            REPI(x, 0, W)
            {
                if (y == H - 1 && x == W - 1) continue;
                if (a[y][x] % 2 == 0) continue;
                if (x == W - 1)
                {
                    a[y + 1][x]++;
                    ops.push_back({y + 1, x + 1, y + 2, x + 1});
                }
                else
                {
                    a[y][x + 1]++;
                    ops.push_back({y + 1, x + 1, y + 1, x + 2});
                }
            }
        }
        else
        {
            for (int x = W - 1; x >= 0; --x)
            {
                if (y == H - 1 && x == 0) continue;
                if (a[y][x] % 2 == 0) continue;
                if (x == 0)
                {
                    a[y + 1][x]++;
                    ops.push_back({y + 1, x + 1, y + 2, x + 1});
                }
                else
                {
                    a[y][x - 1]++;
                    ops.push_back({y + 1, x + 1, y + 1, x});
                }
            }
        }
    }

    cout << ops.size() << endl;
    for(auto& o : ops) cout << o.by << " " << o.bx << " " << o.ay << " " << o.ax << endl;

    return 0;
}


Measured memory_bytes: 5236
#include <iostream>
using namespace std;
 
int fld[17][17];
int cnt[17][17];
 
int main(){

    int X,Y,S;
    while(cin >> X >> Y, X || Y ) {

      for(int y = 0 ; y< 17 ; y++)
        for(int x = 0 ; x< 17 ; x++){
            fld[y][x] = 3;
            cnt[y][x] = 0;
        }
 
        for(int y = 0 ; y < Y ; y++)
	  for(int x= 1 ; x <= X ; x++){
            cin >> fld[y][x];
            cnt[y][x] = ( (y == 0 && fld[y][x] == 0 )? 1 : 0 );
	  }
 
        for(int y = 0 ; y < Y - 1 ; y++ )
	  for(int x = 1 ; x <= X  ; x++ ){
            if(fld[y][x] == 0){
	      if(fld[y + 1][x + 1] == 0) cnt[y + 1][x + 1] += cnt[y][x];
	      if(fld[y + 1][x - 1] == 0) cnt[y + 1][x - 1] += cnt[y][x];
	      if(fld[y + 1][x] != 1) cnt[y + 1][x] += cnt[y][x]; 
            }
            if( fld[y][x] == 2 && fld[y + 2][x] != 1 ){
	      cnt[y + 2][x] += cnt[y][x];
            }
	  }
 
        S = 0;
        for(int y=Y-1; y< Y+2; y++)
	  for(int x=1  ; x<=X  ; x++)
            S+=cnt[y][x];
 
 
        cout << S << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1160
import math
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
a,b = iim()

if 8-min(a,b) < abs(a-b):
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3064
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextLine() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextLine())
	if e != nil {
		panic(e)
	}
	return i
}

func nextStrSplit() []string {
	splitted := strings.Fields(nextLine())
	n := len(splitted)
	res := make([]string, n)
	for i, str := range splitted {
		res[i] = str
	}
	return res
}

func nextStrSplitChar() []string {
	splitted := strings.Split(nextLine(), "")
	return splitted
}

type coord struct {
	y, x, step int
}

func main() {
	var h, w int
	fmt.Scanf("%d %d\n", &h, &w)

	field := make([][]string, h)
	for i := range field {
		field[i] = nextStrSplitChar()
	}

	steps := make([][]int, h)
	for i := range steps {
		steps[i] = make([]int, w)
	}

	// count black tiles
	nBlack := 0
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if field[y][x] == "#" {
				nBlack++
			}
			steps[y][x] = -1
		}
	}

	// BFS
	queue := []coord{}
	queue = append(queue, coord{0, 0, 0})
	steps[0][0] = 0 // init

	moves := [][]int{
		[]int{-1, 0}, // left
		[]int{1, 0},  // right
		[]int{0, -1}, // up
		[]int{0, 1},  // down
	}

	for len(queue) > 0 {
		now := queue[0]
		queue = queue[1:] // deque
		for _, s := range moves {
			dx, dy := s[0], s[1]
			x := now.x + dx
			y := now.y + dy

			// field && unvisited
			if y >= 0 && y < h && x >= 0 && x < w && steps[y][x] == -1 && field[y][x] == "." {
				queue = append(queue, coord{y, x, now.step + 1})
				steps[y][x] = now.step + 1
			}
		}
	}

	// result
	if steps[h-1][w-1] == -1 {
		fmt.Println(-1)
	} else {
		fmt.Println(h*w - nBlack - (steps[h-1][w-1] + 1))
	}
}


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

int main(){
    int N;
    cin >> N;
    float X1=(float)N/1.08;
    float X2=X1+1;
    bool judge1=true;
    bool judge2=true;
    if((int)((int)X1*1.08)!=N){
        judge1=false;
        if((int)((int)X2*1.08)!=N){
            judge2=false;
        }
    }
    if(judge1){
        cout << (int)X1 << endl;
    }
    else if(judge2){
        cout << (int)X2 << endl;
    }
    else{
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 384
import functools
n, x = map(int, input().split())
a = [(0, 0)] + list(map(int, input().split()))

def f(a, b):
    d = max(0, (b + a[0]) - x)
    return max(0, b - d), a[1] + d

print(functools.reduce(f, a)[1])


Measured memory_bytes: 14596
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val S, T = in.next
  val rots = (0 until S.size).map {i =>
    val (l, r) = S.splitAt(i)
    r + l
  }
  println(if (rots.contains(T)) "Yes" else "No")
}

Measured memory_bytes: 25540
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    m = int(input())
    print(48-m)

if __name__ == '__main__':
    main()

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

using namespace std;

template< typename T >
struct edge
{
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s)
{
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  for(auto &e : edges) {
    if(dist[e.src] == INF) continue;
    if(dist[e.src] + e.cost < dist[e.to]) return vector< T >();
  }
  return dist;
}


int main()
{
  int V, E, S;
  scanf("%d %d %d", &V, &E, &S);
  Edges< int > g;
  for(int i = 0; i < E; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    g.emplace_back(x, y, z);
  }
  auto cost = bellman_ford(g, V, S);
  if(cost.empty()) {
    puts("NEGATIVE CYCLE");
  } else {
    for(int i = 0; i < V; i++) {
      if(cost[i] == numeric_limits< int >::max()) puts("INF");
      else printf("%d\n", cost[i]);
    }
  }
}




Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
queue<ll>que;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    for(ll i=1;i<=9;i++)
        que.push(i);
    ll now=1;
    while(true){
        ll x=que.front();
        que.pop();
        if(now==n){
            cout<<x<<endl;
            return 0;
        }
        ll tmp=x%10;
        if(tmp-1>=0)
            que.push(x*10+tmp-1);
        que.push(x*10+tmp);
        if(tmp+1<=9)
            que.push(x*10+tmp+1);
        now++;
    }
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        char[][] map = new char[n][];
        for(int i = 0; i < n; i++){
            map[i] = sc.next().toCharArray();
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(map[i][j] == '.'){
                    ans = Math.max(ans,bfs(n,m,map,i,j));
                }
            }
        }
        System.out.println(ans);
    }
 
    public static int bfs(int n, int m, char[][]map,int sy,int sx){
        char[][] bfsmap = new char[n][];
        for(int i = 0; i < n; i++){
            bfsmap[i] = map[i].clone();
        }
        Point[] D4 = {new Point(-1, 0),new Point(1,0), new Point(0,1), new Point(0,-1)};
        Point start = new Point(sx, sy);
        boolean[][] arrived = new boolean[n][m];
	    int[][] moves = new int[n][m];
	    for(int i = 0; i < n; i++){
            Arrays.fill(moves[i],99999999);
        }
        moves[sy][sx] = 0;
        ArrayDeque<Point> dq = new ArrayDeque<>();
        dq.add(start);
 
        while (dq.size() > 0) {
            Point p = dq.removeFirst();
            for (int i=0; i<4; i++) {
                int x = p.getX()+D4[i].getX();
                int y = p.getY()+D4[i].getY();
                if(!(0 <= y && y < n && 0 <= x && x < m)){
                    continue;
                }
                else if (bfsmap[y][x] == '.') {
                    dq.addLast(new Point(x, y));
                    bfsmap[y][x] = '#';
                    moves[y][x] = Math.min(moves[y][x],moves[p.getY()][p.getX()] + 1);
                    arrived[y][x] = true;
                }
            }
        }
        int ret = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(arrived[i][j]){
                    ret = Math.max(ret,moves[i][j]);
                }
            }
        }
        return ret;
    }
}
 
class Point{
 
	private int x;
	private int y;
 
	Point(int a, int b) {x=a; y=b;}
 
	int getX() {return x;}
	int getY() {return y;}
	void setX(int n) {x = n;}
	void setY(int n) {y = n;}
 
}

Measured memory_bytes: 26924
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    uint64_t N, A, B, C, D, E;
    uint64_t min, ans = 0;

    scanf("%"PRIu64, &N);
    scanf("%"PRIu64, &A);
    scanf("%"PRIu64, &B);
    scanf("%"PRIu64, &C);
    scanf("%"PRIu64, &D);
    scanf("%"PRIu64, &E);

    min = A;
    if (B < min) min = B;
    if (C < min) min = C;
    if (D < min) min = D;
    if (E < min) min = E;

    if (A == min) {
        ans = 0 + ((N + A - 1) / A) + 4;
        printf("%"PRIu64"\n", ans);
        return 0;
    }
    if (B == min) {
        ans = 1 + ((N + B - 1) / B) + 3;
        printf("%"PRIu64"\n", ans);
        return 0;
    }
    if (C == min) {
        ans = 2 + ((N + C - 1) / C) + 2;
        printf("%"PRIu64"\n", ans);
        return 0;
    }
    if (D == min) {
        ans = 3 + ((N + D - 1) / D) + 1;
        printf("%"PRIu64"\n", ans);
        return 0;
    }
    if (E == min) {
        ans = 4 + ((N + E - 1) / E) + 0;
        printf("%"PRIu64"\n", ans);
        return 0;
    }
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
from bisect import *

n = int(input())
(*A, ) = map(int, input().split())
(*B, ) = map(int, input().split())
S = [A[i] - B[i] for i in range(n)]
if sum(S) < 0:
    print(-1)
    exit()
S.sort()
neg = bisect_left(S, 0)
pos = bisect_right(S, 0)
ne = sum(S[:pos])
rui = [S[-1]]
for i in reversed(S[pos:n - 1]):
    rui.append(rui[-1] + i)
print(neg + bisect_left(rui, -ne) + (neg != 0))


Measured memory_bytes: 24168
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class c{
    public static void Main(){
        //2StreamWriter sw = new StreamWriter("out.txt");
        int n = int.Parse(Console.ReadLine());
        int[] ans = new int[n+1];
        for(int x=1; x<=(int)Math.Sqrt(n); x++){
            for(int y=1; y<=(int)Math.Sqrt(n); y++){
                for(int z=1; z<=(int)Math.Sqrt(n); z++){
                    int t = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
                    if(t <= n){
                        ans[t]++;
                    }
                }
            }
        }
        for(int i=1; i<=n; i++){
            Console.WriteLine(ans[i]);
        }
    }
}


Measured memory_bytes: 17796
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    vector<int64_t> a(3);
    for(int i=0; i<3; i++){
        cin >>  a.at(i);
    }
    sort(a.begin(), a.end());
    if (a.at(0) != a.at(1) && a.at(1) == a.at(2)) {
        cout << "Yes" << endl;
    } else if (a.at(0) == a.at(1) && a.at(1) != a.at(2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  if ((N%10) * 100 + (N/10%10) * 10 + N/100%10 == N) {
    cout << "Yes" << endl;
  } else { 
    cout << "No" << endl;
  }
  
  
  
  return 0;  
}

Measured memory_bytes: 256
#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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

vector<pint> g[801];
int p[801],d[801];
int sum1,sum2,mx;
int dfs(int v,int par){
    int n=g[v].size();
    int mx1=0,mx2=0;
    rep(i,n){
        if(g[v][i].second!=par){
            if(g[g[v][i].second].size()<=1) continue;
            sum2+=g[v][i].first*2;
            int t=dfs(g[v][i].second,v)+g[v][i].first;
            if(mx1<t) mx2=mx1,mx1=t;
            else if(mx2<t) mx2=t;
        }
    }
    mx=max(mx,mx1+mx2);
    return mx1;
}
int main(){
    int n;
    int di;
    while(cin>>n,n){
        rep(i,n) g[i].clear();
        sum1=0;
        FOR(i,1,n){
            cin>>p[i];
            --p[i];
        }
        FOR(i,1,n){
            cin>>d[i];
            sum1+=d[i];
        }
        FOR(i,1,n){
            g[i].pb(d[i],p[i]);
            g[p[i]].pb(d[i],i);
        }
        int mn=1000100010;
        rep(i,n){
            sum2=0,mx=0;
            dfs(i,-1);
            mn=min(mn,sum1+sum2-mx);
        }
        cout<<mn<<endl;
    }
    return 0;
}


Measured memory_bytes: 3244
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_MOD			1000000007								// 除数(10の9乗+7)
#define D_FLOG_MAX		100005									// 最大蛙数

// 内部変数
static FILE *szpFpI;											// 入力
static int siFCnt;												// 蛙数
static int si1FCnt[D_FLOG_MAX];									// 蛙数[最高順位]

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 積 - 取得
int
fGetModMulti(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	return (int)((long long)piVal1 * (long long)piVal2 % D_MOD);
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1FCnt, 0, sizeof(si1FCnt));

	// 蛙数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siFCnt);

	// 蛙 - 取得
	int liNow = -1;
	int liOrd = 1;
	for (i = 0; i < siFCnt; i++) {
		int liPos;
		fscanf(szpFpI, "%d", &liPos);

		// 蛙数[最高順位] - セット
		si1FCnt[liOrd]++;
		if (liNow + 1 < liPos) {
			liNow += 2;
		}
		else {
			liOrd++;
		}
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// パターン数 - 取得
	int liFCnt = 1;
	int liPCnt = 1;
	for (i = 1; i < siFCnt; i++) {
		liFCnt += si1FCnt[i] - 1;
		liPCnt = fGetModMulti(liPCnt, liFCnt);
	}

	return liPCnt;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 512
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N, K =map(int, input().split())
blue = K
red = N - K
over = 10**9 + 7

for i in range(K):
    if i <= red:
        print((cmb(red+1, i+1)  * (cmb(blue-1, i))) % over)
    else:
        print(0)              

Measured memory_bytes: 3444
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, M = read_int()

def solve():
    ans = 0
    return N * (N - 1) // 2 + M * (M - 1) // 2

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3952
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 

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


struct Node{
	int cnt;
	Node *left, *right;
	Node(){}
	Node(int cnt, Node *left, Node *right){
		this->cnt = cnt;
		this->left = left;
		this->right = right;
	}
 
	Node* insert(int s, int e, int val);
};
 
 
Node *null = new Node(0, NULL, NULL);
Node* root[100005];
 
Node* Node::insert(int s, int e, int pos){
	
	if(pos<s || pos>e)	return this;
 
	if(s == e)	return new Node(this->cnt+1, null, null);
 
	int mid = (s + e)/2;
	Node* resultant = new Node(this->cnt+1, this->left->insert(s, mid, pos), this->right->insert(mid+1, e, pos));
	return resultant;
}
 
 
int query(Node *a, Node *b, int s, int e, int lo, int hi){
	
	if(s > e || lo > e || s > hi)	return 0;
	if(s >= lo && e <= hi)	return b->cnt - a->cnt;
 
	int mid = (s + e)/2;
 	int x = query(a->left, b->left, s, mid, lo, hi);
 	int y = query(a->right, b->right, mid+1, e, lo, hi);
 	return x+y;
}


int n, m;
vector<int> arr[100005];


int main(){
 
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);

	scanf("%d%d", &n, &m);
	for(int i=0;i<n;i++){
		int l, r;
		scanf("%d%d", &l, &r);
		arr[l].pb(r);
	}

	null->left = null->right = null;
	root[0] = null;

	for(int i=1;i<=m;i++){
		root[i] = root[i-1];
		for(auto it : arr[i])
			root[i] = root[i]->insert(1, m, it);
	}

	printf("%d\n", n);
	for(int i=2;i<=m;i++){
		
		int ans = n, last = 0;
		for(int j=i;j<=m;j+=i){
			ans -= query(root[last], root[j-1], 1, m, last+1, j-1);
			last = j;
		}
		if(last != m)
			ans -= query(root[last], root[m], 1, m, last+1, m);
		printf("%d\n", ans);
// break;
	}

    return 0;
}








Measured memory_bytes: 172416