akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
using namespace std;
int n;
long long ans;
long long a[100010],b[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",a+i,b+i);
	}
	for(int i=n;i>=1;i--)
	{
		if((a[i]+ans)%b[i]==0)continue;
		ans=((a[i]+ans)/b[i]+1)*b[i]-a[i];
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};

template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}

extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


int main()
{
	string s;
	cin>>s;
	int sum=0;
	REP(i,s.size())
		sum+=s[i]-'0';
	int ans=sum;
	ans=(s.size()-1)*9 + s[0]-'0'-1;
	chmax(ans, sum);
	print(ans);
}


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

using namespace std;

int main() {
    int n ; cin>>n;
    double money = 0 ;
    for(int i = 0 ; i < n; ++i){
      double x; cin>>x;
      string s; cin>>s;
      if(s == "JPY")money += x;
      else money += x * 380000.0;
    }
   cout<<setprecision(10);
   cout<<fixed;
   cout<<money<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N,i,j,k;
	float p,odd,n;
	scanf("%d",&N);
	int arr[N];
	j = 0;
	n = N;
	for (i=1;i<=N;i++){
		arr[j]=i;
		j++;
	}
	odd = 0;
	for (k=0;k<N;k++){
		if (arr[k]%2 != 0){
			odd++;
		}
	}
	p = odd/N;
	printf("%f\n",p);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
const int INF=10000;
vector<int> E[2000];
int d[2000][2000];
int res, MAX;
void dfs(int k,int x){
    MAX=max(MAX,res);
    d[k][x]=res;
    res++;
    rep(i,0,E[x].size()){
        if(d[k][E[x][i]]==INF) dfs(k,E[x][i]);
    }
    res--;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,K;
    cin>>N>>K;
    int A[N-1],B[N-1];
    rep(i,0,N-1){
        cin>>A[i]>>B[i];
        E[A[i]-1].pb(B[i]-1);
        E[B[i]-1].pb(A[i]-1);
    }
    rep(i,0,N){
        rep(j,0,N) d[i][j]=INF;
    }
    MAX=0;
    rep(i,0,N){
        res=0;
        dfs(i,i);
    }
    if(MAX<=K) cout <<0<<"\n";
    else{
        if(K%2){
            int ans=0;
            rep(i,0,N-1){
                set<int> s;
                rep(j,0,N){
                    if(d[A[i]-1][j]<=K/2) s.insert(j);
                    if(d[B[i]-1][j]<=K/2) s.insert(j);
                }
                int t=s.size();
                ans=max(ans,t);
            }
            cout <<N-ans<<"\n";
        }
        else{
            int ans=0;
            rep(i,0,N){
                int res=0;
                rep(j,0,N){
                    if(d[i][j]<=K/2) res++;
                }
                ans=max(ans,res);
            }
            cout <<N-ans<<"\n";
        }
    }
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, D, X;
  cin >> N >> D >> X;
  int A[N];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
   int ans = X;
   for(int i = 0; i < N; i++){
    int tmp = (D - 1) / A[i] + 1;
     ans += tmp;
   }
    cout << ans << endl;
 }
   


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

using namespace std;
typedef long long ll;

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

    ll ok = 0;
    ll ng = k + 1;
    while (ng - ok > 1) {
        ll mid = (ok + ng) / 2;
        ll tmp = mid;

        ll sum = 0;
        for (ll i = 0; i < n && tmp > 0; i++) {
            sum += tmp;
            tmp /= 2;
        }

        if (sum <= k)ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
    return 0;
}



Measured memory_bytes: 3100
N, W = map(int,input().split(" "))
w,v = [0]*(N+1),[0]*(N+1)
for i in range(N):
    w[i+1],v[i+1] = map(int,input().split(" "))

dp = [ [0]*(W+1) for _ in range(N+1) ]
for i in range(1,N+1):
    for j in range(1,W+1):
        if j >= w[i]:
            dp[i][j] = max([dp[i][j],dp[i-1][j],dp[i-1][j-w[i]] + v[i]])
        else:
            dp[i][j] = max([dp[i][j],dp[i-1][j]])

print(dp[N][W])


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

const int W = 1e5;
const int N = 100;

int main() {
  	ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
	int n, w, inp1, inp2;
	vector<pair<int, int>> arr;
	unsigned long long dp[N + 1][W + 1];
	cin >> n >> w;
	for(int i = 0; i < n; i++){
		cin >> inp1 >> inp2;
		arr.push_back({inp1, inp2});
	}
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= w; j++){
			if(i == 0 || j == 0)
				dp[i][j] = 0;
			else if(j >= arr[i - 1].first)
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - arr[i - 1].first] + arr[i - 1].second);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[n][w];
	return 0;
}

