akhauriyash/Code-Regression huggingface dataset:
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
ll dist[123456];
vector<vi> adj(123456),cost(123456);
int dfs(int cur,int prev,ll dis){
	dist[cur]=dis;
	int i;
	rep(i,adj[cur].size()){
		if(adj[cur][i]==prev)
			continue;
		dfs(adj[cur][i],cur,dis+cost[cur][i]);
	}
	return 0;
}
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int i,u,v,w;
    rep(i,n-1){
    	cin>>u>>v>>w;
    	adj[u].pb(v);
    	adj[v].pb(u);
    	cost[u].pb(w);
    	cost[v].pb(w);
    }
    int q,k;
    cin>>q>>k;
    dfs(k,-1,0);
    while(q--){
    	cin>>u>>v;
    	cout<<dist[u]+dist[v]<<endl;
    }

    return 0;      

}



Measured memory_bytes: 19328
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

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

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
/* にゃーん  */


int main(){
    int a,b,c,x,y,z=0,ans = 0;
    cin >> a >> b >> c >> x >> y;
    if((a+b) > c*2){
        int max = 0;
        if(x>y){
            max = x;
        }else{
            max = y;
        }
        int ans_ = max*2* c;
        while(x>0&&y>0){
            x--;
            y--;
            z+=2;
        }
        ans = c*z+a*x+b*y;
        if(ans>ans_){
            ans = ans_;
        }
    }else{
        ans = a*x + b*y;
    }
    

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

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    ll n = 0, m = 0;
    cin >> n >> m;
    vector<pair<ll, ll>> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i).first >> a.at(i).second;
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    priority_queue<ll> que;
    ll now = 0;
    for (int i=1; i<=m; i++) {
        while (now < n && a.at(now).first <= i) {
            que.push(a.at(now).second);
            now++;
        }
        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2936
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/11/20 07:29:12
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<pair<int, ll>> graph[100001];
vector<ll> dist;
bool dfs(int s, ll l) {
  if (dist[s] == -1) {
    dist[s] = l;
  } else {
    return l == dist[s];
  }
  bool res = true;
  for (auto t:graph[s]) {
    res &= dfs(t.first, l+t.second);
  }
  return res;
}

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

  int n, m;
  cin >> n >> m;
  vector<bool> root(n, true);
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r; l--; r--;
    ll d;
    cin >> d;
    graph[l].emplace_back(r, d);
    root[r] = false;
  }

  dist.resize(n, -1);
  bool ans = true;
  for (int i = 0; i < n; i++) {
    if (not root[i]) continue;
    ans &= dfs(i, 0ll);
  }
  ans &= *min_element(dist.begin(), dist.end()) == 0;
  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 11264
from collections import deque
D,G = [int(i) for i in input().split()]
P = [0]*D
n = 0
for i in range(D):
    p,c = [int(j) for j in input().split()]
    P[i] = [int(k) * 100 * (i+1) for k in range(p+1)]
    P[i][-1] += c
    n += p
deq = deque()
ans = n
deq.append((0,0,0))
dic = {}

while(len(deq)>0):
    tmp = deq.pop()
    if tmp[0]+1 > len(P):
        break
    for i,j in enumerate(P[tmp[0]]):
        cand = (tmp[0]+1, tmp[1]+i, tmp[2]+j)
        if cand[1] < ans:
            if cand[2] < G:
                if cand[1] not in dic:
                    dic[cand[1]] = cand[2]
                    deq.appendleft(cand)
                elif dic[cand[1]] <= cand[2]:
                    dic[cand[1]] = cand[2]
                    deq.appendleft(cand)
            else:
                ans = cand[1]
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 H, W, N, SR, SC;
  string S, T;
  cin >> H >> W >> N >> SR >> SC >> S >> T;

  i64 L = 0, R = W + 1, U = 0, D = H + 1;
  rrep(i, N - 1, -1){
    if(T[i] == 'L') R = min(R + 1, W + 1);
    if(T[i] == 'R') L = max(L - 1, i64(0));
    if(T[i] == 'U') D = min(D + 1, H + 1);
    if(T[i] == 'D') U = max(U - 1, i64(0));

    if(S[i] == 'L') L++;
    if(S[i] == 'R') R--;
    if(S[i] == 'U') U++;
    if(S[i] == 'D') D--;

    if(L + 1 == R or U + 1 == D){
      cout << "NO\n";
      return;
    }
  }

  if(SR <= U or D <= SR or SC <= L or R <= SC){
    cout << "NO\n";
  }else{
    cout << "YES\n";
  }

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 920
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int a,b,n,m,ans=0;
    string s,t;
    cin>>n>>a>>b;
    if(n*a>b){
        cout<<b<<endl;
    }
    else    cout<<(n*a)<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int k;
    cin >> s >> k;
    int n=s.size();

    for(int i = 0; i < n; i++) {
        int cost=s[i]-'a';
        if(cost!=0) cost=26-cost;
        if(k<cost) continue;
        else{
            s[i]='a';
            k-=cost;
        }
    }
    s[n-1]+=k%26;
    cout << s << "\n";

    return 0;
}

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

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

