akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int H, W; cin >> H >> W;
    vector<vector<int>> c(H, vector<int>(W));
    for (auto &ci: c) for (auto &cij: ci) cin >> cij;
    vector<vector<int>> dp(H, vector<int>(W));
    int ans = 0;
    for (int i = 0, j = 0; i < H; i++) ans |= dp[i][j] = !c[i][j];
    for (int j = 0, i = 0; j < W; j++) ans |= dp[i][j] = !c[i][j];
    for (int i = 1; i < H; i++) for (int j = 1; j < W; j++) {
        if (c[i][j]) {
            dp[i][j] = 0;
        } else {
            dp[i][j] = min({dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]}) + 1;
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans * ans << endl;
    return 0;
}


Measured memory_bytes: 18160
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define foo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(a,min(b,min(c,d)))
#define max4(a,b,c,d)       max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, ll exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = pow(10,9)+7;
const int N = 3e5, M = N;

//=================================================== ====================================
vi g[N];
int vis[N];
int nodes=0;

void iluzn(){
 int n;
 cin>>n;
 string s="";
 int i;
 fo(i,n)
   s+="ACL";
  cout<<s;
  
}


 
int main() {
  #ifndef ONLINE_JUDGE
    freopen("ab.txt","r",stdin);
    freopen("b.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t=1,i;
    // cin>>t;
     while(t--) iluzn();
    return 0;
}
int mpow(int base, ll exp) {
  base %=mod ;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    // g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10708
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        int ones = 0;
        int zeros = 0;
        for (int i = 0; i < s.length(); ++i) {
            if (s.charAt(i) == '0') {
                if (ones > 0) {
                    --ones;
                } else {
                    ++zeros;
                }
            } else {
                if (zeros > 0) {
                    --zeros;
                } else {
                    ++ones;
                }
            }
        }
        int res = s.length() - (zeros + ones);
        System.out.println(res);
    }
}


Measured memory_bytes: 24908
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
#define shosu(x) fixed<<setprecision(x)
typedef long long ll;

int main()
{	
	int a,b;
	char op;
	cin>>a;
	cin>>op;
	cin>>b;
	
	if(op=='+')
		cout<<a+b<<endl;
	else
		cout<<a-b<<endl;


	return 0;
}



Measured memory_bytes: 764
#include <algorithm>
#include <ctype.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define ENDL '\n'
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FOR_EACH(i, v) for (auto&& i : v);

const int MOD = 1000000007;

template<int mod> class Fp {
public:
	long long mVal;

	Fp(long long val = 0)
	{
		mVal = val % mod;
		if (mVal < 0) {
			mVal += mod;
		}
	}

	int getMod() { return mod; }

	Fp operator-() const
	{
		return mVal ? mod - mVal : 0;
	}

	Fp& operator+=(const Fp& fp)
	{
		mVal += fp.mVal;
		if (mVal >= mod) {
			mVal -= mod;
		}
		return *this;
	}

	Fp& operator-=(const Fp& fp) {
		mVal -= fp.mVal;
		if (mVal < 0) {
			mVal += mod;
		}
		return *this;
	}

	Fp& operator*=(const Fp& fp) {
		mVal = mVal * fp.mVal % mod;
		return *this;
	}

	Fp& operator/=(const Fp& fp) {
		long long a = fp.mVal;
		long long b = mod;
		long long u = 1LL;
		long long v = 0LL;
		while (b) {
			long long t = a / b;
			a -= t * b;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		mVal = mVal * u % mod;
		if (mVal < 0) {
			mVal += mod;
		}
		return *this;
	}
};

Fp<MOD> operator+(const Fp<MOD>& fp1, const Fp<MOD>& fp2)
{
	return Fp<MOD>(fp1) += fp2;
}

Fp<MOD> operator-(const Fp<MOD>& fp1, const Fp<MOD>& fp2)
{
	return Fp<MOD>(fp1) -= fp2;
}

Fp<MOD> operator*(const Fp<MOD>& fp1, const Fp<MOD>& fp2)
{
	return Fp<MOD>(fp1) *= fp2;
}

Fp<MOD> operator/(const Fp<MOD>& fp1, const Fp<MOD>& fp2)
{
	return Fp<MOD>(fp1) /= fp2;
}

bool operator==(const Fp<MOD>& fp1, const Fp<MOD>& fp2)
{
	return fp1.mVal == fp2.mVal;
}

bool operator!=(const Fp<MOD>& fp1, const Fp<MOD>& fp2)
{
	return !(fp1 == fp2);
}

ostream& operator<<(ostream& os, const Fp<MOD>& fp)
{
	return os << fp.mVal;
}

Fp<MOD> modPow(const Fp<MOD>& fp, long long n)
{
	if (!n) {
		return Fp<MOD>(1LL);
	}
	Fp<MOD> t = modPow(fp, n / 2);
	t *= t;
	if (n & 1) {
		t *= fp;
	}
	return t;
}

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

	int N;
	cin >> N;

	Fp<MOD> power(1LL);
	FOR(i, N) {
		power *= i + 1;
	}

	cout << power << ENDL;

	return 0;
}

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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define debug(x) cerr<<#x<<"="<<x<<'\n'

