akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const ll inf = 1LL << 51;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    int A,B,Q; cin >>A>>B>>Q;
    vector<ll> S(A), T(B), ans(Q);
    REP(i,A)cin >> S[i];
    REP(i,B) cin >> T[i];
    //REP(i,Q) cin >> queri[i];
    S.push_back(-inf);
    S.push_back(-inf - 1);
    S.push_back(inf);
    S.push_back(inf+1);
    T.push_back(-inf);
    T.push_back(-inf - 1);
    T.push_back(inf);
    T.push_back(inf+1);
    

    
    sort(ALL(S));
    sort(ALL(T));

    REP(i,Q){
        ll mini = inf;
        ll q; cin >> q;
        auto s_pointer = lower_bound(ALL(S), q);
        auto t_pointer = lower_bound(ALL(T), q);
        ll bigs = *s_pointer;
        ll smalls = *prev(s_pointer);
        ll bigt = *t_pointer;
        ll smallt = *prev(t_pointer);

        auto nextt_p_big = lower_bound(ALL(T), bigs);
        ll bigmint = min(*nextt_p_big - bigs, bigs - *prev(nextt_p_big));
        mini = min(mini, bigs - q + bigmint);
        //cout << bigs - q + bigmint << endl;

        auto nextt_p_small = lower_bound(ALL(T), smalls);
        ll smallmint = min(*nextt_p_small - smalls, smalls - *prev(nextt_p_small));
        mini = min(mini, q - smalls + smallmint);
        //cout << q - smalls + smallmint << endl; 

        auto nexts_p_big = lower_bound(ALL(S), bigt);
        ll bigmins = min(*nexts_p_big - bigt, bigt - *prev(nexts_p_big));
        mini = min(mini, bigt - q + bigmins);
        //cout << bigt - q + bigmins << endl;

        auto nexts_p_small = lower_bound(ALL(S), smallt);
        ll smallmins = min(*nexts_p_small - smallt, smallt - *prev(nexts_p_small));
        mini = min(mini, q - smallt + smallmins);
        //cout << q - smallt + smallmins << endl;

        ans[i] = mini;
        //cout << endl;
    }
    REP(i,Q){
        cout << ans[i]<<endl;
    }
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        string s; cin>>s;
        int n=s.size();
        int l=0,r=n-1;
        rep(i,n)
        {
                if(s[i]=='A')
                {
                        l=i;
                        break;
                }
        }
        rep(i,n)
        {
                if(s[n-1-i]=='Z')
                {
                        r=n-1-i;
                        break;
                }
        }
        cout<<r-l+1<<endl;
}

Measured memory_bytes: 640
N = int(input())
W = list(map(int, input().split()))

sum = sum(W)

X = [0 for i in range(N)]
X[0] = W[0]
for i in range(1, N):
  X[i] = X[i-1] + W[i]

Y = [0 for i in range(N-1)]
for i in range(N-1):
  Y[i] = abs(sum - X[i] - X[i])

print(min(Y))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  ll N; cin >> N;
  vector<ll> A(N);
  ll ans = 0, neg = 0, zero = 0;
  ll min = MOD;
  rep(i,N) {
    cin >> A[i];
    if(A[i] < 0) {
      ++neg;
      chmin(min, -1*A[i]);
      ans += -1*A[i];
    } else {
      chmin(min, A[i]);
      ans += A[i];
    }
    if(A[i] == 0) ++zero;
  }
  if(zero>0 || neg%2==0)
    cout << ans << endl;
  else
    cout << ans - min*2 << endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 998244353;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N, S; cin >> N >> S;
	vll A(N); cin >> A;
	vvll dp(N, vll(6666, 0));

	ll sum = 0;	
	for (int i = 0; i < N; i++) {
		dp[i][A[i]] = i+1;
	}
	for (int i = 0; i < N-1; i++) {
		for (int j = 0; j < S; j++) {
			(dp[i+1][j+A[i+1]] += dp[i][j]) %= mod;
			(dp[i+1][j] += dp[i][j]) %= mod;
		}
	}
	for (int i = 0; i < N; i++) {
		(sum += dp[i][S] * (N-i)) %= mod;
	}
	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 156672
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int N;
int A,B;
int a[100001];
string s;
vector<int> G[1001];
int main(){
  cin >> N;
  if(N%10==N/100)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

def str_read(s):
    while True:
        if len(s) == 0:
            return True
        else:
            if s[0:5] in ['maerd', 'esare']:
                s = s[5:]
            elif s[0:6] in ['resare']:
                s = s[6:]
            elif s[0:7] in ['remaerd']:
                s = s[7:]
            else:
                return False


si = input()
if str_read(si[::-1]):
    print('YES')
else:
    print('NO')



Measured memory_bytes: 3316
n = int(input())
a = list(map(int, input().split()))

flag=True
dp = [[0,0] for _ in range(n+1)]
if a[0]==0:
    dp[0]=[0,1]
    if n==0:
        flag=False
elif a[0]==1:
    dp[0]=[1,0]
else:
    flag=False
for i in range(1,n+1):
    free = dp[i-1][1]*2
    occu = a[i]
    if free-occu<0:
        flag=False
        break
    else:
        free-=occu
    dp[i]=[occu,free]
dp[n][1]=0
ans=0
ch=1001001001
for i in reversed(range(n+1)):
    free=min(ch,dp[i][1])
    ch=dp[i][0]+free
    ans+=dp[i][0]+free

if flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 711180
#include <stdio.h>
int main(void){
    int N, i, j, cnt = 0;
    
    scanf("%d", &N);
    
    for(i = 0; i < 10; i++){
        for(j = 0; j < 10; j++){
            if(N == i * j){
                cnt = cnt + 1;
            }
        }
    }
    if(cnt == 0){
        printf("No\n");
    }else if(cnt >= 1){
        printf("Yes\n");
    }
}


Measured memory_bytes: 1644
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),Q=in();
	vector<queue<int>> S(N);
	REP(i,Q){
		int q=in();
		int t=in();
		if(!q){
			S[t].push(in());
		}
		else if(q==1){
			if(!S[t].empty()) out(S[t].front());
		}
		else{
			if(!S[t].empty()) S[t].pop();
		}
	}

	return 0;
}


