akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int N = 5e3 + 5;
const int mod = 1e9 + 7;
inline int pls( int a , int b ) { a += b - mod; return a + ( a >> 31 & mod ); }
inline int mns( int a , int b ) { a -= b; return a + ( a >> 31 & mod ); }
inline void inc( int & a , int b ) { a += b - mod; a += a >> 31 & mod; }
inline void dec( int & a , int b ) { a -= b; a += a >> 31 & mod; }

int A , B , n , ans;
int f[N] , g[N][2];

int main( void ) {
  cin >> n >> A >> B; 
  if( A > B ) swap( A , B );
  ans = 1;
  for( int i = 1 ; i <= n ; ++i ) ans = pls( ans , ans );
  if( B == 1 ) return printf("%d",ans) , 0;
  f[0] = 1;
  for( int i = 1 ; i <= B ; ++i ) {
    f[i] = f[i - 1];
    for( int j = A ; j <= i ; ++j ) {
      if( j ^ i ) inc( f[i] , f[i - j - 1] );
      else inc( f[i] , 1 );
    }
  }
  g[0][0] = 1;
  for( int i = 1 ; i < B ; ++i )
    g[i][0] = f[i - 1];
  for( int i = 1 ; i <= n ; ++i ) {
    for( int j = 1 ; j < B && j <= i ; ++j )
      inc( g[i][0] , 1LL * g[i - j][1] * ( j == 1 ? 1 : f[j - 2] ) % mod );
    for( int j = 1 ; j < A && j <= i ; ++j )
      inc( g[i][1] , g[i - j][0] );
  }
  dec( ans , g[n][1] );
  for( int i = 1 ; i < B && i <= n ; ++i )
    dec( ans , 1LL * g[n - i][1] * f[i - 1] % mod );
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 3756
/*
ABHIJEET BISWAS
CSE 4th SEM 
MNNIT ALLAHBAD
https://atcoder.jp/contests/dp/tasks/dp_p
*/
 
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define MAX 1000009
#define pb push_back
#define mp map<int,int>
#define f first
#define s second
#define popi __builtin_popcount
#define popll __builtin_popcountll
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ld pi=2.0*acos(0.0);
int dp[100008][2];
vector<int> graph[100008]; 
int n;
void dfs(int v,int p)
{
	for(int i=0; i<graph[v].size(); i+=1)
	{
		int u = graph[v][i];
		if(u!=p)
		dfs(u,v);
	}
	dp[v][0]=dp[v][1]=1;
	for(int i=0; i<graph[v].size(); i+=1)
	{
		int u = graph[v][i];
		if(p!=u)
		{
			dp[v][0]=(1LL*dp[v][0]*((dp[u][1]+dp[u][0])%MOD))%MOD;
			dp[v][1]=((1LL*dp[v][1]*dp[u][0]))%MOD;
		}
	}
}
int main() {
	fastIO
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		graph[x].pb(y);
		graph[y].pb(x);
	}
	dfs(1,-1);
	cout<<(dp[1][0]+dp[1][1])%MOD<<endl;
	return 0;
}

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

int main(void)
{
    string a;
    int n, c;
    while (cin >> a && a != "-") {
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> c;
            for(int j = 0; j < c; ++j) {
                a.push_back(*a.begin());
                a.erase(a.begin());
            }
        }
        cout << a << endl;
    }

    return 0;
}






Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

#if 1
//No.3
int main()
{
	UINT K, N;
	cin >> K >> N;

	UINT* A = new UINT[N];
	for (UINT i = 0; i < N; ++i) {
		cin >> A[i];
	}

	UINT minStart = 0;
	UINT minCost = 0xFFFFFFFF;
	for (UINT start = 0; start < N; ++start) {
		UINT cost;

		//時計回り
		if (start == 0) {
			cost = A[N - 1] - A[start];
		}
		else {
			cost = K - (A[start] - A[start - 1]);
		}
		minCost = min(minCost, cost);

		//反時計回り
		if (start == N - 1) {
			cost = A[start] - A[0];
		}
		else {
			cost = K - (A[start + 1] - A[start]);
		}
		minCost = min(minCost, cost);
	}

	cout << minCost;

	delete[] A;
	return 0;
}
#endif

