akhauriyash/Code-Regression huggingface dataset:
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s;
  ans = 9 * (Size(s) - 1);
  ans += s[0] - '0';
  ans--;
  rep(i, Size(s)) cnt += s[i] - '0';
  ans = max(ans, cnt);
  Cout(ans);
  return 0;
}

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

int main() {
	long long n,k;
	cin >> n >> k;
	long long a[n+1];
	for(long long i=1;i<=n;i++){
		cin >> a[i];
	}
	vector<long long>b(1e6,0);
	b[0]=1;
	map<long long,long long>mp;
	mp[1]++;
	long long c=1,memo;
	while(1){
		b[c]=a[b[c-1]];
		mp[b[c]]++;
		if(mp[b[c]]==2){
			memo=c;
			break;
		}
		c++;
	}
	if(memo>=k) cout << b[k] << endl;
	else{
		long long d;
		for(long long i=0;i<memo;i++){
			if(b[i]==b[memo]){
				d=i;
				break;
			}
		}
		cout << b[(k-d)%(memo-d)+d] << endl;
	}
}


Measured memory_bytes: 24748
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

private val KEYENCE = "keyence"

fun main(args: Array<String>) {
    val S = readLine()!!

    for (i in 0 until KEYENCE.length) {
        val raw = "${KEYENCE.dropLast(i + 1)}.*${KEYENCE.drop(KEYENCE.length - i - 1)}"

        if (Regex(raw).matches(S)) {
            println("YES")
            return
        }
    }

    if (Regex("${KEYENCE}.*").matches(S)) {
        println("YES")
        return
    }

    println("NO")
}

Measured memory_bytes: 33676
package main

import (
	"fmt"
)

func main() {
	var argA, argB int
	_, err := fmt.Scan(&argA, &argB)

	if err != nil {
		panic(err)
	}

	if (argA*argB)%2 == 0 {
		fmt.Println("Even")
	} else {
		fmt.Println("Odd")
	}
}


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

int main() {
  int n;
  string s;
  int ac=0, wa=0, tle=0, re=0;
  cin >> n;
  for(int i=0;i<n;i++) {
     cin >> s;
     if(s == "AC") {
       ac++; 
     }
     if(s == "WA") {
       wa++; 
     }
     if(s == "TLE") {
       tle++; 
     }
     if(s == "RE") {
       re++; 
     }
  }
     cout << "AC x " << ac << endl;
     cout << "WA x " << wa << endl;
     cout << "TLE x " << tle << endl;
     cout << "RE x " << re << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
int a, y;
scanf("%d %d", &a, &y);
    if(a==2||y==2){
        printf("No\n");
    }
    else if((a==1||a==3||a==5||a==7||a==8||a==10||a==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))
    {
        printf("Yes\n");
    }
    else if((a==4||a==6||a==9||a==11)&&(y==4||y==6||y==9||y==11))
    {
        printf("Yes");
    }
    else{
        printf("No");
    }
return 0;
}

Measured memory_bytes: 1612
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll tim;

template<typename T,const T id>
struct ConvexHullTrick{
    struct Line{
        T a,b;
        Line(T a=0,T b=0):a(a),b(b){}
        T get(T x){return max(tim+x-b+a,3*(x-b)+a);}
    };

    struct Node{
        Line l;
        Node *lhs,*rhs;
        Node(Line l):l(l),lhs(nullptr),rhs(nullptr){}
    };

    const int n;
    const vector<T> pos;
    Node* root;

    ConvexHullTrick(const vector<T> &pos):n(pos.size()),pos(pos),root(nullptr){}
    Node* insert(Node* p,int lb,int ub,Line& l){
        if(!p)return new Node(l);
        if(p->l.get(pos[lb])<=l.get(pos[lb])&&p->l.get(pos[ub])<=l.get(pos[ub]))return p;
        if(p->l.get(pos[lb])>=l.get(pos[lb])&&p->l.get(pos[ub])>=l.get(pos[ub])){
            p->l = l;
            return p;
        }
        int mid=(lb+ub)/2;
        if(p->l.get(pos[mid])>l.get(pos[mid]))swap(p->l , l);
        if(p->l.get(pos[lb])>=l.get(pos[lb])){
            p->lhs=insert(p->lhs,lb,mid,l);
        }
        else {
            p->rhs=insert(p->rhs,mid+1,ub,l);
        }
        return p;

    }
    void insert(T a,T b){
        Line l(a,b);
        root=insert(root,0,n-1,l);
    }
    T get(Node* p,int lb,int ub,int t){
        if(!p)return id;
        if(lb==ub)return p->l.get(pos[t]);
        int mid=(lb+ub)/2;
        if(t<=mid)return min(p->l.get(pos[t]),get(p->lhs,lb,mid,t));
        else return min(p->l.get(pos[t]),get(p->rhs,mid+1,ub,t));
    }

