akhauriyash/Code-Regression huggingface dataset:
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct BIT { //1-indexed
private:
    int n,n2;
    vector<ll> bit;

public:
    BIT(ll N){
        n = N;
        bit.assign(n+1, 0);
        n2 = 1;
        while(n2 * 2 <= n) n2 *= 2;
    }

    ll sum(ll x){ //[1, x]
        ll res = 0;
        for(ll i = x; i > 0; i -= i & -i) res += bit[i];
        return res;
    }

    ll sum(ll lv, ll rv){ // [lv, rv)
        return sum(rv-1) - sum(lv);
    }

    void add(ll x, ll v){
        if(x == 0) return;
        for(ll i = x; i <= n; i += i & -i) bit[i] += v;
    }

    ll lower_bound(ll w) {
        if (w <= 0) return 0;
        ll x = 0;
        for (ll k = n2; k > 0; k /= 2) {
            if (x + k <= n && bit[x + k] < w) {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};
vector<ll> compress(vector<ll> x, ll n){
    // [1,n]
	vector<ll> v;
	v.push_back(-INF); v.push_back(INF);
	rep(i,0,n) v.push_back(x[i]);
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	vector<ll> res;
	rep(i,0,n) res.push_back(lower_bound(v.begin(), v.end(), x[i]) - v.begin());
	return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    vector<ll> a(100010);
    rep(i,0,N) cin >> a[i];
    rep(i,0,N) a[i] -= K;
    vector<ll> sum(100010);
    rep(i,0,N) sum[i+1] = sum[i] + a[i]; 
    vector<ll> ac = compress(sum, N+1);
    BIT bit(100010);
    ll ans = 0;
    rep(i,0,N+1){
        ans += bit.sum(ac[i]);
        bit.add(ac[i], 1);
    }
    print(ans);





    

}


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

int main () {
  int N, M;
  cin >> N >> M;
  
  vector<int> vec(2 * M);
  vector<int> road(N);
  for (int i = 0; i < 2 * M; i++) {
    cin >> vec.at(i);
    
    for (int j = 0; j < N; j++) {
      if (vec.at(i) == j + 1)
        road.at(j)++;
    }
  }
  
  for (int i = 0; i < N; i++) 
    cout << road.at(i) << endl;
}

Measured memory_bytes: 384
from itertools import combinations
from heapq import heappush, heappop

class Dijkstra:
    def __init__(self, N):
        self.N = N # #vertices
        self.E = [[] for _ in range(N)]

    def add_edge(self, init, end, weight, undirected=False):
        self.E[init].append((end, weight))
        if undirected: self.E[end].append((init, weight))
    
    def distance(self, s):
        INF = float('inf')
        E, N = self.E, self.N
        self.dist = dist = [INF] * N # the distance of each vertex from s
        self.prev = prev = [-1] * N # the previous vertex of each vertex on a shortest path from s
        dist[s] = 0
        n_visited = 1 # #(visited vertices)
        heap = []
        heappush(heap, (0, s))
        while heap:
            d, v = heappop(heap)
            if dist[v] < d: continue
            for u, c in E[v]:
                temp = d + c
                if dist[u] > temp:
                    dist[u] = temp; prev[u] = v
                    heappush(heap, (temp, u))
            n_visited += 1
            if n_visited == N: break
        return dist
    
    def shortest_path(self, t):
        P = []
        prev = self.prev
        while True:
            P.append(t)
            t = prev[t]
            if t == -1: break
        return P[::-1]

def dist(p1, p2): return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) ** 0.5
    
xs, ys, xt, yt = map(int, input().split())
N = int(input())
P = [[(xs, ys), 0, 0], [(xt, yt), 0, 1]]
for i in range(2, N+2):
    x, y, r = map(int, input().split())
    P.append([(x, y), r, i])
dk = Dijkstra(N+2)
for [p1, r1, i], [p2, r2, j] in combinations(P, 2):
    d = max(0, dist(p1, p2) - (r1 + r2))
    dk.add_edge(i, j, d, undirected=True)
print(dk.distance(0)[1])

Measured memory_bytes: 125320
#include<bits/stdc++.h>
using namespace std;
char s[10][10];
int main(){
	int h,w,x=0,y=0,cnt=0;
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		scanf("%s",s[i]);
		for(int j=0;j<w;j++) cnt+=(s[i][j]=='#');
	}
	while(x+1<h||y+1<w){
		if(s[x][y]!='#') break;
		cnt--;
		bool d=x+1<h&&s[x+1][y]=='#',r=y+1<w&&s[x][y+1]=='#';
		if(d&&!r) x++;
		else if(!d&&r) y++;
		else break;
	}
	if(x+1<h||y+1<w||cnt>1) puts("Impossible");
	else puts("Possible");
	return 0;
}

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

int main(void)
{
    string s;
    cin >> s;

    char c1, c2;
    int n1 = 0;
    int n2 = 0;
    c1 = s[0];
    if (s[1] == c1) c2 = s[2];
    else c2 = s[1];

    for (int i = 0; i < 4; i++) {
        if (s[i] == c1) n1++;
        if (s[i] == c2) n2++;
    }
    if (n1 == 2 && n2 == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define len length()
#define sz size()
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort(v.begin(), v.end())
#define veci(a, n) vector<int> a(n)
#define vecs(a, n) vector<string> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define sp(n) cout << setprecision(n) << fixed

int main () {
    int W, H, N;
    cin >> W >> H >> N;
    int x_ma=W, x_mi=0, y_ma=H, y_mi=0;
    rep(i, N){
        int x, y, a;
        cin >> x >> y >> a;
        if(a==1) x_mi=max(x_mi, x);
        if(a==2) x_ma=min(x_ma, x);
        if(a==3) y_mi=max(y_mi, y);
        if(a==4) y_ma=min(y_ma, y);
    }
    int ans;
    if((x_ma>x_mi) && (y_ma>y_mi)){
        ans = (x_ma-x_mi)*(y_ma-y_mi);
    }
    else ans = 0;
    cout << max(0, ans) << endl;
    return 0;  
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
S = input()

c = Counter(S)
S_target = 'R' * c['R'] + 'W' * c['W']

ans = 0
for a, b in zip(S, S_target):
    if b == 'W':
        break
    if a != b:
        ans += 1
print(ans)


Measured memory_bytes: 9876
k = int(input(''))
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[k-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        int c = 0;
        int d = i;
        for(int j = 0; j < 5; j++) {
            c += d % 10;
            d /= 10;
        }
        if(c >= a && c <= b) ans+=i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define REPR(i, n) for(int i = int(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

int main() {
    int n; cin >> n;
    int cnt = 0;
    int cntA = 0, cntB = 0;
    bool onlyA = false, onlyB = false;
    REP(i, n) {
        string s; cin >> s;
        REP(j, s.size()-1) {
            if (s[j] == 'A' && s[j + 1] == 'B') cnt++;
        }
        if (s[0] == 'B') cntB++;
        if (s[s.size() - 1] == 'A') cntA++;
        if (s[0] == 'B' && s[s.size() - 1] != 'A') onlyB = true;
        if (s[0] != 'B' && s[s.size() - 1] == 'A') onlyA = true;
    }
    if (!onlyA) cntB--;
    if (!onlyB) cntA--;
    cout << cnt + max(0,min(cntA, cntB)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
int main() 
{

  fast();

    string s;
    cin >>s;
    for(ll j=s.size()-1;j>=0;j--)
    {
        string s1=s.substr(0,j/2);

        string s2=s.substr(j/2,j/2);
         // cout<<s1<<" "<<s2<<edl;
        ll lo=s1.size()+s2.size();
        if(s1==s2&&lo%2==0)
        {
            cout<<lo<<edl;
            return 0;
        }
    }

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<random>
#include<ctime>
#include<cstdlib>
#include<complex>
#include<fstream>
using namespace std;

int main(){

  int cnt=0;
  string s;
  cin >> s;

  if(s[0]=='1'){
    cnt++;
  }
  if(s[1]=='1'){
    cnt++;
  }
  if(s[2]=='1'){
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}

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

int main() {
	string S;
	cin >> S;
	int n = S.length();
	vector<bool> alph(26,false);
	int min = 0;

	for (int i = 0; i < n; i++) {
		alph[S[i] - 'a'] = true;
		while (min < 26 && alph[min]) min++;
	}
	if (min < 26) printf("%c",'a'+min);
	else cout << "None";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}

ll n,W;
ll v[105],w[105],dp[105][100005];

ll fxn(ll pos,ll we)
{
	if(we>W)
	{
		return INT_MIN;
	}
	if(pos>=n)
	{
		return 0;
	}
	if(dp[pos][we]!=-1)
	{
		return dp[pos][we];
	}
	ll ans;
	ans=max(fxn(pos+1,we+w[pos])+v[pos],fxn(pos+1,we));
	dp[pos][we]=ans;
	return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i;
    cin>>n>>W;
    for(i=0;i<n;i++)
    {
    	cin>>w[i]>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<fxn(0,0)<<"\n";
	return 0;
}

Measured memory_bytes: 85672
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
template<class T>
struct Sieve {
  T n;
  vector<T> f, primes;
  Sieve(T n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  //素数かどうかのboolを返す
  bool isPrime(T x) { return f[x] == x;}
  //昇順の素因数リストを返す
  vector<T> factorList(T x) {
    vector<T> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  //昇順の(素因数、その数)のpairを返す
  vector<pair<T,T>> factor(T x) {
    vector<T> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<pair<T,T>> res(1, make_pair(fl[0], 0));
    for (T p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}
int main(){
    ll a,b; cin >> a >> b;
    ll gcdab = gcd(max(a,b),min(a,b));  
    int mx = sqrt(gcdab) + 1;
    int ans = 1;
    for(int i=2; i<=mx; i++){
        if(gcdab % i == 0) ans++;
        while(gcdab % i == 0) gcdab /= i;
        if(gcdab==1) break;
    }
    if(gcdab!=1) ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  while (getline(cin, s), s != ".") {
    stack<char> t;
    rep(i, s.size()) {
      if (s[i] == '[' || s[i] == '(') t.push(s[i]);
      if (s[i] == ')') {
        if (t.size() && t.top() == '(') {
          t.pop();
        } else {
          cout << "no" << endl;
          goto next;
        }
      }
      if (s[i] == ']') {
        if (t.size() && t.top() == '[') {
          t.pop();
        } else {
          cout << "no" << endl;
          goto next;
        }
      }
    }
    cout << (t.size() ? "no" : "yes") << endl;
  next:;
  }
}

Measured memory_bytes: 3052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

class Main
{
	public static void main(String[] args) throws Exception
	{
		invoke(System.in);
	}

	public static void	invoke(InputStream is) throws IOException
	{
		// input
		BufferedReader	reader = new BufferedReader(new InputStreamReader(is));
		String	line = reader.readLine();

		int	m = Integer.parseInt(line);
		System.out.println(48 - m);

	}

}

Measured memory_bytes: 24532
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    bool flg = false;
    for (int i=0; i<=n/4; i++){
        for(int k=0; k<=n/7; k++){
            if (4 * i + 7 * k == n) flg=true;
        }
    }
    if(flg) out("Yes");
    else out("No");
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b;
  cin >> a >> b;

  int l, r;
  l = r = 1;
  for (int i = 2; i < 1000; i++) {
    r += i;
    if (r - l == b - a) {
      cout << l - a << endl;
      return 0;
    }
    l = r;
  }

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  map<int, int> D; rep(i,N) { int tmp; cin >> tmp; D[tmp]++; }
  int M; cin >> M;
  map<int, int> T; rep(i,M) { int tmp; cin >> tmp; T[tmp]++; }

  string result = "YES";
  for (auto x: T) if (x.second>D[x.first]) result = "NO";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 18944
import sys
input = sys.stdin.readline

def solve(A, i, n, m):
    if m == 0:
        return True
    if i >= n:
        return False
    return solve(A, i + 1, n, m) or solve(A, i + 1, n, m - A[i])

def main():
    n = int(input())
    A = list(map(int, input().split()))

    _ = int(input())
    m_list = list(map(int, input().split()))
    sum_list = sum(A)

    for m in m_list:
        if sum_list < m:
            print("no")
        elif solve(A, 0, n, m):
            print("yes")
        else:
            print("no")

if __name__ == '__main__':
    main()


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

int i,c;

int area(int d) {
    int sum = 0;
    for(i=d; i<=600-d;i += d){
        c = d * i * i;
        sum = sum + c;
        
    }
    return sum;
}

int main(void){
    int d;
    while(cin >> d) {
       cout << area(d) << endl;
    }
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    int a[110000];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int k;
        cin >> k;
        cout << lower_bound(a, a+n, k) - a << endl;
    }
    return 0;
}


Measured memory_bytes: 3492
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    vector<ll> v(n,0);
    for(int i = 0;i < n; i++){
        cin>>v[i];
    }
    ll ans=0;
    ll x=0;
    ll y=0;
    for(int i = 0;i < 60; i++){
        x=0;
        for(int j = 0;j < n; j++){
            if(v[j]>>i&1) x++;
        }
        //y=n-x;
        ll now = x*(n-x) % MOD;
        //cout<<i<<" "<<x<<" "<<y<<endl;
        //cout<<endl;

        rep(j,i) now=now*2%MOD;
        //cout<<"now:"<<now<<endl;
        ans+=now;
        ans%=MOD;
        
        //ans+=now*((1<<i)%MOD);
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
import math
n = int(input())
sqrt_n = math.ceil(math.sqrt(n))

result = 100
for i in range(1, sqrt_n + 1):
  if n % i == 0:
    digit = max(len(str(i)), len(str(n // i)))
    if digit < result:
      result = digit

print(result)

Measured memory_bytes: 3060
s = int(input())
if s == 1 or s == 2:
    print(4)
    exit(0)
cnt = 1
while(1):
    cnt += 1
    #print(s)
    if s == 1:
        break
    elif s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
print(cnt)

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL a;
    cin>>a;
    LL s=0;
    s=a+a*a+a*a*a;
    cout<<s;
}



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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n,m;
	cin >> n >> m;
	
	int ans = min(n , m/2);
	
	n -= ans;
	m -= 2*ans;
	ans += m/4;
		
	cout << ans;

}



Measured memory_bytes: 256
import qualified Control.Monad as Monad

main = loopPutCase 1

loopPutCase :: Int -> IO ()
loopPutCase i = do
                x <- getLine
                Monad.when (read x /= 0) $ do
                                putStrLn $ "Case " ++ show i ++ ": " ++ x
                                loopPutCase $ i + 1


Measured memory_bytes: 4008
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

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

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	int w, h, n;
	cin >> w >> h >> n;
	vector<vector<bool>> av(w, (vector<bool>(h, true)));
	REP(i, n) {
		int type, x, y;
		cin >> x >> y >> type;
		if (type == 1) {
			REP(i, x)REP(j, h)av[i][j] = false;
		}
		if (type == 2) {
			FOR(i, x, w)REP(j, h)av[i][j] = false;
		}
		if (type == 3) {
			REP(j, y)REP(i, w)av[i][j] = false;
		}
		if (type == 4) {
			FOR(j, y, h)REP(i, w)av[i][j] = false;
		}
	}
	ll ans = 0;
	REP(i, w)REP(j, h)if (av[i][j])ans++;
	cout << ans << endl;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<int MOD>
class ModInt {
public:
    ModInt() :value(0) {}
    ModInt(long long val) :value((int)(val<0 ? MOD + val % MOD : val % MOD)) { }

    ModInt& operator+=(ModInt that) {
        value = value + that.value;
        if (value >= MOD)value -= MOD;
        return *this;
    }
    ModInt& operator-=(ModInt that) {
        value -= that.value;
        if (value<0)value += MOD;
        return *this;
    }
    ModInt& operator*=(ModInt that) {
        value = (int)((long long)value * that.value % MOD);
        return *this;
    }
    ModInt &operator/=(ModInt that) {
        return *this *= that.inverse();
    }
    ModInt operator+(ModInt that) const {
        return ModInt(*this) += that;
    }
    ModInt operator-(ModInt that) const {
        return ModInt(*this) -= that;
    }
    ModInt operator*(ModInt that) const {
        return ModInt(*this) *= that;
    }
    ModInt operator/(ModInt that) const {
        return ModInt(*this) /= that;
    }
    ModInt pow(long long k) const {
        ModInt n = *this, res = 1;
        while (k) {
            if (k & 1)res *= n;
            n *= n;
            k >>= 1;
        }
        return res;
    }
    ModInt inverse() const {
        long long a = value, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
    int toi() const { return value; }

private:
    int value;
};
typedef ModInt<1000000007> mint;
ostream& operator<<(ostream& os, const mint& x) {
    os << x.toi();
    return os;
}

const int MA = 51;
// i段目、保留、奇妙さ
mint dp[MA][MA][MA*MA];

void solve() {
    int N, K;
    cin >> N >> K;

    dp[0][0][0] = 1;

    rep(i, N) rep(j, i + 1) rep(k, N*N + 1) {
        mint cur = dp[i][j][k];
        if (!cur.toi())continue;
        dp[i + 1][j + 1][k + (j + 1) * 2] += cur;
        dp[i + 1][j][k + j * 2] += cur * (j * 2 + 1);
        if (j > 0)dp[i + 1][j - 1][k + (j - 1) * 2] += cur * j * j;
    }

    cout << dp[N][0][K] << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 26624
n = int(input())
A, B = [], []
for _ in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

ans = 0
for j in range(n):
    i = n-j-1
    a = A[i] + ans
    b = B[i]
    if a%b == 0:
        continue
    ans += b-a%b
print(ans)


Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br =  new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int k = Integer.parseInt(input[1]);
        input = br.readLine().split(" ");
        int arr[] = new int[n];
        int dp[] = new int[n];
        int m = 0;
        for (String s: input){
            arr[m++] = Integer.parseInt(s);
        }

        for (int i = 1; i < k && i < n; i++) {
            int min = Integer.MAX_VALUE;
            for (int j = 0; j < i; j++) {
                int x = Math.abs(arr[i] - arr[j]) + dp[j];
                if (x < min) min = x;
            }
            dp[i] = min;
        }

        for (int i = k; i < n; i++) {
            int min = Integer.MAX_VALUE;
            for(int j = i - k; j < i; j++) {
                int x = Math.abs(arr[i] - arr[j]) + dp[j];
                if (x < min) min = x;
            }
            dp[i] = min;
        }
        System.out.println(dp[n- 1]);
    }
}


Measured memory_bytes: 35796
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		long n = nl();
		long a = nl();
		long b = nl();
		long dist = Math.abs(a - b);
		long result = 0;
		if(dist % 2 == 0) {
			result = dist / 2;
		} else {
			result = Math.min((a - 1 + b - 1 + 1) / 2, (n - a + n - b + 1) / 2);
		}
		System.out.println(result);
	}
	


	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21076
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        long p;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            p = in.nextLong();
            long sum = 0;
            Man[] men = new Man[n];
            for (int i = 0; i < n; i++) {
                int w = in.nextInt();
                int b = in.nextInt();
                men[i] = new Man(w, b);
                sum -= p * b;
            }
            Arrays.sort(men);

            for (int i = 0; i < n; i++) {
                sum += men[i].score;
                if (sum >= 0) {
                    out.println(i + 1);
                    return;
                }
            }

            throw new RuntimeException();
        }

        private class Man implements Comparable<Man> {
            long score;

            public Man(int w, int b) {
                score = (100 - p) * w + p * b;
            }


            public int compareTo(Man o) {
                return -1 * Long.compare(score, o.score);
            }

        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 47424
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
typedef vector<PII> VP;
typedef vector<vector<PII> > VVP;

int main(void) {
    while(true) {
        int m;
        int t;
        int p;
        int r;
        cin >> m >> t >> p >> r;
        if (m == 0 && t == 0 && p == 0 && r == 0) {
            break;
        }
        VVP table(t, VP(p, make_pair(0, 1)));
        for (int i = 0; i < r; i++) {
            int m2;
            int t2;
            int p2;
            int j;
            cin >> m2 >> t2 >> p2 >> j;
            t2--;
            p2--;
            if (j == 0) {
                table[t2][p2].first += m2;
                table[t2][p2].second = j;
            } else {
                table[t2][p2].first += 20;
            }
        }
        priority_queue<PIII> pq;
        for (int i = 0; i < t; i++) {
            int solve = 0;
            int total_time = 0;
            for (int j = 0; j < p; j++) {
                if (table[i][j].second == 0) {
                    solve++;
                    total_time += table[i][j].first;
                }
            }
            pq.push(make_pair(solve, make_pair(-total_time, i + 1)));
        }
        PIII ans = pq.top();
        int solve = ans.first;
        int time = ans.second.first;
        pq.pop();
        cout << ans.second.second;
        while(!pq.empty()) {
            PIII ans = pq.top();
            if (ans.first == solve && ans.second.first == time) {
                cout << "=" << ans.second.second;
            } else {
                solve = ans.first;
                time = ans.second.first;
                cout << "," << ans.second.second;
            }
            pq.pop();
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3096
s = gets.chomp
c1 = c2 = ''
s.each_char.with_index do |c, i|
    if i == 0
        c1 = c
    elsif i == 1
        c2 = c
        if c1 == c2
            puts "1 2"
            exit
        end
    else
        if c1 == c
            puts "#{i - 1} #{i + 1}"
            exit
        elsif c2 == c
            puts "#{i} #{i + 1}"
            exit
        else
            c1 = c2
            c2 = c
        end
    end
end
puts "-1 -1"

Measured memory_bytes: 2044
#include<stdio.h>
#include<iostream>
#include<string>
#include<memory>
#include<cmath>
#include<algorithm>
#include<vector>
int main(){
    int N,K;

    std::cin>>N>>K;
    double ans=0;
    double cal=0;
    
    for(int i=1;i<=N;i++){
        int ed=0;
        int score=i;
        double coin=1.0;
        while(score<K){
            score*=2;
            coin/=2;
        }
        cal+=coin;
    }
    ans=cal/N;

    //std::cout<<ans<<std::endl;
    printf("%.12f\n",ans);
    
    return 0;
}



Measured memory_bytes: 3768
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    int mi = INF;
    for (int i = 0; i + k <= n; i++) {
        int l = a[i], r = a[i + k - 1];
        if (r <= 0) mi = min(mi, abs(l));
        else if (l >= 0) mi = min(mi, abs(r));
        else mi = min(mi, abs(l) + abs(r) + min(abs(l), abs(r)));
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a, a + 3);
  cout<<a[0] + a[1]<<endl;
  return 0;
}


Measured memory_bytes: 896
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
def main():
    n, k = list(map(int, input().split()))
    a = (n-1)*(n-2)//2
    if k > a:
        print('-1')

    else:
        print(n-1+a-k)
        #頂点1を中心とするスターグラフ作成
        for i in range(2, 1+n):
            print(1, i)

        cnt = 0
        for i in range(2, n):
            for j in range(i+1, n+1):
                if cnt >= a-k:
                    return
                print(i, j)
                cnt += 1

main()



Measured memory_bytes: 9204
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
    ll N, M;

    cin >> N >> M;
    ll sum = 0;
    for (int i = 0; i < M; i++) {
        ll A;
        cin >> A;
        sum += A;
    }

    if (N - sum < 0) {
        cout << -1 << endl;
    } else {
        cout << N - sum << endl;
    }

    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll h, w, m, hin, win;
  cin >> h >> w >> m;
  vector<ll> ah(h + 1, 0);
  vector<ll> aw(w + 1, 0);
  set<ll> hash;
  for(int i = 0; i < m; ++i)
  {
    cin >> hin >> win;
    ah[hin]++;
    aw[win]++;
    hash.insert((hin << 32LL) + win);
  }
  ll ah_max_ind = distance(ah.begin(), max_element(ah.begin(), ah.end()));
  ll aw_max_ind = distance(aw.begin(), max_element(aw.begin(), aw.end()));

  vector<ll> ah_ind;
  vector<ll> aw_ind;
  for(int i = 0; i <= h; ++i)
  {
    if (ah[i] == ah[ah_max_ind])
    {
      ah_ind.emplace_back(i);
    }
  }
  for(int i = 0; i <= w; ++i)
  {
    if (aw[i] == aw[aw_max_ind])
    {
      aw_ind.emplace_back(i);
    }
  }

  ll ans = ah[ah_max_ind] + aw[aw_max_ind];
  for(const auto& ih : ah_ind) for(const auto& iw : aw_ind)
  {
    if (hash.find( (ih << 32LL) + iw ) == hash.end())
    {
      cout << ans;
      return;
    }
  }

  // if (hash.find( (ah_max_ind << 32LL) + aw_max_ind ) != hash.end()) ans--;
  cout << ans - 1;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 30276
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n, k;
	long long ans = 0;
	cin >> n >> k;
	vector<long long> a(n + 1), b(n + 1);
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		b[i] = b[i - 1] + max(a[i], 0LL);
		a[i] = a[i - 1] + a[i];
	}
	for(int i = k; i <= n; i++){
		long long t = max(a[i] - a[i - k], 0LL);
		ans = max(ans, b[i - k] + b[n] - b[i] + t);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  char b;
  scanf("%s", &b);

  if (b == 'A') printf("T");
  if (b == 'T') printf("A");
  if (b == 'C') printf("G");
  if (b == 'G') printf("C");
}

Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val ss = next().toList()
    val tt = next().toList()

    var count = 0
    for (i in 0..2) {
        if (ss[i] == tt[i]) count++
    }

    println(count)
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31872
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    vector<int> ord(n);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int s,int t){
        return a[s]<a[t];
    });
    rep(i,n)cout<<ord[i]+1<<" ";
    cout<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  cin >> N;
  cout << N / 3 << endl;

  return 0;
}

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

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

	int ans = 0;
	for (int i = 0; i <= 3; ++i) {
		if (S[i] == '+')
			++ans;
		else
			--ans;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
use std::io;


fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}

fn main() {

    let l = read_line();
    let l2 = l.replace("1","2");
    let l3 = l2.replace("9","1");
    let l4 = l3.replace("2","9");
    
    

    print!("{}", l4);


}   

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N,M;
	cin>>N>>M;
	vector<pair<long long,int> > x(N);
	for(int i=0;i<N;i++)
	{
		cin>>x[i].first;
		cin>>x[i].second;
	}
	sort(x.begin(),x.end());
	long long res = 0;
	int size = 0;
	for(int i=0;i<N;i++)
	{
		if(size+x[i].second>M)
		{
			int diff = M - size;
			res+=(x[i].first*diff);
			break;
		}
		size+=x[i].second;
		res+=(x[i].first*x[i].second);
	}
	cout<<res<<endl;
}

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (C >= A && C <= B)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == ',')
		{
			s[i] = ' ';
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
k = int(input())
d = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
if k <= 9:
    print(k)
else:
    cnt = 9
    while cnt < k:
        p = d.popleft()
        pstr = str(p)
        pstr_last = int(pstr[-1])
        
        if pstr_last - 1 >= 0:
            ad = int(pstr + str(pstr_last - 1))
            d.append(ad)
            cnt += 1
        if cnt == k:
            break
            
        ad = int(pstr + str(pstr_last))
        d.append(ad)
        cnt += 1
        if cnt == k:
            break
            
        if pstr_last + 1 <= 9:
            ad = int(pstr + str(pstr_last + 1))
            d.append(ad)
            cnt += 1
        if cnt == k:
            break
            
    print(ad)

Measured memory_bytes: 5852
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if ((g * 10 + b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}




Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    int cnt = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 0) {
            cnt++;
            a[i] = -a[i];
        }
        sum += a[i];
    }
    sort(a, a + n);
    if (cnt % 2) {
        cout << sum - 2 * a[0] << "\n";
    } else {
        cout << sum << "\n";
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[2010];
int main(){
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(x<=i&&y>=j){
				a[min(j-i,i-x+y-j+1)]++;
			}else{
				if(x>=i&&y<=j){
					a[j-i-(y-x)+1]++;
				}else{
					if(j>=x&&j<=y&&i<=x){
						a[min(j-i,y-j+x-i+1)]++;
					}else{
						if(j>=y&&i<=y&&i>=x){
							a[min(j-i,i-x+j-y+1)]++;
						}else{
							a[j-i]++;
						}	
					}
				}
			}
		}
	}
	for(int i=1;i<=n-1;i++){
		cout<<a[i]<<endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
vector<int> enum_div(int n)//nの約数を列挙
{
	vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int ans = 1;
    vector<int> v = enum_div(M);
    sort(v.begin(), v.end());
    rep(i, v.size()) {
        if ((ll)N * v[i] <= (ll)M) {
            ans = v[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256