akhauriyash/Code-Regression huggingface dataset:
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq


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

H, W = list(map(int, input().split()))
S = []
for i in range(H):
	S.append(list(input()))
for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			S[i][j] = 0
		else:
			S[i][j] = 1

judge = [[0]*W for i in range(H)]
dxy = [[0,1],[1,0],[-1,0],[0,-1]]

total = 0
for i in range(H):
	for j in range(W):
		if judge[i][j] == 0:
			black = 0
			white = 0
			que = deque()
			que.append([i, j])
			judge[i][j] = 1
			black += S[i][j] ^ 1
			white += S[i][j]
			#print(i, j,black, white)
			while len(que) > 0:
				loc = que.popleft()
				for n in range(4):
					loc_new = [loc[0] + dxy[n][0], loc[1] + dxy[n][1]]
					if loc_new[0] >= 0 and loc_new[0] < H and loc_new[1] >= 0 and loc_new[1] < W:
						if judge[loc_new[0]][loc_new[1]] == 0 and S[loc[0]][loc[1]] ^ S[loc_new[0]][loc_new[1]] == 1:
							judge[loc_new[0]][loc_new[1]] = 1
							black += S[loc_new[0]][loc_new[1]] ^ 1
							white += S[loc_new[0]][loc_new[1]]
							que.append(loc_new)
			total += black * white
			#print(total)

print(total)

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

int main(){
    int S,W;

    //N K入力
    int i;

    while(scanf("%d %d",&S,&W)<2);
    int flag;
    //計算処理
    //最終出力 

    if(S>W){
        printf("safe");
    }else{
        printf("unsafe");
        }


    return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;

		for(int i = 1; i <= N; i++) {
			for(int j = 1; j <= N; j++) {
				for(int k = 1; k <= N; k++) {
					sum = sum + GcdMethod(i, j, k);
				}
			}
		}

		System.out.println(sum);
	}

	public static int GcdMethod(int i, int j, int k) {
		int gcdNum = 1;
		int ans = gcd(k, j);
		gcdNum = gcd(ans, i);
		return gcdNum;
	}

	public static int gcd(int x, int y) {
		return y>0?gcd(y,x%y):x;
	}
}


Measured memory_bytes: 35716
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
        int b = sc.nextInt();
        String line = sc.next();
        String[] s = line.split("");
        for(int i=0; i<num; i++){
          if(i == b-1) System.out.print(s[i].toLowerCase());
          else System.out.print(s[i]);
        }
	}
}


Measured memory_bytes: 21712
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;



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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int res = 0;
    for (int a = 0; a <= A; ++a) {
        for (int b = 0; b <= B; ++b) {
            for (int c = 0; c <= C; ++c) {
                int total = 500 * a + 100 * b + 50 * c; // 合計金額
                if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
            }
        }
    }
    cout << res << endl;
}

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

