akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct  Edge{
	int from,to;
};

int V,E;
int max_height = 0;
int height[SIZE],in_num[SIZE],out_num[SIZE],DEPTH[SIZE];
int num_height[SIZE];
Edge edge[2*SIZE];
vector<int> G[SIZE],rev_G[SIZE];



int main(){

	scanf("%d %d",&V,&E);

	for(int i = 0; i < V; i++){

		in_num[i] = 0;
		out_num[i] = 0;
		num_height[i] = 0;
		DEPTH[i] = -BIG_NUM;
	}

	for(int i = 0; i < E; i++){

		scanf("%d %d",&edge[i].from,&edge[i].to);
		edge[i].from--;
		edge[i].to--;
		in_num[edge[i].to]++;
		out_num[edge[i].from]++;
		G[edge[i].from].push_back(edge[i].to);
		rev_G[edge[i].to].push_back(edge[i].from);
	}

	queue<int> Q;

	for(int i = 0; i < V; i++){
		if(in_num[i] == 0){

			DEPTH[i] = 0;
			Q.push(i);
		}
	}

	//トポロジカル順に最大深さを求める
	while(!Q.empty()){

		int node_id = Q.front();
		Q.pop();

		for(int i = 0; i < G[node_id].size(); i++){

			int child = G[node_id][i];
			DEPTH[child] = max(DEPTH[child],DEPTH[node_id]+1);
			in_num[child]--;
			if(in_num[child] == 0){

				Q.push(child);
			}
		}
	}

	for(int i = 0; i < V; i++){
		if(out_num[i] == 0){

			height[i] = 0;
			Q.push(i);
		}
	}

	//トポロジカル順に最大高さを求める
	while(!Q.empty()){

		int node_id = Q.front();
		Q.pop();

		for(int i = 0; i < rev_G[node_id].size(); i++){

			int parent = rev_G[node_id][i];
			height[parent] = max(height[parent],height[node_id]+1);
			max_height = max(max_height,height[parent]);
			out_num[parent]--;
			if(out_num[parent] == 0){

				Q.push(parent);
			}
		}
	}

	for(int i = 0; i < E; i++){

		if(DEPTH[edge[i].from]+height[edge[i].to]+1 != max_height)continue; //最長パス上にないエッジは無視

		num_height[height[edge[i].to]]++;
	}
	bool FLG = false;

	for(int i = 0; i < E; i++){

		if(DEPTH[edge[i].from]+height[edge[i].to]+1 != max_height)continue; //最長パス上にないエッジは無視

		if(num_height[height[edge[i].to]] == 1){

			printf("%d\n",i+1);
			FLG = true;
		}
	}

	if(!FLG){

		printf("-1\n");
	}

	return 0;
}



