akhauriyash/Code-Regression huggingface dataset:
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

const int inf=100000000;



int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n,k;
    cin>>n>>k;
    string S;
    cin>>S;
    S[k-1]=tolower(S[k-1]);
    cout<<S<<endl;

}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
    int n, m, x, y = 0;
    cin >> n >> m >> x >> y;
    int x_max = -100;
    int y_min = 100;
    int tmp = -100;
    REP(i, n)
    {
        cin >> tmp;
        x_max = max(x_max, tmp);
    }
    tmp = 100;
    REP(i, m)
    {
        cin >> tmp;
        y_min = min(y_min, tmp);
    }

    bool war = true;
    for (int z = x + 1; z <= y; z++)
    {
        if (z > x_max && z <= y_min)
        {
            war = false;
            break;
        }
    }
    war ? COUT("War") : COUT("No War");

    return 0;
}

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

int main() {
	int x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	cout<<x2+y1-y2<<endl<<y2+x2-x1<<endl<<y1-y2+x1<<endl<<x2-x1+y1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
//#define f first
//#define s second
//#define mp make_pair
#define gg return 0;
#define pii pair < int, int>
 
using namespace std;
 
const int maxn = 132675;
const int INF = (int)1e9;
 
ll a,b[maxn],c,d,cnt,e[(int)2e3 + 1][(int)2e3 + 1],cost[maxn],tout[maxn],mn = INF,mx = -INF,l,r;
 
ll x[maxn],y[maxn],x2[maxn],y2[maxn];
 
ll kol;

bool u[maxn], m, f;
 
vector <int> v;
 /*
void forn( int s, int f, int inter){
	for(int i = s; i <= f; i += inter){
		b[i] = i;
	}
}
*/ 
ll ans;
 
ll pref;
 
//vector <int> g[maxn],d[maxn];
 
ll lvlc,lvl[maxn];
ll pos;
/*
void dfs(int v){
	lvlc++;
	lvl[v] = lvlc;
	d[lvl[v]].pb(v);
	u[v] = 1;
	for(int i = 0; i < g[v].size(); ++i){
		int to = g[v][i];
		if(!u[to]){
			dfs(to);
		}
	}
	lvlc--;
}*/

map <int, int> mp; 
 
char ch;

string s; 

int main()
{
	cin >> a >> c;
	for(int i = 1; i <= a; ++i){
		cin >> b[i];
	}
	for(int i = 1; i <= a; ++i){	 
    	ll sum = b[i] + b[i + 1]; 
    	if(sum > c){
   		   cnt += sum - c;
   		   b[i + 1] -= (b[i] + b[i + 1] - c);
    	}
	}
	/*for(int i = 1; i <= a; ++i){
		cout << b[i] << " ";
	}*/
	cout << cnt;		
	gg
}

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
int main() {
    cout<<fixed<<setprecision(10);

    ll x; cin>>x;



    auto d = divisor(x);

    rep(i, d.size()){
        ll s , t;
        s = d[i];
        t = x/s;

        for(ll a=0; a <= 1e3; a++){
            ll b = a - s;
            if(a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b == t){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }


    }



    return 0;

}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
class edge
{
public:
	int source,target,cost;
	edge(int insource=0,int intarget=0,int incost=0):
	source(insource),target(intarget),cost(incost){}
	bool operator<(const edge &e)const{return cost<e.cost;}
};

class disjointset
{
public:
	vector<int> rank;
	vector<int> p;
	
	void makeset(int x)
	{
		p[x]=x;
		rank[x]=0;
		return;
	}
	disjointset(int s)
	{
		rank.resize(s);
		p.resize(s);
		for(int i=0;i<s;i++)makeset(i);
		return;
	}
	int findset(int x)
	{
		if(x!=p[x])p[x]=findset(p[x]);
		return p[x];
	}
	void link(int x,int y)
	{
		if(rank[x]>rank[y])p[y]=x;
		else
		{
			p[x]=y;
			if(rank[x]==rank[y])rank[y]++;
		}
		return;
	}
	bool same(int x,int y)
	{
		return findset(x)==findset(y);
	}
	void unite(int x,int y)
	{
		link(findset(x),findset(y));
		return;
	}
};

int n;

vector<edge> kruskal(vector<edge> e)
{
	sort(e.begin(),e.end());
	disjointset d=disjointset(n+1);
	edge ne;
	vector<edge> mst;
	
	for(int i=0;i<e.size();i++)
	{
		ne=e[i];
		if(!d.same(ne.source,ne.target))
		{
			mst.push_back(ne);
			d.unite(ne.source,ne.target);
		}
	}
	
	return mst;
}

int totalcostcal(vector<edge> e)
{
	int ans=0;
	for(int i=0;i<e.size();i++)ans+=e[i].cost;
	return ans;
}

int main()
{
	int m;
	cin>>n>>m;
	int s,t,w;
	vector<edge> e;
	for(int i=0;i<m;i++)
	{
		cin>>s>>t>>w;
		e.push_back(edge(s,t,w));
	}
	cout<<totalcostcal(kruskal(e))<<endl;
	return 0;
}

Measured memory_bytes: 5384
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n;

string s;

const int MAXN = 200005;
int a[MAXN], m[MAXN];

int dp[(1 << 26) + 5];

int mask(int x) {
    return 1 << x;
}

bool contains(int s, int x) {
    return s & mask(x);
}

int main() {
    cin >> s;

    n = s.size();

    FORN(i, n) {
        a[i + 1] = s[i] - 'a';
    }

    m[0] = 0;

    FOR1(i, n) {
        m[i] = m[i-1] ^ mask(a[i]);
    }

    fill(dp, dp + (1 << 26) + 5, INF);

    dp[m[n]] = 0;

    FORD(i, n) {
        int best = INF;

        FORN(j, 26) {
            best = min(best, 1 + dp[m[i] ^ mask(j)]);
        }

        dp[m[i]] = min(dp[m[i]], best);

//        DEBUG(m[i]);
//        DEBUG(dp[m[i]]);
    }

    cout << max(1, dp[0]) << "\n";

    return 0;
}

Measured memory_bytes: 264324
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
}point;

void koch(int n, point p1, point p2){
  if(n == 0) return;

  point s, t, u;
  s.x = (2*p1.x + 1*p2.x)/3;
  s.y = (2*p1.y + 1*p2.y)/3;
  t.x = (1*p1.x + 2*p2.x)/3;
  t.y = (1*p1.y + 2*p2.y)/3;
  u.x = (t.x - s.x)*0.5 - (t.y - s.y)*(sqrt(3.0)/2.0) + s.x;
  u.y = (t.x - s.x)*(sqrt(3.0)/2.0) + (t.y - s.y)*0.5 + s.y;


  koch(n-1, p1, s);
  printf("%lf %lf\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%lf %lf\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%lf %lf\n", t.x, t.y);
  koch(n-1, t, p2);
}

int main(){
  int n;
  point p1 = {0, 0}, p2 = {100, 0};
  scanf("%d", &n);
  printf("%lf %lf\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%lf %lf\n", p2.x, p2.y);
  return 0;
}

Measured memory_bytes: 636
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
int main(void){
	int K;cin>>K;
	vector<int>ans(K,mod);
	deque<pair<int,int>>que;que.pub(mp(1,1));
	while(!que.empty()){
		int it=que.front().fir,aa=que.front().sec;que.pof();
		if(it==0){cout<<aa<<endl;RE;}
		if(ans[it]<=aa){continue;}
		que.puf(mp((it*10)%K,aa));
		que.pub(mp((it+1)%K,aa+1));
		ans[it]=aa;
	}
}

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

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int prim();

int n,M[MAX][MAX];

int main(){
  cin >> n;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e;
      cin >> e;
      M[i][j]=(e==-1)?INFTY : e;
    }
  }

  cout << prim() << endl;
  return 0;
}

