akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    string s, _, __;
    cin >> _ >> s >> __;

    cout << "A" << s[0] << "C" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, M;
    cin >> N >> M;
    vector<int64_t> dp(N + 1, 0);
    vector<int> br(N + 1, 0);
    for(int i = 0; i < M; i++) {
        int a;
        cin >> a;
        br[a] = 1;
    }
    dp[0] = 1;
    for(int i = 1; i <= N; i++) {
        if(br[i]) continue;
        dp[i] += dp[i - 1];
        if(i >= 2) {
            dp[i] += dp[i - 2];
        }
        dp[i] %= MOD;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;
const int N=200005;
void getint(int&num){
    char c;bool flag=0;num=0;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=1;
    while(c>='0'&&c<='9'){num=num*10+c-48;c=getchar();}
    if(flag) num=-num;
}
int n,cnt[50][50];char str[25];ll ans;
int main(){
	getint(n);
	for(int i=1;i<=n;i++){
		scanf("%s",str);
		int m=strlen(str),p=0;
		ll x=0ll;
		for(int j=0;j<m;j++){
			if(str[j]=='.') p=m-j-1;
			else x=x*10+str[j]-'0';
		}
		for(int j=p+1;j<=9;j++)
			x*=10;
		
		//cout<<x<<endl;
		ll y=x;
		int two=0,five=0;
		while(y%2==0)
			two++,y>>=1;
		while(y%5==0)
			five++,y/=5;
		
		for(int i=0;i<=18;i++)
			for(int j=0;j<=18;j++)
				if(min(two+i,five+j)>=18)
					ans+=cnt[i][j];
		cnt[min(two,18)][min(five,18)]++;
	}
	cout<<ans<<endl;
}
/*

*/


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

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

// If I need to find (x / a) % b, I need to use this function:
//    (x / a) % b = (x * inv(a, b)) % b
ll inv(ll a, ll b) {
  if (a != 1) {
    return b - (inv(b % a, a) * b) / a;
  }
  return 1;
}

inline int Pow(int a, int k) {
  int s = 1; 
  for(; k; k >>= 1) {
    k & 1 ? s = 1LL * s * a % MOD : 0;
    a = 1LL * a * a % MOD;
  }
  return s;
}

// Init variables here
const int N = 1e6 + 7;

void input() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);
}

void output() {

}

void preprocess() {

}

void debug() {
  if (true) {

  }
}

int pre[N]; // pre[i] = number of '.' in prefix ending at i
int suf[N]; // suf[i] = number of '#' in suffix begining at i

void solve() {
  preprocess();
  int n; string s;
  cin >> n >> s;
  pre[0] = 0;
  FOR(i, 0, n) {
    pre[i + 1] = pre[i] + (s[i] == '.' ? 1 : 0);
  }
  suf[n] = 0;
  FORD(i, n - 1, 0) {
    suf[i] = suf[i + 1] + (s[i] == '#' ? 1 : 0);
  }
  int res = INF64;
  FORE(i, 0, n) {
    //cerr << pre[i] << ' ' << suf[i] << endl;
    res = min(res, n - pre[i] - suf[i]);
  }
  cout << res << endl;
  //debug();
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

#undef int
int main() {
#define int long long
  ios_base::sync_with_stdio(false);
  cin.tie();
  //auto beginProgram = chrono::steady_clock::now();

  //int t; cin >> t;
  //while (t--) 
  {
    input();
    solve();
    output();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}



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

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

  vector<int> d(N);
  rep(i, 0, N) {
    cin >> d.at(i);
  }

  sort(d.begin(), d.end(), greater<int>());

  int Ans = 1;
  rep(i, 0, N-1) {
    if (d.at(i) > d.at(i+1)) {
      Ans++;
    }
  }

  cout << Ans << endl;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    lint n; cin >> n;
    lint V = 0, E = 0;
    repn(i, n){
        V += i * (n-i+1);
    }
    rep(i, n-1){
        lint u,v; cin>>u>>v;
        if(u>v) swap(u,v);
        E += u * (n-v+1);
    }
    out(V-E);
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
llint mod = 1000000007;

int main() {
  string s;
  cin >> s;
  if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
} 

Measured memory_bytes: 3564
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(string.Join("", s.Where((_, c) => c % n == 0)));
    }
}

