akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long n = cin.Long();
			long k = cin.Long();
			long q = cin.Long();
			long[] a = cin.ArrayLong((int)q);

			long[] seikai = new long[n];
			for (int i = 0; i < q; i++) {
				seikai[a[i] - 1]++;
			}

			long[] scores = new long[n];
			for (int i = 0; i < n; i++) {
				scores[i] = k;
				scores[i] -= q - seikai[i];
			}

			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				if (scores[i] > 0) {
					sb.AppendLine("Yes");
				} else {
					sb.AppendLine("No");
				}
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 19804
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}

int main()
{
    Imposter
    
    int t=1;
    //cin>>t;
    while(t--)
    {
       char ch;
       cin>>ch;
       if(ch>='A' and ch<='Z')
       cout<<"A";
       else
       cout<<"a";
        
    }
    return 0;
}

Measured memory_bytes: 3640
N, A, B, C, D = map(int, input().split())
S = list(input())

def solve(E, x, y, G):
    if y != -1:
        E[y-1] = '#'
    dp = [0]*N
    dp[x-1] = 1
    for i in range(2, N):
        if dp[i-2] or dp[i-1]:
            if E[i] == '.':
                dp[i] = 1
    # print(dp)
    return dp[G-1]

if C < D:
    p = solve(S, B, -1, D)
    q = solve(S, A, -1, C)
else:
    bla = 0
    idx = -1
    for i in range(B-2, N):
        if S[i] == '.':
            bla += 1
        else:
            bla = 0
        if bla == 3:
            idx = i
            break
    # print(idx)
    if idx == -1:
        print('No')
        exit()
    else:
        if D - 1 <= idx - 2:
            print('No')
            exit()

    p = solve(S, A, -1, C)
    q = solve(S, B, -1, D)
    # print(p, q)

if p and q:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6288
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define unmap  	unordered_map<int,int>
#define	unset	unordered_set<int>
#define maxpq  	priority_queue<int>
#define minpq  	priority_queue<int, vector<int>, greater<int>>
#define pb 		push_back		
#define ll 		long long
#define ull     unsigned ll
#define ff 		first
#define ss 		second//typedef second ss;
#define foton(i,n) for(int i=0;i<n;i++)
#define	faton(i,a,n)	for(int i=a;i<=n;i++)
#define mod 	1000000007
int const inf = 10000007;
#define endl "\n"
using namespace std;

int main(){
	fastio;
	int n;cin>>n;
    int r = 0;
    for(int i=1;i<n;i++){
        for(int j=1;j*i<n;j++){
            r++;
        }
    }
	cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 3604
M=1000003
o=->a,n{n<1?1:(n%2>0?a:1)*o[a,n/2]**2%M}
f=f=1,*(1..M).map{|i|f=f*i%M}
gets
$<.map{|s|x,d,n=s.split.map &:to_i
t=x*o[d,M-2]%M
p d<1?o[x,n]:M<t+n     ?0:f[t+n-1]*o[f[t-1],M-2]*o[d,n]%M}

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

int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i=0; i<n; i++) cin >> arr[i];
  for (int i=0; i<n; i++) {
    if ((arr[i]%2 == 0) and (arr[i]%3 != 0) and (arr[i]%5 != 0)) {
      cout << "DENIED\n";
      return 0;
    }
  }
  cout << "APPROVED\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define rep(i,n) for(int i=0; i<n; ++i)
#define irep(i,n) for(int i=n-1; i>=0; --i)
using namespace std;

