akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string S,T; cin >> S >> T;
    string res;
    for(int i = 0; i < S.length(); i++){
        if(i + T.length() > S.length()) break;
        bool f = false;
        for(int j = 0; j < T.length();j++){
            if(S[i + j] == '?')continue;
            if(S[i + j] == T[j])continue;
            f = true;
            break;
        }
        if(f)continue;
        
        string temp;
        for(int j = 0; j < S.length();j++){
            if(j < i){
                if(S[j] == '?') temp += 'a';
                else temp += S[j];
            }else{
                if(j < i + T.length())temp += T[j - i];
                else {if(S[j] == '?') temp += 'a';
                else temp += S[j];
                }
            }
        }
        if(res.length() == 0) res = temp;
        else res = min(res,temp);
    }
    if(res.length() == 0){
        cout << "UNRESTORABLE" << endl;
    }else{
        cout << res << endl;
    }
    return 0;
}


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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int a[N];
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int b[9]{};
  for(int i : a){
    int idx = i / 400;
    if(idx >= 8){
      idx = 8;
      b[idx]++;
    }else{
      b[idx] = 1;
    }
  }
  int Min = 0;
  for(int i = 0; i < 8; i++){
    Min += b[i];
  }
  int Max;
  if(Min == 0){
    Min = 1;
    b[8]--;
  }
  Max = Min + b[8];
  cout << Min << " " << Max << "\n";
  return 0;
}

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

using namespace std;

const int N = 2e5+7;

int n, k, res;
int p[N], s[N];
set<int> st;

