akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(r) r.begin(),r.end()
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        vll a(3);
        in >> a[0] >> a[1] >> a[2];
        sort(all(a));
        if (a[2] % 2 == 0) {
            out << 0 << '\n';
        }
        else {
            out << a[0] * a[1] << '\n';
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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

int n, x, ans, p;

int abs(int a, int b) { return (a < b ? b - a : a - b); }
int GCD(int a, int b) { return (b == 0 ? a : GCD(b, a % b)); }

int main(){
	scanf("%d%d%d", &n, &x, &ans);
	ans = abs(x - ans);
	for (int i = 1; i < n; ++i){
		scanf("%d", &p), p = abs(x - p), ans = GCD(ans, p);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
// C - pushpush
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

vi solve(int N, vi &A){
	vi ans(N+1);
	int ia = 1;
	int mid = N/2;
	if(N%2){//odd
		mid++;
		ans[mid] = A[ia++];
	}
	int f = mid-1, b = mid+1;
	if(N%2 == 0){//even
		f++;
	}
	while(ia<=N){
		if(ia%2){//odd
			ans[f--] = A[ia];
		}
		else{//even
			ans[b++] = A[ia];
		}
		ia++;
	}
	if(N%2 == 0) reverse(ans.begin()+1,ans.end());
	return ans;
}

int main(){
	int N; cin>>N;
	vi A(N+1);
	rp(i, 1, N+1) cin>>A[i];
	vi ans = solve(N, A);
	rp(i, 1, N+1) cout<< ans[i] <<" ";
}

Measured memory_bytes: 3712
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD 1000000007
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int n;cin>>n;
  string s;cin>>s;
  int ans = 0;
  for(int i = 2; s.size() > i; i++){
    if(s[i-2] == 'A' && s[i-1] == 'B' && s[i] == 'C')ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int w,s;
	
	scanf("%d",&w);
	while(w!=-1){
		if(w<=10){
			s=4280-1150;
		}
		else if(w>10 && w<=20){
			s=4280-1150-125*(w-10);
		}
		else if(w>20 && w<=30){
			s=4280-1150-1250-140*(w-20);
		}
		else if(w>30){
			s=4280-1150-1250-1400-160*(w-30);
		}
		printf("%d\n",s);
		scanf("%d",&w);
	}
	return 0;
}

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

int main() {
  char c;
  cin >> c;
  
    if ( c == 'a' ) {
      cout << "vowel" << endl;
    }
   else if ( c == 'e' ) {
      cout << "vowel" << endl;
    }
   else if ( c == 'i' ) {
      cout << "vowel" << endl;
    }
   else if ( c == 'o' ) {
      cout << "vowel" << endl;
    }
   else if ( c == 'u' ) {
      cout << "vowel" << endl;
    }
  else {
    cout << "consonant" << endl;
  }
}  
      


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

using namespace std;

int main(){
	long long n, ans = 0;
	vector<long long> c(4);
	for(int i = 0; i < 4; i++){
		cin >> c[i];
	}
	for(int i = 1; i < 4; i++){
		c[i] = min(c[i], 2 * c[i - 1]);
	}
	cin >> n;
	ans += (n / 2) * c[3] + (n % 2) * c[2];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{int n,m,x,i,y,z,a;
cin>>n>>m>>x;
z=0,y=0;
for(i=0;i<m;i++){
scanf("%d",&a);
if(a<x)z++;
else y++;}
printf("%d\n",min(z,y));
return 0;
} 

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = getInt(sc);
		int a = getInt(sc);
		int count = h / a;
		if (h % a == 0) {
			System.out.println(count);
		} else {
			System.out.println(count + 1);
		}
	}

	private static boolean isEqual(Integer[] perm, int[] target) {
		for (int i = 0; i < perm.length; i++) {

			if (perm[i].intValue() != target[i]) {

				return false;
			}
		}
		return true;
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8


int main() {
    ll N,x[1007],y[1007],L=0;cin>>N;
    rep(i,N){
        cin>>x[i]>>y[i];
        L+=y[i]-x[i]+1;
    }
    cout << L << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((b < c && a > c) || (b > c && a < c))
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
list = Array.new
N.times do |i|
list[i] = gets.to_i
end

s = Array.new

(N-1).times do |i|
	s[i] = (list[i+1]-list[i]).to_i
end

sum=0
max=-1000000000
(N-1).times do |i|
sum += s[i]
if(sum>max)
 max=sum 
end
if sum<0
sum=0
end

end

puts max

Measured memory_bytes: 12088
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
#define pi 3.14159265359
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, d, p;
    cin >> x >> k >> d;
    x = abs(x);
    a = x%d;
    p = (x-a)/d;
    //cout << a << " " << p << endl;
    if(k > p){
        if(p % 2 == k % 2){
            cout << a;
        }
        else{
            cout << abs(a-d);
        }
    }
    else{
        cout << x-k*d;
    }


    return 0;
}


Measured memory_bytes: 3624
# AtCoder Regular Contest 065
# D - 連結 / Connectivity
# https://atcoder.jp/contests/arc065/tasks/arc065_b
import sys
from collections import defaultdict

class UnionFind:
    def __init__(self, n):
        # self.parent = [i for i in range(n)]
        self.parent = list(range(n))
    def find(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parent[x] = y

def main():
    N, *KL = map(int, input().split())
    uf = [UnionFind(N) for _ in range(2)]
    for i in range(2):
        for j in range(KL[i]):
            p, q = map(int, input().split())
            uf[i].union(p-1, q-1)

    d = defaultdict(int)
    for i in range(N):
        d[(uf[0].find(i), uf[1].find(i))] += 1

    ans = [d[(uf[0].find(i), uf[1].find(i))] for i in range(N)]
    print(*ans)
    # for i in range(N):
    #     print(d[(uf[0].find(i), uf[1].find(i))], end = " ")
    # print("")
    
    #print(" ".join([str(d[(uf[0].find(i), uf[1].find(i))]) for i in range(N)]))

if __name__ == "__main__":
    sys.setrecursionlimit(10**6)
    main()


Measured memory_bytes: 53336
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>

#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define LL long long
#define INF (2147483647)
#define sqr(x)	((x)*(x))

using namespace std;

inline void read(int &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}

inline void write(int x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

inline void read(LL &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}

inline void write(LL x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

inline bool cmp(const int a,const int b){
	return a<b;
}

int n,k;
bool f[5005];
int a[5005];

bool check(int p){
	memset(f,false,sizeof(f));
	f[0]=true;
	rep(i,1,n){
		if (i==p)	continue;
		per(j,k,a[i])
			if (f[j-a[i]])	f[j]=true;
	}
	rep(i,max(k-a[p],0),k-1)
		if (f[i])	return true;
	return false;
}

int main(){	
	read(n),read(k);
	rep(i,1,n)	read(a[i]);
	sort(a+1,a+n+1,cmp);
	
	int l=1,r=n,ans=n+1;
	while (l<=r){
		int mid=(l+r)>>1;
		if (check(mid))
			r=mid-1,ans=mid;
		else l=mid+1;
	}
	
	write(ans-1);
} 

Measured memory_bytes: 256
s = input()
s1 = s[:2]
s2 = s[2:]

if 1 <=int(s1) <= 12:
    if 1 <= int(s2) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= int(s2) <= 12:
        print('YYMM')
    else:
        print('NA')

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

int main(){
    int a, b;
    cin >> a >> b;
    
    if(a > b){
        cout << "a > b" << endl;
    } else if(a < b){
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(auto (i)=(a);(i)<(b);(i)++)
#define rev(i,a,b) for(auto (i)=(b)-1;(i)>=(a);(i)--)
using namespace std;

int main(void){
	int N;
	int read[1000];
	int write[1000];
	bool dp[1001];
	while (true){
		cin >> N;
		if (N == 0)
			return(0);

		rep(i, 0, N)
			cin >> read[i] >> write[i];

		int read_sum = 0;
		int read_max = 0;
		int max_index = 0;
		rep(i, 0, N){
			if (read[i] > read_max)
				read_max = read[max_index = i];
			read_sum += read[i];
		}
		read_sum -= read_max;

		int write_sum = 0;
		rep(i, 0, N)
			write_sum += write[i];

		int all_sum = read_max + read_sum + write_sum;
		int wait_space = read_max - read_sum;
		if (wait_space <= 0)
			cout << all_sum << endl;
		else{
			rep(i, 0, wait_space + 1)
				dp[i] = false;
			dp[0] = true;
			rep(i, 0, N)
			if (i!=max_index)
				rev(j, write[i], wait_space + 1)
			if (dp[j - write[i]])
				dp[j] = true;

			rev(i, 0, wait_space + 1)
			if (dp[i]){
				cout << ((wait_space)-i) + all_sum<<endl;
				break;
			}

		}
	}
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  set<int> s(a.begin(), a.end());
  if(s.size() == a.size()) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

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

int main() {
	char s[200055];
	
	scanf("%s", s);

	stack<int> sta;

	int n = strlen(s);

	for (int i = 0; i < n; i++) {
		if (!sta.empty() && s[sta.top()] == 'S' && s[i] == 'T') sta.pop();
		else sta.push(i);
	}

	printf("%d\n", sta.size());

	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,count=0;
  cin>>n;
  for(int i=0;i<30;i++){
    for(int j=0;j<30;j++){
      int ans=i*4+j*7;
      if(ans==n){
        count++;
        break;
      }
    }
  }
  if(count==0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var a = ~~input[0];
  var b = ~~input[1];
  var c = ~~input[2];
  var d = ~~input[3];
  var e = ~~input[4];
  var k = ~~input[5];

  var AtCoder = function(a,b,c,d,e,k){
    this.antena = [a,b,c,d,e];
    this.distance = k;
  };

  AtCoder.prototype = {
    procedure: function(){
      for(var antena1 of this.antena){
        for(var antena2 of this.antena){
          if(Math.abs(antena1-antena2) > this.distance) return false;
        }
      }
      return true;
    }
  }

  var atcoder = new AtCoder(a,b,c,d,e,k);
  if(atcoder.procedure() == true){
    console.log("Yay!");
  }else{
    console.log(":(");
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
  return *(int*)a - *(int*)b;
}
int main(void){
  int i;
  int len;
  int ii[1000000];
  int a,b,c,d=0;
  scanf("%d",&len);
  if(len <= 3){
    printf("0\n");
    return 0;
  }
  for(i=0;i<len;i++){
    scanf("%d",&ii[i]);
  }
  qsort(ii, len, sizeof(int), compare_int);
  for(i=0;i<len;i++){
    //    printf("i%d %d\n",i,ii[i]);
  }
  a = ii[len-1];
  for(i=len-2;i>1;i--){
    if(a == ii[i]){
      b = ii[i];
      i--;
      break;      
    }
    else{
      a = ii[i];
    }
  }
  //        printf("i%d a%d b%d\n",i,a,b);
  c = ii[i];
  i--;
  for(;i>=0;i--){
    if(c == ii[i]){
      d = ii[i];
      break;      
    }
    else{
      c = ii[i];
    }
  }
  if(d == 0){
    printf("0\n");
  }
  else{
    //      printf("%d %d\n",a,c);
    printf("%ld\n",(long)a*c);
  }
  return 0;
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  map<string, int> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;

  string S;
  cin >> S;
  cout << mp[S] << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
	int M, D;
	cin >> M >> D;
	
	ll cnt = 0;
	for(int di = 2; di<10; di++) {
		for(int dii = 2; dii*10+di<D+1; dii++) {
			if(di*dii<=M) {
				cnt++;
				//cout << dii << ' ' << di << endl;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
        vllin2(x,y,n);
        map<pair<ll,ll>,ll> m;
        ll k=0;
        FOR(i,0,n-1){
                FOR(j,i+1,n-1){
                        if(x[j]!=x[i]|y[i]!=y[j]){
                        if(m[mp(x[j]-x[i],y[j]-y[i])]==0){
                                m[mp(x[j]-x[i],y[j]-y[i])]=1;
                                m[mp(x[i]-x[j],y[i]-y[j])]=1;
                        }else{
                                m[mp(x[j]-x[i],y[j]-y[i])]+=1;
                                m[mp(x[i]-x[j],y[i]-y[j])]+=1;
                        }
                        k=max(m[mp(x[j]-x[i],y[j]-y[i])],k);
                        }
                }
        }
        sal(n-k)
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll n;

/* add your algorithm here */

int main() {
  cin >> n;
  vector<ll> a(n,0);
  vector<ll> sum(n+1, 0);
  rep(i,n) {
    cin >> a[i];
    sum[i+1] += sum[i] + a[i];
  }

  ll ans = 10e18+1;
  for (ll i = 1; i < n; ++i) {
    ll t1,t2;
    t1 = sum[i], t2 = sum.back() - t1;
    ll tmp = abs(t1-t2);
    ans = min(tmp, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3328
# include <iostream>
# include <stdio.h>
using namespace std;
int main(){
  char ch;
  string list = "abcdefghijklmnopqrstuvwxyz";
  int number;
  int count[26];
  // 初期化
  for(int i= 0;i<26;i++){
    count[i] = 0;
  }
  while(cin >> ch){
    if('A' <= ch && ch <= 'Z'){
      ch = ch + 32;
    }
    number = ch - 'a';
    if(0 <= number && number <= 25){
      count[number]++;
  }
  }
  for(int i = 0;i<26;i++){
    cout << list[i] << " : " << count[i] << "\n";
  }
  return 0;
}



Measured memory_bytes: 3168
N =int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

ans = num2alpha(N)
print(ans.lower())

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

int main()
{
    string S;

    cin >> S;
    
    if (S == "Sunny"){
        cout << "Cloudy" << endl;
    }
    if (S == "Cloudy"){
        cout << "Rainy" << endl;
    }
    if (S == "Rainy"){
        cout << "Sunny" << endl;
    }
    return 0;
}


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

int main(){
    //int n,c,r=0,l=0,ans=0;
    string a;
    cin>>a;
    if(a.length()==3){
        cout<<a[2]<<a[1]<<a[0];
    }
    else{
        cout<<a;
    }
} 

Measured memory_bytes: 384
N, M = map(int, input().split())
A = list(map(int, input().split()))
magic = [list(map(int, input().split())) for _ in range(M)]
magic = sorted(magic, key=lambda x: -x[1])

hold = []
now = 0
for k, v in magic:
    hold.extend([v]*k)
    now += k
    if now >= N:
        break
A.extend(hold)
A.sort(reverse=True)
print(sum(A[:N]))


Measured memory_bytes: 36856
while True:
    H, W = map(int,input().split())
    
    if H == 0 and W == 0:
        break
    else:
        for j in range(H):
            for i in range(W):
                if j == 0 or j == H-1 or i == 0 or i == W-1:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        print()    


Measured memory_bytes: 7000
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const int MOD=1e9+7;
vector<vector<int>>multiply(vector<vector<int>>a,vector<vector<int>>b,int n)
{
	vector<vector<int>>c(n,vector<int>(n));
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	for(int k=0;k<n;k++)
	{
		c[i][k]+=a[i][j]*b[j][k];
		c[i][k]%=MOD;
	}
	return c;
}
int32_t main()
{
   IOS
   int n,k;cin>>n>>k;
   vector<vector<int>>a(n,vector<int>(n));
   for(int i=0;i<n;i++)
   for(int j=0;j<n;j++)
   cin>>a[i][j];
   
   vector<vector<int>>ans=a;
   k--;
   while( k ){
	   if( k & 1 )
	   {
		   ans=multiply(ans,a,n);
	   }
	   a=multiply(a,a,n);
	   k>>=1;
   }
   int cnt=0;
   for(int i=0;i<n;i++)
   {
	   for(int j=0;j<n;j++)
	   {
		   cnt+=ans[i][j];
		   cnt%=MOD;
	   }
   }
   cout<< cnt << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
 
using namespace std;
#define prime 1000000007
 
#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int n, ans, k;

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

	for (int i = 0; i < n; ++i){
		int x;
		cin >> x;
		if(x >= k) ans++;
	}
	 cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int n;
   cin>>n;
   vector<P> e[100000];
   rep(i, n-1){
      int a, b;
      cin>>a>>b; a--; b--;
      e[a].push_back(make_pair(b, i));
      e[b].push_back(make_pair(a, i));
   }

   vector<int> col(n-1, -1);
   queue<int> q;
   q.push(0);
   int mx=0;
   while(!q.empty()){
      int v=q.front(); q.pop();
      int used= -2;
      for(P p : e[v]){
         int u=p.first, ei=p.second;
         if(col[ei]!= -1) used=col[ei];
      }
      int c=0; if(c==used) c++;
      for(P p : e[v]){
         int u=p.first, ei=p.second;
         if(col[ei]!=used){
            col[ei]=c;
            mx=max(mx, c);
            c++; if(c==used) c++;

            q.push(u);
         }
      }
   }

   cout<<(mx+1)<<endl;
   rep(i, n-1) cout<<(col[i]+1)<<endl;
   return 0;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define ALL(x) (x).begin(),(x).end()
inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

int main () {
  int n,m;
  string in;
  map<string, int> vec;

  cin >> n;
  REP(i, n) {
    cin >> in;
    vec[in] += 1;
  }

  cin >> m;
  REP(i, m) {
    cin >> in;
    vec[in] -= 1;
  }

  auto my_max_it = max_element(ALL(vec), [] (const pair<string, int> & p1, const pair<string, int> & p2) {
    return p1.second < p2.second;
  });

  cout << max(my_max_it->second, 0) << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  rep (i, N) {
    int l, r;
    cin >> l >> r;
    
    int sum;
    sum += (r - l) + 1;
    
    if (i == N - 1) {
      cout << sum << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    int N;
    cin >> N;
    set<string> sstr;
    vector<string> vstr(N);
    REP(i, N) { cin >> vstr.at(i); }

    char end = vstr[0].back();
    sstr.insert(vstr[0]);
    FOR(i, 1, N) {
        if (end != vstr[i][0]) {
            cout << "No" << endl;
            return 0;
        }
        end = vstr[i].back();
        auto itr = sstr.find(vstr[i]);
        if (itr != sstr.end()) {
            cout << "No" << endl;
            return 0;
        }
        sstr.insert(vstr[i]);
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int m, d;

int main() {
    cin >> m >> d;
    int ans = 0;
    for (int i = 1; i <= d; i++) {
        int d1 = i%10, d2 = i/10;
        if (d1 <= 1 || d2 <= 1) continue;
        if (d1*d2 <= m) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    ll n; cin>>n;
    ll ans=INF;
    for(ll i=1; i<=sqrt(n); i++){
        ll bigger=0;
        if(n%i==0){
            ll a=i;
            ll b=n/i;
            string s=to_string(max(a,b));
            ans=min(ans,(ll)s.size());
        }
    }
    cout<<ans<<endl;
}

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


int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    REP(i, N) cin >> d[i];
    set<int> values;
    REP(i,N) values.insert(d[i]);
    cout << values.size() << 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 rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N,M;
	cin>>N>>M;
	vector<P> v(M);
	vector<int> BoxN(N,1);
	vector<bool> InRed(N,false);
	InRed[0] = true;
	rep(i,M){
		int x,y;
		cin>>x>>y;
		x--;y--;
		if(InRed[x]){
			if(BoxN[x]==1){
				InRed[x] = false;
			}
			InRed[y] = true;
		}
		BoxN[x]--;
		BoxN[y]++;
	}
	int ans = 0;
	rep(i,N){
		if(InRed[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) throws NumberFormatException, IOException{
		int n;
		int[] lines=new int[3];
		int max_lines_number=0;
		BufferedReader d=new BufferedReader(new InputStreamReader(System.in));

		n=Integer.valueOf(d.readLine());//なんこの三角形を対象とするか読み取り

		for(int i=0;i<n;i++){//その回数繰り返す

			String array[] =d.readLine().split(" "); //空白区切りなので

			for(int j =0;j<3;j++){
				lines[j]=Integer.valueOf(array[j]);//Stringをintへ
			}

			for(int j =0;j<3;j++){
				if(lines[j]>=lines[max_lines_number])max_lines_number=j;//一番大きい辺の長さが入ってる配列の添字を探す
			}

			int max_line=(int) Math.pow(lines[max_lines_number],2);
			int other_lines=0;
			for(int j=0;j<3;j++){
				if(j!=max_lines_number)other_lines+=Math.pow(lines[j],2);
			}
			if(max_line==other_lines){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}


	}

}

Measured memory_bytes: 10000
H, N = map(int, input().split())
Magic = [list(map(int, input().split())) for i in range(N)]
MAX_COST = max(Magic)[1]
 
# dp[damage] := モンスターに damage を与えるために必要な最小コスト
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H):
    for damage, cost in Magic:
        next_index = min(h + damage, H)
        dp[next_index] = min(dp[next_index], dp[h] + cost)
print(dp[-1])

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }

  int ans = 0;
  bool div_2 = true;

  while(div_2){
    for(int i = 0; i < n; i++){
      if (a.at(i) % 2 != 0){
        div_2 = false;
      }
    }

    if(div_2) ans++;

    for(int i = 0; i < n; i++){
      a.at(i) /= 2;
    }
  }

  cout << ans << endl;
}

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

using namespace std;

#define fee first
#define time second
#define ALL(T) T.begin(),T.end()

const int INF = 1<<24;

int main(){
	int n, m;
	while (cin >> n >> m, n, m) {
		vector< vector<pair<int, int> > > lines(m, vector<pair<int, int> >(m));
		for (int i = 0; i < m; i++)
			for (int j = 0; j < m; j++)
				lines[i][j].fee = lines[i][j].time = INF;
		for (int i = 0; i < n; i++) {
			int a, b; cin >> a >> b;
			cin >> lines[a-1][b-1].fee >> lines[a-1][b-1].time;
			lines[b-1][a-1].fee = lines[a-1][b-1].fee;
			lines[b-1][a-1].time = lines[a-1][b-1].time;
		}

		for (int k = 0; k < m; k++)
			for (int i = 0; i < m; i++)
				for (int j = 0; j < m; j++) {
					lines[i][j].fee = min(lines[i][j].fee, lines[i][k].fee+lines[k][j].fee);
					lines[i][j].time = min(lines[i][j].time, lines[i][k].time+lines[k][j].time);
				}

		int k; cin >> k;
		for (int i = 0; i < k; i++) {
			int p, q, r; cin >> p >> q >> r;
			if (r == 0) { cout << lines[p-1][q-1].fee << endl; }
			else { cout << lines[p-1][q-1].time << endl; }

			// if (r == 0) { // minimum fee
			// 	int cur = q;
			// 	vector<int> cost(m);
			// 	for (int i = 0; i < m; i++) { cost[i] = -1; }
			// 	vector<int> visited(m);
			// 	vector<vector<int> > graph(m);

			// 	while (count(ALL(visited), 0)) {
			// 		vector<int> list;
			// 		for (int i = 0; i < m; i++) {
			// 			if (lines[cur][i].fee != -1) {
			// 				list.push_back(i);
			// 			}
			// 		}
			// 		int I;
			// 		for (int i = 0; i < list.size(); i++) {
			// 			if (cost[list[i]] > cost[cur] + lines[cur][i].fee) {
			// 				cost[list[i]] = cost[cur] + lines[cur][i].fee;
			// 				I = list[i];
			// 			}
			// 		}
			// 		visited[cur] = 1;
			// 		cur = I;
			// 	}
			// 	cout << cost[p] << endl;
			// } else if (r == 1) { // minimum time
			// 	int cur = q;
			// 	vector<int> cost(m);
			// 	for (int i = 0; i < m; i++) { cost[i] = -1; }
			// 	vector<int> visited(m);
			// 	vector<vector<int> > graph(m);

			// 	while (count(ALL(visited), 0)) {
			// 		vector<int> list;
			// 		for (int i = 0; i < m; i++) {
			// 			if (lines[cur][i].time != -1) {
			// 				list.push_back(i);
			// 			}
			// 		}
			// 		int I;
			// 		for (int i = 0; i < list.size(); i++) {
			// 			if (cost[list[i]] > cost[cur] + lines[cur][i].time) {
			// 				cost[list[i]] = cost[cur] + lines[cur][i].time;
			// 				I = list[i];
			// 			}
			// 		}
			// 		visited[cur] = 1;
			// 		cur = I;
			// 	}
			// 	cout << cost[p] << endl;
			// }

		}
	}

	return 0;
}

Measured memory_bytes: 1280
#include<cstdio>  
#include<cstdlib>
#include<cstring>

struct Node{
int key;
Node *next,*prev;
};

Node *nil;

Node* listSearch(int key){
Node *cur=nil->next;
while(cur!=nil&&cur->key!=key){
cur=cur->next;
}
return cur;
}

void init(){
nil=(Node *)malloc(sizeof(Node));
nil->next=nil;
nil->prev=nil;
}

void printList(){
Node *cur=nil->next;
int isf=0;
while(1){
if(cur==nil) break;
if(isf++>0) printf(" ");
printf("%d",cur->key);
cur=cur->next;
}
printf("\n");
}

void deleteNode(Node *t){
if(t==nil) return;
t->prev->next=t->next;
t->next->prev=t->prev;
free(t);
}

void deleteFirst(){
deleteNode(nil->next);
}

void deleteLast(){
 deleteNode(nil->prev);
 }
 
 void deleteKey(int key){
 
 deleteNode(listSearch(key));
 }
 
 void insert(int key){
 Node *x=(Node *)malloc(sizeof(Node));
 x->key=key;
 x->next=nil->next;
 nil->next->prev=x;
 nil->next=x;
 x->prev=nil;
 }
 
 int main(){
 int key,n,i;
 int size=0;
 char com[20];
 int np=0,nd=0;
 scanf("%d",&n);
 init();
 	for(i=0;i<n;i++){
 scanf("%s%d",com,&key);
 if(com[0]=='i'){ insert(key);np++;size++;
}
else if(com[0]=='d'){
if(strlen(com)>6){
if(com[6]=='F') deleteFirst();
else if(com[6]=='L') deleteLast();
}else{
deleteKey(key);nd++;
}
size--;
}
}

printList();

return 0;
}

Measured memory_bytes: 33832
import sys

A,B,C=map(int,input().split())
K=int(input())
for i in range(K+1):
  if(A<B and B<C):
    print("Yes")
    sys.exit()
  elif(A>=B):
    B*=2
  elif(B>=C):
    C*=2
print("No")

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
#define lop(i, s, t) for (int i = s;i < (t);++i)
#define rep(i, s, t) for (int i = s;i <= (t);++i) 
#define dec(i, s, t) for (int i = s;i >= (t);--i)
#define cmin(a, b) (a > b ? a = b : a)
#define cmax(a, b) (a < b ? a = b : a)
using namespace std; 

#define Pr(f,...) printf(f,##__VA_ARGS__),fflush(stdout)

const int N=605,P=1e9+7,B=10;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }

typedef long long ll;

int n,m,ans;
char s[N][N]; 
int h[N][N],pw[N],h2[N][N];

int getHsh1(int i,int l,int r){
	return sub(h[i][r],mul(h[i][l-1],pw[r-l+1]));
}
int getHsh2(int j,int l,int r){
	return sub(h2[r][j],mul(h2[l-1][j],pw[r-l+1]));
}

bool chk(int a,int b){
	rep(i,1,n){
		int x=i+a,y=i+b,l=n-i+1;
		if(getHsh1(x,y,y+l-1)!=getHsh2(y,x,x+l-1)){
			return false;
		}
	}
	return true;
}

int main() {
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout); 
#endif
	scanf("%d",&n); 
	pw[0]=1; rep(i,1,n+n)pw[i]=mul(pw[i-1],B); 
	rep(i,1,n){
		scanf("%s",s[i]+1); 
	}
	m=n+n;
	rep(i,1,m)rep(j,1,m)s[i][j]=s[i>n?i-n:i][j>n?j-n:j];
	rep(i,1,m)rep(j,1,m){
		h[i][j]=mul(h[i][j-1],B)+s[i][j]-'a'+1;
	}
	rep(i,1,m)rep(j,1,m){
		h2[i][j]=mul(h2[i-1][j],B)+s[i][j]-'a'+1;
	}	
	lop(a,0,n)lop(b,0,n)if(chk(a,b))++ans;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

int main(){
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	long long ans = a * c;
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << endl;

}

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

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

    vector<int> a(n, 0);
    int tmp;
    for (int i = 0; i < n-1; i++) {
        cin >> tmp;
        a.at(tmp-1)++;
    }

    for (int i = 0; i < n; i++) {
        cout << a.at(i) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3956
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N, K = MAP()
A = LIST()

i = A.index(1)
print(ceil((N-1)/(K-1)))


Measured memory_bytes: 15956
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

k, s = map(int, read().split())
cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y <= k:
            cnt += 1
print(cnt)


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

#define INF 100000000
#define MOD9(a) (a%1000000009)
#define MOD7(a) (a%1000000007)
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  cout << MAX(A*B, C*D) << endl;

}



Measured memory_bytes: 384
#include <iostream>
using namespace std;
/*
void solve () {

}
*/
int main () {
	//int var;
	int vector[5];
	for(int i = 0; i < 5; i++) {
		cin >> vector[i];
		if (vector[i] == 0) {
			cout << i+1;
			break;
		}
	}
	
	/*
	for (int i = 0; i < 5; i++) {
		if (vector[i] == 0) {
			cout << i+1;
			break;
		}
	}
	*/
	return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	char	str[256];
	
	scanf("%d %d %d", &a, &b, &c);

	ans = c - (a - b);
	
	if (ans<0) ans = 0;
	printf("%d\n",ans);


	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

map<string, ll> mp;
string S;
int N;

ll dfs(int p, int bit, bool to_count){
    if(p == N){
        string s;
        for(int i=0;i<N;i++){
            if(((bit>>i)&1) == 1){
                s.push_back(S[i]);
            }
        }
        s.push_back('|');
        for(int i=N-1;i>=0;i--){
            if(((bit>>i)&1) == 0){
                s.push_back(S[i]);
            }
        }
        assert(s.size() == N + 1);
        if(to_count){
            return mp[s];
        } else {
            mp[s]++;
            return 0;
        }
        mp[s]++;
    }else{
        return dfs(p + 1, bit | (1 << p), to_count) + dfs(p + 1, bit, to_count);
    }
}

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

    dfs(0, 0, false);
    reverse(S.begin(), S.end());

    cout << dfs(0, 0, true) << endl;
    return 0;
}

Measured memory_bytes: 73984
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX_N = 100;
int A[MAX_N];

int int_pow(int a, int b) {
    int tmp = 1;
    while(b != 0) {
        if(b&1) tmp *= a;
        b >>= 1;
        a *= a;
    }
    return tmp;
}

int main()
{
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) scanf("%d", &A[i]);
    int extra_events = 1;
    for(int i = 0; i < N; ++i) {
        if(A[i]%2==0) extra_events *= 2;
    }
    printf("%d\n", int_pow(3,N) - extra_events);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n, a;
    cin >> n >> a;
    n %= 500;
    if(n <= a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int N;
int A[200010];

int main(){
  cin >> N;
  for(int i=0; i < N; ++i) cin >> A[i];
  int counter = 0;
  int check_num = 1;
  for(int i=0; i < N; ++i){
    if(A[i]==check_num) ++check_num;
    else ++counter;
  }
  if(check_num == 1) counter = -1;
  cout << counter << endl;
}

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

int main() {
        string s;
        cin >> s;
        int ans=0;
        int max=-1;
        rep(i, s.length()){
                if(s[i]=='R'){
                        ans++;
                }else{
                        if(max<ans)max=ans;
                        ans = 0;
                }
        }
        if(max<ans)max=ans;
        if(max==-1)max=0;
        cout << max << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main(){
  char s[100000]={};
  int i;
  scanf("%s",s);
  int a;
  a=strlen(s);
  int ans=0;
  for(i=1;i<a;i++){
    if(s[i]!=s[i-1]){
      ans++;
    }
  }

  // printf("%d\n",a);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    double ans = 1;
    if(N % 2 == 0){
        ans = N/2 ;
        ans = ans /N;
    }else{
        ans = N/2 + 1;
        ans = ans/N;       
    }
    cout << ans << endl;
}



Measured memory_bytes: 256