const int maxn=5e5+10;

int n,m;
int tree[30][maxn];
int a[maxn];

int lowbit(int x) {
	return x&(-x);
}

void update(int id,int pos,int val) {
	while (pos<maxn) {
		tree[id][pos]+=val;
		pos+=lowbit(pos);
	}
	return;
}

int query(int id,int pos) {
	int res=0;
	while (pos) {
		res+=tree[id][pos];
		pos-=lowbit(pos);
	}
	return res;
}

int main(){
	scanf("%d\n",&n);
	for (int i=1;i<=n;i++) {
		char c;
		scanf("%c",&c);
		update((int)(c-'a'),i,1);
		a[i]=(int)(c-'a');
	}
	scanf("%d",&m);
	while (m--) {
		int x;
		scanf("%d",&x);
		if (x==1) {
			int y;
			char c;
			scanf("%d %c",&y,&c);
			update(a[y],y,-1);
			a[y]=(int)(c-'a');
			update(a[y],y,1);
		}
		else {
			int l,r;
			scanf("%d%d",&l,&r);
			int ans=0;
			for (int i=0;i<26;i++)
				if (query(i,l-1)!=query(i,r)) ans++;
			printf("%d\n",ans);
		}
	}
	return 0;
}


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

vector<int> to[100005];
int n;
//あとは全頂点との距離を求める。
vector<int> dist;
void dfs(int v,int d=0,int p=-1){
    //↑みたいに、初期値いいね！
    dist[v] = d;
    for(int u : to[v]){
        if(u == p)continue;
        //まさかの、ペアレント設定をするだけで逆流をふせぐ。
        dfs(u,d+1,v);
    }
}
vector<int> calcDist(int s){
    dist = vector<int>(n);
    dfs(s);//初期値は突っ込んである。
    return dist;
}

int main(){
    cin>>n;
    int s,t;//s=高橋,t=青木
    cin>>s>>t;
    --s;--t;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }//隣接リストを作る。

    vector<int> distS = calcDist(s);
    vector<int> distT = calcDist(t);

    int mx=0;
    rep(i,n){
        if(distS[i]<distT[i]){
            //行ける場所
            mx = max(mx,distT[i]);
        }
    }
    int ans = mx -1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10744
#include<stdio.h>
int main() {
   int i, j, num, temp, arr[256],k;
   scanf("%d", &num);
   for (i = 0; i < num; i++) {
      scanf("%d", &arr[i]);
   }
	for(i=0;i<num;i++){
	if(i==num-1)printf("%d",arr[i]);
	else
	printf("%d ",arr[i]);
	}
	putchar('\n');
   for (i = 1; i < num; i++) {
      temp = arr[i];
      j = i - 1;
      while ((temp < arr[j]) && (j >= 0)) {
        arr[j + 1] = arr[j];
        j = j - 1;
      }
   
      arr[j + 1] = temp;
   
   	for (k = 0; k < num; k++) {
	if(k==num-1)printf("%d",arr[k]);
	else
        printf("%d ", arr[k]);
   }
	putchar('\n');
}
   return 0;
}

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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

ll a[100001][3]={0};
ll dp[100001][3]={0};

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
        
	ll n;
	cin>>n;

	for(ll i=1;i<=n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}

	dp[1][0]=a[1][0];
	dp[1][1]=a[1][1];
	dp[1][2]=a[1][2];
	for(ll i=2;i<=n;i++){
		for(ll j=0;j<3;j++){
			for(ll k=0;k<3;k++){
				if(j!=k){
					dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
				}
			}
		}
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;




	return 0;
}

Measured memory_bytes: 4992
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    int t=1;
    // cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        int n=si(s);
        int c=0;
        f(i,0,n)
        {
          if(s[i]!=t[i])
          c++;
        }
        cout<<c;
    }    
} 

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
const int N=100005,mod=1e9+7;
int dp[2][N],sum[2][N],a[N],n,k;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int j=0;j<=k;j++)
		sum[0][j]=1;
	for(int i=1;i<=n;i++)
	{
		int p=i&1;
		for(int j=0;j<=k;j++)
			dp[p][j]=(sum[p^1][j]-(j>a[i]?sum[p^1][j-a[i]-1]:0)+mod)%mod;
		for(int j=0;j<=k;j++)
			sum[p][j]=((j?sum[p][j-1]:0)+dp[p][j])%mod;
	}
	printf("%d\n",dp[n&1][k]);
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	static int cnt;
	void dfs(int n,int s,int num){
		if(n == 0){
			if(s == 0)cnt++;
		}else if(s >= 0){
			for(int i = num;i <= 9;i++){
				dfs(n-1,s-i,i+1);
			}
		}
	}
	void doIt() {
		while(true){
			int n = sc.nextInt();
			int s = sc.nextInt();
			if(n + s == 0)break;
			cnt = 0;
			dfs(n,s,0);
			System.out.println(cnt);
		}
	}
    public static void main(String[] args) {
    	new Main().doIt();
    }
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
int n;
  cin>>n;
  n=n%10;
  if ( n==2||n==5||n==4||n==7||n==9)
    cout<<"hon\n";
    else
     if ( n==0||n==1||n==6||n==8)
       cout<<"pon\n";
      else
        cout<<"bon\n";
}

