akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();

        if (x == 3 || x == 5 || x == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21716
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=200*1000;
P bs[L];
int N;
int main() {
	cin >> N;
	for(int i=0;i<N;i++){
		int x,y;
		cin >> x >> y;
		if(x>y){
			swap(x,y);
		}
		bs[i]=P(x,y);
	}
	sort(bs,bs+N);
	int r0,r1,b0,b1;
	r0=bs[0].first;
	r1=bs[N-1].first;
	b0=b1=bs[0].second;
	for(int i=1;i<N;i++){
		b0=min(b0,bs[i].second);
		b1=max(b1,bs[i].second);
	}
	LL ret=(r1-r0)*(LL)(b1-b0);
	//cerr << ret << endl;
	r1=b1;
	int m0,m1;
	m0=m1=bs[0].second;
	//cerr << r0 << ", " << r1 << endl;
	for(int i=1;i<N;i++){
		b0=min(bs[i].first,m0);
		b1=max(bs[N-1].first,m1);
		//cerr << b0 << ": " << b1 << endl;
		ret=min(ret,(r1-r0)*(LL)(b1-b0));
		m0=min(m0,bs[i].second);
		m1=max(m1,bs[i].second);
	}
	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 1792
import math
a,b,h,m=map(int,input().split())
lrad=6*m
srad=30*h+0.5*m
if abs(lrad-srad)<=180:
    do=abs(lrad-srad)
else:
    do=360-abs(lrad-srad)
rad=math.radians(do)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(rad)))