Measured memory_bytes: 11220
n = int(input())
x = []
y = []
h = []
for i in range(n):
    lis = list(map(int,input().split()))
    x.append(lis[0])
    y.append(lis[1])
    h.append(lis[2])
    if lis[2] != 0:
        index = i
for cx in range(101):
    for cy in range(101):
        height = abs(x[index]-cx) + abs(y[index] - cy) + h[index]
        flag = True
        for j in range(n):
            if h[j] != max(height - abs(x[j]-cx) - abs(y[j] - cy), 0):
                flag = False
                break
        if flag == True:
            ans = [cx,cy,height]
print(*ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 1e5 + 11;
int n, m;
int fa[N], id[N];
LL a[N], b[N], c[N], sum[N], f[N];
bool vis[N];
vector<int> to[N], son;
int find(int x){
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}
bool cmp(int x, int y){
	return c[x] < c[y];
}
int main(){
	cin>>n>>m;
	for(int i = 1;i <= n; i++){
		scanf("%lld%lld", &a[i], &b[i]);
		c[i] = max(0ll, a[i] - b[i]);
	}
	int u, v;
	for(int i = 1;i <= m; i++){
		scanf("%d%d", &u, &v);
		to[u].push_back(v);
		to[v].push_back(u);
	}
	for(int i = 1;i <= n; i++){
		fa[i] = i, id[i] = i;
	}
	sort(id + 1, id + 1 + n, cmp);
	for(int i = 1;i <= n; i++){
		int u = id[i];
		int sz = to[u].size();
		sum[u] = b[u];
		vis[u] = 1;
		son.clear();
 		for(int j = 0;j < sz; j++){
			int v = to[u][j];
			int fu = find(u), fv = find(v);
			if(fu == fv || !vis[v])continue;
			sum[u] += sum[fv];
			fa[fv] = fu;
			son.push_back(fv);
		}
		f[u] = c[u] + sum[u];
		sz = son.size();
		for(int j = 0;j < sz; j++){
			int v = son[j];
			f[u] = min(f[u], sum[u] - sum[v] + max(c[u], f[v]));
		}
	}
	cout<<f[id[n]]<<endl;
	return 0;
}


Measured memory_bytes: 11132
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
//public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

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

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  vector<int> graph[n+1];
  int a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int ans[n+1];
  vector<int> block[n+1];
  for (int i=0;i<k;i++){
    cin >> a >> b;
    block[a].push_back(b);
    block[b].push_back(a);
  }

  int group[n+1];
  int gNum = 1;
  for(int i=1;i<n+1;i++) group[i] = 0;
  for(int i=1;i<n+1;i++){
    if(group[i] != 0) continue;
    queue<int> q;
    q.push(i);
    while(!q.empty()){
      int now = q.front();
      q.pop();
      group[now] = gNum;
      for(int j=0;j<graph[now].size();j++){
        int temp = graph[now][j];
        if(group[temp] != 0) continue;
        q.push(temp);
      }
    }
    gNum++;
  }
  int convert2count[gNum];
  for(int i=1;i<gNum;i++) convert2count[i] = 0;
  for(int i=1;i<n+1;i++){
    convert2count[group[i]]++;
  }
  for(int i=1;i<n+1;i++){
    ans[i] = convert2count[group[i]] - graph[i].size()-1;
    for(int j=0;j<block[i].size();j++){
      int temp = block[i][j];
      if(group[i] == group[temp]) ans[i]--;
    }
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;

}


Measured memory_bytes: 13048
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int n;
	vector<int> v;	
	cin >> n;
	int sub;
	rep(i,n){
		cin >> sub;
		v.push_back(sub);
	}
	int k;
	for(int i=n-1;i>=0;i-=2){
		if(i!=n-1) cout << " ";
		cout << v[i];
	}
	if (n%2) k = 1;
	else k = 0;
	for(int i=k;i<n;i+=2){
		cout << " " << v[i];
	}

	cout << endl;
	return 0;
}


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

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

