akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef long double ld;
using namespace std;

const int MAXN = 100, inf = 1e9;
int f[MAXN + 1][MAXN + 1], a[MAXN * 10 + 1], b[MAXN * 10 + 1], c[MAXN * 10 + 1];

int main() {
    //ios_base::sync_with_stdio(false);
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++)
            f[i][j] = inf;
    }
    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        f[a[i]][b[i]] = min(f[a[i]][b[i]], c[i]);
        f[b[i]][a[i]] = min(f[b[i]][a[i]], c[i]);
    }
    for(int k = 1; k <= n; k++) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                if(f[i][k] < inf && f[k][j] < inf)
                    f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < m; i++) {
        if(f[a[i]][b[i]] < c[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
s = input()
t = input()
csm = Counter(s).most_common()
ctm = Counter(t).most_common()
if len(csm)!=len(ctm):
    print('No')
else:
    for i in range(len(csm)):
        if csm[i][1]!=ctm[i][1]:
            print('No')
            break
        if i==len(csm)-1:
            print('Yes')

Measured memory_bytes: 9744
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
  int a;
  cin>>a;
  int b=0;
  rep1(i,a){
  if(i%3!=0&&i%5!=0)
    b+=i;
  }
  cout<<b;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;
typedef long long ll;

using namespace std;

void solve() {

    ll N, M;
    cin >> N >> M;

    if (2*N >= M) {
        print(M/2);
    } else {
        ll r = M - 2*N;
        print(N + r/4);
    }
}

int main() {

    solve();
    return 0;
}


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

int main(void){
  int a;
  cin >>a;
  if(a >= 1000){
    cout << "ABD";
  }
  else cout << "ABC";

  cout << endl;
  return 0;
}


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

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

	int canPour2A = a - b;

	int leftC = c - canPour2A;
	if (leftC <= 0)
		leftC = 0;

	cout << leftC;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	string s;
	cin >> s;
	if (s[s.size() - 1] == '2' || s[s.size() - 1] == '4' || s[s.size() - 1] == '5' || s[s.size() - 1] == '7' || s[s.size() - 1] == '9') {
		cout << "hon" << endl;
	}
	else if (s[s.size() - 1] == '0' || s[s.size() - 1] == '1' || s[s.size() - 1] == '6' || s[s.size() - 1] == '8') {
		cout << "pon" << endl;
	}
	else if (s[s.size() - 1] == '3') {
		cout << "bon" << endl;
	}
}


Measured memory_bytes: 3624
/*
 1,2,1,0,2
     2+1
       3
*/
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main (){
    int n;cin>>n;
    vector<ll>A(n);
    for(int i=0;i<n;i++)cin>>A[i];
    ll ret=0,sum=0;
    for(int i=0;i<n;i++){
            sum+=A[i];
            if(!A[i]){
                ret+=sum/2;
                sum=0;
            }
    }
    ret+=sum/2;
    cout<<ret<<endl;
    return 0;
}




Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    writeln!(o, "{}", solve(n)).unwrap();
}
fn solve(n: usize) -> usize {
    let mut ans = 0;
    for i in 1..n {
        let n1 = n - i;
        if n1 / i <= i {
            break;
        }
        if n1 % i == 0 {
            ans += n1 / i;
        }
    }
    ans
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	ll l, r, d;
	cin >> l >> r >> d;
	ll ans = 0;
	for(ll i = l; i <= r; i ++){
		if(i % d == 0){
			ans ++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
class Combi
  def initialize(max_n, mod = 10**9+7)
    @mod = mod
    @max_n = max_n

    @fac = Array.new(@max_n+1)
    @inv = Array.new(@max_n+1)
    @finv = Array.new(@max_n+1)

    @fac[0] = @fac[1] = 1
    @finv[0] = @finv[1] = 1
    @inv[1] = 1
    2.upto(@max_n) do |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
    end
  end

  def nCk(n,k)
    @fac[n] * @finv[n - k] * @finv[k] % @mod
  end
end

n,k = gets.chomp.split().map(&:to_i)
a = gets.chomp.split().map(&:to_i)
a.sort!
a.reverse!
MOD = 10**9 + 7

combi = Combi.new(n)

maxsum = 0
minsum = 0
(n-k+1).times do |i|
  newmax = (a[i] * combi.nCk(n-i-1, k-1))%MOD
  maxsum = (maxsum + newmax) % MOD

  newmin = (a[n-i-1] * combi.nCk(n-i-1, k-1))%MOD
  minsum = (minsum + newmin) % MOD
  # p [newmax, maxsum, '', minsum, newmin]
end

ans = maxsum - minsum
ans += MOD if ans < 0
puts ans


Measured memory_bytes: 16508
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();

        if ((b - a) % 2 == 0) {
            System.out.println("Alice");
            return;
        }
        System.out.println("Borys");
    }

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
const int maxn = 405;
typedef long long ll;
int A[maxn];
ll ta[maxn],memo[maxn][maxn];
ll solve(int l,int r){
    if (l+1 == r)return A[l]+A[r];
    if (l == r)return 0;
    if (l > r)return 0;
    ll &ans = memo[l][r];
    if (ans != -1)return ans;
    ans = LLONG_MAX;
    ll c= ta[r]-ta[l-1];
    for (int k = l; k < r;k++){
        ans = min(ans,solve(l,k)+solve(k+1,r));
    }
    return (ans = (ans+c));
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    for (int i = 1; i <= N;i++){
        cin >> A[i];
        ta[i] = A[i]+ta[i-1];
    }
    memset(memo,-1,sizeof memo);
    cout << solve(1,N);
    return 0;
}


Measured memory_bytes: 1536
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int tmp = n;
        int cnt = 0;

        while(tmp > 0){
            tmp /= k;
            cnt++;
        }

        System.out.println(cnt);
        
    }
}

Measured memory_bytes: 22612
import sys
input=sys.stdin.readline
from collections import deque
n,m=map(int,input().split())
E=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    E[a].append(b)
    E[b].append(a)
q=deque([0])
Visited=[False]*n
Visited[0]=True
while True:
    s=q[0]
    for v in E[s]:
        if not Visited[v]:
            Visited[v]=True
            q.appendleft(v)
            break
    else:
        break
while True:
    g=q[-1]
    for v in E[g]:
        if not Visited[v]:
            Visited[v]=True
            q.append(v)
            break
    else:
        break
print(len(q))
print(*list(map(lambda x: x+1,q)))

Measured memory_bytes: 28640
#include <stdio.h>

long long int L[88];

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

Measured memory_bytes: 128
#define DBG 0 //submit 0
#if DBG==1
    #include <algorithm>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <iostream>
    #include <cmath>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;

long long mygcd(long long x,long long y){
    if (x<y) swap(x,y);
    long long r = x%y;
    while(r!=0){
        x = y;
        y = r;
        r = x % y;
    }

    return y;
}

int main(){
    //long long ans = 0,sum = 0;
    long long A,B,lltmp=0,llans=0; 
    long long C,D,N,L,i,j,k,tmp=0,ans = 0;
    //string S;
    cin >> A >> B >> C >> D;

    llans = B - A + 1 - ((B/C-(A-1)/C)+(B/D-(A-1)/D)-(B/(C*D/mygcd(C,D))-(A-1)/(C*D/mygcd(C,D))));

    cout << llans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <list>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

ll solve(int n, int x, V& as){
    ll c = 0;
    
    for(int i = 0; i < n / 2; i++){
        ll e;
        if(as[i] + as[i + 1] > x){
            e = as[i] + as[i + 1] - x;
            c += e;
            if(as[i + 1] >= e){
                as[i + 1] -= e;
            }else{
                as[i + 1] = 0;
                as[i] -= e - as[i + 1];
            }         
        }

        if(as[n - 1 - i] + as[n - 2 - i] > x){
            e = as[n - 1 - i] + as[n - 2 - i] - x;
            c += e;
            if(as[n - 2 - i] >= e){
                as[n - 2 - i] -= e;
            }else{
                as[n - 2 - i] = 0;
                as[n - 1 - i] -= e - as[n - 2 - i];
            }
        }
    }
    
    return c;
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, x;
    cin >> n >> x;
    V as(n);
    for(int i = 0; i < n; i++){
        cin >> as[i];
    }

    cout << solve(n, x, as) << endl;

    return 0;
}


Measured memory_bytes: 640
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) swap(a, b); while (b) swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<string> s(n);
    REP(i, n) cin >> s[i];

    ll ans = 0;
    REP(a, n) {
        bool okay = true;
        REP(i, n) {
            REP(j, n) {
                if (s[(i+a)%n][j] != s[(j+a)%n][i]) {
                    okay = false;
                    break;
                }
            }
            if (!okay) break;
        }
        if (okay) ans++;
    }
    ans *= n;
    cout << ans << endl;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S; cin >> S;
    int ans = 1000;
    for(int i = 0; i < S.size()-2; i++) {
        string k;
        k += S.at(i);
        k += S.at(i+1);
        k += S.at(i+2);
        ans = min(ans, abs(stoi(k) - 753));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3,no-stack-protector")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
#pragma GCC target("avx")

#include<bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using ull = unsigned long long;
 
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define int long long

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

int get_st(int a, int x) {
    int res = 0;
    int rs1 = a / x * x;
    while (a > 0) {
        res += (a / 2) / x;
        a /= x;
    }
    return res;
}


signed main() {
    accell();
     // freopen("twocaptains.in", "r", stdin);
     // freopen("twocaptains.out", "w", stdout);

    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    if (n & 1) {
        cout << 0;
        return 0;
    }
    // cout << get_st(n, 5) << endl;
    cout << min(get_st(n, 2), get_st(n, 5)) << '\n';
    return 0;
}
 


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	int H, W, ans=0;

	cin >> H >> W;
	rep(i,H) rep(j,W){
		string s;
		cin >> s;
		if( s == "snuke" ){
			cout << (char)('A'+j) << i+1 << endl;
		}
	}


	return 0;
}


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

int main(){
  while(1){
    int N,A,B,C,X;
    cin>>N>>A>>B>>C>>X;
    if(N+A+B+C+X==0) break;
    int y;
    int cou=0,f=0;
    for(int i=0;i<N;i++){
      cin>>y;
      while(1){
	if(cou>10000 || cou==-1){
	  cou=-1;
	  break;
	}
	if(cou==0 && X==y && f==0){
	  f=1;
	  break;
	}
	  X=(A*X+B)%C;
	  cou++;
	  
	  if(X==y){
	    if(cou>10000){
	  cou=-1;
	    }
	    break;
	  }
      }
    }
    cout<<cou<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline
import collections
n=int(input())
S=[]
append=S.append
for i in range(n):
  s=input()
  ss=0
  for j in range(10):
    ss+=11**(ord(s[j])-97)
  append(ss)
SS=collections.Counter(S).values()
ans=0
for ss in SS:
  if ss>1:
    ans+=(ss-1)*ss//2
print(ans)




Measured memory_bytes: 17432
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long x;
  cin >> x;
  long ans = 0;
  ans += (x / 11) * 2;
  x %= 11;
  if (x == 0) {}
  else if (x <= 6) ans++;
  else ans+=2;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
/*  ex3_3
    potter0723sw  */

//方針：NをKで何回も割って商が0になるまでの割る回数をカウントする

#include <stdio.h>

int main(void) {
	int N,K,answer;
	scanf("%d %d", &N, &K);
	answer = 1;//最後に2桁残ることを考慮して1からスタート
	while(N >= K){//NがKより小さくなったら割るのを終わる
		N = N / K;
		answer += 1;
    }
    printf("%d\n",answer);
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    ll n, k;
    cin >> n >> k;
    
    if(n > k) {
        ll ans = min(n%k, abs(k-n%k));
        cout << ans << endl;
        return 0;
    }
    else {
        ll ans = min(n, abs(n-k));
        cout << ans << endl;
        return 0;
    }
}




Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define xam INT_MIN
#define nim INT_MAX
#define mp make_pair

using namespace std;
///check n=1;
///check corner case;
int main()
{
    string a,b,c;
    cin>>a;
    ll i;
    for(i=0;i<a.size();i++)cout<<"x";

return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        s: Chars,
    }
    println!(
        "{}",
        if s.len() == s.iter().unique().count() {
            "yes"
        } else {
            "no"
        }
    );
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll K;
    string s;
    cin >> s >> K;

    for(int i = 0;i < s.size();i++){
        if(s.at(i) == '1' and i == (K -1)){
            cout << s.at(i) << endl;
            break;
        }else if(s.at(i) != '1'){
            cout << s.at(i) << endl;
            break;
        }
    }


}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
 
int main() {

    int n;
    cin >> n;
    vector<char> c(n);
    int rc = 0;
    rep(i,n) {
        cin >> c[i];
        if(c[i] == 'R') rc++;
    }

    int ans = 0;
    rep(i,rc) {
        if(c[i] == 'W') ans++;
    }

    cout<<ans<<endl;

 return 0;
}

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

# 素因数分解
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

divisors = make_divisors(N)

a = 1
b = N
sum_ab = 1+N
for n in (divisors):
    tmp_a = n
    tmp_b = N//n
    tmp_ab = tmp_a + tmp_b
    if tmp_ab < sum_ab:
        sum_ab = tmp_ab
        a = tmp_a
        b = tmp_b

ans = a+b-2
print(ans)



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

int main() {

	int W,H,N,ans;
	cin >>W>>H>>N;
  vector<int>X(N),Y(N),A(N),xmax(0),xmin(0),ymax(0),ymin(0);
  
  
  for(int i=0; i<N; i++){
    cin>>X.at(i)>>Y.at(i)>>A.at(i);}
  for(int i=0; i<N; i++){
    if(A.at(i)==1){xmax.push_back(X.at(i));}
    if(A.at(i)==2){xmin.push_back(X.at(i));}
    if(A.at(i)==3){ymin.push_back(Y.at(i));}
    if(A.at(i)==4){ymax.push_back(Y.at(i));}
  }
  sort(xmax.begin(),xmax.end());
  sort(xmin.begin(),xmin.end());
  sort(ymax.begin(),ymax.end());
  sort(ymin.begin(),ymin.end());
  
  if(xmax.empty()){xmax.push_back(0);}
  if(xmin.empty()){xmin.push_back(W);}
  if(ymin.empty()){ymin.push_back(0);}
  if(ymax.empty()){ymax.push_back(H);}
  if(xmax.back()>=xmin.at(0)||ymax.at(0)<=ymin.back()){ans=0;}
  else {ans=(xmin.at(0)-xmax.back())*(ymax.at(0)-ymin.back());}
    
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int kMaxN = 200001;

struct V {
  int c, v;
} v[kMaxN * 4];
int w, h, x, y, z;

void P(int i, int ml, int c) {
  v[i].c = c;
  v[i].v = c != -1 ? ml - c : w;
}

void U(int i, int ml, int mr, int nl, int nr, int c) {
  if (nl == ml && nr == mr) {
    P(i, ml, c);
    return;
  }
  int m = (ml + mr) >> 1;
  if (v[i].c) {
    P(i * 2, ml, v[i].c);
    P(i * 2 + 1, m + 1, v[i].c);
    v[i].c = 0;
  }
  if (nl <= m) {
    U(i * 2, ml, m, nl, min(nr, m), c);
  }
  if (nr > m) {
    U(i * 2 + 1, m + 1, mr, max(m + 1, nl), nr, c);
  }
  v[i].v = min(v[i * 2].v, v[i * 2 + 1].v);
}

void F(int i, int ml, int mr, int t) {
  if (v[i].c) {
    z = v[i].c;
    return;
  }
  int m = (ml + mr) >> 1;
  if (t <= m) {
    F(i * 2, ml, m, t);
  } else {
    F(i * 2 + 1, m + 1, mr, t);
  }
}

int main() {
  cin >> h >> w;
  for (int i = 1; i <= w; i++) {
    U(1, 1, w, i, i, i);
  }
  for (int i = 1; i <= h; i++) {
    cin >> x >> y;
    if (x == 1) {
      U(1, 1, w, x, y, -1);
    } else {
      F(1, 1, w, x - 1);
      U(1, 1, w, x, y, z);
    }
    cout << (v[1].v == w ? -1 : v[1].v + i) << endl;
  }
  return 0;
}

Measured memory_bytes: 7668
#pragma gcc optimize (o3)
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define ll long long
#define ld long double
#define U unsigned
#define pi acos(-1)

using namespace std;

const ll N = 1e2+5, M = 1e5+5;

ll w[N], v[N], vis[N][M], vid;
ll n, W, mxV, V;
pair<ll, ll> dp[N][M];

pair<ll, ll> solve(ll ind, ll curV)
{
    if(curV>mxV) return {-1e9, 1e9};
    if(vis[ind][curV]) return dp[ind][curV];
    vis[ind][curV] = 1;
    if(ind == n) return {0, 0};
    pair<ll, ll> ret = max(make_pair(solve(ind+1, curV+v[ind]).F+v[ind], solve(ind+1, curV+v[ind]).S-w[ind]), solve(ind+1, curV));
    return dp[ind][curV] = ret;
}

int main()
{
    cin>>n>>W;
    for(int i = 0 ; i < n ; i ++)
    {
        cin>>w[i]>>v[i];
        mxV += v[i];
    }
    vid++;
    ll s = 0, e = mxV, mid, best = 0;
    for(int i = 0 ; i < mxV ; i++)
    {
        pair <ll, ll> xx = solve(0, i);
        if(abs(xx.S) <= W)
        {
            best = max(best, xx.F);
        }
    }
    cout<<best;
    return 0;
}


Measured memory_bytes: 237824
#include <stdio.h>
int main()
{
  int n,c;
  for(;;){
    scanf("%d",&n);
    if(n==0) break;
    n = 1000 - n;
    c = 0;
    while(n>=500){
      n -= 500;
      c++;
    }
    while(n>=100){
      n -= 100;
      c++;
    }
    while(n>=50){
      n -= 50;
      c++;
    }
    while(n>=10){
      n -= 10;
      c++;
    }
    while(n>=5){
      n -= 5;
      c++;
    }
    while(n>=1){
      n -= 1;
      c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

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

#define INF (1<<29)
#define max_n 10000

using namespace std;

struct node_t{
  node_t *pp,*lp,*rp;
  int id,val,mini,minId,lazy;
  bool rev;

  node_t(int id,int v):id(id),val(v){
    pp=lp=rp=NULL;
    rev=false; 
    lazy=0; 
    update();
  }
   
  void update(){
    mini=val,minId=id;
    if(lp && mini>lp->mini)mini=lp->mini,minId=lp->minId;
    if(rp && mini>=rp->mini)mini=rp->mini,minId=rp->minId;
  }
   
  void apply(int v){ lazy+=v, val+=v, mini+=v; }
   
  void push(){
    if(rev){
      rev=false;
      swap(lp,rp);
      if(lp)lp->rev^=true;
      if(rp)rp->rev^=true;
    }
    if(lp)lp->apply(lazy);
    if(rp)rp->apply(lazy);
    lazy=0;
  }
 
  bool is_root(){
    return !pp || (pp->lp != this && pp->rp != this);
  }
  
  void rotr(){
    node_t *q=pp,*r=q->pp;
    q->push(),push();
    if((q->lp=rp))rp->pp=q;
    rp=q;q->pp=this;
    if((pp=r)){
      if(r->lp==q)r->lp=this;
      if(r->rp==q)r->rp=this;
    }
    q->update();
  }

  void rotl(){
    node_t *q=pp,*r=q->pp;
    q->push(),push();
    if((q->rp=lp))lp->pp=q;
    lp=q;q->pp=this;
    if((pp=r)){
      if(r->lp==q)r->lp=this;
      if(r->rp==q)r->rp=this;
    }
    q->update();
  }

  void splay(){
    while(!is_root()){
      node_t *q=pp;
      if(q->is_root()){
	if(q->lp==this)rotr();
	else rotl();
      } else {
	node_t *r=q->pp;
	if(r->lp==q){
	  if(q->lp==this){q->rotr();rotr();}
	  else {rotl();rotr();}
	} else {
	  if(q->rp==this){q->rotl();rotl();}
	  else {rotr();rotl();}
	}
      }
    }
    push();
    update();
  }
};

node_t *expose(node_t *x){
  node_t *rp=NULL;
  for(node_t *p=x;p;p=p->pp){
    p->splay();
    p->rp=rp;
    p->update();
    rp=p;
  }
  x->splay();
  return rp;
}

node_t *find_root(node_t *x){
  expose(x);
  while(x->lp)x=x->lp;
  return x;
}

void cut(node_t *c){
  expose(c);
  node_t *p=c->lp;
  c->lp=NULL;
  p->pp=NULL;
  c->val=INF;
}

void link(node_t *c,node_t *p){
  expose(c);
  expose(p);
  c->pp=p;
  p->rp=c;
  c->update();
}

//Unverified.
void evert(node_t *p){
  expose(p);
  p->rev^=true;
}

//Verified.
int minId(node_t *x){expose(x); return x->minId;}
void add(node_t *x,int val){ expose(x); x->apply(val); }

//Verified. AOJ GRL_5_C
node_t *LCA(node_t *x,node_t* y){
  expose(x);
  return expose(y);
}

//AOJ GRL_5_C
node_t *node[100001];

int main(void){
  int n;
  cin >> n;
  
  for(int i=0;i<n;i++)node[i]=new node_t(i,0);
  for(int i=0;i<n;i++){
    int k,t;
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> t;
      link(node[t],node[i]);
    }
  }

  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int u,v;
    cin >> u >> v;
    cout << LCA(node[u],node[v])->id << endl;
  }
  
  return 0;
}

Measured memory_bytes: 8220
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long int lli;

vector<pair<lli, lli> > factoring(lli n){
	vector<pair<lli, lli> > res;
	for(lli i=2; i*i<=n; i++){
		if(n%i == 0){
			res.emplace_back(i, 0);
			while(n%i == 0){
				n /= i;
				res.back().second++;
			}
		}
	}
	if(n != 1){
		res.emplace_back(n, 1);
	}
	return res;
}

int main(){
	lli n;
	cin >> n;
	auto fact = factoring(n);
	lli numfact = 1;
	for(auto p: fact){
		numfact *= p.second +1;
	}
	cout << fact.size() << " " << numfact-1 << endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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; }

int main() {
	int h,a;
	cin >> h >> a;
	int ans;
	ans = h / a;
	if (h % a != 0) ans++;
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int div = 11;
    ull x;
    cin >> x;
    
    ull q = x / div;
    ull res;
    res = q * 2;
    int r = x % div;
    if(r == 0){
        
    }else if(r <= 6){
        res++;
    }else{
        res += 2;
    }
    cout << res << endl;
}

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

int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;

    for(char c : s) {

        int x = c - 'A';
        x += n;
        x %= 26;
        cout << (char)(x + 'A');
    }
    cout << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char ch;
    cin>>ch;
    if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch== 'u')
        cout<<"vowel"<<endl;
    else
        cout<<"consonant"<<endl;
        return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N;

int main(){
    cin >> N;
    for(int i=1;i<=3500;i++){
        for(int j=1;j<=3500;j++){
            ll a = N*i*j;
            ll b = 4*i*j - i*N - j*N;
            if(b <= 0) continue;
            if(a % b != 0) continue;
            cout << i << " " << j << " " << a / b << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  string s;
  cin >> s;
  int res = 0;
  rep(i, s.size()) {
    int cnt = 0;
    for (int j = i; j < s.size(); j++) {
      if (s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T') break;
      ++cnt;
    }
    chmax(res, cnt);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

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

ll n;
string s;

int main() {
  cin >> n >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  rep(i, n / 2) {
    if (s[i] != s[i + (n / 2)]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {

    long N, K;
    cin >> N >> K;

    if (N % K == 0) {
        cout << 0 << endl;
        return 0;
    }

    if (N > K) {
        long tmp = (N / K) + 1;
        cout << abs(N - (tmp * K)) << endl;
        return 0;
    }


    if (N < K) {
        cout << min(N, abs(N - K)) << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
List = [input() for i in range(n)]
res = []

c = collections.Counter(List)


leng = len(c)

ac = c.most_common()
res.append(ac[0][0])
for i in range(1, leng):
    if ac[i][1] >= ac[i-1][1]:
        res.append(ac[i][0])
    else:
        break

#res = sorted(res)
res.sort()
for j in range(len(res)):
    print(res[j])

Measured memory_bytes: 47664
#include<stdio.h>
int main(void)
{
	int n;
	int x1,x2,x3;
	int y1,y2,y3;
	int z1,z2,z3;
	int w1,w2,w3;
	int i,j;
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d %d %d %d %d %d",&x1,&y1,&z1,&w1,&x2,&y2,&z2,&w2);
			x3=x1*x2-y1*y2-z1*z2-w1*w2;
			y3=x1*y2+y1*x2+z1*w2-w1*z2;
			z3=x1*z2-y1*w2+z1*x2+w1*y2;
			w3=x1*w2+y1*z2-z1*y2+w1*x2;
			printf("%d %d %d %d\n",x3,y3,z3,w3);
		}
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
H, W = map(int, input().split())
grid = [input() for i in range(H)]

tate = [[0] * W for i in range(H)]
yoko = [[0] * W for i in range(H)]

for i in range(H):
	for j in range(W):
		if grid[i][j] == ".":
			if tate[i][j] == 0:
				back = 0
				while(1):
					if 0 > i - back or grid[i - back][j] == "#":
						break
					else:
						back += 1
				forth = 0
				while(1):
					if i + forth >= H or grid[i + forth][j] == "#":
						break
					else:
						forth += 1
				for k in range(-back + 1, forth):
					tate[i + k][j] = forth + back - 1
			if yoko[i][j] == 0:
				back = 0
				while(1):
					if 0 > j - back or grid[i][j - back] == "#":
						break
					else:
						back += 1
				forth = 0
				while(1):
					if j + forth >= W or grid[i][j + forth] == "#":
						break
					else:
						forth += 1
				for k in range(-back + 1, forth):
					yoko[i][j + k] = forth + back - 1

maxl = 0
for i in range(H):
	for j in range(W):
		maxl = max(maxl, tate[i][j] + yoko[i][j] - 1)
print(maxl)

Measured memory_bytes: 143328
#include<bits/stdc++.h>
#define nl                 "\n"
#define ll                 long long
#define pb                 push_back
#define pf                 push_front
#define np                 next_permutation
#define pp                 prev_permutation
#define sqr(x)             ((x)*(x))
#define pi                 acos(-1)
#define setprecision(x)    fixed<<setprecision((int)(x))
#define mem1(x)            memset(x,0,sizeof(x))
#define mem2(x)            memset(x,-1,sizeof(x))
#define all(x)             (x).begin(),(x).end()
#define rev(x)             reverse(all(x))
#define iota(x,a)          iota(all(x),a)
#define sorta(x)           sort(all(x))
#define sortd(x)           sort(all(x),greater<int>())
#define csort(x,c)         sort(all(x),c)
#define rsort(x)           sort(x.rbegin(),x.rend())
#define faster_io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all_ele(x)         for(auto i:(x)){cout<<i<<' ';}cout<<nl;
#define multiple_test      int t; cin>>t; while(t--){solve();}
#define single_test        solve();
using namespace std;
//vector<vector<int>>p(sz,vector<int>(sz,val));
void solve()
{
   int n,d,c=0;
   cin>>n>>d;
   while(n--)
   {
       double x,y;
       cin>>x>>y;
       if(sqrt(sqr(x)+sqr(y))<=d)
        c++;
        //cout<<sqrt(sqr(x)+sqr(y))<<nl;
   }
   cout<<c<<nl;
}
int main()
{
    faster_io;
    //multiple_test
    single_test
    return 0;
}




Measured memory_bytes: 3820
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>
#include <iomanip>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int l;
    double x, y;
    cin >> l;

    x = max(0.0, 2.0*l/6.0);
    y = l - 2 * x;

    cout << setprecision(6) << fixed <<  x*x*y << '\n';

    return 0;
}



Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
cost=[0,abs(h[1]-h[0])]
for i in range(2,n): cost.append(min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2])))
print(cost[-1])

Measured memory_bytes: 13928
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static Scanner sc;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long[] H = new long[N];
        for(int i = 0; i < N; i++) {
            H[i] = sc.nextLong();
        }

        if(N == K) {
            System.out.println("0");
            return;
        }

        long[][] dp = new long[N][N-K+1];
        for(int i = 0; i < N; i++) {
            dp[i][0] = 0;
            dp[i][1] = H[i];
        }

        for(int l = 2; l <= N-K; l++) {
            for(int k = 0; k < N; k++) {
                if(k + 1 >= l) {
                    long min = -1;
                    for(int i = 0; i < k; i++) {
                        if(dp[i][l-1] != -1) {
                            long tmp = dp[i][l-1] + Math.max(0, H[k] - H[i]);
                            if(min == -1 || tmp < min) {
                                min = tmp;
                            }
                        }
                    }
                    dp[k][l] = min;
                } else {
                    dp[k][l] = -1;
                }
            }
        }

        long result = -1;
        for(int i = (N - K) - 1; i < N; i++) {
            if(result == -1 || dp[i][N-K] < result) {
                result = dp[i][N-K];
            }
        }
        System.out.println(result);
    }
}


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

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

int main() {
    int N;
    cin>>N;
    vector<long long> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    long long res=1;
    vector<long long> L(N+1);
    vector<long long> R(N+1);
    L[0]=0;
    R[N]=0;
    for(int i=1;i<N+1;i++){
      L[i]=__gcd(L[i-1],A[i-1]);
    }
    for(int i=N-1;i>=0;i--){
      R[i]=__gcd(R[i+1],A[i]);
    }
    for(int i=0;i<N;i++){
   	  res=max(res,__gcd(L[i],R[i+1]));
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 2560
n = int(input())
S=[]
for i in range(n):
    S.append(input())

ans = []

if n>1:
    #チェックする文字をS[0]から取得
    for i in S[0]:
        #すべてのSについてチェックする文字の存在判定
        hantei=[]
        for j in range(1,n):
            idx = S[j].find(i)
            hantei.append(idx) #存在する位置をリストに追加
            if idx >= 0: S[j] = S[j][:idx] + S[j][idx+1:] #存在した場合はそれを除去そておく
        if min(hantei) >= 0: ans.append(i)
else:
    ans = [i for i in S[0]]

#辞書順にする
ans.sort()
#文字列にする
ans2 = ''.join(ans)
print(ans2)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    int n; cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll sa = 0, sb = 0;
    rep(i, n) {
        if (a[i] > b[i]) sa += a[i] - b[i];
        else sb += (b[i] - a[i]) / 2;
    }
    cout << (sa <= sb ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
a = int(input())
t = [0]*1000000
t[a] = 1
for i in range(2,1000001):
    if a % 2 == 0:
        a //= 2
    else:
        a = 3*a + 1
    if t[a]:
        break
    t[a] = 1
print(i)

Measured memory_bytes: 10740
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL n, m;
    cin >> n >> m;
    if( n == 1 && m == 1 ) cout << 1;
    else if( n == 1 ) cout << m - 2;
    else if( m == 1 ) cout << n - 2;
    else cout << ( n - 2 ) * ( m - 2 );
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// mint
#include<cstdint>
int64_t const MOD = 1e9+7;

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};
typedef mod_int<MOD> mint;

int main() {
  int N, K; std::cin >> N >> K;
  int L = 31630; //std::min(N/2, 31630);
  //while(L*L <= N) ++L;
  std::vector<mint> dp1(L+1), dp2(L+1);
  std::fill_n(dp1.begin()+1, std::min(L, N), mint(1));
  std::fill_n(dp2.begin()+1, L, mint(1));
  
  mint sum; 
  while(K--) {
    std::swap(dp1, dp2);
    // sum up previous dp1[] to current dp2[]
    for(int i = 1; i <= L; ++i) dp2[i] += dp2[i-1];
    //
    sum = dp2[N/(L+1)];
    // sum up previous dp2[] to current dp1[]
    for(int i = L; i > 0; --i) {
      sum += dp1[i]*mint(N/i - N/(i+1));
      dp1[i] = sum;
    }
  }
  fin(sum.v_);
  return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();

    int dp[n + 1][m + 1];
    for (int j = 0; j <= m; ++j) dp[0][j] = 0;
    for (int i = 0; i <= n; ++i) dp[i][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            dp[i + 1][j + 1] = dp[i + 1][j];
            if (dp[i + 1][j] < dp[i][j + 1]) dp[i + 1][j + 1] = dp[i][j + 1];
            if (s[i] == t[j] && dp[i + 1][j + 1] < dp[i][j] + 1) dp[i + 1][j + 1] = dp[i][j] + 1;
        }
    }

    string ans = "";
    int i = n, j = m;
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i - 1][j]) --i;
        else if (dp[i][j] == dp[i][j - 1]) --j;
        else if (dp[i][j] == dp[i - 1][j - 1] + 1) {
            ans += s[i - 1];
            --i;  --j;
        }
    }
    reverse(ans.begin(), ans.end());

    cout << ans << endl;
}


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

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans = 0;
    ans += (N /(A+B)) * A;
    N %= (A+B);
    if(N > A) ans += A;
    else ans += N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(a,b,c);
  FOR(i,1,a+1){
    if(i*b>=c) {
      z=i;
      break;
    }
  }
  FOR(i,1,b+1){
    if(i*a>=c) {
      y=i;
      break;
    }
  }
  OUT(min(y,z));
}

Measured memory_bytes: 256