    T get(T x){
        int t=lower_bound(pos.begin(),pos.end(),x)-pos.begin();
        return get(root,0,n-1,t);
    }
};
int main(){
   int n;cin>>n;ll e;
    cin>>e>>tim;
    vector<ll> a(n+2);
    rep(i,n)cin>>a[i+1];
    a[n+1]=e;
    ConvexHullTrick<ll,longinf> cht(a);
    cht.insert(a[1],a[1]);
    rep(i,n){
        ll x=cht.get(a[i+1]);
        cht.insert(x+a[i+2]-a[i+1] ,a[i+2]);
    }
    cout<<cht.get(a[n])+a[n+1]-a[n]<<endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
ll inf=1e9;
int main(){
	int n,k;cin>>n>>k;
	atcoder::mcf_graph<ll,ll> g(n*2+2);
	int s=n*2,t=s+1;
	g.add_edge(s,t,n*k,inf);
	rep(i,n){
		g.add_edge(s,i,k,0);
		g.add_edge(i+n,t,k,0);
		rep(j,n){
			ll a;cin>>a;
			g.add_edge(i,j+n,1,inf-a);
		}
	}
	auto[_,cost]=g.flow(s,t,n*k);
	vector grid(n,string(n,'.'));
	for(auto e:g.edges()){
		if(e.from!=s&&e.to!=t&&e.flow>0){
			grid[e.from][e.to-n]='X';
		}
	}
	cout<<k*n*inf-cost<<endl;
	for(auto s:grid)cout<<s<<endl;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//ll MOD=1000000007;
ll INF=300000000000;
int main(){
    ll N, M, L;
    cin>>N>>M>>L;
    vector<ll> A(M), B(M), C(M);
    for(ll i=0; i<M; i++){
      	ll a, b, c;
      	cin>>a>>b>>c;
        a--; b--;
      	A[i]=a;
      	B[i]=b;
      	C[i]=c;
    }
    ll Dist[N][N];
  	for(int i=0; i<N; i++){
    	for(int j=0; j<N; j++){
          	Dist[i][j]=INF;
        }
    }
    for(int i=0; i<N; i++){
        Dist[i][i]=0;
    }
    for(int i=0; i<M; i++){
        Dist[A[i]][B[i]]=C[i];
        Dist[B[i]][A[i]]=C[i];
    }
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                Dist[i][j]=min(Dist[i][j],Dist[i][k]+Dist[k][j]);
            }
        }
    }
    ll Way[N][N];
  	for(int i=0; i<N; i++){
    	for(int j=0; j<N; j++){
          	Way[i][j]=301;
        }
    }
    for(int i=0; i<N; i++){
        Way[i][i]=0;
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(i!=j){
                if(Dist[i][j]<=L){
                    Way[i][j]=1;
                }
            }
        }
    }

    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                Way[i][j]=min(Way[i][j],Way[i][k]+Way[k][j]);
            }
        }
    }
	int Q;
    cin>>Q;
    vector<ll> S(Q), T(Q);
    for(int i=0; i<Q; i++){
      	ll s, t;
      	cin>>s>>t;
      	s--; t--;//ここを変えた
        S[i]=s;
      	T[i]=t;
        if(Way[S[i]][T[i]]==301){
          cout<<-1<<endl;
        }
        else{
            cout<<Way[S[i]][T[i]]-1<<endl;
        }
    }
  	return 0;
}

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


