akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

map<int,int> mp;
int a[200005];
int main() {
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;++i) cin>>a[i];
    for(int i=1;i<=n;++i) {
        ans += mp[i-a[i]];
        mp[a[i]+i]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 21348
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int N, S, dp[3030][3030], a[3030];

int main()
{
	fast();

	cin >> N >> S;

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

	dp[0][0] = 1;

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= S; j++)
		{
			if (j + a[i] <= S)
				dp[i + 1][j + a[i]] = (dp[i][j] + dp[i + 1][j + a[i]]) % mod2;
			dp[i + 1][j] = ((2 * dp[i][j]) % mod2 + dp[i + 1][j]) % mod2;
		}
	}
	cout << dp[N][S] << "\n";
}

Measured memory_bytes: 39120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static double solve[][] = new double[3001][3001];
    public static double probabilities[] = new double[3000];
    public static void main(String args[])throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n=Long.parseLong(br.readLine());
        String S[]=br.readLine().split(" ");
        for(int i=0;i<n;i++)
            probabilities[i]=Double.parseDouble(S[i]);
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=n;j++)
                solve[i][j]=0;
        }
        solve[0][0]=1;
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=n;j++)
            {
                solve[i][j+1]+=solve[i][j]*(1-probabilities[j]);
                solve[i+1][j+1]=solve[i][j]*(probabilities[j]);
            }
        }
        double totalProbability=0.0d;
        for(int i=0;i<(n+1)/2;i++)
            totalProbability+=solve[i][(int)n];
        System.out.println(1-totalProbability);
        /*for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=n;j++)
                System.out.printf("%1.8f ",solve[i][j]);
            System.out.println();
            //System.out.println(solve[i][(int)n]);
        }*/

    }
}

Measured memory_bytes: 131024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

//INSERT ABOVE HERE
signed main(){
  string s,t;
  cin>>s>>t;
  vector<Int> v(26,-1);
  
  Int n=s.size();
  for(Int i=0;i<n;i++) v[s[i]-'a']=t[i]-'a';
  auto NO=[](){cout<<"No"<<endl;exit(0);};
  for(Int i=0;i<n;i++) if(v[s[i]-'a']!=t[i]-'a') NO();

  for(Int i=0;i<26;i++)
    for(Int j=0;j<i;j++)
      if(~v[i]&&~v[j]&&v[i]==v[j]) NO();
  
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int n;
	cin >> n;
  	int ans;
  	for(int i=1; i<=n; i++){
		ans += i;
    }
  	cout << ans << endl;
	
	return 0;
}


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