int prim(){
  int u,minv,d[MAX],p[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;

  while(1){
    minv=INFTY;
    u = -1;
    for(int i=0;i<n;i++){
      if(minv > d[i] && color[i]!=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;

    for(int h=0;h<n;h++){
      if(color[h]!=BLACK && M[u][h]!=INFTY){
        if(d[h]>M[u][h]){
          d[h]=M[u][h];
          p[h]=u;
          color[h]=GRAY;
        }
      }
    }
  }
  int vv=0;
  for(int i=0;i<n;i++){
    if(p[i]!=-1) vv=vv+M[i][p[i]];
  }
  return vv;
}



Measured memory_bytes: 3116
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  char s[100];
  int count=0;
  int len,i;
  scanf("%s",s);
  len=strlen(s);
  for(i=0;i<len;i++){
    if(s[i]!=s[len-1]){
      count++;
    }
    len--;
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.);
int x[233],y[233],n,sz;
double ans,st[666];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
		scanf("%d%d",x+i,y+i);
	for(int i=1;i<=n;i++){
		sz=0;
		for(int j=1;j<=n;j++)
			if(i^j)
				st[++sz]=atan2(x[j]-x[i],y[j]-y[i]);
		sort(st+1,st+sz+1);
		st[0]=st[sz]-2.*pi;
		ans=0;
		for(int j=1;j<=n;j++)
			ans=max(ans,st[j]-st[j-1]-pi);
		printf("%.8f\n",ans/2./pi);
	}
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  ll H,A;
  cin >> H >> A;
  cout << (H + A - 1) / A << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e2+10;
char a[N][N];
typedef pair<int,int> P;
vector<P> V[N][N];
int n,m;
int dir[4][2]={
        {-1,0},
    {0,-1},{0,1},
        {1,0}
};
bool check(int x,int y){
    return x>=1&&x<=n&&y>=1&&y<=m;
}
int cnt[2];
bool vis[N][N];
void dfs(int x,int y){
    vis[x][y]=true;
    if(a[x][y]=='#'){
        cnt[0]++;
    }else{
        cnt[1]++;
    }
    for(auto v: V[x][y] ){
        if(!vis[v.first][v.second]){
            dfs(v.first,v.second);
        }
    }
}
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    n=h,m=w;
    for(int i=1;i<=h;i++){
        scanf("%s",a[i]+1);
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            for(int k=0;k<4;k++){
                int tx=i+dir[k][0];
                int ty=j+dir[k][1];
                if(check(tx,ty)&&a[i][j]!=a[tx][ty]){
                    V[i][j].push_back(make_pair(tx,ty));
                }
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            memset(cnt,0,sizeof(cnt));
            if(!vis[i][j]){
                dfs(i,j);
                ans+=1LL*cnt[0]*cnt[1];
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, K;
int h[100100];

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

    std::cin >> N >> K;

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

    std::sort(h, h + N);

    int lb = -1, ub = 1'000'000'000;
    
    while(ub - lb > 1){
        int m = (lb + ub) / 2;

        int mx = 0;

        for(int i=0;i<N;++i){
            int j = std::upper_bound(h, h + N, h[i] + m) - h;
            mx = std::max(mx, j - i);
        }

        if(mx >= K){
            ub = m;
        }else{
            lb = m;
        }
    }

    std::cout << ub << std::endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new PlacingMarbles();
			Instance.Exec();
		}
	}

	public class PlacingMarbles
	{
		public void Exec()
		{
			string s = Console.ReadLine();
			List<bool> slist = new List<bool>() { s[0] == '1', s[1] == '1', s[2] == '1' };
			int count = 0;
			foreach (var item in slist) {
				if (item) {
					++count;
				}
			}

			Console.WriteLine(count.ToString());

			Console.Out.Flush();

			Console.ReadLine();
		}
	}
}

Measured memory_bytes: 13268
import sys

a, b, c, x, y = map(int, input().split())

price = 0
another = sys.maxsize

if 2*c < a + b:
    price += 2 * c * min(x, y)
    another = 2 * c * max(x, y)
    if x > y:
        price += (x - y) * a
    else:
        price += (y - x) * b
else:
    price = a * x + b * y
    
print(price) if another > price else print(another)

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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            Console.WriteLine((N - 2) * 180);

        }
    }
}