Measured memory_bytes: 3648
package main
 
import (
  "os"
  "fmt"
  "bufio"
  "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
  sc.Scan()
  i, err := strconv.Atoi(sc.Text())
  if err != nil {
    panic(err)
  }
  return i
}

func main() {
  sc.Split(bufio.ScanWords)
  
  a := nextInt()
  b := nextInt()
  c := nextInt()
  d := nextInt()
  max := a * c
  if b * d > max {
    max = b * d
  }
  if a * d > max {
  	max = a * d
  }
  if b * c > max {
    max = b * c
  }
  fmt.Println(max)
}

Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
const int N=1e4+5;
int n,a[N],sum[N];
bool vis[N];
int pow(int a,int n)
{
    if(n>=9) return 1e9;
    int ans=1;
    for(int i=1;i<=n;i++) ans=ans*10;
    return ans;
}
bool check(int p)
{
    int t=20;
    while(t--)
    {
        int f=rand()*rand()%1000000000+1;
        ll ans=0;
        for(int i=n;i>=0;i--)
            ans=(ans*f+a[i])%p;
        if(ans) return false;
    }
    return true;
}
vector<int>v;
int main()
{
    scanf("%d",&n);
    int k=0;
    for(int i=n;i>=0;i--)
    {
        scanf("%d",&a[i]);
        k=__gcd(k,a[i]);
    }
    k=abs(k);
    for(int j=2;j*j<=k;j++)
        if(k%j==0)
    {
        v.push_back(j);
        while(k%j==0) k/=j;
    }
    if(k>1) v.push_back(k);
    for(int i=2;i<=n;i++)
        if(!vis[i])
    {
        if(check(i)) v.push_back(i);
        for(int j=i+i;j<=n;j+=i)
            vis[j]=true;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
        if(i==v.size()-1||v[i]!=v[i+1])
    {
        printf("%d\n",v[i]);
    }
}


Measured memory_bytes: 384
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,m = readInts()
mod = 10**9+7
if abs(n-m)>1:
	print(0)
else:
	ans = 1
	for i in range(1,n+1,):
		ans = (ans*(i%mod))%mod
	for i in range(1,m+1):
		ans = (ans*(i%mod))%mod
	if abs(n-m)==0:
		ans = (ans*2)%mod
	print(ans)

Measured memory_bytes: 67160
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

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

int main () {
    int W, H;
    while (cin >> H >> W, W + H) {
        vector<vector<char> > map(W + 2, vector<char>(H + 2, '#'));
        int sx, sy;
        REP (i, 1, W + 1) {
            REP (j, 1, H + 1) {
                cin >> map[i][j];
                if (map[i][j] == '@') {
                    sx = j;
                    sy = i;
                }
            }
        }
        queue<pii> q;
        q.push(make_pair(sx, sy));
        int dx[4] = {0, 1, 0, -1};
        int dy[4] = {1, 0, -1, 0};
        vector<vector<bool> > check(W + 2, vector<bool>(H + 2, false));
        while (q.size()) {
            pii qq = q.front();
            q.pop();
            if (check[qq.second][qq.first]) continue;
            check[qq.second][qq.first] = true;
            REP (k, 0, 4) {
                int xx = qq.first + dx[k];
                int yy = qq.second + dy[k];
                if (map[yy][xx] == '#') continue;
                q.push(make_pair(xx, yy));
            }
        }
        int ans = 0;
        REP (i, 1, W + 1) REP (j, 1, H + 1) ans += check[i][j];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3080
#include <iostream> // cout, endl, cin
#include <string>
using namespace std;

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

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<cstdio>
using namespace std;
int main(){
char a;
while(1){
	scanf("%c",&a);
	if(isalpha(a)){
		if(islower(a)) printf("%c",toupper(a));
		else printf("%c",tolower(a));
	}
	else printf("%c",a);
if(a=='\n')break;
}
return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a == b && b == c) ? "Yes" : "No") << endl;
  return 0;
}

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


int main() {
	int X, Y, Z;
	int K;
	cin >> X >> Y >> Z;
	cin >> K;
	vector<long long> A(X), B(Y), C(Z);

	for (int i = 0; i < X; i++) cin >> A[i];
	for (int i = 0; i < Y; i++) cin >> B[i];
	for (int i = 0; i < Z; i++) cin >> C[i];

	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	sort(B.begin(), B.end());
	reverse(B.begin(), B.end());
	sort(C.begin(), C.end());
	reverse(C.begin(), C.end());

	vector<long long> ABC;
	for (int a = 0; a < X; a++)
	{
		for (int b = 0; b < Y; b++)
		{
			if ((a + 1) * (b + 1) > K) break;

			for (int c = 0; c < Z; c++)
			{
				if ((a + 1) * (b + 1) * (c + 1) > K) break;

				ABC.push_back(A[a] + B[b] + C[c]);
			}
		}
	}


	sort(ABC.begin(), ABC.end());
	reverse(ABC.begin(), ABC.end());

	for (int i = 0; i < K; i++)
	{
		cout << ABC[i] << endl;
	}

}

Measured memory_bytes: 1404
import java.util.Arrays;
import java.util.Scanner;

//Railway Ticket
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int x = 4*sc.nextInt()+2*sc.nextInt()+sc.nextInt();
		System.out.println(x==6||x==1?"Open":"Close");
	}
	
	void debug(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main() {
  int k,x;
  cin >> k >> x;
  for(int i = k-1; i > 0; i--){
    cout << x-i << " ";
  }
  cout << x << " ";
  for(int i = 1; i < k; i++){
    if(i==k-1) cout << x+i;
    else cout << x+i << " ";
  }
}

Measured memory_bytes: 256
import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
 
N = int(input())
WSV = list(tuple(map(int, input().split())) for _ in range(N))
WSV.sort(key=lambda x: x[0] + x[1])
 
 
U = 2 * 10 ** 4 + 100
dp = np.zeros(U, dtype=np.int64)
for w, s, v in WSV:
    dp[w:w+s+1] = np.maximum(dp[w:w+s+1], dp[:s+1] + v)
 
print(dp.max())

Measured memory_bytes: 27640
import Foundation

let input:Int = Int(readLine()!)!

func add(num: Int) -> Int {
  (num + 1) * (num) / 2
}
let number = add(num:input) + 15 * add(num: input / 15) - 3 * add(num: input / 3) - 5 * add(num: input / 5)
print( number )


Measured memory_bytes: 13188
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int M1,D1,M2,D2;
    cin>>M1>>D1;
    cin>>M2>>D2;

    if(M1!=M2){
        cout << 1<<endl;
    }else{
        cout <<0<<endl;
    }

    return 0;

}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.conv;
import std.numeric;
import std.math;
import std.string;

