akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128


signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  char nxt[333];
  nxt['L'] = 'U';
  nxt['U'] = 'R';
  nxt['R'] = 'D';
  nxt['D'] = 'L';
  int sr, sc, h, w, n;
  string s, t;
  cin >> h >> w >> n >> sr >> sc >> s >> t;
  auto ok = [&](int x, int edge) {
    int c = x;
    for(int i = 0; i < n; ++i) {
      if(s[i] == 'R') {
        ++c;
        if(c > edge) {
          return 1;
        }
      }
      if(t[i] == 'L' && c > 1) {
        --c;
      }
    }
    return 0;
  };
  const int edge[] = {w, h, w, h};
  const int bgn[] = {sc, h - sr + 1, w - sc + 1, sr};
  for(int i = 0; i < 4; ++i) {
    if(ok(bgn[i], edge[i])) {
      cout << "NO" << endl;
      return 0;
    }
    for(char &ch : s) {
      ch = nxt[ch];
    }
    for(char &ch : t) {
      ch = nxt[ch];
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

typedef long long int int64;

#define POS(i,j) ((i)*n+(j))

static inline int64 min(int64 a,int64 b){
  return a<b?a:b;
}

void run(void){
  int n;
  scanf("%d",&n);
  int a[400];
  int i,j,k;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc(n*n,sizeof(int64));
  for(k=2;k<=n;k++){
    for(i=0;i<=n-k;i++){
      int64 local=dp[POS(i,1)]+dp[POS(i+1,k-1)];
      for(j=2;j<k;j++){
	local=min(local,dp[POS(i,j)]+dp[POS(i+j,k-j)]);
      }
      for(j=i;j<i+k;j++) local+=a[j];
      dp[POS(i,k)]=local;
    }
  }
  printf("%lld\n",dp[POS(0,n)]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1408
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.Set;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		int N = fs.nextInt();
		Set<String> S = new HashSet<String>();
		for(int i = 1; i < N+1; i++ ) {
			S.add(fs.next());
		}
		System.out.println(S.size());


	}

}


Measured memory_bytes: 63012
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int A[100000] = {};
int B[100000] = {};
int score[100000] = {};
int main() {
	int N,T;
	
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}

	/*
	for (int i = 0; i < N; i++) {
		int tmp = 0;
		for (int j = i+1; j < N; j++) {
			if (A[i] < A[j]) {
				int tmp1 = A[j] - A[i];
				if (tmp < tmp1) tmp = tmp1;
			}
		}
		score[i] = tmp;
	}
	*/
	int min = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0) min = A[i];
		else {
			score[i] = A[i] - min;
			if (A[i] < min) min = A[i];
		}
	}

	/*
	for (int i = 0; i < N; i++) {
		cout << score[i] << endl;
	}
	*/

	sort(score, score + N);
	reverse(score, score + N);

	int tmp = 0;
	int  ans = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0){
			tmp = score[0];
		}
		if (tmp == score[i]) ans++;
	}

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

Measured memory_bytes: 1408
// 解法理解したのでコードだけまねた。
 // 素数判定の時間計算量は√N！！！
 #include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    long long N;
    cin >> N;
    auto pf = prime_factorize(N);
    long long res = 0;
    for (auto p : pf) {
        long long e = p.second;
        long long tmp = 0, cur = 1;
        while (e >= cur) e -= cur++, ++tmp;
        res += tmp;
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
 
int N;
vector<int> v;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  v.resize(N+5, 0);
  for(int i=1; i<=N; ++i) cin >> v[i];
  int tot_dist = 0;
  for(int i=0; i<=N; ++i){
    tot_dist += abs(v[i+1] - v[i]);
  }
  for(int i=1; i<=N; ++i){
    int x;
    x = tot_dist - (abs(v[i-1] - v[i]) + abs(v[i+1] - v[i]));
    x += abs(v[i+1] - v[i-1]);
    cout << x << "\n";
  }
  return 0; 
}



