akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 305
#define MOD 1000000007

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

int A[SIZE*2];
int id[SIZE*2];
ll dp[2][SIZE][SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<2*n;i++) scanf("%d",&A[i]),A[i]--;
	int cnt=0,zan=0;
	for(int i=0;i<n;i++)
	{
		if(A[2*i]>=0&&A[2*i+1]>=0)
		{
			id[A[2*i]]=id[A[2*i+1]]=-1;
		}
		else
		{
			int a=max(A[2*i+1],A[2*i]);
			if(a>=0)
			{
				id[a]=1;
				//zan++;
			}
			else cnt++;
		}
	}
	int pos=0;
	dp[pos][0][0]=1;
	for(int i=0;i<2*n;i++)
	{
		if(id[i]==-1) continue;
		pos^=1;
		memset(dp[pos],0,sizeof(dp[pos]));
		//if(id[i]==1) zan--;
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<=n;k++)
			{
				if(dp[pos^1][j][k]==0) continue;
				ll vl=dp[pos^1][j][k];
				if(id[i]==1)
				{
					if(j>0)
					{
						dp[pos][j-1][k]+=vl*(ll) j%MOD;
						if(dp[pos][j-1][k]>=MOD) dp[pos][j-1][k]-=MOD;
					}
					dp[pos][j][k+1]+=vl;
					if(dp[pos][j][k+1]>=MOD) dp[pos][j][k+1]-=MOD;
				}
				else
				{
					if(k>0)
					{
						dp[pos][j][k-1]+=vl%MOD;
						if(dp[pos][j][k-1]>=MOD) dp[pos][j][k-1]-=MOD;
					}
					dp[pos][j][k+1]+=vl;
					if(dp[pos][j][k+1]>=MOD) dp[pos][j][k+1]-=MOD;
					dp[pos][j+1][k]+=vl;
					if(dp[pos][j+1][k]>=MOD) dp[pos][j+1][k]-=MOD;
				}
			}
		}
	}
	//printf("%d\n",cnt);
	ll ret=dp[pos][0][0];
	for(int i=1;i<=cnt;i++) ret=ret*(ll) i%MOD;
	printf("%lld\n",ret);
	return 0;
}


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