int main()
{
    cin >> n >> k;
    p[0] = -1;
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
        s[i] = s[i-1]+(p[i] < p[i-1]);
    }
    for (int i = 0; i < k; ++i) st.insert(p[i]);
    for (int l = 1, r = k, flag = 1; r <= n; r = (++l)+k-1) {
        if (s[r]-s[l] == 0) {
            res += flag;
            flag = 0;
        } else {
            int minv = *st.begin(), maxv = *st.rbegin();
            if (l == 1 || p[l-1] != minv || p[r] < maxv) ++res;
        }
        st.erase(p[l-1]);
        st.insert(p[r]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll cnt = 0;
    rep(i, n-1) {
        if(s[i] == s[i+1]) {
            cnt++;
        }
    }

    out(min(n-1, cnt + 2*k));
    re0;
}

Measured memory_bytes: 512
n, m = map(int, input().split())

import math
if abs(n - m) >= 2:
    print(0)
elif abs(n - m) == 1:
    print(math.factorial(n) * math.factorial(m) % (10 ** 9 + 7))
elif abs(n - m) == 0:
    print(2 * math.factorial(n) * math.factorial(m) % (10 ** 9 + 7))


Measured memory_bytes: 5192
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <string>

using namespace std;

int main() {
	stack<int> s1;
	stack < pair<int, int> > s2;
	string str;
	pair<int,int> p;
	cin >> str;
	for (int i = 0; str[i] !=NULL; i++) {
		if (str[i] != '/') {
			if (str[i] == '\\')
				s1.push(i);
		}
		else {
			if (s1.size() > 0) {
				p.first = s1.top(); s1.pop();
				p.second = 0;
				while (s2.size() > 0 && s2.top().first > p.first) {
					p.second += s2.top().second;
					s2.pop();
				}
				p.second += (i - p.first);
				s2.push(p);
			}
		}
	}
	

	int sum = 0;
	vector<int> vec;
	while (!s2.empty()) {
		vec.push_back(s2.top().second); s2.pop();
	}
	reverse(vec.begin(), vec.end());
	for (int i = 0; i < vec.size(); i++)
		sum += vec[i];
	cout << sum << endl;
	cout << vec.size();
	for (int i = 0; i < vec.size(); i++) {
		cout << " ";
		cout << vec[i];
	}
	cout << endl;

	return 0;
}

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

int main() {
  int n, cnt = 0; 
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  for(int i = 0; i < n - 2; i++) {
    for(int j = i + 1; j < n - 1; j++) {
      for(int k = j + 1; k < n; k++) {
        vector<int> v{l[i], l[j], l[k]};
        sort(v.begin(), v.end());
        if(l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) continue;
        else if(v[2] < v[0] + v[1]) cnt++;
      }
    }
  }
  cout << cnt;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N, M;
int cnt[60];
int a, b;

signed main()
{
    cin >> N >> M;
    REP(i,M) {
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    
    FOR(i,1,N+1) {
        cout << cnt[i] << endl;
    }    
}


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

int main() {
    int n, x, t;
    cin >> n;
    cin >> x;
    cin >> t;
    int ans = ((n-1)/x+1)*t;
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector< vector <int> >vee;
typedef vector<pair<int,int> >vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const int N=1e5+5;
bool f;
ll dp[105][N],v[N],w[N],n,m;
ll solve(int i=0,int rem=m)
{
    if(i==n)return 0;
    ll &ret=dp[i][rem];
    if(~ret)
    return ret;
    return ret=max(solve(i+1,rem),rem>=w[i]?solve(i+1,rem-w[i])+v[i]:0);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
     memset(dp,-1,sizeof dp);
     cin>>n>>m;
     rep(i,n&&cin>>w[i]>>v[i]);
      cout<<solve();

go;
}


Measured memory_bytes: 82304
import bisect
import sys
input = sys.stdin.readline
A, B, Q = list(map(int, input().split()))
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
s.append(-100000000000);s.append(100000000000)
t.append(-100000000000);t.append(100000000000)
s = sorted(s, reverse=False)
t = sorted(t, reverse=False)

for i in range(Q):
    xi = int(input())
    sr = s[bisect.bisect_left(s, xi)]
    sl = s[bisect.bisect_left(s, xi) - 1]
    tr = t[bisect.bisect_left(t, xi)]
    tl = t[bisect.bisect_left(t, xi) - 1]

    ans = min(max(sr, tr) - xi, xi - min(sl, tl),
              tr - sl + min(tr - xi, xi - sl), sr - tl + min(sr - xi, xi - tl))
    print(ans)

Measured memory_bytes: 12184
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>

#define MOD 1000000007
#define INF INT_MAX
#define NINF INT_MIN
#define LLINF LLONG_MAX
using ll = long long;
using namespace std;

int main() {
    int N, M=0, l=0,r=0;
    cin >> N;
    string S;
    cin >> S;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == '(') {
            M++;
        }
        else {
            if (M == 0) {
                l++;
            }
            else {
                M--;
            }
        }
    }
    r = M;
    for (int i = 0; i < l; i++)
    {
        cout << "(";
    }
    cout << S;
    for (int i = 0; i < r; i++)
    {
        cout << ")";
    }
    cout << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10000)


def main():
    # 入力処理
    N, C, K = [int(x) for x in input().split()]
    Ts = sorted([int(input()) for i in range(N)])

    print("N={}, C={}, K={}".format(N, C, K),
          file=sys.stderr)

    # アルゴリズム本体
    M = 1               # バスの数
    n = 0               # 現在のバスに乗っている人数
    Tlim = Ts[0] + K    # 現在のバスの発車ギリギリの時刻

    for T in Ts:
        if T > Tlim or n >= C:
            # 次のバスを準備
            M += 1
            Tlim = T + K
            # 次のバスに一人追加
            n = 1
        else:
            # このバスに一人追加
            n += 1

    # 出力
    print(M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8280
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
ans = 0

for i in range(n):
    cnt = c
    A = list(map(int, input().split()))
    for j in range(m):
        cnt += A[j] * B[j]
    if cnt > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define loop(i, a, b) for(li i=a; i<=b; i++)
#define stuff ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long li;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<li, li> lii;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ii> vii;
typedef vector<lii> vlii;
li mod = 1e9+7;
li expo(li base, li exponent)
{
	li ans=1;
	while(exponent)
	{
		if(exponent&1) ans = (ans*base)%mod;
		base = (base*base)%mod;
		exponent >>= 1;
	}
	return ans;
}
li gcd(li x, li y)
{
	if(y==0) return x;
	return gcd(y, x%y);
}


typedef tree<li, null_type, less<li>,
rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
	stuff;
	// #ifndef ONLINE_JUDGE 
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// freopen("error.txt", "w", stderr);
	// #endif

	li x;
	cin >> x;
	li amt = 100;
	li ans=0;
	while(amt<x)
	{
		li num = amt/100;
		amt += num;
		ans++;
	}
	cout << ans;
	return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int64 DigitSum(int64 x, int64 b) {
  int64 s = 0;
  while (x > 0) {
    s += x % b;
    x /= b;
  }
  return s;
}

int64 Solve() {
  int64 n;
  int64 t;
  cin >> n >> t;

  if (n < t) return -1;
  
  // In the following, t <= n.

  // 1 digit
  if (n == t) {
    return n + 1;
  }

  // >=3 digits
  int64 u = -1;
  for (int64 b = 2; b <= n; b++) {
    if (n < b * b) {
      u = b;
      break;
    }
    int64 s = DigitSum(n, b);
    // cout << "b : " << b << " s: " << s << endl;
    if (s == t) return b;
  }

  // 2 digits
  for (int64 x = u; x >= 1; x--) {
    if ((n - (t - x)) % x == 0) {
      int64 b = (n - (t - x)) / x;
      int64 y = n - b * x;
      if (x < b && 0 <= y && y < b) {
        // cout << "b: " << b << " x: " << x << " y: " << y << endl;
        return b;
      }
    }
  }
  return -1;
}

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

  cout << Solve() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
map<ll, P> mp[110000];
map<ll, ll> M[110000];
ll h, w, d, a, q, l, r;
int main(void){
    // Your code here!
    cin >> h >> w >> d;
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++) {
            cin >> a;
            mp[a % d][a / d] = P(i, j);
        }
    }
    for (ll i = 0; i < d; i++) {
        auto itr = mp[i].end();
        ll r = itr->first;
        for (ll j = 0; j < r; j++) {
            P p1 = mp[i][j], p2 = mp[i][j + 1];
            M[i][j + 1] = M[i][j] + abs(p1.first - p2.first) + abs(p1.second - p2.second);
        }
    }
    cin >> q;
    for (ll i = 0; i < q; i++) {
        cin >> l >> r;
        ll x = l % d, y = l / d, z = r / d;
        cout << M[x][z] - M[x][y] << endl;
    }
}


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

inline int dist(int x, int y) {
  if (x >= y) return x - y;
  else return y - x;
}

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if ((dist(a, c) <= d) || ((dist(a, b) <= d) && (dist(b, c) <= d))) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n,m = map(int, input().split())
mod = 1000000007
broken = [0 for i in range(n+1)]
for j in range(m):
    a = int(input())
    broken[a] = -1
broken[0] = 1
broken[1] = 1 if broken[1] != -1 else 0
for i in range(2,n+1):
    if broken[i] == -1:
        continue
    one = broken[i-1] if broken[i-1] != -1 else 0
    two = broken[i-2] if broken[i-2] != -1 else 0
    broken[i] = (one + two) % mod
print(broken[-1])

Measured memory_bytes: 7028
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int oki,ne;
  oki = h1 * 60 + m1;
  ne = h2 * 60 + m2;
  cout << ne - oki - k << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;
const ll MOD=1000000007;

template <class type> void printVector(vector<type> vec){
    stringstream ss;
    ll n=vec.size();
    for(ll i=0;i<n;i++)
    {
        ss<<vec[i]<<" ";
        if(i!=n-1)ss<<" ";
    }
    cout<<ss.str()<<endl;
}

template <class type> void inputVector(vector<type>& vec){
    for(ll i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
}

template<ll MOD> struct Fp {
    ll val;
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr ll getmod() { return MOD; }
    constexpr Fp operator - () const noexcept { //符号
        return val ? Fp(MOD - val) : Fp(0);
        //return val ? MOD - val : 0; これじゃだめ？
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(this->val) += r; }//ここでthisなのは？->コピーコンストラクタが自動生成されているから ここでFp()なのは自身の値は変わらないから
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(this->val) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(this->val) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(this->val) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;//1bit目が1=奇数,1ならここは2になる。
        return t;
    }
};

using mint = Fp<MOD>;

mint calc(ll N, ll K) {
    mint res = 1;
    for (ll n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }//Cの計算
    return res;
}

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    mint res = modpow(mint(2), N) - 1;
    res -= calc(N, A) + calc(N, B);
    cout << res << endl;
}

