akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl;


//UnionFind群
class UnionFind {
protected:
    vector<int> par;
    vector<int> data;
    int cnt;
public:
    UnionFind() : par(1), data(1), cnt(1) {};

    UnionFind(int N);

    int root(int x);

    int marge(int x, int y);

    bool same(int x, int y);

    int add();

    int add(int x);

    inline int getSize(int x) { return data.at(root(x)); };
};

UnionFind::UnionFind(int N) : par(N), data(N), cnt(N) {
    for (int i = 0; i < N; i++) {
        par.at(i) = -1;
        data.at(i) = 1;
    }
}


int UnionFind::root(int x) {
    if (par.at(x) == -1) return x;
    return par.at(x) = root(par.at(x)); // 経路圧縮
}

int UnionFind::marge(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return rx;
    else { // ノード数の少ない方に接続
        if (data.at(rx) < data.at(ry)) swap(rx, ry);
        par.at(ry) = rx;
        data.at(rx) += data.at(ry);
        return rx;
    }
    return rx;
}

bool UnionFind::same(int x, int y) {
    return root(x) == root(y);
}

int UnionFind::add() {
    par.push_back(cnt);
    cnt++;
    return cnt - 1;
}

int UnionFind::add(int x) {
    par.push_back(cnt);
    cnt++;
    return marge(x, cnt);
}


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < n;i ++){
        if (i % 2 == 0) {
            alice += a.at(i);
        }else{
            bob += a.at(i);
        }
    }
    cout << abs(alice - bob ) << endl;

}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
string s,s1; 
int check(int lol){
	//int val=s[0];
	int i;
	rep(i,s.length()-lol){
		if(s[i]!=s[0])
			return 0;
	}
	return 1;
}
int update(int val){
	int i;
	char ch=(char)(val+'a');
	rep(i,s.length()-1){
		if(s[i]==ch || s[i+1]==ch){
			s[i]=ch;
		}

	}
	return 0;
}
int main(){
    std::ios::sync_with_stdio(false);
    
    cin>>s;
    s1=s;
    int n=s.length();
    int i,j,maxi=inf;
    rep(i,26){
    	s=s1;
    	rep(j,n){
    		if(check(j)){
    			maxi=min(maxi,j);
    			break;
    		}
    		update(i);

    	}
    }
    cout<<maxi<<endl;
    
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abc161/tasks/abc161_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve() {
  ll K;
  cin >> K;

  queue<ll> q;
  rep1(num, 9) q.push(num);

  rep(i, K - 1) {
    ll n = q.front();
    q.pop();

    if (n % 10 >= 1) q.push(10 * n + (n % 10 - 1));
    q.push(10 * n + (n % 10));
    if (n % 10 <= 8) q.push(10 * n + (n % 10 + 1));
  }

  ll res = q.front();

  cout << res << "\n";
}

// priority_queue なら順番を気にせずに済む
// ただし、桁数が小さいものの方が先に取り出されることには依存している
void solve2() {
  ll K;
  cin >> K;

  priority_queue<ll, V<ll>, greater<ll>> q;
  rep1(num, 9) q.push(num);

  rep(i, K - 1) {
    ll n = q.top();
    q.pop();

    q.push(10 * n + (n % 10));

    if (n % 10 >= 1) q.push(10 * n + (n % 10 - 1));
    if (n % 10 <= 8) q.push(10 * n + (n % 10 + 1));
  }

  ll res = q.top();

  cout << res << "\n";
}

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif


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

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

    int cnt[30] = {}; // cnt[0]は「a」の出現回数、cnt[1]は「b」、・・・
    for (int i = 0; i < w.length(); i++)
    {
        int n = w[i] - 'a';
        cnt[n]++;
    }

    string ans = "Yes";
    for (int j = 0; j < 26; j++)
    {
        if (cnt[j] % 2 == 1) ans = "No";
    }

    cout << ans << endl;
    return 0;
}

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

