akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
    ll n, now=-1, ans=1, mo = 998244353, bf=1, ne=0;
    cin >> n;
    vector<ll> d(n);
    rep(i, n)cin >> d.at(i);
    if(d.at(0) != 0)ans=0;
    sort(all(d));
    rep(i, n){
        if(d.at(i) == now)ne++;
        else{
            if(now+1 != d.at(i)){
                ans = 0;
                break;        
            }
            else{
                now++;
                bf=ne;
                ne=1;
            }
        }
        if(i){
            ans *= bf;
            ans %= mo;
        }
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;


    vector<int> v[500000];
    int n, m;
    int ans = 0;
    int h[500000];
    int a[500000], b[500000];

int main(){

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i]; a[i]--,b[i]--;
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    for (int i = 0; i < n; i++) {
        int flag = 1;
        while (!v[i].empty()) {
            int from = v[i].back(); v[i].pop_back();
            if (h[i] <= h[from]) flag = 0; 
        }
        if (flag) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 18844
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b; cin >> a >> b;
  if(b%a==0){
      cout << a + b << endl;
  }else{
      cout << b-a << endl;
  }

}

Measured memory_bytes: 764
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N, M;
ll dp[MAX/10];
set<ll> s;
ll c[]={0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

void rec(ll n, ll len) {
    if(len==0) return;
    ll i;
    ll max=0;
    for(auto it=s.begin(); it!=s.end(); it++) {
        i=*it;
        if(n<c[i]) continue;
        if(dp[n-c[i]]==len-1) chmax(max, i);
    }
    cout << max;
    rec(n-c[max], len-1);
}

int main(void) {
    cin >> N >> M;
    ll i, j;
    
    for(i=0; i<M; i++) {
        ll a;
        cin >> a;
        s.insert(a);
    }
    
    memset(dp, -1, sizeof(dp));
    dp[0]=0;
    for(i=0; i<=N; i++) {
        if(dp[i]==-1) continue;
        for(auto it=s.begin(); it!=s.end(); it++) {
            j=*it;
            if(i+c[j]<=N) chmax(dp[i+c[j]], dp[i]+1);
        }
    }
    
    rec(N, dp[N]);
    cout << "\n";
}





Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll a[100000];

int main()
{
	int n;
	ll x;
	ll ans=0;
	
	cin>>n>>x;
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	for(int i=1;i<n;i++)
	{
		if(a[i]+a[i-1]>x)
		{
			ll temp;
			temp=max(0LL,x-a[i-1]);
			ans+=(a[i]-temp);
			a[i]=temp;
			if(a[i]+a[i-1]>x)
			{
				ans+=a[i]+a[i-1]-x;
				a[i-1]-=a[i]+a[i-1]-x;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){

    ll n,m;
    cin >> n >> m;

    vector<string> s(m);
    vector<int> p(m);
    
    vector<int> pe(n,0);

    set<int> ac;
    rep(i,m){
        cin >> p[i] >> s[i];
        if(ac.find(p[i])==ac.end()){
            if(s[i]=="AC"){
                ac.insert(p[i]);
            }else{
                pe[p[i]]++;
            }
        }
    }
    int ans=0;
    rep(i,n){
        if(ac.find(i+1)!=ac.end()){
            ans+=pe[i+1];
        }
    }
    cout << ac.size() << " " << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
constexpr long long int mod = 1000000007;


//M*X+R=Y

int main() {
	long long N, K;
	cin >> N >> K;
	long long ans=0,T=(N/K);
	//剰余が(0,0,0);
	if (T >= 1)ans += T*T*T;

	//剰余が(K/2,K/2,K/2);
	if (K % 2 == 0) {
		//cerr << "U";
		long long U = (N / K);
		if (N % K >= K / 2)U++;
		if (U >= 1)ans += U * U * U;
	}
	cout << ans;
}

Measured memory_bytes: 256
/**
 * @Date:   2018-07-17T14:21:30+08:00
 * @Last modified time: 2019-08-02T20:22:15+08:00
 */

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PL;
typedef pair<P, LL> PP;
typedef pair<P, LL> PP;
typedef long long LL;

#define xx first
#define yy second

int main()
{
  // #ifndef ONLINE_JUDGE
  //freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n,m;
  cin>>n>>m;
  set<int> si;
  for(int i=1;i<=m;i++)
    si.insert(i);
  vector<P> vp;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    vp.push_back({b,a});
  }
  sort(vp.begin(),vp.end());
  LL ans = 0;
  for(int i=n-1;i>=0;i--){
    auto it = si.lower_bound(vp[i].yy);
    if(it!=si.end()){
      ans += vp[i].xx;
      si.erase(it);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6140
import sys
input = lambda: sys.stdin.readline().rstrip()

div = [0] * 1000005

N = int(input())

A = list(map(int, input().split()))

for num in A:
    if div[num] == 0:
        for i in range(num, 1000004, num):
            div[i] += 1
    elif div[num] != 0:
        div[num] += 1        

ans = 0

for num in A:
    if div[num] == 1:
        ans += 1

print(ans)

Measured memory_bytes: 132712
import sys
N = int(input())
A = list(map(int, input().split()))

A.sort()

M = 0
for i in range(N):
    if i == 0:
        M -= A[i]
    elif i == N-1:
        M += A[i]
    else:
        M += abs(A[i])
print (M)

if N == 2:
    print (A[1], A[0])
    sys.exit()

for i in range(1,N-1):
    if A[i] >= 0:
        print (A[0], A[i])
        A[0] = A[0] - A[i]
    else:
        print (A[N-1], A[i])
        A[N-1] = A[N-1] - A[i]
print (A[N-1], A[0])

Measured memory_bytes: 14144
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    
    cin >> s;
    long i,j;
    long num;
    long dif=1000;
    long ans;
    for(i=0;i<s.size()-2;i++){
        string S;
        for(j=0;j<3;j++){
            S+=s.at(i+j);
        }
        num=atoi(S.c_str());
        //cout << i+1 <<"番目 " <<S <<" "<< num << endl;
        dif=min(dif,abs(753-num));
        if(dif==abs(753-num))ans=abs(753-num);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


#define MAXN 100001
typedef long long ll;
bool operator<(pair<int, int> const& a, pair<int, int> const& b) {
  return (a.first-a.second)<(b.first-b.second);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  vector<pair<int, int>> p;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    p.push_back({a, b});
  }
  sort(p.begin(), p.end());
  ll sm = 0;
  int mn = 1e9+1;
  for (int i = 0; i < n; ++i) {
    sm += p[i].first;
    if (p[i].first>p[i].second) mn = min(mn, p[i].second);
  }
  if (mn==1e9+1) cout << 0 << endl;
  else cout << sm-mn << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>


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; }

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;

using namespace std;
typedef long long ll;


int dh[] = { 1,0,-1,0 };
int dw[] = { 0,1,0,-1 };

vector<int> BFS01(int start, vector<vector<pair<int, int>>>& g) {
	vector<int> d(g.size(), inf);
	d[start] = 0;
	deque<int> dq; dq.emplace_back(start);
	while (!dq.empty()) {
		int cur = dq.front();
		dq.pop_front();
		for (auto nxt : g[cur]) {
			int to, cost; tie(to, cost) = nxt;
			if (chmin(d[to], d[cur] + cost)) {
				if (cost == 0) dq.emplace_front(to);
				else dq.emplace_back(to);
			}
		}
	}
	return d;
}

int main()
{

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

	int H, W; cin >> H >> W;
	int sh, sw; cin >> sh >> sw; sh--; sw--;
	int th, tw; cin >> th >> tw; th--; tw--;
	vector<string> vs(H); for (int i = 0; i < H; i++) cin >> vs[i];
	vector<vector<pair<int, int>>> g(H * W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (vs[i][j] == '#') continue;
			for (int k = 0; k < 4; k++) {
				int nh = i + dh[k];
				int nw = j + dw[k];
				if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue;
				if (vs[nh][nw] == '#') continue;
				g[i * W + j].emplace_back(nh * W + nw, 0);
			}
			for (int k = -2; k <= 2; k++) {
				for (int l = -2; l <= 2; l++) {
					int nh = i + k;
					int nw = j + l;
					if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue;
					if (vs[nh][nw] == '#') continue;
					g[i * W + j].emplace_back(nh * W + nw, 1);
				}
			}
		}
	}
	auto d = BFS01(sh * W + sw, g);
	int res = d[th * W + tw];
	if (res == inf) res = -1;
	cout << res << endl;
}

Measured memory_bytes: 120552
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    int n,x[100];

    int i,j;
    scanf("%d",&n);
    for (i = 0; i < n; i++)scanf("%d",&x[i]);

    qsort(x,n,sizeof(int),asc);

    long long ans = 1000000000,buf = 0;

    for (i = x[0]; i <= x[n - 1]; i++)
    {
        buf = 0;
        for (j = 0; j < n; j++)
        {
            buf += (x[j] - i) * (x[j] - i);
        }
        if(buf < ans)ans = buf;
    }

    printf("%lld",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
inline int read() {
    int f=1,sum=0;
    char x=getchar();
    for(;(x<'0'||x>'9');x=getchar()) if(x=='-') f=-1;
    for(;x>='0'&&x<='9';x=getchar()) sum=sum*10+x-'0';
    return f*sum;
}

#define M 55
int n;
int du[M];
bool vis[M],re[M];
int e_size,head[M],fa[M],pre[M];
struct node {
	int x,y;
	
	inline void in() {
		x=read(),y=read();
		if(x>y) swap(x,y);
	}
	inline bool operator <(const node &a) const {
		if(x!=a.x) return x<a.x;
		return y<a.y;
	}
}a[M],b[M];

struct edge {int v,nxt;}e[M*2];

inline void e_add(int u,int v) {
	e[++e_size]=(edge){v,head[u]};
	head[u]=e_size;
}

inline bool check() {
	for1(1,n-1,i) if(a[i].x!=b[i].x||a[i].y!=b[i].y) return 0;
	return 1;
}

inline void dfs1(int x,int *ha) {
	for(int i=head[x];i;i=e[i].nxt) {
		int v=e[i].v;
		if(v==ha[x]) continue;
		ha[v]=x,dfs1(v,ha);
	}
}

inline void dfs2(int x) {
	vis[x]=1;
	for(int i=head[x];i;i=e[i].nxt) {
		int v=e[i].v;
		if(v==pre[x]||fa[v]!=x) continue;
		dfs2(v);
	}
}

inline int calc_(int x,int y) {
	e_size=0;
	memset(re,0,sizeof(re));
	memset(du,0,sizeof(du));
	memset(vis,0,sizeof(vis));
	memset(pre,0,sizeof(pre));
	memset(head,0,sizeof(head));
	re[x]=1;
	++du[x],++du[y];
	e_add(x,y),e_add(y,x);
	for1(1,n-1,i) {
		int u=a[i].x;
		int v=a[i].y;
		if(u==x||v==x) continue;
		++du[u],++du[v];
		e_add(u,v),e_add(v,u);
	}
	dfs1(x,pre),dfs2(x);
	//for1(1,n,i) cout<<pre[i]<<" "; cout<<endl;
	int cnt=0,now=0;
	for1(1,n,i) now+=vis[i];
	cnt=now;
	while (now!=n) {
		int pos=0;
		for1(1,n,i) if(!vis[i]&&vis[fa[i]]&&!re[i]&&du[i]==1) {pos=i;break;}
		if(!pos) break;
		//cout<<pos<<" "<<pre[pos]<<endl;
		re[pos]=vis[pos]=1,++now;
		--du[pre[pos]],++du[fa[pos]];
	}
	return now==n?n-cnt+1:1e9;
}

int main () {
//	freopen("a.in","r",stdin);
	int Test_=read();
	while (Test_--) {
		n=read();
		for1(1,n-1,i) a[i].in();
		for1(1,n-1,i) b[i].in();
		sort(a+1,a+n),sort(b+1,b+n);
		
		if(check()) puts("0");
		else {
			int shu[M]={0};
			for1(1,n-1,i) ++shu[a[i].x],++shu[a[i].y];
			int ans=1e9;
			for1(1,n,i) if(shu[i]==1) {
				e_size=0;
				memset(fa,0,sizeof(fa));
				memset(head,0,sizeof(head));
				for1(1,n-1,j) e_add(b[j].x,b[j].y),e_add(b[j].y,b[j].x);
				dfs1(i,fa);
				for1(1,n,j) if(i!=j) {
					int num=calc_(i,j);
					ans=min(ans,num);
				}
			}
			if(ans==1e9) ans=-1;
			printf("%d\n",ans);
		}
	}
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "p", long, "dist");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    long iter = s.length;
    auto dream = "dream", dreamer = "dreamer";
    auto erase = "erase", eraser = "eraser";
    while (iter > 0)
    {
        if(s[max(0, iter - cast(long) dream.length) .. iter] == dream)
            iter -= dream.length;
        else if(s[max(0, iter - cast(long) dreamer.length) .. iter] == dreamer)
            iter -= dreamer.length;
        else if(s[max(0, iter - cast(long) erase.length) .. iter] == erase)
            iter -= erase.length;
        else if(s[max(0, iter - cast(long) eraser.length) .. iter] == eraser)
            iter -= eraser.length;
        else
            break;
    }
    if(iter)
        writeln("NO");
    else
        writeln("YES");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2556
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
    if(a>b){
        a = b; return true;
    }
    else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
    if(a<b){
        a = b; return true;
    }
    else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
    cout << a << " " << b << " " << c << "\n";
}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

struct sum2D{
    vector<vector<ll>> sum;
    ll n,m;
    
    sum2D(vector<vector<ll>> &a){
        n = a.size();
        m = a[0].size();
        sum.resize(n+1);
        rep(i,n+1) sum[i].resize(m+1,0);
        rep(i,n) rep(j,m) sum[i+1][j+1] = a[i][j];
        rep(i,n) rep(j,m+1) sum[i+1][j] += sum[i][j];
        rep(j,m) rep(i,n+1) sum[i][j+1] += sum[i][j];
    }

    ll get(int y1, int x1, int y2, int x2){
        if(y1 > y2 || x1 > x2) return 0;
        y1--; x1--;
        return sum[y2][x2] - sum[y2][x1] - sum[y1][x2] + sum[y1][x1];
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m,q; cin >> n >> m >> q;
    vs s(n); rep(i,n) cin >> s[i];
    vvl tmpv(n,vl(m));
    rep(i,n) rep(j,m) tmpv[i][j] = s[i][j] - '0';
    vvl tate(n,vl(m,0)), yoko(n,vl(m,0));
    rep(i,n) rep(j,m){
        if(i < n-1 && tmpv[i][j] == 1 && tmpv[i+1][j] == 1) tate[i][j] = 1;
        if(j < m-1 && tmpv[i][j] == 1 && tmpv[i][j+1] == 1) yoko[i][j] = 1;
    }
    sum2D v(tmpv), ne(tate), me(yoko);
    while(q--){
        int a,b,c,d; cin >> a >> b >> c >> d;
        int ans = v.get(a,b,c,d) - ne.get(a,b,c-1,d) - me.get(a,b,c,d-1);
        cout << ans << "\n";
    }
}

Measured memory_bytes: 195644
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back      
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define pw(x) (1ll<<(x))
#define buli(x) __builtin_popcountll(x)
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define M 1000000007
#define N 211111

#define TASK "1"

using namespace std;

int cnt[26];

int main(){
	#ifdef home
		freopen(TASK".in","r",stdin);	
		freopen(TASK".out","w",stdout);
	#endif		
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	long long ans = 1;
	for (int i = s.size() - 1; i >= 0; i--) {
		ans += s.size() - i - 1 - cnt[s[i] - 'a'];
		cnt[s[i] - 'a']++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int a_, a[n] = {0};
    for(int i = 0; i < m; ++i) {
        cin >> a_;
        a_--;
        a[a_] = 1;
    }
    int sum = 0, ans = 0;
    for(int i = x; i < n; ++i) ans += a[i];
    for(int i = x-2; i >= 0; --i) sum += a[i];
    cout << min(sum, ans) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int d;

	while(scanf("%d", &d)==1)
	{
		printf("Christmas");
		for(int i=25-d;i>0;i--)
		{
			printf(" Eve");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (a == b && b == c || a != b && b != c && a != c) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, x, y;
    cin >> n >> x >> y;
    ll m[n+1][n+1];
    if (x>y)
    {
    	x=x^y;
    	y=x^y;
    	x=x^y;
    }
    map<ll, ll> ans;
    // ans[1]+=2;
    for (int i = 1; i <=n ; ++i)
    {
    	for (int j = 1; j <=n; ++j)
    	{
    		m[i][j]=min((ll)abs(i-j),(ll)min(abs(y-i)+abs(j-x)+(ll)1, abs(y-j)+abs(i-x)+(ll)1));
    		// if (i<=x&&j>=y||i>=y&&j<=x)
    		// {
    		// 	m[i][j]-=abs(x-y);
    		// 	m[i][j]++;
    				
    		// }
    			ans[m[i][j]]++;	
    	}
    }
    for (int i = 1; i < n; ++i)
    {
    	cout << ans[i]/2 <<"\n";
    }
    return 0;
}

Measured memory_bytes: 31616
#include<stdio.h>

int main(){
  int h=0, m=0, s=0, h1=0, m1=0, s1=0, S=0;
  scanf("%d", &S);

  h = S/3600;
  h1 = h;
  m = (S - (h*3600))/60;
  m1 = m;
  s = S - (h*3600 + m*60);
  
  printf("%d:%d:%d\n", h1, m1, s);

  return 0;
}


Measured memory_bytes: 2104
/**
 * File    : E.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-5-26 21:42:14
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

class BIT
{ // index starts at 1.
public:
  int N;
  ll *data;

  BIT(int n) : N(n)
  {
    data = new ll[N + 1];
    for (auto i = 1; i <= N; ++i)
    {
      data[i] = 0;
    }
  }

  ~BIT()
  {
    delete[] data;
  }

  ll sum(int i)
  { // [1, i]
    ll s = 0;
    while (i > 0)
    {
      s += data[i];
      i -= i & -i;
    }
    return s;
  }

  ll sum(int a, int b)
  { // [a, b)
    return sum(b - 1) - sum(a - 1);
  }

  void add(int i, ll x)
  {
    while (i <= N)
    {
      data[i] += x;
      i += i & -i;
    }
  }

  void add(int i)
  {
    add(i, 1);
  }
};

typedef pair<int, int> P;

int N;
int K;
int Q;
int A[2010];
vector<P> V;
bool visited[2010];

int main()
{
  cin >> N >> K >> Q;
  for (auto i = 0; i < N; i++)
  {
    cin >> A[i];
    V.push_back(P(A[i], i));
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  int ans = 1000000007;
  fill(visited, visited + 2010, false);
  for (auto i = 0; i < N; i++)
  {
    int Y = V[i].first;
    // cerr << "Y = " << Y << endl;
    int k = V[i].second;
    visited[k] = true;
    int left[2010];
    int right[2010];
    int t = -1;
    for (auto j = 0; j < N; j++)
    {
      if (!visited[j])
      {
        t = j;
      }
      left[j] = t;
    }
    t = N;
    for (auto j = N; j >= 0; j--)
    {
      if (!visited[j])
      {
        t = j;
      }
      right[j] = t;
    }
    /*
    for (auto j = 0; j < N; j++)
    {
      cerr << j << " : " << left[j] << " " << right[j] << endl;
    }
    */
    BIT bit(N + 1);
    int cnt[2010];
    for (auto j = 0; j <= i; j++)
    {
      k = V[j].second;
      bit.add(k + 1);
      cnt[k] = bit.sum(left[k] + 2, right[k] + 1);
      // cerr << "cnt[" << k << "] = " << cnt[k] << endl;
    }
    int sel = 0;
    for (auto j = i; j >= 0; j--)
    {
      k = V[j].second;
      if (cnt[k] >= K)
      {
        sel++;
        if (sel == Q)
        {
          int X = V[j].first;
          ans = min(ans, X - Y);
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import copy
N = int(input())
X = [int(x) for x in input().split()]
Y = copy.copy(X)
X.sort()  #ソートした

for i in range(0,N):
    if Y[i] <= X[(N // 2) -1]:
        print(X[(N // 2)])
    else:
        print(X[(N // 2)-1])

Measured memory_bytes: 27156
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[3];
        for (int i = 0; i < 3; i++) {
            num[i] = sc.nextInt();
        }
        System.out.println(num[2] + " " + num[0] + " " + num[1]);
    }
}

Measured memory_bytes: 24404
#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 N;
int F[210010];
int Finv[210010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2)) % mod;
}

void fact(void) {
	F[0] = 1;
    Finv[0] = 1;
	for (int i = 1; i <= 210000; i++) {
		F[i] = Mul(i, F[i - 1]);
        Finv[i] = power(i, mod - 2);
	}
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    fact();
    //rep(i, N) cout << i << " " << F[i] << " " << Finv[i] << endl;
    REP(i, 2, N) Finv[i] = (Finv[i] + Finv[i - 1]) % mod;
    int ans = 0;
    int A[200010];
    REP(i, 1, N) {
        cin >> A[i];
        ans = (ans + A[i] * (Finv[i] + Finv[N - i + 1] - 1) + mod) % mod;
    }
    cout << ans * F[N] % mod << endl;

    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string str;
    while(cin>>str){
        if(str.length()!=2)
            reverse(str.begin(),str.end());
        cout<<str<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1000000000
using namespace std;
int main()
{
    int n,a[40],b[40],c[40],ans;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    for(int i=1;i<=n-1;i++)
        scanf("%d",&c[i]);
    ans=b[a[1]];
    for(int i=2;i<=n;i++)
    {
        ans+=b[a[i]];
        if(a[i]-a[i-1]==1)
            ans+=c[a[i-1]];
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3,typename T4> inline void print4(T1 a, T2 b, T3 c, T4 d){
	cout << a << " " << b << " " << c << " " << d << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n,k,c; cin >> n >> k >> c;
	string s; cin >> s;
	vl sum(n+1,0);
	for(ll i=n-1; i>=0; i--){
		sum[i] = sum[i+1];
		if(i+c+1>=n){
			chmax(sum[i],s[i]=='o');
		}else{
			chmax(sum[i],sum[i+c+1]+(s[i]=='o'));
		}
	}
	vl ans;
	ll cnt = 0;
	ll stop = 0;
	rep(i,n){
		if(i<n-1){
			if(sum[i+1] + cnt < k && !stop) ans.push_back(i); 
		}else{
			if(cnt < k) ans.push_back(i);
		}
		if(!stop){
			if(s[i]=='o'){
				stop += c;
				cnt++;
			}
		}else{
			stop--;
		}
	}
	for(auto i : ans) cout << i+1 << endl;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    string p = "pairwise coprime", s = "setwise coprime", o = "not coprime";
    ll gcd_all = a[0];

    repd(i, 1, n) { gcd_all = gcd(gcd_all, a[i]); }
    if (gcd_all != 1) {
        cout << o << endl;
        return 0;
    }

    set<ll> prime_all;
    rep(j, n) {
        ll num = a[j];
        for (ll i = 2; i * i <= num; i++) {
            if (num % i == 0) {
                if (prime_all.find(i) != prime_all.end()) {
                    cout << s << endl;
                    return 0;
                }
                prime_all.insert(i);
                while (num % i == 0) {
                    num /= i;
                }
            }
        }
        if (num != 1) {
            if (prime_all.find(num) != prime_all.end()) {
                cout << s << endl;
                return 0;
            }
            prime_all.insert(num);
        }
    }

    cout << p << endl;
    return 0;
}



Measured memory_bytes: 11464
/**
*    created: 13.06.2020 20:56:37
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    string s;
    cin >> s;
    char a[3];
    rep(i, 3) a[i] = s[i];
    rep(i,3) cout << a[i] ;
    cout  << endl;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d%d",&a,&b);
	c=a+b;
	if(c<24){
		printf("%d",c);
	}else{
	c-=24;
	printf("%d",c);
}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD = 1e9 + 7;
const int N = 5e5 + 10;
int a[N];
int st[4 * N];
int ans[N];
vector<pair<int,int> >vp[N];
int l[N],r[N];
int query(int node, int L, int R, int i, int j)
{
    if(j < L || i > R)
        return 0;
    if(i <= L && R <= j)
        return st[node];
    int M = (L + R) / 2;
    int left = query(node * 2, L, M, i, j);
    int right = query(node * 2 + 1, M + 1, R, i, j);
    return left + right;
}

void update(int node, int L, int R, int pos, int val)
{
    if(L == R)
    {
        st[node] = val;
        return;
    }
    int M = (L + R) / 2;
    if(pos <= M)
        update(node * 2, L, M, pos, val);
    else
        update(node * 2 + 1, M + 1, R, pos, val);
    st[node] = st[node * 2] + st[node * 2 + 1];
}
int32_t main()
{
    IOS;
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for(int i = 1; i <= k; i++)
    {

        cin >> l[i] >> r[i];
        vp[r[i]].pb({l[i], i});
    }
    map<int,int>mp;
    for(int i = 1; i <= 5e5; i++)
    {
        if(mp[a[i]] > 0)
        {
            update(1, 1, n, mp[a[i]], 0);
        }
        mp[a[i]] = i;
        update(1, 1, n, mp[a[i]], 1);
        for(auto it : vp[i])
        {
            ans[it.ss] = query(1, 1, n, it.ff, i);
        }
    }
    for(int i=1;i<=k;i++)
        cout<<ans[i]<<" ";
    cout<<endl;


}

Measured memory_bytes: 83804
import java.util.*;
import java.util.Collections;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        if(a*N >= b) {
            System.out.println(b);
        }else {
            System.out.println(a * N);
        }
    }
}

Measured memory_bytes: 23508
n, p = map(int, input().split())
if p in (2, 5):
  c = 0
  for i, x in enumerate(map(int, input()[::-1])):
    if x % p == 0:
      c += n-i
  print(c)
else:
  c = [0] * p
  y = 0
  t = 1
  for x in map(int, input()[::-1]):
    y = (y + t*x) % p
    c[y] += 1
    t = (10 * t) % p
  print(sum(i * (i-1) // 2 for i in c) + c[0])

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
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; }

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

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

    if(a.size()>b.size()){
        out("GREATER");
    }
    else if(a.size()<b.size()){
        out("LESS");
    }
    else if(a>b){out("GREATER");}
    else if(a<b){
        out("LESS");
    }
    else{
        out("EQUAL");
    }
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt(), S = scan.nextInt();
        int x, y, cnt = 0;

        for (x=0; x <= K; x++) {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;

int main()
{
    cin >> N;
    vector<ll> a(N + 1), b(N);
    for (int i = 0; i <= N; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
    }

    ll ans = 0LL;
    for (int i = 0; i < N; i++)
    {
        if (a[i] > 0)
        {
            if (b[i] >= a[i])
                ans += a[i], b[i] -= a[i], a[i] = 0;
            else
                ans += b[i], a[i] -= b[i], b[i] = 0;
        }

        if (a[i + 1] > 0)
        {
            if (b[i] >= a[i + 1])
                ans += a[i + 1], b[i] -= a[i + 1], a[i + 1] = 0;
            else
                ans += b[i], a[i + 1] -= b[i], b[i] = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int P[N], Q[N];
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> Q[i];
    }
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        v[i] = i + 1;
    }
    bool flag = true;
    int a = 1;
    while(flag) {
        flag = false;
        for (int i = 0; i < N; i++) {
            if (v[i] != P[i]) {
                flag = true;
                next_permutation(v.begin(), v.end());
                a++;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        v[i] = i + 1;
    }
    int b = 1;
    flag = true;
    while(flag) {
        flag = false;
        for (int i = 0; i < N; i++) {
            if (v[i] != Q[i]) {
                flag = true;
                next_permutation(v.begin(), v.end());
                b++;
            }
        }
    }
    cout << abs(a - b) << "\n";
    return 0;
}

Measured memory_bytes: 256
open Scanf
open Printf

let rint () = scanf " %d" (fun x -> x)
let stoa s = Array.init (String.length s) (String.get s)
let atos a = String.init (Array.length a) (Array.get a)

let () =
  let k = rint () and x = rint () in
  for i = -1000000 to 1000000 do
    if i >= x - k + 1 && i <= x + k - 1 then
      printf "%d " i
  done;
  printf "\n"

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    string s, ans;
    cin >> s;
    int y, m, d;
    y = stoi(s.substr(0,4));
    m = stoi(s.substr(5,2));
    d = stoi(s.substr(8,2));
    if(m >= 5) ans = "TBD";
    else ans = "Heisei";

    cout << ans << endl;


    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;


int main(){
  int R, G;
  cin >> R >> G;
  
  cout << 2*G - R << endl;
  
}

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

int main()
{
	int n;
	scanf("%d", &n);
	if (!(n & (n - 1)))
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	int m = n;
	printf("%d %d\n", 1 + n, 3);
	if (n % 2 == 0)
		m--;
	for(int i = 2; i < m; i += 2)
	{
		printf("%d %d\n", i, i + 1);
		printf("%d %d\n", i, 1);
		printf("%d %d\n", i + n, i + 1 + n);
		printf("%d %d\n", i + n + 1, 1);
	}
	if (n % 2 == 0)
	{
		int x = n & -n;
		int y = n - x;
		printf("%d %d\n", x, n);
		printf("%d %d\n", y + n + 1, n * 2);
	}
	return 0;
}

Measured memory_bytes: 3808
#include<stdio.h>

int main(){
    int r,d,x,y;
    scanf("%d %d %d",&r,&d,&x);
    for(int i=1;i<11;i++){
        y=r*x-d;
        printf("%d\n",y);
        x=y;
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();
        int count = 0;
        boolean flag = false;
        for (int i = 0; i < N; i++) {
            count += sc.nextInt();
            if (H <= count) {
                flag = true;
            }
        }
        System.out.println(flag ? "Yes" : "No");
    }
}

Measured memory_bytes: 46540
#include <iostream>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define SZ(x) int((x).size())
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> vec(k,0);
    for(int i = 1; i <= n; i++)
    {
        vec[i%k]++;
    }
    ll ans = 0;
    for(int a = 0; a < k; a++)
    {
        int b = (k-a)%k;
        int c = (k-a)%k;
        if ((b+c)%k == 0) {
            ans += vec[a] * vec[b] * vec[c];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
// --------------
// Tejas Pandey  |
// 11 - 07 - 20  |
// AIsing ABC    |
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<int,int> res;
  for(int i = 1; i<= 100;i++)
	for(int j = 1;j <= 100;j++)
		for(int k = 1;k <= 100;k++){
			int val = i*i+j*j+k*k+i*j+j*k+i*k;
			res[val]++;
		}
  int n;
  cin >> n;
  for(int i = 0;i < n;i++) cout << res[i + 1] << "\n";
  return 0;
}


Measured memory_bytes: 5416
import math

def merge(A, left, mid, right, cnt):
    n1 = mid - left
    n2 = right - mid
    L = [0]*(n1+1)
    R = [0]*(n2+1)
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]
    L[n1] = math.inf
    R[n2] = math.inf
    i = 0
    j = 0
    for k in range(left,right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else: 
            A[k] = R[j]
            j += 1
            cnt += mid - left - i
            
    return A, cnt


def mergeSort(A, left, right, cnt):
    if left+1 < right:
        mid = (left + right)//2
        A, cnt = mergeSort(A, left, mid, cnt)
        A, cnt = mergeSort(A, mid, right, cnt)
        A, cnt = merge(A, left, mid, right, cnt)
    return A, cnt
        
n = int(input())
A= list(map(int,input().split()))

A_out, cnt_out = mergeSort(A,0,len(A),0)

print(str(cnt_out))


Measured memory_bytes: 28956
/*
	bfs 找环
*/
#include <bits/stdc++.h>
#define N 1005
#define M 2005

using namespace std;

int n, m;
int dep[N];
int head[N], nex[M], to[M], e;
int stk[N], top;
bool instack[N], vis[N], G[N][N];
vector<int> res;

inline int Rd() {
	int x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline void Ae(int u, int v) {
	nex[++e] = head[u], head[u] = e;
	to[e] = v;
}

void calc(int u, int v) {
	do {
		res.push_back(stk[top]);
	} while(stk[top--] != v);
	int ans = res.size();
	printf("%d\n", ans);
	for(int i = 0; i < ans; ++i) printf("%d\n", res[i]);
	exit(0);
}
void dfs(int u) {
	stk[++top] = u;
	instack[u] = vis[u] = true;
	for(int i = head[u]; i; i = nex[i]) {
		int v = to[i];
		if(vis[v]) {
			if(instack[v]) calc(u, v);
		} else {
			dfs(v);
		}
	}
	instack[u] = false, --top;
	return;
}

int main() {
	n = Rd(), m = Rd();
	for(int i = 1; i <= m; ++i) {
		int u = Rd(), v = Rd();
		G[u][v] = true;
		Ae(u, v);
	}
	
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			if(G[i][j] && G[j][i]) {
				puts("2");
				printf("%d\n%d\n", i, j);
				return 0;
			}	
		}
	}
	for(int i = 1; i <= n; ++i)
		if(!vis[i])
			dfs(i);
	puts("-1");
	return 0;	
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	int K, N;
	cin >> K >> N;
	vector<int> A(3 * N);
	REP(i, N) {
		cin >> A[i];
		A[N + i] = A[i] + K;
		A[2 * N + i] = A[i] + 2 * K;
	}
	int res = K;
	REP(i, N) {
		res = min(res, K - (A[N + i + 1] - A[N + i]));
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2688
A= list(map(int,input().split()))
B=len([i for i in A if i%2==1])
ans=0
if B==1 or B==2:
    if B==1:
        A=[i+1 if i%2==0 else i for i in A]
    else:
        A=[i+1 if i%2==1 else i for i in A]
    A.sort(reverse=True)
    maximum=A[0]
    ans+=1+(maximum-A[1])//2+(maximum-A[2])//2
    print(ans)
elif B== 3 or B==0:
    A.sort(reverse=True)
    maximum=A[0]
    print((maximum-A[1])//2+(maximum-A[2])//2)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n,x,t;
  cin>>n>>x>>t;
  ll total,time;
  if(n>x){
  	total=x;
    time=t;
  	while(total<n){
  	    total=total+x;
  		time=time+t;
	}
  }
  
  else if(n<=n){
  	time=t;
  }
  
  cout<<time<<endl;
  
  
  return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sqr(x) (x) * (x)
#define cube(x) (z) * (z) * (x)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}

signed main() {
  int N   = in();
  int ans = INF;
  FOR(i, 1, 100001) {
    if (N % i == 0) {
      ans = min(ans, max((int)log10(i) + 1, (int)log10(N / i) + 1));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli dp[100010]={0};

signed main(){

	lli n,k;
	cin>>n>>k;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	/*lli dp[i] i:残りの数, dp[i]:iに応じた場合の数 */
	dp[k]=1;

	for(lli i=0;i<n;i++){
		lli nextdp[100010]={0};
		for(lli j=k;j>=0;j--){
			if(dp[j]==0)continue;
			nextdp[j] += dp[j];
			//nextdp[j] %= MOD;
			lli nextPos = j-a[i]-1;
			if(nextPos<0)continue;
			nextdp[nextPos] -= dp[j];
			//nextdp[nextPos] %= MOD;
		}

		for(lli j=k;j>=0;j--){
			nextdp[j] += nextdp[j+1];
			//nextdp[j] %=MOD;
			dp[j] = nextdp[j] % MOD;
		}
	}
	cout<<dp[0]%MOD<<endl;

	return 0;
}

Measured memory_bytes: 1792