akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<ll> sum(100010, 0);
    for(int i = 0; i < m; i++)
    {
        int l, r; cin >> l >> r;
        sum[l]++;
        sum[r + 1]--;
    }
    ll max_v = 0;
    for(int i = 1; i < sum.size(); i++)
    {
        sum[i] += sum[i - 1];
    }
    ll ans = 0;
    for(int i = 1; i < sum.size(); i++)
    {
        if(m == sum[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>

#include <fstream>

using namespace std;
typedef long long ll;
static const ll Z = 1 << 21;
char s[Z], t[Z];

#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int A, B, C; cin >> A >> B >> C;
	cout << (((A + B) >= C) ? "Yes" : "No") << endl;

	return 0;
}

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

using namespace std;
typedef long long llint;

const int maxn = 2e5+10;
const llint mod = 998244353;
const int maxv = 1e6+10;

int n;
llint niz[maxn];
llint w[maxv], v;
llint sum[maxv], sq[maxv];

llint pot(llint a, llint b) {
    if (b == 0) return 1LL;
    else if (b % 2 == 1) return (a * pot(a, b - 1)) % mod;
    else {
        llint out = pot(a, b / 2);
        return (out * out) % mod;
    }
}

llint inv(llint x) {
    return pot(x, mod - 2);
}

llint divi(llint a, llint b) {
    return (a * inv(b)) % mod;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%lld", niz+i);
    v = *max_element(niz, niz+n);

    for (int i = 1; i <= v; i++) {
        w[i] += inv(i), w[i] %= mod;
        for (int j = i + i; j <= v; j += i)
            w[j] += mod - w[i], w[j] %= mod;
    }

    for (int i = 0; i < n; i++) {
        sum[(int)niz[i]] += niz[i], sum[(int)niz[i]] %= mod;
        sq[(int)niz[i]] += (niz[i] * niz[i]) % mod, sq[(int)niz[i]] %= mod;
    }

    llint sol = 0;
    for (int i = 1; i <= v; i++)
        for (int j = i + i; j <= v; j += i)
            sum[i] += sum[j], sum[i] %= mod, sq[i] += sq[j], sq[i] %= mod;

    for (int i = 1; i <= v; i++) {
        //printf("%d -> %lld %lld\n", i, sum[i], sq[i]);

        llint tren = (sum[i] * sum[i]) % mod;
        tren += mod - sq[i], tren %= mod;
        sol += (divi(tren, 2) * w[i]) % mod, sol %= mod;
    }
    printf("%lld\n", (sol + mod) % mod);
    return 0;
}


Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#define ll long long
#define endl "\n"
#define __ ios::sync_with_stdio(0), cin.tie(NULL);
using namespace std;

ll n,a[696969],mn,mx;

int main(){
	 __

	cin >> n;
	for(int i=n-1; i>=0; i--) cin >> a[i];

	mn = 2, mx = 3;
	if(a[0]!=2){
		cout << "-1\n";
		return 0;
	}

	for(int i=1; i<n; i++){
		//if(mx%a[i]!=0 && mn%a[i]!=0 && mn/a[i]==mx/a[i]){
			//cout << -1 << endl;
			//return 0;
		//}
		if(mn%a[i]!=0) mn = a[i] * ((mn/a[i])+1);
		mx = a[i]*(mx/a[i])+a[i]-1;
	//cout << a[i] << " " << mn << " " << mx << endl;
	}

	if(mx<mn) cout << -1 << endl;
	else cout << mn << " " << mx << endl;

}

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

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

bool flag;

void dfs(string str){
	if(str=="ABC"){
		flag=true;
	}
	if(flag)return;
	if(str.size()<3)return;
	if(str.substr(0,3)=="ABC"){
		string next="";
		for(int j=0;j<str.size();j++){
			string tmp="";
			for(int k=0;(k<3 && j+k<str.size());k++){
				tmp+=str[j+k];
			}
			if(tmp=="ABC"){
				next+='A';
				j+=2;
			}else{
				if(tmp[0]=='A')return;
				next+=str[j];
			}
		}
		dfs(next);
	}else if(str.substr(str.size()-3,3)=="ABC"){
		string next="";
		for(int j=0;j<str.size();j++){
			string tmp="";
			for(int k=0;(k<3 && j+k<str.size());k++){
				tmp+=str[j+k];
			}
			if(tmp=="ABC"){
				next+='C';
				j+=2;
			}else{
				if(tmp.size()>=3 && tmp[2]=='C')return;
				next+=str[j];
			}
		}
		dfs(next);
	}else{
		string next="";
		bool change=false;
		for(int j=0;j<str.size();j++){
			string tmp="";
			for(int k=0;(k<3 && j+k<str.size());k++){
				tmp+=str[j+k];
			}
			if(tmp=="ABC"){
				next+='B';
				j+=2;
				change=true;
			}else{
				if(tmp.size()>=2 && tmp[1]=='B')return;
				next+=str[j];
			}
		}
		if(change)dfs(next);
	}
}

int main(void){
	string str;
	cin >> str;
	flag=false;
	dfs(str);
	printf("%s\n",flag?"Yes":"No");
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template<typename T>
class BITree {
    public:
        BITree(int n) : m_N(n + 1) { m_Tree.assign(m_N, 0); }
        // [1, i] の合計値を返す (log m_N)
        // 閉区間であることに注意
        T Sum(int i) {
            assert(i >= 0 && i < m_N);
            T s = 0;
            while(i > 0) { s += m_Tree[i]; i -= i & -i; }
            return s;
        }
        // [i, j] の合計値を返す (log m_N)
        // i < j
        // 閉区間であることに注意
        T Sum(int i, int j) {
            assert(i <= j);
            return Sum(j) - Sum(i-1);
        }
        // i 番目の要素(1-indexed)に x を足して更新 O(log m_N)
        void Add(int i, T x){ while(i < m_N) { m_Tree[i] += x; i += i & -i; } }
    private:
        int m_N;            // 要素数
        vector<T> m_Tree;   // BIT 本体
};

ll N, M;
vector< pair<ll, ll> > AB;  // first: スコア, second: 時間

// [lb, ub] 内のまだ使われていない Bi で一番左にあるものを返す
// ない場合は -1 を返す
static inline ll get_index(BITree<ll>& bitree, ll lb, ll ub) {
    if(lb > ub) { return -1; }
    DBG("lb: %lld, ub: %lld\n", lb, ub);
    if(bitree.Sum(lb+1, ub+1) <= 0) { return -1; }
    while(ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        DBG("lb: %lld, ub: %lld\n", lb, ub);
        if(bitree.Sum(lb+1, mid+1) > 0) { ub = mid; }
        else { lb = mid; }
    }
    DBG("lb: %lld, ub: %lld\n", lb, ub);
    if(bitree.Sum(lb+1, lb+1) > 0) { return lb; }
    return ub;
}

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

    cin >> N >> M;
    REP(i, N) {
        ll score, day;
        cin >> day >> score;
        AB.push_back(make_pair(score, day));
    }
    SORT(AB);
    reverse(AB.begin(), AB.end());

    BITree<ll> bitree(M);
    for(int i = 1; i <= M; ++i) { bitree.Add(i, 1); }

    ll ans = 0;
    for(int i = 0; i < N; ++i) {
        pair<ll, ll> cand = AB[i];
        // cand が入るかチェック
        DBG("cand.second: %lld\n", cand.second);
        int ind = get_index(bitree, cand.second-1, M-1);
        if(ind >= 0) {
            bitree.Add(ind + 1, -1);
            ans += cand.first;
        }
#if 0
        for(int t = cand.second; t <= M; ++t) {
            if(isEmpty[t]) {
                // 空きに格納
                isEmpty[t] = false;
                ans += cand.first;
                break;
            }
        }
#endif
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 2672
k = gets.to_i
puts 50
a = Array.new(50,49)
for i in 0..49
    a[i] += k/50
end
k %= 50
for i in 0..49
    a[i] -= k
end
for i in 0..k-1
    a[i] += 51
end
puts a.join(" ")

Measured memory_bytes: 1788
n,k=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
def f(x,y):
  return nCr_mod(x-1,y-1)
r=n-k+2
for i in range(1,k+1):
  bule=f(k,i)
  red=f(r,i+1)
  print((bule*red)%mod)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

const int MAX = 510000;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    ll ans=0;
    COMinit();
    rep(i,1,h-a+1){
        ans+=(COM(b+i-2,i-1)*COM(w-b+h-i-1,h-i))%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}



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

int main() {
   int n,k;
   cin >> n >> k;
   ll ans = 0;
   for (int i = 0; i < n; i++) {
      int h;
      cin >> h;
      if(h>=k)ans++;
   }
   cout << ans <<endl;
}

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

using namespace std;

int h, w, n;


int inside(int x, int y) {
	return (1 <= x && x <= h) && (1 <= y && y <= w);
}

int main() {
	cin >> h >> w >> n;
	int x, y;
	cin >> x >> y;

	string s, t;

	cin >> s >> t;

	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());

	int x_min = 1, x_max = h;
	int y_min = 1, y_max = w;

	int ok = 1;

	for (int i = 0; i < n; ++i) {
		if(t[i] == 'R') {
			y_min--;
			y_min = max(y_min, 1);
		} else if(t[i] == 'L') {
			y_max++;
			y_max = min(y_max, w);
		} else if(t[i] == 'D') {
			x_min--;
			x_min = max(x_min, 1);
		} else {
			x_max++;
			x_max = min(x_max, h);
		}	
		if(x_min > x_max) ok = 0;
		if(y_min > y_max) ok = 0;
		//printf("%d %d %d %d\n", x_min, x_max, y_min, y_max);	
		if(s[i] == 'L') {
			y_min++;
		} else if(s[i] == 'R') {
			y_max--;
		} else if(s[i] == 'U') {
			x_min++;
		} else {
			x_max--;
			
		}
		if(x_min > x_max) ok = 0;
		if(y_min > y_max) ok = 0;	
	}
	if(x_min <= x_max){
		if(!(x_min <= x && x <= x_max)) {
			ok = 0;
		}
	}
	if(y_min <= y_max){
		if(!(y_min <= y && y <= y_max)) {
			ok = 0;
		}
	}


	if(ok)puts("YES");
	else puts("NO");


}

Measured memory_bytes: 776
#include<iostream>
using namespace std;
int gcd(int x,int y){
  if(x<y) swap(x,y);
  int b;
  while(x%y!=0){
    b=x;
    x=y;
    y=b%y;
  }
  return y;
}
int main(){
  int x,y;
  cin >> x >> y;
  cout << gcd(x,y) <<endl;
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    ll N, M, X; cin >> N >> M >> X;
    vector<ll> cost(N);
    vector<vector<ll>> book(N, vector<ll>(M));
    for (int i = 0; i < N; i++) {
        cin >> cost[i];
        for (int j = 0; j < M; j++) {
            cin >> book[i][j];
        }
    }

    ll ans = 1e15;
    ll twos = pow(2, N);
    for (ll i = 0; i < twos; i++) {
        bool flag = true;
        vector<ll> alg(M);
        ll temp = i, kari = 0;
        vector<int> bin(N);
        for (int j = 0; temp > 0; j++) {
            bin[j] = temp % 2;
            temp /= 2;
        }
        for (int a = 0; a < N; a++) {
            if (bin[a] == 0) continue;
            kari += cost[a];
            for (int b = 0; b < M; b++) {
                alg[b] += book[a][b];
            }
        }
        for (int c = 0; c < M; c++) {
            if (alg[c] < X) {
                flag = false;
                break;
            }
        }
        if (flag) ans = min(ans, kari);
    }
    if (ans != 1e15)
        cout << ans << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 4108
#include <iostream>
#include <string.h>
#include <map>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n,k,l,p,q;
int dsu[2][200010];
map<PII,ll> cnt;

int fi(int x,int idx) {
    return dsu[idx][x]==x?x:(dsu[idx][x]=fi(dsu[idx][x],idx));
}

int main() {
    scanf("%d%d%d",&n,&k,&l);
    memset(dsu,0,sizeof(dsu));
    for (int i=1;i<=n;i++) {
        dsu[0][i]=dsu[1][i]=i;
    }
    for (int i=0;i<k;i++) {
        scanf("%d%d",&p,&q);
        dsu[0][fi(p,0)]=fi(q,0);
    }
    for (int i=0;i<l;i++) {
        scanf("%d%d",&p,&q);
        dsu[1][fi(p,1)]=fi(q,1);
    }
    for (int i=1;i<=n;i++) {
        cnt[mp(fi(i,0),fi(i,1))]++;
    }
    for (int i=1;i<=n;i++) {
        printf("%lld ",cnt[mp(fi(i,0),fi(i,1))]);
    }
    printf("\n");
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

struct UnionFind {
    // 根を保存する（根のみ負値で木の大きさが保存される）
    vector<int> Parent;
    // 要素数Nで初期化
    UnionFind(int N) { Parent = vector<int>(N, -1); }
    // 根を求める
    int root(int A) {
        if (Parent[A] < 0) return A;
        else return Parent[A] = root(Parent[A]);
    }
    // 属する木の大きさ
    int size(int A) { return -Parent[root(A)]; } 
    // 統合
    void unite(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) return;
        if (size(A) < size(B)) swap(A, B); 
        Parent[A] += Parent[B];
        Parent[B] = A;
    } 
    // 同値類判定
    bool same(int A, int B) { return root(A) == root(B); }
};

int n, m;
string s;
int a[100001], b[100001];

signed main() {
    cin >> n >> m;
    for (int i=0;i<m;i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    UnionFind island(n);
    int connect[100001] = {};
    for (int i=m;i>0;i--) {
        if (!island.same(a[i-1],b[i-1])) {
            connect[i-1] = island.size(a[i-1])*island.size(b[i-1]);
            island.unite(a[i-1],b[i-1]);
        }
    }
    int asum[100001] = {};
    asum[m-1] = 0;
    for (int i=m;i>1;i--) {
        asum[i-2] = asum[i-1] + connect[i-1];
    }

    int mx = n*(n-1)/2;
    for (int i=0;i<m;i++) {
        cout << mx - asum[i] << endl;
    }
}

// 逆に考える
// 全て崩落した状態から橋ができるとき，繋がった島の数を数える
// i番目の橋ができたときに新たに繋がる数は島の数の積
// 繋がっている場合はそのまま
// 累積和で繋がっている島の数を求める
// 求めるのは繋がっていない島の数なので全てが繋がったときの数から引く


Measured memory_bytes: 5248
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
typedef pair<ll, ll>P;
signed main() {
	ll n, ans = 0;
	cin >> n;
	for (ll i = 1; i * i <= n; i++) {
		if (i * i == n)continue;
		if (n % i == 0 && n / i == i + 1)continue;
		if (n % i == 0)ans += (n - i) / i;
	}
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize
    }
    let mut x = m;
    let mut ans = 1;
    let d = 1000000007;
    let mut c = 0;
    while x % 2 == 0 {
        c += 1;
        x /= 2;
    }
    ans = ans * h_m(n,c,d) % d;

    let mut ps: Vec<usize> = Vec::new();
    let mut p = 3;
    let mut is_prime: bool;
    while p * p <= x {
        is_prime = true;
        for x in ps.clone() {
            if p % x == 0 {
                is_prime = false;
                break;
            }
            if p < x * x {
                break;
            }
        }
        if is_prime {
            ps.push(p);
        }
        p += 2;
    }

    for q in ps {
        c = 0;
        while x % q == 0 {
            c += 1;
            x /= q;
        }
        ans = ans * h_m(n,c,d) % d;
    }
    if x != 1 {
        ans = ans * n % d;
    }
    println!("{}",ans);
}


fn h_m(n: usize, m: usize, d: usize) -> usize {
    comb_m(n+m-1, m, d)
}

fn stair_m(n: usize, m: usize, d: usize) -> usize {
    (n..m+1).fold(1, |ac,x| ac * x % d)
}

fn comb_m(n: usize, r: usize, d: usize) -> usize {
    stair_m(n+1-r, n, d) * inv_m(stair_m(1, r, d),d) % d
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n,d-2,d)
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}


Measured memory_bytes: 4352
def main():
    n = int(input())
    h = [int(x) for x in input().split()]
    tmp = 0
    ans = 0

    for i in range(n-1):
        if h[i] >= h[i+1]:
            tmp+=1
            ans = max(tmp, ans)
        else:
            tmp=0
    print(ans)

main()


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
vector<int> linker[MAXN];
int n, mx[MAXN], cmx[MAXN], dep[MAXN];
void upd(int x, int v)
{
	if (v >= mx[x]) cmx[x] = mx[x], mx[x] = v;
	else if (v > cmx[x]) cmx[x] = v;
}
void dfs(int x, int fa)
{
	dep[x] = dep[fa] + 1;
	cmx[x] = mx[x] = dep[x];
	for (int cur : linker[x])
		if (cur != fa)
		{
			dfs(cur, x);
			upd(x, mx[cur]);
		}
}
int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i < n; i ++)
	{
		int u, v; cin >> u >> v;
		linker[u].push_back(v);
		linker[v].push_back(u);
	}
	dfs(1, 0);
	int qwq = 0;
	for (int i = 1; i <= n; i ++)
		qwq = max(qwq, mx[i] + cmx[i] - dep[i] * 2);
	puts(qwq % 3 == 1 ? "Second" : "First");
}

Measured memory_bytes: 25472
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007 
int32_t main()
{
    fast;
    int r,d,x;
    cin>>r>>d>>x;
    for(int i=0;i<10;i++)
    {
        x=x*r-d;
        cout<<x<<"\n";
    }
   
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int main(){
    int n; cin>>n;
    int d[n];
    for(int i=0; i<n; i++)
        cin>>d[i];
    sort(d, d+n);
    OUT(d[n/2]-d[n/2-1]);
}

Measured memory_bytes: 640
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
using namespace std;
int read(){
	int x=0,f=1,c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f^=1;
	for(; isdigit(c);c=getchar())x=x*10+c-48;
	return f?x:-x;
}
const int N=1<<18;
int n,K;
int a[N],b[N];
ll L[N],R[N],rL[N],rR[N];
ll dpL[N],dpR[N];
void chkmin(int&x,int y){if(y<x)x=y;}
ll cst(ll x,ll y){return y>=x?y-x:y-x+K;}
struct SegT{
	int mn[N<<1];
	void ini(int v){
		for(int i=1;i<(N<<1);++i)mn[i]=v;
	}
	void upd(int l,int r,int v){
		for(l+=N,r+=N;l<r;l>>=1,r>>=1){
			if(l&1)chkmin(mn[l++],v);
			if(r&1)chkmin(mn[--r],v);
		}
	}
	int qry(int x){
		int ans=1<<30;
		for(x+=N;x;x>>=1){
			chkmin(ans,mn[x]);
		}
		return ans;
	}
}segt;
int main(){
	n=read(),K=read();
	for(int i=0;i<n;++i)a[i]=read(),b[i]=read();
	for(int i=0;i<n;++i){
		if(i)L[i]=((L[i-1]-2*a[i-1])%K+K)%K;
		R[i]=((R[i-1]-2*a[i])%K+K)%K;
	}
	for(int i=0;i<n;++i)
		if(b[i]==2)L[i]=0,R[i]=K-1;
		else if(2*a[i]>K){
			puts("-1");return 0;
		}
	vector<int>v;
	for(int i=0;i<n;++i)v.PB(L[i]),v.PB(R[i]);
	v.PB(0),v.PB(K);
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=0;i<n;++i){
		rL[i]=L[i],rR[i]=R[i];
		L[i]=lower_bound(v.begin(),v.end(),rL[i])-v.begin();
		R[i]=lower_bound(v.begin(),v.end(),rR[i])-v.begin();
	}
	dpL[n-1]=dpR[n-1]=0;
	segt.ini(1<<30);
	ll ans=1LL<<60;
	for(int i=n-2;~i;--i){
		if(L[i+1]<=R[i+1]){
			segt.upd(R[i+1]+1,v.size(),i+1);
			segt.upd(0,L[i+1],i+1);
		}else segt.upd(R[i+1]+1,L[i+1],i+1);
		int j;
		j=segt.qry(L[i]);
		if(j>=n)dpL[i]=0;
		else dpL[i]=min(dpL[j]+cst(rL[i],rL[j]),dpR[j]+cst(rL[i],rR[j]));
		j=segt.qry(R[i]);
		if(j>=n)dpR[i]=0;
		else dpR[i]=min(dpL[j]+cst(rR[i],rL[j]),dpR[j]+cst(rR[i],rR[j]));
	}
	segt.ini(1);
	for(int i=0;i<n;++i){
		int j;
		j=-segt.qry(L[i]);
		if(j<0)ans=min(ans,dpL[i]);
		j=-segt.qry(R[i]);
		if(j<0)ans=min(ans,dpR[i]);
		if(L[i]<=R[i]){
			segt.upd(R[i]+1,v.size(),-i);
			segt.upd(0,L[i],-i);
		}else segt.upd(R[i]+1,L[i],-i);
	}
	ll sum=0;
	for(int i=0;i<n;++i)sum+=a[i];
	printf("%lld\n",ans+2*sum);
	return 0;
}


Measured memory_bytes: 17524
import itertools
import math
K = int(input())
g = [[0] * (K+1) for _ in range(K+1)]
out = 0
for a, b, c in itertools.combinations_with_replacement(range(1, K+1), 3):
  if g[a][b] == 0:
    g[a][b] = math.gcd(a, b)
  d = g[a][b]
  if g[d][c] == 0:
    g[d][c] = math.gcd(d, c)
  if a == b and b == c:
    out += g[d][c]
  elif a != b and b != c:
    out += g[d][c] * 6
  else:
    out += g[d][c] * 3
print(out)

Measured memory_bytes: 9444
#include <bits/stdc++.h>
using namespace std;
double dp[305][305][305];
bool done[305][305][305];
int n;
double dfs(int a, int b, int c) {
    if (done[a][b][c]) return dp[a][b][c];
    if (a == 0 && b == 0 && c == 0) return 0;
    done[a][b][c] = true;
    double ret = 0;
    double n_p = (double)n;
    double a_p = (double)a / n_p, b_p = (double)b / n_p, c_p = (double)c / n_p;
    n_p = 1 / (1 - (double)(n - a - b - c) / n_p);
    ret += n_p;
    if (a > 0) ret += dfs(a-1, b, c) * n_p * a_p;
    if (b > 0) ret += dfs(a + 1, b - 1, c) * n_p * b_p;
    if (c > 0) ret += dfs(a, b + 1, c - 1) * n_p * c_p;
    // printf("%f, %f, %f\n", a_p, b_p, c_p);
    return dp[a][b][c] = ret;
}
int main() {
    cin >> n;
    int cnt[4] = {0, 0, 0, 0};
    for (int i = 0; i < 305; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++)
        done[i][j][k] = false;
    for (int i = 0; i < n; i++) {
        int a_temp;
        cin >> a_temp;
        cnt[a_temp]++;
    }
    // cout << cnt[1] << endl;
    // cout << cnt[2] << endl;
    // cout << cnt[3] << endl;
    // cout << dfs(1, 1, 1) << endl;
    cout << fixed << setprecision(20) << dfs(cnt[1], cnt[2], cnt[3]) << endl;
    return 0;
}

Measured memory_bytes: 140284
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main(void)
{
    char inChar;
    cin >> inChar;

    if(isupper(inChar)){
        cout << "A\n";
    } else {
        cout << "a\n";
    }
    
    return 0;
}


Measured memory_bytes: 3008
n = int(input())
a = list(map(int,input().split()))
sum_a = sum(a)

mod = 1000000000 + 7
ans = 0

for i in range(n):
    sum_a -= a[i]
    pdt = a[i] * sum_a
    ans += pdt

ans %= mod
print(ans)

Measured memory_bytes: 31492
#include<stdio.h>
#include<algorithm>

int main(){
	int a[3];
	while(scanf("%d%d%d",a,a+1,a+2),a[0]){
		int b,c;
		scanf("%d",&b);
		std::sort(a,a+3);
		int d=a[0]*a[0]+a[1]*a[1];
		for(int i=0;i<b;i++){
			scanf("%d",&c);
			if(d<c*c*4)printf("OK\n");
			else printf("NA\n");
		}
	}
}

Measured memory_bytes: 0
#define NDEBUG
#include <cassert>
#include <cstdint>
#include <functional>
#include <vector>

template <typename Monoid> class SegmentTree {
	using uint32 = std::uint_fast32_t;
	using F = std::function<Monoid(const Monoid &, const Monoid &)>;
	const F f;
	const Monoid neutral_;
	const uint32 size_;
	std::vector<Monoid> tree;
	static uint32 getsize(const uint32 size) {
		uint32 ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const uint32 index) {
		tree[index] = f(tree[index << 1], tree[index << 1 | 1]);
	}

public:
	SegmentTree(const uint32 size, const Monoid &neutral = Monoid(),
		const F &f = std::plus<Monoid>())
		: f(f), neutral_(neutral), size_(getsize(size)),
		tree(size_ << 1, neutral_) {}
	SegmentTree(const std::vector<Monoid> &arr, const Monoid &neutral = Monoid(),
		const F &f = std::plus<Monoid>())
		: f(f), neutral_(neutral), size_(getsize(arr.size())),
		tree(size_ << 1, neutral_) {
		for (uint32 i = 0; i < arr.size(); ++i)
			tree[size_ + i] = arr[i];
		for (uint32 i = size_; --i;)
			recalc(i);
	}
	void update(uint32 index, const Monoid &data) {
		assert(index < size_);
		tree[index += size_] = data;
		while (index >>= 1)
			recalc(index);
	}
	void update(uint32 index, const std::function<Monoid(const Monoid &)> &g) {
		update(index, g(tree[index + size_]));
	}
	Monoid range(uint32 begin, uint32 end) const {
		assert(begin <= end);
		assert(begin <= size_);
		assert(end <= size_);
		Monoid retL = neutral_, retR = neutral_;
		for (begin += size_, end += size_; begin < end; begin >>= 1, end >>= 1) {
			if (begin & 1)
				retL = f(retL, tree[begin++]);
			if (end & 1)
				retR = f(tree[end - 1], retR);
		}
		return f(retL, retR);
	}
	const Monoid &operator[](const uint32 index) const {
		assert(index < size_);
		return tree[index + size_];
	}
};
#include<iostream>
#include<algorithm>
int main(void) {
	int n, q;
	std::cin >> n >> q;
	SegmentTree<int> T(n, 2147483647, [](int l, int r) {return std::min(l, r);});
	while (q--) {
		int c, x, y;
		std::cin >> c >> x >> y;
		if (c) {
			std::cout << T.range(x, y + 1) << "\n";
		}
		else {
			T.update(x, y);
		}
	}
	return 0;
}


Measured memory_bytes: 3880
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; k++)
using namespace std;