const ll mod =  998244353;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976
const double PI = 3.1415926535897932;

int main()
{
    string s; cin >> s;
    int n = s.size()-1;
    char c = s[n];
    if(s[n] == '3') cout << "bon";
    else if(c == '0' || c == '1' || c == '6' || c == '8') cout << "pon";
    else cout << "hon";
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 200005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,m;
	cin>>n>>m>>k;
	ll ar[n+1],br[m+1],psm[m+1];
	psm[0]=0;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(i=1;i<=m;i++){
		cin>>br[i];
		psm[i]=psm[i-1]+br[i];
	}

	ll s=0,ans=0;
	ll a,b,mid,an=0;
	a=1; b=m;
	while(b>=a){
		mid=(a+b)/2;
		if(psm[mid]+s<=k){
			an=mid;
			a=mid+1;
		}
		else b=mid-1;
	}
	ans=max(ans,an);

	for(i=1;i<=n;i++){
		s+=ar[i];
		if(s>k) continue;
		a=1; b=m; an=0;
		while(b>=a){
			mid=(a+b)/2;
			if(psm[mid]+s<=k){
				an=mid;
				a=mid+1;
			}
			else b=mid-1;
		}
		ans=max(ans,an+i);
		// cout<<an<<" "<<i<<endl;
	}
	cout<<ans;
	return 0;	
}

Measured memory_bytes: 8344
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <sstream>

#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>

#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main(){
	int cont = 0;
	string x, y;
	cin >> x >> y;
	
	for(int i = 0; i < x.length(); i++){
		if(x[i] != y[i]) cont++;
	}
	
	cout << cont << endl;


	return 0;
}


Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
 
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
 
void solve()
{
    int n[5];
    rep(i,5)
        cin >> n[i];
    rep(i,5)
    {
        if(n[i]==0)
        {
            cout << i+1 << "\n";
            break;
        }
    }
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    int t=1;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3644
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

    N, M, X = map(int, input().split())
    A = []
    for i in range(N):
        a = [int(x) for x in input().split()]
        A.append(a)

    ans = 10 ** 7
    for bit in range(1 << N):
        res = [0 for _ in [0] * (M + 1)]
        for i in range(N):
            if bit & (1 << i):
                res = [a + b for a, b in zip(res, A[i])]
        if all(a >= X for a in res[1:]):
            ans = min(ans, res[0])
    if ans == 10 ** 7:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    int n,x = 1;
    cin >> n;
    while(x <= 50000  || x <= n){
      	int s = x*1.08;
        if(n == s){
            cout << x << endl;
            return 0;
        }
        x++;
    }
    cout << ":(" << endl;
}


Measured memory_bytes: 256
program sample
    implicit none
    character(1000)::s
    integer(8) :: i,j,m,n,a,b,x(26),y(26)
    
    read(*,*) n
    
    read(*,*)s
    x(:)=0
    y(:)=0

    do i=1,n
        call alfnumber(s(i:i),a)
        y(a)=y(a)+1
    end do
    m=0

    do i=1,n
        call alfnumber(s(i:i),a)
        y(a)=y(a)-1
        x(a)=x(a)+1
        b=0
        do j=1,26
            if(x(j)*y(j)>0)then
                b=b+1
            end if
        end do
        if (b>m)then
            m=b
        end if
    end do
    write(*,*) m
  
    stop
    contains
    subroutine alfnumber(st,a)
        implicit none
        character,intent(in) :: st
        integer(8),intent(out) ::  a
        integer::i
        character(1)::ch(26)
        ch=(/'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'/)
        do i=1,26
            if(st .eq. ch(i))then
                a=i
                return
            end if
        end do 
        end subroutine alfnumber
end program sample
  



Measured memory_bytes: 2860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long double A,B,H,M;
  cin >> A >> B >> H >> M;
  
  long double radA,radB,rad;

  radA = 30 * H + 0.5 * M;
  radB = 6 * M;
  rad = fabs(radB - radA);

  long double length_A;
  length_A = pow(A,2) + pow(B,2) - 2*A*B*cos(rad*3.14159265358979323846/180);
  length_A = pow(length_A,0.5);

  printf("%20.20Lf\n", length_A);
}

