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


int func(int n)
{
    if (n % 100 != 0) {
        return 0;
    }
    return func(n / 100) + 1;
}

int main()
{
    int D, N;
    cin >> D >> N;

    int count = 0;
    for (int i = 1; ; i++) {
        if (func(i) == D) {
            count++;
            if(count == N){
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n, k;
   cin >> n >> k;
   vector<int> num(n);
   rep(i, 0, k) {
      int d;
      cin >> d;
      rep(i, 0, d) {
         int a;
         cin >> a;
         a--;
         num[a]++;
      }
   }
   int ans = 0;
   rep(i, 0, n) if (num[i] == 0) ans++;
   cout << ans << endl;
   return 0;
}

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

int main() {
    long N, x;
    cin >> N;
    for (int i = 1; i <= sqrt(N); i++) {
        if (N % i == 0) {
            x = i;
        }
    }
    cout << x + N / x - 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


int main(){

	int s;
	vector<int>W,K;

	rep(i,20){

		cin >> s;
		if(i<10) W.push_back(s);
		else K.push_back(s);
	}

	sort(W.begin(),W.end()); sort(K.begin(),K.end());

	cout << W[9]+W[8]+W[7] << " " << K[9]+K[8]+K[7] << endl;

	return 0;
}

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

int main() {
  string s;

  cin >> s;

  if (s.size() % 2 != 0) {
    cout << "No";
    return 0;
  }

  for (int i = 0; i < (int)s.size(); i += 2) {
    if (s[i] != 'h' || s[i + 1] != 'i') {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";

  return 0;
}

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

int count(string str){
    int num=0;
    for(int i=0; i < str.length() ; i++){
        if(str[i]== '1'){
            num+=1;
        }
    }
    return num;
}

int main (){
    string s;
    cin >> s;
    cout << count(s);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){

  int n;
  int v[100000];
  vector<int> a(100001);
  vector<int> b(100001);

  for(int i=0;i<100001;i++){
    a[i]=0;
    b[i]=0;
  }

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

  //cout << n << endl;
  for(int i=0;i<n;i++){
    //cout << v[i] << " ";
  }
  //cout << endl;

  for(int i=0;i<n;i+=2){
    a[v[i]]++;
  }
  for(int i=1;i<n;i+=2){
    b[v[i]]++;
  }
  int a_num,b_num;
  if(n%2==0){
    a_num=n/2;
    b_num=n/2;
  }
  else{
    a_num=n/2+1;
    b_num=n/2;
  }
  //cout << a_num << endl;
  //cout << b_num << endl;

  int max_a = *max_element(a.begin(),a.end());
  int max_b = *max_element(b.begin(),b.end());

  //cout << max_a << endl;
  //cout << max_b << endl;


  int max_a_index = distance(a.begin(),max_element(a.begin(),a.end()));
  int max_b_index = distance(b.begin(),max_element(b.begin(),b.end()));


  //cout << max_a_index << endl;
  //cout << max_b_index << endl;
  int max_a_2nd;
  int max_b_2nd;
  int max_a_2nd_i;
  int max_b_2nd_i;

  if(max_a_index==max_b_index){
    //cout << "same number!" << endl;
    a[max_a_index]=0;
    b[max_b_index]=0;
    max_a_2nd = *max_element(a.begin(),a.end());
    max_b_2nd = *max_element(b.begin(),b.end());
    max_a_2nd_i = distance(a.begin(),max_element(a.begin(),a.end()));
    max_b_2nd_i = distance(b.begin(),max_element(b.begin(),b.end()));

    if(max_a_2nd > max_b_2nd){
      max_a=max_a_2nd;
    }
    else{
      max_b=max_b_2nd;
    }

    //cout << max_a << endl;
    //cout << max_b << endl;
  }
  //cout << a_num << endl;
  //cout << b_num << endl;
  cout << (a_num - max_a)+(b_num - max_b) << endl;



  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll l, r, d;
    cin >> l >> r >> d;
    ll ans = 0;
    for (ll i = l; i <= r; i++)
    {
        if (i % d == 0)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>


int sieve[10000000+7];


int main(){
    int n;
    scanf("%d", &n);

    for (int i=2; i < n; i++){
        for (int j=i+i; j <= n; j+=i)
            sieve[j]++;
    }

    long long ans = 0;
    for (int i=1; i <=n; i++){
        ans += (long long)i*(sieve[i]+2);
    }

    printf("%lld\n", ans-1);

    return 0;
}


Measured memory_bytes: 40788
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){
    int N,result;
    cin >> N;
    if(N<105){
        result = 0;
    } if (105 <=N && N<135){
        result = 1;
    } if (135<=N && N<165){
        result = 2;
    } if (165 <= N && N < 189){
        result = 3;
    } if (189<= N && N<195){
        result =4;
    } if ( 195 <= N){
        result = 5;
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _##i = (b); i <= _##i; ++i)
#define FORD(i, a, b) for (int i = (a), _##i = (b); i >= _##i; --i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define left lajcljascjljl
#define right aucouasocjolkjl
#define y0 u9cqu3jioajc

#define TWO(X) (1LL<<(X))
#define CONTAIN(S,X) ((S) & TWO(X))

int rand16() {
    return rand() & (TWO(16) - 1);
}
int my_rand() {
    return rand16() << 15 | rand16();
}

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

const int MN = 811;

int m, n, k;
char a[MN][MN];
int d[MN][MN];

const int di[4] = {-1,1,0,0};
const int dj[4] = {0,0,-1,1};

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9) << boolalpha;
    while (cin >> m >> n >> k) {
        FOR(i,1,m) FOR(j,1,n) cin >> a[i][j];

        memset(d, -1, sizeof d);
        queue<int> qu;
        queue<int> qv;
        FOR(i,1,m) FOR(j,1,n) if (a[i][j] == 'S') {
            d[i][j] = 0;
            qu.push(i);
            qv.push(j);
        }
        while (!qu.empty()) {
            int u = qu.front(); qu.pop();
            int v = qv.front(); qv.pop();
            int l = d[u][v];
            if (l == k) continue;

            REP(dir,4) {
                int uu = u + di[dir], vv = v + dj[dir];
                if (uu < 1 || uu > m || vv < 1 || vv > n) continue;
                if (d[uu][vv] >= 0) continue;
                if (a[uu][vv] == '#') continue;

                d[uu][vv] = l + 1;
                qu.push(uu);
                qv.push(vv);
            }
        }

        int res = 1000111000;
        FOR(i,1,m) FOR(j,1,n) {
            int l = d[i][j];
            if (l < 0) continue;

            int need = min(min(i - 1, m - i), min(j - 1, n - j));
            res = min(res, (need + k - 1) / k + 1);
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 6016
#include <stdio.h>

int max(int a, int b) {
	return a > b ? a : b;
}

int main() {
	int arr[2][110];
	int i, j;
	int n;
	int f[110][2];

	scanf("%d", &n);
	for (i = 0; i < 2; i++) {
		for (j = 0; j < n; j++) {
			scanf("%d", &arr[i][j]);
		}
	}

	f[0][0] = arr[0][0];
	f[0][1] = arr[0][0] + arr[1][0];

	for (i = 1; i < n; i++) {
		f[i][0] = f[i - 1][0] + arr[0][i];
		f[i][1] = max(f[i][0] + arr[1][i], f[i - 1][1] + arr[1][i]);
	}

	printf("%d", f[n - 1][1]);

	getchar(); getchar();
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <set>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int a,b,c,d,e,f;
vector<int> wtr;
vector<int> sgr;

struct sol{
    int wtr,sgr;
};

sol thi(sol sol1,sol sol2){
    sol rtn;
    if(sol1.sgr*sol2.wtr>=sol1.wtr*sol2.sgr){
        rtn = sol1;
    }else{
        rtn = sol2;
    }
    return rtn;
}


int main(void){
    cin >> a >> b >> c >> d >> e >> f;
    for(int i=0;a*i*100<=f;++i){
        for(int j=0;a*i*100+b*j*100<=f;++j){
            int vol = a*i*100+b*j*100;
            if(0<vol){
                wtr.push_back(vol);
            }
        }
    }
    for(int i=0;c*i<=f;++i){
        for(int j=0;c*i+d*j<=f;++j){
            int vol = c*i+d*j;
            if(0<vol){
                sgr.push_back(vol);
            }
        }
    }
    set<int> s(sgr.begin(),sgr.end());
    vector<int> sgr2(s.begin(),s.end());
    set<int> w(wtr.begin(),wtr.end());
    vector<int> wtr2(w.begin(),w.end());
    sol res = {a*100,0};
    REP(i,wtr2.size()){
        REP(j,sgr2.size()){
            if(wtr2[i]+sgr2[j]<=f){
                if(100*sgr2[j]<=wtr2[i]*e){
                    sol sol1 = {wtr2[i],sgr2[j]};
                    res = thi(res,sol1);
                }
            }else{
                break;
            }
        }
    }
    cout << res.wtr+res.sgr << " " << res.sgr << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define Maxn 100010
int n, a[Maxn], S_g[Maxn], P_g[Maxn], Ans;

inline int gcd(int x, int y) { if (!y) return x; return gcd(y, x%y); }
int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	S_g[1]=a[1]; for (int i=2; i<=n; i++) S_g[i]=gcd(S_g[i-1], a[i]);
	P_g[n]=a[n]; for (int i=n-1; i>=1; i--) P_g[i]=gcd(P_g[i+1], a[i]);
	for (int i=1; i<=n; i++) Ans = max(Ans, gcd(S_g[i-1], P_g[i+1])); 
	printf("%d\n", Ans);
}

Measured memory_bytes: 1408
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s >> s;
	printf("A%cC\n", s[0]);

	return 0;
}

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

using namespace std;

using lint = long long;
using ldouble = long double;

map<pair<int, int>, int> pat;
map<pair<int, int>, pair<int, int>> opp;

const int dx[4] = {0, -1, 1, 0}, dy[4] = {-1, 0, 0, 1};

bool paint(pair<int, int> p, int c) {
    // cerr << p.first << "," << p.second << " " << c << endl;

    if (!opp.count(p)) return true;
    if (pat.count(p)) return pat[p] == c;

    pat[p] = c;

    for (int i = 0; i < 4; ++i) {
        auto q = make_pair(p.first + dx[i], p.second + dy[i]);
        if (!paint(q, (q == opp[p] ? 1 - c : c))) {
            pat.erase(p);
            return false;
        }
    }
    return true;
}

bool solve() {
    pat.clear();
    opp.clear();

    int N;
    cin >> N;
    if (N == 0) return false;

    vector<pair<int, int>> T(N);
    for (auto& t : T) {
        char dir;
        cin >> t.first >> t.second >> dir;
        auto s = t;
        ++(dir == 'x' ? s.first : s.second);
        opp[t] = s;
        opp[s] = t;
    }

    for (int i = 0; i < N; ++i) {
        if (pat.count(T[i])) continue;
        if (!paint(T[i], 0) && !paint(T[i], 1)) {
            cout << "No" << endl;
            return true;
        }
    }

    cout << "Yes" << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 12344
n = int(input())
l = list(map(int, input().split()))
l.sort()
#l = list(set(l))
#l.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            #print(i,j,k)
            if (l[i]+l[j] > l[k]):
                if (l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]):
                    ans += 1
print(ans)

Measured memory_bytes: 9192
N,K = map(int, input().split())
A = [int(c) for c in input().split()]
cnt = 0
p = 0
used = [False]*N
used[0] = True
while True:
  p = A[p]-1
  cnt += 1
  if used[p]:
    m = p
    break
  used[p] = True
p = 0
while m!=p and K:
  cnt -= 1
  p = A[p]-1
  K -= 1
if K==0:
  print(p+1)
  import sys
  sys.exit()
K %= cnt
while K:
  p = A[p]-1
  K -= 1
print(p+1)

Measured memory_bytes: 92372
import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val (n, q) = jin.readLine().split(" ").map { it.toInt() }
    val next = IntArray(n + 1)
    val last = IntArray(n + 1)
    val colors = listOf(0) + jin.readLine().split(" ").map { it.toInt() }
    val bit = BinaryIndexTree(1, n)
    for (j in 1..n) {
        if (last[colors[j]] == 0) {
            bit.update(j, 1)
        }
        next[last[colors[j]]] = j
        last[colors[j]] = j
    }
    val queries = Array(q) {
        val (l, r) = jin.readLine().split(" ").map { it.toInt() }
        Query(it, l, r)
    }
    queries.sortBy { it.from }
    val answer = IntArray(q)
    var from = 1
    for (query in queries) {
        while (from < query.from) {
            bit.update(from, -1)
            if (next[from] != 0) {
                bit.update(next[from], 1)
            }
            from++
        }
        answer[query.ix] = bit.query(query.to)
    }
    println(answer.joinToString("\n"))
}

data class Query(val ix: Int, val from: Int, val to: Int)

class BinaryIndexTree(val treeFrom: Int, treeTo: Int) {
    val value = IntArray(treeTo - treeFrom + 2)

    fun update(index: Int, delta: Int) {
        var i = index + 1 - treeFrom
        while (i < value.size) {
            value[i] += delta
            i += i and -i
        }
    }

    fun query(to: Int): Int {
        var res = 0
        var i = to + 1 - treeFrom
        while (i > 0) {
            res += value[i]
            i -= i and -i
        }
        return res
    }
}

Measured memory_bytes: 141520
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)



int main()
{
  int N;
  cin >> N;
  vector<int> h(N);
  rep (i,N) cin >> h.at(i);
  
  int count = 1;
  rep(i,N){
   if (i == 0) continue;
    bool see = true; 
    rep(j,i){
       if (h.at(j) > h.at(i)) see = false;
     }
    if (see) count++;
  }
  
  cout << count <<endl;
  
  
    return 0;
}


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

using namespace std;
#define MAX (int)1e6
vector<int> dp(MAX,INT_MAX);

int solve(vector<int> a , int n) 
{
	dp[0] = 0;
	for (int i = 0 ; i <= n ; i++)
	{
		for (int j : {i + 1, i + 2}) 
		{
			if (j <= n) dp[j] = min(dp[j],dp[i] + abs(a[i]-a[j]));	
		}
	}
	return dp[n-1];	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0 ; i < n ; i++) cin >> a[i];
	cout << solve(a,n) << "\n";
	return 0;
}

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

int main()
{
  string s;
  cin >> s;
  char tmp = s[0];
  int ans = 0;
  for (int i = 1; i < s.size(); i++) {
	if (tmp != s[i]) {
	  ans++;
	  tmp = s[i];
	}
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
ll N;

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

  cin >> N;
  ll ans = N*(N-1)/2;

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

Measured memory_bytes: 256
s=[1,0,0,0]
for c in input():
  if c!="?":
    i="ABC".find(c)
    s[i+1]+=s[i]
  else:
    s=[s[0]*3,s[1]*3+s[0],s[2]*3+s[1],s[3]*3+s[2]]
  s=[i%(10**9+7)for i in s]
print(s[3])

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1), b(N+1,0);
    for(int i=1; i<=N; i++) cin >> a[i];
    
    b[1]=1;
    
    bool flag=false;
    int i=1, cnt=0;
    while(1){
        if(b[2]==1){
            flag=true;
            break;
        }
        if(cnt>N*10){
            cnt = -1;
            break;
        }
        
        b[i]=0;
        b[a[i]]=1;
        i = a[i];
        cnt++;
        //cout << i <<" "<< cnt << endl;
    }
    cout << cnt << endl;
}


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

struct edge {
  edge() {}
  edge(int to, int cost, int c) : to(to), cost(cost), c(c) {}

  int to, cost, c;
};

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

  map<int, vector<edge>> G[100000];
  vector<map<int, int>> C(100000);
  for (int i = 0; i < m; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    --u, --v;

    G[u][c].push_back(edge(v, 0, c));
    G[v][c].push_back(edge(u, 0, c));
    C[v][c] = 1;
    C[u][c] = 1;
  }

  for (int i = 0; i < n; ++i) {
    for (auto &v : C[i]) {
      G[i][v.first].push_back(edge(i, 0, 0));
      G[i][0].push_back(edge(i, 1, v.first));
    }
  }

  using P = pair<int, pair<int, int>>;
  const int inf = 1001001001;

  priority_queue<P, vector<P>, greater<P>> pq;
  vector<map<int, int>> d(100000);
  d[0][0] = 0;
  pq.push(P(0, make_pair(0, 0)));

  while (!pq.empty()) {
    P p = pq.top();
    pq.pop();

    int v = p.second.first;
    int c = p.second.second;
    if (d[v][c] < p.first) continue;
    for (auto &e : G[v][c]) {
      if (!d[e.to].count(e.c) || d[e.to][e.c] > d[v][c] + e.cost) {
        d[e.to][e.c] = d[v][c] + e.cost;
        pq.push(P(d[e.to][e.c], make_pair(e.to, e.c)));
      }
    }
  }

  int ans = inf;
  for (auto &i : d[n - 1]) ans = min(ans, i.second);

  if (ans == inf)
    cout << -1 << endl;
  else
    cout << ans << endl;
}


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

pre = 99
cnt = 0
for i in A:
    cnt += B[i-1]
    if i == pre + 1:
        cnt += C[i-2]
    pre = i

print(cnt)

Measured memory_bytes: 3064
fun main (args : Array<String>) {
	val (len, num1) = readLine()!!.split(" ").map(String::toInt)
	val str1 = readLine()
	var num2 : Int = num1.toInt()
	var str2 : String = str1.toString()
	var count : Int = 0
	var result : String = ""
	for (i in str2) {
		count++
		if (count == num2) {
			if (i.toString() == "A") {
				result += "a"
			} else if (i.toString() == "B") {
				result += "b"
			} else if (i.toString() == "C") {
				result += "c"
			}
		} else {
			result += i
		}
	}
	println("${result}")
}

Measured memory_bytes: 35924
import java.io.*;
public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split("");
		int bet = 0;
		for (int i = 1; i < line.length; i++) {
			if (!line[i].equals(line[i-1])) {
				bet++;
			}
		}
		System.out.println(bet);
	}
}

Measured memory_bytes: 17492
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s;
  rep(i,3){
    string t;
    cin >> t;
    s+=t[i];
  }
  cout << s << endl;
}


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

int main(){
	char input[20];
	scanf("%s", input);
	int len=strlen(input);
	
	for(int i=0; i<len; i++){
		if(input[i]==','){
			input[i]=' ';
		}
	}
	printf("%s", input);
	
	
	return 0;
}

Measured memory_bytes: 1676
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>

using namespace std;

int main() {
    
    
    string s;
    cin >> s;
    
    map<char, int> m;
    for (int i = 0; i < s.size(); ++i)
    {
        m[s[i]]++;
    }
    if (m.size() == 2)
    {
        for (auto itr = m.begin(); itr != m.end(); ++itr)
        {
            if (itr->second != 2)
            {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    
    
    return 0;
}

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

#include <iostream>

using namespace std;

int main()
{
    int n;
    int64_t a[10000];

    cin >> n;

    int64_t min = 1000000 + 1, max = -1000000 - 1, sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];

        min = std::min(min, a[i]);
        max = std::max(max, a[i]);
        sum += a[i];
    }

    cout << min << ' ' << max << ' ' << sum << endl;
}

Measured memory_bytes: 1236
#include <iostream>

int main()
{
    int i, x;
    int arr[9999] = {};

    i = 0;

    while (1)
    {
        std::cin >> x;

        if (x == 0 || i > 9999)
        {
            break;
        }

        arr[i++] = x;
    }


    for (int n = 0; n < i; n++)
    {
        std::cout << "Case " << n + 1 << ": " << arr[n] << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main(){
  int a[7],b[7];
  int i;
  for(i=0;i<7;i++){
    cin >> a[i];
    cin >> b[i];
  }
  for(i=0;i<7;i++){
    cout << a[i]-b[i] <<endl;
  }
  return(0);
}



Measured memory_bytes: 3116
#include <stdio.h>
#define FREE 0
#define N_FREE 1
#define Q 2
#define N 8
 
int board[N][N];
int row[N],col[N],dneg[2*N-1],dpos[2*N-1];
 
void printboard(){
  int i, j;
  
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(board[i][j] == N_FREE && row[i] != j)
    return;
    }
  }
  
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(row[i] == j)
    printf("Q");
      else
    printf(".");
    }
    printf("\n");
  }
};
 
void putQueen(int i){
  int j;
   
  if(i==N){  
    printboard();
    return;
  }
 
  for(j=0;j<N;j++){
    if(col[j]==N_FREE || dpos[i+j]==N_FREE || dneg[i-j+N-1]==N_FREE){ 
      continue;
    }
 
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = N_FREE; 

    putQueen(i+1);
     
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
};
 
int main(){
  int k,r,c;
  int i;
  
     
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d",&r);
    scanf("%d",&c);
    board[r][c] = N_FREE; //1
  }
   
  putQueen(0);
      
  return 0;
}

Measured memory_bytes: 572
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    if(s.size()%2 == 0){
        rep(i,s.size()/2){
            if(s[s.size()/2-1-i] != s[s.size()/2+i]){
                ans++;
            }
        }
    }
    else{
        rrep(i,s.size()/2+1){
            if(s[s.size()/2-i] != s[s.size()/2+i]){
                ans++;
            }
        }
    }
    dunk(ans);
    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	string s;
	cin>>s;
	cout<<s;
	if(s.back()=='s')cout<<"es"<<endl;
	else cout<<"s"<<endl;
}


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




string alphabet = "abcdefghijklmnopqrstuvwxyz";

struct restaurant {
	string name;
	int point;
	int id;
};

bool operator<(const restaurant & a, const restaurant & b) {
	for (int i = 0; i < a.name.size(); i++) {
		if (i >= b.name.size()) return false;
		if (alphabet.find(a.name[i]) < alphabet.find(b.name[i])) return true;
		if (alphabet.find(a.name[i]) > alphabet.find(b.name[i])) return false;
	}
	if (a.name.size() < b.name.size()) return true;
	return a.point > b.point;
}


int main() {
	int n;
	cin >> n;
	set<restaurant> l;
	restaurant buf;
	for (int i = 1; i <= n; i++) {
		cin >> buf.name >> buf.point;
		buf.id = i;
		l.insert(buf);
	}

	for (restaurant i : l) {
		cout << i.id << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int N;
	cin>>N;
	
	int t = 0,x=0,y=0;
	
	for(int i=0;i<N;i++){
		int tt,xx,yy;
		cin>>tt>>xx>>yy;
		int tdif = tt-t;
		int k = abs(xx-x)+abs(yy-y);
		if(tdif<k){
			cout<<"No"<<endl;
			return 0;
		}
		if((tdif-k)%2==1){
			cout<<"No"<<endl;
			return 0;
		}
		t=tt;
		x=xx;
		y=yy;
	}
	
	cout<<"Yes"<<endl;
	
    return 0;
}


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

using namespace std;

int n;
int a[maxn];

struct Edge{
	int x, y, z;
};
vector<Edge> v;

int main(){
	scanf("%d", &n);
	if(n == 2) return printf("2 2\n1 2 0\n1 2 1"), 0;//debug:我究极弱智  
	n--;
	int x = 1, y = 2;
	while(1){
		if(x << 2 > n) break;
		x <<= 1, y++;
	}
	bool tag = false;
	if((x << 2) - 1 == n) x <<= 1, y++, tag = true;
	for(int i = 1;i < y;i++){
		v.push_back((Edge){i, i + 1, 0});
		v.push_back((Edge){i, i + 1, x >> (i - 1)});
	}
	if(!tag){
		v.push_back((Edge){1, y, n});
		for(int i = 1;i <= y;i++) a[i] = n & 1, n >>= 1;
		int sum = 1 << (y - 1);
		for(int i = y - 1;i;sum += a[i] * (1 << (i - 1)), i--) if(a[i]) v.push_back((Edge){1, y - i + 1, sum});
	}
	printf("%d %d\n", y, v.size());
	for(int i = 0;i < v.size();i++) printf("%d %d %d\n", v[i].x, v[i].y, v[i].z);
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};int dy[4] = {0,-1,0,1};

int main() {
    int n,w;cin >> n >> w;
    vector<pair<int,int> > v(n);
    for(int i=0;i<n;i++){
	cin >> v[i].first >> v[i].second;
    }
    int dp[n+1][w+1] = {0};
    rep(i,n+1)rep(j,w+1)dp[i][j] = 0;
    for(int i=1;i<=n;i++){
	for(int j=0;j<=w;j++){
	   chmax(dp[i][j],dp[i-1][j]);
	   int value = v[i-1].first;
	   int weight = v[i-1].second;
	   if(j>=weight)  chmax(dp[i][j],max(dp[i-1][j-weight]+value,dp[i][j-weight]+value));
	}
    }
    cout << dp[n][w] << endl;
/*    for(int i=0;i<=n;i++){
	for(int j=0;j<=w;j++){
	    cout << dp[i][j] << " ";
	}
	cout << endl;
    }
*/
    return 0;
}



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

using namespace std;

using ll = long long;

const ll MOD = 1e9 + 7;
const ll NMAX = 100005;

vector<ll> graf[NMAX];
ll dp[2][NMAX];
bool viz[NMAX];

void dfs(ll nod)
{
    dp[1][nod] = dp[0][nod] = 1;
    for(auto vertice: graf[nod]){
        if(!viz[vertice]){
            viz[vertice] = true;

            dfs(vertice);

			dp[0][nod] = dp[0][nod] * (dp[0][vertice] + dp[1][vertice]) % MOD;
			dp[1][nod] = dp[1][nod] * dp[0][vertice] % MOD;
        }
    }
}

int main()
{
    int n;
    cin>>n;
    for(int i = 0 ; i < n -  1 ; i++){
        int x, y;
        cin>>x>>y;
        graf[x].push_back(y);
        graf[y].push_back(x);
    }

    viz[1] = true;
    dfs(1);
    cout<<(dp[0][1] + dp[1][1]) % MOD;

    return 0;
}


Measured memory_bytes: 12928
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e18
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;


ll dp[200010];
int main(){
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, n)cin >> a[i];
   vector<int> tab(200010, -1);
   dp[0] = 1;
   rep(i, n){
      if(tab[a[i]] == -1 || tab[a[i]] == i){
         dp[i + 1] = dp[i] % MOD;
      }
      else {
         dp[i + 1] = (dp[i] + dp[tab[a[i]]]) % MOD;
      }
      tab[a[i]] = i + 1;
   }
   cout << dp[n] << endl;
}


Measured memory_bytes: 6432
#include<stdio.h>

int main(){
    int x,y;
    char op;
    while(scanf("%d %c %d",&x,&op,&y) && op !='?'){
        if(op == '+'){
            printf("%d\n",x+y);
        } else if(op == '-'){
            printf("%d\n",x-y);
        } else if(op == '*'){
            printf("%d\n",x*y);
        } else if(op == '/'){
            printf("%d\n",x/y);
        }
    }
    return 0;
}


Measured memory_bytes: 2740
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=998244353; //1000000007;

ll mod_pow(ll a,ll x){
    ll ret=1;
    while(x>0){
        if(x&1){(ret*=a)%=MOD;}
        (a*=a)%=MOD;
        x>>=1;
    }
    return ret;
}

int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> A(n,vector<ll>(m));
    for(auto &I:A){for(auto &T:I){cin>>T;}}
    ll cnt=m;
    ll w=0;
    for(int i=0;i<n && w<m;i++,w++){
        for(int h=i+1;h<n;h++){
            if(A[i][w]==0 && A[h][w]==1){swap(A[i],A[h]);}
        }
        if(A[i][w]==0){cnt--; i--; continue;}
        for(int h=i+1;h<n;h++){
            if(A[h][w]){
                for(int w=0;w<m;w++){
                    A[h][w]^=A[i][w];
                }
            }
        }
        if(i+1==n){cnt-=m-w-1;}
    }
    ll ans=mod_pow(2,n+m-1)-mod_pow(2,n+m-cnt-1);
    ans%=MOD;
    if(ans<0){ans+=MOD;}
    cout<<ans<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N;
    cin >> N;
    string tmp = to_string(N);
    int s = 0;
    rep(i, tmp.size())
    {
        s += int(tmp[i]) - 48;
    }
    if (N % s == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }

long long int solve(int size, int a[])
{
    long long int ans = 0;
    if(size%2==0)
    {
        long long int k = size-1;
        for(int i=size-1;i>=0;i--)
        {
            ans+=k*a[i];
            ans = ans%MOD;
            k-=2;
        }
    }
    else
    {
        long long int k = size-1;
        for(int i=size-1;i>=0;i--)
        {
            ans+=k*a[i];
            ans = ans%MOD;
            k-=2;
        }
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int n,m;
    cin>>n>>m;
    int x[n];
    int y[m];
    for(int i=0;i<n;i++)
        cin>>x[i];
    for(int i=0;i<m;i++)
        cin>>y[i];
    long long int sumx = 0;
    sumx = solve(n,x);
    long long int sumy=0;
    sumy = solve(m,y);
    cout<<(sumx*sumy)%MOD<<endl;
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var K = sc.ReadInt();
        var S = sc.ReadInt();
        var ans = 0;
        for (int x = 0; x <= K; x++)
        {
            for (int y = 0; y <= K; y++)
            {
                var z = S - x - y;
                if (0 <= z && z <= K) ans++;
            }
        }
        Console.WriteLine(ans);
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int n, c, f, i, j;
vector<int> a(200000), vis(1000001), spf(1000001, 2);
int main()
{
    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    for (i = 3; i < 1e6; i += 2)
        spf[i] = i;
    for (i = 3; i < 998; i += 2)
        if (spf[i] == i)
            for (j = i * i; j < 1e6; j += i)
                if (spf[j] == j)
                    spf[j] = i;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> a[i], vis[a[i]]++;
    if (vis[1])
    {
        if (vis[1] == 1)
            cout << 1 << '\n';
        else
            cout << 0 << '\n';
        return 0;
    }
    for (i = 0; i < n; i++)
        if (vis[a[i]] == 1)
        {
            if (a[i] != spf[a[i]])
                for (j = spf[a[i]]; j * j <= a[i]; j++)
                    if (a[i] % j == 0 && (vis[a[i] / j] || vis[j]))
                    {
                        c++;
                        break;
                    }
        }
        else c++;
    cout << n - c << '\n';
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll a, b, m;
    cin >> a >> b >> m;
    vector<ll> v(a), u(b);
    for(auto& i : v) cin >> i;
    for(auto& i : u) cin >> i;

    vector<ll> w(m);
    REP(i, m){
        int x, y;
        ll c;
        cin >> x >> y >> c;
        w[i] = v[x-1] + u[y-1] - c;
    }

    cout << min(MIN(v) + MIN(u), MIN(w)) << endl;
    return 0;
}


Measured memory_bytes: 2560
from collections import defaultdict

H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]

def solve() :
    d = defaultdict(int)
    for y in range(H) :
        for x in range(W) :
            d[a[y][x]] += 1
            
    one = 1 if H % 2 == W % 2 == 1 else 0
    two = 0

    if H % 2 == 1 : two += W // 2
    if W % 2 == 1 : two += H // 2
        
    for v in d.values() :
        if v % 4 == 3 :
            one -= 1
            two -= 1
        elif v % 4 == 2 :
            two -= 1
        elif v % 4 == 1 :
            one -= 1
        
        if one < 0 or two < 0 :
            return 'No'
            
    return 'Yes'
    
print(solve())

Measured memory_bytes: 39024
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;

int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int a=1;a<=n;a++){
        ans+=n/a;
        if(n%a==0) ans--;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

char c[] = "BCDE", ans;
int a, b;

int main(){
	while (cin >> a >> b&&a + b){
		ans = 'A';
		int sum = a + b;
		REP(i, 4){
			cin >> a >> b;
			if (sum < a + b){
				ans = c[i];
				sum = a + b;
			}
		}
		cout << ans << " " << sum << endl;
	}

}

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll gcd(ll x, ll y) {
    return y ? gcd(y, x%y) : x;
}

ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> a(n);
    ll l = 1;
    for(auto &x : a) {
        cin >> x;
        l=lcm(l,x/2);
    }
    ll ret = 0;
    //cout << l << endl;
    for(auto &x:a){
        if(l%x==0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/l+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    ans+=(n/i)*max((ll)0,i-k)+max((ll)0,n-(n/i)*i-k+1);
  }
  if(k==0)
    ans-=n;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256