vi score_of_grp;
vi dp;

void rec(int i,const vi & not_taken, int mask, int grp){
    if (i == not_taken.size()) {
        dp[mask ^ grp] = max(dp[mask ^ grp], dp[mask] + score_of_grp[grp]);
        return;
    }
    rec(i+1, not_taken, mask, grp);
    rec(i+1, not_taken, mask, grp ^ (1<<not_taken[i]));
}

int32_t main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vvi score(n,vi(n));
    tr(i,0,n-1){
        tr(j,0,n-1){
            cin>>score[i][j];
        }
    }
    int sz = 1ll<<n;
    score_of_grp.resize(sz);
    dp.resize(sz+1, 0);
    //preprocessing for each group
    tr(mask,0,sz - 1){
        tr(i,0,n-1){
            if (mask & (1<<i)) {
                tr(j,i+1,n-1){
                    if (mask & (1<<j)) {
                        score_of_grp[mask] += score[i][j];
                    }
                }
            }
        }
    }
    // iterating for each group to be taken
    tr(mask,0,sz - 1){
        vector<int> not_taken;
        tr(i,0,n-1){
            if (!(mask & (1<<i))) {
                not_taken.push_back(i);
            }
        }
        rec(0, not_taken, mask, 0);
    }
    cout<<dp[sz-1]<<endl;
    return 0;
}


