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

int main()
{
  int n,i,j;
  string s;
  char c[10][5]={
    {},
    {'.',',','!','?',' '},
    {'a','b','c'},
    {'d','e','f'},
    {'g','h','i'},
    {'j','k','l'},
    {'m','n','o'},
    {'p','q','r','s'},
    {'t','u','v'},
    {'w','x','y','z'}
  };
  cin>>n;
  while(cin>>s){
    j=0;
    for(i=0;i<s.size();i++){
      if(s[i]!='0'){
	j++;
      }else{
	if(j)cout<<c[s[i-1]-'0'][(j-1)%(3+2*(s[i-1]=='1')+(s[i-1]=='7')+(s[i-1]=='9'))];
	j=0;
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define ui unsigned int 
using namespace std;

int main() {
	int s, h, m;
	cin >> s;
	h = s / 3600;
	s = s % 3600;
	m = s / 60;
	s = s % 60;
	cout << h << ":" << m << ":" << s << endl;
}



Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

vector<int> have(14, 0);

bool dfs(int left, int right, int turn, int myCnt, int yourCnt) {
	//cout << left << " " << right << " " << turn << " " << myCnt << " " << yourCnt << endl;
	if (myCnt == 6) return true;
	if (yourCnt == 6) return false;
	//if (left == 0 && right == 14) return (turn == 1) ? true : false;
	// turn = 0で自分の番
	bool win = false;
	if (turn == 0) {
		bool can = false;
		if (left != 0)
			if (have[left] == 1) {
				win = dfs(left - 1, right, 1 - turn, myCnt + 1, yourCnt);
				can = true;
			}
		if (win) return true;
		if (right != 14)
			if (have[right] == 1) {
				win = dfs(left, right + 1, 1 - turn, myCnt + 1, yourCnt);
				can = true;
			}
		if (!can) win = dfs(left, right, 1 - turn, myCnt, yourCnt);
	}
	else {
		bool can = false;
		win = true;
		if (left != 0)
			if (have[left] == 0) {
				win = dfs(left - 1, right, 1 - turn, myCnt, yourCnt + 1);
				can = true;
			}
		if (!win) return false;
		if (right != 14)
			if (have[right] == 0) {
				win = dfs(left, right + 1, 1 - turn ,myCnt, yourCnt + 1);
				can = true;
			}
		if (!can) win = dfs(left, right, 1 - turn, myCnt, yourCnt);
	}

	return win;
}

int main() {
	int n;
	cin >> n;
	vector<vector<int>> f(n, vector<int>(6));
	for(int j = 0; j < n; j++)
		for (int i = 0; i < 6; i++) cin >> f[j][i];

	for (int i = 0; i < n; i++) {
		// 相手のカードもわかる 6 + 6 + 1 = 13のため
		bool win = false;

		//sort(f.begin(), f.end());
		/*
		// 先手だから勝てる場合
		for (int j = 1; j <= 6; j++) {
			if (f[i][j - 1] != j) break;
			if (j == 6) {
				cout << "yes" << endl;
				win = true;
			}
		}
		for (int j = 8; j <= 13; j++) {
			if (f[i][j - 8] != j) break;
			if (j == 13) {
				cout << "yes" << endl;
				win = true;
			}
		}

		if (win) continue;
		*/

		for (int j = 1; j <= 13; j++) have[j] = 0;
		for (int j = 0; j < 6; j++) {
			have[f[i][j]] = 1;
		}
		win = dfs(6, 8, 0, 0, 0);

		if (win) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}


Measured memory_bytes: 3160
# すぬけくんは文字列 s の連続した一部分(部分文字列という)を
# 取り出して先頭が A であり末尾が Z であるような文字列を作ることにしました。
# すぬけくんが作ることのできる文字列の最大の長さを求めてください。
# なお，s には先頭が A であり末尾が Z であるような
# 部分文字列が必ず存在することが保証されます。

# 文字列を取得
s = gets.chomp

# 最初のAの位置と、最後のZの位置を格納する変数を宣言
start_position = 0
end_position = 0

# 最初のAの位置を特定
s.length.times do |i|
  if s[i] == "A"
    start_position = i
    break
  end
end

# 最後のZの位置を特定
(s.length - start_position).times do |i|
  if s[i + start_position] == "Z"
    end_position = i + start_position
  end
end

# 結果を出力
puts end_position - start_position + 1

Measured memory_bytes: 2172
/*input
FESTIVAL2016CODE
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
  char s[32];
  char r[] = "CODEFESTIVAL2016";
  scanf("%s",&s);
  int ans = 0;
  int n = strlen(s);
  for (int i = 0; i < n; ++i)
  {
    ans += r[i] != s[i];
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int N=1e5+10;
char a[N],b[N];
int n,m,x=1,f[N][26],sum,p[26];
long long ans;
int main()
{
	scanf("%s%s",a+1,b+1);
	n=strlen(a+1);
	m=strlen(b+1);
	for(int i=1;i<=n;i++)
	{
		a[i]-='a';
		p[a[i]]=1;
	}
	for(int i=1;i<=m;i++)
	{
		b[i]-='a';
		if(!p[b[i]])
		{
			puts("-1");
			return 0;
		}
	}
	for(int i=n;i;i--)
		for(int j=0;j<26;j++)
			if(a[i]==j)f[i-1][j]=i;
			else f[i-1][j]=f[i][j];
	while(x<=m)
	{
		sum=0;
		for(int i=f[0][b[x]];i<=n&&x<=m;i=f[i][b[x]])
		{
			if(!i)
			{
				if(x<=m)sum=n;
				break;
			}
			sum=i;
			x++;
			if(x>m||i==n)break;
		}
		ans+=sum;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

bool dpx[8000][3000];
bool dpy[8000][3000];

int main(){
    string S; cin>>S;
    vector<int> x,y;
    int X,Y; cin>>X>>Y;
    int muki=1;
    int i=0;
    int N=S.size();
    while(true){
        while(S.at(i)=='T'){i++; muki*=(-1); if(i==N) break;}
        if(i==N) break;
        int memory=i;
        while(S.at(i)=='F') {i++; if(i==N) break;}
        
        if(memory!=i){
            if(memory==0) X-=(i-memory);
            else if(muki==1) x.push_back(i-memory);
            else y.push_back(i-memory);
        }
        if(i==N) break;
    }



    int xsum=0, ysum=0;
    for(int i=0;i<x.size();i++) xsum+=x.at(i);
    for(int i=0;i<y.size();i++) ysum+=y.at(i);
    
    bool able=true;
    bool ans=false;
    if((xsum-X)%2 || (ysum-Y)%2) able=false;
    if(abs(X)>xsum || abs(Y)>ysum) able=false;
    dpx[0][0]=1;
    dpy[0][0]=1;

    int xx=(xsum-X)/2, yy=(ysum-Y)/2;
    if(able){
        bool Xable=false;
        if(xx==0) Xable=true;
        for(int i=0;i<x.size();i++){
            for(int j=0;j<8000;j++){
                if(dpx[j][i]){
                    dpx[j][i+1]=true; 
                    dpx[j+x.at(i)][i+1]=true;
                    if(j==xx || j+x.at(i)==xx) Xable=true;
                }
                if(Xable) break;
            }
            if(Xable) break;
        }

        if(Xable){
            if(yy==0) ans=true;
            for(int i=0;i<y.size();i++){
                for(int j=0;j<8000;j++){
                    if(dpy[j][i]){
                        dpy[j][i+1]=true; 
                        dpy[j+y.at(i)][i+1]=true;
                        if(j==yy || j+y.at(i)==yy) ans=true;
                    }
                if(ans) break;
                }
            if(ans) break;
        }
        }

    }

    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e2+5, M=1e5+5, oo=0x3f3f3f3f, mod = 1e9+7;

string s, s2;
int n, m, mem[3100][3100];

int solve(int i, int j){
   if(i == n || j == m) return 0;
   if(mem[i][j] != -1) return mem[i][j];
   if(s[i] == s2[j])
        return mem[i][j] = 1+solve(i+1, j+1);

   int op1= solve(i+1, j);
   int op2 = solve(i, j+1);
   return mem[i][j] = max(op1, op2);

}

void print(int i, int j){
   if(i == n || j == m) return;
   if(s[i] == s2[j]){
       cout << s[i];
        print(i+1, j+1);
        return;
   }
   int op1= solve(i+1, j);
   int op2 = solve(i, j+1);
   if(solve(i, j) == op1) print(i+1, j);
   else print(i, j+1);
 }


int main()
{
    _69e27
    memset(mem, -1, sizeof mem);
    cin >> s >> s2;
    n = s.size();
    m = s2.size();
    solve(0, 0);
    print(0, 0);
    // cout << ans;
    return 0;
}


Measured memory_bytes: 38144
#include<stdio.h>
int main(){
    int ans,h,m,s;
    while(scanf("%d",&ans)!=EOF){
        h=ans/3600;
        m=(ans-h*3600)/60;
        s=ans-3600*h-60*m;
        printf("%d:%d:%d\n",h,m,s);
    }
    return 0;
    
    
}


Measured memory_bytes: 2088
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
int main() {
	int n, m;
	cin >> m >> n;
	int sum = 0;
	for (int i = 0; i < m; i++) {
		int sum2 = 0, x;
		for (int j = 0; j < n; j++) {
			cin >> x;
			if (x == 1)sum2++;
		}
		sum = max(sum, sum2);
	}
	cout << sum << endl;
}

Measured memory_bytes: 3088
def happy():
  x = int(input())
  y = 0 
  z = 0
  
  if x >= 500:

    while x >= 500:
      x -= 500
      y += 1

      if 5 <= x <500:
        while x >= 5:
          x -= 5
          z +=1
        print(y *1000 +z *5)
        return

    print(y*1000)

  else:
    if x >= 5:
      while x >= 5:
        x -= 5
        z += 1
      print(z*5)

    else:
      print("0")

happy()

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

int main(){
  ll n,m;
  cin >> n>>m;
  vector<P> v(n);
  rep(i,n){
    cin>>v.at(i).first>>v.at(i).second;
  }
  sort(v.begin(),v.end());
  ll num=0,sum = 0,i=0;
  bool ok = true;
  while(ok){
    if (num+v.at(i).second<m){
      sum= sum+v.at(i).first * v.at(i).second;
      num+=v.at(i).second;
      i++;
    }
    else {
      while(num<m){
        sum+=v.at(i).first;
        num++;
      }
    }
    if (num == m){
      ok = false;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
h, w = [int(i) for i in input().split()]
a = []
a.append(['.'] * (w + 2))
for j in range(h):
    a.append(['.'] + list(input()) + ['.'])
a.append(['.'] * (w + 2))

for j in range(1, h + 1):
    for i in range(1, w + 1):
        if a[j][i] == '.':
            n = [
                a[j - 1][i - 1],
                a[j - 1][i],
                a[j - 1][i + 1],
                a[j][i - 1],
                a[j][i + 1],
                a[j + 1][i - 1],
                a[j + 1][i],
                a[j + 1][i + 1],
            ].count('#')
            print(n, end='')
        else:
            print('#', end='')
    print()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long int
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0){
    	return a;
	} 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
int dsu[1000001],s[100005];
void init(int n,int m){
	for(int i=1;i<=n;i++){
		dsu[i]=i;
		s[i]=1;
	}
}
int root(int x){
	while(dsu[x]!=x){
		x = dsu[x];
	}
	return x;
}
void uni(int x,int y){
	int p = root(x);
	int q = root(y);
	if(p==q){
		return;
	}
	else{
		if(s[p]<s[q]){
			s[q]+=s[p];
			dsu[p] = q;
		}
		else{
			s[p]+=s[q];
			dsu[q] = p;
		}
	}
}
int power(int x, unsigned int y)  
{  
    int res = 1;
    x = x ; 
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res);   
        y = y>>1;  
        x = (x*x);  
    }  
    return res;  
}
vector<int>graph[100001];
set<pair<int,int>>st;
char arr[1001][1001];
bool visit[1001][1001];
void dfs(int x,int y,int n,int m){
	st.erase({x,y});
	visit[x][y]=true;
	if(x<n-1 && arr[x+1][y]=='#' && !visit[x+1][y])dfs(x+1,y,n,m);
	if(x>0 && arr[x-1][y]=='#' && !visit[x-1][y])dfs(x-1,y,n,m);
	if(y<m-1 && arr[x][y+1]=='#' && !visit[x][y+1])dfs(x,y+1,n,m);
	if(y>0 && arr[x][y-1]=='#' && !visit[x][y-1])dfs(x,y-1,n,m);
}
signed main(){
	FAST
	int n,k;
	cin>>n>>k;
	int arr[n];
	int dp[k+1]={0};
	for(int i=0;i<n;i++){
		cin>>arr[i];
		dp[arr[i]]=1;
	}
	sort(arr,arr+n);
	for(int i=1;i<=k;i++){
		if(dp[i]==0){
			bool flag=false;
			for(int j=0;j<n;j++){
				if(i-arr[j]>0 && dp[i-arr[j]]!=1){
					dp[i]=1;
					flag=true;
				}
			}
			if(!flag)dp[i]=2;
		}
	}
	if(dp[k]==1)cout<<"First";
	else cout<<"Second";
}

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    int n, m; cin >> n >> m;
    v<int> h(n); rep(i,n) cin >> h[i];
    set<int> st; rep(i,n) st.insert(i+1);

    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (h[a] <= h[b] && st.count(a+1)) st.erase(st.find(a+1));

        if (h[a] >= h[b] && st.count(b+1)) st.erase(st.find(b+1));
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 8344
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    List<String> day = Arrays.asList("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT");
    System.out.println(7 - day.indexOf(s));
  }
}


Measured memory_bytes: 35612
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr;
            while (IsInput(out arr))
            {
                var n = arr[0]; //1 ～ nまで
                var x = arr[1]; //合計(target)

                var c = 0;

                for(var i = n; i >= 3; --i)
                {
                    for(var k = i - 1; k >= 2; --k)
                    {
                        var m = x - i - k;
                        if (m >= k) break;
                        if (m < 1) continue;
                        c++;
                    }
                }
                Console.WriteLine(c);
            }
        }

        private static bool IsInput(out int[] arr)
        {
            var s = Console.ReadLine();
            if (s == "0 0") { arr = null; return false; }

            arr = s.Split(' ').Select(int.Parse).ToArray();
            return true;
        }
    }
}


Measured memory_bytes: 18428
////**********CODED BY :- DURGESH KUMAR***************////
#include<bits/stdc++.h>
#define ff double
#define endl "\n"
#define M 1000000007
#define forever while(1)
#define ll long long
#define pb push_back
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define test ll t;cin>>t;while(t--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
using namespace std;
int main()
{

string str;
cin>>str;
if(str=="Sunny")
    cout<<"Cloudy"<<endl;
else if(str=="Cloudy")
    cout<<"Rainy"<<endl;
else if(str=="Rainy")
    cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef struct Card{
  char mark;
  int number;
} card;

int main(){
  int num,i,j,min,flag,check=0;
  card CA_1[36],CA_2[36],tmp;
  scanf("%d",&num);
  for(i=0;i<num;i++)scanf(" %c%d",&CA_1[i].mark,&CA_1[i].number);
  for(i=0;i<num;i++)CA_2[i]=CA_1[i];

  /*BubbleSort*/
  flag=1;
  while(flag){
    flag=0;
    for(j=num-1;j>=1;j--){
      if(CA_1[j].number<CA_1[j-1].number){
        tmp=CA_1[j];
        CA_1[j]=CA_1[j-1];
        CA_1[j-1]=tmp;
        flag=1;
      }
    }
  }

  /*BubblePrint*/
  for(i=0;i<num-1;i++)printf("%c%d ",CA_1[i].mark,CA_1[i].number);
  printf("%c%d\n",CA_1[i].mark,CA_1[i].number);
  puts("Stable");

  /*SelectionSort*/
  for(i=0;i<num-1;i++){
    min=i;
    for(j=i;j<num;j++){
      if(CA_2[j].number<CA_2[min].number){
        min=j;
      }
    }
    if(CA_2[i].number!=CA_2[min].number){
      tmp=CA_2[i];
      CA_2[i]=CA_2[min];
      CA_2[min]=tmp;
    }
  }

  /*SelectionPrint*/
  for(i=0;i<num-1;i++)printf("%c%d ",CA_2[i].mark,CA_2[i].number);
  printf("%c%d\n",CA_2[i].mark,CA_2[i].number);
  for(i=0;i<=num-1;i++){
    if(CA_2[i].number==CA_1[i].number&&CA_2[i].mark!=CA_1[i].mark){
      check=1;
    }
  }
  if(check==1)puts("Not stable");
  else puts("Stable");
  return 0;
}

Measured memory_bytes: 608
#include <iostream>

const int MAX   = 100;
const int INFTY = (1<<21);
const int WHITE = 0;
const int GRAY  = 1;
const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while (1) {
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > M[u][v]) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != -1) sum += M[i][p[i]];
    }

    return sum;
}

int main() {
    std::cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int e;
            std::cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }

    std::cout << prim() << std::endl;

    return 0;
}


Measured memory_bytes: 3116
using System;
using System.Linq;

namespace ABC158
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] A, B;
            A = new int[2] { (int)((ab[0] + 0.07) / 0.08), (int)((ab[0] + 1.07) / 0.08) };
            B = new int[2] { (int)((ab[1] + 0.09) / 0.1), (int)((ab[1] + 1.09) / 0.1) };
            int ans = -1;
            if (A[0] < B[0])
            {
                if (A[1] <= B[0]) { }
                else { ans = B[0]; }
            }
            else if (A[0] > B[0])
            {
                if (B[1] <= A[0]) { }
                else { ans = A[0]; }
            }
            else { ans = A[0]; }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
int main(void) {
    int a, b, c, x;
    int i, j, k;
    int ans=0;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&x);

    for(i=0;i<=a;i++){
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                if(500*i+100*j+50*k==x){
                    ans++;
                }
            }
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		int q = scanner.nextInt();
		for (int i = 0; i < q; i++) {
			String order = scanner.next();
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			if (order.equals("print")) {
				System.out.println(str.substring(a,b+1));
			}else if (order.equals("reverse")) {
				str = str.substring(0,a) + (new StringBuffer(str.substring(a,b+1)).reverse().toString()) + (str.substring(b+1,str.length()));
			}
			else if (order.equals("replace")) {
				String p = scanner.next();
				str = str.substring(0,a) + p + str.substring(b+1,str.length());
			}
		}
		
	}
}


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