Measured memory_bytes: 11220
import java.util.*;
import java.text.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> prime = new ArrayList<Integer>();
		prime.add(2);
		for(int i=3; i<1000000; i=i+2){
			boolean check = true;
			int k=0;
			while(i>=prime.get(k)*prime.get(k)){
				if(i%prime.get(k) == 0){
					check = false;
					break;
				}
				k++;
			}
			if(check) prime.add(i);
		}
		while(in.hasNext()){
			int n = in.nextInt();
			int ans=0;
			for(int i=0; n>=prime.get(i); i++){
				ans++;
				if(i==prime.size()-1) break;
			}
			System.out.println(ans);
		}
	}
}

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

int n;
int MAXIMUM=100005;
long INF = 1e15;
// W:未訪問
// G:訪問する候補
// B:訪問済み
int W=0,G=1,B=2;
vector<pair<int,int>> adj[100005];
long d[100005];
int dijkstra(int K){
  priority_queue<pair<int,int>> PQ;
  int u,minv;
  int color[MAXIMUM];
  // d[n]:Tに属する頂点と V - T に属する頂点をつなぐ辺の中で重みが最小の辺の重みを記録

  //初期化
  for(int i=0;i<n;i++){
    d[i]=INF;
    color[i]=W;
  }

  d[K]=0;
  PQ.push(make_pair(0,K));
  color[K] = G;

  while (!PQ.empty()) {
    pair<int,int> f = PQ.top();
    PQ.pop();
    u = f.second;
    // 頂点を訪問済に
    color[u] = B;
    //最小値を取り出し、それが最短でなければ無視
    if( d[u]<f.first*(-1)) continue;

    //訪問済みでないかつ辺がつながっている頂点の中でコストが最小の辺を選択
    for(int j=0;j<adj[u].size();j++){
      int v = adj[u][j].first;
      if(color[v]== B) continue;
      if(d[v]>d[u]+adj[u][j].second){
        d[v]=d[u]+adj[u][j].second;
        PQ.push(make_pair(d[v]*(-1),v));
        color[v]=G;
      }
    }
  }


}