Measured memory_bytes: 4312
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

#define FOR(i,n) for(ll i=0;i<n;i++) 
#define RFOR(i,n) for(ll i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl

#define MAX_N 100ll 

//入力
int a ,b,c,d ;

int main() {

	cin >> a >> b >> c >> d;

	if (a*b >= c*d) COUT(a*b);

	else COUT(c*d);

	return 0;
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    LL p = 1;
    int N;
    cin >> N;

    for (int i = 1; i <= N; i++){
        p = i * p;
        p %= mod;
    }

    cout << p << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    int n;
    cin >> n;
    cout << n * n * n << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

final class Main {

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String input = inputReader.readLine();
            if (input == null || input.equals("0")) {
                break;
            }
            int inputCount = Integer.parseInt(input);
            while (inputCount-- > 0) {
                input = inputReader.readLine();
//                input = input.replaceAll("^Hoshino$", "Hoshina")
//                        .replaceAll(" Hoshino$", " Hoshina")
//                        .replaceAll("^Hoshino ", "Hoshina ")
//                        .replaceAll(" Hoshino ", " Hoshina ")
//                        .replaceAll("^Hoshino\\.", "Hoshina.")
//                        .replaceAll(" Hoshino\\.", " Hoshina.");
                input = input.replaceAll("Hoshino", "Hoshina");
                System.out.println(input);
            }
        }
    }
}