int lcm(int a, int b) {
	if (a > b) return lcm(b, a);
	return a / gcd(a, b) * b;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int T[N];
	rep(i, N) cin >> T[i];
	if (N == 1) {
		cout << T[0] << endl;
		return 0;
	}
	int L = lcm(T[0], T[1]);
	rep(i, N - 2) {
		L = lcm(L, T[i + 2]);
	}
	cout << L << endl;

    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 N 100005
#define INF 1000000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 998244353;
int main(){
    ll n;
    cin>>n;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    bool f=false;
    REP(i,n){
        if(-d*i+c*(n-1-i)<=(b-a)&&(b-a)<=d*(n-1-i)-c*i){
            f=true;
            break;
        }
    }
    if(f)OUT("YES");
    else OUT("NO");
    return 0;
}

Measured memory_bytes: 3664
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int mod=998244353;
string str;
map <string,int> f;
map <string,int> g;

int F(string s);
int G(string s) {
	if(g.find(s)!=g.end()) return g[s];
	if(s.size()==1) return g[s]=s[0]-'0'+1;
	for(int i=1;i<(int)s.size();++i) if(!(s.size()%i)) {
		string t;
		for(int j=0;j<i;++j) {
			bool flag=true;
			for(int k=0;k<(int)s.size()/i;++k) if(s[i*k+j]=='0') flag=false;
			t+=(char)(flag+'0');
		}
		g[s]=(g[s]+F(t))%mod;
	}
	return g[s];
}
int F(string s) {
	if(f.find(s)!=f.end()) return f[s];
	for(int i=1;i<=(int)s.size();++i)
		f[s]=(f[s]+1ll*F(s.substr(0,s.size()-i))*G(s.substr(s.size()-i,s.size()))%mod)%mod;
	return f[s];
}

int main() {
	cin>>str,f[""]=1,cout<<F(str)<<endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s, t;
  cin >> s >> t;
  ll ans = INF;
  int sl = s.size();
  int tl = t.size();
  rep(i, sl - tl + 1) {
    ll cnt = 0;
    rep(j, tl) if (s[i + j] != t[j]) cnt++;
    ans = min(ans, cnt);
  }

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


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int a[105];
void judge(int *a, int n)
{
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        if((a[i] % 2)==1) continue;
        if(a[i] % 3 && a[i] % 5 )
        {
            printf("DENIED\n");
            return ;
        }
    }
    printf("APPROVED\n");
}
int main()
{
    int n;
    scanf("%d", &n);
    judge(a, n);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

int main()
{
	char s[100002];
	int bw [2][2] = {0,0};
	scanf("%s",s);

	int i = 0;
	while(s[i]){
		i++;
	}
	int length = i;
	for(int i = 0;i < length;i++){
		bw[i % 2][s[i] - 48] += 1;
	}
	if ((bw[0][1] + bw[1][0]) < (bw[0][0] + bw[1][1])){
		printf("%d",bw[0][1] + bw[1][0]);
	}else{
		printf("%d",bw[0][0] + bw[1][1]);
	}
}

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

using namespace std;

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

    int i = 0;
    int ans = 0;
    int tmp = 0;

    while (i < N) {
        int H;
        cin >> H;

        if(H >= tmp) {
            ans++;
            tmp = H;
        }
        i++;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second

const int maxn = 112345;

vector<int> G[maxn];
int deg[maxn], n, m, par[maxn];

int main() {
    scanf("%d%d", &n, &m);
    FOR(i, 1, n + m - 1) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].eb(v);
        deg[v]++;
    }
    queue<int> q;
    FOR(i, 1, n) if (!deg[i]) q.push(i);
    assert(q.size() == 1);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int v : G[u]) {
            deg[v]--;
            if (!deg[v]) {
                par[v] = u;
                q.push(v);
            }
        }
    }
    FOR(i, 1, n) printf("%d\n", par[i]);
}

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

#define MAX 101
int main(){
  
  int color[MAX];
  int i;
  for(i=0;i<MAX;i++){
    color[i]=0;
  }
  int a,b,c;
  cin >> a>>b>>c;
  color[a]++;
  color[b]++;
  color[c]++;
  int sum=0;
  for(i=0;i<MAX;i++){
    if(color[i]){
      sum++;
    }
  }

  cout<<sum<<endl;
  return 0;
  
}


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

using namespace std;
#define set_precision(ans,l) cout << fixed << setprecision(l)<<ans;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<ll>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(), greater<ll>())
#define init(a)  memset((a),0,sizeof(a))
#define pi pair<int,int>
#define pb push_back
#define pl pair<ll,ll>
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
long double EPS = 1e-9;

/*struct comp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};*/

