akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
#define int long long
const int MOD=1e9+7;
const int N=1e5+5;
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
int invmod(int x) {return power(x,MOD-2);}
int32_t main()
{
	string s;
	cin>>s;
	if((s[0]-'0')*10+(s[1]-'0')>0&&(s[0]-'0')*10+(s[1]-'0')<=12)
	{
		if((s[2]-'0')*10+(s[3]-'0')>0&&(s[2]-'0')*10+(s[3]-'0')<=12)
		{
			cout<<"AMBIGUOUS"<<endl;
			return 0;
		}
		else
		{
			cout<<"MMYY"<<endl;
			return 0;
		}
	}
	if((s[2]-'0')*10+(s[3]-'0')>0&&(s[2]-'0')*10+(s[3]-'0')<=12)
	{
		cout<<"YYMM"<<endl;

	}
	else
		cout<<"NA"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int x,s[210];
long long dp[210][100010] = {},mod = 1000000007,ans = 0;
int main(){
	int i,j,k,n;
	cin >> n >> x;
	for(i=0;i<n;i++){
		cin >> s[i];
	}
	sort(s,s + n);
	for(i=0;i<=x;i++){
		dp[0][i] = i;
	}
	for(i=1;i<=n;i++){
		for(j=0;j<=x;j++){
			dp[i][j] = (dp[i-1][j%s[i-1]] + dp[i-1][j]*(i-1))%mod;
		}
	}
	cout << dp[n][x] << endl;
}

Measured memory_bytes: 157952
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#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;

struct edge{
  int a, b;
  bool operator<(const edge &r) const{
    return a==r.a ? b<r.b : a<r.a;
  }
};

void swap(int &a, int &b){
  if(a > b){
    a^=b;
    b^=a;
    a^=b;
  }
  return;
}

int main(){
  int n;
  cin>>n;
  int c[n], score[n];
  edge e[n-1];
  queue<edge> q;

  REP(i, n-1){
    cin>>e[i].a>>e[i].b;
    --e[i].a;
    --e[i].b;
    swap(e[i].a, e[i].b);
  }
  REP(i, n){
    cin>>c[i];
    score[i]=-1;
  }
  //sort(e, e+n-1);
  sort(c, c+n, greater<int>());
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  int csum=0;
  score[e[0].a]=c[0];
  q.push(e[0]);

  int at,bt;
  int count=1;
  while(!q.empty()){
    edge et = q.front();
    q.pop();
    at=et.a;
    bt=et.b;
    if(score[at]>0 && score[bt]>0) continue;
    if(score[at]==-1) {score[at] = c[count];}
    if(score[bt]==-1) {score[bt]=c[count];}
    csum+=c[count];
    ++count;

    for(int j=0; j<n-1; ++j){
      if(score[e[j].a]==-1 && score[e[j].b]!=-1) q.push(e[j]);
      if(score[e[j].b]==-1 && score[e[j].a]!=-1) q.push(e[j]);
    }
    if(count==n)break;
  }
  cout<<csum<<endl;
  REP(i, n-1) cout<<score[i]<<" ";
  cout<<score[n-1]<<endl;

  return 0;
}


Measured memory_bytes: 412424
N=int(input())
h=list(map(int,input().split()))
cnt=0
L=0
R=0
time=0

while L<=N-1:
  time +=1
  R=-1
  for i in range(L,N):
    if h[i]>0:
      R=i
      h[i] -= 1
    else:
      break
  #print(time,L,R,h)
  if R>=L:
    cnt +=1
  else:
    L +=1
    
print(cnt)

Measured memory_bytes: 3064
// Bismillah .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const ll mx = 1e18;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    ll x,ans =1;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++)
    {

        if(ans>mx/a[i])
        {
            cout<<-1<<endl;
            return 0;
        }
        ans*=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4408
import math
# Python program to find angle
# between hour and minute hands

# Function to Calculate angle b/w
# hour hand and minute hand
def calcAngle(h, m):
    # validate the input
    if (h < 0 or m < 0 or h > 12 or m > 60):
        print('Wrong input')

    if (h == 12):
        h = 0
    if (m == 60):
        m = 0

    # Calculate the angles moved by
    # hour and minute hands with
    # reference to 12:00
    hour_angle = 0.5 * (h * 60 + m)
    minute_angle = 6 * m

    # Find the difference between two angles
    angle = abs(hour_angle - minute_angle)

    # Return the smaller angle of two
    # possible angles
    angle = min(360 - angle, angle)

    return angle


# Driver program
a,b,h,m = map(int,input().strip().split())
z = calcAngle(h, m)
p = math.cos((calcAngle(h, m)*math.pi)/180)
print((a**2+b**2-2*a*b*p)**0.5)

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

int main(){
	ll n,x;
	cin >> n >> x;
	vector<ll> a(n,0);
	int sum = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(),a.end());
	ll count = 0;
	int y = x;
	while(a[count] <= y && count < n){
		y -= a[count];
		count++;
	}
	if(x != sum && count == n)count--;
	cout << count << endl;
	return 0;
}

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

int main() {
    vector<int> vec(3);
    rep(i, 3) cin >> vec[i];
    sort(vec.begin(), vec.end());
    cout << vec[2] - vec[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int G[N][N],d[N],n,t,Q[N],head,tail;

void BFS(void);
void enqueue(int);
int dequeue(void);

int main (){
  int i,j,k,u,v;

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

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1] = 1;
    }
  }

  BFS();

  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,d[i]);
  }
  return 0;
}