int main() {
  string N;
  cin >> N;
  if(N[0] == N[1] && N[0] == N[2]) cout << "Yes";
  else if (N[1] == N[2] && N[1] == N[3]) cout << "Yes";
  else cout << "No";
}

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

using namespace std;

#define N 200200
#define PI acos(-1)

int a, b, c, d, n;

struct point {
    int x, y;
} points[N];

bool cmp(point a, point b) {
    return a.x < b.x;
}

int seg[4*N];

void update(int id, int ini, int fim, int pos, int val) {
    if (ini == fim) {
        seg[id] = val;
        return;
    }
    int meio = (ini + fim) / 2;

    if (pos <= meio) update(2*id, ini, meio, pos, val);
    else update(2*id+1, meio+1, fim, pos, val);

    seg[id] = max(seg[2*id], seg[2*id+1]);
}

int query(int id, int ini, int fim, int start, int end) {
    if (start > fim || end < ini)
        return 0;
    if (ini >= start && fim <= end)
        return seg[id];

    int meio = (ini + fim) / 2;

	return max(query(2*id, ini, meio, start, end), query(2*id+1, meio+1, fim, start, end));
}

set < int > diff;
map < int, int > ind, posx, posy;
int inv[N];

int main() {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &points[i].x, &points[i].y);
        posx[points[i].x] = points[i].y;
        posy[points[i].y] = points[i].x;
        diff.insert(points[i].y);
    }

    int cont = 2;
    for (set < int >::iterator it = diff.begin(); it != diff.end(); it++) {
        inv[cont] = *it;
        ind[*it] = cont++;
    }

    for (int i = 0; i < n; i++)
        points[i].y = ind[points[i].y];

    sort(points, points+n, cmp);

    long double ans = 0.0;

    if (a == c) {
        ans = abs(b - d);
        ans *= 100;

        if (posx.count(a) && posx[a] > min(b, d) && posx[a] < max(b, d)) {
            ans -= 20;
            ans += PI * 10;
        }
    }
    else if (b == d) {
        ans = abs(a - c);
        ans *= 100;

        if (posy.count(b) && posy[b] > min(a, c) && posy[b] < max(a, c)) {
            ans -= 20;
            ans += PI * 10;
        }
    }
    else if ((a-c < 0 && b-d < 0) || (a-c > 0 && b-d > 0)) {
        for (int i = 0; i < n; i++) {
            if (points[i].x < min(a, c) || points[i].x > max(a, c) || inv[points[i].y] < min(b, d) || inv[points[i].y] > max(b, d)) continue;
            int x = query(1, 1, N, 1, points[i].y);
            update(1, 1, N, points[i].y, x+1);
        }

        ans += abs(a - c);
        ans += abs(b - d);
        ans *= 100;
        ans -= 20 * query(1, 1, N, 1, N);
        ans += 10 * (PI / 2) * query(1, 1, N, 1, N);

        if (query(1, 1, N, 1, N) == min(abs(a-c), abs(b-d)) + 1)
            ans += 10 * (PI / 2);
    }
    else {
        for (int i = 0; i < n; i++) {
            if (points[i].x < min(a, c) || points[i].x > max(a, c) || inv[points[i].y] < min(b, d) || inv[points[i].y] > max(b, d)) continue;
            int x = query(1, 1, N, points[i].y, N);
            update(1, 1, N, points[i].y, x+1);
        }

        ans += abs(a - c);
        ans += abs(b - d);
        ans *= 100;
        ans -= 20 * query(1, 1, N, 1, N);
        ans += 10 * (PI / 2) * query(1, 1, N, 1, N);

        if (query(1, 1, N, 1, N) == min(abs(a-c), abs(b-d)) + 1)
            ans += 10 * (PI / 2);
    }

    printf("%.15Lf\n", ans);

    return 0;
}