int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> sVec(H, vector<char>(W));

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> sVec.at(i).at(j);
		}
	}

	vector<bool> row(H, false);
	vector<bool> col(W, false);
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (sVec.at(i).at(j) == '#')
			{
				row.at(i) = true;
				col.at(j) = true;
			}
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (row.at(i) && col.at(j))
			{
				cout << sVec.at(i).at(j);
			}
		}
		if (row.at(i))
		{
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int n,m;
  cin >> n >> m;
  vector<int> se;
  se.resize(m);
  REP(i,m) cin >> se[i];
  int answer=0;
  answer=max(answer,se[0]-1);
  REP(i,m-1) answer=max(answer,(se[i+1]-se[i])/2);
  answer=max(answer,n-se[m-1]);
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1308
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
  int hand[5];
  for(;;){
    if(scanf("%d,%d,%d,%d,%d",&hand[0],&hand[1],&hand[2],&hand[3],&hand[4]) == EOF){break;}
    sort(hand,hand+5);
    int p = 0;
    for(int i=0; i<5; i++){
      int x = 0;
      for(int j=i+1; j<5; j++){
	if(hand[i] == hand[j]){x++;}
      }
      if(x == 1){p+=1;}
      if(x == 2){p+=3;}
      if(x == 3){p+=5;}
      i+=x;
    }
    if(p == 0){
      if(hand[1] == hand[0]+1 && hand[2] == hand[1]+1 && hand[3] == hand[2]+1 && hand[4] == hand[3]+1){p = 6;}
      if(hand[0] == 1 && hand[1] == 10 && hand[2] == 11 && hand[3] == 12 && hand[4] == 13){p = 6;}
    }
    if(p == 0){cout <<"null"<<endl;}
    else if(p == 1){cout <<"one pair"<<endl;}
    else if(p == 2){cout <<"two pair"<<endl;}
    else if(p == 3){cout <<"three card"<<endl;}
    else if(p == 4){cout <<"full house"<<endl;}
    else if(p == 5){cout <<"four card"<<endl;}
    else if(p == 6){cout <<"straight"<<endl;}
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end(), greater<long long>());
  long long res = 0;
  for (int i = 0; i + 1 < N; ++i) {
    res += A[(i + 1) / 2];
  }
  cout << res << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll K;
vector<ll> A;
ll mo=1000000007;
map<vector<ll>,vector<pair<ll,ll>>> S;

ll cost(ll a,ll b) {
	ll ret=0;
	if(a==0) return 0;
	for(int i=60;i>=0;i--) {
		if((a&(1LL<<i))==(b&(1LL<<i))) {
			if(a&(1LL<<i)) ret |= 1LL<<i;
		}
		else {
			for(int j=0;j<i;j++) if(a&(1LL<<j)) ret |= 1LL<<i;
			break;
		}
	}
	return ret;
}

void hoge(int shift, ll mi) {
	ll left=K-shift-__builtin_popcountll(mi);
	if(left<0) return;
	int i;
	
	vector<ll> V;
	FOR(i,N) {
		if(A[i]-mi<0) return;
		if(i) V.push_back(((A[i]-mi)>>shift)-((A[i-1]-mi)>>shift));
		left=min(left,((A[i]-mi)>>shift));
	}
	/*
	cout<<"! "<<shift<<" "<<mi<<" : ";
	FORR(v,V) cout<<v<<" ";
	cout<<"  : "<<left<<endl;
	*/
	pair<ll,ll> p={((A[0]-mi)>>shift)-left,(A[0]-mi)>>shift};
	//cout<<p.first<<" "<<p.second<<endl;
	S[V].push_back(p);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	A.resize(N);
	FOR(i,N) cin>>A[i];
	
	FOR(i,61) {
		vector<ll> V;
		FOR(j,N) V.push_back(A[j]&((1LL<<i)-1));
		sort(ALL(V));
		V.erase(unique(ALL(V)),V.end());
		ll prev=0;
		FORR(c,V) {
			//cout<<i<<" "<<prev<<":"<<cost(prev,c)<<":"<<c<<"   "<<hoge(i,cost(prev,c))<<endl;
			hoge(i,cost(prev,c));
			prev=c+1;
		}
	}
	
	ll ret=0;
	FORR(m,S) {
		auto p=m.second;
		sort(ALL(p));
		FOR(i,p.size()) {
			int j=i+1;
			ll L=p[i].first,R=p[i].second;
			while(j<p.size() && p[j].first<=L) R=max(R,p[j++].second);
			(ret+=R-L+1)%=mo;
			i=j-1;
		}
		
	}
	
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 16384
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    auto ns = stdin.byLine().map!(to!int).array();
    immutable m = ns.reduce!max()*2;
    auto p = new bool[m];
    foreach(i;2..m) if(!p[i])
        for(int j=2; i*j<m; ++j) p[i*j]=true;
    int search(int n,int d)
    {
        for(int i=n+d; 0<=i && i<m; i+=d)
            if(!p[i]) return i;
        return -1;
    }
    ns.map!(n=>[search(n,-1),search(n,1)].map!(to!string).join(" ")).join("\n").writeln();
}

Measured memory_bytes: 1108
N,*ABf = map(int, open(0).read().split())
AB = [ABf[i:i+2] for i in range(0, len(ABf), 2)]
A = sorted([x[0] for x in AB])
B = sorted([x[1] for x in AB])
if N % 2 == 1:
    print(B[N//2]-A[N//2]+1)
else:
    print(int(((B[N//2-1]+B[N//2])*(0.5)-(A[N//2-1]+A[N//2])*(0.5))*2+1))

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

#define jaldi ios_base::sync_with_stdio(false)
#define fr(i,j,n) for(i=j;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%ld",&x)
#define sll(x) scanf("%lld",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%ld",x)
#define pll(x) printf("%lld",x)
#define pc(x) printf("%c",x)
#define ps(x) printf("%s",x)
#define vi vector<int> 
#define vl vector<long> 
#define vll vector<long long>
#define vc vector<char>  
#define vs vector<string>
#define vvi vector<vector<int>> 
#define vvll vector<vector<long long>> 
#define F first
#define S second
#define ll long long
#define pb push_back
#define ppii pair<int,int> 
#define ppll pair<long long,long long>
#define ppcc pair<char,char>
#define ppss pair<string,string> 
#define vpll vector<pair<long long,long long>>
#define PI 3.1415926535897932384626
#define precision(x) cout<<fixed<<setprecision(x) 
#define mod 998244353

int x_d[8] = {-1,1,0,0,-1,-1,1,1};
int y_d[8] = {0,0,-1,1,-1,1,-1,1};

ll power(ll b,ll e)
{
    if(b==0)
        return 0;
    
    ll r=1;
    while(e>0)
    {
        if(e%2)
            r=(r*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return r;
}

int main()
{
    jaldi;
    precision(20);
    
    double n;
    cin>>n;

    cout<<2*n*PI<<endl;

    return 0;
}

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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' ' << endl; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n >> m >> k;
  	if (n+m+k>21)
      dbg("bust");
  else
    dbg("win");
}


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

int cmpstr(const void * a, const void * b) {
    //const char *x = a, *y = b;
    return strcmp(a, b);
    //return 0;
}

int main() {
    int n, l;

    scanf("%d %d", &n, &l);

    char s[n][l+1];

    //printf("%p %p %p\n", s, s[0], s[n-1]);

    for(int i = 0; i < n; ++i)
        scanf("%s", s[i]);

    // ordenar as strings
    qsort(s, n, sizeof(s[0]), cmpstr);

    for(int i = 0; i < n; ++i)
        printf("%s", s[i]);
    printf("\n");










    return 0;
}


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

int main(){
	int n;
	scanf("%d", &n);
	int o = 0;
	f(i, 0, n){
		int t;
		scanf("%d", &t);
		if (t & 1)++o;
	}
	printf("%s\n", o & 1 ? "NO" : "YES");
}


Measured memory_bytes: 256
// 単一始点全点間最短路を求めるアルゴリズム
// 不平路を検出した時は、空列を返す
// O(VE)


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};


template<typename T>
vector<T> bellman_ford(vector<vector<pair<int, T>>> g, int s){

    int n = (int)g.size();
    // ここで怒られる場合は inf を自分で定義する
    const auto inf = numeric_limits<T>::max();
    vector<T> dist(n, inf);
    dist[s] = 0;
    for(int i = 0; i < n - 1; i++){
        for(int u = 0; u < n; u++){
            for(auto &e : g[u]){
                if(dist[u] == inf) continue;
                dist[e.first] = min(dist[e.first], dist[u] + e.second);
            }
        }
    }

    for(int u = 0; u < n; u++){
        for(auto &e : g[u]){
            if(dist[u] == inf) continue;
            if(dist[u] + e.second < dist[e.first]) return vector<T>();
        }
    }

    return dist;
}

signed main(){
    
    int n, m, r; cin >> n >> m >> r;
    vector<vector<pair<int, int>>> g(n);
    for(int i = 0; i < m; i++){
        int a, b, c; cin >> a >> b >> c;
        g[a].push_back({b, c});
    }

    auto dist = bellman_ford(g, r);
    if(dist.size() == 0) cout << "NEGATIVE CYCLE" << endl;
    else{
        for(int i = 0; i < n; i++){
            if(dist[i] == numeric_limits<int>::max()) cout << "INF" << endl;
            else cout << dist[i] << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3232
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std ;

#define PI 3.1415927

int main(){
	
	double n , angle , red = 90 ;
	double x=0 , y=0 ;
	
	while(1){
		scanf("%lf,%lf",&n ,&angle ) ;
		if( n==0 && angle==0 ) break ;
		
		x += n*cos(PI/180 * red) ;
		y += n*sin(PI/180 * red) ;
		
		red -= angle ;
	}
	
	int ans_x = x ;
	int ans_y = y ;
	
	printf("%d\n%d\n",ans_x ,ans_y) ;
	
return 0 ;
}

Measured memory_bytes: 1212
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
string s;
int main(){
	ios::sync_with_stdio(false);
	cin>>s;
	if (s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A, B;
  cin >> A >> B;
  for(int i=1; i<=3; i++){
	if (A!=i && B!=i){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
    int h1, m1, h2, m2, k;
    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
    int h = (h2-h1)*60;
    int m = m2-m1;
    printf("%d", h+m-k);
    return 0;
}

Measured memory_bytes: 1720
#include<cstdio>
#include<climits>
#include<iostream>
using namespace std;
long long w[101],m,f[100001];
int n,v[101],ans;
int main(){
	scanf("%d%lld",&n,&m);
	for(int i=0;i<=100000;i++){
		f[i]=INT_MAX;
	}
	f[0]=0;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=100000;j>=v[i];j--){
			f[j]=min(f[j],f[j-v[i]]+w[i]);
			if(f[j]<=m){
				ans=max(ans,j);
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 1024
s=input()
while 1:
    for i in range(len(s)):
        if s[i]=="B":
            if 0<i<len(s):
                s = s[:i-1]+s[i+1:]
                break
            elif i==len(s):
                s = s[:i]
            else:
                s = s[1:]
                break
    else:
        print(s)
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const ll oo = 1e18;
const int MOD = 1000000007;
const int N = 500010;
#define x first
#define y second
#define pb push_back
#define mp make_pair

int n , d[N] , q, r, D;
ll B[N], A[N];


int main() {
	scanf("%d%d", &n, &D);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &d[i]);
	}
	int cur = 0;
	A[0] = D;
	for (int i = 1 ; i <= n ; ++i) {
		if (abs((cur + (cur>D?-1:1)*d[i]) - D) < abs(cur - D)) {
			cur = cur + (cur>D?-1:1)*d[i];
		}
		A[i] = abs(cur-D);
	}
	B[n + 1] = 1;
	for (int i = n ; i >= 1 ; --i) {
		B[i] = B[i + 1];
		if (B[i+1]>d[i]/2)
			B[i] = d[i] + B[i+1];
	}
	scanf("%d",&q);
	while (q--) {
		scanf("%d", &r);
		if(A[r-1]>=B[r+1]){
			puts("YES");
		}else{
			puts("NO");
		}
	}
	return 0;
}


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

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

Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 1000

int main(void)
{
	int n, m, x, way, goal;
	int i;
	int grid[SIZE], dice[SIZE];

	while (1) {
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0) break;
		
		way = 0;
		for (i = 0; i < SIZE; i++) {
			grid[i] = 0; dice[i] = 0;
		}
		
		for (i = 0; i < n; i++)
			scanf("%d", &grid[i]);
		for (i = 0; i < m; i++)
			scanf("%d", &dice[i]);

		for (i = 0; i < m; i++) {
			way += dice[i]; 
			way += grid[way]; 
			if (way >= n - 1) {
				goal = i + 1;
				break;
			}
		}
		printf("%d\n", goal);
	}

	return 0;
}

Measured memory_bytes: 608
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	int[] num = new int[n];
		for(int i=0;i<n;i++){
          num[i] = sc.nextInt();
        }
      	Arrays.sort(num);
      	int sum = 0;
      	for(int i=0;i<k;i++){
          sum += num[i];
        }
      	System.out.println(sum);
	}
}

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

int main()
{
    int n;
    cin>>n;
    for(int i = 1 ; i<10 ; i++)
    {
        for(int j = 1 ; j<10 ; j++)
        {
            if(i*j==n)
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}
        

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++){
    cin >>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int count = 1;
  
  for(int i=1; i<N;i++){
    if(vec.at(i) == vec.at(i-1)){
      continue;
    }
    else {
       count++;
    }
  }
       cout << count << endl;
       
       
  
  
}


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

template <class T>
inline void read(T &res)
{
	char ch; bool flag = false; res = 0;
	while (ch = getchar(), !isdigit(ch) && ch != '-');
	ch == '-' ? flag = true : res = ch ^ 48;
	while (ch = getchar(), isdigit(ch))
		res = res * 10 + ch - 48;
	flag ? res = -res : 0;
}

const int N = 1e7 + 5;
const int mod = 998244353;
int fra[N], inv[N], ex[N], n;

inline int quick_pow(int x, int k)
{
	int res = 1;
	while (k)
	{
		if (k & 1)
			res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;
		k >>= 1;
	}
	return res;
}

inline void add(int &x, int y)
{
	x += y;
	x >= mod ? x -= mod : 0;
}

inline void dec(int &x, int y)
{
	x -= y;
	x < 0 ? x += mod : 0;
}

inline int C(int n, int m)
{
	return 1ll * fra[n] * inv[m] % mod * inv[n - m] % mod;
}

int main()
{
	read(n);
	fra[0] = 1;
	for (int i = 1; i <= n; ++i)
		fra[i] = 1ll * fra[i - 1] * i % mod;
	inv[n] = quick_pow(fra[n], mod - 2);
	for (int i = n; i >= 1; --i)
		inv[i - 1] = 1ll * inv[i] * i % mod;
	ex[0] = 1;
	for (int i = 1; i <= n; ++i)
		add(ex[i] = ex[i - 1], ex[i - 1]);

	int half = n >> 1, ans = quick_pow(3, n);
	for (int i = half + 1; i <= n; ++i)
		dec(ans, 2ll * C(n, i) * ex[n - i] % mod);
	printf("%d\n", ans);
}

Measured memory_bytes: 117376
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, K; cin >> N >> K;
    
    double ans = 0.0;
    FOR(i, 1, N+1){
        ll sc = i; ll cnt = 0;
        while(sc < K){
            sc *= 2; cnt++;
        }
        ans += 1.0 / ( N * 1ll << cnt);
    }
    cout << fixed << setprecision(30) << ans << endl;
    return 0;
}


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

char a[110][110];

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

    int h,w;
    cin>>h>>w;

    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>a[i][j];

    for(int i=0;i<w+2;i++)printf("#");
    printf("\n");

    for(int i=0;i<h;i++)
    {
        printf("#");
        for(int j=0;j<w;j++)
        {
            printf("%c",a[i][j]);
        }
        printf("#\n");
    }

    for(int i=0;i<w+2;i++)printf("#");
    printf("\n");

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

#define MAX 500000
#define INFTY 2000000000

int cnt;
int L[MAX/2+1],R[MAX/2+1];

void merge(int a[] , int left , int mid , int right){
    int n1 = mid-left;
    int n2 = right-mid;
    for(int i = 0 ; i<n1 ; i++){
        L[i] = a[left+i];
    }
    for(int i = 0 ; i<n2 ; i++){
        R[i] = a[mid+i];
    }
    L[n1] = R[n2] = INFTY;

    int i = 0;
		int j = 0;
    for(int k = left ; k<right ; k++){
        cnt++;
        if(L[i]<=R[j]){
            a[k] = L[i++];
        }
        else{
            a[k] = R[j++];
        }
    }
}

void mergeSort(int a[] , int left , int right){
    if(left+1<right){
        int mid = (left+right)/2;
        mergeSort(a,left,mid);
        mergeSort(a,mid,right);
        merge(a,left,mid,right);
    }
}

int main(){
    int a[MAX+2];
    int n;  cin>>n;
    for(int i = 0 ; i<n ; i++){
        cin>>a[i];
    }

    mergeSort(a,0,n);


    for(int i = 0 ; i<n ; i++){
        if(i!=0)
					cout << ' ';
        cout << a[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 6864
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void){
  int N,M,X,Y;
  int x[1000],y[1000];
  scanf("%d%d%d%d",&N,&M,&X,&Y);
  int i,max_x=X,min_y=Y;
  for(i=0;i<N;i++) {scanf("%d",&x[i]);if(x[i]>max_x) max_x=x[i];}
  for(i=0;i<M;i++) {scanf("%d",&y[i]);if(y[i]<min_y) min_y=y[i];}
  if(max_x<min_y) printf("No War");
  else printf("War");
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
int main(int argc, char *argv[]) {
	map<char, bool> cups;
	cups.insert(make_pair('A', true));
	cups.insert(make_pair('B', false));
	cups.insert(make_pair('C', false));
	char c1, c2;
	while (EOF != scanf("%c,%c", &c1, &c2)) {
		swap(cups[c1], cups[c2]);
		//printf("%c %c\n", c1, c2);
	}
	map<char, bool>::iterator it = cups.begin();
	while (it != cups.end()) {
		if (it->second) {
			printf("%c\n", it->first);
			break;
		}
		it++;
	}
	return 0;
}

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

typedef long long ll;
const int maxn=3e5+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,m;
string s,t;
int nex[maxn][30];

int32_t main()
{
    IOS
    cin>>s>>t;
    n=s.length(),m=t.length();
    s=s+s;
    memset(nex,-1,sizeof(nex));
    for (int i=2*n-2;i>=0;i--)
    {
        for (int j=0;j<26;j++) nex[i][j]=nex[i+1][j];
        nex[i][s[i+1]-'a']=(i+1)%n;
    }
    int now=-1;
    for (int i=0;i<n;i++)
    {
        if (s[i]==t[0])
        {
            now=i+1;
            break;
        }
    }
    if (now==-1) return cout<<-1<<endl,0;
    int ans=now;
    now--;
    for (int i=0;i<=m-2;i++)
    {
        if (nex[now][t[i+1]-'a']==-1) return cout<<-1<<endl,0;
        if (now==nex[now][t[i+1]-'a']) ans=ans+n;
        else ans=ans+(nex[now][t[i+1]-'a']+n-now)%n;
        now=nex[now][t[i+1]-'a'];
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong N;
	string S;

	cin >> N;
	cin >> S;

	for (auto &s: S) {
		cout << (char)('A' + (s - 'A' + N) % 26);
	}
	cout << endl;

	return 0;
}

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

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  int count = 0;
  for(int i = 0; i < n; i++){
    int h;
    cin >> h;
    if(h >= k) count++;
  }
  
  cout << count << endl;
  
  return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<string> input(n);
    rep(i, n) {
        cin >> input[i];
    }

    int ans = 0;
    rep(i, n) {
        rep(j, input[i].size()-1) {
            if (input[i][j] == 'A' && input[i][j+1] == 'B') ans++;
        }
    }

    int bxa = 0, bx = 0, xa = 0;
    rep(i, n) {
        if (input[i][0] == 'B' && input[i].back() == 'A') {
            bxa++;
        } else if (input[i].back() == 'A') {
            xa++;
        } else if (input[i][0] == 'B') {
            bx++;
        }
    }


    if (xa && bx) {
        int xbabax = min({xa, bx});
        xa -= xbabax;
        bx -= xbabax;
        ans += xbabax + bxa;
        bxa = 0;
    }

    if (bxa) {
        ans += bxa - 1 + (int)(bx != 0 || xa != 0);
    }

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

    return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long  ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

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

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int j = 0; j < n; j++) {
        cin >> b[j];
    }
    for (int k = 0; k < n - 1; k++) {
        cin >> c[k];
    }

    int sum = 0;
    for (int m = 0; m < n; m++) {
        sum += b[a[m] - 1];
        if (a[m + 1] - a[m] == 1) {
            sum += c[a[m] - 1];
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628
use std::io::*;
use std::str::*;

use std::process;

fn main(){
    let s = read_str();
    for i in 0..2{
        if s[i] == '9' {
            println!("Yes");
            process::exit(0);
        }
    }
    println!("No");

}

#[allow(dead_code)]
fn read_str() -> Vec<char>{
    let s :String = read();
    s.chars().collect::<Vec<char>>()
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(|_| panic!("Faild to parse {}", s))
}


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

int main(void) {
	int a,b,c,d,e,k,dif;
	cin >>a>>b>>c>>d>>e>>k;
	
	dif =e-a;
	if (dif<=k) {
	 cout <<"Yay!";
	}else {
		cout <<":(";
	}
	// your code goes here
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll a;
	cin >> a;
	string s;
	cin >> s;
	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
}

Measured memory_bytes: 3672
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize, _z: i64, w: i64,
        a: [i64; n]
    }

    println!("{}", if n == 1 {
        (a[0] - w).abs()
    } else {
        std::cmp::max(
            (a[n-1] - w).abs(),
            (a[n-2] - a[n-1]).abs()
        )
    });
}


Measured memory_bytes: 4476
n = int(input())
ab = [[int(item) for item in input().split()] for _ in range(n)]
ab.sort(key=lambda x: x[0] + x[1], reverse=True)

ans = 0
for i, (a,b) in enumerate(ab):
    if i % 2 == 0:
        ans += a
    else:
        ans -= b
print(ans)

Measured memory_bytes: 26020
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <map>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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

struct Node {
  int x;
  ll c;
  vector<Node*> children;
  Node(int x_) {
    x = x_;
    c = 0;
  };
};

void dfs(Node* v) {
  for(auto i = v->children.begin(); i!=v->children.end(); i++) {
    (*i)->c += v->c;
    dfs(*i);
  }
}

void dfsp(Node* v) {
  std::cout << v->x << std::endl;
  for(auto i = v->children.begin(); i!=v->children.end(); i++) {
    dfsp(*i);
  }
}

int main(void) {
  int n;
  int q;
  cin>>n>>q;
  map<int, Node*> nodes;
  vector<int> roots(n+1);
  roots[0] = 1;
  for(int i=1; i<n+1; i++) {
    roots[i] = 0;
  }
  for(int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    auto f = nodes.find(a);
    if(f == nodes.end()) {
      nodes[a] = new Node(a);
    }
    f = nodes.find(b);
    if(f == nodes.end()) {
      nodes[b] = new Node(b);
    }
    nodes[a]->children.push_back(nodes[b]);
    roots[b] = 1;
  }
  int root;
  for(int i=0; i<n+1; i++) {
    if(roots[i]==0) {
      root = i;
    }

  }
  // dfsp(nodes[root]);
  for (int i=0; i<q; i++) {
    int x, y;
    cin>>x>>y;
    nodes[x]->c += y;
  }
  dfs(nodes[root]);
  for (int i=1; i<n+1; i++){
    std::cout << nodes[i]->c << " ";
  }
  return 0;
}



Measured memory_bytes: 37632
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}


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

	if (c > b and b > a) {
		cout << "Yes";
		return 0;
	}

	if (a == b and b == c) {
		if (k >= 3)
			cout << "Yes";
		else
			cout << "No";
		return 0;


	}

	if (b <= a) {

		ll l1;
		if ((a - b) & 1)
			l1 = (a - b) / 2 + 1;
		else
			l1 = (a - b) / 2;

		ans += l1;
		b *= pow(2, l1);
		if (b / 2 > a) {
			ans--;
			b /= 2;
		}
		else if ( b <= a) {
			ans++;
			b *= 2;
		}
		// cout<<b<< " ";

	}
	if (c <= b) {
		ll l2;
		if ( (b - c) & 1)
			l2 = (b - c) / 2 + 1;
		else
			l2 = (b - c) / 2;

		ans += l2;
		c *= pow(2, l2);
		if (c / 2 > b) {
			ans--;
			c /= 2;
		}
		else if ( c <= b) {
			ans++;
			c *= 2;
		}

		// cout<<c<<endl;
	}

	if (ans <= k)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}







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

typedef struct demand
{
    int a;
    int b;
}demand_t;

int compare_b(const void *x, const void *y)
{
    return (*((demand_t *)x)).b-(*((demand_t *)y)).b;
}

int main(void)
{
    int n,m,cut[100000-1],precutj,i,ans=0;
    demand_t demands[100000];

    scanf("%d %d",&n,&m);
    for ( i = 0; i < m; i++)
    {
        scanf("%d %d",&(demands[i].a),&(demands[i].b));
        demands[i].b--;
    }

    qsort(demands,m,sizeof(demand_t),compare_b);

    for ( i = 0; i < m; i++)
    {
        if(i==0)
        {
            precutj=demands[i].b;
            ans++;
        }
        else
        {
            if(precutj<demands[i].a||demands[i].b<precutj)
            {
                precutj=demands[i].b;
                ans++;
            }
        }
    }

    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int[][] c = new int[3][3];
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        c[i][j] = scanner.nextInt();
      }
    }

    int c012 = c[0][0] + c[1][1] + c[2][2];
    int c021 = c[0][0] + c[1][2] + c[2][1];
    int c102 = c[0][1] + c[1][0] + c[2][2];
    int c120 = c[0][1] + c[1][2] + c[2][0];
    int c210 = c[0][2] + c[1][1] + c[2][0];
    int c201 = c[0][2] + c[1][0] + c[2][1];

    if (c012 == c021 && c021 == c102 && c102 == c120 && c120 == c210 && c210 == c201) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  LL a[n];
  int even=0;
  REP(i, n) {
    cin>>a[i];
    if(a[i]%2==0) ++even;
  }

  if(even==n) cout<<"second"<<endl;
  else cout<<"first"<<endl;

  return 0;

}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(n) for ( int i =0; i < n ; i ++)
int N, M;
vector<int> x, d;
int main()
{
	scanf("%d %d", &N, &M);
	printf("%f", (double)N / M);
}

Measured memory_bytes: 256
#include <iostream>


int main()
{
	long long q, h, s, d, n;

	std::cin >> d >> s >> h >> q;

	std::cin >> n;


	if (d * 2 <= s) {
		s = -1;
	}

	if ((s != -1 && s * 2 <= h) || d * 4 <= h) {
		h = -1;
	}


	if ((h != -1 && h * 2 <= q) || (s != -1 && s * 4 <= q) || d * 8 <= q)  {
		q = -1;
	}

//std::cout << d << " " << s << " " << h << " " << q << std::endl;
		long long ans = 0;

		if (q != -1)
		{
			ans += q * (n / 2);
		n %= 2;
	}
	if (h != -1 && n != 0 ){
		ans += h * n;
		n = 0;
	} 

	if (s != -1 && n != 0) {
		ans += s * (n * 2);
		n = 0;
	}
	if (n != 0) {
		ans += d * (n * 4);
	}

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

	return 0;
}

Measured memory_bytes: 256