Measured memory_bytes: 4168
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define sll(n) scanf("%lld",&n)
#define sll2(x,y) scanf("%lld%lld",&x,&y)
#define sll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define REP(i,x,y) for(ll i = x;i <= y;++i)
#define debug(x) cerr<<#x<<"::"<<x<<endl
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<"\n"
ll power(ll x,ll y,ll z) {
	ll ret = 1;
	while(y > 0) {
		if(y & 1) ret = (ret*x)%z;
		x = (x*x)%z;
		y >>= 1;
	}
	return ret;
}
const ll N = 105, inf = 1e15;
ll dp[N][N];
string s[N];
int main() {
 
	ll n,m;
	sll2(n,m);
	REP(i,0,n-1) cin >> s[i];
	// REP(i,1,n) REP(j,1,m) dp[i][j] = inf;
	char pre = '$';
	REP(j,1,m) {
		dp[1][j] = dp[1][j - 1];
		if(s[0][j - 1] == '#') {
			if(pre != '#') dp[1][j]++;
		}
		pre = s[0][j - 1];
	}
	pre = s[0][0];
	REP(i,2,n) {
		REP(j,1,m) {
			if(j == 1) {
				dp[i][j] = dp[i - 1][j];
				if(s[i - 1][0] == '#' && pre != '#') dp[i][j]++;
				pre = s[i - 1][0];
			} else {
				char up = s[i - 2][j - 1],lf = s[i - 1][j - 2], curr = s[i - 1][j - 1];
				if(up == '#' && lf == '#') {
					dp[i][j] = min(dp[i][j - 1], dp[i - 1][j]);
					
				} else if(up == '#' && lf == '.') {
					if(curr == '#') {
						dp[i][j] = min(dp[i - 1][j], dp[i][j - 1] + 1);
					} else {
						dp[i][j] = min(dp[i][j - 1], dp[i - 1][j]);
					}
				} else if(up == '.' && lf == '#') {
					if(curr == '#') {
						dp[i][j] = min(dp[i - 1][j] + 1, dp[i][j - 1]);
					} else {
						dp[i][j] = min(dp[i][j - 1], dp[i - 1][j]);
					}
				} else {
					if(curr == '#') {
						dp[i][j] = 1 + min(dp[i - 1][j], dp[i][j - 1]);
					} else {
						dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
					}
				}
			}
		}
	}
	printf("%lld\n", dp[n][m]);
	
 
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
class Main{
	public static void main(String[] args){
    	Scanner console = new Scanner(System.in);
    	int N = console.nextInt();
      int M = console.nextInt();
      System.out.println(combination(N) + combination(M));
	}
	
	public static int combination(int num){
	   int comb = 0;
      int temp = 1;
      for(int i = num; i > num - 2; i--){
         temp *= i;
      }
      temp /= 2;
      if(temp != 0){
         comb = temp;
     	}
     	return comb;
	}
}

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

typedef long long ll;
void solve()
{
	int i,j,n;
	cin>>n;
	vector <double> v(n);
	for(i=0;i<n;i++)
		cin>>v[i];
	vector <vector <double>>dp(n+1,vector <double>(n+1,0.0));
	dp[1][0]=1-v[0];
	dp[1][1]=v[0];
	double ans=0;
	for(i=2;i<=n;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(j==0)
				dp[i][j]=dp[i-1][j]*(1-v[i-1]);
			else if(j==i)
				dp[i][j]=dp[i-1][j-1]*v[i-1];
			else
				dp[i][j]=dp[i-1][j]*(1-v[i-1])+dp[i-1][j-1]*v[i-1];
		}
	}
	for(j=n/2+1;j<=n;j++)
		ans+=dp[n][j];
	cout << fixed << setprecision(9) <<ans<<endl;
}
int main()
{

	solve();
	return 0;
}

Measured memory_bytes: 70784
N, M = map(int, input().split())

if M == 0:
    print(0, 0)
    exit()

wacount = [0]*(N+1)
wa = [0]*(N+1)
ac = [0]*(N+1)

for _ in range(M):
    pi, Si = map(str, input().split())
    pi = int(pi)
    if Si == "WA":
        wacount[pi] += 1
    elif ac[pi] == 0:
        wa[pi] = wacount[pi]
        ac[pi] += 1

print(sum(ac), sum(wa))