Measured memory_bytes: 43264
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const long double pi = 3.14159265358979323846;



void solve() {
  ll n; cin >> n;
  ll a[n]; f0r(i, n) cin >> a[i];

  sort(a, a + n);

  ll ans = a[n - 1], cnt = n - 2;
  f0rd(i, n - 2) {
    ll v = min(2LL, cnt);
    ans += a[i] * v;
    cnt -= v;
  }

  cout << ans << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 5184
import numpy as np

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n, X = list(map(int, input().split()))
x = np.array(list(map(int, input().split())))

x = np.append(x, X)
x = np.sort(x)

d = np.diff(x)
h = d[-1]
for i in range(len(d)-1):
    h = gcd(h, d[i])

print(h)

Measured memory_bytes: 23056
module global_variables
end module global_variables
program main
  use global_variables
  implicit none
  integer i
  integer a(3)
  character(3) s
  read *, s
!  print '(a)', s
  do i=1,3
    read(s(i:i),*) a(i)
  enddo
  print '(i0)', sum(a)
end program main


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L W(L f){X[f]=n;S(f=H[f],O[f]=++b);f&&W(f);}
L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
  d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
     //for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;
       for(D(b=0);n<*Z;n++)!b|H[P[n]]-n&&W(n);//W(L f){X[f]=n;S(f=H[f],O[f]=++b);f&&W(f);}
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 38024
import itertools as ite
import math
import random

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

def func(diff, cnt9, cnt0):
    if cnt9 <= 0:
        return (diff == 0)
    num = int("9" * cnt9 + "0" * cnt0)
    return sum(func(diff + i * num, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1)) for i in range(-9, 10) if abs(diff + i * num) < num)

