akhauriyash/Code-Regression huggingface dataset:
n=int(input())
p=list(map(int,input().split()))

ans=0
for i in range(n-1):
    if p[i]==i+1:
        p[i],p[i+1]=p[i+1],p[i]
        ans+=1
if p[n-1]==n:
    ans+=1
print(ans)

Measured memory_bytes: 14008
#include<iostream>
#include<queue>
using namespace std;
int N,M,S,T,u,v,D;
vector<pair<int,int>>G[1<<17];
long mod=1e9+7,a[1<<17],b[1<<17],c[1<<17],d[1<<17];
priority_queue<pair<long,int>>P;
void calc(int S,long*d,long*w)
{
	for(int i=w[S]=1;i<=N;)d[i++]=-1e18;
	P.push({d[S]=0,S});
	while(P.size())
	{
		long c=P.top().first,u=P.top().second;
		P.pop();
		if(d[u]==c)for(auto p:G[u])
		{
			long v=p.first,nxt=c-p.second;
			if(d[v]<nxt)w[v]=w[u],P.push({d[v]=nxt,v});
			else if(d[v]==nxt)(w[v]+=w[u])%=mod;
		}
	}
}
main()
{
	cin>>N>>M>>S>>T;
	for(;cin>>u>>v>>D;G[v].push_back({u,D}))G[u].push_back({v,D});
	calc(S,a,b);calc(T,c,d);
	long ans=b[T]*b[T],t=a[T];
	for(u=0;u++<N;)
	{
		if(2*a[u]==t)ans-=b[u]*b[u]%mod*d[u]%mod*d[u]%mod;
		for(auto p:G[u])if(2*a[u]>t&&2*a[v=p.first]<t&&a[u]+c[v]-p.second==t)ans-=b[u]*b[u]%mod*d[v]%mod*d[v]%mod;
	}
	cout<<ans%mod;
}

Measured memory_bytes: 14448
#include<stdio.h>
int main(){
    int i,n;
    scanf("%d",&n);
    double a[n];
    double c=0.0;
    for(i=0;i<n;i++){
        scanf("%lf",&a[i]);
    }
    for(i=0;i<n;i++){
        c=(double)c+1.0/a[i];
    }
    double d=(double)1.0/c;
    printf("%lf",d);
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int n; cin >> n;
    map<int,int> odd, even;
    rep(i,n){
        int v; cin >> v;
        if(i % 2){
            odd[v]++;
        }else{
            even[v]++;
        }
    }
    
    vector<pair<int, int>> odd_v, even_v;
    for(auto p : odd) odd_v.emplace_back(make_pair(p.second, p.first));
    for(auto p : even) even_v.emplace_back(make_pair(p.second, p.first));
    sort(rALL(odd_v));
    sort(rALL(even_v));
    odd_v.emplace_back(make_pair(0,0));
    even_v.emplace_back(make_pair(0,0));
    
    if(odd_v[0].second != even_v[0].second){
        cout << n - odd_v[0].first - even_v[0].first << endl;
    }else{
        int a = n - odd_v[0].first - even_v[1].first;
        int b = n - odd_v[1].first - even_v[0].first;
        cout << min(a,b) << endl;
    }
}


Measured memory_bytes: 6136
import itertools

n = int(input())
testimonials = []

for i in range(n):
    a = int(input())
    testimonial = []
    for j in range(a):
        x, y = map(int, input().split())
        testimonial.append((x-1, y))
    testimonials.append(testimonial)

ans = 0
for item in itertools.product([0, 1], repeat=n):
    flag = 1
    for i, testimonial in enumerate(testimonials):
        if item[i]:
            for (x, y) in testimonial:
                if item[x] != y:
                    flag = 0
                    break
    if flag:
        ans = max(ans, sum(item))

print(ans)


Measured memory_bytes: 43628
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
//#define cin fin
//#define cout fout
using namespace std;

//ifstream fin("file.in");
//ofstream fout("file.out");

const int nmax=1e3+5;
const int mod=1e9+7;
const int mod1=998244353;

int a,b;

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> a >> b;
	cout << max(a+b,max(a-b,a*b));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
static std::vector<std::vector<bool>> memo(3000, std::vector<bool>(3000, false));
static int MW = 0, MS =0;

static void rec(
    const int w,
    const int s,
    const int a,
    const int b,
    const int c,
    const int d,
    const int e,
    const int f)
{
    if (w > f || s > f || w + s > f) {
        return;
    }
    if (memo[w][s]) {
        return;
    }
    memo[w][s] = true;

    if (s <= (e * w / 100)) {
        if (MW + MS == 0) {
            MW = w;
            MS = s;
        }
        else if (s*(MW+MS) >= MS*(w+s)) {
            MW = w;
            MS = s;
        }
    }

    rec(w + 100 * a, s, a, b, c, d, e, f);
    rec(w + 100 * b, s, a, b, c, d, e, f);
    rec(w, s + c, a, b, c, d, e, f);
    rec(w, s + d, a, b, c, d, e, f);
}