const int max_size = 1e5 + 1;

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

  vector<int> v(N);
  rep(i, N) cin >> v[i];

  bool same =
      all_of(v.begin(), v.end(), [&](auto x) { return x == v.front(); });

  int ans;
  if (same)
    ans = N / 2;
  else {
    vector<int> v0(max_size), v1(max_size);
    for (int i = 0; i < N; i += 2)
      v0[v[i]]++;
    for (int i = 1; i < N; i += 2)
      v1[v[i]]++;
    int v0_max = 0, v0_snd = 0;
    int v1_max = 0, v1_snd = 0;
    for (int i = 1; i < max_size; i++) {
      if (v0[i] > v0[v0_snd]) {
        v0_snd = i;
      }
      if (v0[i] > v0[v0_max]) {
        v0_snd = v0_max;
        v0_max = i;
      }
    }
    for (int i = 1; i < max_size; i++) {
      if (v1[i] > v1[v1_snd]) {
        v1_snd = i;
      }
      if (v1[i] > v1[v1_max]) {
        v1_snd = v1_max;
        v1_max = i;
      }
    }
    int n0 = v0[v0_max], n1 = v1[v1_max];
    if (v0_max == v1_max)
      ans = N - max(n0 + v1[v1_snd], v0[v0_snd] + n1);
    else
      ans = N - n0 - n1;
  }

  cout << ans << endl;
}

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

