akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(1 << n), first(1 << n), second(1 << n, -1);
	for (int i = 0; i < 1 << n; ++i) {
		cin >> a[i];
		first[i] = i;
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 1 << n; ++j) {
			if ((j >> i) & 1) {
				int k = j - (1 << i);
				if (a[first[j]] < a[first[k]]) {
					second[j] = (a[first[j]] < (second[k] != -1 ? a[second[k]] : -1) ? second[k] : first[j]);
					first[j] = first[k];
				}
				else if (a[first[k]] > (second[j] != -1 ? a[second[j]] : -1)) {
					second[j] = first[k];
				}
			}
		}
	}
	int ret = 0;
	for (int i = 1; i < 1 << n; ++i) {
		ret = max(ret, a[first[i]] + a[second[i]]);
		cout << ret << '\n';
	}
	return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

int gcd(int a,int b){
	if(!(a % b)) return b;
	return gcd(b,a % b);
}

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

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	nongetpop(array,&(*size));
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	int n;
	int *l,*r;
	int ans = 0;
	scanf("%d",&n);
	l = (int *)malloc(sizeof(int) * n);
	r = (int *)malloc(sizeof(int) * n);
	for (int i = 0; i < n; ++i)
	{
		scanf(" %d%d",&l[i],&r[i]);
		ans += (r[i] - l[i] + 1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N ;
  cin >> N;
  vector<string> w(N);
  for(int i= 0; i<N; i++){
    cin >> w.at(i);
  }
  for(int i = 0; i<N-1; i++){
    for(int j= i+1; j<N; j++){
      if(w.at(i) == w.at(j)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  for(int i = 0; i< N-1; i++){
    string w_1, w_2;
    w_1 = w.at(i);
    w_2 = w.at(i+1);
    if(w_1.at(w_1.size()-1) != w_2.at(0)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
}


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

bool isPow_of_2(int n){
    if(n==1)    return true;

    if(n%2==0)  return isPow_of_2(n/2);
    else   return false;
}

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

    if(n==1){
        cout << 1 << endl;
        return 0;
    }

    for(int i=n;i>=0;i--){
        if(isPow_of_2(i)){
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3112
#include<iostream>

using namespace std;

int main(){
  int r=0, d=0, x2000=0, xo=0;

  cin >> r >> d >> x2000;

  xo=x2000;
  for(int i=1;i<=10;i++){
    xo = r*xo - d;
    cout << xo << endl;
  }

  return 0;
}


Measured memory_bytes: 256
s=input()
flag=0
if len(s)==2:
    if s[0]==s[1]:
        print('1 2')
    else:
        print('-1 -1')
else:
    for i in range(len(s)-2):
        if s[i]==s[i+1] and s[i+1]==s[i+2] and s[i]==s[i+2]:
            continue
        else:
            if s[i]==s[i+1] or s[i+1]==s[i+2] or s[i]==s[i+2]:
                print(i+1,i+3,sep=' ')
                flag=1
                break
    if flag==0:
        print('-1 -1')
            
    

                


Measured memory_bytes: 3188
#ABC042C

S=input()
#[start:stop:step] stepに負数を指定すると末尾からのスライスになる
S=S[::-1]
s1="maerd"
s2="remaerd"
s3="esare"
s4="resare"
i=0

while i<len(S):
    if S[i:i+5] == s1 or S[i:i+5] == s3:
        i+=5
    elif S[i:i+6] == s4:
        i+=6
    elif S[i:i+7] ==s2:
        i+=7
    else:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 3188
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

LL w, h, n, posi[101010], posj[101010];
vector<LL> ilist, jlist, icouho, jcouho;


int main() {
	cin >> w >> h >> n;
	for (int i = 0; i < n; i++) {
		cin >> posi[i] >> posj[i];
		ilist.emplace_back(posi[i]);
		jlist.emplace_back(posj[i]);
	}
	sort(ALL(ilist));
	sort(ALL(jlist));
	//UNIQ(ilist);
	//UNIQ(jlist);
	if (jlist.size() % 2 == 1) {
		jcouho.emplace_back(jlist[jlist.size() / 2]);
	}
	else {
		jcouho.emplace_back(jlist[jlist.size() / 2]);
		jcouho.emplace_back(jlist[jlist.size() / 2 - 1]);
	}

	if (ilist.size() % 2 == 1) {
		icouho.emplace_back(ilist[ilist.size() / 2]);
	}
	else {
		icouho.emplace_back(ilist[ilist.size() / 2]);
		icouho.emplace_back(ilist[ilist.size() / 2 - 1]);
	}
	sort(ALL(icouho));
	sort(ALL(jcouho));
	LL ans = LINF;
	LL ansmidi, ansmidj;
	for (int i = 0; i < icouho.size(); i++) {
		for (int j = 0; j < jcouho.size(); j++) {
			LL maxd = 0;
			LL midi = icouho[i], midj = jcouho[j];
			//cout << midi<<" " << midj<<endl;
			LL sum = 0;
			for (int k = 0; k < n; k++) {
				sum += (abs(midi - posi[k]) + abs(midj - posj[k])) * 2;
				maxd = max(maxd, abs(midi - posi[k]) + abs(midj - posj[k]));
			}
			sum -= maxd;
			if (ans > sum) {
				ans = sum;
				ansmidi = midi, ansmidj = midj;
			}
		}
	}
	cout << ans << endl;
	cout << ansmidi << " " << ansmidj << endl;
	//system("pause");
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
//author wjl

using namespace std;
#define LL long long
#define Rint register int
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define pii pair<int ,int>
#define MS0(X) memset(X,0,sizeof(X))
#define MSf(X) memset(X,false,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define BR printf("--------------------\n")
#define pb push_back
#define rep(i,a,b) for(Rint i=a;i<=b;++i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dirx[8]={1,0,-1,0,1,-1,-1,1};
int diry[8]={0,1,0,-1,1,1,-1,-1};
int n,t;
struct node
{
    int a,b;
}st[maxn];
bool cmp(node a,node b)
{
    return a.a<b.a;
}
int dp[3005][6005];
int mx[3005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>t;
    for(int i=1;i<=n;i++)
    {
        cin>>st[i].a>>st[i].b;
    }
    sort(st+1,st+n+1,cmp);
    for(int i=n;i>=1;i--)
    {
        mx[i]=max(mx[i+1],st[i].b);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=t+st[i].a-1;j>=st[i].a;--j)
        {
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-st[i].a]+st[i].b);
            ans=max(ans,dp[i][j]);
        }
        for(int j=st[i].a-1;j>=0;--j)
        {
            dp[i][j]=dp[i-1][j];
            ans=max(ans,dp[i][j]);
        }
        /*for(int j=t-1;j>=0;j--)
        {
            dp[i][j]=dp[i-1][j];
            if(j>=st[i].a)
                dp[i][j]=max(dp[i][j],dp[i-1][j-st[i].a]+st[i].b);
        }
        ans=max(ans,dp[i][t-1]+mx[i+1]);*/
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 71936
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
int a=0,b=-1,c=0,d=0;
std::cin >> x>>y;

std::cout << x+y/2 << '\n';
}


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

int main() {
    string S; cin >> S;
    int cnt = 0;
    if (S.at(0) != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    for (int i = 1; i < S.size(); i++) {
        if (S.at(i) > 96) continue;
        else if (i >= 2 && i <= S.size() - 2) {
            if (S.at(i) == 'C') cnt++;
        } else {
            cout << "WA" << endl;
            return 0;
        }
    }
    if (cnt == 1) {
        cout << "AC" << endl;
    } else cout << "WA" << endl;
}

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

int main(){
  ll n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  a--,b--,c--,d--;
  string s;
  cin >> s;
  bool flag=false;
  bool flag2=true;
  int temp=a,temp2=b;
  for(int i=a;i<=c-1;i++){
    if(s[i]=='#' && s[i+1]=='#'){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=b;i<=d-1;i++){
    if(s[i]=='#' && s[i+1]=='#'){
      cout << "No" << endl;
      return 0;
    }
  }
  if(c<d)flag=true;
  for(int i=max((ll)0,b-1);i<=min(d-1,n-3);i++){
    if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
      flag=true;
    }
  }
  if(!flag){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
return 0;}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n,i,j,k;
  long flag=1;
  char s[301][301];
  long cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s[i]);
  }
  for(i=0;i<n;i++){
    flag=1;
    for(j=0;j<n-1;j++){
      for(k=j+1;k<n;k++){
        if(s[(i+j)%n][k]!=s[(i+k)%n][j]) flag=0;
      }
    }
    cnt+=(long)flag*n;
  }
  printf("%ld\n",cnt);
}

Measured memory_bytes: 256
import math

def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    A = read_ints()
    assignment_days = sum(A)
    return -1 if assignment_days > N else N-assignment_days


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 9892
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI 3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007

map<string, int> m;



int main()
{
	FAST;
	ll n;
	cin >> n;
	string s;
	cin >> s;
	for(ll i = 0; i < s.size(); i ++){
		s[i] += n;
		if(s[i] > 90){
			s[i] = 64 + (s[i] - 90);
		}
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3552
H, W= map(int, raw_input().split())
array = []
for i in range(H):
    array.append(list(raw_input()))


left = 0
possible = True
for i in range(H):
    for j in range(W):
        if array[i][j] == "#":
            if j < left:
                possible = False
                break
            if j > left:
                left = j

if possible:
    print "Possible"
else:
    print "Impossible"
    


Measured memory_bytes: 2568
//https://atcoder.jp/contests/dp/tasks/dp_d
//shauryakr
#include<bits/stdc++.h>
using namespace std;
long long int n, W, profit[110], we[110];
long long int dp[110][100005];
long long int solve(int ind, int w)
{
    if(ind == n)
        return 0;
    if(dp[ind][w] != -1)
        return dp[ind][w];
    long long int ans = solve(ind+1, w);
    if(we[ind] <= w)
    {
        ans = max(ans, solve(ind+1, w-we[ind]) + profit[ind]);
    }
    dp[ind][w] = ans;
    return ans;
}
int main()
{
    cin >> n >> W;
    for(int i=0; i<n; i++)
    {
        cin >> we[i] >> profit[i];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, W) << endl;
    return 0;
}

Measured memory_bytes: 86144
/* ----------------------- reclone_rk --------------------------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define prq priority_queue<int>
#define prqp priority_queue<pair<int,int>>
#define vtr vector<int>
#define INF INT_MAX
#define NINF INT_MIN
#define endl "\n"
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pvtr vector<pair<int,int>>
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

const double pi = 3.14159265358979323846;
signed main()
{   
    string s;
    cin>>s;
   	// string ans = "";
   	stack<char>ans;
   	for(int i=0; i<s.length(); i++)
   	{
   		if(s[i] != 'B')
   		{
   			ans.push(s[i]);
   		}
   		else
   		{
   			if(ans.size() > 0)
   				ans.pop();
   		}
   	}
   	string as = "";
   	while(ans.size() > 0)
   	{
   		as += ans.top();
   		ans.pop();
   	}
   	reverse(as.begin(), as.end());
   	cout<<as<<endl;
   	// for(auto it = ans.begin(); it != ans.end(); it++)
   		// cout<<(*it);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll ans,n;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
		if(i%3!=0&&i%5!=0)
			ans+=ll(i);
	printf("%lld",ans);
	return 0; 
}

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

namespace 練習１
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            if (S.Contains("AA"))
            {
                if (S.Contains("AAA"))
                {
                    Console.WriteLine("No");
                }
                else
                {
                    Console.WriteLine("Yes");
                }
            }
            else if (S.Contains("BB"))
            {
                if (S.Contains("BBB"))
                {
                    Console.WriteLine("No");
                }
                else
                {
                    Console.WriteLine("Yes");
                }
            }
            else if (S.Contains("ABA"))
            {
                Console.WriteLine("Yes");
            }
            else if (S.Contains("BAB"))
            {
                Console.WriteLine("Yes");
            }
        }
    }
}


Measured memory_bytes: 11092
def main():
    a, b = scan()
    print(0 if a < 2 * b else a - 2 * b)
    

def iread():
    return int(input())


def sread():
    return input()


def aread(t="int"):
    if t == "int":
        ret = [int(i) for i in input().split()]
    elif t == "str":
        ret = list(input().split())
    return ret


def scan():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))


#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321

#define MAXN 100500
int N,M,K,Q,T;

vector<int> v[26];
int r[200500];
int dp[200500];
char p[200500];
int nxt[200500];
int main(void){
	string s; cin >> s;
	for(int i=0;i<s.size();i++) v[s[i]-'a'].push_back(i);
	int n = sz(s);
	for(int i=0;i<n;i++){
		int mx = -1;
		rep(j,26)if( j != (s[i]-'a') ){
			auto it = lower_bound(all(v[j]),i+1);
			if( it == v[j].end() ){
				mx = INF;
				break;
			}
			mx = max(mx, *it);
		}

		r[i] = mx;
	//	printf("%d %d\n",i,r[i]);
	}
	dp[n] = 1;
	p[n] = 'a';
	nxt[n] = -1;
	for(int i=n-1;i>=0;i--){
		if( r[i] == INF ){
			dp[i] = 1;
			nxt[i] = -1;
			rep(j,26){
				auto low = lower_bound(all(v[j]), i);
				if( low == v[j].end() ){
					p[i] = 'a'+j;
					break;
				}
			}
			continue;
		}
		dp[i] = INF;
		rep(j,26){
			auto low = lower_bound(all(v[j]), i);
			int pos = *low;
			if( dp[i] > dp[pos+1]+1 ){
				dp[i] = dp[pos+1]+1;
				p[i] = j+'a';
				nxt[i] = pos+1;
			}
		}
	}
	int pos = 0;
	while( pos != -1 ){
		printf("%c",p[pos]);
		pos = nxt[pos];
	}

}

Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main()
{
  int N;
  cin >> N;

  vector<int> num(N,0);
  for (int i = 0; i < N - 1; ++i)
  {
    int j;
    cin >> j;
    ++num[j-1];
  }
  for (int i = 0; i < N; ++i) cout << num[i] << endl;
}

Measured memory_bytes: 4040
#include<stdio.h>
int main(){
	int H,W;
	int i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0) break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++)printf("#");
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2052
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
//function myout(t){print(t);}//standard output
function myout(t){console.log(t);}//standard output
function myerr(t){console.err(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
 
function Main(input) {
  input = myconv(input,3);
  var a = input[0];
  var b = input[1];
  if(a == b){
     myout("EQUAL");
     }else if(a.length > b.length){
     myout("GREATER");
  }else if(a.length < b.length){
           myout("LESS");
	}else{
     for(var i = 0; i < a.length; i++){
       var da = myconv(a.slice(i,i+1),1);
       var db = myconv(b.slice(i,i+1),1);
       if(da > db){
          myout("GREATER");
         return;
          }else if(da < db){
         myout("LESS");
            return;
       }
     }
	}
}
 
Main(myin());

Measured memory_bytes: 7372
takahashi_hp, takahashi_attack, aoki_hp , aoki_attack = gets.split.map(&:to_i)


loop do
  (aoki_hp -= takahashi_attack)
  if aoki_hp <= 0
    puts "Yes"
    break
  end
  (takahashi_hp -= aoki_attack)
  if takahashi_hp <= 0
    puts "No"
    break
  end
end

Measured memory_bytes: 14344
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1)
            q = 2 ** max(0, n - j - 1)
            ans += x * p * q

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define N 100009
#define ll long long
#define mod 1000000007

string s[1009];
ll dp[1009][1009];
int n, m;

ll solve(int i, int j)
{
    if(i == n - 1&& j == m - 1) return 1;
    if(i == n || j == m) return 0;
    if(s[i][j] == '#') return 0;
    if(dp[i][j] != -1) return dp[i][j];
    ll ans = 0;
    if(i < n) ans += solve(i + 1, j);
    if(j < m) ans += solve(i, j + 1);
    //cout<< i << " " << j << endl;
    return dp[i][j] = ans % mod;
}

int main()
{
    memset(dp, -1, sizeof(dp));
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> s[i];
    cout << solve(0, 0) << endl;
}





Measured memory_bytes: 9344
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

int main() {
  ll n, r;
  scanf("%lld %lld", &n, &r);

  if (n >= 10) {
    cout << r << endl;
  } else {
    // r = h - 100 * (10-k)
    ll v = r + 100 * (10 - n);
    cout << v << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <limits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define REP(i,b,n) for(i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

int main()
{
	double w;
	
	while(cin >> w, !cin.eof())
	{
		if( w <= 48.00 )
			cout << "light fly" << endl;
		else if( w <= 51.00 )
			cout << "fly" << endl;
		else if( w <= 54.00 )
			cout << "bantam" << endl;
		else if( w <= 57.00 )
			cout << "feather" << endl;
		else if( w <= 60.00 )
			cout << "light" << endl;
		else if( w <= 64.00 )
			cout << "light welter" << endl;
		else if( w <= 69.00 )
			cout << "welter" << endl;
		else if( w <= 75.00 )
			cout << "light middle" << endl;
		else if( w <= 81.00 )
			cout << "middle" << endl;
		else if( w <= 91.00 )
			cout << "light heavy" << endl;
		else
			cout << "heavy" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	double d;
	int n, b;
	cin >> d >> n >> b;
	vector<pair<double, double>> obs(n);
	REP(i, n){
		cin >> obs[i].first >> obs[i].second;
	}
	double ans=1e8;
	REP(i,b+1){
		double ma=0.0;
		REP(j,n){
			double x = obs[j].first;
			double y = obs[j].second;
			while (x>d/(i+1)){
				x -= d / (i + 1);
			}
			

			double a = -(x*x) + d / (i + 1)*x;
			if (x > 0.0){
				if ((a / (2 * y) < (d / (i + 1))*(d / (i + 1))*y / (2 * a)))
					ma = max(ma, sqrt((a / (2 * y) + (d / (i + 1))*(d / (i + 1))*y / (2 * a))));
				else
					ma = max(ma,sqrt(d / (i + 1)));
			}
		}
		ans = min(ans, ma);
	}

		printf("%.5lf\n", ans);
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/09  Problem: ABC 121 C / Link: http://abc121.contest.atcoder.jp/tasks/abc121_c  ----- */


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


	LL N, M; cin >> N >> M;
	vector<LL> a(N), b(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i] >> b[i];
	}

	VI id(N, 0);
	iota(ALL(id), 0);
	sort(ALL(id), [&](int i,int j) {
		return a[i] < a[j];
	}
	);
	LL ans = 0LL;
	for (int i : id) {
		if (M > 0) {
			ans += a[i] * min(M, b[i]);
			M -= min(M, b[i]);
		}
	}


	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int abd = abs(a-b);
    int bcd = abs(b-c);
    int acd = abs(a-c);
    if(d >= acd){
        cout << "Yes" << endl;
        return 0;
    }
    if(d >= abd && d >= bcd){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3664
S = int(input())


def main():
    result = 0
    dp = [0 for _ in range(max(S+1, 7))]
    dp[3] = 1
    dp[4] = 1
    dp[5] = 1
    for i in range(6, S+1):
        dp[i] = (dp[i-1] + dp[i-3])
    return dp[S] % 1000000007


print(main())


Measured memory_bytes: 9272
#include<cstdio>
#define N 100010
using namespace std;

int n;
char s[N];
int a[N];

void print(){
	for(int i=1;i<=n;i++) printf("%c",a[i]?'W':'S');
}

bool judge(int d,char c,int x,int y){
	if(d==0&&c=='o'&&x==y){return 1;}
	if(d==0&&c=='x'&&x!=y){return 1;}
	if(d==1&&c=='x'&&x==y){return 1;}
	if(d==1&&c=='o'&&x!=y){return 1;}
	return 0;
}

int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int d0=0;d0<=1;d0++){
		for(int d1=0;d1<=1;d1++){
			a[1]=d0;a[2]=d1;
			for(int i=3;i<=n;i++){
				if(a[i-1]==0&&s[i-1]=='o') 
				a[i]=a[i-2];
				if(a[i-1]==0&&s[i-1]=='x') 
				a[i]=a[i-2]^1;
				if(a[i-1]==1&&s[i-1]=='x')
				 a[i]=a[i-2];
				if(a[i-1]==1&&s[i-1]=='o')
				 a[i]=a[i-2]^1;
			}
			if(judge(a[1],s[1],a[n],a[2])&&judge(a[n],s[n],a[n-1],a[1])){
				print();
				return 0;
			}
		}
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7


		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];
			int[] a = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(p => p).ToArray();
			int[] match = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

			int[] dp = new int[n + 1];
			for (int i = 1; i <= n; i++) {
				dp[i] = -1;
				for (int j = 0; j < a.Length; j++) {
					int num = i - match[a[j]];
					if (num >= 0 && dp[num] >= 0) {
						dp[i] = Math.Max(dp[i], dp[num] + 1);
					}
				}
			}

			int c = n;
			while (c > 0) {
				for (int i = 0; i < a.Length; i++) {
					int num = c - match[a[i]];
					if (num >= 0 && dp[num] == dp[c] - 1) {
						c = num;
						Console.Write(a[i]);
						break;
					}
				}
			}
			Console.WriteLine();


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13376
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
int n ;
int dp[100000+10];
int INF = 1e8;
int dfs(int i){
    if(i >= n)return INF;
    if(i == n-1) return 0;
    if(dp[i] != -1)return dp[i];
    int c1 = abs(v[i]-v[i+1]) + dfs(i+1);
    int c2 = abs(v[i]-v[i+2]) + dfs(i+2);
    int ans = min(c1 , c2);
    dp[i] = ans;
    return ans;
}
int main(){
    cin>>n;
    v.resize(n+2);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    v[n] = 0;
    v[n+1] = 0;
    memset(dp,-1,sizeof dp);
    int c = dfs(0);
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=1e9;
const ll MOD=1e9+7;

int N;
vector<int> a,b;
vector<vector<int> > G;
ll solve(int u,int c,int p){
    if(G[u].size()==1) return 1;
    ll res=0;
    for(auto v:G[u]){
        if(v==p) continue;
        if(c==1) res=(res+solve(v,0,u))%MOD;
        res=(res+solve(v,0,u))%MOD;
    }
    return res%MOD;
}
int main(){
    int N;cin>>N;
    if(N==0){
        cout<<0<<endl;
        return 0;
    }
    vector<int> ans;
    while(N!=0){
        int r=(abs(N)%2==1?1:0);
        N=(N-r)/(-2);
        ans.push_back(r);
    }
    reverse(ans.begin(),ans.end());
    for(int i=0;i<(int)ans.size();++i) cout<<ans[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
string S; cin >> S; int ans=1;
if(S=="RRR"){ ans=3; }
if(S=="SSS"){ ans=0; }
if(S=="RRS"||S=="SRR"){ ans=2; }
cout << ans << "\n";
}

Measured memory_bytes: 3544
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  String s = sc.next();
  int x = 0;
  int max = 0;
  for(int i = 0;i < N;i++){
    if(s.charAt(i) == 'I'){
      x++;
      max = Math.max(max,x);
    }
    else x--;
  }
  System.out.println(max);
}}

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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)

int L;
int nq = 0;
string soln;

int ask(string s) {
    ++nq;
    assert(nq <= 850);

    //int lcs[SZ(soln)][SZ(s)];
    //FOR(i,0,SZ(soln)-1) FOR(j,0,SZ(s)-1) {
    //    lcs[i][j] = 1e9;
    //    lcs[i][j] = min(lcs[i][j],(i>0?lcs[i-1][j]:j+1)+1);
    //    lcs[i][j] = min(lcs[i][j],(j>0?lcs[i][j-1]:i+1)+1);
    //    lcs[i][j] = min(lcs[i][j],(i>0&&j>0?lcs[i-1][j-1]:max(i,j))+(soln[i]!=s[j]));
    //}
    //return lcs[SZ(soln)-1][SZ(s)-1];
    
    cout << "? " << s << endl;
    int x; cin >> x;
    return x;
}

void answer(string s) {
    cout << "! " << s << endl;
}

string solve(vector<string>& vec, int l, int r) {
    if (l > r) return "";
    if (l == r) return vec[l];
    int m = (l+r)/2;
    string p = solve(vec,l,m), q = solve(vec,m+1,r), res = "";
    while (!p.empty() && !q.empty()) {
        string s = res + q[0] + p;
        if (ask(s) == L-SZ(s)) {
            res += q[0];
            q.erase(q.begin());
        } else {
            res += p[0];
            p.erase(p.begin());
        }
    }
    res += p + q;
    return res;
}

void run() {
    vector<char> A;
    FOR(i,0,9) A.push_back('0'+i);
    FOR(i,0,25) A.push_back('a'+i);
    FOR(i,0,25) A.push_back('A'+i);

    int f[SZ(A)];
    L = 0;
    vector<string> vec;
    FOR(i,0,SZ(A)-1){
        string s = "";
        FOR(j,1,128) s += A[i];
        f[i] = 128-ask(s);
        L += f[i];
        if (f[i]) {
            string t = "";
            FOR(j,1,f[i]) t += A[i];
            vec.push_back(t);
        }
    }
    string ans = solve(vec,0,SZ(vec)-1);
    answer(ans);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //soln = "qdj8098udci93ud9kiawdca0osdmcDJHD09IDscm89auda0289xika0wud9c323mucioqdj8098udci93ud9kiawdca0osdmcDJHD09IDscm89auda0289xika0wud9c";
    //soln = "Atcod3rIsGreat";
    run();
    //TRACE(nq);
}



Measured memory_bytes: 3800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <regex>
#include <algorithm>
#include <cstdlib>

using namespace std;

const int INF = 1<<29;

int main()
{
    int n;
    cin >> n;
    vector<int> vec;

    for (int i=0; i<n ; i++) {
        int tmp;
        cin >> tmp;
        vec.push_back(tmp);
    }

    int dp[100010];
    for (int i=0; i<100010; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int i=0; i<n; i++) {
        dp[i+1] = dp[i+1] < abs(vec[i+1] - vec[i]) + dp[i] ?
         dp[i+1] : abs(vec[i+1] - vec[i])+dp[i];
        dp[i+2] = dp[i+2] < abs(vec[i+2] - vec[i]) + dp[i] ?
         dp[i+2] : abs(vec[i+2] - vec[i])+dp[i];
    }

    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1144
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(a + b >= c ? "Yes" : "No");
    }
}

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

using namespace std;
int main(){
  int N;cin>>N;
  int Q;cin>>Q;
  string S;cin>>S;
  int AC[N+1]={};
  AC[0]=0;
  //AC[i] i文字目までに含まれる'AC'の個数
  for(int i=1;i<N;i++){
  	if(S[i-1]=='A'&&S[i]=='C'){
    	AC[i+1]=AC[i]+1;
    }else{
    	AC[i+1]=AC[i];
    }
  }
  int l;
  int r;
  int output;
  for(int i=0;i<Q;i++){
  	cin>>l;cin>>r;
    cout<<AC[r]-AC[l]<<endl;
  }
  	
}



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

int main(){
	int a,b;
	cin>>a>>b;
	int g[]={0,1,3,1,2,1,2,1,1,2,1,2,1};

	if(g[a]==g[b])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int main()
{
     ///"In the name of Allah,most gracious and most merciful"///

        ll i,j,x,y,z,count=0,sum=0,n;
        cin>>n;
        x=n+(n*n)+(n*n*n);
        cout<<x<<endl;


    return 0;
}



Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

long long a, b, c, d;

long long divC, divD, divCD;

long long  doGcd(const long long &a, const long long &b)
{
	if (a % b == 0)
		return b;
	else
	{
		return doGcd(b, a % b);
	}
}

long long gcd(const long long &a, const long long &b)
{
	if (a < b)
		return doGcd(b, a);
	
	return doGcd(a, b);
}


int main()
{
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	
	divC = b / c - a / c ;
	if (a % c == 0)
		divC++;
		
	divD = b / d - a / d;
	if (a % d == 0)
		divD++;
		
	long long g = gcd(c, d);
	long long lcmCD = c / g * d;
	divCD = b / lcmCD - a / lcmCD;
	if (a % lcmCD == 0)
		divCD++;
		
	long long divTotal = (long long )divC + divD - divCD;
	long long ansB = (b - a + 1) - divTotal;
	printf("%lld\n", ansB);
	
	return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,r=0,l=0,ans=1000000;
string S;

int main(){
    cin>>N>>S;
    repi(i,1,N){
        if(S[i]=='E')r++;
    }
    ans=min(ans,r+l);
    // cout<<l<<" : "<<r<<endl;
    repi(i,1,N){
        if(S[i-1]=='W')l++;
        if(S[i]=='E')r--;
        // cout<<l<<" : "<<r<<endl;
        ans=min(ans,r+l);
    }
    out(ans);
   
}


Measured memory_bytes: 900
from math import factorial
import sys

def comb(n,k,p):
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))

    n = max(A)
    A.remove(n)
    A.sort()
    max_r = n/2
    max_r_2 = n - max_r
    min_sub = sys.maxint
    r = 0
    for i in range(len(A)):
        if abs(max_r - A[i]) < min_sub or abs(max_r_2 - A[i]) < min_sub:
            min_sub = min(abs(max_r - A[i]), abs(max_r_2 - A[i]))
            r = A[i]
##    for i in range(N - 1):
##        cm = comb(n, A[i], p)
##        if max_num < cm:
##            max_r = A[i]
##            max_num = cm
    print n, r


if __name__ == '__main__':
    main()

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

int main() {
    string s;
    int K;
    cin >> s >> K;
    
    map<string, bool> mp;
    vector<string> subs;
    for(int i=0; i<int(s.size()); i++) {
        string temp = "";
        for(int j=0; j<5 && i+j<s.size() ; j++) {
            temp += s[i+j];
            if(mp[temp] == false){
                subs.push_back(temp);
                mp[temp] = true;
            }
        }
    }

    sort(subs.begin(), subs.end());
    //subs.erase(unique(subs.begin(), subs.end()), subs.end());
    

    //rep(i, subs.size()) cout << subs[i] << endl;

    cout << subs[K-1] << endl;
    return 0;
}

Measured memory_bytes: 2048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int a, b;
    cin >> a >> b;
    cout << a/b + !!(a%b) << endl;
    return 0;
}


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

using namespace std;

#define FILE(Name) freopen(Name".in", "r", stdin), freopen(Name".out", "w", stdout)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline T gcd(T&a, T b) { return !b ? a : gcd(b, a % b); }
typedef unsigned uit;
typedef long long ll;
typedef double db;

// 看题目取用
// const int mod = 2999999; // for Hash
// const int mod = 4999999; // for Hash
// const int mod = 19491001;
// const int mod = 19260817;
// const int mod = 104857601;
// const int mod = 998244353;
// const int mod = 998244853;
// const int mod = 1004535809;
const int mod = 1000000007;

template<typename T> const T Mod(T x) { return x >= mod * 2 ? x % mod : (x >= mod ? x - mod : x); }
template<typename T> const void Add(T&a, T b) { a = Mod(a + b); }

char s[120];

int main() {
	gstr(s); int k; gi(k);
	int len = strlen(s);
	ll res = 0;
	int l = 0, lc = 0, bg = 0;
	for(int i = 0; i < len; i++) {
		if(s[i] == lc) ++l;
		else {
			if(l && !bg) bg = l;
			res += 1LL * k * (l >> 1);
			lc = s[i];
			l = 1;
		}
	}
	if(l == len)
		res = 1LL * k * len >> 1;
	else {
		if(s[len - 1] == s[0]) {
			res -= 1LL * (bg >> 1) * (k - 1);
			res += 1LL * ((bg + l) >> 1) * (k - 1) + (l >> 1);
		} else res += 1LL * (l >> 1) * k;
	}
	print(res), pc('\n');
	return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main { 

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String[] line = sc.nextLine().split(" ");
    	int intA = Integer.parseInt(line[0]);
    	int intB = Integer.parseInt(line[1]);
    	int intC = Integer.parseInt(line[2]);
    	int tmp1 = intA - intB;
    	int tmp2 = intC - tmp1;
    	int result = 0;
    	if(tmp2 < 0) {
    		result = 0;
    	}else {
    		result = tmp2;
    	}
    	

    	System.out.println(result);
    	
	}
}

Measured memory_bytes: 21844
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
          var r = cin.ReadInt;
          Console.WriteLine(2 * r * 3.141592);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 18632
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

  static Scanner sc = new Scanner(System.in);


  public static void main(String[] args) {
    int n = sc.nextInt();

    Map<String, Integer> nmap = new HashMap<>();
    for (int i = 0; i < n; i++) {
      String keyword = sc.next();
      if (!nmap.containsKey(keyword)) {
        nmap.put(keyword, 1);
      } else {
        nmap.put(keyword, nmap.get(keyword) + 1);
      }
    }
    int m = sc.nextInt();
    for (int i = 0; i < m; i++) {
      String keyword = sc.next();
      if (!nmap.containsKey(keyword)) {
        nmap.put(keyword, -1);
      } else {
        nmap.put(keyword, nmap.get(keyword) - 1);
      }
    }

    int answer = 0;
    for (Map.Entry<String, Integer> entry : nmap.entrySet()) {
      answer = Math.max(entry.getValue(), answer);
    }
    System.out.println(answer);
  }
}


Measured memory_bytes: 21716
n = int(input())
judge = {'AC':0,'WA':0,'TLE':0,'RE':0}
for i in range(n):
    s = input()
    judge[s] += 1
print('AC x',judge['AC'])
print('WA x',judge['WA'])
print('TLE x',judge['TLE'])
print('RE x',judge['RE'])

Measured memory_bytes: 9068
num = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

prev = a[0]-1
ans = b[a[0]-1]

for i in a[1:]:
  _i = i-1
  ans += b[_i]
  if prev + 1 == _i:
    ans += c[prev]
  prev = _i

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int h, n, w;
    int t = 0;
    cin >> h >> w >> n;
    if(n==h*w)
    {
        if(h>w)
        {
            cout << w;
            return 0;
        }
        else
        {
            cout << h;
            return 0;
        }
    }
    else if(h<w)
    {
        t = n % w;
        if(t==0)
        {
            cout << n / w;
            return 0;
        }
        else
        {
            cout << n / w + 1;
            return 0;
        }
    }
    else
    {
        t = n % h;
        if(t==0)
        {
            cout << n / h;
            return 0;
        }
        else
        {
            cout << n / h + 1;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256