int main() {
    int a, b, c, d, e, f; std::cin >> a >> b >> c >> d >> e >> f;

    rec(0, 0, a, b, c, d, e, f);
    std::cout << MW + MS << " " << MS << std::endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin >> n;
	int a[n];
	vector<pair<int, int>> v;
	int x;
	int y = -1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) {
			x = a[i];
		} else {
			if (a[i-1] > a[i]) {
				if (y != -1) {
					v.push_back(make_pair(x, y));
					y = -1;
				}
				x = a[i];
			} else {
				y = a[i];
				if (i == n-1) {
					v.push_back(make_pair(x, y));
				}
			}
		}
	}
	long long money = 1000;
	for (auto e : v) {
		//printf("%d, %d\n", e.first, e.second);
		long long tmp = money / (long long)e.first;
		money = money - tmp*(long long)e.first + tmp*(long long)e.second;
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n;
long long a[200005];
long long x;
long long y;
long long xx;
long long yy;
const long long MAX = 710000;
const long long 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 (long long 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(long long n, long long 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()
{
	COMinit();
	cin>>x>>y;
	if((x+y)%3!=0)
	{
		cout<<0<<endl;return 0;
	}
	n=(x+y)/3;
	xx=x-n;
	yy=y-n;
	cout<<COM(n,xx)<<endl;
	return 0;
}//151840682  999999 999999

Measured memory_bytes: 16896
N = int(input())
A = list(map(int,input().split()))
tot = 0
cnt = 0
for i in range(N):
    tot += A[i]
    if i%2==0:
        if tot<=0:
            cnt += abs(tot)+1
            tot = 1
    if i%2==1:
        if tot>=0:
            cnt += tot+1
            tot = -1
cmin = cnt
cnt = 0
tot = 0
for i in range(N):
    tot += A[i]
    if i%2==0:
        if tot>=0:
            cnt += tot+1
            tot = -1
    else:
        if tot<=0:
            cnt += abs(tot)+1
            tot = 1
cmin = min(cmin,cnt)
print(cmin)

Measured memory_bytes: 85316
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] a) throws NumberFormatException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer strToke;
        String line;
        int num = 0;
        // データ読み込み
        while ((line = in.readLine()) != null && num <= 1000) {
            if (num != 0) {
                strToke = new StringTokenizer(line);
                int b = Integer.parseInt(strToke.nextToken());
                int c = Integer.parseInt(strToke.nextToken());
                int d = Integer.parseInt(strToke.nextToken());
                if (b > c && b > d) {
                    checkTriangle(b, c, d);
                } else if (c > b && c > d) {
                    checkTriangle(c, b, d);
                } else {
                    checkTriangle(d, b, c);
                }
            }
            num++;
        }
    }

    private static void checkTriangle(int aLong, int aShort1, int aShort2) {
        if ((aLong * aLong) == (aShort1 * aShort1 + aShort2 * aShort2)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

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

class UnionFind{
  public:
  // 親の番号を格納する．親の場合は-(その集合のサイズ)
  vector<int> Parent; 
  
  // 全て-1
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  // Aがどのグループに属しているか
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]); // return前に自分の親を更新することで高速化
  }
  
  // 自分のいるグループの頂点数を調べる
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  // AとBをくっつける
  bool connect(int A, int B){
    // AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
    A = root(A);
    B = root(B);
    if(A == B){
      // すでにくっついているからくっつけない
      return false;
    }
    
    // グループのサイズが大きい方(A)に小さい方(B)をくっつけたい
    // 大証が逆ならひっくり返す
    if(size(A) < size(B)) swap(A, B);
    
    // Aのサイズを更新する
    Parent[A] += Parent[B];
    // Bの親をAに変更する
    Parent[B] = A;
    
    return true;
  }
};