int R;
int J,GJ,H,GH;
bool f = false;
int main(){
  while(cin >> R && R){
    int min = 1000;
    int min_J, min_GJ, min_H, min_GH;
    int cnt;
    cin >> J >> GJ >> H >> GH;
    
    rep(i,J+1){
    rep(j,GJ+1){
    rep(k,H+1){
    rep(l,GH+1){
      int dif = i*10 + j*50 + k * 100 + l * 500 - R;
      if(dif < 0) continue;
      cnt = J + GJ + H + GH;
      cnt -=  i+j+k+l;
      if(l > 0 && dif/500 > 0) continue;
      cnt+= dif/500; dif -= 500 * (dif/500);
      if(k > 0 && dif/100 > 0) continue;
      cnt+= dif/100; dif -= 100 * (dif/100);
      if(j > 0 && dif/50 > 0) continue;
      cnt+= dif/50; dif -= 50 * (dif/50);
      if(i > 0 && dif/10 > 0) continue;
      cnt+= dif/10; dif -= 10 * (dif/10);
      if( cnt <= min){
        min = cnt;
        min_J = i; min_GJ = j; min_H = k; min_GH = l;
      }
    }}}}
    
    if(f == false) f = true;
    else cout << endl;
    
    if(min_J > 0) cout << "10 " << min_J << endl;
    if(min_GJ > 0) cout << "50 " << min_GJ << endl;
    if(min_H > 0) cout << "100 " << min_H << endl;
    if(min_GH > 0) cout << "500 " << min_GH << endl;
    
    
  }
  return 0;
}
 

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

int candidate[50];

int main() {
    int n,p;
    while(cin>>n>>p, n|p) {
        for(int i=0; i<50; ++i) candidate[i] = 0;
        int count = 0,cup = p,idx = 0,stepc = 0;
        while(true) {
            stepc++;
            if(cup > 0) {
                candidate[idx]++;
                cup--;
                if(candidate[idx] == 1) count++;
                //if(cup == 0) cout<<idx<<endl;
                if(cup == 0 && count == 1) {
                    cout<<idx<<endl;
                    break;
                }
            }else{
                if(candidate[idx] > 0) count--;
                cup = candidate[idx];
                candidate[idx] = 0;
            }
            idx = (idx+1)%n;
            //if(stepc >= 1000000) cout<<"efaw"<<endl;
        }
    }
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    bool can = true;
    for (int i = 0; i < N; i++)
    {
        if(A[i] % 2 == 0) {
            if(A[i] % 3 != 0 && A[i] % 5 != 0)
                can = false;
        }
    }

    if(can) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N,M=map(int,input().split())
ab=[]
for i in range(M):
    ab.append(list(map(int,input().split())))

ans=0

def dfs(x):
    flg[x]=True
    for i in range(len(G[x])):
        
        if flg[G[x][i]]:
            continue
        else:
            dfs(G[x][i])

for i in range(M):
    flg=[False for k in range(N+1)]
    flg[0]=True
    G=[[] for k in range(N+1)]
    for j in range(M):
        if j!=i:
            G[ab[j][0]].append(ab[j][1])
            G[ab[j][1]].append(ab[j][0])
    dfs(1)
    
    for j in range(N+1):
        if flg[j]:
            continue
        else:
            ans+=1
            break

print(ans)
    


Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int s ;
  cin >> s ;
  
  vector<int> ss(1000001) ; 
  ss[0] = s ;
  
  for(int i=1;i<1000001;i++){
    if(ss[i-1]%2==0){
      ss[i] = ss[i-1]/2 ;
    }else if(ss[i-1]%2!=0){
      ss[i] = ss[i-1]*3+1 ;      
    }
    for (int j = 0; j < i; j++) {
      if (ss[i] == ss[j]) {
        cout << i+1 << "\n";
        return 0;
      }
    }
  }
}


Measured memory_bytes: 4096
a, b, c, x, y = map(int, input().split())

tmp1 = c * min(x, y) * 2
tmp2 = 0
if x < y:
    tmp2 = b * abs(x - y)

elif x > y:
    tmp2 = a * abs(x - y)

else:
    tmp2 = float("INF")

pattern1 = (a * x + b * y)
pattern2 = tmp1 + tmp2
pattern3 = c * max(x, y) * 2

print(min(pattern1, pattern2, pattern3))


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int H,W,D;
int A[300][300];
int Q;
int L[100010];
int R[100010];
int acc[100010];

int main ()
{
    cin >> H >> W >> D;
    REP(i,H) REP(j,W) cin >> A[i][j];
    cin >> Q;
    REP(i,Q) cin >> L[i] >> R[i];

    vector < vector < int > > ord;
    REP(x,H) REP(y,W) ord.push_back({A[x][y], x, y});
    sort(ord.begin(), ord.end());

    fill (acc, acc + 100010, -1);

    for (int i = 0; i < ord.size(); i++) {
        if (acc[i + 1] >= 0) break;
        int sum = 0;
        int px = ord[i][1];
        int py = ord[i][2];
        for (int j = i; j < ord.size(); j += D) {
            int x = ord[j][1];
            int y = ord[j][2];
            sum += abs(x - px) + abs(y - py);
            px = x;
            py = y;
            acc[j + 1] = sum;
        }
    }

    REP(i,Q) {
        cout << acc[R[i]] - acc[L[i]] << endl;
    }

    return 0;
}