void main()
{
	auto tokens = split(chomp(readln()));
	auto N = to!ulong(tokens[0]);
	auto M = to!ulong(tokens[1]);
	string S = chomp(readln());
	string T = chomp(readln());

	ulong lcm = (N * M) / gcd(N, M);
	if (S[0] != T[0]) writeln("-1");
	else
	{
		uint nr = cast(uint)(lcm / N);
		uint mr = cast(uint)(lcm / M);
		bool flag = true;
		foreach (i; 1..cast(uint)N)
		{
			uint p1= i * nr;
			if (p1 % mr != 0) continue;
			//foreach (j; 1..M)
			{
				uint j = p1 / mr;
				//uint p2 = j * mr;
				//if (p1 == p2)
				{
					if (S[i] != T[j])
					{
						flag = false;
						break;
					}
				}
			}
		}
		ulong r = nr > mr ? nr * N : mr * M;
		if (flag) writeln(r);
		else writeln("-1");
	}

	stdout.flush();
}

Measured memory_bytes: 508
def to_binary(i)
  # 左から下位桁だよ
  bins = []
  while i > 0
    bins.push(i % 2)
    i /= 2
  end
  bins
end
def to_digit(bins)
  result = 0
  bins.reverse.each do |binary|
    result = result * 2 + binary
  end
  result
end
def xor(a, b)
  bins = []
  [a.size, b.size].max.times do |i|
    bins[i] = ((a[i] || 0) + (b[i] || 0)) % 2
  end
  bins
end

a,b = gets.split.map(&:to_i)
xor_list = []

case a%4
when 0 then;;
when 1 then; xor_list.concat([a, a+1, a+2])
when 2 then; xor_list.concat([a, a+1])
when 3 then; xor_list.concat([a])
end

case b%4
when 0 then; xor_list.concat([b])
when 1 then; xor_list.concat([b, b-1])
when 2 then; xor_list.concat([b, b-1, b-2])
when 3 then;;
end

puts to_digit(xor_list.map{|i| to_binary(i) }.inject([]){|a,b| xor(a,b) })


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main() {
    int N = 0;
    int u, k, v;
    int G[101][101] = {};
    scanf("%d", &N);
    
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &u, &k);

        for (int j = 0; j < k; j++) {
            scanf("%d", &v);
            G[u][v] = 1;
        }
    }
    
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (j != 1) cout << " ";
            cout << G[i][j];
        }
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3280
N = int(input())

list = [i+1 for i in range(N)]

num = 0
if N % 2 == 1:
    n = N // 2
    for i in range(n):
        num += 2*2*(i)
    num += N - 1
    print(num)
    for l in list[:-1]:
        print(N, l)
    list.pop(-1)
else:
    n = N // 2
    for i in range(n):
        num += 2*2*(i)
    print(num)

while(1):
    if len(list) == 2:
        break
    for l in list[1:-1]:
        print(list[-1], l)
        print(list[0], l)
    list.pop(0)
    list.pop(-1)