Measured memory_bytes: 1024
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 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...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    int N;
    cin>>N;
    vl P(N);
    vl num_idx(N,0);
    REP(i,N){
        cin>>P[i];
        P[i]--;
        num_idx[P[i]]=i;
    }
    int cnt=1;
    int ans=N-1;
    REP(i,num_idx.size()-1){
        if(num_idx[i+1]>num_idx[i]) cnt++;
        else{
            cnt=1;
        }
        ans=min(ans,N-cnt);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 6432
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int n,st[100005],in;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        scanf("%d",&in);
        st[in - 1] = i;
    }
    for(int i = 0;i < n;i++){
        printf("%d",st[i]);
        printf(" ");
    }
    printf("\n");
    return(0);
}




Measured memory_bytes: 1152
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define why         (ll)1000000007
//#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod){
    ll result=1;
    while(power){
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod){
    return fast_power(base,mod-2,mod);
}


ll solve(){
    ll k; cin>>k;
    ll a,b; cin>>a>>b;
    lp(i,a,b+1) if(i%k == 0){
        cout<<"OK";
        return 0;
    }
    cout<<"NG";
    return 0;
}

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3652
five_hnd = int(input())
one_hnd = int(input())
fifty = int(input())
target = int(input())
num = 0
for i in range(five_hnd + 1):
  for j in range(one_hnd + 1):
    for k in range(fifty + 1):
      sum = 500*i + 100*j + 50*k
      if (sum) == target :
        num +=1
print(num)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> v;
    for (int i = a; i < a + k && i <= b; ++i) {
        v.insert(i);
    }
    for (int i = b; i > b - k && i >= a; --i) {
        v.insert(i);
    }
    for (int i : v) {
        cout << i << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        a: [u32; n],
    }
    let mut ans = 0;
    for i in 0..n {
        if a[i] < a[ans] {
            ans = i;
        }
    }
    println!("{}", ans + 1);
}

fn main() {
    run();
}



Measured memory_bytes: 5032
#include <stdio.h>
#include <cmath>
typedef long long ll;
typedef long double ld;
using namespace std;
int main(){
    ll x, y;
    scanf("%lli %lli", &x, &y);
    ll temp =  y / x;
    ll cnt = 0;
    while(temp){
        ++cnt;
        temp >>= 1;
    }
    printf("%lli", cnt);
}

Measured memory_bytes: 128
s = input()
t = input()
sl = len(s)
tl = len(t)
res = list(s)

def check(s1, s2):
    for i in range(len(s1)):
        if s1[i] == '?':
            continue
        if s1[i] != s2[i]:
            return False
    return True

for i in range(sl-tl, -1, -1):
    if check(s[i: i+tl], t):
        res[i: i+tl] = t
        res = ['a' if s == '?' else s for s in res]
        break
else:
    res = list('UNRESTORABLE')

print(''.join(res))

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

#ifdef LOCAL

template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<template<class, class...> class C, class... A>
typename enable_if<!is_same<C<A...>, string>::value, ostream&>::type
operator<<(ostream& os, const C<A...> &c) {
	auto i = c.begin();
	while (i != c.end()) {
		os << " {"[i == c.begin()] << *i;
		os << ",}"[++i == c.end()];
	}
	return os;
}

#define debug(x) cerr << #x << " = " << x << endl;

#else
#define debug(...) {}
#endif

const int N = 1e6 + 5;

#define st first
#define nd second

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

char slo[N];

int dp[N];

map<int,int> best;