int main(void){
  char s[10005];
  scanf("%s",s);
  int n = strlen(s);
  if(s[n-1] == 's'){
    s[n] = 'e';
    s[n+1] = 's';
    s[n+2] = '\0';
  }else{
   s[n] = 's';
   s[n+1] = '\0';
  }
  printf("%s",s);
  return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
     
int main()
{
  int n;
  cin >> n;
  int t = n;
  int count=0;
  while(t!=0)
  {
    count++;
    t=t/10;
  }
  int ans =0;
  for(int i=1;i<=count;i++)
  { 
    
    if(i%2 != 0)
    {
      if(i == count)
        ans += n-pow(10,(i-1)) +1;
      else if(i==1)
        ans += 9;
      else
      {
        ans +=(pow(10,i)-1) - pow(10,(i-1)) +1; 
      }
    }
  //cout << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    VI a(n); VIin(a);
    rep(i,n) a[i] -= i+1;
    SORT(a);

    int ans = 0,res;
    if(n%2 == 1) res = a[n/2];
    else res = (a[n/2]+a[n/2-1])/2;
    rep(i,n) ans += abs(res - a[i]);
    ANS;

    return 0;
}



Measured memory_bytes: 1792
N = int(input())
*A, = map(int,input().split())

mod = 10**9+7

ans = 3
if A[0]!=0: ans = 0
dp = [1,0,0]
for a in A[1:]:
    ans *= dp.count(a)
    ans %= mod
    if ans == 0: break
    dp[dp.index(a)] += 1
print(ans)

Measured memory_bytes: 56108
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;
int main() {
	string a;
	int num[7];
	int swap;
	for(int i = 1;i < 7;i++){
		cin >> num[i];
	}
	cin >> a;
	for(int i = 0;i < a.size();i++){
		swap = num[1];
		if(a[i] == 'N'){
			num[1] = num[2];
			num[2] = num[6];
			num[6] = num[5];
			num[5] = swap;
		}
		else if(a[i] == 'S'){
			num[1] = num[5];
			num[5] = num[6];
			num[6] = num[2];
			num[2] = swap;
		}
		else if(a[i] == 'E'){
			num[1] = num[4];
			num[4] = num[6];
			num[6] = num[3];
			num[3] = swap;
		}
		else if(a[i] == 'W'){
			num[1] = num[3];
			num[3] = num[6];
			num[6] = num[4];
			num[4] = swap;
		}
	}
	cout << num[1] << endl;
}

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

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

    int x, a, b;
    cin >> x >> a >> b;
    if (abs(a - x) > abs(b - x))
    {
        cout << "B" << endl;
    }
    else 
    {
        cout << "A" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define all(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main() {
  int s; cin >> s;
  int a = s/100;
  int b = s%100;
  if((1<=a && a<=12) && (b==0 || b>=13)) cout << "MMYY" << endl;
  else if((1<=b && b<=12) && (a==0 || a>=13)) cout << "YYMM" << endl;
  else if((a==0 || a>=13) && (b==0 || b>=13)) cout << "NA" << endl;
  else cout << "AMBIGUOUS" << endl;



}


Measured memory_bytes: 256
n = gets.to_i
a = ""
cnt = 0
#for i in 0...n do
#  a += gets.to_i + " "
#end

a = gets.split(" ").map!{|i| i.to_i}

#p a

loop do
  isBreak = false
  for i in 0...n do
    if not a[i] % 2 == 0
      isBreak = true
      break
    end
    a[i] = a[i] / 2
  end
  if isBreak == true
    break
  end
  cnt += 1
end

puts cnt


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);


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

  int n;
  cin >> n;
  map<ll, int> mp;
  rep(i, n) {
    ll a; cin >> a;
    mp[a]++;
  }

  vector<ll> e;

  for (auto itr = mp.rbegin(); itr != mp.rend(); itr++) {
    if (itr->second >= 2) e.push_back(itr->first);
    if (e.size() >= 2) break;
    if (itr->second >= 4) e.push_back(itr->first);
    if (e.size() >= 2) break;
  }

  if (e.size() < 2) cout << 0 << endl;
  else cout << e[0] * e[1] << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <random>
#include <map>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)
#define YN(f) f?cout<<"YES"<<endl:cout<<"NO"<<endl;
#define yn(f) f?cout<<"Yes"<<endl:cout<<"No"<<endl;

int n,m;
int a[1500];
int b[1500];
int index_a;
int index_b;
const int mod=1e9+7;
int ans=1;

signed main(){
	cin>>n>>m;rep(i,n)cin>>a[i];rep(i,m)cin>>b[i];sort(a,a+n);sort(b,b+m);reverse(a,a+n);reverse(b,b+m);
	for(int i=n*m;i>=1;i--){
		bool A=false;
		bool B=false;
		if(a[index_a]==i)A=true;
		if(b[index_b]==i)B=true;
		if(A&&B){
			index_a++;
			index_b++;
		}
		else if(A&&(!B)){
			index_a++;
			ans=(ans*index_b)%mod;
		}
		else if(B&&(!A)){
			index_b++;
			ans=(ans*index_a)%mod;
		}
		else{
			if(index_a*index_b-n*m+i<=0){
				cout<<0<<endl;
				return 0;
			}
			ans=(ans*(index_a*index_b-n*m+i))%mod;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
 
int main (){
	int N, max, min, index_max = 0, index_min = 0;
	int a[50];
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", &a[i]);
	
	max = a[0];
	min = a[0];
	for (int i = 1; i < N; i++) {
		if (max <= a[i]) {
			index_max = i;
			max = a[i];
		}
		if (min >= a[i]) {
			index_min = i;
			min = a[i];
		}
	}
	if (max < 0) {
		printf("%d\n", N - 1);
		for (int i = N; i >= 2; i--)
			printf("%d %d\n", i, i - 1);
	} else if (min >= 0) {
		printf("%d\n", N - 1);
		for (int i = 1; i < N; i++)
			printf("%d %d\n", i, i + 1);
	} else if (abs(min) >= max) {
		printf("%d\n", 2 * N - 1);
		for (int i = 1; i <= N; i++)
			printf("%d %d\n", index_min + 1, i);
		for (int i = N; i >= 2; i--)
			printf("%d %d\n", i, i - 1);
	} else {
		printf("%d\n", 2 * N - 1);
		for (int i = 1; i <= N; i++)
			printf("%d %d\n", index_max + 1, i);
		for (int i = 1; i < N; i++)
			printf("%d %d\n", i, i + 1);
	}
	return 0;
}

Measured memory_bytes: 128
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val a = intList().sorted()
    val max = a.last()
    val flags = Array(max + 1) { true }
    val proceed = hashMapOf<Int, Boolean>()
    a.forEach { i ->
        var v = if (proceed[i] == true) {
            i
        } else {
            i + i
        }
        proceed[i] = true
        while (v <= max) {
            flags[v] = false
            v += i
        }
    }
    println(a.count { flags[it] }.toString())
}

Measured memory_bytes: 82776
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
int mh(pii p1, pii p2) { return abs(p1.first - p2.first) + abs(p1.second - p2.second); }
/* main */
int main(){
    int N, M;
    cin >> N >> M;
    vector<pii> student(N), checkPoint(M);
    int x, y;
    for (int i = 0; i < N; i++) { cin >> x >> y; student[i] = pii(x, y); }
    for (int i = 0; i < M; i++) { cin >> x >> y; checkPoint[i] = pii(x, y); }

    for (int i = 0; i < N; i++) {
        int p = 0;
        int mi = INF;
        for (int j = 0; j < M; j++) {
            int d = mh(student[i], checkPoint[j]);
            if (d < mi) {
                mi = d;
                p = j;
            }
        }
        cout << p + 1 << '\n';
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, x;
    cin >> n >> x;
    int min_m = 10000;
    for (int i = 0; i < n; i++)
    {
        int m;
        cin >> m;
        min_m = min(min_m, m);
        x -= m;
    }
    int ans = n;
    ans += x / min_m;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,k,i,c=0,d;
  cin>>a>>b;
  if(a>=2) c+=(a*(a-1))/2;
  if(b>=2) c+=(b*(b-1))/2;
  cout<<c<<endl;

}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc020.contest.atcoder.jp/tasks/agc020_b>
問題文============================================================
 スケートリンクで、一人の大人の司会と N 人の子供がゲームを行います。
 ゲームは K ラウンドからなり、ラウンド i では司会が次のように言います。
 
 Ai 人組を作って！
 
 すると、まだ脱落していない子供たちは Ai 人からなるグループをできるだけ多く組みます。
 一人につき一つのグループにしか入れません。
 グループに入れなかった子供たちは脱落し、その他は次のラウンドに進みます。 ラウンドで誰も脱落しないこともありえます。
 
 最後まで、つまりラウンド K のあとまで残ったのは 2 人で、彼らが勝者となりました。
 
 あなたは A1, A2, ..., AK の値を聞き、N の値は知りませんが、推定してみたくなりました。
 
 ゲームの開始前にいた子供たちの人数として考えられる最小の値と、最大の値を求めてください。
 もしくは、考えられる N の値は存在しないと判定してください。
 

=================================================================

解説=============================================================

================================================================
*/
void solve(){
    ll K; cin >> K;
    vector<ll> A(K);
    for(auto &in:A) cin >> in;
    if(A[K-1] != 2){ cout << -1 << endl; return; }
    ll l = 2, r = 2;
    for(ll i = K - 1; i >= 0; i--){
        if(l/A[i] == r/A[i]){
            if(l % A[i] != 0){
                cout << -1 << endl; return;
            }
        }
        ll t = (l + A[i] - 1)/A[i] * A[i];
        if(t > r){
            cout << -1 << endl; return;
        }
        l = t;
        r = (r/A[i] + 1)*A[i] - 1;
    }
    cout << l << " " << r << endl;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


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

int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for(long long i=0LL; i<n; i++){
    cin >> a.at(i);
  }
  
  long long p =1LL;
  long long ifz=0LL;
  for(long long i=0LL; i<n; i++){
    if(a.at(i) == 0LL){
      ifz++;
    }
  }
  
  if(ifz > 0LL){
    p = 0LL;
  }
  
  else if (ifz == 0LL){
  for(long long i=0LL; i<n; i++){
    if(a[i] > 1000000000000000000LL/p){
      p = -1;
      break;
    }
    p *= a[i];
  }
  }
  
  cout << p << endl;
	return 0;
}


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

int main(){

    int x, y, i=1;

    while(1){
        cin >> x >> y;
        if(x==0 && y==0)
            break;
        if(x<=y){
            cout << x << " " << y <<"\n";
            i += 1;
        }
        else{
            cout << y << " " << x <<"\n";
            i += 1;
        }
    }

    return 0;
}


Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<utility>
#include<string>
using namespace std;
int main() {
	queue<pair<string, int> > Q;
	int n, p,time;
	string name;
	cin >> n >> p;
	for (int i = 0; i < n; i++) {
		cin >> name >> time;
		Q.push(make_pair(name, time));
	}
	pair<string, int> t;
	int elaps = 0, a;
	while (!Q.empty()) {
		t = Q.front();
		Q.pop();
		a = min(t.second, p);
		elaps += a;
		t.second -= p;
		if (t.second > 0) {
			Q.push(t);
		}
		else {
			cout << t.first << ' ' << elaps << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6216
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int N;
    cin>>N;
    ll dp[N+2][N+2];
    rep(i,N+2)rep(j,N+2)dp[i][j]=0;
    dp[0][0]=1;
    for(int i=1;i<=N;i++){
        char c;cin>>c;
        rep(j,N+1){
            if(c=='-'){
                dp[i][j]+=dp[i-1][j];
            }else if(c=='D'){
                dp[i][j]+=j*dp[i-1][j];
                dp[i][j]%=MOD;
                dp[i][j]+=(j+1LL)*(j+1)%MOD*dp[i-1][j+1];
                dp[i][j]%=MOD;
            }else{
                if(j>0)
                    dp[i][j]+=dp[i-1][j-1];
                dp[i][j]+=j*dp[i-1][j];
                dp[i][j]%=MOD;
            }
        }
    }
    cout<<dp[N][0]<<endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;

ll factorial(ll N){
    ll ans = 1;
    for(int i = 1; i <= N; i++){
        ans =  (ans * i) % MOD;
    }
    return ans;
}

int main() {
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    if(abs(N - M) > 1){
        cout << 0 << endl;
        return 0;
    }

    if(N == M){
        ans = factorial(N) * factorial(M) * 2 % MOD;
    }else{
        ans = factorial(N) * factorial(M) % MOD;
    }

    cout << ans << endl;

}


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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main() {
	int n, k;
	int ans = 1;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		ans = min(ans*2, ans+k);
	}
	cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    vector<vector<int>> ans(H, vector<int>(W));
    rep(y, H) {
        rep(x, W) {
            bool one = false;
            if (A <= x) one = !one;
            if (B <= y) one = !one;
            ans[y][x] = one;
        }
    }

    rep(y, H) {
        rep(x, W) {
            cout << ans[y][x];
        }
        cout << endl;
    }
}


Measured memory_bytes: 5120
package main
import (
  "fmt"
  "strconv"
)
func main() {
  var n,m,t int
  fmt.Scan(&n)
  m = 100000000
  for a:=1;a<=n/2;a++ {
    b := n-a
    t = f(a)+f(b)
    if m > t { m = t }
  }
  fmt.Println(m)
}
func f(x int) int {
  var s string
  var m,t int
  s = strconv.Itoa(x)
  m = 0
  for i:=0;i<len(s);i++ {
    t,_ = strconv.Atoi(s[i:i+1])
    m += t
  }
  return m
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>

using namespace std;

#define ll long long
#define _ABS(x) (((x) < 0) ? (-(x)):(x))

const int mod = 1000000000 + 7;

int N, M;

int S[2005];
int T[2005];

int dp[2005];

int main()
{
	scanf("%d %d", &N, &M);

	for (int i = 0; i < N; ++i) scanf("%d", &S[i]);
	for (int i = 0; i < M; ++i) scanf("%d", &T[i]);


	for (int i = 0; i < M; ++i)
	{
		int sum = 0;
		for (int j = 0; j < N; ++j)
		{
			int temp = sum;
			sum = (sum + dp[j]) % mod;
			if (T[i] == S[j]) dp[j] = (dp[j] + temp + 1) % mod;
		}
	}

	int ans = 1;

	for (int i = 0; i < N; ++i) ans = (ans + dp[i]) % mod;
	printf("%d\n", ans);

	return 0;
}

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

const int MAX = 1000001; 

struct Query 
{ 
	int l, r, c; 
}; 

bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

void update(int c, int val, int bit[], int n) 
{ 
	for (; c <= n; c += c&-c) 
		bit[c] += val; 
} 

int query(int c, int bit[], int n) 
{ 
	int s = 0; 
	for (; c>0; c-=c&-c) 
		s += bit[c]; 
	return s; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].c] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

int main() 
{ 
	int n,q;
	cin>>n>>q;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	Query queries[q];
	for(int i=0;i<q;i++){
		int left,right;
		cin>>left>>right;
		queries[i].l=(left-1);
		queries[i].r=(right-1);
		queries[i].c=i;
	} 
	//int q = sizeof(queries)/sizeof(queries[0]); 
	sort(queries, queries+q, cmp); 
	answeringQueries(a, n, queries, q); 
	return 0; 
}

Measured memory_bytes: 19392
import math

N = int(input())
a = list(map(int,input().split()))
m = max(a)
c = [0] * (m+1)

for i in a:
  c[i] += 1

pairwise = True
for i in range(2, m+1, 1):
  cnt = 0
  for j in range(i, m+1, i):
    cnt += c[j]
    if cnt > 1:
      pairwise = False
      break
if pairwise:
  print("pairwise coprime")
  exit()

g = 0
for i in range(N):
  g = math.gcd(g, a[i])
if g == 1:
  print("setwise coprime")
  exit()

print("not coprime")

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll x;
	cin>>x;
	ll cnt=1;
	ll m = 100;
	while((m+0.01*m) < x){
		cnt++;
		m += 0.01*m;
	}
	cout<<cnt<<endl;
	return 0;
}

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


int main() {
    int h,w;
    cin >> h >> w;
    char a[200][200];

    rep2(i,1,h+1)rep2(j,1,w+1){
        cin>>a[i][j];
    }

    rep(i,h+2){
        rep(j,w+2){
            if(i==0 || i==h+1 || j==0 || j==w+1) a[i][j] = '#';
            cout << a[i][j];
        }
        cout<<endl;
    }

    return 0;
}

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

typedef long long int int64;

#define POS(i,j) ((i)*n+(j))

void sieve(char *p,int n){
  int i,j;
  for(i=2;i<=n;i++) p[i]=1;
  p[0]=p[1]=0;
  for(i=2;i*i<=n;i++){
    if(!p[i]) continue;
    for(j=i*i;j<=n;j+=i) p[j]=0;
  }
  return;
}

inline void printPositiveInt(int64 v){
  int64 d=1;
  while(10*d<=v) d*=10;
  while(d>0){
    putchar('0'+(v/d));
    v%=d;
    d/=10;
  }
  return;
}

void run(void){
  const int n=500;
  char *p=(char *)malloc(sizeof(char)*8001);
  sieve(p,8000);
  int *l=(int *)malloc(sizeof(int)*2*n);
  int *r=(int *)malloc(sizeof(int)*2*n);
  int lp=0;
  int rp=0;
  int i=2;
  while(lp<2*n){
    l[lp++]=i++;
  }
  while(rp<2*n){
    if(p[i]) r[rp++]=i;
    i++;
  }
  int64 *board=(int64 *)malloc(sizeof(int64)*n*n);
  int j;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if((i+j)%2==0){
	board[POS(i,j)]=l[(i+j)/2]*r[((n-i)+j)/2];
      } else {
	int64 local=(int64)l[(i+j)/2]*l[(i+j)/2+1]*r[((n-i)+j)/2]*r[((n-i)+j)/2+1];
	board[POS(i,j)]=local+1;
      }
    }
  }
  int m;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    printPositiveInt(board[POS(i,0)]);
    for(j=1;j<m;j++){
      putchar(' ');
      printPositiveInt(board[POS(i,j)]);
    }
    putchar('\n');
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 4608
import java.util.*;
public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();

    sc.close();

    String[] arr = S.split("");

    int countA = 0;

    for (int i = 0; i < arr.length; i++) {
      
      if (i % 2 == 0) {
        if (arr[i].equals("1")) {
          countA++;
        }
      } else {
        if (arr[i].equals("0")) {
          countA++;
        }
      }

    }

    int countB = 0;

    for (int i = 0; i < arr.length; i++) {
      
      if (i % 2 == 0) {
        if (arr[i].equals("0")) {
          countB++;
        }
      } else {
        if (arr[i].equals("1")) {
          countB++;
        }
      }

    }

    if (countA < countB) {
      System.out.println(countA);
    } else {
      System.out.println(countB);
    }
    
  }

}

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

int bsearch(int *array, int lb, int ub, int key)
{
  int mid;
  while(ub-lb>1){
    mid  = (lb+ub)/2;
    if(array[mid]<key){
      lb=mid;
    }
    else{
      ub=mid;
    }
  }
  return ub;
}

int main()
{
  int N;
  int a[110000], b[110000], c[110000];
  ll res=0;
  cin >> N;
  rep(i,N) cin >> a[i+1];
  rep(i,N) cin >> b[i+1];
  rep(i,N) cin >> c[i];
  a[0] = b[0] = 0;
  a[N+1] = b[N+1] = INF;

  sort(a,a+N+1);
  sort(b,b+N+1);
  sort(c,c+N);

  ll ab[110000];
  FOR(j,1,N){
    int idxA = bsearch(a, 0, N+1, b[j]);
    ab[j] = (ll)(idxA-1);
    //cout << b[j] << ":" << idxA << "(" << a[idxA-1] << "," << a[idxA] << "]" \
<< "-->" << ab[j] << endl;                                                      
  }

  ll bc[110000];
  bc[0] = 0;
  bc[1] = ab[1];
  FOR(i,1,N-1){
    bc[i+1] = bc[i] + ab[i+1];
  }
  rep(i,N){
    int idxB = bsearch(b, 0, N+1, c[i]);
    //cout << c[i] << ":" << idxB << "(" << b[idxB-1] << "," << b[idxB] << "]" \
<< "-->" << bc[idxB-1] << endl;                                                 
    res += bc[idxB-1];
  }
  cout << res << endl;
  return 0;
}




Measured memory_bytes: 3200
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

set = Set.new
[*1..9].each do |i|
  [*1..9].each do |j|
    set.add(i*j)
  end
end

if set.include?(N)
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 14460
#include<iostream>
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<math.h>
#include<climits>
#include<map>
#include<string.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000009
using namespace std;
#define ll long long





int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n = 0;
    cin >> n;
    ll max = 0;
    int *arr = new int[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> arr[i];
    }
    ll sum = 0;
    for (int i = 1; i < n; i++)
    {
        if (arr[i - 1] > arr[i])
        {
            sum = sum + (arr[i - 1] - arr[i]);
            arr[i] = arr[i - 1];
        }
    }
    cout << sum << endl;








}




Measured memory_bytes: 4344
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    string s,t;
    cin >> s >> t;  
    int n=s.size();
    int ans=0;
    rep(i,n) {
        if (s[i]!=t[i]) ++ans;
    }
    cout << ans << endl;
     
    return 0;   
}

Measured memory_bytes: 3868
N,M=map(int,input().split())
S=list(map(int,input().split()))
T=list(map(int,input().split()))
X=[[0]*(M+1) for i in range(N+1)]
DP=[[0]*M for i in range(N)]
DP[0][0]=0
mod=10**9+7
for i in range(N):
  for j in range(M):
    if S[i]==T[j]:
      DP[i][j]=(X[i][j]+1)%mod
    X[i+1][j+1]=(DP[i][j]+X[i+1][j]+X[i][j+1]-X[i][j])%mod
print((X[N][M]+1)%mod)

Measured memory_bytes: 104412
while True:
    try:
        a=int(input())
        if a==0:
            pass
        else:
            x=a//5
            y=a//(5**2)
            z=a//(5**3)
            w=a//(5**4)
            u=a//(5**5)
            s=a//(5**6)
            print(x+y+z+w+u+s)
    except:
        break;


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

using namespace std;

int main()
{
    //ifstream fin("fis.in");
    //ofstream fout("fis.out");
    double n;
    cin>>n;
    n=n/3;
    cout<<setprecision(12)<<fixed<<n*n*n;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

int main() {
  int n,i,j,e,sum,t,x,minv,M[MAX][MAX],d[MAX],P[MAX],vis[MAX];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) {
    for(j = 0 ; j < n ; j++) {
      scanf("%d",&e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for(i = 0 ; i < n ; i++) {
    d[i] = INFTY;
    P[i] = -1;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1) {
    minv = INFTY;
    t = -1;
    for(i = 0 ; i < n ; i++) {
      if(minv > d[i] && !vis[i]) {
        t = i;
        minv = d[i];
      }
    }
    if(t == -1)
      break;
    vis[t] = 1;
    for(x = 0 ; x < n ; x++) {
      if(!vis[x] && M[t][x] != INFTY) {
        if(d[x] > M[t][x]) {
          d[x] =  M[t][x];
          P[x] = t;
        }
      }
    }
  }

  sum = 0;

  for(i = 0 ; i < n ; i++) {
    if(P[i] != -1)
      sum += M[i][P[i]];
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2032
#include <iostream>

using namespace std;

class Dice {
public:
        int face[6];

        int getRightFace(int up, int front);
};

int Dice::getRightFace(int up, int front)
{
        if ((up == face[1] && front == face[2]) ||
                (up == face[2] && front == face[4]) ||
                (up == face[3] && front == face[1]) ||
                (up == face[4] && front == face[3])) {
                return face[0];
        }

        if ((up == face[0] && front == face[3]) ||
                (up == face[2] && front == face[0]) ||
                (up == face[3] && front == face[5]) ||
                (up == face[5] && front == face[2])) {
                return face[1];
        }

        if ((up == face[0] && front == face[1]) ||
                (up == face[1] && front == face[5]) ||
                (up == face[4] && front == face[0]) ||
                (up == face[5] && front == face[4])) {
                return face[2];
        }

        if ((up == face[0] && front == face[4]) ||
                (up == face[1] && front == face[0]) ||
                (up == face[4] && front == face[5]) ||
                (up == face[5] && front == face[1])) {
                return face[3];
        }

        if ((up == face[0] && front == face[2]) ||
                (up == face[2] && front == face[5]) ||
                (up == face[3] && front == face[0]) ||
                (up == face[5] && front == face[3])) {
                return face[4];
        }

        return face[5];
}

int main()
{
        Dice dice;

        for (int i = 0; i < 6; i++) {
                cin >> dice.face[i];
        }
        int q;
        cin >> q;
        for (int i = 0; i < q; i++) {
                int up, front;
                cin >> up >> front;
                cout << dice.getRightFace(up, front) << endl;
        }

        return 0;
}

Measured memory_bytes: 1160
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>; 

bool check(vi &p){
    rep(i, p.size()){
        rep(j, p.size()){
            if(i != j){
                if(abs(i-j) == abs(p[i]-p[j])){
                    return false;
                }
            }
        }
    }
    return true;
}

int main() {
    int k;
    cin >> k;
    vi r(k), c(k);
    rep(i, k){
        cin >> r[i] >> c[i];
    }
    vector<string> field(8, "");
    rep(i, 8){
        rep(j, 8){
            field[i] += '.';
        }
    }

    vi perm(8);
    iota(perm.begin(), perm.end(), 0);
    //r行c列にクイーンがあるということをperm[r] == cとする
    do{
        bool con = false;
        rep(i, k){
            if(perm[r[i]] != c[i]){
                con = true;
                break;
            }
        }
        if(con) continue;

        if(check(perm)){
            rep(i, 8){
                field[i][perm[i]] = 'Q';
                cout << field[i] << endl;
            }
            return 0;
        }
    }while(next_permutation(perm.begin(), perm.end()));
}


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

using std::max; using std::swap; using std::abs; using std::priority_queue; using std::queue; using std::bitset; using std::make_tuple; 
using std::istream; using std::ostream; using std::fixed; using std::greater; using std::tuple; using std::tie; using std::make_pair;
using std::cout; using std::cerr; using std::endl; using std::lower_bound; using std::upper_bound; using std::deque; using std::min; 
using std::map; using std::string; using std::fill; using std::copy; using std::sort; using std::unique; using std::unordered_set; 
using std::multiset; using std::nth_element; using std::min_element; using std::max_element; using std::vector; using std::set; 
using std::unordered_map; using std::pair; using std::next_permutation; using std::reverse; using std::rotate; using std::cin; 
using std::iota; using std::function; using std::shuffle; using std::iter_swap;

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

int const INF = 100 + (int) 1e9;
ll const INFL = 100 + (ll) 1e18;
ld const PI = 3.141592653589793238462643L;
std::mt19937 mt19937(960172);

ll rnd(ll x, ll y) { static auto gen = std::bind(std::uniform_int_distribution<ll>(), mt19937); return gen() % (y - x + 1) + x; }
bool is_prime(ll x) { if (x <= 1) return 0; for (ll y = 2; y * y <= x; ++y) if (x % y == 0) return 0; return 1; }
ll sqr(int a) { return (ll) a * a; } ld sqr(ld a) { return a * a; } ll sqr(ll a) { return a * a; }
ll gcd(ll a, ll b) { while (b > 0) { ll t = a % b; a = b; b = t; } return a; }




void solve() {
    
    set<int> a;
    for (int i = 0; i < 3; ++i) {
        int x;
        cin >> x;
        a.insert(x);
    }
    
    cout << a.size() << endl;
    
}



int main() {
    
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    
    cout.precision(15);
    cout << fixed;
    cerr.precision(6);
    cerr << fixed;
    
    int tcn = 1;
    for (int tn = 1; tn <= tcn; ++tn)
        solve();
    
#ifdef LOCAL
    cerr << "time: " << (ll) clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n, k = MII()
    pp = MII()
    pp.sort()
    print(sum(pp[:k]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9252
# A(x1, y1), B(x2, y2), C(x3, y3), D(x4, y4)
# Aを原点としたときにBが第n象限にいるかで場合分け
x1, y1, x2, y2 = gets.chomp.split.map(&:to_i)
tx, ty = (x1-x2).abs, (y1-y2).abs
if x1<=x2 && y1<=y2
    # 第1象限
    x3, y3 = x2-ty, y2+tx
    x4, y4 = x1-ty, y1+tx
    puts "#{x3} #{y3} #{x4} #{y4}"
elsif x1>=x2 && y1<=y2
    # 第2象限
    x3, y3 = x2-ty, y2-tx
    x4, y4 = x1-ty, y1-tx
    puts "#{x3} #{y3} #{x4} #{y4}"
elsif x1>=x2 && y1>=y2
    # 第3象限
    x3, y3 = x2+ty, y2-tx
    x4, y4 = x1+ty, y1-tx
    puts "#{x3} #{y3} #{x4} #{y4}"
elsif x1<=x2 && y1>=y2
    # 第4象限
    x3, y3 = x2+ty, y2+tx
    x4, y4 = x1+ty, y1+tx
    puts "#{x3} #{y3} #{x4} #{y4}"
end

Measured memory_bytes: 1788
from collections import Counter

N = int(input())
a = list(map(int, input().split()))
cnts = Counter(a)

_sum = 0
for key,value in cnts.items():
    _sum +=  value*(value-1)//2

for ai in a:
    ans = _sum
    c = cnts[ai]
    ans -= c*(c-1)//2
    ans += (c-1)*(c-2)//2
    print(ans)


Measured memory_bytes: 26780
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define ppll pair<ll, pll>
#define pii pair<int, int> 
#define mod 1000000007
#define pb push_back
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro%mod);
}
vector<int> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
bool cmp(pll a,pll b){
    return a.se<b.se;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll ans=(n-1)/2;
    cout<<ans;
    return 0;
}


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

int n, a;
string s, w;

int main() {
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>a;
		if(a%2 == 0){
			if(a % 3 && a % 5){
				cout<<"DENIED";
				return 0;
			}
		}
	}
	cout<<"APPROVED";
	return 0;
}

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

#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a, b, c) min(a, min(b, c))
#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>str;
	if(str[0]=='M')
	cout<<6;
	else if(str=="TUE")
	cout<<5;
	else if(str[0]=='W')
	cout<<4;
	else if(str=="THU")
	cout<<3;
	else if(str=="FRI")
	cout<<2;
	else if(str=="SAT")
	cout<<1;
	else 
	cout<<7;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int A[3];
    A[0]=a;
    A[1]=b;
    A[2]=c;
    sort(A,A+3);
    bool act=false;
    if(A[0]+A[1]==A[2]){
        act=true;
    }
    if(act){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int l = 0, g = 0;
    int a;
    for (int i=0; i<m; i++) {
        cin >> a;
        if (a < x) {
            l++;
        } else {
            g++;
        }
    }
    cout << min(l, g) << endl;
}

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

int main() {
  int x,n;cin>>x>>n;
  vector<int> vec(102);
  rep(i,n){
    int p;cin>>p;
    vec[p]++;
  }
  int ans,cnt=1e9;
  rep(i,102){
    if(vec[i]==0&&cnt>abs(x-i)){
      ans=i;
      cnt=abs(x-i);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define el '\n'
#define ull unsigned long long
#define ui unsigned int
#define ll long long
string s;

bool case_test()
{
    int ed=s.size(),c=0;
    for(int i=1;i<ed;i++)
    {
        if(isupper(s[i]) &&  ( s[i] !='A' && s[i] != 'C') )
            return false;
    }
    return true;
}
bool check_c()
{
    int c=0;
    for(int i=2;i<=s.size()-2;i++)
    {
        if(s[i]=='C')
            c++;
    }
    if(c==1)
        return true;
    return false;
}


int main()
{
    int n;
    cin>>s;
    if(s[0]=='A'  && check_c()   && case_test() )
        cout<<"AC"<<el;
    else
        cout<<"WA"<<el;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

  int i;
  
  for(i=3;i<=n;i++){

    
    if(i%3 == 0 || i%10 == 3 || i/10 == 3 || i/10%10 == 3 || i/100%10 == 3 || i/1000 == 3){
      printf(" %d",i);
    }
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2084