akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}
func main() {
	var N, M int
	fmt.Scanf("%d %d\n", &N, &M)
	sum := 0
	for i := 0; i < M; i++ {
		var a int
		fmt.Scan(&a)
		sum += a
	}
	if sum > N {
		fmt.Println(-1)
	} else {
		fmt.Println(N - sum)
	}
}


Measured memory_bytes: 2496
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


#define N 	 100005
void solve(){
	int n, d, x;
	cin>>n>>d>>x;
	rep(i,0,n){
		int t;
		cin>>t;
		x+=ceil((d*1.0)/t);
	}
	cout<<x<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main(){

int N, M, MAX_L = 1, MIN_R = N;
cin >> N >> M;

for(int i = 0; i < M; i++){ 
     int L, R;
     cin >> L;
     cin >> R;
     if(MAX_L < L) MAX_L = L;
     if(MIN_R > R) MIN_R = R;
}

if(MIN_R < MAX_L) cout << 0 << endl;
else cout << (MIN_R - MAX_L) + 1 << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int n;
  double x[3],y[3];
  double a[2],b[2],c[2];
  double xa,ya;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      scanf("%lf %lf",&x[j],&y[j]);
    }
    for(int j=1;j<3;j++){
      a[j-1]=2*(x[j]-x[0]);
      b[j-1]=2*(y[j]-y[0]);
      c[j-1]=x[0]*x[0]-x[j]*x[j]+y[0]*y[0]-y[j]*y[j];
    }
    xa=(b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0]);
    ya=(c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0]);
    printf("%.3f %.3f %.3f\n",xa,ya,hypot(abs(xa-x[0]),abs(ya-y[0])));
  }
}

Measured memory_bytes: 0
S = input()
N = len(S)
rS = S[::-1]

ans = 0
tot = 0
from collections import defaultdict
dic = defaultdict(int)
for i in range(N):
    dic[tot] += 1
    tot += int(rS[i]) * pow(10,i,2019)
    tot %= 2019
    ans += dic[tot]

print(ans)

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