D = input()

ans = 0
for d in range(1, 21):
    ans += func(D, d, 0) * (10 - d % 2 * 9)
print ans


Measured memory_bytes: 2936
x, y, z, K = map(int, input().split())
a = sorted(list(map(int, input().split())))[::-1]
b = sorted(list(map(int, input().split())))[::-1]
c = sorted(list(map(int, input().split())))[::-1]

ans = []
for i in range(x):
    for j in range(y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            ans.append(a[i] + b[j] + c[k])
ans = sorted(ans)[::-1]
print(*ans[:K])


Measured memory_bytes: 16840
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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 all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;

int n;

void func(ll cur,int use,ll &count){
    if(cur>n)return;
    if(use==0b111)count++;
    func(10*cur+7,use|0b001,count);
    func(10*cur+5,use|0b010,count);
    func(10*cur+3,use|0b100,count);
}

int main(){
    cin>>n;
    ll ans=0;
    func(0,0,ans);
    cout<<ans<<endl;
}

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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << 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;
using P = pair<int,int>;
const int INF = 1000000000;
const int MOD = 1000000007;

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

int main() {
  int s, w;
  cin >> s >> w;
  if(s > w){
    cout << "safe" << endl;
  }
  else{
    cout << "unsafe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main() {
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)
		cout<<"Possible"<<endl;
	else
		cout<<"Impossible"<<endl;
	return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> S.at(i).at(j);
        }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int cnt=0;
            if(S.at(i).at(j)=='#'){
                cout << '#';
            }else{
                if(i!=0){
                    if(S.at(i-1).at(j)=='#'){
                        cnt++;
                    }
                    if(j!=W-1){
                        if(S.at(i-1).at(j+1)=='#'){
                            cnt++;
                        }
                    }
                    if(j!=0){
                       if(S.at(i-1).at(j-1)=='#'){
                            cnt++;
                        }
                    }
                }
                if(i!=H-1){
                    if(S.at(i+1).at(j)=='#'){
                    cnt++;
                    }
                    if(j!=0){
                        if(S.at(i+1).at(j-1)=='#'){
                            cnt++;
                        }
                    }
                    if(j!=W-1){
                        if(S.at(i+1).at(j+1)=='#'){
                            cnt++;
                        }
                    }
                }
                if(j!=0){
                    if(S.at(i).at(j-1)=='#'){
                        cnt++;
                    }
                }
                if(j!=W-1){
                    if(S.at(i).at(j+1)=='#'){
                        cnt++;
                    }
                }            
                cout << cnt;
            }
        }
        cout << endl;
    }
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

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

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    LL ans = x*a + y*b;

    for(LL i=0;i<=max(x, y);i++){
        ans = min(ans, i*2*c + a*max(0LL, x-i) + b*max(0LL, y-i));
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <climits>

using namespace std;

typedef signed long long ll;

int main(void)
{
    int N = 5;
    int count = 0;

    cin >> N;

    // int array[5] = {1,2,3,4,5};
    vector<int> A(N, 0);
    // vector<int> A(array, array + sizeof(array)/sizeof(array[0]));
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    for (int i = 0; i < N - 1; i++)
    {
        int minv = i;
        for (int j = i + 1; j < N; j++)
        {
            if (A[minv] > A[j])
            {
                minv = j;
            }
        }
        if (minv != i)
        {
            swap(A[minv], A[i]);
            count++;
        }
    }

    for (int i = 0; i < N; i++)
    {
        if (i > 0)
        {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string pos = "A";

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                if (input.Contains(pos))
                {
                    pos = input.Replace(pos, "").Trim(',');
                }
            }
            Console.WriteLine(pos);
        }
    }
}