Measured memory_bytes: 3600
N, K = map(int, input().split())

MOD = 10 ** 9 + 7
cnt = [0] * (K + 1)
ans = 0
for x in reversed(range(1, K + 1)):
    cnt[x] += pow(K // x, N, MOD)
    for n in range(2, K + 1):
        if x * n > K:
            break
        cnt[x] -= cnt[x * n]
    cnt[x] %= MOD
    ans += x * cnt[x] % MOD

print(ans % MOD)


Measured memory_bytes: 69004
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> a(N), b(M);
	for (auto& x : a) cin >> x;
	for (auto& x : b) cin >> x;
	auto c = convolution(a, b);
	for (auto x : c) cout << x << " ";
	cout << endl;
}


Measured memory_bytes: 19064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        long[] a = new long[n];
        long sum = 0; 
        for(int i=0; i<n; i++) {
            a[i] = fs.nextLong();
            sum ^= a[i];
        }
        for(int i=0; i<n; i++) {
            System.out.print((sum^a[i]) + " ");
        }        
    }

    static class FastScanner {
        BufferedReader br = null;
        StringTokenizer st;
    
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
    
        String next() {
            while(st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    
        double nextDouble() {
            return Double.parseDouble(next());
        }
    
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 62216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<ll,ll> p[200005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i].second>>p[i].first;
	}
	sort(p+1,p+1+n);
	ll now=0;
	for(int i=1;i<=n;i++){
		if(now+p[i].second>p[i].first){
			cout<<"No"<<endl;
			return 0;
		}
		else{
			now+=p[i].second;
		}
	}
	cout<<"Yes"<<endl;
}

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

public class P
{
    public int x { get; set; }
    public int y { get; set; }
    public int step { get; set; }
}

public class hello
{
    public static int w, h;
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            w = int.Parse(line[0]);
            h = int.Parse(line[1]);
            if (w == 0 && h == 0) break;
            var map1 = new bool[h, w - 1];
            var map2 = new bool[h - 1, w];
            for (int i = 0; i < h - 1; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < w - 1; j++)
                    map1[i, j] = line[j] == "1";
                line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < w; j++)
                    map2[i, j] = line[j] == "1";
            }
            line = Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < w - 1; i++)
                map1[h - 1, i] = line[i] == "1";
            goBfs(map1, map2);
        }
    }
    static void goBfs(bool[,] map1, bool[,] map2)
    {
        var dxy = new int[] { 1, -1 };
        var visited = new int[h, w];
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                visited[i, j] = int.MaxValue;
        var q = new Queue<P>();
        q.Enqueue(new P { x = 0, y = 0, step = 1 });
        visited[0, 0] = 1;
        while (q.Count() > 0)
        {
            var t = q.Dequeue();
            if (t.x == h - 1 && t.y == w - 1) { Console.WriteLine(t.step); return; }
            var nstep = t.step + 1;
            for (int i = 0; i < 2; i++)
            {
                var nx = t.x;
                var ny = t.y + dxy[i];
                var mapny = i == 0 ? t.y : t.y - 1;
                if (ny >= 0 && ny < w && !map1[nx,mapny] && nstep < visited[nx,ny])
                {
                    q.Enqueue(new P { x = nx, y = ny, step = nstep });
                    visited[nx, ny] = nstep;
                }
            }
            for (int i = 0; i < 2; i++)
            {
                var nx = t.x + dxy[i];
                var ny = t.y;
                var mapnx = i == 0 ? t.x : t.x - 1;
                if (nx >= 0 && nx < h && !map2[mapnx, ny] && nstep < visited[nx, ny])
                {
                    q.Enqueue(new P { x = nx, y = ny, step = nstep });
                    visited[nx, ny] = nstep;
                }
            }
        }
        Console.WriteLine(0);
    }
}


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


