akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0}; //次に行くところ
int dx[] = {0,1}; //上に同じ

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

  ll n,ans = 0;
  cin >> n;
  vector<ll> a(n);

  for (int i = 0; i < n; i++){
    cin >> a[i];
    if (i != 0 && a[i] < a[i-1]){
      ans += a[i-1]-a[i];
      a[i] = a[i-1];
    }
  }
  
  cout << ans << '\n';
  return 0;
}

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

s = input()
if s[0] == 'R':
    if s[1] == "R":
        if s[2] == "R":
            print(3)
        else:
            print(2)
    else:
        print(1)
else:
    if s[1] == "R":
        if s[2] == "R":
            print(2)
        else:
            print(1)
    else:
        if s[2] == "R":
            print(1)
        else:
            print(0)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int c[51];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int x,m;
    cin>>x>>m;
    int r,l;
    for (int i=0;i<m;i++){
        cin>>r>>l;
        c[r]++;
        c[l]++;
    }
    for (int i=1;i<=x;i++)
        cout<<c[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;


import java.io.*;
/**
 * MLASERP
 */
public class Main {

    
    static MyScanner in  = new MyScanner();
   static int mod  = 1000000007;
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      static StringTokenizer st;
      static int []dr  = {1,-1,0,0};
      static int [] dc = {0,0,-1,1};
public static void main(String[] args) {
    int N = in.nextInt();
    int [] a = new int[N];
    for(int i=0;i<N;i++){
        a[i] = in.nextInt();
    }
    int max = a[0];
    long val =0;
    for(int i=1;i<N;i++){
        if(a[i]<=max){
            val+=(max-a[i]);
        }else{
            max = a[i];
        }
    }
    out.println(val);
   out.flush();

}
static int rcToxy(int r, int c,int W){
    return r*W+c;
}
static class Node{
    int r, c,prev,change;
    Node(int r, int c){
        this.r =r ;
        this.c = c;
    }
}
public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         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: 55388
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
       
    do {
        cin >> a >> b >> c;
    } while ((a < 1 || a > 10000) || (b < 1 || b > 10000) || (c < 1 || c > 10000));
    
    while (!(a <= b && b <= c)) {
           if (a > b) {
               int temp1 = a;
               a = b;
               b = temp1;
           } 
	  
           if (b > c) {
	       int temp2 = b;
               b = c;
               c = temp2;
           }	   
    }

    cout << a << " " << b << " " << c << endl;

    return (0);
}

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

bool is_prime(int k)
{
	for(int j=2;j*j<=k;j++){
		if(k%j==0) {
			return false;
		}
	}
    return true;
}


int main()
{
    stringstream ss;
    // 入力
    int N,M;
    cin>>N>>M;

    ll x[N+1],y[N+1],z[N+1];
    for(int i=0;i<N;i++){
    	cin>>x[i]>>y[i]>>z[i];
    }

    ll sum[8][N+1];
    for(int i=0;i<N;i++){
    	sum[0][i]=x[i]+y[i]+z[i];
    	sum[1][i]=x[i]+y[i]-z[i];
    	sum[2][i]=x[i]-y[i]+z[i];
    	sum[3][i]=x[i]-y[i]-z[i];
    	sum[4][i]=-1*x[i]+y[i]+z[i];
    	sum[5][i]=-1*x[i]+y[i]-z[i];
    	sum[6][i]=-1*x[i]-y[i]+z[i];
    	sum[7][i]=-1*x[i]-y[i]-z[i];
    }

    ll ans[8];
    for(int i=0;i<8;i++){
    	ans[i]=0;
        sort(sum[i],sum[i]+N);
        for(int j=N-1;j>N-M-1;j--){
        	ans[i]+=sum[i][j];

        }
    }
    ll answer=0;
    for(int i=0;i<8;i++){
    	if(ans[i]>answer) answer=ans[i];
    }

    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 384
//2001年アジアA Starship Hakodate-maru

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int Max(int n1,int n2);

int main(){
	int f1[54]={0},f2[96]={0};
	for(int i=0;i<54;i++) f1[i] = i*i*i;
	for(int i=0;i<96;i++) f2[i] = i*(i+1)*(i+2)/6;
	int num;
  while(scanf("%d",&num),num){
		int max=0;
		for(int i=0;i<54;i++){
			for(int j=0;j<96;j++){
				if(f1[i]+f2[j]<=num) max=Max(max,f1[i]+f2[j]);
			}
		}
		printf("%d\n",max );
  }
  exit(0);
}

int Max(int n1,int n2){
  if(n1>n2)return n1;
  else return n2;
}



Measured memory_bytes: 2036
N,A,B,C,X,Y[100];
main(){
	int n,i;
	for(;scanf("%d",&N)*N;){
		scanf("%d%d%d%d",&A,&B,&C,&X);
		for(i=0;i<N;i++)
			scanf("%d",Y+i);
		i=0;
		for(n=0;n<10001&&i<N;n++){
			if(X==Y[i]){
				i++;
			}
			X=(A*X+B)%C;
		}
		printf("%d\n",i<N?-1:n-1);
	}
	{int n;for(n=1000000;n--;)getchar();}//delay(0.52s)
	exit(0);
}

Measured memory_bytes: 412
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> a[i];
    }
    int ans = 0;
    int light = 1;
    for (int i = 0; i < N; ++i)
    {
        ++ans;
        light = a[light - 1];
        if (light == 2)
        {
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3776
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    double l;
    cin >> l;
    double i = l/3;
    cout << fixed << setprecision(8) << pow(i,3) << endl;
}

Measured memory_bytes: 4140
#include <iostream>
#include <vector>
#include <string>
#include <random>
#include <algorithm>
#include <iomanip>
#include <map>
using namespace std;

#define FOR(i,a,b) for(int i = a; i < b; ++i)
#define REP(i,n)   for(int i = 0; i < n; ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

ull powmod(ull a, ull b, ull mod) {ull res = 1; for(; b; b >>= 1){if (b & 1) {res = res * a % mod;} a = a * a % mod;} return res;}

int main(){
  ull N, M;
  map<string, ll> mp;
  ll res = 0;

  cin >> N;
  REP(i, N){
    string s;
    cin >> s;
    auto itr = mp.find(s);
    if (itr != mp.end()){
      ++mp[s];
    }else{
      mp[s] = 1;
    }
  }

  cin >> M;
  REP(i, M){
    string s;
    cin >> s;
    auto itr = mp.find(s);
    if (itr != mp.end()){
      --mp[s];
    }else{
      mp[s] = -1;
    }
  }

  for (auto itr = mp.begin(); itr != mp.end(); ++itr){
    if(itr->second > res){
      res = itr->second;
    }
  }
  cout << res << "\n";

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long Int;
int n;
int res;
string str[310];

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

	for(int i = 0;i < n;i++){
		int ok = n;
		for(int j = 0;j < n;j++){
			for(int k = 0;k < n;k++){
				int jj = (j+i) % n;
				int kk = (k+i) % n;
				if(str[jj][k] != str[kk][j])ok = 0;
			}
		}
		res += ok;
	}
	cout << res << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
	int a,b,c;
	int x=0;
	int i;
	
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=a;i<=b;i++){
		if(c%i==0)x++;
	}
	printf("%d\n",x);
	return 0;
}

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

int main() {
  char C;
  cin >> C;

  set<int> st;
  st.insert('a');
  st.insert('e');
  st.insert('i');
  st.insert('o');
  st.insert('u');

  if (st.find(C) != st.end()) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
s = input()
k = int(input())
f = True
c = 0
for i in s:
    if i=='1' and f: c+=1
    else: 
        f=False
        break
if c==0:
    print(s[0])
else:
    if c>=k: print(s[0])
    else: print(s[c])

Measured memory_bytes: 38256
#include<stdio.h>

int sort(int A[], int n){
  int i, g, t;
  int s = 0;
  if (n == 1) {
      s = 0;
      return s;
  }
  for ( i = 0; i < n; i++){
    for ( g = n-1; g >= i+1; g--){
      if ( A[g] < A[g-1] ){
            t = A[g];
            A[g] = A[g-1];
            A[g-1] = t;
            s++;
      }
    }
  }
  return s;
}

int main(){
  int A[100], n, i, s = 0;

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

  for ( i = 0; i < n-1; i++ ){
    printf("%d ", A[i]);
  }
  printf("%d", A[i]);
  printf("\n");
  printf("%d\n", s);

  return 0;
}


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

int main(void){
  long long a, b, k;
  long long zero = 0;
  cin >> a >> b >> k;
  if(k>a){
    b = max(zero, b-(k-a));
    a = 0;
  }else if(k==0){;}
  else if(a==0){
    a = 0;
    b = max(zero, b-k);
  }
  else if(k<=a){
    a = a - k;
  }

  cout << a << " " <<  b << endl;
  return 0;
}


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

int main()
{
    double n, m, d;
    cin >> n >> m >> d;
    double p = (n - d) / (n * n) * (m - 1) * 2;
    if (d == 0)
        p /= 2;

    printf("%lf\n", p);
    return 0;
}


Measured memory_bytes: 256
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let mut n: i64 = iter.next().unwrap().parse().unwrap();
    let mut ret: Vec<char> = vec![];
    while {
        let b = if n.abs() % 2 == 0 {'0'} else {'1'};
        ret.push(b);
        n = if n.abs() % 2 == 1 {
            (n-1)/-2
        } else {
            n/-2
        };
        n != 0
    } {}
    ret.reverse();
    println!("{}", ret.into_iter().collect::<String>());
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

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

int a, b, c, d, n;
string s;

void no () {
	cout << "No" << endl;
	exit(0);
}

void can (int i, int j) {
	for (int k = i; k + 1 <= j; k++)
		if (s[k] == '#' && s[k+1] == '#')
			no();
}

void three (int i, int j) {
	for (int k = i; k + 2 <= j; k++)
		if (s[k] == '.' && s[k+1] == '.' && s[k+2] == '.')
			return;
	no();
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> a >> b >> c >> d >> s;
	a--, b--, c--, d--;
	can(a, c);
	can(b, d);

	if (d < c)
		three(b - 1, d + 1);

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 592
using System;
class ProgramD
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            double sum = 0.0;

            long[] a = new long[n];

            string[] input2 = Console.ReadLine().Split(' ');
            for(int i = 0;i < n;i++)
                a[i] = long.Parse(input2[i]);
            
            for(int i = 0; i < k ;i++)
                sum += (double)(1.0 + (a[i] - 1) * 0.5);
            
            
            double ans = sum;


            //漸化式で攻撃する回数を求める
            for(int i = k; i < n;i++)
            {
                sum -= (double)(1.0 + (a[i - k] - 1.0) * 0.5);
                sum += (double)(1.0 + (a[i] - 1.0) * 0.5);
                
                if(sum > ans)
                {
                    ans = sum;
                }
            }


            //答え出力
            Console.WriteLine(ans);
        } 
    } 

Measured memory_bytes: 29020
n = int(input())
a = list(map(int, input().split()))

x = max(a)
dp = [0] * (x+1)
for ai in a:
    i = 1
    if dp[ai] <= 2:
        while i * ai <= x:
            dp[i * ai] += 1
            i += 1

ans = 0
for ai in a:
    if dp[ai] <= 1:
        ans += 1

print(ans)

Measured memory_bytes: 132828
k = int(input())
lunlun = [1, 2, 3, 4, 5, 6, 7, 8, 9] #ルンルン数リスト

for i in range(k):
    x = lunlun[i]
    if x%10 != 0:
        lunlun.append(x*10+x%10-1)
    lunlun.append(x*10+x%10)
    if x%10 != 9:
        lunlun.append(x*10+x%10+1)
        #print(lunlun)
print(x)

Measured memory_bytes: 15784
n, m = gets.split.map(&:to_i)
l_arr = []
r_arr = []
m.times do
  l, r = gets.split.map(&:to_i)
  l_arr << l
  r_arr << r
end

if r_arr.min == l_arr.max
  puts 1
elsif r_arr.min > l_arr.max
  puts (r_arr.min - l_arr.max) + 1
else
  puts 0
end

Measured memory_bytes: 3468
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vii vector<pii>
#define vvi vector<vector<int>>
#define vvii vector<vector<pii>>
#define vvll vector<vector<ll>>
#define umap unordered_map
#define uset unordered_set
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define debugrep(i, a, b) for (int i = a; i < b; i++)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define debugrep(i, a, b)
#define check(...)
#endif

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

    string s, t;
    cin >> s;
    cin >> t;
    if (s.size() + 1 == t.size() &&
        t.substr(0, s.size()) == s) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
int main(){
    using namespace std;
    int n,m;
    cin>>n>>m;
    string a[n],b[m];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<m;i++)cin>>b[i];

    bool ans=false;
    for(int i=0; i<=n-m; i++){
        for(int j=0; j<=n-m; j++){ //左上i,j
            for(int k=0; k<m; k++){
                if (a[i+k].substr(j,m)!=b[k]) break;
                if (k==m-1)ans=true;
            }
        }
    }

    cout << (ans ? "Yes\n" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int main(void) {
	int num, i, j, h, w;
	cin >> h >> w;
	vector<string> mp(h + 1);
	vector<vector<ll>> dp(h + 1, vector<ll>(w + 1, 0));
	rep(i, h) {
		cin >> mp[i];
		mp[i] += "#";
	}
	mp[h] = string(w + 1, '#');
	dp[0][0] = 1;
	rep(i, h) {
		rep(j, w) {
			dp[i][j] %= MOD;
			dp[i][j + 1] += mp[i][j + 1] == '.' ? dp[i][j] : 0;
			dp[i + 1][j] += mp[i + 1][j] == '.' ? dp[i][j] : 0;

		}
	}
	cout << dp[h - 1][w - 1] << "\n";
	return 0;
}

Measured memory_bytes: 13372
N,M = map(int,input().split())

S = list(map(int,input().split()))
T = list(map(int,input().split()))


ans = [[0] * (M+1) for i in range(N+1)]

for i in range(N+1):

    for j in range(M+1):

        if i == 0 or j == 0:
            ans[i][j] = 1

        elif S[i-1] == T[j-1]:
            ans[i][j] = ans[i-1][j] + ans[i][j-1]

        else:
            ans[i][j] = ans[i-1][j] + ans[i][j-1] - ans[i-1][j-1]

        ans[i][j] %= (10 ** 9 + 7)

print (ans[-1][-1])


Measured memory_bytes: 72668
N, M = map(int, input().split())

bulbs = []
for m in range(M):
    ks = map(int, input().split())
    bulbs.append(list(ks)[1:])

P = list(map(int, input().split()))

result = 0
for m in range(2**N):
    switches = list(map(int, list(str(bin(m))[2:])))
    switches = [0]*(N-len(switches)) + switches

    flag = True
    for idx, bulb in enumerate(bulbs):
        count = 0
        for switch in bulb:
            count += switches[switch-1]
        if count % 2 != P[idx]:
            flag = False
            break
    if flag:
        result += 1
print(result)


Measured memory_bytes: 42968
#include<bits/stdc++.h>
using namespace std;
const int Maxn=1e5+100;
int n,a,k,out[Maxn];
vector <int> vec1,vec2,vec4;
int main(){
	cin>>n;
	for(int i=0,a;i<n;i++){
		cin>>a;
		if(a%4==0)
			vec4.push_back(a);
		else if(a%2==0)
			vec2.push_back(a);
		else
			vec1.push_back(a);
	}
	k=4;
	for(int i=0;i<n;i++){
		if(k==1){
			if(vec4.size()==0){
				cout<<"No";
				return 0;
			}
			vec4.pop_back();
			k=4;
		}
		else if(k==2){
			if(vec2.size()!=0)
				vec2.pop_back(),k=2;
			else if(vec4.size()!=0)
				vec4.pop_back(),k=4;
			else{
				cout<<"No";
				return 0;
			}
		}
		else if(k==4){
			if(vec1.size()!=0)
				vec1.pop_back(),k=1;
			else if(vec2.size()!=0)
				vec2.pop_back(),k=2;
			else if(vec4.size()!=0)
				vec4.pop_back(),k=4;
		}
	}
	cout<<"Yes";
}


Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
using namespace std;

int len;
int main() {
    //freopen("input.txt", "r", stdin) ;
    //freopen("output.txt", "w", stdout) ;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    cin>>len;
    vector<ll> lists(len,0);
    for(int i=0;i<len;i++) cin>>lists[i];
    ll ans=0;
    for(int i=1;i<len;i++){
        if(lists[i-1]>lists[i]){
            ans+=lists[i-1]-lists[i];
            lists[i]=lists[i-1];
        }
    }
    cout<<ans;
    return 0;
}




Measured memory_bytes: 4768
import Data.Maybe
main = do
  (a:b:c:d:_) <- getLine >>= return . (map (read . (\c -> [c]))) :: IO [Int]
  let op = ['+', '-']
  let eq = [(op1,op2,op3) | op1<-op, op2<-op, op3<-op]
  
  putStrLn $ (head . catMaybes) (map (\x -> f x a b c d) eq)
  where
    f (op1,op2,op3) a b c d
      | a `op1'` b `op2'` c `op3'` d == 7 = Just ((show a) ++ [op1] ++ (show b) ++ [op2] ++ (show c) ++ [op3] ++ (show d) ++ "=7")
      | otherwise = Nothing
      where
        op1' = g op1
        op2' = g op2
        op3' = g op3


    g '-' = (-)
    g '+' = (+)


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

int max(int a,int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int main(){

  int n;
  scanf("%d",&n);

  if( n%10 ==2 ){
    puts("hon");
  }
    if( n%10 ==4 ){
    puts("hon");
  }
    if( n%10 ==5 ){
    puts("hon");
  }
    if( n%10 == 7 ){
    puts("hon");
  }
    if( n%10 ==9){
    puts("hon");
  }
    if( n%10 ==0){
    puts("pon");
  }
      if( n%10 == 1 ){
    puts("pon");
  }
      if( n%10 ==6 ){
    puts("pon");
  }
      if( n%10 ==8){
    puts("pon");
  }
    if( n%10 ==3){
    puts("bon");
  }

  return 0;
}

Measured memory_bytes: 1644
#include<iostream>
using namespace std;
int d[51][3210],n,m,s,i,j,k;
int main(){
	while(cin>>n>>m>>s&&n){
		n*=n;
		for(i=0;i<=n;i++)for(j=0;j<=s;j++)d[i][j]=0;d[0][0]=1;
		for(k=1;k<=m;k++){
			for(i=n;i;i--){
				for(j=k;j<=s;j++){
					d[i][j]=(d[i][j]+d[i-1][j-k])%100000;
				}
			}
		}
		cout<<d[n][s]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3624
# ギブアップして解説を見た上で、コードを書きました。

n , k = gets.split.map(&:to_i)
ans = 0

if k == 0
	print n**2
	exit
else
	(2..n).each do |b|
		ans += n/b * [0, b-k].max + [0, n%b-k+1].max
	end
end

print ans


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

int main() {
    int a,b;
    int c=1;
    cin >> a;
    cin >> b;
    while(a>0){
        c = c*b;
        if (b/c==1){
            b--;
        }
        a--;
    }
    cout << c;
}


Measured memory_bytes: 3588
import java.util.*;
 
class Main {
 
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    int[] fromAnt;
    fromAnt = new int[5];
    int[] toAnt;
    toAnt = new int[5];
    
    for(int i = 0; i < 5; i++) {
      fromAnt[i] = sc.nextInt();
      toAnt[i] = fromAnt[i];
    }
    int k = sc.nextInt();
    
    for(int i = 0; i < 5; i++) {
      for(int j = i+1; j < 5; j++) {
        if(toAnt[j] - fromAnt[i] > k) {
          System.out.println(":(");
          return;
        }
      }
    }
    
    System.out.println("Yay!");
	return;    
  }
 
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
struct Node
{
    ll  a,b;
} s[maxn];
bool cmp(Node a,Node b)
{
    return a.a+a.b>b.a+b.b;
}
int vis[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>s[i].a>>s[i].b;

    }
    ll sum1=0,sum2=0;
    sort(s,s+n,cmp);
    for(int i=0;i<n;i++)
    {
        sum1+=s[i].a;
        i++;
        if(i>=n)
            break;
        sum2+=s[i].b;
    }
  cout<<sum1-sum2<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;
 
int main() {
 int N;
 cin >>N;
 if(N<1200){
 	ce("ABC");
 }else if(N<2800){
 	ce("ARC");
 }else{
 	ce("AGC");
 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
    fast;
    lli n,x,t;
    cin>>n>>x>>t;
    if(x>=n)
    {
        cout<<t;
    }
    else
    {
        if(n%x==0)
        {
            cout<<t*(n/x);
        }
        else
        {
            cout<<t*(n/x+1);
        }
    }
    
    return 0;
}

Measured memory_bytes: 3636
#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 pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long n,a,b;
  cin >> n >> a >> b;
  long d = a - b;
  vector<long> h(n);
  rep(i,n) cin >> h.at(i);
  long maxi = 1e9;
  long mini = 1;
  while(maxi - mini > 1){
    long mid = (maxi + mini)/2;
    long cnt = 0;
    rep(i,n){
      long tmp = h.at(i) - b*mid;
      if(tmp <= 0) continue;
      cnt += (tmp+d-1)/d;
    }
    if(cnt < mid) maxi = mid;
    else mini = mid;
  }
  long cnt = 0;
  rep(i,n){
    long tmp = h.at(i) - b*mini;
    if(tmp <= 0) continue;
    cnt += (tmp + d - 1)/d;
  }
  if(cnt <= mini) cout << mini << endl;
  else cout << maxi << endl;
}


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

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

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int x, a, b; cin >> x >> a >> b;

  x -= a;
  cout << x % b << endl;
  
  return (0);
}

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
int N;
multiset<int> A;
int main() {
	int t, k, c=0;
	scanf("%d", &N);
	rep(i, 0, N)scanf("%d", &t), A.insert(t);
	while (A.size() > 1) {
		auto it = A.end();
		it--;
		t = *it;
		A.erase(it);
		for (k = 1; k <= t; k *= 2);
		it = A.find(k - t);
		if (it != A.end()) {
			A.erase(it);
			c++;
		}
	}
	printf("%d", c);
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define hetu int t;cin >> t;while(t--) 


void solve()
{
	int n;
	cin >> n;
	int a[n];
	int cnt=0;
	for(int i=0;i<n;++i)
	cin >> a[i];
	for(int i=0;i<n;++i)
	{
		for(int j=i+1;j<n;++j)
		{
			for(int k=j+1;k<n;++k)
			{
				if(a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[i]+a[k]>a[j] && a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k] && i!=j && i!=k && j!=k)
				cnt++;
			}
		}
	}
	cout << cnt << endl;

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//hetu
	solve();
	return 0;
}

Measured memory_bytes: 3644
import heapq
import itertools
import sys

input = sys.stdin.readline

def main():

    n,m,r = map(int,input().split())
    R = list(map(int,input().split()))
    for i in range(r):
        R[i] -= 1

    roots = [[] for _ in range(n)]
    for _ in range(m):
        a,b,c = map(int,input().split())
        roots[a-1].append((b-1, c))
        roots[b-1].append((a-1, c))

    def dijkstra(edges, s):
        hq = []
        d = [-1] * n
        d[s] = 0
        heapq.heappush(hq, (0, s))
        while hq:
            d1, p = heapq.heappop(hq)
            for p2, d2 in edges[p]:
                if d[p2] == -1 or d[p2] > d1 + d2:
                    d[p2] = d1 + d2
                    heapq.heappush(hq, (d1+d2, p2))
        return d

    ans = 10**10
    d = []

    for i in range(n):
        d1 = dijkstra(roots, i)
        d.append(d1)

    ptr = list(itertools.permutations(R, len(R))) # 順列列挙 5P3

    for i in ptr:
        tmp = 0
        for j in range(len(i) - 1):
            tmp += d[i[j]][i[j+1]]
        ans = min(ans, tmp)

    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for(int i = 0; i < N; i++){
        std::cin >> A[i];
    }
    long double sum = 0;
    for(auto t : A){
        sum += (long double)1 / (long double)t;
    }
    std::cout << (long double)1 / (long double)sum << std::endl; 
    return 0;
}

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

using std::cin;
using std::cout;
using std::string;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if ( n % 2 == 1 ) {
        cout << "No" << "\n";
    } else {
        int aux = n / 2;
        bool flag = true;
        for (int i = 0; i < aux; ++i) {
            if (s[i] != s[i + aux]) {
                flag = false;
            }
        }

        string ans = flag ? "Yes" : "No";
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
def calc_div2(n):
    return n/2

count = 0
flag = 0
n_num = input()
data_list = list(map(int, input().split()))

while flag == 0:
    for data in data_list:
        if data%2 != 0:
            flag = 1
            break
    if flag == 0:
        data_list = list(map(calc_div2, data_list))
        count+=1
print( count )

Measured memory_bytes: 9200
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n,m,x;
  cin>>n>>m>>x;
  vector<ll> vc;
  vector<vector<ll> > vv(n,vector<ll>());
  rep(i,0,n){
    ll a;
    cin>>a;
    vc.pb(a);
    rep(j,0,m){
      ll b;
      cin>>b;
      vv[i].pb(b);
    }
  }
  ll mn = 1000000000;
  rep(i,0,1<<n){
    ll a = 0;
    ll d[15];
    clr(d,0);
    rep(j,0,n){
      if((i>>j)&1){
        a += vc[j];
        rep(k,0,m){
          d[k] += vv[j][k];
        }
      }
    }
    ll flag = 1;
    rep(j,0,m){
      if(d[j]<x)flag = 0;
    }
    if(flag==1){
      mn = min(mn,a);
    }
  }
  if(mn==1000000000){
    cout << -1 << endl;
  }
  else{
    cout << mn << endl;
  }
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n;
  cin >> n;
  vector<pair<double,string>> a;
  double ans=0;
  rep(i,n) {
    double x;
    string y;
    cin >> x >> y;
    a.push_back(make_pair(x,y));
    if(a.at(i).second == "JPY") 
      ans += a.at(i).first;
    else 
      ans += a.at(i).first * 380000;
  }
  cout << fixed << setprecision(5);
  cout << ans;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N+1);
    rep(i, N){
        int a;
        cin >> a;
        A[a]++; 
    }

    sort(all(A));
    reverse(all(A));

    int ans = 0;

    rep(i, K){
        ans += A[i];
    }

    cout << N - ans << endl;
    
}

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

	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 = int(input())
s = []
for _ in range(n):
	tmp = list(input())
	tmp.sort()
	s.append(tmp)

s.sort()

count = 1
ans = 0
for i in range(n-1):
	if s[i] == s[i+1]:
		count += 1
	else:
		ans += cmb(count,2)
		count = 1

if count != 1:
	ans += cmb(count,2)

print(ans)


Measured memory_bytes: 24652
#include<stdio.h>

int main(void){
  double a,b,c,d,e,f;
  while(scanf("%lf %lf %lf %lf %lf %lf", &a,&b,&c,&d,&e,&f)!=EOF){
    printf("%.3f %.3f\n",c/a-(b*(a*f-d*c))/(a*(a*e-b*d)) ,(a*f-d*c)/(a*e-b*d));
  }
  return 0;
}

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

int main() {
  int n,m;
  cin >>n>>m;
  int a[n][n];
  int b[m][m];
  string s;
  for(int i=0;i<n;i++){
    cin>>s;
    for(int j=0;j<n;j++){
      if(s[j]=='.')a[i][j]=0;
      else a[i][j]=1;
    }
  }
  for(int i=0;i<m;i++){
    cin>>s;
    for(int j=0;j<m;j++){
      if(s[j]=='.')b[i][j]=0;
      else b[i][j]=1;
    }
  }
  
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      bool hantei=true;
      for(int k=0;k<m;k++){
        for(int l=0;l<m;l++){
          if(a[i+k][j+l]!=b[k][l]){
            hantei=false;
            break;
          }
        }
        if(hantei==false)break;
      }
      if(hantei){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3616
//
// Created by yijiezhu on 12/21/16.
//
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

const string origin = "01234567";
int delta[] {-1, 1, -4, 4};
map<string, int> dp;

void bfs() {
    queue<string> que;
    que.push(origin);
    dp.insert(make_pair(origin, 0));

    while (!que.empty()) {
        string v = que.front(); que.pop();
        int z(0);
        for (int i = 1; i < 8; i++) {
            if (v[i] == '0') z = i;
        }
        for (int q = 0; q < 4; q++) {
            if (z == 4 && delta[q] == -1) continue;
            if (z == 3 && delta[q] == 1) continue;
            int nz = z + delta[q];
            if (nz < 0 || nz >= 8) continue;
            string nk = v;
            swap(nk[z], nk[nz]);
            if (dp.find(nk) == dp.end()) {
                que.push(nk);
                dp[nk] = dp[v] + 1;
            }
        }
    }
}

int main() {
    bfs();
    string s;
    while (getline(cin, s)) {
        s.erase(remove(s.begin(), s.end(), ' '), s.end());
        cout << dp[s] << endl;
    }
}

Measured memory_bytes: 5208
import math
def calculate(arr1,arr2,zeroExist):
    if (len(arr1) % 2 == 0) or (zeroExist == True):
        return sum(arr2) + sum(arr1)
    else:
        return sum(arr2) + sum(arr1) - 2 * (calculateAbsSmallest(arr1,arr2))


def calculateAbsSmallest(arr1,arr2):
    arr1.sort()
    arr2.sort()
    if len(arr2) == 0:
        return arr1[0]
    return min(arr1[0],arr2[0])

N = int(input())

arr1 = []
arr2 = []
zeroExist = False
for s in input().split(" "):
    if int(s) == 0:
        zeroExist = True
    if int(s) < 0:
        arr1.append(abs(int(s)))
    else:
        arr2.append(int(s))

arr1 = list(arr1)
arr2 = list(arr2)

res = calculate(arr1,arr2,zeroExist)
print(res)






Measured memory_bytes: 14684
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	ll gcd(ll a, ll b, ll c) {
		ll res = std::gcd(a, b);
		res = std::gcd(res, c);
		return res;
		//return gcd(a, gcd(b, c));
	}

	void solve() {
		IOS;
		int n;
		cin >> n;
		ll res = 0;
		FOR(i, 1, n+1) {
			FOR(j, 1, n + 1) {
				FOR(k, 1, n + 1) {
					res += gcd(i, j, k);
				}
			}
		}
		put(res);
	}
} // namespace idaten

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

Measured memory_bytes: 3612
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N = I()
    a = LI()
    b = LI()
    cnt = 0
    for i in range(len(b)):
        left = min(a[i], b[i])
        cnt += left
        b[i] -= left

        right = min(a[i+1], b[i])
        cnt += right
        b[i] -= right
        a[i+1] -= right
    print(cnt)
    """
    a = [0] + a
    b = [0] + b + [0]
    cnt = 0
    for i in range(1, N+2):
        if a[i] - b[i-1] >= 0:
            cnt += b[i-1]
            a[i] = a[i] - b[i-1]
            b[i-1] = 0
        else:
            cnt += a[i]
            b[i-1] = b[i-1] - a[i]
            a[i] = 0

        if a[i] - b[i] >= 0:
            cnt += b[i]
            a[i] = a[i] - b[i]
            b[i] = 0

        else:
            cnt += a[i]
            b[i] = b[i] - a[i]
            a[i] = 0
    print(cnt)
    """

main()



Measured memory_bytes: 21616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()

int main(){
	long A,B,C,D;cin>>A>>B>>C>>D;
	long l=C*D/__gcd(C,D);
	long x=B-(B/C+B/D-B/l);
	A--;
	long y=A-(A/C+A/D-A/l);
	cout<<x-y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int H,W;
	int N;
	cin>>H>>W;
	cin>>N;
	int i,j;
	vector<int> A(N);
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	vector<vector<int>> C(H,vector<int>(W));
	int color=1;
	i=0;
	j=0;
	bool ToRight=true;
	for (int k=0;k<N;k++){
		for (int l=0;l<A[k];l++){
			C[i][j]=color;
			if (ToRight){
				if (j<W-1){
					j++;
				}else{
					i++;
					j = W-1;
					ToRight=false;
				}
			}else{
				if (j>0){
					j--;
				}else{
					j=0;
					i++;
					ToRight=true;
				}
			}
		}
		color++;
	}
	for (i=0;i<H;i++){
		for (j=0;j<W;j++){
			cout<<C[i][j];
			if (j<W-1){
				cout<<" ";
			}
		}
		cout<<endl;
	}
	return 0;
}

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

int mp[5];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  for(int i=0;i<n;i++){
    int t;cin>>t;
    if(t%4==0){
      mp[4]++;
    }else if (t%2==0){
      mp[2]++;
    }else{
      mp[0]++;
    }
  }

  if(mp[4]>=mp[0]){
    cout<<"Yes"<<endl;
  }else if((mp[4]+1==mp[0])&&mp[2]==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

A,B=rl()
print((A-1)*(B-1))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cassert>
using namespace std;
typedef unsigned long long ll;
static const int BIT = 64;
static const int TH_MAX = 800;
static const int TW_MAX = 800;
static const int PH_MAX = 100;
static const int PW_MAX = 100;

char T[TH_MAX][TW_MAX+1];
char P[PH_MAX][PW_MAX+1];

int PH, PW, TH, TW;
ll K, R, Y;

ll M[PH_MAX][PW_MAX/BIT+1][256];
ll st[PH_MAX][PW_MAX/BIT+1];

void makeMask(){
  R = PW%BIT;
  K = PW/BIT + (R>0?1:0);
  Y = (1LL<<(R + (BIT-1))%BIT);
  string L = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?";
  for ( int r = 0; r < PH; r++ ){
    for ( int c = 0; c < L.size(); c++ ){
      for ( int k = 0; k < K; k++ ){
        for ( int b = 0; b < BIT; b++ ){
          if ( k*BIT+b >= PW ) continue;
          if ( P[r][k*BIT+b] == L[c] || L[c] == '?' || P[r][k*BIT+b] == '?'){
            M[r][k][L[c]] += (1LL<<b);
          }
        }
      }
    }
  }
}

main(){
  cin >> TW >> TH >> PW >> PH;
  for ( int i = 0; i < TH; i++ ) scanf("%s", T[i]);
  for ( int i = 0; i < PH; i++ ) scanf("%s", P[i]);

  makeMask();

  int ans = 0;
  for ( int h = 0; h < TH; h++ ){
    for ( int i = 0; i < PH; i++ ){
      for ( int j = 0; j < K; j++ ) st[i][j] = 0;
    }
    for ( int w = 0; w < TW; w++ ){
      int ok = 0;
      for ( int r = 0; r < PH; r++){
        if ( h + r >= TH ) continue;

        for ( int k = K-1; k >= 0; k-- ){
          int ca = (st[r][k-1] & (1LL<<(BIT-1)))>0?1:0;
          if ( k == 0 ) ca = 1;
          st[r][k] = ((st[r][k] << 1) | ca ) & M[r][k][T[h+r][w]];
        }
        if ( st[r][K-1] & Y ) ok++;
      }
      if ( ok == PH ) ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4212
/*
妙题，神
考虑第 i 行和第 i + 1 行之间的边的贡献
显然是 (1 ~ i 行白点贡献) * (i + 1 ~ h 行白点贡献)
那么算过贡献以后将 i 和 i + 1 合并，将该行的值从 1 变为 2
对列也这么做一遍
最后剩下的是个 2n * 2n 的方格图
bfs一遍，n^4
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7, N = 1e6 + 10, M = 105, inf = 0x3f3f3f3f;
ll h, w, n, xx, yy, r[N], c[N], ans, cnt[M][M];
int dis[M][M];
bool mp[M][M];
struct node { ll x, y; }a[N];
vector<int> row, col;
const int d[][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

void uniq(vector<int> &vec) {
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());  // !!!
}

queue<node> q;
void bfs(int sx, int sy) {
    memset(dis, 0x3f, sizeof(dis));
    q.push((node){sx, sy});
    dis[sx][sy] = 0;
    while (q.size()) {
        node t = q.front(); q.pop();
        rep(i, 0, 3) {
            int tx = t.x + d[i][0], ty = t.y + d[i][1];
            if (tx < 0 || ty < 0 || tx > xx || ty > yy || mp[tx][ty] || dis[tx][ty] != inf) continue;
            dis[tx][ty] = dis[t.x][t.y] + 1;
            q.push((node){tx, ty});
        }
    }
}

int main() {
    cin >> h >> w >> n;
    rep(i, 1, h) r[i] = w;
    rep(i, 1, w) c[i] = h;
    row.push_back(1), row.push_back(h + 1), col.push_back(1), col.push_back(w + 1);
    rep(i, 1, n) {
        scanf("%lld%lld", &a[i].x, &a[i].y);
        ++a[i].x, ++a[i].y;
        row.push_back(a[i].x), row.push_back(a[i].x + 1);
        col.push_back(a[i].y), col.push_back(a[i].y + 1);
        r[a[i].x]--, c[a[i].y]--;
    }
    uniq(row), uniq(col);
    rep(i, 1, n) {
        int x = lower_bound(row.begin(), row.end(), a[i].x) - row.begin();
        int y = lower_bound(col.begin(), col.end(), a[i].y) - col.begin();
        mp[x][y] = 1;
    }
    
    rep(i, 1, h) r[i] = (r[i] + r[i - 1]) % mod;
    rep(i, 1, w) c[i] = (c[i] + c[i - 1]) % mod;
    rep(i, 1, h - 1)
        if ((r[i] - r[i - 1] + mod) % mod == w && (r[i + 1] - r[i] + mod) % mod == w)
            ans = (ans + 2 * r[i] * (r[h] - r[i] + mod) % mod) % mod;  // * 2, 后面会 / 回去
    rep(i, 1, w - 1)
        if ((c[i] - c[i - 1] + mod) % mod == h && (c[i + 1] - c[i] + mod) % mod == h)
            ans = (ans + 2 * c[i] * (c[w] - c[i] + mod) % mod) % mod;
    
    xx = row.size() - 2;
    yy = col.size() - 2;
    rep(i, 0, xx)
        rep(j, 0, yy)
            if (!mp[i][j])
                cnt[i][j] = 1ll * (row[i + 1] - row[i]) * (col[j + 1] - col[j]) % mod;  // !!!

    rep(i, 0, xx) {
        rep(j, 0, yy) {
            if (!mp[i][j]) {
                bfs(i, j);
                rep(k, 0, xx) {
                    rep(l, 0, yy) {
                        if (!mp[k][l]) {
                            ans = (ans + cnt[i][j] * dis[k][l] % mod * cnt[k][l] % mod) % mod;
                        }
                    }
                }
            }
        }
    }
    printf("%lld\n", ans * (mod / 2 + 1) % mod);  // mod / 2 + 1 = (mod - mod / 2) * inv[mod % 2] % mod
    return 0;
}


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


int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,k;
  cin>>n>>k;
  ll v[n],w[n];
  ll dp[n+1][k+1];
  for(int i=0; i<n; i++){
    cin>>w[i]>>v[i];
  }
  for(int i=0; i<=n; i++){
    for(int j=0; j<=k; j++){
        dp[i][j]=0;
    }
  }
  for(int i=1; i<=n; i++){
    for(int j=0; j<=k; j++){
        if(j>=w[i-1]){
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
        }
        else{dp[i][j]=dp[i-1][j];}
    }

  }
  ll ans=0;
  for(int i=0; i<=k; i++){
    ans=max(dp[n][i],ans);
  }
  cout<<ans;

  return 0;
}

Measured memory_bytes: 82532
//+-----------------+//
//|😈_Anonymous06_😈|//
//+-----------------+//
#include <bits/stdc++.h>
#define ll/*////////*/long long
#define gcd()/*////////*/___gcd()
#define pi/*////////*/3.141592653
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//------Enter your code here.------
	char a;cin>>a;if(a>='a' and a<='z')cout<<"a\n";else cout<<"A\n";	
}

Measured memory_bytes: 3644
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n, r;
  scanf("%d %d", &n, &r);

  if (n >= 10) {
    cout << r << endl;
    return 0;
  }

  cout << (r + 100 * (10 - n)) << endl;
  
  return 0;
}


Measured memory_bytes: 256
(defun create-data () 
  (let ((n (read)) 
        (a)) 
    (dotimes (i n) 
      (push (read) a))
    a)) 

(defun papers-please (a) 
  (let ((ans "APPROVED")) 
    (dolist (i a)
      (if (not (oddp i))
          (when (not (or (zerop (rem i 3)) (zerop (rem i 5))))
            (setf ans "DENIED") 
            (return)))) 
    ans)) 

(format t "~A~%" (papers-please (create-data))) 



Measured memory_bytes: 13544
#include <bits/stdc++.h>
 
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;
using namespace std;

struct edge {
    int src, dest, cost; 
    edge(int s, int t, int c): src(s), dest(t), cost(c) {}
};
const int INF = 1e8;

void bellman_ford(const vector<edge> &edges, vector<int> &d, const int s) {
    d.assign(d.size(), INF);
    d[s] = 0;
    for(int i=0; i < d.size(); ++i) {
        for(int j=0; j < edges.size(); ++j) {
            edge e = edges[j];
            if (d[e.dest] > d[e.src] + e.cost) {
                d[e.dest] = d[e.src] + e.cost;
            }
        }
    }
}

int main(void) {
    int n, m, s, g1, g2;
    while(cin >> n >> m >> s >> g1 >> g2 && n) {
        vector<edge> edges;
        vector<vector<int> > d(n, vector<int>(n));
        --s; --g1; --g2;
        REP(i, m) {
            int b1, b2, c;
            cin >> b1 >> b2 >> c;
            edges.push_back(edge(b1-1, b2-1, c));
        }
        REP(i, n) {
            bellman_ford(edges, d[i], i);
        }
        int ans = 0;
        int cost = numeric_limits<int>::max();
        REP(i, n) {
            cost = min(cost, d[s][i] + d[i][g1] + d[i][g2]);
        }
        cout << cost << endl;
    }
    return 0;
}

Measured memory_bytes: 3196