Measured memory_bytes: 4152
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,ans[501][501];
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>a>>b;a--;b--;
    rep(i,100){
        rep(j,100){
            if(i<50)ans[i][j]='.';
            else ans[i][j]='#';
        }
    }
    rep(i,50){
        rep(j,100){
            if(b==0)break;
            if(i%2==0){
                if(j%2==0){
                    ans[i][j]='#';
                    b--;
                }
            }
            if(b==0)break;
        }
        if(b==0)break;
    }
    rrep(i,50,100){
        rep(j,100){
            if(a==0)break;
            if(i%2!=0){
                if(j%2==0){
                    ans[i][j]='.';
                    a--;
                }
            }
            if(a==0)break;
        }
        if(a==0)break;
    }
    cout<<"100 100\n";
    rep(i,100){
        rep(j,100){
            cout<<ans[i][j];
        }
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << "[DBG] " << #X << "=" << (X) << '\n';
	#define SAY(X) cout << "[SAY] " << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)2e5 + 7;
vector<int> g[MAXN];
int n, m;
string S;
int cntA[MAXN], cntB[MAXN], killed[MAXN];

void solve() {
	cin >> n >> m >> S;
	for(int i = 0; i < m; ++i) {
		int v = fetch<int>() - 1;
		int u = fetch<int>() - 1;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	for(int v = 0; v < n; ++v) {
		auto& row = g[v];
		sort(row.begin(), row.end());
		row.erase(unique(row.begin(), row.end()), row.end());
	}
	for(int v = 0; v < n; ++v) {
		for(auto& u: g[v]) {
			if(S[u] == 'A') ++cntA[v];
			if(S[u] == 'B') ++cntB[v];
		}
	}
	set<pii> setik;
	for(int v = 0; v < n; ++v) {
		setik.emplace(min(cntA[v], cntB[v]), v);
	}
	while(!setik.empty()) {
		auto iter = setik.begin();
		int v = iter->second;
		killed[v] = 1;
		if(cntA[v] > 0 && cntB[v] > 0) break;
		setik.erase(iter);
		for(auto& u: g[v]) {
			if(killed[u]) continue;
			setik.erase(make_pair(min(cntA[u], cntB[u]), u));
			if(S[v] == 'A') --cntA[u];
			if(S[v] == 'B') --cntB[u];
			setik.emplace(min(cntA[u], cntB[u]), u);
		}
	}
	int cnt = 0;
	for(int v = 0; v < n; ++v) cnt += (cntA[v] > 0) && (cntB[v] > 0);
	cout << (cnt > 0 ? "Yes\n" : "No\n");
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 21584
#include <algorithm>
#include <cstdio>
using ll = long long;
int a[100005], b[100005], app[200005];
int main()
{
	// freopen("AGC028-C.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", a + i, b + i);
		app[i << 1] = a[i];
		app[i << 1 | 1] = b[i];
	}
	ll sum_a = 0, sum_b = 0, sum = 0;
	std::sort(app, app + (n << 1));
	for (int i = 0; i < n; i++)
	{
		sum += app[i];
		sum_a += a[i];
		sum_b += b[i];
	}
	ll ans = std::min(sum_a, sum_b);
	for (int i = 0; i < n; i++)
	{
		int pos = n - 1;
		ll res = sum;
		if (std::max(a[i], b[i]) > app[pos])
			res += std::max(a[i], b[i]) - app[pos--];
		if (std::min(a[i], b[i]) > app[pos])
			res += std::min(a[i], b[i]) - app[pos--];
		ans = std::min(ans, res);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1664
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

A,B,C = map(str,input().split())

if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")

    


Measured memory_bytes: 7872
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

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

const int INF = 1001001001;
const double EPS = 1e-10;

double func(int y, int r, int t)
{
	if(t == 1)
		return 1.0 + y*r/100.0;
	else
		return pow(1.0 + r/100.0, y);
}

int main()
{
	int n;
	while(scanf("%d", &n), n){
		int y;
		scanf("%d", &y);
		
		int bestb;
		double best = -1.0;
		rep(i, n){
			int b, r, t;
			scanf("%d%d%d", &b, &r, &t);
			
			double tmp = func(y, r, t);
			if(best < tmp){
				best = tmp;
				bestb = b;
			}
		}
		printf("%d\n", bestb);
	}
	return 0;
}

Measured memory_bytes: 1032
"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

import itertools as it
# import collections
import sys


def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


def main():
    S = input()
    counts = [sum(1 for _ in iterable) for _, iterable in it.groupby(S)]
    acc = list(it.accumulate(counts))
    res = [0] * len(S)
    i = 0
    while i < len(counts):
        rs = counts[i]
        ls = counts[i + 1]
        res[acc[i] - 1] = (rs + 1) // 2 + ls // 2
        res[acc[i]] = rs // 2 + (ls + 1) // 2
        i += 2
    print(*res)
        


if __name__ == "__main__":
    main()


Measured memory_bytes: 52572
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		string[] A = new string[N];
		for(var i=0;i<N;i++){
			A[i] = Console.ReadLine();
		}
		string str2 = Console.ReadLine();
		long M = long.Parse(str2);
		string[] B = new string[M];
		for(var i=0;i<M;i++){
			B[i] = Console.ReadLine();
		}
		long max = 0;
		for(var i=0;i<N;i++){
			long pt = 0;
			for(var j=0;j<N;j++)
				if(A[i] == A[j])
					pt += 1;
			for(var j=0;j<M;j++)
				if(A[i] == B[j])
					pt -= 1;
			max = Math.Max(pt,max);
		}
		Console.WriteLine(max);
	}
}

Measured memory_bytes: 13140
N = int(input())
A = list(map(lambda a: int(a) - 1, input()))

prd = 1
if all(a % 2 == 0 for a in A):
    prd = 2
    A = [a // 2 for a in A]

ans = 0
for i in range(N):
    if (N - 1) & i == i:
        ans ^= A[i] % 2

print(prd * ans)


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

int main(){
	int n;
	cin >> n;
	
	for(int xx = 0;xx < n;xx++){
		int r, t;
		cin >> r >> t;

		vector<int> a;
		vector<int> b;

		if(r % 100 == 0){
			a.push_back(r / 100);
		}else{
			a.push_back(r / 100);
			a.push_back((r+99) / 100);
		}

		if(t % 30 == 0){
			b.push_back(t / 30);
		}else{
			b.push_back(t / 30);
			b.push_back((t + 29) / 30);
		}

		vector<int> ans;		
		
		for(int i = 0;i < a.size();i++){
			for(int j = 0;j < b.size();j++){
				ans.push_back(a[i] + b[j] * 5);
			}
		}
		
		sort(ans.begin(), ans.end());
		
		for(int i = 0;i < ans.size();i++){
			cout << ans[i];
			if(i != ans.size()-1){
				cout << " ";
			}else{
				cout << endl;
			}
		}
		

	}
	
	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
  
bool has_divisor(int N, int i) {
  if (i == N) {
    return false;
  }
  if (N % i == 0) {
    return true;
  }
  return has_divisor(N, i + 1);
}

bool is_prime(int N) {
  if (N == 1) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else {
    return !has_divisor(N, 2);
  }
}

int main() {
  int x;
  cin >> x;
  rep(i,100000){
    if(is_prime(i + x)){
      cout << i + x;
      break;
    }
       }


  return 0;
}

Measured memory_bytes: 256
//AddSubMul.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int sum[]=new int[3];
        sum[0]=a+b;
        sum[1]=a-b;
        sum[2]=a*b;
        System.out.println(Math.max(Math.max(sum[0],sum[1]),sum[2]));
        sc.close();
    }
}

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

int main() {
  int n, cnt = 0; string s; cin >> n >> s;
  for (int i = 0; i < n-2; i++) {
    if (s[i] == 'A') {
      if (s[i+1] == 'B' && s[i+2] == 'C')
        cnt++;
    }
  }
  cout << cnt << 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;
using ll = long long;
using P = pair<int,int>;
using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    ll sb = d[n/2] - d[n/2 - 1] ;
    cout << sb << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>

typedef struct {
  double x, y;
} Plot;

/* プロトタイプ宣言 */
void print(Plot p);
void kock(int n, Plot p1, Plot p2);

int main() {
int n;
  Plot p1, p2;
  scanf("%d", &n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  print(p1);
  kock(n, p1, p2);
  print(p2);

  return 0;
}

void print(Plot p){ printf("%.8f %.8f\n", p.x, p.y); }

void kock(int n, Plot p1, Plot p2) {
  Plot s, t, u;
  double rot = 60.0*(acos(-1)/180.0);
  if ( n == 0 ) return;
  
  s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;
  u.x = (t.x - s.x) * cos(rot) - (t.y - s.y ) * sin(rot) + s.x;
  u.y = (t.x - s.x) * sin(rot) + (t.y - s.y ) * cos(rot) + s.y;
  
  kock(n-1, p1, s);
  print(s);
  kock(n-1, s, u);
  print(u);
  kock(n-1, u, t);
  print(t);
  kock(n-1, t, p2);
}






Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //エラーの出ないエラーを起こした時にデバッグできる
#define rep(i, n) for (int i = 0; i < (n); i++)

int main(){
  vector<int> x(5);
  
  for (int i = 0; i < 5; i++){
    cin >> x.at(i);
    
    if (x.at(i) == 0){
      cout << i+1 << endl;
      return 0;
    }
  }
    
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

const ll MOD=1000000007;

int N,K;
void input()
{
    cin>>N>>K;
}

void solve()
{
    ll ans=0;
    vi A(N+1); for(int i=0;i<=N;++i) A[i]=i;
    ll MIN=0,MAX=0;
    for(int i=0;i<K-1;++i) {MIN+=A[i];MAX+=A[N-i];}
    for(int i=K-1;i<=N;++i){
        MIN+=A[i];MAX+=A[N-i];
        ans+=(MAX-MIN+1)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 4008
object Main extends App {
  import scala.collection.mutable
  import scala.io.StdIn._

  val mod = 1000000007L
  val Array(n, m) = readLine.trim.split(' ').map(_.toLong)
  if (n == 1) println((m + 1) % mod)
  else {
    val maxDiff = (m / (n - 1)) % mod
    println((((((m + 1) % mod) * maxDiff * 2) % mod + (m + 1) % mod - (maxDiff * (maxDiff + 1) % mod) * (n - 1)) % mod + mod) % mod)
  }

  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 44180
#include<complex>
#include<iostream>

using namespace std;

typedef complex<long double> P;

// ?¨±?????????????????
#define EPS (1e-16)
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2??????????????????????????????????????????
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

// ?????? (dot product) : a???b = |a||b|cos??
long double dot(P a, P b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}

// ?????? (cross product) : a??b = |a||b|sin??
long double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

int is_intersected_ls(P a1, P a2, P b1, P b2) {
	return (cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < EPS) &&
		(cross(b2 - b1, a1 - b1) * cross(b2 - b1, a2 - b1) < EPS);
}

// 2??´?????????????????? : a//b <=> cross(a, b) = 0
int is_parallel(P a1, P a2, P b1, P b2) {
	return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

// ???c?????????a,b????????????????????????(1)
int is_point_on_line(P a, P b, P c) {
	return EQ(cross(b - a, c - a), 0.0) &&
		(dot(b - a, c - a) > -EPS) &&
		(dot(a - b, c - b) > -EPS);
}

// a1,a2???????????¨??????????????¨b1,b2???????????¨??????????????????????¨????
P intersection_ls(P a1, P a2, P b1, P b2) {
	P b = b2 - b1;
	long double d1 = abs(cross(b, a1 - b1));
	long double d2 = abs(cross(b, a2 - b1));
	long double t = d1 / (d1 + d2);

	return a1 + (a2 - a1) * t;
}

int main() {
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		long double x0, y0, x1, y1, x2, y2, x3, y3;
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		P p0(x0, y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);
		P ans = intersection_ls(p0, p1, p2, p3);
		cout.precision(20);
		cout << showpoint << ans.real() << " " << ans.imag() << endl;
	}
}

Measured memory_bytes: 1300
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int sx, sy, tx, ty;

  cin >> sx >> sy >> tx >> ty;


  for(int yu = 0; yu < ty - sy; yu++) cout << "U";
  for(int xr = 0; xr < tx - sx; xr++) cout << "R";
  for(int yd = 0; yd < ty - sy; yd++) cout << "D";
  for(int xl = 0; xl < tx - sx; xl++) cout << "L";

  cout << "L";
  for(int yu = 0; yu < ty - sy + 1; yu++) cout << "U";
  for(int xr = 0; xr < tx - sx + 1; xr++) cout << "R";
  cout << "D";
  cout << "R";
  for(int yd = 0; yd < ty - sy + 1; yd++) cout << "D";
  for(int xl = 0; xl < tx - sx + 1; xl++) cout << "L";
  cout << "U";

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int a, b, ans;
	char op;

	while (1) {
		scanf("%d %c %d", &a, &op, &b);

		if (op == '?') {
			break;
		}

		switch (op) {
		case '+':

			ans = a + b;
			break;

		case '-':
			ans = a - b;
			break;

		case '*':
			ans = a * b;
			break;

		case '/':
			ans = a / b;
			break;
		}

		printf("%d\n", ans);

	}

	return(0);

}


Measured memory_bytes: 2048
#include<iostream>
//#include<cmath>
using namespace std;

int main(){
    int w,h,x,y,r,wdash,hdash;
    //cout<<"please input 2 numbers.\n"<<endl;
    cin >>w>>h>>x>>y>>r;
    hdash=h-r;
    wdash=w-r;
    if (((r<=x)&&(x<=wdash))&&((r<=y)&&(y<=hdash))){
        cout<<"Yes"<<endl;}
    else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3096
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/12 15:47:51
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 11, M = 1000 + 5;

void run() {
    int n, m, k; cin >> n >> m >> k;
    vector <string> s(n);
    vector <vector <int>> sum(n, vector <int>(m));
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < m; j++) {
            if (i) sum[i][j] += sum[i - 1][j];
            if (j) sum[i][j] += sum[i][j - 1];
            if (i && j) sum[i][j] -= sum[i - 1][j - 1];
            if (s[i][j] == '1') ++sum[i][j];
        }
    }
    auto calc = [&] (int r1, int r2, int c1, int c2) {
        int res = sum[r2][c2];
        if (r1) res -= sum[r1 - 1][c2];
        if (c1) res -= sum[r2][c1 - 1];
        if (r1 && c1) res += sum[r1 - 1][c1 - 1];
        return res;  
    };
    auto chk = [&] (vector <int>& rows, int j1, int j2) {
        int last = 0;
        for (int i = 0; i < sz(rows); i++) {
            if (calc(last, rows[i], j1, j2) > k) return false;
            last = rows[i] + 1;
        }
        return true;
    };
    int ans = INF;
    for (int sta = 0; sta < 1 << (n - 1); sta++) {
        vector <int> rows;
        for (int i = 0; i < n - 1; i++) if (sta >> i & 1) {
            rows.push_back(i);
        }
        rows.push_back(n - 1);
        vector <int> dp(m + 1, INF);
        dp[0] = 0;
        for (int i = 1; i <= m; i++) {
            int l = 1, r = i + 1, mid;
            while (l < r) {
                mid = (l + r) >> 1;
                if (chk(rows, mid - 1, i - 1)) r = mid;
                else l = mid + 1;
            }
            dp[i] = dp[r - 1] + 1;
        }
        int res = sz(rows) + dp[m] - 2;
        ans = min(ans, res);
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 384
from copy import deepcopy
from collections import deque


def bfs(maze, x, y):
    res = 0
    que = deque([])
    que.append((x, y, 0))

    while que:
        i, j, c = que.popleft()
        if maze[i][j] == "#":
            continue
        maze[i][j] = "#"
        res = max(res, c)
        for dx, dy in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            que.append((i + dx, j + dy, c + 1))

    return res


def main():
    h, w = map(int, input().split())
    wall = ["#"] * (w + 2)
    maze = [wall]
    for _ in range(h):
        line = ["#"] + list(input()) + ["#"]
        maze.append(line)
    maze.append(wall)

    ans = 0
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if maze[i][j] == "#":
                continue
            m = deepcopy(maze)
            ans = max(ans, bfs(m, i, j))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        char c[] = s.toCharArray();
        String ans = "";
        if(c[2]==c[3]&&c[4]==c[5]){
            ans = "Yes";
        }else{
            ans = "No";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 32664
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

int draw[] = {1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049, 531441};

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

  int n; cin >> n;

  vector<int> dp(n+1, INF);
  for (int i = 0; i <= n; i++) {
    dp[i] = i;
  }

  for (int i = 1; i < 13; i++) {
    for (int j = 0; j <= n; j++) {
      if (j - draw[i] < 0) continue;
      chmin(dp[j], dp[j-draw[i]] + 1);
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 640
A,B = map(int,input().split())
b = list(bin(B))[2:]
b.reverse()
if A%2 == 0:
    if ((B-A)+1)%2 == 0:
        if ((B-A)+1)//2%2 == 0:
            print(0)
        else:
            print(1)
    else:
        if ((B-A)+1)//2%2 == 0:
            print(B)
        else:
            if b[0] == '0':
                print(B+1)
            else:
                print(B-1)
else:
    if ((B-A)+1)%2 == 0:
        if ((B-A)+1)//2%2 == 1:
            print(A^B)
        else:
            print(1^A^B)
    else:
        if ((B-A)+1)//2%2 == 0:
            print(A)
        else:
            print(A^1)

Measured memory_bytes: 38384
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<limits>
#include<stack>
//include<bits/stdc++.h>
using namespace std;
int main()
{
	stack<char>st;
	string str;
	cin >> str;
	bool foundmatches = false;
	int count = 0;
	//for (long long iteration = 0; iteration < pow(10, 10000); iteration++)
	//{
	count = 0;
	int size = str.size();
	for (int i = 0; i < size; i++)
	{
		if (str[i] == 'S')
			st.push('S');
		else if (str[i] == 'T' && st.empty() == false)
		{
			st.pop();
			count++;
		}
	}
	//}
	cout << str.size() - count * 2 << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdbool.h>


int main() {
	int maxl=0,minr=1000000,n,m,l[100001],r[100001];
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &l[i], &r[i]);
		if (minr > r[i])minr = r[i];
		if (maxl < l[i])maxl = l[i];
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (i <= minr && i >= maxl)cnt++;

	}
	printf("%d", cnt);

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(int i = 0; i <N; i++)
using namespace std;


const int MOD = pow(10,9)+7;
const int MAX = 2047483647;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



int main() {
    
    ll N = lin();
    ll K = lin();
    
    ll ans = 0;
    
    ll countvals[K];
    
    for(auto i = 0; i<K;i++){
        countvals[i] = 0;
    }
    
    for(auto i = 1; i<=N;i++){
        
        if ((2*i)%K == 0){
            countvals[i%K]++;
        }
    }

    
    for(auto i = 0; i<K;i++){
        
        ans += countvals[i]*countvals[i]*countvals[i];
        
    }
    
    
    cout << ans << endl;
    


    
    return 0;
}






Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

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

    vector<int> color(9);
    rep(i,n){
        int ai = a[i] / 400;
        if (ai > 8) ai = 8;
        color[ai]++;
    }

    int minAns = 0, maxAns = 0;
    rep(i,8){
        if (color[i]) minAns++;
    }
    maxAns = minAns + color[8];
    if (minAns == 0) minAns = 1;
    printf("%d %d\n", minAns, maxAns);
    return 0;
}

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

using namespace std;

bool myBinarySearch(int S[], int begin, int end, int target) {
  if(begin > end) {
    return false;
  }
  int mid = (begin + end) / 2;
  if(S[mid] > target) {
    return myBinarySearch(S, begin, mid - 1, target);
  }
  else if(S[mid] < target) {
    return myBinarySearch(S, mid + 1, end, target);
  }
  else {
    return true;
  }
}

int main(void) {
  int S[100000];
  int T[50000];
  int n, m;

  cin >> m;
  for(int i = 0; i < m; i++) {
    cin >> S[i];
  }
  sort(S, S + m);

  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> T[i];
  }
  sort(T, T + n);

  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(myBinarySearch(S, 0, m, T[i])) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1760
n,m=gets.split.map &:to_i;
$p=Array.new(n+1).map{Array.new(11,0)};
$g=Array.new(n+1).map{Array.new(0)};
m.times{a,b=gets.split.map &:to_i;$g[a].push(b);$g[b].push(a)}
def f(u,d,l)
	if d>=0&&$p[u][d]<1
		$p[u][d]=l;
		$g[u].each{|v|f v,d-1,l}
	end
end
q=gets.to_i;
d=$<.map &:split;
1.upto(q){|i|0.upto(d[-i][1].to_i){|a|f d[-i][0].to_i,a,d[-i][2].to_i}};
1.upto(n){|i|p$p[i][0]}

Measured memory_bytes: 70508
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N;
ll A;
ll cand[3];
int main(){
	cin >> N;
	ll ans = 1;
	REP(i,0,N){
		cin >> A;
		ll cnt = 0;
		REP(j,0,3){
			if(A == cand[j]){
				cnt++;
			}
		}
		ans *= cnt;
		ans %= mod;
		REP(j,0,3){
			if(A == cand[j]){
				cand[j]++;
				break;
			}
		}
	}
	p(ans);
	return 0;
}

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

string s;

bool operation(char ch) {
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i + 1] == ch) {
      s[i] = ch;
    }
  }
  s = s.substr(0, s.length() - 1);
  return true;
}

bool check(char ch) {
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != ch) {
      return false;
    }
  }
  return true;
}

int main() {
  int ans = 0;
  cin >> s;
  string s_base = s;
  int len = s.length();
  ans = len / 2;

  for (int i = 0; i < 26; i++) {
    s = s_base;
    int count = 0;
    char ch = 'a' + i;
    //cerr << ch << ":";

    for (int j = 0; j < (len / 2) + 1; j++) {
      if (check(ch) == true) {
        //cerr << ch << ":" << count;
        break;
      }
      operation(ch);
      //cerr << s << " ";
      count++;
    }
    //cerr << endl;
    ans = min(ans, count);
  }
  cout << ans << endl;
  return 0;
}
/*

whbrjpjyhsrywlqjxdbrbaomnw
   4      |        |

         */

Measured memory_bytes: 256
n,m = map(int,input().split())
x = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
ans = 0
for i in range(2 ** n):
    bag = []
    cnt = 0
    for j in range(n):  
        if ((i >> j) & 1):  
            bag.append(True)
        else:
            bag.append(False)
    for l in range(m):
        res = 0
        for h in x[l][1:]:
            if bag[h-1]:
                res += 1
        if res%2!=p[l]:
            break
        else:
            cnt += 1
    if cnt==m:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main() {
	int n, k;
	cin >> n >> k;

	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	sort(p.begin(), p.end());

	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += p[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3632
//##MohK..
//22/05/2020   ...   5,32
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a;
    cin>>a;
    string x;
    cin>>x;
    if(a==x.size()||a>x.size())cout<<x<<endl;
    else {
        for(ll i=0;i<a;i++){
            if(i==a-1){
                cout<<x[i]<<"..."<<endl;
            }
            else
            cout<<x[i];
        }
    }

    return 0;
}



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

int main() {
  vector<ll> a(3);
  rep(i,3) cin >>a[i];
  if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0) cout << 0 << endl;
  else {
    sort(a.begin(), a.end());
    cout << a[0]*a[1] << endl;
  }
  return 0;
}

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

int main()
{ 
	ll n,k,x;
	cin>>n>>k;

	ll dp[k+1];
	memset(dp,0,sizeof(dp));
	dp[0]=1;

	for(ll i=0;i<n;i++)
	{
		cin>>x;

		vector<ll> pre(k+1,0);
		pre[0]=1;

		for(ll j=1;j<=k;j++)
			pre[j]=(pre[j-1]+dp[j])%mod;

		for(ll j=0;j<=k;j++)
		{
			ll z=pre[j];

			if(j-x>=1)
			z=(z-pre[j-x-1]+mod)%mod;

			dp[j]=z;
		}
	}
	cout<<dp[k]<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int N;
char u[11];
long double sum, x;
int main(){
	cin>>N;
	while(N--){
		cin>>x>>u;
		if(u[0] == 'J'){
			sum += x;
		}
		else sum += x * 380000.0;
	}
	cout<<sum<<"\n";
	return 0;
}

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

int main(){
	string s,t;
	cin >> s >> t;
	
	cout << t << s << endl;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  
  map<char, char> cs, ct;
  int l = s.size();
  bool ok = true;
  for(int i = 0; i < l; i++){
    char ns = s.at(i), nt = t.at(i);
    if(cs.count(ns)){
      if(cs.at(ns) != nt) ok = false;
    }
    else if(ct.count(nt)){
      if(ct.at(nt) != ns) ok = false;
    }
    else{
      cs[ns] = nt;
      ct[nt] = ns;
    }
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3924
from math import sqrt
from itertools import product
import sys

n = int(input())
p = []
def factorization(arg):
    while arg % 2 == 0:
        p.append(2)
        arg //= 2
    for i in range(3, int(sqrt(arg)) + 1, 2):
        while arg % i == 0:
            p.append(i)
            arg //= i
    if arg > 1:
        p.append(arg)
if n == 1:
    print(1)
else:
    factorization(n)
    min = sys.maxsize
    for bit in range(2 ** len(p)):
        a = 1
        b = 1
        for i in range(len(p)):
            if ((bit >> i) & 1):
                a *= p[i]
            else:
                b *= p[i]
        if min > a and a >= b:
            min = a
        elif min > b and b > a:
            min = b
    print(len(str(min)))

Measured memory_bytes: 41308
#include <stdio.h>
#define swap(X, Y) {int Z; Z = Y; Y = X; X = Z}
int main()
{
	int a, i =1;
	
	
	
	while(true)
	{
		scanf("%d", &a);
		if(a == 0)
		{
			break;
		}
		printf("Case %d: %d\n", i++, a);
	}
	return 0;
}


Measured memory_bytes: 2564
import sys
input = sys.stdin.readline
n=int(input())
A=list(map(int,input().split()))
A.sort()
from collections import Counter
c=Counter(A).items()
#print(c)
cnt=0
for key,val in c:
    if val%2==0:
        cnt+=1
print(len(c) if cnt%2==0 else len(c)-1)


Measured memory_bytes: 62108
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int, int> PII;

const int N = 2e5 + 10;
const long long INF = (ll)1e18;

char s[N];
ll num[30];

int main ()
{
	scanf("%s", s);
	ll len = strlen(s);
	memset(num, 0, sizeof(num));
	for(int i = 0; i < len; i++)
		num[s[i] - 'a']++;
	
	ll ans = len * (len - 1) / 2 + 1;
	for(int i = 0; i < 30; i++)if(num[i])
		ans -= num[i] * (num[i] - 1) / 2;
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

typedef long long ll;
const ll InF = 1e9 + 1;

int main() {
  int N,flag;
  ll sum,minval;
  cin>>N;
  vector<ll> A(N);
  sum = 0;
  minval = InF;
  for(int i = 0; i < N; i++) {
    cin>>A[i];
    if(A[i]<0) flag++;
    sum += llabs(A[i]);
    minval = min(minval,llabs(A[i]));
  }
  if(flag%2==0) cout<<sum<<endl;
  else cout<<sum-2*minval<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a[4];
  cin>>a[0]>>a[1]>>a[2]>>a[3];
  ll p[4];
  p[0] = a[0]*a[2];
  p[1] = a[0]*a[3];
  p[2] = a[1]*a[2];
  p[3] = a[1]*a[3];
  ll ans = p[0];
  for(int i=1;i<4;++i){
    if(ans < p[i]) ans = p[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim], Fac[lim];
lld nCr(lld n, lld r) {
    return Fac[n] * powP(Fac[r] * Fac[n - r] % mod, mod - 2) % mod;
}
lld BackM[lim];

int main(){
    mod = 998244353;
    lld n = sc(), m = sc(), k = sc();
    Fac[0] = 1;
    rep(i,1,lim-1) Fac[i] = Fac[i - 1] * i % mod;
    BackM[0] = 1; BackM[1] = m;
    rep(i,2,lim-1) {
        BackM[i] = BackM[i - 1] * (m - 1) % mod;
    }
    lld ans = 0;
    rep(i,0,k) {
        // Error(i, ans, nCr(n - 1, i), BackM[n - i], nCr(n - 1, i) * BackM[n - i] % mod);
        ans = (ans + nCr(n - 1, i) * BackM[n - i] % mod) % mod;
    }
    prL(ans);
    return 0;
}


Measured memory_bytes: 8512
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
int main()
{
     long long int n,a1,i,q,b,c,s=0;
       vector<int>a(100001,0);
               cin>>n;
        for(i=0;i<n;i++)
        {
                cin>>a1;
                a[a1]++;
                s=s+a1;
        }
        cin>>q;
        while(q--)
        {
                cin>>b>>c;
                if(a[b]!=0)
                {
                        s=s-b*a[b]+c*a[b];
                        a[c]=a[c]+a[b];
                        a[b]=0;
                        
                }
               cout<<s<<endl; 
        }
        //cout<<s<<endl;
}

Measured memory_bytes: 3748
import math
import collections
# 試し割法

N, P = map(int, input().split())


def trial_division(n):
    # 素因数を格納するリスト
    factor = []
    # 2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    # リストが空ならそれは素数
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor


lst = trial_division(P)
c_lst = collections.Counter(lst)

ans = 1
for k, v in c_lst.items():
    while v >= N:
        ans *= k
        v -= N
print(ans)


Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	string s;
	int q;
	cin >> s >> q;
	bool st=0;
	vector<char> v[2];
	while(q--) {
		int qt;
		cin >> qt;
		if(qt==1) {
			st=!st;
		} else {
			int f;
			char c;
			cin >> f >> c, --f;
			v[f^st].push_back(c);
		}
	}
	string t;
	for(int i=(int)v[0].size()-1; ~i; --i)
		t+=v[0][i];
	t+=s;
	for(char c : v[1])
		t+=c;
	if(st)
		reverse(t.begin(), t.end());
	cout << t;
}

Measured memory_bytes: 1448
n,m=map(int,input().split())
x=list(map(int,input().split()))
ans=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    if x[a-1]>x[b-1]:
        ans[b-1]+=1
    elif x[a-1]<x[b-1]:
        ans[a-1]+=1
    else:
        ans[a-1]+=1
        ans[b-1]+=1
print(ans.count(0))

Measured memory_bytes: 20148