int main(){
  int N;
  int a[100010];
  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> a[i];
  }
  
  int ok = 0;
  int d = 1;
  int i;
  for(i = 1;i < N;i++){
    d = a[d - 1];
    if(d == 2){
      ok++;
      break;
    }
  }
  
  if(ok > 0){
    cout << i << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 640
n = int(input())
buttons = []
for _ in range(n):
    buttons.append(int(input()))
def calc():
    count = 0
    now = 1
    flag = True
    for i in range(n):
        if not flag:
            pass
        elif now == 2:
            print(count)
            flag = False
        else:
            now = buttons[now-1]
        count += 1
    if flag:
        print(-1)

calc()

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

int main() {
	double n;
	cin >> n;
	vector<double> v(n);
	rep(i, n) cin >> v[i];
	sort(v.begin(), v.end());
	double tmp = v[0];
	for (int i = 1; i < n; ++i) {
		tmp = (tmp + v[i]) / 2;
	}
	cout << setprecision(10) << fixed << tmp << endl;
	return 0;
}


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

int main() {
    int N, X;
    cin >> N >> X;
    int res = 1;
    int cur = 0;
    for(int i=0; i<N; ++i) {
        int L;
        cin >> L;
        cur += L;
        if(cur <= X) ++res;
    }
    cout << res << endl;
}

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

int main() {
  int N;
  int c = 0;
  int a, b;
  cin >> N;

  for(int i = 0; i < N;i++) {
    cin >> a >> b;
    c += b- a +1;
  }
  cout << c;
  return 0;
}


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

typedef long long ll;
ll N;
ll A[100010] = {0},B[100010] = {0},C[100010]={0};
int main(){
	cin >> N;
	A[0] = 0;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		B[i] = abs(A[i]-A[i-1]);
		C[i] = B[i]+C[i-1];
	}
	A[N+1] = 0;
	C[N+1] = C[N]+abs(A[N]);
	for(int i=1;i<=N;i++){
		ll a;
		if((A[i]-A[i-1])*(A[i+1]-A[i-1])<=0){
			a = C[N+1]-2*abs(A[i]-A[i-1]);
		}else if((A[i]-A[i+1])*(A[i-1]-A[i+1])<=0){
			a = C[N+1] - 2*abs(A[i]-A[i+1]);
		}
		else{
			a = C[N+1];
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+3;

int n;
char s[N];
int LL[N],LR[N];
int RL[N],RR[N];
int ans[N];

int main() {
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++) {
		if(s[i]=='L')
			LL[i]=i,LR[i]=LR[i-1];
		else LL[i]=LL[i-1],LR[i]=i;
	}
	for(int i=n;i>=1;i--) {
		if(s[i]=='L')
			RL[i]=i,RR[i]=RR[i+1];
		else RL[i]=RL[i+1],RR[i]=i;
	}
	for(int i=1;i<=n;i++) {
		if(s[i]=='L') {
			int st=i-LR[i];
			if(st%2==0)
				ans[LR[i]]++;
			else ans[LR[i]+1]++;
		}
		else {
			int st=RL[i]-i;
			if(st%2==0)
				ans[RL[i]]++;
			else ans[RL[i]-1]++;
		}
	}
	for(int i=1;i<n;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)

#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long ll;
const int N = 2e5+1 , M = 5e5+1, OO = 0x3f3f3f3f,MOD = 1e9+7;
map<int,pair<ll,ll>> ans;
int arr[N];
ll tot=0;
int main()
{
  double l;
  scanf("%lf",&l);
  printf("%.12f\n",(l*l*l)/27.0);
  
  
  #ifdef _LOCAL_DEFINE  
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// hash struct for unordered_map
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    ll n;
    cin >> n;
    // n-=1;
    string s;
    while(n)
    {
        ll r=n%26;
        if(r==0)
        {
            char ch='z';
            n-=1;
            s+=ch; 
        }
        else
        {
            char ch='a'+r-1;
            s+=ch;
        }
        
        n/=26;
    } 
    reverse(s.begin(),s.end());
    cout << s << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

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

int main() {
    vector<vector<char>> s(3,vector<char>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> s.at(i).at(j);
        }
    }
    for(int i = 0; i < 3; i++){
        cout << s.at(i).at(i);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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 main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int x;
    cin >> x;
    if (x >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

struct Point {
	double x, y;
	Point(){}
	Point(double x,double y):x(x),y(y){}
	bool operator <(const Point &p) const {
	return x < p.x || (x == p.x && y < p.y);
	}
};

double cross(const Point &O, const Point &A, const Point &B){
	return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
}

int convex_hull(vector<Point> P){
	int n = P.size(), k = 0;
	vector<Point> H(2*n);
	sort(P.begin(), P.end());
	for (int i = 0; i < n; i++) {
		while (k >= 2 && cross(H[k-2], H[k-1], P[i]) <= 0.0) k--;
		H[k++] = P[i];
	}
	for (int i = n-2, t = k+1; i >= 0; i--) {
		while (k >= t && cross(H[k-2], H[k-1], P[i]) <= 0.0) k--;
		H[k++] = P[i];
	}
	return k-1;
}
int main(){
	int n;
	while(scanf("%d",&n),n){
		vector < Point > vp;
		for(int i = 0; i < n; i++){
			double x,y;
			scanf("%lf,%lf",&x,&y);
			vp.push_back(Point(x,y));
		}
		printf("%d\n",n-convex_hull(vp));
	}
}

Measured memory_bytes: 1232
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            long N = long.Parse(line);
            long sum = 0;
            for(int i = 1; i <= N; i++)
            {
                if (i % 3 != 0 && i % 5 != 0)
                {
                    sum += i;
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 27520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,m;
    cin>>n>>m;
    ll mx=1;
    if(n==1)
    {
        cout<<m<<endl;
        return 0;
    }
    for(ll i=2;i*i<=m;i++)
    {

        if(m%i==0)
        {
            ll p = 1LL*i*n;
            if(p>m)
            {
                continue;
            }

            mx = max(mx,1LL*i);
            ll k = m/i;
            ll pp = 1LL*k*n;
            if(pp>m)
            {
                continue;
            }
            mx = max(mx,1LL*k);
        }
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 171
//C - One Quadrillion and One Dalmatians
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    string ans = "";
    while(n>0){
        int m = (n%26);
        if (m==0) {
            m+=26;
            n--;
        }
        ans += 0x60+m;
        n=n/26;
    }
    reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N,0),C(0);
  for(int &i:A)
    cin>>i;
  for(int i=N;i>0;i--){
    int cnt=0;
    for(int j=2;i*j<=N;j++)
      cnt+=B[i*j-1];
    B[i-1]=(A[i-1]+cnt)%2;
  }
  for(int i=0;i<N;i++)
    if(B[i])
      C.push_back(i+1);
  cout<<C.size()<<endl;
  for(int i=0;i<(int)C.size();i++){
    cout<<C[i];
    if(i==C.size()-1)
      cout<<endl;
    else
      cout<<' ';
  }
}

Measured memory_bytes: 7364
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    ll num = m*1900 + (n-m)*100;
    ll hoge = 1;
    rep(i,m){
        hoge *= 2;
    }
    cout << num*hoge << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;

int main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   ll a,b, c;
   ll k;
   cin >> a >> b >> c >> k;

   if (k % 2 == 0) { // 偶数 1 -1 0
        a = a + (-b);
        outl(a);
   } else { // -1 1 0
        a = (-a) + b;
        outl(a);
   }
}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define zero(a) memset(a, 0, sizeof a)

template<class T> constexpr bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; }

vector<vector<string>> D[4] = {
{
  {
    "x#x",
    "<<x",
    "xxx"
  },
  {
    "x#x",
    "#<x",
    "xvx"
  },
  {
    "x#x",
    "#<>",
    "x#x"
  },
  {
    "x^#",
    "x<x",
    "xxx"
  },
},
{
  {
    "x^x",
    "x^#",
    "xxx"
  },
  {
    "x#x",
    "<^#",
    "xxx"
  },
  {
    "x#x",
    "#^#",
    "xvx"
  },
  {
    "xxx",
    "x^>",
    "xx#"
  },
},
{
  {
    "xxx",
    "x>>",
    "x#x"
  },
  {
    "x^x",
    "x>#",
    "x#x"
  },
  {
    "x#x",
    "<>#",
    "x#x"
  },
  {
    "xxx",
    "x>x",
    "#vx"
  },
},
{
  {
    "xxx",
    "#vx",
    "xvx"
  },
  {
    "xxx",
    "#v>",
    "x#x"
  },
  {
    "x^x",
    "#v#",
    "x#x"
  },
  {
    "#xx",
    "<vx",
    "xxx"
  },
}
};

const string dirs = "<^>v";
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

char G[55][55];
int H, W;

tuple<int, int, int> walk(int y, int x, int d) {
  tuple<int, int, int> next;
  rep(i, D[d].size()) {
    auto& T = D[d][i];
    assert(dirs.find(T[1][1]) == d);

    bool ok = 1;
    int ry = -1, rx = -1, rd = -1;
    REP(i, -1, 2) REP(j, -1, 2) {
      if(i == 0 && j == 0) continue;
      const int ny = y + i, nx = x + j;
      if(T[i+1][j+1] == 'x') {
        continue;
      }
      else if(T[i+1][j+1] == '#') {
        ok &= !in_range(ny, nx, H, W) || G[ny][nx] == '#';
      }
      else {
        ok &= in_range(ny, nx, H, W) && G[ny][nx] != '#';
        if(ok) {
          assert(dirs.find(T[i+1][j+1]) != string::npos);
          ry = ny, rx = nx, rd = dirs.find(T[i+1][j+1]);
        }
      }
    }
    if(ok) {
      next = make_tuple(ry, rx, rd);
    }
  }
  return next;
}

int main() {

  cin >> H >> W;
  rep(i, H) {
    cin >> G[i];
  }

  int y, x, d;

  rep(i, H) rep(j, W) {
    if(dirs.find(G[i][j]) != string::npos) {
      y = i, x = j, d = dirs.find(G[i][j]);
    }
  }

  bool vis[55][55][4]; zero(vis);
  vis[y][x][d] = 1;

  while(1) {
    auto next = walk(y, x, d);
    tie(y, x, d) = next;
    if(vis[y][x][d]) break;
    vis[y][x][d] = 1;
    if(G[y][x] == 'G') {
      int ans = 0;
      rep(i, 55) rep(j, 55)
        ans += vis[i][j][0] || vis[i][j][1] || vis[i][j][2] || vis[i][j][3];
      cout << ans << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  
  return 0;
}

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

int main() {
    int a, b; cin >> a >> b;
    if (a <= b){
        for (int i = 0; i < b; ++i) {
            cout << a;
        }
    } else {
        for (int i = 0; i < a; ++i) {
                cout << b;
            }
        }
    return 0;
}


Measured memory_bytes: 256
/*
 * 0603.cc: Illumination
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

int as[MAX_N];
vpii dfs;

/* subroutines */

inline int dlen(int i) { return (dfs[i].second - dfs[i].first + 1); }

/* main */

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

  for (int i = 0; i < n - 1;) {
    int j = i + 1;
    while (j < n && as[j - 1] != as[j]) j++;
    if (j > i + 1) dfs.push_back(pii(i, j - 1));
    i = j;
  }
  //for (int i = 0; i < dfs.size(); i++)
  //printf("(%d,%d)\n", dfs[i].first, dfs[i].second);
  
  int ans = 0, dn = dfs.size();

  if (dn == 0) ans = min(n, 3);
  else {
    for (int i = 0; i < dn; i++) {
      int &d0 = dfs[i].first, &d1 = dfs[i].second, len = dlen(i);

      // reverse all
      int len0 = len;
      len0 +=
	(i > 0 && dfs[i - 1].second == d0 - 1) ?
	dlen(i - 1) : (d0 > 0) ? 1 : 0;
      len0 +=
	(i < dn - 1 && dfs[i + 1].first == d1 + 1) ?
	dlen(i + 1) : (d1 < n - 1) ? 1 : 0;
      if (ans < len0) ans = len0;
      
      // reverse left-adjacent one
      if (d0 > 0) {
	int len1 = len + 1;
	if (i > 0 && dfs[i - 1].second == d0 - 2) len1 += dlen(i - 1);
	else if (d0 > 1 && (i == 0 || dfs[i - 1].second < d0 - 2))
	  len1++;
	if (ans < len1) ans = len1;
      }

      // reverse right-adjacent one
      if (d1 < n - 1) {
	int len2 = len + 1;
	if (i < dn - 1 && dfs[i + 1].first == d1 + 2) len2 += dlen(i + 1);
	else if (d1 < n - 2 && (i == dn - 1 || dfs[i + 1].first > d1 + 2))
	  len2++;
	if (ans < len2) ans = len2;
      }
    }
  }
  
  printf("%d\n", ans);
  return 0;
}

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

const int MX = 100001;

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

  if((a*b)%2==1) cout << "Odd" << endl;
  else cout << "Even" << endl;
  
  return 0;
}

Measured memory_bytes: 3560
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int d = sc.nextInt();

		int[] c = new int[27];
		for ( int i=1; i<27; i++ ) {
			c[i] = sc.nextInt();
		}

		int[][] s = new int[d][27];
		for ( int i=0; i<d; i++ ) {
		for ( int j=1; j<27; j++ ) {
			s[i][j] = sc.nextInt();
		}
		}

		int[] last = new int[27];
		for ( int i=0; i<d; i++ ) {
			int t = 0;
			int man = -999999999;

			for ( int j=1; j<27; j++ ) {
				int manj = 0;
				for ( int k=1; k<27; k++ ) {
					if ( j==k ) {
						manj += s[i][j];
					} else {
						manj -= (c[k]*((i+1)-last[k]));
					}
				}

				if ( manj>man ) {
					man = manj;
					t = j;
				}
			}

			last[t] = i+1;
			System.out.println(t);
		}

	}
}

Measured memory_bytes: 46632
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+7;
bool pd(string s){
    int l = s.size()-1,r=0;
    while(0<l-r){
        if(s[r]!=s[l]) return false; 
        r++,l--;
    }
    return true;
}
int main(){
    string s;
    cin>>s;
    if(pd(s.substr(0,s.size()))&&pd(s.substr(0,(s.size()-1)/2))&&pd(s.substr((s.length()+3)/2 - 1,s.length() - ((s.length()+3)/2 - 1))))
        puts("Yes");
    else 
        puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

vector<int> memo(50,0);

vector<vector<int>>dp(110,vector<int>(11000,0));

signed main(){
  int N,W;cin>>N>>W;
  vector<int> value(N),weight(N);
  REP(i,0,N)cin>>value[i]>>weight[i];
  REP(i,0,N)REP(w,0,W+1){
    if(w>=weight[i]){
      dp[i+1][w]=max(dp[i][w],dp[i+1][w-weight[i]]+value[i]);
    }
    else{
      dp[i+1][w]=dp[i][w];
    }
  }
  // debug(dp)
  print(dp[N][W])



}



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

template<typename T> 
struct BIT{
  int n;
  vector<T> d;
  BIT(int n = 0):n(n), d(n+1){}
  void add(int i, T x = 1){
  	for(i++; i <= n; i += i&-i){
      d[i] += x;
    }
  }
  T sum(int i){
    T ret = 0;
    for(i++; i; i-=i&-i){
      ret += d[i];
    }
    return ret;
  }
};

int main(){
  int n, q; cin >> n >> q;
  vector<int> c(n);
  vector<int> f(n+1, -1);
  for(int i = 0; i < n; i++) cin >> c[i];
  vector<vector<int>> p(n);
  for(int i = 0; i < n; i++){
    int l = f[c[i]];
    if(l != -1) p[l].push_back(i);
    f[c[i]] = i;
  }
  
  vector<vector<pair<int,int>>> qs(n);
  for(int i = 0; i < q; i++){
    int l, r; cin >> l >> r;
    --l; --r;
    qs[l].emplace_back(r, i);
  }
  
  BIT<int> d(n);
  vector<int> ans(q);
  for(int x = n-1; x >= 0; --x){
    for(int y : p[x]) d.add(y, 1);
    for(pair que : qs[x]){
      int r = que.first, idx = que.second;
      ans[idx] = (r-x+1) - d.sum(r);
    }
  }
  for(int i = 0; i < q; i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 60000
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,pair<int,int>>
#define F first
#define S second
using namespace std;
#define mod 1000000007

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

    int t=1;
    while(t--){
        int x; cin>> x;
        if(x>=30) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
             cout << std::setprecision(15) ;
         int h,w,k;
         cin>>h>>w>>k;
         string s[h];
         for(int i=0;i<h;i++)cin>>s[i];
      
        int p,q,d[h],dd[h]={},ans=h*w+1;bool t=true,tt;
        for(int i=(1<<(h-1));i<(1<<h);i++){
                for(int j=0;j<h;j++)d[j]=0;
                p=1;q=0;t=true;
                for(int r=0;r<w;r++){
                        tt=false;
               for(int j=0;j<h;j++){
                       if(s[j][r]=='1')q++;
                       if(i&(1<<j)){
                               if(q>k)t=false;
                               dd[j]=q;
                               q=0;
                       }

               }
               for(int j=0;j<h;j++){

                       if(d[j]+dd[j]>k)tt=true;
               }
               if(tt){
                       p++;
                       for(int j=0;j<h;j++){
                               d[j]=dd[j];
                               dd[j]=0;
                       }
               }else{
                       for(int j=0;j<h;j++){
                               d[j]+=dd[j];
                               dd[j]=0;
                       }
               }
              
               //  cerr<<p<<' ';
                }
              //  cerr<<endl;
               
                if(t){
                        q=0;
                        for(int j=0;j<h;j++)if(i&(1<<j))q++;
                        ans=min(q+p-2,ans);
                }


        }
        cout<<ans;

         
}

        


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,m; cin >> n >> m;
  if(n%2==1){
    rep(i,m){
      cout << i+1 << " " << n-(i+1) << endl;
    }
  }
  else{
    set<int> st;
    rep(i,m){
      if(st.count(n-2*i-1)||n-2*i-1==2*i+1) n--;
      cout << i+1 << " " << n-i << endl;
      st.insert(n-2*i-1);
      st.insert(2*i+1);
    }
  }
}

Measured memory_bytes: 8276
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll a,b; cin >> a >> b;
  cout << (b-a)*(b-a+1)/2 -b << endl;
}

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

#l = list(map(int, input().split()))
#import numpy as np
#arr = np.array([int(i) for i in input().split()])
'''
a,b=[],[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

a,b,c,d=map(int, input().split())
print(max(a*c,a*d,c*b,b*d))

Measured memory_bytes: 9160
def main():
  N, X = map(lambda i: int(i), input().split(' '))
  m = []
  minimum = -1
  for i in range(N):
    m.append(int(input()))
    X -= m[i]
    if minimum == -1 or minimum > m[i]:
      minimum = m[i]
  print((X // minimum) + N)

main()


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
P f(int x){
    int a = x%10;
    int b = 0;
    while (x){
        b = x;
        x /=10;
    }
    return P(a, b);
}
int main() {
    int n;
    cin >> n;
    map<P, int> freq;
    rep(i, 1, n+1){
        P p = f(i);
        freq[p]++;
    }
    ll ans = 0;
    rep(i, 1, n+1){
        P p = f(i);
        P q(p.second, p.first);
        ans += freq[q];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    ll ans = 0;
#if true
    ll s = 0;
    ll index = 0;
    REP(i, N) {
        if ((s & A[i]) != 0) {
            ll n = 0;
            while ((s & A[i]) != 0) {
                ans += i - index;
                s ^= A[index++];
                n++;
            }
        }
        s ^= A[i];
    }
    ll m = N - index;
    ans += m * (m + 1) / 2;
#endif

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

LLI func( LLI n)
{
    if(n<5)
        return 0;
    return (n/5)/2 + func(n/5);
}

int main()
{
    int i,j;
    LLI N;

    scanf("%lld", &N);

    if(N%2==1)
        printf("0\n");
    else
    {
        printf("%lld\n", func(N));
    }


    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/   \/_________/\/__/   \/__/
//


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

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


Measured memory_bytes: 3560
#include <stdio.h>
using namespace std;
int main()
{
    char c;
    int n,f=0,i;
    scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%c",&c);
		if(c=='Y')
			f=1;
			
	}
	if(f==1)
 		printf("Four");
 	else
 		printf("Three");
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, m, q = map(int, input().split())
  lx = [tuple(map(int, input().split())) for _ in range(q)]
  
  def calc_score(nums):
    return sum([d for a, b, c, d in lx if nums[b-1] - nums[a-1] == c])  
  
  def dfs(nums, depth=0):
    if depth == n:
      return calc_score(nums)
    
    start = 0 if len(nums) == 0 else nums[-1]
    max_score = -1
    for e in range(start, m):
      max_score = max(max_score, dfs(nums + [e], depth+1))
    return max_score
  
  print(dfs([], 0))
    

if __name__=='__main__':
  main()


Measured memory_bytes: 9196
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <list>
#include <deque>
#include <numeric>
#include <set>
#include <climits>
#include <utility>
#include <map>
typedef long long ll;
typedef unsigned long long ull;
inline int max( int x, int y ){ return x > y ? x : y ; }
inline int min( int x, int y ){ return x < y ? x : y ; }
inline ll max( ll x, ll y ){ return x > y ? x : y ; }
inline ll min( ll x, ll y ){ return x < y ? x : y ; }
inline ull max( ull x, ull y ){ return x > y ? x : y ; }
inline ull min( ull x, ull y ){ return x < y ? x : y ; }
int GCD( int a, int b ) { return b ? GCD( b , a%b ) : a; }
using namespace std;
#define INF 987654321
#define MOD 1000000007
#define PIV 3.14159265358979323846
#define MAXN 10000


int main(){
	
	int N;
	string str;
	
	scanf("%d", &N);
	cin >> str;
	if( N >= 3200 ) cout << str;
	else cout << "red";
	
}











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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct edge{
    P to;
    int cost;
};

struct node{
    P v;
    int cost;

    bool operator<(const node & right) const {
        return cost > right.cost;
    }
};

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

    int n, m;
    cin >> n >> m;

    map<P, vector<edge> > g;
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        g[{a, c}].push_back({{b, c}, 0});
        g[{b, c}].push_back({{a, c}, 0});
        g[{a, c}].push_back({{a, 0}, 0});
        g[{a, 0}].push_back({{a, c}, 1});
        g[{b, c}].push_back({{b, 0}, 0});
        g[{b, 0}].push_back({{b, c}, 1});
    }

    map<P, int> dis;
    for(auto x : g){
        dis[x.first] = IINF;
    }
    dis[{n - 1, 0}] = IINF;

    priority_queue<node> que;
    que.push({{0, 0}, 0});
    while(!que.empty()){
        node now = que.top();
        que.pop();
        if(dis[now.v] <= now.cost){
            continue;
        }
        dis[now.v] = now.cost;
        for(auto x : g[now.v]){
            if(dis[x.to] > now.cost + x.cost){
                que.push({x.to, now.cost + x.cost});
            }
        }
    }

    if(dis[{n - 1, 0}] < IINF){
        cout << dis[{n - 1, 0}] << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 94708
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int N,A,B,T1;
  	cin>>N>>A>>B;
  	T1 = N*A;
  
  	if(T1<B){
      cout<<T1<<endl;
    }else{
      cout<<B<<endl;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
struct UnionFind {
    int sz;
    std::vector<int> par;
    UnionFind(int sz) {
        this->sz = sz;
        par.clear();
        par.resize(sz, -1);
    }
    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }
    void unite(int a, int b) {
        int roota = root(a);
        int rootb = root(b);
        if(roota == rootb) return;
        if(par[rootb] < par[roota]) std::swap(roota, rootb);
        par[roota] += par[rootb];
        par[rootb] = roota;
    }
    bool same(int a, int b) {
        return (root(a) == root(b));
    }
    int size(int a) {
        return -par[root(a)];
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
using ld = long double;
using Point = std::complex<ld>;
const ld eps = 1e-9, pi = acos(-1.0);
namespace std
{
bool operator<(const Point &lhs, const Point &rhs)
{
 if (lhs.real() < rhs.real() - eps)
  return true;
 if (lhs.real() > rhs.real() + eps)
  return false;
 return lhs.imag() < rhs.imag();
}
}
Point input_point()
{
 ld x, y;
 std::cin >> x >> y;
 return Point(x, y);
}
bool eq(ld a, ld b)
{
 return (abs(a - b) < eps);
}
ld dot(Point a, Point b)
{
 return real(conj(a) * b);
}
ld cross(Point a, Point b)
{
 return imag(conj(a) * b);
}
int ccw(Point a, Point b, Point c)
{
 b -= a;
 c -= a;
 if (cross(b, c) > eps)
  return 1;
 if (cross(b, c) < -eps)
  return -1;
 if (dot(b, c) < 0)
  return 2;
 if (norm(b) < norm(c))
  return -2;
 return 0;
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<Point> v(n);
  for(int i=0;i<n;++i) {
    double x, y; cin >> x >> y;
    v[i] = Point(x, y);
  }

  double l = 0.0, r = 1000.0;
  while(r - l > eps) {
    double rad = (l + r) / 2;
    int ma = 1;
    for(int i=0;i<n;++i) {
      for(int j=i+1;j<n;++j) {
        Point mid = (v[i] + v[j]) / (ld)2.0;
        Point diff = (v[i] - v[j]) / (ld)2.0;
        ld l2 = abs(diff);
        if(l2 + eps > rad) continue;
        ld tang = (rad * rad) / (l2 * l2) - 1;
        Point d(-imag(diff), real(diff));
        Point test1 = mid + d * sqrt(tang);
        Point test2 = mid - d * sqrt(tang);
        int cnt1 = 0, cnt2 = 0;
        for(int k=0;k<n;++k) {
          if(abs(v[k] - test1) < rad + eps) {
            cnt1++;
          }
          if(abs(v[k] - test2) < rad + eps) {
            cnt2++;
          }
        }
        ma = max(ma, max(cnt1, cnt2));
      }
    }
    if(ma == n) {
      r = rad;
    } else {
      l = rad;
    }
  }
  cout << l << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
       string s;
       while(cin>>s)
       {
           long l,a[100100]={0},p=0;
           l=s.size();
           fr(i,l)
           {
               a[s[i]]++;
           }
           fr(i,1000)
           {
               if(a[i]%2!=0)
               {
                   p=1;

               }
           }
           if(p==0)
           {
               cout<<"Yes\n";
           }
           else
            cout<<"No\n";
       }

        return 0;

}




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


int main(){
  string S;
  cin >> S;
  
  rep(i,S.size()) S.at(i) = 'x';
  
  cout << S <<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
 int main(){
    int K,S;
    int ans=0;
    cin >> K >> S;

    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K; j++){
            if(0 <= S - (i + j) && S - (i + j)  <= K){
                ans++;
                // cout << S - (i + j) << endl;
            } 
        }  
    }
    cout << ans <<endl;     
 }

Measured memory_bytes: 256
N, M = map(int, input().split())
G = [[] for i in range(3 * N)]
for i in range(M):
    u, v = map(int, input().split())
    u, v = u - 1, v - 1
    G[u].append([v + N, 1])
    G[u + N].append([v + 2 * N, 1])
    G[u + 2 * N].append([v, 1])

S, T = map(int, input().split())
S, T = S - 1, T - 1


def dijkstra(graph, start, inf=float('inf')):
    import heapq
    n = len(graph)
    distances = [inf] * n
    distances[start] = 0
    visited = [False] * n

    # 距離・頂点
    hq = [(0, start)]
    while hq:
        dist, fr = heapq.heappop(hq)
        visited[fr] = True

        for to, cost in graph[fr]:
            new_dist = distances[fr] + cost
            if (visited[to]) or (distances[to] <= new_dist):
                continue

            distances[to] = new_dist
            heapq.heappush(hq, (new_dist, to))

    return distances


distances = dijkstra(G, S)
print(distances[T] // 3 if distances[T] != float('inf') else -1)


Measured memory_bytes: 90668
def solve(fld)
  $h.times do |y|
    fld[y].each_cons(2).with_index do |(a, b), x|
      if a != b
        fld[y][x], fld[y][x+1] = fld[y][x+1], fld[y][x]
        return true if chain(fld.transpose.map{ |ar| ar.reverse })
        fld[y][x], fld[y][x+1] = fld[y][x+1], fld[y][x]
      end
    end
  end
  false
end
  
def chain(fld)
  loop do
    $f = false; $t = true
    adjust(fld)
    return true if $t
    fld = erase(fld, $w, $h, erase(fld.transpose, $h, $w).transpose)
    return false unless $f
  end
end
  
def erase(fld, r, c, nfld = fld)
  r.times do |y|
    fld[y].each_cons($n).with_index do |ar, x|
      next if ar.any?{ |v| !v }
      if ar.all?{ |v| v == ar[0] }
        $f = true
        while x < c && ar[0] == fld[y][x]
          nfld[y][x] = nil
          x += 1
        end
      end
    end
  end
  nfld
end
  
def adjust(fld)
  $w.times do |x|
    fld[x].map! { |v|
      if /[A-Z]/ =~ v
        $t = false
        v
      end
     }.compact!
  end
  fld.map!{|ar| ar.fill(nil, ar.size...$h) }
end
  
$h, $w, $n = gets.split.map(&:to_i)
fld = $h.times.map{ gets.chomp.split('').map{ |v| v if /[A-Z]/ =~ v } }
puts solve(fld) ? 'YES' : 'NO'

Measured memory_bytes: 10636
#include <stdio.h>
int main(void){
    long a,b,x,count=0;
    scanf("%ld%ld%ld", &a,&b,&x);
    if(a==0) count = b/x+1;
    else count = b/x-(a-1)/x;
    printf("%ld", count);
    return 0;
}

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

using namespace std;

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

int N, A, B, C;
int v[8];

int dfs(int x, int a, int b, int c){
  if (x == N){
    if (a == 0 || b == 0 || c == 0) return 1e9;
    return abs(a - A) + abs(b - B) + abs(c - C);
  }
  int ret = 1e9;
  ret = min(ret, dfs(x + 1, a, b, c));
  ret = min(ret, dfs(x + 1, a + v[x], b, c) + 10);
  ret = min(ret, dfs(x + 1, a, b + v[x], c) + 10);
  ret = min(ret, dfs(x + 1, a, b, c + v[x]) + 10);
  return ret;
}

int main(){
  cin >> N >> A >> B >> C;
  rep(i, 8) cin >> v[i];
  cout << dfs(0, 0, 0, 0) - 30 << endl;
}

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

using namespace std;

bool hasBit(int mask, int bit) {
	return !!(mask & (1 << bit));
}

vector<int> G[500000];

int DFS(int node, int par) {
	
	vector<int> Cnt(31);
	for(auto vec : G[node]) {
		if(vec == par) continue;

		int take = DFS(vec, node);
		for(int bit = 0; bit <= 30; ++bit)
			Cnt[bit] += hasBit(take, bit);
	}

	int tag;
	for(tag = 30; tag >= 0; --tag)
		if(Cnt[tag] >= 2)
			break;
	for(++tag; Cnt[tag] >= 1; ++tag);

	int ans = (1 << tag);
	for(++tag; tag <= 30; ++tag)
		ans |= (Cnt[tag] << tag);
	return ans;
}

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

	for(int i = 2; i <= n; ++i) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	cout << __lg(DFS(1, 0)) << endl;

	return 0;
}

Measured memory_bytes: 28720
N, X = map(int, input().split())
L = [int(i) for i in input().split()]
D = []
for i in range(N+1):
    if i == 0:
        D.append(0)
    else:
        D.append(D[i-1] + L[i-1])
print(len([i for i in D if i <= X]))

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

using namespace std;
set<int> s;
set<int>::iterator it;
int main()
{
    
    int n, q, x;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> q;
        switch (q)
        {
        case 0:
            cin >> x;
            s.insert(x);
            cout << s.size() << endl;
            break;

        case 1:
            cin >> x;
            it = s.find(x);
            (it != s.end()) ? cout << 1 << endl : cout << 0 << endl;
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 12360
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct Point {
	double x, y;
	bool operator < (const Point& p)const {
		if (y == p.y)return x < p.x;
		return y < p.y;
	}
};

Point sub(Point p1, Point p2) {
	Point p;
	p.x = p1.x - p2.x;
	p.y = p1.y - p2.y;
	return p;
}

double cross(Point v1, Point v2) {
	return v1.x * v2.y - v1.y * v2.x;
}

int main() {
	int n;
	vector<Point> P;
	vector<Point> U;
	vector<Point> L;

	cin >> n;
	for (int i = 0; i < n; i++) {
		Point p;
		cin >> p.x >> p.y;
		P.push_back(p);
	}

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

	U.push_back(P[0]);
	U.push_back(P[1]);

	for (int i = 2; i < P.size(); i++) {
		while (U.size() > 1) {
			int s = U.size();
			Point v1 = sub(U[s - 1], U[s - 2]);
			Point v2 = sub(P[i], U[s - 2]);
			if (cross(v1, v2) >= 0)break;
			U.pop_back();
		}
		U.push_back(P[i]);
	}

	L.push_back(P[P.size() - 1]);
	L.push_back(P[P.size() - 2]);

	for (int i = P.size() - 3; i >= 0; i--) {
		while (L.size() > 1) {
			int s = L.size();
			Point v1 = sub(L[s - 1], L[s - 2]);
			Point v2 = sub(P[i], L[s - 2]);
			if (cross(v1, v2) >= 0)break;
			L.pop_back();
		}
		L.push_back(P[i]);
	}

	cout << U.size() + L.size() - 2 << endl;
	for (int i = 0; i < U.size(); i++) {
		cout << U[i].x << " " << U[i].y << endl;
	}
	for (int i = 1; i < L.size() - 1; i++) {
		cout << L[i].x << " " << L[i].y << endl;
	}

	return 0;

}

Measured memory_bytes: 6496
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, n) for (int i = (a); i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (ll)1e9 + 7;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int n = (r - l) / d;
  if (r % d == 0 || l % d == 0) n++;
  cout << n << endl;
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define OO 1e9
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))

const double eps=1e-9;
const  int MOD=1e10;
const int N=1e5+9;
const int inf = 1<<30;


template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
int n;
int arr[N],g2[N],g[N];

int32_t main() {
    IOS;
cin>>n;
FOR(i,1,n){
    cin>>arr[i];
    g[i]=gcd(g[i-1],arr[i]);
}
int mx=0;
FORD(i,n,1){
    g2[i]=gcd(arr[i],g2[i+1]);
    mx=max(mx,gcd(g[i-1],g2[i+1]));
}
cout<<mx;
}

Measured memory_bytes: 2560
n, m = map(int, input().split())
l = [0]*(10**5+10)

for i in range(n):
    a, b = map(int, input().split())
    l[a] += b

sum = 0
for i in range(len(l)):
    sum += l[i]
    if sum >= m:
        print(i)
        break

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

int main() {
    
    int n,k;
    cin >> n >> k;
    
    double ans=0.0;

    for (int d = 1; d <= n; d++){
        
        int cnt=max(0.0,ceil(log2((double)k/(double)d)));
        ans=ans+pow(0.5,(double)cnt)/(double)n;
    }

    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 4144
#include<iostream>
using namespace std;
int map[100][100];
int h,w,n;
int c[10000];
int p[2][100];
main()
{
	cin>>h>>w>>n;
	for(int i=0;i<n;i++)cin>>c[i];
	for(int i=0;i<w;i++)p[0][i]=i,p[1][i]=w-i-1;
	int now=0,cnt=0;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			map[i][p[i%2][j]]=now+1;
			cnt++;
			if(c[now]==cnt)
			{
				cnt=0;
				now++;
			}
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cout<<map[i][j]<<(j<w-1?" ":"\n");
		}
	}
}


Measured memory_bytes: 384
N = io.read("*n", "*l")
S = io.read()
x = 0
y = 0
for i = 1, N do
    if string.sub(S, i, i) == "I" then
        y = y+1
    else
        y = y-1
    end
    x = math.max(x, y)
end
print(x)

Measured memory_bytes: 760