int main(){
	int h, w, n;
	cin >> h >> w >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	vector<int> x, y;
	int arr[100][100];
	for(int i = 0; i < h; i++){
		if(i % 2){
			for(int j = 0; j < w; j++){
				x.push_back(i);
				y.push_back(j);
			}
		} else {
			for(int j = w-1; j >= 0; j--){
				x.push_back(i);
				y.push_back(j);
			}
		}
	}
	int f = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < a[i]; j++){
			arr[x[f]][y[f]] = i+1;
			f++;
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << arr[i][j] << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 512
n, s = map(int, input().split())
*A, = map(int, input().split())
p = 998244353
DP = [[0 for j in range(s + 1)] for i in range(n + 1)]
DP[0][0] = 1
for i in range(n):
    for j in range(s + 1):
        if j >= A[i]:
            DP[i + 1][j] = (2 * DP[i][j] + DP[i][j - A[i]]) % p
        else:
            DP[i + 1][j] = (2 * DP[i][j]) % p
print(DP[n][s] % p)


Measured memory_bytes: 147188
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MaxL = 200003;
char s[MaxL];int l;
int cnt[MaxL][26];

int main() {
    scanf("%s",s+1);l=strlen(s+1);
    for (int i=1;i<=l;++i) {
        for (int j=0;j<26;++j) cnt[i][j]=cnt[i-1][j];
        cnt[i][s[i]-'a']++;
    }
    LL sum=1;
    for (int i=1;i<=l;++i) sum+=i-cnt[i][s[i]-'a'];
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	string s;
	bool flag=true;
	cin>>s;
	for(int i=0;i<3;i++)
	{
		if(s[i]==s[i+1])flag=false;
	}
	if(flag)cout<<"Good"<<endl;
	else cout<<"Bad"<<endl;
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc141/tasks/abc141_e
# https://www.slideshare.net/hcpc_hokudai/ss-121539419
# これのほうがいいかな？ https://sen-comp.hatenablog.com/entry/2020/01/16/174230

# 結局これが一番わかりやすい https://qiita.com/Pro_ktmr/items/16904c9570aa0953bf05

# zアルゴリズムをやるらしい


def z_algorithm(S: str):
    '''SとS[i]の最長共通接頭辞長 Z[i] の配列を返す O(len(S))'''
    Z = [-1] * len(S)  # -1で初期化 (-1が出てきたらおかしい！)
    Z[0] = len(S)
    i = 1  # 現在求めたいZ[i]の位置
    j = 0  # S[i:i+j]の文字列は先頭と一致している
    while i < len(S):
        while (i + j < len(S) and S[j] == S[i + j]):
            j += 1
        Z[i] = j

        if j == 0:
            i += 1
            continue
        k = 1
        while (k < j and k + Z[k] < j):  # ならば再利用可能
            # ∵kからZ[k]後がjより小さいということは同一文字列の終了がjを突き抜けないことが保証されている
            # →Z[k]のほうが必ず早く終了するので値はZ[i+k]の値はZ[k]になる
            Z[i + k] = Z[k]
            k += 1
        i += k  # 次のiはまだ埋まっていないところまで移動
        j -= k  # jも無駄な探索を避けるために移動分だけの幅減少に留める
        # jの働き後半がはみ出すときは確定させないで次の探索で確定できるようにするというだけ
    return Z


N = int(input())
S = input()
# まずzアルゴリズムを任意の開始地点に用いる
# ほしいデータ構造
# S[i:]とS[j:]の最長共通接頭辞長行列 M[i][j]
# これのうち重複していないなかでの最大値が答え。
# つまりmax{M[i][j] | i+M[i][j]<=j}

# i,jはあくまで相対位置なのでMを実際に構成しなくてもiを一つずつずらしてjを調べるということでおk
ans = 0
for i in range(N):  # 開始位置
    Z = z_algorithm(S[i:])
    for j in range(N - i):
        if Z[j] <= j:
            ans = max(ans, Z[j])
print(ans)


Measured memory_bytes: 51548
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct matsui{
  int m, t;
  bool isin;
};

vector<matsui> h;

void nxt(void){
  int3(m, a, b);
  h.pb((matsui){m, a, true});
  h.pb((matsui){m, b, false});
  return;
}

bool mys(matsui qwe, matsui rty){
  if(qwe.t != rty.t)return qwe.t < rty.t;
  return !qwe.isin;
}

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    if(!n)break;
    rep(i, n)nxt();

    sort(all(h), mys);

    int sum = 0;
    rep(i, h.size()){
      if(h[i].isin)sum += h[i].m;
      else sum -= h[i].m;
      if(sum > 150)break;
    }
    puts((i == h.size()) ? "OK" : "NG");

    h.clear();
//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,m;
  cin >> n >> m;
  
  cout << (1900 * m + 100 * n - 100 * m) * pow(2,m);
  
  
  return 0;
}

Measured memory_bytes: 256
from sys import stdin
rr = lambda: stdin.readline().strip()

N = int(rr())
A = []
for _ in xrange(N):
    A.append(map(lambda x: x=='#', rr()))

def solve(N, A):
    B = zip(*A)
    if not any(any(row) for row in A):
        return -1
    return len({c for c, col in enumerate(B)
                      if not all(col)}) +\
           min(N - sum(row) + (not any(B[r]))
               for r, row in enumerate(A))

print solve(N, A)


Measured memory_bytes: 35740
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX 3333
signed main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  int dp[MAX]={};
  dp[0]=1;
  for(int i=0;i<MAX;i++){
    if(i+c<3333) dp[i+c]|=dp[i];
    if(i+d<3333) dp[i+d]|=dp[i];
  }
  int s=0,w=100*a;
  for(int i=0;i<40;i++){
    for(int j=0;j<40;j++){
      if(i==0&&j==0) continue;
      int tw=100*a*i+100*b*j;
      if(tw>f) continue;
      for(int k=0;k<MAX;k++){
	if(!dp[k]) continue;
	if(tw+k>f) continue;
	if(tw*e<k*100) continue;
	//cout<<tw*e<<" "<<k*100<<endl;
	if(k*(w+s)>s*(tw+k)){
	  w=tw;
	  s=k;
	}
      }
    }
  }
  
  cout<<s+w<<" "<<s<<endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
string s;
#define MAXN 110

int main()
{
	int n, m, x;
	int a[MAXN] = {0};
	int a_ind;
	
	cin >> n >> m >> x;
	REP(m){
		 cin >> a_ind;
		a[a_ind] = 1;	
}
	
	int max1 = 0, max2 = 0;
	
	for(int i = x + 1; i < n; i++)
	{
		max1 += a[i];
	}
	for(int i = x - 1; i > 0; i--)
	{
		max2 += a[i];
	}
	cout << min(max1, max2) << endl;
	
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		ArrayDeque<Integer> deque = new ArrayDeque<>();
		//Iterator<Integer> it = deque.iterator();
		long[] flist = new long[4000000];
		int Findex = 2000000;//indexはじめ
		int Lindex = Findex+1;//indexおわり
		int n = sc.nextInt();
		
		for(int i=0;i<n;i++){
			int q = sc.nextInt();
			
			if(q == 0){
				int d = sc.nextInt();
				int x = sc.nextInt();
				
				if(d == 0){
					//deque.addFirst(x);
					flist[Findex] = x;
					Findex--;
				}else{
					//deque.addLast(x);
					flist[Lindex] = x;
					Lindex++;
				}
			}else if(q == 1){
				int d = sc.nextInt();
				
				//Iterator<Integer> it = deque.iterator();
				//int num = it.next();
				//Object[] list = new Object[deque.size()];
				//int a = deque.iterator().next();
				
				//for(int j=0;j<d;j++){
					//deque.iterator();
					//num = it.next();
				//}
				
				//list = deque.toArray();
				
				System.out.println(flist[Findex + d+1]);
				
			}else{
				int d = sc.nextInt();
				
				if(d == 0){
					//deque.removeFirst();
					flist[Findex] = 0;
					Findex++;
				}else{
					//deque.removeLast();
					flist[Lindex] = 0;
					Lindex--;
				}
			}
		}

	}

}



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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;

    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3688