Measured memory_bytes: 5492
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int tmp = 0;

		if( a > b ) {
			tmp = a;
			a = b;
			b = tmp;
		}

		if( b > c ) {
			tmp = b;
			b = c;
			c = tmp;
		}


		if( a > b ) {
			tmp = a;
			a = b;
			b = tmp;
		}

		System.out.println( a + " " + b + " " + c );
	}
}



Measured memory_bytes: 26180
n = int(input())
ret = [0 for _ in range(1,n+1)]
def f(x,y,z):
	return x*x + y*y + z*z + x*y + y*z + x*z

for x in range(1,n+1):
	for y in range(1,n+1):
		for z in range(1,n+1):
			if f(x,y,z) > n:
				z = 1
				break
			ret[f(x,y,z)-1] += 1
		if f(x,y,z) > n:
			y = 1
			break
	if f(x,y,z) > n:
		x = 1
		break

for i in ret:
	print(i)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pa pair<int,int>
#define F first
#define S second
typedef long long ll;
ll MOD=1e9+7;
ll t[10000][10000];

int main()
{
    int n,k;
    cin>>n>>k;
    int l=k;
    int r=n-k;
    t[0][0]=1;

    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= n; j++)
            if (j >= 1)
                t[i][j] = (t[i - 1][j] + t[i - 1][j - 1]) % MOD;
            else
                t[i][j] = t[i - 1][j];

    for (int i = 1; i <= k; i++)
        cout << t[r + 1][i] * t[l - 1][i - 1] % MOD << endl;


    return 0;
}


Measured memory_bytes: 156416
// B - Increment Decrement
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; string s; cin>>n>>s;
	int x=0, ans = x;
	for(int i=0; i<n; i++) ans = max(ans, s[i]=='I'?++x:--x);
	cout<< ans <<endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

const ll INF = 1LL<<60;

//#define __DBG__

ll A,B;

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

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


void solve(void){
  
  cin >> A >> B;

  ll C = lcm(A,B);
  
  
  cout << C << endl;
  
  
  return;
}

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


    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}





Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;

    int ans = n * (n - 1) / 2;
    cout << ans << endl;

    return 0;
}


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (bit & (1LL << i))

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<typename T> using VVVV = std::vector<std::vector<std::vector<std::vector<T>>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
template<class T> inline std::vector<T> unique(std::vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}
// 初項s, 交差dのn個の数列の和
long long sum_of_arithmetic_progression(long long s, long long d, long long n) {
    return n * (2 * s + (n - 1) * d) / 2;
}

const int INF = 1 << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = {0, -1, 0, 1}, dx4 = {1, 0, -1, 0};
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

    int N, W;
    cin >> N >> W;

    V<int> w_list(N), v_list(N);
    FOR(i, 0, N) {
        cin >> w_list[i] >> v_list[i];
    }

    VV<LL> dp(N + 1, V<LL>(100010, INF));
    dp[0][0] = 0;
    int ans = 0;
    FOR(i, 0, N) {
        int w = w_list[i];
        int v = v_list[i];

        FOR(j, 0, dp[0].size()) {
            if (dp[i][j] == INF) {
                continue;
            }

            // not use
            chmin(dp[i + 1][j], dp[i][j]);

            // use
            if (dp[i][j] + w <= W) {
                chmin(dp[i + 1][j + v], dp[i][j] + w);
                ans = max(ans, j + v);
            }
        }
    }
    print(ans);

	return 0;
}