Measured memory_bytes: 7984
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

inline void solve(){
  int n;
  string s[10005];
  int x[50000]={};
  int a=0,b=0,ab=0;
  int d=0;
  cin >> n;

  FOR(i,n){
    cin >> s[i];
    FOR(j,s[i].length()){
      if(s[i][j]=='A' && s[i][j+1] == 'B'){
        ab++;
        x[i]++;
      }
    }
    if(s[i][0]=='B') b++;
    if(s[i][s[i].length()-1]=='A') a++;
    if(s[i][0]=='B' && s[i][s[i].length()-1]=='A'){
      d++;
      a--;
      b--;
    }
  }
  bool l = false;
  if(d){
    d--;
    l = true;
  }

  int ans =0;

  ans += ab + d;
  if(l){
    if(a){
      a--;
      ans++;
    }
    if(b){
      b--;
      ans++;
    }
  }
  
  cout << ans + min(a, b) fin;
  

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 768
import java.lang.Math.min
import java.lang.Math.abs
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (n, k) = sc.nextLine().split(" ").map { it.toLong() }

    val n1 = n%k
    val n2 = abs(n1-k)
    println(min(n, min(n1, n2)))
}

Measured memory_bytes: 35896
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    string op;

    cin >> a >> op >> b;

    if (op == "+")
    {
        cout << (a + b) << endl;
    }
    else
    {
        cout << (a - b) << endl;
    }
    
    return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N,K;
    cin >> N >> K;
    vector<int> v(N,0);
    vector<bool> isMinV(N+1, false);
    REP(i,N) cin >> v[i];
    int minimum = *min_element(ALL(v));
    isMinV[0]=true;
    FOR(i,0,N+1) {
        if (minimum==v[i]) isMinV[i+1]= true;
    }

    // 尺の中に入る。最小値で無い要素の個数
    int shakuInFalse=0;
    REP(i,K) {
        if (!isMinV[i])  shakuInFalse++;
    }

    REP(i,N+1) {
        // cout << isMinV[i] << endl;
    }
    int ans=0;
    // 尺取法
    REP(i,(N+1)-K+1) {
        // 要素の確認
        // 最後で、尺の中にfalseが入っていたら答えを+1して終了
        if (i==((N+1)-K)) {
            if (shakuInFalse >0)ans++;
            continue;
        }

        bool best = shakuInFalse == (K-1);
        bool need = !isMinV[i];
        // 筒の中を全てtrueにする。
        if (best || need) {
            FOR(j,i,i+K) isMinV[j]=true;
            shakuInFalse=0;
            ans++;
        }
        // 次の要素を確認する。
        bool next = isMinV[i+K];
        if (!next) shakuInFalse++;
        // 前の要素を確認する。
        bool before = isMinV[i];
        if (!before) shakuInFalse--;

    }
    cout << ans << endl;

    return 0;
}


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

int N;
unordered_map<int, int> c;

