akhauriyash/Code-Regression huggingface dataset:
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define sz(a)  int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1};
const int dw[8] = {0, 0, 1, -1,1,-1,1,-1};
typedef long long ll;
typedef pair<int, int> p;
typedef vector <int> VI;
typedef vector <string> VS;

vector <int> his;

int main(){

	int n;
	cin >> n;

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

	ll ans = 0;
	
	for(int i = 0; i < n - 1; i++){
		ans += a[i] / 2;
		if(a[i] % 2 == 1 && a[i+1] > 0){
			a[i+1]--;
			ans++;
		}
	}
	ans += a[n-1] / 2;

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


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
int linersearch(int a[],int n,int key)
{
  int i = 0;
  a[n] = key;
  while(a[i] != key) i++;
  return i!=n;
}
int main ()
{
  int i,n,a[10001],q,key,sum = 0;
  scanf("%d",&n);
  for(i = 0;i<n;i++)
    scanf("%d",&a[i]);
  scanf("%d",&q);
  for(i = 0;i<q;i++)
  {  scanf("%d",&key);
      if(linersearch(a,n,key))
        sum++;
}
  printf("%d\n",sum);
return 0 ;
}



Measured memory_bytes: 3216
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, y, m, d, res, i;

    n = sc.nextInt();
    for(i = 0;i < n;i++){
      y = sc.nextInt(); m = sc.nextInt(); d = sc.nextInt();
      res = d;

      if(y % 3 == 0)res += (m - 1) * 20;
      else if(m % 2 == 1)res += (m - 1) / 2 * 39;
      else res += (m - 2) / 2 * 39 + 20;

      if(y % 3 == 1)res += (y - 1) / 3 * 590;
      else if(y % 3 == 2)res += (y - 2) / 3 * 590 + 195;
      else res += (y - 3) / 3 * 590 + 390;

      out.println(196471 - res);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 20476
# -*- coding: utf-8 -*-

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

a = 0
b = 0

for i in range(n):
    if i % 2 == 1:
        a = a + 1
    else:
        b = b +1

if a >= k or b >= k:
    print('YES')
else:
    print('NO')

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t, u;
    t = s.substr(0, n/2);
    u = s.substr(n/2);
    if (t==u) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

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

    if (s == "SUN") {
        cout << 7 << endl;
    }
    else if (s == "MON") {
        cout << 6 << endl;
    }
    else if (s == "TUE") {
        cout << 5 << endl;
    }
    else if (s == "WED") {
        cout << 4 << endl;
    }
    else if (s == "THU") {
        cout << 3 << endl;
    }
    else if (s == "FRI") {
        cout << 2 << endl;
    }
    else if (s == "SAT") {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <map>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

const int MOD = 1000*1000*1000+7;
int add(int a, int b) { return ((ll)a+b)%MOD; }
int mul(int a, int b) { return ((ll)a*b)%MOD; }

map<vector<char>, int> dp[42];

int main() {
  int N, X, Y, Z;
  while (cin >> N >> X >> Y >> Z) {
    for (int i : range(42)) dp[i].clear();
    int pw[50];
    pw[0] = 1;
    for (int i : range(1, 50)) pw[i] = mul(10, pw[i - 1]);

    int res = 0;
    dp[0][vector<char>(0)] = 1;
    for (int i : range(N)) {
      for (auto& pp : dp[i]) {
        /*
        cout << i << ", " << pp.second << " : ";
        for (int c : pp.first) cout << c << " ";
        cout << endl;
        */

        for (int j : range(1, 11)) {
          auto vc = pp.first;
          vc.insert(vc.begin(), 0);

          // normalize
          bool goal = 0;
          for (auto& c : vc) {
            if (c == -1) continue;

            bool invalid = 0;
            if (0 <= c && c < X && c + j > X) invalid = 1;
            else if (X <= c && c < X + Y && c + j > X + Y) invalid = 1;
            else if (X + Y <= c && c < X + Y + Z && c + j > X + Y + Z) invalid = 1;

            if (!invalid && c + j == X + Y + Z) {
              goal = 1;
            }

            if (invalid) c = -1;
            else c += j;
          }

          if (goal) {
            res = add(res, mul(pp.second, pw[N - 1 - i]));
            /*
          cout << "############ ";
        cout << i << " : ";
        for (int c : vc) cout << c << " ";
        cout << endl;
        cout<<res<<endl;
        */
            continue;
          }
          while (vc.size() && vc.back() == -1) vc.pop_back();


          dp[i + 1][vc] = add(dp[i + 1][vc], pp.second);
        }
      }
    }
    cout << res << endl;
  }
}


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

int main() {
  int N,K,x,y;
  cin >> N >> K;
  y = 0;
  
  for(int i = 0; i < N; i++){
    cin >> x;
    if(K - x > x)  y = y + 2 * x;
    if(K - x <= x) y = y + 2 * (K - x);
  }
  cout << y << endl; 
}

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

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

const int N = 2010;

int n, m, a[N][N];
char s[N][N];

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);

  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < m - 1; ++j) {
      int cnt = 0;
      cnt += s[i][j] == '#';
      cnt += s[i][j + 1] == '#';
      cnt += s[i + 1][j] == '#';
      cnt += s[i + 1][j + 1] == '#';
      a[i][j] = ~cnt & 1;
    }
  }

  int ans = max(n, m); 
  for(int i = 0; i < n - 1; ++i) {
    for(int j = 0; j < m - 1; ++j)
      if(a[i][j]) a[i][j] += a[i - 1][j]; 

    int mx = 0; 
    stack<int> st; 
    for(int j = 0; j < m; ++j) {
      while(st.size() && a[i][st.top()] >= a[i][j]) {
        int t = st.top();
        st.pop(); 
        mx = max(mx, (a[i][t] + 1) * (st.size() ? j - st.top() : j + 1)); 
      }
      st.push(j); 
    }

    ans = max(ans, mx); 
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 19840
(n, x) = list(map(int, input().split()))

num = 1
pate = 1
for i in range(n):
    num = num * 2 + 3
    pate = pate * 2 + 1

def culc(l, idx, num, pate):
    npate = (pate - 1) // 2
    nnum = (num - 3) // 2
    mid = (num + 1) // 2
    if l == 1:
        if idx == 0:
            return 0
        elif idx == 1:
            return 0
        elif idx == 2:
            return 1
        elif idx == 3:
            return 2
        elif idx == 4:
            return 3
        else:
            return 3
    elif mid == idx:
        return npate + 1
    elif mid < idx:
        return npate + 1 + culc(l - 1, idx - mid, nnum, npate)
    else:
        return culc(l - 1, idx - 1, nnum, npate)
print(culc(n, x, num, pate))


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

int main() {
    uint N;
    cin >> N;
    vector<double> X(N);
    vector<double> Y(N);
    double lx = 1000;
    double hx = 0;
    double ly = 1000;
    double hy = 0;

    for (uint i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
        lx = min(lx, X[i]);
        hx = max(hx, X[i]);
        ly = min(ly, Y[i]);
        hy = max(hy, Y[i]);
    }

    double curX = (hx + lx) / 2;
    double curY = (hy + ly) / 2;
    double nxtX = 0;
    double nxtY = 0;

    double alfa = 0.1;
    uint idx = 0;

    while (alfa > pow(10, -8)) {
        curX = nxtX;
        curY = nxtY;
        double maxD = 0;

        for (uint i = 0; i < N; i++) {
            double d = pow(X[i] - curX, 2) + pow(Y[i] - curY, 2);

            if (maxD < d) {
                maxD = d;
                idx = i;
            }
        }

        nxtX = (1 - alfa) * curX + alfa * X[idx];
        nxtY = (1 - alfa) * curY + alfa * Y[idx];
        alfa = alfa * 0.9999;
    }

    double ans = sqrt(pow(X[idx] - curX, 2) + pow(Y[idx] - curY, 2));
    printf("%.6f\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define EPS 1e-6
 
int main()
{
    fast;
    double r;
    cin>>r;
    cout<<fixed<<setprecision(20)<<(2*(M_PI)*r);
    
    return 0;
}

Measured memory_bytes: 3808
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define N 1000000
int main() {
	int i, j, cnt, *p, n;
	p = (int*)calloc(N, sizeof(int));
	for (i = 2; i <= (int)sqrt((double)N); ++i) if (!*(p + i)) for (j = 2; j*i < N; j++) *(p + i*j) = 1;
	while (1) {
		scanf("%d", &n);
		if (n == 0) break;
		cnt = 0;
		for (i = 2; i <= n / 2; i++) if (!*(p + i) && !*(p + n - i)) cnt++;
		printf("%d\n", cnt);
	}
	free(p);
	return 0;
}

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

int main() {
  string s; cin >>s;
  int posa, posz;
  
  for (int i=0; i<s.size(); i++){
    if (s.at(i) == 'A'){
      posa = i;
      break;
    }
  }
  for (int i=0; i<s.size(); i++){
    if (s.at(s.size()-1-i) == 'Z'){
      posz = s.size()-1-i;
      break;
    }
  }
  cout <<posz-posa+1 <<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>

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

using namespace std;
using ll = long long;

int main() {
    
    int ans, n;
    int sum = 0;
    vector<int> a;
    vector<int> tg;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        a.push_back(ai);
        sum += ai;
    }
    
    for (int i = 0; i < n; i++) {
        tg.push_back(abs(sum - a[i] * n));
    }
    
    ans = min_element(tg.begin(), tg.end()) - tg.begin();
    
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int n,m,i,j,k,h;
char x,s[54][54],s1[54][54];
bool ok,ok1;
int main()
{
    scanf ("%d %d", &n, &m);
    for (i=0;i<=(n-1);i++)
    {
        scanf ("%c", &x);
        for (j=0;j<=(n-1);j++)
            scanf ("%c", &s[i][j]);
    }
    for (i=0;i<=(m-1);i++)
    {
        scanf ("%c", &x);
        for (j=0;j<=(m-1);j++)
            scanf ("%c", &s1[i][j]);
    }
    ok1=false;
    for (i=0;(i<=(n-m)) && (ok1==false);i++)
        for (j=0;(j<=(n-m)) && (ok1==false);j++)
        {
            ok=true;
            for (k=0;(k<=(m-1)) && (ok==true);k++)
                for (h=0;h<=(m-1);h++)
                {
                    if (s[i+k][j+h]!=s1[k][h])
                    {
                        ok=false;
                        break;
                    }
                }
            if (ok==true)
                ok1=true;
        }
    if (ok1==true)
        printf ("Yes\n");
    else
        printf ("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc149/abc149_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll a, b, k;
  cin >> a >> b >> k;

  a -= k;
  if (a < 0) {
    b += a;
    a = 0;
  }
  if (b < 0) b = 0;

  cout << a << ' ' << b << endl;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for (auto &x : X) cin >> x;
  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }
  sort(X.begin(), X.end());
  vector<int> diff(M - 1);
  for (int i = 0; i < M - 1; i++) {
    diff[i] = X[i + 1] - X[i];
  }
  sort(diff.begin(), diff.end());
  long long ans = 0;
  for (int i = 0; i < M - N; i++) {
    ans += diff[i];
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 1024
#include<stdio.h>
int main() {
	int i,n;
	scanf("%d",&n);
	int a;
	int b[n];
	for( i=0;i<n;i++) {
		b[i]=0;
	}
	for( i=0;i<n-1;i++){
		scanf("%d",&a);
		b[a-1]=b[a-1]+1;
	}
	for( i=0;i<n;i++) {
		printf("%d\n",b[i]);
	}
}


Measured memory_bytes: 2504
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin >> S;
  
  int num = 0;
  for(int i=0; i<(S.size()/2); i++){
    if(S.at(i) != S.at(S.size()-1-i))
      num++;
  }
  cout << num << endl;
  
  return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ms(v, x) memset((v), (x), sizeof(v))
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define iopt ios::sync_with_stdio(false); cin.tie(0)

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a%b); }
int power(int x, int p, int MOD) {
    if(p == 0) return 1%MOD;
    if(p == 1) return x%MOD;
    int res = power(x, p/2, MOD);
    res = (long long)res*res%MOD;
    if(p&1) res = (long long)res*x%MOD;
    return res;
}

typedef pair<int, int> ii;
typedef long double LD;
typedef vector<int> vi;

int32_t main(){
  iopt;
  int n, m; cin >> n >> m;
  string s, t;
  cin >> s >> t;

  int ans = n*m/gcd(n, m);

  map<int, char> st;
  for(int i = 0; i < n; i++) {
    st[i * (ans/n)] = s[i];
  }

  for(int i = 0; i < m; i++) {
    int idx = i * (ans / m);
    if(st.count(idx) && st[idx] != t[i]) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6144
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { //GIMME AC
		Scanner input = new Scanner(System.in); 
		int N = input.nextInt();
		String x = input.next();
		int[][] pref = new int[N+1][10]; //How many 1,2,3...,9 occurrences up to index i
		boolean[] first = new boolean[10]; //Was first digit ever 0,1,2,3,..,9
		int ans = 0;
		//If so, DON'T recalculate
		for (int i = 0; i < N; i++) {
			for (int p = 0; p <= 9; p++) {
				pref[i+1][p]=pref[i][p]; //Need to store previous data
			}
			int digit = Integer.parseInt(x.substring(i,i+1));
			pref[i+1][digit]++;
		}
		for (int i = 0; i < N; i++) {
			int digit = Integer.parseInt(x.substring(i,i+1));
			if (!first[digit]) {
				first[digit]=true;
				boolean[] second = new boolean[10]; //Was second digit "          "
				for (int next = i+1; next < N; next++) {
					int d = Integer.parseInt(x.substring(next,next+1));
					if (!second[d]) {
						second[d]=true;
						for (int p = 0; p <= 9; p++) {
							if (pref[N][p]-pref[next+1][p]>0) { //Why next+1???
								ans++;
							} 
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}


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

bool isACGT(char c) {
    return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}

int main() {
    string S;
    cin >> S;

    bool acgt = false;
    int MAX = 0;
    int tmp = 0;

    for (int i = 0; i < S.size(); ++i) {
        if (isACGT(S.at(i))) {
            acgt = true;
            tmp++;
            MAX = max(tmp, MAX);
        } else {
            acgt = false;
            MAX = max(tmp, MAX);
            tmp = 0;
        }
    }
    cout << MAX << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 1000;

int main()
{
//	freopen("input.txt","r",stdin);
//	ios::sync_with_stdio(false); cin.tie(0);
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	if(abs(x-a)>abs(x-b)){
		printf("B\n");
	} 
	else printf("A\n");
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	for i := 0; i < 4; i++ {
		c := S[i]
		n := 0
		for j := 0; j < 4; j++ {
			if i == j {
				continue
			}
			if c == S[j] {
				n++
			}
		}
		if n != 1 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
	return
}


Measured memory_bytes: 512
# 整数の入力
import numpy as np

N = int(input())
S = input()


def check_condition(S):
    N = len(S)
    ind = np.where(S=="R")[0]
    if len(ind) == 0 or len(ind) == N:
        return True
    
    if np.max(ind) == len(ind) - 1:
        return True
    
    return False

def alter(S):
    if check_condition(S):
        return 0
    ind = np.where(S=="R")[0]
    num_r = len(ind)
    num_offset = np.sum(ind > num_r - 1)
    return num_offset

S = np.array(list(S))
print(alter(S))

Measured memory_bytes: 29448
#include <iostream>
#include <vector>
#include <string>
using namespace std;

long long A[87] = {0};

long long ryka(int n){
  long long result = 0;

  if(A[n] != 0){ return A[n]; }
  else if(n == 1) {return 1;}
    else if(n == 0) { return 2; }

  result = ryka(n-1) + ryka(n-2);
  A[n] = result;
  return result;
}

int main(){

  int n;
  cin >> n;
  cout << ryka(n) << endl;

  return 0;
}


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

int main() {
	int a[200];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int alice, bob;
	alice = bob = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1) {
			alice += a[n - i];
		}
		else {
			bob += a[n - i];
		}
	}
	cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int f[26];
int main(){
  string s;
  cin>>s;
  int n=s.size();
  uli ans=1;
  for(int i=0;i<n;i++){
    ans+=i-f[s[i]-'a'];
    f[s[i]-'a']++; 
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	char S[100];
  	char T[100];
  	
  	cin >> N >> S >> T;
  	
  	for(int i = 0 ; i < N; i++){
      cout << S[i] << T[i];
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
#define LEN 10000001
  
typedef struct pp{
    char name[100];
    int t;
}P;
  
P Q[LEN+1];
int head = 1, tail = 0, n, empty = 0;
  
void push(P x){
    empty++;
    Q[++tail] = x;
}
  
P pop(){
    P res;
    empty--;
    res = Q[head++];
    return res;
}
  
  
int main(){
    int time = 0, count = 0;
    int i, ms;
    P u;
    scanf("%d %d", &n, &ms);
  
    empty = n;
    tail = n;
  
    for ( i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
  
    while(empty != 0){
  
        u = pop();
        if(u.t <= ms) {
            time += u.t;
            printf("%s %d\n", u.name, time);
        }
  
        else if(u.t > ms){
            time += ms;
            u.t -= ms;
            push(u);
        }
        else if(u.t == 0) continue;
    }
  
  
    return 0;
}

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

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

  // https://atcoder.jp/contests/abc179/editorial/99
  int counter = 0;
  for (int A = 1; A <= N - 1; A++) {
    counter += (N - 1) / A;
  }
  cout << counter << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 1000
ll n,m;
int main()
{
	scanf("%d %d",&n,&m);
	if (n>m) swap(n,m);
	if (n==1&&m==1) printf("1\n");
	else if (n==1) 
	{
		printf("%lld\n",m-2);
	}
	else printf("%lld\n",(n-2)*(m-2));
	return 0;
}

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

#define MAX_SIG 100
#define MAX_OPE 1000000

using namespace std;

int main(){

	int i = 0;
	int j;
	int stac[MAX_SIG];
	char sign[MAX_OPE];

	while (1){

		if (scanf("%s", sign) == EOF){
			break;
		}

		if (sign[0] == '\n'){
			break;
		}

		if (*sign == '+'){
			i--;
			i--;
			stac[i] += stac[i + 1];
			i++;
		}
		else if (*sign == '-'){
			i--;
			i--;
			stac[i] -= stac[i + 1];
			i++;
		}
		else if (*sign == '*'){
			i--;
			i--;
			stac[i] *= stac[i + 1];
			i++;
		}
		else {
			stac[i] = atoi(sign);
			i++;
		}
	}

	cout << stac[0] << endl;

	return 0;

}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<string> word(N);
    for (int i = 0; i < N; ++i){
        cin >> word.at(i);
    }
    
    map <string,int> memo;
    for ( int i = 0; i < N; ++i ){
        /* 文字がある場合は count を 1 増やす */
        /* ない場合は作り、count を 1 にする */
        if ( memo.count(word.at(i)) ) {
            memo.at(word.at(i)) += 1;
        } else {
            memo[word.at(i)] = 1;
        }
    }
    
    int max_val = -1;
    /* この方法では、辞書順に処理される */
    for ( pair<string,int> x: memo){
        string key = x.first;
        int val = x.second;
        if ( val > max_val){
            max_val = val;
        }
    }
    for ( pair<string,int> x: memo){
        string key = x.first;
        int val = x.second;
        if ( val == max_val ){
            cout << key << endl;
        }
    }
    
    return 0;
}


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

using namespace std;
using ll = long long;

ll mod = 1000000007;

int main() {
  ll n, k;
  cin >> n >> k;

  vector<ll> as(n);
  for (auto &v : as)
    cin >> v;

  ll ans = 0;
  for (ll i = 0; i < n; ++i)
    for (ll j = i + 1; j < n; ++j) {
      ans = (ans + (as[i] > as[j])) % mod;
    }
  ans = ans * k % mod;

  ll m = 0;
  for (ll i = 0; i < n; ++i)
    for (ll j = 0; j < n; ++j)
      m = (m + (as[i] > as[j])) % mod;

  ll g = k * (k - 1) / 2 % mod;
  ans = (ans + m * g % mod) % mod;

  cout << ans << endl;

}


Measured memory_bytes: 3656
package main

import (
	"fmt"
	"math"
)

var ans int

func max(seq []int) int {
	res := math.MinInt64
	for _, v := range seq {
		if v > res {
			res = v
		}
	}
	return res
}

func min(seq []int) int {
	res := math.MaxInt64
	for _, v := range seq {
		if v < res {
			res = v
		}
	}
	return res
}

func fn(h, w int) {
	for i := 1; i < h; i++ {
		a := i * w
		b := (h - i) * (w / 2)
		c := h*w - a - b

		tmp := max([]int{a, b, c}) - min([]int{a, b, c})
		if ans > tmp {
			ans = tmp
		}
	}
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	if h%3 == 0 || w%3 == 0 {
		fmt.Println(0)
		return
	}
	ans = h
	if w < h {
		ans = w
	}
	fn(h, w)
	fn(w, h)
	fmt.Println(ans)
}


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

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b, x;
  cin >> a >> b >> x;
  int max_v = a * a * b;
  double theta;
  if (x == max_v) {
    theta = 0.0;
  } else if (x >= max_v / 2) {
    double bi = (double)(2.0 * (max_v - x)) / (a * a);
    theta = atan(a / bi);
  } else if (x > 0) {
    double ai = (double)(2.0 * x) / (a * b);
    theta = atan(ai / b);
  } else {
    theta = M_PI / 2.0;
  }
  printf("%.10f\n", 90.0 - (theta * 180 / M_PI));
}

void answer2() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b, x;
  cin >> a >> b >> x;
  int max_v = a * a * b;
  double theta;
  if (x >= max_v / 2) {
    double bi = (double)(2.0 * (max_v - x)) / (a * a);
    theta = atan(bi / a);
  } else if (x > 0) {
    double ai = (double)(2.0 * x) / (a * b);
    theta = atan(b / ai);
  }
  printf("%.10f\n", theta * 180 / M_PI);
}

int main() {
  //answer1();
  answer2();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// // hash struct for unordered_map
// struct hash_pair { 
//     template <class T1, class T2> 
//     size_t operator()(const pair<T1, T2>& p) const
//     { 
//         auto hash1 = hash<T1>{}(p.first); 
//         auto hash2 = hash<T2>{}(p.second); 
//         return hash1 ^ hash2; 
//     } 
// };

// int MAXNUM = 5e3+5;
// vector <int>vis(MAXNUM);
// vector<int> pr;
// void sieve() {
// 	pr.push_back(2);
// 	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
// 		pr.push_back(i);
// 		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
// 	}
// }
// //************************************************************************

void solve()
{
    int x; 
    cin >> x;
    x-=400;
    cout << 8-(x/200) << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int d[110];

int main()
{
	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++)
		scanf("%d", &(d[i]));
		
	long long sum = 0;
	for (int i = 0 ; i < n ; i++)
		for (int j = i + 1 ; j < n ; j++)
			sum = sum + d[i] * d[j];
	
	
	printf("%I64d\n", sum);
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	map<string,int> mp;
	int hoge=0;
	REP(i,n){
		string s;
		cin>>s;
		hoge=max(hoge,++mp[s]);
	}
	
	set<string> st;
	for(auto elem:mp){
		if(elem.second==hoge){
			st.insert(elem.first);
		}
	}
	
	for(auto elem:st){
		cout<<elem<<endl;
	}
}

Measured memory_bytes: 34560
#include<bits/stdc++.h>
int a[100000];
using namespace std;
int main()
{
	int n,ba=0,ma=0;
	cin>>n;
	cin>>a[0];
	for(int t=1;t<n;t++)
	{
		cin>>a[t];
		if(a[t]<=a[t-1])
		{
			ba++;
		}
		else
		{
			ma=max(ma,ba);
			ba=0;
		}
	}
	ma=max(ma,ba);
	cout<<ma;
	return 0;
} 

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    char num[3][3];
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> num[i][j];
        }
    }
    for(int i = 0; i < 3; ++i){
        cout << num[i][i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 200002
mt19937 myrand(time(0));

ll n, k;
ll a[mx];

ll check(ll x) {
	ll ret = 0;
	for (int i = 0; i < n; i++) {
		ret += (a[i] + x - 1) / x;
		ret--;
	}
	return ret;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin >> n >> k;
	ll lo = 1, hi = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		hi = max(hi, a[i]);
	}
	ll ans = -1;
	while (lo <= hi) {
		ll mid = (lo + hi) / 2;
		debug() << imie(mid)imie(check(mid));
		if (check(mid) <= k) {
			ans = mid;
			hi = mid - 1;
		}
		else lo = mid + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5132
#include "bits/stdc++.h"
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cout << ", "; cetak(v...);}
 
#define debug(x...) cout << '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())


const int MOD = 1e9 + 7;

int add(int x, int y){
    int ret = x + y;
    if(ret >= MOD) ret -= MOD;
    return ret;
}
int sub(int x, int y){
    int ret = x - y;
    if(ret < 0) ret += MOD;
    return ret;
}
int mul(int x, int y){
    return (long long)x * y % MOD;
}


const int mx = 1e5 + 10;

void solve(){
    int n, k, s;
    cin >> n >> k >> s;
    vector<int> ans(n);
    for(int i = 0; i < k; i++) ans[i] = s;
    for(int i = k; i < n; i++){
        int apa = 1e9;
        if(s == apa) apa = 1e9 - 1;
        ans[i] = apa;
    }
    for(int i = 0; i < n; i++){
        if(i > 0) cout << ' ';
        cout << ans[i];
    }
    cout << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


int main(int argc, char** argv) {
    int n;
    std::vector<int> rgb(3);
    cin >> rgb[0] >> rgb[1] >> rgb[2] >> n;
    int ans{0};
    std::sort(rgb.begin(), rgb.end(), std::greater<int>());

    for (int i = 0; i <= n; i+=rgb[0]) {
        for (int j = 0; (j+i) <= n; j+=rgb[1]) {
            if (((j+i) - n) % rgb[2] == 0) {
                ++ans;
            }
        }
    }

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

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    vi d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    sort(all(d));
    cout << d[n/2] - d[n/2-1];
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define INF (1LL << 31)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "

int main()
{
    ll n, m; cin >> n >> m;
    vector<P> ab(m);
    rep(i, m) cin >> ab[i].second >> ab[i].first;

    sort(ab.begin(), ab.end());
    ll ra = 0;
    ll cnt = 0;

    rep(i, m) {
        if (ra <= ab[i].second){
            ++cnt;
            ra = ab[i].first;
        }
    };
    // rep(i, n) cout << arm[i].first << " " << arm[i].second << endl;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
using namespace std;

const ll inf = 1e17;
const ll N = 1e6+10;
const ll bits = 62;
const ll mod = 1e9+7;

int main(){

   ll n,k,q;
   cin>>n>>k>>q;

   vector<ll>arr(n+1,k),ans(n+1,0);

   ll temp;

   for(ll i=1;i<=q;i++){
      cin>>temp;
      ans[temp]++;
   }

   for(ll i=1;i<=n;i++){
      if(arr[i] - (q-ans[i]) > 0){
         cout<<"Yes\n";
      }else{
         cout<<"No\n";
      }
   }



   
   
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

ll mod = 1000000007;
ll ans = 1;
ll k;

void dfs(vvi &g, vi &p, vi &ccnt, vi &visited, ll v)
{
    if (visited[v] == 1)
    {
        return;
    }
    visited[v] = 1;

    if (ans < 0)
    {
        ans = 0;
        return;
    }

    if (p[v] == -1)
    {
        ans *= k;
    }
    else if (p[p[v]] == -1)
    {
        ans *= k - ccnt[p[v]] - 1;
    }
    else
    {
        ans *= k - ccnt[p[v]] - 2;
    }
    ans %= mod;

    for (ll u : g[v])
    {
        if (u == p[v])
        {
            continue;
        }
        p[u] = v;
        dfs(g, p, ccnt, visited, u);
        ccnt[v]++;
    }
}

int main()
{
    int n;
    cin >> n >> k;
    vvi g(n);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vi p(n, 0);
    vi ccnt(n, 0);
    vi visited(n, 0);
    p[0] = -1;
    dfs(g, p, ccnt, visited, 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12800
<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",fgets(STDIN)));
	}
}

/*		START		*/
$X = getq();
$ans_b=array();
if($X<=3){echo "1\n";exit;}
for ($i=$X; $i >= 1; $i--) {
	for ($j=$X; $j >=2 ; $j--) {
		$temp=pow($i,$j);
		if($temp<=$X){
			array_push($ans_b,$temp);
		}
	}
}
echo max($ans_b)."\n";
?>

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

using namespace std;

typedef unsigned long long ll;

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

	ll dp[100][21] = {0}; // dp[?¬?????????????][?¨??????????] = ??´????????°
	dp[1][v[0]] = 1;

	for (int i = 1; i < n-1; ++i) {
		for (int j = 0; j <= 20; ++j) {
			if (j+v[i] <= 20) dp[i+1][j+v[i]] += dp[i][j]; // +
			if (j-v[i] >= 0) dp[i+1][j-v[i]] += dp[i][j]; // -
		}
	}

	cout << dp[n-1][v[n-1]] << endl;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    string s;
    cin >> s;
    if (s[s.length() - 1] == 's') {
        s = s+"es";
    }else {
        s = s+ "s";
    }
    cout << s << endl;
    return 0;
}



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

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

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
template <int NMAX>
class UnionFind {
private:
  int par[NMAX];  // 親
  int rank[NMAX]; // 木の深さ

public:
  ll N;      // number of nodes
  vll sizes; // node iが親であるgroupの要素数

  // n is the number of nodes
  void init(int n) {
    N = n;
    sizes.resize(N, 1);

    for (int i=0; i<n; i++) {
	par[i] = i;
	rank[i] = 0;
    }
  }

  void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x==y) return;

      if (rank[x] < rank[y]) {
  	par[x] = y;
	sizes[y] = sizes[x] + sizes[y]; // xは放置
      } else {
  	par[y] = x;
  	if (rank[x] == rank[y]) rank[x]++;
	sizes[x] = sizes[x] + sizes[y]; // yは放置
      }
  }

  int find(int x) {
      if (par[x] == x) {
  	return x;
      } else {
  	return par[x] = find(par[x]);
      }
  }

  bool same(int x, int y) {
      return find(x) == find(y);
  }
};

constexpr int N_MAX = 1e5;
int N, M;

UnionFind<N_MAX> uf;

int main(int argc, char** argv) {
  cin >> N >> M;
  uf.init(N);

  for (int i=0; i<M; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--; // 0-indexed
    uf.unite(x, y);
  }

  si ret;
  for (int i=0; i<N; i++) {
    ret.insert(uf.find(i));
  }

  cout << ret.size() << endl;

  return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll A[100005];

int main()
{
    ll N,M,ans=0,i,l,r;
    cin>>N>>M;
    for(i=1;i<=M;i++)
    {
      cin>>l>>r;
      A[l]++;
      A[r+1]--;
    }
    for(i=1;i<=N;i++)
    {
      A[i] = A[i] + A[i-1];
      if(A[i]==M)
      ans++;
    }
    cout<<ans<<endl;
    return 0;
}
 

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << (a+b)%24;
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b;
  cin>>a>>b;
  cout<<(a-1)*(b-1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n ;
    vl v;
    cin >> n ;
    forn(i ,1 , n ){
       ll x;
       cin >> x;
       v.pb(x);
    }
    ll ziz = acc(v) % n  ;
    ll foo ;
    if(ziz == 0){
        foo = acc(v)/n ;
    }
    else {
        foo = acc(v)/n ;
        ++foo ;
    }
    ll res = 0 ;
    forn(i , 0 , n-1){
       res = res + (foo-v[i])*(foo-v[i]);
    }
    ll res1 = 0 ;
    if(ziz== 0) {
        cout << res << el ;
        ro ;
    }
    else {
        --foo;
        forn(i , 0 , n-1){
           res1 = res1 + (foo-v[i])*(foo-v[i]);
        }
    }
    res = min(res , res1) ;
    cout << res << el ;
 }































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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
  for (int i = 0; i < N; i ++) {
    for (int j = N - 1; j >= i + 1; j --) {
      if (A[j].value < A[j - 1].value) {
        Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  for (int i = 0; i < N; i ++) {
    int minj = i;
    for (int j = i; j < N; j ++) {
      if (A[j].value < A[minj].value) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N) {
  for (int i = 0; i < N; i ++) {
    if (i) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
  for (int i = 0; i < N; i ++) {
    if (C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main() {
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for (int i = 0; i < N; i ++) {
    cin >> C1[i].suit >> C1[i].value;
  }

  for (int i = 0; i < N; i ++) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if (isStable(C1, C2, N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
}



Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	int s1=a.size();
	if(s1!=b.size())
	{
		cout<<"NO"<<endl;
		return 0;
	}
	for(int i=0,j=s1-1;i<=s1/2+1;i++,j--)
		if(a[i]!=b[j])
		{
	    	cout<<"NO"<<endl;
	    	return 0;
    	}
    cout<<"YES"<<endl;
	return 0;
}

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

using namespace std;

int main(){
	
	while(1){
		
		int n;
		cin >> n;
		
		if(n==0) break;
		
		bool lu=false,ru=false,u=false;
		int cnt=0;
		
		for(int i=0;i<n;i++){
			string d;
			cin  >> d;
			if(d=="lu") lu=true;
			else if(d=="ld") lu=false;
			else if(d=="ru") ru=true;
			else ru=false;
			
			if(ru==true&&lu==true&&u==false){
				u=true;
				cnt++;
			}else if(ru==false&&lu==false&&u==true){
				u=false;
				cnt++;
			}
		}
		cout << cnt << endl;
	}	
	
	return 0;
}


Measured memory_bytes: 3128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)
			throws IOException {
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));
		String[] input = null;
		Cheese c = null;
		Gate g = null;
		while (true) {
			input = br.readLine().split(" ");
			int height = Integer.parseInt(input[1]);
			int width = Integer.parseInt(input[0]);
			int depth = Integer.parseInt(input[2]);
			if(height + width + depth == 0)	break;
			c = new Cheese(width, height, depth);
			int numGate = Integer.parseInt(br.readLine());
			for (int i = 0; i < numGate; i++) {
				g = new Gate(
						Integer.parseInt(br.readLine()));
				System.out.println((c.isSmaller(g)) ? "OK"
						: "NA");
			}
		}
	}
}

class Cheese {
	int width;
	int height;
	int depth;
	double lengthWH;
	double lengthHD;
	double lengthWD;

	public Cheese(int width, int height, int depth) {
		this.width = width;
		this.height = height;
		this.depth = depth;
		this.lengthWH = Math.sqrt(this.width * this.width
				+ this.height * this.height);
		this.lengthHD = Math.sqrt(this.height * this.height
				+ this.depth * this.depth);
		this.lengthWD = Math.sqrt(this.width * this.width
				+ this.depth * this.depth);
	}

	public boolean isSmaller(Gate gate) {
		int gateDiameter = gate.getDiameter();
		return ((this.lengthHD < gateDiameter)
				|| (this.lengthWD < gateDiameter) || (this.lengthWH < gateDiameter));
	}
}

class Gate {
	int r;

	public Gate(int r) {
		this.r = r;
	}

	public int getDiameter() {
		return this.r * 2;
	}
}

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

using namespace std;

typedef long long ll;

const ll M=1e9+7;
typedef vector<ll> Vec;
typedef vector<Vec> Mat;

int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        Mat S(n+1,Vec(k+1));
        S[0][0]=1;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=k;j++)
            {
                S[i][j]=S[i-1][j]*j%M+S[i-1][j-1];
                S[i][j]%=M;
            }
        }
        cout<<S[n][k]<<endl;
    }

    return 0;
}




Measured memory_bytes: 10808
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        int ca[15]={0};
        int ii;
        double zen=0,you=0;
        for(int i=1;i<=10;i++)ca[i]=1;
        ca[a]=0;ca[b]=0;ca[c]=0;
        ii=20-a-b;
        for(int i=1;i<=10;i++)if(ca[i]==1)zen++;
        for(int i=1;i<=ii;i++)if(ca[i]==1)you++;
        if(zen/2<=you)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        //cout<<zen<<you<<endl;
    }
    return 0;
}

Measured memory_bytes: 1148