Measured memory_bytes: 80256
def main():
    N = int(input())
    H = list(map(int, input().split()))
    dp = [float("inf") for _ in range(N+2)]
    dp[0] = 0
    for i in range(N):
        for j in [1, 2]:
            if i+j < N:
                dp[i+j] = min(dp[i+j], dp[i]+abs(H[i]-H[i+j]))
    print(dp[N-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 52856
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
const int nmax = 1000;
const int vmax = 1000000;
vvint a(nmax,vint(nmax,0));
vvint par(vmax);
vvint chd(vmax);
vvint id(nmax,vint(nmax,0));
vint np(vmax);
vint dp(vmax);
int to_id(int x, int y){
    if(x>=y){
        swap(x,y);
    }
    return id[x][y];
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    REP(i,n){
        REP(j,n-1){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int v=0;
    REP(i,n){
        for(int j=i+1;j<n;j++){
            id[i][j]=v;
            v++;
        }
    }
    REP(i,n){
        int pre;
        pre = to_id(i,a[i][0]);
        for(int j=1;j<n-1;++j){
            int now = to_id(i,a[i][j]);
            par[now].pb(pre);
            chd[pre].pb(now);
            pre = now;
        }
    }
    queue<int> q;
    REP(i,v){
        if((int)par[i].size()==0){
            q.push(i);
            dp[i]=1;
        }else{
            np[i] = (int)par[i].size();
        }
    }
    
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(int i : chd[now]){
            dp[i] = max(dp[i],dp[now]+1);
            np[i]--;
            if(np[i]==0){
                q.push(i);
            }
        }
    }

    int ans = 0;
    REP(i,v){
        if(np[i]>0){
            puts("-1");
            return 0;
        }
        ans = max(ans,dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 94080
#include"bits/stdc++.h"

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int i;
    //入力
    int a,b;
    cin>>a>>b;
    //処理
    if(a<2*b)cout<<0<<endl;
    else cout<<(a-2*b)<<endl;
    //出力
}

Measured memory_bytes: 768
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N, X[200000], Xc[200000], m, t;

int main()
{
  cin >> N;
  REP(i, N)
  {
    cin >> X[i];
  }

  copy(X, X + N, Xc);

  sort(X, X + N);
  m = X[(N + 1) / 2 - 1];

  REP(i, N)
  {
    t = m < Xc[i] ? X[(N + 1) / 2 - 1] : X[(N + 1) / 2];
    cout << t << '\n';
  }

  return 0;
}


Measured memory_bytes: 5376
#include <math.h>
#include <iostream>
#include <iomanip>
using namespace std;

int main (){
    double r ,s, l;
    cin >> r;
    s = r* r * M_PI;
    r = r * 2 * M_PI;
    cout << fixed << setprecision(10) << s << " " <<fixed <<setprecision(10) << r << endl;  
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << ", ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << " ]" ;
}

#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
#define sz(a) (ll)(a).size()
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    ll n;
    cin >> n;
    ll d;
    cin >> d;
    ll dis[n];
    loop(i,0,n){
        ll x, y;
        cin >> x >> y;
        dis[i] = x * x + y * y;
    }
    ll ans = 0;
    loop(i,0,n){
        if(dis[i] <= d*d) ans++;
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


Measured memory_bytes: 5212
#include <bits/stdc++.h>
typedef long long LL;
const int M = 200007;

int n; LL m;
int fir[M], las[M], nxt[M];
int jp[M], stp[M], ans[M];
int a[M];

LL getloop() {
	int x = 1;
	LL res = 0;
	do {
		res += stp[x];
		x = jp[x];
	} while(x != 1);
	return res;
}

int main() {

	std::ios::sync_with_stdio(false);
	std::cin >> n >> m;
	LL s = n * m;

	for (int i = 1; i <= n; ++i) std::cin >> a[i];
	for (int i = 1; i <= n; ++i) if (!fir[a[i]]) fir[a[i]] = i;
	for (int i = n; i >= 1; --i) {
		if (!las[a[i]]) {
			nxt[i] = fir[a[i]];
		}
		else nxt[i] = las[a[i]];
		las[a[i]] = i;
	}
	for (int i = 1; i <= n; ++i) {
		jp[i] = nxt[i] == n ? 1 : nxt[i] + 1;
		stp[i] = nxt[i] > i ? nxt[i] - i + 1 : nxt[i] + n - i + 1;
	}

	LL d = getloop();
	s = s % d;

	int x = 1;
	while (s >= stp[x]) {
		s -= stp[x];
		x = jp[x];
	}
	if (s != 0) {
		memset(las, 0, sizeof las);
		int tot = 0;
		while (s--) {
			if (!las[a[x]]) {
				ans[++tot] = a[x];
				las[a[x]] = tot;
			}
			else {
				for (int tmp = las[a[x]] - 1; tot > tmp; --tot) 
					las[ans[tot]] = 0;
			}
			x = x == n ? 1 : x + 1;
		}
		assert(tot != 0);
		for (int i = 1; i <= tot; ++i) {
			std::cout << ans[i] << (i == tot ? "" : " ");
		}
		std::cout << std::endl;
	}
	
	return 0;
}


Measured memory_bytes: 7040
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------


int main(void){
    int x, a, b;
    cin >> x >> a >> b;

    if(a - b >= 0){
        cout << "delicious" << endl;
    } else if(abs(a - b) <= x){
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
from decimal import Decimal

N = int(input())
wordlist = [chr(i) for i in range(97, 97+26)]
ans=[]

while True:
    tmp = Decimal(N) % Decimal(26)
    N = Decimal(N) // Decimal(26)

    if tmp==0:
        N-=1

    ans.insert(0, wordlist[int(tmp-1)])

    if N == 0:
        break

print(*ans, sep='')


Measured memory_bytes: 10060
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<utility>
#include<vector>

int main(void) {
	using uint32 = unsigned int;
	uint32 n, ans = 0;
	scanf("%u", &n);
	std::vector<uint32> a(n), b(n), c(n), d(n);
	for (auto &e : a)
		scanf("%u", &e);
	for (auto &e : b)
		scanf("%u", &e);
	if (n & 1) {
		for (const auto e : a)
			ans ^= e;
		for (const auto e : b)
			ans ^= e;
	}
	for (auto &e : a)e = ~e;
	for (uint32 i = 0;i < 28;++i) {
		const uint32 pbit = (uint32)1 << i;
		uint32 midA = n, midB = n;
		for (const auto e : a)
			midA -= e >> i & 1;
		for (const auto e : b) 
			midB -= e >> i & 1;
		uint32 lA = 0, lB = 0;
		for (const auto e : a)
			c[e & pbit ? midA++ : lA++] = e;
		for (const auto e : b)
			d[e & pbit ? midB++ : lB++] = e;
		std::swap(a, c);
		std::swap(b, d);
		lA = 0;
		lB = 0;
		const uint32 mask = (pbit << 1) - 1;
		while (lA < n) {
			while (lB < n && (a[lA] & mask) >= (b[lB] & mask))
				++lB;
			if (n - lB & 1)
				ans ^= pbit << 1;
			++lA;
		}
	}
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  Int m=5;
  vector<Int> a(m);
  for(Int i=0;i<m;i++) cin>>a[i];
  Int x=a[0];
  for(Int y:a) chmin(x,y);
  cout<<(n+x-1)/x+4<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define INF 0x7fffffff

int graph[110][110];
int sptSet[100];
int dist[100];
int V;

int minDistance()
{
	int min_v, min = INF;
	for (int i = 0; i < V; i++)
	{
		if (min > dist[i] && !sptSet[i])
			min = dist[i], min_v = i;
	}
	return min_v;
}

void dijsktra()
{
	for (int i = 0; i < V; i++)
		dist[i] = INF;
	for (int i = 0; i < V; i++)
		sptSet[i] = 0;
	dist[0] = 0;
	for (int i = 0; i < V - 1; i++)
	{
		int p = minDistance();
		sptSet[p] = 1;
		for (int j = 0; j < V; j++)
		{
			if (!sptSet[j] && graph[p][j] && dist[p] + graph[p][j] < dist[j])
				dist[j] = dist[p] + graph[p][j];
		}
	}
}



int main()
{
	scanf("%d", &V);
	for (int i = 0; i < V; i++)
	{
		int m, k, q, w;
		scanf("%d%d", &m, &k);
		for (int j = 0; j < k; j++)
		{
			scanf("%d%d", &q, &w);
			graph[m][q] = w;
		}
	}
	dijsktra();
	for (int i = 0; i < V; i++)
		printf("%d %d\n", i, dist[i]);
}


Measured memory_bytes: 2080
#include<cstdio>
#include<set>
#include<bitset>
#define ll long long
using namespace std;
bitset<4000100> st;
int main()
{
	int n;
	scanf("%d", &n);
	int sum = 0;
	st[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		int q;
		scanf("%d", &q);
		sum += q;
		st |= (st << q);
	}
	sum++;
	sum /= 2;
	for (int i = sum; i <= 4000000; i++) {
		if (st[i]) {
			printf("%d", i);
			return 0;
		}
	}
}

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

int N, K;
int P[1100];

int main(){
  cin >> N >> K;
  rep(i, N) cin >> P[i];
  sort(P, P + N);

  int ans = 0;
  rep(i, K) ans += P[i];
  cout << ans << endl;
}


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

int main(){
    int n,x,sum=0,ans=0;cin>>n>>x;
    vector<int> m(n);
    for(int i=0;i<n;i++){
        cin>>m.at(i);
        sum+=m.at(i);
    }
    sort(m.begin(),m.end());
    ans=n+(x-sum)/m.at(0);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    char ch='a';
    while(a.size()||b.size()||c.size())
    {
        if(ch=='a')
        {
            if(a.size()==0)
            {
                cout<<'A';
                return 0;
            }
            ch=a[0];
            a.erase(0,1);
        }
        else if(ch=='b')
        {
            if(b.size()==0)
            {
                cout<<'B';
                return 0;
            }
            ch=b[0];
            b.erase(0,1);
        }
        else
        {
            if(c.size()==0)
            {
                cout<<'C';
                return 0;
            }
            ch=c[0];
            c.erase(0,1);
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e,f;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	e=c-(d-b);
	f=d+(c-a);
	printf("%d %d %d %d",e,f,e-(c-a),f-(d-b));
	return 0;
}

Measured memory_bytes: 128
// D - Fennec VS. Snuke
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

void distance(int p, int d, vvi &T, vi &visited){
	if(visited[p] > 0) return;
	visited[p] = d;
	for(int c:T[p]) distance(c, d+1, T, visited);
}

string solve(int N, vvi &T){
	vi f(N+1), s(N+1);
	distance(1, 1, T, f);
	distance(N, 1, T, s);
	int c = 0;
	rp(i, 2, N) c += f[i]<=s[i]? 1: -1;
	return c>0? "Fennec": "Snuke";
}

int main(){
	int N; cin>>N;
	vvi T(N+1, vi());
	rp(i, 0, N-1){
		int a,b; cin>>a>>b;
		T[a].push_back(b);
		T[b].push_back(a);
	}
	cout<< solve(N, T) <<endl;
}

Measured memory_bytes: 11136
#include <iostream>
#include <math.h>
#include <set>
#include<vector>
#include<string>
#include <algorithm>
#include<queue>
#include<map>
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define per(i,j,k) for(int i = (int)j;i >= (int)k;i --)
#define F(i,k) for(int i=(int)0;i<(int)k;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
const int maxn = 5e3 + 5;
using namespace std;
ll m,n,k;
double v[maxn];
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	double ans = 0;
	rep(i, 1, n) {
		cin >> v[i];
	}
	sort(v + 1, v + 1 + n);
	double now = v[1] + v[2];
	now /= 2.;
	rep(i, 3, n) {
		now += v[i];
		now /= 2;
	}
	cout << now << endl;
	cin >> n;

}

/*

*/

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int M = input.nextInt();
		
		if(N==M) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


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

int main(){
	int N;
	cin >> N;
	double a;
	double sum(0);
	for(int i(0);i<N;++i){
		cin >> a;
		sum += 1/a;
	}
	cout << 1/sum << endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

const int MAX_N = 101;

ll ans = 0;
vl cnt(MAX_N,0);

int main() {
  int n; cin >> n;
  for (int i = 2; i <= n; i++) {
    int num = i;
    for (int j = 2; j <= n; j++) {
      while (num % j == 0) {
        cnt[j]++;
        num /= j;
      } 
    }
  }
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      for (int k = 0; k < MAX_N; k++) {
        if (i == j || j == k || k == i) continue;
        if (cnt[i] >= 2) if (cnt[j] >= 4) if (cnt[k] >= 4) ans++;
      }
    }
  }
  ans >>= 1;
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      if (i == j) continue;
      if (cnt[i] >= 2) if (cnt[j] >= 24) ans++;
      if (cnt[i] >= 4) if (cnt[j] >= 14) ans++;
    }
  }
  for (int i = 0; i < MAX_N; i++) {
    if (cnt[i] >= 74) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


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

  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> minous;
  vector<int> plus;
  ll res = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    res += abs(v[i]);
    if(v[i] == 0) {
      minous.push_back(0);
      plus.push_back(0);
    }

    if(v[i] < 0) minous.push_back(v[i]);
    else if(v[i] > 0) plus.push_back(v[i]);
  }

  sort(ALL(v));
  sort(ALL(minous));
  sort(ALL(plus));

  if(n == 2){
    if(v[0] > v[1]){
      cout << v[0] << ' ' << v[1] << endl;
      cout << v[0]-v[1] << endl;
    }else{
      cout << v[1] << ' ' << v[0] << endl;
      cout << v[1]-v[0] << endl;
    }
    return 0;
  }


  if(int(plus.size()) == n){
    ll sum2 = v[0];
    ll maxv2 = v[n-1];
    for (int i = 1; i < n-1; i++){
      sum2 -= v[i];
    }
    maxv2 -= sum2;
    cout << maxv2 << endl;


    ll sum = v[0];
    ll maxv = v[n-1];
    for (int i = 1; i < n-1; i++){
      cout << sum <<' ' << v[i] << endl;
      sum -= v[i];
    }
    cout << maxv << ' ' << sum << endl;
    return 0;
  }else if(int(minous.size()) == n){
    ll sum2 = v[n-1];
    ll maxv2 = v[0];
    for (int i = n-2; i >= 1; i--) {
      sum2 -= v[i];
    }
    sum2 -= maxv2;
    cout << sum2 << endl;

    ll sum = v[n-1];
    ll maxv = v[0];
    for (int i = n-2; i >= 1; i--) {
      cout << sum << ' ' << v[i] << endl;
      sum -= v[i];
    }
    cout << sum << ' ' << maxv << endl;
    return 0;
  }

  int index = -1;
  cout << res << endl;
  for (int i = 0; i < n; i++) {
    if(v[i] >= 0){
      index = i;
      break;
    }
  }


  ll sum = v[index-1];
  for (int i = index; i < n-1; i++) {
    cout << sum << ' ' << v[i] << endl;
    sum -= v[i];
  }
  cout << v[n-1] << ' ' << sum << endl;
  sum = v[n-1] - sum;
  for (int i = 0; i < index-1; i++) {
    cout << sum << ' ' << v[i] << endl;
    sum -= v[i];
  }
}


Measured memory_bytes: 2808
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const LL MOD = 1e9 + 7;

int n, tot;
struct point
{
	int x, y;
	int id;
}PP[MaxN + 5];
struct Edge
{
	int u, v;
	int w;
}ed[2 * MaxN + 5];
int fa[MaxN + 5];

int cmpx(point a, point b) {return a.x < b.x;}
int cmpy(point a, point b) {return a.y < b.y;}
int cmpe(Edge x, Edge y) {return x.w < y.w;}

int find(int x)
{
	if(fa[x] == x) return x;
	else return fa[x] = find(fa[x]);
}
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		tot = 0;
		for(int i = 1; i <= n; i++)
		{
			scanf("%d %d", &PP[i].x, &PP[i].y);
			PP[i].id = i;
		}
		sort(PP + 1, PP + n + 1, cmpx);
		for(int i = 1; i <= n - 1; i++)
		{
			ed[++tot].u = PP[i].id;
			ed[tot].v = PP[i + 1].id;
			ed[tot].w = min(abs(PP[i].x - PP[i + 1].x), abs(PP[i].y - PP[i + 1].y));
		}
		sort(PP + 1, PP + n + 1, cmpy);
		for(int i = 1; i <= n - 1; i++)
		{
			ed[++tot].u = PP[i].id;
			ed[tot].v = PP[i + 1].id;
			ed[tot].w = min(abs(PP[i].x - PP[i + 1].x), abs(PP[i].y - PP[i + 1].y));
		}
		
		LL ans = 0;
		for(int i = 1; i <= n; i++) fa[i] = i;
		sort(ed + 1, ed + tot + 1, cmpe);
		for(int i = 1; i <= tot; i++)
		{
			int u = ed[i].u, v = ed[i].v;
			if(find(u) != find(v))
			{
				ans += (LL)ed[i].w;
				fa[find(v)] = find(u);
			}
		}
		printf("%lld\n", ans);
		
		memset(PP, 0, sizeof(PP));
		memset(ed, 0, sizeof(ed));
	}
	return 0;
}

Measured memory_bytes: 4096
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * (10**5+10)
dp[0] = 0
for i in range(0, N-1):
    dp[i+1] = chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]))
    if i < N-2:
        dp[i+2] = chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]))