#include<stdio.h>
int main(){
  int n,a,b,ans=0;
  scanf("%d%d",&n,&b);
  for(int i=1;i<n;i++){
    scanf("%d",&a);
    if(a==b){
      ans++;
      b=100001;
    }
    else{
      b=a;
    }
  }
  printf("%d",ans);
  return 0;
}

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

int main(void){
    string T, S;
    cin >> T >> S;
  	int count = 0;
    for(int i=0;i<3;i++){
    	if(T[i] == S[i]){
        	count++;
        }
    }
  	cout << count <<"\n";
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c = map(int, readline().split())
    print(min(c, b // a))


if __name__ == '__main__':
    main()


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

int main() {
  int m1,m2,d1,d2;
  cin >> m1>> d1>>m2>>d2;
  if(m1==12){
  if(m2==1){
  cout<<"1";
  }
    else{
    cout<<"0";
    }
  }
  else if(m2==m1+1){
  cout<<"1";
  }else{
  cout<<"0";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read();
    vector<int> A(N), B(N);
    for (auto& a:A) {
        a = read();
    }
    B = A;
    sort(B.begin(), B.end());
    int max1 = B[N-1], max2 = B[N-2];
    for (auto& a:A) {
        printf("%d\n", a == max1 ? max2 : max1);
    }
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll X;
  cin >> X;

  ll current = 100;
  for (ll i = 0; i < 1e19; ++i) {
    if (current >= X) {
      cout << i << endl;
      return 0;
    }
    current *= 1.01;
    current = floor(current);
  }

  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int A[100];

int main() {
  int n;
  scanf("%d", &n);
  double ans = 0;
  rep(i, n) scanf("%d", &A[i]);
  rep(i, n) { ans += 1 / (double)A[i]; }
  printf("%.5lf", 1 / ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s2i(string s){
  int x;
  stringstream ss(s);
  ss >> x;
  return x;
}
string i2s(int x){
  stringstream ss;
  ss << x;
  return ss.str();
}
int main(){
  vector<string> v;
  string s;
  int i,j,k;
  while(cin>>s,s!="=") v.push_back(s);
  while(v.size()!=1){
    //for(i=0;i<v.size();i++) cout << v[i] << endl;
    //cout << endl;
    for(i=0;i<v.size();i++){
      if(v[i]=="*"){
	v[i-1]=i2s(s2i(v[i-1])*s2i(v[i+1]));
	v.erase(v.begin()+i);
	v.erase(v.begin()+i);
	break;
      }
      if(v[i]=="/"){
	v[i-1]=i2s(s2i(v[i-1])/s2i(v[i+1]));
	v.erase(v.begin()+i);
	v.erase(v.begin()+i);
	break;
      }
      if(v[i]=="+"){
	v[i-1]=i2s(s2i(v[i-1])+s2i(v[i+1]));
	v.erase(v.begin()+i);
	v.erase(v.begin()+i);
	break;
      }
      if(v[i]=="-"){
	v[i-1]=i2s(s2i(v[i-1])-s2i(v[i+1]));
	v.erase(v.begin()+i);
	v.erase(v.begin()+i);
	break;
      }
    }
  }
  cout << s2i(v[0]) << endl;
  return 0;
}

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

public class Main {
    static final Scanner sc    = new Scanner(System.in);
    static final int     MOD   = (int) 1E9 + 7;
    static final long    INF_L = (long) 4E18;

    public static void main(String[] args) {
        int N = nint();
        int K = nint();
        int[] a = nints(N);
        
        boolean[] turnPlayerWins = new boolean[K+1];
        
        for (int i = a[0]; i <= K; i++) {
            for (int n = 0; n < N; n++) {
                if (i - a[n] >= 0 && !turnPlayerWins[i - a[n]]) {
                    turnPlayerWins[i] = true;
                    break;
                }
            }
        }
        
        System.out.println(turnPlayerWins[K] ? "First" : "Second");
    }

    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    static int[] nints(int N) {
        return nints(N, 0, 0);
    }

    @Deprecated
    private static int[] nints(int N, int padL, int padR) {
        int[] a = new int[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int N) {
        return nlongs(N, 0, 0);
    }

    static long[] nlongs(int N, int padL, int padR) {
        long[] a = new long[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int N) {
        return ndoubles(N, 0, 0);
    }

    static double[] ndoubles(int N, int padL, int padR) {
        double[] d = new double[N + padL + padR];
        for (int i = 0; i < N; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int H, int W) {
        return nchars2(H, W, 0, 0);
    }

    static char[][] nchars2(int H, int W, int padLU, int padRD) {
        char[][] a2 = new char[H + padLU + padRD][W + padLU + padRD];
        for (int i = 0; i < H; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, W);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 22100
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

void addary( vector< PII > &ary, int n )
{
	REP( i, 0, n )
	{
		int a, b;
		cin >> a >> b;
		ary.PB( MP( a, b ) );
	}

	return;
}

int solve( vector< PII > ary )
{
	const int N = ary.size();

	VVI G( N ); // 隣接リスト

	REP( i, 0, N )
	{
		REP( j, 0, N )
		{
			if ( i == j )
			{
				continue;
			}

			if ( ary[i].fst < ary[j].fst && ary[i].snd < ary[j].snd )
			{
				G[i].PB( j );
			}
		}
	}

	VI dist( N, 1 );

	// ベルマンフォードもどき
	while ( true )
	{
		bool update = false;

		REP( i, 0, N )
		{
			REP( j, 0, G[i].size() )
			{
				if ( dist[ G[i][j] ] < dist[i] + 1 )
				{
					dist[ G[i][j] ] = dist[i] + 1;
					update = true;
				}
			}
		}

		if ( !update )
		{
			break;
		}
	}

	return *max_element( ALL( dist ) );
}

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

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

		if ( !n )
		{
			break;
		}

		vector< PII > ary;
		addary( ary, n );

		cin >> n;
		addary( ary, n );

		cout << solve( ary ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1320
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n,M[N][N];
int d[N];

void bfs(int s){
    queue<int> q;
    q.push(s);
    for(int i=0;i<n;i++) d[i]=INFTY;
    d[s]=0;
    int u;
    while(!q.empty()){
	u=q.front(); q.pop();
	for(int v=0;v<n;v++){
	    if(M[u][v]==0) continue;
	    if(d[v]!=INFTY) continue;
	    d[v]=d[u]+1;
	    q.push(v);
	}
    }
    for(int i=0;i<n;i++){
	cout << i+1 << " " << ((d[i]==INFTY)? (-1):d[i]) << endl;
    }
}

int main(void){
    int u,k,v;

    cin>>n;
    
    for(int i=0;i<n;i++){
	cin >> u >> k;
	u--;
	for(int j=0;j<k;j++){
	    cin >> v;
	    v--;
	    M[u][v]=1;
	} 
    }

    bfs(0);

    return 0;
}

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

main() {
    int X,A,B; cin >> X >> A >> B;
    cout << (X-A)%B << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<ll> a(N), sum(N + 1), sum2(N + 1, 0);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum[i + 1] = a[i];
		sum2[i + 1] = sum2[i];
		if (a[i] > 0) sum2[i + 1] += a[i];
	}
	for (int i = 1; i <= N; i++) sum[i] += sum[i - 1];
	ll ans = 0;
	for (int i = 0; i <= N - K; i++) {
		ans = max(ans, sum2[N] - sum2[i + K] + sum2[i] + max(sum[i + K] - sum[i], 0LL));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int INF = 1e9;
int main(void){
    int n, m, x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int> > a(n, vector<int> (m));
    rep(i, n){
        cin>>c[i];
        rep(j, m) cin>>a[i][j];
    }
    int ans = INF;
    for(int bi = 0;bi<(1<<n);bi++){
        vector<int> d(n);
        int sum = 0;
        rep(j, n){
            if((bi>>j)&1) {
                d[j]=1;
            }
        }
        vector<int> tmp(m);
        rep(j, n){
            if(d[j] == 1){
                rep(i, m) tmp[i] += a[j][i];
                sum += c[j];
            }
        }
        bool ok = true;
        rep(i, m){
            if(tmp[i]<x) ok = false;
        }
        if(ok) ans = min(ans, sum);
    }
    if(ans == INF) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 17)

vector<int> a[MAXN];

int p[MAXN];
int v[MAXN];
int d[MAXN];
int md[MAXN];

void dfs(int cur, int curdist) {
	v[cur] = 1;
	d[cur] = curdist;
	for (int i = 0; i < a[cur].size(); i++) {
		int nnext = a[cur][i];
		if (!v[nnext]) {
			p[nnext] = cur;
			dfs(nnext, curdist + 1);
			md[cur] = max(md[cur], md[nnext] + 1);
		}
	}
}

int n, uu, vv;

int solve(int cur, int steps) {
	if (steps >= (d[uu] + 1) / 2) {
		return 0;
	}
	//return md[cur] + (d[cur] - (d[cur] & 1));
	int dist = d[cur] - steps;
	return steps + md[cur] + (dist - 1);
}

int main() {
	cin >> n >> uu >> vv;
	for (int i = 0; i < n - 1; i++) {
		int v1, v2;
		cin >> v1 >> v2;
		a[v1].push_back(v2);
		a[v2].push_back(v1);
	}
	dfs(vv, 0);
/*	for (int i = 1; i <= n; i++) {
		cerr << "parent  = " << p[i] << " depth =  " << d[i] << " max depth = " << md[i] << endl;
	}*/
	int cur = uu;
	int ret = 0;
	int steps = 0;
	while (cur != vv) {
		ret = max(ret, solve(cur, steps));
		cur = p[cur];
		steps++;
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 17676
import java.util.*;

class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    ArrayList<Integer> al = new ArrayList<Integer>();
    while (scanner.hasNextInt()) {
       al.add(scanner.nextInt());
    }
    
    Collections.sort(al);
    Collections.reverse(al);
    for (int i = 0; i < 3; i++) {
      System.out.println(al.get(i));
    }
  }
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  cout << 800 * n - n / 15 * 200 << endl;

  return 0;
}


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

typedef long long ll;
using namespace std;

const ll base = 1000000000;
const ll max = 1000000000000000000;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll q = n / base;
  ll r = n % base;
  if(r == 0) {
    q -= 1;
    r = base;
  }
  cout << 0 << " " << 0 << " " << base << " " << 1 <<  " " << base - r << " " << 1 + q << endl;
  return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int l = abs(b - a);
    if (l % 2 == 0) {
        puts("Alice");
    } else {
        puts("Borys");
    }
    return 0;
}


Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split()))

S = [0 for _ in range(N+1)]
for i in range(1, N+1):
    S[i] = S[i-1] + A[i-1]
# print(S)

ans = float("inf")
for i in range(0, N-1):
    ans = min(ans, abs((S[N] - S[i+1]) - (S[i+1] - S[0])))

print(ans)

Measured memory_bytes: 23800
import java.util.LinkedList;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		LinkedList<Integer> list = new LinkedList<Integer>();
		
		while(scan.hasNextInt() == true){
			int a = scan.nextInt();
			if(a == 0) {
				System.out.println(list.pop());
			} else {
				list.push(a);
			}
		}
	}
}

Measured memory_bytes: 15372
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <stdlib.h>

using namespace std;

int main(void)
{
	int n, a, b, c, d, G,A,B;
	cin >> n >> a >> b >> c >> d;

	if (a % c == 0)
	{
		A = a / c;
	}
	else
	{
		A = (a / c) + 1;
	}
	if (b % d == 0)
	{
		B = b / d;
	}
	else
	{
		B = (b / d) + 1;
	}


	if (A >= B)
	{
		G = A;
	}
	else if (A < B)
	{
		G = B;
	}

	cout << n - G << endl;
}

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

using namespace std;

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

typedef long long int ll;


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

	int k,x;

	cin >> k >> x;

	for(int i=x-(k-1) ; i<=x+(k-1) ; i++)
		cout << i << " ";
	return 0;
}

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	int a[n], b[n], c[n-1];
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n-1) cin >> c[i];

	int bef = -100;
	int ans = 0;
	rep(i, n){
		int p = a[i] - 1;
		ans += b[p];
		if(p == bef + 1) ans += c[p - 1];
		bef = p;
	}

	cout << ans << endl;
}


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

li = []
for i in A:
    li.append(abs(i))
li.sort()

count = 0
for i in A:
    if i < 0:
        count += 1

if count % 2 == 0:
    b = sum(li)
else:
    b = sum(li) - li[0] * 2

print(b)


Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n, k, s;
	cin>>n>>k>>s;

	for (int i=0;i<k;++i)
		cout<<s<<" ";

	if (s==((int)1e9))
	{
		for (int i=0;i<(n-k);++i)
		{
			int x = (int)1e9;
			x--;
			cout<<x<<" ";
		}
	}
	else
	{
		for (int i=0;i<(n-k);++i)
		{
			int x = (int)1e9;
			cout<<x<<" ";
		}
	}


	



	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int solve(){
  int X, Y;
  cin >> X >> Y;

  if(X == Y) return -1;
  if(Y < X && X%Y == 0) return -1;
  return X;
}

signed main() {
  cout << solve() << endl;

  return 0;
}

Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int  in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int a,b;

signed main(){
    io();

    cin>>a>>b;
    if(a>8||b>8){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }
    

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 1e5+7;
const int maxM = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
//const int INF = 2e9+9;
const int MOD = 1e9+7;

ll n,k;
ll F[210][maxN];
ll G[210][maxN];
ll s[210][maxN];
ll t[210][maxN];
int main()
{
	scanf("%lld%lld",&n,&k);
	ll m = sqrt(n);
	for(ll i=1;i<=m;i++)
		F[1][i] = 1;
	for(ll i=1;i<=m;i++)
	{
		G[1][i] = n/i - max(n/(i+1), m);
	}
	for(ll i=1;i<k;i++)
	{
		for(int j=1;j<=m;j++)
			s[i][j] = (s[i][j-1] + F[i][j])%MOD;
		for(int j=1;j<=m;j++)
			t[i][j] = (t[i][j-1] + G[i][j])%MOD;
		for(int j=1;j<=m;j++)
		{
			F[i+1][j] += s[i][m];
			F[i+1][j] %= MOD;
			
			F[i+1][j] = (F[i+1][j] + t[i][m] - t[i][j-1] + MOD)%MOD;
			
			G[i+1][j] = (G[i+1][j] + s[i][j]*(n/j - max(n/(j+1), m))%MOD)%MOD;
		}
		
	}
	ll ans = 0;
	for(int i=1;i<=m;i++)
	{
		ans += F[k][i];
		ans %= MOD;
		ans = (ans + G[k][i])%MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 316160
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
        
        Map<Integer, Integer> input = new HashMap<Integer, Integer>();
        
        int in = 0;
        int x = 0;
        
        for(int i = 0 ; i < 3 ; i++){
            in = scan.nextInt();
            if(input.get(in) != null){
                x = input.get(in);
                x = x + 1;
                input.put(in, x);
            }else{
                x = x + 1;
                input.put(in, x);
            }
            x = 0;
        }
        
        int number5 = 0;
        int number7 = 0;
        String ans = "NO";
        
        number5 = input.get(5);
        if(number5 != 0){
            if(number5 == 2){
            number7 = input.get(7);
            if(number7 != 0){
            if(number7 == 1){
                ans = "YES";
            }
            }
        }
  
        }
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 20948
#include <cmath>
#include <cstdio>

int main() {
	int sampleNum;
	scanf("%d", &sampleNum);
	for (; sampleNum > 0; --sampleNum) {
		double x1, y1, x2, y2, x3, y3;
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);

		double ax = x3 - x2;
		double ay = y3 - y2;
		double a2 = ax * ax + ay * ay;
		double a = sqrt(a2);
		double bx = x1 - x3;
		double by = y1 - y3;
		double b2 = bx * bx + by * by;
		double b = sqrt(b2);
		double cx = x2 - x1;
		double cy = y2 - y1;
		double c2 = cx * cx + cy * cy;
		double c = sqrt(c2);

		double crossabz = ax * by - ay * bx;

		double px, py, r;

		if (crossabz == 0) {
			if (a < b) {
				if (b < c) {
					px = (x1 + x2) / 2.;
					py = (y1 + y2) / 2.;
					r = c / 2.;
				} else {
					px = (x3 + x1) / 2.;
					py = (y3 + y1) / 2.;
					r = b / 2.;
				}
			} else {
				px = (x2 + x3) / 2.;
				py = (y2 + y3) / 2.;
				r = a / 2.;
			}
		} else {
			double bunbo = a2 * a2 - 2. * a2 * (b2 + c2) + (b2 - c2) * (b2 - c2);
			double keisu1 = a2 * (a2 - b2 - c2);
			double keisu2 = b2 * (b2 - c2 - a2);
			double keisu3 = c2 * (c2 - a2 - b2);
			px = (keisu1 * x1 + keisu2 * x2 + keisu3 * x3) / bunbo;
			py = (keisu1 * y1 + keisu2 * y2 + keisu3 * y3) / bunbo;

			double s = fabs(crossabz) / 2.;
			r = a * b * c / (4. * s);
		}

		if ( px <= 0. && px > 5.e-4 ) { px = 0.; }
		if ( py <= 0. && py > 5.e-4 ) { py = 0.; }

		printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}
	return 0;
}

Measured memory_bytes: 0
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> x, y;
  bool flag = true;
  int oe = 0;
  rep(i, n){
    ll a, b;
    cin >> a >> b;
    x.pb(a);
    y.pb(b);
    if(i == 0){
      oe = (a + b) % 2;
      if(oe < 0)oe += 2;
    }else{
      int toe = (a + b) % 2;
      if(toe < 0)toe += 2;
      if(oe != toe){
        flag = false;
      }
    }
  }
  if(!flag){
    cout << - 1 << endl;
    return 0;
  }
  // add R
  int res = 36;
  if(oe == 0){
    res++;
    rep(i, n){
      x[i]--;
    }
  }
  vector<string> ans(n);
  rep(i, n){
    vector<int> up, vp;
    ll u = x[i] + y[i];
    ll v = x[i] - y[i];
    for(int j = 35; j >= 0; j--){
      ll base = (ll)1 << j;
      if(u > 0){
        up.pb(1);
        u = u - base;
      }else{
        up.pb(-1);
        u = base + u;
      }
      if(v > 0){
        vp.pb(1);
        v = v - base;
      }else{
        vp.pb(-1);
        v = base + v;
      }
    }
    rep(j, up.size()){
      if(up[j] == 1 && vp[j] == 1)ans[i] += "R";
      else if(up[j] == 1 && vp[j] == -1)ans[i] += "U";
      else if(up[j] == -1 && vp[j] == 1)ans[i] += "D";
      else ans[i] += "L";
    }
  }
  cout << res << endl;
  if(res == 37)cout << 1 << " ";
  for(int i = 35; i >= 0; i--){
    cout << ((ll)1 << i);
    if(i != 0)cout << " ";
    else cout << endl;
  }
  rep(i, n){
    if(res == 37)cout << "R";
    cout << ans[i] << endl;
  }

//   rep(i, n){
//     ll basex = 0, basey = 0;
//     if(res == 37)basex++;
//     for(int j = 35; j >= 0; j--){
//       ll base = (ll)1 << j;
//       if(ans[i][35-j] == 'L')basex -= base;
//       else if(ans[i][35-j] == 'R')basex += base;
//       else if(ans[i][35-j] == 'U')basey += base;
//       else basey -= base;
//     }
//     cout << basex << " " << basey << endl;
//   }
	return 0;
}


Measured memory_bytes: 384
import math
abcde = [input() for i in range(5)]

flg = -1
for i in range(1,10):
    if flg != -1:
        break
    for j in range(5):
        if abcde[j][-1]==str(i):
            flg = j
            break
total = 0
for i in range(5):
    if flg==i:
        total += int(abcde[i])
    else:
        total += math.ceil(int(abcde[i])/10)*10
print(total)

Measured memory_bytes: 81556
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

string s,t;
cin >> s >> t;
cout << t << s << endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
//
//  abc149_a.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

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

std::vector<int> permutations;

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

int main() {
  string s, t;
  std::cin >> s >> t;

  std::cout << t << s << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
typedef long long int ll;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back

void input(){
    int n, d; cin >> n >>d;
    int ans = (int) ceil((double)n / (double)(2 * d + 1));
    cout << ans << endl;
}
int main()
{
 input();
 return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)

{
	int a, b, c, x,y,sum;
	while (1)
	{
		sum = 0;
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)break;
		for (a = 1; a <= (x - 2); a++)
		{
			for (b = (a + 1); b <= (x - 1); b++)
			{
				for (c = (b + 1); c <= x; c++)
				{
					if ((a + b + c) == y)
					{
						sum = sum + 1;
					}
				}
			}
		}
		printf("%d\n", sum);
	}
	
	return 0;
}


Measured memory_bytes: 2044
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

typedef long long ll;

const int N=4e5+1e3+7;

ll ans,r[N],n,tong[N];

char s[N];

int main()
{
	scanf("%s",s);
	n=strlen(s);
	ans+=n*(n-1)/2;
	for(int i=0;i<n;i++)
		tong[s[i]]++;
	for(int i='a';i<='z';i++)
		ans-=tong[i]*(tong[i]-1)/2;
	cout<<ans+1;
}

Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<string.h>

using namespace std;

int main(){

	string s, w;
	int count = 0;

	cin >> w >> s;
	
	for (int i = 0; i < w.size(); i++){
		w[i] = tolower(w[i]);
	}


	while (s != "END_OF_TEXT"){

		for (int i = 0; i < s.size();i++){
			s[i] = tolower(s[i]);
		}

		if (s == w)count++;
		cin >> s;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3172