signed main()
{
  int n,m; cin>>n>>m;
  vector<int> A(m), B(m);
  rep(i,m){
    cin>>A[i]>>B[i];
    A[i]--; B[i]--;
  }
  
  vector<ll>  ans(m);
  ans[m-1] = (ll)n * (n-1) / 2;
  
  UnionFind Uni(n);
  
  // iの状態からi-1の状態を求めるため、i >= 1の範囲でのループになる
  for(int i = m-1; i >= 1; i--){
    if(Uni.root(A[i]) != Uni.root(B[i])){
      ans[i - 1] = ans[i] - (ll)Uni.size(A[i]) * Uni.size(B[i]);
      Uni.connect(A[i], B[i]);
    }
    else ans[i - 1] = ans[i];
  }
  
  rep(i,m){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, K, X[50], Y[50];

int main(void) {
  cin >> N >> K;
  REP(i, 0, N) cin >> X[i] >> Y[i];

  vector<ll> vx(N), vy(N);
  REP(i, 0, N) vx[i] = X[i];
  REP(i, 0, N) vy[i] = Y[i];
  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());
  vx.erase(unique(vx.begin(), vx.end()), vx.end());
  vy.erase(unique(vy.begin(), vy.end()), vy.end());

  ll ans = (1LL << 62);
  REP(i1, 0, vx.size()) REP(i2, i1 + 1, vx.size()) REP(j1, 0, vy.size()) REP(j2, j1 + 1, vy.size()) {
    ll x1 = vx[i1], x2 = vx[i2], y1 = vy[j1], y2 = vy[j2];
    ll cnt = 0;
    REP(i, 0, N) if(x1 <= X[i] && X[i] <= x2 && y1 <= Y[i] && Y[i] <= y2) cnt++;
    if(cnt >= K) ans = min(ans, (x2 - x1) * (y2 - y1));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;

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)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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")
    };
}

const MOD: i64 = 1_000_000_007;

fn comb(n: u32, k: u32) -> u32 {
    if n < k {
        return 0;
    }

    let mut c = 1;
    let m = if n - k > k { n - k } else { k };
    for i in m + 1..n + 1 {
        c *= i;
    }
    for i in 1..(n - m + 1) {
        c /= i;
    }
    return c;
}

fn recursive(i: u32, s: Vec<char>, k: u32) -> u32 {
    if k <= 0 {
        return 1;
    }
    if i >= s.len() as u32 {
        return 0;
    }
    let mut c = 0;
    let n = s[i as usize] as u32 - '0' as u32;
    if s.len() as u32 - i - 1 >= k && n != 0 { // 先頭を０とした場合
        c += comb(s.len() as u32 - i - 1, k) as u32 * (9 as u32).pow(k);
    }
    if n > 1 { // 先頭から１引いた場合
        c += (n - 1) * comb(s.len() as u32 - i - 1, k - 1) as u32 * (9 as u32).pow(k - 1);
    }
    if n != 0 {
        c += recursive(i + 1, s, k - 1);
    } else {
        c += recursive(i + 1, s, k);
    }
    return c;
}

fn main() {
    input! {
        s: chars,
        k: u32,
    }

    println!("{}", recursive(0, s, k));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;
typedef long long ll;
int n, cnt, X[210], Y[210], P[210]={1};
bool done[210][210];
int norm(int x){
	return (x+MOD)%MOD;
}
bool linear(int a, int b, int c){
	return (X[a]-X[c])*(Y[b]-Y[c])-(Y[a]-Y[c])*(X[b]-X[c])==0;
}
int subset(int x){
	return norm(P[x]-x-1);
}
void count(int v, int u){
	if(done[v][u]) return;
	vector<int> V;
	for(int i=1; i<=n; i++)
		if(linear(u,v,i))
			V.push_back(i);
	int m=V.size();
	for(int i=0; i<m; i++)
		for(int j=0; j<m; j++)
			done[V[i]][V[j]]=true;
	cnt=(cnt+subset(m))%MOD;
}
int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++)
		P[i]=(P[i-1]*2)%MOD;
	for(int i=1; i<=n; i++)
		scanf("%d%d", X+i, Y+i);
	for(int i=1; i<=n; i++)
		for(int j=i+1; j<=n; j++)
			count(i, j);
	int ans=subset(n);
	printf("%d", norm(ans-cnt));
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		for(int i=0; i<m; i++){
			a[i] = sc.nextInt();
		}
		int ans = n;
		for(int i: a){
			ans -= i;
		}
		if(ans > -1){
			System.out.println(ans);
		} else {
			System.out.println(-1);
		}

	}
}


Measured memory_bytes: 38956
a = input()
R = int(len(a))
if a == "KIHBR" or a == "KIHBRA" or a == "KIHBAR" or a == "KIHBARA" or a == "KIHABR" or a == "KIHABRA" or a == "KIHABAR" or a == "KIHABARA" or a == "AKIHBR" or a == "AKIHBRA" or a == "AKIHBAR" or a == "AKIHBARA" or a == "AKIHABR" or a == "AKIHABRA" or a == "AKIHABAR" or a == "AKIHABARA":
 print("YES") 
else:
 print("NO")

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

using namespace std;