Measured memory_bytes: 1664
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

vector<int>ans;

map<int,int>mp;


int main() {

	int A,B,K;

	scanf("%d %d %d",&A,&B,&K);

	int i;

	for(i=0;i<K;i++){
		if(A<=A+i&&A+i<=B){	
		ans.push_back(A+i);
		mp[A+i]=1;
		}
	}
	for(i=0;i<K;i++){
		if(mp[B-i]==0 && A<=B-i&&B-i<=B){
		ans.push_back(B-i);
		}
	}

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

	for(i=0;i<ans.size();i++){
	cout<<ans[i]<<endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int a, p;
    cin >> a >> p;
    p += a*3;
    int ans = p/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a;
	string s;
	cin >> s;
	cin >> a;
	vector<string> kiyo;
	rep(i, 0, s.size()) {
		rep(j, 1, a+1) {

		
		string ses = s.substr(i, j);
		kiyo.push_back(ses);
		}
	}
	sort(kiyo.begin(), kiyo.end());
	kiyo.erase(unique(kiyo.begin(), kiyo.end()), kiyo.end());
	
	cout << kiyo[a - 1] << endl;
	
}
	

Measured memory_bytes: 1660
<?php
  fscanf(STDIN,"%d",$n);
  $p=preg_split("/ /",trim(fgets(STDIN)));
  $c=0;
  for($i=1;$i<$n+1;$i++){
    if($i!=$p[$i-1]){
        $c++;
    }
  }

  if($c==0 or $c==2){
    print("YES\n");
  }else{
    print("NO\n");
  }
?>

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst;
	Edge(){}
	Edge(int s,int d):src(s),dst(d){}
};
typedef vector<vector<Edge>> Graph;

void dfs(const Graph& g,int v,vi& vis,vi& order)
{
	if(vis[v]) return;
	vis[v]=1;
	for(auto e:g[v]) dfs(g,e.dst,vis,order);
	order.push_back(v);
}

int main()
{
	for(int n;cin>>n && n;){
		int rx,ry,cx,cy; cin>>rx>>ry>>cx>>cy;
		vi xs(n),ys(n),rs(n);
		rep(i,n) cin>>xs[i]>>ys[i]>>rs[i];
		
		// wallの周上にbedやlairはない
		rep(i,n){
			int dx=xs[i]-rx,dy=ys[i]-ry;
			assert(dx*dx+dy*dy!=rs[i]*rs[i]);
			dx=xs[i]-cx,dy=ys[i]-cy;
			assert(dx*dx+dy*dy!=rs[i]*rs[i]);
		}
		
		// n:rat, n+1:cat
		// u->v: uがvの内側にある（接してもいない）
		Graph g(n+2);
		rep(i,n) repi(j,i+1,n) if(rs[i]!=rs[j]){
			int u=i,v=j;
			if(rs[u]>rs[v]) swap(u,v);
			int dx=xs[v]-xs[u],dy=ys[v]-ys[u],dr=rs[v]-rs[u];
			// rs[u]+sqrt(dx*dx+dy*dy)<rs[v]
			if(dx*dx+dy*dy<dr*dr)
				g[u].emplace_back(u,v);
		}
		rep(i,n){
			int dx=xs[i]-rx,dy=ys[i]-ry;
			if(dx*dx+dy*dy<rs[i]*rs[i]) g[n].emplace_back(n,i);
			dx=xs[i]-cx,dy=ys[i]-cy;
			if(dx*dx+dy*dy<rs[i]*rs[i]) g[n+1].emplace_back(n+1,i);
		}
		
		vvi order(2);
		rep(i,2){
			vi vis(n+2);
			dfs(g,n+i,vis,order[i]);
			reverse(all(order[i]));
		}
		//dump(order[0]); dump(order[1]);
		
		vvi dist(2,vi(n+2,-1));
		rep(i,2){
			dist[i][n+i]=0;
			for(int u:order[i]) if(dist[i][u]!=-1) for(auto e:g[u]){
				int v=e.dst;
				dist[i][v]=max(dist[i][v],dist[i][u]+1);
			}
		}
		//dump(dist[0]); dump(dist[1]);
		
		int res=0;
		rep(i,n){
			if(dist[0][i]!=-1 && dist[1][i]==-1) res=max(res,dist[0][i]);
			if(dist[0][i]==-1 && dist[1][i]!=-1) res=max(res,dist[1][i]);
		}
		rep(i,n) rep(j,n) if(dist[0][i]!=-1 && dist[1][j]!=-1){
			int dx=xs[j]-xs[i],dy=ys[j]-ys[i],rsum=rs[i]+rs[j];
			// sqrt(dx*dx+dy*dy)>rs[i]+rs[j]
			if(dx*dx+dy*dy>rsum*rsum)
				res=max(res,dist[0][i]+dist[1][j]);
		}
		//printf("%d %d %d %d ",rx,ry,cx,cy);
		cout<<res<<endl;
	}
}