void BFS(void){
  int v,i;
  d[0] = 0;
  head = 0;
  tail = 0;
  enqueue(0);

  while(head != tail){
    v = dequeue();
    for(i=0;i<n;i++){
      if(G[v][i] && d[i] == -1){
        d[i] = d[v]+1;
        enqueue(i);
      }
    }
  }
  return;
}

void enqueue(int n){
  Q[tail] = n;
  tail++;
  if(tail==N) tail=1;
}
int dequeue(){
  int n;
  n = Q[head];
  head++;
  if(head==N) head=1;
  return n;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*🍈( '-'  🍈*/

int main(){
	ll A,B,C,D;
	cin >> A >> B >> C >> D;
	A--;
	ll AC,BC,AD,BD,AY,BY;
	ll Y = C * D / gcd(C,D);
	BD = B / D;
	AD = A / D;
	AC = A / C;
	BC = B / C;
	BY = B / Y;
	AY = A / Y;
	ll ans = (BC+BD-BY) - (AC+AD-AY);

	cout << B-A-1+1 - ans << "\n";
	return 0;
}


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

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

	vector<int> x(n),y(n);
	vector<int> xary,yary;

	for(int i = 0; i < n; ++i){
		cin >> x[i] >> y[i];
		xary.push_back(x[i]);
		yary.push_back(y[i]);
	}
	
	sort(begin(xary),end(xary));
	sort(begin(yary),end(yary));
	
	ll ans = 1LL * (xary[n-1] - xary[0]) * (yary[n-1] - yary[0]);

	for(int xi = 0; xi < n; ++xi){
		for(int xj = xi + 1; xj < n;++xj){
			for(int yi = 0; yi < n; ++yi){
				for(int yj = yi + 1; yj < n;++yj){
	
					int num = 0;
					ll lx = xary[xi],rx = xary[xj];
					ll by = yary[yi],uy = yary[yj];

					for(int i = 0; i < n;++i){
						if(lx <= x[i] and x[i] <= rx and by <= y[i] and y[i] <= uy){
							num++;
						}
					}

					if(num >= k) ans = min(ans,1LL * (rx - lx) * (uy - by));
				}
			}
		}
	}

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

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.typecons;

  int n; rd(n);
  int m; rd(m);

  auto lose=new int[](n), g=new int[][](n);
  foreach(i; 0..m){
    int a, b; rd(a, b);
    g[a-1]~=(b-1);
    lose[b-1]++;
  }

  bool multi=false;
  auto used=new bool[](n);
  foreach(_; 0..n){
    int[] cand;
    foreach(i; 0..n){
      if(used[i]) continue;
      if(lose[i]>0) continue;
      cand~=i;
    }
    if(cand.length>1) multi=true;
    auto i=cand[0];
    foreach(j; g[i]) lose[j]--;
    writeln(i+1);
    used[i]=true;
  }

  if(multi) writeln(1);
  else writeln(0);
}
void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}



Measured memory_bytes: 10800
// ABC165B - 1%