int main() {
	scanf("%s", slo);
	int maska = 0;
	for (int i = 0; slo[i]; i ++) {
		maska ^= (1<<(slo[i] - 'a'));
		dp[i] = N;
		for (int j = 0; j <= 'z' - 'a'; j ++) {
			if ((maska == (1<<j)) || best[maska ^ (1<<j)] != 0) {
				dp[i] = min(best[maska ^ (1<<j)], dp[i]);
			}
			if (maska == 0 || best[maska] != 0) dp[i] = min(dp[i], best[maska]);
		}
		dp[i] ++;
		best[maska] = min(best[maska], dp[i]);
		if (best[maska] == 0 && maska != 0) best[maska] = dp[i];;
		debug(i);
		debug(dp[i]);
	}
	printf("%d\n", dp[strlen(slo) - 1]);
}


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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD1 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int H,W; cin>>H; cin>>W;
  int A,B; cin>>A; cin>>B;
  vector<vector<int> > res (H,vector<int>(W,0));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      res[i][j] = (i<B)^(j<A);
    }
    
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cout<<res[i][j];
    }
    cout<<endl;
  }
  
  

  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 11068
#include<stdio.h>
int main()
{
    long long l,m,n,sum=0;
    int i,j,k;
    scanf("%lld %lld %lld",&l,&m,&n);
    long long a[l][m],b[m][n],c[l][n];
    for(i=0;i<l;i++){
        for(j=0;j<m;j++){
            scanf("%lld",&a[i][j]);
        }
    }
     for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            scanf("%lld",&b[i][j]);
        }
    }
    for(i=0;i<l;i++){
        for(j=0;j<n;j++){
            for(k=0;k<m;k++){
                sum=sum+(a[i][k]*b[k][j]);
            }
            c[i][j]=sum;
            sum=0;
        }
    }
    for(i=0;i<l;i++){
        for(j=0;j<n-1;j++){
            printf("%lld ",c[i][j]);
        }
        printf ("%lld\n",c[i][j]);
    }
    return 0;
}




Measured memory_bytes: 2108
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    A = input([[int, 3], 3])
    N = input(int)
    B = input([int, N])

    ans = 0
    for x in range(3):
        for y in range(3):
            if A[x][y] not in B:
                break
        else:
            ans += 1
    for y in range(3):
        for x in range(3):
            if A[x][y] not in B:
                break
        else:
            ans += 1
    for z in range(3):
        if A[z][z] not in B:
            break
    else:
        ans += 1
    for z in range(3):
        if A[z][2 - z] not in B:
            break
    else:
        ans += 1
    yesno(not ans == 0)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

using namespace std;

typedef pair<int, int> ii;
const int N = 5e3 + 10;
int f[N][N];
int t[N][N];
int main() {
    string s0, s1;
    cin >> s0 >> s1;
    int n = s0.length(), m = s1.length();

    for(int i = n - 1; i >= 0; i--) 
        for(int j = m - 1; j >= 0; j--)
            if (s0[i] == s1[j]) {
                f[i][j] = f[i + 1][j + 1] + 1;
            } else {
                f[i][j] = f[i + 1][j];
                if (f[i][j] < f[i][j + 1]) {
                    f[i][j] = f[i][j + 1];
                    t[i][j] = 1;
                }
            }
    for(int i = 0, j = 0; i < n && j < m;) {
        if (s0[i] == s1[j]) {
            cout << s0[i];
            i++, j++;
        }else {
            if (t[i][j]) j++;
            else i++;
        }
    }
}