Measured memory_bytes: 10000
#include <iostream>
#include <cstring>

char board[100][100];
bool hasArrived[100][100];

int main() {
	int h, w;
	while (std::cin >> h >> w, h + w != 0) {
		for (int y = 0; y < h; ++y)
			for (int x = 0; x < w; ++x)
				std::cin >> board[x][y];

		int px = 0, py = 0;
		while (true) {
			if (hasArrived[px][py]) {
				std::cout << "LOOP" << std::endl;
				break;
			}

			hasArrived[px][py] = true;

			if (board[px][py] == '.') {
				std::cout << px << " " << py << std::endl;
				break;
			}
			
			if (board[px][py] == '>')
				++px;
			else if (board[px][py] == '<')
				--px;
			else if (board[px][py] == 'v')
				++py;
			else if (board[px][py] == '^')
				--py;
		}

		std::memset(board, 0, sizeof(board));
		std::memset(hasArrived, 0, sizeof(hasArrived));
	}
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
const long long MOD = 1e9+7;
int main(){
    int k,x;
    cin >> k >> x;
    if(500*k>=x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	int n, a[111111], flag1 = 0, flag2 = 0,i,m=0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] >= 0)
			flag1 = 1;
		if (a[i] <= 0)
			flag2 = 1;
	}
	sort(a, a + n);
	if (flag1 == 1 && flag2 == 1) {
		for (i = 0; i < n; i++)
			m += abs(a[i]);
		cout << m << endl;
		i = n-2;
		while (a[i] >= 0&&i>0) {
			cout << a[0] << " " << a[i] << endl;
			a[0] -= a[i];
			i--;
		}
		i = 1;
		while (a[i] < 0&&i<n-1) {
			cout << a[n-1] << " " << a[i] << endl;
			a[n-1] -= a[i];
			i++;
		}
		cout << a[n-1] << " " << a[0] << endl;
	}
	else if (flag2 == 0) {
		for (i = 0; i < n; i++)
			m += a[i];
		m -= a[0]*2;
		cout << m << endl;
		for (i = 1; i < n - 1; i++) {
			cout << a[0] << " " << a[i] << endl;
			a[0] -= a[i];
		}
		cout << a[n - 1] << " " << a[0] << endl;
	}
	else {
		for (i = 0; i < n; i++)
			m -= a[i];
		m += a[n-1] * 2;
		cout << m << endl;
		for (i = 1; i < n - 1; i++) {
			cout << a[n-1] << " " << a[i] << endl;
			a[n-1] -= a[i];
		}
		cout << a[n - 1] << " " << a[0] << endl;
	}
}