int main() {
  cin >> N;
  rep(i, N) {
    int a;
    cin >> a;
    c[a]++;
  }

  int ans = 0;
  rep(x, 1e5 + 1) {
    int res = c[x];
    if (x - 1 >= 0) res += c[x - 1];
    if (x + 1 <= 1e5) res += c[x + 1];
    ans = max(ans, res);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct to{
	ll l,t;
};
vector<to> mp[100001];
ll dis[100001];

void dfs(ll u,ll fa){
	for(ll i=0; i<mp[u].size(); i++){
		ll v=mp[u][i].t;
		if(v==fa) continue;
		dis[v]=dis[u]+mp[u][i].l;
		dfs(v,u);
	}
	return;
}

int main(){
	ll n,a,b,c,q,k,x,y;
	cin>>n;
	for(ll i=1; i<n; i++){
		cin>>a>>b>>c;
		mp[a].push_back((to){c,b});
		mp[b].push_back((to){c,a});
	}
	cin>>q>>k;
	dfs(k,0);
	for(ll i=0; i<q; i++){
		cin>>x>>y;
		cout<<dis[x]+dis[y]<<endl;
	}
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define F first
#define S second

typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e12;
const ll mlnf = -1e12;

void debug_vector(vector<int>& v)
{
    int n = v.size();
    for (int i = 0; i < n; i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

void solve();

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

void solve()
{
    int N;
    std::cin >> N;
    std::vector<int> P(N);
    std::vector<int> Q(N);
    for (int i = 0; i < N; i++) {
        std::cin >> P[i];
    }
    for (int i = 0; i < N; i++) {
        std::cin >> Q[i];
    }
    std::vector<int> V(N);
    for (int i = 0; i < N; i++) {
        V[i] = i + 1;
    }
    int cnt = 0;
    int a, b;
    do {
        cnt++;
        if (P == V) {
            a = cnt;
        }
        if (Q == V) {
            b = cnt;
        }
    } while (next_permutation(all(V)));
    cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N, Q = map(int, input().split())
    uni = UnionFind(N)
    for _ in range(Q):
        t, u, v = map(int, input().split())
        if t == 0:
            uni.union(u,v)
        else:
            if uni.same(u,v):
                print(1)
            else:
                print(0)

if __name__ == "__main__":
    main()

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

vector < int > G[100005];
bool flag[100005] = {};

vector < int > vec1, vec2;
int N, M;
int P[100005];


void dfs(int v)
{
	if ( flag[v] ) return;
	flag[v] = true;
	vec1.push_back(v); vec2.push_back(P[v]);
	for ( auto &x : G[v] ) {
		dfs(x);
	}
	return;
}

int main()
{
	int cnt = 0;	
	cin >> N >> M;

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

	for ( int i = 0; i < M; i++ ) {
		int a, b;
		cin >> a >> b; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	for ( int i = 0; i < N; i++ ) {
		while ( !vec1.empty() ) vec1.pop_back();
		while ( !vec2.empty() ) vec2.pop_back();
		if ( !flag[i] ) {
			dfs(i);
		}
		sort(begin(vec2), end(vec2));
		for ( auto &x : vec1 ) {
			if ( binary_search(begin(vec2), end(vec2), x) ) {
				cnt++;
			}
		}
	}
	
	cout << cnt << endl;

	return (0);
}


Measured memory_bytes: 10156
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
const int MAXN = 2e5 + 5;
const int MOD = 1e9 + 7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
 
int N;
char S[MAXN];
int a,b,c,d;

int cango(int start, int end) {
    while (start < end) {
        if (S[start+1] == '.') start++;
        else if (S[start+2] == '.') start += 2;
        else return 0; 
    }

    return 1;
}
 
int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    cin >> N >> a >> b >> c >> d >> S;
    a--; b--; c--; d--;
 
    if (!cango(b,d) || !cango(a,c)) FAILNO;
 
    if (d < c) {
        int found = 0;
        for (int i = b-1; !found && i+2 <= d+1; i++)
            found = S[i] == '.' &&
                S[i+1] == '.' &&
                S[i+2] == '.';

        if (!found) FAILNO;
    }

    cout << "Yes\n";
    return 0;
}


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

int a[10000];

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> a[i];
	}
	int b = 0;
	for (int i = 0; i < m; ++i)
	{
		b = b + a[i];
	}
	if (b <= n)
		cout << n-b;
	else
		cout << "-1";
}

Measured memory_bytes: 3656
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		ou.println(n * 1.0 / m);
		ou.flush();
	}
}

Measured memory_bytes: 35380
#include<bits/stdc++.h>
using namespace std;
int main(){
int n=0,h=0;
              cin>>n;
  vector<int> Ans(n+1,0);
               for(int i=1;i*i<=n;i++){
                for(int j=1;j*j<=n;j++){
                	for(int k=1;k*k<=n;k++){
                      h=i*i + j*j + k*k + i*j + i*k + j*k;
                      if(h<=n){
                      Ans[h]++;
                      }
                    }
                }
              }
              for(int i=1;i<=n;i++){
              cout<<Ans[i]<<'\n';
              }
              return 0;
            
}

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

int main() {
  int N,sum=0;
  cin >>N;
  
  vector<int> W(N);
  
  for (int i=0;i<N;i++){
    cin >>W.at(i);
    sum+=W.at(i);
  }
  int sum1=W.at(0),sum2=0;
  for (int i=0;i<N-1;i++){
    sum2=sum1+W.at(i+1);
    if (abs(sum-2*sum1)>abs(sum-2*sum2)){
      sum1=sum2;
    }
    else{
      break;
    }
  }
  
  cout << abs(sum-2*sum1) <<endl;
      
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = ReadLong();
            var sqrt = Math.Sqrt(n);
            long min = int.MaxValue;
            for (var i = 1; i <= sqrt; i++)
            {
                if (n % i == 0)
                {
                    var a = n / i;
                    ChangeMin(ref min, (long)Math.Log10(a > i ? a : i) + 1);
                }
            }
            Console.WriteLine($"{min}");
        }
        public static bool ChangeMin(ref long lhs, long rhs)
        {
            if (lhs > rhs)
            {
                lhs = rhs;
                return true;
            }
            else
            {
                return false;
            }
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13268
import math

n = int(input())
l = list(map(int, input().split()))
d = {}
for e in l:
    if e in d:
        d[e] += 1
    else:
        d[e] = 1

for i in range(1, n+1):
    if i in d:
        print(d[i])
    else:
        print(0)


Measured memory_bytes: 33672
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456], ng[213456];
int keta(int x) {
	int res = 0;
	while(x >= 1) {
		x /= 10; res++;
	}return res;
}
signed main() {
	int n, m, a, sum = 0, ans = 0; string b; cin >> n >> m;
	for (int h = 0; h < m; h++) {
		cin >> a >> b;
		if (b == "AC") { test[a] = 1; }
		else if (test[a] == 0) { ng[a]++; }
	}
	for (int h = 0; h < n; h++) {
		if (test[h + 1] == 1) { 
			ans++; sum += ng[h + 1];
		}
	}
	cout << ans << ' ' << sum << endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

int parent(int);
int left(int);
int right(int);

int main(){
  int  i,H,A[250];
  scanf("%d",&H);
  for(i=1;i<H+1;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<H+1;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i)<=H){
      printf("left key = %d, ",A[left(i)]);    
    }

    if(right(i)<=H){
      printf("right key = %d, ",A[right(i)]);    
    }
    if(i!=H+1){
      printf("\n");
    }
  }

  return 0;
}


int parent(int i){
  return i/2;
}


int left(int i){
  return 2*i;
}


int right(int i){
  return 2*i+1;
}



Measured memory_bytes: 2048
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string & str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	sort(all(a), greater<int>());
	int ng = n + 1, ok = 0;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (a[mid - 1] >= mid)ok = mid;
		else ng = mid;
	}
	printf("%d\n", ok);

	Please AC;
}