Measured memory_bytes: 9672
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
sumA = sum(As)
sumB = sum(Bs)
D = sumA-sumB
if sumA < sumB:
    ans = -1
else:
    ans = 0
    ds = 0
    dif = [As[i]-Bs[i] for i in range(N)]
    dif.sort()
    for d in dif:
        if d < 0:
            ds += d
            ans += 1
        else:
            break
    for i in range(1, N+1):
        if ds < 0:
            ds += dif[-i]
            ans += 1
        else:
            break
print(ans)

Measured memory_bytes: 18356
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define all(x) x.begin(),x.end()
#define mod 1000000007

ll expo(ll a,ll b){ll r=1;a=a%mod;while(b){if(b%2)r=(r*a)%mod;a=(a*a)%mod;b=b/2;}
return r;}
struct greaterr
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};



/*vector<bool> sieve(10000007,true);

void help(){
     sieve[0] = false;
     sieve[1] = false;

     for(int i=2;i*i<=10000000;++i){
        if(sieve[i]){
            for(int j=i*i;j<=10000000;j+=i)
                sieve[j] = false;

        }
     }

}


ll exp(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}
*/
int main() {
   fastIO

   int a;
   string s;

   cin>>a>>s;

   if(a<3200)
    cout<<"red";
   else
    cout<<s;







	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int dp[4000][4000]={0};
  string s,t;
  cin >> s >> t;
  for(int i=0; i<s.size(); i++)
  {
    for(int j=0; j<t.size(); j++)
    {
      if(s[i] == t[j])
      {
        dp[i+1][j+1] = dp[i][j]+1;
      }
      else
      {
        dp[i+1][j+1] = max(dp[i+1][j],  dp[i][j+1]);
      }
    }
  }

  string ans = "";
  int i=s.size(), j=t.size();
  while(i>0 && j>0){
    if(dp[i][j] == dp[i-1][j])
    {
      i--;
    }
    else if(dp[i][j] == dp[i][j-1])
    {
      j--;
    }
    else if(dp[i][j] == dp[i-1][j-1]+1)
    {
      ans = s[i-1]+ans;
      i--;
      j--;
    }
  }
  cout << ans << endl;
}


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