int main(){
  int n,i=0;
  cin>>n;
  if(n>194) i=5;
  else if(n>188) i=4;
  else if(n>164) i=3;
  else if(n>134) i=2;
  else if(n>104) i=1;
  cout<<i<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int num;
    cin >> num;
    int val [num];
    int cost [num];
    int v, c, x,y;
    for(int i=0; i<num; i++ ){
        cin >> val[i];
    }
    for(int i=0; i<num; i++ ){
        cin >> cost[i];
    }  
    for(int i=0; i<num; i++ ){
        x = val[i] - cost[i];
        if(x > 0){
            y = y + x;
        }
    }
    cout << y << '\n';

return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int cnt(int &x) {
    int res = 0;
    while(x % 2 == 0) {
        res ++;
        x /= 2;
    }
    return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int ans = 0;
    rep(i, N) {
        int a; cin >> a;
        ans += cnt(a);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
#define fir first
#define sec second
typedef long long int lli;
typedef pair<lli,lli> mp;
typedef pair<lli,mp> mmp;

vector<mp> vs[100005];
lli dis[100005]={};

lli uni[100005];
int find(int p){
  if(uni[p]==p)return p;
  return (uni[p]=find(uni[p]));
}

mp dob[100005][20];
lli dep[100005]={};

void dfs(int no,int pa,lli co,int dd){
  dob[no][0]=mp(pa,co);
  dep[no]=dd;
  rep(i,vs[no].size()){
    lli to=vs[no][i].fir,
	nco=vs[no][i].sec;
    if(to==pa)continue;
    dfs(to,no,nco,dd+1);
  }
}

void mdob(int p){
  reg(i,1,19){
    reg(j,1,p){
      mp pa=dob[j][i-1];
      dob[j][i]=mp(dob[pa.fir][i-1].fir, min(dob[pa.fir][i-1].sec,pa.sec));
    }
  }
}

void succ(int& p,int i,lli& res){
  res=min(res,dob[p][i].sec);
  p=dob[p][i].fir;
}

lli lca(int p,int q){
  if(dep[p]<dep[q])swap(p,q);
  //printf("st..%d %d\n",p,q);
  lli res=10000000000;
  rep(i,20){
    if((dep[p]-dep[q])&(1<<i)){
      succ(p,i,res);
    }
  }
  if(p==q)return res;
  
  //printf("tyu..%d %d %lld\n",p,q,res);
  for(int i=19;i>=0;i--){
    if(dob[p][i].fir!=dob[q][i].fir){
      succ(p,i,res);
      succ(q,i,res);
    }
  }
  
  if(p!=q)res=min(res, min(dob[p][0].sec,dob[q][0].sec));
  return res;
}
    

lli ans[100005];

int m,n,k,qq;
int main(void){
  scanf("%d%d%d%d",&n,&m,&k,&qq);
  rep(i,m){
    lli a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    vs[a].push_back(mp(b,c));
    vs[b].push_back(mp(a,c));
  }

  memset(dis,-1,sizeof(dis));
  priority_queue<mp,vector<mp>,greater<mp> > que;
  rep(i,k){
    lli a;
    scanf("%lld",&a);
    que.push(mp(0,a));
    
  }

  //dist
  while(!que.empty()){
    lli no=que.top().sec,
	nco=que.top().fir;
    que.pop();
    //printf("%lld %lld\n",no,nco);
    if(dis[no]!=-1)continue;
    dis[no]=nco;
    rep(i,vs[no].size()){
      lli to=vs[no][i].fir,
	  co=vs[no][i].sec;
      if(dis[to]!=-1)continue;
      que.push(mp(nco+co,to));
    }
  }
  
  /*
  reg(i,1,n){
    printf("d..%lld\n",dis[i]);
  }*/
  //kra
  reg(i,1,n)uni[i]=i;
  vector<mmp> kra;
  reg(i,1,n){
    rep(j,vs[i].size()){
      lli to=vs[i][j].fir;
      if(to>=i)continue;
      kra.push_back( mmp( min(dis[i],dis[to]),mp(i,to)) );
    }
    vs[i].clear();
  }
  sort(kra.begin(),kra.end(),greater<mmp>());
  
  rep(i,kra.size()){
    mmp pa=kra[i];
    lli a=pa.sec.fir,
	b=pa.sec.sec,
	c=pa.fir;
    if(find(a)==find(b))continue;
    uni[uni[a]]=uni[b];
    //printf("kra..%lld %lld %lld\n",a,b,c);
    vs[a].push_back(mp(b,c));
    vs[b].push_back(mp(a,c));
  }
  
  //dob
  dfs(1,0,-1,1);
  
  /*
  reg(i,1,n){
    printf("dep..%lld ed..%d %lld %lld\n",dep[i],i,dob[i][0].fir,dob[i][0].sec);
  }*/
  mdob(n);
  
  rep(i,qq){
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%lld\n",lca(a,b));
  }
  //rep(i,qq)printf("%lld\n",ans[i]);
  return 0;
}

Measured memory_bytes: 61432
S=input()
flag=True
while len(S)>7:
    if S[-7:]=="dreamer":
        S=S[:-7]
    elif S[-5:]=="dream" or S[-5:]=="erase":
        S=S[:-5]
    elif S[-6:]=="eraser":
        S=S[:-6]
    else:
        flag=False
        break
if S=="dreamer" or S=="dream" or S=="erase" or S=="eraser" or S=="":
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3188
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<math.h>

using namespace std;

int a[101];

int solve(int n){
	int c = 0;
	int b = 1;
	int damy;
	if (n == 1)return c;
	while (1){
		int f = 0;
		for (int i = n - 1; i >= 0; i--){
			if (a[i] < a[i - 1]){
				c++;
				f++;
				damy = a[i - 1];
				a[i - 1] = a[i];
				a[i] = damy;
				if (i - 1 == 0)break;
			}
			else if (f>0 && a[i] >= a[i - 1])break;
			else if (i == 1 && f == 0)return c;

		}



	}
	

}


int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	int c = solve(n);
	for (int i = 0; i < n; i++){
		if (i != n - 1)cout << a[i]<<' ';
		else cout << a[i] << endl;
	}
	cout << c << endl;
	return 0;

}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[200001];
int i,j,k,n,a[200001],b[200001];
bool work(){
	int i;
	for (i=3;i<=n;i++) a[i]=a[i-1]^b[i-1]^a[i-2];
	a[n+1]=a[1];a[0]=a[n];
	for (i=1;i<=n;i++)
	 if (a[i-1]^a[i+1]^b[i]^a[i]) return 0;
	return 1;
}
int main(){
	scanf("%d%s",&n,s);
	for (i=0;i<n;i++) b[i+1]=(s[i]=='o')?0:1;
	for (i=0;i<2;i++)
	 for (j=0;j<2;j++){
		a[1]=i;a[2]=j;
		if (work()){
			for (k=1;k<=n;k++) putchar((a[k])?'W':'S');
			puts("");
			return 0;
		}
	 }
	puts("-1");
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;


class Edge {
public:
  ll t, w;
  Edge(ll t, ll w): t(t), w(w){}
};

vector<Edge> g[MAX*2];
ll N;
P x[MAX], y[MAX];

ll solve() {
  ll clr[MAX]={};
  ll d[MAX];
  ll i;
  priority_queue<P> q;
  q.push({0, 0});
  
  for(i=0; i<N; i++) d[i]=INF;
  d[0]=0;
  
  while(q.size()) {
    P f=q.top(); q.pop();
    ll u=f.second;
    
    if(d[u]<-f.first) continue;
    clr[u]=1;
    
    for(i=0; i<g[u].size(); i++) {
      Edge e=g[u][i];
      
      if(clr[e.t]) continue;
      if(d[e.t]<=e.w) continue;
      
      d[e.t]=e.w;
      q.push({-d[e.t], e.t});
      
    }
    
  }
  
  ll res=0;
  for(i=0; i<N; i++) res+=d[i];
  
  return res;
}

int main(void) {
  cin >> N;
  ll i;
  
  for(i=0; i<N; i++) {
    cin >> x[i].first >> y[i].first;
    x[i].second=i;
    y[i].second=i;
  }
  sort(x, x+N);
  sort(y, y+N);
  
  for(i=0; i<N-1; i++) {
    g[x[i].second].push_back({x[i+1].second, abs(x[i].first-x[i+1].first)});
    g[x[i+1].second].push_back({x[i].second, abs(x[i].first-x[i+1].first)});
    g[y[i].second].push_back({y[i+1].second, abs(y[i].first-y[i+1].first)});
    g[y[i+1].second].push_back({y[i].second, abs(y[i].first-y[i+1].first)});
  }
  
  
  pt(solve());
}






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

int main() {
  int n,m;
  cin>>n>>m;

  vector<vector<int>> job(100001);
  for(int i=0; i<n; i++) {
    int a,b;
    cin>>a>>b;
    job[a].push_back(b);
  }

  int ans = 0;
  priority_queue<int, vector<int>, less<int>> work;
  for(int i=1; i<=m; i++) {
    for(int next: job[i]) {
      work.push(next);
    }
    if(!work.empty()) {
      ans += work.top();
      work.pop();
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 5632
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        int c = b+a;
        if(c%2==1){
            System.out.print("IMPOSSIBLE");
        } else{
            System.out.print(c/2);
        }
    }
    
}


Measured memory_bytes: 21844
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    vector<long long> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    long long lastH = H[N - 1];
    for (int i = N - 2; i >= 0; i--) {
        if (H[i] > lastH) {
            if (H[i] - 1 == lastH) {
                lastH = H[i] - 1;
            } else {
                cout << "No" << endl;
                return 0;
            }
        } else {
            lastH = H[i];
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque
N, Q = map(int, input().split())
Graph = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Graph[a].append(b)
    Graph[b].append(a)

counter_list = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    counter_list[p] += x

# 各頂点に counter を持たせて，幅優先探索で足していく
dist = [-1 for _ in range(N)]
dist[0] = 1
que = deque()
que.append(0)
while que:
    v = que[0]
    que.popleft()
    for new_v in Graph[v]:
        if dist[new_v] != -1:
            continue
        dist[new_v] = 1
        que.append(new_v)
        counter_list[new_v] += counter_list[v]

print(" ".join(map(str, counter_list)))

Measured memory_bytes: 132728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b;

            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            if (n * a <= b)
                Console.WriteLine(n * a);

            else if(n * a >= b)
                Console.WriteLine(b);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int hp[n];
    for(int i = 0; i < n; i++)
        cin >> hp[i];
    int count = 0;
    int check = 0;
    sort(hp, hp+n);
    while(count!=n-1){
        for(int i = check+1; i < n; i++){
            hp[i]=hp[i]%hp[check];
            if(hp[i]==0) count++;
        }
        sort(hp, hp+n);
        check = count;
    }
    cout << hp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]){

  char C[6];

  for(int i = 0; i < 6; i++){
    cin >> C[i];
  }
  if(C[0] == C[5] && C[1] == C[4] && C[2] == C[3])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


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

using namespace std;

#define ll long long

ll f[1000001], p[1000001];
ll n;

const ll mod = 1000000007;

int main ()
{
  ios_base::sync_with_stdio (0);
  cin >> n;
  for (int i=1; i <= n; ++ i) f[i] = p[i] = 0;
  f[1] = p[1] = n;
  f[2] = n*n%mod;
  p[2] = (p[1] + f[2]) % mod;
  for (int i = 3; i <= n; i++)
    {
      f[i] = f[i - 1];
      f[i] += (n-1) * (n-1);
      f[i] += p[i-3];
      f[i] += n-i+2;
      f[i] %= mod;
      p[i] = (f[i] + p[i - 1]) % mod;
    }
  cout << f[n];
  return 0;
}


Measured memory_bytes: 15872
import sys
input = sys.stdin.readline
from collections import deque
mod = 10**9+7
rng = 200100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
deg = [0]*(n+1)
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
  deg[a] += 1
  deg[b] += 1
deg[1] += 1
stack = [1]
cnt = [0]*(n+1)
for i in range(2,n+1):
  if deg[i] == 1:
    stack.append(i)
    cnt[i] = 1
dp = [[] for i in range(n+1)]
while stack:
  x = stack.pop()
  if dp[x]:
    cnt[x] = sum(dp[x])+1
  for y in graph[x]:
    if deg[y] > 1:
      dp[y].append(cnt[x])
      deg[y] -= 1
      if deg[y] == 1:
        stack.append(y)
def euler_tour(G, root=1):
  n = len(G)
  euler = []
  dq = deque([root])
  dq2 = deque()
  visited = [0]*(n+1)
  while dq:
    u = dq.pop()
    euler += [u]
    if visited[u]:
      continue
    for v in G[u]:
      if visited[v]:
        dq += [v]
    # [親頂点、子頂点、子頂点、。。。]と入れていく.その後連結
      else:
        dq2 += [v]
    dq.extend(dq2)
    dq2 = deque()
    visited[u] = 1
  return euler
order = euler_tour(graph)
ans1 = fctr[n]
for i in range(1,n+1):
  ans1 = (ans1*pow(cnt[i],mod-2,mod))%mod
ans = [0]*(n+1)
ans[1] = ans1
for i in range(1,len(order)):
  prv = order[i-1]
  now = order[i]
  no = cnt[now]
  cnt[prv] -= cnt[now]
  cnt[now] += cnt[prv]
  pr = cnt[prv]
  if ans[now]:
    continue
  ans[now] = ans[prv]*pow(pr,mod-2,mod)*no%mod
ans = ans[1:]
print(*ans,sep="\n")

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1000000007
#define INF 100000000
#define fk first
#define sv second

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel\n";
  else cout << "consonant\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>
#include <iomanip> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;

const int N = 1000001;
ll factorialNumInverse[N + 1]; 
ll naturalNumInverse[N + 1]; 
ll fact[N + 1]; 
void InverseofNumber(ll p){ 
    naturalNumInverse[0] = naturalNumInverse[1] = 1; 
    for (int i = 2; i <= N; i++) 
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; 
}
void InverseofFactorial(ll p) { 
    factorialNumInverse[0] = factorialNumInverse[1] = 1; 
    for (int i = 2; i <= N; i++) 
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; 
} 
void factorial(ll p) { 
    fact[0] = 1; 
    for (int i = 1; i <= N; i++) { 
        fact[i] = (fact[i - 1] * i) % p; 
    } 
} 
ll Binomial(ll N, ll R, ll p) 
{ 
    // n C r = n!*inverse(r!)*inverse((n-r)!) 
    ll ans = ((fact[N] * factorialNumInverse[R]) 
              % p * factorialNumInverse[N - R]) 
             % p; 
    return ans; 
} 

int main(){
	fast;
	#ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	auto start = high_resolution_clock::now(); 

	ll p = 1000000007; 
    InverseofNumber(p); 
    InverseofFactorial(p); 
    factorial(p); 

	ll x, y;
	cin >> x >> y;

	ll k, w;
	w = 2*x-y;
	k = 2*y-x;

	if (w >= 0 && k >= 0 && w%3 == 0 && k%3 == 0){
		k = k/3;
		w = w/3;
		cout << Binomial(k+w, k, p) << endl;
	}
	else 
		cout << 0 << endl;

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << fixed << setprecision(9) << double(duration.count()) / 1000000 << endl; 

	return 0;
}


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

int main(){
  int n,x;
  int sum=0;
  cin>>n>>x;
  int cnt=1;
  rep(i,n){
    int a;
    cin>>a;
    sum+=a;
    if(sum<=x){
      cnt++;
    }else{
      cout<<cnt<<endl;
      return 0;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main(){
    int n;
    scanf("%d",&n);
    vector <int> p(n);
    vector <int> q(n);
    int a,b,count;
    for(int i=0;i<n;i++) scanf("%d",&p[i]);
    for(int i=0;i<n;i++) scanf("%d",&q[i]);

    vector <int> v={};
    for(int i=1;i<=n;i++) v.push_back(i);

    do{
        if(p==v) a=count;
        if(q==v) b=count;
        count++;
    }while(next_permutation(v.begin(), v.end()));

    printf("%d\n",abs(a-b));
    

   return 0;


}

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

using namespace std;
int main(int argc, const char * argv[]) {
    
    int a, b;
    cin >> a >> b;

    int r = 0;
    if (a >= 13 ) r = b;
    else if ( a >= 6) r = b/2;

    cout << r << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest._700problems
{
    class ARC091_E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nab = ReadInts();
            long n = nab[0];
            long a = nab[1];
            long b = nab[2];
            bool reverse = a < b;
            long high = Max(a, b);
            long low = Min(a, b);
            if (a * b < n || n + 1 < a + b)
            {
                WriteLine(-1);
                return;
            }

            long first = n - high + 1;
            List<long> res = new List<long>();
            for(int i = 0; i < high; i++)
            {
                res.Add(first + i);
            }
            if (low > 1)
            {
                long now = first - 1;
                for(long i = low-1; i >=1; i--)
                {
                    List<long> cache = new List<long>();
                    long cnt = 0;
                    while (now >= i && cache.Count < high)
                    {
                        cache.Add(now);
                        now--;
                    }
                    cache.Reverse();
                    res.AddRange(cache);
                }
            }
            for(int i = 0; i < res.Count; i++)
            {
                Write(reverse ? n - res[i] + 1 : res[i]);
                if (i < res.Count - 1) Write(' ');
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 28756
#include <stdio.h>
#define MAX 1200

int main(void) {
    char ch;
    int alphabet = 97;
    int num[MAX];

    while(scanf("%c", &ch) != EOF) {
      if('a' <= ch && ch <= 'z') {
        num[ch-'a']++;
      }
      else if('A' <= ch && ch <= 'Z') {
        num[ch-'A']++;
      }
    }

    for(int i=0; i<26; ++i) {
        printf("%c : %d\n", alphabet++, num[i]);
    }

    return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin>>a>>b>>c;
  d=0;
  for(int i=b;i<=c;i++){
    if(i%a==0){
      cout<<"OK"<<endl;
      d++;
      break;
    }
  }
  if(d==0){
    cout<<"NG"<<endl;
  }
}

Measured memory_bytes: 3676
#include<stdio.h>

int main(){
	char c, c2;
	while( scanf("%c", &c) != 0 ){
		if( c < 'A' || 'Z' < c ){ break; }
		c2 = c - 3;
		printf("%c", (c2>='A'?c2:c2+26));
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2620
import math

def main():
    N, D = map(int, input().split())
    X, Y, ans = 0, 0, 0

    for _ in range(N):
        X, Y = map(int, input().split())
        if D >= math.sqrt(X ** 2 + Y ** 2):
            ans += 1

    print(f'{ans}')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int t, h, s;
    while(cin >> t >> h >> s, ~t){
        int rem = 7200-t*3600-h*60-s;
        printf("%02d:%02d:%02d\n", rem/3600, rem%3600/60, rem%60);
        rem *= 3;
        printf("%02d:%02d:%02d\n", rem/3600, rem%3600/60, rem%60);
    }
    return 0;
}


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

#define int long long

int mod = 1000000007;

// #include "debug.cpp"

int dp[1000010][4];

int32_t main(){
	int n;
	cin >> n;

	if(n == 1){
		cout << "0\n";
		return 0;
	}

	dp[2][0] = 64;
	dp[2][1] = 17;
	dp[2][2] = 17;
	dp[2][3] = 2;

	for(int i=3; i<=n; i++){
		dp[i][0] = dp[i-1][0]*8;
		dp[i][1] = dp[i-1][0] + dp[i-1][1]*9;
		dp[i][2] = dp[i-1][0] + dp[i-1][2]*9;
		dp[i][3] = dp[i-1][1] + dp[i-1][2] + dp[i-1][3]*10;

		dp[i][0] %= mod;
		dp[i][1] %= mod;
		dp[i][2] %= mod;
		dp[i][3] %= mod;
	}

	cout << dp[n][3] << "\n";
}

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

const int N = 200010;
const int mod = 1e9 + 7;

typedef long long LL;

char s[N];

int f[N], g[N], dp[2][2][N];

int main() {
    int n, m; scanf("%d%d%s", &n, &m, s + 1);
    bool flag = false;
    for (int i = 1; i <= m; i++) if (s[i] != s[1]) {
        flag = true; break;
    } 
    if (flag) {
        if (n & 1) return puts("0"), 0;
        int fir = 0;
        for (int i = 1; i <= m; i++) if (s[i] != s[1]) {
            fir = i - 1; break;
        }
        int lim = fir | 1;
        for (int i = fir + 1; i <= m; i++) if (s[i] != s[1]) {
            int j = i + 1;
            while (j <= m && s[j] == s[1]) j++;
            if (j <= m && (j - i - 1) % 2 == 1) lim = min(lim, j - i - 1); 
        } 
        n /= 2, lim = (lim + 1) / 2;
        for (int i = 1; i <= lim; i++) f[i] = i * 2;
        for (int i = 1, diff = 0; i <= n; i++) {
            diff = (diff + g[i]) % mod, f[i] = (f[i] + diff) % mod;
            if (i + 1 <= n) g[i + 1] = (g[i + 1] + f[i]) % mod;
            if (i + lim + 1 <= n) g[i + lim + 1] = (g[i + lim + 1] - f[i] + mod) % mod;
        }
        printf("%d\n", f[n]);
    } else {
        dp[1][1][1] = dp[0][0][1] = 1;
        for (int i = 2; i <= n; i++) 
            for (int t = 0; t <= 1; t++) {
                dp[t][0][i] = (dp[t][1][i - 1] + dp[t][0][i - 1]) % mod;
                dp[t][1][i] = dp[t][0][i - 1];
            }
        printf("%d\n", ((LL)dp[1][0][n] + dp[0][0][n] + dp[0][1][n]) % mod);
    }
    return 0;
}

Measured memory_bytes: 4480
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


n = ii()
dp = []
dp.append((1,"a"))
for i in range(1,n):
    dpat = []
    tmp = i+1
    for j in range(len(dp)):
        for i in range(dp[j][0] + 1):
            if i == dp[j][0]:
                dpat.append((i+1,dp[j][1] + chr(97+i)))
            else:
                dpat.append((dp[j][0],dp[j][1] + chr(97+i)))
    dp = dpat
if n == 1:
    print("a")
else:
    for i in range(len(dp)):
        print(dp[i][1])


Measured memory_bytes: 67036
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

        int n, count;;
        StringBuilder sb = new StringBuilder("");

        while (sc.hasNextInt()) {
            n = sc.nextInt();

            count = 0;
            for (int i = 2; i <= n; i++) {
                if (isPrime(i)) count++;
            }

            sb.append(count);
            sb.append('\n');
        }
        System.out.print(sb);
    }

    private static boolean isPrime(int n) {
        if (n <= 1) return false;
        else if (n <= 3) return true;
        else if (n % 2 == 0 || n % 3 == 0) return false;

        int i = 5;
        while (i * i <= n) {
            if (n % i == 0 || n % (i+2) == 0) return false;
            i += 6;
        }

        return true;
    }
}

Measured memory_bytes: 26324
#include <bits/stdc++.h>
#define rep(i,a,b) for(long long i = a; i < b; i++)
#define dump(a) for(auto x : a) cout << x << " "; cout << "\n"
#define print(a) cout << a << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using namespace std;
typedef long long ll;
using vi   = vector<int>;
using vll  = vector<ll>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvs  = vector<vector<string>>;

const static string el = "\n";

int main()
{
  int result = 1,n,k;cin>>n>>k;
  rep(i,0,n) {
    if (result>=k) result+=k;
    else result*=2;
  }
  print(result);
  return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

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

		 int index1=0;
		 for(int a=0;a<S.length();a+=2)//奇数
		 {
			 	if(S.charAt(a)=='R'||S.charAt(a)=='U'||S.charAt(a)=='D') {
			 		++index1;
			 	}
		 }

		 
		 int index2=0;
		 for(int a=1;a<S.length();a+=2)
		{
					 if(S.charAt(a)=='L'||S.charAt(a)=='U'||S.charAt(a)=='D') 
						 ++index2;
		}
		 if(index1+index2 == S.length())
		 {
			 System.out.println("Yes");
		 }
		 else
			 System.out.println("No");
			
	}
			 
			
			 

		 }
	

Measured memory_bytes: 22868
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }

  int ans = 1000000000;
  for (int i = 0; i < N; i++){
    int tmp = A[i], c = 0;
    while (tmp%2 == 0){
      tmp /= 2;
      c++;
    }
    if (ans > c){
      ans = c;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 3752
#include<vector>
#include<cmath>
#include<complex>
#include<iostream>
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<float.h>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<algorithm>
using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int
int N, M;
int a[100];
int main(void){
	cin >> N >> M;
	for(int i=0;i<M;i++) cin >> a[i];
	int cnt = 0;
	for(int i=0;i<M;i++){
		if (a[i]%2) cnt++;
	}
	if (cnt>=3){
		cout << "Impossible" << endl;
		return 0;
	}
	int cnt2 = 0;
	for(int i=1;i<M-1;i++){
		if (a[i]%2){
			if (cnt2==0) swap(a[0], a[i]); else swap(a[M-1], a[i]);
			cnt2++;
		}
	}
	vector<int> ret;
	for(int i=0;i<M;i++){
		if (i==0){
			if (a[i]>1) ret.push_back(a[i]-1);
			if (i==M-1){
				ret.push_back(1);
			}else{
				ret.push_back(2);
			}
		}else if (i==M-1){
			if (a[i]>1) ret.push_back(a[i]-1);
		}else{
			if (a[i]>4) ret.push_back(a[i]-4);
			if (a[i]>2){
				ret.push_back(4);
			}else{
				ret.push_back(2);
			}
		}
	}
	for(int i=0;i<M;i++) cout << a[i] << ((i+1==M) ? "\n" : " ");
	cout << ret.size() << endl;
	for(int i=0;i<ret.size();i++) cout << ret[i] << ((i+1==ret.size()) ? "\n" : " ");
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
b_list = list(map(int, input().split()))
sum = 0
min = b_list[0]
for i in range(n-1):
    if b_list[i] < min:
        min = b_list[i]
        sum+=min
    else:
        sum+=min
        min = b_list[i]

sum+=b_list[-1]
print(sum)


Measured memory_bytes: 3060
a=0;b=0;c=0
N,A,B=map(int,input().split())
if N<=(A+B):
  print(min(N,A))
else:
  if A==0:
    print(0)
  else:
    a=N//(A+B)
    b=N%(A+B)
    c=a*A+min(b,A)
    print(c)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
	int i,n,a,b,c;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d %d %d",&a,&b,&c);
		a=a*a,b=b*b,c=c*c;
		if(a+b==c||a+c==b||b+c==a)
			printf("YES\n");
		else
			printf("NO\n");
	}
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
int mod = 1000000007;
int main(void){
    int n;cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    } 
    vector<ll> sum(n);
    sum[0] = a[0];
    for(int i=1;i<n;i++){
        sum[i] = sum[i-1]+a[i];
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll tmp = (sum[n-1]-sum[i]) % mod;
        ans += a[i]*tmp;
        ans %= mod;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6412
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, Q = MAP()
    S = INPUT()

    lis = [0]
    for i in range(N-1):
        lis.append(lis[i] + int(S[i:i+2] == "AC"))

    for _ in range(Q):
        l, r = MAP()
        print(lis[r-1] - lis[l-1])


if __name__ == '__main__':
        main()

Measured memory_bytes: 53324
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(l[n-1])

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int array[] = new int[N];
		for(int i = 0; i < N; i++) {
			int h = sc.nextInt();
			array[h-1] = i+1;
		}
		for(int i = 0; i < array.length; i++) {
			System.out.print(array[i]+" ");
		}
	}

}


Measured memory_bytes: 62756
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int M;
    scan(M);
    print(48 - M);
    debug(48 - M);

    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 repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a,b,c;
  cin >> a>>b>>c;
 
  if(a==b) {
  cout << c << endl;
  }
   
  else if(c==b) {
  cout << a << endl;
  }
  
  else {
  cout << b << endl;
  }
  
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
  string s;
  cin >> s;
  int res = 0;
  for(int i = 0; i < s.length(); i++){
    int c = 0;
    for(int j = i; j < s.length(); j++){
      if(s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T'){
        c++;
      }else{
        break;
      }
    }
    if(c > res){
      res = c;
    }
  }
  cout << res << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline ll read(){
  ll x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
ll f[N][64], x[N], y[N];
int main(int argc, char const *argv[]) {
  int n = read();
  for (int i = 1; i <= n; ++ i) {
    x[i] = read();
    y[i] = x[i] - x[i - 1];
    f[i][0] = i;
  }
  int m = read();
  ll k = read();
  for (int i = 1; i <= m; ++ i) {
    int a = read();
    swap(f[a][0], f[a + 1][0]);
  }

  for (int i = 1; i <= 63; ++ i) {
    for (int j = 1; j <= n; ++ j) {
      f[j][i] = f[f[j][i - 1]][i - 1];
    }
  }

  ll ans = 0;
  for (int i = 1; i <= n; ++ i) {
    int p = i;
    for (int j = 63; ~j; -- j) {
      if (k >> j & 1) {
        p = f[p][j];
      }
    }
    printf("%lld.0\n", ans += y[p]);
  }

  return 0;
}
/*
首先可以推出

  f[x] = f[x-1] + f[x+1] - f[x]

我们差分一下来看

  f[x-1], f[x], f[x+1]
  ->  f[x]-f[x-1], f[x+1]-f[x]

  f[x-1], f[x-1] + f[x+1] - f[x], f[x+1]
  -> f[x+1]-f[x], f[x]-f[x-1]

发现变换就是差分之后交换两个相邻的数。。。

那么直接差分 + 倍增就好了
*/

Measured memory_bytes: 52992
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll n;cin>>n;
    double t,a;cin>>t>>a;
    double sa = 100000000000.0;
    ll num = 0;
    REP(i,n){
        double h;cin>>h;
        // cout<<sa<<endl;
        // cout<<abs(t-h*0.006-a)<<endl;
        if (sa > abs(t-h*0.006-a)){
            sa = abs(t-h*0.006-a);
            num = i+1;
        } 
    }
    cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
const int maxn = 1e9 + 7;
int main()
{
    long long a;
    scanf("%lld", &a);
    long long sum = 1;
    for(long long i = 1; i <= a; i++){
        sum = sum * i % maxn;
    }
    printf("%lld", sum);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

ll MOD = 1e9 + 7;

ll modPow(ll m, ll n) {
	ll out = 1;
	while(n--) {
		out = (out * m)%MOD;
	}
	
	return out%MOD;
}

int main() {
	ll n;
	cin >> n;
	
	ll a = modPow(10, n);
	ll b = modPow(9, n);
	ll c = modPow(8, n);
	ll answer = (a - 2*b + c + 2*MOD) % MOD;
	
	cout << answer << endl;
	
	return 0;
}


Measured memory_bytes: 3568
import sys

sys.setrecursionlimit(100000)

tmp=input().split(" ")
n = int(tmp[0])
m = int(tmp[1])

node_groups = [ i for i in range(n)]
group_sizes = [ 1 for _ in range(n)]

edges = []
for i in range(m):
    tmp=input().split(" ")
    edges.append([int(tmp[0])-1, int(tmp[1])-1])

hubensa_list = [0] * (m + 1)
hubensa_list[m] = n*(n-1)//2

def root(i):
    if node_groups[i] == i:
        #print(i, "is root.")
        return i
    else:
        #_1 = node_groups[i]
        node_groups[i] = root(node_groups[i])
        #_2 = node_groups[i]
        #print ("root: ", _1, _2)
        return node_groups[i]

def same(a, b):
    return root(a) == root(b)

def size(i):
    return group_sizes[root(i)]

def unite(a, b):
    a = root(a)
    b = root(b)

    if a == b:
        return
    
    group_sizes[a] += size(b)
    node_groups[b] = a


for i in range(m-1, -1, -1):
    edge = edges[i]
    # print("edge: ",edge)
    #print("node_groups: ", node_groups)
    node_1 = edge[0]
    node_2 = edge[1]

    root_1 = root(node_1)
    root_2 = root(node_2)
    if root_1 == root_2:
        hubensa_list[i] = hubensa_list[i+1]
        continue

    # 不便さをだす
    hubensa_list[i] = hubensa_list[i+1] - (size(root_1) * size(root_2))

    unite(root_1, root_2)

#print("node_groups: ", node_groups)


for i in range(1, m+1):
    print(hubensa_list[i])

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

int main()
{
  int n, x;cin>> n>> x;
  int a[n];

  rep(i, n) {
    cin>>a[i];
  }

  sort(a,a+n);

  int ans = 0;
  rep(i, n) {
    if(x >= a[i]) {
      x = x-a[i];
      ans++;
    }
  }
  if (x > 0 && ans == n) ans--;

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

Measured memory_bytes: 256