int main(){
  int n;
  int ans = 0;
  int a[50];
  int b[50];
  cin >> n;
  rep(i, n){
    cin >> a[i];
  }
  rep(i, n){
    cin >> b[i];
  }
  rep(i, n){
    if(a[i] > b[i]){
      ans += a[i] - b[i];
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  ll n;
  cin >> n;
  
  vector<ll> p(100);
  p[0]=2;
  p[1]=1;
  
  for(int i=2; i<100;i++){
    p[i]=p[i-1]+p[i-2];
  }
  
  cout << p[n];
  
}


Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

x1 = inputs[0][0]
y1 = inputs[0][1]
x2 = inputs[0][2]
y2 = inputs[0][3]

vx = x2 - x1
vy = y2 - y1

vxd = -1 * vy
vyd = vx

x3 = x2 + vxd
y3 = y2 + vyd

x4 = x3 - vx
y4 = y3 - vy

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    int ans=0;
    int notten=inf;
    vin s(n);
    rep(i,n){
        cin>>s[i];
        ans+=s[i];
        if(s[i]%10!=0)notten=min(notten,s[i]);
    }
    if(ans%10==0){
        if(notten!=inf)ans-=notten;
        else ans=0;
    }
    cout<<ans<<endl;
}

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


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

    long long n, k;
    cin >> n >> k;
    vector <long long> arr(n);
    for(long long i=0;i<n;i++){
        cin >> arr[i];
    }
    long long mini = LONG_LONG_MAX;
    for(int i=0;i<n-k+1;i++){
        mini = min(mini, min(abs(arr[i])+abs(arr[i]-arr[i+k-1]), abs(arr[i+k-1])+abs(arr[i+k-1]-arr[i])));
    }
    cout << mini << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>

using namespace std;

#define INF 1 << 28

struct edge_t {
    int from, to, enemy, distance;
    edge_t(int from=0, int to=0, int distance=0, int enemy=0) :
        from(from), to(to), distance(distance), enemy(enemy){}
};

struct state_t {
    int min_enemy;
    int money;
    int city;
    state_t(int city=0, int min_enemy=0, int money=0) :
        city(city), min_enemy(min_enemy), money(money) {}
    bool operator<(const state_t &o) const {
        return min_enemy == o.min_enemy ? 
                    money < o.money :
                    min_enemy < o.min_enemy;
    }
    bool operator>(const state_t &o) const {
        return min_enemy == o.min_enemy ?
                    money > o.money :
                    min_enemy > o.min_enemy;
    }
};

#define MAX_V 101
#define MAX_L 101

int V;
vector<edge_t> graph[MAX_V];
//int enemy[MAX_V][MAX_L];

int N, M, L;

int dijkstra(int s, int g) {
    int enemy[MAX_V][MAX_L];
    priority_queue< state_t, vector<state_t>, greater<state_t> > q;
    for (int i = 0; i < MAX_V; i++) 
        for (int j = 0; j < MAX_L; j++) 
            enemy[i][j] = INF;
    enemy[s][L] = 0;
    q.push(state_t(s, 0, L));

    while (!q.empty()) {
        state_t p = q.top(); q.pop();
        if (enemy[p.city][p.money] < p.min_enemy) continue;
        for (int i = 0; i < graph[p.city].size(); i++) {
            edge_t e = graph[p.city][i];

            // 護衛を雇わなかったとき
            if (enemy[e.to][p.money] > enemy[p.city][p.money] + e.enemy) {
                enemy[e.to][p.money] = enemy[p.city][p.money] + e.enemy;
                q.push(state_t(e.to, enemy[e.to][p.money], p.money));
            }
            
            // 護衛を雇ったとき
            // そもそも護衛を雇う予算があるか
            if (p.money - e.distance < 0) continue;
            // あるなら
            if (enemy[e.to][p.money - e.distance] > enemy[p.city][p.money]) {
                enemy[e.to][p.money - e.distance] = enemy[p.city][p.money];
                q.push(state_t(e.to, enemy[e.to][p.money - e.distance], p.money - e.distance));
            }
        }
    }

    int min_enemy = INF;
    for (int i = 0; i < MAX_L; i++)  {
        min_enemy = min(min_enemy, enemy[g][i]);
    }
    return min_enemy;
}

int main() {
    while (cin >> N >> M >> L) {
        if (N == 0 && M == 0 && L == 0) break;
        for (int i = 0; i < N; i++) graph[i].clear();
        for (int i = 0; i < M; i++) {
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            graph[a].push_back(edge_t(a, b, d, e));
            graph[b].push_back(edge_t(b, a, d, e));
        }
        cout << dijkstra(1, N) << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
const int MAX = 123456*2;
int p[MAX];
int N;
int main(){
  for(int i=2;i*i<MAX;i++){
    if( p[i] ) continue;
    for(int j=i+i;j<MAX;j+=i)
      p[j] = 1;    
  }
  while( cin >> N && N ){
    int cnt = 0;
    if( N == 1 ) {
      cout << 1 << endl; continue;
    }
    for(int i=N+1;i<2*N;i++) cnt+=(1-p[i]);
    cout << cnt << endl;
  }  
}

Measured memory_bytes: 2124
import itertools as it

N=int(input())
P=tuple([int(i) for i in input().split()])
Q=tuple([int(i) for i in input().split()])

perms=list(it.permutations(range(1, N+1)))
a=perms.index(P)
b=perms.index(Q)

print(abs(a-b))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

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

void solve(ll N, ll M, ll K, vector<ll> A, vector<ll> B) {

  vector<ll> Asum(N + 1), Bsum(M + 1);
  FOR(i, 1, N + 1)
    Asum[i] = Asum[i-1] + A[i - 1];
  // REP(i, N + 1)
  //   cout << Asum[i]<<" ";
  // cout << endl;
  FOR(i, 1, M + 1)
    Bsum[i] = Bsum[i-1] + B[i - 1];

  ll an(N);
  while (an >= 0) {
    if (Asum[an] <= K)
      break;
    an--;
  }
  ll bn(0);
  while(bn <= M) {
    // printf("bn %lld Bsum[bn] %lld K = %lld , Asum[an] = %lld \n", bn, Bsum[bn], K, Asum[an]); 
    if (Bsum[bn] > K - Asum[an])
      break;
    bn++;
  }
  bn--;
  ll ans(an + bn);

  while (an >= 0 && bn <= M) {
    an--;
    while (bn <= M) {
      if (Bsum[bn] > K - Asum[an])
	break;
      bn++;
    }
    bn--;
    ans = max(ans, an + bn);
  }
  // printf("an = %lld bn = %lld \n", an, bn);
  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  ll M;
  cin >> M;
  ll K;
  cin >> K;
  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }
  vector<ll> B(M);
  REP(i, M) {
    cin >> B[i];
  }

  solve(N, M, K, move(A), move(B));

  return 0;
}


Measured memory_bytes: 9532
N = int(input())
#import numpy as np
H = list(map(int,input().split()))
ans = 0
a = H[0]
index = 0

counter = 0
for i in range(N-1):
    #H[i] = int(input())
    b = int(H[i + 1])
    #print(a,b)
    if a>=b:
        counter +=1
    else:
        ans = max(ans,counter)
        counter = 0
    a = b
ans = max(ans,counter)
print(ans)




Measured memory_bytes: 15020
import math

N, P = map(int, input().split())
max_value = round(pow(P, 1/N)) + 1 
ans = 1

if N == 1:
    ans = P
else:
    for i in range(1, max_value):
        mod = i ** N
        if P % mod == 0:
            ans = i

print(ans)


Measured memory_bytes: 3188
#include <cmath>
#include <cstdio>
#include <cctype>

struct t
{
	int a;
	#define dd c=getchar()
	inline void read()
	{
		a=0;bool f=false;char dd;
		for(;!isdigit(c);dd)if(c=='-')f=true;
		for(;isdigit(c);dd)	a=(a<<1)+(a<<3)+(c^48);
		c=getchar();if(f)a=-a,f=false;
		for(;isdigit(c);dd)	a=(a<<1)+(a<<3)+(c^48);
	}
	#undef dd
	inline bool pan()
	{
		double x=sqrt((double)a);
		if(floor(x)==x)	return true;
		else	return false;
	}
	inline void print()
	{
		if(pan())	puts("Yes");
		else	puts("No");
		return;
	}
}tt;

int main()
{
	tt.read();tt.print();
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int arr[n];
    int s = 0;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        s += arr[i];
    }
    sort(arr, arr + n, greater<int>());   
    int res;
    if(s % (4 * m) == 0){
        res = s / (4 * m);
    }else{
        res = (s / (4 * m)) + 1;
    }
    int flag = 0;
    for(int i = 0; i < m; i++){
        if(arr[i] < res){
            flag++;
            cout << "No" << endl;
            break;
        }
    }
    if(flag == 0){
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

enum ATGC{
    A = 1,
    G = 2,
    C = 3,
    T = 4,
};


int main(){
    int n;
    cin >> n;
    vector<vector<ll>> dp(n, vector<ll>(1 << 3*3 , 0));

    REP(i, 4){
        dp[0][i+1] = 1;
    }

    for(int i=1; i<n; i++){
        for(int j=1; j<=4; j++){
            REP(k, 1 << 3*3){
                if(j == C){
                    if((k & 0b111111) == (A << 3) + G) continue;
                    if((k & 0b111111) == (G << 3) + A) continue;
                    if((k & 0b111111000) == (A << 6) + (G << 3)) continue;
                    if((k & 0b111000111) == (A << 6) + G) continue;
                }
                if(j == G){
                    if((k & 0b111111) == (A << 3) + C) continue;
                }
                dp[i][j + (k << 3) & 0b111111111] += dp[i-1][k];
                dp[i][j + (k << 3) & 0b111111111] %= MOD;
            }
        }
    }

    cout << accumulate(all(dp.back()), 0LL) % MOD << endl;
}

/*
int main(){
    int n;
    cin >> n;

    vector<vector<ll>> dp(n, vector<ll>(4, 1));
    //0:A, 1:C, 2:G, 3:T

    for(int i=1; i<n; i++){
        REP(j, 4){
            dp[i][j] = accumulate(all(dp[i-1]), 0LL) % MOD;
        }
        if(i > 1){
            dp[i][C] -= dp[i-1][G] - dp[i-2][G] - dp[i-2][C] - dp[i-2][T];
            dp[i][C] -= dp[i-1][A] - dp[i-2][A] - dp[i-2][C] - dp[i-2][T];
            dp[i][G] -= dp[i-1][C] - dp[i-2][C] - dp[i-2][G] - dp[i-2][T];
        }
        if(i > 2){
            dp[i][C] -= dp[i-2][G] - dp[i-3][G] - dp[i-3][C] - dp[i-3][T];
            dp[i][C] -= dp[i-1][G] - dp[i-2][A];

        }
        REP(j, 4){
            dp[i][j] += MOD;
            dp[i][j] %= MOD;
        }
    }

    for(auto i : dp){
        for(auto j : i){
            cout << j << " ";
        }
        cout << endl;
    }

    cout << accumulate(all(dp.back()), 0LL) % MOD << endl;

    return 0;
}



/*
    vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(4, vector<ll>(4, 0)));

    REP(i, 4){
        REP(j, 4){
            dp[0][i][j] = 1;
            dp[1][i][j] = 1;
        }
    }

    for(int i=2; i<n; i++){
        REP(j, 4){
            REP(k, 4){
                dp[i][j][k] = accumulate(all(dp[i-1][k]), 0LL) % MOD;
            }
        }
        dp[i][C][G] -= dp[i-1][G][A];
        dp[i][C][A] -= dp[i-1][A][G];
        dp[i][G][C] -= dp[i-1][C][A];
    }

    ll ans = 0;

    for(auto i : dp.back()){
        for(auto j : i){
            ans += j;
            ans %= MOD;
        }
    }

    cout << ans << endl;
*/

Measured memory_bytes: 640
from itertools import accumulate

N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9 + 7
DP = [0] * (K+2)
DP[0] = 1
for a in A:
    D = [0] * (K+2)
    for i, d in enumerate(DP):
        if d > 0:
            D[i] += d
            D[min(K+1, i + a + 1)] -= d
    for i in range(1, K+2):
        D[i] += D[i-1]
        D[i] %= mod
    DP = D
print(DP[K])

Measured memory_bytes: 149900
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define rhl (1000000007)
#define N (1000005)

using namespace std;

struct data{ int x,y; }a[35];

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

int cnt[65][65],can[65][65],dis[65][65],ans;
int sx[N],sy[N],covx[N],covy[N],n,m,k,lx,ly;
queue<pair<int,int> > Q;
vector<int> px,py;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q*x;
}

il void bfs(RG int sx,RG int sy){
  memset(dis,0,sizeof(dis)),dis[sx][sy]=1,Q.push(make_pair(sx,sy));
  while (!Q.empty()){
    pair<int,int> now=Q.front(); Q.pop();
    for (RG int i=0,x,y;i<4;++i){
      x=now.first+dx[i],y=now.second+dy[i];
      if (x<0 || x>lx || y<0 || y>ly || dis[x][y] || can[x][y]) continue;
      dis[x][y]=dis[now.first][now.second]+1,Q.push(make_pair(x,y));
      ans=(ans+1LL*cnt[sx][sy]*cnt[x][y]%rhl*(dis[x][y]-1))%rhl;
    }
  }
  return;
}

int main(){
  n=gi(),m=gi(),k=gi();
  px.push_back(1),px.push_back(n+1);
  py.push_back(1),py.push_back(m+1);
  for (RG int i=1;i<=n;++i) sx[i]=m;
  for (RG int i=1;i<=m;++i) sy[i]=n;
  for (RG int i=1;i<=k;++i){
    px.push_back(a[i].x=gi()+1),px.push_back(a[i].x+1);
    py.push_back(a[i].y=gi()+1),py.push_back(a[i].y+1);
    --sx[a[i].x],--sy[a[i].y],covx[a[i].x]=covy[a[i].y]=1;
  }
  for (RG int i=1;i<=n;++i) (sx[i]+=sx[i-1])%=rhl;
  for (RG int i=1;i<=m;++i) (sy[i]+=sy[i-1])%=rhl;
  for (RG int i=1;i<n;++i) if (!covx[i] && !covx[i+1]) ans=(ans+2LL*sx[i]*(sx[n]-sx[i]))%rhl;
  for (RG int i=1;i<m;++i) if (!covy[i] && !covy[i+1]) ans=(ans+2LL*sy[i]*(sy[m]-sy[i]))%rhl;
  sort(px.begin(),px.end()),px.erase(unique(px.begin(),px.end()),px.end()),lx=px.size()-2;
  sort(py.begin(),py.end()),py.erase(unique(py.begin(),py.end()),py.end()),ly=py.size()-2;
  for (RG int i=1;i<=k;++i){
    a[i].x=lower_bound(px.begin(),px.end(),a[i].x)-px.begin();
    a[i].y=lower_bound(py.begin(),py.end(),a[i].y)-py.begin();
    can[a[i].x][a[i].y]=1;
  }
  for (RG int i=0;i<=lx;++i)
    for (RG int j=0;j<=ly;++j)
      cnt[i][j]=1LL*(px[i+1]-px[i])*(py[j+1]-py[j])%rhl;
  for (RG int i=0;i<=lx;++i)
    for (RG int j=0;j<=ly;++j) if (!can[i][j]) bfs(i,j);
  cout<<1LL*(ans+rhl)*(rhl/2+1)%rhl; return 0;
}


Measured memory_bytes: 13952
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n != -1 )
	{
		vector <int> numbers;
		int w = n;
		while ( w >= 4 )
		{
			numbers.push_back( w % 4 );
			w /= 4;
		}
		numbers.push_back( w % 4 );

		reverse( numbers.begin(), numbers.end() );
		for ( vector <int>::iterator it = numbers.begin(); it != numbers.end(); it++ )
		{
			cout << *it;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
using namespace std;

int N, A, B, C;
int l[8];
int INF = 100000000;
int solve(int i, int p, int q, int r, int c);
int mini(int p, int q);
int main() {
    scanf("%d %d %d %d", &N, &A, &B, &C);
    for (int i = 0; i < N; i++) {
        scanf("%d", &l[i]);
    }

    printf("%d\n", solve(0, 0, 0, 0, 0));
    return 0;
}

int solve(int i, int p, int q, int r, int c) {
    if (i == N && (p == 0 || q == 0 || r == 0)) return INF;
    if (i == N) return (std::abs(p - A) + std::abs(q - B) + std::abs(r - C) + c);
    int min = INF;
    int temp;
    temp = (p == 0 ? solve(i+1, p + l[i], q, r, c) : solve(i+1, p + l[i], q, r, c + 10));
    temp = mini(q == 0 ? solve(i+1, p, q + l[i], r, c) : solve(i+1, p, q + l[i], r, c + 10), temp);
    temp = mini(r == 0 ? solve(i+1, p, q, r + l[i], c) : solve(i+1, p, q, r + l[i], c + 10), temp);
    temp = mini(solve(i+1, p, q, r, c), temp);
    return temp;
}

int mini(int p, int q) {
    return p > q ? q : p;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
k=int(input())
s=input().rstrip("\n")
if len(s)<=k:
    print(s)
else:
    print(s[:k]+"...")

Measured memory_bytes: 9168
#include <cstdio>
#include <iostream>
#include <cmath>
const int maxn = 100;
using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b))
        cout << "A" << endl;
    else
        cout << "B" << endl;
    return 0;
}


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

typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> S(N), T(N);
    vector<pair<ll, ll>> X(N);
    rep(i, N)
    {
        ll a, b;
        cin >> a >> b;
        X[i].second = a - b;
        X[i].first = a + b;
    }
    sort(X.begin(), X.end());
    ll res = 0;
    ll t = -1000000000000;
    rep(i, N)
    {
        if (t < X[i].second)
        {
            res++;
            t = X[i].first-1;
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int M;
    cin >> M;
    int ans = 24 + (24 - M);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,h,a[1001]={};
  char num[1001]={};
  for(i=0;i<10000;i++){
    scanf("%s",num);
    if(num[0]=='0') break;
    for(j=0;j<1001;j++){
      a[i]+=num[j]-'0';
       if(num[j+1]=='\0') break;
    }
  }
  for(h=0;h<i;h++){
    printf("%d\n",a[h]);
  }
  return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int> p(a),q(b),r(c);
    rep(i,a) cin>>p[i];
    rep(i,b) cin>>q[i];
    rep(i,c) cin>>r[i];
    sort(p.begin(),p.end(),greater<int>());
    sort(q.begin(),q.end(),greater<int>());
    sort(r.begin(),r.end(),greater<int>());
   
    priority_queue<int> que1;
    rep(i,x){
        que1.push(p[i]);

    }
    rep(i,y){
        que1.push(q[i]);
    }
    rep(i,c){
        que1.push(r[i]);
    }
    ll sum=0;
    rep(i,x+y){
        sum +=que1.top();
        que1.pop();
        
    }
    cout << sum;
}

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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  vector<int> v;
  for(int i=0;i<n;i++){
    int t;
    cin>>t;
    v.push_back(t);
  }
  sort(v.begin(),v.end());
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=v[i];
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int main()
{
    int n, m;

    cin >> n >> m;
    cout << (1900 * m + 100 * (n - m)) * pow(2, m) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	string x;
	int s=0,e=0;
	cin>>x;
	for(int i=0;i<x.length();i++){
		if(x[i]=='A'){
			s=i;
			break;
		}
	}
	for(int i=x.length()-1;i>=0;i--){
		if(x[i]=='Z'){
			e=i;
			break;
		}
	}
	cout<<e-s+1<<endl;
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define MAXI ((ll)1e16)
#define MINI ((ll)-1e16)
using namespace std;
typedef long long ll;  
     
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }          
ll n,w,res;
ll weight[101];
ll val[101];
ll dp[101][100001];
ll solve(ll i, ll value){
	if(value<0)return MAXI;
	if(i==-1 && (value<0 || value>0))return MAXI;
	if(i==-1)return 0;
	if(dp[i][value]!=-1)return dp[i][value];
	dp[i][value] = min(weight[i]+solve(i-1,value-val[i]),solve(i-1,value));
	return dp[i][value];
}
int main(){FIN;
	cin >> n >> w;
	fore(i,0,n){
		cin >> weight[i] >> val[i];
	}
	memset(dp,-1,sizeof(dp));
	for(int i = 100000 ; i>-1 ; i--){
		if(solve(n-1,i)<=w){
			cout << i << endl;
			return 0;
		}
	}
	
}

Measured memory_bytes: 79360
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

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

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;

  int x = 0;  //確定した参加者
  int y = 0;  //海外の学生の順位

  rep(i, n) {

    if(s[i]=='c') {
      no();
    }else if(s[i]=='a') {
      if(x<a+b) {
        yes();
        ++x;
      }else {
        no();
      }
    }else if(s[i]=='b') {
      ++y;
      if(x<a+b&&y<=b) {
        yes();
        ++x;
      }else {
        no();
      }
    }
  }

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

ll gcd (ll a, ll b) {     //Eulers algorithm
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

ll arr[21][21];
ll dp[(1<<21)+1];
ll m = 1000000007;
ll f(ll s,ll n){
  ll j = __builtin_popcount(s);
  if(s == (1<<n)-1){return 1;}
  if(dp[s]!=-1){return dp[s];}
//   cout<<j<<"\n";
  ll ans = 0;
  rep(i,0,n-1){
      if( (s & 1<<i)==0 && arr[i][j]==1){
          ans = (ans + f((s | 1<<i),n)%m)%m;
      }
  }
  dp[s] = ans;
  return ans;
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n; cin>>n;
    memset(dp,-1,sizeof(dp));
    rep(i,0,n-1){
        rep(j,0,n-1){
            cin>>arr[i][j];
        }
    }
    cout<<f(0,n);
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    ll x;
    cin >> x;

    for (ll i = 1; ; i++) {
        ll tmp = i * (i + 1) / 2;
        if (tmp >= x) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

#define int long long int
#define MOD 1000000007

int32_t main()
{
    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        int n, k ;
        cin >> n >> k ;
        int a[n] ;
        for(int i = 0 ; i < n ; i++)
        {
            cin >> a[i] ;
        }
        int dp[n] ;
        memset(dp, 0, sizeof(dp)) ;
        dp[0] = 0 ; dp[1] = abs(a[0] - a[1]) ;
        
        for(int i = 2 ; i < n ; i++)
        {
            int ans = 100000000000 ;
            for(int j = 1 ; j <= min(i, k) ; j++)
                ans = min(dp[i-j] + abs(a[i] - a[i - j]), ans) ;
                
            dp[i] = ans ;
            
        }
        cout << dp[n-1] ;
    }
    return 0 ;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define modulo 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
int main(){
	fast_io;
	string s;
	cin>>s;
	ll temp=0,ans;
	for (int i = 0; i < s.size(); ++i){
		temp+=(s[i]-'0');
	}
	ans=9*(s.size()-1)+((s[0]-'0')-1);
	ans=max(ans,temp);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3552
n = int(input())
#n, m = map(int, input().split())
al = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
mod = 10**9+7
add = 0
ans = 0
for i in range(n-1, 0, -1):
    add = (add+al[i]) % mod
    ans = (ans+add*al[i-1]) % mod

print(ans)


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

namespace ABC144_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var ans = PrimeFactors(n);
            Console.WriteLine(ans);
        }

        public static long PrimeFactors(long n)
        {
            var ret = n - 1;
            var m = (long)Math.Sqrt(n);
            for (int i = 2; i <= m; i++)
            {
                if (n % i == 0)
                {
                    ret = Math.Min(ret, i + n / i - 2);
                }
            }

            return ret;
        }
    }
}


Measured memory_bytes: 13140
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
a.sort()
cnt = 0
price = 0
for i in range(n):
    if cnt + a[i][1] >= m:
        price += (m-cnt)*a[i][0]
        print(price)
        break
    else:
        cnt += a[i][1]
        price += a[i][1]*a[i][0]


Measured memory_bytes: 27760
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(1e6) + 5;
int D[N];
int main(void)
{
    int n;
    cin>>n;
    for (int i = 0;i < n;++i)
        D[i] = 1e9;
    D[1] = 0;
    priority_queue < pii , vector < pii > , greater < pii > > q;
    q.push(mp(0,1));
    while (!q.empty())
    {
        int node = q.top().se;
        q.pop();
        if (D[(node + 1) % n] > D[node] + 1)
            D[(node + 1) % n] = D[node] + 1,q.push(mp(D[node] + 1,(node + 1) % n));
        if (D[(10 * node) % n] > D[node])
            D[(10 * node) % n] = D[node],q.push(mp(D[node],(10 * node) % n));
    }
    cout << (1 + D[0]) << '\n';
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int len = S.size();

  for(int i = 0; i < len; i++){
    int org = S.at(i);
    if(org - 'A' + N >= 26){
      S.at(i) = org + N - 26;
    }else{
      S.at(i) = org + N;
    }
  }
  cout << S << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String str1=sc.nextLine();
    String str2=sc.nextLine();
    int m=str1.length();
    int n=str2.length();
    String new_str2=str2.substring(0,m);
    if(str1.equals(new_str2)){
      if(n==m+1){
          System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35572
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;


/**
   ceil(0, 2) == 0
   ceil(1, 2) == 1
   ceil(2, 2) == 1
   ceil(3, 2) == 2
   ceil(4, 2) == 2
*/
template<class T>
T ceil(T dividend, T divisor)
{
    return (dividend + (divisor - 1)) / divisor;
}
int main()
{
    int64_t A, B, C, D, E, F;
    std::cin >> A >> B >> C >> D >> E >> F;

    // 100 * S <= W * E
    // W + S <= F

    // W += 100*A
    // W += 100*B
    // S += C;
    // S += D;

    // F 以下となる水の組み合わせ

    std::unordered_set<int64_t> water;
    for (int64_t a = 0; a*100*A <= F; ++a) {
        for (int64_t b = 0; b*100*B <= F; ++b) {
            auto w = 100*a*A + 100*b*B;
            if (w <= 0 || w > F) {
                continue;
            }
            water.insert(w);
        }
    }

    std::unordered_set<int64_t> suger;
    for (int64_t c = 0; c*C <= F; ++c) {
        for (int64_t d = 0; d*D <= F; ++d) {
            auto s = c*C + d*D;
            if (/*s <= 0 ||*/ s > F) {
                continue;
            }
            suger.insert(s);
        }
    }


    double max = 0;
    int64_t maxW = 0;
    int64_t maxS = 0;

    for (auto w: water) {
        for (auto s: suger) {
            if (w + s > F) {
                continue;
            }
            if (100 * s > w * E) {
                continue;
            }

            double n = 100.0 * s / (w + s);
            if (max <= n) {
                maxW = w;
                maxS = s;
                max = n;
            }
        }
    }

    std::cout << maxS + maxW << " " << maxS << std::endl;

    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 6-a-b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc136/tasks/abc136_c
# 前から順に最善を考えていけば良い

N = int(input())
H = list(map(int, input().split()))


# 1 2 1 1 3
# 0 1 1 1 2 みたいにして判別する

# 1 3 1 1 3
# 0 2 1 #この時点でだめ

pre = H[0] - 1  # 一段下げても`悪化しない`
for h in H[1:]:
    if h > pre:
        pre = h - 1
    elif h == pre:
        pre = h
    elif h < pre:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
int main() {
	int i,j,a,l;
	string n;
	cin>>n;
	l=n.size();
	for(i=0; i<l; i++)
		if(n[i]=='C')
			for(j=i+1; j<l; j++)
				if(n[j]=='F') {
					cout<<"Yes"<<endl;
					return 0;
				}
	cout<<"No"<<endl;
	return 0;
}

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

typedef long long ll;
const ll mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<vector<int>> edges(100010);
vector<vector<ll>> dp(2,vector<ll>(100010,1));

void dfs(int i,int par) {
    for (int j : edges[i]) if (j != par) dfs(j,i);

    for (int j : edges[i]) if (j != par) {
        dp[0][i] *= dp[0][j]+dp[1][j];
        dp[1][i] *= dp[0][j];
        dp[0][i] %= mod;
        dp[1][i] %= mod;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0;i < n-1;++i) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
    dfs(0,-1);
    cout << (dp[0][0]+dp[1][0]+mod*2)%mod << endl;
    return 0;
}

Measured memory_bytes: 12912
#include <iostream>
using namespace std;
int main(){
    int n,sum=0; cin >> n;
    int A[n], B[n], C[n];
    for (int i=0; i<n; i++){
        cin >> A[i];
    }
    for (int i=0; i<n; i++){
        cin >> B[i];
    }
    for (int i=0; i<n-1; i++){
        cin >> C[i];
    }
    for (int i=0; i<n; i++){
        sum += B[A[i]-1];
        if (i>=1 && (A[i]-A[i-1] == 1)){
            sum += C[A[i-1]-1];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<int> v;

void init(int n) {
  v = vector<int>(n, 1);
  for (int i = 1; i < n; i++) {
    v[i] = v[i-1]*2%MOD;
  }
}
 
int f(int n) {
  return v[n]-1;
}
 
signed main() {
  int N; 
  cin >> N;

  init(200010);
  map<pair<int, int>, pair<int, int>> m;

  int zero = 0;
  REP(i, N){
    int x, y;
    cin >> x >> y;
    if(x == 0 && y == 0){
      zero++;
      continue;
    }

    int g = gcd(x, y);
    x /= g; y /= g;
    if(y < 0){
      x = -x;
      y = -y;
    }
    if(y == 0 && x < 0) x = -x;

    bool rot = false;
    if(x <= 0) rot = true;
    if(rot){
      int tmp = x;
      x = y; y = -tmp;
    }
    if(rot) m[{x, y}].first++;
    else m[{x, y}].second++;
  }

  int ans = 1;
  for(auto p : m){
    int v = p.second.first;
    int u = p.second.second;
    int now = ((f(v)+f(u)+1)%MOD+MOD)%MOD;
    (ans *= now) %= MOD;
  }

  cout << ((ans+zero-1)%MOD+MOD)%MOD << "\n";

  return 0;
}

Measured memory_bytes: 20324
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>
#include <numeric>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int n, m;
	cin >> n >> m;
	vector<int> l(m), r(m);
	rep(i, m) cin >> l[i] >> r[i];

	// 重複部分を取る
	/*vector<ll> sum(n + 1, 0);

	rep(i, m) {
		sum[r[i]]++;
		sum[l[i] - 1]++;
	}

	rep(i, n + 1) {
		cout << sum[i] << " ";
	}
	cout << endl;*/

	int lmax = 0;
	int rmin = inf;
	rep(i, m) {
		lmax = max(lmax, l[i]);
		rmin = min(rmin, r[i]);
	}

	cout << max(rmin - lmax + 1, 0) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){

  int W = 0;
  int H = 0;
  int x = 0;
  int y = 0;
  int r = 0;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(0 <= x-r && W >= x+r && 0 <= y-r && H >= y+r)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define INF 1e7
#define mod 1000000007

using namespace std;
typedef long long int ll;
typedef tuple<int,int,int> tii;
typedef tuple<long long int,long long int,long long int> tll;
typedef tuple<double,double,double> tdd;


int main()
{
    int N; cin >> N;
    bool f = true;
    int k;
    for(k = 1; k*(k-1)/2 <= N; k++) 
    {
        if(k*(k-1)/2 == N) 
        {
            f = false;
            break;
        }
    }
    if(f) 
    {
        cout << "No" << endl;
        return 0;
    }
    else 
    {
        cout << "Yes" << endl;
        cout << k << endl;
    }
    for(int i = 1; i <= k; i++)
    {
        cout << k-1 << " ";
        if(i == 1) 
        {
            for(int j = 1; j*(j-1)/2 + 1 <= N; j++) cout << j*(j-1)/2 + 1 << " ";
            cout << endl;
        }
        else if(i == 2)
        {
            int first = 1;
            for(int j = 1; j <= k-1; j++)
            {
                cout << first << " ";
                first += j+1;
            }
            cout << endl;
        }
        else
        {
            int first = (i-1)*(i-2)/2 + 1;
            for(int j = 1; j <= i-1; j++)
            {
                cout << first << " ";
                first++;
            }
            first--;
            first += i-1;
            for(int j = i; j <= k-1; j++)
            {
                cout << first << " ";
                first += j;
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>

bool dfs(int i, std::vector<int>& A, int qn, int sum, int n)
{
	if (sum == qn)
		return true;
	if (i == n - 1)
		return false;
	if (dfs(i + 1, A, qn, sum +  A.at(i + 1), n))
		return true;
	if (dfs(i + 1, A, qn, sum, n))
		return true;
	return false;
}

int main()
{
	int n, q;
	std::cin >> n;
	std::vector<int> A(n);
	for (int i = 0; i < n; i++)
	{
		int a;
		std::cin >> a;
		A.at(i) = a;;
	}
	std::cin >> q;
	std::vector<int> Q(q);
	for (int i = 0; i < q; i++)
	{
		int x;
		std::cin >> x;
		Q.at(i) = x;
	}
	for (int x = 0; x < q; x++)
	{
		int qn = Q.at(x);
		if (dfs(-1, A, qn, 0, n))
			std::cout << "yes\n";
		else
			std::cout << "no\n";
	}
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	string s;
	cin>>n>>s>>k;
	for(int i = 0; i < n; ++i){
		if(s[i] != s[k - 1])s[i] = '*';
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1,d2,d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    n = II()
    now_t = 0
    now_x = now_y = 0
    for i in range(n):
        t, x, y = MII()
        dt = t - now_t
        dx = x - now_x
        dy = y - now_y
        if dx+dy > dt: print('No'); return None
        if (dx+dy)%2 != dt%2: print('No'); return None
    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//E
int compare_int(const void *a, const void *b) {//sort
  return *(int*) a - *(int*) b;
}
int main(void) {
  int n, k, i, cou=0, tmp;
  scanf("%d", &n);
  int a[n];
  for(i=0; i < n; i++){
    scanf("%d", &a[i]);
  }
  qsort(a, n, sizeof(int), compare_int);//sort

  for(i=0; i < n-1; i++){
    if(a[i]==a[i+1]){
      printf("NO");
      return 0;
    }
  }
  printf("YES");
  return 0;
}


Measured memory_bytes: 1788