Measured memory_bytes: 3252
///****In the name of ALLAH, most Gracious, most Compassionate****//

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

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

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const ll N=5e3+5;
const ll oo=1e9+7;

ll state[N];
ll nxt[N];
ll c[N];
ll dep[N];
ll parent[N];
bool incycle[N];

ll qsum[N];

ll k;
ll len = -1;
ll cycle_cost = 0;
ll ans = -1e18;
void dfs(ll u)
{
    state[u] = 1;

    if(dep[u]  > k)
        return ;

    qsum[dep[u]] = qsum[dep[u]-1] + c[u];

    ll v =nxt[u];

    if(state[v] == 0)
    {
        dep[v] = dep[u] + 1;
        dfs( v );
    }
    else
    {
        assert(state[v] == 1);

        ll x  = u;
        while(1)
        {
            incycle[x] = 1;
            if(x== v) break;
            x = parent[x] ;

        }
        len = dep[u] - dep[v] + 1;
        cycle_cost = qsum[dep[u]] - qsum[dep[u] - len];
    }

    ans = max(ans , qsum[dep[u]]);

//    DBG(u);
//    DBG(incycle[u]);

    if(incycle[u])
    {
        ll z = (k - dep[u] ) / len;
        ans = max(ans , z * cycle_cost + qsum[dep[u]]);
    }

    state[u] = 2;
}

#define CLR(x) memset(x , 0 , sizeof x)