int main(){
  int X,Y;
  cin>>n;
  for(int i=0;i<n-1;i++){
      adj[i].push_back(make_pair(i+1,1));
      adj[i+1].push_back(make_pair(i,1));
    }
  vector<long> ans(n);
  cin>>X>>Y;
  adj[X-1].push_back(make_pair(Y-1,1));
  for(int i=0;i<n;i++){
      dijkstra(i);
      for(int j=i+1;j<n;j++){
      //  cout<<d[j]<<endl;
        ans[d[j]]++;
      }
  }
for(int i=1;i<=n-1;i++){
cout<<ans[i]<<endl;
}
}


Measured memory_bytes: 2688
import sys
n, h = map(int, input().split())
ans = 0
ans, a, b = 0, 0, []

for _ in range(n):
    c1, c2 = map(int, input().split())
    a = max(a, c1)
    b.append(c2)
b = sorted(b, reverse=True)

def count(ans, num):
    if num.is_integer():
        ans += int(num)
    else:
        ans += int(num)+1
    print(ans)
    sys.exit()
    

i = 0
while h > 0:
    if i == len(b):
        count(ans, h/a)
    elif a >= b[i]:
        count(ans, h/a)
    else:
        h -= b[i]
        ans += 1
        i += 1
print(ans)


Measured memory_bytes: 13896
#include<stdio.h>
#define N 10000

int main(void){

  int n, q, C=0, i, j;
  int S[N], T[N];

  scanf("%d",&n);

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

  scanf("%d",&q);

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

  for(j=0;j<q;j++){
    for(i=0;i<n;i++){

      if(S[i] == T[j]){
	C++;
	break;
      }
    }
  }

  printf("%d\n", C);

  return 0;
}



Measured memory_bytes: 2144
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

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

  auto it = max_element(begin(A), end(A));
  *it /= 2;
  const ll ans = accumulate(cbegin(A), cend(A), 0LL);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, T = map(int,input().split())
mincost = 1001
for i in range(1, N+1):
    c, t = map(int,input().split())
    if t <= T:
        cost = c
        if cost < mincost:
            mincost = cost

if mincost == 1001:
  print('TLE')
if mincost < 1001:
  print(mincost)


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
  long long int x,t;
  long long int ans=0,k=0;
  scanf("%lld",&x);
  while(x>=2){
    x/=2;
    ans+=1;
    k+=1;
  }
  t=pow(2,k+1);
  printf("%lld",t-1);
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
int N;
  cin>>N;
  for(int i=1;i<10;i++){
     for(int j=1;j<10;j++){
     if(i*j==N){
          cout<<"Yes";
       return 0;
     }
     }
  }
  cout<<"No";
}

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

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	while (x != 0 || y != 0) {
		cout << min(x, y) << " " << max(x, y) << endl;
		cin >> x >> y;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans = (int) 1e9;
  for (int a = 1; a < n; a++) {
    int b = n - a;
    int sum = 0;
    int x = a, y = b;
    
    while (x > 0) {
      sum += x % 10;
      x /= 10;
    }
    
    while (y > 0) {
      sum += y % 10;
      y /= 10;
    }
    ans = min(ans, sum);
  }

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

Measured memory_bytes: 256
//49
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int eval(const char **s){
  if(**s=='('){
    (*s)++;
    int a=eval(s);
    char o=**s;
    (*s)++;
    int b=eval(s);
    (*s)++;
    if(o=='*'){
      return min(a,b);
    }else{
      return max(a,b);
    }
  }else if(**s=='-'){
    (*s)++;
    return -eval(s)+2;
  }else{
    char c=**s;
    (*s)++;
    return c-'0';
  }
}

int dfs(const char *os,char q){
  if(q>'R'){
    return eval(&os)==2;
  }else{
    int r=0;
    for(int i=0;i<3;i++){
      char s[80];
      strcpy(s,os);
      replace(s,s+80,q,char('0'+i));
      r+=dfs(s,q+1);
    }
    return r;
  }
}

int main(){
  for(char s[80];cin>>s,s[0]!='.';){
    cout<<dfs(s,'P')<<endl;
  }
  return 0;
}

Measured memory_bytes: 1148
from bisect import insort_left as il
n=int(input())
a=[]

d={}
for i in range(n):
    s,p=input().split()
    p=int(p)
    a.append(p)
    
    if s not in d:
        d[s]=[p]
    else:
        il(d[s],p)

s=sorted(d)




for i in s:
    
    
    for j in range(len(d[i])):
        print(a.index(d[i].pop())+1)
    


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s;
	cin >> s;
	if (s == "SUN")
	{
		cout << 7 << endl;
	}
	else if (s == "MON")
	{
		cout << 6 << endl;
	}
	else if (s == "TUE")
	{
		cout << 5 << endl;
	}
	else if (s == "WED")
	{
		cout << 4 << endl;
	}
	else if (s == "THU")
	{
		cout << 3 << endl;
	}
	else if (s == "FRI")
	{
		cout << 2 << endl;
	}
	else
		cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

void printvec(vi& x, int size = 0) {
    if (x.size() == 0) {
        cout << endl;
        return;
    }
    cout << x.front();
    for (int i = 1; i < (size == 0 ? x.size() : size); i++) {
        cout << " " << x[i];
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }

    as.erase(unique(as.begin(), as.end()), as.end());
    printvec(as);
}


Measured memory_bytes: 3596
import java.util.*;
import java.math.BigInteger;
// warm-up
// Looks like this is the safest
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(), A=sc.nextInt(), B=sc.nextInt(), t=n, i=0;
		BigInteger s = BigInteger.ZERO;
		long[] T = new long[n];
		long[] b = new long[n-1];
		long[] c = new long[n-1];
		while (t-->0) T[i++] = sc.nextLong();
		b[0] = c[0] = (T[1]-T[0])*A;
		for (i=1; i<n-1; i++) {
			b[i] = (T[i+1]-T[i])*A;
			c[i] = b[i]+c[i-1];
		}
		for (i=0; i<n-1; i++) {
			s = s.add(new BigInteger("" + Math.min(B, b[i])));
			s = new BigInteger("" + Math.min(c[i], s.longValue()));
		}
		System.out.println(s);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}