int main()
{
   int n; cin >> n;
   string s; cin >> s;
   int sol = 0;
   for(char a = '0'; a <= '9'; a++){
        for(char b ='0'; b <= '9'; b++){
            for(int c = '0'; c <= '9'; c++){
                vector<int> ch = {c, b, a};
                for(int i = 0; i < s.size(); i++){
                    if(s[i] == ch.back()){
                        ch.pop_back();
                        if(ch.empty()){
                            sol++;
                            break;
                        }
                    }
                }
            }
        }
   }
   cout << sol << endl;
   return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc() {
	ll n, m;
	ll ans = 0;

	cin >> n >> m;

	ans = (n * (n - 1)) / 2;
	ans += (m * (m - 1)) / 2;

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

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

	solve_abc();

	return 0;
}

Measured memory_bytes: 256
import numpy as np

def main():
    n = int(input())
    a = []
    b = []

    if n % 2:
        ma = n
    else:
        ma = n + 1
    for i in range(1, n+1):
        for j in range(1, n+1):
            if i + j != ma and i < j:
                a.append(i)
                b.append(j)

    print(len(a))
    for i, j in zip(a, b):
        if i < j:
            print(i, j)


if __name__ == '__main__':
   main() 


Measured memory_bytes: 13020
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n ; cin >> n ;
    vector<long double> p(n+1);
    for(int i=1;i<=n;i++) cin >> p.at(i);
    vector<vector<long double>> dp(n+1,vector<long double>(n+1,0.0));
    dp.at(0).at(1) = 1.0 - p.at(1);
    dp.at(1).at(1) = p.at(1);
    for(int i=1;i<n;i++){
        for(int j=0;j<=i;j++){
            long double x = dp.at(j).at(i);
            dp.at(j).at(i+1) += x * (1.0-p.at(i+1));
            dp.at(j+1).at(i+1) += x * p.at(i+1);
        }
    }
    //rep(i,n+1){rep(j,n+1){cout << dp.at(i).at(j)<<" ";}cout << endl;}
    long double ans = 0;
    for(int i=(n/2)+1;i<=n;i++){
        ans += dp.at(i).at(n);
    }
    cout << setprecision(12) << ans << endl;  

}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

class CommonIO {
public:
    CommonIO() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(false);
    }
    ~CommonIO() {}

    template <class T>
    void scan(T &v) {
        std::cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        std::cout << v;
    }
    template <class T>
    void print(std::vector<T> &v) {
        if (v.size() == 0) return;
        print(*v.begin());
        for (auto it = ++v.begin(); it != v.end(); ++it) {
            print(' ');
            print(*it);
        }
    }
    template <class T>
    void print(std::vector< std::vector<T> > &grid) {
        if (grid.size() == 0) return;
        print(*grid.begin());
        for (auto it = ++grid.begin(); it != grid.end(); ++it) {
            print('\n');
            print(*it);
        }
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(' ');
        print(rest...);
    }

    template <class T>
    void printl(T v) {
        print(v);
        std::cout << '\n';
    }
    template <class T, class... Rest>
    void printl(T v, Rest... rest) {
        print(v);
        print(' ');
        printl(rest...);
    }
} io;

int main() {
    ll a, b;
    io.scan(a, b);
    if (a < 10 && b < 10) {
        io.printl(a * b);
    } else {
        io.printl(-1);
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();

		int[] W = new int[N];
		int[] E = new int[N];
		for(int i = 0;i < N;i++) {
			if(S.charAt(i)=='W') {
				W[i]++;
			}else if(S.charAt(i)=='E') {
				E[i]++;
			}
		}
		int[] Wsum = new int[N+1];
		int[] Esum = new int[N+1];
		Wsum[0] = 0;Esum[0] = 0;
		for(int i = 0;i < N;i++) {
			Wsum[i+1] = Wsum[i]+W[i];
			Esum[i+1] = Esum[i]+E[i];
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 0;i < N;i++) {
			int calc = 0;
			calc += Esum[N]-Esum[i+1];
			calc += Wsum[i];
			ans = Math.min(ans, calc);
		}
		System.out.println(ans);
	}
}

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

