akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>          
using namespace std;
typedef long long ll;

int main() {
    vector<int> x(5);
    int ans;
    for (int i=0; i<5; i++) {
        cin >> x[i];
        if (x[i]==0) {
            ans = i+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll dp[100000 + 1];

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

	for (int i = 0; i < n+1; i++) {
		dp[i] = INT32_MAX;
	}
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		dp[i+1] = min(dp[i]+1, dp[i+1]);
		for (int j = 6; i+j < n + 1; j *= 6) {
			dp[i + j] = min(dp[i] + 1, dp[i + j]);
		}
		for (int j = 9; i+j < n + 1; j *= 9) {
			dp[i + j] = min(dp[i] + 1, dp[i + j]);
		}
	}

	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;

int n, a[200100];

int main(){
	scanf("%d", &n);
	for ( int i = 0; i < n; i++ )
		scanf("%d", a + i);
	for ( int i = n - 1; i >= 0; i -= 2 )
		printf("%d ", a[i]);
	for ( int i = n % 2; i < n; i += 2 )
		printf("%d ", a[i]);
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include<algorithm>
#define MAX 502
using namespace std;

int N;
int T[MAX][MAX], D[MAX][MAX];

int compute(int p, int q) {
    return D[q][q] - D[p - 1][q];
}

int main() {
    for (int i = 0; i < MAX; i++) {
        for (int j = 0; j < MAX; j++) {
            T[i][j] = 0;
            D[i][j] = 0;
        }
    }
    int M, Q, L, R, p, q;
    cin >> N >> M >> Q;
    for (int i = 0; i < M; i++) {
        cin >> L >> R;
        T[L][R]++;
    }
    for (int i = 0; i < MAX - 1; i++) {
        for (int j = 0; j < MAX - 1; j++) {
            D[i + 1][j + 1] = D[i][j + 1] + D[i + 1][j] - D[i][j] + T[i + 1][j + 1];
        }
    }
    for (int i = 0; i < Q; i++) {
        cin >> p >> q;
        cout << compute(p, q) << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    int ret = 1e8;
    for (int i = 0; i < 1 << (h - 1); ++i) {
        int temp = __builtin_popcount(i); // holizontal cut
        vector<int> white(h, 0);
        bool ng    = false;
        bool cut   = false;
        for (int j = 0; j < w; ++j) {
            int row = 0;
            for (int l = 0; l < h; ++l) {
                if (s[l][j] == '1') {
                    white[row]++;
                    if (white[row] > k) {
                        cut = true;
                    }
                }
                if (1<<l & i) {
                    row++;
                }
            }
            if (ng)
                break;
            if (cut) { // vertical cut
                temp++;
                cut = false;
                white.assign(h, 0);
                row = 0;
                for (int l = 0; l < h; ++l) {
                    if (s[l][j] == '1') {
                        white[row]++;
                        if (white[row] > k)
                            ng = true;
                    }
                    if (1<<l & i) {
                        row++;
                    }
                }
            }
            if (ng)
                break;
        }
        if (!ng)
            chmin(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations

L, R = map(int,input().split())
mods = []
for num in range(L, min(R+1,L+2020)):
    mods.append(num % 2019)

ans = float('inf')
for cmb in combinations(mods, 2):
    ans = min(ans, (cmb[0] * cmb[1]) % 2019)
print(ans)

Measured memory_bytes: 40428
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int imos[30][200001];
int main() {
	int N, C;
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		int s, t, c;
		cin >> s >> t >> c;
		c--;
		s = s * 2 - 1;
		t *= 2;
		imos[c][s]++;
		imos[c][t]--;
	}
	for (int i = 0; i < C; i++) {
		for (int j = 1; j <= 200000; j++) {
			imos[i][j] += imos[i][j - 1];
		}
	}
	int ans = 0;
	for (int i = 0; i <= 200000; i++) {
		int sum = 0;
		for (int j = 0; j < C; j++) {
			if (imos[j][i] >= 1) sum++;
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> t(n);
	rep(i,n) cin >> t[i];
	int m;
	cin >> m;
	vector<int> p(m);
	vector<int> x(m);
	rep(i,m) cin >> p[i] >> x[i];
	vector<int> ans(m);
	rep(i,m){
	int sum = 0;
	rep(j,n){
		if(j != p[i] - 1) sum += t[j];
	}	
	    sum += x[i];
		ans[i] = sum;
	}
	rep(i,m) cout << ans[i] << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {

	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+') {
			ans++;
		}else {
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int x;
  cin>>x;
  cout<<1-x<<endl;
  return 0;
}


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

string s, t;
int memo[3010][3010];
int used[3010][3010];

int solve(int i, int j) {
    if(i == s.size() || j == t.size())
        return 0;

    if(memo[i][j] != -1)
        return memo[i][j];

    int r1 = (s[i] == t[j] ? 1 + solve(i+1, j+1) : 0),
        r2 = solve(i+1, j), 
        r3 = solve(i, j+1),
        rTot = max({r1, r2, r3});
    
    used[i][j] = (rTot == r2 ? 2 : (rTot == r3 ? 3 : 1));

    return memo[i][j] = rTot;
}


int main() {
    cin >> s >> t;

    memset(memo, -1, sizeof memo);
    solve(0,0);

    int i = 0, j = 0;
    string res = "";
    while(i < s.size() && j < t.size()) {
        if(used[i][j] == 1) {
            res += s[i];
            i++, j++;
        } else if(used[i][j] == 2)
            i++;
        else 
            j++;
    }
    
    cout << res << "\n";
}

Measured memory_bytes: 71552
import numpy as np
n,m,x=map(int,input().split())
text=[]
cost=[]
for i in range(n):
    text.append(list(map(int,input().split())))
text=np.array(text)

#ビット全探索。bin(i)の各桁を要素に対応させる。
for i in range(2**n):
    flag=0
    bought_text=np.array([0 for j in range(m+1)])
    for j in range(n):
        #0bxxx1と0b0001の比較(＆は論理積)
        if((i>>j)&1):
            bought_text+=text[j]
    for k in range(m):
        if bought_text[k+1]<x:
            flag=1
            break
    if flag==0:
        cost.append(bought_text[0])
print(min(cost) if cost else "-1")

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

int main() {
    int N, W;
    cin >> N >> W;
    int weight[110], value[110];
    for (int i = 0; i < N; i++) cin >> weight[i] >> value[i];

    long long dp[110][100100] = {0};
    for (int i = 0; i < N; i++) {
        for (int sum_w = 0; sum_w <= W; sum_w++) {
            if (sum_w >= weight[i]) dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 86652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(){
    string n;
    cin >> n;
    int len = n.length();

    int sum = 0;
    rep(i, len) sum += n[i] - '0';
    if(sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());
            var max = (n + 1) / 2;
            var minSum = int.MaxValue;
            for (int i = 1; i <= max; i++) {
                var s1 = i.ToString();
                var s2 = (n - i).ToString();
                var sum = s1.Select(x => x - '0').Sum() + s2.Select(x => x - '0').Sum();
                minSum = Math.Min(minSum, sum);
            }

            Console.WriteLine(minSum);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 39752
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}

signed main (){
    int s;
    cin>>s;
    map<int,int> mp;
    mp[s]++;
    for(int i=2;;i++){
        if(s%2==0)s/=2;
        else s=3*s+1;
        if(mp[s]!=0){
            cout<<i<<endl;
            return 0;
        }else mp[s]++;
    }

}
/*
*/


Measured memory_bytes: 256
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    ll wallet = 1000;
    rrep(i, 1, n) {
        if (a[i - 1] <= a[i]) {
            ll stock = wallet / a[i - 1];
            wallet -= stock * a[i - 1];
            wallet += a[i] * stock;
        }
    }
    cout << wallet << endl;
    return 0;
}


Measured memory_bytes: 3196
def main():
    S = input()
    dict = {}
    for i in range(4):
        if S[i] in dict:
            dict[S[i]] += 1
        else:
            dict[S[i]] = 1
    if len(dict.values()) == 2:
        if list(dict.values())[0] == 2:
            return "Yes"
    else:
        return "No"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
class mairala
{
public:
    void solve()
    {
        int n, d, x, y, count = 0;
        cin>>n>>d;
        while(n--)
        {
            cin>>x>>y;
            if(sqrt(pow(x, 2) + pow(y, 2)) <= d) count++;
        }
        cout<<count<<endl;
    }
};
int main(void)
{
    mairala m;
    m.solve();
}

Measured memory_bytes: 3672
a, b, c, d, e, f = map(int, input().split())
a100 = a*100
b100 = b*100

ok = []
for ai in range(31):
    for bi in range(31):
        for ci in range(101):
            for di in range(101):
                ab = ai*a100 + bi*b100
                cd = ci*c + di*d
                if ab + cd > f:
                    break
                else:
                    if (ab/100) * e >= cd:
                        ok.append([ab + cd, cd])
print(*sorted(ok, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])


Measured memory_bytes: 45316
#!/usr/bin/env python3
def solve(s):
    i = 0
    for c in 'AKIHABARA':
        if i < len(s) and c == s[i]:
            i += 1
        elif c == 'A':
            pass
        else:
            return False
    if i != len(s):
        return False
    return True
print(['NO', 'YES'][solve(input())])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main() {
 
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> count(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        count[a[i]]++;
    }
    ll totalCount = 0;
    for (int i = 0; i <= n; i++) {
        if (count[i] > 0) totalCount += ((ll) count[i]) * ((ll)(count[i] - 1)) / 2;
    }
    for (int i = 0; i < n; i++) {
        cout << totalCount - (count[a[i]] - 1) << endl;
    }

    return 0;

}

Measured memory_bytes: 4096
from math import gcd

K = int(input())
out = 0
Count = [0]*K
gcds = [[0]*K for i in range(K)]

for i in range (1,K+1):
    for j in range(1,+K+1):
        value = gcd(i,j)
        gcds[i-1][j-1]=value
        Count[value-1]+=1

for i in range(1,K+1):
    for j in range(1,K+1):
        out +=gcds[i-1][j-1]*Count[j-1] #値*回数
        
print(out)

Measured memory_bytes: 9344
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, M = [int(x) for x in stdin.readline().rstrip().split()]
# 展望台iの標高
H = [0] + [int(x) for x in stdin.readline().rstrip().split()]
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]

near_max = [0 for _ in range(N+1)]

for A, B in AB:
    near_max[A] = max(near_max[A], H[B])
    near_max[B] = max(near_max[B], H[A])

ans = 0

for i in range(1, N+1):
    if H[i] > near_max[i]:
        ans += 1

print(ans)

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;

    if(C % gcd(A, B) == 0) PR("YES");
    else PR("NO");

    return 0;
}

/*



*/

Measured memory_bytes: 3612
let () = Scanf.scanf "%d %d\n0 " @@ fun n t ->
  let ts = Array.init (n - 1) @@ fun _ ->
    Scanf.scanf "%d " @@ fun t -> t in
  Array.fold_left (fun (acc, prev) t -> (t - prev :: acc, t)) ([], 0) ts
  |> fst
  |> List.map (min t)
  |> List.fold_left ( + ) t
  |> Printf.printf "%d\n"



Measured memory_bytes: 16768
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll const MOD = 1e9 + 7;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll comb = 1;
  vector<ll> cnt(3, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    ll t = 0, color = -1;
    if (A[i] == cnt[0]) {
      t++, color = 0;
    }
    if (A[i] == cnt[1]) {
      t++, color = 1;
    }
    if (A[i] == cnt[2]) {
      t++, color = 2;
    }
    if (color == -1) {
      cout << 0 << endl;
      return 0;
    }
    comb = (comb * t) % MOD;
    cnt[color]++;
  }
  cout << comb << endl;
  return 0;
}

Measured memory_bytes: 4016
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int MOD=10000;
int dp[503][10][2][2][503];
char A[2][505];
int M;

char tmp[506];

int dfs(int x,int d,int n,bool f,int up,int mod)
{
	if(d==0)memset(dp,-1,sizeof(dp));
	//printf("%d %d %d %d %d %d\n",x,d,n,f,up,mod);
	if(~dp[d][n][f][up][mod])return dp[d][n][f][up][mod];
	if(d==strlen(A[x]))
	{
	//	if(mod==0)puts(tmp);
		return mod==0;
	}
	int res=0;
	int ub=(f?9:A[x][d]-'0');
	for(int i=0;i<=ub;i++)
	{
		if(up==0&&n<=i)continue;
		if(up==1&&n>=i)continue;
		if(up==2&&n&&n==i)continue;

		int nf;
		if(up==2)
		{
			if(n==0)nf=2;
			else if(n>i)nf=1;
			else nf=0;
		}else nf=!up;
		tmp[d]=i+'0';
		res=(res+dfs(x,d+1,i,f|(i!=A[x][d]-'0'),nf,(mod*10+i)%M))%MOD;
	}
	return dp[d][n][f][up][mod]=res%MOD;
}


int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%s%s%d",A[0],A[1],&M);
	for(int i=strlen(A[0])-1;A[0][i]>=0;i--)
	{
		if(A[0][i]=='0')
			A[0][i]='9';
		else
		{
			A[0][i]=A[0][i]-1;break;
		}
	}
	printf("%d\n",(dfs(1,0,0,0,2,0)-dfs(0,0,0,0,2,0)+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 40808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	class Vertex {
		int c = -1;
		List<Integer> vertices = new ArrayList<Integer>();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		Vertex[] vertices = new Vertex[n];
		for (int i = 0; i < n; i++) {
			vertices[i] = new Vertex();
		}
		for (int i = 0; i < m; i++) {
			st = new StringTokenizer(reader.readLine());
			int u1 = Integer.parseInt(st.nextToken());
			int u2 = Integer.parseInt(st.nextToken());
			vertices[u1].vertices.add(u2);
			vertices[u2].vertices.add(u1);
		}
		dfs(vertices);
		int q = Integer.parseInt(reader.readLine());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int u1 = Integer.parseInt(st.nextToken());
			int u2 = Integer.parseInt(st.nextToken());
			if (vertices[u1].c == vertices[u2].c) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		reader.close();
	}
	
	private void dfs(Vertex[] vertices) {
		int color = 0;
		int n = vertices.length;
		for (int i = 0; i < n; i++) {
			if (vertices[i].c == -1) {
				color++;
				Stack<Integer> stack = new Stack<Integer>();
				stack.push(i);
				while (!stack.empty()) {
					Vertex vertex = vertices[stack.pop()];
					vertex.c = color;
					for (int j = 0; j < vertex.vertices.size(); j++) {
						int u = vertex.vertices.get(j);
						if (vertices[u].c == -1) {
							stack.push(u);
						}
					}
				}
			}
		}
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}


Measured memory_bytes: 79096
#include <cstdio>
using namespace std;

bool a[21][21];
bool b[21];
int c[21];

int main() {
  int m, n, x, y;

  scanf("%d", &m);
  scanf("%d", &n);

  for (int i=1; i<=m; i++) c[i] = 0;
  for (int i=1; i<=m; i++) b[i] = false;

  for (int i=1; i<=m; i++) {
    for (int j=1; j<=m; j++) {
      a[i][j] = false;
    }
  }
  for (int i=0; i<n; i++) {
    scanf("%d %d", &x, &y);
    a[x][y] = true;
    c[y]++;
  }
  for (int i=1; i<=m; i++) {
    if (!a[i][2] && i!=2) {
      a[i][2] = true; // tama
      c[2]++;
    }
  }

  for (int i=0; i<m; i++) {
    x = 1;
    while (b[x]||c[x]) x++;
    for (int j=1; j<=m; j++) {
      if (a[x][j]) --c[j];
    }
    b[x] = true;
    printf("%d\n", x);
  }

  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    int a[100];
    int m[100];
    int ans=0;
    rep(i,n){
        cin>>a[i];
        ans+=a[i];
    }
    sort(a,a+n);
    rep(i,n)m[i]=a[i]%10;
    if(ans%10!=0)cout<<ans<<endl;
    else {
        bool found=false;
        rep(i,n){
            if(m[i]!=ans%10){
                cout<<ans-a[i]<<endl;
                found=true;
                break;
            }
        }
        if(found==false)cout<<0<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){

int N,M;
scanf("%d%d",&N,&M);
int city[N];
for (int i = 0; i < N; i++){city[i]=0;}

while (M)
{
  int a,b;
  scanf("%d%d",&a,&b);
  city[a-1]++;
  city[b-1]++;
  M--;
}
for (int i = 0; i < N; i++)
{
  printf("%d\n",city[i]);
}



return 0;

}

Measured memory_bytes: 1704
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n = INT()
v = LIST()

v_odd = [v[i] for i in range(n) if i % 2 == 1]
v_even = [v[i] for i in range(n) if i % 2 == 0]

count_odd = Counter(v_odd)
count_even = Counter(v_even)

if count_odd.most_common()[0][0] != count_even.most_common()[0][0]:
	print(int(n/2-count_odd.most_common()[0][1] + n/2 - count_even.most_common()[0][1]))
else:
	if len(count_odd) == 1 and len(count_even) == 1:
		print(int(n/2))
	else:
		if len(count_odd) == 1:
			print(int(n/2 - count_even.most_common()[1][1]))
		elif len(count_even) == 1:
			print(int(n/2 - count_odd.most_common()[1][1]))
		else:
			tmp1 = int(n/2-count_odd.most_common()[1][1] + n/2 - count_even.most_common()[0][1])
			tmp2 = int(n/2-count_odd.most_common()[0][1] + n/2 - count_even.most_common()[1][1])
			print(min(tmp1, tmp2))

Measured memory_bytes: 18744
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

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

	vector<int> a(N);
	rep(i, N) cin >> a[i];
	sort(RALL(a));

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i%2 == 0) {
			ans += a[i];
		}
		else {
			ans -= a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, k;
  cin >> n >> k;
  vector<llong> v(n);
  REP(i,n){
    cin >> v[i];
  }

  SORTV(v);
  llong ans = INF;
  for(int i = 0; i + k - 1 < n; ++i){
    ans = min(ans, v[i+k-1] - v[i]);
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int k,a,b;
	cin>>k>>a>>b;
	int fv = ((a + k - 1)/k) * k;
	if(fv > b)
	cout<<"NG\n";
	else cout<<"OK\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<string> W(N);
  for (int i = 0; i < N; ++i) {
    cin >> W[i];

    if (i > 0 and W[i-1].back() != W[i].front()) {
      cout << "No";
      return 0;
    }
  }

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

  for (int i = 1; i < N; ++i) {
    if (W[i-1] == W[i]) {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
int main()
{
    FAST
        // freopen("input1.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
        ll n;
    cin >> n;
    string s[n];
    rep(i, 0, n)
    {
        cin>>s[i];
    }
    ve<ll> adj[n + 1];
    rep(i, 0, n)
    {
        rep(j, 0, n)
        {
            if (s[i][j] == '1')
            {
                adj[i + 1].pb(j + 1);
            }
        }
    }
    ll dis[n + 1][n + 1];
    rep (i,0,n+1)
    {
        rep (j,0,n+1)
        {
            dis[i][j]=0;
        }
    }
    rep(x, 1, n + 1)
    {
        queue<ll> q;
        ve<bool> visit(n + 1, false);
        visit[x] = true;
        dis[x][x] = 0;
        q.push(x);
        while (!q.empty())
        {
            ll s = q.front();
            q.pop();
            // process node s
            for (auto u : adj[s])
            {
                if (visit[u])
                    continue;
                visit[u] = true;
                dis[x][u] = dis[x][s] + 1;
                // cout<<"disxu.. "<<dis[x][u]<<"\n";
                q.push(u);
            }
        }
    }
    ll ans=-1;
    rep (i,1,n+1)
    {
        ll sz=0;
        rep (j,1,n+1)
        {
            sz=max(dis[i][j],sz);
        }
        rep (j,1,n+1)
        {
            ll x1=dis[i][j];
            for (auto k: adj[j])
            {
                if (abs(dis[i][k]-x1)!=1)
                {
                    goto zee;
                }
            }
        }
        ans=max(sz+1,ans);
        zee:;
    }
    cout<<ans<<"\n";
}


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


void solve(long long N, long long K){

  long long b;
  long long count=0;
  for(b=K+1;b<N+1;++b){
    long long p = N / b;
    long long r = N % b;
    count += p * (b-K);
    count += max((long long)0, r-K+1);
    if(K==0)count -= 1;
    // cout << "b:"<<b << " add:" << p * (b-K) << "," << max((long long)0, r-K+1) << endl;
  }
  cout << count << "\n";
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  solve(N, K);
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
 
signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long X;
    scanf("%lld",&X);
    int now = 100;
    int ans = 0;
    while(1){
        now+=now/100;
        ans++;
        if(now>=X){
            cout<<ans<<endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3764
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')

def f(x):
    pow_2 = 1
    while pow_2 <= x:
        pow_2*=2
    return pow_2-x
def main():
    N=I()
    A=sorted(LI())
    C = Counter(A)
    ans = 0
    for a in A[::-1]:
        pair = f(a)

        if(a!=pair and C[a] and C[pair]):
            ans += 1
            C[a]-=1
            C[pair]-=1
        if(a==pair and C[a]>=2):
            ans += 1
            C[a]-=2
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 117072
#include <cstdio>
#include <cmath>

using namespace std;

long long a, b, c;
int q;

int main()
{
    scanf("%d", &q);
    while (q--)
    {
        scanf("%lld%lld", &a, &b);
        if (a == b) printf("%lld\n", 2 * a - 2);
        else
        {
            c = sqrt(a * b);
            if (c * c == a * b) --c;
            if (c * (c + 1) >= a * b) printf("%lld\n", 2 * c - 2);
                else printf("%lld\n", 2 * c - 1);
        }
    }
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

ll rev(ll n) {
  ll res = 0;
  while (n > 0) {
    int r = n % 10;
    res = res * 10 + r;
    n /= 10;
  }
  return res;
}

bool check(ll N, ll D) {
  return rev(N) == N + D;
}

ll ways0(int m) {
  if (m < 0) return 0;
  return 9-m;
}

ll ways(int m) {
  return 10-abs(m);
}

ll ten[20];
ll total = 0;
void rec(ll L, ll R, ll D, ll curr) {
  if (curr == 0) return;

  if (L == R) {
    if (D == 0) {
      total += curr * 10;
    }
    return;
  }
  if (L < R) {
    if (D == 0) {
      total += curr;
    }
    return;
  }

  ll C = ten[L] - ten[R];
  if (D < -C*10 || C*10 < D) return;
  if (R == 0) {
    for (int a = 0; a <= 9; a++) {
      rec(L-1, R+1, D - (ten[L]-ten[R]) * a, curr * ways0(a));
    }

  } else {
    for (int a = -9; a <= 9; a++) {
      rec(L-1, R+1, D - (ten[L]-ten[R]) * a, curr * ways(a));
    }
  }
}

ll solve(ll D, ll k) {
  if (k <= 6) {
    ll res = 0;
    for (int n = ten[k-1]; n < ten[k]; n++) {
      if (check(n, D)) ++res;
    }
    return res;
  }
  total = 0;
  rec(k-1, 0, D, 1);
  return total;

}

int main2() {
  ll D = nextLong();
  ll ans = 0;
  for (int k = 1; k <= 18; k++) {
    ans += solve(D, k);
  }
  cout << ans << endl;
  return 0;
}

int main() {

  ten[0] = 1;
  for (int i = 1; i < 20; i++) ten[i] = ten[i-1] * 10;

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 3720
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())

import queue, itertools

dxy = ((1,0), (-1,0), (0,1), (0,-1))
ans = 0
for s in itertools.product(range(H), range(W)):
    if S[s[0]][s[1]] == '#': continue
    
    q = queue.Queue()
    dist = [[-1]*W for _ in range(H)]     

    q.put(s)
    dist[s[0]][s[1]] = 0
    while not q.empty():
        y, x = q.get()         
        for dx, dy in dxy:
            nx, ny = x+dx, y+dy
            if nx<0 or ny<0 or nx>=W or ny>=H or S[ny][nx] == '#' or dist[ny][nx] >= 0: 
                continue
            dist[ny][nx] = dist[y][x] + 1
            q.put((ny, nx))
    
    ans = max(ans, max(map(max, dist)))

print(ans)

Measured memory_bytes: 78080
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
using namespace std;

int main() {
      int N,a,b;
    cin >> N;
  int  maxi = 100000;
  for(int i = 1;i< N/2+1;i++){
  a = N - i;
  b = i + 0;
  int sum = 0;
  int dig = 0;
    while(a){
    dig = a % 10;
    sum = sum + dig;
    a = a / 10;
  }
    while(b){
    dig = b % 10;
    sum = sum + dig;
    b = b / 10;
  }

  maxi = min(sum,maxi);
  
}
cout <<  maxi << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> c(n), s(n), f(n);
    for(int i=0;i<n-1;i++){
    	cin >> c[i] >> s[i] >> f[i];
    }
    for(int i=0;i<n;i++){
    	ll now = 0;
    	for(int j=i;j<n-1;j++){
    		now = max(now, s[j]);
    		ll maki = now + f[j] - 1;
    		maki /= f[j];
    		now = maki * f[j];
    		now += c[j];
    	}
    	cout << now << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

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

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int m = in();
  int total = 0;
  int votes[n];
  for(int i = 0; i < n; ++i) {
    cin >> votes[i];
    total += votes[i];
  }
  int tmp;
  if(total%(4*m)) {
    tmp = floor(double(total) / 4 / m);
    int counter = 0;
    for(int i = 0; i < n; ++i) {
      if(votes[i]>tmp) ++counter;
    }
    if(counter < m) {
      cout << "No";
    } else {
      cout << "Yes";
    }
    cout << "\n";
  } else {
    tmp = total/4/m;
    int counter = 0;
    for(int i = 0; i < n; ++i) {
      if(votes[i]>=tmp) ++counter;
    }
    if(counter < m) {
      cout << "No";
    } else {
      cout << "Yes";
    }
    cout << "\n";
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  long long N,ans;
	cin>>N;
	ans=0;
	for(long long i=1;i<N;i++){
		for(long long j=1;j<N+1;j++){
			if(N-i*j>0)ans++;
			else if(N-i*j<=0)break;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main()
{
//    ll t;
//    cin>>t;
//    for(ll q=1;q<=t;q++)
   {
    ll n;
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
     cout<<"hon";
     else if(n==0||n==1||n==6||n==8)
      cout<<"pon";
      else
       cout<<"bon";
    // vector<ll> v;
    // for(ll i=0;i<n;i++)
    //  {
    //      ll x;
    //      cin>>x;
    //      v.push_back(x);
    //  } 
    
   }

    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
 
#define s(a) sin(a*M_PI/180)
#define S(a) (float)a
 
int main()
{
  int n;
 
  while (scanf("%d", &n), n) {
    double a1 = 0.0, a2 = 0.0, in, rem = 360;
    for(int i = 0 ; i < n-1 ; i++){
      scanf("%lf" ,&in);
      rem -= in;
      a1 += s(in);
    }
    a1 += s(rem);
 
    scanf("%d" ,&n);
    rem = 360;
    for(int i = 0 ; i < n-1 ; i++){
      scanf("%lf" ,&in);
      rem -= in;
      a2 += s(in);
    }    
    a2 += s(rem);
 
    if(S(a1) > S(a2)){
      puts("1");
    }else if(S(a1) < S(a2)){
      puts("2");
    }else{
      puts("0");
    }
  }
 
  return 0;
}

Measured memory_bytes: 2860
#include <cstdio>
#include<iostream>

#define NMAX 100

using namespace std;
   
int main(void){

	int score[NMAX+1]={0};
	int rank[NMAX+1];
	int max,cnt;
	int num,dat;
	int ra;
	char ch;

	while(1){
		cin>>num>>ch>>dat;
		if(num==0&&dat==0) break;
		score[num]+=dat;
	}
	ra=1;
	while(1){
		cnt=0,max=-1;
		for(int i=1;i<=NMAX;i++){
			if(score[i]==-1) cnt++;
			else if(max<score[i]) max=score[i];
		}
		if(cnt==NMAX) break;
		for(int i=1;i<=NMAX;i++){
			if(score[i]==max){
				rank[i]=ra;
				score[i]=-1;
			}
		}
		ra++;
	}

	int inp;

	while(cin>>inp){
		cout<<rank[inp]<<endl;
	}

    return 0;
}

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

int main(){
  int q;
  cin>>q;
  while(q--){
    string x,y;
    cin>>x>>y;
    vector<vector<int>> dp(x.size()+1,vector<int>(y.size()+1,0));
    
    for(int xi=0;xi<x.size();++xi){
      for(int yi=0;yi<y.size();++yi){
        if(x[xi]==y[yi]){
          dp[xi+1][yi+1]=dp[xi][yi]+1;
        }else{
          if (dp[xi+1][yi]>dp[xi][yi+1]){
            dp[xi+1][yi+1]=dp[xi+1][yi];
          }else{
            dp[xi+1][yi+1]=dp[xi][yi+1];
          }
        }
      }
    }
    int ans=dp[x.size()][y.size()];
    cout << ans << endl;
  }
}


Measured memory_bytes: 6892