Measured memory_bytes: 63760
#include<stdio.h>
int main()
{
	int a[5],k,i,t;
	for(i=0;i<5;i++)
		scanf("%d\n",&a[i]);
	scanf("%d",&k);
	if(a[4]-a[0]<=k)
		t=1;
	else
		t=0;
	if(t)
		printf("Yay!\n");
	else
		printf(":(\n");
	return 0;
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a,b=0;
signed main(){
	cin>>a;
	b=(a/11)*2;
	a=a-(a/11)*11;
	if(0<a&&a<7){
		b++;
	}else if(0<a&&a<11){
		b+=2;
	}
	cout<<b;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : AMAN SAXENA *
* "There's some good in this world, and it's worth fighting for." *
* INSTITUTION : KIET Group of Institutions *
******************************************/
#include <bits/stdc++.h>

const long long MODULO=1000000007;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FOR1(i,a,n) for(int i=a;i<=n;i++)
#define FOR2(i,a,n) for(int i=a;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

template <typename TYPE> void in(TYPE &x){cin>>x;}

void solve()
{
    int n;
    cin >> n;
    ll ans = 1;
    vector<ll> A(n);
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        if(a == 0){
            cout << 0;
            return ;
        }
        A[i] = a;
    }
    for(int i = 0; i < n; i++){
        if(ans > 1000000000000000000/A[i]){
            cout << -1 << endl;
            return ;
        }
        ans *= A[i];
    }
    cout << ans << endl;
}

void test()
{
    int t;
    cin>>t;
    while(t--) //for(int j=1;j<=t;j++) cout << "Case #" << j << ": ";
    {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // test();
    solve();
    
    return 0;
}

Measured memory_bytes: 3992
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B;
	
	cin >> A >> B;

	if (A >= 13)
	{
		cout << B << endl;
	}
	else if ( A >= 6)
	{
		cout << (B >> 1) << endl;
	}
	else 
	{
		cout << 0 << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
N=int(input())
dp=[[0]*3 for _ in range(N)]
a,b,c = map(int,input().split())
dp[0]=[a,b,c]
for i in range(1,N):
  a,b,c = map(int,input().split())
  dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
  dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b
  dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[-1]))
  

Measured memory_bytes: 60268
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  cout<<(n-2)*180<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#define P x*y==
using namespace std;
int main(){
  int x,y;
  scanf("%d %d",&x,&y);
  if(x==2||y==2) printf("No\n");
  else if(x==4||x==6||x==9||x==11){
    if(y==4||y==6||y==9||y==11) printf("Yes\n");
    else printf("No\n");
  } else if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
    printf("Yes\n");
  } else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	activities := make([][]int, n)
	for i := 0; i < n; i++ {
		activities[i] = make([]int, 3)
		fmt.Scanf("%d%d%d", &activities[i][0], &activities[i][1], &activities[i][2])
	}
	ans := maximumTotalPoints(n, activities)
	fmt.Println(ans)
}

// https://atcoder.jp/contests/dp/tasks/dp_c
func maximumTotalPoints(n int, activities [][]int) int {
	dp := make([]int, 3)
	for i := 0; i < n; i++ {
		newDP := make([]int, 3)
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j != k {
					newDP[k] = int(math.Max(float64(newDP[k]), float64(dp[j]+activities[i][j])))
				}
			}
		}
		dp = newDP
	}
	return int(math.Max(float64(dp[0]), math.Max(float64(dp[1]), float64(dp[2]))))
}


Measured memory_bytes: 12044
#include <stdio.h>
     