Measured memory_bytes: 120448
#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[i];
  }
  int sum = 0;
  vector<int> B(N);
  for (int i=0; i < N; i++) {
    sum += A[i];
  }
  int sumA = 0;
  for (int k=0; k < N; k++) {
    sumA += A[k];
    B[k] = sum - (sumA * 2);
    if (B[k] < 0) {
      B[k] *= -1;
    }
  }
  sort(B.begin(), B.end());
  cout << B[0];
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int m,ans;
	cin>>m;
	ans=48-m;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        long N = sc.nextLong();
        HashMap<Long,Integer> prime = primeFactor(N);
        
        for(long key:prime.keySet()){
            if(prime.get(key)>0){
                long val = prime.get(key);
                int ck = 1;
                while(val>=ck){
                    val-=ck;
                    ck++;
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }

    
    public static HashMap<Long,Integer> primeFactor(long n) {
        final HashMap<Long,Integer> list = new HashMap<Long,Integer>();
        if (n < 2) {
            return list;
        }

        int two=0;
        while (n != 1 && n % 2 == 0) {
            //list.put(2l, list.getOrDefault(2l, 0)+1);// add(2l);
            two++;
            n >>>= 1;
        }
        list.put(2l,two);

        for (long i = 3; i * i <= n; i += 2) {
            if(n%i==0){
                int cnt = 0;
                while (n % i == 0) {
                    cnt++;
                    n /= i;
                }
                list.put(i,cnt);
            }
        }

        if (n != 1) {
            list.put(n,1);
        }
        return list;
    }

}


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


int main(){
    int n, ans = 0;
    cin >> n;
    rep(i,n){
        int l, r;
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    ll n, m, ans = 0; cin >> n >> m;
    vector<pll> v(m);
    rep(i, m){
        ll a, b; cin >> a >> b; a--, b--;
        v[i] = pll(b, a);
    }
    sort(all(v));
    ll bre = -1;
    rep(i, m){
        if(v[i].second >= bre){
            ans++;
            bre = v[i].first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4824
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;


class BIT{
	int N;
	vector<int>bit;
	void add_(int x,int y){
		while(x<=N){
			bit[x]+=y;x+=x&-x;
		}
	}
	int sum_(int x){
		int res=0;
		while(x>0){
			res+=bit[x];x-=x&-x;
		}
		return res;
	}
public:
	int lower_bound(int w){
		if(w<=0)return -1;
		int x=0;
		int k=1;while(k*2<=N)k*=2;
		for(;k>0;k/=2){
			if(x+k<=N&&bit[x+k]<w){
				w-=bit[x+k];
				x+=k;
			}
		}
		return x;
	}
	void add(int x,int y){add_(x+1,y);}
	int sum(int l,int r){return sum_(r)-sum_(l);}
	BIT(int x):N(x),bit(x+1){}
};
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,Q;cin>>N>>Q;
	BIT bit(N);
	rep(i,N){int a;cin>>a;bit.add(i,a);}
	while(Q--){
		int t;cin>>t;
		if(!t){
			int p,x;cin>>p>>x;bit.add(p,x);
		}else {
			int l,r;cin>>l>>r;cout<<bit.sum(l,r)<<"\n";
		}
	}
}

Measured memory_bytes: 8256
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;

int main(){
    int N,K;
    cin>>N>>K;
    if(K==1) cout<<"0"<<endl;
    else{
        int n=N-K;
        cout<<n<<endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, d, x[10][10];

int main() {
	cin >> n >> d;
	inc(i, n) {
	inc(j, d) {
		cin >> x[i][j];
	}
	}
	
	int ans = 0;
	inc(i, n) {
	inc(j, i) {
		int s = 0;
		inc(k, d) { s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]); }
		int t = sqrt(s);
		if(t * t == s) { ans++; }
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

vector<vector<int>> d, c;
vector<vector<int>> conv;

int n, C;
ll calc(void) {
  ll res = INF;
  rep(i, C) rep(j, C) if(i != j) rep(k, C) if(i != k && j != k) {
    ll discomfort = 0;
    rep(l, C) discomfort += d[l][i] * conv[0][l];
    rep(l, C) discomfort += d[l][j] * conv[1][l];
    rep(l, C) discomfort += d[l][k] * conv[2][l];
    res = min(res, discomfort);
  }
  return res;
}

int main(){
  
  cin >> n >> C;
  d.resize(C, vector<int>(C));
  c.resize(n, vector<int>(n));
  conv.resize(3, vector<int>(C));
  rep(i, C)rep(j, C) {
    int a;
    cin >> a;
    d[i][j] = a; 
  }
  rep(i, n)rep(j, n) {
    int a;
    cin >> a;
    --a;
    c[i][j] = a;
  }
  rep(i, n) {
    rep(j, n) {
      int remainder = (i + j + 2) % 3;
      conv[remainder][c[i][j]]++;
    }
  }
  ll ans = 0;
  ans += calc();
  cout << ans << endl;


}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N; cin >> N;
    for(ll h=1;h<=3500;h++){
        for(ll n=1;n<=3500;n++){
            if(4*h*n-N*(n+h) <= 0) continue;
            ll ch = N*h*n;
            ll mo = 4*h*n-N*(n+h);
            if(ch % mo == 0){
                cout << h << " " << n << " " << ch/mo << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=5e5+5;
const ll mod=1e9+7;
int main()
{
    int i,j;
    ll x,y;
    cin>>x>>y;
    int ans=0;
    while(x)
    {
        ans++,x/=y;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(){
  int N,L;
  cin >> N >> L;
  int apple[N];
  int sum = 0;
  for(int i = 0; i < N; i++){
    apple[i] = L + i;
    sum += apple[i];
  }

  if(apple[N - 1] <= 0) sum -= apple[N - 1];
  else if(apple[0] >= 0) sum -= apple[0];

  cout << sum << endl;


 
  return 0;
}






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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;//T

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y




}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  /*場所を探している*/
  while(x != NIL){
    y = x;
    if (z->key < x->key)
    x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if (y == NIL)
  root = z;
  else if(z->key < y->key)
    y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u != NIL) {
    if(u->left != NIL) inorder(u->left);
    printf(" %d",u->key);
    if(u->right != NIL) inorder(u->right);
  }
}
void preorder(Node u){ 
  if(u != NIL) {
    printf(" %d",u->key);
    if(u->left != NIL) preorder(u->left);
    if(u->right != NIL) preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};

int main() {
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  ll ans = 1e17;
  ans = min(ans, N * 4 * Q);
  ans = min(ans, N * 2 * H);
  ans = min(ans, N * S);
  if (2 <= N) {
    ll d = N / 2;
    N %= 2;
    ans = min(ans, d * D + N * 4 * Q);
    ans = min(ans, d * D + N * 2 * H);
    ans = min(ans, d * D + N * S);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {

            string str = Console.ReadLine();
            char[] ch = str.ToCharArray();

            int result = 0;
            char prev = '0';
            for(int i=0;i<ch.Length;i++)
            {
                if (i == 0 || ch[i] != prev)
                {
                    result++;
                    if (prev != '1')
                    {
                        prev = ch[i];
                    } else
                    {
                        prev = '0';
                    }
                }
                else {
                    prev = '1';
                }
            }
            Console.WriteLine(result);
        }


    }
}

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

struct cand {
  int u, n;
};

vector<vector<int>> dist;
vector<vector<int>> adj;
queue<cand> q;

void kkp(int n, int i, int u) {
  if(dist[u][i] != -1) return;

  dist[u][i] = n;
  if(i == 0) {
    q.push(cand{u, n});
    return;
  }

  for(auto v: adj[u]) kkp(n, i-1, v);
}

int main () {
  int N, M;
  cin >> N >> M;
  adj = vector<vector<int>>(N+1);

  rep(i,M) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
  }

  int S, T;
  cin >> S >> T;

  dist = vector<vector<int>>(N+1, vector<int>(4, -1));
  q.push(cand{S, 0});

  while(!q.empty()) {
    cand c = q.front(); q.pop();
    kkp(c.n + 1, 3, c.u);
  }

  cout << dist[T][0] << endl;

  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		double m,e,j;
		rep(i,0,n){
			cin>>m>>e>>j;
			if(max(m,max(e,j))==100) o('A');
			else if(m+e>=180) o('A');
			else if(m+e+j>=240) o('A');
			else if(m+e+j>=210) o('B');
			else if(m+e+j>=150 && max(m,e)>=80) o('B');
			else o('C');
		}

	}
}

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

int main() {
    int p, q, r;  cin >> p >> q >> r;
    cout << (p+q+r) - max({p,q,r}) << endl;
}

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

template <typename T>
struct Diameter {
    struct Edge {
        int to;
        T cost;
        Edge(int to, T cost) : to(to), cost(cost) { }
    };
    typedef pair< T, int > P;
    vector<vector<Edge>> graph;
    int v;
    Diameter(int v) : v(v), graph(v) { }
    T calc() {
        P f = dfs(0, -1);
        P s = dfs(f.second, -1);
        return s.first;
    }
    void add_edge(int start, int to, T cost) {
        graph[start].emplace_back(to, cost);
        graph[to].emplace_back(start, cost);
    }
    P dfs(int id, int parent) {
        P ret = make_pair((T)0, id);
        for (Edge e : graph[id]) {
            if (e.to == parent) continue;
            auto next = dfs(e.to, id);
            next.first += e.cost;
            ret = max(ret, next);
        }
        return ret;
    }
};

/*
    verified https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_5_A
*/
int main() {
    int n; cin >> n;
    Diameter<int> diameter(n);
    for (int i = 0; i < n - 1; ++i) {
        int s, t, w; cin >> s >> t >> w;
        diameter.add_edge(s, t, w);
    }
    cout << diameter.calc() << endl;
}



Measured memory_bytes: 12748
'use strict';
function main(input) {
  let a = Number(input.trim().split('\n'));
  const Five = Math.floor(a / 500);
  a -= (500 * Five);
  const five = Math.floor(a / 5);
  
  console.log(1000 * Five + 5 * five);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7624
#include<cstdio>/*c++输入输出*/
#include<iostream>/*c++输入输出*/
#include<cmath>//c++数学 函数
#include<algorithm>//c++算法
#include<cstring>//字符串
#include<map>//数组
#include<queue>//队列
#include<stack>//栈
using namespace std;//……
char s[30];
int vis[125];
int main(){
    scanf("%s",s + 1);
    int l = strlen(s + 1);
    for(int i = 1 ; i <= l; i++){
        vis[s[i] - '0']++;
        if(vis[s[i] - '0'] > 1){
            printf("no");
            return 0;
        }
    }
    printf("yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    string s;
    cin >> s;

    vector<pair<char, ll>> vec;
    char tmp = s.at(0);
    ll count = 0;
    rep(i,s.size()){
        if(tmp != s.at(i)){
            vec.push_back(make_pair(tmp, count));
            tmp = s.at(i);
            count = 1;
        }else{
            count++;
        }
    }
    vec.push_back(make_pair(tmp, count));

    /*
    rep(i,vec.size()){
        cout << vec[i].first << " " << vec[i].second << endl;
    }
    */

    vector<ll> ans(s.size());
    ll sum = 0;

    for(ll i = 0; i <= vec.size() - 2; i+=2){
        ll r = vec[i].second;
        ll l = vec[i+1].second;

        if(r % 2 == 0){
            ans[sum+r] += r / 2;
            ans[sum+r-1] += r / 2;
        }else{
            ans[sum+r] += r / 2;
            ans[sum+r-1] += (r / 2) + 1;
        }

        if(l % 2 == 0){
            ans[sum+r] += l / 2;
            ans[sum+r-1] += l / 2;
        }else{
            ans[sum+r] += (l / 2) + 1;
            ans[sum+r-1] += l / 2;
        }

        /*
        cout << "sum = " << sum << " i = " << i << "-----------" << endl;
        rep(i,s.size()){
            cout << ans[i] << " ";
        }
        cout << endl;
        */
       
        sum += (r + l);
        
    }

    rep(i,s.size()){
        cout << ans[i] << " ";
    }
    cout << endl;

}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;
const ll mod = 1000000007;

int main()
{
  string s; cin>>s;
  int n = s.size();
  vector<vector<ll>> dp(n+1, vector<ll>(13, 0));
  dp[0][0] = 1;
  rep(i, n) {
    rep(j, 13) {
      if (s[i] == '?') {
        rep(x, 10) (dp[i+1][(j*10+x)%13] += dp[i][j]) %= mod;
      } else {
        int x = s[i]-'0';
        (dp[i+1][(j*10+x)%13] += dp[i][j]) %= mod;
      }
    }
  }
  cout << dp[n][5] << endl;

  return 0;
}


Measured memory_bytes: 13696
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

const int MAX_N = 100010;
int N;
LL h[MAX_N];
LL dp[MAX_N];

int main()
{
    cin >> N;
    REP(i, N) cin >> h[i];
    dp[N - 1] = 0;
    dp[N - 2] = abs(h[N - 2] - h[N - 1]);
    for (int i = N - 3; i >= 0; --i)
    {
        dp[i] = min(dp[i + 1] + abs(h[i] - h[i + 1]), dp[i + 2] + abs(h[i] - h[i + 2]));
    }
    cout << dp[0] << endl;
    return 0;
}

Measured memory_bytes: 1792
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $route = [];
  for ($i=0; $i<$n; $i++) {
    $route[$i] = [];
  }

  for ($i=0; $i<$m; $i++) {
    list($x, $y) = explode(" ", trim(fgets(STDIN)));
    $route[$x][] = $y;
    $route[$y][] = $x;
  }

  $marked = [];
  $q = new SplQueue();
  $q->enqueue(1);
  $marked[1] = true;
  while($q->count() > 0){
    $k = $q->dequeue();
    //echo $k." ";
    //var_dump($route[$k]);
    foreach($route[$k] as $value){
      if(isset($marked[$value])){
        continue;
      }
      $q->enqueue($value);
      //echo "value:".$value." ".$k;
      $marked[$value] = $k;
    }
  }

  echo "Yes".PHP_EOL;
  for($i=2; $i<=$n; $i++){
    echo $marked[$i].PHP_EOL;
  }

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

int main(){
  int a,sum,k,l,sta,suc,h[50],han[5]={5,7,5,7,7};
  string s;
  while(cin>>a){
    if(a==0)break;
    for(int i=0;i<a;i++){
      cin>>s;
      h[i]=s.size();
    }
    suc=0;
    for(int i=0;i<a;i++){
      sum=0;k=0;l=0;
      while(1){
	sum+=h[i+k];
	  if(sum==han[l]){
	    l++;
	    sum=0;
	  }else if(sum>han[l])break;
	if(l==5){
	  suc=1;
	  break;
	}
	k++;
	if(k>=a)break;
      }
      if(suc==1){
	sta=i;
	break;
      }
    }
    cout<<sta+1<<endl;
  }
  return 0;
}

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

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

  vector<ll> A(N + 1);
  for (int i = 2; i <= N; i++) cin >> A[i];

  map<ll, ll> m;

  for (int i = 2; i <= N; i++) {
    m[A[i]] ++;
  }

  for (ll i = 1; i <= N; i++) {
    cout << m[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 17248
import collections
N,K = map(int,input().split())

J = []
for i in range(K):
    d = int(input())
    A = [int(g) for g in input().split()]
    J.extend(A)
    i = i + 1
    
j = collections.Counter(J)
ans = N - len(j)

print(ans)

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

int main() {
  int m,n;
  cin >> n >> m;
  int a[n];
  int total = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    total += a[i];
  }
  int c = 4 * m;
  int b = (total + (c-1)) / c;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(b <= a[i]){
      cnt++;
    }
  }
  if(cnt >= m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int N; cin >> N;
	vector<vector<int>> F(N,vector<int>(10)),P(N,vector<int>(11));
	rep(i,N)rep(j,10) cin >> F[i][j];
	rep(i,N)rep(j,11) cin >> P[i][j];

	int ans = -INF;
	repr(i,1,1<<10){
		int now = 0;
		rep(j,N){
			int cnt = 0;
			rep(k,10){
				if((i >> k & 1) && F[j][k] == 1) cnt++;
			}
			now += P[j][cnt];
		}
		ans = max(ans,now);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll N; cin>>N;
	string s;
	while(N)
		s+='a'+(N-1)%26, N--, N/=26;
	reverse(s.begin(),s.end());
	cout<<s<<"\n";
	return 0;
}

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

int main(){
  int a,b,answer;
  char op;
  
  while(!(op=='?')){
    cin >> a >> op >> b;
    if(op=='?'){
      break;
    }
    
    else if(op=='+'){
      answer = a + b;
    }
    else if(op=='-'){
      answer = a - b;
    }
    else if(op=='*'){
      answer = a * b;
    }
    else if(op=='/'){
      answer = a / b;
    }
    
    cout << answer<<endl;
  }
  return 0;
  
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a) (a).begin(), (a).end()

int divide_count(int n){
	int count = 0;
	while(n){
		if(n % 2 == 0) ++count;
		else return count;
		n /= 2;
	}
	return count;
}

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	int total = 0;
	rep(i, n){
		total += divide_count(a[i]);
	}
	cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  rep(i,N){
    cin >> A.at(i);
  }
  
  int deny_or_not = 0;
  
 rep (i,N){
   if(A.at(i) % 2 == 0){
     if(A.at(i) % 5 == 0 || A.at(i) % 3 == 0){
     }else{
       deny_or_not = 1;
     }
   }
     
 }
  
  if (deny_or_not == 0){
     cout << "APPROVED";
   }else{
     cout << "DENIED";
   }
  
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  int sum = 1;
  if (N > 1) {
    for (int i = 0; i < N-1; i++) {
      if (vec.at(i) != vec.at(i+1)) {
        sum++;
      }
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b;
  cin >> a >> b;
  ll ans=0;
  if(a<b) ans+=b,b--;
  else ans+=a,a--;
  ans+=max(a,b);
  cout << ans << endl;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
// const ll MOD = 998244353;
const double PI=3.14159265358979323846;



int main() {
    int n; cin >> n;
    int m = 0;
    rp(i, 1, 500) {
        if(2 * n == i * (i+1)) {
            m = i;
        }
    }
    if(m == 0) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << m+1 << endl;

    vector<vector<int>> res(m+1, vector<int>(m));
    int now = 0;
    int k = 1;
    while(now < m) {
        rp(i, now, m) {
            res[now][i] = k;
            res[i+1][now] = k;
            k++;
        }
        now++;
    }
    for(auto x: res) {
        cout << m;
        for(auto y: x) {
            cout << " " << y;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3844
#include<bits/stdc++.h>
const double PI=3.14159265358979323846;
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(void){
    int n;cin>>n;
    int h[n];rep(i,n)cin>>h[i];
    reverse(h, h+n);
    int before = h[0];
    rep1(i,n-1){
        if(before<h[i]-1){
            co("No");return 0;
        }
        else if(before == h[i]-1){
            before = h[i]-1;
        }
        else{before=h[i];}
    }
    co("Yes");
}

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

int main()
{
	int n;
	int i;
	
	cin >> n;
	
	for(i=1;i<=n;i++){
		if(i%3==0)
			cout << ' ' << i;
		else if(i%10==3)
			cout << ' ' << i;
		else if((i/10)%10==3)
			cout << ' ' << i;
		else if((i/100)%10==3)
			cout << ' ' << i;
		else if((i/1000)%10==3)
			cout << ' ' << i;
	}
	cout << endl;
	
	return 0;
}

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

using namespace std ;

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

   int n, k, v ;
   cin >> n >> k ;
   for(int i = 0 ; i < n ; i++){
     cin >> v ;
   }

   int cn = 0 ;
   for(int i = 1 ; i < n ; i += k - 1){
        cn++ ;
   }

   cout << cn;

}


Measured memory_bytes: 256