print(dp[N-1])


Measured memory_bytes: 13904
def main():
    N = int(input())
    As = input().split(" ")
    len_As = len(As)
    len_setAs = len(set(As))
    if len_As == len_setAs:
        ans = "YES"
    else:
        ans = "NO"
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 84336
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,ans;
int main()
{
    scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e);
    ans=(e%2==0)?(min(min(min(a*8,b*4),c*2),d)*e/2):(min(min(a*4,b*2),c)+min(min(min(a*8,b*4),c*2),d)*(e-1)/2);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
S = input()
N = input()
N = int(N)
re = False
foward = ""
back = ""

for i in range(N):
    que = input().split(" ")
    if que[0] == "1":
        if re:
            re = False
        else:
            re = True
    else:
        if re:
            if que[1] == "1":
                back += que[2]
            else:
                foward += que[2]
        else:
            if que[1] == "1":
                foward += que[2]
            else:
                back += que[2]
S = foward[::-1]+S+back
if re:
    print(S[::-1])
else:
    print(S)

Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    double a, b, x;
    cin>>a>>b>>x;

    double t = b - x / a / a;

    double ans;
    if (a / 2.0 / t > a / b) {
        double sn = a / 2.0 / t;
        ans = 90.0 - atan(sn) * 180.0 / PI;
    }
    else {
        ans = atan(2.0 * x / a / b / b);
        ans = 90 - ans * 180 / PI;
    }
    printf("%.10f\n", ans);
}

Measured memory_bytes: 384