int triJudgefunc(int x, int y, int z);
     
int main(void)
{
    int row;
    scanf("%d", &row);
    for (int i = 0; i < row; ++i) {
        int firstn, secondn ,thirdn; 
        scanf("%d %d %d", &firstn, &secondn, &thirdn);
        if (triJudgefunc(firstn, secondn, thirdn) == 0) {
        printf("YES\n");
        } else {
        printf("NO\n");
        }
    }
    return 0;
}
     
     
     
int triJudgefunc(int x, int y, int z)
{
    int maxlength, notmax1, notmax2;
    if (x > y) {    //x > y
        if (x > z) {
            maxlength = x; notmax1 = y; notmax2 = z;    //x???max
        } else {
            notmax1 = x; notmax2 = y; maxlength = z;    //z???max
        }
    } else {    //y > x
        if (y > z) {
            notmax1 = x; maxlength = y; notmax2 = z;    //y???max
        } else {
            notmax1 = x; notmax2 = y; maxlength = z;    //z???max
        }
    }
    int result = maxlength * maxlength - notmax1 * notmax1 - notmax2 * notmax2;
    return result;
}
 

Measured memory_bytes: 1004
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

const int base = 100;
ll memo[base * 2][base * 2];

int count(ll n, int p) {
    int res = 0;
    while (n % p == 0) {
        res++;
        n /= p;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    ll ans = 0;
    vector<P> tmp(n);
    REP(i, 0, n) {
        string s;
        cin, s;
        ll a = 1, b = 0;
        bool dot = false;
        REP(j, 0, s.size()) {
            if (s[j] == '.') {
                dot = true;
            } else {
                b = b * 10 + s[j] - '0';
                if (dot) {
                    a = a * 10;
                }
            }
        }
        ll g = gcd(a, b);
        a /= g;
        b /= g;
        dump(b, a);
        int t = 0, w = 0;
        t += count(b, 2);
        w += count(b, 5);
        t -= count(a, 2);
        w -= count(a, 5);
        memo[t + base][w + base]++;
        if (t >= 0 && w >= 0) {
            ans--;
        }
        tmp[i] = P(t, w);
    }

    for (int i = base * 2 - 1; i >= 0; i--) {
        for (int j = base * 2 - 1; j > 0; j--) {
            memo[i][j - 1] += memo[i][j];
        }
    }
    for (int i = base * 2 - 1; i > 0; i--) {
        for (int j = base * 2 - 1; j >= 0; j--) {
            memo[i - 1][j] += memo[i][j];
        }
    }

    for (auto [t, w] : tmp) {
        t = -t + base;
        w = -w + base;
        ans += memo[t][w];
    }
    print(ans / 2);

    return 0;
}


Measured memory_bytes: 6672
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is #" << (x) <<"#" <<endl
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 1e5+5;
const ll inf = 1e18+7;

ll dp[MAX];
bool visited[MAX];
vi adj[MAX];

ll DP(ll u)
{
  ll &ans = dp[u];
  if(ans) return ans;
  for(auto v : adj[u]) ans = max(ans,DP(v)+1);
  return ans;
}

int main() {
  fastio;
  ll n,m,x,y;
  cin>>n>>m;
  while(m--) 
  {
     cin>>x>>y;
     visited[y]=true;
     adj[x].pb(y);
  }
  ll ans=0;
  f(i,1,n+1){
    if(!visited[i]) ans = max(ans,DP(i));
  }
  cout<<ans<<"\n";
  return 0; 
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B) {
  if(A%2==1&&B%2==1)cout<<YES<<endl;
  else cout<<NO<<endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(a*10+b+c,max(b*10+a+c,c*10+a+b));
}
/*
  for(int i=0;i<4;i++){
    if(s[i]=='-')o----;
    o++;
  }
  cout << o;
}
*/


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int num, i = 0, buf, data[3] = { 0 };
	cin >> num;
	for (; i < num; i++) {
		scanf("%d", &buf);
		if ((buf & 1) == 1)
			data[0]++;
		else if ((buf & 2) == 2)
			data[1]++;
		else
			data[2]++;
	}
	if (data[2] >= data[0])
		cout << "Yes\n";
	else if (data[1] == 0 && data[2] == data[0] - 1)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n, x, a, b, c, ret;
	for (;;) {
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0) {
			return 0;
		}
		ret = 0;
		for (c = 1; c <= n; c++) {
			for (b = 1; b < c; b++) {
				a = x - c - b;
				if (a < b && a > 0) {
					ret++;
				}
			}
		}
	printf("%d\n", ret);
	}
}

Measured memory_bytes: 600
#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 pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