int main()
{
	int a,b;
	cin >> a >> b;
	if(a == b)
	{
		cout << "a == b" << endl;
	}
	else if(a < b)
	{
		cout << "a < b"<< endl;
	}
	else if(a > b)
	{
		cout << "a > b" << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int count=1;
  for(int i=1;i<n;i++){
    if(a[i]>a[i-1])count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import product
s=list(input())
a=list(product(['','+'],repeat=len(s)-1))
a_list=[]
for i in a:
    an=[s[0]]
    for j,k in zip(i,s[1:]):
        an+=j+k
    a_list.append(an)
count=0
for i in a_list:
    count+=eval(''.join(i))
print(count)

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

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

    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << R + 100 * (10 - N) << endl;
    }

    return 0;
}


Measured memory_bytes: 3608
def main():
    N = int(input())
    *a, = map(int, input().split())
    *b, = map(int, input().split())
    *c, = map(int, input().split())

    a.sort()
    b.sort()
    c.sort()

    ans = 0
    ai = 0  # [0,ai)
    ci = 0  # [ci,N)
    for mid in b:
        while ai < N and a[ai] < mid:
            ai += 1

        while ci < N and c[ci] <= mid:
            ci += 1

        ans += ai * (N - ci)

    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()


Measured memory_bytes: 22720
a, b, c, d = map(int, input().split())

takeshi_turn = True
while a > 0 and c > 0:
	if takeshi_turn:
		c -= b
		takeshi_turn = False
	else:
		a -= d
		takeshi_turn = True

if c <= 0:
	print("Yes")
else:
	print("No")


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

using namespace std;

#define MOD 1000000007
#define N 51
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

ll res[N][N], a[N][N], temp[N][N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, i, j, k;
    ll K, ans;
    cin>>n>>K;
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            cin>>a[i][j];
        }
        res[i][i] = 1;
    }
    while(K){
        if(K & 1){
            memset(temp, 0, sizeof temp);
            for(i=0; i<n; i++){
                for(j=0; j<n; j++){
                    for(k=0; k<n; k++){
                        temp[i][j] = (temp[i][j] + (a[i][k] * res[k][j]) % MOD) % MOD;
                    }
                }
            }
            for(i=0; i<n; i++){
                for(j=0; j<n; j++){
                    res[i][j] = temp[i][j];
                }
            }
        }
        memset(temp, 0, sizeof temp);
        for(i=0; i<n; i++){
            for(j=0; j<n; j++){
                for(k=0; k<n; k++){
                    temp[i][j] = (temp[i][j] + (a[i][k] * a[k][j]) % MOD) % MOD;
                    }
                }
            }
        for(i=0; i<n; i++){
            for(j=0; j<n; j++){
                a[i][j] = temp[i][j];
            }
        }
        K = K>>1;
    }
    ans = 0;
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            ans = (ans + res[i][j]) % MOD;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<queue>
#include<utility>
#include<algorithm>

using namespace std;

vector<int> edges[123456];

int N,M,s,t;

vector<int> dijkstra(int s){
  vector<int> d(N,1e9);
  queue<pair<int,int> > que;
  que.push({s,0});
  while(!que.empty()){
    auto c=que.front();
    que.pop();
    if(d[c.first]<=c.second)continue;
    d[c.first]=c.second;
    for(auto e:edges[c.first]){
      que.push({e,c.second+1});
    }
  }
  return d;
}

