akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
use std::cmp::min;
#[fastout]
fn main() {
    input! {
        l: usize,
        r: usize,
    }
    let tmp_l = l % 2019;
    let tmp_r = r % 2019;
    if tmp_l >= tmp_r || tmp_l == 0 || tmp_r == 0 || r - l >= 2019 {
        println!("0");
    } else {
        let mut ans = std::usize::MAX;
        for i in tmp_l..=tmp_r {
            for j in i + 1..=tmp_r {
                ans = min(ans, (i * j) % 2019);
            }
        }
        println!("{}", ans);
    }
}


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

const int maxn = 1e5 + 5;
int a[maxn];
char s[maxn];

int main() {

    scanf("%s", s);
    int R = 0, L = 0, Ln, Rn;
    while(s[R]) {

        while(s[R] == 'R') R++;
        Ln = R - L; L = R+1;
        while(s[L] == 'L') L++;
        Rn = L - R;

        a[R] = a[R-1] = (Ln+Rn)/2;
        if((Ln+Rn)&1)
            if(Ln > Rn && Ln&1 || Ln < Rn && !(Rn&1)) a[R-1]++;
            else a[R]++;

        R = L;
    }
    for(int i = 0; s[i]; i++)
        printf("%d ", a[i]);
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
	int sum;
	int r;
	
	while (1){
		scanf("%d", &sum);
		if (sum == 0){
			break;
		}
		for (int i = 0; i < 9; i++){
			scanf("%d", &r);
			sum -= r;
			}
	
		printf("%d\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define rv(c) reverse(c.begin(),c.end())
#define is(a) insert(a)
using namespace std;
int main(){
	int N; cin>>N;
	rep(n,N){
		string T,t[2]; set<string> s;
		cin>>T;
		rep(i,T.size()-1)rep(j,4){
			t[0]=T.substr(0,i+1),t[1]=T.substr(i+1);
			rep(k,2)if(j&(1<<k))rv(t[k]);
			s.is(t[0]+t[1]),s.is(t[1]+t[0]);
		}
		cout<<s.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 996
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 400005
#define inf 0x7fffffff
using namespace std;
 
struct E {int next, to, dis;} e[N];
int n, m, num, flag, cnt;
int h[N], a[N], pos[N], obj[N];
bool vis[N];
 
int read()
{
    int x = 0; char c = getchar();
    while(c < '0' || c > '9') c = getchar();
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x;
}
 
void add(int u, int v, int w)
{
    e[++num].next = h[u];
    e[num].to = v;
    e[num].dis = w;
    h[u] = num;
}
 
void dfs(int x)
{
    if(flag) return;
    vis[x] = 1;
    for(int i = h[x]; i != 0; i = e[i].next)
    {
        int t = pos[x] + e[i].dis;
        if(pos[e[i].to] == inf) pos[e[i].to] = t, dfs(e[i].to);
        else if(t != pos[e[i].to]) {flag = 1; return;}
    }
}
 
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        int a = read(), b = read(), c = read();
        add(a, b, c), add(b, a, -c);
        pos[a] = pos[b] = inf;
        obj[++cnt] = a, obj[++cnt] = b;
    }
    sort(obj + 1, obj + 1 + cnt);
    cnt = unique(obj + 1, obj + 1 + cnt) - obj - 1;
    for(int i = 1; i <= cnt; i++)
        if(!vis[obj[i]])
        {
            flag = 0;
            pos[obj[i]] = 0;
            dfs(obj[i]);
            if(flag) {cout << "No"; return 0;}
        }
    cout << "Yes";
    return 0;
}

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

#define ll long long

unordered_map<ll, ll> allCombination(vector<ll> &v) {

  int sz = v.size();
  unordered_map<ll, ll> ret;

  if(sz >= 10) {
    unordered_map<ll, ll> a, b;
    vector<ll> av, bv;
    for(int i = 0; i < sz; i++) {
      if(i < sz / 2) {
        av.push_back(v[i]);
      }else {
        bv.push_back(v[i]);
      }
    }
    a = allCombination(av);
    b = allCombination(bv);
    for(auto i: a) {
      for(auto k: b) {
        ret[i.first + k.first] += i.second * k.second;
      }
    }
    return ret;
  }

  for(int i = 0; i < (1 << sz); i++) {
    ll t = 0;
    for(int k = 0; k < sz; k++) {
      if((i >> k) & 1) {
        t += v[k];
      }
    }
    ret[t] += 1;
  }
  return ret;
}

ll pow(ll a, ll b) {
  ll ret = 1;
  for(ll i = 0; i < b; i++) {
    ret *= a;
  }
  return ret;
}

int main() {
  int N, A;
  cin >> N >> A;
  int x[N];
  for(int i = 0; i < N; i++){
    cin >> x[i];
    x[i] -= A;
  }

  vector<ll> av, bv;
  int zero_n = 0;
  for(int i = 0; i < N; i++) {
    if(x[i] > 0) {
      av.push_back(x[i]);
      continue;
    }
    if(x[i] < 0) {
      bv.push_back(- x[i]);
      continue;
    }
    zero_n += 1;
  }

  if(av.size() > bv.size()) {
    swap(av, bv);
  }

  vector<ll> bv1, bv2;
  for(int i = 0; i < bv.size(); i++) {
    if(i < bv.size() / 2) {
      bv1.push_back(bv[i]);
    }else {
      bv2.push_back(bv[i]);
    }
  }

  unordered_map<ll, ll> avcombi, bv1combi, bv2combi;
  avcombi = allCombination(av);
  bv1combi = allCombination(bv1);
  bv2combi = allCombination(bv2);

  ll ans = 0;

  for(auto i: avcombi) {
    for(auto k: bv1combi) {
      if(bv2combi.find(i.first - k.first) != bv2combi.end()) {
        ans += i.second * k.second * bv2combi[i.first - k.first];
      }
    }
  }
  ans *= pow(2, zero_n);
  cout << ans - 1 << endl;
}


Measured memory_bytes: 256
from math import sqrt

N, P = map(int, input().split())

F = {}
for i in range(2, int(sqrt(P)) + 1):
    if P % i != 0:
        continue
    F[i] = 0
    while P % i == 0:
        P //= i
        F[i] += 1
if P > 1:
    F[P] = 1

ans = 1
for p in F.keys():
    ans *= p ** (F[p] // N)
print(ans)


Measured memory_bytes: 3064
# B
s = int(input())

def is_unique(seq):
    return len(seq) == len(set(seq))

a = []
a.append(s)
for i in range(1, 100000):
    if a[i-1] % 2 == 0:
        a.append(a[i-1]/2)
    else:
        a.append(a[i-1]*3 + 1)
    if not is_unique(a):
        print(i+1)
        break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9+5)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

int main(){
	string str;
	cin >> str;
	int ans = str.size();
	REP(i, str.size()/2){
		if(str[i]!=str[i+1]){
			ans = min(ans, (int)str.size()-i-1);
		}
	}
	for(int i=str.size()-1;i>str.size()/2;--i){
		if(str[i-1]!=str[i]){
			ans = min(ans, i);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() 
{
   int x, y;
   cin >> x >> y;

   vector<int> a = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
   cout << (a[x] == a[y] ? "Yes" : "No") << endl;
}


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

int main() {
	string s,t;
	cin>>s>>t;
	int n = s.length(); 
  
    char arr[n + 1]; 
  
    strcpy(arr, s.c_str());
    
    int m = t.length(); 
  
    char brr[m + 1]; 
  
    strcpy(brr, t.c_str());
    for(int i=0;i<n;i++){
    	if(arr[i]!=brr[i]){
    	cout<<"No";
    	return 0;
    		
    	}
    	
    }
    cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3628
/*16D8104015E Nobushige Sen 18.5.15*/
#include<iostream>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
 
int main(){
  int n,p,S[100000],T[100000];
  bool exist;
  cin >> n;
  rep(i,n)cin >> S[i];
  cin >> p;
  rep(i,p)cin >> T[i];
 
  int h;
  rep(i,n){
    int ch = i;
    REP(j,i,n){
      if(S[ch] > S[j])ch = j;
    }
    h=S[ch];
    S[ch]=S[i];
    S[i]=h;
  }
 
  int count=0;
 
  rep(i,p){
    int lef=0,rig=n;
    exist = false;
    while(lef < rig){
      int index=(lef+rig)/2;
      if(T[i] == S[index]){
    exist=true;
    break;
      }
      else if(T[i] < S[index]){
    rig=index;
      }
      else {
    lef = index+1;
      }
    }
    if(exist){
      count++;
    }
  }
  cout << count << endl;
 
 

}

/*
id10-Hazuki-Yagyuu-no-Macbook:nobu yagyuhazuki$ ./4_A
5
1 2 3 4 5
3
3 4 1
3
*/




Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    int n,ans=0;
    char c;
    cin>>n;
    vector<vi> s(26);
    rep(i,n) cin>>c,s[c-'a'].pb(i);
    rep(i,n-1){
        int sum=0;
        rep(j,26){
            bool a=0,b=0;
            for(auto x:s[j])if(x<=i)a=1;else b=1;
            if(a&&b)sum++;
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    ll total = 0;
    rep(i, N){
        cin >> A[i];
        total += A[i];
    }
    rep(i, N) cin >> B[i];

    ll ans = 0, aa = 0, bb = 0;
    vector<ll> dis;//たりない分
    vector<ll> amari;//余る分
    rep(i, N){
        if(A[i] < B[i]){
            bb += B[i] - A[i];
            dis.push_back(B[i] - A[i]);
            ans++;
        }else if(B[i] < A[i]){
            aa += A[i] - B[i];
            amari.push_back(A[i] - B[i]);
        }
    }
    sort(dis.begin(), dis.end());
    sort(amari.begin(), amari.end(), greater<ll>());

    if(bb == 0){
        cout << 0 << endl;
        return 0;
    }
    if(aa < bb){
        cout << -1 << endl;
        return 0;
    }else{
        ans++;
        int i = 0, j = 0;
        while(j < dis.size()){

            if(amari[i] < dis[j]){
                ans++;
                dis[j] -= amari[i];
                i++;
            }else{
                
                amari[i] -= dis[j];
                j++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
n = int(input())
l = list(map(int, input().split()))

ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            a = l[i]
            b = l[j]
            c = l[k]
            if a != b and b != c and c != a and a + b > c and b + c > a and c + a > b:
                ans += 1
print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int pp, m, f[5], a[200003], bj = 1;
string s, t, q;
ll n;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gl();
	if (n & 1) {puts("0"); return 0;}
	ll numm = 0, num = 0;
    ll o = n, q = 5;
    n >>= 1;
    while (n >= q)
    {
		numm = numm + n / q;
		q = q * 5;
	}
	printf("%lld\n", numm);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int  N = sc.nextInt();
        long M = sc.nextLong();
        List<long[]> al = new ArrayList<>();
        for(int i = 0; i < N; i++){
            long Ai = sc.nextLong(),
                 Bi = sc.nextLong();
            al.add(new long[]{Ai, Bi});
        }
        al.sort(Comparator.comparing(x -> x[0]));   
        int shop = 0;
        long money = 0;
        while(true){
            long stock = al.get(shop)[1],
                 price = al.get(shop)[0];
            if(stock < M){
                money += price*stock;
                M -= stock;
                shop++;
            }
            else{
                money += price*M;
                break;
            }
        }
        System.out.println(money);
    }
}

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

A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
A.sort()
B.sort()

if N%2:
  ma = A[N//2]
  mb = B[N//2]
  print(max(0, mb-ma+1))
else:
  ma = A[N//2] + A[N//2-1]
  mb = B[N//2] + B[N//2-1]
  print(max(0, mb-ma+1))

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

  int main(){
    int a,b,c;cin>>a>>b>>c;
    int cnt=0;
    cnt=max(a,b);
    cnt=max(cnt,c);
    cout<<cnt*9+a+b+c;
  }

Measured memory_bytes: 256
#include <iostream>
#include <set>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main () {
  std::cin.tie(0); // tie
  std::ios::sync_with_stdio(false); // sync
  int n, i;
  string command, str;
  set<string> S;

  cin >> n;
  rep(i,n) {
    cin >> command >> str;
    if (command == "insert") {
      S.insert(str);
    } else if (command == "find") {
      (S.find(str) != S.end())? cout << "yes" : cout << "no";
      cout << endl;
    }
  }
  return 0;
}
  

Measured memory_bytes: 27812
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
using namespace std;
vector<int> tipo;
vector<int> antes;
deque<char> dq;
int tot=0;
vector<char> c;
int main(){
    fastio;
    string s; cin>>s;
    int q; cin>>q;
    while(q--){
        int tp; cin>>tp;
        if(tp==1){
            tot++;
        }else{
            int ti; char ci;
            cin>>ti>>ci;
            tipo.push_back(ti);
            c.push_back(ci);
            antes.push_back(tot);
        }
    }
    if(tot%2==1){
        for(int i=0; i<(int)s.size(); i++)dq.push_front(s[i]);
    }else{
        for(int i=0; i<(int)s.size(); i++)dq.push_back(s[i]);
    }
    for(int i=0; i<(int)tipo.size(); i++){
        int aux = tot - antes[i];
        if(aux%2 == 1)tipo[i] = (tipo[i]==1) ? 2 : 1;
        if(tipo[i]==1){
            dq.push_front(c[i]);
        }else{
            dq.push_back(c[i]);
        }
    }
    while(!dq.empty()){
        char atual = dq.front(); dq.pop_front();
        cout<<atual;
    }
    cout<<endl;
}

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

typedef long long ll;

int main(){
  ll n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  ll dis=b-a;
  bool ans=false;
  for(ll i=0;i<n;i++){
    ll max_dis=d*i-c*(n-1-i);
    ll min_dis=c*i-d*(n-1-i);
    if(min_dis<=dis&&dis<=max_dis){
      ans=true;
    }
  }
  cout << (ans?"YES":"NO") << endl;
}

Measured memory_bytes: 256
def main():
    M = int(input())
    n, s = 0, 0
    for _ in range(M):
        d, c = list(map(int, input().split()))
        n += c
        s += d * c
    # 9 * n + s から 9 ずつ減らしていって、 10 ～ 18 になったら終わり
    print((9 * n + s - 10) // 9)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
int n,a[100009],dp[100009],ans;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	dp[0]=1000000009;
	for(int i=1;i<=n;i++) {
		if(dp[ans]>=a[i]) {
			dp[ans+1]=a[i];
			ans++;
		}
		int l=0,r=ans;
		while(l<r) {
			int m=(l+r)/2;
			if(dp[m]>=a[i]) l=m+1;
			else r=m;
		}
		if(l!=0) dp[l]=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 2e5 + 2, inf = 1e18;

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

    int n;
    cin >> n;
    char ch;
    while (cin >> ch) {
        cout << (char)((ch - 'A' + n) % 26 + 'A');
    }    
}


Measured memory_bytes: 3640
/*
input:
0 1 2 3 4 5 6 7
1 0 2 3 4 5 6 7
7 6 5 4 3 2 1 0
ouput:
0
1
28
*/

#include <iostream>
#include <queue>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef pair<string, int> P;

const int INF = 100000000;

//&#36755;入
string a;

//移&#21160;方向
int op[4] = {-1, 1, -4, 4};

map<string, int> dp;						//保存从string&#21464;到"01234567"的int

//&#35745;算从"01234567"&#36716;&#25442;到其他序列所需的最小&#27493;数
void bfs(){
	queue<P> que;
	que.push(P("01234567", 0));
	dp["01234567"] = 0;
	while(!que.empty()){
		P p = que.front();
		que.pop();
		string s = p.first;
		int cur = p.second;
		for(int i = 0; i < 4; i ++){
			//&#26500;造下一次交&#25442;
			int next = cur + op[i];
			string str = s;
			swap(str[cur], str[next]);
			map<string, int>::iterator it = dp.find(str);
			//判断是否可移&#21160;以及是否&#35775;&#38382;&#36807;
			if(0 <= next && next < 8 
				&& !(cur == 3 && next == 4) && !(cur == 4 && next == 3) 
				&& it == dp.end()){

				que.push(P(str, next));
				dp[str] = dp[s] + 1;
			}
		}
	}
}

void solve(){
	//&#21024;除空格
	a.erase(remove(a.begin(), a.end(), ' '), a.end());
	cout<<dp[a]<<endl;
}

int main(int argc, char const *argv[]){
	bfs();
	while(getline(cin, a)){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3440
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long ans = 0;
		if (n % 2 == 0) {
		    for (long i = 10; i <= n; i *= 5) {
		        ans += n / i;
		    }
		} else {
		    ans = 0;
		}
		System.out.println(ans);
   }
}


Measured memory_bytes: 23764
# n = int(input())
x, y = map(int, input().split())
# l = list(map(int, input().split()))

if (y - 2*x)%2 == 0 and 0 <= x - (y - 2*x)/2 and 0 <= y - 2*x:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9168
class UnionFind():
	def __init__(self, N):
		self.N = N # データ数
		self.d = [-1]*N # 親の番号，根の場合は，-(集合の要素数)

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x==y: return False
		if self.d[x] > self.d[y]: x,y = y,x
		self.d[x] += self.d[y]
		self.d[y] = x
		return True

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

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


n,m,k = map(int, input().split())
uf = UnionFind(n)
G_friend = [[] for i in range(n)]
for i in range(m):
    a,b = map(lambda x: int(x)-1, input().split())
    G_friend[a].append(b)
    G_friend[b].append(a)
    uf.union(a,b)

num_block = [0]*n
for i in range(k):
    a,b = map(lambda x: int(x)-1, input().split())
    if uf.same(a,b) and b not in G_friend[a]:
        num_block[a] += 1
        num_block[b] += 1

ans = [0]*n
for i in range(n):
    ans[i] = uf.size(i) - len(G_friend[i]) - 1 - num_block[i]
print(*ans)

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

int main()
{
	int n = 0;
  	int t;
  	cin >> t;
  	string s;
  	cin >> s;
  	int max = n;
  	for(int i = 0; i < s.size(); i++) {
    	if(s[i] == 'D') {
      		n--;
    	} else {
          	n++;
          	if(n> max)
              	max = n;
        }
    }
  	cout << max << endl;
  
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  bool ans=true;
  rep(i,3) if(S.at(i)==S.at(i+1)) ans = false;
  if(ans){cout << "Good" <<endl;
         }else cout << "Bad" << endl;
}


Measured memory_bytes: 256
list = input().split()
w = int(list[0])
h = int(list[1])
n = int(list[2])
list2 = []
i = 0
while i < n:
   list2.append(input().split())
   i += 1

i = 0
a = int(0)
b = int(w)
c = int(0)
d = int(h)
while i < n:
    list3 = list2[i]
    if int(list3[2]) == 1:
        a = max(a,int(list3[0]))
    elif int(list3[2]) == 2:
        b = min(b,int(list3[0]))
    elif int(list3[2]) == 3:
        c = max(c,int(list3[1]))
    else:
        d = min(d,int(list3[1]))
    i += 1
if b < a:
    print(0)
elif d < c:
    print(0)
else:
    print((b-a)*(d-c))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;
  cin >> n >> k >> q;
  vector<int>a(q);
  vector<int>b(n+1,0);
  for(int i = 0;i<q;i++){
    cin >> a[i];
    b[a[i]]++;
  }
  for(int j = 1;j<n+1;j++){
    int sum = 0;
    sum = k - q + b[j];
    if(sum <=0){cout << "No"<<endl;}
    else cout << "Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408
N, K = map(int,input().split())
A = list(map(int,input().split()))
B = [0];BB=[0]
S = set([]);S.add(0)
now = 0
Flag = False
loop_start = -1
if K <= 2*pow(10,5)+10:
  for i in range(K):
    nxt = A[now]-1
    BB.append(nxt)
    now = nxt
  #print(BB)
  print(BB[K]+1)
  exit()
for i in range(N*2):
  nxt = A[now]-1
  #print(now,nxt)
  if nxt in S:
    if Flag:
      if nxt == loop_start:
        #print(nxt,i)
        loop_cycle = i-loop_num
        break
    else:
      loop_start = nxt
      loop_num = i
      B.append(nxt)
      #print(loop_num,loop_start,B)
      Flag = True
  else:
    B.append(nxt);S.add(nxt)
  now = nxt
loop_num += 1-loop_cycle
#print(B,loop_start,loop_cycle,loop_num)
loc = (K-loop_num)%loop_cycle+loop_num
#print(loc)
#print(len(B))
print(B[loc]+1)

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

int main(){
    int d, n, x = 1;
    cin >> d >> n;
    if(n == 100){
        n = 101;
    }
    for(int i=0; i<d; ++i){
        n *= 100;
    }
    cout << n << endl;
    return 0;
}

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

int main ()
{
    int n,m,c=0;
    double s=0;
    cin>>n>>m;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
        s+=x[i];
    }
    s=s/(4*m*1.0);
    sort(x,x+n);
    for(int i=n-1;i>=0;i--)
    {
        if(x[i]>=s)c++;
        else break;
    }

    if(c>=m)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, sum, ans, a[100000][3];
bool f;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	rep(i,3)
		rep(j, 3) {
		cin >> a[i][j];
	}
	rep(i,100) {
		LL A[3], B[3];
		A[0] = i,
			B[0] = a[0][0] - A[0], B[1] = a[0][1] - A[0], B[2] = a[0][2] - A[0],
			A[1] = a[1][0] - B[0], A[2] = a[2][0] - B[0];
		bool F = 0;
		rep(j,3)
			rep(k, 3) {
			if (A[j] + B[k] != a[j][k])
				F = 1;
		}
		if (F == 0) {
			yn(1);
			return 0;
		}
	}
	yn(0);
	return 0;
}

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

int main(){
  vector<pair<int,int> > d;
  pair<int,int> k;
  int n,m,a,b,sum;
  while(1){
    cin>>n>>m;
    if(n==0)break;
    d.clear();
    for(int i=0;i<n;i++){
      cin>>a>>b;
      k.first=b*-1;
      k.second=a;
      d.push_back(k);
    }
    sort(d.begin(),d.end());
    sum=0;
    for(int i=0;i<n;i++){
      if(m!=0){
	if(d[i].second<m){
	  m-=d[i].second;
	}else {
	  sum+=(d[i].first*-1)*(d[i].second-m);
	  m=0;
	}
      }else {
	sum+=(d[i].first*-1)*d[i].second;
      }
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 3248
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
	res = list(sys.stdin.readline())
	if res[-1] == "\n":
		return res[:-1]
	return res


def IR(n):
	return [I() for i in range(n)]


def LIR(n):
	return [LI() for i in range(n)]


def SR(n):
	return [S() for i in range(n)]


def LSR(n):
	return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
	n, m = LI()
	if n == m:
		print('Yes')
	else:
		print('No')
	return


# Solve
if __name__ == "__main__":
	solve()


Measured memory_bytes: 38384
#include <stdio.h>

int main(void){

  int a,b;
  scanf("%d%d",&a,&b);

  if(a<b)
    printf("a < b\n");
  else if(a>b)
    printf("a > b\n");
  else if(a==b)
    printf("a == b\n");

  return(0);
}

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

int main()
{
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,cunt,x;
int main(){
    cin>>N;
    int d[N];
    for(int i=0;i<N;i++){
        bool flag=1;
        cin>>x;
        for(int j=0;j<=cunt;j++)                                    
            flag*=(d[j]!=x?1:0);
        if(flag==1){
            d[cunt]=x;
            cunt++;
        }
    }
    cout<<cunt<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>

using namespace std;
//累乗(繰り返し2乗法)　aのb乗(mod)を求める。


int main()
{
	string str;
	long long int n, m, a, b,c;
	const long long int mod = 1000000007;
	cin >>a>>b>>c ;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {

		cout << "NO" << endl ;
	}
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <math.h>
#include <time.h>
#include <fstream>
#include <list>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long int lld;
typedef long double ld;
typedef vector<int> vi;
typedef vector<char> vch;
typedef vector<lld> vlld;

typedef struct node
{
	int ed;
	lld val;
} node;

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

	lld n, ok = 0, a = 1, tmp;

	cin >> n;

	while (1)
	{
		tmp = n / a - (n % a == 0 ? 1 : 0);

		if (tmp == 0)
			break;

		ok += tmp;

		a++;
	}

	cout << ok << '\n';

	return 0;
}


Measured memory_bytes: 3648
S,K=open(0);K=int(K);s=1;l=[]
for c,d in zip(S,S[1:]):
 if c==d:s+=1
 else:l+=[s];s=1
if len(l)==1:print(l[0]*K//2)
elif S[0]==S[-2]:print(K*sum(i//2for i in l[1:-1]+[l[0]+l[-1]])-(l[0]&l[-1]&1))
else:print(K*sum(i//2for i in l))

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

int N, a, b;
int data[10010];

int calculateSum(int n){
  int sum = 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  cin >> N >> a >> b;
  int sum = 0;

  for (int i = 0; i <= N; i++)
  {
    int tmp = calculateSum(i);
    if (tmp >= a && tmp <= b)
    {
      sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)

char field[200][200];

int main() {
    int H, W;
    cin >> H >> W;
    rep(i, 200) {
        rep(j, 200) {
            field[i][j] = '#';
        }
    }
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> field[i][j];
        }
    }
    rep(i, H + 2) {
        rep(j, W + 2) {
            cout << field[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#define repeat(i,n)     for(int i=0; i<(n); ++i)
#define repeat1(i,n)    for(int i=1; i<=(n); ++i)
#define range(i,l,r)    for(int i=(l); i<(r); ++i)

using namespace std;
typedef long long llint;

typedef pair<int, int>  pii;
// typedef pair<llint, pair<pii, pii> >  edge;
typedef pair<llint, pii>    edge;
int dir[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

int main() {
    int w, h;
    llint   tmp;

    scanf("%d%d", &w, &h);
    vector<bool> vp(w, false), vq(h, false);
    priority_queue<edge, vector<edge>, greater<edge> > qe;

    repeat(i, w) {
        scanf("%lld", &tmp);
        qe.push(edge(tmp, pii(0, i)));
    }
    repeat(j, h) {
        scanf("%lld", &tmp);
        qe.push(edge(tmp, pii(1, j)));
    }

    llint   tot = 0;

    edge    te;
    int np = 0, nq = 0;
    while(!(qe.empty())) {
        te = qe.top(); qe.pop();
        if(te.second.first == 0) {
            tot += te.first * (h - nq + 1);
            ++ np;
        }
        else if(te.second.first == 1) {
            tot += te.first * (w - np + 1);
            ++ nq;
        }
    }
    printf("%lld\n", tot);

    return 0;
}


Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl


int main() {

    string S;
    int K;
    cin >> S >> K;

    vector<string> v;
    for (int i = 0; i < S.size(); i++) {
        for (int j = i;j < i + 5; j++) {
            v.push_back(S.substr(i, j - i + 1));
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    cout << v[K - 1] << endl;
}

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


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

  deque<int> ans;
  queue<int> q;
  vector<bool> used(N, false);
  q.push(0);
  ans.push_back(0);
  used[0] = true;
  while (q.size()) {
    int s = q.front(); q.pop();
    int cnt = (s == 0) ? 0 : 1;
    for (auto&& t : G[s]) {
      if (cnt < 2 && !used[t]) {
        cnt++;
        q.push(t);
        used[t] = true;
        if (s == ans.front()) {
          ans.push_front(t);
        } else {
          ans.push_back(t);
        }
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] + 1 << ( (i != ans.size() - 1) ? ' ' : '\n' );
  }
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define ll        long long
#define endl      "\n"
#define loop(n)   for(int i=0;i<n;i++)

using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length(),x=0;
    loop(n){
        if(s[i]==t[i])x++;
        else{x=0; break;}
    }
    if(x!=0 && n==(t.length()-1)){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
 
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;//(cost,to)
using vP = vector<P>;
using vvP= vector<vP>;

const int INF = 1001001001;


int main(){
    int h,w,k;cin>>h>>w>>k;
    
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    
    int ans=0;
    
    rep(i,1<<h)rep(j,1<<w){
        int count = 0;
        rep(di,h)rep(dj,w){
            if(((i>>di)&1) && ((j>>dj)&1) && s[di][dj]=='#')count++;
        }
        
        if(count==k)ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
n=int(input())
digit=len(str(n))
def su(k):
  t=[int(str(k)[i]) for i in range(len(str(k)))]
  return sum(t)
m=su(n)
for i in range(1,digit):
  m=max(m,su(pow(10,i)*(n//pow(10,i))-1))
print(m)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    ll money=A*X+B*Y;
    ll mi=min(X,Y);
    ll money2=A*(X-mi)+B*(Y-mi)+2*C*mi;
    ll ma=max(X,Y);
    ll money3=2*C*ma;
    cout<<min(min(money,money2),money3)<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

bool isPar(string s)
{
    ll n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return 0;
        }
    }
    return 1;
}

ll nOfD(ll n)
{
    ll d=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) d+=2;
        i++;
    }
    if(i * i == n)d++;
    return d;
}
ll sOfD(ll n)
{
    ll sum=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) sum+=i,sum+=n/i;
        i++;
    }
    if(i * i == n)sum+=i;
    return sum;
}
bool isP(ll x)
{
    if(x==2)return 1;
    if(x<2 || x%2==0)return 0;
    for(ll i=3;i * i <= x;i+=2)
    {
        if(x%i==0)return 0;
    }
    return 1;
}
ll lcm(ll a, ll b)
{
    return (a / __gcd(a, b) * b);
}
ll nPr(ll n,ll r)
{
    if(r==0)return 1;
    ll ans = 1;
    while(r--)ans*=n,n--;
    return ans;
}
ll nCr1(ll n,ll r)
{
    if(r==0)return 1;
    ll ans=r;
    ll rr=r;
    while(--rr)ans*=rr;
    return nPr(n,r)/ans;
}
ll power(ll x, ll y)
{
      ll ans=1;
      while(y--)ans*=x;
      return ans;
}
ll nCr(ll n,ll r)
{
     if(n==r ||r==0) return 1;
     if(r>n)return 0;
     if(r==1) return n;
     return nCr(n-1,r) + nCr(n-1,r-1);
}
///priority_queue<int,vector<int>,greater<int> >pq;
//###################################################\\


int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    ///freopen("ss.txt","r",stdin);
    ///freopen("out.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        ll a[n];
        for(int i=0;i<n;i++)cin>>a[i];
        sort(a,a+n);
        //set<vector<int> >s;
        ll ans=0;
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                for(int k=j+1;k<n;k++)
                {
                    if(a[k]<(a[i]+a[j]) && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])ans++;
                }
            }
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

const int N = 1001;
int F[1001];
int V, d;

vector<int> Alist[1001];

int f(int n)
{
  if (n == -1) return 1;
  else if (n == 0) return 1;
  else if (n <= 1000) return F[n];
  else return -1;
}

void dfs(int v, bool *visited)
{
  visited[v] = true;
  for (int i=0;i<Alist[v].size();i++)
  {
    int w = Alist[v][i];
    if (!visited[w]) dfs(w, visited);
  }
  return;
}


int num_components()
{
  bool visited[1001];
  int n = 0;
  for (int i=1;i<=V;i++) visited[i]=false;
  for (int v=1;v<=V;v++)
  {
    if (!visited[v])
    {
      dfs(v, visited);
      n++;
    }
  }
  return n;
}

int main()
{
  while (cin >> V >> d)
  {
    for (int i=1;i<=V;i++)
      F[i] = ((f(i-1) % N)+ (f(i-2) % N)) % N;

    for (int i=1;i<=V;i++) Alist[i].clear();
    for (int i=1;i<=V;i++)
    {
      for (int j=i+1;j<=V;j++)
      {
        if (abs(f(i)-f(j)) < d)
        {
          Alist[i].push_back(j);
          Alist[j].push_back(i);
        }
      }
    } // Graph created
    int res = num_components();
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD (int)(1e9+7)
#define INF 0x3f3f3f3f
#define MAXN (int)(51)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
ll n,K;
ll dp[MAXN];
vector< vll > a(MAXN,vll (MAXN));
vector< vll > b(MAXN,vll (MAXN));
vector< vll > F(MAXN,vll (MAXN));
void multiply( vector< vll > &a,vector <vll> &b) 
{
    ll mul[n+1][n+1]; 
    for (int i = 1; i <= n; i++) 
    { 
        for (int j = 1; j <=n; j++) 
        { 
            mul[i][j] = 0; 
            for (int k = 1; k <= n; k++) 
                mul[i][j]=addmod(mul[i][j],mult(a[i][k],b[k][j])); 
        } 
    } 
      for (int i=1; i<=n; i++) 
        for (int j=1; j<=n; j++) 
            a[i][j] = mul[i][j]; 
} 
  
void power( vector < vll > &f,ll n) 
{
	if(n==1)return; 
    power(f,n/2); 
    multiply(f,f); 
    if (n%2 != 0) 
        multiply(f,b); 

} 

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

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>a[i][j];
			b[j][i]=a[i][j];
			F[j][i]=b[j][i];
		}
	}
	for(int i=1;i<=n;i++)
		dp[i]=1;
	ll res=0;
	power(F,K);
    for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			res=addmod(res,mult(F[i][j],dp[j]));
		}
	}
	cout<<res<<endl;
  	
}


Measured memory_bytes: 384
// Problem : A - Guess The Number
// Contest : Virtual Judge - Showdown
// URL : https://vjudge.net/contest/391413#problem/A
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n,m;
	cin>>n>>m;
	vi v(n);
	bool vis[n],flag=true;
	loop(i,n)
	vis[i]=false;
	loop(i,m)
	{
		int x,y;
		cin>>x>>y;
		x--;
		if(!vis[x] || y==v[x])
		{
			v[x]=y;
			vis[x]=true;
		}
		else 
		flag=false;
	}
	if(n==1)
	{}
	else if(v[0]==0 && !vis[0])
	v[0]=1;
	else if(v[0]==0)
	flag = false;
	if(flag)
		trav(i,v)
		cout<<i;
	else
		cout<<-1;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
N = int(input())
an = list(map(int, input().split()))

sub = []

heikin = [sum(an)//len(an), sum(an)//len(an)+1]

for hei in heikin:
    s_sub = 0
    for a in an:
        s_sub += (hei - a)**2
    sub.append(s_sub)

print(min(sub))


Measured memory_bytes: 2940
# coding: utf-8
def main():
    a, b = map(int, input().split())
    ans = ''
    if a >= b:
        for i in range(a):
            ans += str(b)
    else:
        for i in range(b):
            ans += str(a)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long long a[101];
int main()
{
	long long n;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	long long t=a[1];
	for(int i=1;i<n;i++)
		t=t/__gcd(t,a[i+1])*a[i+1];
	printf("%lld",t);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using pii = pair<int,int>; 
using db = double; 
using vi = vector<int>; 
#define fir first
#define sec second
#define pb push_back
#define lowbit(x) ((x)&(-(x))) 

struct data {
	int a, b, c; 
}p[200000]; 

int x, y, z; 
ll l[200000], r[200000]; 

bool cmp(data x, data y) {
	return x.b-x.c > y.b-y.c; 
}

int main() {
	scanf( "%d%d%d", &x, &y, &z ); 
	int n = x+y+z;
	for (int i = 1; i <= n; ++i) 
		scanf( "%d%d%d", &p[i].a, &p[i].b, &p[i].c ); 
	sort(p+1, p+n+1, cmp); 
	
	l[y] = 0; multiset<ll> S; 
	for (int i = 1; i <= y; ++i) {
		l[y]+=p[i].b; 
		S.insert(p[i].b-p[i].a); 
	}
	for (int i = y+1; i < n-z+1; ++i) {
		l[i]=l[i-1]+p[i].b; 
		S.insert(p[i].b-p[i].a); 
		auto u = S.begin(); 
		l[i]-=*u; S.erase(u); 
	}
	
	r[n-z+1] = 0; S.clear(); 
	for (int i = n; i >= n-z+1; --i) {
		r[n-z+1]+=p[i].c; 
		S.insert(p[i].c-p[i].a); 
	}
	for (int i = n-z; i > y; --i) {
		r[i]=r[i+1]+p[i].c; 
		S.insert(p[i].c-p[i].a); 
		auto u = S.begin(); 
		r[i]-=*u; S.erase(u); 
	}
	
	ll ans = 0; 
	for (int i = y; i < n-z+1; ++i) 
		ans = max(ans, l[i]+r[i+1]); 
	cout<<ans<<endl; 
}


Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;


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

    int n; cin >> n;

    std::vector<int> v(n);
    std::vector<int> c(n);

    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];

    int ans = -1000000;

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit)
    {
        int val=0, cost=0;

        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) {
                val+=v[i];
                cost+=c[i];
            }
        }

        ans = max(ans, val-cost);

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
#define ll long long
using namespace std;



int main(){

    int a;
    string S;

    cin >> S;

    a = S.size();

    for(int i = 0;i < a;i ++){

        cout << "x";
    }

    return 0;
}


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

using namespace std;


int main(){
	int n ; cin>>n;
	string s ; cin>>s;
	bool b = true;
	for(int i = 0 ; i < n / 2 ; i++){
		if(s[i]!=s[i+n/2]){
			b=false;
		}
	}
	if(n%2==1){
		b=false;
	}
	if(b){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}

	int l ; cin>>l;
	
	
	
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};


int main(void){
    string a,N;
    N="0";
    cin >> a;
    N+=a;
    int L=N.length();
    int ans=0;
    for(int i=L-1;i>=0;i--){
        int num=N[i]-'0';
        if(num==10) num=0,N[i-1]++;
        ans+=min(num,10-num);
        if(num>=5) if(num>=6 || N[i-1]-'0'>=5) N[i-1]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2460
#include<iostream>
using namespace std;
int main(){
    long long n,k,ans=0LL;
    cin>>n>>k;
    for(long long b=k+1LL;b<=n;b++)ans+=(n/b)*(b-k)+max(n%b-k+(k!=0LL),0LL);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256