Measured memory_bytes: 7040
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(Math.Max(0, input[2] - (input[0] - input[1])));
        }
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static bool Good(int N, string[] A, int k)
        {
            for (int i = 0; i < N; ++i)
            {
                for (int j = 0; j < N; ++j)
                {
                    if (A[(i + k) % N][j] != A[(j + k) % N][i]) { return false; }
                }
            }
            return true;
        }
        static int Solve(int N, string[] A)
        {
            int count = 0;
            for (int i = 0; i < N; ++i)
            {
                if (Good(N, A, i)) { count += N; }
            }
            return count;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            var A = new string[N];
            for (int i = 0; i < N; ++i) { A[i] = Read(); }
            Console.WriteLine(Solve(N, A));
        }
    }
}


Measured memory_bytes: 13140
n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r*g*b

for i in range(n-2):
  for j in range(i+1, n-1):
    k = j + (j - i)
    if k > n-1:
    	break
    if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
      ans -= 1
print(ans)

Measured memory_bytes: 9176
# -*- coding: utf-8 -*-
INF = 2**62-1


def read_int():
    return int(input())


def slv(X):
    T = 100
    for i in range(INF):
        T += T // 100
        T = int(T)
        if X <= T:
            return i + 1


def main():
    X = read_int()
    print(slv(X))