int main()
{
	string str, order, repStr;
	cin >> str;

	int n = 0;
	cin >> n;
	int ord1 = 0, ord2 = 0;
	while (n--) {
		cin >> order;
		cin >> ord1 >> ord2;

		if (order == "replace") {
			cin >> repStr;
			str.replace(ord1, ord2 - ord1 + 1, repStr);
		}else if (order == "reverse"){
			
			repStr = str.substr(ord1, ord2 - ord1+1);
			reverse(repStr.begin(), repStr.end());
			str.replace(ord1, ord2 - ord1 + 1, repStr);
		}
		else if (order == "print") {
			cout << str.substr(ord1, ord2 - ord1+1) << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 3216
# TLE
import sys
import numpy as np
from collections import deque

# input = sys.stdin.readline

s = list(input())

n = int(input())

d = deque(s)

reverse = False
for ii in range(n):
    q = input()
#     print("".join(s))
    if q[0] == "1":
        reverse += 1
        reverse %= 2
#         s = s[::-1]
    else:
        t, f, c = q.split()
        if f == "1":
            if reverse:
                d.append(c)
            else:
                d.appendleft(c)
        else:
            if reverse:
                d.appendleft(c)
            else:
                d.append(c)
                
if reverse:
    d.reverse()
print("".join(d))

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

int main(){
  int n, q;
  std::cin >> n >> q;
  std::string s;
  std::cin >> s;
  std::vector<int> l(q);
  std::vector<int> r(q);
  for(int i = 0; i < q; ++i){
    std::cin >> l[i] >> r[i];
  }

  int acCount = 0;
  std::vector<int> acCountArr(n - 1);
  for(int i = 0; i < n - 1; ++i){
    if(s[i] == 'A' && s[i + 1] == 'C')
      acCountArr[i] = ++acCount;
    else
      acCountArr[i] = acCount;
  }

  for(int i = 0; i < q; ++i){
    int leftCount;
    if(l[i] == 0)
      leftCount = 0;
    else
      leftCount = acCountArr[l[i] - 2];
    int rightCount = acCountArr[r[i] - 2];
    std::cout << rightCount - leftCount << std::endl;
  }

  return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	
	queue<char> q;
	
	int cnt = 0;
	q.push(s[0]);
	for(int i=1; i < s.length(); i++) {
		if(!q.empty() && (q.front() == '0' && s[i] == '1' || q.front() == '1' && s[i] == '0')) {
			cnt += 2;
			q.pop();
		}
		else {
			q.push(s[i]);
		}
	}
	
	cout << cnt;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define input(x) istream_iterator<x>(cin)
const int N = 1e6;

int n, m;
int a[N];

int main() {
    cin >> n >> m;
    copy_n(input(int), m, a);
    long long sum = 0;
    for (int i = 0; i < m; i++) {
        sum += a[i];
    }
    long long ans = clamp(n - sum, -1LL, (long long)N);
    cout << ans << "\n";
    return 0;
}





Measured memory_bytes: 3624
#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))

int main() {
    ll n;
    ll a[100010];
    cin>>n;
    int cnt1=0,cnt2=0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        if(a[i]%4==0) cnt1++;
        else if(a[i]%2==0) cnt2++;
    }
    if(n%2==0){
        if(cnt1+cnt2/2>=n/2){
            cout<<"Yes"<<endl;
        }
        else cout<< "No"<<endl;
    }
    else{
        if(cnt1+cnt2/2>=(n-1)/2){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }





    return 0;
}

Measured memory_bytes: 1024
#a = gets.chomp.to_i
m,d = gets.chomp.split(" ").map{|i|i = i.to_i}
#s = gets.chomp

count = 0
d.times do|i|
  d_10 = ((i+1)/10)
  next if d_10 <= 1
  d_1 = ((i+1)%10)
  next if d_1 <= 1

  if (d_10*d_1) <= m then
    #puts "now d_10 = #{d_10}, d_1 = #{d_1}, m = #{m}"
    count += 1
  end
  
end
puts count

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

int main(){
    int A,B,K;
    cin>>A>>B>>K;
    int i;
    for(i=100;i>0;i--){
        if(A%i==0&&B%i==0){
            if(K==1){
                break;
            }else{
                K-=1;
            }
        }
    }
    cout<<i<<endl;
}

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

int n, x, a[20], s;

bool chk(int s) {
    while (s) {
        if (a[s % 10]) return 0;
        s /= 10;
    } return 1;
}

int main() {
    scanf("%d%d", &s, &n);
    for (int i = 1; i <= n; i++) scanf("%d", &x), a[x] = 1;
    while (!chk(s)) s++;
    printf("%d\n", s);
    return 0;
}


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

int main() {
    int N;
    string c;
    cin >> N;
    bool f = false;

    for (int i = 0; i < N; i++) {
        cin >> c;
        if (c == "Y") {
            f = true;
        }
        else {
            continue;
        }
    }
    if (f) {
        cout << "Four" << endl;
    }
    else cout << "Three" << endl;
    
}

Measured memory_bytes: 384
n,k=map(int,input().split())
w=[0]*n
for i in range(n):
    w[i] = int(input())

def hantei(w,a,k):
    tumu=a
    daime=1
    for ww in w:
        if ww<=tumu:
            tumu-=ww
        else:        
            tumu=a
            daime+=1
            if ww<=tumu:
                tumu-=ww
            else:
                return False
    if daime >k:
        return False
    else:
        return True


right= max(w)*n +1
left = min(w)

while left<right:
    mid  = (left+right)//2
    if hantei(w,mid,k):
        right=mid
    else:
        left=mid+1
print(left)



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

using namespace std;
using ll = long long;

ll n, ans;

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i != 0) continue;
        if (n / i > 0 && i < n / i - 1) ans += n / i - 1;
        if (i > 1 && i - 1 > n / i && i * i < n) ans += i - 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    
    int N,x;
    long long int cnt=0;
    cin>>N>>x;
    vector<int> S(N+1,0);
    for(int i=0;i<N;i++){
        cin>>S.at(i+1);
    }
    for(int i=1;i<=N;i++){
        if(S.at(i-1)+S.at(i)>x){
            cnt+=(S.at(i)+S.at(i-1)-x);
            S.at(i)=x-S.at(i-1);
        }
    }
    cout<<cnt<<endl;
}


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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, L;
	cin >> N >> L;
	vector<string> vec;
	for (int i = 0; i < N; i++) {
		string str;
		cin >> str;
		vec.push_back(str);
	}

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

	for (int i = 0; i < vec.size(); i++)
		cout << vec[i];
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    char ima = 'R';
    int cnt = 0;
    rep(i,n-1){
        if (s.at(i) == 'L' && s.at(i+1) == 'R'){
            cnt++;
        }
    }
    cnt++;
    int m = cnt;
    vector<int> ar(m);
    cnt = 0;
    int cn = 0;
    rep(i,m){
        while (cn < n-1 && (s.at(cn) == 'R' || s.at(cn+1) == 'L')){
            cnt++;
            cn++;
        }
        cnt++; cn++;
        ar[i] = cnt;
        cnt = 0;
    }
    rep(k,m){
        rep(i,ar[k]){
            if (s.at(cnt) == 'R'){
                if (s.at(cnt+1) == 'L'){
                    if (ar[k] % 2 == 0){
                        ans[cnt] = ar[k] / 2;
                    }
                    else if (i % 2 == 0){
                        ans[cnt] = (ar[k]+1) / 2;
                    }
                    else {
                        ans[cnt] = (ar[k]-1) / 2;
                    }
                }
            }
            else {
                if (s.at(cnt-1) == 'R'){
                    ans[cnt] = ar[k] - ans[cnt-1];
                }
            }
            cnt++;
        }
    }
    rep(i,n-1){
        cout << ans[i] << " ";
    }
    cout << ans[n-1] << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int n;
double a[51],ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i];
	sort(a+1,a+n+1);
	ans=(a[1]+a[2])/2.0;
	for (int i=3;i<=n;++i) ans=(ans+a[i])/2.0;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        var str = Console.ReadLine();
        var q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            var input = Console.ReadLine().Split();
            var a = int.Parse(input[1]);
            var b = int.Parse(input[2]);
            var str1 = str.Substring(0, a);
            var str2 = "";
            var str3 = (b == str.Length - 1) ? "" : str.Substring(b + 1);
            switch (input[0])
            {
                case "print":
                    Console.WriteLine(str.Substring(a, b - a + 1));
                    break;
                case "reverse":
                    foreach (var item in str.Substring(a, b - a + 1))
                    {
                        str2 = item + str2;
                    }
                    str = str1 + str2 + str3;
                    break;
                case "replace":
                    str2 = input[3];
                    str = str1 + str2 + str3;
                    break;
                default:
                    break;
            }
        }
    }
}


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