Measured memory_bytes: 82492
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


h, w, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
facts, invs = prepare(h + w, MOD)
ans = 0
ib = invs[b - 1]
iwb = invs[w - b - 1]
for down in range(h - a):
    left_pattern = facts[b - 1 + down] * ib * invs[down] % MOD
    right_pattern = facts[h - 1 - down + w - b - 1] * invs[h - 1 - down] * iwb % MOD
    ans = (ans + left_pattern * right_pattern) % MOD
print(ans)


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

const int N=1e5+10;
int A[N*2],n;

bool judge(int k)
{
    if(A[n-1]<=k&&A[n]<=k) return 1;
    if(A[n-1]>k&&A[n]>k) return 0;
    if(A[n]<=k&&A[n+1]<=k) return 1;
    if(A[n]>k&&A[n+1]>k) return 0;
	for(register int i=1;i<n;i++)
	{
		if(A[n+i]<=k&&A[n+i+1]<=k) return 1;
		if(A[n+i]>k&&A[n+i+1]>k) return 0;
		if(A[n-i-1]<=k&&A[n-i]<=k) return 1;
		if(A[n-i-1]>k&&A[n-i]>k) return 0;
	}
	return (A[1]<=k);
}

signed main()
{
	scanf("%d",&n);
	for(register int i=1;i<2*n;i++)
		scanf("%d",A+i);
	int L=1,R=2*n-1;
	while(R-L>1)
	{
		int mid=(L+R)>>1;
		if(judge(mid)) R=mid;
		else L=mid;
	}
	printf("%d\n",R);
	return 0;
}

Measured memory_bytes: 896
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val sList = mutableListOf<String>()
    (1..n).forEach { sList.add(readLine()!!.toCharArray().sorted().joinToString("")) }
    sList.sort()

    var ans = 0L
    var c = 1L
    for (i in 0 until n - 1) {
        if (sList[i] == sList[i + 1]) {
            ans += c
            c++
        } else {
            c = 1L
        }
    }
    println(ans)
}


Measured memory_bytes: 77484
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> Hs(N, 0);
    for (auto &h : Hs) cin >> h;
    int rec = 0;
    int count = 0;
    for (auto h: Hs){
        if (h >= rec){
            ++count;
            rec = h;
        }
    }
    cout << count << endl;
    return 0;
}

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