int main(){
  cin>>N>>M>>s>>t;
  s--;
  t--;
  while(M--){
    int x,y;
    cin>>x>>y;
    x--;
    y--;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }
  auto sto=dijkstra(s);
  auto tto=dijkstra(t);
  int sp=sto[t];
  sort(begin(sto),end(sto));
  long long ans=0;
  for(auto e:tto){
    ans+=upper_bound(begin(sto),end(sto),sp-2-e)-lower_bound(begin(sto),end(sto),sp-2-e);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 10332
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    string s;
    cin >> s;
    bool res = 1, a = 0, b = 0, c = 0;
    res &= (s.size() >= 6);
    for (int i = 0; i < (int)s.size(); i++) {
        a |= isdigit(s[i]);
        b |= islower(s[i]);
        c |= isupper(s[i]);
    }
    res &= a;
    res &= b;
    res &= c;
    cout << (res ? "VALID" : "INVALID") << endl;
    return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define int long long int
#define MOD 1000000007
using namespace std;
void solve() {
        int a, b;
        cin >> a >> b;
        int num = (b+a-3)/(a-1);
        cout << num << endl;
        return ;
}

int32_t main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        solve();
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,nr,c,s;
int main()
{
   // ifstream cin ("a.in");
   // ofstream cout ("a.out");
    cin>>n;
    if(n<10)
    {
        cout<<n;
        return 0;
    }
    c=-1;
    while(n!=0)
    {
        s+=n%10;
        ++nr;
        n/=10;
        if(n<10&&c==-1)c=n;
    }
    if(s<(nr-1)*9+c-1)cout<<(nr-1)*9+c-1;
    else cout<<s;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            int X = int.Parse (Console.ReadLine ());

            for (int i = 1; i < 9; i++)
            {
                if (X < 400 + 200 * i)
                {
                    Console.Write (9 - i);
                    return;
                }
            }
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 27536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  string s;
  cin >> s;
  if (s.at(0) != s.at(1) && s.at(1) != s.at(2) && s.at(0) != s.at(2)){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#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 k;

bool dfs(int i, int a, int b, int c) {
  if (i==k) {
    if (a<b && b<c) {
      return true;
    } else {
      return false;
    }
  }

  if (dfs(i+1, a*2,   b,   c)) return true;
  if (dfs(i+1,   a, b*2,   c)) return true;
  if (dfs(i+1,   a,   b, c*2)) return true;

  return false;
}  

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cin >> k;
  
  if (dfs(0, a, b, c)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3524
#include <iostream>
using namespace std;
int n;
char a[10];
void print(){
    for(int j = 0;j<n;j++){
        cout << a[j];
    }
    cout << endl;
}
char* re(int idx,int kind){
    if(idx == n-1){
      
        print();
        return a;
    }
    idx++;
    for(int i=0;i<kind;i++){
        a[idx]='a'+i;
        re(idx,kind);
      //cout << idx << " " << kind << " ";
    }
    a[idx]='a'+kind;
  	kind++;
    re(idx,kind);
  	return a;
}
int main(){
    
    cin >> n;
    a[0]='a';
    re(0,1);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
typedef pair<int, int> P;

int main() {
  int n; cin >> n;
  vector<vector<int>> to(n), cost(n);
  rep(i, n-1) {
    int a, b, w; cin >> a >> b >> w;
    a--, b--;
    to[a].push_back(b); cost[a].push_back(w);
    to[b].push_back(a); cost[b].push_back(w);
  }

  vector<int> ans(n, -1);
  queue<int> q;
  ans[0] = 0;
  q.push(0);
  while(!q.empty()) {
    int v = q.front();
    q.pop();
    rep(i, to[v].size()) {
      int u = to[v][i];
      int w = cost[v][i];
      if(ans[u] != -1) continue;
      ans[u] = (ans[v] + w) % 2;
      q.push(u);
    }
  }

  rep(i, n) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 11904
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

INF = float('inf')
abs_min = INF
neg_cnt = 0
res = 0

for i in range(N):
    if A[i] < 0:
        neg_cnt += 1
    abs_min = min(abs_min, abs(A[i]))
    res += abs(A[i])

if neg_cnt % 2:
    res -= 2 * abs_min

print(res)


Measured memory_bytes: 19960
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    
    D = defaultdict(int)
    count = 0
    for a in A:
        D[a] += 1
        if D[a] > a:
            count += 1
    for k in D:
        if D[k] < k:
            count += D[k]
    print(count)

Measured memory_bytes: 18676
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>
#include <queue>

#define PI 3.14159265358979
#define MOD 1000000007

using namespace std;

int main(void) {
	long long int n,sum;
	map<string, double> s;
	string t;
	int i, j, k;
	bool flag = false;
	cin >> n;
	sum = 0;
	for (i = 0; i < n; i++) {
		cin >> t;
		if (s[t] == 0)sum++;
		s[t]++;
	}
	
	cout << sum << endl;
		/*if(flag)cout << "Yes" << endl;
			else cout << "No" << endl;*/
	return 0;
}

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

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

    long long min;
    if (n % k == 0) {
        cout << 0 << endl;
        return 0;
    }
    min = n % k;
    if ((min - k) * -1 < min) {
        min = (min - k) * -1;
    }

    cout << min << endl;

    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>

using namespace std;
typedef long long lint;
int main() {
    int N;
    cin >> N;
    int x = 0, y = 0;
    for (int i = 0; i < N; i++) {
        int t, nx, ny;
        cin >> t >> x >> y;
        int dist = abs(nx - x) + abs(ny - y);
        if (dist <= t && (dist - t) % 2 == 0) {
            x = nx; y = ny;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var max = 55555;
            var prime = new Prime(max);
            var primes = new long[n];
            var i = 0;
            var p = 6;
            while (i < n && p <= max)
            {
                if (prime.IsPrime(p))
                {
                    primes[i] = p;
                    i++;
                }
                p += 5;
            }
            Console.WriteLine(string.Join(" ", primes));
        }

        public class Prime
        {
            public Dictionary<long, long> Factors => new Dictionary<long, long>(_factors);
            private Dictionary<long, long> _factors;
            private static HashSet<long> _primes;
            public Prime(long n)
            {
                if (_primes == null) _primes = new HashSet<long>();
                _factors = new Dictionary<long, long>();
                var tmp = n;
                var max = (long)Math.Sqrt(n);
                var p = 2;
                while (p <= max)
                {
                    if (tmp % p == 0)
                    {
                        _factors[p] = 0;
                        _primes.Add(p);
                        while (tmp % p == 0)
                        {
                            tmp /= p;
                            _factors[p]++;
                        }
                    }
                    p++;
                }
                if (tmp > 1)
                {
                    _factors[tmp] = 1;
                    _primes.Add(tmp);
                }
            }
            public bool IsPrime(long n)
            {
                if (_primes.Contains(n)) return true;
                var p = new Prime(n);
                return _primes.Contains(n);
            }
        }
    }
}


Measured memory_bytes: 11360
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
typedef unsigned long long ULL;

int main() {
	int n;
	int ans = 0;
	int temp = 10000001;
	std::vector <int> vec;
	std::cin >> n;

	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		vec.push_back(a);
	}

	for (int i = 0; i < vec.size(); ++i) {
		if (temp == vec[i]) {
			ans += 1;
			temp = 1000001;
		}
		else {
			temp = vec[i];
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

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

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
using namespace std;


int main(){
	ll n, m, c; cin >> n >> m >> c;
	vl b(m);
	ll ans = 0;
	for (int i = 0; i < m; ++i) cin >> b[i];
	for (int i = 0; i < n; ++i){
		ll judge = 0;
		for (int j = 0; j < m; ++j){
			ll a; cin >> a;
			judge += a*b[j];
		}if (judge + c > 0) ans++;
	}cout << ans << endl;
	return 0;
}

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

int main() {
  int N, count;
  cin >> N;
  set<int> st;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (st.count(A) == 0) {
      st.insert(A);
    }
    else if (st.count(A) == 1) {
      st.erase(A);
    }
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 4864
n = int(input())
a_list = [int(input()) for _ in range(n)]
if a_list[0] > a_list[1]:
    i_max = 0
    i_max2 = 1
else:
    i_max = 1
    i_max2 = 0
a_max = a_list[i_max]
a_max2 = a_list[i_max2]
for i, a in enumerate(a_list):
    if i < 2:
        continue
    if a > a_max:
        i_max2 = i_max
        a_max2 = a_max
        i_max = i
        a_max = a
    elif a > a_max2:
        i_max2 = i
        a_max2 = a
for i in range(n):
    if i == i_max:
        print(a_max2)
    else:
        print(a_max)


Measured memory_bytes: 12520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());

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

  vector<int> acNum(N), waNum(N);

  REP(i, M) {
    int p;
    string S;

    cin >> p >> S;
    --p;

    if (acNum[p]) continue;
    
    if (S == "AC") {
      acNum[p] = 1;

    } else {
      waNum[p]++;
    }
  }

  int AC = 0, PENA = 0;

  REP(i, N) {
    AC += acNum[i];
    if (acNum[i]) PENA += waNum[i];
  }

  cout << AC << " " << PENA << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    lol a,b,x;
    string s;
    cin>>s;
    if(s=="a" || s=="i" || s=="u" || s=="e" || s=="o") cout<<"vowel\n";
    else cout<<"consonant\n";
    return(0);
}

Measured memory_bytes: 3600
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

for i in range(n):
    if a[i] + a[i + 1] < b[i]:
        ans += a[i] + a[i + 1]
        a[i + 1] = 0
    else:
        ans += b[i]
        if a[i] < b[i]:
            a[i + 1] -= b[i] - a[i]

print(ans)


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

int main() {
  int N, M;
  cin >> N >> M;
  int ans = N * (N - 1) / 2;
  ans += M * (M - 1) / 2;
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    LL a[n+1];
    fill(a,a+n+1,0);
    int ans=0;
    for(int i=0;i<n;i++){
        LL t;
        cin >> t;
        if(t<=n) a[t]++;
        else ans++;
    }
    for(int i=1;i<=n;i++){
        if(a[i]>i) ans+=a[i]-i;
        else if(a[i]<i) ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll modpow(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=modpow(a,b/2,p);
		return t*t%p;
	}
	return a*(modpow(a,b-1,p))%p;
} 
//cout << fixed << setprecision(桁数);
//__builtin_popcount()
signed main(){
	ll n,m; cin>>n>>m;
	vector<pl> vec(n);
	priority_queue<ll> q;
	rep(i,0,n)cin>>vec[i].first>>vec[i].second;
	sort(all(vec));
	vec.push_back(make_pair(MOD,MOD));
	ll j=0;
	ll ans=0;
	rep(i,1,m+1){
		while(j<n && vec[j].first<=i){
			q.push(vec[j].second);
			j++;
		}
		if(q.empty())continue;
		ll add=q.top(); q.pop();
		ans+=add;
	}
	cout<<ans<<endl;




	return 0;
}


Measured memory_bytes: 6444
#include<stdio.h>
int main(){
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if(a*b>c*d){
        printf("%d\n", a * b);
    }else {
        printf("%d\n", c * d);
    }
}

Measured memory_bytes: 128
#include<cstdio>
int can(int x,int y,int z){
	int q=0;
	for(int l=0;l<=x/y;l++){
		int p=(x-y*l+z)%z;
		if(p==0){
			q=1;
			break;
		}
	}
	return q;
}
int main(){
	double kosa=0;
	int mizu=0;
	int satou=0;
	int a,b,c,d,e,f;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	for(int i=1;i<=30;i++){
		if(can(i,a,b)==1){
			int s=0;
			for(int j=0;j<=i*e+1;j++){
				if(i*100+j>f || j==i*e+1){
					double v=(100*s)/(i*100+s);
					if(mizu*s>i*satou*100 || kosa==0){
						mizu=i*100;
						satou=s;
						kosa=v;
					}
					break;
				}
				if(can(j,c,d)==1){
					s=j;
				}
			}
		}
	}
	if(satou==0)mizu=a*100;
	printf("%d %d",mizu+satou,satou);
	return 0;
}

Measured memory_bytes: 128
S = list(input())
N = len(S)

ACGT = ['A','C','G','T']
tmp = 0
X = []

for i in range(N):
    if S[i] in ACGT:
        tmp += 1
    else:
        X.append(tmp)
        tmp = 0

X.append(tmp)
print(max(X))


Measured memory_bytes: 9000
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

ll gcd(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

int main()
{
    int a, b, t;
    cin >> a >> b >> t;

    cout << b * (t / a) << endl;
}


Measured memory_bytes: 256
/***

   Author : Md. Jashim Uddin
   From   : RMSTU

 ***/
#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)
#define     forn(i,n)       for(int i=1;i<=n;i++)
#define      mx               10001
int main()
{

    string s;
    cin>>s;
    string ss;
    cin>>ss;
    ll c=0;
    for(int i=0;i<s.size();++i)
    {
        if(s[i]==ss[i])c++;
    }
    cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll n ; cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a.at(i);
    
    if(n!=0 && a.at(0) != 0){
        cout << -1 << endl;
        return 0;
    }
    if(n==0){
        if(a.at(0) == 1){
            cout << 1 << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }

    vector<ll> rui(n+1,0); //rui 制限の値
    rui.at(n) = a.at(n);
    for(int i=n-1;i>=0;i--){
        rui.at(i) = rui.at(i+1) + a.at(i);
    }

    vector<ll> nokori(n+1,0);
    nokori.at(0) = 1;

    for(int i=1;i<n;i++){
        //cout << i << endl;
        ll max_bunki = nokori.at(i-1)*2;
        if(max_bunki <= rui.at(i)){
            nokori.at(i) = nokori.at(i-1) * 2 - a.at(i);
        }else{
            nokori.at(i) = rui.at(i) - a.at(i);
        }
        if(nokori.at(i) <= 0){
            cout << -1 << endl;
            return 0;
        }
    }

    if(a.at(n) < nokori.at(n-1) || a.at(n) > nokori.at(n-1)*2){
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    rep(i,n+1) ans+=a.at(i);
    rep(i,n) ans+=nokori.at(i);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5616
#include<cstdio>
#include<iostream>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<cstdlib>
#include<stack>
#include<ctime>
#include<map>
#include<list>
#include<cctype>
using namespace std;

int main()
{
	int n;
	scanf("%d",&n);
	if(n>=30) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3660
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    K = read_int()
    A, B = read_ints()
    a = A//K
    if a*K == A or (a+1)*K <= B:
        return 'OK'
    return 'NG'


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


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


int main() {

    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e-a > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T)
{
    string ans = YES;

    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] != T[i])
        {
            ans = NO;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 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()
{
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

class DisjointSet {
public:
	vector<int> rank, p;

	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0; i < size; i++) makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};

int main(void)
{
	int n, q, a, b, t;
	cin >> n >> q;

	DisjointSet ds = DisjointSet(n);

	for (int i = 0; i < q; i++) {
		cin >> t >> a >> b;
		if (t == 0) ds.unite(a, b);
		else if (t == 1) {
			if (ds.same(a, b)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <string>
using namespace std;
using ull= unsigned long long;

int main() {
    string a, b;
    int c, d;

    cin >> a >> b;
    if(a.size() < b.size()) {
        cout << "LESS" << endl;
        return 0;
    } else if(a.size() > b.size()){
        cout << "GREATER" << endl;
        return 0;
    } else {
        for (int i = 0; i < a.size(); i++)
        {
            int res;
            res = a[i] - b[i];
            if (res < 0) {
                cout << "LESS" << endl;
                return 0;
            } else if(res > 0) {
                cout << "GREATER" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  int l[n];
  rep(i,n)cin >> l[i];
  int sum = 0;
  rep(i,n)sum+=l[i];
  rep(i,n){
    if(sum-l[i]<=l[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256