int main(){
  int n;cin>>n;
  long long ans=0,ctn=1;
  
  vector<string> s(n);
  REP(i,n){
    cin>>s.at(i);  
    sort(s.at(i).begin(),s.at(i).end());
  }
  sort(s.begin(),s.end());
  
  for(int i=0;i<n-1;i++){
    if(s.at(i)==s.at(i+1)){
      ctn++;
      if(i==n-2) ans+=ctn*(ctn-1)/2;
    }else{
      ans+=ctn*(ctn-1)/2;
      ctn=1;
    }
  }
  
  cout<<ans;
}

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

int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    int a = 0;
    a = A-B;
    if(C >= a){
    cout<<C-a<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atCoder
{
    static class Class1
    {
        static Scanner sc = new Scanner();
        static void Main(string[] args)
        {
            var s = sc.ReadLine();
            if(4 <= s.Length && s.Substring(0, 4) == "YAKI")
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

public static class Extension
{
    public static IEnumerable<int> To(this int from, int to)
    {
        return Enumerable.Range(from, to);
    }

    public static void Times(this int times, Action<int> action)
    {
        0.To(times).ToList().ForEach(x => action(x));
    }
}

public class Scanner
{
    private string line;
    private string[] token;
    private int cursole = 0;

    public string ReadLine()
    {
        line = Console.ReadLine();
        token = line.Split(' ');
        cursole = 0;
        return line;
    }

    public string Next()
    {
        if (token == null) ReadLine();
        if (token.Length <= cursole) ReadLine();
        var ret = token[cursole];
        ++cursole;
        return ret;
    }

    public IEnumerable<double> NextDoubleList()
    {
        return NextList().Select(s => Double.Parse(s));
    }

    public int NextInt() { return Int32.Parse(Next()); }

    public long NextLong() { return Int64.Parse(Next()); }

    public double NextDouble() { return Double.Parse(Next()); }

    public IEnumerable<string> NextList()
    {
        ReadLine();
        cursole = Int32.MaxValue;
        return token;
    }

    public IEnumerable<int> NextIntList()
    {
        return NextList().Select(s => Int32.Parse(s));
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
using namespace std;
int a[100005];
int main(void)
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    cout << a[n/2]-a[n/2-1];
    return 0;
}


Measured memory_bytes: 640
group_A = [1,3,5,7,8,10,12]
group_B = [4,6,9,11]
group_C = [2]
x,y = map(int,input().split())
if(x in group_A):
    if(y in group_A):
        print("Yes")
    else:
        print("No")
elif(x in group_B):
    if(y in group_B):
        print("Yes")
    else:
        print("No")
else:
    if(y in group_C):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin >> x;
    if(x>=400&&x<=599)
        cout << 8 << endl;
    if(x>=600&&x<=799)
        cout << 7 << endl;
    if(x>=800&&x<=999)
        cout << 6 << endl;
    if(x>=1000&&x<=1199)
        cout << 5 << endl;
    if(x>=1200&&x<=1399)
        cout << 4 << endl;
    if(x>=1400&&x<=1599)
        cout << 3 << endl;
    if(x>=1600&&x<=1799)
        cout << 2 << endl;
    if(x>=1800&&x<=1999)
        cout << 1 << endl;
}


Measured memory_bytes: 3628
def main():
    h = int(input())
    a = list(map(int, input().split()))

    for i, j in enumerate(a, start=1):
        print('node {}: key = {}, '.format(i, j), end='')
        # 親条件
        if i // 2 >= 1:
            print('parent key = {}, '.format(a[i//2 -1]), end='')
        # 左子条件
        if i * 2 <= h:
            print('left key = {}, '.format(a[2*i - 1]), end='')
        if i * 2 + 1 <= h:
            print('right key = {}, '.format(a[2*i]), end='')
        print()
        
if __name__ == '__main__':
    main()


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

int main() {
  int n;
  while(cin >> n) {
    int cnt = 0;
    for(int a = 0; a < 10; a++) {
      for(int b = 0; b < 10; b++) {
        for(int c = 0; c < 10; c++) {
          for(int d = 0; d < 10; d++) {
            if(a+b+c+d == n) cnt++;
          }
        }
      }
    }

    cout << cnt << endl;
  }
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

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

using namespace std;
using ll = long long int;

const ll INF = 1LL<<60;
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; }

int main(void) {
    int a, b; cin >> a >> b;
    if (a - 2 * b < 0) cout << 0 << endl;
    else cout << a - 2 * b << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	a=~~input[0]
	b=~~input[1]
	console.log('%d',Math.max(a+b,a-b,a*b))

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

H, W = map(int, input().split())

a = [[0 for j in range(W)] for i in range(H)]
b = [[0 for j in range(W)] for i in range(H)]

SS = []

for i in range(H):
    S = input() + "#"
    j = 0
    while j < W:
        if S[j] == "#":
            a[i][j] = 0
            j += 1
        else:
            count = 0
            k = j
            while S[k] == ".":
                count += 1
                k += 1
            for l in range(count):
                a[i][j+l] = count
            j = j + count
    SS.append(S)

SS.append("#"*(W+1))

for j in range(W):
    i = 0
    while i < H:
        if SS[i][j] == "#":
            b[i][j] = 0
            i += 1
        else:
            count = 0
            k = i
            while SS[k][j] == ".":
                count += 1
                k += 1
            for l in range(count):
                b[i+l][j] = count
            i = i + count

ans = 0
for i in range(H):
    for j in range(W):
        if ans < a[i][j] + b[i][j]:
            ans = a[i][j] + b[i][j]
print(ans-1)









Measured memory_bytes: 150072
def main():
    n,k=map(int,input().split())
    mod=10**9+7

    import numpy as np
    def prepare(n):
        nrt = int(n ** 0.5) + 1
        nsq = nrt * nrt
        facts = np.arange(nsq, dtype=np.int64).reshape(nrt, nrt)
        facts[0, 0] = 1
        for i in range(1, nrt):
            facts[:, i] = facts[:, i] * facts[:, i - 1] % mod
        for i in range(1, nrt):
            facts[i] = facts[i] * facts[i - 1, -1] % mod
        facts = facts.ravel().tolist()
 
        invs = np.arange(1, nsq + 1, dtype=np.int64).reshape(nrt, nrt)
        invs[-1, -1] = pow(facts[-1], mod - 2, mod)
        for i in range(nrt - 2, -1, -1):
            invs[:, i] = invs[:, i] * invs[:, i + 1] % mod
        for i in range(nrt - 2, -1, -1):
            invs[i] = invs[i] * invs[i + 1, 0] % mod
        invs = invs.ravel().tolist()
 
        return facts, invs

    facts,invs=prepare(3*n)
    
    def nck(n,k):
        if k<0 or k>n:
            return 0
        else:
            return facts[n]*invs[n-k]*invs[k]%mod

    if k>=n-1:
        print(nck(2*n-1,n-1))
        exit()
    
    else:
        ans=0
        for i in range(k+1):
            ans+=nck(n,i)*nck(n-1,i)
            ans%=mod
        print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 64264
n,k=map(int,input().split())
r,s,p=map(int,input().split())
d={}
d["r"]=p
d["s"]=r
d["p"]=s
t=input()
ans=0

l=[0]*n

for i in range(n):
    if i>=k:
        if t[i]==t[i-k]:
            if l[i-k]:
                ans+=d[t[i]]
            else:
                l[i]=1
        else:
            ans+=d[t[i]]
    else:
        ans+=d[t[i]]
print(ans)


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

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

	int N = s.size();
	int c[N];
	for (int i = 0; i <  N; i++) {
		c[i] = (int)(s.at(i) - '0' );
	}
	
	if (c[0] + c[1] + c[2] + c[3] == 7) cout << c[0] << '+' << c[1] << '+' << c[2] << '+' << c[3] << "=7" << endl;
	else if (c[0] + c[1] + c[2] - c[3] == 7) cout << c[0] << '+' << c[1] << '+' << c[2] << '-' << c[3] << "=7" << endl;
	else if (c[0] + c[1] - c[2] + c[3] == 7) cout << c[0] << '+' << c[1] << '-' << c[2] << '+' << c[3] << "=7" << endl;
	else if (c[0] - c[1] + c[2] + c[3] == 7) cout << c[0] << '-' << c[1] << '+' << c[2] << '+' << c[3] << "=7" << endl;
	else if (c[0] + c[1] - c[2] - c[3] == 7) cout << c[0] << '+' << c[1] << '-' << c[2] << '-' << c[3] << "=7" << endl;
	else if (c[0] - c[1] - c[2] + c[3] == 7) cout << c[0] << '-' << c[1] << '-' << c[2] << '+' << c[3] << "=7" << endl;
	else if (c[0] - c[1] + c[2] - c[3] == 7) cout << c[0] << '-' << c[1] << '+' << c[2] << '-' << c[3] << "=7" << endl;
	else if (c[0] - c[1] - c[2] - c[3] == 7) cout << c[0] << '-' << c[1] << '-' << c[2] << '-' << c[3] << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
#encoding:utf-8 No.0521 2014.11.11
while (price = gets.chomp.to_i) != 0
  change = 1000 - price
  count = 0
  coins = [500,100,50,10,5,1]
  coins.each do |coin|
    count += change/coin
    change = change%coin
  end
  puts count
end

Measured memory_bytes: 6088
import sys
A, B, K = map(int, input().split())
cnt = 0
if min(A, B) == 1:
    print(1)
    sys.exit()
    
for i in range(min(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        cnt += 1
        if cnt == K:
            print(i)
            break

Measured memory_bytes: 3060