akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

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

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int w, h;
	cin >> h >> w;

	vector<string> s(h);

	for (int y = 0; y < h; y++) {
		cin >> s[y];
	}

	queue<P> q;
	q.push(P(0, 0));

	while (q.size()) {
		auto t = q.front();
		q.pop();
		s[t.second][t.first] = '.';
		{
			int x = t.first + 1;
			int y = t.second;
			if (check(x, y, w, h) && s[y][x] == '#') {
				q.push(P(x, y)); continue;
			}
		}
		{
			int x = t.first;
			int y = t.second + 1;
			if (check(x, y, w, h) && s[y][x] == '#') {
				q.push(P(x, y)); continue;
			}
		}
	}

	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			if (s[y][x] == '#') {
				cout << "Impossible" << endl; return 0;
			}
		}
	}

	cout << "Possible" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(void)
{
  unsigned long int N,A,B;
  std::cin >> N >> A >> B;
    
  unsigned long int  m = N/(A+B);
  unsigned long int  p = N%(A+B);
    
  if( A < p )
  {
    std::cout << (m+1)*A <<std::endl;
  }else{
    std::cout << m*A + p <<std::endl;
  }    
    
 return 0; 
}

Measured memory_bytes: 256
N, M = map(int, input().split())

def flip(a,b):
    A = max(a,b)
    B = min(a,b)

    if B >= 2:
        return (A-2) * (B-2)

    if B == 1:
        if A >= 2:
            return A-2
        elif A == 1:
            return 1

a = flip (N, M)
print(a)


Measured memory_bytes: 38256
A, B, C = map(int, input().split())
if A == B == C:
  if A % 2 == 0:
    print(-1)
  else:
    print(0)
else:
  ans = 0
  while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    p, q, r = A // 2, B // 2, C // 2
    A, B, C = q + r, p + r, p + q
    ans += 1
  print(ans)

Measured memory_bytes: 61652
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    if(abs(x-a) > abs(x-b)){
      cout << 'B';
    }else{
      cout << 'A';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	
	while (1) {
		int n;

		cin >> n;
		if (n == 0) {
			break;
		}

		vector<string> l(n);
		vector<int> p(n), a(n), b(n), c(n), d(n), e(n), f(n), s(n), m(n), time(n), money(n);
		vector<double>adv(n);
		vector< pair<double, string> > pa(n);

		

		FOR(i, 0, n - 1) {
			cin >> l[i] >> p[i] >> a[i] >> b[i] >> c[i] >> d[i] >> e[i] >> f[i] >> s[i] >> m[i];
			int timetmp = 0;
			int moneytmp = 0;
			timetmp = a[i] + b[i] + c[i] + (d[i] + e[i])*m[i];
			moneytmp = f[i] * m[i] * s[i];
			moneytmp -= p[i];
			adv[i] = (double)moneytmp / (double)timetmp;
			pa[i].first = adv[i];
			pa[i].second = l[i];

			//cout << moneytmp << " " << timetmp << endl;
		}

		sort(pa.begin(), pa.end());

		double tmp;
		int first;
		int second;

		

		RFOR(i, n - 1, 0) {
			tmp = pa[i].first;
			first = i;
			second = i;
			RFOR(j, i-1, 0) {
				//cout << i << " " << j << " " << tmp << " " << pa[j].first << endl;
				if (tmp == pa[j].first) {
					if (j == 0) {
						second = 0;
						break;
					}
					continue;
				}
				else {
					second = j + 1;
					break;
				}
			}
			i = second;
			//cout << first << " " << second << endl;
			FOR(j, second, first) {
				cout << pa[j].second << endl;
			}

		}

		/*RFOR(i, n - 1, 0) {
			cout << pa[i].second << endl;
		}*/

		cout << "#" << endl;


	}



	
	

	return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

vector<bool> prime_table(int n) {
  vector<bool> prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x; cin >> x;
  auto pt = prime_table(200000);
  int ind = x;
  while(!pt[ind]) ind++;
  cout << ind << endl;
  return 0;
}



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


int main(){
    int N;
    cin >> N;
    bool F[111][11]={0};
    int P[111][11];
    int c[111]={0};
    
    for(int i=0; i<N; i++){
        for(int j=0; j<10; j++){
            cin >> F[i][j];
        }
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<=10; j++){
            cin >> P[i][j];
        }
    }
    
    int Ma=-1e9;
    for(int bit=1; bit < (1<<10); bit++){
        int sum=0;
        fill(c,c+111,0);
        for(int i=0; i<10; i++){
            if(bit & (1<<i)){
                for(int j=0; j<N; j++){
                    if(F[j][i]==1){
                        c[j]++;
                    }
                }
            }
        }
        for(int i=0; i<N; i++){
            sum += P[i][c[i]];
        }
        
        Ma = max(Ma, sum);
        
    }
    
    cout << Ma << endl;
}

