akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <iostream>

using namespace std;

const vector<string> name = { "", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts" };

int main()
{
	int n, m;

	while (true)
	{
		cin >> m >> n;

		if (m == 0 && n == 0) { break; }

		vector<int> calc(18, 0);

		calc[0] = 1;

		for (int rep = 0; rep < n; rep++)
		{
			for (int i = 0; i < 18; i++)
			{
				calc[i] *= m;
			}

			for (int i = 0; i < 17; i++)
			{
				calc[i + 1] += calc[i] / 10000;
				calc[i] %= 10000;
			}
		}

		for (int i = 17; i >= 0; i--)
		{
			if (calc[i] != 0)
			{
				cout << calc[i] << name[i];
			}
		}
		
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define MS(x, i) memset(x, i, sizeof x)
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define NOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

char F[200];

int nums[maxn];

ll f[maxn];
ll inv[maxn];

ll n, aa, bb;

inline ll read() {
    ll ret = 0, sgn = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if(ch == '-') sgn = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        ret = ret*10 + ch - '0';
        ch = getchar();
    } 
    return ret*sgn;
}

inline void write( ll x ) {
    ll tmp = x > 0 ? x : -x;
    if(x < 0) putchar('-');
    int cnt = 0;
    while(tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while(cnt > 0) putchar(F[--cnt]);
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
    if(b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll res = exgcd(b, a % b, y, x);
    y -= (a / b) * x;

    return res;
}

ll Inv(ll a)
{
    ll d, x, y;
    d = exgcd(a, mod, x, y);
    if(d == 1)
        return (x % mod + mod) % mod;
    return -1;
}

ll qpow(ll a, ll b)
{
    ll base = a;
    ll ans = 1;
    
    while(b)
    {
        if(b & 1)
            ans = (ans * base) % mod;
        
        b >>= 1;
        base = (base * base) % mod;
    }

    return ans;
}

void init()
{
    f[0] = f[1] = 1;
    for(int i = 2; i < maxn; i++)
        f[i] = (f[i - 1] * i) % mod;
    
    inv[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    inv[0] = 1;

    for(int j = maxn - 2; j >= 1; j--)
        inv[j] = (inv[j + 1] * (j + 1)) % mod;
}

ll C(ll n, ll m)
{
    return (f[n] * (inv[m] * inv[n - m] % mod)) % mod;
}

int main()
{
    NOS
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    init();

    int n, k;
    cin >> n >> k;

    ll ans = 0;

    for(int i = 0; i <= min(n - 1, k); i++)
    {
        ans = (ans + C(n, i) * C(n - 1, n - i - 1)) % mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)















int main(){
    string s;
    cin >> s;
    char t = 'A';
    ll ans = 0, sz = 2;
    REP(i, s.size()){
        if(sz == 2){
            ans++;
            t = s[i];
            sz = 1;
        }
        else{
            if(s[i] == t){
                if(i == s.size() - 1){
                    break;
                }
                else{
                    i++;
                    ans++;
                    sz = 2;
                }
            }
            else{
                ans++;
                sz = 1;
                t = s[i];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
//#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="SUN")cout<<7;
    else if(s=="MON")cout<<6;
    else if(s=="TUE")cout<<5;
    else if(s=="WED")cout<<4;
    else if(s=="THU")cout<<3;
    else if(s=="FRI")cout<<2;
    else cout<<1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 1047483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
const int MAX_V=110;
int d[MAX_V][MAX_V];
int V;
void warshall_floyd(){
  for(int k=1;k<=V;k++)
    for(int i=1;i<=V;i++)
      for(int j=1;j<=V;j++)
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}

int main(){
  int m;
  cin>>V>>m;
  vector<pair<int,int> >hen(m);
  int dp[V+2][V+2]={};
  for(int i=0;i<V+2;i++)
    for(int j=0;j<V+2;j++){
      if(i==j){d[i][j]=0;dp[i][j]=0;}
      else{d[i][j]=INF;dp[i][j]=INF;}
    }
  for(int j=0;j<m;j++){
    int a,b,c;
    cin>>a>>b>>c;
    d[a][b]=c;
    d[b][a]=c;
    dp[a][b]=c;
    dp[b][a]=c;
    hen[j]=mp(a,b);
  }
  int ans=m;
  warshall_floyd();
  for(int i=0;i<m;i++){
    if(dp[hen[i].F][hen[i].S]==d[hen[i].F][hen[i].S])
      ans--;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll mod(ll a, ll x) {
  return (a % x + x) % x;
}
int main(){
	ll n;cin>>n;
	if(n==0){
		cout<<0<<endl;
		return 0;
	}
	vector<ll> ans;
	ll cnt=1;
	while(n!=0){
		if(mod(n,ll(pow(2,cnt)))){
			if(mod(cnt-1,2)){
				n+=ll(pow(2,cnt-1));
			}else{
				n-=ll(pow(2,cnt-1));
			}
			ans.pb(1);
		}else{
			ans.pb(0);
		}
		cnt++;
	}
	rep(i,ans.size()){
	  cout<<ans[ans.size()-1-i];
	}
	cout<<endl;
  return 0;
}

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

void solve(std::vector<long long> A) {
    ll a = abs(A[0] - A[1]);
    ll b = abs(A[1] - A[2]);
    ll c = abs(A[2] - A[0]);
    cout << a + b + c - max(max(a, b), c) << endl;
}

int main() {
    std::vector<long long> A(3);
    for (int i = 0; i < 3; i++) {
        scanf("%lld", &A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 3680
S = input()

for i in range(len(S)):
    # 0オリジン[偶数]
    if i % 2 == 0:
        if S[i] not in ['R', 'U', 'D']:
            print("No")
            exit()
    else:
        if S[i] not in ['L', 'U', 'D']:
            print("No")
            exit()
print("Yes")

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/06/15  Problem: diverta2019-2 A / Link: https://atcoder.jp/contests/diverta2019-2  ----- */


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

	LL N, K; cin >> N >> K;
	LL ans = (K>1?N-K:0);
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
dp=[0]*n
dp[0]=1
mod=998244353
csdp=0
s=[]
for _ in range(k):
	l,r=map(int,input().split())
	s.append([-r,-l])
for i in range(1,n):
	for j in range(k):
		if s[j][0]>=0:csdp=(csdp-dp[s[j][0]])%mod
		s[j][0]+=1
		s[j][1]+=1
		if s[j][1]>=0:csdp=(csdp+dp[s[j][1]])%mod
	dp[i]=csdp
print(dp[n-1])

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

int main()
{
	int n;
	while(cin >> n){
		int ng = n % 10;
		int ns = n / 10 % 10;
		int nb = n / 100;
		if(ng == 7 || ns == 7 || nb == 7){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 3636
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

char S[10001] = {0};

int main()
{
	int N = 0, len = 0, i = 0;
	scanf("%d", &N);
	scanf("%s", S);
    len = strlen(S);
	for (i = 0; i < len; i++) {
		char a = S[i] + N;
		if (90 < a) {
			a = (a - 90) + 64;
		}
		printf("%c",a);
	}
	printf("\n");
    return 0;
}


Measured memory_bytes: 128
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define tree 			ped
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<int>
#define pint        	pair<int, int>
#define umint        	unordered_map<int, int>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define fj(x)			for(int j=0; j<x; j++)
#define fn(n, x)		for(int i=n; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

string s;
int d;
unordered_map<bool, unordered_map<int, umint>> dict;

int calculate(int sum, int index, bool e){

	if(s.length()==index){
		if(sum==0)
			return 1;
		return 0;
	}

	if(dict.find(e)!=dict.end())
		if(dict[e].find(index)!=dict[e].end())
			if(dict[e][index].find(sum)!=dict[e][index].end())
				return dict[e][index][sum];

	int ans=0;
	f(10){
		int a = s[index]-'0';
		if(a==i && e){
			ans+=calculate((sum+i)%d, index+1, true);
			ans%=mod;
			break;
		}
		ans+=calculate((sum+i)%d, index+1, false);
		ans%=mod;
	}
	dict[e][index][sum]=ans;
	return ans;
}

int32_t main() {

    om_shree_ganeshaya_namah();

    cin>>s>>d;

    int ans = calculate(0, 0, true);
    ans--;
    if(ans<0)
    	ans+=mod;
    cout<<(ans);
}

Measured memory_bytes: 53764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
ll a[3100][3100];
ll dp[3100][3100][4];
int main() {
    int h, w, K;
    cin >> h >> w >> K;
    
    rep(i,h)rep(j,w)a[i][j] = 0;
    rep(i,K){
        int x, y, v;
        cin >> x >> y >> v;
        x--; y--;
        a[x][y] = v;
    }
    
    rep(i,h)rep(j,w)rep(k,4)dp[i][j][k] = 0;
    dp[0][0][1] = a[0][0];
    rep(i,h){
        rep(j,w){
            if(i > 0){
                rep(k,4){
                    dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][k]);
                    dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][k] + a[i][j]);
                }
            }
            if(j > 0){
                rep(k,4){
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k]);
                    if(k>0) dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + a[i][j]);
                }
            }
        }
    }
    ll ans = 0;
    rep(k,4)ans = max(ans,dp[h-1][w-1][k]);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 366864
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, cos, sin, pi
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

A, B, H, M = map(int, input().split())
from decimal import Decimal, getcontext
getcontext().prec = 2000

A = Decimal(A)
B = Decimal(B)
H = Decimal(H)
M = Decimal(M)
mi = 60*H + M
pi = Decimal(math.pi)
a = pi * mi / 360
b = 6*M * pi / 180

cosv = Decimal(cos(b)*cos(a) + sin(b)*sin(a))
C = pow(A, 2) + pow(B, 2) - 2*A*B*cosv
C = C**Decimal(1/2)
print(float(C))


Measured memory_bytes: 10448
N, M = map(int, input().split())
S = input()
T = input()

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
#%%
# L は N, Mの最小公倍数
L = lcm(N, M)

# 文字が一致しなければならないindexは公倍数で、L//MとL//Nが入れ替わる
if S[::L//M] == T[::L//N]:
    print(L)
else:
    print(-1)


Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int M,D;
    cin>>M>>D;
    int count=0;
    for(int i=1;i<=M;i++){
        for(int j=1;j<=D;j++){
            int x=j/10;
            int y=j%10;
            if(x>1 && y>1 && i==x*y)count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<iterator>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;
#define INF int(2e9)
#define MP make_pair
typedef pair<int, int> P;
inline int in() {
	int temp;
	scanf("%d", &temp);
	return temp;
}

int n = in(), m = in(), ans;
int pre[101];
bool boo[101][101];
vector<P> g[101];
void dijkstra(int s)
{
	int flag[101] = {};
	fill(flag, flag + 101, INF);
	fill(pre, pre + 101, -1);
	flag[s] = 0;
	priority_queue<P> que;
	que.push(MP(0, s));
	while (!que.empty())
	{
		P p = que.top();
		p.first *= -1;
		que.pop();
		for (int i = 0; i < g[p.second].size(); i++)
		{
			if (flag[g[p.second][i].second] > p.first + g[p.second][i].first)
			{
				que.push(MP(-p.first - g[p.second][i].first, g[p.second][i].second));
				flag[g[p.second][i].second] = p.first + g[p.second][i].first;
				pre[g[p.second][i].second] = p.second;
			}
		}
	}
}
void check(int s)
{
	for (int i = 1; i <= n; i++)
	{
		if (pre[i] == -1) continue;
		boo[i][pre[i]] = true;
		boo[pre[i]][i] = true;
	}
}
int main() {
	for (int i = 0; i < m; i++)
	{
		int a = in(), b = in(), c = in();
		g[a].push_back(MP(c, b));
		g[b].push_back(MP(c, a));
	}
	for (int i = 1; i <= n; i++)
		sort(g[i].begin(), g[i].end());
	for (int i = 1; i <= n; i++)
	{
		dijkstra(i);
		check(i);

	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < g[i].size(); j++)
		{
			if (!boo[i][g[i][j].second])
			{
				ans++;
			}
		}
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 256
n, q = gets.chomp.split(' ').map(&:to_i)
tree = Array.new(n)
n.times { |i| tree[i] = [] }
(n - 1).times do
  a, b = gets.chomp.split(' ').map { |i| i.to_i - 1 }
  tree[a] << b
  tree[b] << a
end
values = Array.new(n, 0)
q.times do
  i, v = gets.chomp.split(' ').map(&:to_i)
  values[i - 1] += v
end
queue = [0]
visited = Hash.new(false)
until queue.empty?
  q = queue.pop
  next if visited[q]
  visited[q] = true
  tree[q].each do |t|
    next if visited[t]
    values[t] += values[q]
    queue << t
  end
end
puts values.join(' ')

Measured memory_bytes: 38012
N = int(input())
W = list(map(int, input().split()))
minDif = 10**8
accumW = [0]
for i in range(N):
    accumW.append(accumW[i]+W[i])
for i in range(1, N):
    minDif = min(minDif, abs(accumW[N] - 2*accumW[i]))
print(minDif)


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void) {
     long double A,B,N;
    cin >> A >> B >> N; 
    long int max = 0,n = A;
    if(A>B){
        n = B;
    }
    if(n>=N){
    for(long int i=0; i<=N;++i){
        //printf("%Lf\n",(floor(A*i/B)- A*floor(i/B)));
    if(floor(A*i/B)- A*floor(i/B) > max){
        max = floor(A*i/B)- A*floor(i/B);
    }
    }
    }
    else{
    for(long int i=0; i<=n;++i){
        //printf("%Lf\n",(floor(A*i/B)- A*floor(i/B)));
    if(floor(A*i/B)- A*floor(i/B) > max){
        max = floor(A*i/B)- A*floor(i/B);
    }
    }
    if(B<=N){
    for(long int i=B; i>=B-n;--i){
       // printf("%Lf\n",(floor(A*i/B)- A*floor(i/B)));
    if(floor(A*i/B)- A*floor(i/B) > max){
        max = floor(A*i/B)- A*floor(i/B);
    }
    }
    }
     for(long int i=N; i>=N-n;--i){
       // printf("%Lf\n",(floor(A*i/B)- A*floor(i/B)));
    if(floor(A*i/B)- A*floor(i/B) > max){
        max = floor(A*i/B)- A*floor(i/B);
    }
    }
    }
   /* for(long int i=0; i<=N; i = i + n){
        printf("%Lf\n",(floor(A*i/B)- A*floor(i/B)));
    if(floor(A*i/B)- A*floor(i/B) > max){
        max = floor(A*i/B)- A*floor(i/B);
    }
    }

*/
    
printf("%ld\n",max);
  return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

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

    for (int i = 0; i < s.size(); i++) {
        cout << 'x';
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(void){
  int n,i,p=0;
  cin >> n;
  vector<P> t(n,P(0,0));
  for (i=0;i<n;i++) cin >> t.at(i).second >> t.at(i).first;
  sort(t.begin(),t.end());
  for (i=0;i<n;i++){
    p+=t.at(i).second;
    if (p>t.at(i).first) break;
  }
  if (i==n) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 1792
module ABC081

	! <module>s to import
	use, intrinsic :: iso_fortran_env


	! require all variables to be explicitly declared
	implicit none


	! accessibility of <subroutine>s and <function>s in this <module>
	public  :: ABC081_A


	! constants for this <module>
	character(len=1, kind=1), parameter, private :: chr_target = '1'
	integer( kind=INT32 ),    parameter, private :: num_char   = 3


	! contained <subroutine>s and <function>s are below
	contains


	subroutine ABC081_A

		! variables for this <subroutine>
		character(len=num_char, kind=1) :: buffer
		integer( kind=INT16 )           :: itr, count

		! STEP.01
		! read out the target positive integers
		read *, buffer

		! STEP.02
		! count the number of the `1`
		count = 0

		if( ichar( buffer(1:1) ) .eq. ichar( chr_target ) ) count = count+1
		if( ichar( buffer(2:2) ) .eq. ichar( chr_target ) ) count = count+1
		if( ichar( buffer(3:3) ) .eq. ichar( chr_target ) ) count = count+1

		! STEP.03
		! output the result
		write( unit=OUTPUT_UNIT, fmt='(I0)', advance='yes' ) count

		! STEP.END
		return

	end subroutine ABC081_A

end module ABC081


program main

	! <module>s to import
	use, non_intrinsic :: ABC081

	! require all variables to be explicitly declared
	implicit none

	call ABC081_A


end program main


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

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7, SZ = 2e5 + 10;

ll n;
bool need[SZ];
vector<vector<ll>> gr;

ll bpow(ll vl, ll p, ll mod) {
	if (p == 0) return 1;
	if (p % 2 == 1) {
		return (bpow(vl, p - 1, mod) * vl) % mod;
	}
	else {
		ll b = bpow(vl, p / 2, mod);
		return (b * b) % mod;
	}
}

ll dist[SZ], cnt[SZ];
ll dp[SZ][2], smdp[SZ][2];
bool fl = true;

ll sub[SZ];

void dfs(int v, int curD) {
	if (fl) cnt[dist[v]]++;
	sub[v] = 1;
	for (auto to : gr[v]) {
		dist[to] = dist[v] + 1;
		dfs(to, curD);
		sub[v] += sub[to];
	}

	if (curD == dist[v]) {
		dp[v][0] = 1;
		dp[v][1] = 1;
	}
	else {
		ll s = 1, s2 = 1;
		for (auto to : gr[v]) {
			s *= dp[to][0] + dp[to][1];
			s2 *= dp[to][0];
			s2 %= MOD;
			s %= MOD;
		}

		ll hv = 0;
		for (auto to : gr[v]) {
			hv += ((dp[to][1] * s2) % MOD) * bpow(dp[to][0], MOD - 2, MOD);
			hv %= MOD;
		}
		dp[v][1] = hv;
		dp[v][0] = (s - hv + MOD) % MOD;
	}
}

void input() {
	cin >> n;
	gr.resize(n + 1);
	for (int i = 0; i < n; i++) {
		ll p;
		cin >> p;
		gr[p].push_back(i + 1);
	}
	n++;
}

void precalc(int v) {
	sub[v] = 1;
	cnt[dist[v]]++;
	for (auto to : gr[v]) {
		dist[to] = dist[v] + 1;
		precalc(to);
		sub[v] += sub[to];
	}
}

void clear(bool flag = true) {
	for (int i = 0; i <= n; i++) {
		dp[i][0] = 0;
		dp[i][1] = 0;
		if (flag) sub[i] = 0;
		if (flag) dist[i] = 0;
		if (flag) fl = true;
		if (flag) cnt[i] = 0;
	}
}

map<ll, vector<pair<ll, ll>>> mrg[SZ];

void sol(int v) {
	set<ll> rc;

	for (auto to : gr[v]) {
		sol(to);
		if (mrg[to].size() > mrg[v].size()) mrg[to].swap(mrg[v]);

		for (auto c : mrg[to]) {
			for (auto cur : c.second) {
				mrg[v][c.first].push_back(cur);
				if (mrg[v][c.first].size() == 2) rc.insert(c.first);
			}
		}

		mrg[to].clear();
	}

	mrg[v][dist[v]].push_back({ 1, 1 });
	for (auto cur : rc) {
		ll s = 1, s2 = 1;
		for (auto to : mrg[v][cur]) {
			s *= to.first + to.second;
			s2 *= to.first;
			s2 %= MOD;
			s %= MOD;
		}

		ll hv = 0;
		for (auto to : mrg[v][cur]) {
			hv += ((to.second * s2) % MOD) * bpow(to.first, MOD - 2, MOD);
			hv %= MOD;
		}
		pair<ll, ll> nw = { (s - hv + MOD) % MOD, hv };
		
		mrg[v][cur].clear();
		mrg[v][cur].push_back(nw);
	}
}

ll sl() {
	set<ll> c;
	ll ans = 0;
	clear();
	precalc(0);
	sol(0);
	for (auto cur : mrg[0]) {
		ans += (cur.second[0].second * bpow(2ll, n - cnt[cur.first], MOD)) % MOD;
		ans %= MOD;
	}

	return ans;
}

ll brute() {
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		dfs(0, i);
		ans += (dp[0][1] * bpow(2ll, n - cnt[i], MOD)) % MOD;
		for (int j = 0; j < n; j++) {
			smdp[j][0] += dp[j][0];
			smdp[j][1] += dp[j][1];
			smdp[j][0] %= MOD;
			smdp[j][1] %= MOD;
		}
		ans %= MOD;
		fl = false;
	}

	return ans;
}

int main() {
	fastInp;

	input();
	clear();
	ll q2 = sl();

	cout << q2;
	return 0;
}

Measured memory_bytes: 106368
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    if(a + b >= c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : AOJ_Test.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main() {
	unsigned long long int N;
	vector<unsigned long long int> Ai;
	cin >> N;
	Ai.resize(N);
	for (unsigned int i = 0; i < N; i++) {
	    cin >> Ai[i];
	}

    unsigned long long int answer = 0;
    unsigned long long int mulans = 0;
    unsigned long long int mulbase = 0;

	for (unsigned int i = 0; i < N - 1; i++) {
		mulbase = (mulbase + Ai[N-1-i]) % 1000000007;
	    mulans = (mulbase * Ai[N-2-i]) % 1000000007;
	    answer = (answer + mulans) % 1000000007;
	}

    cout << answer << endl;
	// cout << tlen - max << endl;
	return 0;
}


Measured memory_bytes: 4832
s = input()
s1 = s[:int((len(s)-1)/2)]
s2 = s[int((len(s)+3)/2-1):len(s)]
if s == s[::-1]:
    if s1 == s1[::-1]:
        if s2 == s2[::-1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
        
else:
    print('No')

Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll H, W, D; cin >> H >> W >> D;
    vvl as(H, vl(W, 0)); REP(i, H) REP(j, W) cin >> as[i][j];
    ll Q; cin >> Q;
    vl ls(Q,0), rs(Q,0); REP(i, Q) cin >> ls[i] >> rs[i];
    
    vpl coord(H*W+10);
    REP(i, H){
        REP(j, W){
            ll a = as[i][j];
            coord[a] = PL(i,j);
        }
    }
    
    vl cost_sum(H*W+10, 0);
    FOR(a, 1, H*W+10){
        if(a <= D){
            cost_sum[a] = 0; continue;
        }
        PL l = coord[a-D];
        PL r = coord[a];
        cost_sum[a] = cost_sum[a-D] + abs(r.ff - l.ff) + abs(r.ss - l.ss);
    }
    
    REP(i, Q){
        cout << cost_sum[rs[i]] - cost_sum[ls[i]] << endstr;
    }
    return 0;
}


Measured memory_bytes: 5504
/**
*    author:  yuya1234
*    created: 05.07.2020 21:00:47
**/

#include <bits/stdc++.h>

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--)

#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  if(n%1000==0)cout<<0<<endl;
  else cout<<1000-n%1000<<endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>

#define INF 1000000000
using namespace std;

struct edge {
    int from;
    int to;
    int w;
};
struct node {
    node() : id {-1}, d {INF}, ns {} {};
    node(int i, vector<edge>& vec) : id {i}, d {INF}, ns {vec} {};
    int id;
    int d;
    vector<edge> ns;
};

vector<int> dijkstra(node* graph, int n, int st){
    auto ds = vector<int>(n, INF);
    auto comp = [](node* x, node* y){return x->d < y->d;};
    priority_queue<node*, vector<node*>, decltype(comp)> que(comp);
    node* start = &graph[st];
    start->d = 0;
    que.push(start);
    while(que.size()){
        node* n = que.top();
        que.pop();
        if(n->d < ds[n->id]){
            ds[n->id] = n->d;
            for(auto e : n->ns){
                node* next_n = &graph[e.to];
                next_n->d = min(next_n->d, n->d + e.w);
                que.push(next_n);
            }
        }
    }
    return ds;
}

int main(){
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    int n;
    cin >> n;
    node graph[n];
    for(int i = 0; i < n; ++i){
        int id;
        int m;
        cin >> id >> m;
        auto vec = vector<edge>(m);
        int v, c;
        for(int j = 0; j < m; ++j){
            cin >> v >> c;
            vec[j] = edge {id, v, c};
        }
        graph[id] = node(id, vec);
    }
    auto ds = dijkstra(graph, n, 0);
    for(int i = 0; i < n; ++i){
        cout << i << ' ' << ds[i] << endl;
    }
}

Measured memory_bytes: 1520
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long v = sc.nextLong();
		long b = sc.nextLong();
		long w = sc.nextLong();
		long t = sc.nextLong();
		sc.close();

		long soutaV = v - w;
		if(soutaV<=0L) {
			System.out.println("NO");
			return;
		}

		long soutaD = b - a;
		if(soutaD<=0L) {
			soutaD = -1L * soutaD;
		}

		long distance = soutaV * t;
		if(distance>=soutaD) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}


Measured memory_bytes: 27084
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

#include<bits/stdc++.h>
using namespace std;

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int n; cin >> n;
	string s; cin >> s;
	int l=0,r=n-1;
	int cnt =0;
	while(l<=r){
		if(s[l]=='W' && s[r]=='R'){
			swap(s[l],s[r]);
			cnt++;
			l++;
			r--;
		}
		if(s[l]=='R') l++;
		if(s[r]=='W') r--;
	}
	r = n-1;
	while(r >= 0 && s[r]=='W'){
		r--;
	}
	for(;r>=0;r--) if(s[r]=='W') cnt++;
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3776
c = input()
if c == 'a':
	print('vowel')
elif c == 'i':
	print('vowel')
elif c == 'u':
	print('vowel')
elif c == 'e':
	print('vowel')
elif c == 'o':
	print('vowel')
else:
	print('consonant')	
	

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		long X = GetLong();
		long c = 100;
		for(long i = 0; ; i++)
		{
			c = (long)((double)c * 1.01);
			if(c >= X)
			{
				WriteLine(i + 1);
				return;
			}
		}
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

using namespace std;

typedef long long ll;
const int maxn = (int)1e5 + 1;

int n, m;
int a, b, c;
vector < int > g[maxn];
int u[maxn], ans;

void dfs(int v){
    u[v] = 1;
    for(int i : g[v]){
        if(!u[i]){
            dfs(i);
        }
    }
}

int main(){
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        cin >> a >> b >> c;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i = 1; i <= n; i++){
        if(!u[i]){
            ans++;
            dfs(i);
        }
    }
    cout << ans;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n+1);
  vector<int> b(n+1);
  for (int i=1;i<=n;++i) {
    cin >> a[i];
  }
  
  int tot=0;
  
  for (int i=0;i<n;++i) {
    int l=n-i;
    int q=n/l;
    b[l]=a[l];
    for (int j=2;j<=q;++j) {
      b[l]+=b[l*j];
    }    
    b[l]=b[l]%2;
    if (b[l]==1) {
      tot += 1;
    }    
  }
  cout<<tot<<endl;
  for (int i=1;i<=n;++i) {
    if (b[i]==1) {
      cout<<i;
      cout<<" ";
    }
  }
}



Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int n, y;
  read n >> y;
  tuple<int, int, int> ans = make_tuple(-1, -1, -1);
  // 10000 count
  REP(i, n + 1) {
    // 5000 count
    REP(j, n - i + 1) {
      if ((10000 * i + 5000 * j + 1000 * (n - i - j)) == y) {
        ans = make_tuple(i, j, n - i - j);
      }
    }
  }
  cout << get<0>(ans) << " " << get<1>(ans) << " " << get<2>(ans) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
  int n, x;
  int count = 0;
  int j = 2;
  cin >> n;
  int data[n];

  //n個のデータの読み込み
  for (int i = 0; i < n; i++)
  {
    cin >> x;
    data[i] = x;
  }

  /*for (int j = 2; j <= sqrt(data[n - 1]); j++)
  {if()
  }*/
  while (j < sqrt(data[n]))
  {
    for (int i = 0; i < n; i++)
    {
      if ((data[i] % j == 0 && data[i] != j) || data[i] == 1)
      {
        //cout << "j=" << j << endl;
        //cout << data[i] << endl;
        data[i] = -1;
      }
    }
    j++;
  }

  for (int i = 0; i < n; i++)
  {
    if (data[i] != -1)
    {
      count++;
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3084
from collections import deque

def main():
    S = input()
    Q = deque(S)
    cnt = 0
    while Q:
        if len(Q) == 1:
            break
        front = Q.popleft()
        back = Q.pop()
        if front == back:
            continue
        if front == 'x':
            cnt += 1
            Q.append(back)
            continue
        if back == 'x':
            cnt += 1
            Q.appendleft(front)
            continue
        print(-1)
        exit()

    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 47600
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var a = F;
		WriteLine(3 * a * a);
	}
}
static class Func
{
	public static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	public static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	public static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	public static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	public static int FirstBinary(int min, int max, Predicate<int> pred)
	{
		while (min < max)
		{
			var mid = (min + max) / 2;
			if (pred(mid)) max = mid;
			else min = mid + 1;
		}
		return min;
	}
	public static long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
	public static long Mod(long a, long mod) => (a % mod + mod) % mod;
	public static long Inverse(long a, long mod) => Mod(SolveLinear(Mod(a, mod), mod)[0], mod);
	public static long Pow(long a, long b, long mod)
	{
		var p = 1L;
		var x = a;
		while (b > 0)
		{
			if ((b & 1) == 1) p = (p * x) % mod;
			b >>= 1;
			x = (x * x) % mod;
		}
		return p;
	}
	public static long[] SolveLinear(long n, long m)
	{
		var A = new long[,] { { n < 0 ? -1 : 1, 0 }, { 0, m < 0 ? -1 : 1 } };
		n = Abs(n); m = Abs(m);
		while (m > 0)
		{
			long q = n / m, r = n % m;
			n = m; m = r;
			for (var i = 0; i < 2; i++)
			{
				var x = A[i, 1];
				A[i, 1] = A[i, 0] - q * x;
				A[i, 0] = x;
			}
		}
		return new long[] { A[0, 0], A[1, 0] };
	}
	public static int CombineHashCodes(int h1, int h2) => (((h1 << 5) + h1) ^ h2);
}


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

using namespace std;

const int mod = 1e9 + 7, N = 105;
int n, K, suma, dp[N][N * N], sumt;

int binpw (int aa, int mm) {
    int ret = 1;
    for (; mm; mm >>= 1, aa = (1LL * aa * aa) % mod) if(mm & 1) ret = (1LL * ret * aa) % mod;
    return ret;
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> K;
    suma = (1LL * ( (K * (K + 1) ) / 2 * n) % mod * binpw(K + 1, n - 1) ) % mod;

    dp[n + 1][0] = 1;
    for (int i = n; i > 0; --i) {
        for (int j = 0; j < N * N; ++j) {
            if(!dp[i + 1][j]) continue;

            for (int k = 0; k <= K; ++k) {
                if(k <= i && j + (j + k) / i < N * N) {
                    dp[i][j + (j + k) / i] += dp[i + 1][j];
                    dp[i][j + (j + k) / i] %= mod;
                }
                if(k > i) {
                    dp[i][j] = (dp[i][j] + dp[i + 1][j]) % mod;
                }
            }
        }
    }

    for (int i = 0; i < N * N; ++i) sumt = (sumt + 1LL * i * dp[1][i]) % mod;

    cout << (suma - sumt + mod) % mod;

    return 0;
}


Measured memory_bytes: 2560
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;


/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
int N,Q;
cin >> N >> Q;
string S;
cin >> S;
vector<int> l(Q);
vector<int> r(Q);
REP(i,Q){
    cin >> l[i] >> r[i];
}
vector<int> cnt(S.size()+1);
REP(i,S.size()+1){
    cnt[i+1] = cnt[i];
    if(S[i] == 'C' && S[i-1] == 'A'){
        cnt[i+1]++;
    }
}

REP(i,Q){
    cout << cnt[r[i]]-cnt[l[i]] << endl;
}
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999


int m,n;
int b[110];

bool solve(int v){
    int l=0;
    int x=v;
    rep(i,n){
        while(x<b[i]&&l<m){
            x=v;
            l++;
        }
        if(l>=m)return false;
        if(x>=b[i]){
            x-=b[i];
        }
    }
    return true;
}

int main(){
    while(cin>>m>>n){
        if(m==0&&m==0)break;
        rep(i,n)cin>>b[i];
        
        int left=0;
        int right=1500000-1;
        while(right>left+1){
//            cout<<left<<" "<<right<<endl;
            int cent=(left+right)/2;
            bool res = solve(cent);
            if(res) right=cent;
            else left=cent;
        }
        cout<<right<<endl;
    }
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(auto &e : A) cin >> e;
    vector<bool> seen(K + 1);
    vector<bool> dp(K + 1);
    auto f = [&](auto &&f, int n) -> bool {
        if(seen[n]) return dp[n];
        for(auto &a : A) {
            if(n - a >= 0 && !f(f, n - a)) dp[n] = true;
        }
        seen[n] = true;
        return dp[n];
    };
    cout << (f(f, K) ? "First" : "Second") << '\n';
}


Measured memory_bytes: 11440
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <vector>
#include <queue>

using namespace std;
const int maxn = 200005;
typedef long long LL;
typedef unsigned int u32;
#define pb push_back
int n,stk[maxn],top,par[maxn],sz[maxn];
vector<int> adj[maxn];

void dfs(int u,int fa) {
	sz[u]=1;
	for (u32 j=0;j<adj[u].size();j++)
	{
		int v=adj[u][j];
		if (v==fa) continue;
		par[v]=u;dfs(v,u);sz[u]+=sz[v];
	}
}
int main()
{
	#ifdef LOCAL_JUDGE
		freopen("snuke.in","r",stdin);
		freopen("snuke.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int u,v,i=1;i<n;i++) 
		scanf("%d %d",&u,&v),adj[u].pb(v),adj[v].pb(u);
	dfs(1,0);top=0;
	for (int u=n;u;u=par[u]) stk[++top]=u;
	for (int i=top-1;i>=1;i--) sz[stk[i+1]]-=sz[stk[i]];
	int snu=0;
	for (int i=1;i<=top/2;i++) snu+=sz[stk[i]];
	if (n-snu>snu) printf("Fennec");else printf("Snuke");
	
	return 0;
}

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

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

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

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			final int ope_num = Integer.parseInt(br.readLine());
			Dictionary(ope_num,br);
		} catch (NumberFormatException | IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
	
	//enum宣言
	public static enum Operate{
		insert("insert"),
		find ("find"),;
		
		private final String name;
		
		Operate(String name){
			this.name = name;
		}
		
		String getName(){
			return this.name;
		}

		public static Operate getEnumName(String str){
			for(Operate v : values()){
				if(v.getName().equals(str)){
					return v;
				}
			}
			throw new IllegalArgumentException("undefined : " + str);
		}
	}

	public static void Dictionary( int ope_num ,BufferedReader br ){
		HashMap<String,Integer> que = new HashMap<String,Integer>();
		int i;
		int count = 0;
		
		for ( i = 0; i < ope_num; i++) {
			try {
				final String[] op = br.readLine().split(" ");		//キーと命令を分割
			 
				switch( Operate.getEnumName(op[0]) ){				//命令によって処理
				case insert:
					que.put(op[1],count);							//最後尾に随時追加していく
					count ++;
					break;
				case find:	
					if( que.containsKey(op[1]) ) {					//一致したらYes
						System.out.println("yes");
					}else {
						System.out.println("no");
					}
				}
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		}
	}
}


Measured memory_bytes: 193408
s=input()
flag=0
a,b=-1,-1
if len(s)==2:
    if s[0]==s[1]:
        a,b=1,2
else:
    for i in range(len(s)-2):
        if s[i]==s[i+1] or s[i]==s[i+2]:
            a,b=i+1,i+3
            break
print(a,b,sep=' ')

            
    

                


Measured memory_bytes: 3188