Measured memory_bytes: 7068
def main():
    # import sys
    # readline = sys.stdin.buffer.readline
    # readlines = sys.stdin.buffer.readlines
    N, M = map(int, input().split())
    cnt = 0

    if N >= M // 2:
        cnt = M // 2
    else:
        cnt += N
        M -= 2 * N
        cnt += M // 4
    
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
    int c[128][14] = {0};
    int n, r; 
    char s, ss[] = {'S', 'H', 'C', 'D'};

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf(" %c %d", &s, &r);
        c[s][r] = 1;
    }

    for (int i = 0; i < 4; i++)
    {
        s = ss[i];
        for (int r = 1; r <= 13; r++)
        {
            if (c[s][r] == 0)
                printf("%c %d\n", s, r);
        }
    }

    return 0;
}


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


void solve(long long a, long long b){
    if (a % 2 == 0 || b % 2 == 0) cout << "Even" << endl; else cout << "Odd" << endl; 
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

int main() {
    int n,ans = 0;
    cin >> n;
    rep3(i,1,n) {
        int count = 0;
        if(i % 2 == 0) {
            continue;
        }
        rep3(j,1,i) {
            if(i%j == 0) {
                count++;
            }
        }
        if(count == 8) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapfy(int );
int extract(void);
void increaseKey(int ,int);
void insert(int);

int main(){
    int key;
    char com[10];
    
    while(1){
        scanf("%s",com);
        if(com[0]=='e' && com[1]=='n') break;
        if(com[0]=='i'){
            scanf("%d",&key);
            insert(key);
        }else{
            printf("%d\n",extract());
        }
    }
    return 0;
}

void maxHeapfy(int n){
    int left,right,largest;
    
    left=2*n;
    right=2*n +1;
    
    if(left<=H && A[left]>A[n]) largest = left;
    else largest = n;
    if(right<=H && A[right]>A[largest]) largest = right;
    
    if(largest != n){
        int x =A[n];
        A[n] = A[largest];
        A[largest] = x;
        maxHeapfy(largest);
    }
}

int extract(){
    int maxv;
    if(H<1) return -INFTY;
    maxv=A[1];
    A[1]=A[H--];
    maxHeapfy(1);
    return maxv;
}

void increaseKey(int i,int key){
    int swap;
    if(key<A[i]) return;
    A[i]=key;
    while(i>1 && A[i/2]<A[i]){
        swap=A[i];
        A[i]=A[i/2];
        A[i/2]=swap;
        i=i/2;
    }
}

void insert(int key){
    H++;
    A[H]=-INFTY;
    increaseKey(H,key);
}



Measured memory_bytes: 5644
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
const double EPS=0.00001;

LL d[301][301];
bool wf(int N){
    REP(k,N)REP(i,N)REP(j,N){
        if(d[i][j]>d[i][k]+d[k][j]){
            return false;
        }
    }
    return true;
}
int main(){
    int N;
    cin>>N;
    REP(i,301)REP(j,301)d[i][j]=2e9;
    REP(i,N)REP(j,N)cin>>d[i][j];
    if(!wf(N)){
        cout<<-1<<endl;
        return 0;
    }
    bool flag=1;
    while(flag){
        flag=0;
        REP(k,N)REP(i,N)FOR(j,i+1,N){
            if(k==i||k==j)continue;
            if(d[i][j]!=2e9&&d[i][j]==d[i][k]+d[k][j]){
                //cout<<d[i][j]<<" "<<d[i][k]<<" "<<d[k][j]<<endl;
                d[i][j]=2e9;flag=1;   
            }
        }
    }
    LL res=0;
    REP(i,N)FOR(j,i+1,N){
        if(d[i][j]<=1e9){
            res+=d[i][j];
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 896
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
    int n,num=0,flag=0;
    cin>>n;
    for(int i=1,a,b;i<=n;i++){
        cin>>a>>b;
        if(a==b) num++;
        else num=0;
        if(num>=3) flag=1;
    }
    if(flag==1) puts("Yes");
    else puts("No");
    return 0;
}

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

public class Main {
	
	public void solve() throws IOException{
		int n = nextInt();
		long sum = 0;
		for(int i = 0; i < n; i++){
			sum += nextInt();
		}
		writer.println(sum/n);
	}
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run() throws IOException{
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

Measured memory_bytes: 11000
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N,M=mis()
    H=lmis()
    W = [set() for _ in range(N)]
    for _ in range(M):
        a, b = mis()
        W[a-1].add(b-1)
        W[b-1].add(a-1)
    ans = 0
    for i in range(N):
        if len(W[i])==0 or H[i] > max(H[p] for p in W[i]):
            ans += 1
    print(ans)

main()



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

int main(){
    int n, p, minp = 1000000, res = 0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> p;
        if(p <= minp){
            res++;
            minp = p;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

// int main() {
//   ll n;
//   cin >> n;
//   ll ans = n * (n-1) % modint;

//   rep(i,n-2){
//     ans = (ans * 8) % modint;
//   }
//   cout << ans << endl;
// }

int main(){
  int n;
  cin >> n;
  int flag = 0;
  string ans = "No"

  rep(i,n){
      int d1,d2;
      cin >> d1 >> d2;
      if(d1 == d2){
        flag++;
      }
      else{
        flag = 0;
      }
      if(flag == 3){
        ans = "Yes";
      }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,i,x;
	int a[110]; 
	cin >> n;
	for(i=1;i<n;i++){
		cin >> a[i];
	}
	a[n]=a[n-1];
	x=a[1];
	for(i=1;i<n;i++){
		if(a[i]<a[i+1])
			x+=a[i];
		else
			x+=a[i+1];
	}
	cout << x << endl; 
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long k;
    cin >> k;
    if (k % 2 == 0 || k % 5 == 0) {
        cout << "-1\n";
        return 0;
    }
    long long sum = 0, len = 1, p = 1;
    while (true) {
        sum = (sum + 7 * p) % k;
        if (sum == 0) {
            cout << len << '\n';
            break;
        }
        len++;
        p = p * 10 % k;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define rg register
#define LL long long
#define __space putchar(' ')
#define __endl putchar('\n')
template <typename qwq> inline void read(qwq &x)
{
	x = 0;
	rg LL f = 1;
	rg char c = getchar();
	while (c < '0' || c > '9')
	{
		if (c == '-') f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9')
	{
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	x *= f;
}
template <typename qaq> inline void print(qaq x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9) print(x / 10);
	putchar(x % 10 + '0');
}
int n, d;
int main()
{
	read(n), read(d);
	rg int tmp = n / (2 * d + 1);
	if (!tmp) print(1);
	else if (!(n % (tmp * (2 * d + 1)))) print(tmp);
	else print(tmp + 1);
	return 0;
}

Measured memory_bytes: 256
N=int(input())
time=[0]*N
sime=[0]*N
so=[[0 for i in range(2)]for j in range(N)]
for k in range(N):
    time[k],sime[k]=map(int,input().split())
    so[k][1]=time[k]
    so[k][0]=sime[k]

so.sort()
gokei=0
OK="Yes"
for kai in range(N):
    gokei=gokei+so[kai][1]
    if(gokei>so[kai][0]):
        OK="No"
print(OK)



Measured memory_bytes: 41888
#include<iostream>
using namespace std;
#define ll long long int
int main(){
	string s1,s2;
	cin>>s1>>s2;
	ll count =0;
	for(ll i=0;i<s1.length();i++){
		if(s1[i]!=s2[i]){
			count++;
		}
	}
	cout<<count;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

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

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((ll)(x).size())

int main() {
  double D, T, S;
  cin >> D >> T >> S;
  if (D / S <= T) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)

int N, tt[22][22], use[22];

int dfs(int v, int p, int ct) {
	int res = ct;
	
	for_(i,0,N) {
		if (i == p || tt[v][i] == -1 || !use[i]) continue;
		res = max(res, dfs(i, v, ct + tt[v][i]));
	}
	
	return res;
}

int main() {
	while (cin >> N, N) {
		memset(tt, -1, sizeof(tt));
		
		for_(i,0,N-1) {
			int a, b, t; cin >> a >> b >> t;
			--a; --b;
			tt[a][b] = tt[b][a] = t;
		}
		
		fill(use, use + N, 1);
		for_(i,1,N) {
			int cnt = 0;
			for_(j,0,N) if (tt[i][j] != -1) ++cnt;
			if (cnt == 1) use[i] = 0;
		}
		
		int ans = 0;
		for_(i,0,N) for_(j,i+1,N) if (use[i] && use[j] && tt[i][j] > 0) ans += tt[i][j];
		
		cout << 2 * ans - dfs(0, N, 0) << endl;
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 998244353;
const ll MAXN = 303;


ll dp[MAXN][MAXN*MAXN];

main(){
	int n;
	cin >> n;
	ll arr[n];
	int S = 0;
	for(int i=0;i<n;++i){
		cin >> arr[i];
		S += arr[i];
	}
	fill(&dp[0][0], &dp[0][0] + MAXN*MAXN*MAXN, 0);
	dp[0][0] = 1;
	for(auto i=0;i<n;++i){
		for(auto j=0;j<MAXN*MAXN;++j){
			dp[i+1][j+arr[i]] += dp[i][j];
			dp[i+1][j+arr[i]]%=MOD;
			dp[i+1][j] += 2LL*dp[i][j];
			dp[i+1][j]%=MOD;
		}
	}
	ll K = 0;
	for(auto i=(S+1)/2;i<=S;++i){
		K += dp[n][i];
	}
	fill(&dp[0][0], &dp[0][0] + MAXN*MAXN*MAXN, 0);
	dp[0][0] = 1;
	ll L = 0;
	if(S%2==0){
		for(auto i=0;i<n;++i){
			for(auto j=0;j<MAXN*MAXN;++j){
				dp[i+1][j+arr[i]] += dp[i][j];
				dp[i+1][j+arr[i]]%=MOD;
				dp[i+1][j] += dp[i][j];
				dp[i+1][j]%=MOD;
			}
		}
		L = dp[n][S/2];
	}
	ll ans = 1;
	for(int i=0;i<n;++i){
		ans *= 3LL;
		ans %= MOD;
	}
	ans += MOD - (3*K)%MOD;
	ans %=MOD;
	ans += 3*L;
	ans %=MOD;
	cout << ans << endl;
}


Measured memory_bytes: 217728
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();   
        int N = r.i();
        int[] p = r.ii();
        int[] q = new int[N];
        for(int i = 0; i < N; i++)
            q[i] = p[i];
        Arrays.sort(q);
        int count = 0;
        for(int i = 0; i < N; i++){ 
            if(p[i] != q[i]){
                count++;
            }
        }
        println(count > 2 ? "NO" : "YES");
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 20820
/*�������������Ɠǂ�����*/
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 long long int N;
 
 int main()
 {
	 cin >> N;
	 vector<int> A(1000001, 0), e(1000001,0);//vector�̗v�f����()��
	 long long int num = N;
	 bool ok = false;
	 for (int i=2; i<=1000000;i++)
	 {
		 while (num % i == 0)
		 {
			 ok = true;
			 A.at(i)++;
			 num /= i;
		 }
		 int a=sqrt(2 * A[i]);
		 if (a * (a + 1) <= 2*A[i]) e[i]=a;
		 else e[i]=a - 1;	
		 if (num == 1) break;
	 }
	 
	 if (N == 1)cout << 0 << endl;
	 else if (num > 1000000 && ok == false) cout << 1 << endl;
	 else if (num > 1000000) cout << accumulate(e.begin(), e.end(), 0) + 1 << endl;
	 else cout << accumulate(e.begin(), e.end(), 0) << endl;

 
	return 0;
}



Measured memory_bytes: 11180
import sys

s, t = sys.stdin.read().split()
n = len(s); m = len(t)
s = list(s)

def main():
    for i in range(n - m, -1, -1):
        for j in range(m):
            if t[j] != s[i+j] != '?':
                break 
        else:
            for j in range(m):
                s[i+j] = t[j]
            for i in range(n):
                if s[i] == '?': s[i] = 'a'
            print(''.join(s))
            return
    print('UNRESTORABLE')
    
if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>

int D[7]={0,6,7,5,5,20,15},S,G,Ts[2],Tg[2],d,i,r;
int p[7][7]={
	{0,30,50,60,70,135,165},
	{0,0,35,45,60,115,150},
	{0,0,0,25,40,100,135},
	{0,0,0,0,25,85,130},
	{0,0,0,0,0,60,115},
	{0,0,0,0,0,0,50}};
int up(int x){if(x%50)x+=50;return x/50*50;}
int ch(int t){return 1050<=t&&t<=1170;}
int main()
{
	for(;scanf("%d",&S),S;)
	{
		scanf("%d%d%d%d%d",&Ts[0],&Ts[1],&G,&Tg[0],&Tg[1]);
		S--;G--;
		if(S>G)S^=G^=S^=G;
		for(d=0,i=S+1;i<=G;i++)d+=D[i];
		r=p[S][G]*10;
		if(d<=40&&(ch(Ts[0]*60+Ts[1])||ch(Tg[0]*60+Tg[1])))
			r=up(r/2);
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if n > 81 {
		fmt.Println("No")
		return
	} else {
		for i := 1; i <= 9; i++ {
			a := n / i
			d := n % i
			if d == 0 && a < 10 {
				fmt.Println("Yes")
				return
			}
		}
		fmt.Println("No")
	}
}


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

int main()
{
    char a,b;
    cin>>a>>b;
    if(a=='H')
    {
        if(b=='H')
        {
            cout<<"H";
        }
        else
            cout<<"D";
    }
    else
    {
        if(b=='H')
        {
            cout<<"D";
        }
        else
            cout<<"H";

    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    std::string S;

    std::cin >> S;

    auto get = [&](){
        if (S == "RRR") return 3;
        if (S == "RRS") return 2;
        if (S == "SRR") return 2;
        if (S == "RSR") return 1;
        if (S == "SSR") return 1;
        if (S == "SRS") return 1;
        if (S == "RSS") return 1;
        return 0;
    };

    std::cout << get() << std::endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <queue>

using namespace std;


int main()
{
	int A, B;
	cin >> A >> B;

	int ans = 0;
	int cnt = 0;

	if (B == 1)
	{
		cout << 0 << endl;
		return 0;
	}

	while (true)
	{
		if (cnt == 0)
		{
			ans += A;
		}
		else
		{
			ans += A - 1;
		}
		
		cnt ++;

		if (ans >= B)
		{
			break;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define loop(i, start, end) for(int i=start; i<=end; ++i)
#define MOD 1e9+7
using namespace std;

int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

template <typename T>
void cloneArray(T *a, T *b, int start, int end) {
    loop(i, start, end) {
        *(b+i)=*(a+i);
    }
}

template <typename T>
void inputArray(T *a, int start, int end) {
    loop(i, start, end) cin >> a[i];
}

template <typename T>
void printArray(T *a, int start, int end) {
    loop(i, start, end) cout << *(a+i) << ' ';
}

void ruffleSort(int *a, int n) {
    unsigned seed=0;
    shuffle(a, a+n, default_random_engine(seed));
    sort(a, a+n);
}

int main(int argc, char const *argv[])
{   
    IOS;
    string n;
    cin >> n;
    ll ans=0;
    loop(i, 0, n.length()-1) {
        ans+=(n[i]-'0');
    }
    ans%9 ? cout << "No" : cout << "Yes";
    //cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
    return 0;
}

Measured memory_bytes: 3752
S = input()
N = len(S)
M = (N-1)/2
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return "No"
    return "Yes"

if is_kaibun(S)=="Yes":
    S = S[:int(M)]
    print(is_kaibun(S))
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>
int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int main()
{
    int n;
    long long int sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=gcd(gcd(j,k),i);
            }
        }
    }
    printf("%lld",sum);
}


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

int main() {
    string s;
    cin >> s;
    string ans;
    for (auto& e : s) {
        if (e == 'B') {
            if (!ans.empty()) ans.pop_back();
        } else {
            ans += e;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
string str;
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","w",stdout);
    cin >> str;
    int n = sz(str);
    ll ans = 0ll;
    repd(i, 0, n - 1)
    {
        ans += str[i] - '0';
        ans %= 9;
    }
    if (ans == 0)
    {
        cout << "Yes" << endl;
    } else
    {
        cout << "No" << endl;
    }
    return 0;
}




Measured memory_bytes: 3764
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np
from functools import lru_cache

X = list(map(int,readline().split()))
Y = list(map(int,readline().split()))

for i in [1,3,5]:
    X[i] += 1
    Y[i] += 1

X1 = X[:2]; X2 = X[2:4]; X3 = X[4:]
Y1 = Y[:2]; Y2 = Y[2:4]; Y3 = Y[4:]

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

U = 2 * 10 ** 6 + 10
MOD = 10**9 + 7
fact, fact_inv = make_fact(U,MOD)

@lru_cache(5)
def make_comb(n):
    return fact[n] * fact_inv[:n+1] % MOD * fact_inv[:n+1][::-1] % MOD

answer = 0
for p in itertools.product([0,1],repeat=6):
    x1,x2,x3,y1,y2,y3 = [A[i] for A,i in zip([X1,X2,X3,Y1,Y2,Y3],p)]
    sgn = (-1) ** sum(p)
    a,b,c,d = x2-x1, x3-x2, x2-x1+y2-y1, x3-x2+y3-y2
    c += 2; d += 2; sgn = -sgn
    # (1+A)^c(1+B)^d / (A-B)^2 における A^aB^b の係数
    # まずはa+b+2次式部分を抽出する：A側の次数で持つ
    D = a + b + 2
    # A^i B^j の寄与。
    L = max(0, D-d)
    R = min(c, D)
    if L > R:
        continue
    x = make_comb(c)[L:R+1]
    L,R = D-R,D-L
    y = make_comb(d)[L:R+1]
    x = x * y[::-1] % MOD
    # B=1と見立てる。(1-A)^2 で割って、A^(a-L)の係数
    np.cumsum(x,out=x)
    x %= MOD
    np.cumsum(x,out=x)
    x %= MOD
    L,R = D-R,D-L
    if 0 <= a-L < len(x):
        answer += sgn * x[a-L]

answer %= MOD
print(answer)

Measured memory_bytes: 176440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
    set<char> st;
    char a,b,c,d;
    for (int i = 0;i < 4;i++){
        char tmp;
        cin >> tmp;
        st.insert(tmp);
    }
    if (st.size() == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

   return 0;

}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int as[n+1];
  int bs[n];
  
  for (int i = 0; i <= n; i++) {
    cin >> as[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> bs[i];
  }
  
  long long total = 0;
  
  for (int i = 0; i < n; i++) {
    int b = bs[i];
    int a = min(as[i], b);
    as[i] -= a;
    b -= a;
    
    int a2 = min(as[i+1], b);
    as[i+1] -= a2;
    
    total += (a+a2);
    
    // cout << a << " " << a2 << endl;
  }
  
  cout << total << endl;
    
  return 0;
}


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

const ll INF = 1LL << 60;

ll N, K;

int main() {
    cin >> N >> K;
    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }
    // bを固定

    ll ans = 0;
    for (int b = 1; b <= N; b++) {
        // はみ出たぶん
        ll r = N % b;
        ans += max(r - K + 1, 0LL);

        // 周期丸ごとを含む分
        ll p = N / b;
        ans += p * max((b - 1 - K) + 1, 0LL);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>

int main() {
	int N, P[100], i, j, max;
	char S[100][11];
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%s %d", S[i], &P[i]);
	}
	for (i = 0; i < N; i++) {
		max = i;
		for (j = 0; j < N; j++) {
			if (strcmp(S[max], S[j]) > 0 || strcmp(S[max], S[j]) == 0 && P[max] < P[j]) {
				max = j;
			}
		}
		printf("%d\n", max + 1);
		S[max][0] = '{';
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
x = [list(map(int,input().split())) for i in range(n)]
x.sort(key=lambda x:x[0])
x.append([2*10**9+1,0])
y = [0]*(n-1) + [n-1]
a = [0]*(n-1) + [2]
for i in range(n-2,-1,-1):
  j = i+1
  while x[j][0] < sum(x[i]):
    j = y[j] + 1
  y[i] = j - 1
for i in range(n-2,-1,-1):
  a[i] = a[y[i]+1] if y[i]+1 < n else 1
  a[i] = (a[i]+a[i+1]) % 998244353
print(a[0])

Measured memory_bytes: 97880
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> p(N+1, 0);
    FOR(i, 1, N+1) cin >> p[i];

    // 累積和
    FOR(i, 1, N+1) p[i] += p[i-1]+1;

    double ans = 0;
    REP(i, N-K+1) ans = max(ans, (p[i+K]-p[i])/2.0);
    cout << fixed << setprecision(7) << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<cctype>
using namespace std;



int main(void)
{
  int a,b;
  cin>>a>>b;
  if(a<=8&&b<=8){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
 
  return 0;
}

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

int N, M, X[1 << 18], Y[1 << 18], Z[1 << 18];
vector<int> G[1 << 18];
bool used[1 << 18];

void dfs(int pos) {
	if (used[pos] == true) return;
	used[pos] = true;
	for (int i : G[pos]) dfs(i);
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> X[i] >> Y[i] >> Z[i];
		G[X[i]].push_back(Y[i]);
		G[Y[i]].push_back(X[i]);
	}
	int cnt = 0;
	for (int i = 1; i <= N; i++) {
		if (used[i] == true) continue;
		cnt++; dfs(i);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 14976
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let mut N: usize = sc.get();
    let mut ans = String::new();
    let cs: Vec<char> = (b'a'..=b'z').map(|c| char::from(c)).collect();
    while N != 0 {
        ans.push(cs[(N-1) % 26]);
        N = (N-1) / 26;
    }
    let ans: String = ans.chars().rev().collect();
    println!("{}", ans);
}


Measured memory_bytes: 2136
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  int a, b, c;
  cin >> a >> b >> c;
  cout << a + b + c - max(a, max(b, c)) << endl;
  return 0;
}

Measured memory_bytes: 256