if __name__ == '__main__':
    main()


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

int main()
{
    int n,r;
    scanf("%d %d",&n,&r);
    if(n<10)
    {
        printf("%d\n",r+100*(10-n));
    }
    else
    {
        printf("%d\n",r);
    }
    
    return 0;
}


Measured memory_bytes: 256
import sys


def solve(n, ws):
    res = sys.maxsize
    for i in range(1, n):
        s1 = sum(ws[:i])
        s2 = sum(ws[i:])
        diff = abs(s1 - s2)
        res = min(res, diff)
    return res


def main():
    n = int(input())
    ws = [int(w) for w in input().split()]
    res = solve(n, ws)
    print(res)


if __name__ == "__main__":
    main()

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll h,w; cin>>h>>w;
    char s[h][w];
    rep(i,h)rep(j,w) cin>>s[i][j];

    ll di[]={1,1,1,0,0,-1,-1,-1},dj[]={1,0,-1,1,-1,1,0,-1};
    rep(i,h){
        rep(j,w){
            ll num=0;
            if(s[i][j]=='#') continue;
            rep(k,8){
                ll ni=i+di[k],nj=j+dj[k];
                if(ni<0||h<=ni||nj<0||w<=nj) continue;
                if(s[ni][nj]=='#') num++;
            }
            s[i][j]=num+'0';
        }
    }
    rep(i,h)rep(j,w){
        cout<<s[i][j];
        if(j==w-1) cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"

long long int powmod(long long int a, long long int b, const int mod) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powmod(a, b / 2, mod);
	ans *= aa*aa;
	ans %= mod;
	if (b % 2)ans *= a;
	ans %= mod;
	return ans;
}