Measured memory_bytes: 9360
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
const int N = 1e5 + 5;
int dp[2][N];
vector<int> g[N];
void dfs(int u,int p){
	dp[0][u] = 1;
	dp[1][u] = 1;
	for(int v : g[u]){
		if(v != p){
			dfs(v, u);
			dp[0][u] = (dp[0][u] * (dp[0][v] + dp[1][v])) % mod;
			dp[1][u] = (dp[1][u] * dp[0][v]) % mod;
		}
	}
}
void solve(){
	int n;
	cin >> n;
	fr(i, 1, n - 1){
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	dfs(1, 0);
	cout << (dp[0][1] + dp[1][1]) % mod;
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
 	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    vector<char> N(2000000);
    ll sum=0;
    for(ll i=0; i<2000000; i++) {
        cin >> N.at(i);
        int a;
        a=N.at(i)-'0';
      	if(a<0) break;
        sum+=a;
    }
    if(sum%9==0) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 4896
#abc100 b
d,n=map(int,input().split())

def func(x):
    if x%100!=0:
        return 0
    return func(int(x/100))+1
i=1
cnt=0
while True:
    if func(i)==d:
        cnt+=1
        if cnt==n:
            print(i)
            break
    i+=1


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
  int t=0,h=0,n;
  string T,H;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>T>>H;
    if(T==H){
      t++;
      h++;
    }
    else if(T>H) t+=3;
    else h+=3;
  }
  cout<<t<<" "<<h<<endl;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int m, d;
	cin >> m >> d;
	int ans = 0;

	for (int i = 1; i <= m; ++i) {
		for (int j = 10; j <= d; ++j) {
			int rec1 = j % 10;
			int rec2 = j / 10;
			if (rec1 >= 2 && rec2 >= 2 && rec1 * rec2 == i) {
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAXs 10000
#define MAXt 500

int linearSearch(int S[], int T, int n)
{
	int i = 0;
	int key = T;
	while(S[i] != key) {
		i++;
		if(i == n)
			return 0;
	}
	return 1;
}

int main()
{	
	int i;
	int s, q;
	int count = 0;
	int S[MAXs], T[MAXt];

	scanf("%d", &s);
	for(i = 0; i < s; ++i)
		scanf("%d", &S[i]);

	scanf("%d", &q);
	for (i = 0; i < q; ++i)
	{
		scanf("%d", &T[i]);
		count += linearSearch(S, T[i], s);
	}

	printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

func main() {
	var x1, y1, x2, y2 float64
	fmt.Scan(&x1, &y1, &x2, &y2)
	ans := math.Sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
	fmt.Println(ans)
}



Measured memory_bytes: 1172
#include<stdio.h>

int gcd(int a, int b, int c);

int main(void){

    int K;
    
    long int answer = 0;

    //入力部分
    scanf("%d",&K);

    //計算部分
    for(int a = 1; a <= K; a++){
        for(int b = 1; b <= K; b++){
            for(int c = 1; c <= K; c++){
                answer += gcd(a,b,c);
            }
        }
    }

    //出力部分
    //answer = gcd(2,2,2);
    printf("%ld\n",answer);
}

int gcd(a,b,c){
    int g=a;
    if(g>b)g=b;
    if(g>c)g=c;
    while(g!=1){
        if((a%g==0) && (b%g==0) && (c%g==0)){
            //printf("(%d,%d,%d)%d\n",a,b,c,g);
            break;
        }
        g--;
    }
    return g;
}

Measured memory_bytes: 1732
from collections import Counter


N = int(input())
D = Counter(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

for t in T:
    if D[t] - 1 < 0:
        print("NO")
        break
    D[t] -= 1
else:
    print("YES")


Measured memory_bytes: 50568
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    final long MOD = (long)1e9+7;

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

    void run() {
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] num = new long[k+1];

        for (int i=k; i>=1; i--) {
            num[i] = modpow(k/i, n);
            for (int j=2; j*i<k+1; j++) {
                num[i] = (num[i]-num[j*i]+MOD)%MOD;
            }
        }

        long ans = 0;

        for (int i=1; i<=k; i++) {
            ans += i*num[i];
            ans %= MOD;
        }

        System.out.println(ans%MOD);

    }

    long modpow(long x, long n) {
        long sum = 1;
        while (n>0) {
            if ((n&1)==1) {
                sum *= x;
                sum %= MOD;
            }
            x *= x;
            x %= MOD;
            n >>= 1;
        }
        return sum%MOD;
    }

}


Measured memory_bytes: 36400
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;
typedef pair<int,string> pis;

bool cmp(pis x, pis y){
	return x.first < y.first;
}

void Main()
{
  	int N, M;
	cin >> N >> M;
  	//vector<int> p(M), S(M);
  	int p;
    string S;
  	vector<pis> data(M);
  	rep(i,M) {
      	cin >> p >> S;
  		data[i] = make_pair(p, S);
    }
  	stable_sort(data.begin(), data.end(), cmp);
  	
  	/*
    rep(i,M){
		cout << i << ": " << data[i].first << " " << data[i].second << endl;
    }
	*/
  	ll temp = 0;
  	ll penalty = 0;
  	ll ac = 0;
  	int flag = 0;  	
  	rep(i,M){
    	if(i != 0 && data[i-1].first != data[i].first) {
          	flag = 0;
          	temp = 0;
        	//cout << i << ": flag_reset" << endl;
        }
      	if(flag == 0 && data[i].second != "AC"){
          	temp++;
          	//cout << i << ": penalty" << endl;
        }
      	else if(flag == 0 && data[i].second == "AC") {
          	flag = 1;
          	penalty += temp;
            ac++;
          	//cout << i << ": flag" << endl;
        }
    }
  	cout << ac << " " << penalty << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main(){
  int i;
  char c;
  bool f[26]={};
  while(cin>>c) f[c-'a']=1;
  for(i=0;i<26;i++){
    if(f[i]==0){
      printf("%c\n", 'a'+i);
      break;
    }
  }
  if(i==26) cout<<"None"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define test() ll t;cin>>t;while(t--)
#define MOD 1000000007
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

int main() {
    SPEED;
    //CODE
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	ll dp[n]={0};
	dp[1]=abs(a[1]-a[0]);
	for(ll i=2;i<n;i++){
		dp[i]=INT_MAX;
		for(ll j=max(0LL,i-k);j<i;j++){
			dp[i]=min(dp[i],dp[j]+abs(a[j]-a[i]));
		}
	}
	cout<<dp[n-1];
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

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

	vector<char>v;

	for (int i = 0; i < s.size(); i++) {
		//char k = s[i - 1];
		if (s[i] == '0') {
			v.push_back('0');
		}
		if (s[i] == '1') {
			v.push_back('1');
		}
		if (s[i] == 'B'){
			if (i != 0 && !v.empty()) {
				v.pop_back();
			}
		}
	}
	
	rep(i, v.size()) {
		cout << v[i];
	}
}

Measured memory_bytes: 256
x,y=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
A,B=sorted(A)[::-1],sorted(B)[::-1]
mod=10**9+7
X,Y=0,0
for i in range(x):
  d=A[i]*(x-i)-A[i]*(i)-A[i]
  X+=d
  X%=mod
for i in range(y):
  d=B[i]*(y-i)-B[i]*(i)-B[i]
  Y+=d
  Y%=mod
print(X*Y%mod)

Measured memory_bytes: 24396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  int sum=0;
  for (int i=0;i<N;i++){
    sum+=v[i];
  }
  if (v[N-1]*2<sum){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

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



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
   unordered_set<string>st;
   int n;
   cin>>n;
   for(int i=0;i<n;i++){
     string s;
     cin>>s;
     st.insert(s);
   }
   cout<<st.size()<<endl;
  return 0;
}

Measured memory_bytes: 17696
import sys,math,copy,queue,itertools,bisect,collections
from heapq import *
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

N,M = LI()
H = [0] + LI()
root = [[] for _ in range(N+1)]
for _ in range(M):
    a,b = LI()
    root[a].append(b)
    root[b].append(a)

ans = 0
for i in range(1,N+1):
    x = H[i]
    for r in root[i]:
        if H[r] >= x: break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 92844
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;
constexpr ll MOD=1e9+7;

int main()
{
	int N;
	cin>>N;
	vector<ll> A(N);
	rep(i,N)cin>>A[i];
	ll res=0;
	rep(idx,60){
		ll cnt0=0,cnt1=0;
		for(auto a:A)((a>>idx)&1?cnt1:cnt0)++;
		ll tres = (1ll<<idx)%MOD;
		(tres*=cnt0)%=MOD;
		(tres*=cnt1)%=MOD;
		(res+=tres)%=MOD;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 2560
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

N = ri()
S = rls()
ans = 0
num = 0
for i in S:
    num += 1 if i == "I" else -1
    ans = max(ans, num)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int f(int n)
{
	int res = 0;
	int c = 2;
	while (n >= c)
	{
		res += n / c;
		c *= 2;
	}
	return res;
}
int g(int n, int r)
{
	if (f(n) > f(r) + f(n - r))
		return 0;
	return 1;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	char s[1000006];
	scanf("%s", s);
	int a[1000006];
	for (i = 0; i < n; i++)
		a[i] = s[i] - '1';
	int c = 0;
	for (i = 0; i < n; i++)
		if (a[i] == 1)
			c++;
	int cnt[3];
	for (i = 0; i < 3; i++)
		cnt[i] = 0;
	for (i = 0; i < n; i++)
		cnt[a[i]] += g(n - 1, i);
	for (i = 0; i < 3; i++)
		cnt[i] %= 2;
	if (c == 0)
	{
		if (cnt[2] > 0)
			printf("2\n");
		else
			printf("0\n");
	}
	else
	{
		if (cnt[2] > 0 && cnt[1] > 0)
			printf("1\n");
		else if (cnt[2] > 0)
			printf("0\n");
		else if (cnt[1] > 0)
			printf("1\n");
		else
			printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll dp[10010][51];

int main(){
    ll N,W; cin >> N >> W;
    ll w[110],v[110];
    ll dp[111][100100] = {0};//dpは重さを示す
    for(ll i = 1; i <= N; i++) cin >> w[i] >> v[i];
    for(ll i = 1; i <= 1e5; i++) dp[0][i] = INF;

    for(ll i = 1; i <= N; i++){
        for(ll j = 0; j <= 100000; j++){
            dp[i][j] = dp[i-1][j];
            if(j - v[i] >= 0){
                dp[i][j] = min(dp[i][j], w[i]+dp[i-1][j-v[i]]);
            } //重さについて
        }
    }
    ll ans = 0;
    for(ll i = 1e5; i >= 0; i--){
        if(dp[N][i] <= W){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 87040
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#define INF 1e16
#define N (998244353)
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
typedef pair<ll,P> Q;

ll dist[200010];
vector<int>g[200010];
bool visited[200010];
int ans[200010];

int main(void){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<=n;i++)dist[i]=(ll)INF;
    dist[1]=0;
    queue<P>que;
    que.push(P(1,0));
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int now = p.first;
        ll d = p.second;
        if(visited[now])continue;
        visited[now]=true;
        for(int i=0;i<g[now].size();i++){
            int next = g[now][i];
            if(dist[next]>dist[now]+1){
                dist[next]=dist[now]+1;
                ans[next]=now;
                que.push(P(next,dist[next]));
            }
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)cout<<ans[i]<<endl;
    return 0;
}

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

int main() {
  double N;
  cin >> N;
  ll ans = 0;
  for(int i = 1; i <= sqrt(N); i++) {
    if(i * i <= N) ans = i * i; 
  }

  cout << ans;
  return 0;
}



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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;
const double INF = 1000000;

struct Func {
  int l, r, v;

  Func(int a, int b, int c) {
    l = a;
    r = b;
    v = c;
  }

  double ve(double x) {
    if(l-eps < x && x < r+eps) {
      return v;
    } else if(x < l+eps) {
      return v + (l-x);
    } else {
      return v + (x-r);
    }
  }
};

void printv(vector<auto> const& s) {
  REP(i, s.size()) {
    cout << s[i] << endl;
  }
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vi t(n+1), v(n);
  t[0] = 0;
  REP(i, n) {
    cin >> t[i+1];
    t[i+1] += t[i];
  }
  REP(i, n) {
    cin >> v[i];
  }
  int ti = t[n];

  vector<Func> f(n+2, Func(0, 0, 0));
  REP(i, n) {
    f[i] = Func(t[i], t[i+1], v[i]);
  }
  f[n] = Func(0, 0, 0);
  f[n+1] = Func(ti, ti, 0);

  vector<double> ans(2*ti+1);
  double mi = INF;
  REP(i, 2*ti+1) {
    mi = INF;
    REP(j, n+2) {
      // cout << i << ":" << j << ":" << f[j].ve((double)(i)/2.0) << endl;
      if(mi > f[j].ve((double)(i)/2.0)-eps) {
        mi = f[j].ve((double)(i)/2.0);
      }
    }
    ans[i] = mi;
  }
  // REP(i, 2*ti+1) {
  //   cout << i / 2.0 << ":" << ans[i] << endl;
  // }
  double res = 0.0;
  REP(i, 2*ti) {
    res += 0.25 * (ans[i] + ans[i+1]);
  }
  cout << res << endl;
  
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()
T = input()

cnt = 0
for i in range(3):
    if S[i] == T[i]:
        cnt += 1
print(cnt)


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

int N,K;
int p[200100];
//ll sum[200100];
double sum[200100];

double f(double x) {
  return x * ( x + 1.0 ) / 2.0;
}

void solve() {
  sum[0] = f(p[0]) / (double)p[0];
  REP(i,1,N) sum[i] = sum[i-1] + f(p[i]) / (double)p[i];
  //REP(i,1,N) sum[i] = sum[i-1] + p[i];
  double maxi = 0;
  rep(i,N) {
    if( i + K - 1 < N ) {
      double a = sum[i+K-1];
      if( i - 1 >= 0 ) a -= sum[i-1];
      if( LT(maxi,a) ) maxi = a;
    } else break;
  }
  printf("%.10f\n",maxi);
}

int main() {
  cin >> N >> K;
  rep(i,N) cin >> p[i];
  solve();
  return 0;
}


Measured memory_bytes: 2560
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

X = int(input())
result = 0
while result == 0:
    if is_prime(X):
        result = X
    else:
        X += 1
print(X)

Measured memory_bytes: 38896
import sys
input = sys.stdin.readline

N = int(input())
P = list(map(int, input().split()))
cnt = 0
for i, p in enumerate(P):
    num = i + 1
    if num != p:
        continue
    else:
        if(i+1 < N):
            next = P[i+1]
            tmp = P[i]
            P[i] = P[i+1]
            P[i+1] = tmp
            cnt += 1
        else:
            cnt += 1
print(cnt)


Measured memory_bytes: 54556
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val aList = (0..1).map {
        readLine()?.split(" ")?.map { it.toInt() }!!
    }

    // まずは0行目1行目それぞれについて、
    // 左から右への各項までの累積和を持った配列を作る
    val accList = mutableListOf<MutableList<Int>>().apply {
        add(mutableListOf<Int>().apply {
            for (i in 0..n) add(0)
        })
        add(mutableListOf<Int>().apply {
            for (i in 0..n) add(0)
        })
        this[0][0] = aList[0][0]
        this[1][0] = aList[1][0]
    }
    for (i in 1 until n) {
        accList[0][i] = accList[0][i - 1] + aList[0][i]
        accList[1][i] = accList[1][i - 1] + aList[1][i]
    }

    // あとは貪欲にすべてのパターン(100通り、どこで下に降りるか）を試行する
    var maxCandies = 0
    for (i in 0 until n) {
        val leaveCandies = if (i == 0) 0 else accList[1][i - 1]
        val candies = accList[0][i] + (accList[1][n - 1] - leaveCandies)
        if (candies > maxCandies) {
            maxCandies = candies
        }
    }
    println(maxCandies)
}

Measured memory_bytes: 37772
N, M, K = map(int, input().split())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))

A_sum = [0]
B_sum = [0]

for a in A_list:
    A_sum.append(A_sum[-1] + a)

for b in B_list:
    B_sum.append(B_sum[-1] + b)

count = 0
j = M
for i, a in enumerate(A_sum):
    if a > K:
        break
    while B_sum[j] > K - a:
        j -= 1
    if count < i + j:
        count = i + j

print(count)

Measured memory_bytes: 134028
h, w = list(map(int, input().split()))
s = []
a = "."*(w+2)
s.append(a)
for i in range(h):
    p = input()
    x = "."+p+"."
    s.append(x)
s.append(a)


for i in range(1, h+1):
    for j in range(1, w+1):
        count = 0
        if s[i][j]==".":
            if s[i-1][j-1]=="#":
                count += 1
            if s[i-1][j]=="#":
                count += 1
            if s[i-1][j+1]=="#":
                count += 1
            if s[i][j-1]=="#":
                count += 1
            if s[i][j+1]=="#":
                count += 1
            if s[i+1][j-1]=="#":
                count += 1
            if s[i+1][j]=="#":
                count += 1
            if s[i+1][j+1]=="#":
                count += 1
            print(count, end="")
        else:
            print("#", end="")
    print()

#print(s)

Measured memory_bytes: 3444
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int a, b;
  cin >> a >> b;
  int sum = 0;
  for(int i=1;i<=n;i++){
    int num=0;
    if(i / 10 == 0){
      num = i;
    }
    else if(i / 100 == 0){
      num += i / 10;
      num += i % 10;
    }
    else if(i / 1000 == 0){
      int k = i;
      num += k / 100;
      k = k%100;
      num += k / 10;
      k = k%10;
      num += k;
    }
    else if(i / 10000 == 0){
      int k = i;
      num += k / 1000;
      k = k%1000;
      num += k / 100;
      k = k%100;
      num += k / 10;
      k = k%10;
      num += k;
    }
    else{
      num = 1;
    }
    if(a <= num && num <= b) sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n;
long mod=1e9+7,dp[111][64];
main()
{
	cin>>n;
	dp[0][63]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<64;j++)
		{
			string T="";
			int o=j;
			for(int k=0;k<3;k++)
			{
				T+="ACGT"[o%4];
				o/=4;
			}
			reverse(T.begin(),T.end());
			for(int k=0;k<4;k++)
			{
				string now=T;
				now+="ACGT"[k];
				bool flag=false;
				flag|=now[0]=='A'&&now[2]=='G'&&now[3]=='C';
				flag|=now[0]=='A'&&now[1]=='G'&&now[3]=='C';
				flag|=now[1]=='G'&&now[2]=='A'&&now[3]=='C';
				flag|=now[1]=='A'&&now[2]=='C'&&now[3]=='G';
				flag|=now[1]=='A'&&now[2]=='G'&&now[3]=='C';
				if(flag)continue;
				int comv=0;
				for(int l=1;l<4;l++)comv=comv*4+
					(now[l]=='A'?0:now[l]=='C'?1:now[l]=='G'?2:3);
				dp[i][comv]+=dp[i-1][j];
				dp[i][comv]%=mod;
			}
		}
	}
	long ans=0;
	for(int i=0;i<64;i++)
	{
		ans+=dp[n][i];
		ans%=mod;
	}
	cout<<ans<<endl;
}

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

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

	vector<pair<int, int>> nums(n);

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

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

	int res = 0;

	for (int mask = 0; mask < (1 << n); mask++) {
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (mask & (1 << i)) {
				sum += nums[i].first;
				sum -= nums[i].second;
			}
		}
		res = max(res, sum);
	}

	cout << res;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::string s;
  int k;
  std::cin >> k >> s;
  if (s.size() <= k) {
    std::cout << s;
  } else {
    std::cout << s.substr(0, k) + "...";
  }
  return 0;
}

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

#define rep(i, a, n) for(int i=(a);i<(n);++i)
#define per(i, a, n) for(int i=(a);i>(n);--i)
#define pb emplace_back
#define mp make_pair
#define lowbit(x) (x & -x)

typedef long long LL;
typedef pair<int, int> pii;

const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1.0);

int n;

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


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#define MAX 100010
#define INFTY 10000000
#define NIL -1

struct Node {
	int value;
	struct Node *next;
};
typedef struct Node node_t;


int N;
int M;
int id =1;
node_t *G[MAX];
int color[MAX];

node_t* addNode(node_t *node, int value)
{
	node_t *new = (node_t*)malloc(sizeof(node_t));
	new->value = value;
	new->next = node;
	return new;
}

void dfs(int r)
{
	color[r] = id;
	node_t *n;
	for (n=G[r]; n!=NULL; n=n->next) {
		int v = n->value;
		if (color[v] == NIL) {
			color[v] = id;
			dfs(v);
		}
	}
}

void assignColor()
{
	int i, u;
	for (i=0; i<N; i++) {
		color[i] = NIL;
	}
	for (u=0; u<N; u++) {
		if (color[u] == NIL) {
			dfs(u);
			id++;
		}
	}
}


int main()
{
	int i, n, u, v;	
	scanf("%d %d", &N, &M);	
	for (i = 0; i < M; i++) {
		scanf("%d %d", &n, &v);
		G[n] = addNode(G[n], v);
		G[v] = addNode(G[v], n);
	}
	
	assignColor();
	
	int Q;
	scanf("%d", &Q);
	for (i = 0; i < Q; i++) {
		scanf("%d %d", &u, &v);
		if (color[u] == color[v]) {
			puts("yes");			
		}
		else {
			puts("no");
		}
	}

	return 0;
}

Measured memory_bytes: 9564
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		//入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		sc.close();

		//処理
		boolean f = (Math.abs(a-b) > 1);

		//出力	
		out.println(f ? "Alice" : "Brown");
		out.flush();
	}
}

Measured memory_bytes: 24148
import math

N, M, X = map(int, input().split())
costs = []
values = []
values_per_algs = [[] for _ in range(M)]
for _ in range(N):
  book = list(map(int, input().split()))
  costs.append(book[0])
  values.append(book[1:])
  for i in range(1, M+1):
    values_per_algs[i-1].append(book[i])

def rec(i, cost, val_per_algs):
  if i==N:
    if sum([1 if vals < X else 0 for vals in val_per_algs]) > 0:
      return math.inf
    else:
      return cost
  tmp_val_per_algs = val_per_algs.copy()
  for j in range(M):
    tmp_val_per_algs[j] += values[i][j]
  return min(rec(i+1, cost+costs[i], tmp_val_per_algs), rec(i+1, cost, val_per_algs.copy()))
  

def main():
  if sum([1 if sum(vals) < X else 0 for vals in values_per_algs]) > 0:
    print(-1)
    return
  print(rec(0, 0, [0 for i in range(M)]))
main()



Measured memory_bytes: 9260
N, M = gets.split.map(&:to_i)
S = Array.new(N+1, 0)
gets.split.map(&:to_i).each_with_index do |a,i|
  S[i + 1] = S[i] + a
end
ans = (1 .. N).group_by{|i| S[i] % M }.inject(0) do |s,(k,v)|
  c = v.size
  s + c*(c-1)/2 + (k == 0 ? c : 0)
end
puts ans


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

int main(){
  int n;
  cin >> n;
  vector<int> f(n+1,0);
  rep(x,1,105){
    rep(y,1,105){
      rep(z,1,105){
        int tmp = pow(x+y,2) + pow(y+z,2) + pow(z+x,2);
        if(tmp/2<n+1) f[tmp/2]++;
      }
    }
  }
  rep(i,1,n+1) cout << f[i] << endl;
  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
    int main(){
        int N;
            cin >> N;
        vector<int> p(N);
        int max = 0;
        int maxi = 0;
        int sum = 0;
            
            for(int u = 0; u < N; u++){
                cin >> p.at(u);
            }
            
            for(int i = 0; i < N; i++){
                
                if(p.at(i) >= max){
                    
                    max = p.at(i);
                    maxi = i;
                }
            }
                for(int j = 0; j < N; j++){
                    if(j == maxi){
                        sum += p.at(j)/2;
                    }else{
                        sum += p.at(j);
                    }
                }
                    cout << sum << endl;
                    //cout << maxi <<max;
    return 0;}


Measured memory_bytes: 256
//by OIerC
//Forca Barcelona!
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#define rep(i, a, b) for (register int i=(a); i<=(b); ++i)
#define per(i, a, b) for (register int i=(a); i>=(b); --i)
using namespace std;
const int N=200005;
vector<int> G[N];
int dis[N], ans, n, rt;

inline int read()
{
 	int x=0,f=1;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*f;
}

void dfs(int u, int fa)
{
	for (int v: G[u]) if (v^fa)
		dis[v]=dis[u]+1, dfs(v, u);
}

int main()
{
	n=read();
	rep(i, 1, n-1)
	{
		int u=read(), v=read();
		G[u].push_back(v); G[v].push_back(u);
	}
	dfs(1, 0);
	rep(i, 1, n) if (dis[i]>dis[rt]) rt=i;
	memset(dis, 0, sizeof(dis)); dfs(rt, 0);
	rep(i, 1, n) if (dis[i]>ans) ans=dis[i];
	if (ans%3==1) puts("Second"); else puts("First");
	return 0;
}


Measured memory_bytes: 21376
n = gets.to_i
votes = []
n.times { votes << gets.split.map(&:to_i) }
a, b = votes.shift
votes.each do |a_rate, b_rate|
  a_multiple, a_mod = a.divmod(a_rate)
  a_multiple += 1 if a_mod.nonzero?
  b_multiple, b_mod = b.divmod(b_rate)
  b_multiple += 1 if b_mod.nonzero?
  multiple = [a_multiple, b_multiple].max
  a = a_rate * multiple
  b = b_rate * multiple
end
puts a + b


Measured memory_bytes: 1916
#include<stdio.h>
int main(void)
{
	char a[100][101];
	int h,w,i;
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++)  scanf("%s",a[i]);
	for(i=0;i<w+2;i++)  printf("#");
	printf("\n");
	for(i=0;i<h;i++)  printf("#%s#\n",a[i]);
	for(i=0;i<w+2;i++)  printf("#");
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cctype>
#include <cstring>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

typedef long long LL;
typedef int matrix[3][3];
const int p=1e9+7;
int n,m,a[100100];
matrix ans,x,y,z;

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

void mul(matrix &a,matrix &b)
{
    static matrix c;
    memset(c,0,sizeof(c));
    repu(i,0,2)
        repu(k,0,2)
            repu(j,0,2)
                c[i][j]=(c[i][j]+LL(a[i][k])*b[k][j])%p;
    memcpy(a,c,sizeof(a));
}

void power(matrix &x,int k)
{
    static matrix ret;
    memset(ret,0,sizeof(ret));
    ret[0][0]=ret[1][1]=ret[2][2]=1;
    for (; k; k>>=1,mul(x,x))
        if (k&1)
            mul(ret,x);
    memcpy(x,ret,sizeof(x));
}

int main()
{
    scanf("%d%d",&n,&m),a[0]=-1;
    repu(i,1,m)
        a[i]=getint();
    ans[0][0]=ans[1][1]=ans[2][2]=1;
    x[0][0]=x[0][2]=x[1][1]=x[1][2]=x[2][0]=1,x[0][1]=x[2][1]=x[2][2]=2;
    y[0][0]=y[0][2]=y[1][1]=y[1][2]=y[2][2]=1,y[0][1]=2;
    repu(i,1,m)
    {
        memcpy(z,x,sizeof(z)),power(z,a[i]-a[i-1]-1);
        mul(ans,z),mul(ans,y);
    }
    memcpy(z,x,sizeof(z)),power(z,n-a[m]-1);
    mul(ans,z);
    printf("%d\n",ans[0][2]);
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long n = s.nextLong();
        long l = 1;
        for (int i= 1; i <= Math.sqrt(n); i ++) {
            if (n % i == 0)
                l=i;
        }
        System.out.println(l + (n / l) - 2);
    }
}

Measured memory_bytes: 23764
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
g = [[] for _ in range(n)]
for i in range(m):
    a, b = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
print("Yes")
q = [0]
ds = [9999999] * n
ds[0] = 0
z = 0
pre = [-1] * n
while z < len(q):
    cur = q[z]
    for e in g[cur]:
        if ds[e] > ds[cur] + 1:
            ds[e] = ds[cur] + 1
            pre[e] = cur
            q.append(e)
    z += 1

for i in range(1, n):
    print(pre[i]+1)


Measured memory_bytes: 95544
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin>>s;
	string ch="ABC";
	string sh="ARC";
	if(s==ch)
	{
		cout<<sh;
	}
	else
	{
		cout<<ch;
	}
	return 0;
}

Measured memory_bytes: 3628
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{

        //入力
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();


        // 出力
        if(B - A <= 0){
            System.out.println("delicious");
        }
        else if(B - A <= X){
            System.out.println("safe");
        }
        else{
            System.out.println(("dangerous"));
        }
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	sort(a, a + 5, greater<int>());
	int i;
	for(i = 0; i < 4; i++)cout << a[i] << " ";
	cout << a[4] << endl;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
# define pb push_back
# define FOR(i,a,n) for(int i=a;i<n;i++)
# define mp make_pair
# define RFOR(i,a,n) for(int i=n;i>a;i--)
# define pii pair<long long int,long long int>
#define ub upper_bound
#define lb lower_bound
typedef long long int ll;
string s,t;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>s>>t;
	ll n,m;
	n=s.size();
	m=t.size();
	ll arr[n+1][m+1]={0};
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		arr[i][j]=0;
	}
	FOR(i,1,n+1)
	{	
		for(int j=1;j<m+1;j++)
		{	
		if(s[i-1]==t[j-1])
		arr[i][j]=arr[i-1][j-1]+1;
		else
		arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
	    }
	}
	string str;
	ll i,j;
	i=n;j=m;
	while(i||j)
	{
		if(arr[i][j]==arr[i-1][j])
		i--;
		else if(arr[i][j]==arr[i][j-1])
		j--;
		else
		{
			i--;
			j--;
			str+=s[i];
		}
		if(arr[i][j]==0)
		break;
	}
	string str1;
	ll z=str.size();
	FOR(i,0,z)
	{
		str1+=str[z-i-1];
	}
	cout<<str1<<endl;
}

Measured memory_bytes: 70656
#include<iostream>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
int main(){
    string a,b;
    cin >> a >> b;
    for(int i=0;i<b.size();i++){
    	cout << a[i]<<b[i];
    }
    if(a.size()>b.size())cout << a[a.size()-1];
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

const int mod = 1e+9 + 7;
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	//貪欲法を試す
	long long A,B,N;
	cin>>A>>B>>N;
	long long i = min(B-1,N);
	cout<<(A*i)/B - A*(i/B)<<endl;
}

Measured memory_bytes: 3620
n = int(input())

h = list(map(int,input().split()))

lenh = len(h)

ans = 0

while max(h)>0:
    x = max(h)
    q = 0
    for i in range(lenh):
        if h[i] == x:
            if q == 0:
                ans += 1
                q = 1
            h[i] -= 1
        else:
            q = 0
        
print(ans)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=105;
char s[max_n];
int k;
int main(){
    scanf(" %s",s+1);
    scanf("%d",&k);
    int n=strlen(s+1);
    vector<int> v;
    for(int i=1;i<=n;i++){
        int j=i;
        while(j<=n&&s[j]==s[i])j++;
        v.push_back(j-i);
        i=j-1;
    }
    ll ans=0;
    if(v.size()==1)ans=1ll*v[0]*k/2;
    else{
        if(s[1]==s[n]){
            for(int i=1;i+1<v.size();i++){
                int x=v[i]/2;
                ans+=1ll*x*k;
            }
            ans+=v[0]/2+v.back()/2;
            ans+=1ll*(v[0]+v.back())/2*(k-1);
        }
        else{
            for(auto x:v)ans+=x/2;
            ans*=k;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
primes = factorization(N)
nums = []
for i in primes:
    for j in range(i[1]):
        nums.append(i[0] ** (j + 1))
nums_sorted = sorted(nums)
if 1 in nums_sorted:
    nums_sorted.remove(1)

done = []
count = 0
for i in nums_sorted:
    if N < i:
        break
    if N % i == 0:
        count += 1
        N /= i
print(count)


Measured memory_bytes: 9504
def main():
  s = input()
  ans = [1] * len(s)
  for i in range(len(s)-2):
    if s[i]=='R' and s[i+1]=='R':
      ans[i+2] += ans[i]
      ans[i] = 0
  for i in range(len(s)-1, 1, -1):
    if s[i]=='L' and s[i-1]=='L':
      ans[i-2] += ans[i]
      ans[i] = 0
  print(" ".join(map(str, ans)))
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 10484
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define po pop()
#define pu push
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){if(a==1)return false; for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL ceil2(LL a,LL b){LL c=a/b; if(a%b)c++; return c; }
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;string st,s1,s2,s3; char ch;
    while(cin>>a>>b)
    {
        if(a<b)
        {
            rep(i,b)cout<<a;
            cout<<en;
        }
        else
        {
            rep(i,a)cout<<b;
            cout<<en;
        }
    }
    return 0;
}


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


int main(){
    char S[10];


    scanf("%s", S);

    if(strcmp(S,"ABC") == 0){
        printf("ARC");
        return 0;
    }else{
        printf("ABC");
        return 0;
    }
    

    return 0;
}


Measured memory_bytes: 1736
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
ll l;
ll a[100001];
bool flag[100001];
int res[100001];

int main(void){
	scanf("%d%lld",&n,&l);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<n-1;i++){
		if(a[i]+a[i+1]>=l){
			printf("Possible\n");
			int cnt=0;
			for(int j=i;j>=0;j--){
				res[cnt]=j;
				cnt++;
			}
			for(int j=i+1;j<n-1;j++){
				res[cnt]=j;
				cnt++;
			}
			for(int j=n-2;j>=0;j--){
				printf("%d\n",res[j]+1);
			}
			return 0;
		}
	}
	printf("Impossible\n");
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>

using namespace std;
int main(){

	string s;
	int y, m;

	cin>> s;

	y = std::stoi(s.substr(0, 4));
	m = std::stoi(s.substr(5, 2));

	//cout<< y << " " << m << "\n";

	if(2019<=y){
		if(5<=m){
			cout<< "TBD" << "\n";
		}else{
			cout<< "Heisei" << "\n";
		}
	}else{
		cout<< "Heisei" << "\n";
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int N,H,W;
int val;
int V[10005];
int C[105][105];
int ind=1;
int main()
{
    cin>>H>>W>>N;for(int i=1;i<=N;i++)cin>>V[i];
    for(int i=1;i<=H;i++)
    {
        for(int j=(i%2 ? 1:W);j&&j<=W;j+=(i%2 ? 1:-1))
        {
            C[i][j]=ind;
            V[ind]--;
            while(!V[ind])ind++;
        }
    }
    for(int i=1;i<=H;i++,cout<<"\n")for(int j=1;j<=W;j++)cout<<C[i][j]<<" ";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int m1, m2, d1, d2;

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

	cin >> m1 >> d1 >> m2 >> d2;
	
	if (m2 == m1 + 1)
		cout << 1 << endl;
	else
		cout << 0 << endl;
}



Measured memory_bytes: 256
inpt = list(map(int, input().split()))

N = inpt[0]
K = inpt[1]

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

print(len(Base_10_to_n(N, K)))

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let d: usize = read();
    println!("{}", std::cmp::min(a, b) + std::cmp::min(c, d));
}

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

int main()
{
  string s;
  cin>>s;
  int a=0,b=0;
  for(int i=0;i<3;i++)
  {
    if(s[i]=='A')
      a++;
    else
      b++;
  }
  if(a==0 || b==0)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        n:i64,
    }
    let mut n = n;
    if n == 2 {
        println!("{}", 1);
        return;
    }
    let mut ans = 0;
    let mut divs = divisor((n - 1) as usize);
    let mut dvs2 = divisor(n as usize);
    for &d in divs.iter().chain(dvs2.iter()) {
        if d == 1 {
            continue;
        }
        let mut m = n as usize;
        while m % d == 0 {
            m /= d;
        }
        if m % d == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}
pub fn divisor(n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res.sort();
    res
}


Measured memory_bytes: 2144