int main() {
	int n, d[110], ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> d[i];
	for (int i = 0; i < n; i++)for (int j = i + 1; j < n; j++) {
		if (i != j)ans += d[i] * d[j];
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

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

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

int main() {
	int n;
	while (cin >> n, n){
		vector<int> vi;
		REP(i, n){
			int j;
			cin >> j;
			vi.push_back(j);
		}
		vector<int> vi2;
		vi2.push_back(0);
		REP(i, n){
			if (i > 0)vi2.push_back(vi2[i] + vi[i]);
			else vi2.push_back(vi[0]);
		}
		int max=-100000;
		FOR(i,0 ,n){
			FOR(j,i+1, n+1){
				int plus = vi2[j] - vi2[i];
				if (max < plus)max = plus;
			}
		}
		cout << max << endl;
	}
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
using P = pair<int,pair<int,int>>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};




int main()
{
    long long N;
    cin >> N;
    long long t = 100;
    
    int count = 0;
    while(t < N)
    {
        t*=1.01;
        count++;
    }
    
    cout << count << endl;
    return 0;
}
/*
 if(data[a] == data[b])
 {
 cout << "Yes" << endl;
 }
 else
 {
 cout << "No" << endl;
 }
 */

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

 
    return 0;
}
*/

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

f = [int(input().replace(" ", ""), 2) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = float('-inf')

for i in range(1, 1024):
    price = 0
    for j in range(n):
        price += p[j][bin(i & f[j]).count('1')]
    ans = max(ans, price)

print(ans)

Measured memory_bytes: 3064
S = input()

tmp = 0
Sd = []
while tmp < len(S):
    c = S[tmp]
    l = 0
    while c == S[tmp+l]:
        l += 1
        if tmp+l == len(S): break
    Sd.append((c,l))
    tmp += l

print(len(Sd)-1)

Measured memory_bytes: 10356
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    string A,B; cin >> A >> B;
    if(A.size() > B.size()) cout << "GREATER" << endl;
    else if(A.size() < B.size()) cout << "LESS" << endl;
    else if(A.size() == B.size()){
        if(A < B) cout << "LESS" << endl;
        else if(A > B) cout << "GREATER" << endl;
        else cout << "EQUAL" << endl;
    }
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    for (;;) {
        int n, m; cin >> n >> m; if (!n) break;
        vector<int> h(n), w(m);
        rep(i, 0, n) cin >> h[i];
        rep(i, 0, m) cin >> w[i];
        map<int, int> mh, mw;
        rep(i, 0, n) {
            int sum = 0;
            rep(j, i, n) {
                sum += h[j];
                mh[sum]++;
            }
        }
        rep(i, 0, m) {
            int sum = 0;
            rep(j, i, m) {
                sum += w[j];
                mw[sum]++;
            }
        }
        ll ans = 0;
        for (auto p : mh) {
            ans += 1ll * p.second * mw[p.first];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 34372
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}



int main() {

ll x;
  cin >>x;
  if(x==1) {
cout<<0<<endl;
  }
  else {
cout<<1<<endl;
  }

}


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

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

	stack<int> s;
	stack<pair<int, int> > l;

	for (int i = 0; i < (int)str.size(); ++i) {
		if (str[i] == '\\') {
			s.push(i);
		} else if (str[i] == '/' && !s.empty()) {
			int a = i - s.top();
			while (!l.empty() && l.top().first > s.top()) {
				a += l.top().second;
				l.pop();
			}
			l.emplace(s.top(), a);
			s.pop();
		}
	}

	int sum = 0;
	stack<int> ans;
	while (!l.empty()) {
		ans.push(l.top().second);
		sum += l.top().second;
		l.pop();
	}

	cout << sum << endl;
	cout << ans.size();
	while (!ans.empty()) {
		cout << " " << ans.top();
		ans.pop();
	}
	cout << endl;
}



Measured memory_bytes: 3272
#include <iostream>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
  string s;
  cin >> s;
  cout << s[0] << s.substr(1, s.length() - 2).length() << s[s.length() - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;


int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}

int main() {
		int n;
		cin >> n;
		int A[100000];
		for (int i = 0;i < n;i++) {
			cin >> A[i];
		}
		int ad=partition(A, 0, n - 1);
		for (int i = 0;i < n;i++) {
			if (i == ad) {
				cout << "[" << A[i] << "] ";
			}
			else if (i == n - 1) {
				cout << A[i] << endl;
			}
			else cout << A[i] << " ";
		}

}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
 
int lcs[3001][3001];
vector<char> res;
 
void GetLCS(string s, string t, int i, int j)
{
    if (i == 0 || j == 0)
        return;
 
    if (s[i-1] == t[j-1])
    {
        res.push_back(s[i-1]);
        GetLCS(s, t, i-1, j-1);
    }
    else if (lcs[i][j] == lcs[i-1][j])
    {
        GetLCS(s, t, i-1, j);
    }
    else
    {
        GetLCS(s, t, i, j-1);
    }
}
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    string s,t;
 
    cin >> s >> t;
    int l1 = s.length();
    int l2 = t.length();
 
    // base case
    for(int i=0; i<=l2; ++i)
        lcs[0][i] = 0;
    for(int i=0; i<=l1; ++i)
        lcs[i][0] = 0;
 
    for(int i=1; i<=l1; ++i)
    {
        for(int j=1; j<=l2; ++j)
        {
            if(s[i-1] == t[j-1])
            {
                lcs[i][j] = lcs[i-1][j-1] + 1;
            }
            else
                lcs[i][j] = max(lcs[i][j-1], lcs[i-1][j]);
        }
    }
    
    if (lcs[l1][l2] != 0)
    {
        int i = l1, j=l2;
    
    
        GetLCS(s, t, l1, l2);
        reverse(res.begin(), res.end()); 
        for (auto it = res.begin(); it != res.end(); it++) 
            cout << *it; 
    }
    else
        cout << "";
        
    return 0;
}

Measured memory_bytes: 65664
// @flow

const main = (input /*: string */) => {
  const r = reader(input)
  const n = r.n()
  const s = r.s()

  console.log(_rot(s, n))
}

const _rot = (s /* :string */, n /*: number */) =>
  s
    .split('')
    .map(c => _shift(c, n))
    .join('')

const _shift = (c /*: string */, n /*: number */) => {
  const ac = 'A'.charCodeAt(0)

  return String.fromCharCode(((c.charCodeAt(0) + n - ac) % 26) + ac)
}

const reader = (str /*: string*/) => {
  const lines = str.trim().split('\n')
  const s = () => lines.shift() || ''
  const n = () => Number(s())

  const ss = () => s().split(' ')
  const ns = () => ss().map(v => Number(v))

  return { lines, s, n, ss, ns }
}

const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

main(getInput())


Measured memory_bytes: 7500
#include<stdio.h>
#include<math.h>
int main()
{
	while (1){
		int n = 0, s[1000], i;
		double hensa = 0, heikin = 0;

		scanf("%d", &n);
		if (n == 0)
			break;
		
		for (i = 0; i < n; i++){
			scanf("%d", &s[i]);
			heikin += s[i];
		}
		heikin = heikin / n;

		for (i = 0; i < n; i++){
			hensa += (s[i] - heikin) * (s[i] - heikin);
		}
		hensa = hensa / n;
		hensa = sqrt(hensa);
		printf("%f\n", hensa);
	}
	return(0);
}


Measured memory_bytes: 2060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;
int main() {
	int k, a, b;
	cin >> k >> a >> b;

	for (int i = a; i <= b; i++){
		if (i%k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
}


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

int main(){
    ll a;
    char b_[8];
    cin >> a >> b_;
    int b=0;
    if(b_[0] != '.') b+=(b_[0]-'0')*100;
    if(b_[1] != '\0'){
        if(b_[2] != '\0'){
            b+=(b_[2]-'0')*10;
            if(b_[3] != '\0'){
                b+=(b_[3]-'0');
            }
        }
    }
    ll ans;
    ans = a*b;
    ans /=100;
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}


int main(){
    int n=in(),k=in();
    string s=strin();
    vec a(n),b(n+2,0);
    rep(i,n)a[i]=s.at(i)=='0'?0:1;
    int index=0;
    b[0]=s.at(0)=='1'?1:-1;
    rep2(i,1,n-1){
        if(a[i]==1&&b[index]>0)b[index]++;
        else if(a[i]==0&&b[index]<0)b[index]--;
        else if(a[i]==1&&b[index]<0)b[++index]=1;
        else if(a[i]==0&&b[index]>0)b[++index]=-1;
    }
    int cnt0=0;
    rep(i,b.size()){
        if(b[i]<0)cnt0++;

    }
    if(k>=cnt0){
        cout<<n<<endl;
        return 0;
    }
    ll ans=0;
    vecll c(n+1);
    c[0]=0;
    rep(i,n){
        c[i+1]=c[i]+abs(b[i]);
    }
    int p=b[0]>0?1:2;
    for(int i=p;i+2*k<n+1;i+=2){
        ans=max(ans,c[i+2*k]-c[i-1]);
    }
    ans=max(ans,c[2*k]);
    cout<<ans<<endl;
}


Measured memory_bytes: 2048
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

typedef long long ll;
using namespace std;

int m[1001][1001] = {};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int c = 0;
    for (int i = 0; i < n; i++) {
        for (int k = i + 1; k < n; k++) {
            m[i][k] = m[k][i] = c;
            c++;
        }
    }
    vector<int> G[c];
    int appeared[c];
    fill(appeared, appeared + c, 0);
    for (int i = 0; i < n; i++) {
        int prev = -1;
        for (int k = 1; k < n; k++) {
            int a; cin >> a;
            a--;
            int current = m[i][a];
            if (prev >= 0) {
                G[prev].push_back(current);
                appeared[current]++;
            }
            prev = current;
        }
    }
    int ans = 1;
    queue<pair<int, int>> zeros;
    for (int i = 0; i < c; i++) if (appeared[i] == 0) zeros.push({i, 1});
    int cnt = 0;

    if (zeros.empty()) {
        cout << -1 << endl;
        return 0;
    }
    while (zeros.size()) {
        cnt++;
        int z = zeros.front().first;
        int step = zeros.front().second;
        ans = max(step, ans);
        zeros.pop();
        for (auto& g : G[z]) {
            appeared[g]--;
            if (appeared[g] == 0) {
                zeros.push({g, step+1});
            }
        }
        G[z].clear();
    }
    if (cnt != n*(n-1)/2) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<P> VP;
const int INF = 1LL<<60;
const int MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}

signed main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,char>> a(n*2);
  rep(i,n){
    cin>>a[i].first>>a[i+n].first;
    a[i].second='a';
    a[i+n].second='b';
  }
  SORT(a);
  reverse(all(a));
  int ans=0,sum=0,idx=0;
  while(sum<m){
    if(a[idx].second=='b'){
      ans++;
      sum+=a[idx].first;
      idx++;
    }
    else {
      ans+=(m-sum)/a[idx].first;
      sum+=((m-sum)/a[idx].first)*a[idx].first;
      if(sum<m)ans++;
      break;
    }
  }
  out(ans);
  
  return 0;
}



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

template<class Monoid> struct SegmentTree {
    using Function = function< Monoid(Monoid, Monoid) >;

    int N; vector<Monoid> segment;
    const Function func;
    const Monoid id;

    SegmentTree(int n, const Function func, const Monoid id) : func(func), id(id) {
        N = 1;
        while (N < n) N <<= 1;
        segment.assign(2 * N, id);
    }

    void set(int num, Monoid x) {
        segment[N + num] = x;
    }
    void build() {
        for (int k = N - 1; k > 0; k--) {
            segment[k] = func(segment[2*k], segment[2*k+1]);
        }
    }
    void update(int k, Monoid x) {
        k = k + N; segment[k] = x;
        while(k >>= 1) {
            segment[k] = func(segment[2*k], segment[2*k+1]);
        }
    }

    // query:[a, b)
    Monoid query(int a, int b) {
        Monoid L = id; Monoid R = id; a += N; b += N;
        for (; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = func(L, segment[a++]);
            if (b & 1) R = func(segment[--b], R);
        }
        return func(L, R);
    }
    // 0-based numbering;
    Monoid operator[](const int k) const {
        return segment[N+k];
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    using robot = pair<int, int>;
    vector<robot> v;
    for (int i = 0; i < n; i++) {
        int x, d; cin >> x >> d;
        v.emplace_back(x, d);
    }
    sort(v.begin(), v.end());
    SegmentTree<int> s(n, [](int a, int b){return max(a, b);}, -1);
    for (int i = n-1; i >= 0; i--) {
        int d = v[i].first + v[i].second;
        auto r = lower_bound(v.begin(), v.end(), make_pair(d, 0)) - v.begin();
        auto res = max(s.query(i+1, r), i);
        s.update(i, res);
    }
    vector<long long> dp(n+1, 0); dp[0] = 1;
    for (int i = 0; i < n; i++) {
        dp[s[i]+1] = (dp[s[i]+1] + dp[i]) % mod;
        dp[i+1] = (dp[i+1] + dp[i]) % mod;
    }
    cout << dp[n] << "\n";
    return 0;
}

Measured memory_bytes: 5616
def main():
    n,k=map(int,input().split())
    ans=0
    baisuu=n//k
    ans+=baisuu**3
    if k%2==0:
        if baisuu*k+k//2<=n:
            hanbun=baisuu+1
        else:
            hanbun=baisuu
        ans+=hanbun**3
    print(ans)
if __name__=="__main__":
    main()

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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 0x7fffffffffffffff

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int da[1000001];
vi d[1000001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    for (int i = 2; i < 1000001; ++i){
        if(d[i].empty()){
            for (int j = i; j < 1000001; j+=i){
                d[j].pb(i);
            }
        }
    }
    int n; cin >> n;
    int g;
    vi v(n);
    for (int i = 0; i < n; ++i){
        cin >> v[i];
        if(!i) g = v[i];
        else g = __gcd(g, v[i]);
    }
    if(g > 1){
        cout << "not coprime\n";
    }else{
        for (int i = 0; i < n; ++i){
            for(auto l : d[v[i]]){
                if(da[l]){
                    cout << "setwise coprime\n";
                    return 0;
                }else da[l] = 1;
            }
        }

        cout << "pairwise coprime\n";
    }


    return 0;
}

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

int main(void){
  int x, y;
  cin >> x >> y;
  if (x == 2 || y == 2) cout << "No" << endl;
  else if (x == 4 || x == 6 || x == 9 || x == 11){
    if (y == 4 || y == 6 || y == 9 || y == 11) cout <<"Yes" << endl;
    else cout <<"No" << endl;
  }
  else {
    if (y != 4 || y != 6 || y != 9 || y != 11)  cout <<"Yes"<< endl;
    else cout <<"No"<< endl;
  }
}


Measured memory_bytes: 256
class UnionFind
  attr_accessor :parent
  def initialize(size)
    @parent = Array.new(size, -1)
  end

  def root(x)
    @parent[x] < 0 ? x : @parent[x] = root(@parent[x])
  end

  def same?(x, y)
    root(x) == root(y)
  end

  def unite(x, y)
    x_root = root(x)
    y_root = root(y)
    return false if x_root == y_root

    if @parent[x_root] > @parent[y_root]
      x_root, y_root = y_root, x_root
    end

    @parent[x_root] += @parent[y_root]
    @parent[y_root] = x_root
    return true
  end

  def size(x)
    return -@parent[root(x)]
  end
end

require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,m,k = gets.chomp.split.map(&:to_i)

uf = UnionFind.new(n+1)
h = {}
m.times do
  a, b = gets.chomp.split.map(&:to_i)
  a-=1
  b-=1
  uf.unite(a,b)

  h[a] ||= Set.new
  h[a].add b
  h[b] ||= Set.new
  h[b].add a
end

k.times do
  c,d = gets.chomp.split.map(&:to_i)
  c-=1
  d-=1
  h[c] ||= Set.new
  h[c].add d
  h[d] ||= Set.new
  h[d].add c
end


ans = Array.new(n)
n.times do |i|
  root = uf.root(i)
  size = uf.size(i)
  unless h[i].nil?
    h[i].each do |j|
      if uf.root(j) == root
        size -= 1
      end
    end
  end
  ans[i] = size - 1
end


puts ans.join(' ')


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

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

int main(){
  ll n,m;
  cin >> n >> m;

  ll ans1 = min(n, m/2);
  ll ans2 = (m-ans1*2)/4;

  cout << ans1 + ans2;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
const int MM = 5e5+5, SQ = 700;

int n, q, a[MM], cnt[MM], val, ans[MM];
struct st{
	int l, r, id;
	bool operator<(const st &o) const{
		if(l/SQ != o.l/SQ)
			return l/SQ < o.l/SQ;
		return r < o.r;
	}
} b[MM];

int main(){
	scan(n, q);
	for(int i = 1; i <= n; i++)
		scan(a[i]);
	for(int i = 0; i < q; i++){
		scan(b[i].l, b[i].r);
		b[i].id = i;
	}
	sort(b, b+q);
	int l = 1, r = 0;
	for(int i = 0; i < q; i++){
		while(l < b[i].l){
			if(!--cnt[a[l++]])
				val--;
		}
		while(l > b[i].l){
			if(!cnt[a[--l]]++)
				val++;
		}
		while(r < b[i].r){
			if(!cnt[a[++r]]++)
				val++;
		}
		while(r > b[i].r){
			if(!--cnt[a[r--]])
				val--;
		}
		ans[b[i].id] = val;
	}
	for(int i = 0; i < q; i++)
		print(ans[i]);
}

Measured memory_bytes: 15424
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
using namespace std;
using s64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{
    s64 n,m;
    cin >> n >> m;
    s64 a[m];
    s64 b[m];
    rep(i,m) cin >> a[i] >> b[i];

    s64 full_conv = n*(n-1)/2;
    s64 inconvs[m];
    s64 tmp_conv = 0;
    unordered_map<s64, unordered_set<s64>> connected_islands; // map_id, set
    unordered_map<s64, s64> islands; // island_id, map_id
    rep(i,m)
    {
        s64 ai = a[m-1-i];
        s64 bi = b[m-1-i];

        s64 a_id = -1;
        s64 b_id = -1;

        if(islands.find(ai) != islands.end())
            a_id = islands[ai];
        if(islands.find(bi) != islands.end())
            b_id = islands[bi];

        if(a_id < 0 && b_id < 0)
        {
            unordered_set<s64> iset({ai,bi});
            connected_islands.insert({s64(i),iset});
            islands.insert({ai, s64(i)});
            islands.insert({bi, s64(i)});
            tmp_conv += 1;
        }
        else if(a_id < 0 && b_id >= 0)
        {
            tmp_conv += connected_islands[b_id].size();
            connected_islands[b_id].insert(ai);
            islands.insert({ai, b_id});
        }
        else if(a_id >= 0 && b_id < 0)
        {
            tmp_conv += connected_islands[a_id].size();
            connected_islands[a_id].insert(bi);
            islands.insert({bi, a_id});
        }
        else
        {
             if(a_id != b_id)
             {
                 s64 a_size = connected_islands[a_id].size();
                 s64 b_size = connected_islands[b_id].size();

                 if(a_size < b_size)
                 {
                     for(auto aj:connected_islands[a_id])
                     {
                         connected_islands[b_id].insert(aj);
                         islands[aj] = b_id;
                     }
                     connected_islands.erase(a_id);
                 }
                 else
                 {
                     for(auto bj:connected_islands[b_id])
                     {
                         connected_islands[a_id].insert(bj);
                         islands[bj] = a_id;
                     }
                     connected_islands.erase(b_id);
                 }

                 tmp_conv = tmp_conv - a_size*(a_size-1)/2 - b_size*(b_size-1)/2 + (a_size+b_size)*(a_size+b_size-1)/2;        
             }
        }

        inconvs[m-1-i] = full_conv - tmp_conv;       
    }

    inconvs[m] = full_conv;

    rep2(i,1,m+1) cout << inconvs[i] << endl;
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;


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

    cin>>n;
    map<int,double> mp;
    mp[0]=1;
    
    while (n--) {
	double P; cin>>P;
	map<int,double> _mp;
	for (auto p: mp) {
	    _mp[p.first+1] += P*p.second;
	    _mp[p.first-1] += (1.0-P)*p.second;
	}
	swap(mp, _mp);
    }

    double res=0;
    for (auto p: mp) {
	if (p.first>0) res+=p.second;
    }

    cout<<fixed<<setprecision(9)<<res<<endl;
  

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int main(void){
    int A,B;
    cin>>A>>B;
    int ans=max(A+B,max(A-B,A*B));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    n, c, k = map(int, input().split())
    t = list(int(input()) for _ in range(n))
    t.sort()
    ans = 1
    limit = t[0] + k
    bus = 0
    for i in range(n):
        bus += 1
        if t[i] > limit or bus > c:
            limit = t[i] + k
            ans += 1
            bus = 1
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 7432
#!/usr/bin/env python3
from functools import reduce

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while 0 < b:
        a, b = b, a % b
    return a


def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    x = list(map(int, input().split()))

    y = list(map(lambda v: abs(v - X), x))

    a = reduce(gcd, y)

    print(a)


if __name__ == '__main__':
    main()



Measured memory_bytes: 14596
#include <stdio.h>
int main(){
 
  int W,H,x,y,r;
 
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 
  if (x-r >= 0 && x+r <= W){
 
    if (y-r >= 0 && y+r <= H){
 
      printf("Yes\n");
 
      } else {
       
      printf("No\n");
 
    }
 
  } else {
 
  printf("No\n");
 
  }
 
  return 0;
 
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> a(H, vector<int>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> a[i][j];
    }
  }

  int N = 0;
  vector<vector<int>> yxyx;

  rep(i, H) {
    rep(j, W - 1) {
      if (a[i][j] % 2) {
        a[i][j]--;
        a[i][j + 1]++;
        N++;
        vector<int> temp = {i + 1, j + 1, i + 1, j + 2};
        yxyx.pb(temp);
      }
    }
  }

  int j = W - 1;
  rep(i, H - 1) {
    if (a[i][j] % 2) {
      a[i][j]--;
      a[i + 1][j]++;
      N++;
      vector<int> temp = {i + 1, j + 1, i + 2, j + 1};
      yxyx.pb(temp);
    }
  }

  cout << N << endl;
  rep(i, yxyx.size()) {
    rep(j, 4) {
      cout << yxyx[i][j];
      if (j != 3)
        cout << ' ';
    }
    cout << endl;
  }
}

Measured memory_bytes: 10160
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=100005;
const LL Mod=1e9+7;
int main()
{
//    freopen("input.in","r",stdin);
//    freopen("output1.out","w",stdout);
    char s[205],t[205];
    while(scanf("%s%s",s,t)!=EOF)
    {
        int len=strlen(s);
        for(int i=0;i<len;i++)
            s[i+len]=s[i];
        bool yes=false;
        for(int i=0;i<len;i++)
        {
            if(s[i]==t[0])
            {
                bool eq=true;
                for(int j=0;j<len;j++)
                {
                    if(s[j+i]!=t[j])
                    {
                        eq=false;
                        break;
                    }
                }
                if(eq)
                {
                    yes=true;
                    break;
                }
            }
        }
        printf("%s\n",yes?"Yes":"No");
    }
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import *
sys.setrecursionlimit(10**5)
def dfs(x):
    visited[x]=True
    for i in range(len(adj[x])):
        t=adj[x][i]
        distance[t]=max(distance[t],distance[x]+1)
        indegree[t]-=1
        if(indegree[t]==0):
            dfs(t)

MAX = 10**5+5
indegree=[0]*(MAX)
distance=[0]*(MAX)
visited = [False]*(MAX)
adj = defaultdict(list)
N,M=list(map(int,input().split()))
for i in range(M):
    a,b=list(map(int,input().split()))
    adj[a].append(b)
    indegree[b]+=1
ans=0
for i in range(1,N+1):
    if(visited[i]==False and indegree[i]==0):
        dfs(i)
for i in range(1,N+1):
    ans=max(ans,distance[i])

print(ans)


Measured memory_bytes: 221684
n = int(input())
if n < 10:
  print(n)
elif n < 100:
  print(9)
elif n < 1000:
  print(n - 99 + 9)
elif n < 10000:
  print(909)
elif n < 100000:
  print(n - 9999 + 909)
else:
  print(90909)

Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>

using namespace std;
using ll = long long;
const ll res = 1000000007;


int main() {
	ll n, ans=0;
	vector<vector<ll>> a(3, vector<ll>(3)), r(3, vector<ll>(3));

	for (ll i = 0; i < 3; i++)
		for (ll j = 0; j < 3; j++) {
			cin >> a[i][j];
			r[i][j] = 0;
		}
			

	cin >> n;
	vector<ll> b(n);

	for (ll i = 0; i < n; i++)
		cin >> b[i];

	for (ll i = 0; i < 3; i++)
		for (ll j = 0; j < 3; j++) {
			for (ll k = 0; k < n; k++)
				if (a[i][j] == b[k]) {
					r[i][j] = 1;
				}
					
		}

	if (r[0][0] + r[0][1] + r[0][2] == 3)
		ans = 1;
	if (r[1][0] + r[1][1] + r[1][2] == 3)
		ans = 1;
	if (r[2][0] + r[2][1] + r[2][2] == 3)
		ans = 1;
	if (r[0][0] + r[1][0] + r[2][0] == 3)
		ans = 1;
	if (r[0][1] + r[1][1] + r[2][1] == 3)
		ans = 1;
	if (r[0][2] + r[1][2] + r[2][2] == 3)
		ans = 1;
	if (r[0][0] + r[1][1] + r[2][2] == 3)
		ans = 1;
	if (r[0][2] + r[1][1] + r[2][0] == 3)
		ans = 1;

	if (ans == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

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

Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[200000], a[300000], b[300000];
string str, ss;
bool f;
char c, ch[100][100];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v;
map<LL, LL>ma;
multiset<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	rep(i, n-1) {
		m -= a[i];
		if (m >= 0) {
			ans++;
		}
	}
	if (m == a[n - 1])
		ans++;
	cout << ans << endl;
	return 0;
}


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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  char e=a[0]-32;
  char f=b[0]-32;
  char g=c[0]-32;
  cout<<e<<f<<g;
  
  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll e, y, result;
  string s;
  s =  "";
  cin >> e >> y;
  result = y;
  if (e == 0) {
    if (1989 <= y) {
      result -= 1988;
      s = "H";
    } else if (1926 <= y) {
      result -= 1925;
      s = "S";
    } else if (1912 <= y) {
      result -= 1911;
      s = "T";
    } else if (1868 <= y) {
      result -= 1867;
      s = "M";
    }
  }
  else if (e == 1) result += 1867;
  else if (e == 2) result += 1911;
  else if (e == 3) result += 1925;
  else if (e == 4) result += 1988;

  cout << s << result << endl;
	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <utility>
#include <algorithm>
//#include <functional>
//#include <boost/foreach.hpp>
using namespace std;

int main(){
  pair<int,pair<int,int> > pai[1001];
  int n,m,a,t,y1,y2;
  while(1){
    cin>>n>>m>>a;
    if(n==0)break;
    for(int i=0;i<m;i++){//横棒の数だけ
      cin>>t>>y1>>y2;
      pai[i].first=t;
      pai[i].second.first=y1;
      pai[i].second.second=y2;
    }
    sort(pai,pai+m);
    reverse(pai,pai+m);
    for(int i=0;i<m;i++){
      if(pai[i].second.first==a)a=pai[i].second.second;
      else if(pai[i].second.second==a)a=pai[i].second.first;
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <string.h>

#define ARG_MAX	(  51 )
#define N_MAX	( 101 )

int main()
{
	char str_odd[ARG_MAX] = {0};
	char str_even[ARG_MAX] = {0};
	char str_answer[N_MAX] = {0};
	
	scanf( "%s", str_odd );
	scanf( "%s", str_even );
	
	int len_odd  = strlen( str_odd );
	
	int i;
	for ( i = 0; i <= len_odd; i++ )
	{
		str_answer[ 2 * i    ] = str_odd[i];
		str_answer[ 2 * i + 1] = str_even[i];
	}
	
	printf( "%s\n", str_answer );
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> H(N);
    for(int i=0;i<N;i++) cin >> H[i];
    bool ok = true;
    for(int i=N-1;i>=1;i--){
        if(H[i]<H[i-1]){
            H[i-1]--;
        }
        ok &= H[i-1]<=H[i];
    }
    cout << (ok? "Yes\n":"No\n");
}

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

int main(){
    int a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    }
    int b[20],n,k;
    map<int,int>m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>k;m[k]=1;
    }
    int flag=0;
    for(int i=0;i<3;i++){
        if(m[a[i][0]] && m[a[i][1]] && m[a[i][2]]) {
            flag=1;break;
        }
    }
    for(int i=0;i<3;i++){
        if(m[a[0][i]] && m[a[1][i]] && m[a[2][i]]) {
            flag=1;break;
        }
    }
    if(m[a[0][0]] && m[a[1][1]] && m[a[2][2]]) {
            flag=1;
        }
        if(m[a[0][2]] && m[a[1][1]] && m[a[2][0]]) {
            flag=1;
        }
        if(flag) puts("Yes");
        else puts("No");
    return 0;
}


Measured memory_bytes: 256