const int k = 12;
//?´???°??????
bool mirror_rabin(const long long int n) {
	if (n == 2)return true;
	if (n == 1 || (n & 1) == 0)return true;
	int s = 0;
	int d = n - 1;
	while (!(d % 2)) {
		s++;
		d /= 2;
	}
	for (int i = 0; i < k; ++i) {
		const long long int a = rand() % (n - 1) + 1;
		long long int t = d;
		long long int y = powmod(a, t, n);
		while (t != n - 1 && y != 1 && y != n - 1) {
			y = (y*y) % n;
			t <<= 1;
		}
		if (y != n - 1 && (t & 1) == 0)return false;
	}
	return true;
}
bool isso(long long int a) {
	return mirror_rabin(a);
	if (a == 1 || a == 0)return false;
	for (long long int i = 2; i*i <= a; ++i) {
		if ((a%i)) {
		}
		else {
			return false;
		}
	}
	return true;
}


int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		int num = N;
		if (num < 19) {
			cout << 13 << endl;
		}
		else {
			while (num % 30 != 19)num--;
			while (1) {
				if (mirror_rabin(num) && mirror_rabin(num - 2) && mirror_rabin(num - 6) && mirror_rabin(num - 8)) {
					cout << num << endl;
					break;
				}
				num -= 30;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
 
bool thru[2510], work[2510];
 
void search(int now, vector<vector<int>> &G){
    work[now]=1;
    for(int i=0; i<G[now].size(); ++i){
        if(!work[G[now][i]]){
            search(G[now][i], G);
        }
    }
}
 
int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> g(N+1), rev(N+1);
	vector<vector<ll>> cost(N+1);
	for(int i=0; i<M; ++i){
	    int a, b;
	    ll c;
	    cin >> a >> b >> c;
	    g[a].push_back(b);
	    cost[a].push_back(-c);
	    rev[b].push_back(a);
	}
	search(1, g);
	for(int i=1; i<=N; ++i){
	    thru[i] |= work[i];
	    work[i]=0;
	}
	search(N, rev);
	int cnt=0;
	for(int i=1; i<=N; ++i){
	    thru[i] &= work[i];
	    if(thru[i]) ++cnt;
	}
	vector<ll> mn(N+1, 1e18);
	mn[1]=0;
	for(int i=1; i<cnt; ++i){
	    for(int p=1; p<=N; ++p){
	        if(thru[p]){
	            for(int q=0; q<g[p].size(); ++q){
	                if(thru[g[p][q]]){
	                    mn[g[p][q]]=min(mn[g[p][q]], mn[p]+cost[p][q]);
	                }
	            }
	        }
	    }
	}
	for(int p=1; p<=N; ++p){
	    if(thru[p]){
	        for(int q=0; q<g[p].size(); ++q){
	            if(thru[g[p][q]]){
	                if(mn[g[p][q]]>mn[p]+cost[p][q]){
	                    cout << "inf" << endl;
	                    return 0;
	                }
	            }
	        }
	    }
	}
	cout << -mn[N] << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int N =sc.nextInt();
	    int A = sc.nextInt();
	    int B = sc.nextInt();
	    A = A*N;
	    System.out.println(Math.min(A, B));

	}


}