Measured memory_bytes: 3620
import java.io.*;
class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int x = Integer.parseInt(br.readLine().trim());
    if(x >= 30)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 32580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int> x(m);
	rep(i,m){
		cin>>x[i];
	}
	int cnt=m-n;
	if(cnt<=0){
		cout<<0<<endl;
		return 0;
	}
	sort(begin(x),end(x));
	vector<int> y;
	rep(i,m-1){
		y.push_back(x[i+1]-x[i]);
	}
	sort(begin(y),end(y));
	int ans=0;
	rep(i,cnt) ans+=y[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <list>
#include <cmath>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <functional>
#include <cassert>
using namespace std;

#define tmax(a, b) if (b > a) a = b
#define tmin(a, b) if (b < a) a = b
#define lson(a) a << 1
#define rson(a) (a << 1) | 1
#define par(a) a >> 1
char inc() { char _[10]; scanf("%s", _); return _[0]; }
int ini() { int _; scanf("%d", &_); return _; }
long long inll() { long long _; scanf("%I64d", &_); return _; }
double ind() { double _; scanf("%lf", &_); return _; }
string ins() { string _; cin >> _; return _; }
int inl(char _[]) { if (!fgets(_, (int)1e8, stdin)) return -1; int i = strlen(_); if (_[i - 1] == '\n') _[--i] = 0; return i; }

typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef long long LL;
const int inf = 0x3f3f3f3f;
const LL lnf = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.14159265358979323846;
const double eps = 1e-8;
const int mod = 100007;
const int maxn = 1e4 + 10;


int main() {
	int CAS = 0;
	//std::ios::sync_with_stdio(0);
	//std::cin.tie(0);
#ifdef NIGHT_13
	//freopen("myout.txt", "w", stdout);
	freopen("in.txt", "r", stdin);
	int time_night_13 = clock();
#endif // NIGHT_13

	string a, b, c;
	while (cin >> a >> b >> c) {
		puts(a.back() == b.front() && b.back() == c.front() ? "YES" : "NO");
	}

#ifdef NIGHT_13
	fprintf(stderr, "\nTime: %dms\n", (int)clock() - time_night_13);
#endif // NIGHT_13
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

typedef pair <int,int> pi;
typedef pair <int,pi> pii;

struct point{
    point(int x, int y, int ind){
        this->x=x;
        this->y=y;
        this->ind=ind;
    }
    int x,y;
    int ind;
};

int getdist(int i,int j, vector <pi> &a){
    return min(abs(a[i].fi-a[j].fi),abs(a[i].se-a[j].se));
}

int par[100005],Size[100005];

int root(int i)
{
    while (par[i] != i)
    {
        par[i] = par[par[i]];
        i = par[i];
    }
    return i;
}

void wunion(int A, int B)
{
    int root_A = root(A);
    int root_B = root(B);
    if (Size[root_A] < Size[root_B])
    {
        par[root_A] = par[root_B];
        Size[root_B] += Size[root_A];
    }
    else
    {
        par[root_B] = par[root_A];
        Size[root_A] += Size[root_B];
    }

}

bool Find(int A, int B)
{
    if (root(A) == root(B))       //if A and B have same root,means they are connected.
        return true;
    else
        return false;
}

int main(){
    int n;
    cin >> n;
    vector <pi> a(n);
    vector <point> st;
    for(int i=0;i<n;i++){
        cin >> a[i].fi >> a[i].se;
        st.emplace_back(a[i].fi,a[i].se,i);
    }
    sort(st.begin(),st.end(),[](const point &l,const point &r){
        return l.x<r.x;
    });
    set <pii> e;
    for(int i=1;i<n;i++){
        e.insert({getdist(st[i].ind,st[i-1].ind,a),{st[i].ind,st[i-1].ind}});
        e.insert({getdist(st[i].ind,st[i-1].ind,a),{st[i-1].ind,st[i].ind}});
    }
    sort(st.begin(),st.end(),[](const point &l,const point &r){
        return l.y<r.y;
    });
    for(int i=1;i<n;i++){
        e.insert({getdist(st[i].ind,st[i-1].ind,a),{st[i].ind,st[i-1].ind}});
        e.insert({getdist(st[i].ind,st[i-1].ind,a),{st[i-1].ind,st[i].ind}});
    }
    for(int i=0;i<n;i++){
        par[i]=i;
        Size[i]=1;
    }
    long long ans=0;
    for(auto x:e){
        int i=x.se.fi, j =x.se.se;
        if(!Find(i,j)){
            wunion(i,j);
            ans+=x.fi;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 28020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, char>P;
int main(){
    
    for(int n; cin >> n, n;){
        vector<char>v(n + 1);
        for(int i = 1; i <= n; i++)cin >> v[i];
        bool TIE = true;
        for(int i = 1; i <= n; i++){
            vector<P>vote(26, P(0, 'x'));
            for(int j = 0; j < 26; j++)vote[j].second = 'A' + j;
            for(int j = 1; j <= i; j++)vote[v[j] - 'A'].first++;
            sort(vote.begin(), vote.end(), greater<P>());
            if(vote[0].first > vote[1].first && vote[0].first > vote[1].first + n - i){
                TIE = false;
                cout << vote[0].second << " " << i << endl;
                break;
            }
        }
        if(TIE)cout << "TIE" << endl;
    }

    return 0;
}



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)

using namespace std;

#define IINF INT_MAX
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef VVI matrix;

#define MAX 810
double A[MAX][MAX],B[MAX][MAX];

int rnk(int n){
  int res = 0;
  //matrix B(n,VI(n+1,1));
  rep(i,n) rep(j,n+1) B[i][j] = 1;
 
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) B[i][j] = A[i][j];
   
  for(int i=0;i<n;i++){
    int pivot = i;
    for(int j=i;j<n;j++){
      if(abs(B[j][i]) > abs(B[pivot][i])) pivot = j;
    }
    swap(B[i],B[pivot]);
    if(abs(B[i][i]) > EPS) res++;
 
     
    if(abs(B[i][i]) > EPS){
      for(int j=i+1;j<=n;j++) B[i][j] /= B[i][i];
      for(int j=0;j<n;j++){
        if(i != j){
          for(int k=i+1;k<=n;k++) B[j][k] -= B[j][i] * B[i][k];
        }
      }
    }
  }
  return res;
}



int main() {
  srand((unsigned int)time(NULL));
  int N,a,b,c,d,e,n,cnt=0;
  cin >> N >> a >> b;
  vector<int> s,t;
  rep(i,N) {
    cin >> c >> d;
    e = abs(c-d);
    if( e <= a || ( b <= e && e <= 2 * a ) ) ++cnt;
    else s.push_back(c), t.push_back(d);
  }
  n = (int)s.size();
  rep(i,n) {
    REP(j,i+1,n) {
      e = abs( ( s[i] + s[j] ) - ( t[i] + t[j] ) );
      if( e <= a || ( b <= e && e <= 2 * a ) ) {
	A[i][j] = rand() % 1000000;
	A[j][i] = -A[i][j];
      }
    }
  }
  cout << cnt + (int)(rnk(n)/2) << endl;
  return 0;
}



Measured memory_bytes: 12616
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  xs <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  ys <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  zs <- U.unfoldrN (n-1) (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let y = U.sum ys
  let z = U.sum $ U.zipWith (\i j -> if j == i + 1 then zs U.! (i-1) else 0) xs (U.tail xs)
  print $ y + z


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    vector<int> t(N); // r => 0, s => 1, p => 2 と変換する
    rep(i, N) {
        if (T[i] == 'r') t[i] = 0;
        if (T[i] == 's') t[i] = 1;
        if (T[i] == 'p') t[i] = 2;
    }

    map<char, int> mp; // じゃんけんに勝った時に得るスコアのマップ
    mp['r'] = P;
    mp['s'] = R;
    mp['p'] = S;

    vector<vector<int>> dp(N + K, vector<int>(3));
    rep(l, K) {
        for (int i = l; i < N; i += K) {
            int ni = i + K;
            rep(j, 3) { // じゃんけんの3パターンを試す
                // このじゃんけんでjを出す場合,直前の手はj以外
                chmax(dp[ni][j], dp[i][(j + 1) % 3]);
                chmax(dp[ni][j], dp[i][(j + 2) % 3]);

                if (t[i] == j) { // じゃんけんに勝った場合
                    chmax(dp[ni][j], dp[i][(j + 1) % 3] + mp[T[i]]);
                    chmax(dp[ni][j], dp[i][(j + 2) % 3] + mp[T[i]]);
                }
            }
        }
    }

    int ans = 0;
    rep(l, K) ans += max(dp[N + K - 1 - l][0], max(dp[N + K - 1 - l][1], dp[N + K - 1 - l][2]));
    cout << ans << endl;
}

Measured memory_bytes: 11008
A=input()
B=input()
C=input()

card={"a":A,"b":B,"c":C}
answer={"a":"A","b":"B","c":"C"}
turn="a"

while True:
    if len(card[turn])==0:
        break
    next_turn=card[turn][0]
    card[turn]=card[turn][1:]
    turn=next_turn

print(answer[turn])

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a == b){
			System.out.println(c);
		}else if(a == c){
			System.out.println(b);
		}else{
			System.out.println(a);
		}
	}
}


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

