akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	ll n, k; cin >> n >> k;
	string s; cin >> s;

	ll x = 0;
	ll ans = 0;
	Rep(i, n) {
		if (s[i - 1] == 'R' && s[i] == 'L') ++x;
		else if (s[i - 1] == s[i]) ++ans;
	}
	if(x != 1) ans += min(x, k) * 2;
	if (k - x > 0 && s[0] != s.back()) ++ans;
	
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define fi second
#define se second
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
typedef long long LL;
const int mod = 1e9 + 7;

int n, a, b;

int main() {
    cin >> n >> a >> b;
    if (abs(a - b) & 1) puts("Borys");
    else puts("Alice");
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[][] path = Enumerable.Repeat(0, nm[1]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

        int[][] map = Enumerable.Repeat(0, nm[0]).Select(_ => Enumerable.Repeat(int.MaxValue / 2, nm[0]).ToArray()).ToArray();
        for (int i = 0; i < path.Length; i++)
        {
            map[path[i][0] - 1][path[i][1] - 1] = path[i][2];
            map[path[i][1] - 1][path[i][0] - 1] = path[i][2];
        }

        bool flag = true;
        while (flag)
        {
            flag = false;
            for (int i = 0; i < nm[0]; i++)
            {
                for (int j = 0; j < nm[0]; j++)
                {
                    if (i != j)
                    {
                        for (int k = 0; k < nm[0]; k++)
                        {
                            if (k != i && k != j && map[i][j] > map[i][k] + map[k][j])
                            {
                                flag = true;
                                map[i][j] = map[i][k] + map[k][j];
                                map[j][i] = map[i][k] + map[k][j];
                            }
                        }
                    }
                }
            }
        }

        int res = 0;
        for (int i = 0; i < path.Length; i++)
        {
            if (map[path[i][0] - 1][path[i][1] - 1] < path[i][2])
            {
                res++;
            }
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13524
#include<stdio.h>
 
int main()
{
  int length = 0;
  int height = 0;
  int area = 0;
  int cir = 0;
 
  scanf("%d %d", &length, &height);
  area = length * height;
  cir = length*2 + height*2;
 
  printf("%d %d\n", area, cir);
 
  return 0;
}
 
 



 

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	string s[3];
	REP(i, 3)cin >> s[i];
	int t = 0, p[3] = { 0 };
	while (1) {
		if (p[t] == s[t].size()) {
			printf("%c", 'A' + t);
			return 0;
		}
		int n = s[t][p[t]] - 'a';
		p[t]++;
		t = n;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	char date2[10];
	
	scanf("%s", &date2);
	date2[0] = '2';
	date2[1] = '0';
	date2[2] = '1';
	date2[3] = '8';
	
	printf("%s", date2);
	
	return 0;
	
}

Measured memory_bytes: 3080
import sys
readline = sys.stdin.readline

DIV = 998244353
N,S = map(int,readline().split())
A = list(map(int,readline().split()))

# ある数の取り得る状態は以下
# (1)部分集合Pに含まれない
# (2)部分集合Pに含まれ、和に使われている
# (3)部分集合Pに含まれ、和に使われていない

# dp[i][j][k] = i - 1個目まで処理したときに、部分集合Pに含まれ(j)、総和がkになっている個数
dp = [[[0] * (S + 1) for j in range(2)] for i in range(N + 1)]
dp[0][0][0] = 1

for i in range(N):
  for k in range(S + 1):
    # (1)部分集合Pに含まれない
    dp[i + 1][0][k] += dp[i][0][k]
    dp[i + 1][0][k] += dp[i][1][k]
    dp[i + 1][0][k] %= DIV

    # (2)部分集合Pに含まれ、和に使われている
    if k + A[i] <= S:
      dp[i + 1][1][k + A[i]] += dp[i][0][k]
      dp[i + 1][1][k + A[i]] += dp[i][1][k]
      dp[i + 1][1][k + A[i]] %= DIV

    # (3)部分集合Pに含まれ、和に使われていない
    dp[i + 1][1][k] += dp[i][0][k]
    dp[i + 1][1][k] += dp[i][1][k]
    dp[i + 1][1][k] %= DIV

print((dp[-1][0][-1] + dp[-1][1][-1]) % DIV)


Measured memory_bytes: 216232
#include <stdio.h>

int main( void ) {
	int n, y, m, d, tmp;

	for ( scanf( "%d", &n ); n--; printf( "%d\n", 196470 - tmp ) ) {
		scanf( "%d %d %d", &y, &m, &d );
		y--;
		m--;

		tmp = y / 3 * 590 + y % 3 * 195 + m * 20 - ( ( y + 1 ) % 3 ? m / 2 : 0 ) + d - 1;
	}

	return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

          
            int ans = 0;
            for(var i = 1; i < N; i++)
            {
                char[] sl = s.Substring(0, i).Distinct().ToArray();
                char[] sr = s.Substring(i).Distinct().ToArray();
                int type = 0;
                for(var j = 0; j < sl.Length; j++)
                {
                    if (sr.Contains(sl[j]))
                    {
                        type++;
                    }
                }
                ans = Math.Max(ans, type);
            }

            Console.WriteLine(ans);


            //Console.Out.Flush();
            
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



Measured memory_bytes: 13268
#include <stdio.h>

int main(int argc, const char * argv[]) {

    
    long power=1;
    long discount = 10*10*10*10*10*10*10*10*10+7;
    int N;
    scanf("%d",&N);
    for(long i=0; i<N; i++){
        power = power*(i+1);
        power = power%discount;
//        printf("%ld\n", power);
    }
    
    printf("%ld\n",power%discount);
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, d; cin >> n >> d;
	ll ans = 0;
	for(ll i = 0; i < n; i++) {
		ll x, y; cin >> x >> y;
		ans += x * x + y * y <= d * d;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3624
import heapq
import collections
from collections import deque

n = int(input())
ab = []
visit = [-1 for _ in range(n+1)]
tree = [[]  for _ in range(n+1)]
colors = {}
for i in range(n-1):
    a, b = map(int,input().split())
    ab.append((a, b))
    tree[a].append(b)
    tree[b].append(a)
    colors[(a,b)] = -1
    colors[(b,a)] = -1

# abの色を格納
visit[1]=1

q = deque([(1,0)]) #V,color のtuple
K = 0
while q:
    v,from_color = q.popleft()
    c = 1
    for next_v in tree[v]:
        if visit[next_v] == -1:
            visit[next_v] = 1
            if c == from_color:
               c += 1
            colors[(v,next_v)] = colors[(next_v,v)] = c
            q.append((next_v,c))
            c += 1
anss = []
K = 0
for temp in ab:
    a,b = temp
    K = max(K, colors[(a,b)] )
    anss.append(colors[(a,b)])

print(K)
for c in anss:
    print(c)





# for k,v in di:
#     color = max(colors,len(v))


Measured memory_bytes: 107936
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
using namespace std;
int min (int a, int b){
  if(a<b) return a;
  else return b;
}
int max (int a, int b){
  if(a>b) return a;
  else return b;
}
int main(){
  int n,m;
  string s1[110],s2[110];

  cin >>n;
  for(int i=0;i<n;i++)
  cin >>s1[i];

  cin >>m;
  for(int i=0;i<m;i++)
  cin >>s2[i];

  int ans=0;

  for(int i=0;i<n;i++){
    int cnt1=0;
    int cnt2=0;
    for(int j=0; j<n;j++){
      if(s1[i]==s1[j]) cnt1++;
    }

    for(int j=0; j<m;j++){
      if(s1[i]==s2[j]) cnt2++;
    }
    if( ans <cnt1-cnt2) ans=cnt1-cnt2;
  }
  cout <<ans<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s,t;
int n,m;
int dp[100005];
map<int,vector<int>> ma;

int longestpath(int i)
{
    int maxi = 0;
    if(dp[i]!=-1)
        return dp[i];
    for(int j = 0;j<ma[i].size();j++)
    {
        maxi = max(maxi,1+longestpath(ma[i][j]));
    }
    return dp[i] = maxi;
}






int main()
{
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(int i = 0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        ma[x].push_back(y);
    }
    int maxi = 0;
    for(int i = 1;i<=n;i++)
    {
        maxi = max(maxi,longestpath(i));
        //cout<<i<<" -> "<<maxi<<"\n";
    }
    cout<<maxi<<"\n";
    return 0;
}


Measured memory_bytes: 14976
#include<bits/stdc++.h>
using namespace std;
#define l long long
int main()
{
  int n;
  cin>>n;
  l a,b;
  vector<pair<l,l> > p;
  for(int i=0;i<n;i++)
  {
    cin>>a>>b;
    p.push_back({b,a});
  }
  l sum=0;
  int flag=0;
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++)
  {
    sum+=p[i].second;
    if(sum>p[i].first)
      flag=1;
  }
  if(flag==1)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 6384
#include<iostream>
#include<cstdio>
using namespace std;
int main(){

  int x;

  cin>>x;

  int a[x];

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

  for(int i=x-1;i>0;i--){

    cout<<a[i]<<" ";
  }

  cout<<a[0]<<endl;


 

  return 0;
}

Measured memory_bytes: 3084
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il int max(int x,int y){return x>y?x:y;}
il int min(int x,int y){return x<y?x:y;}
il int abs(int x){return x>0?x:-x;}
il void swap(int &x,int &y){int t=x;x=y;y=t;}
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 150010
int n,m;
bool used[N];
struct node{int l,r;}a[N];
bool cmp(node a,node b){return a.l<b.l;}
int main(){
	in2(n,m);
	for(int i=1;i<=m;i++)in2(a[i].l,a[i].r);
	sort(a+1,a+m+1,cmp);
	int l=a[1].l,r=a[1].r,ans=1;
	for(int i=2;i<=m;i++){
		if(a[i].l>=l)l=a[i].l;
		if(a[i].r<=r)r=a[i].r;
		if(l>=r){ans++;l=a[i].l;r=a[i].r;}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
h, n = map(int, input().split())
inf = 10**10
dp = [inf]*(h+1)
dp[0] = 0
for i in range(n):
    a, b = map(int, input().split())
    
    for j in range(h+1):
        if j- a>0:
            dp[j] = min(dp[j-a]+b, dp[j])
        else:
            dp[j]= min(dp[j], b)

print(dp[h])

Measured memory_bytes: 44392
#! env/bin/local python3
# -*- coding:utf-8 -*-

# -- submit ----

import itertools

# --- fetch input ---
inputs: list = []
while True:
    try:
        inputs.append(input().strip('\n'))
    except EOFError:
        break

# --- write code below ---
x = float(inputs[0])

a_range = range(1, 10**3)
b_range = range(-10**3, 10**3)

for a in a_range:
    for b in b_range:
        if a ** 5 - b ** 5 == x:
            print(a, b)
            break
    else:
        continue
    break


Measured memory_bytes: 9116
def main():
    N = int(input())
    P = [int(i) for i in input().split()]
    ans = 0
    le = 0
    for i, p in enumerate(P):
        if i+1 == p:
            le += 1
        elif le > 0 and i+1 != p:
            ans += (le + 1) // 2
            le = 0
    if le > 0:
        ans += (le + 1) // 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 52908
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll long long
//#define __int64 long long

int n;
ll a[233333];


int main(void){
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)a[i]*=-1;
    
    multiset<ll>ta;
    rep(i,n){
        auto itr=ta.upper_bound(a[i]);
        if(itr==ta.end()){
            ta.insert(a[i]);
            //cout<<"A"<<a[i]<<endl;
        }
        else{
            //cout<<"B"<<a[i]<<" "<<(*itr)<<endl;
            ta.erase(itr);
            ta.insert(a[i]);
        }
    }
    cout<<ta.size()<<endl;
}


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

using namespace std;

bool cnt[30];
string s;

int main()
{
	cin>>s;
	int i,j;
	for (i=0;i<s.size();i++)
		cnt[s[i]-'a']=1;
	i=0;
	while (cnt[i])i++;
	if (i==26)cout<<"None"<<endl;
	else cout<<char(i+'a')<<endl;
	return 0;
}

Measured memory_bytes: 512
K,S = map(int,input().split())

def nHr(n):
    return (n+2)*(n+1)//2
whole = nHr(S)
oneGreater = twoGreater = threeGreater = 0

if S >= K+1:
    oneGreater = nHr(S-(K+1))
    if S >= 2*(K+1):
        twoGreater = nHr(S-2*(K+1))
        """
        if S >= 3*(K+1):
            threeGreater = nHr(S-3*(K+1))
        """

ans = whole -(oneGreater*3 - twoGreater*3 + threeGreater)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
#define ll long long
#define vi vector<int>
#define pb push_back
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 100000000
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mk(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define re return
// #define endl "\n"
#define max2(x,y)              (x>y)?x:y
#define min2(x,y)              (x<y)?x:y
#define mid(s,e)               (s+(e-s)/2)
#define mini                   INT_MIN
#define maxo                   INT_MAX
#define rep(i,a,b) for(int i=a;i<(int)(b);++i)
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define show(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl
#define en cout<<"\n";

int main()
{
    // #ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    cout<<3*n*n<<endl;
}

Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, P = [int(x) for x in input().split()]

    def prime_factorization(n):
        i = 2
        factors = []
        while i * i <= n:
            if n % i:
                i += 1
            else:
                n //= i
                factors.append(i)
        if n > 1:
            factors.append(n)
        return factors

    primes = prime_factorization(P)
    c = collections.Counter(primes)

    ans = 1
    for k in c.keys():
        if c[k] >= N:
            ans *= k ** (c[k] // N)

    print(ans)

    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 9384
# 6,5の面を順に出し続けるのが最善
x = int(input())
tmp = x // 11 # 6,5の面を出したセット数
tmp2 = x % 11 # 端数
ans = tmp * 2
if 1 <= tmp2 <= 6: # 6をもう1度出す
  ans += 1
elif tmp2 >= 7: # 5ももう1度出す
  ans += 2
print(ans)

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

long long diva(long long x,long long y){
    long long ans;
    while(y>=1){
        if(y>x){
            swap(x,y);
        }
        if(x%y == 0){
            ans = y;
            break;
        }
        if(y == 1){
            ans = 1;
            break;
        }
        x = x%y;
    }
   	return ans;
}


int main(){
    long long A,B;
    long long ans=1ll;
    cin >> A >> B;
    long long C =diva(A,B);;
    for(long long i=2;i<= sqrt(C);i++){
        if(C%i == 0){
          ans++;
        }
        while(C%i == 0){
          C /=i;
        }
      	if(C == 1){
          break;
        }  
    }
  	if(C!=1){
      ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdlib.h>
#define INF 1000000000;

int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	int c=a+b;
	if(c>=24){
		c=c-24;
	}
	printf("%d",c);
	return 0;
}

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

#define ll long long

void solve(){
    ll x, k, d; cin>>x>>k>>d;
    x = abs(x);
    ll i = ceil(x/d);
    i = (i>k ? k: i);
    //i = (x == d ? 0 : i);

    x = x-i*d;

    x = (k-i)%2 == 0 ? x : x-d;

    cout<<abs(x)<<endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3608
def main():
    n = input()
    
    if len(n) == 1:
        print(n)
        return

    if set(n[1:]) == {'9'}:
        print(int(n[0]) + 9 * (len(n) - 1))
        return

    print(9 * (len(n) - 1) + int(n[0]) - 1)   
    

    # for i, c in enumerate(n):
    #     if c != '9':
    #         print(9 * (len(n) - 1) + int(n[0]) - 1)
    #         return
    # else:
    #     print(9 * len(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int n,cnt[4];
double f[310][310][310];
double DFS(int a,int b,int c)
{
	if(a==0&&b==0&&c==0) return 0;
	else if(f[a][b][c]) return f[a][b][c];
	double ans=1.0*n/(a+b+c);
	if(a) ans+=(1.0*a/(a+b+c))*DFS(a-1,b,c);
    if(b) ans+=(1.0*b/(a+b+c))*DFS(a+1,b-1,c);
    if(c) ans+=(1.0*c/(a+b+c))*DFS(a,b+1,c-1);
    return f[a][b][c]=ans;
}
int main()
{
	cin>>n;
	for(int x,i=1;i<=n;i++) cin>>x,cnt[x]++;
	printf("%.14lf\n",DFS(cnt[1],cnt[2],cnt[3]));
	return 0;
}

Measured memory_bytes: 114332
#include <iostream>
#include <vector>

template<class T> void output(std::vector<T> & A) {
    const int n = A.size();
    for (int i = 0; i < n - 1; ++i) {
        std::cout << A[i] << " ";
    }
    std::cout << A[n - 1] << std::endl;
}

void swapval(int& a, int& b) {
    const int tmp = a;
    a = b;
    b = tmp;
}

void selectionSort(std::vector<int>& A) {
    const int N = A.size();
    int cnt = 0;
    for (int i = 0; i < N - 1; ++i) {
        int minj = i;
        for (int j = i; j < N; ++j) {
            if (A[minj] > A[j]) {
                minj = j;
            }
        }
        if (i != minj) {
            swapval(A[minj], A[i]);
            ++cnt;
        }
    }
    output(A);
    std::cout << cnt << std::endl;
}

int main() {
    int n; std::cin >> n;
    std::vector<int> A(n);
    for (int i = 0; i < n; ++i) std::cin >> A[i];

    selectionSort(A);

    return 0;
}


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{

        List<int> a = new List<int>();
        List<int> b = new List<int>();

        //long[] a = new long[n];


		//string[] s = Console.ReadLine().Split(' ');

		// int a = int.Parse(Console.ReadLine());

		
        while(true)
        {
            string[] s = Console.ReadLine().Split(' ');
            int c = int.Parse(s[0]);
            int d = int.Parse(s[1]);

            if (c == 0 && d == 0) break;

            a.Add(c);
			b.Add(d);

		}

		for (int i = 0; i < a.Count; i++)
		{
			for (int y = 0; y < a[i]; y++)
			{
				for (int x = 0; x < b[i]; x++)
				{
					if (x == 0 || y == 0 || x == b[i] - 1 || y == a[i] - 1)
					{
						Console.Write("#");
					}
					else
					{
						Console.Write(".");
					}

				}
				Console.WriteLine("");
			}
			Console.WriteLine("");
		}

		//Console.WriteLine("");


	}
}

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

using namespace std;

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

    map<char, int> m;
    for (int i = 0; i < S.size(); ++i) {
        if (m.find(S[i]) == m.end()) {
            m.insert(make_pair(S[i], 1));
        } else {
            m[S[i]]++;
        }
    }

    auto ans = "Yes";
    for (auto data : m) {
        if (data.second != 2) {
            ans = "No";
        }
    }

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

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

def main():
    A, B, C, K = MI()
    ans = 0

    ans += min(A, K)
    K -= A

    if K <= 0:
        print(ans)
        return

    K -= B

    if K <= 0:
        print(ans)
        return

    ans -= K

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68244
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	String station = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				return;
			}
			int key[] = new int[n];
			for (int i = 0; i < n; i++) {
				key[i] = sc.nextInt();
			}
			String st = sc.next();
			String ans = "";
			int index = 0;
			for (int i = 0; i < st.length(); i++) {
				char obj = st.charAt(i);
				int location = 0;
				while (obj != station.charAt(location)) {
					location++;
				}
				location -= key[index++ % n];
				if (location < 0) {
					location += 52;
				}
				ans += station.charAt(location);
			}
			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26920
#include <iostream>
using namespace std;
int calc(int x) {
	int ret = 0;
	while(x % 100 == 0) {
		x /= 100;
		++ret;
	}
	return ret;
}
int main() {
	int D, N;
	cin >> D >> N;
	int cnt = 0, val = 0;
	while(cnt < N) {
		++val;
		if(calc(val) == D) ++cnt;
	}
	cout << val << '\n';
	return 0;
}




Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
void call(int n){
  for (int i = 1; i <= n; i++){
    int x = i;
    if (x % 3 == 0){
      cout << " " << i;
      continue;
    }
    while (x){
      if (x % 10 == 3){
        cout << " " << i;
        break;
      }
      x /= 10;
    }
  }
  cout << endl;
}
int main(){
  int n; cin >> n;
  call(n);
  return 0;
}


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


struct UnionFind {
    vector<int> data; int group;
    UnionFind(int N) : data(N, -1), group(N) {}
    void init(int N) {
        data.assign(N, -1);
        group = N;
    }
    void unite(int x, int y) {
        x = root(x); y = root(y);
//        if(data[x] < data[y])  swap(x, y);        
        if(x != y){
            data[x] += data[y];
            data[y] = x;
            --group;
        }
    }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]);}
    bool same(int a, int b) { return root(a) == root(b);}
};

class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

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

    int n, q;
    cin >> n >> q;
    UnionFind uf(n);

    for(int _ : in(q)) {
        int k, u, v;
        cin >> k >> u >> v;
        if(k)
            cout << uf.same(u, v) << '\n';
        else
            uf.unite(u, v);
    }
    return 0;
}

Measured memory_bytes: 3208
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      a: chars,
      b: chars,
      c: chars,
    }
    if a[a.len()-1] == b[0] && b[b.len()-1] == c[0] {
        println!("{}", "YES");
    } else {
        println!("{}", "NO");
    }
}


Measured memory_bytes: 4352
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		for (;;) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if ((w | h) == 0) {
				return;
			}
			char[][] f1 = new char[h][w];
			char[][] f2 = new char[h][w];
			int sw1, sh1, sw2, sh2;
			sw1 = sh1 = sw2 = sh2 = 0;
			for (int i = 0; i < h; i++) {
				String in1 = sc.next();
				String in2 = sc.next();
				for (int j = 0; j < w; j++) {
					f1[i][j] = in1.charAt(j);
					f2[i][j] = in2.charAt(j);
					if (f1[i][j] == 'L') {
						sw1 = j;
						sh1 = i;
					}
					if (f2[i][j] == 'R') {
						sw2 = j;
						sh2 = i;
					}
				}
			}
			boolean[][][][] visit = new boolean[h][w][h][w];
			boolean ok = false;
			visit[sh1][sw1][sh2][sw2] = true;
			LinkedList<Pos> que = new LinkedList<Pos>();
			que.add(new Pos(sh1, sw1, sh2, sw2));
			while (!que.isEmpty()) {
				Pos now = que.poll();
				if (f1[now.h1][now.w1] == '%' && f2[now.h2][now.w2] == '%') {
					ok = true;
					break;
				}
				for (int i = 0; i < 4; i++) {
					int nh1 = now.h1 + dy[i];
					int nw1 = now.w1 + dx[i];
					int nh2 = now.h2 + dy[i];
					int nw2 = now.w2 + (dx[i] * -1);
					if (!inner(nh1, nw1, h, w) || f1[nh1][nw1] == '#') {
						nh1 = now.h1;
						nw1 = now.w1;
					}
					if (!inner(nh2, nw2, h, w) || f2[nh2][nw2] == '#') {
						nh2 = now.h2;
						nw2 = now.w2;
					}
					if ((f1[nh1][nw1] != '%' && f2[nh2][nw2] == '%')
							|| (f1[nh1][nw1] == '%' && f2[nh2][nw2] != '%')) {
						continue;
					}
					if (!visit[nh1][nw1][nh2][nw2]) {
						visit[nh1][nw1][nh2][nw2] = true;
						que.add(new Pos(nh1, nw1, nh2, nw2));
					}
				}
			}
			System.out.println(ok ? "Yes" : "No");
		}
	}

	class Pos {
		int w1;
		int h1;
		int w2;
		int h2;

		public Pos(int h1, int w1, int h2, int w2) {
			super();
			this.h1 = h1;
			this.w1 = w1;
			this.h2 = h2;
			this.w2 = w2;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}
}

Measured memory_bytes: 173892
#include<bits/stdc++.h>
#define LL long long
#define PAIR pair<LL,LL>
using namespace std;
const int mo=1e9+7;
int n,p,q; LL ans,f[95];
vector<PAIR> V[95];
void Query()
{
	int i; LL x,y; p=1;
	scanf("%lld %lld",&x,&y);
	if(x>y) swap(x,y);
	while(f[p+1]<=x&&f[p+2]<=y) p++;
	printf("%d ",p);
	if(p==1){
		if(x==1){ printf("%d\n",(int)(y%mo));}
		else printf("4\n");
		return ;
	  }
	p--,ans=0;
	for(i=0;i<V[p].size();i++){
		if(V[p][i].second<=x) (ans+=(y-V[p][i].first)/V[p][i].second)%=mo;
		if(V[p][i].second<=y) (ans+=(x-V[p][i].first)/V[p][i].second)%=mo;
	  }
	printf("%d\n",ans);
}
void prepare()
{
	int i,j; LL k;
	V[1].push_back(PAIR(1,2));
	V[1].push_back(PAIR(1,3));
	for(i=2;i<=n;i++)
		for(j=0;j<V[i-1].size();j++)
			for(k=V[i-1][j].first+V[i-1][j].second;k<=f[i+2];k+=V[i-1][j].second)
				V[i].push_back(PAIR(V[i-1][j].second,k));
}
int main()
{
	scanf("%d",&q);
	f[0]=f[1]=1,n=1;
	while(f[n]+f[n-1]<=(1e18))
		f[n+1]=f[n]+f[n-1],++n;
	f[n+1]=f[n]+f[n-1];
	f[n+2]=f[n+1]+f[n];
	prepare();
	while(q--) Query();
	return 0;
}


Measured memory_bytes: 4096
a,b=map(int,input().split())
List=list(map(int,input().split()))
t=-1
S=[0]
for i in range(a):
    S+=[S[i]+List[i]]
t=-1
for i in range(a-b+1):
    if S[i+b]-S[i]>t:
        t=S[i+b]-S[i]
print((t+b)/2)

Measured memory_bytes: 25060
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <stdlib.h>
const int MAX = 3;



void p(int h,int w){
    

}
void q(int h,int w){

}

int main(){
    ll h;
    ll w;
    cin >> h >> w;

    ll s = h * w;
    ll ans;
    if(h == 1LL || w == 1LL) ans = 1LL;
    else ans = s % 2 == 0 ? ans = s/2 : s / 2 + 1;
    
    // x1 + y 1 = x2 + y2を探す
    
    
    cout << ans << endl;


   
    




   
    

    



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
const int MAX_N=100000;
struct UF{
    int par[MAX_N]; //親
    int height[MAX_N];  //木の深さ
    int num[MAX_N];
    
    //n要素で初期化
    void init (int n){
        for (int i=0;i<n;i++){
            par[i]=i;
            height[i]=0;
            num[i]=1;
        }
    }
    
    //木の根を求める
    int find (int x){
        if (par[x]==x){
            return x;
        }
        else{
            return par[x] = find(par[x]);
        }
    }
    
    //xとyの属する集合を併合
    void unite (int x, int y){
        x=find(x);
        y=find(y);
        if (x==y) return;
        
        if (height[x] < height[y]){
            par[x]=y;
            num[y]=num[x]+num[y];
        }
        else {
            par[y]=x;
            num[x]=num[x]+num[y];
            if (height[x]==height[y]) height[x]++;
        }
    }
    
    //xとyが同じ集合に属するか否か
    bool same (int x, int y){
        return find(x) == find(y);
    }
};
UF uf;
ll N,M;
int A[100000], B[100000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M;
    rep(i,0,M){
        cin>>A[i]>>B[i];
        A[i]--;
        B[i]--;
    }
    uf.init(N);
    vector<ll> ans;
    ll res=0;
    ll o=N*(N-1)/2;
    ans.pb(o);
    rer(i,M,0){
        if(uf.same(A[i],B[i])){
            ans.pb(o-res);
        }
        else{
            ll x=uf.num[uf.find(A[i])];
            ll y=uf.num[uf.find(B[i])];
            res=res-x*(x-1)/2-y*(y-1)/2+(x+y)*(x+y-1)/2;
            ans.pb(o-res);
            uf.unite(A[i], B[i]);
        }
    }
    rer(i,M,0){
        cout <<ans[i]<<"\n";
    }
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define n 5
using namespace std;

int main(){
    int a[n];
    int k;
    for(int i=0;i<n;i++) cin>>a[i];
    cin>>k;
    if(a[n-1]-a[0]<=k) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
}

Measured memory_bytes: 256
/*input
1 0 1
2 1 2
1 0 1
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long c[3][3],a[3],b[3],n;
void get(){
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j){
			assert(a[i]!=-1000 || b[j]!=-1000);
			if(b[j]==-1000){
				b[j] = c[i][j] - a[i];
			}
			else if(a[i]==-1000){
				a[i] = c[i][j] - b[j];
			}
		}
}
bool check(){
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j)
			if(a[i]+b[j]!=c[i][j])
				return false;
	return true;
}
int main(){
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	for(int i=0;i<3;++i)
		for(int j=0;j<3;cin>>c[i][j++]);
	for(int i=0;i<=500;++i){
		a[0]=a[1]=a[2]=b[0]=b[1]=b[2]=-1000;
		a[0]=i;
		get();
		if(check()) return cout<<"Yes",0;
	}
	cout<<"No";
}

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 505


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

	int a[5], k = 125;
	int sum = 0;
	for (int i = 0; i < 5; ++i)
	{
		cin >> a[i];
		if(a[i] % 10)
		{
			if(a[i] % 10 < k)
				k  = a[i] % 10;
			a[i] += (10 - a[i] % 10);
		}
	}
	// cout << k << "\n";
	for (int i = 0; i < 5; ++i)
	{
		// cout << a[i] << " ";
		sum += a[i];
	}
	cout << sum - (k == 125 ? 0 : 10 - k);
	return 0;
}

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

int main(){

	int n, ans = 100000;
	
	cin >> n;
	
	for(int i = 0; i < n; i++) {
		ans *= 1.05;
		ans = 1000 * (ans / 1000 + (ans % 1000 != 0));
	}
	
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl

int main(){
	int n;
	int a[3][3];
	REP(i,3){
		REP(j,3){
			cin>>a[i][j];
		}
	}
	cin>>n;
	REP(t,n){
		int b;
		cin>>b;
		REP(i,3){
			REP(j,3){
				if(a[i][j]==b){
					a[i][j]=-1;
				}
			}
	}
	}
	int ans=-1;
	REP(i,3){
		if(a[i][0]==a[i][1]&&a[i][1]==a[i][2]){
			ans=1;
		}
	}
	REP(j,3){
		if(a[0][j]==a[1][j]&&a[1][j]==a[2][j]){
			ans=1;
		}
	}
	if(a[0][0]==a[1][1]&&a[2][2]==a[1][1]){
			ans=1;
		}
		if(a[2][0]==a[1][1]&&a[0][2]==a[1][1]){
			ans=1;
		}
	if(ans==1){
		OUT("Yes");
	}else OUT("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#define MOD 1000000007
using namespace std;

int main(){

  int h, w;
  cin >> h >> w;
  
  vector<vector<long long int>> dp(h+1, vector<long long int>(w+1, -1));
  for(int i = 0; i < h; i++){
    string tmp;
    cin >> tmp;
    dp[i+1][0] = 0;
    for(int j = 0; j < w; j++){
      if(tmp[j] == '#') dp[i+1][j+1] = 0;
      if(i == 0) dp[i][j+1] = 0;
    }
  }
  dp[1][1] = 1;

  /*
  for(int i = 0; i <= h; i++){
    for(int j = 0; j <= w; j++) cout << dp[i][j];
    cout << endl;
  }
  */

  for(int i = 1; i <= h; i++) for(int j = 1; j <= w; j++)
    if(dp[i][j] < 0) dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;

  cout << dp[h][w] << endl;
}


Measured memory_bytes: 8064
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import math
import sys
input = sys.stdin.readline

N = int(input())
ans = 0
k = int(math.log10(N)) + 1
A = N//(10**(k-1))
if (A + 1) * (10 ** (k - 1)) - 1 <= N:
    ans = A + 9*(k-1)
else:
    ans = A-1+9*(k-1)
print(ans)


Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void YAY(bool b = true) {cout << (b ? "Yay!" : ":(") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
V<> VEC(ll n) {V<> v(n); REP(i, n) cin >> v[i]; return v;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1;} return ret;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c, k; cin >> a >> b >> c >> k;
    REP(i, k){
        if(a >= b){
            b *= 2;
            continue;
        }
        else c *= 2;
    }
    Yes(a < b and b < c);
}

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

int main(){
  int answer = 0;
  int N;
  cin >> N;
  int a = 1;
  int b = 1;
  int c = 1;
  while(a<N) {
    if(a*b<N){
      answer++;
    }
    if(a*b<N){
      b++;
    }else{
      b = 1;
      a++;
    }
  }
  cout << answer << endl;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=c-a;
    int y=d-b;
    cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<"\n";
    return 0;
}
/**

**/


Measured memory_bytes: 256
module Main where

m = 1000000007

main :: IO ()
main = do
  [n, k] <- map (read :: String -> Integer) . words <$> getLine
  as <- map (read :: String -> Int) . words <$> getLine
  print $ solve n k as
  where
    solve n k as =
      let
        inner = f as
        inter_all = f (as ++ as)
        inter = inter_all - (2 * inner)
      in ((inter * (k * (k - 1) `div` 2)) + k * inner) `mod` m

f :: [Int] -> Integer
f [] = 0 
f (a:as) = fromIntegral (length (filter (a >) as)) + f as

Measured memory_bytes: 1404
import numpy as np
from itertools import combinations_with_replacement

X, Y = map(int, input().split())
flag = 0

for x in combinations_with_replacement('24', X):
    a = np.array(list(map(int, x)))
    if a.sum() == Y:
        flag = 1
        break
if flag == 1:
    print('Yes')
else:
    print('No')

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

def count(n,s):
    cntw=0
    cnte=0
    mcntw=0
    mcnte=0
    maxn=0
    for i in range(n):
        if s[i]=="W":
            cntw+=1
        else:
            cnte+=1
        if maxn<cnte-cntw:
            maxn=cnte-cntw
            mcnte=cnte
            mcntw=cntw

    if cntw==0 or cnte==0:
        print(0)
        return

    else:
        print(mcntw+cnte-mcnte)
        return
count(n,s)



Measured memory_bytes: 9784
#include <stdio.h>
#include <math.h>


int main()
{
	int n;
	int x, tmp;
	int i, j;

	scanf("%d", &n);

	for(i = 0; i < pow(2, n); i++){
		printf("%d:", i);

		x = i;
		j = 0;
		while( (tmp = x / 2) >= 1){
			if(x % 2)
				printf(" %d", j);
			x = tmp;
			j++;
		}
		if(x)
			printf(" %d", j);

		printf("\n");
	}

	return 0;
}


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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}

void bfs(vector<int> x[],int v,int depth[],int visited[])
{
    int dep = 0;
    visited[v]=1;
    queue<int> q;
    depth[v]=dep;
    dep++;
    for(auto i:x[v])
    {
        q.push(i);        
        depth[i]=dep;  
    }
    dep++;
    while(!q.empty())
    {
        int t=q.front();
        q.pop();
        if(!visited[t])
        {
            visited[t]=1;
            depth[t]=dep;
            for(auto i:x[t])
                q.push(i);
            dep++;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<int> x[n];
    for(int i=0;i<m;i++)
    {
        int temp,temp1;
        cin>>temp>>temp1;
        x[temp-1].pb(temp1-1);
        x[temp1-1].pb(temp-1);
    }
    bool check=1;
    int depth[n]={INT_MAX},visited[n]={0};
    bfs(x,0,depth,visited);
    for(int i=0;i<n;i++)
        if(depth[i]==INT_MAX)
        {
            check=0;
            break;
        }
    if(check)
    {
        cout<<"Yes\n";
        for(int i=1;i<n;i++)
        {
            int min_v=INT_MAX,v;
            for(auto j:x[i])
            {
                if(min_v>depth[j])
                {
                    min_v=depth[j];
                    v=j;
                }
            }
            cout<<v+1<<"\n";
        }
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 18460
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int R , G , B , N;
    scanf("%d %d %d %d" , &R , &G , &B , &N);
    int ans = 0;
    for(int i = 0 ; i <= 3000 ; i++)
    {
        for(int j = 0 ; j <= 3000 ; j++)
        {
            if(N - (R*i + G*j) >= 0)
            {
                if( (N - (R*i + G*j)) % B == 0)
                {
                    ans++;
                }
            }
            
        }
    }
    printf("%d\n" , ans);
    return 0;
}

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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
#define FI first
#define SE second
const long mod = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<pair<int,string>> vec (N);
    for(int i = 0;i < N;i++){
        cin >> vec.at(i).second;
        SORT(vec.at(i).second);
        vec.at(i).first = vec.at(i).second.size();
    }
    SORT(vec);

    for(int i = 0;i < N;i++){
//        cout << vec.at(i).second << "(" << vec.at(i).first << ")" << endl;
    }

    for(int i = 0;i < vec.at(0).first;i++){
//        cout << "TEST:" << vec.at(0).second.at(i) << endl;
        bool mtest = true;
        for(int j = 1;j < N;j++){
            bool test = false;
            for(int k = 0;k < vec.at(j).first;k++){
//                cout << "CHAR is " << vec.at(j).second.at(k) << "..." << endl;
                if(vec.at(j).second.at(k) == vec.at(0).second.at(i)){
                    test = true;
                    vec.at(j).second.at(k) = '*';
                    break;
                }
            }
            if(test == false){
//                cout << j << ":NO!" << endl;
                mtest = false;
                break;
            }
            else{
//                cout << j << ":YES!" << endl;
            }
        }
        if(mtest){
            cout << vec.at(0).second.at(i);
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
//#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int MAXN = 50;

char a[1 + MAXN][1 + MAXN], b[1 + MAXN][1 + MAXN];

bool Check(int n, int m, int x, int y) {
    for (int i = 1; i <= m; i++)
        for (int j = 1; j <= m; j++)
            if (b[i][j] != a[x + i - 1][y + j - 1])
                return false;
    return true;
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i] + 1;
    for (int i = 1; i <= m; i++)
        cin >> b[i] + 1;
    for (int i = 1; i + m - 1 <= n; i++)
        for (int j = 1; j + m - 1 <= n; j++)
            if (Check(n, m, i, j)) {
                cout << "Yes\n";
                return 0;
            }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
import queue

n = int(input())


q = queue.Queue()

for i in range(1,10):
    q.put(i)

x = 0
for i in range(n):
    x = q.get()
    l = x % 10
#    print(x,l)
    if l != 0:
        q.put(x*10 + l - 1)
    q.put(x*10 + l)
    if l != 9:
        q.put(x*10 + l + 1)
        
#while not q.empty():
#    print (q.get())
    
print(x)


Measured memory_bytes: 12480