Measured memory_bytes: 21716
#include <stdio.h>
 
int main(void){
    int n,m,line[3][50]={0},i,sum,o,j,a,b,c,min=2500;
    char map[50][51],temp[4]="WBR";
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%s",map[i]);
    }
    for(i=0;i<3;i++){
        for(o=0;sum=0,o<n;o++){
            for(j=0;j<m;j++){
                if(temp[i] != map[o][j])sum++;
            }
            line[i][o]=sum;
        }
    }
    for(i=1;i<n-1;i++){
        for(o=i+1;o<n;o++){
            sum=0;
            for(a=0;a<i;sum+=line[0][a],a++);
            for(b=i;b<o;sum+=line[1][b],b++);
            for(c=o;c<n;sum+=line[2][c],c++);
            if(min > sum)
                min=sum;
        }
    }
    printf("%d\n",min);
    return 0;
}

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



int main(void){
    int N,M,C,k=0,sum;
    int A[101],B[101];
    cin>>N>>M>>C;
    for(int j=0;j<M;j++){
        cin>>B[j];
    };
    for(int i=0;i<N;i++){
        sum=0;
        for(int j=0;j<M;j++){
            cin>>A[j];
        };
        for(int j=0;j<M;j++){
            sum=sum+A[j]*B[j];
        };
            sum=sum+C;
        if(sum>0){
            k+=1;
        };
        };
    cout<<k;
    }



Measured memory_bytes: 256
# -*- coding utf-8 -*-
MOD = 10 ** 9 + 7

S = input()
# S = '?' * 100000
mods = [0] * 13
mods[0] = 1

digit = 1
for s in S[::-1]:
    next_mods = [0] * 13
    if s == '?':
        for i in range(10):
            for m in range(13):
                next_mods[(m + i * digit) % 13] += mods[m]
    else:
        for m in range(13):
            next_mods[(m + int(s) * digit) % 13] += mods[m]

    for m in range(13):
        next_mods[m] %= MOD
    mods = next_mods
    digit *= 10
    digit %= 13    # this line dramatically reduces calculation time

ans = mods[5]

print(ans)


Measured memory_bytes: 43244
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int n;
    string ju;
    int result[2000]={0};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int hit=0,out=0;
        while(1){
            cin>>ju;
            if(ju[0]=='H'&&ju[1]=='I'){
                if(hit<3)
                    hit++;
                else
                    result[i]++;
            }
            else if(ju[1]=='O')
                result[i]+=(hit+1),hit=0;
            else
                out++;
            if(out==3)
                break;
        }
    }
    for(int i=0;i<n;i++)
        printf("%d\n",result[i]);
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#include <vector>
#include <queue>

using namespace std;

#define forn(i, n) for(int i = 0; i < (n); i++)
#define formn(i, n) for(int i = (m); i < (n); i++)
#define foreach(x, c) for(auto x : (c))

typedef long long lld;
typedef unsigned long long llu;
typedef unsigned int uint;

const int MAXN = 2e5;

typedef pair<int, int> pii;

vector<int> G[MAXN];
int used[MAXN];
lld ans;
lld cant = 0;

void bfs(int v) {
	queue<pii> Q;
	Q.push({v, 0});
	used[v] = 0;
	while (!Q.empty()) {
		auto cur = Q.front();
		int nd = (cur.second + 1) % 2;
		Q.pop();
		foreach(u, G[cur.first]) {
			if (used[u] == -1) {
				used[u] = nd;
				Q.push({u, nd});
			} else if (used[u] != 2 && used[u] != nd) {
				used[u] = 2;
				Q.push({u, nd});
			}
		}
	}
}

int main() {
	fill(used, used + MAXN, -1);
	lld n, m;
	scanf("%lld%lld", &n, &m);
	forn(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		G[--a].push_back(--b);
		G[b].push_back(a);
	}
	ans = n * (n - 1) / 2 - m;
	bfs(0);
	lld no = 0, ne = 0;
	forn(i, n) {
		no += used[i] == 0;
		ne += used[i] == 1;
	}
	printf("%lld\n", ans - (no * (no - 1) / 2) - (ne * (ne - 1) / 2));
}


Measured memory_bytes: 9344
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def A159():
    N, M = [int(_) for _ in input().split()]
    if N <= 1:
        cn = 0
    else:
        # nC2
        cn = combinations_count(N, 2)
    if M <= 1:
        cm = 0
    else:
        cm = combinations_count(M, 2)
    print(cn+cm)

if __name__ == "__main__":
    A159()

Measured memory_bytes: 3060