using namespace std;

int main() {
   int c=0;
   int n;
   cin>>n;
   
   int temp=0,temp2=0;
   int f=0;
   for(int i=0;i<n;++i)
   {
       int C,D;
       cin>>C>>D;
       
     
           if(C==D)
           {
           
           c++;
           
       }
       else
       {
           
           c=0;
           
       }
       
       if(c==3)
       {
           f=1;
       }
   }
   
   if(f)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

Real calc(P a,P b,P c){
  // sub c
  a -= c;
  b -= c;
  // rotate
  P rot = b / abs(b);
  a /= rot;
  b /= rot;
  Real mul = b.real();
  a /= mul;
  if(a.imag()<0){
    a = conj(a);
  }
  // (0,0), (1,0), (x,y>0)
  Real p = abs(a);
  Real q = abs(a-P(1,0));
  Real y = a.imag();
  Real s = y/2.0;
  Real r = s / (p/2.0 + q/2.0 + y + 0.5);
  return r*mul;
}

int main(){
  int x,y;
  P a,b,c;
  scanf("%d%d",&x,&y);a=P(x,y);
  scanf("%d%d",&x,&y);b=P(x,y);
  scanf("%d%d",&x,&y);c=P(x,y);
  Real ans = 0.0;
  CHMAX(ans,calc(a,b,c));
  CHMAX(ans,calc(b,c,a));
  CHMAX(ans,calc(c,a,b));
  printf("%.9lf\n",ans);
  return 0;
}


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

#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction(a) cout.unsetf(ios::floatfield); cout.precision(a); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);



int main()
{
    faster();

    int n;
    cin>>n;
    int rem;
    rem = n%10;
    if(rem==1 || rem==0 || rem==6 || rem==8){
        cout<<"pon"<<endl;
    }
    else if(rem==3){
        cout<<"bon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }


    return 0;
}



Measured memory_bytes: 3572
mo = 1000000007
n = int(input())
t = list(map(int,input().split()))
a = list(map(int,input().split()))

if n == 1:
    if t[0] == a[0]:
        print(1)
    else:
        print(0)
    exit()

mt = [False] * n # 山の高さが1通りのときTrue
mt[0] = True
mt[-1] = True

for i in range(1, n):
    if t[i - 1] < t[i]:
        mt[i] = True
        if a[i] < t[i]:
            print(0)
            exit()

for i in range(n - 2, -1, -1):
    if a[i] > a[i + 1]:
        mt[i] = True
        if t[i] < a[i]:
            print(0)
            exit()

ans = 1
for i in range(n):
    if not mt[i]:
        ans *= min(t[i], a[i])
        ans %= mo

print(ans)


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

int main(){
    int h,w; cin>>h>>w;
    vector<string> c(h);
    for(int i=0;i<h;i++) cin>>c[i];

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int p,q,a,n;

int dfs(int x, int y, int z, int mul, int num) {
  if (x < 0 || mul > a || num > n) return 0;
  if (x == 0) return 1;
  int res = dfs(x*z-y,y*z,z,mul*z,num+1);
  if (mul*z <= a) res += dfs(x,y,z+1,mul,num);
  return res;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> p >> q >> a >> n, p) {
    cout << dfs(p,q,1,1,0) << endl;
  }

  return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	ll ans = 1LL << 60;
	for(int l = 0; l + K - 1 < N; l++) {
		int r = l + K - 1;
		if (A[l] * A[r] < 0) {
			// l -> r
			ans = min(ans, 2 * abs(A[l]) + abs(A[r]));
			// r -> l
			ans = min(ans, 2 * abs(A[r]) + abs(A[l]));
		} else {
			ans = min(ans, max(abs(A[l]), abs(A[r])));
		}

	}

	cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 1024
import heapq
while True:
    N = int(input())
    if not N:
        break
    f = [0] * N
    for i in range(N):
        f[i] = list(map(int,input().split()[1:]))

    dp = [ [0] * 51 for i in range(51) ]

    for i in range(N):
        for j in range(N):
            dp[j][i] = 1<<i
    for i in range(1,31):
        ds = [ j for j in range(N) if i in f[j]]
        for d1 in ds:
            for d2 in ds:
                dp[i][d1] |= dp[i-1][d2]
        for j in range(N):
            dp[i][j] |= dp[i-1][j]
    ans = 40
    for i in range(31):
        for j in range(N):
            if dp[i][j] == (1<<N)-1:
                ans = min( (ans,i) )
    if ans > 30:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 7928
#include <iostream>
#include <string>
#include<iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include<queue>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include <map>
#include<string.h>
#include<sstream>
#include<stack>
const double pi = 3.14159265359;
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long n, k,arr[200005],sp=0,ans=0;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	sp = n - k;
	for (int i = 0; i < sp; ++i) {
		ans += arr[i];
	}
	cout << ans;
	return 0;
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if(a.second != b.second){
    return a.second < b.second;
  }
  else{
    return a.first < b.first;
  }
}


int main (void) {

    ll N;
    scanf("%lld", &N);
    ll a,b;
    
    vector<pair<ll, ll>> pairs(N);

    REP(int,i,0,N){
      scanf("%lld %lld", &a, &b);
      pairs[i] = make_pair(a, b);
    }

    sort(pairs.begin(), pairs.end(), compare_by_b);
    ll TimePool = 0;
    ll WorkTime = 0;
    REP(int,i,0,N){
      if ( pairs[i].first > pairs[i].second ){
        printf("No\n");
        return 0;
      }
      else{
        WorkTime += pairs[i].first;
        if ( WorkTime > pairs[i].second ){
          printf("No\n");
          return 0;
        }
      }
    }

    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {
    char in[1000] = { 0 };
    cin.getline(in, sizeof(in));
    int offset = 0;

    for (int i = 0; i < 1000; ++i) {
        if (('a' <= in[i]) && (in[i] <= 'z')) {
            in[i] -= 32;
        }
    }

    cout << in << endl;

    return 0;
}

Measured memory_bytes: 1128
from collections import deque

n, k, l = list(map(int, input().split()))

def get_groups(n, m):
    road = [[] for _ in range(n+1)]
    for _ in range(m):
        p, q = list(map(int, input().split()))
        road[p].append(q)
        road[q].append(p)

    groups = [0]*(n+1)
    group_idx = 1
    connect = deque()
    for i in range(1, n+1):
        if groups[i] == 0:
            groups[i] = group_idx
            connect.clear()
            connect.append(i)
            while len(connect) > 0:
                cnct = connect.popleft()
                for c in road[cnct]:
                    if groups[c] == 0:
                        groups[c] = group_idx
                        connect.append(c)
            group_idx += 1
            
    return groups

road_groups = get_groups(n, k)
train_groups = get_groups(n, l)
# print(road_groups, train_groups)
pairs = {}
for c in range(1, n+1):
    key = (road_groups[c], train_groups[c])
    if not key in pairs.keys():
        pairs[key] = 1
    else:
        pairs[key] += 1

ans = []
for c in range(1, n+1):
    key = (road_groups[c], train_groups[c])
    ans.append(str(pairs[key]))
print(' '.join(ans))


Measured memory_bytes: 56588
int main(void){
	int i,l,ans=0;
	char s[100],t[100];
	scanf("%s",s);
	scanf("%s",t);

	l=strlen(s);

	char cp[l*2];

	strcpy(cp,s);
	strcat(cp,s);

	for(i=0;i<l;i++){
		if(strncmp(cp+i,t,l)==0){
			ans=1;
			break;
		}
	}

	if(ans==1){
		printf("Yes");
	}else{
		printf("No");
	}
 
	return 0;
 
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;

int t[3][30];

int calc(const vector<vector<int> >& d, const vector<vector<int> >& c, int c1, int c2, int c3){
	int ret =0;
	for(int i = 0; i < d.size(); ++i){
	    ret += d[i][c1]*t[0][i];
	    ret += d[i][c2]*t[1][i];
	    ret += d[i][c3]*t[2][i];
    }
	return ret;
}

int main(){
    int n, C; cin >>n>>C;
    vector<vector<int>> d(C, vector<int>(C));
    vector<vector<int>> c(n, vector<int>(n));
    for(int i = 0; i < C; ++i){
  	  for(int j = 0; j < C; ++j){
  	      cin >> d[i][j];	
        }
    }
    
    for(int i = 0; i < n; ++i){
  	  for(int j = 0; j < n; ++j){
  	      cin >> c[i][j]; --c[i][j];
            ++t[(i+j)%3][c[i][j]];
        }
    }
    
    int ans = INF32;
    for(int i = 0; i < C; ++i){
    	for(int j = 0; j < C; ++j){
    	    if(i==j) continue;
    	    for(int k = 0; k < C; ++k){
    	        if(j==k || k==i){continue;}
                int tmp =calc(d,c,i,j,k);
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;

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

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [10 ** 18 for _ in range(n)]
dp[0] = 0

for i in range(1, n):
    dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2])
print(dp[-1])

Measured memory_bytes: 13976
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


def main():
    N= int_raw()
    return (N-2)*180


print(main())


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;

  int n_b = n - 1;

  vector<int> v(n);
  for (int i = 0; i < n_b; i++) {
    cin >> v[i];
  }
  cout << endl;

  int result = 0;
  result += v[0];
  for (int i = 1; i < n_b; i++) {
    result += min(v[i], v[i - 1]);
  }
  result += v[n_b - 1];

  cout << result << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s= sc.next();
		if ("ARC".equals(s)) {
			System.out.println("ABC");	
		} else {
			System.out.println("ARC");
		}
	}
}

Measured memory_bytes: 35672
N = int(input())
H = [int(a) for a in input().split()]

C = [0] * N
C[1] = abs(H[1]-H[0])

for i in range(2, N):
    C[i] = min(C[i-2]+abs(H[i]-H[i-2]), C[i-1]+abs(H[i]-H[i-1]))
    
print(C[N-1])

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

int main() {
int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if(r<=x && r<=y && r<=W-x && r<=H-y){
    cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }

}





Measured memory_bytes: 3100
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;
#define N_max 100001

inline vll Accumulate(vll input) {
	vll v(input.size());
	v[0] = input[0];
	for (unsigned int i = 1; i < input.size(); i++) {
		v[i] = v[i - 1] + input[i];
	}

	return v;
}

int solve(vll vec, ll Key) {
	vll acc = Accumulate(vec);
	int i = 0;
	for (; acc[i + 1] < Key; i++) {

	}
	i++;

	return i;
}

int main() {
	ll N, K;
	cin >> N >> K;
	vll As(N_max);
	rep(i, N_max) {
		As[i] = 0;
	}

	rep(i, N) {
		int a, b;
		cin >> a >> b;
		As[a] += b;
	}
	int ans_index = solve(As, K);

	cout << ans_index << endl;

}


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

const int mod = 1e9 + 7;
const int mnx = 1e6 + 9;

int a[mnx];
bool pos[mnx];
int n, m, x, y;

int main() {

cin >> n >> m;

pos[1] = 1;

for(int i = 1; i <= n; i++){
    a[i] = 1;
}

for (int i = 0; i < m; i++) {
    cin >> x >> y;
    a[x]--; a[y]++;
    if (pos[x]) {
        if (a[x] == 0) {
            pos[y] = 1; pos[x] = 0;
        } else {
            pos[y] = 1;
        }
    }
}

int cnt = 0;

for (int i = 1; i <= n; i++) {
    cnt += pos[i];
}

cout << cnt << endl;

return 0;

}


Measured memory_bytes: 768