Measured memory_bytes: 16900
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c;
    while(cin>>a>>b>>c){
        map<int,int>m;
        m[a]++;
        m[b]++;
        m[c]++;
        map<int,int>::iterator it;
        for(it=m.begin();it!=m.end();it++){
            if((it->second) == 1)cout<<(it->first)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

ans = 'U' * dy + 'R' * dx
ans += 'D' * dy + 'L' * dx
ans += 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
ans += 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;

typedef long long ll;

ll n, m;
ll solve();
const int mod = 1e9+7;
ll factorial(ll n)
{
    ll ret = 1;
    for (ll i = 1; i <= n; ++i)
        ret = ret * i % mod;
    return ret;
}
int main()
{
    scanf("%lld %lld", &n, &m);
    printf("%lld\n", solve());
}
ll solve()
{
    if (n > m)
        swap(n, m);
    if (n == m)
    {
        ll f = factorial(n);
        return f*f%mod*2%mod;
    }
    if (n+1==m)
    {
        ll f = factorial(n);
        return f*f%mod*m%mod;
    }
    return 0;
}
    

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

int main() {
  long L,R;
  cin>>L>>R;
  long ans=9099;
  bool flg=false;
  for(long i=L;i<R;i++){
    for(long j=i+1;j<=R;j++){
      ans=min(ans,(i*j)%2019);
      if(ans==0){
        flg=1;
        break;
      }
    }
    if(flg) break;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3652
n = int(input())
k = list(map(int, input().split()))
p = min(k)
counta = 0
min_ = 2147483647
if max(k) == min(k):
    print(0)
    exit()

while p != max(k):
    tmp = 0
    for i in range(0,n):
        tmp += ((k[i]-p)**2)
    if tmp < min_:
        min_ = tmp
    p += 1
print(min_)

Measured memory_bytes: 3064
n = gets.strip.to_i

hist = 6.times.map{0}

n.times.each do
  h = gets.strip.to_f

  k = ((h - 160) / 5).floor
  if k < 0
    k = 0
  elsif k > 5
    k = 5
  end

  hist[k] += 1
end

for i in (0..5)
  puts "#{i + 1}:" + "*" * hist[i]
end

Measured memory_bytes: 6108
N,K=map(int,input().split())
S=input()
Happy=0
for i in range(N):
    if i>0 and S[i-1]==S[i]=='L':
        Happy+=1
    elif i<N-1 and S[i]==S[i+1]=='R':
        Happy+=1
print(min(Happy+2*K,N-1))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,K;
  cin >> N >> K;
  double ans = 0;
  for(int i=1;i<N+1;i++)
  {
    if(i>=K)
    {
      double k = 1;
      k /= N;
      ans += k;
    }
    else
    {
      double a = 1;
      a /= N;
      double n = i;
      while(n<K)
      {
        n *= 2;
        a /= 2;
      }
      ans += a;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3708
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            
            string input = Console.ReadLine();
            int n = int.Parse(input);

            int[] tako = new int[n];
            string[] takoyaki = Console.ReadLine().Split();
            int sum = 0;
            
            for(int i = 0;i < n ;i++)
                tako[i] = int.Parse(takoyaki[i]);

            for(int i = 0; i < n; i++)
                for(int j = i + 1; j < n;j++)
            {
                sum += tako[i] * tako[j];
            }

            Console.WriteLine(sum);
                
        }
    }

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;


int main(){
    ll N;
    cin>>N;
    vl A(N);
    vl la(N,0),ra(N,0);
    F0R(i,N){
        cin>>A[i];
    }
    ll maxi=0;
    F0R(i,N){
        la[i]=maxi;
        maxi=max(maxi,A[i]);
    }
    maxi=0;
    for(int i=N-1;i>=0;i--){
        ra[i]=maxi;
        maxi=max(A[i],maxi);
    }
    for(int i=0;i<N;i++){
        out(max(la[i],ra[i]));
    }

    return 0;
}


Measured memory_bytes: 6272
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};


int A[304][304];
int main(){
  int N, M;
  std::cin >> N >> M;
  for (int i=0; i<N; i++) {
    for (int j=0; j<M; j++) {
      std::cin >> A[i][j];
      A[i][j]--;
    }
  }
  std::vector<bool > canuse(M+4, true);
  int cnt = M;
  int ans = 1001001001;
  while(cnt>0) {
    std::map<int, int> mp;
    for (int i=0; i<N; i++) {
      for (int j=0; j<M; j++) {
        if (canuse[A[i][j]]){
          mp[A[i][j]]++;
          break;
        }
      }
    }
    int max = -1;
    int sportsid;
    for (auto &entry : mp) {
      if (entry.second > max) {
        max = entry.second;
        sportsid = entry.first;
      }
    }
    //printf("cnt=%d, max=%d\n", cnt, max);
    ans = std::min(ans, max);
    canuse[sportsid] = false;
    cnt--;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3528
# encoding:utf-8
import copy
import numpy as np
import random
import math
import bisect #bisect_left　これで二部探索の大小検索が行える

n = int(input())
traffic_time = []
for i in range(5):
    traffic_time.append(int(input()))

traffic_time.sort()

wait_time = math.ceil(n/traffic_time[0])
# print(wait_time)
# if wait_time <= 1:
#     wait_time = 0
wait_time -= 1
# if n%traffic_time[0] == 0:
#     wait_time -= 1

wait_time = max(wait_time,0)

print(wait_time+5)


Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	Int N, D;
	cin >> N >> D;


	Int ans = (N + 2 * D) / (2 * D + 1);
	cout << ans << "\n";


}

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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    vector <ll> arr(5,0);
    for (int z=0;z<6;z++){
    	ll temp;
    	cin >> temp;
    	arr[temp]++;
    }
    for (int z=1;z<5;z++){
    	if (arr[z] > 2){
    		cout << "NO" << endl;
          	return 0;
    	}
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break
    tile = [list(input()) for i in range(H)]
    x = y = 0
    while True:
        tmp = tile[y][x]
        tile[y][x] = "*"
        if tmp == "*":
            print("LOOP")
            break
        elif tmp == ">":
            x+=1
        elif tmp == "<":
            x-=1
        elif tmp == "^":
            y-=1
        elif tmp == "v":
            y+=1
        elif tmp == ".":
            print(x, y)
            break
#        print(x,y)


Measured memory_bytes: 5776
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  ll res = 0, sum = 0;
  for (int i = 0; i < N; i++) {
    ll A;
    cin >> A;
    if (A == 0) {
      res += sum / 2;
      sum = 0;
    } else {
      sum += A;
    }
  }
  res += sum / 2;
  cout << res << endl;
  return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\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<int> zAlgorithm(string& s) {
    int n = s.size();
    vector<int> ret(n,0);
    ret[0] = n;
    int i = 1,j = 0;
    while (i < n) {
        while (i+j < n && s[j] == s[i+j]) ++j;
        ret[i] = j;
        if (j == 0) {
            ++i;
            continue;
        }
        int k = 1;
        while (i+k < n && k+ret[k] < j) {
            ret[i+k] = ret[k];
            ++k;
        }
        i += k;
        j -= k;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0;i < n-1;++i) {
        string t = s.substr(i,n-i);
        vector<int> pre = zAlgorithm(t);
        for (int j = 1;j < n-i;++j) {
            ans = max(ans,min(j,pre[j]));
        }
    }
    cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  int red=0;
  int blue=0;
  for(int i=0 ; i<S.size() ; i++){
    if(S.at(i)=='0'){
      red++;
    }
    else{
      blue++;
    }
  }
  int x=min(red,blue);
  cout << 2*x << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
int a[MAXN],n,L;
int main()
{
	scanf("%d%d",&n,&L);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	bool flag=false;
	int pos=0;
	for(int i=1;i<n;++i)
		if(a[i]+a[i+1]>=L){flag=true,pos=i;break;}
	if(!flag){puts("Impossible");return 0;}
	else{
		puts("Possible");
		for(int i=1;i<pos;++i)
			printf("%d\n",i);
		for(int i=n-1;i>pos;--i)
			printf("%d\n",i);
		printf("%d\n",pos);
	}
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::multiset<int> s;
    for (int i = 0; i < n; i++) {
        int a; std::cin >> a;
        auto iter = s.lower_bound(a);
        if (iter == s.begin()) {
            s.insert(a);
        }
        else {
            iter--;
            s.erase(iter);
            s.insert(a);
        }
    }
    std::cout << s.size() << std::endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
        #include <math.h>
        using namespace std;
         
        int main(){
        	int n,k,s;
          	cin >> n >> k;
          	s =k;
              for(int i=0;i<n-1;i++){
              s*=k-1;
              }
          	cout << s;
        }

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

int main()
{
    int n,m;
    cin>>m>>n;
    vector<vector<char>> mat(m,vector<char> (n));
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
            cin>>mat[i][j];

    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
            cout<<mat[i][j];
        cout<<endl;
        for(int j=0;j<n;j++)
            cout<<mat[i][j];
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    string t; cin >> t;

    int sl = s.size();
    REP(i,sl) {
        bool ok = true;
        REP(j,sl) {
            if (s[(i+j) % sl] != t[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            OUT("Yes")
            return 0;
        }
    }

    OUT("No")
    
    return 0;
}

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

// 比較演算子を自動生成
#define CAT(a, b) a ## b
#define COMP_1(v1) return lhs.v1 < rhs.v1
#define COMP_2(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_1(__VA_ARGS__)
#define COMP_3(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_2(__VA_ARGS__)
#define COMP_4(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_3(__VA_ARGS__)
#define COMP_5(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_4(__VA_ARGS__)
#define LESS_THAN(A, n, ...) bool operator<(const A & rhs) const { auto& lhs = *this; CAT(COMP_, n)(__VA_ARGS__); }

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define FOR(i, s, n) for(ll i = (s); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()

// 10^x (by math)
#define TEN(x) ((ll)1e##x)

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;

void solution(istream& cin, ostream& cout) {
	ll n, m; cin >> n >> m;
	vvl g(n);
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	auto dijk = [](vvl& g) {
		struct P { ll dist, prev_id; };
		struct Q {
			ll dist, id, prev_id;
			bool operator<(const Q& rhs) const {
				if (dist != rhs.dist) return dist > rhs.dist;
				if (id != rhs.id) return id > rhs.id;
				return prev_id > rhs.prev_id;
			}			
		};

		vector<P> ret(g.size(), P{ -1, -1 });
		ret[0] = P{ 0, -1 };
		priority_queue<Q> q;
		q.push(Q{0, 0, -1});
		while (!q.empty()) {
			auto cur = q.top();
			q.pop();
			if (ret[cur.id].prev_id != cur.prev_id) continue;
			for (auto next : g[cur.id]) {
				if (ret[next].dist == -1 || ret[next].dist > cur.dist + 1) {
					ret[next] = P{ cur.dist + 1, cur.id };
					q.push(Q{ cur.dist + 1, next, cur.id });
				}
			}
		}

		return ret;
	};
	auto dij = dijk(g);
	FOR(i, 1, n) {
		if (dij[i].dist == -1) {
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes\n";
	FOR(i, 1, n) {
		cout << (dij[i].prev_id + 1) << "\n";
	}
}

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	solution(cin, cout);
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N, M;
vector<ll> A;
vector<bool> isBreak;
ll dp[MAX_N];

ll dfs(ll i = 0) {
    if(i >= N) { return 1; }
    if(isBreak[i]) { return 0; }

    ll& ret = dp[i];
    if(~ret) { return ret; }
    ret = 0;

    // 1 段上
    if(!isBreak[i + 1]) {
        ret += dfs(i+1);
        ret %= MOD;
    }
    if(i + 2 <= N && !isBreak[i + 2]) {
        ret += dfs(i+2);
        ret %= MOD;
    }

    return ret;
}

signed main()
{
    cin >> N >> M;
    A.resize(M);
    isBreak.assign(N, false);
    REP(i, M) {
        cin >> A[i];
        isBreak[A[i]] = true;
    }

    MINUS(dp);
    ll ans = dfs();
    printf("%lld\n", ans);
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

#define x(p) real(p)
#define y(p) imag(p)

const double eps=1e-8;
const double inf=1e12;
typedef complex<double> P;

namespace std{
  bool operator<(const P& a,const P& b){
    return x(a)==x(b)?y(a)<y(b):x(a)<x(b);
  }
}
double cross(const P& a,const P& b){
  return y(conj(a)*b);
}
double dot(const P& a,const P& b){
  return x(conj(a)*b);
}
struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

P projection(const L& l,const P& p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*x(c/b);
}
P reflection(const L& l,const P& p){
  return p+2.0*(projection(l,p)-p);
}
//// counter-clockwise
int ccw(P a,P b,P c) {
  b=b-a;c=c-a;
  if(cross(b,c)>0) return +1;       // counter clockwise
  if(cross(b,c)<0) return -1;       // clockwise
  if(dot(b,c)<0)   return +2;       // c--a--b on line
  if(norm(b)<norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L& l,const L& m){
  return abs(cross(l[1]-l[0],m[1]-m[0]))>eps;
}
bool intersectSS(const L& s,const L& t){
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0&&ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0;
}
P crosspoint(const L& l,const L& m) {
  double A=cross(l[1]-l[0],m[1]-m[0]);
  double B=cross(l[1]-l[0],l[1]-m[0]);
  if (abs(A)<eps&&abs(B)<eps) return m[0]; // same line
  if (abs(A)<eps) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0]+B/A*(m[1]-m[0]);
}
bool intersectSP(const L& s,const P& p){
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0])<eps;
}
double distanceSP(const L& s,const P& p) {
  const P r=projection(s,p);
  return intersectSP(s,r)?abs(r-p):min(abs(s[0]-p),abs(s[1]-p));
}
double distanceSS(const L& s,const L& t) {
  return intersectSS(s,t)?0:min(min(distanceSP(s,t[0]),distanceSP(s,t[1])),
                                min(distanceSP(t,s[0]),distanceSP(t,s[1])));
}

int main(){
	cin.sync_with_stdio(false);
  int q;
  cin>>q;
  while(q--){
    P p[4];
    rep(i,4){
      double x,y;
      cin>>x>>y;
      p[i]=P(x,y);
    }
    printf("%.10f\n", distanceSS(L(p[0],p[1]),L(p[2],p[3])));
  }
  return 0;
}

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

int main(){
    int i = 0;
    while(i < 10000){
        int x;
        scanf("%d", &x);
        if(x == 0) break;
        i++;
        printf("Case %d: %d\n", i, x);
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		//入力表示
		int N = scanner.nextInt();
		
      	//1以上９以下の場合
		for (int a = 1; a <= 9; a++) {
			for (int b = 1; b <= 9; b++) {
				if (N == a * b) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}

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

using namespace std;

typedef long long ll;

int N;
ll A[2 * 100000 + 10];

vector<vector<ll>> L;

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

	int cnt = 0;
	L.resize(N);
	for (int i = 0; i < N; i++) {
		if (A[i] == 0 && i != 0)cnt++;
		L[cnt].push_back(A[i]);
	}

	ll ans = 0;
	for (int i = 0; i < L.size(); i++) {
		if (L[i].size() == 0)continue;

		for (int j = 0; j < L[i].size(); j++) {
			if (L[i][j] > j) {
				cout << "-1" << endl;
				return 0;
			}
			if (j > 0 && (L[i][j] > L[i][j - 1] + 1)) {
				cout << "-1" << endl;
				return 0;
			}
		}
		
		for (int j = 1; j < L[i].size(); j++) {
			if (L[i][j] == L[i][j - 1] + 1)ans++;
			else ans += (L[i][j]);
		}

	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
	int N,sc,count=0;
	cin>>N;
	vector<vector<int>> v(N);
	for(int i=0;i<N;i++)
	{
		cin>>sc;
		v[i].push_back(sc);
		cin>>sc;
        v[i].push_back(sc);
	}
	
	for(int i=0; count<3&&i<N;i++)
	{
		if((count==1||count==2)&&v[i][0]!=v[i][1])
		count=0;
	if(v[i][0]==v[i][1])
	count++;
    }
    
    if(count==3)
    cout<<"Yes";
    else cout<< "No";
}
	


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<string.h>
#include<cmath>
#include<algorithm>
#include<assert.h>
using namespace std;
#define endl '\n'
#define int long long
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const ll INF=4223372036854775807,max_n=200005,mod=1e9+7;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int weizhi1=-1;
int weizhi2=-1;
int x;
ll a[max_n];
ll b[max_n];
ll max1;
signed main()
{
	ll n,m,k;cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[i]=a[i-1]+x;
	}
	for(int i=1;i<=m;i++)
	{
		cin>>x;
		b[i]=b[i-1]+x;
	}
	for(int i=0;i<=n;i++)
	{
		if(a[i]>k)break;
		else
		{
			ll dang=k-a[i];
			//ÏÂÃæÔÚbÊý×éÖÐ¶þ·Ö²éÕÒ
			ll tt=upper_bound(b+1,b+1+m,dang)-b-1;
			max1=max(max1,i+tt);
		}
	}
	cout<<max1;
}

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

int main() {
    char ch;
    cin >> ch;
    switch(ch) {
        case 'a':
        case 'i':
        case 'u':
        case 'e':
        case 'o':
            cout << "vowel" << endl;
            break;
        default:
            cout << "consonant" << endl;
            break;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

main(){
	int a, b, c,i,sort[3];
	
	scanf("%d%d%d",&a,&b,&c);
	
	if(a<b){
		if(a<c){
			if(b<c){
				sort[0]=a;
				sort[1]=b;
				sort[2]=c;
			}
			else{
				sort[0]=a;
				sort[1]=c;
				sort[2]=b;
			}
		}
		else{
			sort[0]=c;
			sort[1]=a;
			sort[2]=b;
		}
	}
	else{
		if(a<c){
			sort[0]=b;
			sort[1]=a;
			sort[2]=c;
		}
		else{
			if(b<c){
				sort[0]=b;
				sort[1]=c;
				sort[2]=a;
			}
			else{
				sort[0]=c;
				sort[1]=b;
				sort[2]=a;
			}
		}
	}
	
	printf("%d %d %d\n",sort[0],sort[1],sort[2]);
	
	return 0;
}

Measured memory_bytes: 596
loop = False
while 1:
    m = int(raw_input())
    if m == 0: break
    if loop is True: print ''
    cm = [10, 50, 100, 500]
    c = map(int, raw_input().split())
    mintn = 81
    fc = [0 for i in xrange(4)]
    mc = [0 for i in xrange(4)]
    t = 0
    for i in xrange(4):
        t += c[i]*cm[i]
        ch = t-m
    for i in xrange(3,-1,-1):
        while(ch >= cm[i]):
            ch -= cm[i]
            mc[i] += 1
    for i in xrange(4):
        fc[i] = c[i] - mc[i]
        if fc[i] < 0: fc[i] = 0
    for i in xrange(4):
        if fc[i] != 0: print "%d %d" % (cm[i], fc[i])
    loop = True

Measured memory_bytes: 5596
#include <stdio.h>
int main(){
  char c[300];
  int m,h,i,j,k,num=0,temp;
  while(1){
    scanf("%s",&c);
    if(c[0]=='-')break;
    for(num=0; num<300; num++)if(c[num]=='\0')break;
    scanf("%d",&m);
    for(i=0; i<m; i++){
      scanf("%d",&h);
      for(j=0; j<h; j++){
    temp=c[0];
    for(k=0; k<num; k++){
          c[k]=c[k+1];
    }
        c[num-1]=temp;
      }
    }
    printf("%s\n",&c);
  }
  return 0;
}



Measured memory_bytes: 2068
n = int(input())
a = [int(input()) for i in range(n)]

ans = 0

for i in range(n - 1, -1, -1):
	if i == 0 and a[i] != 0:
		print(-1)
		exit()
	else:
		if a[i - 1] + 1 < a[i]:
			print(-1)
			exit()
		elif a[i - 1] + 1 == a[i]:
			ans += 1
		else:
			ans += a[i]
print(ans)

Measured memory_bytes: 57660
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll A, B, T;
  cin >> A >> B >> T;
  ll c = T / A;
  COUT(B * c);
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>

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

    int q;
    scanf("%d", &q);
    int t[q];
    for (int j = 0; j < q; j++) {
        scanf("%d", &t[j]);
    }

    int answer = 0;
    for (int j = 0; j < q; j++) {
        for (int i = 0; i < n; i++) {
            if (t[j] == s[i]) {
                answer++;
                break;
            }
        }
    }
    
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 2740
function main(input) {
  	input = input.split(" ");
  	var numberOfTrees = parseInt(input[0]);
    var D = parseInt(input[1]);
    var firstPoint = D + 1;
    var j = firstPoint + D;
    var checkModulo = numberOfTrees%j;
    if (checkModulo) {
        var i = numberOfTrees / j;
        return Math.trunc( i ) + 1;
    } else {
        return numberOfTrees / j;
    }
}
console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  set<char> set;
  for(int i = 0;i < s.size();i++) {
    set.insert(s.at(i));
  }
  char c = 'a';
  for(int i = 0;i < 26;i++) {
    if(!set.count(c)) {
      cout << c << endl;
      return 0;
    }else {
      c++;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll dp[101][4][4][4];
char conv[] = "ACGT";

bool check(string str) {
	REP(i, (int)str.size() - 2) if (str.substr(i, 3) == "AGC") return false;
	REP(i, (int)str.size() - 1) {
		string cur = str;
		swap(cur[i], cur[i + 1]);
		REP(j, (int)cur.size() - 2) if (cur.substr(j, 3) == "AGC") return false;
	}
	
	return true;
}

int main() {
	int N;
	cin >> N;
	
	dp[0][0][0][0] = 1;
	REP(i, N) {
		REP(j, 4) REP(k, 4) REP(l, 4) {
			if (!dp[i][j][k][l]) continue;
			
			string cur;
			if (i >= 3) cur += conv[j];
			if (i >= 2) cur += conv[k];
			if (i >= 1) cur += conv[l];
			
			REP(m, 4) {
				string next = cur;
				next += conv[m];
				if (check(next)) (dp[i + 1][k][l][m] += dp[i][j][k][l]) %= MOD;
			}
		}
	}
	
	ll ans = 0;
	REP(i, 4) REP(j, 4) REP(k, 4) (ans += dp[N][i][j][k]) %= MOD;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,a,b,c[17]={0};
	scanf("%d %d",&a,&b);
	for(i=1;a>0&&i<17;i++)
	{
		if(c[i]==0&&c[i-1]!=1)
		{
			a--;
			c[i]=1;
		}	
	}
	for(i=1;i<17&&b>0;i++)
	{
		if(c[i]==0&&c[i-1]!=2)
		{
			b--;
			c[i]=2;
		}	
	}
	if(a==0&&b==0)
		printf("Yay!");
	else
		printf(":(");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
  vector<ll> sugar;
  for (ll i = 0; i <= 3000; i++) {
    for (ll j = 0; j <= 1500; j++) {
      if (C*i+D*j <= F) {
        sugar.push_back(C*i+D*j);
      }
    }
  }
  sort(sugar.begin(), sugar.end());
  
  vector<ll> water;
  for (ll i = 0; i <= 30; i++) {
    for (ll j = 0; j <= 15; j++) {
      if (0< A*100*i+B*100*j && A*100*i+B*100*j <= F) {
        water.push_back(A*100*i+B*100*j);
      }
    }
  }
  vector<double> density;
  map<double, ll> dw;
  map<double, ll> ds;
  for (ll i = 0; i < water.size(); i++) {
    ll w = water[i];
    ll s = *(upper_bound(sugar.begin(), sugar.end(), min(F-w, E*w/100))-1);
    //cout << w << " " << s << endl;
    double d = (double)s/(double)(w+s);
    //cout << d << endl;
    density.push_back(d);
    dw[d] = w;
    ds[d] = s;
  }
  sort(density.begin(), density.end());
  double d = density[density.size()-1];
  //cout << d << endl;
  cout << dw[d]+ds[d] << " " << ds[d] << endl;
}

Measured memory_bytes: 2420
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
int prime(int n)
{
 for(int i=2;i*i<=n;i++)
      {
          if(n%i==0)
          return 0;
      }
      return 1;
}
int gcd(int a, int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
int lcm(int a, int b)  
  {  
     return (a*b)/gcd(a, b);  
  } 
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {  
        int a,b;
        cin>>a>>b;
        cout<<lcm(a,b);
        
        
    }
    
}
// 🍪 🍪 🍪


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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
      int n;
      cin >> n;
      ll ans=0;
      for(int i=0;i<n-1;i++){
         ll a,b;
         cin >> a >> b;
         ans -= (min(a,b))*(n-max(a,b)+1);
      }
      for(ll i=1;i<=n;i++){
         ans += i*(n-i+1);
      }
      cout << ans;
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3808
#include <stdio.h>

int main(){
  int i,j,k;
  int n;
  scanf("%d",&n);
  int L[150];
  int ans = 0;
  for(i=0;i<n;++i){
    scanf("%d",&L[i]);
  }
  for(i=0;i<n;++i){
    for(j=i+1;j<n;++j){
      for(k=j+1;k<n;++k){
		//printf("%d %d %d\n",i,j,k);
        if(L[i]>=L[j]+L[k])continue;
        if(L[j]>=L[i]+L[k])continue;
        if(L[k]>=L[j]+L[i])continue;
        if(L[i]==L[j])continue;
        if(L[j]==L[k])continue;
        if(L[k]==L[i])continue;
  		ans++;      
      }
    }
  }
  
  printf("%d\n",ans);
}

Measured memory_bytes: 1732
n=int(input());l=[0,1];a=0;b=c=1;p=998244353
for i in range(2,n//2+1):
 l+=[l[p%i]*(p-int(p/i))%p]
for i in range(n,n//2,-1):
 a+=b*c%p;b=2*b%p;c=c*i*l[n+1-i]%p
print((pow(3,n,p)-2*a+p)%p)

Measured memory_bytes: 132500
#include <iostream>

using namespace std;

int main()
{
    int n,c=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]%2==0){
            if((a[i]%3!=0)&&(a[i]%5!=0)){
                c++;
                break;
            }
        }
    }
    if(c==0) cout << "APPROVED";
    else cout <<"DENIED";
    
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = list(input())
t = list(input())

n = len(s)
flag2 = 0
for i in range(n):
    flag = 0
    for j in range(n):
        index = min(i + j, i + j - n)
        if s[index] == t[j]:
            flag += 1
    if flag == n:
        print("Yes")
        exit()
    else:
        flag2 += 1
if flag2 == n:
    print("No")


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  char curr = 't';
  while(true)
  {
    if(curr == 't')
    {
      c -= b;
      if( c <= 0)
      {
        cout << "Yes\n";
        return 0;
      }
      curr = 'a';
    }
    else
    {
      a -= d;
      if(a <= 0 )
      {
        cout << "No\n";
        return 0;
      }
      curr = 't';
    }
  }
}

Measured memory_bytes: 3572
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  double x, h;
  while (cin >> x >> h, x) {
    cout << prec(8) << x * x + x * hypot(h, x / 2) * 2 << endl;
  }
}

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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

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

  int n; cin >> n;
  vector<int> a(n+1), b(n);
  for (auto &i : a) cin >> i;
  for (auto &i : b) cin >> i;

  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    int mm = min(a[i], b[i]);
    ans += mm;
    a[i] -= mm;
    b[i] -= mm;

    mm = min(a[i+1], b[i]);
    ans += mm;
    b[i] -= mm;
    a[i+1] -= mm;
  }

  cout << ans << ende;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    string r, g, b; cin >> r >> g >> b;
    string ans = r + g + b;

    if (stoi(ans) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

int n;
vector<ll> a;
vector<ll> imos;

ll sum(ll l, ll r){
    return imos[r] - imos[l];
}

ll get(int l, int r, ll lb){
    // l:bad, r:good
    ll x = l;
    // cout << l << ' ' << r << ' ' << lb << "->";
    while(l+1 < r){
        int m = (l+r)/2;
        if(sum(x,m) < lb) l = m;
        else r = m;
    }
    // cout << r << endl;
    return r;
}

bool check(ll lb){
    // cout << lb << endl;
    rep(i,n){
        ll x = get(i,i+n,lb);
        ll y = get(x,i+n,lb);
        if(sum(i,x) >= lb && sum(x,y) >= lb && sum(y,i+n) >= lb){
            return true;
        }
    }
    return false;
}

ll solve(){
    a.insert(a.end(), a.begin(), a.end());
    imos.assign(a.size()+1,0);
    rep(i,a.size()) imos[i+1] = imos[i] + a[i];
    ll l = 1, r = imos[n];
    while(l+1 < r){
        ll m = (l+r)/2;
        if(check(m)) l = m; else r = m;
    }
    return l;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(cin >> n){
        a.resize(n);
        rep(i,n) cin >> a[i];
        cout << solve() << endl;
    }
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N;
    cin >> N;
    vector<lint> A(N);
    rep(i, N) cin >> A[i];

    const lint M = 1001000;
    // const lint M = 20;
    vector<vector<lint>> primes(M + 1, vector<lint>(0));
    for (int p = 2; p <= M; p++) {
        if (primes[p].size() != 0) continue;
        for (int pk = p; pk <= M; pk += p) {
            primes[pk].push_back(p);
        }
    }

    vector<lint> min_factor(M, 1);
    for (int p = 2; p <= M; p++) {
        if (min_factor[p] != 1) continue;
        for (int pk = p; pk <= M; pk += p) {
            if (min_factor[pk] == 1) min_factor[pk] = p;
        }
    }
    // dump(min_factor);

    lint G      = 0;
    rep(i, N) G = __gcd(G, A[i]);
    if (G != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    set<lint> used;
    for (int i = 0; i < N; i++) {
        // for (auto p : primes[A[i]]) {
        //     if (used.count(p) == 1) {
        //         cout << "setwise coprime" << endl;
        //         return 0;
        //     } else {
        //         used.insert(p);
        //     }
        // }

        set<lint> primess{};
        int a = A[i];
        while (a != 1) {
            primess.insert(min_factor[a]);
            a /= min_factor[a];
        }
        for (auto p : primess) {
            if (used.count(p) == 1) {
                cout << "setwise coprime" << endl;
                return 0;
            } else {
                used.insert(p);
            }
        }
    }

    cout << "pairwise coprime" << endl;

    return 0;
}

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

int n;
vector<array<int, 3>> arr;
int dp[100009][4];

int solve(int id, int k)
{
	if(id == n)
		return 0;
	if(dp[id][k] != -1)
		return dp[id][k];
	vector<int> v = {0, 1, 2};
	if(id) v.erase(v.begin() + k);
	int ans = 0;
	for(int &x : v)
		ans = max(ans, arr[id][x] + solve(id + 1, x));
	return dp[id][k] = ans;
}

int main()
{
	cin >> n;
	memset(dp, -1, sizeof(dp));
	for(int i = 0; i < n; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		arr.push_back({a, b, c});
	}
	cout << solve(0, 3) << '\n';

	return 0;
}

Measured memory_bytes: 15476