akhauriyash/Code-Regression huggingface dataset:
//kunal_goyal
#include<bits/stdc++.h>

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
 
int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	//srand (time(NULL));
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
    
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int ans = 0;
    fors(tr, 0 , n+1){
		fors(tg, 0, n+1){
			int tb = n - tr*r - tg*g;
			if(tb>=0 and tb%b == 0) ans++;
		}
	}
    cout<<ans;
    return 0;
    
}


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

int main() {
    int n,k;
    string s,ans="";
    cin>>n>>k>>s;
    for(int i=0;i<n;i++)
    {
        if(k==i+1)
        {
            if(s[i]=='A')
                ans +='a';
            if(s[i]=='B')
                ans +='b';
                if(s[i]=='C')
                ans +='c';
        }
        else
        {
            ans +=s[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int[] array;
    static int n;
    static int[] a;
    static int[][] x;
    static int[][] y;
    static int ans = 0;
    
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        
        // array: 長さnのbit列
        array = new int[n];
        
        // 全探索する時のデータを取得
        a = new int[n];
        x = new int[n][n-1];
        y = new int[n][n-1];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            for (int j = 0; j < a[i]; j++) {
                x[i][j] = sc.nextInt()-1;
                y[i][j] = sc.nextInt();
            }
        }
        
        // arrayのパターンを全探索
        // ex.[1, 1, 1], [1, 1, 2], ... , [m, m, m]
        dfs(0, 0);
        
        // ans: costの最小値
        System.out.println(ans);
    }
    
    public static void dfs(int index, int now) {
        // 終了条件
        if (index == n) {
            // できあがったarrayで計算
            
            boolean ok = true;
            int count = 0;
            for (int i = 0; i < n; i++) {
                if (array[i] == 0) continue;
                count++;
                
                for (int j = 0; j < a[i]; j++) {
                    int num = x[i][j];
                    int state = y[i][j];
                    if (array[num] != state) ok = false;
                }
            }
            
            if (ok) {
                ans = Math.max(ans, count);
            }
            return;
        }
        
        // 次項の取る値: 0 or 1
        for (int i = 0; i < 2; i++) {
            array[index] = i;
            dfs(index + 1, i);
        }
    }
}

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

int main() {
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(abs(a-b) <= d && abs(b-c) <= d || abs(a-c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


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

int main(){
    int K;
    cin >> K;
    int i;
    int ans = 1;
    vector<int> modK(1000010);
    modK.at(0) = 0;

    for(i=1;i<=K;i++){
        modK.at(i) = (modK.at(i-1)*10+7)%K;
    }

    for(i=1;i<=K;i++){
        if(modK.at(i) == 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 6748
n,q = map(int,input().split())
lis1 = []
for i in range(n):
  lis1.append([])
for i in range(q):
  lis = list(map(int,input().split()))
  if lis[0] == 0:
    lis1[lis[1]].append(lis[2])
    
  elif lis[0] == 1 and len(lis1[lis[1]])>0:
    print(lis1[lis[1]][0])
  elif lis[0] == 2 and len(lis1[lis[1]])>0:
    del lis1[lis[1]][0]
  


Measured memory_bytes: 13696
#include <iostream>

using namespace std;

int main() {
    long long int x;
    cin >> x;
    
    if(x<=6) {
        cout << 1 << endl;
    } else if(x<=11) {
        cout << 2 << endl;
    } else {
        if(x%11==0) {
            cout << x*2/11 << endl;
        } else if(x%11<=6) {
            cout << (x/11)*2+1 << endl;
        } else {
            cout << (x/11)*2+2 << endl;
        }
    }


    return 0;
    
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine();
            var N = S.Length;
            var Mod = 2019L;
            var nums = new long[Mod];
            ++nums[0];
            var tP = 1L;
            var sum = 0L;
            for (var i = 0; i < N; ++i)
            {
                var n = S[N - 1 - i] - '0';
                sum = (sum + n * tP % Mod) % Mod;
                ++nums[sum];
                tP = tP * 10 % Mod;
            }
            var ans = 0L;
            foreach (var n in nums)
                ans += n * (n - 1) / 2;
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 26528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int a, b, c, d, e;
  string s, t;
  cin >> a >> b >> c;
  if(b * c >= a) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 3624
//Silk Road
#include <iostream>
#include <climits>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int D[N], C[M], Fatigue[N + 1][M - N + 1];
    for(int i = 0; i < N; i++) cin >> D[i];
    for(int i = 0; i < M; i++) cin >> C[i];

    for(int i = 0; i < N + 1; i++) {
        for(int j = 0; j < M - N + 1; j++) {
            Fatigue[i][j] = INT_MAX;
        }
    }
    Fatigue[0][0] = 0;


    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M - N + 1; j++) {
            if(j != M - N) Fatigue[i][j + 1] = min(Fatigue[i][j + 1], Fatigue[i][j]);
            Fatigue[i + 1][j] = min(Fatigue[i + 1][j], Fatigue[i][j] + D[i] * C[i + j]);
        }
    }

    int minf = INT_MAX;
    for(int j = 0; j < M - N + 1; j++) {
        minf = min(minf, Fatigue[N][j]);
    }

    cout << minf << endl;

    return 0;
}


Measured memory_bytes: 4088
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
long long
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	int liACnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liACnt);

	// 回数・合計 - 取得
	long long llOCnt = -1;
	long long llSum = 0;
	for (i = 0; i < liACnt; i++) {
		long long llNum, llDCnt;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%lld%lld", &llNum, &llDCnt);
		llOCnt += llDCnt;
		llSum += llNum * llDCnt;
	}

	// 回数 - 加算
	while (llSum >= 10) {
		long long llUCnt = llSum / 10;
		llOCnt += llUCnt;
		llSum -= llUCnt * 9;
	}

	return llOCnt;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// 出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

int main(){
    int N, color=1;
    string S;
    cin >> N >> S;
    for(int i=1; i<N; i++){
        if(S[i-1] != S[i]){
            color++;
        }
    }
    cout << color << endl;
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
vec v,sum;
mat dp;
ll solve(ll a,ll b){
  if(b==a+1)return 0;
  if(dp[a][b]!=inf)return dp[a][b];
  ll i,res=inf;
  For(i,a+1,b)chmin(res,solve(a,i)+solve(i,b));
  return dp[a][b]=res+sum[b]-sum[a];
}
int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans;
  cin>>N;
  v.resize(N);
  sum.resize(N+1,0);
  dp.resize(N,vec(N+1,inf));
  rep(i,N){
    cin>>v[i];
    sum[i+1]=v[i]+sum[i];
  }
  cout<<solve(0,N)<<endl;
  return 0;
}

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

int main(){
	int N,K;
	string S;
	cin >> N >> K >> S;
	
	vector<int> A;
	int c=1;
	for(int i=0;i<N;i++){
		if(i==N-1)A.push_back(c);
		else if(S[i]==S[i+1])c++;
		else{
			A.push_back(c);
			c=1;
		}
	}
	int M=A.size();
	K=min(2*K+1,M);
	
	int sum=accumulate(A.begin(),A.begin()+K,0);
	int maxsum=sum;
	int l=0;
	for(int i=K;i<M;i++){
		sum=sum+A[i]-A[i-K];
		if(sum>maxsum){
			maxsum=sum;
			l=i-K+1;
		}
	}
	int r=l+K;
	int ans=maxsum-1;
	for(int i=0;i<l;i++)ans+=A[i]-1;
	for(int i=r;i<M;i++)ans+=A[i]-1;
	cout << ans << endl;
	return 0;
}

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

int main(void) {
    int H,W;cin>>H>>W;
    for (int i = 0; i < H; i++) {
        string s;cin>>s;
        int cloud_pos = -1;
        for (int j = 0; j < W; j++) {
            char c = s[j];
            if (c == '.') {
                if (cloud_pos == -1) cout << -1;
                else {
                    cloud_pos++;
                    cout << cloud_pos;
                }
            } else {
                cloud_pos = 0;
                cout << 0;
            }
            if (j < W - 1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int A, B, ans=1;
    cin >> A >> B;
    int count = A;
    while(count < B){
        ans+=1;
        count = count + A -1;
    }
    if(B==1) ans=0;
    cout << ans << endl;

    return 0;
}


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

int main() {
  string b ;
  cin >> b ;
  
  for ( int i = 0 ; i < b.size() ; i++ ){
  	if ( b.at(i) =='A' )
      b.at(i) = 'T';
  	else if ( b.at(i) == 'C' )
      b.at(i) = 'G';
  	else if ( b.at(i) == 'G' )
      b.at(i) = 'C';
  	else if ( b.at(i) == 'T' )
      b.at(i) = 'A';
  }
  cout << b << endl;
}

Measured memory_bytes: 256
#!ruby -aplF,
g=$F.group_by &:to_i
s=g.size
m=g.map{|k,v|v.size}.max
k=g.keys.sort
$_=m>3?"four card":m>2?s>2?"three card":"full house":m>1?s>3?"one pair":"two pair":k[4]-k[0]<5||k[1]>9?:straight: :null

Measured memory_bytes: 6116
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint K;
  cin>>K;
  cout<<50<<endl;
  int i=0;
  for(i;i<50-K%50;i++){
    cout<<(lint)49+K/50-K%50;
    cout<<(i!=49?" ":"\n");
  }
  for(i;i<50;i++){
    cout<<(lint)100+K/50-K%50;
    cout<<(i!=49?" ":"\n");
  }
  return 0;
}


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

using namespace std;

int c[1410][1410];
int dp[1410];

int main(void) {
  int h, w;
  cin >> h >> w;

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

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (!i) {
        dp[j] = c[i][j] ? 0 : 1;
      } else {
        dp[j] = c[i][j] ? 0 : dp[j] + 1;
      }
    }

    vector<int> L(w), R(w);
    stack<int> st;
    for (int j = 0; j < w; j++) {
      while (!st.empty() && dp[st.top()] >= dp[j]) st.pop();
      L[j] = st.empty() ? 0 : st.top() + 1;
      st.push(j);
    }
    while (!st.empty()) st.pop();
    for (int j = w - 1; j >= 0; j--) {
      while (!st.empty() && dp[st.top()] >= dp[j]) st.pop();
      R[j] = st.empty() ? w : st.top();
      st.push(j);
    }

    for (int j = 0; j < w; j++) {
      ans = max(ans, dp[j] * (R[j] - L[j]));
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10720
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

ll dp[100][2];
int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    for(int i = 0;i<100;i++) {
        for(int j = 0;j<2;j++) {
            dp[i][j] = -1;
        }
    }
    dp[0][0] = 0;
    for(int i = 0;i<50;i++) {
        ll mask = 1LL <<(50-1-i);
        int cnt = 0;
        rep(i,n) if(a[i]&mask) cnt++;
        ll cost0 = mask*cnt;
        ll cost1 = mask*(n-cnt);
        // cout << cost0 << " " << cost1 << endl;
        if(dp[i][1] != -1) {
            chmax(dp[i+1][1],dp[i][1] + max(cost0,cost1));
        }
        if(dp[i][0] != -1) {
            if(k&mask) {
                chmax(dp[i+1][1],dp[i][0]+cost0);
            }
        }
        if(dp[i][0] != -1) {
            if(k & mask) chmax(dp[i+1][0],dp[i][0]+cost1);
            else chmax(dp[i+1][0],dp[i][0]+cost0);
        }
        // cout << dp[i][0] << " " << dp[i][1] << endl;
    }
    cout << max(dp[50][0],dp[50][1]) << endl;
}


Measured memory_bytes: 3964
import sys

def def1(s):
    
    if s[0] == s[1]:
        return True
    
    if len(s) == 2:
        return False
    
    return def1(s[1:])

def main():
    input = sys.stdin.readline
    S = input()
    
    print('Bad' if def1(S) else 'Good')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
<?php
  $n = trim(fgets(STDIN));
  $ans = 0;
  for ($i = 1; $i * $i <= $n; $i++) {
    $ama = $n % $i;
    if ($ama == 0) {
      $res = $n / $i;
      $tmp = ($res - 1) + ($i - 1);
      if ($ans == 0 || $tmp < $ans) {
        $ans = $tmp;
        continue;
      }
    }
  }
  echo $ans . PHP_EOL;


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

int main(int argc, char const *argv[])
{
  int N, A, B;
  int train, taxi;

  scanf("%d", &N);
  scanf("%d", &A);
  scanf("%d", &B);

  train = A * N;
  taxi = B;

  if (train < taxi)
  {
    printf("%d", train);
  }else
  {
    printf("%d", taxi);
  }
  
  
  return 0;
}



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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n; ++i)
    {
        int j = n - i;
        if (i >= j)
            break;
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
 int n;
  cin>>n;
  vl dp(n+1);
  rep(i,n+1)dp[i]=i;
  vl vec={6,36,216,1296,7776,46656,9,81,729,6561,59049};
  rep(j,vec.size()){
    rep(i,n+1){
      if(i>=vec[j])dp[i]=min(dp[i],dp[i-vec[j]]+1);
    }
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc119/tasks/abc119_b
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#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; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    int n;
    double d, sum = 0;
    string s;
    cin >> n;

    REP(i, n) {
        cin >> d >> s;
        if (s.compare("JPY") == 0) {
            sum += d;
        } else {
            sum += (d * 380000);
        }
    }
    printf("%.5f\n", sum);

    return 0;
}


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

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

  int a ,b ,c;
  cin >> a >> b >> c;

  if(b/a<=c)cout << b/a << endl;
  else cout << c << endl;

  return 0;
}

Measured memory_bytes: 3548
#include<stdio.h>

int main(void){

int n,i,ai,max,min;

double sum;


sum=0.0;


max=-1000000;


min=1000000;


scanf("%d",&n);

for(i=0;i<n;i++){

scanf("%d",&ai);

if(ai<min){


min=ai;


}


if(max<ai){


max=ai;


}


sum=sum+ai;


}


printf("%d %d %.0lf\n",min,max,sum);


return 0;


}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,S=0,m=0;cin>>N;int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
    S+=a[i];
    a[i]*=N;
  }
  for(int i=0;i<N;i++)a[i]=abs(a[i]-S);
  for(int i=1;i<N;i++){
    if(a[m]>a[i])m=i;
  }
  cout<<m<<endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}
ll n,k,r,s,p;
string x;

map<char,int>m;

int point[100100];

int main()
{
    weewoo;
    cin >> n >> k >> r >> s >> p;
    cin >> x;
    m['r']=p;
    m['s']=r;
    m['p']=s;
    for(int i=0;i<n;i++){
        if(i<k){
            point[i] = m[x[i]];
        }
        else{
            if(x[i]==x[i-k]){
                if(m[x[i]]>point[i-k]){
                    point[i-k]=0;
                    point[i] = m[x[i]];
                }
            }
            else{
                point[i] = m[x[i]];
            }
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=point[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
class DSJ {
public:
    int ngroups;
    vector<int> fa,sz;
    DSJ() {}
    DSJ(int _n) {
        ngroups = _n;
        fa = vector<int> (_n+1);
        sz = vector<int> (_n+1, 1);
        REP(i,0,_n) fa[i] = i;
    }
    int find(int x) {
        return x==fa[x] ? x : fa[x]=find(fa[x]);
    }
    int size(int x) {
        return sz[find(x)];
    }
    void con(int x,int y) {
        x = find(x);
        y = find(y);
        if (x==y) return;
        fa[x] = y;
        sz[y] += sz[x];
        ngroups--;
    }
    int groups() {
        return ngroups;
    }
};
int n,m,X[M],Y[M],Z[M];
DSJ dsj;
int main()
{
    while (~scanf("%d %d", &n,&m)) {
        dsj = DSJ(n);
        REP(i,1,m) scanf("%d %d %d",&X[i],&Y[i],&Z[i]);
        REP(i,1,m) {
            dsj.con(X[i], Y[i]);
        }

        printf("%d\n", dsj.groups());
    }
    return 0;
}


Measured memory_bytes: 2176
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=readline().strip()
    if n[-1]=="2" or n[-1]=="4" or n[-1]=="5" or n[-1]=="7" or n[-1]=="9":
        print("hon")
    elif n[-1]=="0" or n[-1]=="1" or n[-1]=="6" or n[-1]=="8":
        print("pon")
    else:
        print("bon")
if __name__=="__main__":
    main()

Measured memory_bytes: 9000
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef int64_t lint;
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

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

template<class T=int> T in(){
    T x;
    cin>>x;
    return (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 gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
//------------------------------------------------------------




//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    
    string s=in<string>();
  	Yes(s[0]=='7'||s[1]=='7'||s[2]=='7');
    
    
    
    
    
    
    
    
    
//------------------------------------------------------------
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 8;

int main(void){
    for(vs t(N);;){
        int l = N, r = 0, u = N, d = 0;
        rep(i, N){
            if(!(cin >> t[i])) return 0;
            
            rep(j, N) if(t[i][j] == '1')
                l = min(l, j), r = max(r, j), 
                u = min(u, i), d = max(d, i);
        }
        int w = r - l + 1, h = d - u + 1;

        cout << (w == 4 ? 'C':h == 4 ? 'B':w == 2 ? h == 2 ? 'A': t[u][l] == '1' ? 'F':'D': t[u][l] == '1' ? 'E':'G') << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer>
inline _typer read() {
	_typer init = 0;
	char ch = getchar(), k = 0;
	for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
	for ( ; isdigit(ch); ch = getchar()) init = (init << 3) + (init << 1) + (ch ^ 48);
	return k ? -init : init;
}
const ll N = 200005, INF = 1e9;

int n;
struct JOB {
	int ustime, endtime;
	bool operator < (const JOB &__) const {
		return endtime < __.endtime ||
			(endtime == __.endtime && ustime < __.ustime);
	}
} A[N];

int main() {
	n = read<int>();
	rep (i, 1, n) A[i].ustime = read<int>(), A[i].endtime = read<int>();
	sort(A + 1, A + n + 1);
	int curtime = A[n].endtime, cur = n;
	while (curtime >= 0 && cur) {
		if (curtime > A[cur].endtime) curtime = A[cur].endtime;
		curtime -= A[cur].ustime;
		--cur;
	}
	if (cur > 0 || curtime < 0) puts("No");
	else puts("Yes");
	return 0;
}



Measured memory_bytes: 1792
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
MOD = 10**9+7
# MOD = 998244353

a, b, c, k = map(int, input().split())
if k <= a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a - (k - a - b))



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

int main(void) {
  int N;
  cin >> N;
  int prev_x = 0, prev_y = 0, prev_t = 0;
  bool ok = true;
  for (int i = 0; i < N; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    int diff = (t - prev_t) - (abs(prev_x - x) + abs(prev_y - y));
    // cerr << diff << endl;
    if (diff >= 0 && diff % 2 == 0) {
      prev_x = x;
      prev_y = y;
      prev_t = t;
    } else {
      ok = false;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(b>=a) {
			System.out.println(a);
		}
		else {
			System.out.println(a-1);
		}
	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};

// const int C ;
// const int M = 1000000007;

int N;
int a[100010];
int ans[100010];
vector<int> V[100010];

int calc(int root) {
  if (ans[root] >= 0) return ans[root];
  if (V[root].empty()) {
    return ans[root] = 0;
  }
  vector<int> T;
  for (auto x : V[root]) {
    T.push_back(calc(x));
    // cerr << "calc(" << x << ") = " << calc(x) << endl;
  }
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());
  int M = T.size();
  for (auto i = 0; i < M; i++) {
    T[i] += i+1;
  }
  return ans[root] = *max_element(T.begin(), T.end());
}

int main () {
  cin >> N;
  a[0] = -1;
  for (auto i = 1; i < N; i++) {
    cin >> a[i];
    a[i]--;
    V[a[i]].push_back(i);
  }
  fill(ans, ans+N, -1);
  cout << calc(0) << endl;
}


Measured memory_bytes: 17408
import java.text.DecimalFormat;
import java.util.*;

public class Main {
    public static void main(String[] args)  throws java.io.IOException{
        Scanner sc = new Scanner(System.in);
        Double r = sc.nextDouble();
        sc.close();
        DecimalFormat df1 = new DecimalFormat("0.00000");
        System.out.println(df1.format(r*r*Math.PI) + " " + df1.format(2*r*Math.PI));
    }
}

Measured memory_bytes: 18564
#include<bits/stdc++.h>
int main(){
    long long _,a,b,c,d;
    std::cin>>a>>b>>_>>c>>d>>_>>_;
    long long ans=b+2*(a/2+c/2+d/2)+3*(a%2&&c%2&&d%2);
    if(a--&&c--&&d--){
        long long x=b+2*(a/2+c/2+d/2)+3;
        if(ans<x)ans=x;
    }
    std::cout<<ans<<std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll x;
    cin>>x;
    ll count=0;
    ll a=100;
    while(a<x){
        a*=1.01;
        count+=1;
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 3648
<?php
  $num = (int)fgets(STDIN);
$tmp = fgets(STDIN);
$str = explode(' ', $tmp);

$str1 = str_split($str[0]);
$str2 = str_split($str[1]);
$ans = '';

for($i=0; $i<$num; $i++){
	$ans .= $str1[$i]. $str2[$i];
}

echo $ans;


Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    double a, b, x;
    cin >> a >> b >> x;
    if (x * 2 < a * a * b) {
        x /= a;
        x *= 2;
        x /= b;
        cout << setprecision(13) << atan(b / x) / 3.141592653589793 * 180;
    } else {
        //y=x*2/a/a-b
        double y = x * 2 / a / a - b;
        cout << setprecision(13) << atan((b - y) / a) / 3.141592653589793 * 180;
    }
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
LL mod=1000000007;
LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};




int main(){
    int a,b;cin >> a >> b;
    cout << max(a-2*b,0) << endl;
    return 0;
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

const int mod = 1e9+7;

int n;

int main(){
    scanf("%d" , &n);
    n--;
    long long sm = 1ll * n * (n + 1ll) / 2;
    printf("%lld\n" , sm);
}

Measured memory_bytes: 256
N,M=map(x->parse(Int,x),split(readline()))
L=1
R=N
for i=1:M
	l,r=map(x->parse(Int,x),split(readline()))
	L=max(L,l)
	R=min(R,r)
end
if L<=R
	println(R-L+1)
else
	println(0)
end


Measured memory_bytes: 171236
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();

		int min = 1000;

		if(p+q < min) {
			min = p+q;
		}
		if(p+r < min) {
			min = p+r;
		}
		if(r+q < min) {
			min = r+q;
		}
		System.out.println(min);
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> upper(N);
  for (int i = 0; i < N; i++) cin >> upper.at(i);
  vector<int> lower(N);
  for (int i = 0; i < N; i++) cin >> lower.at(i);
  
  int max_sum = -1;
  for (int i = 1; i <= N; i++) {
    int upper_sum = 0;
    int lower_sum = 0;
    int sum = 0;
    for (int a = 0; a < i; a++) {
      upper_sum += upper.at(a);
    }
    for (int a = i - 1; a < N; a++) {
      lower_sum += lower.at(a);
    }
    sum = upper_sum + lower_sum;
    if (max_sum < sum) {
      max_sum = sum;
    }
  }
  cout << max_sum << endl;
}

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

#define MAX (1000000)

int main(void)
{
	char prime[MAX + 1];
	int n;
	char buf[256];
	
	memset(prime, 1, sizeof(prime));
	
	prime[0] = prime[1] = 0;
	for (int i = 2; i * i < MAX; i++){
		if (prime[i] == 1){
			for (int j = i * 2; j <= MAX; j += i){
				prime[j] = 0;
			}
		}
	}
	
	while (fgets(buf, 256, stdin) != NULL){
		int ans;
		
		n = atoi(buf);
		
		ans = 0;
		for (int i = 2; i <= n; i++){
			ans += prime[i];
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 0
H, W = map(int, input().split(' '))
maps = [list('.'+input()+'.') for _ in range(H)]
maps = [['.'] * (W+2)] + maps + [['.'] * (W+2)]

for i in range(1, H+1):
    for j in range(1, W+1):
        if maps[i][j] == '.':
            maps[i][j] = (maps[i-1][j-1:j+2] + maps[i][j-1:j+2] + maps[i+1][j-1:j+2]).count('#')
maps.pop(0)
maps.pop(H)
for i in maps:
    print(''.join(map(str, i[1:-1])))

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll k,a,b; cin >>k>>a>>b;
  if(b<=a+2){
    cout<<k+1<<endl;
    return 0;
  }
  ll sum=0;
  if((k-a)%2==0)sum=(k-a)/2*(b-a)+a+1;
  if((k-a)%2==1)sum=(k-a+1)/2*(b-a)+a;
  cout<<sum<<endl;
}

Measured memory_bytes: 3616
def main():
    a, b, m = map(int, input().split())
    
    # 冷蔵庫
    f_list = list(map(int, input().split()))
    # 電子レンジ
    m_list = list(map(int, input().split()))
    # 割引券
    t_list = [list(map(int, input().split())) for _ in range(m)]
    # 金額
    p_list = []
    
    
    p_list.append(min(f_list) + min(m_list))
    for t in t_list:
        p_list.append(f_list[t[0]-1] + m_list[t[1]-1] - t[2])
    
    ans = min(p_list)
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 42408
#include<stdio.h>
#include<string.h>

int array_num = 0;
int array[2000000];


int partition(int start_point, int end_point)
{
    int pivot = array[end_point];

    int small_edge = start_point;
    int large_edge = start_point;

    int swap = 0;


    for(; large_edge < end_point ; large_edge++) 
    {
        if(array[large_edge] < pivot)
        {
            swap = array[large_edge];
            array[large_edge] = array[small_edge];
            array[small_edge] = swap;

            small_edge++;

        }
    }

    swap = array[end_point];
    array[end_point] = array[small_edge];
    array[small_edge] = swap;

    return small_edge;
}

void quicksort(int start_point, int end_point)
{
    int pivot = partition(start_point, end_point);

    if(start_point < (pivot-1))
        {
            quicksort(start_point, (pivot-1));
        }

    if((pivot+1) < end_point)
        {
            quicksort((pivot+1), end_point);

        }

}

int main()
{
    int n, k, a = 0;

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

    for (int i = 0; i<n; i++)
    {
        scanf("%d", &array[i]);
    }

    array_num = n;

    quicksort(0, (array_num-1));

    for (int i = 0; i<k; i++)
    {
        a += array[i];
    }

    printf("%d", a);

    return 0;
}

Measured memory_bytes: 1724
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int INF = 1e9;
const double PI = acos(-1.0);

int t, n, k, a[N][5], dp[N][5];

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 3; ++j)
            cin >> a[i][j];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 3; ++j) {
            for (int l = 1; l <= 3; ++l) {
                if (j == l)
                    continue;
                dp[i][j] = max(dp[i][j], dp[i - 1][l] + a[i][j]);
            }
        }
    }
    cout << max({dp[n][1], dp[n][2], dp[n][3]});
}


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

int main()
{
    int k, x;
    while (cin >> k >> x) {
        k *= 500;
        if (x <= k) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
    }
    return 0;
}


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

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i=0;i<n;i++) cin >> x[i] >> y[i];
  bool odd = true;
  bool even = true;
  for (int i=0;i<n;i++) {
    if ((abs(x[i])+abs(y[i]))%2 == 0) {
      odd = false;
    }
    else {
      even = false;
    }
  } 
  if (!odd && !even) {
    cout << -1 << endl;
  } 
  else {
    vector<long long> arms(33,1);
    vector<long long> sums(33,0);
    if (odd) {
      for (int i=31;i>=0;i--) {
        arms[i] = arms[i+1]*2;
        sums[i] = sums[i+1]+arms[i+1];
      }
    }
    if (even) {
      sums[31] = 1;
      for (int i=30;i>=0;i--) {
        arms[i] = arms[i+1]*2;
        sums[i] = sums[i+1]+arms[i+1];
      } 
    } 
    cout << 33 << endl;
    for (int i=0;i<33;i++) {
      if (i != 0) cout << ' ';
      cout << arms[i];
    }
    cout << endl;
    vector<int> dx={0,1,0,-1};
    vector<int> dy={1,0,-1,0};
    vector<char> dir={'D','L','U','R'};
    for (int i=0;i<n;i++) {
      long long nx = x[i];
      long long ny = y[i];
      for (int j=0;j<33;j++) {
        for (int k=0;k<4;k++) {
          long long tox = nx+arms[j]*dx[k];
          long long toy = ny+arms[j]*dy[k];
          if(abs(tox)+abs(toy) <= sums[j]) {
            cout << dir[k];
            nx = tox;
            ny = toy;
            break;
          }
        }
      }
      cout << endl;
    }
  }
  
}

Measured memory_bytes: 3596
#■標準入力ショートカット

from collections import defaultdict


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N = get_next_int()
    ans = defaultdict(int)
    for i in range(N):
        key = input()
        ans[key] += 1
    M = get_next_int()
    for i in range(M):
        key = input()
        ans[key] -= 1
    max_val = max(ans.values())
    value = 0 if max_val < 0 else max_val
    print(value)


solve()

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b < c + d) {
    cout << "Right" << endl;
  }
  else if (a + b > c + d) {
    cout << "Left" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N,T; cin >> N >> T;
  vector<int> cost;
  for(int i=0;i<N;i++){
    int c,t; cin >> c >> t;
    if(t<=T) cost.push_back(c);
  }
  if(cost.empty()) cout << "TLE" << endl;
  else cout << *min_element(cost.begin(), cost.end()) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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); }

//-----CODE------//


void solve(void)
{
  int N,A,B;
  cin>>N>>A>>B;
  cout<<max(0LL,(N-1)*B + A - (N-1)*A - B + 1)<<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 256