vector<int> g[100001];
bool used[100001];
int from[200001],to[200001];
bool z[100001];
void bfs(int sr,int s){
    queue<pint> q;q.push({sr,0});
    used[sr]=true;
    while(!q.empty()){
        pint pi=q.front();q.pop();
        rep(i,g[pi.first].size()){
            int nx=g[pi.first][i];
            if(!used[nx]&&pi.second+1<=s){
                used[nx]=true;
                q.push({nx,pi.second+1});
            }
        }
    }
}
int n;
vector<pint> vp[100001];
ll d[100001];
ll INF=1000100010001000100;
int dijkstra(int st){
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    rep(i,n) d[i]=INF;
    d[st]=0;
    pq.push(make_pair(0,st));
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        int t=pi.second;
        if(d[t]<pi.first) continue;
        for(auto it:vp[t]){
            if(d[it.second]>d[t]+it.first){
                d[it.second]=d[t]+it.first;
                pq.push(make_pair(d[it.second],it.second));
            }
        }
    }
}
int main(){
    int m,k,s,p,q;
    cin>>n>>m>>k>>s>>p>>q;
    int zi;
    rep(i,k){
        cin>>zi;
        g[0].pb(zi);
        z[zi]=true;
    }
    rep(i,m){
        cin>>from[i]>>to[i];
        g[from[i]].pb(to[i]);
        g[to[i]].pb(from[i]);
    }
    bfs(0,s+1);
    rep(i,m){
        if(z[from[i]]||z[to[i]]) continue;
        int cost=(to[i]==n)?0:used[to[i]]?q:p;
        vp[from[i]-1].pb(cost,to[i]-1);
        cost=(from[i]==n)?0:used[from[i]]?q:p;
        vp[to[i]-1].pb(cost,from[i]-1);
    }
    dijkstra(0);
    cout<<d[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 25152
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define opr iterator
typedef long long ll;
using namespace std;
string s,t,tmp;
int len1;
int len2;
bool check(int start,int end)
{
	for(int i=0;i<len2;i++)
	{
		if(s[i+start]!='?'&&s[i+start]!=t[i])
		{
			return false;
		}
	}
	return true;
}
string get(int start,int end)
{
	string use=s;
	for(int i=0;i<len2;i++)
	{
		use[i+start]=t[i];
	}
	return use;
}
int main()
{
	cin>>s>>t;
	tmp=""; 
	for(int i=1;i<=100;i++)
	{
		tmp+='z';
	}
	len1=s.length();
	len2=t.length();
//	cout<<len1<<" "<<len2<<endl;
	for(int i=0;i<=len1-len2;i++)
	{
		if(check(i,i+len2))
		{
			tmp=min(get(i,i+len2),tmp);
		}
	}
	if(tmp.length()>len1)
	{
		cout<<"UNRESTORABLE"<<endl;
		exit(0);
	}
	for(int i=0;i<tmp.length();i++)
	{
		if(tmp[i]=='?')
		{
			tmp[i]='a';
		}
	}
	cout<<tmp<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include "math.h"

using namespace std;

int a,b;

int main() {
    
    cin >> a >> b;
    
    if (b % a == 0) {
        cout << a+b << endl;
    } else {
        cout << b-a << endl;
    }
    
    return 0;
}

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

using namespace std;

int main ( ) {
    string s;
    int numberSum = 0;

    cin >> s;
    if (s[0] == '1') {
        numberSum++;
    }

    if (s[1] == '1') {
        numberSum++;
    }

    if (s[2] == '1') {
        numberSum++;
    }
    cout << numberSum << endl;
}

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

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    int ans1[n], ans2[n];

    for(int i = 0; i < n; i++) {
        ans1[i] = lower_bound(a, a + n, b[i]) - a;
        ans2[i] = lower_bound(b, b + n, c[i]) - b;
    }
    
    int dp[n];
    dp[0] = ans1[0];
    for(int i = 1; i < n; i++) {
        dp[i] = dp[i - 1] + ans1[i];
    }
    int ans = 0;
    for(int i =0 ;i < n; i++) {
        if(ans2[i] == 0) continue;
        ans += dp[ans2[i] - 1];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4992
#include<vector>
#include<climits>
#include<algorithm>

const long long int INF = INT_MAX;
const long long int NIL = -1;
int leftMostBit(int x) {
  if(x == 0) return 0;
  x = (x & 0x55555555) << 1 | (x >> 1) & 0x55555555;
  x = (x & 0x33333333) << 2 | (x >> 2) & 0x33333333;
  x = (x & 0x0f0f0f0f) << 4 | (x >> 4) & 0x0f0f0f0f;
  x = (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24);
  int deBruijnSequence[32] = {0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14};
  return 31 - deBruijnSequence[((x & -x) * 0x076be629U) >> 27];
}
class RangeMinimumQuery {
public:
  RangeMinimumQuery(int s) {
    size_ = 1 << leftMostBit(s);
    if(size_ != s) size_ <<= 1;
    node_ = std::vector<long long int>((size_ << 1) - 1, INF);
  }
  long long int find(int left, int right) const {
    return query(left, right, 0, 0, size_ - 1);
  }
  void update(int index, int value) {
    int i = index + size_ - 1;
    node_[i] = value;
    while((i = parent(i)) != NIL) node_[i] = std::min(node_[left_child(i)], node_[right_child(i)]);
  }
private:
  int parent(int node) const {return node == 0 ? NIL : (node - 1) >> 1;}
  int left_child(int node) const {return (node << 1) + 1;}
  int right_child(int node) const {return (node << 1) + 2;}
  long long int query(int a, int b, int k, int l, int r) const {
    if(b < l || r < a) return INF;
    if(a <= l && r <= b) return node_[k];
    int vl = query(a, b, left_child(k), l, (l + r) / 2);
    int vr = query(a, b, right_child(k), (l + r) / 2 + 1, r);
    return std::min(vl, vr);
  }

  int size_;
  std::vector<long long int> node_;
};

#include<iostream>
using namespace std;

struct Star {long long int x, y, b;};
bool operator<(const Star& lhs, const Star& rhs) {return lhs.b < rhs.b;}

int main() {
  int N, d;
  cin >> N >> d;
  vector<Star> star(N);
  for(auto& s: star) cin >> s.x >> s.y >> s.b;
  sort(begin(star), end(star));
  RangeMinimumQuery left(N), right(N), top(N), bottom(N);
  for(int i = 0; i < N; ++i) {
    left.update(i, star[i].x);
    right.update(i, -star[i].x);
    top.update(i, star[i].y);
    bottom.update(i, -star[i].y);
  }
  long long int answer = 0;
  int low, high;
  for(low = high = 0; low < N; ++low) {
    while(high < N - 1 && star[high + 1].b - star[low].b <= d) ++high;
    long long int area = -right.find(low, high) - left.find(low, high);
    area *= -bottom.find(low, high) - top.find(low, high);
    answer = max(answer, abs(area));
  }
  cout << answer << endl;
}

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

int main(){

  int x,y,r,tmp;

  scanf("%d %d",&x,&y);
  
  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }

  r = x % y;

  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }

  printf("%d\n",y);

  return 0;
}

Measured memory_bytes: 592
n = int(input())

numbers = list(map(int, input().split()))
comp_list = []
result = 0

for i in range(n-2):
    comp_list.clear()
    comp_list.append(numbers[i])
    comp_list.append(numbers[i+1])
    comp_list.append((numbers[i+2]))
    sorted_list = sorted(comp_list)
    if sorted_list[1] == numbers[i+1]:
        result += 1
print(result)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
	
	public static int maxProfitQuadratic(int[] prices) {
		int maxProfit = prices.length > 1 ? prices[1] - prices[0] : 0;
		for(int i = 0; i < prices.length - 1; i++) {
			for(int j = i + 1; j < prices.length; j++) {
				if(prices[j] - prices[i] > maxProfit)
					maxProfit = prices[j] - prices[i];
			}
		}
		
		return maxProfit;
	}
	
	public static int maxProfitLinear(int[] prices) {
		int maxProfit = prices.length > 1 ? prices[1] - prices[0] : 0;
		int minValue = Math.min(prices[1], prices[0]);
		for(int i = 2; i < prices.length; i++) {
			maxProfit = Math.max(maxProfit,  prices[i] - minValue);
			minValue = Math.min(minValue,  prices[i]);
		}
		return maxProfit;
	}
	
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int size = scan.nextInt();
		int[] prices = new int[size];
		for(int i = 0; i < size; i++)
			prices[i] = scan.nextInt();
		
		System.out.println(maxProfitLinear(prices));
	}
}



Measured memory_bytes: 101348
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc138/tasks/abc138_c
N = int(input())
v = list(map(int, input().split()))
s = sorted(v)
c = s[0]
for i in range(1, N):
    c = (s[i] + c) / 2
print(c)

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

using namespace std;

#define fst() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef long double ld;

int main()
{
  fst();
  ll x,y,i;
  cin>>x>>y;
  i=0;
  while(x<=y)
  {
    x*=2;
    i++;
  }
  cout<<i<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, m;

	cin>>n>>m;

	vvi s(m);
	vi p(m);

	rep(i, m){
		int k;
		cin>>k;
		s[i]=vi(k);
		rep(j, k){
			cin>>s[i][j];
			s[i][j]--;
		}
	}

	rep(i, m) cin>>p[i];

	ll ans=0;
	rep(i, pow(2, n)){
		bool flag=true;
		rep(j, m){
			int count=0;
			rep(k, s[j].size()){
				if(i&(1<<s[j][k])) count++;
			}
			if(count%2!=p[j]){
				flag=false; break;
			}
		}
		if(flag) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256