ll cel(ll a,ll b){return((a-1)/b+1);} 
ll gcd(ll a, ll b){
    if (a < b)swap(a, b);
    return (b == 0)? a: gcd(b, a % b);
}
ll MIN(ll a,int b){ll ans;(a>=b)?ans=b:ans=a;return ans;}
ll MAX(ll a,int b){ll ans;(a>=b)?ans=a:ans=b;return ans;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll po(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1){ans=(ans*x)%mod;}
        y>>=1;x=(x*x)%mod;
    }
    return ans;
}

int main()
{
    FIO;
    ll n,t,x,y,m=10,k;
    cin>>n;
    if(n<2)cout<<0;
    else if(n==2)cout<<2;
    else {
        ll ans=0;
        rep(i,0,n){
            ans=(ans+(po(m-2,i)*po(m-1,n-i-1))%mod)%mod;
        }
        ans=(ans+ans)%mod;
        ll r=po(m,n)-po(m-2,n)-ans;
        r=(r)%mod;
        r=(mod+r)%mod;
        cout<<r;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iomanip>
using namespace std;
long long n,m,i,j,a,b,c,d;
int main()
{
	cin>>n>>a>>b>>c>>d;
	n--;
	d-=c;
	for (i=0;i<=n;i++)
	{
		j=n-i;
		if (b-a>=-d*j+i*c-j*c&&b-a<=d*i+i*c-j*c)
		{
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
L = list(map(int, input().split()))
import itertools as it
L=[0]+list(map(lambda x : x % M,it.accumulate(L)))
S=sorted(L)
#print(S)
tmp = -1
ans = 0
cnt=0
def nC2(n):
    return int(n*(n-1)/2)
for i in range(len(S)):
    
    if tmp == S[i]:
        cnt += 1
        if len(S)-1 == i:
            ans += nC2(cnt+1)
    else:
        ans += nC2(cnt+1)
        cnt = 0
    tmp = S[i]

print(ans)

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <climits>
using namespace std;

typedef vector<int>			vi;
typedef vector<vi>			vvi;
typedef vector<vvi>			vvvi;
typedef long long int 		ll;
typedef vector<ll>			vll;
typedef vector<vll>			vvll;
typedef vector<vvll>		vvvll;

typedef pair<int, int>		ii;
typedef vector<ii>			vii;
typedef set<int> 			si;


int main(){

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int a, b;
	cin >> a >> b;


	if(6 <= a && a <= 12)
		b /= 2;
	else if(a < 6)
		b = 0;

	cout << b;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.StringTokenizer;

/**
 * Packet Transportation
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			byte n = Byte.parseByte(line);

			// router info
			Router.setCount(n);
			for (int i = 0; i < n; i++) {
				StringTokenizer st = new StringTokenizer(br.readLine());
				byte id, next;
				id = Byte.parseByte(st.nextToken());
				next = Byte.parseByte(st.nextToken());
				Router.setRouter(id);
				for (int j = 0; j < next; j++) {
					Router.getRouter(id)
							.addNext(Byte.parseByte(st.nextToken()));
				}
			}

			// packet info
			int p = Integer.parseInt(br.readLine());
			for (int i = 0; i < p; i++) {
				byte src, dst;
				int ttl, hop;
				int d1, d2;
				line = br.readLine();
				d1 = line.indexOf(' ');
				d2 = line.indexOf(' ', d1 + 1);
				src = Byte.parseByte(line.substring(0, d1));
				dst = Byte.parseByte(line.substring(d1 + 1, d2));
				ttl = Integer.parseInt(line.substring(d2 + 1));
				hop = Router.getHops(src, dst, ttl);
				if (hop > 0) {
					System.out.println(hop);
				} else {
					System.out.println("NA");
				}
			}
		}
	}
}

class Router {

	byte id;
	ArrayList<Byte> nexts;

	private static Router[] routers;

	static Router[] setCount(byte n) {
		if (routers == null) {
			routers = new Router[n + 1];
		}
		return routers;
	}

	static void setRouter(byte id) {
		Router r = new Router(id);
		routers[r.id] = r;
	}

	static Router getRouter(byte id) {
		return routers[id];
	}

	static int getHops(byte src, byte dst, int ttl) {

		Deque<Router.Hop> deque = new ArrayDeque<Router.Hop>();
		boolean[] passed = new boolean[routers.length];
		int hop = 0;

		Router r = getRouter(src);
		deque.offer(r.new Hop(r, ttl - 1));
		passed[r.id] = true;
		while (!deque.isEmpty()) {
			Hop h = deque.poll();
			if (h.router.id == dst) {
				hop = ttl - h.ttl;
				break;
			} else if (h.ttl > 0) {
				if (h.router.nexts.size() != 0) {
					for (Byte i : h.router.nexts) {
						if (!passed[i]) {
							r = getRouter(i);
							deque.offer(r.new Hop(r, h.ttl - 1));
							passed[i] = true;
						}
					}
				}
			}
		}
		return hop;
	}

	//
	private Router(byte id) {
		this.id = id;
		nexts = new ArrayList<Byte>();
	}

	public void addNext(byte id) {
		nexts.add(id);
	}

	private class Hop {
		Router router;
		int ttl;

		public Hop(Router router, int ttl) {
			this.router = router;
			this.ttl = ttl;
		}
	}

}

Measured memory_bytes: 23596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

ll F(ll a) {
    if(a <= 9) return 1;
    return F(a / 10) + 1;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 1e9;
    for(ll i = 1; i * i <= N; i++) {
        if(N % i != 0) continue;
        chmin(ans, max(F(i), F(N / i)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int A, P; cin >> A >> P;
	cout << (3 * A + P) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),x=s.nextInt();

		int p=0;
		int r=1;
		for(int i=0;i<n;++i) {
			p+=s.nextInt();
			if(p<=x)
				++r;
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 22612
s = input()
t = input()
ds = {}
dt = {}
for i in range(len(s)):
  if s[i] in ds:
    if ds[s[i]] == t[i]:
      pass
    else:
      print('No')
      exit()
  else:
    ds[s[i]] = t[i]
    
  if t[i] in dt:
    if dt[t[i]] == s[i]:
      pass
    else:
      print('No')
      exit()
  else:
    dt[t[i]] = s[i]
    
print('Yes')

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>

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

    std::vector<long long> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

    std::sort(a.begin(), a.end(), std::greater<long long>());
    
    std::map<long long, long long> map;
    for(int i = 1; i < n; ++i){
        map.insert(std::make_pair(std::abs(a.at(0) - a.at(i) * 2), a.at(i)));
    }

    std::cout << a.at(0) << " " << map.begin()->second << std::endl;

    return 0;
}

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

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

using namespace std;
using graph=vector<vector<int>>;

using matching=vector<pair<int,int>>;

int h,w;

vector<matching> M; // all matchings of rows

void dfs(int i,int mask,bool center,matching& tmp){
	if(mask==(1<<h)-1){
		M.emplace_back(tmp);
		return;
	}

	if(mask>>i&1) return dfs(i+1,mask,center,tmp);

	for(int j=i+1;j<h;j++) if((mask>>j&1)==0) {
		tmp.emplace_back(i,j);
		dfs(i+1,mask|1<<i|1<<j,center,tmp);
		tmp.pop_back();
	}
	if(h%2==1 && !center){
		tmp.emplace_back(i,i);
		dfs(i+1,mask|1<<i,true,tmp);
		tmp.pop_back();
	}
}

graph G;
int memo[1<<12][2];

bool dfs2(int u,int mask,bool center){
	int& res=memo[mask][center];
	if(res!=-1) return res;

	if(mask==(1<<w)-1) return res=true;
	if(u==w) return res=false;

	if(mask>>u&1) return res=dfs2(u+1,mask,center);

	for(int v:G[u]) if((mask>>v&1)==0) {
		if(u!=v){
			if(dfs2(u+1,mask|1<<u|1<<v,center)) return res=true;
		}
		else if(w%2==1 && !center){
			if(dfs2(u+1,mask|1<<u,true)) return res=true;
		}
	}
	return res=false;
}

int main(){
	char B[12][13];
	scanf("%d%d",&h,&w);
	rep(i,h) scanf("%s",B[i]);

	{
		matching tmp;
		dfs(0,0,false,tmp);
	}

	for(const auto& mat:M){
		G=graph(w);
		rep(u,w) for(int v=u;v<w;v++) {
			bool ok=true;
			rep(i,mat.size()){
				int r1,r2; tie(r1,r2)=mat[i];
				if(B[r1][u]!=B[r2][v] || B[r1][v]!=B[r2][u]){ ok=false; break; }
			}
			if(ok){
				G[u].emplace_back(v);
				if(u<v) G[v].emplace_back(u);
			}
		}

		memset(memo,-1,sizeof memo);
		if(dfs2(0,0,false)) return puts("YES"),0;
	}
	puts("NO");

	return 0;
}


Measured memory_bytes: 1212
temp=input().split()
N=int(temp[0])
M=int(temp[1])

index=[int(1) for i in range(N)]
for i in range(M):
  index[int(int(input())-1)]=0

temp=[0, 1]
for i in range(N):
  if index[i]==1:
    temp=[temp[1], temp[0]+temp[1]]
  else:
    temp=[temp[1], 0]
    
print(temp[1]%1000000007)

Measured memory_bytes: 45168
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)
#define cio ios::sync_with_stdio(false);

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int t = 0;
string num = "";
int l = 0;
int k;

void f(int n,int d,string str)
{
    if (d == l) {
        t ++;
        if (t == k) num += str + (char) (n + '0');
        return;
    }
    int s = (n == 0 ? 0 : n - 1);
    int e = (n == 9 ? n : n + 1);
    for (int i = s;i <= e;i ++)
    {
        if (t != k) f(i,d + 1,str + (char)(n + '0'));
    }
}

int main()
{
    
    scanf("%d",&k);
    
    while (t != k)
    {
        for (int i = 1;i < 10;i ++)
        {
            if (t == k) break;
            f(i,0,string());
        }
        l ++;
    }
    cout << num << endl;
    
    return 0;
}


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

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

using namespace std;

typedef long long ll;

struct Data {
  ll a,b;
  bool operator < ( const Data &data ) const {
    if( b != data.b ) return b > data.b;
    return a > data.a;
  }
};

#define MAX 300010

ll bit[2][MAX];

inline void add(ll a,ll w,const int type) {
  for(int x=a;x<MAX;x+=x&-x) bit[type][x] += w;
}

inline ll sum(ll a,const int type) {
  ll ret = 0;
  for(ll x=a;x>0;x-=x&-x) ret += bit[type][x];
  return ret;
}

inline bool check(int M,int v) {
  ll denominator = sum(M,0);
  ll numerator = sum(M,1);
  return ( numerator <= denominator * (ll)v );
}

bool comp(Data d1,Data d2) {
  if( d1.a != d2.a ) return d1.a < d2.a;
  return d1.b < d2.b;
}

typedef pair<ll,ll> ll2;
void compute(vector<Data> &vec,int n) {
  sort(vec.begin(),vec.end(),comp);
  map<ll2,int> toIndex;
  rep(i,n) toIndex[ll2(vec[i].a,vec[i].b)] = i+1;
  sort(vec.begin(),vec.end());
  ll maxi = 0;
  rep(i,n){
    ll v = vec[i].b;
    ll a = vec[i].a;
    assert(toIndex.count(ll2(a,v)));
    int ID = toIndex[ll2(a,v)];
    add(ID,1,0);
    add(ID,a,1);
    ll L = 1, R = n+1;
    while( R - L ) {
      ll M = ( L + R ) / 2LL;
      if( check(M,v) ) {
        L = M + 1LL;
        maxi = max(maxi,sum(M,0));
      } else {
        R = M;
      }
    }
  }
  cout << maxi << endl;
}

int main() {
  vector<Data> vec;
  int N,a,b;
  scanf("%d",&N);
  rep(i,N) {
    scanf("%d %d",&a,&b);
    vec.push_back((Data){(ll)a,(ll)b});
  }
  compute(vec,N);
  return 0;
}

Measured memory_bytes: 31240
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int q = scan.nextInt();
		Queue<Data> queue = new ArrayDeque<Data>();
		for(int i = 0; i < n; i++) {
			Data d = new Data(scan.next(), scan.nextInt());
			queue.add(d);
		}
		scan.close();
		StringBuilder sb = new StringBuilder();
		int time = 0;
		while(queue.size() != 0) {
			Data d = queue.poll();
			if(q >= d.getTime()) {
				time += d.getTime();
				if(queue.size() == 0) {
					sb.append(d.getName() + " " + time);
				}else {
					sb.append(d.getName() + " " + time + "\n");
				}

			}else {
				time += q;
				int res = d.getTime() - q;
				d.setTime(res);
				queue.add(d);
			}
		}
		System.out.println(sb.toString());
	}
}

class Data{
	String name;
	int time;
	public Data(String name, int time) {
		this.name = name;
		this.time = time;
	}
	public String getName() {
		return name;
	}
	public int getTime() {
		return time;
	}
	public void setTime(int time) {
		this.time = time;
	}
}



Measured memory_bytes: 73612
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	long long ans = 1, count = 0, A, MOD = 1000000007;
	vector<pair<long long, int> > V;
	cin >> N;
	for (int i = 0; i < N * 2; i++) {
		cin >> A;
		if (i < N) V.push_back({ A, 1 });
		else V.push_back({ A, -1 });
	}
	sort(V.begin(), V.end());
	for (auto it = V.begin(); it != V.end(); it++) {
		if ((count < 0 && it->second > 0) || (count > 0 && it->second < 0)) {
			ans *= abs(count);
			ans = ans % MOD;
		}
		count += it->second;
	}
	cout << ans;
}

Measured memory_bytes: 6384
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = Long.parseLong(sc.next());
    long B = Long.parseLong(sc.next());
    long K = Long.parseLong(sc.next());

    if (K >= A) {
      System.out.print(0 + " ");
      if (B > K - A) {
        System.out.println(B - (K - A));
      } else {
        System.out.println(0);
      }
    } else {
      System.out.println((A-K) + " " + B);
    }
  }
}

Measured memory_bytes: 21716
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut c = vec![];
    for _ in 0..n {
        let x: u64 = iter.next().unwrap().parse().unwrap();
        c.push(x);
    }

    let mut indices = std::collections::HashMap::new();
    for i in 0..n {
        indices.entry(c[i]).or_insert(vec![]).push(i);
    }

    let mut dp = vec![0;n+1];
    dp[0] = 1;
    for i in 0..n {
        let next_index = match indices.get(&c[i]) {
            None => None,
            Some(arr) => {
                let idx = arr.lower_bound(&i);
                if idx + 1 < arr.len() && arr[idx+1] != i+1 {
                    Some(arr[idx+1])
                } else {
                    None
                }
            }
        };
        if let Some(v) = next_index {
            dp[v] += dp[i];
            dp[v] %= M;
        }
        dp[i+1] += dp[i];
        dp[i+1] %= M;
    }
    println!("{}", dp[n]);
}

#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

#[doc = " https://qiita.com/hatoo@github/items/fa14ad36a1b568d14f3e"]
pub trait BinarySearch<T> {
    #[doc = " Return the position of the first element **greater than or equal to** element x"]
    fn lower_bound(&self, x: &T) -> usize;
    #[doc = " Return the position of the first element **greater than** element x"]
    fn upper_bound(&self, x: &T) -> usize;
}
#[doc = " sorted slice required"]
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                std::cmp::Ordering::Less => {
                    low = mid + 1;
                }
                _ => {
                    high = mid;
                }
            }
        }
        low
    }
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                std::cmp::Ordering::Greater => {
                    high = mid;
                }
                _ => {
                    low = mid + 1;
                }
            }
        }
        low
    }
}

Measured memory_bytes: 27312
N = int(input())
loopnum, _ = divmod(N,2)
min_count = 100000
ans = 100000

for num in range(1,loopnum+1):
    count = 0
    A = str(num)
    B = str(N-num)
    for i in range(len(str(A))):
        count += int(A[i])
    for j in range(len(str(B))):
        count += int(B[j])
    if min_count >= count:
#         print(A + B)
        min_count = count
        ans = count
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using edge = int;
using graph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const ll MAXN = 8020;

int main(){
  string s; cin >> s;
  int x,y; cin >> x >> y;

  vector<int> t;
  int cnt = 0;
//文字列を変形する
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'T'){
      if(cnt != 0) t.push_back(cnt);
      t.push_back(0);
      cnt = 0;
    }else{
      cnt++;
      if(i == s.size()-1) t.push_back(cnt);
    }
  }

  bool dp_x[MAXN][MAXN*2] = {false}, dp_y[MAXN][MAXN*2] = {false};
  dp_x[0][8000] = true;
  dp_y[0][8000] = true;

  bool flag = false;
  bool xy = true; // trueならx軸について見ている
  int cnt_x = 0,cnt_y = 0;
  int prev_x =0, prev_y =0;
  for(int i = 0; i < t.size(); i++){
    if(t[i] == 0){
      xy  = !xy;
    }else if(xy){
      cnt_x++;
      for(int j = 0; j < MAXN*2; j++){
        if(dp_x[cnt_x-1][j]){
          if(j+t[i] < MAXN*2) dp_x[cnt_x][j+t[i]] = true;
          if(j-t[i] >= 0 && flag) dp_x[cnt_x][j-t[i]] = true;
        }
      }
    }else if(!xy){
      cnt_y++;
      for(int j = 0; j < MAXN*2; j++){
        if(dp_y[cnt_y-1][j]){
          if(j+t[i] < MAXN*2) dp_y[cnt_y][j+t[i]] = true;
          if(j-t[i] >= 0) dp_y[cnt_y][j-t[i]] = true;
        }
      }
    }

    if(!flag) flag = true;
  }

  cout << ((dp_x[cnt_x][x+8000] && dp_y[cnt_y][y+8000]) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 251520
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<998244353>;

const int MX = 2000010;
mint f[MX+1],g[MX+1];
mint C(int x,int y){
	return f[x]*g[y]*g[x-y];
}
void precalc(){
	f[0] = 1;
	rep1(i,MX) f[i] = f[i-1]*i;
	g[0] = 1;
	rep1(i,MX) g[i] = g[i-1]/i;
}

int main(){
	precalc();
	int A,B;
	cin>>A>>B;
	if(A>B) swap(A,B);
	mint ans = mint(A+B)*C(A+B-1,A-1);
	rep1(i,A){
		mint tmp = C(2*i,i) * C(A+B-2*i,A-i) / 2;
		ans += tmp;
	}
	ans /= C(A+B,A);
	ans += B-A;
	cout<<ans<<endl;
}


Measured memory_bytes: 16000
#include <stdio.h>;

int main() {
	int A,B,C,i,j=0;
	scanf("%d%d%d",&A,&B,&C);
	for(i=0;i<100;i++){
		if(A*i%B==C){
			j=1;
		}
	}
	if(j==1){
		printf("YES");
	}
	else{
		printf("NO");
	}
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            Console.WriteLine(S.Count(x => x == '1'));
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n;
	cin>>n;
	int ans=0;
	FOR(i, 1, n+1){
		int m=i;
		int cnt=0;
		while(m>0){
			++cnt;
			m/=10;
		}
		if(cnt&1){
			++ans;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;

int main() {
    string str;
    cin >> str;
    
    int A[4];
    for(int i=0; i<4; i++) {
        A[i] = (int)str[i] - '0';
    }
    
    int tmp;
    int ans_bit=0;
    for(int bit=0; bit<(1<<3); bit++) {
        tmp=A[0];
        for(int f=0; f<3; f++) {
            if(bit & (1<<f)) {
                tmp += A[f+1];
            } else {
                tmp -= A[f+1];
            }
        }
        if(tmp==7) {
            ans_bit = bit;
            break;
        }
    }
    
    cout << A[0];
    for(int f=0; f<3; f++) {
        if(ans_bit & (1<<f)) {
            cout << '+' << A[f+1];
        } else {
            cout << '-' << A[f+1];
        }
    }
    
    cout << "=7" << endl;

    return 0;
    
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll n,k;
    cin >> n >> k;
    ll ans=0;
    ll v=1;
    while(v<=n){
        ans++;
        v*=k;
    }
    cout << ans << endl;
    return 0;
} 

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

#define all(x) begin(x), end(x)
#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)

using ll = long long;
using vi = vector<int>;

int main() {
	int n,vb;
	cin >> n;
	vi a(n),b(n),c(n);
	rep (i,n) cin>>a[i], b[i]= a[i]-i-1, c[i]=b[i];

	sort(all(b));
	vb = n&1 ? b[(n>>1)] : b[(n>>1)-1];

	ll r = 0;
	rep (i, n) r += abs(c[i]-vb);

	log(r);
	return 0;
}



Measured memory_bytes: 2560
A,B,C = (x for x in input().split())

list_A = list(A)
list_B = list(B)
list_C = list(C)

if list_A[len(list_A)-1] == list_B[0] and list_B[len(list_B)-1] == list_C[0]:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut a = 0;
    while a < n {
        a += 1000
    }
    put!(a - n);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 2124
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
    int n,a[200000],f;
    cin>>n;
    if(n%2==0)
        f=0;
    else
        f=1;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=n-1;i>=0;i-=2){
        cout<<a[i]<<" ";
    }
    for(int i=f;i<n;i+=2){
        cout<<a[i]<<" ";
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 2944