#include <bits/stdc++.h>
using namespace std;

int main() {
	long long int X;
	cin >> X;

	long long int ans = 1;
	long long int money = 100;

	while (1) {
		money += money / 100;
		if (money >= X) {
			break;
		}
		++ans;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

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

    bool odd = false;
    for(int i=0; i<N; i++){
        if(a[i]%2==1) odd = true;
    }

    if(odd){
        cout << "first" << endl;
    }else{
        cout << "second" << endl;
    }
}



Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#define rep(i) for(int i=0;i<n;i++)
using namespace std;
int n,c,a[110],b[110];
int main(){
	while(cin>>n&&n){
		rep(i)a[i]=1145141919,b[i]=0;
		rep(i)
			rep(j){
				cin>>c;
				a[i]=min(a[i],c);
				b[j]=max(b[j],c);
			}
	rep(i)rep(j)if(a[i]==b[j]){cout<<a[i]<<endl;goto loop;}
	cout<<"0"<<endl;
	loop:;
	}
	return 0;
}

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

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

    int ans = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I')
            cnt++;
        else
            cnt--;

        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

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

    vector<int> a(n);

    rep(i,0,a.size())
    {
        cin>>a[i];
    }

    int sum = 0;

    rep(i,0,a.size())
    {
        rep(j,i+1,a.size())
        {
            sum += (a[i]*a[j]);
        }
    }

    cout<<sum<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

void solve(std::string s, std::string t){
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    if (s < t) cout << YES << '\n';
    else cout << NO << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(s, t);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main() {
  int k;
  string s;
  cin >> k >> s;
  if(s.size() <= k) cout << s << endl;
  else {
    cout << s.substr(0, k) + "..."<< endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;

int main() {
	int n, a[50];
	cin >> n;
	int x = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] != i + 1) {
			x++;
		}
	}
	if (x > 2)cout << "NO";
	else cout << "YES";
	cout << endl;
}

Measured memory_bytes: 256
// test.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <iostream>
#include <algorithm>
#include <vector>




using namespace std;


int main()
{
	// 整数の入力
	string S;
	cin >> S ;
	
	int flag = 0;
	for (int i = 0; i < S.size(); i++) {
		if (i % 2 != 0) {
			if (S.at(i) != 'L' && S.at(i) != 'U' && S.at(i) != 'D') {

				flag = 1;
				//cout << "flag ON" << S.at(i) << " i;" << i;
			}
		}
		else {
			if (S.at(i) != 'R' && S.at(i) != 'U' && S.at(i) != 'D') {
				flag = 1;
			}
			
		}
	}
	
	if (flag == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	
	

	return 0;
}





// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

using namespace std;
using ll=long long;

int main(){
    ll n;
    cin>>n;
    vector<ll> x(n);
    for (int i = 0; i < n; ++i) {
        cin>>x[i];
    }
    ll ans=10000000;
    for (int i = 1; i <= 100; ++i) {
        ll tans=0;
        for (int j = 0; j < n; ++j) {
            tans+=(x[j]-i)*(x[j]-i);
        }
        if(tans<0)continue;
        ans=min(ans,tans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function (line) {
  var i,x,result="";
  var a = line.split(' ');
  var b = parseInt(a[0],10);
  for(i=3;i<=b;i++){
    x = i;  
    if(x%3==0)
      result += " "+i;
    else{
      for( ; ; ){
        if(x<1)
          break;
        if(x%10==3){
          result += " "+i;
          break;
        }
        x = Math.floor(x/10);
      }
    }
  }
  console.log(result);
  process.exit();
});
process.stdin.on('end', function () {
});

Measured memory_bytes: 18428
a,b,c,x,y=map(int,input().split())
if (a+b)<=2*c:
    print(a*x+b*y)
elif (a+b)>2*c:
    if x==y:
        print(2*x*c)
    elif x<y:
        if b>2*c:
            print(c*2*y)
        else:    
            print(2*x*c+b*(y-x))
    else:
        if a>2*c:
            print(c*2*x)
        else:    
            print(2*y*c+a*(x-y))
    

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

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

  int S_before = S.size();
  S.erase(unique(S.begin(), S.end()), S.end());

  if(S_before == S.size()){
    cout << "Good" << endl;
  }else {
    cout << "Bad" << endl;
  }
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))

dp = [0] * (K+1)

for i in range(0,K+1):
    if dp[i] == 0:
        for j in A:
            if i + j > K:
                break
            dp[i + j] = 1

print('First' if dp[K] else 'Second')

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

void solveA(){
  string n;
  cin >> n;

  for(int i=0;i<3;i++){
    if(n[i]=='1'){
      n[i]='9';
    }
    else {
      n[i]='1';
    }
  }

    cout << n << endl;
}
void solveB(){
  string n;
  cin >> n;

  if(n[0]<n[1] || (n[0]==n[1]&&n[1]<n[2])){
    n[0]++;
  }
    n[1]=n[0];
    n[2]=n[0];
    cout << n << endl;
}

void solveC(){
  
}
void solveD(){

}

int main(){
  solveB();
}


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

int main(){
  int N, M; cin >> N >> M;
  vector<vector<int>> H(N, vector<int>(2));
  for(int i = 0; i < N; i++){
    cin >> H.at(i).at(0);
    H.at(i).at(1) = 0;
  }
  
  for(int i = 0; i < M; i++){
    int A, B; cin >> A >> B;
    if(H.at(A-1).at(0) >= H.at(B-1).at(0)){
      H.at(B-1).at(1)++;
    }
    if(H.at(A-1).at(0) <= H.at(B-1).at(0)){
      H.at(A-1).at(1)++;
    }
  }
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(H.at(i).at(1) == 0){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 8764
r, g, b = map(int, input().split())
k = int(input())
for i in range(k):
    if b <= r or b <= g:
        b *= 2
    elif g <= r:
        g *= 2
    else:
        b *= 2
if r < g and g < b:
    print('Yes')
else:
    print('No')


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

int main() {
  string S, T;
  cin >> S >> T;

  bool ok = false;
  string ans = S;

  reverse(ans.begin(), ans.end());
  reverse(T.begin(), T.end());

  rep(i, ans.size() - T.size() + 1) {
    bool flag = false;
    rep(j, T.size()) {
      if (ans[i + j] != T[j] && ans[i + j] != '?')
        break;
      if (j == T.size() - 1)
        flag = true;
    }
    if (flag) {
      ans = ans.substr(0, i) + T +
            ans.substr(i + T.size(), ans.size() - i - T.size());
      ok = true;
      break;
    }
    if (ok)
      break;
  }

  if (ok) {
    rep(i, ans.size()) {
      if (ans[i] == '?')
        ans[i] = 'a';
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  } else
    puts("UNRESTORABLE");
}

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

int main() {
    int A[3][3], x[3], y[3];
    for (int i=0; i<3; i++){
        for (int j=0; j<3; j++){
            cin >> A[i][j];
        }
    }
    x[0]=0;
    for (int i=0; i<3; i++){
        y[i]=A[0][i];
    }
    for (int i=0; i<3; i++){
        x[i]=A[i][0]-y[0];
    }
    for (int i=0; i<3; i++){
        for (int j=0; j<3; j++){
            if (A[i][j]!=x[i]+y[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
/**
 * ?????????????´¢

??????????????? W ??¨?????? T ????????????????????????T ??????????????? W
?????°???????????????????????°?????????????????????????????????

?????? T ????????????????????????????????????????????§????????????????????????????????? Ti
??¨???????????????????????? Ti ?????????????????? W ??¨??????????????????????????°??????????????????

???????????§????????¨?°???????????????\???????????????

Constraints
W????????????????????????10????¶????????????????
T??????????????????????????????????????????1000????¶????????????????
Input
?????????????????? W ????????????????????????

?¶???????????????°????????????????????£??????????????????????????????END_OF_TEXT
??¨??????????????????????????????????????????????????????

Output
?????? W ?????°???????????????????????????

Sample Input
computer
Nurtures computer scientists and highly-skilled computer engineers
who will create and exploit "knowledge" for the new era.
Provides an outstanding computer environment.
END_OF_TEXT
Sample Output
3
 */

#include <iostream>
#include <sstream>
#include <locale>
#include <algorithm>
#include <vector>

/**
 * split a string into a vector at a Delimiter
 * @param   str         sting to be splitted
 * @param   Delimiter
 * @return              vector of splitted strings
 */
std::vector<std::string> splitString(std::string str, char Delimiter) {
  std::vector<std::string> v;
  std::stringstream ss(str);
  std::string Token;

  while (getline(ss, Token, Delimiter)) {
    v.push_back(Token);
  }

  return v;
}

int main(int argc, char const *argv[]) {
  std::string W, T;
  getline(std::cin, W);
  std::transform(W.begin(), W.end(), W.begin(), tolower);
  unsigned int Count = 0;

  while (true) {
    getline(std::cin, T);
    if (T == "END_OF_TEXT") {
      break;
    } else {
      std::transform(T.begin(), T.end(), T.begin(), tolower);
      std::vector<std::string> vT = splitString(T, ' ');
      
      for (const auto& Token : vT) {
        if (Token == W) {
          Count++;
        }
      }
    }
  }
  std::cout << Count << std::endl;
  return 0;
}

Measured memory_bytes: 3168
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def nCb(n, b):
    if b > n - b:
        b = n - b
    r = 1
    for k in range(n, n-b, -1):
        r = r * k
    d = 1
    for k in range(1, b+1):
        d = d * k
    return r // d

def main():
    n,a,b = LI()
    v = sorted(LI(),reverse=True)
    if v[0] == v[a-1]:
        t = a-1
        for i in range(a,n):
            if v[0] != v[i]:
                break
            t = i
        t += 1
        r = 0
        for i in range(a,min(b,t)+1):
            r += nCb(t,i)
        return "{}\n{}".format(v[0], r)

    t = 0
    tu = 0
    va = v[a-1]
    for i in range(n):
        if v[i] > va:
            tu += 1
        elif v[i] == va:
            t += 1
        else:
            break
    r = nCb(t,a-tu)
    return "{}\n{}".format(sum(v[:a]) * 1.0 / a, r)



print(main())


Measured memory_bytes: 7860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
  int count = 0;
  for(int i = 0; i < s.size();i++){
    if(s.at(i) != t.at(i)){
      count++;}
  }
  cout << count << endl;
}
      

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

#define N 200010
char s[N];

int main()
{
	scanf("%s", s);
	int n = strlen(s);
	long long ans = 0, c = 0;
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'B') ++c;
		else ans += c; 
	}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
a=list(map(int,input().split()))
sum=0
for i in range(n):
    sum=sum+a[i]
    
x= (sum)/(4*m)
#print(x)
l=[]
for j in range(n):
    if(a[j] >= x):
        l.append(a[j])
#print(l)        
if(len(l)>=m):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
n=int(input())
s=input()

maxcount=0
for i in range(n-1):
    left=s[:i+1]
    right=s[i+1:]
    
    leftset=set()
    for ss in left:
        leftset.add(ss)

    rightset=set()
    for ss in right:
        rightset.add(ss)

    maxcount=max(maxcount,len(leftset&rightset))
print(maxcount)

Measured memory_bytes: 3064
S = input()

s = list(S)

answer = 0
for i in reversed(range(1, len(s))):
    if i >= len(s):
        continue
         
    if s[i] != s[i - 1]:
        s.pop(i - 1)
        s.pop(i - 1)
        answer = answer + 2

print(answer)


Measured memory_bytes: 3956
# n*m?????????A??¨m*1??????????????????b??¨??????????¨????????????°??????

n, m = map(int, input().split())

A = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
    A[i] = list(map(int, input().split()))

b = [[0] for i in range(m)]
for i in range(m):
    b[i][0] = int(input())

c = [[0] for i in range(n)]            #A??b
for i in range(n):
    for j in range(m):
        c[i][0] += A[i][j] * b[j][0]

for i in range(n):
    print(c[i][0])

Measured memory_bytes: 7928
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;

const long long inf2 = (long long)1e18;
const long long mod = (long long)(1e9+7);
const long long inf1 =(long long)(1e6);
int p = mod;

int power(int x, int y) 
{ 
    int res = 1;
    x = x % p; 
  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
}
 
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    read(n);
    readarr(a, n);
    int spf[inf1+1] = {};
    fori(i, 2, 1e6)
    {
        if(!spf[i])
        {
            for(int j = i; j <= 1e6; j += i) spf[j] = i;
        }
    }
    int ans[inf1+1] = {};
    int val = 0;
    fori(i, 1, n)
    {
        val += power(a[i], mod-2); val %= mod;
        map <int, int> mp;
        while(a[i] != 1)
        {
            int x = spf[a[i]];
            mp[x]++;
            a[i] = a[i]/x;
            ans[x] = max(ans[x], mp[x]);
        }
    }

    fori(i, 2, 1e6) val = val*power(i, ans[i])%mod;
    cout << val;

    return 0;
}

Measured memory_bytes: 16000
#include <stdio.h>
int main()
{
    int W,a,b,c,d;
    scanf("%d%d%d",&W,&a,&b);
    if(a>b)
        {
            c=a;
            a=b;
            b=c;
        }
        if(b<=a+W)
            d=0;
        else
        {
            d=b-a-W;
        }
        printf("%d\n",d);
        return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, K;
  cin >> N >> K;
  int64 ret = K;
  for(int k = 1; k < N; k++) ret *= K - 1;
  cout << ret << endl;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e7+9;
int main()
{
    FASTINOUT;
    ll x;
    cin>>x;
    cout<<fixed<<setprecision(6)<<2*3.141592*x<<"\n";
    return 0;
}

Measured memory_bytes: 3796
#!/usr/bin/env ruby

# ??¨?????????????????????????????????????????????
eratos = []
1.upto(999_999){ |n| eratos[n] = 1 }
eratos[1] = 0

1.upto(999_999) do |n|
  next if eratos[n] == 0
  tmp = n * 2
  while tmp < 1_000_000
    eratos[tmp] = 0
    tmp += n
  end
end

while line = gets
  n=line.chomp!.to_i
  puts eratos[1..n].reduce(:+)
end

Measured memory_bytes: 18912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

ll gcd(ll a, ll b)
{
    if (a == 0 || b == 0)
    {
        return max(a, b);
    }
    else
    {
        if(a < b) {
            swap(a,b);
        }
        ll r = a % b;
        while (r != 0)
        {
            a = b;
            b = r;
            r = a % b;
        }
        return b;
    }
}

int main() {
    ll A,B;
    cin >> A >> B;
    ll C = gcd(A,B);
    ll ret = 1;
    for(ll i = 2;i * i <= C;i++) {
        if(C % i == 0) {
            ret++;
            while(C % i == 0) {
                C /= i;
            }
        }
    }
    if(C != 1) {
        ret++;
    }
    cout << ret << endl;
}

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

bool isOnly(string s) {
    set<char> st;
    for (char i : s) {
        st.insert(i);
    }
    return st.size() == 1;
}

int main() {
    string s;
    cin >> s;
    set<char> st;
    for (char i : s) st.insert(i);
    int ans = 1001001001;
    for (char target : st) {
        string now = s;
        string next;
        int cnt = 0;
        while (!isOnly(now)) {
            for (int i = 0; i < now.size() - 1; ++i) {
                char pb;
                if (now[i] == target or now[i + 1] == target) pb = target;
                else pb = now[i];
                next.push_back(pb);
            }
            now = next;
            next.clear();
            ++cnt;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    static final int INF = (int)1e9;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        char[] s = sc.next().toCharArray();
        long k = Integer.parseInt(sc.next());
        
        int n = s.length;
        
        long gcnt = 0;
        long scnt = 0;
        long cnt = 0;
        if(s[0] == s[n-1]){
            //後ろと前がつながる
            for(int i=n-1; i>=0; i--){
                if(s[i]==s[0]){
                    gcnt++;
                }else{
                    break;
                }
            }
            for(int i=0; i<n; i++){
                if(s[i]==s[0]){
                    scnt++;
                }else{
                    break;
                }
            }
        }
        
        if(scnt == n){
            //一種類なら
            System.out.println( n*k/2 );
        }else{
            int ren = 0;
            for(int i=0; i<n-1; i++){
                if(s[i] == s[i+1]){
                    ren++;
                    if(ren%2==1){
                        cnt++;
                    }
                }else{
                    ren = 0;
                }
            }
            long ans = cnt*k;
            if(k != 1){
                ans += (gcnt+scnt)/2*(k-1)-(gcnt/2+scnt/2)*(k-1);
            }
            System.out.println(ans);
        }
        
    }
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> S(H + 2, vector<char>(W + 2, '.'));
  
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> S.at(i).at(j);
    }
  }
  
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (S.at(i).at(j) == '.') {
        int count = 0;
        for (int k = -1; k < 2; k++) {
          for (int l = -1; l < 2; l++) {
            if (S.at(i + k).at(j + l) == '#') {
              count++;
            }
          }
        }
        S.at(i).at(j) = to_string(count).at(0);
      }      
    }
  }
  
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j < W; j++) {
      cout << S.at(i).at(j);
    }
    cout << S.at(i).at(W) << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");}
    if(a>b){
      printf("a > b\n");}
      if(a==b){
	printf("a == b\n");}
	return(0);}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int k, n, l;
    cin >> k >> n;

    vector<int> a(n);
    vector<int> dif(n);
    rep(i, n) cin >> a[i];

    dif[0] = a[0] + (k - a[n-1]);
    rep1(i, n) dif[i] = a[i] - a[i-1];

    int d_max = -1;
    rep(i, n) d_max = max(d_max, dif[i]);

    cout << k - d_max << endl;

    return 0;
}

Measured memory_bytes: 1792
#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);
  }
  int ans = 0;
  int m = 100000000;
  
  for(int i = 0; i < N; i++){
    if(m >= vec.at(i)){
      ans++;
      m = min(m, vec.at(i));
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .expect ("Parse error" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        n: u64
    }
    for x in 0..50001 {
        let y = (x as f64 * 1.08) as u64;
        if y == n {
            println!("{}", x);
            return;
        }
    }
    println!(":(");
}

Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[-1]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = map(int,readline().rstrip().split())
        tes[i][x-1] = y

cnt = 0
for i in range(2**N):
    hon = [0]*N
    for j in range(N):
        if (i>>j)&1:
            hon[j] = 1
    flag = True
    for j in range(N):
        if hon[j]:
            for k in range(N):
                if tes[j][k] == -1:
                    continue
                if tes[j][k] != hon[k]:
                    flag = False
                    break
        if not flag:
            break
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int a[n];
    int total = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        total += a[i];
    }
    int count = 0;

    int x;
    if(total%(4*m) == 0) x = total/(4*m);
    else x = total/(4*m) + 1;

    for(int i = 0; i < n; i++){
        if(a[i] >= x) count++;
    }

    //cout << x << " " << count << " " << total << endl;

    if(count >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;
int a[100010],b[100010],c[100010];
int dp[100010][3];

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>N;
    rep(i,0,N){
        cin>>a[i]>>b[i]>>c[i];
    }
    rep(i,0,N){
        dp[i+1][0]=max(dp[i][1],dp[i][2])+a[i];
        dp[i+1][1]=max(dp[i][0],dp[i][2])+b[i];
        dp[i+1][2]=max(dp[i][0],dp[i][1])+c[i];
    }
    cout<<max({dp[N][0],dp[N][1],dp[N][2]})<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <vector>
#include <string>
using namespace std;

int h, w;
vector<string> v;

int main(){
	scanf("%d %d", &h, &w);
	for(int i=0; i<h; ++i){
		char t[10];
		scanf("%s", t);
		v.push_back(t);
	}
	int x = 0;
	for(int i=0; i<h; ++i){
		while(x <= w && v[i][x] == '#'){
			v[i][x] = '.';
			++x;
		}
		--x;
	}
	bool f = true;
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j)
			if(v[i][j] == '#')
				f = false;
	if(f) printf("Possible\n");
	else printf("Impossible\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;

for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}


Measured memory_bytes: 4468
// 解き直し.
// https://img.atcoder.jp/data/arc/060/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

// n を b進数表記した場合の各桁の和.
// @param b: 2以上の整数.
// @param n: 1以上の整数.
// @return: 計算結果.
LL f(LL b, LL n){
    if(n < b) return n;
    else      return f(b, n / b) + (n % b);
}

int main(){
    
    // 1. 入力情報.
    LL N, S;
    scanf("%lld %lld", &N, &S);
    
    // 2. S = N の 場合.
    if(N == S){
        printf("%lld\n", N + 1);
        return 0;
    }
    
    // 3. S != N の 場合.
    // 3-1. 2 <= b <= √N かつ f(b, N) = S となる 整数b が 存在するか.
    int rn = (int)sqrt(N);
    repx(b, 2, rn + 1){
        if(f((LL)b, N) == S){
            printf("%d\n", b);
            return 0;
        }
    }
    
    // 3-2. √N < b <= N かつ f(b, N) = S となる 整数b が 存在するか.
    // 上位桁 p, 下位桁 q として, N = p * b + q, p + q = S に注意.
    // -> 上位桁 p を 全探索し, 条件を満たすものを探索.
    // subtask1_100000000000_2.txt などの WA回避のため, ロジック修正.
    // repx(p, 1, rn){
    repr(p, rn, 1){
        LL b = (N - S) / (LL)p + 1LL;
        if(b < 2LL) continue;
        if(f(b, N) == S){
            printf("%lld\n", b);
            return 0;
        }
    }
    
    // 3-3. 存在しなかった場合.
    puts("-1");
    return 0;
    
}

Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <math.h>
using namespace std;
 
int main()
{
	int i;
	long long min=0;
	long long a;
	long double N;
	long long T;
	long double t;
	long  long ANS;
	vector<long long> A;
	cin >> N;
	for(i=0;i<5;i++){
		cin >> a;
		A.push_back(a);
	}
	vector<long long>::iterator itr = min_element(A.begin(), A.end());
	T = ceil(N / *itr);
	ANS = T+4;
	cout << ANS << endl;
}

Measured memory_bytes: 256
import sys

def parse(inp):
    N=int(next(inp).split()[0])
    
    gifts=[[] for _ in range(N)]
    
    for i in range(N):
        gifts[i]=list(next(inp).split())
    return N,gifts
  
def main(inp):
    N=inp[0]
    gifts=inp[1]
    
    total = 0
    
    for i in range(N):
        if(gifts[i][1]=="JPY"):
            total += int(gifts[i][0])
        elif(gifts[i][1]=="BTC"):
            total += float(gifts[i][0])*380000.0
            
    return total
  
print(main(parse(sys.stdin)))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

struct edge{
    ll u;
    ll v;
    ll cost;
    edge(){}
    edge(ll u, ll v,ll cost):u(u),v(v),cost(cost){}
};

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<vector<edge>> G(N);
    for(int i = 0; i < N-1;i++){
        ll a,b,c; cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(edge(a,b,c));
        G[b].push_back(edge(b,a,c));
    }
    ll Q,K; cin >> Q >> K;
    K--;
    vector<ll> dist(N,LINF);
    queue<ll> q; q.push(K);
    dist[K] = 0;
    while(!q.empty()){
        ll n = q.front(); q.pop();
        for(auto e:G[n]){
            if(dist[e.v] > dist[e.u] + e.cost){
                dist[e.v] = dist[e.u] + e.cost;
                q.push(e.v);
            }
        }
    }
    for(int i = 0; i < Q;i++){
        ll x,y; cin >> x >> y;
        x--; y--;
        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 11520
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int sum=0;
  int m=-1;
  for(int i=0; i<3; i++){
    int x;
    cin >> x;
    sum += x;
    chmax(m,x);
  }
  if(m*3%2 == sum%2){
    cout << (m*3-sum)/2 << endl;
  }else{
    cout << ((m+1)*3-sum)/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=0;
    int l[26];
    for(int i=0;i<26;i++){
        l[i]=0;
    }
    for(int i=0;i<4;i++){
        char a;
        cin >>a;
        l[a-'A']++;
    }
    ans=0;
    for(int i=0;i<26;i++){
        if(l[i]==2)ans++;
    }
    
        if(ans==2)cout <<"Yes"<<endl;
        else cout <<"No"<<endl;


    return 0;

}

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

int n,m=0;
char s[102];
char x[26],y[26];

int main(){
  int i,j,c=0;
  cin >> n;
  for(i=0;i<n;i++)cin >> s[i];
  for(i=1;i<n;i++){
    c=0;
    for(j=0;j<26;j++){
      x[j]=0;
      y[j]=0;
    }
    for(j=0;j<n;j++){
      if(j<i)x[s[j]-'a']=1;
      else y[s[j]-'a']=1;
    }
    for(j=0;j<26;j++)if(x[j]==y[j]&&x[j]==1)c++;
    if(m<c)m=c;
  }
  

  cout <<m<< endl;

  return 0;
}


Measured memory_bytes: 256