int main()
{
    int N,ans=0,a,b,maxA=0;

    cin>>N;

    for(int i=1;i<=N;i++){
        cin>>a>>b;

        if(a>maxA){
            ans=a+b;
            maxA=a;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<pair<int,int> > X(N);
  for (int i = 0; i < N; i++){
    int a;
    cin >> a;
    X.at(i) = make_pair(a, i);
  }
  sort(X.begin(), X.end());
  int median1 = X.at(N/2).first;
  int median2 = X.at(N/2-1).first;
  vector<int> ans(N);
  for (int i = 0; i < N; i++){
    if (i < N/2){
      ans.at(X.at(i).second) = median1;
    } else {
      ans.at(X.at(i).second) = median2;
    }
  }
  for (int i = 0; i < N; i++){
    cout << ans.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;

///////////////////////////
////Prime Creator//////////
///////////////////////////
//bool Prime[100001] = {};
//void createPrime() {
//	ll n = 100001;
//	rep(i, 0, n) Prime[i] = true;
//	Prime[0] = false;
//	Prime[1] = false;
//	rep(i, 2, n) {
//		if (Prime[i]) {
//			rep(j, 2, n) {
//				if (j*i >= n)break;
//				Prime[j*i] = false;
//			}
//		}
//	}
//}
///////////////////////////
///////////////////////////

//Minimum Value
static const ll MIN_LL = (ll)1 << 55;

////Warshall Floyid
////All value should be initialized by MIN_LL
//static const ll wf_size = 300;
//ll wf[wf_size][wf_size];
//void WarshalFloyid() {
//	rep(k, 0, wf_size)rep(i, 0, wf_size)rep(j, 0, wf_size)wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
//}

ll N, A, B;
ll C;
ll h[100001] = {};
ll k[100001] = {};
bool t(ll n) {
	ll cnt = 0;
	rep(i, 0, N) {
		ll p = h[i];
		p -= B * n;
		if (p > 0) {
			cnt += p / C + (p % C != 0 ? 1 : 0);
		}
	}
	return cnt <= n;
}

int main() {
	cin >> N >> A >> B;
	C = A - B;
	rep(i, 0, N)cin >> h[i];

	ll lb = 0, ub =  (ll)1 << 31;//1000000001;//
	ll m = 0;

	rep(i, 0, 1000) {
		m = (lb + ub) / 2;
		if (t(m)) {
			//success
			ub = m;
		}
		else {
			//fail
			lb = m;
		}
	}

	cout << ub << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
using namespace std;
int main(){
  string s;
  cin >> s;
  string str1,str2;
  int ans = 0;
  int len = s.length();
  if(len%2==0){
  str1 = s.substr(0,len/2);
  str2 = s.substr(len/2);
  reverse(str2.begin(), str2.end());
    rep(i,len/2){
      if(str1[i]!=str2[i]){
        ans++;
      }
    }
  }else{
    str1 = s.substr(0,(len-1)/2);
    str2 = s.substr((len+1)/2);
    reverse(str2.begin(), str2.end());
    rep(i,(len-1)/2){
      if(str1[i]!=str2[i]){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int n,m,p,head[5005],rhead[5005],size,rsize,times[5005],dp[5005];
bool ok[5005],vis[5005];
struct node{
	int start;
	int to;
	int w;
	int next;
}mem[5005],rmem[5005];
void addedge(int x,int y,int w)
{
	size++;
	mem[size].start=x;
	mem[size].to=y;
	mem[size].w=w;
	mem[size].next=head[x];
	head[x]=size;
} 
void addedge_reverse(int x,int y,int w)
{
	rsize++;
	rmem[rsize].start=x;
	rmem[rsize].to=y;
	rmem[rsize].w=w;
	rmem[rsize].next=rhead[x];
	rhead[x]=rsize;
}
void prebfs()
{
	queue<int> q;
	ok[n]=1;
	q.push(n);
	while(!q.empty())
	{
		int now = q.front();
		q.pop();
		for(int e = rhead[now];e!=-1;e = rmem[e].next)
		{
			int v = rmem[e].to;
			if(!ok[v])
			{
				ok[v]=1;
				q.push(v);
			}
		}
	}
}
bool spfa()
{
	memset(dp,-0x7f7f7f7f,sizeof(dp));
	queue<int> q;
	vis[1]=1;
	times[1]=1;
	dp[1]=0;
	q.push(1);
	while(!q.empty())
	{
		int now = q.front();
		q.pop();
		vis[now]=0;
		for(int e=head[now];e!=-1;e=mem[e].next)
		{
			int v = mem[e].to;
			if(ok[v]&&dp[v]<dp[now]+mem[e].w)
			{
				dp[v]=dp[now]+mem[e].w;
				if(!vis[v])
				{
					vis[v]=1;
					times[v]++;
					q.push(v);
					if(times[v]>n) return false;
				}
			}
		}
	}
	return true;
}
int main()
{
	memset(head,-1,sizeof(head));
	memset(rhead,-1,sizeof(rhead));
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1;i<=m;i++)
	{
		int aa,bb,cc;
		scanf("%d%d%d",&aa,&bb,&cc);
		addedge(aa,bb,cc-p);
		addedge_reverse(bb,aa,cc-p);
	}
	prebfs();
	if(spfa()==false)cout<<"-1";
	else cout<<max(dp[n],0)<<endl;
	return 0;
}

Measured memory_bytes: 512
n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))
ans = 0
sum = 0
for i, v in enumerate(l):
  sum += v

  if i == (n-1) and sum < x:
    break

  if sum <= x:
    ans += 1
  else:
    break
    
print(ans)


Measured memory_bytes: 2940
#include <iostream>

int main() {
    int N;
    long int ans = 0;
    std::cin >> N;

    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(i * j < N) {
                ans++;
            }
            else {
                break;
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3632
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int a[3];

int main(){
  REP(i,3)
    cin>>a[i];

  if(a[2] >= a[0] && a[2] <= a[1]){
    cout<<"Yes\n";
  } else {
    cout<<"No\n";
  }
    

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod = 1000000007;
const int N = 100010;
 
int main() 
{
   // freopen("in.txt", "r", stdin);
    int n;

    while (~scanf("%d", &n))
    {
        set<int>S;
        for (int i = 0; i < n; i++)
        {
            int x;
            scanf("%d", &x);
            if (S.find(x) == S.end())
                S.insert(x);
            else
                S.erase(x);

        }
        printf("%d\n", S.size());
    }
   
    return 0;
}


Measured memory_bytes: 4864
MAX_N = 10 ** 5 + 10
N = int(input())
dp = [[0] * 3 for _ in range(MAX_N)]

arr = [0] * MAX_N
for i in range(N):
    arr[i] = list(map(int, input().split()))
for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + arr[i][k])
print(max(dp[N]))

Measured memory_bytes: 68716
#include<bits/stdc++.h>
using namespace  std ;
typedef long long  ll;
typedef pair<ll, ll> Pll;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define rad(X) cout << (X) << endl
#define ASH(X) cout << (X) << " "
#define debug(x) cout << #x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define FOR(I,A,B) for(ll I = (A); I <= (B); I++)
#define cir(I,B,A) for(ll I = (A); I >=(B); I--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define SORT(c) (sort(c.begin(),c.end()))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASES int ___T; cin >> ___T; for(int cs=1;cs<=___T;cs++)
#define FAST()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll fx[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll fy[] = {0, 1, 1, 1, 0, -1, -1, -1};
vector<ll>a,b,c;
map<ll,ll>m1,m2,m3;

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

void Execute()
{
      ll N,NB,VAL,A,B,C,G,INC,DEC,L,R,D;
      cin >> N >>G;

      //14 3
      //1 2 3 4 5 6 7 8 9 10 11 12 13 14
      //atcoder

      ll atcoder = 0;
      ll ans=2*G;
      while(1)
      {
        if(N<1) break;
        N-=ans;
        N-=1;
        atcoder++;


      }

      cout<<atcoder<<endl;





}

int32_t main()
{
    //freopen("atomm.txt", "r", stdin);
    FAST();
    //CASES

        Execute();

}


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

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;
static const ll MOD = 1000000007;


int main() {
    int n;

    cin >> n;

    vector<int> a(n + 1);
    rep(i, n)cin >> a[i + 1];
    vector<int> b(n + 1);
    for (int i = n; i >= 1; --i) {
        int sum = 0;
        for (int j = i + i; j <= n; j += i) {
            sum ^= b[j];
        }
        b[i] = sum ^ a[i];
    }
    vector<int> ans;

    for (int i = 1; i <= n; i++) {
        if (b[i])ans.push_back(i);
    }

    cout << ans.size() << endl;
    rep(i, ans.size()) {
        printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' ');
    }

}



Measured memory_bytes: 3064
import math
n, m = [int(item) for item in input().split()]

ans = 0
for i in range(1, int(math.sqrt(m))+1):
  if m%i == 0:
    if m >= i*n:
      ans = max(ans, i)
    if i>= n:
      ans = max(ans, m//i)
    
print(ans)

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

int main() {
    int n, k;
    cin >> n >> k;
    int H[n];
    for(int i = 0; i < n; i++){
        cin >> H[i];
    }
   sort(H, H+n);
    long long int min = 1000000000000;
    for(int i = 0; i < n-k+1; i++){
        if(H[i+k-1] - H[i] < min){
            min = H[i+k-1] - H[i];
        }
    }
    cout << min << endl;
    return 0;
}




Measured memory_bytes: 640
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
input = sys.stdin.readline

N, K = [int(ele) for ele in input().split()]
ab = [0]*N
for i in range(N):
    ab[i] = [int(ele) for ele in input().split()]


def main():
    ab.sort()  # pythonのsortは１つ目の要素に関する安定ソート
    ans = 0
    k = 0
    for ele in ab:
        k += ele[1]
        if k < K:
            continue
        elif K <= k:
            ans = ele[0]
            break

    print(ans)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
    return divisors


class Node():

    def __init__(self):
        self.idx = None
        self.left = None
        self.right = None
        self.parent = None
        return

    def pre_order(self):
        global pre_order_str
        pre_order_str += str(self.idx) + " "
        if self.left:
            self.left.pre_order()

        if self.right:
            self.right.pre_order()

    def in_order(self):
        global in_order_str

        if self.left:
            self.left.in_order()

        in_order_str += str(self.idx) + " "

        if self.right:
            self.right.in_order()

    def post_order(self):
        global post_order_str
        if self.left:
            self.left.post_order()

        if self.right:
            self.right.post_order()

        post_order_str += str(self.idx) + " "


class HeapHelper():
    """HeapContrler.
    完全二分木を二分ヒープで表現した配列 A に対して、
    HeapHelper.parent(idx) とするとそのノードの親の添字を返す
    存在しない場合は Falseを返す

    Returns:
        [type] -- [description]
    """

    def __init__(self):
        return

    @staticmethod
    def parent(i):
        if i == 1:
            return False

        return int(i/2)

    @staticmethod
    def left(i):
        l_idx = 2*i
        if H < l_idx:
            return False

        return l_idx

    @staticmethod
    def right(i):
        r_idx = 2*i + 1
        if H < r_idx:
            return False

        return r_idx


if __name__ == "__main__":
    main()


Measured memory_bytes: 21640