akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int cnt=0;
    while(n>0){
        cnt++;
        n/=k;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> A(n);
    rep(i,n)cin>>A[i];
    for(int i=k+1;i<=n;i++){
        int p=i-1;
        if(A[p-k]<A[p])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 4828
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10000005];
ll b[10000005];
int dp[10005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
string s[200005];
int main() {
	int ans = inf;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> dp[i][j];
			ans = min(ans, dp[i][j]);
		}
		a[i] = ans;
		ans = inf;
	}
	for (int i = 0; i < 3; i++) {
		b[i] = dp[0][i] - a[0];
	}
	for (int i = 1; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (dp[i][j] != a[i] + b[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 7936
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
c = [0]*n
for i in range(n):
    b[i] = a[i]-i
for i in range(n):
    c[i] = a[i]+i
cb = Counter(b)
cc = Counter(c)
k=cb.keys()
ans = 0
for i in k:
    ans += cb[i]*cc[i*(-1)]
print(ans)


Measured memory_bytes: 63464
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
   ll n,m;
   cin>>n>>m;
   ll cc=0;
   ll k=1;
   while(k<m){
    k--;
    k+=n;
    cc++;
   }
   cout<<cc<<endl;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 100000000;
  for (int i=0;i<N;i++){
  	int a;
    cin >> a;
    int j = 0;
    while (a%2==0){
      a /= 2;
      j++;
    }
    if (ans > j) ans = j;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
import fractions

# 最小公倍数lcm（ least common multiple）を返す関数は用意されていない
# が、lcm(a, b) = a * b / gcd(a, b)で求められる

A, B = map(int, input().split())
ans = A * B // fractions.gcd(A, B)
print(ans)


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

using namespace std;

int main(){
    int n,a,mini,ans = -(1<<30);
    cin >> n >> mini;
    for (int i =0; i<n-1; i++){
        cin >> a;
        if (ans < a - mini) ans = a-mini;
        if (mini>a) mini = a;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define scn(n) scanf("%d",&n)
const int N=2e5+4;
using namespace std;

int k,n;
int arr[N];
bool possible(int mid){
    int total=0;
    
    for(int i=0;i<n;i++)
    {
        int cut = (arr[i]+mid-1)/mid;
        cut--;
        total+=cut;
    }
    
    return total<=k;
}

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

    int mx=-1;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        mx = max(mx,arr[i]);
    }
    
    sort(arr,arr+n);
    
    int low=1,high=mx;
    
    while(low<high){
        int mid = (low+high)/2;
        
        if(possible(mid))
        high=mid;
        
        else
        low=mid+1;
    }
    cout<<low;
	return 0;
}

Measured memory_bytes: 4320
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a,b;
    cin>>n>>m;
    b=n*m;
    if(b%2==0)
    {
        cout<<"Even"<<endl;
    }
    else
    {
        cout<<"Odd"<<endl;
    }


}


Measured memory_bytes: 3516
#include <iostream>

using namespace std;

int strcomp(char *c1, char *c2, int l);
int partition(char **input_array, int i, int j, char *div, int l);
int quickSort(char **input_array, int i, int j, char *div, int l);

int main(){
  
  int n, l;
  char **input_array;
  
  cin >> n >> l;
  // n = 3;
  // l = 3;
  
  input_array = new char*[n];
  for (int i=0; i<n; i++){
    input_array[i] = new char[l];
  }

  for(int i=0; i<n; i++){
    cin >> input_array[i];
  }

  // char init_array[][4] = {"dxx", "axx", "cxx"};
  // for(int i=0; i<n; i++){
  //   for (int j = 0; j < l; j++){
  //     input_array[i] = init_array[i];
  //   }
  // }

  quickSort(input_array, 0, n-1, input_array[0], l);
  
  for(int i=0; i<n; i++){
    if(i==n-1){
      cout << input_array[i] << endl;
    } else{
      cout << input_array[i];
    }
  }
  
  delete[] input_array;
  return 0;
}

int strcomp(char *c1, char *c2, int l){
  for(int j=0; j<l; j++){
    if(c1[j]<c2[j]){
      return 1;
    }
    else if(c1[j]>c2[j]){
      return -1;
    }
  }
  return 0;
}

int partition(char **input_array, int i, int j, char *div, int l){
  int left, right;
  char *temp;
  if(i>j){
    cout << "inputed index is invaild. l must be larger than i" << endl;
    return -2;
  } else if(i==j){
    // cout << "sorting is completed" << endl;
    return -1;
  } else{
    left=i;
    right=j;
    while(left<=right){
      for (int k = left; k < j; k++)
      {
        if(strcomp(input_array[k], div, l)>0){
          left++;
        } else{
          break;
        }
      }
      

      for (int k = right; k > i; k--)
      {
        if(strcomp(input_array[k], div, l)<=0){
          right--;
        } else{
          break;
        }
      }
      
      if(left>right){
        break;
      } else{
        temp = input_array[right];
        input_array[right] = input_array[left];
        input_array[left] = temp;
        left++;
        right--;
      }
    }
  }
  return left;
}

int quickSort(char **input_array, int i, int j, char *div, int l){
  int next_left = partition(input_array, i, j, div, l);
  if(next_left<0){
    return next_left;
  } else{
    quickSort(input_array, i, next_left-1, input_array[i], l);
    quickSort(input_array, next_left, j, input_array[next_left], l);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    int n; cin >> n;
    vector<pair<string, int>> v(n);
    for(int i = 0; i < n; i++)
    {
        string s; cin >> s;
        int t; cin >> t;
        v[i] = make_pair(s, t);
    }
    string s; cin >> s;
    bool flag = false;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(flag) ans += v[i].second;
        if(v[i].first == s)
        {
            flag = true;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int> >g1(n + 3), g2(n + 3);
    for(int i = 1; i <= n; i++){
        int p;
        cin >> p;
        for(int j = 1; j <= p; j++){
            int u, v;
            cin >> u >> v;
            if(v == 1){
                g1[i].push_back(u);
            }
            else{
                g2[i].push_back(u);
            }
        }
    }
    int q = 1;
    for(int i = 1; i <= n; i++){
        q = q * 2;
    }
    int ans = 0;
    for(int i = 0; i < q; i++){
        set<int>st1;
        int j = i;
        for(int k = 1; k <= n; k++){
            if(j % 2 == 1){
                st1.insert(k);
            }
            j = j/2;
        }
        set<int>st2 = st1;
        set<int>st3 = st1;
        set<int>::iterator it;
        for(it = st1.begin(); it != st1.end(); it++){
            int u = *it;
            for(int k = 0; k < g1[u].size(); k++){
                st2.insert(g1[u][k]);
            }
            for(int k = 0; k < g2[u].size(); k++){
                st3.erase(g2[u][k]);
            }
        }
        if(st1 == st2 && st1 == st3){
            int r = st1.size();
            ans = max(ans, r);
        }
    }
    cout << ans;
    return 0;
}

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

int main(){
    int k;
    int n;
    cin >> k;
    cin >> n;
    int a[n];
    int b[n]; //家と家との距離
    int l = 0;
    for (int i=0; i<n; i++) {
      cin >> a[i];
    }
    for (int h=0; h<n; h++) {
        if (h != n-1){
          b[h] = a[h+1] - a[h]; //(i+1)番目と(i+2)番目との距離
          }
        else{
          b[h] = k + a[0] - a[h]; //n番目と1番目との距離
        }
    }
    //家と家との距離の最大値を求める
    for (int j=0; j<n; j++){
        if (b[j] >= l){
            l = b[j];
        }
        else{
        }
    }
    cout << k - l << endl;
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
//const int INF = INT_MAX  ;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

typedef pair<int, char> PC;

int main() {
//    vector<int> f(5);
    int has = 10;
    int ans = 0;
    rep(i, 5) {
        int c;
        cin >> c;

        if (c % 10 != 0) {
            has = min(c % 10, has);
        }

        int d = ((c + 9) / 10) * 10;
        ans += d;
    }

    cout << ans - 10 + has << endl;

}



Measured memory_bytes: 256
N = int(input())
ans = [0] * (N + 5)
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if N >= tmp:
                ans[tmp] += 1

for i in range(1, N+1):
    print(ans[i])


Measured memory_bytes: 9372
N, A, B = map(int, input().split())
sum_num = 0
for i in range(0, N + 1):
  num = i
  digit_list =[]
  while num > 0:
    digit_list.append(num%10)
    num //= 10
  if (A <= sum(digit_list)) and (sum(digit_list) <= B):
    sum_num += i
print(sum_num)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    VAR(i64, N, K);
    i64 ans = K;
    rep(i, 0, N-1) {
        ans *= (K - 1);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
n = int(input())
t = [False]*(n+1)
t[0] = True
l = [int(i) for i in input().split()]
ans = 0
for i in range(n):
  x = l[i]
  if t[x-1]:
    t[x] = True
    ans = max(ans, x)
print(n-ans if ans > 0 else -1)

Measured memory_bytes: 26280
S = input()
q = False

for i in range(1 << 4):
    s = list('aKIHaBaRa')
    for j in range(4):
        flag = (i >> j) & 1
        if flag:
            if j == 0:
                s[0] = 'A'
            elif j == 1:
                s[4] = 'A'
            elif j == 2:
                s[6] = 'A'
            else:
                s[8] = 'A'
    s = ''.join(s)
    s = s.replace('a','')
    if s == S:
        q = True

if q:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
N,M = map(int, input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
now_item = 0
money = 0

for e in AB:
    price = e[0]
    amount = e[1]
    if now_item + amount < M:
        now_item += amount
        money += price * amount
    else:
        money += price * (M - now_item)
        print(money)
        exit()


Measured memory_bytes: 29028
N = int(input())
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]

if N % 10 in hon:
  print('hon')
elif N% 10 in pon:
  print('pon')
elif N% 10 in bon:
  print('bon')
else:
  pass

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    int p_stack[N+1];
    int P;
    p_stack[0]=0;
    for(int i=1; i<=N; i++){
        cin >> P;
        p_stack[i]=p_stack[i-1]+P+1;
    }
    int ans=0;
    for(int i=K; i<=N; i++){
        ans=max(ans,p_stack[i]-p_stack[i-K]);
    }
    printf("%.7lf",(double)ans/2.0f);
    return 0;
}


Measured memory_bytes: 1024
from fractions import gcd
n,a,b,k=map(int,input().split())
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

N = n # N は必要分だけ用意する
mod = 998244353
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

ls=[]
res=0
#print(g,numa)
for i in range(n+1):
    #print((k-a*i)%b)
    if (k-a*i)%b==0:
      j= (k-a*i)//b
      #print(a,b,i,j)
      #ls.append((p*numa+i,j))
      if j<=n:
        ls.append((i,j))
#print(ls)
for tup in ls:
  res+=cmb(n,tup[0])*cmb(n,tup[1])
  #print(res)
print(res%mod)



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

int main(){
    int n, q; cin >> n >> q;
    dsu data(n);
    while (q--) {
        int t, u, v; cin >> t >> u >> v;
        if (t) cout << (data.same(u,v) ? 1 : 0) << "\n";
        else data.merge(u,v);
    }
    return 0;
}

Measured memory_bytes: 4040
#include<iostream>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int ar[m][2];
for(int i=0;i<m;i++)
	cin>>ar[i][0]>>ar[i][1];
int s=ar[0][0],e=ar[0][1];
for(int i=1;i<m;i++)
{
if(e<ar[i][0])
	{s=1;e=0;break;}
if(s>=ar[i][0])
	{
	if(e<=ar[i][1])
		continue;
	else if(e>ar[i][1])
		e=ar[i][1];
	}
if(s<ar[i][0])
	{
	if(e<=ar[i][1])
		s=ar[i][0];
	else if(e>ar[i][1])
		{s=ar[i][0];e=ar[i][1];}
	}
}
cout<<e-s+1;
return 0;
}


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

const long long int MOD = 1e9+7;
#define pb push_back
typedef long long ll;
const long long int N = 1e6;

int main(){
    
    int n,k;
    cin>>n>>k;
    vector<int> dp(n+5,1e9),h(n+5);
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        for(int j=i-1;j>=max(1,i-k);j--){
            dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
        }
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 4060
#include <stdio.h>

int main(void){
	char s[5];
	scanf("%s",&s);
	
	if(s[0] == s[1] && s[0] == s[2] && s[0] == s[3]){
		printf("No\n");
	}else{
		if(s[0] == s[1]){
			if(s[2] == s[3]){
				printf("Yes\n");
			}else{
				printf("No\n");
			}
		}else if(s[0] == s[2]){
			if(s[1] == s[3]){
				printf("Yes\n");
			}else{
				printf("No\n");
			}
		}else if(s[0] == s[3]){
			if(s[1] == s[2]){
				printf("Yes\n");
			}else{
				printf("No\n");
			}
		}else{
			printf("No\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!

from collections import defaultdict
import copy

N = int(input())
A = sorted(list(map(int, input().rstrip().split(' '))))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
                
    divisors.sort()
    return divisors
    
max_divisor = 0
for a in A[:2]:
    divisors = make_divisors(a)
    
    for divisor in divisors:
        if divisor > max_divisor:
            nondivisable = 0
            for a in A:
                if a % divisor != 0:
                    nondivisable += 1
                if nondivisable > 2:
                    break
                
            if nondivisable <= 1:
                max_divisor = divisor
            
            
print(max_divisor)
            
    

Measured memory_bytes: 14912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		String[] card= {"S","H","C","D"};
		ArrayList<String> list=new ArrayList<String>();
		for(int j=0;j<=3;j++) {
			for(int i=1;i<=13;i++) {
				list.add(card[j]+" "+String.valueOf(i));
			}
		}

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		int count=0;

		while(n>count) {
			String m=br.readLine();
			list.remove(list.indexOf(m));
			count++;
		}

		for(String checked:list) {
			System.out.println(checked);
		}
	}

}



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

// n の i ビット目と j ビット目を swap する
void swp(int &n, int i, int j) {
    if ((n >> i & 1) ^ (n >> j & 1) == 0) return;
    n ^= (1 << i);
    n ^= (1 << j);
}

// [0, n) ビット目を使って a を b にする
vector<int> dfs(int n, int a, int b) {
    if (n == 1) return {a, b};

    b ^= a;
    int msb = 31 - __builtin_clz(b);
    if (b) swp(b, n - 1, msb);

    int onehot = 1 << (n - 1);
    int mask = onehot - 1;
    auto first = dfs(n - 1, 0, 1);
    auto second = dfs(n - 1, 1, b & mask);

    vector<int> res;
    for (auto x : first) res.push_back(x);
    for (auto x : second) res.push_back(x | onehot);

    for (auto& x : res) swp(x, n - 1, msb);
    for (auto& x : res) x ^= a;
    return res;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if (!__builtin_parity(a ^ b)) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    auto res = dfs(n, a, b);
    for (int i = 0; i < res.size(); i++) {
        cout << res[i] << ((i == res.size() - 1) ? "\n" : " ");
    }
}


Measured memory_bytes: 1628
package main

import "fmt"

func main() {
  var (
    n, q int
    s    string
  )
  fmt.Scan(&n, &q, &s)
  t := make([]int, n)
  for i := 1; i < n; i++ {
    t[i] = t[i-1]
    if s[i] == 'C' && s[i-1] == 'A' {
      t[i]++
    }
  }
  for i := 0; i < q; i++ {
    var l, r int
    fmt.Scan(&l, &r)
    fmt.Println(t[r-1] - t[l-1])
  }
}


Measured memory_bytes: 6144
#include <stdio.h>

#define MAX_NAME_LENGTH 10+1    // name????????§
#define MAX_PROCESS 100000      // ?????§??????????????°

//?????\????????????????????????????§???????
typedef struct{
    char name[MAX_NAME_LENGTH];
    int time;
}Process;

Process Q[MAX_PROCESS];
int head=0,tail=0;

//?????\??????????´?x?????????????????¢??°
void enqueue(Process x){
    Q[tail]=x;
    if(tail+1 == MAX_PROCESS){//????????°?????????????????¨??????
        tail=0;
    }else{
        tail++;
    }
}

//?????\??????????????????????´??????????????????¢??°
Process dequeue(){
    Process x = Q[head];
    if(head+1 == MAX_PROCESS){//????????°?????????????????¨??????
        head=0;
    }else{
        head++;
    }
    return x;
}

int main(){
    int n,q,i,count=0;
    Process x;
    scanf("%d %d",&n,&q);   //??????????????°n??¨???????????????n?????\???
    
    for(i=0;i<n;i++){
        scanf("%s %d",x.name,&x.time);
        enqueue(x);         //?????\??????????´?x???????????????
    }
    
    while(1){
        x=dequeue();    //?????\????????????????´????????????????
        if(x.time<=q){  //???????????????????????????????????????????????\????????£?????´???
            count+=x.time;
            printf("%s %d\n",x.name,count);
        }else {         //?????????????????????????????????????????????????????§????????£?????´???
            count+=q;
            x.time-=q;
            enqueue(x); //???????????\?????´???
        }
        if(tail==head)break;//?????\??????head??¨tail????????´??????????????\??????????????????????????£????????´???break
    }
}

Measured memory_bytes: 3224
/*
Template for vjudge.net

	Author: Iqbal Hossain Rasel
	CodeForces: The_Silent_Man
	AtCoder   : IHR57
	TopCoder  : IHR57

*/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int dist[MAX], vis[MAX];
vector<int> graph[MAX];

void dfs(int u)
{
    vis[u] = 1;
    int mx = 0;
    if(graph[u].size() == 0){
        dist[u] += 1;
    }
    for(int i = 0; i < graph[u].size(); i++){
        int v = graph[u][i];
        if(!vis[v]){
            dfs(v);
        }
        dist[u] = max(dist[u], 1 + dist[v]);
    }
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    int n, m, u, v;
    cin>>n>>m;

    for(int i = 0; i < m; i++){
        cin>>u>>v;
        graph[u].pb(v);
    }

    memset(vis, 0, sizeof(vis));
    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            dfs(i);
        }
    }

    cout<<*max_element(dist + 1, dist + n + 1) - 1<<endl;

    return 0;
}


Measured memory_bytes: 8576
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val t = (1..3).map { sc.nextInt() }
    val max = t.max()!!
    var sumDiff = t.map { max - it }.sum()
    if (sumDiff % 2 != 0) {
        sumDiff += 3
    }
    println(sumDiff / 2)
}

Measured memory_bytes: 31644
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	t := make([]int, n)
	for i := 0; i < n; i++ {
			fmt.Scan(&t[i])
	}

	var cnt int = 0

	for i := 0; i < (n - 1); i++ {
		if t[i] > t[i + 1]{
			cnt  += (t[i] - t[i + 1])
			t[i + 1] = t[i]
		}
	}

	fmt.Println(cnt)
}

Measured memory_bytes: 6484
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define fr first
#define se second
#define ull unsigned long long
#define getbit(x,i) (x>>i)&1

void solve(){
    char c;cin>>c;
    if(c>='a' and c<='z') cout<<'a'<<endl;
    else cout<<'A'<<endl;
    
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll qu=1;
    // cin>>qu;
    for(ll cas=1;cas<=qu;cas++){
        // cout<<"Case #"<<cas<<": ";
        solve();
    }
}

Measured memory_bytes: 3636
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub fn is_prime(n: u64) -> bool {
    if n < 2 {
        return false;
    }
    let mut i = 2;
    while i * i <= n {
        if n % i == 0 {
            return false;
        }
        i += 1;
    }
    true
}

fn solve() {
    input! {
        mut x: u64
    };

    loop {
        if is_prime(x) {
            println!("{}", x);
            return;
        }
        x += 1;
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2216
#include <stdio.h>

int	main()
{
	int	N;
	int	D, X, A;
	int	i, n, sum, a;

	scanf("%d\n%d %d\n", &N, &D, &X);
	i = 0;
	sum = 0;
	while (i < N)
	{
		scanf("%d\n", &A);
		n = 0;
		a = A;
		while (a <= D || n == 0)
		{
			n++;
			a = n * A + 1;
			sum++;
		}
		i++;
	}
	sum += X;
	printf("%d\n", sum);
	return (0);
}

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


int main() {
  string N;
  cin >> N;
  
  int fst=0, scd=0;
  for (int i=0; i<4; i++) {
    if (N.at(0)==N.at(i)) fst++;
    else if (N.at(1)==N.at(i)) scd++;
    //else if (N.at(2)==N.at(i)) thd++;
    //else if (N.at(3)==N.at(i)) fth++;
  }
  
  if (N.at(0)==N.at(1) && N.at(0)==N.at(2)) cout << "Yes" << endl;
  else if (N.at(1)==N.at(2) && N.at(1)==N.at(3)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3596
while True:
    m,f,r = [int(i) for i in input().split()]
    if m == f == r == -1:
        break

    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5604
a[999],u[99],i,j,k,z;main(b){for(;~scanf("%d",a+i++););for(;b;)for(b=i=z++&&!printf("%d\n",b,u[b]=1);*a/++i;b=u[i]|k?b:i)for(j=k=a[1];j;)k-=u[a[2*j--]]||a[2*j+3]-i;}

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

typedef long long ll;

#define W 100001
#define N 101
int n, weight;
ll w[N], v[N], dp[W];

signed main() {
        scanf("%d%d", &n, &weight);
        for (int i = 1; i <= n; i++)
                scanf("%lld%lld", &w[i], &v[i]);

        for (int j = 1; j <= n; j++)
                for (int i = weight; i >= w[j]; i--)
                        dp[i] = max(dp[i-w[j]] + v[j], dp[i]);

        printf("%lld \n", dp[weight]);
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

const int MAX_N = 30;

void success () {
  cout << "Yes" << endl;
  exit(0);
}

void failure () {
  cout << "No" << endl;
  exit(0);
}

int cnt [MAX_N];

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;

      cnt[c - 'a']++;
    }
  }

  int c4 = 0, c2 = 0, c1 = 0;
  for (int i = 0; i < MAX_N; i++) {
    if (cnt[i] % 4 == 0) c4 += cnt[i] / 4;
    else if (cnt[i] % 2 == 0) c2 += 1;
    else c1 += 1;
  }

  if (n % 2 == 1 && m % 2 == 1) {
    if (c1 == 1 && c2 <= n / 2 + m / 2) {
      success();
    } else {
      failure();
    }
  }

  if (n % 2 == 0 && m % 2 == 0) {
    if (c1 == 0 && c2 == 0) success();
    else failure();
  }

  if (n % 2 == 0) swap(n, m);
  if (c1 == 0 && c2 <= m / 2) success();
  else failure();
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = ReadInt();
            var S = Read();
            if (S.Length <= K) Console.WriteLine(S);
            else
            {
                Console.WriteLine(S.Substring(0, K) + "...");
            }

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static string[] ReadArrayString() { return Read().Split(' '); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}


Measured memory_bytes: 27552
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long n;
    std::cin >> n;

    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::map<long long, long long> l, r;
    for (int i = 0; i < n; i++) {
        l[i - a[i]]++;
        r[i + a[i]]++;
    }

    long long count = 0;
    for (auto t : l) {
        count += t.second * r[t.first];
    }

    std::cout << count << std::endl;
}


Measured memory_bytes: 39088
import java.util.Scanner;


class Main {
	public static void main(String args[]) {
		//実行処理
		CountingSort();
	}

	public static void CountingSort(){ 
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		int array[] = new int[num];
		int max = 0;
		int[] sort = new int[num];
		
		
		//配列作成同時にカウント
		for(int i = 0; i < num; i ++ ){
			array[i] = scanner.nextInt();
			//比較して更新
			max = Math.max(max, array[i]);
		}
		int[] count = new int[max + 1];
		for(int i = 0; i < num; i ++ ){
			count[array[i]] ++;
		}
		//カウントの位置
		for(int i = 1; i <= max; i ++ ){
			count[i] += count[i - 1];
		}
		//ソート処理
		for(int i = num - 1; i >= 0; i -- ){
				count[array[i]] --;
				sort[count[array[i]]] = array[i];
				
		}

		//出力
		StringBuilder sb = new StringBuilder("");
        sb.append(sort[0]);
        for (int i = 1; i < num; i++) {
            sb.append(" ").append(sort[i]);
        }
        System.out.println(sb);

		//後処理
		scanner.close();
	}
}


Measured memory_bytes: 516300
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[100010];
int main()
{
    int i,j,k,s;
    scanf("%s",a);
    k=strlen(a);
    s=k;
    for(i=1;i<k;i++)
    if(a[i]!=a[i-1])
    {
        j=max(i,k-i);
        s=min(s,j);
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 256
A2=list(input())
A1=[]
L=len(A2)
A1.append(A2[0])

for i in range(1,L):
    if len(A1)>=1 and A1[-1]=="S" and A2[i]=="T":
        A1.pop(-1)
    else:
        A1.append(A2[i])

print(len(A1))

Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=55;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,k,d;
    set<int>s;
    cin>>n>>k;
    for(int x,i=1;i<=k;i++){ 
    cin>>d;
    while(d--){ 
        cin>>x;
        s.insert(x);
    }
 } 
 cout<<n-(int)s.size()<<'\n';
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3624
n=int(input())
v=list(map(int,input().split()))
a=dict()
b=dict()

def mkdc(l):
    di=dict()
    for i in range(len(l)):
        if l[i] in di:
            di[l[i]]+=1
        else:
            di[l[i]]=1
    return di

e,o=[],[]      
for i in range(int(n/2)):
    e.append(v[2*i])
    o.append(v[2*i+1])
#print(e)
de=mkdc(e)
do=mkdc(o)
#print(de)
de=sorted(de.items(),key=lambda d: d[1],reverse=True)
do=sorted(do.items(),key=lambda d: d[1],reverse=True)
de.append((0,0))
do.append((0,0))
#de=sorted(de)
#print(de)
if do[0][0]==de[0][0]:
    print(n- do[0][1]-max(de[1][1],do[1][1]))
else:
    print(n-de[0][1]-do[0][1])


Measured memory_bytes: 65388
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr(i,n) for(int i=0;i++<n;)
#define Fr(i,n) for(int i=0;i<n;i++)

int n,m,x,y,dp[100010]={};
vector<int> e[100010]={};

int M(int i){
  if(dp[i]!=0) return dp[i];
  int s=e[i].size(),k=1;
  Fr(j,s) k=max(k,1+M(e[i][j]));
  dp[i]=k;
  return k;
}

int main(){
  cin>>n>>m;
  fr(i,m){cin>>x>>y;e[x].pb(y);}
  int ans=0;
  fr(i,n) ans=max(ans,M(i));
  cout<<ans-1<<endl;
}

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

using namespace std;

/* UnionFind：素集合系管理の構造体(union by rank)
	isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
	unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
*/
struct UnionFind {  // The range of node number is u 0 v n-1
	vector<int> rank, parents;
	UnionFind() {}
	UnionFind(int n) {  // make n trees.
		rank.resize(n, 0);
		parents.resize(n, 0);
		for (int i = 0; i < n; i++) {
			makeTree(i);
		}
	}
	void makeTree(int x) {
		parents[x] = x;  // the parent of x is x
		rank[x] = 0;
	}
	bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
	void unite(int x, int y) {
		x = findRoot(x);
		y = findRoot(y);
		if (rank[x] > rank[y]) {
			parents[y] = x;
		}
		else {
			parents[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}
	int findRoot(int x) {
		if (x != parents[x]) parents[x] = findRoot(parents[x]);
		return parents[x];
	}
};

// 辺の定義
struct Edge {
	long long u;
	long long v;
	long long cost;
};

bool comp_e(const Edge &e1, const Edge &e2) { return e1.cost < e2.cost; } // 辺を直接比較するための関数

/* Kruskal :クラスカル法で minimum spanning tree を求める構造体
	入力: 辺のvector, 頂点数V
	最小全域木の重みの総和: sum
	計算量: O(|E|log|V|)
*/

struct Kruskal {
	UnionFind uft;
	long long sum;  // 最小全域木の重みの総和
	vector<Edge> edges;
	int V;
	Kruskal(const vector<Edge> &edges_, int V_) : edges(edges_), V(V_) { init(); }
	void init() {
		sort(edges.begin(), edges.end(), comp_e); // 辺の重みでソート
		uft = UnionFind(V);
		sum = 0;
		for (auto e : edges) {
			if (!uft.isSame(e.u, e.v)) { // 閉路にならなければ加える
				uft.unite(e.u, e.v);
				sum += e.cost;
			}
		}
	}
};

int main() {

	int n;
	cin >> n;
	vector<vector<int>> VE(n, vector<int>(n));
	int counter=0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> VE[i][j];
			if (VE[i][j] != -1) { counter++; }
		}
	}

	int V, E;
	V = n;
	E = counter;
//	cin >> V >> E;
	vector<Edge> edges(E);
//	for (int i = 0; i < E; i++) {
	counter = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			long long s, t, w;
			//		cin >> s >> t >> w;
			if (VE[i][j] != -1) {
				s = i;
				t = j;
				w = VE[i][j];

				Edge e = { s, t, w };
				edges[counter] = e;
				counter++;
			}
		}
	}
//	}


	Kruskal krs(edges, V);
	cout << krs.sum << endl;
	return 0;
}


Measured memory_bytes: 3192
#include<stdio.h>
int main(){
  int i=0,j=0,k=0;
  int N=0,temp=0;
  int num[100];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&num[i]);
  }
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",num[i]);
  }
  printf("\n");
  for(i=1;i<N;i++){
    temp=num[i];
    j=i-1;
    while(j>=0&&num[j]>temp){
      num[j+1]=num[j];
      j--;
    }
    num[j+1]=temp;
    for(k=0;k<N;k++){
      if(k>0)printf(" ");
      printf("%d",num[k]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2756
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[200000];
int ra[200001];
map<int, int> dict;

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) ra[i + 1] = ra[i] + a[i];
	
	rep(i, n + 1) {
		if (dict.find(ra[i]) == dict.end()) dict[ra[i]] = 0;
		dict[ra[i]]++;
	}
	
	int ans = 0;
	for (map<int, int>::iterator it = dict.begin(); it != dict.end(); it++) {
		int cnt = it->second;
		ans += cnt * (cnt - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 12 15:50:41 2019

@author: shinjisu
"""


import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def dmp(x):
    global debug
    if debug:
        print(x)


# ABC 100 B Ringo's Favorite Numbers
def abc100b():
    D, N = getIntList()
    if N % 100 == 0:
        return (N+1) * 100**D  # WA N==100のとき正しくない 101*100**D
    else:
        return N * 100**D


# ABC 101 B digit sum
def abc101b():
    N = getInt()
    sm = 0
    n = N
    while n > 0:
        sm += n % 10
        n //= 10
    if N % sm == 0:
        return 'Yes'
    else:
        return 'No'


debug = False  # True False
print(abc101b())


Measured memory_bytes: 3064
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define MOD 1000000007

 
int main()
{
	fast;
	string s;
	cin>>s;
	string s1,s2;
	cin>>s1;
	if(s1.size()-s.size()==1)
	{
		for (int i = 0; i < s.size(); ++i)
		{
			s2.pb(s1[i]);
		}
		if(s==s2)
			cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	else
		cout<<"No"<<endl;
	
}

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

#define maxN 100005
#define mod 1000000007
vector<long long> v(101);
vector<vector<long long>> dp(101,vector<long long>(maxN,0));

inline long long add(long long x,long long y){ x+=y; if(x>=mod) x-=mod; return x; }
inline long long sub(long long x,long long y){ x-=y; if(x<0) x+=mod; return x; }

int main()
{
    long long n=0,k=0;
    cin>>n>>k;

    for(long long i=0;i<n;i++) cin>>v[i];
    for(long long i=1;i<=n;i++) dp[i][0]=1;



    for(long long j=0;j<=k;j++)
    {
        if(j<=v[0]) dp[1][j]=1;
        else dp[1][j]=0;
    }

    if(n>1) for(long long j=1;j<=k;j++) dp[1][j]=add(dp[1][j],dp[1][j-1]);

    for(long long i=2;i<=n;i++)
    {
        for(long long j=1;j<=k;j++)
        {

            long long mx=j,mn=j-v[i-1]-1;
            if(mn<0) dp[i][j]=dp[i-1][mx]-0;
            else dp[i][j]=sub(dp[i-1][mx],dp[i-1][mn]);
        }

        if(i<n) for(long long j=1;j<=k;j++) dp[i][j]=add(dp[i][j],dp[i][j-1]);
    }

    cout<<dp[n][k]%mod;


    
    return 0;
}


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

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main() {
  int N,M;
  cin >> N >> M;
  UnionFind tree(N+M);
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    for(int j=0;j<x;j++){
      int y;
      cin >> y;
      tree.unite(i,y+N-1);
    }
  }
  bool ans=true;
  for(int i=0;i<N;i++){
    if(!tree.same(0,i))ans=false;
  }
  if(ans) cout << "YES";
  else cout << "NO";
}





Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  string n;
  cin>>n;
  long long s=0;
  for(int i=0;i<n.size();i++){
    s+=(long long)(n.at(i)-'0');
  }
  long long N=stoi(n);
  if(N%s==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}
    

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,ans=0,active=0;
    cin >> n;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    rep(i,n){
        if(active < h[i]) ans += (h[i]-active);
        active = h[i];
    }
    cout << ans << "\n";
    return 0;
}

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


using namespace std;

#define f first
#define s second

template<typename T> int sz(T x){return static_cast<int>(x.size());}



using ll = long long;

struct entry{
    int len, X, Y;
    entry(){
        len=X=Y=0;
    }
    entry(int a, int b, int c){
        len=a, X=b, Y=c;
    }
};


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    string s, t;
    cin >> s >> t;
    int N = sz(s), M = sz(t);
    vector<vector<entry> > dp(N+1, vector<entry>(M+1, (entry){-100, 0, 0}));
    dp[0][0].len = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (s[i] == t[j]) {
                if (dp[i+1][j+1].len < 1 + dp[i][j].len) {
                    dp[i+1][j+1] = (entry){1+dp[i][j].len, i, j};
                }
                continue;
            }
            if (dp[i][j+1].len < dp[i][j].len) {
                dp[i][j+1] = (entry){dp[i][j].len, i, j};
            }
            if (dp[i+1][j].len < dp[i][j].len) {
                dp[i+1][j] = (entry){dp[i][j].len, i, j};
            }
        }
    }
    int endx, endy;
    endx=endy=-1;
    int answer = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            if (dp[i][j].len > answer) {
                endx = i, endy = j;
                answer = dp[i][j].len;
            }
        }
    }
    if (answer == 0) {
        cout << "\n";
        return 0;
    }
    assert (answer > 0);
    string A = "";
    while (endx != 0 and endy != 0) {
        entry NEW = dp[endx][endy];
        if (NEW.X == endx-1 && NEW.Y == endy - 1) {
            A += s[NEW.X];
        }
        endx = NEW.X, endy = NEW.Y;
    }
    reverse(A.begin(), A.end());
    cout << A << "\n";
    /* cout << answer << "\n"; */
}



Measured memory_bytes: 109032
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1) << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

m = 0
a =0
loop = True

while loop:
  count =0
  for j in range(a,n-1):
    if h[j]>=h[j+1]:
      count+=1
    else:
      a = j+1
      break      
  if m<count and count>0:
    m = count
    
  if a > n-2 or j >= n-2:
        loop = False
      
print(m)

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;

void solve(){
    ll x, y;
    cin >> x >> y;
    ll prev = 1;
    int cnt = 0;
    for(ll i = x; i <= y;){
        //cout << i << ' ';
        prev = i;
        i = prev * 2;
        cnt++;
    }
    if(prev > y) cnt--;
    cout << cnt;
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



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

int main(){
  string S;
  cin >> S;
  int sum = 700;
  if(S.at(0) == 'o') sum += 100;
  if(S.at(1) == 'o') sum += 100;
  if(S.at(2) == 'o') sum += 100;
  cout << sum << endl;
}

Measured memory_bytes: 764