Measured memory_bytes: 256
/* 
Mohit Dhattarwal
*/
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define gcd(a,b) __gcd(a,b)
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define filewr() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
 
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,ll> psl;
typedef pair<ll,string> pls;
 
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}
 
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
 
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
const ld PI = 3.1415926535897932384626433832795;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;

void solve()
{
	ll n;
	cin>>n;
	map<ll,ll> m;
	ll x;
	ll sum = 0;
	
	for(ll i =0; i<n; i++)
	{
		cin>>x;
		sum+=x;
		m[x]++;
	}
	ll q,a,b;
	cin>>q;
	for(ll i =0; i<q; i++)
	{
		cin>>a>>b;
		sum-=(m[a]*a);
		sum+=(m[a]*b);
		m[b] += m[a];
		m[a] = 0;
		
		cout<<sum<<'\n';
	}
}

int main(){
	fastio();
	ll t;
	t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

#define MAX_N (100)

int main(int argc, char *argv[]) {
  // read inputs
  int N, X, ls[MAX_N];
  scanf("%d %d", &N, &X);
  for (int i = 0; i < N; i++) {
    scanf("%d", &ls[i]);
  }

  // solve
  int d = 0, cnt = 1;
  for (int i = 0; i < N; i++) {
    d += ls[i];
    if (d <= X) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
void InsertionSort(int N, vector<int>& A) {
	for (int i = 1; i < N; i++) {
		if (A.at(i - 1) > A.at(i)) {
			int tmp = A.at(i);
			int j = i - 1;
			while (j >= 0) {
				if (A.at(j) <= tmp) break;
				A.at(j + 1) = A.at(j);
				j--;
			}
			A.at(j) = tmp;
		}
		for (int k = 0; k < N; k++) {
			cout << A.at(k);
			if (k != N - 1) cout << ' ';
		}
		cout << endl;
	}
}
long long GCD(long long A, long long B) {
	if (B == 0) return A;
	else return GCD(B, A % B);
}
bool Prime_Num(long long N) {
	for (long long i = 2; i <= sqrt(N); i++) {
		if (N % i == 0) {
			return false;
		}
	}
	return true;
}
void BubbleSort(long long N, vector<long long>& A) {
	long long ans = 0;
	long long Limits = N;
	for (int i = 0; i < N; i++) {
		for (long long i = 1; i < Limits; i++) {
			if (A.at(i - 1) > A.at(i)) {
				ans++;
				swap(A.at(i - 1), A.at(i));
			}
		}
		Limits--;
	}
	for (long long i = 0; i < N; i++) {
		cout << A.at(i);
		if (i != N - 1) cout << ' ';
	}
	cout << endl << ans << endl;
}
void SelectionSort(long long N, vector<long long>& A) {
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		long long Pos = i;
		for (long long j = i; j < N; j++) {
			if (A.at(j) < A.at(Pos)) Pos = j;
		}
		if (Pos != i) {
			ans++;
			swap(A.at(i), A.at(Pos));
		}
	}
	for (long long i = 0; i < N; i++) {
		cout << A.at(i);
		if (i != N - 1) cout << ' ';
	}
	cout << endl << ans << endl;
}
int main() {
	long long N;
	cin >> N;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	SelectionSort(N, A);
}


Measured memory_bytes: 3116
N = int(input())
A = 0
ans = ''
for i in range(1,15):
    if N <= A + 26 ** i:
        l = i
        break
    A += 26**i

M = N - A - 1

for i in range(l):
    c = M % 26
    M //= 26
    ans += chr(ord('a') + c)

print(ans[::-1])

Measured memory_bytes: 9136
#input S
S=input()

count=0
for i in range(1,len(S)):
    if S[i]==S[i-1]:
        if S[i]=='0':
            S=S[:i]+'1'+S[i+1:]
        else:
            S=S[:i]+'0'+S[i+1:]
        count=count+1

print(count)



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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
typedef struct po{
  int x,y;
}Point;
class polygon{
public:
  int mm;
  vector<Point> p;
  polygon(int m){
    mm = m;
    p.resize(mm);
    for(int i=0;i<mm;i++){
      cin>>p[i].x>>p[i].y;
    }
  }
  void rotate(){
    for(int i=0;i<mm;i++){
      Point tmp=p[i];
      p[i].x=-tmp.y;
      p[i].y=tmp.x;
    }
  }

  bool check(Point a,Point b,Point a2,Point b2){
    return ((b.x-a.x)==(b2.x-a2.x)&&(b.y-a.y)==(b2.y-a2.y));
  }

  bool search(vector<Point> origin){
    bool flag1=true;
    bool flag2=true;
    if(origin.size()!=p.size())return false;
    for(int i=0;i<mm-1;i++){
      if(!check(p[i],p[i+1],origin[i],origin[i+1]))
	flag1=false;
      if(!check(p[mm-(i+1)],p[mm-(i+2)],origin[i],origin[i+1]))
	flag2=false;
    }
    if(flag1||flag2)
      return true;
    else
      return false;
  }
};
int main(){
  int n;
  while(cin>>n,n){
    vector<int>ans;
    int mm;cin>>mm;
    polygon origin(mm);
    for(int i=1;i<=n;i++){
      int m;cin>>m;
      polygon pg(m);
      for(int j=0;j<4;j++){
	if(pg.search(origin.p)){
	  ans.pb(i);
	  break;
	}
	pg.rotate();
      }
    }
    for(int i=0;i<ans.size();i++)
      cout<<ans[i]<<endl;
    cout<<"+++++"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main() {
    string s,t;
    cin>>s>>t;
    bool ok=true;
    for (int i = 0; i < s.size(); i++)
    {
        /* code */
        if (s[i]!=t[i])
        {
            /* code */
            ok=false;
        }
        
    }
    if (ok)
    {
        /* code */
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    
    
}

Measured memory_bytes: 3636
#include <cstdio>

int main()
{
  long long n;
  scanf("%lld", &n);
  if (n & 1)
  {
    puts("0");
    return 0;
  }
  long long ans = 0;
  for (long long i = 10; i <= n; i *= 5)
  {
    ans += n / i;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string
import sys
from array import array
from collections import deque

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

s = deque()
s.append(input())
Q = int(input())
rev_count = 0

for i in range(Q):
    a = input()
    if a[0] == "1":
        rev_count += 1
    else:
        b = a.split()
        if rev_count % 2 == 0:
            if b[1] == "1":
                s.appendleft(b[2])
            else:
                s.append(b[2])
        else:
            if b[1] == "1":
                s.append(b[2])
            else:
                s.appendleft(b[2])

if rev_count % 2 == 0:
    print(''.join(s))
else:
    a = ''.join(s)
    print(a[::-1])



Measured memory_bytes: 8732
a,b,c,d=input()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
if 1<=10*a+b<=12 and 1<=10*c+d<=12:
  print("AMBIGUOUS")
elif 1<=10*a+b<=12 and (10*c+d==0 or 10*c+d>=13):
  print("MMYY")
elif (10*a+b==0 or 10*a+b>=13) and 1<=10*c+d<=12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next(),b = sc.next();
    for(int i = 0;i < b.length();i++){
      System.out.print(a.substring(i,i+1)+b.substring(i,i+1));
    }
    if((a.length() - b.length()) % 2 == 1){
      System.out.print(a.substring(a.length()-1,a.length()));
    }
  }
}


Measured memory_bytes: 22608
#include <iostream>

using namespace std;

int main() 
{
    int a, b, c, i, ans;
    cin >> a >> b >> c;
    ans = 0;
    for(i=a; i<=b; i++)
    {
        if(c % i == 0)
       ans = ans + 1;
    }
    cout << ans << endl;
}    


Measured memory_bytes: 3108
function Main(input){
	input=input.split(/\n|\s/);
	var arr=[];
	var jl=input[0].length;
	for(var i=0;i<jl;i=(i+1)|0){
		for(var k=1;k<6;k=(k+1)|0){
			arr[arr.length]=input[0].slice(i,k+i);
		}
	}
	arr=arr.filter(function(x,i,self){return self.indexOf(x)===i;});
	arr.sort();
	console.log(arr[(input[1]|0)-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int x = sc.nextInt();
        System.out.println(x*x*x);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 24244
import sys
import heapq


def input():
    return sys.stdin.readline().strip()


def dijkstra(start, n_nodes, edge):
    dist = [float("inf")] * n_nodes
    dist[start] = 0
    # 優先度キューの準備
    q = [(dist[start], start)]
    heapq.heapify(q)
    while q:
        # スタートから最も最短距離のものを取り出す
        d, i = heapq.heappop(q)
        # 記録してある情報よりも，取り出した要素に入っている距離情報の方が大きければ
        # 打ち切り．次の要素を取り出す操作に戻る
        if dist[i] < d:
            continue
        # そこから移動できる頂点を探し，最短距離が更新できるものがあれば，
        # 距離を更新して，その頂点への距離と頂点の方法を優先度キューにpush
        for cost, j in edge[i]:
            if dist[j] > dist[i] + cost:
                dist[j] = dist[i] + cost
                heapq.heappush(q, (dist[j], j))
    return dist


def main():
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        edge[u - 1].append([w, v - 1])
        edge[v - 1].append([w, u - 1])
    D = dijkstra(0, N, edge)
    for d in D:
        if d % 2 == 0:
            print(0)
        else:
            print(1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 49184
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()

dp = [99999999]*(n+1)
dp[0] = 0
for i in range(1, n+1):
    dp[i] = dp[i-1] + 1
    k = 6
    while i-k >= 0:
        dp[i] = min(dp[i], dp[i-k]+1)
        k *= 6
    k = 9
    while i-k >= 0:
        dp[i] = min(dp[i], dp[i-k]+1)
        k *= 9
print(dp[n])



Measured memory_bytes: 42604
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.00001;

int main() {
    int n;
    scanf("%d",&n);
    vector<pair<int,int>> r(n);
    for(int i = 0;i < n;i++) scanf("%d %d",&r[i].first,&r[i].second);
    sort(r.begin(),r.end(),[](auto& i,auto& j){return i.second < j.second;});
    int t = 0,p = 1;
    for(auto& e:r) {
        t += e.first;
        if(e.second < t) p = 0;
    }
    printf("%s\n",(p ? "Yes" : "No"));
}


Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



constexpr int MAX_SIZE = 2e5+1;
int n, q, l = 0, r;
using Quiz = std::pair<char, bool>;
std::stack<Quiz> questions;
char Golem[MAX_SIZE];
char a, b;
bool c;

int main(void){
  scanf("%d %d\n", &n, &q);
  r = n - 1;
  scanf("%s", Golem);
  REP(_, q){scanf("\n%c %c", &a, &b); questions.push(make_pair(a, b == 'L'));}
  REP(_, q){
    //cout << a << ' ' << c << BR;
    a = questions.top().first;
    c = questions.top().second;
    questions.pop();
    if(c){ // L
      if(Golem[l] == a) l++;
      if(r != n - 1 and Golem[r+1] == a) r++;
    }
    else{
      if(l != 0 and Golem[l-1] == a) l--;
      if(Golem[r] == a) r--;
    }
  }
  printf("%d\n", r-l+1);
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int n, q, t;
    string name;

    queue<pair<string, int> > Q;

    cin >> n >> q;

    for(int i = 0; i < n; i++){
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }

    pair<string, int> u;
    int elaps = 0, a;

    while(!Q.empty()){
        u = Q.front();
        Q.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if(u.second > 0){
            Q.push(u);
        }else {
            cout << u.first << " " << elaps << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6388
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
using namespace std;
int n, m, i, j, k, t;
int main(){
	cin>>n;
	if(n>=90) {cout<<"Yes";return 0;}
	if(n%10==9) {cout<<"Yes";return 0;}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import bisect, collections

def solution():
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(a[int(input().strip())-1])
    



def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()
    

main()

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int k;
int n;
int a[maxn];

int main(){
    migmig
    cin >> k >> n;
    int mx = 0;
    for(int i = 0 ; i < n ; i ++){
        cin >> a[i];
    }
    for(int i = 0 ; i < n-1 ; i ++){
        mx = max(mx , abs(a[i] - a[i+1]));
    }
    mx = max(mx , k - a[n-1] + a[0]);
    cout << k - mx;

    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std; typedef long long ll;
typedef pair<ll,ll> P;

int main() {
  int n; cin>>n;
  int a[n]; for(int i=0;i<n;i++) cin>>a[i];
  int sm=0; for(int i=0;i<n;i++) sm+=a[i];
  int mn=1e9, id=-1;
  for(int i=0;i<n;i++) {
    if (abs(sm-a[i]*n)<mn) mn=abs(sm-a[i]*n), id=i;
  }
  cout<<id<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int x[5];
    rep(i,5)cin>>x[i];
    rep(i,5){
        if(x[i]==0){
            cout<<i+1<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(N);
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }
    
    int sum1 = 0;
    for (int i = X; 0 < i; i--) {
        for (int  j = 0; j < A.size(); j++) {
            if (i == A[j]) {
                sum1++;
            }
        }
    }
    int sum2 = 0;
    for (int i = X; i < N; i++) {
        for (int  j = 0; j < A.size(); j++) {
            if (i == A[j]) {
                sum2++;
            }
        }
    }
    cout << min(sum1, sum2) << endl;
}

Measured memory_bytes: 256
# 足し合わせしすぎてるのでTLE
import sys
input = sys.stdin.readline

def main():
    H, W, K = map(int, input().split())
    grid = [list(map(int, list(input().strip()))) for _ in range(H)]

    # 折れる箇所全部で折った数が最大値
    ans = (H - 1) * (W - 1)

    # 横線で割るパターン全てについて縦線での降り方を考える
    for i in range(2 ** (H - 1)):
        snap = 0

        hori_grid = [grid[0]]
        for j in range(H - 1):
            if ((i >> j) & 1):
                hori_grid.append(grid[j+1])
                snap += 1
            else:
                hori_grid[-1] = [a + b for a,b in zip(hori_grid[-1], grid[j+1])]

        wc_count = [hori_grid[y][0] for y in range(snap + 1)]

        # 最初の列で超えてる場合はスキップ
        if max(wc_count) > K:
            continue

        for x in range(1, W):
            now_wc_count = [hori_grid[y][x] for y in range(len(wc_count))]
            next_wc_count = [a+b for a,b in zip(wc_count, now_wc_count)]

            if max(next_wc_count) > K:
                snap += 1
                wc_count = now_wc_count
            else:
                wc_count = next_wc_count

        ans = min(ans, snap)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <cstdio>
#include <queue>
using namespace std;

#define INF 1000
int D[10][30],M,C,N;

bool check(int p, int v)
{
	for(int i=0; i<C; i++)
	{
		if(D[p][i]==v)
		{
			for(int j=i; j<C-1; j++)
				D[p][j]=D[p][j+1];
			
			D[p][C-1]=INF;
			return true;
		}
	}
		
	return false;
}

void set(int p, int v)
{
	for(int i=0; i<C; i++)
	{
		if(D[p][i]==INF)
		{
			D[p][i]=v;
			return;
		}
	}
}

int isempty()
{
	for(int i=0; i<M; i++)
	for(int j=0; j<C; j++)
		if(D[i][j]==INF) return i+1;
		
	return -1;
}

int main()
{
	while(scanf("%d%d%d", &M,&C,&N), (M||C||N))
	{
		for(int i=0; i<M; i++)
		for(int j=0; j<C; j++)
			D[i][j]=INF;
			
		queue<queue<int> > q;
		for(int i=0; i<N; i++)
		{
			int K;
			scanf("%d", &K);
			queue<int> tq;
			for(int j=0; j<K; j++)
			{
				int t;
				scanf("%d", &t);
				tq.push(t);
			}
			q.push(tq);
		}

		int ret=0;
		while(!q.empty())
		{
			queue<int> tq=q.front(); q.pop();
			int id=tq.front(); tq.pop();
			
			bool g=false;
			for(int i=0; i<M; i++)
			{
				if(check(i,id))
				{
					ret+=i+1;
					g=true;
					break;
				}
			}
			
			if(!g)
			{
				ret+=M+1;
			}
			
			if(check(0,INF)) 
			{
				set(0,id);
				ret++;
			}
			else
			{
				int tp=0;
				g=false;
				for(int i=0; i<M; i++)
				{
					if(check(i,INF))
					{
						set(i,id);
						tp=i+1;
						
						ret+=tp;
						
						g=true;
						break;
					}
				}
				if(!g) 
				{
					ret+=M+1;
					ret++;
					ret+=M+1;
					ret+=M+1;
					ret++;
					check(0,D[0][0]);
					set(0,id);
				}
				else
				{
					int f=isempty();
					check(tp-1, id);
					if(f==-1)
					{
						ret++;
						ret+=M+1;
						check(0, D[0][0]);
						set(0, id);
						ret++;
						ret+=tp;
					}
					else
					{
						ret++; 
						ret+=f;		 
						int tt=D[0][0];
						check(0,D[0][0]);
						set(0,id);
						set(f-1, tt);
						
						ret+=tp;  
						
						ret++;
					}
				}
			}
			
			if(!tq.empty()) q.push(tq);
		}
		
		printf("%d\n", ret);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

int main()
{
	int m;
	cin >> m;
	string x, y, z, w;
	rep(i, m)
	{
		cin >> x;
		int k=x.size();
		map<string, int> table;
		int ans=0;
		repp(j, 1, k)
		{
			y=x;
			y.resize(j);
			z=x;
			w=x.substr(j);
			rep(l, 8)
			{
				string s=y, t=w;
				if(l%2==0)	reverse(s.begin(), s.end());
				if((l/2)%2==0)	reverse(t.begin(), t.end());
				if(l<4) swap(s, t);
				string u=s+t;
				table[u]++;
				if(table[u]==1) ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    
    if((a % 2 == 1) & (b % 2 == 1)) cout << "Odd" << endl;
    else cout << "Even" << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 料理の数 */
	private static final int N = 5;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int[] n = IntStream.range(0, N).map(i -> scanner.nextInt()).boxed().sorted((x, y) -> {
				int xremain = x % 10, yremain = y % 10;
				return Integer.compare((yremain == 0) ? 10 : yremain, (xremain == 0) ? 10 : xremain);
			}).mapToInt(Integer::intValue).toArray();
			int sum = Arrays.stream(n).limit(N - 1).map(i -> ceiling10(i)).sum() + n[N - 1];
			System.out.println(sum);
		}
	}

	/**
	 * ceiling(n/10)*10 を計算する
	 * 
	 * @param n
	 * @return ceiling(n/10)*10
	 */
	private static int ceiling10(int n) {
		return (n + 9) / 10 * 10;
	}
}


Measured memory_bytes: 36480
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BTheater {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    int l, r;
	    ll sum = 0;
	    in >> n;
	    for(int i=0; i<n; i++){
	        in >> l >> r;
	        sum += r - l + 1;
	    }

	    out << sum << endl;
	}
};


int main() {
	BTheater solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int K = sc.nextInt();
		int S = sc.nextInt();
		int ans = 0;
		
		for(int x = 0; x <= K; x++){
			for(int y = 0; y <= K; y++){
				int z = S - x - y;
				if(z >= 0 && z <= K) ans++;
			}
		}
		
		System.out.println(ans);
	}
}

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

int n, l;
string s[100];

int main() {
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);

	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main(){
int N;
cin>>N;
pair<ll,ll> arm[N];
rep(i,N){
    ll X,L;
    cin>>X>>L;
    arm[i]=make_pair(X+L,X-L);
}
int count=0,now=-1e9;
sort(arm,arm+N);
rep(i,N){
    if(arm[i].second>=now){
        now=arm[i].first;
        count++;
    }
}
cout<<count<<endl;




return 0;
}

Measured memory_bytes: 5084
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

int main(){
    ll x=0,g=0,n,w,l,ans=0,ptr=0;
    string s,s1,s2;
    cin >> n;
    VVI h(n, vector<int>(3));
    VVI dp(n, vector<int>(3));
    rep(i,n){
        rep(j,3)
            cin >> h[i][j];
	}

    rep(i,3){
        dp[0][i] = h[0][i];
    }
    for(int i=0;i<n-1;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(k!=j)
                    dp[i+1][j] = max(dp[i+1][j], dp[i][k]+h[i+1][j]);
            }
        }
    }
    cout << *max_element(ALL(dp[n-1])) << endl;
    return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(ll i=a;i<=(ll)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;
char a[22][22];
bool b[22][22];
int bfs(int w,int x,int y,int z) {
    if(a[w][x]=='#'||a[y][z]=='#'||(w==y&&x==z)) return 0;
    memset(b,0,sizeof b);b[w][x]=1;
    queue<pair<ii,int>> q;q.push({{w,x},0});
    while(!q.empty()) {
        int i=q.front().fi.fi,j=q.front().fi.se,t=q.front().se;
        q.pop();
        if(i==y&&j==z) return t;
        if(!b[i+1][j]&&a[i+1][j]!='#') {q.push({{i+1,j},t+1});b[i+1][j]=1;}
        if(!b[i-1][j]&&a[i-1][j]!='#') {q.push({{i-1,j},t+1});b[i-1][j]=1;}
        if(!b[i][j+1]&&a[i][j+1]!='#') {q.push({{i,j+1},t+1});b[i][j+1]=1;}
        if(!b[i][j-1]&&a[i][j-1]!='#') {q.push({{i,j-1},t+1});b[i][j-1]=1;}
    }
}
int main() {
    cs
    memset(a,'#',sizeof a);
    int r,c,ans=0;cin>>r>>c;
    repp(i,1,r) repp(j,1,c) 
    cin>>a[i][j];
    repp(i,1,r) {
        repp(j,1,c) {
            repp(k,1,r) {
                repp(l,1,c) {
                    ans=max(ans,bfs(i,j,k,l));
                }
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
//----------------------Shanu Garg here---------------------
//-------------Search on youtube : Shanu Garg---------------
//-Studying at National Institute of Technology Delhi(NITD)-
//---------------------From Delhi, India--------------------

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

#define f(i,n) for(auto i=0;i<n;i++)
#define fr(i,n) for(auto i=n-1;i>=0;i--)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define memset(a,first,last,val) fs(i,first,last,1) a[i]=val
#define nl cout<<"\n";
#define chk(x) cout<<#x<<x<<" ", nl
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vvi vector<vi>
#define pr pair<ll, ll>
#define vii vector<pair<int, int>>
#define vll vector<pr>
#define vl vector<ll>
#define m(a,b) map<a, b>
#define mid(a,b) ((a+b)/2)
#define pb push_back
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;

vl vb;
int N;

class triplet{
    public:
    ll f, s, t;};

vl in(ll n){
    vl ar;
    ll x;
    f(i,n)
    cin>>ar[i];
    return ar;
}
vll in_pr(ll n){
    vll ar;
    ll x,y;
    f(i,n)
    {cin>>x>>y;
    ar[i]={x,y};
    }return ar;
}
void out(vl v, char ch='\0'){
    fl(i,v)
    cout<<i<<ch;
}

void printArray(vector<int> arr, int n) 
{ 
    ll num=0;
    for (int i = 0; i < n; i++) 
    num*=10, num+=i;

    if(n==N)
    vb.pb(num);
        
} 

int printfactorialof(int n){
    if(n<=1)
        return 1;
    
    return n*printfactorialof(n-1);
}

void solve(){
ll ans=0;
string str;
m(char, ll) mymap;
cin>>str;
fl(i, str)
 mymap[i]++;

if(mymap['+'] > mymap['-'])
cout<<mymap['+']-mymap['-'], nl

if(mymap['+'] == mymap['-'])
cout<<'0',nl

if(mymap['-'] > mymap['+'])
cout<<"-"<<mymap['-']-mymap['+'] , nl

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
   return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;

char d[1011];

int main()
{
    int i,j,k;
    int a,b,c;
    
    cin>>d;
    for(i=0;i<4;i++)
    {
        cout<<d[i];
    }
    cout<<' ';
    for(i=4;i<strlen(d);i++)
    {
        cout<<d[i];
    }
    cout<<endl;
    
    
    return 0;
}


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

int main(){
  int W,a,b;
  cin >> W >> a >> b;
  int min_distance = max(a,b) - min(a+W,b+W);
  if(min_distance < 0)cout << 0 << endl;
  else cout << min_distance <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

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

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//BELOW

void solve(void)
{ 
  int H,W;
  cin>>H>>W;
  map<char,int> mp;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      char X;cin>>X;
      mp[X]++;
    }
  }
  map<int,int> mp2;
  for (auto &&x : mp)
  {
    mp2[x.second%4]++;
  }
      int res = 1;
  if(H%2 == 1 and W%2 == 1)
  {

    if(mp2[1] + mp2[3] > 1) res = 0;
    if(mp2[2]*2 > H+W-2)res = 0;

  }
    else if(H%2 == 1||W%2 == 1)
    {
      if(mp2[1] + mp2[3] != 0)res = 0;
      if(H%2 == 1)
      {
        if(mp2[2]*2 > W)res = 0;
      }
      else
      {
        if(mp2[2]*2 > H) res = 0;
      } 
    }
    else
    {
      if(mp2[1] + mp2[2] + mp2[3] > 0)res = 0;
    }
    
      if(res)
    {
      cout<<"Yes"<<endl;
    }
    else
    {
      cout<<"No"<<endl;
    }
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

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

  return 0;
}


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

int main(){
    string s,t;
    cin>>s>>t;
    int minj=1000;
    rep(i,s.size()-t.size()+1){
        int count=0;
        rep(j,t.size()){
            if(s[i+j]!=t[j])count++;
        }
        minj=min(minj,count);
    }
    cout<<minj<<endl;
    return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main(void)
{
	int n, t, a, h[1001], i,ans;
	double mini,x[1001];
	scanf("%d%d%d", &n, &t, &a);
	for (i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		x[i] = fabs((double)(a)-((double)(t) - h[i] * 0.006));
	}
	for (i = 0; i < n; i++) {
		if (i == 0) {
			mini = x[i];
			ans = 1;
		}
		else {
			if (mini > x[i]) {
				mini = x[i];
				ans = i + 1;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

def gcd(x, y):
    if x < y:
        x = x ^ y
        y = x ^ y
        x = x ^ y
    div = x % y
    while div != 0:
        x = y
        y = div
        div = x % y
    return y

def lcm(x, y):
    return x*y//gcd(x, y)


A,B,C,D=LI()

Cnum = B//C - A//C + (not A % C)
Dnum = B//D - A//D + (not A % D)
# print(Cnum)
# print(Dnum)
LC = lcm(C,D)
LCnum = B//LC - A//LC + (not A % LC)

BAISUU = ((Cnum + Dnum) - LCnum)
print((B-A+1) - ((Cnum + Dnum) - LCnum))

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(void){
         char s[101];
         char p[101];
         char check[202];
 
         scanf("%s %s", s, p);
 
         strcpy(check, s);
 
         strcat(check, s);
 
         if(strstr(check, p))
                 puts("Yes");
         else
                 puts("No");
 
         return 0;
}


Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		long A = scn.nextLong();
		long B = scn.nextLong();
		long k = scn.nextLong();
		boolean a = true;
		for(int i = 0;i < k;i++) {
			if(a) {
				A /=2;
				B += A;
			}else {
				B /= 2;
				A +=B;
			}
			a = !a;
		}
		System.out.println(A + " " + B);
	}
}


Measured memory_bytes: 24276