akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main(void){
  char str[100];
  scanf("%s",str);
  int i;
  for(i=0;i<strlen(str);i++){
    if(i%2!=0){
      if(str[i]=='R'){
        printf("No");
        return 0;
      }
    }else{
      if(str[i]=='L'){
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
	val ans = mutableListOf<String>()

	while (true) {
		val (x, y) = readLine()!!.split(" ").map { it.toInt() }
		if (x == 0 && y == 0) break

		ans.add("${Math.min(x, y)} ${Math.max(x, y)}")
	}
	println(ans.joinToString("\n"))
}


Measured memory_bytes: 32428
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll a;
    cin>>a;
    if(a<1200)cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

#define MAX_N 128;

int ans;


int main()
{
    int e;
    
    int ans = 100000000;;
    int temp = 10000000;
    
    
    while(cin >> e && e)
    {
        ans = 100000;
        for(int z=0; z<=100; ++z)
        {
            for(int y=0; y<=1000; ++y)
            {
                
                int m = (e - y*y - z*z*z) + y*y + z*z*z;
                if(m == e)
                {
                    int x = e - y*y - z*z*z;
                    if(x >= 0)
                    {
                        if(ans > x+y+z){ans = x+y+z;}
                    }
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
n = gets.to_i
txys = [[0, 0, 0], *n.times.map { gets.split.map(&:to_i) }]

ans = "Yes"
n.times do |i|
  rt, rx, ry = txys[i + 1]
  lt, lx, ly = txys[i]

  t = rt - lt
  x = (rx - lx).abs
  y = (ry - ly).abs

  if x + y > t
    ans = "No"
    break
  end

  t -= (x - y)
  if t.odd?
    ans = "No"
    break
  end
end

puts ans


Measured memory_bytes: 10364
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int,int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int main() {
	string a, b;
	while (cin >> a) {
		if (a == ".")break;
		cin >> b;
		queue<string>q1, q2;
		queue<string>p1, p2;
		int len = a.length();
		string v;
		rep(i, len) {
			if (a[i] == '"') {
				p1.push(v);
				v.clear();
			    string u;
				i++;
				while (a[i] != '"') {
					u += a[i]; i++;
				}
			    q1.push(u);
			}
			else {
				v += a[i];
			}
		}
		len = b.length();
		p1.push(v);
		v.clear();
		rep(i, len) {
			if (b[i] == '"') {
				p2.push(v);
				v.clear();
				string u; i++;
				while (b[i] != '"') {
					u += b[i]; i++;
				}
				q2.push(u);
			}
			else {
				v += b[i];
			}
		}
		p2.push(v);
		int cnt = 0;
		while (!q1.empty() && !q2.empty()) {
			string x = q1.front(); string y = q2.front(); q1.pop(); q2.pop();
			if (x != y)cnt++;
		}
		while (!p1.empty()&&!p2.empty()) {
			string x = p1.front(); string y = p2.front(); p1.pop(); p2.pop();
			if (x != y)cnt = 2;
		}
		if (!p1.empty() || !p2.empty())cnt = 2;
		if (cnt == 0) {
			cout << "IDENTICAL" << endl;
		}
		else if (cnt == 1) {
			cout << "CLOSE" << endl;
		}
		else {
			cout << "DIFFERENT" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <stdlib.h>
 
void Quicksort(int, int);
int Partition(int, int);
 
  
typedef struct{
  int n;
  char c;
  int count;
}Card;
  
Card a[100000];
  
int main(void){
  int n,i,q,f=0;
  char y;
  
  scanf("%d%c",&n,&y);
  for(i = 1; i < n+1; i++){
    scanf("%c%d%c",&a[i].c, &a[i].n, &y);
    a[i].count = i;
  }
  
  Quicksort(1,n);
  
  for(i = 0; i < n; i++){
    if(a[i].n == a[i+1].n && a[i].count > a[i+1].count){
      f = 1;
      break;
    }
  }
  
  if(f == 0){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
  
  for(i = 1; i < n+1; i++){
    printf("%c %d\n",a[i].c,a[i].n);
  }
  return 0;
}
  void Quicksort(int p, int r){
  int q;
  if(p < r){
    q = Partition(p,r);
    Quicksort(p,q-1);
    Quicksort(q+1,r);
  }
}
int Partition(int p, int r){
  int i,j;
  Card x,tmp;
  
  x = a[r];
  i = p - 1;
  
  for(j = p; j <= r-1; j++){
    if(a[j].n <=  x.n){
      i =  i + 1;
      tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  tmp = a[i+1];
  a[i+1] = a[r];
  a[r] = tmp;
  
  return i+1;
}

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

int main(){
    int n,m; cin >> n >> m;
    vector <int> broken(n,0);
    rep(i,m){
        int a; cin >> a;
        broken[a]=1;
    }
    
    vector <int> dp(n+2,0);
    dp[n]=1;
    for (int i=n-1; i>=0; i--){
        if (broken[i]){
            dp[i]=0;
            continue;
        }else{
            dp[i]=(dp[i+1]+dp[i+2])%1000000007;
        }
    }
    cout << dp[0];
    return 0;
}

Measured memory_bytes: 1152
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		if(s.charAt(1) == 'B'){
			System.out.println("ARC");
		}
		else{
			System.out.println("ABC");
		}
	}
}

Measured memory_bytes: 35676
#include <stdio.h>
#include <iostream>
#include <algorithm>
int main(void){
  int n;
  int a[200000];
  int b[200000];
  std::cin >> n;
  for(int i=0;i<n;i++){
    std::cin >> a[i];
    b[i] = a[i];
  }
  std::sort(b,b+n);
  int mid_right = b[(n-2)/2];
  int mid_left = b[n/2];
  if(mid_right == mid_left){
    for(int i=0;i<n;i++){
    	printf("%d\n",mid_right);
    }
    return 0;
  }
  for(int i=0;i<n;i++){
    if(a[i] <= mid_right){
      printf("%d\n",mid_left);
    }else if(a[i] >= mid_left){
      printf("%d\n",mid_right);
    }
  }
  return 0;
}

Measured memory_bytes: 3712
double x[100],y[100],t,u,a,b,s;
n,i,j,k,c;
main(m){
	for(;scanf("%d",&n),i=j=n;printf("%d\n",m)){
		for(m=1;i--;scanf("%lf,%lf",x+i,y+i));
		for(i=n;--i;)
			for(j=i-1;j--;)
				if((u=acos(hypot(x[j]-x[i],y[j]-y[i])/2))<9)
					for(s=1,t=atan2(y[j]-y[i],x[j]-x[i]);c=0,s+3;s-=2)
						for(a=x[i]+cos(t+s*u),b=y[i]+sin(t+s*u),k=n;k--;)
							hypot(a-x[k],b-y[k])<1+1e-7&&++c>m?m=c:0;
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

vector<ll>X[101010];

int main(){

    ll N, M;
    cin >> N >> M;
    for(ll i = 0; i < N; i++){
        ll a, b;
        cin >> a >> b;
        X[a].push_back(b);
    }
    ll ans = 0;
    priority_queue<ll>Q;
    for(ll i = 1; i <= M; i++){
        for(ll j = 0; j < X[i].size(); j++)Q.push(X[i][j]);
        if(Q.empty())continue;
        ans += Q.top();
        Q.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
/* nothing is impossible */
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#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 fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;                                                                                           
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}             
const ll N=1000008;
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,m;
  cin>>n>>m;
  ll ans=1;
  for(ll i=1;i*i<=m;i++)
  {
    if(m%i==0)
    {
      if(i*n<=m)
      {
        ans=max(ans,i);
      }
      if((m/i)*n<=m) ans=max(ans,m/i);
    }
  }
  cout<<ans;
  return 0;   
}

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

int main() {
    string n;
    cin >> n;
    rep(i, 3) {
        if (n[i] == '1') n[i] = '9';
        else if (n[i] == '9') n[i] = '1';
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    ll ans = 0;
    vector<ll> a(s.length()+1, 0);

    for(int i = 0; i < s.length(); i++){
        if(s[i] == '<'){
            if(a[i] >= a[i+1]) a[i+1] = max(a[i+1], a[i]+1);
        }
    }
    for(int i = s.length()-1; i >=0; i--){
        if(s[i] == '>' && a[i] <= a[i+1]){
            a[i] = max(a[i], a[i+1]+1);
        }
    }
    for(int i = 0; i < s.length()+1; i++){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7708
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<vector>
using namespace std;

signed main() {
	int a, b, c; cin >> a >> b >> c;
	cout << (a - c) / (b + c) << endl;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, m, x; cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n);
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }
    int ans = INF;
    for(int bit = 0; bit < (1<<n); ++ bit) {
        int res = 0;
        rep(i, n) {
            if(bit & (1<<i)) res += c[i];
        }
        vector<int> z(m, 0);
        rep(i, n) {
            if(bit & (1<<i)) {
                rep(j, m) {
                    z[j] += a[i][j];
                }
            }
        }
        bool ok = 1;
        rep(j, m) {
            if(z[j] < x) ok = 0;
        }
        if(ok) {
            chmin(ans, res);
        }
    }
    if(ans == INF) {
        cout << -1 << endl;
        return;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    int m[3];
    m[0] = 2*a-1;
    m[1] = 2*b-1;
    m[2] = a+b;
    cout << max({m[0], m[1], m[2]}) << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var h = parseInt(tmp[0], 10);
	var a = parseInt(tmp[1], 10);

	for(i=1;i<=10000;i++){
        if(0>=h-a*i){console.log(i);
                    break;}
       }
	
	
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  vector<int> prime(55555 + 1, 1);
  int x = 2;
  while(x * x <= 55555) {
    for(int i = x * 2; i <= 55555; i += x) prime[i] = 0;
    do
      x++;
    while(!prime[x]);
  }
  int n, c = 0;
  scanf("%d", &n);
  for(int i = 2; i <= 55555; i++) {
    if(prime[i] && i % 5 == 1) printf("%d%c", i, ++c == n ? '\n' : ' ');
    if(c == n) return 0;
  }
}

Measured memory_bytes: 512
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			string s = Console.ReadLine();
			string t = Console.ReadLine();

			int ans = int.MaxValue;
			for (int i = 0; i < s.Length - t.Length + 1; i++) {
				int cnt = 0;
				for (int j = 0; j < t.Length; j++) {
					if (s[i + j] != t[j]) {
						cnt++;
					}
				}
				ans = Math.Min(ans, cnt);
			}
			Console.WriteLine(ans);

		}
	}
}


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

int const MOD = 1e9+5;

#define  pi acos(-1.00)
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define newLine printf("\n")
#define start_p int main()
#define end_p return 0
#define test_IO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;


start_p{
    #ifndef ONLINE_JUDGE
    //test_IO;
    #endif // ONLINE_JUDGE

    double r; cin>>r;
    double c = 2*pi*r;
    cout<<setprecision(20)<<fixed<<c<<endl;
    //67252742410977361942
    end_p;
}



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

int gcd(int a,int b)
{
    if(a%b==0)
        return b;

    else
        return gcd(b,a%b);
}

int main()
{
    int i,j,k,n,sum=0;
    cin>>n;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                sum+=gcd(gcd(i,j),k);
            }
        }
    }

    cout<<sum<<endl;
}


Measured memory_bytes: 3648
(defun greedy-takahashi ()
  (let ((a (read))
        (b (read))
        (k (read))) 
    (setq a (- a k)) 
    (if (> 0 a)
        (progn (setq b (+ b a))
               (setq a 0))) 
    (if (> 0 b) 
        (setq b 0)) 
    (values a b))) 

(multiple-value-bind (a b) (greedy-takahashi) 
  (format t "~D ~D~%" a b))     



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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


long long gcd( long long m, long long n ){

  if ( n == 0) return m;
  return gcd(n,m%n);
}//gcd

long long lcm( long long m, long long n ){
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  VLL a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) a[i] /= 2LL;
  ll xx = a[0];
  rep(i,n) xx = lcm(a[i],xx);
  if(xx > m){
    cout << 0 << endl;
    return 0;
  }
  if(xx % 2 == 1){
    ll ok = m/xx;
    cout << (ok+1LL)/2LL << endl;
  }else{
    ll tmp = xx;
    ll cnt = 0;
    while(tmp%2 == 0){
      tmp /= 2;
      cnt++;
    } 

    rep(i,n) {
      if(a[i] % (ll)(pow(2,cnt)) != 0){
        cout << 0 << endl;
        return 0;
      }
    }
    ll ok = m/xx;
    cout << (ok+1LL)/2LL << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */



#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <limits>


#include <ostream>
#include <sstream>


using namespace std;

class B {
public:
  void solve(std::istream &in, std::ostream &out) {
    ios::sync_with_stdio(false);
    int a, b, c;
    in >> a >> b >> c;
    for (int i = 2; i < 100000; ++i) {
      if ((i * a) % b == c) {
        out << "YES" << endl;
        return;
      }
    }
    out << "NO" << endl;
  }
};


int main() {
  B solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N;

int main(){
    cin>>N;
    out(N*(N+1)/2);
}


Measured memory_bytes: 256
n = int(input())
*A, = input().split()
B = A[:]
for i in range(n):
    for j in range(n-1, i, -1):
        if A[j][1] < A[j-1][1]:
            A[j], A[j-1] = A[j-1], A[j]
print(*A)
print("Stable")

for i in range(n):
    mj = i
    for j in range(i, n):
        if B[j][1] < B[mj][1]:
            mj = j
    B[i], B[mj] = B[mj], B[i]
print(*B)
if A == B:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const int maxN = 2000 + 5;
int n, m;
struct Tree {
	int root;
	set<int> S;
	vector<int> G[maxN];
	void link(int x, int y) {
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int euler[maxN], pre[maxN], post[maxN];
	int dfs_clock;
	void init(int root) {
		this->root = root;
		dfs_clock = 0;
		S.clear();
	}
	void DFS(int u, int fa) {
		for(auto p = G[u].begin(); p != G[u].end(); ++p) if(*p == fa) {
			G[u].erase(p); break;
		}
		euler[pre[u] = ++dfs_clock] = u;
		for(int &v : G[u]) {
			DFS(v, u);
		}
		post[u] = dfs_clock;
	}
	bool contains(int y) {
		return S.count(pre[y]);
	}
	int findtop(int y) {
		auto p = S.lower_bound(pre[y]);
		if(p == S.begin()) return 0;
		else {
			int u = euler[*--p];
			if(pre[u] <= pre[y] && pre[y] <= post[u]) return u;
			else return 0;
		}
	}
	void add(int y) {
		S.insert(pre[y]);
	}
	void remove(int y) {
		S.erase(pre[y]);
	}
	vector<int> headless_subtree(int y) {
		return vector<int>(euler + pre[y] + 1, euler + post[y] + 1);
	}
	void show() {
		for(int x : S) printf("%d ", euler[x]);
		printf("\n");
	}
} t[maxN];

void link(int x, int y) {
//	printf("link %d %d\n", x, y);
	if(t[x].contains(y)) return;
	else if(t[x].findtop(y)) link(t[x].findtop(y), y);
	else if(t[y].findtop(x)) link(t[y].findtop(x), x);
	else {
		t[x].add(y);
		t[y].add(x);
		vector<pii> plan;
		int T = 2;
		while(T--) {
			auto vec = t[x].headless_subtree(y);
			for(int u : vec) if(t[x].contains(u)) {
				t[x].remove(u); t[u].remove(x);
				plan.emplace_back(y, u);
			}
			swap(x, y);
		}
		for(pii p : plan) link(p.first, p.second);
	}
}

short ok[maxN][maxN];
bool check(int x, int y) {
	if(x > y) swap(x, y);
	short &res = ok[x][y];
	if(res != -1) return res;
	res = 0;
	if(t[x].contains(y)) res = 1;
	else {
		int k = t[y].findtop(x);
		if(k && check(k, x)) res = 1;
	}
	return res;
}

int main() {
	cin >> n >> m;
	for(int u = 1; u <= n; ++u) t[u].init(u);
	for(int i = 1; i < n; ++i) {
		int x, y; cin >> x >> y;
		for(int u = 1; u <= n; ++u) t[u].link(x, y);
	}
	for(int u = 1; u <= n; ++u) t[u].DFS(u, -1);
	for(int i = 1; i <= m; ++i) {
		int x, y; cin >> x >> y;
		link(x, y);
	}
//	for(int u = 1; u <= n; ++u) t[u].show();
	memset(ok, -1, sizeof(ok));
	int cnt = 0;
	for(int x = 1; x <= n; ++x) {
		for(int y = x + 1; y <= n; ++y) {
			cnt += check(x, y);
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 290688
n = gets.to_i
s = n.times.map{ gets.chomp.chars.sort }.sort

ans = 0
cnt = 0
n.times do |i|
    
    if i == n - 1 or s[i] != s[i+1]
        ans += (cnt+1)*cnt/2
        cnt = 0
    else
        cnt += 1
    end
end

puts ans

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


def main():
  x, y, na, nb, nc = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0
  
  lx = la[:x] + lb[:y] + lc
  lx.sort(reverse=True)
  print(sum(lx[:x+y]))

if __name__=='__main__':
  main()


Measured memory_bytes: 23328
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
vector<int>a;
ll solve(int x,int y){
    ll res = 0;
    if(x==y)return a[x];
    int mi = a[x];
    int ma = a[y];
    for(int i = y; i>=x; i--){
        if(i==x){
            res += ma;
        }
        else if(a[i]-a[i-1] >1){
            return -1;
        }else if(a[i]-a[i-1] == 1){
            continue;
        }else{
            res+=ma;
            ma = a[i-1];
        }
    }
    return res;
}
int main(){
    int n;
    cin >> n;
    a.resize(n);
    rep(i,n){
        scanf("%d",&a[i]);
    }
    if(a[0]!=0){
        cout << -1 << endl;
        return 0;
    }
    int l = 1;
    int r;
    ll ans = 0;
    for(int i =1; i<n;i++){
        if(i==n-1){
            ll k = solve(l,n-1);
            //show(k);
            ans+=k;
        }else{
            if(a[i]>=a[i+1]){
                r = i;
                ll k = solve(l,r);
                //cout << l << " " << r << endl;
                //show(k);
                if(k==-1){
                    cout << -1 << endl;
                    return 0;
                }
                ans += k;
                l = i+1;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int a, b, m; cin >> a >> b >> m;
	int r[a], f[b];
	for (int i = 0; i < a; ++i)
	{
		cin >> r[i];
	}
	for (int i = 0; i < b; ++i)
	{
		cin >> f[i];
	}
	int ans = *min_element(r, r+a) + *min_element(f, f+b);
	for (int i = 0; i < m; ++i)
	{
		int x, y, c; cin >> x >> y >> c;
		ans = min(ans, r[x-1] + f[y-1] - c);
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int T[101] = {0};

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

  int K, S;
  cin >> K >> S;

  long long ans = 0;
  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      const int z = S - x - y;
      if (0 <= z && z <= K) ++ans;
    }
  }
  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n,k;
int a[maxn];

int32_t main()
{
    IOS
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    int sum=0;
    for (int i=1;i<=n-k;i++) sum+=a[i];
    cout<<sum<<endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	while(1){
		int x,y,z,ans=0;
		cin >> x >> y >> z;
		if(!x&&!y&&!z)	break;
		for(int i=1;i<z;i++){
			for(int j=1;j<z;j++){
				if(int(i*(100+x)/100)+int(j*(100+x)/100)==z)
					ans = max(ans,int(i*(100+y)/100)+int(j*(100+y)/100));
			}
		}
		cout << ans << endl;
	}
}


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

int main()
{
  int A, B;
  cin >> A >> B;
  cout << A*B << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int X = sc.nextInt();
		
		int []x = new int [n];
		int []y = new int [n];
		
		for(int i = 0; i < n ; i++) {
			x[i] = sc.nextInt();
			y[i] = Math.abs(x[i] - X);
		}
		Arrays.sort(y);
		int ans = y[n-1];
		
		for(int i = 0; i < n-1 ; i++) {
			ans = Math.min(ans, gcd(y[i],y[i + 1]));
		}
		System.out.println(ans);

	}
	private static int gcd(int a, int  b) {
		int  temp = 0;

		if(a == 0) {
			return b;
		}
		if(b == 0) {
			return a;
		}
		if(a != 0 || b != 0) {
		while (a % b != 0){
			temp = a;
			a = b;
			b = temp % b;
		}
		}
		return b;
	}

	
	}




Measured memory_bytes: 50224
q, h, s, d = map(int, input().split())
n = int(input())

ans = 0

s = min(s, 2*min(h, 2*q))

if s*2 <= d:
    ans = s*n
elif s*2 > d:
    ans = n//2*d + n%2*s

print(ans)

Measured memory_bytes: 61916
s=raw_input().split(' ')
n=int(s[0])
k=int(s[1])

ar=[]
for i in range(0,n):
	j=int(input())
	ar.append(j)

ar.sort()
i=0; j=k-1;
mn=100000000000
while j<n:
	if ar[j]-ar[i]<mn:
		mn=ar[j]-ar[i]
	j+=1; i+=1;
print(mn);

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

using namespace std; 
 
#define int long long
#define M 1000000007
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	int n,m;
	cin >> n >> m;
	if(n==m){
		cout << "Yes" << endl;
	}	
	else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3644
import numpy as np
x = int(input())
def fp(a):
    if a == 1:
        return False
    for i in range(2,int(np.sqrt(a))+1):
        if a % i == 0:
            return False
    return True
for i in range(x,100004):
    if fp(i):
        print(i)
        exit()

Measured memory_bytes: 12484
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;




int N, M;
vector<VI> G;
int dp[100010];
int t[200010];//size of subtree
int ans[200010];

void dfs1(int now, int pa) {
	dp[now] = 1;
	fore(to, G[now]) {
		if (to == pa)continue;
		dfs1(to, now);
		dp[now] *= dp[to] + 1;
		dp[now] %= M;
	}	
}

void dfs(int now, int pa) {
	ans[now] = 1;
	fore(to, G[now]) {
		ans[now] *= dp[to] + 1;
		ans[now] %= M;
	}

	int n = G[now].size();
	VI L(n), R(n);

	REP(i, n)L[i] = R[i] = dp[G[now][i]] + 1;

	FOR(i, 1, n) {
		L[i] *= L[i - 1];
		L[i] %= M;
	}
	for (int i = n - 2; i >= 0; i--) {
		R[i] *= R[i + 1];
		R[i] %= M;
	}

	REP(i, n) {
		if (G[now][i] == pa)continue;
		dp[now] = 1;
		if (i)dp[now] *= L[i - 1];
		if (i + 1 < n)dp[now] *= R[i + 1];
		dp[now] %= M;
		dfs(G[now][i], now);
	}
}

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

	cin >> N >> M;
	G.resize(N);
	REP(i, N - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs1(0, -1);
	
	dfs(0, -1);
	REP(i, N)cout << ans[i] << "\n";



	return 0;
}



Measured memory_bytes: 18560
import sys
from heapq import heapify, heappush, heappop
hq = []
S = []
for s in sys.stdin:
    if s[2] == "s":
        heappush(hq, -int(s[7:]))
    elif s[2] == "t":
        S.append(-heappop(hq))
    else:
        break
print("\n".join(map(str, S)))



Measured memory_bytes: 99120
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    ll n,t;
    cin >> n >> t;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    ll mi = a[0];
    ll ma = a[0];
    ll k = 0;
    ll ans = 1;

    for(ll i = 1;i < n;i++){
        if(ma < a[i]){
            ma = a[i];
        }
        if(a[i] < a[i-1] || i == n - 1){
            if(k < ma - mi){
                k = ma - mi;
                ans = 1;
            }
            else if(k == ma - mi){
                ans++;
            }
            if(mi > a[i]){
                mi = a[i];
            }
            ma = a[i];
        }
    }

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

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

    int N,M;
    int WA[105000];
    bool AC[105000];
    void solve()
    {
        cin >> N >> M;
        int WAnum = 0;
        int ACnum = 0;
        for(int i = 1; i<=N;i++)
        {
            WA[i]=0;
            AC[i] = false;
        }
        while(M--)
        {
            int p;
            string S;
            cin >> p >> S;
            if(AC[p]) continue;
            if(S == "AC")
            {
                AC[p] = true;
                ACnum++;
                WAnum += WA[p];
            }
            else if(S=="WA")
            {
                WA[p]++;
            }
        }
            cout << ACnum << " " << WAnum << endl;
            
    }
    int main(){
        solve();
        return 0;
    }

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    for(ll i=0;i<n;i++)
    cin>>a[i]>>b[i];
    sort(begin(a),end(a));
    sort(begin(b),end(b));
    if(n%2==1)
    {
        cout<<abs(a[n/2]-b[n/2])+1<<endl;
    }
    else
    {
        ll p=abs(a[n/2]+a[n/2-1]-b[n/2-1]-b[n/2]);
        cout<<p+1<<endl;
    }
    
}

Measured memory_bytes: 6424
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
using namespace std;
typedef long long ll;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	ll b;
	if (k % 2 == 0) {
		b = k / 2;
	}
	else {
		b = k;
	}
//	cout << b << " b" << endl;
	ll ans = 0;
	for (int i = b; i <= n; i += b) {
		ll a = (n - i) / k + (i-1) / k+1 ;
//		cout << i << " " << a * a << endl;
		ans += a * a;
	}
	cout << ans;
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) char a[n + 3][m + 3] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e12;
const ll mod = 1e9 + 7;
vi adj[401];
int n, m;
inline int coo (int i, int j) {return (i - 1)*m + j;}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int d[401][401] = {};
	
    cin >> n >> m;
    READMAT(a, n, m);
    FOR (i, 1, n)
        FOR (j, 1, m)
        {
            if (a[i][j] == '#') continue;
            if (a[i + 1][j] == '.') d[coo(i, j)][coo(i + 1, j)] = d[coo(i + 1, j)][coo(i, j)] = 1;
            if (a[i - 1][j] == '.') d[coo(i, j)][coo(i - 1, j)] = d[coo(i - 1, j)][coo(i, j)] = 1;
            if (a[i][j + 1] == '.') d[coo(i, j)][coo(i, j + 1)] = d[coo(i, j + 1)][coo(i, j)] = 1;
            if (a[i][j - 1] == '.') d[coo(i, j)][coo(i, j - 1)] = d[coo(i, j - 1)][coo(i, j)] = 1;
        }
    
    FOR (i, 1, 400)
        FOR (j, 1, 400)
            if (!d[i][j]) d[i][j] = inf;
            
    int ans = 0;
    
    for (int k = 1; k <= 400; ++k) {
       for (int i = 1; i <= 400; ++i) {
        for (int j = 1; j <= 400; ++j) {
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
    }
    FOR (i, 1, 400)
        FOR (j, 1, 400)
            if ((d[i][j] < inf) && i != j) ans = max(ans, d[i][j]);
    
    cout << ans;
}


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

int main() {

	int cat, cord, x;
	cin >> cat >> cord >> x;

	if (cat > x) {
		cout << "NO";
	}
	else if (cat == x) {
		cout << "YES";
	}
	else if (cat < x&&cat + cord >= x) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
 
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b;
  cin>>a>>b;
  
  if(a%2==1) a++;
  if(b<=a/2) cout<<"YES"<<'\n';
  else cout<<"NO"<<'\n';
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string s;
    cin >> s;

    //int a = strlen(s);

    for(int i = 0; i < s.length(); i++){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
main () {
  int a, b;
  char op;
  while(~scanf("%d%*c%c%*c%d", &a, &op, &b)) {
    switch(op) {
      case '+': printf("%d\n", a + b); break;
      case '-': printf("%d\n", a - b); break;
      case '*': printf("%d\n", a * b); break;
      case '/': printf("%d\n", a / b); break;
      default: return 0;
    }
  }
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

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

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

	// 深さごとの頂点数の上限
	vector<ll> MX(n+1);
	MX = A;
	for(int i = n-1; i >= 0; --i)
	{
		MX[i] += MX[i+1];
	}

	// 根っこから順に比較
	ll ans = 0, v = 1;
	for(int i = 0; i < n+1; ++i)
	{
		if (i != 0)
			v = min(v*2, MX[i]);
		ans += v;
		v -= A[i];
		// 葉の数を引いてvがマイナスになったらはじく
		if (v < 0)
		{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;

	// for(int i = 0; i < n+1; ++i)
	// {
	// 	if (i)
	// 		cout << " ";
	// 	cout << MX[i];
	// }
	// cout << endl;
}



Measured memory_bytes: 4844
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, R = map(int, raw_input().split())
print R + 100 * max(0, 10 - N)

Measured memory_bytes: 4268
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	
	cout << max({a + (a - 1), b + (b - 1), a + b}) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define first F
#define second S

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

int main(void) {
  int i,j;
  int a,b,c,d,p;
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
  cin>>p;
  cout<<min(p*a,b+max(0,(p-c)*d))<<endl;
}

Measured memory_bytes: 3092
#!/usr/bin/env python

def solve(n):
    dp = [0] * (n + 10)
    dp[0] = dp[1] = dp[2] = 1
    for i in xrange(n):
        for j in range(3):
            dp[i+j+1] += dp[i]
    days = (dp[n-1] - 1) / 10 + 1
    years = (days - 1) / 365 + 1
    return years

while True:
    n = int(raw_input())
    if not n:
        break
    print solve(n)

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

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

void solve(long long N, long long M, std::vector<std::string> A, std::vector<std::string> B)
{
    for (ll i = 0; i < N - M + 1; ++i) {
        for (ll j = 0; j < N - M + 1; ++j) {
            bool match = true;
            for (ll k = 0; k < (ll)B.size(); ++k) {
                if (!equal(begin(B[k]), end(B[k]), begin(A[i + k]) + j)) {
                    match = false;
                    break;
                }
            }
            if (match) {
                cout << YES << endl;
                return;
            }
        }
    }
    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)
// clang-format off
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<std::string> A(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> A[i];
    }
    std::vector<std::string> B(M);
    for(int i = 0 ; i < M ; i++){
        std::cin >> B[i];
    }
    cin.tie(nullptr);
    cout.tie(nullptr);
	ios_base::sync_with_stdio(false);
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define all(x) (x).begin(),(x).end()
//#define DEBUG
#ifdef DEBUG
#include "debug.cpp"
#endif
using namespace std;

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    char before = 'R';
    int count = 0;
    vector<int> q;
    rep(i, s.size())
    {
        if (s[i] != before)
        {
            q.push_back(count);
            count = 0;
            before = s[i];
        }
        count++;
    }
    if (count > 0) q.push_back(count);
    for (int i = 0; i < q.size(); i += 2)
    {
        rep(j, q[i] - 1)
        {
            cout << "0 ";
        }
        cout << q[i] / 2 + q[i] % 2 + q[i + 1] / 2 << " ";
        cout << q[i] / 2 + q[i + 1] % 2 + q[i + 1] / 2 << " ";
        rep(j, q[i + 1] - 1)
        {
            cout << "0 ";
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1096
n,m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

P = [0] * (n+1)
pena = [0] * (n+1)
for p,s in ps:
    p = int(p)
    if s == "WA":
        if P[p] == 0: pena[p] += 1
    else:
        P[p] = 1
ans = [0,0]
for p,pe in zip(P,pena):
    p = int(p)
    if p == 0: continue
    ans[0] += 1
    ans[1] += pe
print(" ".join(map(str, ans)))

Measured memory_bytes: 32060
//20181208
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main() {

    int a;
    cin >> a;

    if(a==25) cout << "Christmas" << endl;
    else if(a == 24) cout << "Christmas Eve" << endl;
    else if(a == 23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int a=0,b=0;
    rep(i,N){
        if(S[i] == 'a' && a+b < A+B){
            a++;
            cout << "Yes" << endl;
            continue;
        }
        if(S[i] == 'b' && a+b < A+B && b < B){
            b++;
            cout << "Yes" << endl;
            continue;
        }
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#define ROPi(n) for(int i=0; i<n; i++)
#define ROPj(n) for(int j=0; j<n; j++)
#define ROPia(a,n) for(int i=a; i<n; i++)
using namespace std;

typedef long long int LLI;

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

	int* a = (int*)malloc(sizeof(int)*N);
	LLI totalSum = 0;
	ROPi(N) {
		cin >> a[i];
		totalSum += a[i];
	}

	LLI sumA = a[0];
	LLI sumB = totalSum - a[0];
	LLI ans = (LLI)abs(sumA - sumB);
	LLI temp;

	for (int i = 1; i < N - 1; i++) {
		sumA += a[i];
		sumB -= a[i];
		temp = (LLI)abs(sumA - sumB);
		if (ans > temp)
			ans = temp;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

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

int main() {
    int n, k; cin >> n >> k;
    
    vpii vex;
    
    for(int i = 1; i < n; ++i)
        vex.emplace_back(1, i + 1);
    
    int mx = (n - 1) * (n - 2) / 2;
    
    for(int i = 1; i < n; ++i)
        for(int j = i + 1; j < n; ++j) {
            if(mx == k) { n = 0; continue; }
            vex.emplace_back(i + 1, j + 1);
            mx -= 1;
        }
    
    if(k != mx) cout << -1;
    else {
        cout << vex.size() << '\n';
        for(pii& r : vex)
            cout << r.first << ' ' << r.second << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 384