akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }


vector<int> to[200010];
vector<int> ans;

void dfs(int v, int p=-1){
  for(int u: to[v]){
    if(u == p) continue;
    ans[u]+=ans[v];
    dfs(u,v);
  }
}

signed main()
{
  int n,q; cin>>n>>q;
  rep(i,n-1){
    int a,b;cin>>a>>b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i,q){
    int p, x;
    cin>>p>>x;
    --p;
    ans[p]+=x;
  }
  dfs(0);
  rep(i,n){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 23424
from sys import stdin
N = int(stdin.readline().rstrip())
Lucas_number = [0]*(N+1)
Lucas_number[0] = 2
Lucas_number[1] = 1
for i in range(2,N+1):
    Lucas_number[i] = Lucas_number[i-1] + Lucas_number[i-2]
print(Lucas_number[N])

Measured memory_bytes: 3060
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    s=STR()
    count='1234567890'
    flg=1
    for i in range(len(s)):
        if i!=a:
            if s[i] in count:
                pass
            else:
                flg=0
        else:
            if s[i]=='-':
                pass
            else:
                flg=0
    if flg==1:
        print('Yes')
    else:
        print('No')
        
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
import java.util.Scanner;

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

    public Main() {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        int exp = (int) Math.floor(Math.log(H) / Math.log(2));
        long result = 0;
        for (int i = 0; i <= exp; i++) {
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>
#define LL long long
#define INF 1ll<<60
using namespace std;
const int N=2e5+100;
const int M=4e5+100;
const int mod=1e9+7;
int head[N],Next[M],ver[M],tot;
void add(int x,int y) {
    ver[++tot]=y;
    Next[tot]=head[x];
    head[x]=tot;
}

int vis[N];

int main() {
	int n,m;
    while(cin>>n>> m) {
        tot=1;
        
        memset(head,0,sizeof(head));
        memset(Next,0,sizeof(Next));
        memset(ver,0,sizeof(ver));
		memset(vis,0,sizeof(vis));
		
		for(int i=1;i<=m;i++){
			
			int x,y;
			cin >> x >> y;
			if(x==1)vis[y]++;
			if(y==n)vis[x]++;
		}
		

		int flag=0;
		for(int i=1;i<=n;i++){
			if(vis[i]>=2){
				flag=1;
				break;
			}
		}
		if(flag)cout<<"POSSIBLE"<<endl;
		else cout<<"IMPOSSIBLE"<<endl;
        
    }
    return 0;

}


Measured memory_bytes: 4992
n,k = map(int,input().split())
points = []
for _ in range(n):
  x,y = map(int,input().split())
  points.append((x,y))

points.sort()
ans = float('inf')

for i in range(n-k+1):
  for j in range(i+k-1,n):
    y_sorted = sorted(points[i:j+1], key = lambda x:x[1])
    height_min = float('inf')
    for l in range(j-i-k+2):
      height_min = min(height_min,y_sorted[l+k-1][1] - y_sorted[l][1])
    ans = min(ans, (points[j][0]-points[i][0])*height_min)
print(ans)

Measured memory_bytes: 3064
n = gets.chop.to_i
a = gets.split.map(&:to_i)

cnt = 0
n.times do |i|
  if a[i] < 0
    cnt += 1
  end
end

s = a.map do |i| i.abs end
if cnt%2 != 0
  s.min
  ans = s.inject(:+) - (s.min*2)
  puts ans
else
  ans = s.inject(:+)
  puts ans
end


Measured memory_bytes: 9476
a = input()
A = int(a)
b = input().split()
x = 0
y = 0
for i in range(A):
    if int(b[int(i)]) % 2 == 0:
        if int(b[int(i)]) % 3 == 0:
            x = x + 1
        elif int(b[int(i)]) % 5 == 0:
            x = x + 1
        y = y + 1
if x == y:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;

  ll ans = (1900 * m + 100 * (n - m))*(1LL << m);

  cout << ans << endl;

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    int a, b, c[N];
    vector<int> v[N];
    
    for(int i = 0; i < N - 1; i++){
        cin >> a >> b;
        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
    }
    
    for(int i = 0; i < N; i++) 
        cin >> c[i];
    sort(c, c+N, greater<int>());
    int sum = 0;
    for(int i = 1; i < N; i++)
        sum += c[i];
    
    bool searched[N];
    for(int i = 0; i < N; i++)
        searched[i] = false;
        
    queue<int> ans;
    
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int cur = q.front();
        q.pop();
        
        if(searched[cur]){
            continue;
        }
        ans.push(cur);
        int size = v[cur].size();
        for(int i = 0; i < size; i++){
           int next = v[cur][i];
           if(!searched[next])
                q.push(next);
        }
        searched[cur] = true;
    }
    
    int answer[N];
    for(int i = 0; i < N; i++){
        int cur = ans.front();
        
        
        //cout << cur << c[i] << "\n";
        
        
        ans.pop();
        answer[cur] = c[i];
    }
    
    cout << sum << "\n";
    for(int i = 0; i < N; i++){
        cout << answer[i] << "\n";
    }
    
    return 0;
} 
















Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int g = 0;
    rep(i, n) cin >> a[i], g = gcd(g, a[i]);

    vector<int> cnt(10010010, 0);
    for (int x : a) {
        for (int d = 2; d * d <= x; d++) {
            if (x % d) continue;
            cnt[d]++;
            while (x % d == 0) x /= d;
        }
        if (x > 1) cnt[x]++;
    }

    if (*max_element(all(cnt)) <= 1) {
        cout << "pairwise coprime" << endl;
    } else if (g == 1)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
}

Measured memory_bytes: 46300
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

struct st{
    int x,y,z;

    bool operator < (st a)const{
        if(x!=a.x)return x<a.x;
        if(y!=a.y)return y<a.y;
        return z<a.z;
    };
};


int main(){
    int n,h;
    while(cin>>n>>h&&(n||h)){
        set<pii> xy,xz,yz;
        
        rep(i,h){
            string s;
            int a,b;
            cin>>s>>a>>b;
            a--,b--;
            if(s=="xy")xy.insert(pii(a,b));
            if(s=="xz")xz.insert(pii(a,b));
            if(s=="yz")yz.insert(pii(a,b));
        }
        
        int c=0;
        map<st,int> cross;
        for(auto &e_xy:xy){
            bool f=false;
            for(auto &e_xz:xz){
                if(e_xy.first==e_xz.first){
                    cross[st{e_xy.first,e_xy.second,e_xz.second}]++;
                    f=true;
                }
            }
            if(f)c++;
        }

        for(auto &e_yz:yz){
            bool f=false;
            for(auto &e_xy:xy){
                if(e_yz.first==e_xy.second){
                    cross[st{e_xy.first,e_xy.second,e_yz.second}]++;
                    f=true;
                }
            }
            if(f)c++;
        }

        for(auto &e_xz:xz){
            bool f=false;
            for(auto &e_yz:yz){
                if(e_xz.second==e_yz.second){
                    cross[st{e_xz.first,e_yz.first,e_yz.second}]++;
                    f=true;
                }
            }
            if(f)c++;
        }
        
        int tw=0,th=0;
        for(auto &e:cross){
            if(e.second==1)tw++;
            else if(e.second==3)th++;
            else cout<<e.second<<endl;
        }
        
//       cout<<n*n*n<<" "<<h*n<<" "<<tw<<" "<<th<<endl;
        cout<<n*n*n - h*n + tw + th*2<<endl;
    }
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define int long long

using namespace std;

vector<int> graph[100001];
int dp[100001];

int dfs(int n)
{
    if (dp[n] != -1)
        return dp[n];

    dp[n] = 1;
    for (int i = 0; i < graph[n].size(); i++)
         dp[n] = max(dp[n], dfs(graph[n][i]) + 1);
    return dp[n];
}

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

    int n, m, u, v;
    cin >> n >> m;
    while (m--)
        cin >> u >> v, graph[u].push_back(v);

    fill(dp, dp + 100001, -1);
    for (int i = 1; i <= n; i++)
        dfs(i);

    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = max(ans, dp[i]);
    cout << ans - 1 << '\n';

    return 0;
}


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

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

	vector<int> x(N, 0);
	stack<int> s;
	vector<vector<pair<int, int>>> left(N);
	vector<vector<pair<int, int>>> right(N);
	for (int i = 0; i < M; i++) {
		int L, R, D;
		cin >> L >> R >> D;
		L--;
		R--;
		left[R].push_back({ L, D });
		right[L].push_back({ R, D });
	}

	for (int i = 0; i < N; i++) {
		if (left[i].size() == 0) {
			x[i] = 1;
			s.push(i);
		}
	}

	bool able = true;
	while (!s.empty()) {
		int node = s.top();
		s.pop();
		for (int i = 0; i < right[node].size(); i++) {
			int next = right[node][i].first;
			int xd = x[node] + right[node][i].second;
			if (x[next] == 0) {
				x[next] = xd;
				s.push(next);
			}
			else if (x[next] != xd) {
				able = false;
				break;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		if (x[i] == 0) able = false;
	}

	cout << (able ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 12288
data = raw_input().split()
n = int(data[0])
q = int(data[1])

queue = []
for i in range(n):
	process = raw_input().split()
	process[1] = int(process[1])
	queue.append(process)

time = 0
while len(queue) > 0:
	if queue[0][1] > q:
		queue[0][1] -= q
		time += q
		queue.append(queue[0])
	else:
		time += queue[0][1]
		print("{:} {:}".format(queue[0][0], time))
	del queue[0]

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0; i<n; i++){
  	cin >> a[i];
  }
  
  int ans = 0;
  int tmp = 1;
  while(tmp < n){
    tmp+=(k-1);
    ans++;
  }
    
  cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Station s[] = new Station[N-1];
		Main main = new Main();
		for (int i=0;i<N-1;i++) {
			Station temp = main.new Station();
			temp.C= sc.nextLong();
			temp.S= sc.nextLong();
			temp.F = sc.nextLong();
			s[i] = temp;
		}
		long result[] = new long[N];
		for (int i=0;i<N-1;i++) {
			long now = 0;
			for (int j=i;j<N-1;j++) {
				if (now<=s[j].S) {
					now = s[j].S+s[j].C;
				} else {
					if (now%s[j].F==0) {
						now +=s[j].C;
					} else {
						long next= (now-s[j].S)/s[j].F+1;
						next = s[j].S+s[j].F*next;
						now =next +s[j].C;
					}
				}
			}
			System.out.println(now);
		}
		System.out.println(0);
	}

	public class Station {
		long C;
		long S;
		long F;
	}
}

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	int x;
	cin>>x;
	if(x<1200)
		cout<<"ABC";
	else 
		cout<<"ARC";
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	rep(i, N) cin >> h[i];

	int ans = 0;
	rep(i, N) {
		if (h[i] >= K) ans++;
	}

	cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int Combination(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


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

}


Measured memory_bytes: 3092
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

ll gcd(ll a, ll b){
    if (a<b){
        swap(a,b);
    }
    if(a%b==0){
        return  b;    
    }
    ll c=b;       
    b=a%b;
    return gcd(c,b); 
}
int main() {
 ll n;
 ll t[110];
 cin>>n;
 for(int i=0;i<n;i++) cin>>t[i];
 ll ans=t[0];
 if(n>=2){
 for(int i=1;i<n;i++){
     ll s=ans/gcd(ans,t[i]);
     ans=s*t[i];

 }
 cout<<ans<<endl;
 }
 else{
     cout<<ans<<endl;
 }

    return 0;
}

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

s = 0
mod = 10**9 + 7
for i in range(N-1):
    n = A[i] * A[i+1]
    n = n % mod
    s += n
    s %= mod
    A[i+1] += A[i]
print(s)

Measured memory_bytes: 31600
x,y=map(int,input().split())
if x==0:print(abs(y)+(y<0))
elif y==0:print(abs(x)+(x>0))
elif 0<x<y or x<y<0:print(abs(y-x))
elif 0<y<x or y<x<0:print(2+abs(x-y))
else:print(abs(abs(x)-abs(y))+1)

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int h = in(), w = in();
    vstr a = in(h);

    rep(i, h + 2)
    {
        rep(j, w + 2)
        {
            cout << ((i == 0 || i == h + 1 || j == 0 || j == w + 1) ? '#' : a[i - 1][j - 1]);
        }
        cout << endl;
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
a,b,c,d = map(int,input().split())
import math
lcm = c*d//gcd(c,d)
a_1 = a-1
panish = ((b//c)+(b//d)-(b//lcm))-(((a_1//c)+(a_1//d))-(a_1//lcm))
print(b-a_1-panish)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>

int Partition( std::vector<std::pair<char, int>>& v, int p, int r ){
    int x = v[r].second;
    int i = p - 1;
    for( int j = p; j < r; ++j ){
        if( v[j].second <= x ){
            v[++i].swap( v[j] );
        }
    }
    v[i+1].swap( v[r] );
    return i + 1;
}

void QuickSort( std::vector<std::pair<char, int>>& v, int p, int r ){
    if( p < r ){
        int q = Partition( v, p, r );
        QuickSort( v, p, q-1 );
        QuickSort( v, q+1, r );
    }
}

std::string CheckStable( std::vector<std::pair<char, int>>& initial, std::vector<std::pair<char, int>>& sorted ){
    int N = sorted.size();
    for( int i = 0; i < N; ++i ){
        for( int j = i+1; j < N; ++j ){
            if( initial[i].second == initial[j].second ){
                for( int a = 0/*BinarySearch( sorted, initial[i].second )*/; a < N; ++a ){
                    if( sorted[a].second == initial[i].second ){
                        for( int b = a+1; b < N; ++b ){
                            if( initial[i] == sorted[b] &&
                                initial[j] == sorted[a] ){
                                return "Not stable";
                            }
                        }
                    }
                }
            }
        }
    }
    return "Stable";
}

int main(){
    int n;
    std::cin.tie(0);
    std::cin >> n;

    std::vector<std::pair<char, int>> cards( n );
    int number;
    char symbol;
    for( auto& elem : cards ){
        std::cin >> symbol >> number;
        elem = std::make_pair( symbol, number );
    }

    std::vector<std::pair<char, int>> input( cards );

    QuickSort( cards, 0, cards.size()-1 );

    std::cout << CheckStable( input, cards ) << "\n";
    for( const auto& elem : cards ){
        std::cout << elem.first << " " << elem.second << "\n";
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int main()
{   int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a%b==0&&c>0){
        printf("NO");
        return 0;
    }else if(a%b==0&&c==0){
        printf("YES");
        return 0;
    }
    for(int i=1;i<10000000;i++){
        if((a*i)%b==c){
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}


Measured memory_bytes: 128
//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <map>

using namespace std;
typedef pair<int,int> Paint;
#define MOD 1000000007

bool Pairsecond(const Paint& pf,Paint&ps){//sortCompare
  return pf.second < ps.second;
}
long long kaidan[100000];
int main(){
  int n,m;cin>>n>>m;
  int nw = 0;
  vector<int> b;

  for(int i = 0; m > i; i++){
    int tm;cin>>tm;
    b.push_back(tm);
  }
  if(m!=0)sort(b.begin(),b.end());
  if(m!=0 && b[0] == 0){
    cout << 0 << endl;
    return 0;
  }else{
    kaidan[0] = 1;
  }
  if(m!=0 && b[0]==1){
    kaidan[1]=0;
    nw++;
  }else{
    kaidan[1]=1;
  }
  for(int i = 2; n >= i; i++){
    
    if(m!=0 && b[nw] == i){
      kaidan[i] = 0;
      nw++;
      continue;
    }
    kaidan[i] = (long long)(kaidan[i-1]+kaidan[i-2])%MOD;
  }
  cout << kaidan[n] << endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1000000007;
map<LL, LL> memo;
LL f(LL N)
{
    if (N == 0) return 1;
    if (N == 1) return 2;
    if (memo.count(N)) return memo[N];
    return memo[N] = (N % 2 == 0
        ? f(N / 2) + 2 * f(N / 2 - 1)
        : 2 * f(N / 2) + f(N / 2 - 1)) % MOD;
}
int main()
{
    LL N; cin >> N;
    cout << f(N) << endl;
    return 0;
}


Measured memory_bytes: 256
class BIT:
    # 1-indexed
    def __init__(self, n):
        self.size = n + 1
        self.bit = [0] * self.size

    def add(self, i, x):
        # Add x to a[i]
        while i < self.size:
            self.bit[i] += x
            i += i & -i

    def sumup(self, i):
        # Sum a[1]~a[i]
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & -i
        return res

    def query(self, i, j):
        # Sum a[i]~a[j]
        return self.sumup(j) - self.sumup(i - 1)


N = int(input())
S = list(input())
Q = int(input())
X = [input().split() for _ in range(Q)]

MAX = 5 * 10 ** 5 + 2
d = dict()
for c in range(ord("a"), ord("z") + 1):
    s = chr(c)
    d[s] = BIT(MAX)

for i, v in enumerate(S):
    d[v].add(i + 1, 1)

for q, *x in X:
    if q == "1":
        i = int(x[0])
        c = x[1]

        # Delete index
        d[S[i - 1]].add(i, -1)

        # Add index
        d[c].add(i, 1)
        S[i - 1] = c
    else:
        l, r = map(int, x)

        ans = 0
        for c in range(ord("a"), ord("z") + 1):
            ans += int(d[chr(c)].query(l, r) > 0)
        print(ans)


Measured memory_bytes: 212732
<?php
fscanf(STDIN, "%d %d %d", $A, $B, $M);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$b = array_map('intval', explode(' ', trim(fgets(STDIN))));
$costs = [];
$costs[] = min($a) + min($b);

for ($i = 0; $i < $M; $i++) {
    fscanf(STDIN, "%d %d %d", $x, $y, $c);
    $costs[] = $a[$x - 1] + $b[$y - 1] - $c;
}
printf("%d", min($costs));


Measured memory_bytes: 23024
#[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")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
    }

    print!("{}", n.pow(3));
}

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

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

#define MOD 1000000007

signed main(){
	int n, k;
	cin >> n >> k;

	int l, r;
	l = r = 0;
	int ans = 0;
	n++;
	for(int i = 1;i <= n;i++){
		l += i; 
		r += n-(i-1);
		if(i >= k) ans += r-l+1;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <numeric>
#include <cmath>
#include <tuple>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

int main() {
  int n, m;
  vector<int> x;

  cin >> n >> m;
  each(i, m) {
    int tmp;
    cin >> tmp;
    x.push(tmp);
  }

  sort_asc(x);

  vector<unsigned int> distances;
  for (auto i=0; i < x.size()-1; i++) {
    distances.push(x[i+1] - x[i]);
  }

  sort_desc(distances);

  auto result = 0;
  for (auto i=(n-1); i < distances.size(); i++) {
    result += distances[i];
  }

  std::cout << result << std::endl;

  return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

//すべて半閉区間で扱う
struct cBIT {
  vector<ll> v;
  ll n;
  cBIT(ll n) : n(n), v(n) {}
  void add(ll i, ll x) {
    i++;
    while (i <= n) {
      v[i - 1] += x;
      i += i & -i;
    }
  }
  ll sum(ll i) {
    ll r = 0;
    while (i >= 1) {
      r += v[i - 1];
      i -= i & -i;
    }
    return r;
  }
  ll sum(ll l, ll r){
    if(l>=r)return 0;
    return sum(r)-sum(l);
  }
  ll get(ll i){return sum(i+1)-sum(i);}
};
 
struct BIT {
  cBIT p, q;
  BIT(ll n) : p(n + 1), q(n + 1) {}
  void add(ll l, ll r, ll w) {
    p.add(l, -w * l);
    p.add(r, w * r);
    q.add(l, w);
    q.add(r, -w);
  }
  ll sum(ll r) {
    return p.sum(r) + q.sum(r) * r;
  }
  ll sum(ll l, ll r){
    if(l>=r)return 0;
    return sum(r)-sum(l);
  }
  ll get(ll i){return sum(i+1)-sum(i);}
};
//↑すべて半閉区間で扱う

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> a(N+1,0);
    for(ll i=0;i<N;++i)cin>>a[i+1];
    vector<ll> sum(N+1,0);
    for(ll i=1;i<=N;++i)sum[i]=sum[i-1]+a[i];
    vector<P> vec(N+1);
    for(ll i=0;i<N+1;++i)vec[i]=P(i*K-sum[i],-i);
    ll ans=0;
    sort(vec.begin(), vec.end());
    BIT tree(N+1);
    for(ll i=0;i<N+1;++i){
        ans+=tree.get(-vec[i].second+1);
        tree.add(0,-vec[i].second+1,1);
    }
    prt(ans)fl

    
    return 0;
}


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

int main(){
  
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  
  int r=0;
  for(int A=0;A<=a;++A){
    for(int B=0;B<=b;++B){
      for(int C=0;C<=c;++C){
        int t=A*500+B*100+C*50;
        if (t==x)
          ++r;
      }
    }
  }
  printf("%d",r);
}

  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    int a,b,c,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>n;
    int arr[n];
    for(int i=1; i<=n; i++)cin>>arr[i];
    for(int i=1; i<=n; i++)
    {
        if(i%2!=0 && arr[i]%2!=0)cnt++;
    }
    cout<<cnt<<endl;

}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    rep(i,3){
        if(s[i]=='1') cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int x;
    cin >> x;
    cout << (x+1)%2 << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;

class Program
{
    static void Main()
    {
        int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = inp[0];
        int b = inp[1];
        int c = inp[2];
        Console.WriteLine(Math.Min(c, b / a));
    }
}

Measured memory_bytes: 13268
N, Q = map(int, input().split())
S = input()
TX = [list(input().split()) for _ in range(Q)]
def checkl(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i < 0:
            return False
        if i == N:
            i = N - 1
    return True
def checkr(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i > N - 1:
            return False
        if i == -1:
            i = 0
    return True

ok = N
ng = -1
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkl(med):
        ok = med
    else:
        ng = med
L = ok
ok = -1
ng = N
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkr(med):
        ok = med
    else:
        ng = med
R = ok
print(max(0, R - L + 1))


Measured memory_bytes: 26832
#include<iostream>
#include<map>
#include<utility>
using namespace std;
int main(){
	long long h,w,n;
	cin >> h >> w >> n;
	map<pair<int,int>,int> mass;
	int a,b;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		for(int j=-2;j<=0;j++){
			for(int k=-2;k<=0;k++){
				if(1<=a+j&&a+j+2<=h && 1<=b+k&&b+k+2<=w){
					pair<int,int> P=make_pair(a+j,b+k);
					mass[P]++;
				}
			}
		}
	}
	long long ans[10]={};
	ans[0]=(h-2)*(w-2)-mass.size();
	for(auto i=mass.begin();i!=mass.end();i++){
		ans[i->second]++;
	}
	for(int i=0;i<10;i++) cout << ans[i] << endl;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<string> A(N);
  vector<string> B(M);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<M;i++){
    cin>>B.at(i);
  }
  for(int y=0;y<=N-M;y++){
    for(int x=0;x<=N-M;x++){
      int count=0;
      for(int by=0;by<=M-1;by++){
          if(B.at(by)==A.at(by+y).substr(x,M)){
            count++;
          }
      }
      if(count==M){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


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


int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i,N)cin >> a[i];
    ll res = 0;
    ll sum = 0;
    rep(i,N){
        if(a[i]!= 0)sum += a[i];
        if(a[i] == 0){
            res += sum/2;
            sum = 0;
        }
    }
    res += sum/2;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  char s[n];
  cin >> s;
  int k;
  cin >> k;
  for (int i=0; i<n; i++) {
    if ((i != k-1) && (s[i] != s[k-1])) {
      s[i] = '*';
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

li = make_divisors(n)
ans = 10**10

for i in range(len(li) // 2):
    a = li[i*2]
    b = li[i*2+1]
    ans = min(ans, max(len(str(a)), len(str(b))))

if len(li) % 2 == 1:
    ans = min(ans, len(str(li[-1])))

print(ans)


Measured memory_bytes: 3188
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]
 
ans = float("inf")
 
for bit in range(1 << d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))
 
    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            nokori.discard(i + 1)
 
    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < g:
        use = max(nokori)
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100
 
    if sum >= g:
        ans = min(ans, count)
 
print(ans)

Measured memory_bytes: 9108
#include <stdio.h>

int main(void){
    int h, w;
    int i, j;
    while(1){
    scanf("%d %d", &h, &w);
    if(h + w == 0)
        break;
        for(i = 0; i < h; i++){
           for(j = 0; j < w; j++)
               putchar('#');
           putchar('\n');
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 588
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(char, a, b);

    const auto s = string(b - '0', a);
    const auto t = string(a - '0', b);

    output(min(s, t));

    return 0;
}


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

using namespace std;

int main() {
    string str;
     int n,i=0;
     cin>>n;
     if(n%2==0){
         cin>>str;
     while(i<n/2){
         if(str[i]!=str[n/2+i])
             break;
         i++;
     }
     if(i==n/2)
     cout<<"Yes";
     else
     cout<<"No";
         
     }
     else{
         cout<<"No";
     }
    return 0;
}


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

bool check(int x, vector<int> d) {
  string s = to_string(x);
  for (int i = 0; i < d.size(); i++) {
    for (int j = 0; j < s.size(); j++) {
      if (d[i]==s[j]-'0') return false;
    }
  }
  return true;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  for (int i = 0; i < k; i++) cin >> d[i];
  for (int i = n;; i++) {
    if (check(i, d)) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,mem[100005];
bool vis[100005];
vector<int> g[100005];
int dp(int x)
{
	if(mem[x]!=-1)
		return mem[x];
	int ans=0;
	vis[x]=1;
	for(int i=0;i<g[x].size();i++)
		if(!vis[g[x][i]])
			ans=max(ans,dp(g[x][i])+1);
	vis[x]=0;
	mem[x]=ans;
	return mem[x];
}
int main()
{
	memset(mem,-1,sizeof(mem));
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
		if(mem[i]==-1)
		{
			memset(vis,0,sizeof(vis));
			dp(i);
		}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=max(ans,mem[i]);
	cout<<ans<<endl;
	return 0;
}


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

class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine().Split()[0]);
		int[] qs = Console.ReadLine().Split().Select(str => int.Parse(str)).ToArray();
		int q = int.Parse(Console.ReadLine().Split()[0]);
		int[] ms = Console.ReadLine().Split().Select(str => int.Parse(str)).ToArray();

		Dictionary<int, bool> sumDic = new Dictionary<int, bool>();

		for (int j = 0; j < Math.Pow(2, n); j++)
		{
			var sum = 0;
			for (int k = 0; k < n; k++)
			{
				if (((j >> k) & 1) == 1)
				{
					sum += qs[k];
					sumDic[sum] = true;
				}
			}
		}

		for (int i = 0; i < q; i++)
		{
			System.Console.WriteLine(sumDic.ContainsKey(ms[i]) ? "yes" : "no");
		}
	}
}



Measured memory_bytes: 10208
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  
  bool flag = true;
  for(int i = 0; i < s.size(); i++){
    if(!flag)
      break;
  	if((i + 1) % 2 == 1)
    { //odd
      switch(s[i]){
        case 'R':
        case 'U':
        case 'D':
          continue;
        default:
          flag = false;
      }
    }else {
      //odd
      switch(s[i]){
        case 'L':
        case 'U':
        case 'D':
          continue;
        default:
          flag = false;
      }
    }
  }
  if(flag)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl;
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl;
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (st                                  derr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<pii, int> mpii;
typedef set<int> sti;
const int INF = 1e9, MOD = INF + 7;
int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }
int power(int a, int b) { return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1)); }
int mod(int a) { return (a % MOD + MOD) % MOD; }

/////////////////////////////////////////////////////////////////////

const int N = 1e5 + 20, P = 104729;

int32_t main(){

    sync;

    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i ++) if (s[i] == '2') ans++;
    cout << ans << endl;
    

    return 0;
}
 

Measured memory_bytes: 256