akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <cstdio>
double a,b;
inline char nc()
{
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline double read()
{
    char ch=nc();
    double sum=0;
    while(!(ch>='0'&&ch<='9')) ch=nc();
    while(ch>='0'&&ch<='9') sum=sum*10+ch-48,ch=nc();
    return sum;
}
int main()
{
	a=read(),b=read();
	std::printf("%.6lf",a*b/(a+b));
	return 0;
}

Measured memory_bytes: 128
n, w = map(int, input().split())
item_max = 100
val_max = 1000
col_max = item_max * val_max

# dp[i][j] = item iまでで価値jになるようにした時の最小重み
dp = [[float('inf') for _ in range(col_max + 1)] for _ in range(n + 1)]
for i in range(n + 1):
    dp[i][0] = 0

for i in range(1, n + 1):
    wi, vi = map(int, input().split())
    for j in range(1, col_max + 1):
        if j >= vi:
            dp[i][j] = min(dp[i - 1][j],
                            dp[i - 1][j - vi] + wi)
        else:
            dp[i][j] = dp[i - 1][j]

ans = 0
for i in range(col_max + 1):
    if dp[n][i] <= w:
        ans = i
print(ans)

Measured memory_bytes: 412660
#include<bits/stdc++.h>
using namespace std;
string s;
int ans=0;

int main()
{
    cin>>s;
    int len=s.size();
    for(int i=0;i<len-1;i++)
      if(s[i]!=s[i+1])  ans++;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 100005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	ll mod = 1e9+7;
	ll a[n+1];
	for(int i=1;i<=n;i++){
        cin>>a[i];
	}
	ll dp[k+1][n+1];
	ll sum[k+1][n+1];
	for(int i=0;i<=k;i++){
        dp[i][0] = 0;
        sum[i][0] = 1;
	}
	for(int i=0;i<=n;i++){
        dp[0][i] = 1;
        sum[0][i] = 1;
	}
	for(int i=1;i<=k;i++){
        for(int j=1;j<=n;j++){
            dp[i][j] = (dp[i][j-1] + sum[i-1][j-1] - (i-1-a[j]>=0?sum[i-1-a[j]][j-1]:0)+mod)%mod;
            sum[i][j] = (dp[i][j] + sum[i-1][j])%mod;
        }
	}
	cout<<dp[k][n];
	return 0;
}


Measured memory_bytes: 158080
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	c -= min(c, a-b);
	cout << c;
	return 0;
}


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