void clr(ll n)
{
    CLR(incycle);
    CLR(state);
    len = -1 ;
    cycle_cost = 0;
}

int32_t main()
{
    FastIO;
    ll n;
    cin>>n>>k;
    for(ll i=1;i<=n;i++)
    {
        cin>>nxt[i];
        parent[nxt[i]] = i;
    }
    for(ll i=1;i<=n;i++) cin>>c[i];
    for(ll i=1;i<=n;i++)
    {
        clr(n);
        dep[i] = 1;
        dfs(i);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 4128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  string s;
  cin >> s;
  cout << "ABC" << s << endl; 

  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int64_t> v(n);
  for (auto&& e : v) cin >> e;
  sort(begin(v), end(v), greater<>());
  vector<int64_t> e(2);
  int ix(0);
  for (int i = 0; i < n; i++) {
    if (v[i] == e[ix]) ix++;
    else e[ix] = v[i];
    if (ix == 2) break;
  }
  cout << (ix == 2 ? e[0] * e[1] : 0) << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
     int mx=-1000000000,mi=10000000;
     int N=0;
     long sum=0;
     cin>>N;
     int a,i;
     for(i=0;i<N;i++)
     {
         
          cin>>a;
          sum+=a;
          if(mx<a){
              mx=a;
          }
          if(mi>a)
          {
              mi=a;
          }
          
     }
     cout<<mi<<" "<<mx<<" "<<sum<<"\n";
}


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

using namespace std;

typedef long long LL;
#define N 105

LL n,m,p,mod,ans,f[N][4][N][N],fac[N],ifac[N];

void upd(LL &x,LL y){x=(x+y)%mod;}

LL inv(LL x){return x==1?1:(mod-mod/x)*inv(mod%x)%mod;}

LL C(LL x,LL y){return fac[x]*ifac[y]%mod*ifac[x-y]%mod;}

int main(){
	scanf("%lld%lld%lld%lld",&n,&m,&p,&mod);
	if (n<m) swap(n,m);
	fac[0]=1; for (LL i=1;i<=n;++i) fac[i]=fac[i-1]*i%mod;
	ifac[n]=inv(fac[n]); for (LL i=n-1;~i;--i) ifac[i]=ifac[i+1]*(i+1)%mod;
	f[p+1][3][n][m]=1;
	for (LL i=p;i;--i){
		LL prd1,prd2;
		prd1=prd2=1;
		for (LL j=1;j<=n;++j) prd2=prd2*i%mod;
		for (LL j=0;j<=n;++j){
			LL tmp=1;
			for (LL l=0;l<=m;++l){
				LL t=tmp*ifac[l]%mod;
				for (LL k=l;k<=m;++k)
					upd(f[i][0][j][k-l],f[i+1][3][j][k]*t);
				tmp=tmp*prd1%mod*prd2%mod;
			}
			prd1=prd1*(p-i+1)%mod;
			prd2=prd2*inv(i)%mod;
		}
		prd1=prd2=1;
		for (LL k=1;k<=m;++k) prd2=prd2*i%mod;
		for (LL k=0;k<=m;++k){
			LL tmp=1;
			for (LL l=0;l<=n;++l){
				LL t=tmp*ifac[l]%mod;
				for (LL j=l;j<=n;++j)
					upd(f[i][1][j-l][k],f[i][0][j][k]*t);
				tmp=tmp*prd1%mod*prd2%mod;
			}
			prd1=prd1*(p-i+1)%mod;
			prd2=prd2*inv(i)%mod;
		}
		if (i>1){
			prd1=prd2=1;
			for (LL j=1;j<=n;++j) prd2=prd2*(i-1)%mod;
			for (LL j=0;j<=n;++j){
				LL tmp=1;
				for (LL l=0;l<=m;++l){
					LL t=tmp*ifac[l]%mod;
					for (LL k=l;k<=m;++k)
						upd(f[i][2][j][k-l],f[i][1][j][k]*t);
					tmp=-tmp*prd1%mod*prd2%mod;
				}
				prd1=prd1*(p-i+1)%mod;
				prd2=prd2*inv(i-1)%mod;
			}
			prd1=prd2=1;
			for (LL k=1;k<=m;++k) prd2=prd2*(i-1)%mod;
			for (LL k=0;k<=m;++k){
				LL tmp=1;
				for (LL l=0;l<=n;++l){
					LL t=tmp*ifac[l]%mod;
					for (LL j=l;j<=n;++j)
						upd(f[i][3][j-l][k],f[i][2][j][k]*t);
					tmp=-tmp*prd1%mod*prd2%mod;
				}
				prd1=prd1*(p-i+1)%mod;
				prd2=prd2*inv(i-1)%mod;
			}
		}
		else{
			memcpy(f[i][2],f[i][1],sizeof f[i][2]);
			memcpy(f[i][3],f[i][2],sizeof f[i][3]);
		}
	}
	ans=(f[1][3][0][0]*fac[n]%mod*fac[m]%mod+mod)%mod;
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 34688
#include <stdio.h>
int main(void) {
	int H, W, i, j;
	char name[6];
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) {
		for (j = 0; j < W; j++) {
			scanf("%s", name);
			if(!(strcmp(name, "snuke"))) {
				printf("%c%d\n", 'A' + j, i);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,la=0,x,a,k;
	long long ans=0;
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		k=max(0,a+la-x);
		ans+=k;
		la=a-k;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 50100
 
int prime[MAX-4];
 
void is_prime(){
    for(int i = 0 ; i < MAX ; i++) prime[i] = 0;
    prime[0] = prime[1] = 1;
    for(int i = 4 ; i < MAX ; i += 2) prime[i] = 1;
     
    for(int i = 3 ; i*i < MAX ; i++){
        if(prime[i]) continue;
        for(int j = i*2 ; j < MAX ; j+= i)
            prime[j] = 1;
    }
}
 
    int main(){
        int n;
         
        is_prime();
         
        while(true){
            cin >> n;
            if(!n) break;
             
            int cnt = 0;
            for(int i = 2 ; i <= n/2 ; i++){
                if(!prime[i]&&!prime[n-i]) cnt++;
            }
            cout << cnt << endl;
        }
         
        return 0;
    }

Measured memory_bytes: 1356
#include <climits>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
template <typename T, typename E>
struct SegmentTree {
	typedef function<T(T, T)> F;
	typedef function<T(T, E)> G;
	int n;
	F f;
	G g;
	T d1;
	E d0;
	vector<T> dat;
	SegmentTree(){};
	SegmentTree(int n_, F f, G g, T d1, vector<T> v = vector<T>()) : f(f), g(g), d1(d1) {
		init(n_);
		if (n_ == (int)v.size()) build(n_, v);
	}
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		dat.clear();
		dat.resize(2 * n - 1, d1);
	}
	void build(int n_, vector<T> v) {
		for (int i = 0; i < n_; i++) dat[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	void update(int k, E a) {
		k += n - 1;
		dat[k] = g(dat[k], a);
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	inline T query(int a, int b) {
		T vl = d1, vr = d1;
		for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) vl = f(vl, dat[(l++) - 1]);
			if (r & 1) vr = f(dat[(--r) - 1], vr);
		}
		return f(vl, vr);
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	int n, q;
	cin >> n >> q;
	SegmentTree<int, int> rmq(
	    n, [](int a, int b) { return min(a, b); }, [](int a, int b) { return b; }, INT_MAX);
	for (int i = 0; i < q; i++) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c)
			cout << rmq.query(x, y + 1) << endl;
		else
			rmq.update(x, y);
	}
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n;
	cin >> n;
	int a[n + 1];
	rep(i, 1, n) cin >> a[i];
	int cnt = 0;
	rep(i, 1, n) {
		if (i & 1 && a[i] & 1)
			cnt++;
	}
	cout << cnt;
}

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


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

	// test
	solve();

	return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int d[26] = {};
    rep(i, 0, s.size()){
        d[s[i] - 'a']++;
    }
    int ans = s.size() * (s.size() - 1) / 2 + 1;
    rep(i, 0, 26){
        if(d[i] == 0) continue;
        ans -= d[i] * (d[i] - 1) / 2;
    }
    cout << ans << endl;
    // set<string> st;

    // rep(i, 0, s.size()){
    //     rep(j, i + 1, s.size()){
    //         string t = s;
    //         reverse(t.begin() + i, t.begin() + j + 1);
    //         cout << i << " " << j << " " << t << " " ;            
    //         if(!st.count(t)){
    //             st.insert(t);
    //             cout << "not in" << endl;
    //         }else{
    //             cout << "in" << endl;
    //         }
    //     }
    // }
    // cout << st.size() << endl;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int N) {
    vector<string> S(N);
    for_each(ALL(S), [](string &s){cin >> s;});
    REP(i, N) {
        VI n{5, 7, 5, 7, 7};
        bool f = false;
        int id = 0;
        FOR(j, i, N) {
            n[id] -= (int)S[j].length();
            if (n[id] == 0) id++;
            if (n[id] < 0) break;
            if (id == 5) {
                f = true;
                break;
            }
        }
        if (f) {
            cout << i + 1 << endl;
            return;
        }
    }
    return;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n, n) {
        solve(n);
        //return 0;
    }
}

Measured memory_bytes: 3148
def main():
    IN = [int(_) for _ in input().split()]
    K = IN[1]
    N = IN[0]
    A = [int(_) for _ in input().split()]

    if K >= N:
        print(1)
        return

    v = int((N - 1) / (K - 1))
    if (N - 1) % (K - 1) == 0:
        print(v)
    else:
        print(v+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 13880
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#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;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int a, b;
	cin >> a >> b;
	if (a + b >= 10) cout << "error" << endl;
	else cout << (a + b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
        int n, k; cin >> n >> k;
        for (int x= 0; x < n; ++x){
            int q; cin >> q;
        }
        n = ceil((n-1) * 1.00 / (k-1));
        cout << n << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int maxH = 0;
    int count = 0;
    for (int i = 0; i < N; ++i) {
        int H;
        cin >> H;
        if (maxH <= H) {
            maxH = H;
            ++count;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
void main()
{
    int n = readln.chomp.to!int;
    int[] h = readln.split.to!(int[]);

    int hi;
    int[] cnt = [0];
    foreach (x; h)
    {
        if (x > hi)
        {
            cnt[$-1] = x;
        }
        else if (x < hi)
        {
            cnt[$-1] = hi - x;
            cnt ~= x;
        }

        hi = x;
    }

    cnt.sum.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int l[4] = { 1,-1,0,0 };
int r[4] = { 0,0,1,-1 };
char map[1010][1010];
int visited[1010][1010];
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++)
		for (int y = 1; y <= m; y++)
			scanf(" %1c", &map[i][y]);
	queue<pair<int, int>> qu;
	int xx = 0;
	for (int i = 1; i <= n; i++)
		for (int y = 1; y <= m; y++)
			if (map[i][y] == '#') {
				qu.push({ i,y });
				xx++;
			}
	int dap = 0;
	while (qu.size()) {
		int ps = qu.size();
		while (ps--) {
			int cx = qu.front().first;
			int cy = qu.front().second;
			qu.pop();
			for (int i = 0; i < 4; i++) {
				int nx = cx + r[i];
				int ny = cy + l[i];
				if (nx >= 1 && nx <= n && ny >= 1 && ny <= m&&map[nx][ny]=='.'&&!visited[nx][ny]) {
					qu.push({ nx,ny });
					visited[nx][ny] = 1;
				}
			}
		}
		dap++;
	}
	printf("%d\n", dap-1);
}

Measured memory_bytes: 11408
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
		cerr << (*i) << " ";
    }
    cerr << "\n";
}
int n;
int a[320000];

int main() {
	cin >> n;
	for (int i = 0; i < n * 3; ++i)
		cin >> a[i];
	sort(a, a + 3 * n);
	reverse(a, a + 3 * n);
	ll sum = 0;
	for (int i = 0; i < n; ++i)
		sum += a[2 * i + 1];
	cout << sum << "\n";
	return 0;
}




Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main (){
  COMinit();
  int S,hako=0;
  int ans=0;
  cin>>S;
  while(S>=3){
    S-=3;
    hako++;
    ans+=COM(S+hako-1,S);
    ans=ans%MOD;
  }
  cout<<ans;
}

Measured memory_bytes: 15520
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    int N, K;
    cin >> N >> K;
    vector<ll> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    ll ret = 0;
    rep(i, K) ret += v[i];
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3664