const int MAX = 100001;
int main() {
	int N, Q;
	static int A[MAX], X;
	cin >> N >> Q;
	for (int i = 0;i < N;++ i) cin >> A[i];
	
	static pair<int, long long> ans[MAX]; // ans[i].first ≦ X < ans[i + 1].firstならans[i].secondが答えになるよ
	ans[0] = make_pair(0, 0);
	for (int i = N / 2;i < N;++ i) ans[0].second += A[i]; // xが最小の時の答え
	for (int i = 0, l = N + 1 & 1, r = N / 2;r < N;++ i, l += 2, ++ r) ans[i + 1] = make_pair((A[r] + A[l]) / 2, ans[i].second - A[r] + A[l]); // 区間(l, r]が青木くんが連続して取った区間だよ
	
	for (int i = 0, min, mid, max, halfDiff;i < Q;++ i) {
		min = 0;
		max = (N + 3) / 2;
		cin >> X;
		while(halfDiff = max - min >> 1) (ans[mid = min + halfDiff].first < X ? min : max) = mid; // 二分探索O(logN)
		cout << ans[min].second << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

O(N+QlogN)
*/

Measured memory_bytes: 2944
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe

main :: IO ()
main =
  putStr . unlines . map (unwords . map show)
  . calcAnsG
  . map (map (fst . fromJust . B.readInt) . B.words) . B.lines
  =<< B.getContents

calcAnsG :: [[Int]] -> [[Int]]
calcAnsG [[n, _, w], as] = [[calcAns n w as]]

calcAns :: Int -> Int -> [Int] -> Int
calcAns 1 w [a] = abs (w - a)
calcAns n w as = abs (w - a) `max` abs (b - a)
  where a : b : _ = reverse as


Measured memory_bytes: 1020
#番兵を使ったタイプの解き方
n=input()
s=list(map(int,input().split()))
q=input()
t=list(map(int,input().split()))
count=0
for i in t:
    j=0
    s.append(i)
    while s[j]!=i:j +=1
    s.pop()
    if j==int(n):continue
    else:count +=1
print(count)


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

int main() {
	ll n,a[100010],j,ans=1;
	cin>>n;
	for(int i=0;i<100010;i++){
		a[i]=0;
	}
	bool even;
	if(n%2==0){
		even=1;
		j=1;
	}
	else{
		even=0;
		j=0;
	}
	for(int i=0;i<n;i++){
		int z;
		cin>>z;
		if( (even==1&&z%2==0) || (even==0&&z%2!=0) ){
			cout << "0";
			return 0;
		}
		a[z]++;
	}
	if(j==0){
		if(a[0]!=1){
			cout << "0";
			return 0;
		}
		j=2;
	}
	for(;j<n;j+=2){
		if(a[j]!=2){
			cout << "0";
			return 0;
		}
			ans*=2;
			ans%=1000000000+7;
		
	}
	cout <<ans;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,l,t,cnt,ans[100010];
int main()
{
	scanf("%d%d%d",&n,&l,&t);
	for(int x,y,i=1;i<=n;i++)
	{
		scanf("%d%d",&x,&y);
		ans[i]=x+t*(y==1?1:-1);
		cnt+=ans[i]>0?ans[i]/l:(ans[i]-l+1)/l;
		ans[i]=(ans[i]%l+l)%l;
	}
	sort(ans+1,ans+n+1);
	cnt=(cnt%n+n)%n;
	for(int i=cnt+1;i<=n;i++)
		printf("%d\n",ans[i]);
	for(int i=1;i<=cnt;i++)
		printf("%d\n",ans[i]);
	return 0;
}

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

int main() {
  string S, T;
  int cnt = 0;
  cin >> S;
  cin >> T;
  int size = S.size();
  for (int i = 0; i < size; i++) {
    if (S.at(i)!=T.at(i)) break;
    else cnt++;
  }
  if (cnt==size) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
main(i,j){char s[12]={},t[12]={};for(;~scanf("%s",s);printf("%d\n",*s)){for(i=0;i<12;++i)s[i]-=48;for(i=0;i<9;memcpy(s,t,12),++i)for(j=0;i<9-j;++j)t[j]=(s[j]+s[j+1])%10;}}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
using P = pair<int, int>;
vector<P> rle(const string &s)
{
    vector<P> ret;
    for (auto c : s)
    {
        if (ret.empty() || ret.back().first != c - '0')
        {
            ret.emplace_back(c - '0', 1);
        }
        else
        {
            ++ret.back().second;
        }
    }
    return ret;
}
int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    auto v = rle(s);

    int zero_cnt = 0;
    int cnt = 0;
    int ans = 0;
    queue<P> q;
    for (int i = 0; i < v.size(); ++i)
    {
        if (v[i].first == 0)
            ++zero_cnt;
        cnt += v[i].second;
        q.push(v[i]);

        while (zero_cnt > k)
        {
            P tmp = q.front();
            q.pop();
            if (tmp.first == 0)
                --zero_cnt;
            cnt -= tmp.second;
        }

        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

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 * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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 arr[11][11];
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  // negative(arr);
  int cnt, x;
  fi(0, m) {
    cin >> cnt;
    while(cnt--){
      cin >> x;
      arr[i][x] = 1;
    }
  }
  fi(0, m) {
    cin >> x;
    arr[i][0] = x;
  }
  fi(0, 1 << n) {
    int ng = 0;
    fj(0, m) {
      cnt = 0;
      fk(1, n + 1) {
        if(arr[j][k] && (i >> (k - 1)) & 1) {
          cnt++;
        }
      }
      if(cnt % 2 != arr[j][0]) {
        ng = 1;
        break;
      }
    }
    if(!ng) {
      ans++;
    }
  }
  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;
using ll = long long;
using P = pair<int, int>;

ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}

ll solve(int n, ll m, vector<ll> &a) {
  // 2 で割れるだけ割る (割れる回数が異なったらダメ)
  bool same = true;
  while (a[0] % 2 == 0) {
    rep(i, n) {
      if (a[i] % 2 != 0) return 0;
      a[i] /= 2;
    }
    m /= 2;
  }
  rep(i, n) if (a[i] % 2 == 0) return 0;

  // lcm
  ll lcm = 1;
  rep(i, n) {
    ll g = gcd(lcm, a[i]);
    lcm = lcm / g * a[i];
    if (lcm > m) return 0;
  }
  return (m / lcm + 1) / 2;
}

int main() {
  int n;
  ll m;
  cin >> n >> m;
  vector<ll> a(n);

  // あらかじめ a は一回 2 で割っておく
  rep(i, n) cin >> a[i], a[i] /= 2;
  cout << solve(n, m, a) << endl;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
//int rnd(int x) { return mrand() % x;}
const ll mod=998244353;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

ll n,m,k;
ll Fac[maxn],Inv[maxn];

ll inv(ll x, ll mod)//x关于p的逆元，p为素数
{
    return powmod(x, mod - 2);
}

void init(int n)
{
	Fac[0] = 1;
	rep(i,1,n + 1) Fac[i] = Fac[i - 1] * i % mod;
	Inv[n] = inv(Fac[n],mod);
    for( int i = n - 1; i >= 0; --i ) Inv[ i ] = Inv[ i + 1 ] * ( i + 1 ) % mod;
}

ll C(ll n, ll m, ll mod)//组合数C(n, m) % p
{
    if(m > n)return 0;
    return Fac[n] * Inv[n - m] % mod * Inv[m] % mod;
}

int main()
{
	fastIO;
	cin >> n >> m >> k;
	init(n);
	ll res = 0;
	rep(i,0,k + 1) {
		res += C(n - 1,i,mod) * m % mod * powmod(m - 1,n - i - 1) % mod;
		res %= mod;
	}
	cout << res;
	return 0;
}


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

int main() {
    ll N, Q; cin >> N >> Q;
    Graph g(N+1);
    for(int i=1; i<N; i++){
        int a, b; cin >> a >> b;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
    }

    vector<int> p(Q+1), x(Q+1);
    rep(i,Q) cin >> p.at(i+1) >> x.at(i+1);

    vector<int> cnt(N+1, 0);
    rep(i, Q){
        cnt.at(p.at(i+1)) += x.at(i+1);
    }

    vector<bool> used(N+1, false);
    queue<int> q;
    q.push(1); 

    while(!q.empty()){
        int node = q.front();
        q.pop();
        used.at(node) = true;

        for(auto nextnode: g.at(node)){
            if(used.at(nextnode) != false) continue;

            cnt.at(nextnode) += cnt.at(node);
            q.push(nextnode);
        }
    }

    rep(i, N){
        cout << cnt.at(i+1) << " ";
    }

    cout << endl;

}

Measured memory_bytes: 17140
s = input()
s = s.replace("/","")
if int(s[0:4])<2019:
  print("Heisei")
elif int(s[0:4]) ==2019:
  if int(s[4:6]) <=4:
    print("Heisei")
  else:
    print("TBD")
else:
  print("TBD")


Measured memory_bytes: 38256
def main():
    s = input()
    x, y = map(int, input().split())
    i = 0
    while i < len(s) and s[i] == "F":
        x -= 1
        i += 1
    s = s[i:]
    i, m, d = 0, 0, 0
    mvs = [[], []]
    for c in s:
        if c == 'T':
            if m > 0:
                mvs[d].append(m)
            d = (d+1) % 2
            m = 0
        else:
            m += 1
    if m > 0:
        mvs[d].append(m)
    p = [set([0]), set([0])]
    for d in range(2):
        for m in mvs[d]:
            tmp = set()
            for prev in p[d]:
                tmp.add(prev - m)
                tmp.add(prev + m)
            p[d] = tmp
    if x in p[0] and y in p[1]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 46044
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1 << " | ";__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

const int MOD = 1e9 + 7;
int power(int a,int n){
	int r=1;
	while( n ){
		if( n&1 ){
			r*=a;
			r%=MOD;
		}
		a*=a;
		a%=MOD;
		n>>=1;
	}
	return r;
}

struct box{
	int w,s,v;
};
bool cmp(box a,box b){
	return a.w + a.s > b.w + b.s;
}
int32_t main()
{
   IOS
   const int MXS=2e4+5;// 2* s :  j-s  to be updated
   vector<int>dp(MXS+1);
   int n;cin>>n;
   vector<box>a(n);
   for(int i=0;i<n;i++)
   cin>>a[i].w>>a[i].s>>a[i].v;
   sort(a.begin(),a.end(),cmp);
   for(int i=0;i<n;i++)
   {
	   int w,s,v;
	   w=a[i].w;
	   s=a[i].s;
	   v=a[i].v;
	   vector<int>dp2=dp;
	   for(int j=0;j<=MXS;j++)
	   {
		   int k = min(j-w,s);
		   if( k >= 0 )
		   {
			   dp2[k]=max(dp2[k],dp[j]+v);
		   }
	   }
	   dp=dp2;
   }
   int mxv=0;
   for(int i=0;i<=MXS;i++)
   mxv=max(mxv,dp[i]);
   cout << mxv << endl;
  
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int N, Q;
	string S;
	cin >> N >> Q >> S;
	int count = 0;
	vector<int> data(N, 0);
	for (int i = 0; i < N-1; ++i) {
		if (S.at(i) == 'A') {
			if (S.at(i + 1) == 'C')
				count++;
		}
		data.at(i+1) = count;
	}

	int ans, l, r;
	for (int i = 0; i < Q; ++i) {
		ans = 0;
		cin >> l >> r;
		ans = data.at(r-1);
		ans -= data.at(l-1);
		cout << ans << endl;
	}

}



Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstdlib>

using namespace std;

int main(){
  char in[1] = {};
  int i, n, ans_a, ans_b = 10, ans_p = 10, p, q, flag = 0, sum = 0, ans;

  for(n = 11; n >= 0; n--) {
    scanf("%1s", in);
    if('0' <= in[0] && in[0] <= '9') {
      p = atoi(in);
      if(7 <= n) {
	q = n-5;
      }
      else if(n != 0){
	q = n+1;
      }
      
      if(n == 0) {
	ans = atoi(in);
      }
      
      else sum += p*q;
    }
 
    else if(n != 0) {
      if(7 <= n) {
	flag = n-5;
      }
      else
	flag = n+1;
    }
    
    //        cout << p*q << endl;
  }

  getchar();

  if(flag) {
    ans_p = 10;
    //   cout << "flag" << flag << endl;
    for(i = 0; i < 10; i++) {
      //     cout <<"sum+flag*i"<< sum+flag*i << endl;
      ans_b = 11 - (sum+flag*i) % 11;

       if((sum+flag*i) % 11 <= 1) {
       	ans_b = 0;
       }
      //     cout <<"ans_b" <<ans_b << endl;
      if(ans == ans_b) {
	if(ans_p == 10) {
	  ans_p = i;
	}
	else {
	  cout << "MULTIPLE" << endl;
	  return 0;
	}
      }  
    }
    
    if(ans_p != 10) {
      cout << ans_p << endl;
    }
  }
    
  else {
    ans_a = 11- sum % 11;
    if(sum % 11 <= 1) {
	ans_a = 0;
      }
    cout << ans_a << endl;
  }
  
  return 0;
}
    

Measured memory_bytes: 1164
import java.util.*;

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

    int n = scan.nextInt();
    ArrayList<Integer> set = new ArrayList<>();
    for(int i = 0; i < 2*n; i++) set.add(scan.nextInt());
    Collections.sort(set);

    int result = 0;
    for(int i = 0; i < 2*n; i+=2) {
      result += Math.min(set.get(i),set.get(i+1));
    }
    System.out.println(result);
  }
}


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

int a[3];
int ans;
int main() {
	cin >> a[0] >> a[1] >> a[2];
	
	do {
		int x = a[0] * 10 + a[1] + a[2];
		ans = max(ans,x);
	}while(next_permutation(a,a + 3));
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]

l=[i for i in l if '#' in i]
l=[list(i) for i in zip(*l)]
l=[i for i in l if '#' in i]
l=[list(i) for i in zip(*l)]

for i in l:
  print(''.join(i))

Measured memory_bytes: 3188
S = input()
N = len(S)

if len(set(S))==1:
  print(N)
  exit()

K = (N+1)//2
X = set()
if N&1:
  X = {S[K-1]}
  l = K-2
  r = K
else:
  X = set()
  l = K-1
  r = K
  
while l:
  X.add(S[l])
  X.add(S[r])
  if len(X)>1: break
  K += 1
  l -= 1
  r += 1

print(K)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  ll ans = a[0] - 1;
  ll now = 2;
  for(int i=1;i<n;++i) {
    if(a[i] == now) {
      now++;
    } else {
      ans += (a[i] - 1) / now;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#coding: utf-8
import sys
N = int(input())
words = [input() for w in range(N)]

i = 0
if len(set(words)) != len(words):
    print("No")
    sys.exit()
else:
    while i < N-1:
        if words[i][-1] != words[i+1][0]:
            print("No")
            sys.exit()
        i += 1
    print("Yes")

Measured memory_bytes: 3060
N,Q = [int(i) for i in input().split()]
S=input()
lr = [[int(j)-1 for j in input().split()] for i in range(Q)]

imos = [0 for i in range(N)]
for i in range(N-1):
    if S[i]=='A' and S[i+1]=='C':
        imos[i]=1
for i in range(N-1):
    imos[i+1]+=imos[i]
for l,r in lr:
    res = imos[r]
    if l>0:
        res-=imos[l-1]
    if S[r]=='A' and r<N-1 and S[r+1]=='C':
        res-=1
    print(res)


Measured memory_bytes: 26088
#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>;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    int ans = p+q+r-max(p,max(q,r));
    cout << ans << endl;
    return 0;
}

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

using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<ll,ll> pll ;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define NP next_permutation
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------




















//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s ;
  cin >> s ;
  str u = s ;
  int n = SZ(s) ;
  
  if(s=="zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 <<endl ;
    return 0 ;
  }
  
  if(n<=25){
    vint cnt(26,0) ;
    REP(i,n){
      cnt[s[i]-'a']++ ;
    }
    cout << s  ;
    REP(i,26){
      if(cnt[i]==0){
        cout << (char)('a'+i) <<endl ;
        return 0 ;
      }
    }
  }
  
  
  do{
    REP(i,n){
      str t = s.substr(0,i) ;
      if(t>u){
        cout << t <<endl ;
        return 0 ;
      }
    }
  }while(NP(ALL(s))) ;
      
  
  return 0 ;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
const int mod = 1e9 + 7;
int main(void) {
    int n;
    cin >> n;

    ll ans = 1;

    rep (i, n) {
        ans *= (i + 1);
        ans %= mod;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def f(n):
    i = 0
    while (10**i <= n):
        i += 1
    i -= 1
    return 8 if n % 15 == 0 else 4 if n % 3 == 0 or n % 5 == 0 else i


def fizzbuzzlen(n):
    if n == 0:
        return 0
    i = 0
    ans = 0
    while (10**i <= n):
        start = 10**i
        end = min(10**(i+1)-1, n)
        numbase = (end-start+1)
        num3 = end//3-(start-1)//3
        num5 = end//5-(start-1)//5
        num15 = end//15-(start-1)//15
        numbase = numbase-num3-num5+num15
        ans += (i+1)*numbase+4*num3+4*num5  # +8*num15
        i += 1
    return ans


n = int(input())

# print("".join(["FizzBuzz" if i % 15 == 0 else "Buzz" if i % 5 ==
#              0 else "Fizz" if i % 3 == 0 else str(i) for i in range(1, n+20)])[n-1:n-1+20])


l = 0
r = 10**18+1
while (l+1 != r):
    med = (l+r)//2
    if (fizzbuzzlen(med) < n):
        l = med
    else:
        r = med
s = "".join(["0"if i == 0 else "FizzBuzz" if i % 15 == 0 else "Buzz" if i % 5 ==
             0 else "Fizz" if i % 3 == 0 else str(i) for i in range(l+1, l+21)])
print(s[n-fizzbuzzlen(l)-1:n-fizzbuzzlen(l)-1+20])



Measured memory_bytes: 5612
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int pid=0,pnum=0,rpid[NUM];LL costu[NUM],costv[NUM],cpid[NUM],que[NUM];
int judge(int a,int b){if(pnum<b||b==1)return 0;return cpid[que[a]]>cpid[que[b]]?1:0;}
void push(LL a,int n){int i=++pid,j=++pnum;rpid[i]=n,cpid[i]=a,que[j]=i;while(judge(j/2,j))que[j]=que[j/2],que[j/=2]=i;}
int pop(){int ans=rpid[que[1]],i=1,j;LL n=que[pnum--];que[1]=n;while(judge(i,j=i*2+judge(i*2,i*2+1)))que[i]=que[j],que[i=j]=n;return ans;}
void Dijkstra(int v,int e,int* a,int* b,int* l,int ver,LL* cost){int i,flag[NUM]={0},pre[e+1],last[e+1];FOR(i,1,v+1)cost[i]=LNF,last[i]=-1;cost[ver]=0;FOR(i,0,e)pre[i]=last[a[i]],last[a[i]]=i;while(flag[ver]==0){flag[ver]++;for(i=last[ver];i+1;i=pre[i])if(cost[b[i]]>cost[ver]+l[i]){cost[b[i]]=cost[ver]+l[i];push(cost[b[i]],b[i]);}while(flag[ver]&&pnum)ver=pop();}}

int main(){
  int N,u,v,i;
	LL ans=0;
  scanf("%d%d%d",&N,&u,&v);
	int A[2*N-2],B[2*N-2],l[2*N-2];
	FOR(i,0,N-1)scanf("%d%d",&A[i],&B[i]);
	FOR(i,0,N-1)A[N-1+i]=B[i],B[N-1+i]=A[i],l[i*2]=1,l[i*2+1]=1;
	Dijkstra(N,2*N-2,A,B,l,u,costu);
	Dijkstra(N,2*N-2,A,B,l,v,costv);
	ans=costv[u];
	FOR(i,1,N+1)if(costu[i]<costv[i])ans=MAX(ans,costv[i]);

	printf("%lld\n",ans-1);
	return 0;
}


Measured memory_bytes: 13184
X, N = map(int, input().split())
p = list(map(int, input().split()))

diff = {} #diff: num
for num in range(-101, 202):
    if num not in p:
        if abs(X-num) not in diff.keys():
            diff[abs(X-num)] = []
        diff[abs(X-num)].append(num)

diff = list(diff.items())
diff.sort()
ans = min(diff[0][1])
print(ans)


Measured memory_bytes: 61848
# At ABC 144 C (300)
import math

def f(n):
    min_ = float("inf")
    end = int(math.sqrt(n) + 1)
    for div in range(1, end + 1):
        if n % div == 0:
            r = n // div
            min_ = min(min_, (div - 1) + (r - 1))
    return min_

assert f(10) == 5
assert f(50) == 13
assert f(10000000019) == 10000000018

n = int(input())
ans = f(n)
print(ans)


Measured memory_bytes: 38640
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll dp[55][55][3600];
// dp[i][j][k] := i枚まで見てj枚使ってkが作れる個数

int main(void) {
	ll n, a;
	cin >> n >> a;
	ll x[n];
	rep (i, n) cin >> x[i];

	
	dp[0][0][0] = 1;
	rep (i, n) rep (j, n) rep (k, 2500) {
		dp[i + 1][j][k] += dp[i][j][k];
		dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
	}

	ll ans = 0;
	rrep (i, n) {
		ans += dp[n][i][i * a];
	}

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

Measured memory_bytes: 78464
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;
const int L = 47;
ll f(ll a)
{
    if (a < 0) return 0;
    a++;
    ll ret = 0;
    REP(i,0,L-1)
    {
        ll tmp = a/(1LL<<(i+1));
        ll cnt1 = tmp*(1LL<<i);
        ll d = a%(1LL<<(i+1)) - (1LL<<i);
        if (d > 0) cnt1 += d;
        if (cnt1&1) ret += (1LL<<i);
    }
    //cout << endl;
    return ret;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    ll a,b;
    cin >> a >> b;
    //cout << f(b) << endl;
    ll ans = f(b)^f(a-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N,b=0,s=0;
  scanf("%d",&N);
  int a[N];
  for (int i=0;i<N;i++){
    scanf("%d",&a[i]);
    if (a[i]>b){
      b=a[i];
    }
    s+=a[i];
  }
  s=s-(b/2.0);
  printf("%d",s);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int e[40][40],g[40][40];
signed main(){
  Int n,m;
  Int first=0;
  while(cin>>n>>m,n||m){
    if(exchange(first,1)) cout<<endl;
    memset(e,-1,sizeof(e));
    for(Int i=0;i<m;i++){
      Int a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      e[a][b]=e[b][a]=c;
    }
    
    Int l;
    cin>>l;
    vector<Int> xs(l),ys(l),ts(l);
    vector<string> ss(l);
    for(Int i=0;i<l;i++){
      cin>>xs[i]>>ys[i]>>ts[i]>>ss[i];
      xs[i]--;
      ys[i]--;
    }

    const Int INF = 1e15;
    for(Int i=0;i<40;i++)
      for(Int j=0;j<40;j++)
        g[i][j]=~e[i][j]?e[i][j]:INF;
    
    for(Int i=0;i<40;i++) g[i][i]=0;

    for(Int k=0;k<n;k++)
      for(Int i=0;i<n;i++)
        for(Int j=0;j<n;j++)
          chmin(g[i][j],g[i][k]+g[k][j]);

    using S = pair<Int, string>;    
    vector<S> ans;
    
    using T = tuple<Int, Int, Int, Int>;
    priority_queue<T, vector<T>, greater<T> > pq;
    for(Int i=0;i<l;i++) pq.emplace(ts[i],xs[i],ts[i],i);

    vector<Int> ws(n,0);
    while(!pq.empty()){
      T pt=pq.top();
      Int t,v,a,k;
      tie(t,v,a,k)=pt;
      if(t<ws[v]){
        pq.pop();
        pq.emplace(ws[v],v,a,k);
        continue;
      }
      
      vector<Int> idxs,arrs;
      while(!pq.empty()){
        T qt=pq.top();
        Int tt,vv,aa,idx;
        tie(tt,vv,aa,idx)=qt;
        if(t!=tt||v!=vv) break;
        pq.pop();
        idxs.emplace_back(idx);
        arrs.emplace_back(aa);
      }
      ws[v]=t;
      
      Int arr=arrs[0];
      vector<Int> nxts(idxs.size());
      for(Int i=0;i<(Int)idxs.size();i++){
        chmin(arr,arrs[i]);
        Int y=ys[idxs[i]];
        Int u=-1;
        for(Int j=0;j<n;j++){
          if(e[v][j]<0) continue;
          if(e[v][j]+g[j][y]==g[v][y]){
            u=j;
            break;
          }
        }
        nxts[i]=u;
      }
      
      Int nxt=n;
      for(Int i=0;i<(Int)idxs.size();i++)
        if(arrs[i]==arr) chmin(nxt,nxts[i]);

      ws[v]+=e[v][nxt]*2;
      for(Int i=0;i<(Int)idxs.size();i++){
        if(nxts[i]==nxt){
          if(ys[idxs[i]]==nxt){
            ans.emplace_back(t+e[v][nxt],ss[idxs[i]]);
          }else{
            pq.emplace(t+e[v][nxt],nxt,t+e[v][nxt],idxs[i]);
          }
        }else{
          pq.emplace(ws[v],v,arrs[i],idxs[i]);
        }
      }
    }
    
    sort(ans.begin(),ans.end());
    for(auto p:ans) cout<<p.second<<" "<<p.first<<endl;
  }
  return 0;
}



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

int time(int a1,int a2,int a3,int a4,int a5)
{
	int res = 0;
	res = a1;
	for(;res % 10 != 0;res++)
	{}
	res += a2;
	for(;res % 10 != 0;res++)
	{}
	res += a3;
	for(;res % 10 != 0;res++)
	{}
	res += a4;
	for(;res % 10 != 0;res++)
	{}
	res += a5;
	return res;
}

int min(int arr[])
{
	int x = arr[0];
	for(int i = 0;i < 120;i++)
		if(x > arr[i])
			x = arr[i];
	return x;
}

int main()
{
	int a[6];
	for(int i = 1;i <= 5;i++)
		cin >> a[i];
	int res[120],r = 0;
	for(int i = 1;i <= 5;i++)
	{
		for(int j = 1;j <= 5;j++)
		{
			if(j == i)
				continue;
			for(int k = 1;k <= 5;k++)
			{
				if(k == i || k == j)
					continue;
				for(int l = 1;l <= 5;l++)
				{
					if(l == i || l == j || l == k)
						continue;
					for(int m = 1;m <= 5;m++)
					{
						if(m == i || m == j || m == k || m == l)
							continue;
						res[r++] = time(a[i],a[j],a[k],a[l],a[m]);
					}
				}
			}
		}
	}
	cout << min(res) << endl;
	return 0;
}


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

using namespace std;

int main(void)
{
    vector<string> titles(3);
    for (auto & in : titles) {
        cin >> in;
    }

    for (auto out : titles) {
        cout << out[0];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
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;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void Eratosthenes(ll n,Array& arr) {

}

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

	ll x;
	cin>>x;
	ll n=1e5+10;

	Array arr(1e5+10+1,1);

	for (ll i = 2; i * i <= n; i++) {
  		if (arr[i]) {
   			for (ll j = 2; i * j < n; j++) {
    			arr[i * j] = 0;
   			}
  		}
 	}

	 for(ll i=x;i<n;i++){
		 if(arr[i]){
			 cout<<i<<endl;
			 return 0;
		 }
	 }

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b;
    std::cin>>a>>b;

    std::vector<int> v;
    for(int i = a; i<= b;i++){
        v.push_back(i);
    }
    int cnt = std::count_if(v.begin(), v.end(),
            [](int n) -> bool {
                int k = n;
                int res = 0;
                while(k > 0){
                    res = res * 10 + k % 10;
                    k /= 10;
                }
                return n == res;
            });
    std::cout<<cnt<<std::endl;
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <numeric>
#include <algorithm>

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

const int INF = 1001001001;

int main()
{

    int n, m;
    cin >> n;
    cin >> m;
    vector<pair<int, int>> key;

    REP(i, m)
    {
        int a, b;
        cin >> a;
        cin >> b;
        int s = 0;
        REP(j, b)
        {
            int c;
            cin >> c;
            --c;
            s |= 1 << c;
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1 << n, INF);
    //dp[][]
    dp[0] = 0;
    REP(s, 1 << n)
    {
        REP(i, m)
        {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if (ans == INF)
        ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

const int MAX_S = (1 << 16) + 10;

int nbit(LL S, int i){
    if((S >> i) & 1) return 1;
    else return 0;
}

LL dp[MAX_S];
int N;

vector<vector<LL>> a;

LL rec(LL S){
    if(dp[S] != -LINF) return dp[S];

    LL temp = 0;
    REP(i,N) FOR(j,i+1,N) if(nbit(S,i) && nbit(S,j)) temp += a[i][j];
    for(LL T = (S-1) & S; T > 0; T = (T-1)&S){
        chmax(temp,rec(T)+rec(S^T));
    }
    return dp[S] = temp;
}

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

    cin >> N;
    a = vector<vector<LL>>(N,VL(N));
    REP(i,N){
        REP(j,N) cin >> a[i][j];
    }
    REP(i,MAX_S) dp[i] = -LINF;

    cout << rec((1 << N)-1) << endl;

}


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

A = []
B = []

for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ret = 0
for a, b in zip(A[::-1], B[::-1]):
    k = (a + ret)
    if k % b:
        ret += b - k % b

print(ret)


Measured memory_bytes: 12588
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
acac
acm

output:
2
"""

import sys


def solve():
    dp = [[0] * (len_w2 + 1) for _ in range(len_w1 + 1)]

    for i in range(len_w1 + 1):
        for j in range(len_w2 + 1):
            if not i:
                dp[i][j] = j
            elif not j:
                dp[i][j] = i

            elif w1[i - 1] == w2[j - 1]:
                dp[i][j] = dp[i - 1][j - 1]

            else:
                dp[i][j] = min(dp[i][j - 1], dp[i - 1][j], dp[i - 1][j - 1]) + 1

    return dp[-1][-1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    w1, w2 = _input
    len_w1, len_w2 = len(w1), len(w2)
    print(solve())

Measured memory_bytes: 43840
### main

loop do
  n = gets.strip.to_i
  break if n == 0

  tbl = {}
  n.times do
    c0, c1 = gets.strip.split(' ')
    tbl[c0] = c1
  end

  m = gets.strip.to_i

  input = ''
  output = ''

  m.times do
    c0 = gets.strip
    c1 = tbl[c0]

    input += c0
    output += c1.nil? ? c0 : c1
  end

  #puts "#{input} -> #{output}"
  puts output
end

Measured memory_bytes: 14260
import java.util.*;
public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    long x = sc.nextLong();
    sc.close();

    for (long a = 0; a < 1000; a++) {

      long b5 = (long)Math.pow(a, 5) - x;
      if (b5 == 0) {
        System.out.println(a + " " + b5);
        return;
      }
      for (long b = 1; b < 1000; b++) {
        if (Math.abs(b5) % b == 0 && Math.pow(b,5) == Math.abs(b5)) {
          if (b5 > 0) {
            System.out.println(a + " " + b);
          } else {
            System.out.println(a + " " + (b * -1));
          }
          return;
        }
      }


    }

    /*
    for (long a = 0; a < 100000; a++) {
      for (long b = 0; b < 100000; b++) {
        if (Math.pow(a, 5) - Math.pow(b, 5) == x) {
          System.out.println(a + " " + b);
          sc.close();
          return;
        } else if (Math.pow(a * -1, 5) - Math.pow(b, 5) == x) {
          System.out.println((a * -1) + " " + b);
          sc.close();
          return;
        } else if (Math.pow(a * -1, 5) - Math.pow(b * -1, 5) == x) {
          System.out.println((a * -1) + " " + (b * -1));
          sc.close();
          return;
        } else if (Math.pow(a, 5) - Math.pow(b * -1, 5) == x) {
          System.out.println(a + " " + (b * -1));
          sc.close();
          return;
        }
      }
    }
    */

    sc.close();

  }
}

Measured memory_bytes: 39028
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005;
int n;
ll a[N],b[N];
ll solve()
{
  int ind=1;
  repv(i,0,60)
    {
      int mxind=ind;
      ll mx=-1;
      rep(j,ind,n+1)
	{
	  if(((a[j]>>i)&1) && a[j]>mx)
	    mxind=j,mx=a[j];
	}
      if(mx==-1) continue;
      swap(a[mxind],a[ind]);
      mxind=ind;
      rep(j,1,n+1)
	{
	  if(j!=mxind && ((a[j]>>i)&1) )
	    a[j]=(a[j]^a[mxind]);
	}
      ind++;
    }
  ll ans=0;
  rep(i,1,n+1) ans^=a[i];
  return ans;
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  cin>>n;
  ll tot=0;
  rep(i,1,n+1) cin>>a[i],b[i]=a[i],tot^=a[i];
  rep(j,0,60)
    {
      if(!((tot>>j)&1) ) continue;
      rep(i,1,n+1)
	{
	  if((a[i]>>j)&1) a[i]-=((ll)1<<j);
	}
    }
  ll best=solve();
  cout<<best+(tot^best)<<endl;
  return 0 ;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**7)

def dfs(x):
  if x in memo:
    return memo[x]
  ret=0
  for y in g[x]:
    ret=max(ret,dfs(y)+1)
  memo[x]=ret
  return ret

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
memo={}
for i in range(1,n+1):
  dfs(i)
print(max(memo.values()))

Measured memory_bytes: 68452