akhauriyash/Code-Regression huggingface dataset:
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    os << "{";
    for(int i = 0; i < v.size(); i++)
        os << v[i] << (i+1<v.size()?", ":"");
    os << "}";
    return os;
}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

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

const int MAXEX = 100;
const int MAXP = 100;
const int MAXN = 100;
int memo[MAXP+1][MAXEX+1];
int D;
int N;
int A[MAXN];
int E[MAXN];
int R[MAXN];
const int INF = 1000000000;
int dfs(int rest, int ex) {
    if(rest <= 0) return 0;
    int& res = memo[rest][ex];
    if(res != -1) return res;
    res = INF;
    REP(i, N) if(ex >= R[i]) {
        int nrest = rest - A[i];
        int nex = min(MAXEX, ex+E[i]);
        res = min(res, 1+dfs(nrest,nex));
    }
    return res;
}
int main(){
    iostream_init();
    while(cin >> D >> N && (D > 0)) {
        REP(i, N) cin >> A[i] >> E[i] >> R[i];
        memset(memo, -1, sizeof(memo));
        auto ans = dfs(D, 0);
        if(ans < INF/10) {
            cout << ans << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

/* vim:set foldmethod=marker: */

Measured memory_bytes: 1252
#include <iostream>
#include <string>
#include <vector>

using namespace std;


vector<int> g[1000];
int N,M;
bool used[1000];
int out=0;

void find(int s){
  bool h=true;
  for(int i=0;i<N;i++){
    if(!used[i])h=false;
  }
  for(int i=0;i<g[s].size();i++){
    int to=g[s][i];
    if(used[to])continue;
    used[to]=true;
    find(to);
    used[to]=false;
  }
  if(h)out++;
}


int main(){

  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  used[0]=true;
  for(int i=1;i<N;i++){
    used[i]=false;
  }
  find(0);
  /*
  for(int i=0;i<N;i++){
    cout<<"No_"<<i<<"...";
    for(int j=0;j<g[i].size();j++){
      cout<<g[i][j]<<"...";
    }
    cout<<"turn"<<endl;
  }
  */
  cout<<out<<endl;
}


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

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 1e9
#define MOD 1e9+7
#define LINF (long long)4e18

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vvvvi = vector<vector<vector<vector<int>>>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;
using Pi = pair<int, int>;
using vPi = vector<Pi>;
using vvPi = vector<vector<Pi>>;
using vvvPi = vector<vector<vector<Pi>>>;
using vvvvPi = vector<vector<vector<vector<Pi>>>>;
using Pll = pair<ll, ll>;
using vPll = vector<Pll>;
using Pd = pair<double, double>;
using vPd = vector<Pd>;


int main(){
  string S;
  cin >> S;
  ll ans = 0;
  rep(mask,1<<(S.size()-1)){
    ll now = 0;
    ll a = S[0] - '0';
    rep(i,S.size()-1){
      if(mask & 1<<i){
        now += a;
        a = 0;
      }
      a = a * 10 + S[i+1] - '0';
    }
    
    now += a;
    ans += now;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(input){
    var args = input.split('\n');
    var N = parseInt(args[0].split(' ')[0], 10);
    var S = [];

    for(var i=1; i<=N; i++){
        S.push(args[i]);
    }

    console.log( S.sort().join('') );
}

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

ll gcd(ll a, ll b)
{
	if (a < b) swap(a, b);
	return (a%b ? gcd(a%b, b) : b);
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b)*b;
}

void extgcd(ll a, ll b, ll& x, ll& y)
{
	if (b != 0) { extgcd(b, a % b, y, x); y -= a / b * x; }
	else { x = 1; y = 0; }
}


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	vector<vi> a(n, vi(m));
	cin >> a;
	int ans = 300;
	REP(aaa, m)
	{
		vi cnt(m);
		REP(i, n)
		{
			REP(j, m)
			{
				if (a[i][j] >= 0)
				{
					cnt[a[i][j] - 1]++;
					break;
				}
			}
		}
		int mx = *max_element(ALL(cnt));
		chmin(ans, mx);
		int p = max_element(ALL(cnt)) - cnt.begin();
		REP(i, n)REP(j, m)
		{
			if (a[i][j] == p + 1) a[i][j] = -1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int a, b;
	int p[4] = { 4,6,9,11 };
	cin >> a >> b;
	if (a == b)cout << "Yes" << endl;
	else if (a == 2 || b == 2)cout << "No" << endl;
	else {
		for (int i = 0; i < 4; i++) {
			if (p[i] == a)a = 0;
			if (p[i] == b)b = 0;
		}
		if ((!a&&b)||(a&&!b))cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;

}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<atcoder/all>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
using namespace atcoder;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int main(void){
    int N,Q;
    cin >> N >> Q;
    dsu d(N);
    rep(i,Q){
        int t,u,v;
        cin >> t >> u >> v;
        if(t==0) d.merge(u,v);
        else cout << d.same(u,v) << endl;
    }
}

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

int main(){
  ll k, q;
  cin >> k >> q;
  vector<ll> ans(q);
  ll d[k];
  rep(i,k) scanf("%lld",&d[i]);
  rep(i,q) {
    ll n, x, m;
    scanf("%lld %lld %lld",&n,&x,&m);
    ll dm[k];
    ll s = 0;
    rep(j,k) {
      dm[j] = d[j] % m;
      if(dm[j] == 0) dm[j] = m;
      s += dm[j];
    }
    ll f = x;
    f += s * ((n-1) / k);
    rep(j,(n-1) % k) f += dm[j];
    ans[i] = n - 1 - (f / m - x / m);
  }
  for(auto t : ans) printf("%lld\n",t);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int n, A[2000 + 1];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main() {
    int q, m;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> m;
        if (solve(0, m)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

/**
 * 172 Beginner
 * A:Calc
 */
public class Main {
	public static void main(String[] args){
		// input
		java.util.Scanner inData = new Scanner(System.in);

		int a = inData.nextInt();

		System.out.println(a + a*a + a*a*a);

		inData.close();

	}

}


Measured memory_bytes: 27004
fn main(){
  loop {
    let nm: Vec<usize> = read_vec();
    let n = nm[0];
    let m = nm[1];

    if n == 0 && m == 0 { break; }
  
    let mut wv: Vec<Vec<isize>> = Vec::new();
  
    for _ in 0 .. n {
      wv.push(read_vec());
    }
  
    let mut pv: Vec<Vec<Vec<isize>>> = vec![vec![vec![0;m];m];4];
  
    for i in 0 .. m {
      let t: Vec<isize> = read_vec();
      for j in 0 .. m {
        pv[0][i][j] = t[j];
      }
    }
  
    for k in 1 .. 4 {
      for i in 0 .. m {
        for j in 0 .. m {
          pv[k][j][m-i-1] = pv[k-1][i][j];
        }
      }
    }

    let mut ofs: Vec<usize> = vec![0;4];

    for k in 0 .. 4 {
      for i in (0 .. m).rev() {
        if pv[k][0][i] >= 0 { ofs[k] = i; }
      }
    }

    let mut ans: (usize, usize) = (n, n);

    for y in 0 .. n - m + 1 {
      for x in 0 .. n - m + 1 {
        for r in 0 .. 4 {
          if equal(&wv, &pv, r, y, x) && ans > (y, x + ofs[r]) {
            ans = (y, x + ofs[r]);
          }
        }
      }
    }

    if ans == (n, n) {
      println!("NA");
    } else {
      println!("{} {}", ans.1 + 1, ans.0 + 1);
    }
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn equal(w: &Vec<Vec<isize>>, p: &Vec<Vec<Vec<isize>>>, r: usize, y: usize, x: usize) -> bool {
  let m = p[0][0].len();
  let mut ret = true;

  for i in 0 .. m {
    for j in 0 .. m {
      if p[r][i][j] >= 0 && w[y+i][x+j] != p[r][i][j] { ret = false; }
    }
  }
  ret
}



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

int tax(int x,int p){
    int ans;
    ans=(100+x)*p/100;
    return ans;
}

int solve(int x,int y,int s){
    int ma=0;
    for (int i=1;i<s;i++){
        for (int j=i;j<s;j++){
            if (tax(x,i)+tax(x,j)==s){
                ma=max(ma,tax(y,i)+tax(y,j));
            }
        }
    }
    return ma;
}

int main(){
    int x,y,s;
    while (cin>>x>>y>>s && x>0){
        cout<<solve(x,y,s)<<endl;
    }
}


Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const ll m = 26;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    ll N; cin>>N;
    ll minus = m;
    ll count = 0;
    ll now = N;
    string ans;
    //N;
    while(now != 0){
        ll amari =  (now - 1) % minus;
        ans += amari + 'a';
        now -= (amari + 1);
        now /= m;
    }
    reverse(ALL(ans));
    cout<< ans<<endl;
    /*ll now = N;
    ll minus = m;
    ll count = 0;
    while(true){
        if(N - minus < 0)break;
        minus *= m;
        count++;
    }
    vector<char> ans;
    minus /= m;
    ll n = N;
    REP(i,count-1){
        char c = N / minus + 'a'-1;
        N %= minus;
        //cout << N  << " " << c << endl;
        minus /= m;
        ans.push_back(c);
    }
    ans.push_back(N  + 'a');
    REP(i,ans.size()){
        cout<<ans[i];
    }
    cout << endl;*/
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define optimize ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long
#define ld long double
#define vi vector<int>
#define si set<int>
#define vc vector<char>
#define vb vector<bool>
#define vll vector<ll>
#define vd vector<double>
#define lb(v,x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define up(v,x) upper_bound(v.begin(), v.end(), x) - v.begin() - 1
#define pb push_back
#define lp(i,a,b) for(int i = a ; i <= b ; i ++)
#define rlp(i,a,b) for(int i = b ; i >= a ; i --)
#define a_sort(v) sort(v.begin(), v.end())
#define d_sort(v) sort(v.rbegin(), v.rend())
#define vin(v) for(auto &x : v) cin >> x
#define vout(v) for(auto x : v) cout << x << ' ' ; cout << endl
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pi 3.14159265358979323846264338327950
using namespace std ;
// #define debug

const int MOD = 1E9 + 7 ;
const int N = 1E5 ;

int main() {
    #ifdef debug
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif // debug
    optimize

    int n ; cin >> n ;
    cout << (n + n * n + n * n * n) << endl ;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i, ans=0, m=1e6; cin >> N; int P[N];
for(i=0; i<N; i++){ cin >> P[i]; if(P[i]<m){ ans++; m=P[i]; } }
cout << ans << "\n";
}

Measured memory_bytes: 1024
// @gaurav_512
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1000000007
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'
 
ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//
 
 
void solve()
{
	int H, W;
	cin >> H >> W;
	vector<vector<char>>A(H,vector<char>(W));
	fi(H)
		fj(W)
			cin>>A[i][j];
	vector<vi>dp(H,vi(W,0));
	if(A[0][0]=='#'||A[H-1][W-1]=='#')
	{
		cout<<"0\n";
		return;
	}
	
	for(int i=1; i<H; i++)
		if(A[i][0]=='#')
			break;
		else
			dp[i][0]=1;
	
	for(int i=1; i<W; i++)
		if(A[0][i]=='#')
			break;
		else
			dp[0][i]=1;
	
	for(int i=1; i<H; i++)
	{
		for(int j=1; j<W; j++)
		{
			if(A[i][j]=='#')
				continue;
			dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	
	cout<<dp[H-1][W-1]<<endl;
}
 
int main()
{
	fastio;
//    int T;
//    cin>>T;
//    while(T--)
        solve();
	return 0;
}

Measured memory_bytes: 8196
N,M = map(int, input().split())
S = input()
T = input()

def gcd(v1, v2):
    if v2 == 0:
        return v1
    return gcd(v2, v1%v2)

def lcm(v1,v2):
    return v1 * v2 // gcd(v1,v2)

my_gcd = gcd(N,M)
s_ = S[::N//my_gcd]
t_ = T[::M//my_gcd]
if s_ == t_:
    print(lcm(N,M))
else:
    print(-1)


Measured memory_bytes: 3316
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const int N=2e5+10;
ll a[N];
int main()
{
	ll n,m,i,j,k,s,t,sum,l,r;
      scanf("%lld",&n);
	{
		sum=0;
		for(i=1;i<=n;i++)
		scanf("%lld",&a[i]),sum+=a[i];
		l=0;
		m=1e15;
		for(i=1;i<n;i++)
		 {
		 	l+=a[i];
		 	r=sum-l;
		 	m=min(m,llabs(l-r));
		 }
		 printf("%lld\n",m);
	}
	return 0;
}

Measured memory_bytes: 1664
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    h, n = LI()
    ab = LIR(n)
    maxa = max(map(lambda x: x[0], ab))
    rangeh = h + maxa
    dp = [inf] * (rangeh + 1)
    dp[0] = 0
    for a,b in ab:
        for hi in range(rangeh - a):
            dp[hi + a] = min(dp[hi + a], dp[hi] + b)
        for hi in range(rangeh-1, -1, -1):
            dp[hi] = min(dp[hi], dp[hi + 1])
    print(dp[h])
    return


#main
if __name__ == '__main__':
    solve()


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

int gcd(int a, int b){
	if(a%b==0)	return b;
	return gcd(b,a%b);
}

int main(){
	ll n,m;	scanf("%lld %lld",&n,&m);
	char s[n+5],t[m+5];
	scanf("%s",s+1);
	scanf("%s",t+1);
	int hcf=gcd(n,m);
	bool flag=1;
	for(ll k=0;k<1000000;k++){
		if((1+k*(m/hcf) > m) || (1+k*(n/hcf) > n))	break;
		if(t[1+k*(m/hcf)] != s[1+k*(n/hcf)])	flag=0;
	}
	if(!flag)	printf("-1");
	else	printf("%lld",n*m/hcf);
}

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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
    string s;
    cin>>s;
    rep(i, 0, s.length())cout<<"x";
    cout<<endl;
}


int main()
{
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}

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

#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define FORR(i, a, b) for (long long i = (a); i >= (b); i--)
#define REPR(i, N) for (long long i = n; i >= 0; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(s) (s).begin(), (s).end()
#define pb(a) push_back(a)

#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

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

int main()
{
    ll N;
    cin >> N;
    cout << N * 800 - N / 15 * 200 << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

#endif


class AGC007B
{
public:
	AGC007B()
	{
		cin >> n;
		p.resize(n);
		rep(i, 0, n)
			cin >> p[i];
	}
	void Run(void)
	{
		vector<ll> a(n);
		vector<ll> b(n);

		rep(i, 0, n)
			a[i] = (i + 1) * n;
		copy(all(a), b.begin());
		sort(all(b), greater<ll>());
		rep(i, 0, n)
			b[p[i]-1] += i;

		for(const auto & e: a)
			cout << e << " ";
		cout << endl;
		for (const auto& e : b)
			cout << e << " ";
	}
private:
	ll n;
	vector<ll> p;
};


int main(void)
{
	AGC007B agc007b;
	agc007b.Run();

	return 0;
}


Measured memory_bytes: 1152
S = input()
Q = int(input())
reverse = 0
left = ""
right = ""
for _ in range(Q):
    q = input().split()
    if q[0]=="1":
        reverse += 1
        left, right = right, left
    if q[0]=="2" and q[1]=="1":
        if reverse%2==0: left = q[2]+left
        else: left = left+q[2]
    if q[0]=="2" and q[1]=="2":
        if reverse%2==0: right = right+q[2]
        else: right = q[2]+right
if reverse%2==1:
    left = left[::-1]
    right = right[::-1]
    S = S[::-1]
print(left+S+right)

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

  int N;
  cin>>N;
  map<string, int> m;
  m["fahigigiyfghgjhkjghfgdhgj"]=0;
  string s;
  rep(i,N){
    cin>>s;
    m[s]++;
  }
  priority_queue<pair<int,string>> pq;
  pair<int,string> q;
  for (auto p : m) {
    auto k = p.first;
    auto v = p.second;
    q=make_pair(v,k);
    pq.push(q);
  }
  q=pq.top();
  pq.pop();
  int w=pq.top().first;
  stack<string> v;
  v.push(q.second);
  while(q.first==w){
    v.push(pq.top().second);
    pq.pop();
    w=pq.top().first;
  }
  string g;
  while(v.empty()==0){
    cout<<v.top()<<endl;
    v.pop();
  }
}

Measured memory_bytes: 29936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const ll mod = 1e9 + 7;
ll fact[maxn];
ll inv[maxn];
ll fp(ll b, ll x) {
	ll ans = 1;
	while (x) {
		if (x & 1) {
			ans = ans * b%mod;
		}
		b = b * b%mod;
		x >>= 1;
	}
	return ans;
}
ll Inv(ll x) {
	return fp(x, mod - 2);
}
void init() {
	fact[0] = 1;
	for (int i = 1; i < maxn; i++) {
		fact[i] = fact[i - 1] * i %mod;
	}
	inv[maxn - 1] = fp(fact[maxn - 1], mod - 2);
	for (int i = maxn - 2; i >= 0; i--) {
		inv[i] = inv[i + 1] * (i + 1) % mod;
	}
}
ll C(ll n, ll m) {
	ll ans = 1;
	ans = fact[n] * inv[n - m] % mod*inv[m] % mod;
	return ans;
}
int main() {
	init();
	ll n, k;
	cin >> n >> k;
	if (k >= n) {
		k = n - 1;
	}
	ll ans = 0;
	for (ll i = 0; i <= k; i++) {
		ans = (ans + C(n, i)*C(n - 1, n - i - 1) % mod) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<60;
int MOD = 1e9 + 7;

struct fenwick_tree {
    typedef int T;
    T n;
    vector<T> bit;

    // 各要素の初期値は 0
    fenwick_tree(T num) : bit(num+1, 0) { n = num; }

    // a_i += w
    void add(T i, T w) {
        for (T x = i; x <= n; x += x & -x) {
            bit[x] += w;
        }
    }
    // [1, i] の和を計算.
    T sum(T i) {
        T ret = 0;
        for (T x = i; x > 0; x -= x & -x) {
            ret += bit[x];
        }
        return ret;
    }
    // [left+1, right] の和を計算.
    T sum(T left, T right) {
        return sum(right) - sum(left);
    }
};

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

    fenwick_tree f_tree1(N);

    ll cnt1 = 0, cnt2 = 0;

    rep(i,N){
        for(int j = i+1;j<N;j++){
            if(v[i] > v[j]) cnt1++;
        }
    }


    rep(i,N){
        rep(j,N){
            if(v[i] > v[j]) cnt2++;
        }
    }

    ll x = (K * (K-1)) / 2; x %= MOD;
    ll ans = cnt1 * K;
    ans %= MOD;
    ans += cnt2 * x;
    ans %= MOD;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

#define MAX_N 55
ll C[MAX_N][MAX_N];
void make() {
  rep(i, MAX_N) {
    C[i][1] = i;
    C[i][i] = 1;
    C[0][i] = 1;
    C[i][0] = 1;
  }
  REP(i, 1, MAX_N) rep(j, i) {
    if(i-1 < 0 || j-1 < 0) continue;
    C[i][j] = C[i-1][j] + C[i-1][j-1];
  }
}
ll comb(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return C[n][r];
}

int main() {
  make();
  int N, A, B;
  cin >> N >> A >> B;
  vector<ll> V(N);
  unordered_map<ll, int> mp;
  rep(i, N) {
    cin >> V[i];
    if(mp.count(V[i])) mp[V[i]]++;
    else mp[V[i]] = 1;
  }
  sort(all(V), greater<ll>());
  unordered_map<ll, int> mp2;
  ll M = 0;
  rep(i, A) {
    M+= V[i];
    if(mp2.count(V[i])) mp2[V[i]]++;
    else mp2[V[i]] = 1;
  }
  double ave = double(M) / A;
  cout << setprecision(10) << ave << endl;
  if(ave == V[A-1]) {
    ll ans = 0;
    REP(i, mp2[V[A-1]], min(mp[V[A-1]], B-A+mp2[V[A-1]])+1)
      ans += comb(mp[V[A-1]], i);
    cout << ans << endl;
  } else {
    cout << comb(mp[V[A-1]], mp2[V[A-1]]) << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a,b,c[15],d;
	cin>>a>>b>>c[0];
	for(int i=1;i<=10;i++)
	{
		c[i]=a*c[i-1]-b;
		cout<<c[i]<<endl;
	}
	return 0;
}

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

rb = s.count(')')
lb = s.count('(')

r=0
l=0
ll = 0
rr = 0
for c in s:
  if c =='(' :
    l += 1
  else:
    if l > 0:
      ll += 1
    l -= 1
    if l < 0:
      l = 0          
      
for c in s[::-1]:
  if c ==')' :
    r += 1
  else:
    if r > 0:
      rr += 1
    r -= 1
    if r < 0:
      r = 0
      
print('('*(rb - rr) + s + ')'*(lb - ll))

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  int a,b,H,W;

  while(1){
  scanf("%d %d",&H,&W);
    if( H == 0 && W == 0){ break; }
    for(a = 0 ; a < H ; a++){
      for(b = 0 ; b < W ; b++){
	if(a == 0 || a + 1 == H){
	  printf("#");
	}
	else if( b == 0 || b + 1 == W){
	  printf("#");
	} else {
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[99];
int main(){
	scanf("%s",s);
	ll n=strlen(s);
	ll ans=1e10,crr=0;
	rep(i,0,n){
		crr=crr%100*10+s[i]-48;
		ans=min(ans,llabs(753-crr));
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#define pb push_back
#define mk make_pair
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pair<int, int> >piii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<ll> vll;
const int inf = 1e9;
const ll INF = 1e18;
// const int M = 1e9 + 7;
//__int128
ll n, a, b, M;

typedef vector<vll> mat;

ll mul(ll x, ll y, ll mod) {
	ll ret = 0;
	while(y) {
		if(y & 1)
			ret = (ret + x) % mod;
		x = x * 2 % mod;
		y >>= 1;
	}
	return ret;
}

mat mul(mat &A, mat &B){
	mat C(A.size(), vll(B[0].size()));
	for(int i = 0; i < (int)A.size(); i++){
		for(int j = 0; j < (int)B.size(); j++){
			for(int k = 0; k < (int)B.size(); k++){
				C[i][j] = (C[i][j] + mul(A[i][k], B[k][j], M)) % M; 
			}
		}
	}
	return C;
}
mat pow(mat A, ll n){
	mat B((int)A.size(), vll((int)A.size()));
	for(int i = 0; i < (int)A.size(); i++){
		B[i][i] = 1;
	}
	while(n > 0){
		if(n & 1) {
			B = mul(B, A);
		}
		A = mul(A, A);
		n >>= 1;
	}
	return B;
}


void test(mat A){
	for(int i = 0; i < 3; ++i){
		for(int j = 0; j < 3; ++j){
			cout << A[i][j] << ' ';
		}
		cout << endl;
	}
}

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> a >> b >> M;
	ll base = 1;
	ll res = 0;
	ll c = 0, last = a - b, tot = 0;
	for(int i = 0; i < 19; ++i, base *= 10){
		if(base * 10 <= last) continue;
		ll step = (base * 10 - last - 1) / b;
		if(step + tot >= n){
			step = n - tot;
		}
		if(step == 0) continue;
		mat A(3, vll(3));
		A[0][1] = A[1][1] = A[1][2] = A[2][2] = 1;
		A[0][0] = base * 10;
		A = pow(A, step);
		res = (mul(res, A[0][0], M) + mul(last + b, A[0][1], M) + mul(b, A[0][2], M)) % M;
		// cout << res << endl << endl;
		last = last + step * b;
		tot += step;
		if(tot == n) break;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
def resolve():
  n, m = map(int, input().split())
  arr = []
  for i in range(n):
    a, b = map(int, input().split())
    arr.append([a, b])
  arr.sort()
  ans = 0
  for ab in arr:
    if ab[1] >= m:
      ans += m * ab[0]
      break
    else:
      ans += ab[0] * ab[1]
      m -= ab[1]
  print(ans)

  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 20072
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i,start,end) for(int i=start;i<end;i++)
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<n;)
    {
        char temp=s[i];
        count++;
        while((int)s[i]==(int)temp)
        {
            i++;
        }
    }
    //cout<<s<<endl;
    cout<<count<<endl;
}

Measured memory_bytes: 512
// kartikay26
#include <bits/stdc++.h>
using namespace std;
#define debug(x...) 
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
void print(){cout << endl;} void prints(){}
template<typename T=int> T get(){T x; cin >> x; return x;}
template<typename T> void get(T* x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T> void get(T& x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T, typename... A> void print(T x,A... r){cout << x << " ";print(r...);}
template<typename T, typename... A> void prints(T x,A... r){cout << x << " ";prints(r...);}
typedef long long int ll; typedef double db; typedef vector<ll> vi; typedef pair<ll, ll> pii;
#define int ll
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define clear(x) memset(x, 0, sizeof(x))
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int mod = 1e9+7;
const int N = 1e6+1;

int32_t main(){
	fast_io();

	int n = get();
	vi a(n); get(a,n);
 
	int dp[n+1][n+1][2];
	clear(dp);
 
	auto nmax = [=](int& x, int n) { x = max(x, n); };
 
	for (int len = 1; len <= n; len++){
		for(int l = 0; l <= n - len; l++){
			int r = n - (l+len);
			int p = len % 2;
			int x = dp[l+1][r][p] + a[l];
			int y = dp[l][r+1][p] + a[n-1-r];
			if (x > y){
				dp[l][r][p] = x;
				dp[l][r][p^1] = dp[l+1][r][p^1];
			} else {
				dp[l][r][p] = y;
				dp[l][r][p^1] = dp[l][r+1][p^1];
			}
		}
	}

	// for (int i = 0; i < n; ++i) {
	// 	for (int j = 0; j < n; ++j) {
	// 		prints(dp[j][i][0]);
	// 	}
	// 	print();
	// }
	// print();
	// for (int i = 0; i < n; ++i) {
	// 	for (int j = 0; j < n; ++j) {
	// 		prints(dp[j][i][1]);
	// 	}
	// 	print();
	// }
	// print();
 
	print((dp[0][0][0] - dp[0][0][1]) * int(pow(-1, n)));
	
	return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T>
T arg_min(V<T> v){
    auto itr = min_element(ALL(v));
    return distance(v.be(),itr);
}

int main(){
    int N,T,A;
    cin>>N>>T>>A;
    Vi H(N);
    REP(i,N) cin>>H[i];

    V<double> diff_AH(N);
    REP(i,N){
        diff_AH[i] = abs(A-(T-H[i]*0.006));
    }

    cout<<arg_min(diff_AH)+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1
#define MAX 100000
struct Node{
  int p;
  int l1;
  int r1;
};

struct Node T[MAX];
int depth[MAX],height[MAX];
void setDepth(int u, int d){
  if(u==NIL)return;
  depth[u]=d;
  setDepth(T[u].l1,d+1);
  setDepth(T[u].r1,d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].l1!=NIL)h1=setHeight(T[u].l1)+1;
  if(T[u].r1!=NIL)h2=setHeight(T[u].r1)+1;
  return height[u]=(h1>h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].p==NIL)return NIL;
  if(T[T[u].p].l1 != u && T[T[u].p].l1!=NIL)
    return T[T[u].p].l1;
  if(T[T[u].p].r1 != u && T[T[u].p].r1!=NIL)
     return T[T[u].p].r1;
   else return NIL;
}

 void print(int u){
   int k,m,deg=0; 
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  k=getSibling(u);
  printf("sibling = %d, ", k);
  if(T[u].l1!=NIL)deg++;
  if(T[u].r1!=NIL)deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", depth[u]);
  printf("height = %d, ", height[u]);

  if(T[u].p==NIL)printf("root\n");
  else if(T[u].l1==NIL && T[u].r1==NIL)printf("leaf\n");
  else printf("internal node\n");
}


int main(){
  int i,n,id,l2,r2,root=0;
  scanf("%d", &n);
  for(i=0;i<n;i++)T[i].p=NIL;
  
  for(i=0;i<n;i++){
    scanf("%d %d %d", &id, &l2, &r2);
    T[id].l1=l2;
    T[id].r1=r2;
    if(l2!=NIL)T[l2].p=id;
    if(r2!=NIL)T[r2].p=id;
  }
  
  for(i=0;i<n;i++){
    if(T[i].p==NIL)root=i;}
    setDepth(root,0);
    setHeight(root);
    for(i=0;i<n;i++){print(i);}
    
  return 0;
}



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

int main(){
  int s;
  cin >> s;
  vector<int> a(1000000);
  a.at(0)=s;
  int ans=0;
  for(int i=1; i<1000000; i++){
    if(a.at(i-1)%2==0) a.at(i)=a.at(i-1)/2;
    else a.at(i)=a.at(i-1)*3+1;
  }
  for(int m=1; m<1000000; m++){
    for(int n=0; n<m; n++){
      if(a.at(m)==a.at(n)){
        ans = m+1;
        break;
      }
    }
    if(ans>0) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4096
#include <stdio.h>

int main()
{   int W,a,b;
    scanf("%d %d %d",&W,&a,&b);
    if(b>a+W) {
       printf("%d\n",b-a-W);
	} else if(b<=a+W&&b>=a-W) {
	   printf("0\n");
	} else if (b<a-W) {
		printf("%d\n",a-b-W);
	} 
	  
	  return 0;
}  

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= m; j++) {
            int x = i * j + (n - i) * (m - j);
            if(x == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int s(int n) {
    return ceil((double)n / 10) * 10;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, z, k; cin >> x >> y >> z >> k;
    ll a[x]; rep(i, x) cin >> a[i];
    ll b[y]; rep(i, y) cin >> b[i];
    ll c[z]; rep(i, z) cin >> c[i];
    vector<ll> v;
    rep(i, x) rep(j, y) v.push_back(a[i] + b[j]);
    sort(v.begin(), v.end(), greater<ll>());
    //rep(i, v.size()) cout << v[i] << endl;
    sort(c, c + z, greater<ll>());
    vector<ll> vv;
    rep(i, min((int)v.size(), k)) rep(j, min(z, k)) vv.push_back(v[i] + c[j]);
    sort(vv.begin(), vv.end(), greater<ll>());
    rep(i, k) cout << vv[i] << endl;
}




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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int, int> cnt;
	rep(i,n){
		int a;
		cin >> a;
		cnt[a]++;
	}
	int ans = 0;
	for(auto p : cnt){
		if(p.second%2 == 1) ans++;
	}
	cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int x[n], y[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    y[i] = x[i];
  }

  sort(x, x + n);

  int med_l = x[n / 2 - 1];
  int med_r = x[n / 2];
  for (int i = 0; i < n; i++) {
    if (y[i] <= med_l) {
      cout << med_r;
    } else {
      cout << med_l;
    }
    if (i < n - 1) {
      cout << '\n';
    } else {
      cout << endl;
    }
  }
  return 0;
}


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

using namespace std;

int main(){
    long long A, B, C;
    scanf("%lld %lld %lld", &A, &B, &C);
    for(int i = 1; i <= 10; ++i){
        C = C * A - B;
        printf("%lld\n", C);
    }
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = []
for _ in range(m):
    ab.append(tuple(map(int, input().split())))

towers = [1] * n

for a, b in ab:
    a -= 1
    b -= 1
    a_hi = h[a]
    b_hi = h[b]
    if a_hi == b_hi:
        towers[a] = 0
        towers[b] = 0
    elif a_hi > b_hi:
        towers[b] = 0
    else:
        towers[a] = 0

print(len([i for i in towers if i == 1]))

Measured memory_bytes: 27928
#include<cstdio>

void insertionSort(int A[],int N){
    int value;
    int num;
    for(int i = 0; i < N; i++){
        value = A[i];
        num = i-1;
        while (num >= 0 && A[num] > value){
            A[num+1] = A[num];
            num--;
        }
        A[num+1] = value;
        for (int a = 0; a < N; a++){
            printf("%d", A[a]);
            if (a != N-1){
                printf(" ");
            }
            
        }
        printf("\n");
    }
}
int main(){
    int N;
    int A[1000];
    scanf("%d", &N);
    for (int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    insertionSort(A, N);
    return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  double p = 0;
  for (int i=1; i<=N; i++) {
    int score = i;
    int cointoss = 1;
    while (score < K) {
      score *= 2;
      cointoss *= 2;
    }
    p += (1/(double)N)*(1/(double)cointoss);
  }
  cout << fixed << setprecision(10);
  cout << p << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int A, B;
    scanf("%d%d", &A, &B);

    int sum = A + B;
    int dif = A - B;
    int mul = A * B;

    if(dif <= sum && mul <= sum){
        printf("%d\n", sum);
    }else if(sum <= dif && mul <= dif){
        printf("%d\n", dif);
    }else if(sum <= mul && dif <= mul){
        printf("%d\n", mul);
    }

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void){
    int N,K;
    cin >> N >> K;
    char *s;
    s = new char [N];
    for(int i=0;i<N;i++){
        cin >> s[i];
    }
    s[K-1] += 0x20;
    for(int i=0;i<N;i++){
        cout << s[i] ;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n; cin >> n;
    int r[n];
    rep(i,n) cin >> r[i];
    
    int flag = 1;
    int ok = 0;
    int cnt = 0;
    
    while(flag){
        flag = 0;
        for(int i=n-1 ; i>=ok+1 ; i--){
            if(r[i]<r[i-1]){
                swap(r[i],r[i-1]);
                cnt++;
                flag = 1;
            }
        }
        ok++;
    }
    
    rep(i,n) cout << r[i] << (i != n-1 ? ' ' :'\n');
    cout << cnt << endl;
}







Measured memory_bytes: 3052
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,M;
  cin>>N>>M;
  VI A(N-1+M),B(N-1+M);
  rep(i,N-1+M) cin>>A[i]>>B[i];
  VVI X(N,VI(0));
  VI I(N);
  rep(i,N-1+M){
    X[A[i]-1].pb(B[i]-1);
    I[B[i]-1]++;
  }
  int S=0;
  rep(i,N) if(I[i]==0) S=i;
  VI T(0);
  T.pb(S);
  queue<int> Q;
  Q.push(S);
  VI F(N);
  F[S]++;
  while(!Q.empty()){
    int now=Q.front();
    Q.pop();
    rep(i,X[now].size()){
      int nxt=X[now][i];
      if(!F[nxt]){
        I[nxt]--;
        if(!I[nxt]){
          Q.push(nxt);
          T.pb(nxt);
        }
      }
    }
  }
  VI Z(N);
  rep(i,N){
    int now=T[i];
    if(!Z[now]) Z[now]=1;
    rep(j,X[now].size()){
      int nxt=X[now][j];
      Z[nxt]=max(Z[nxt],Z[now]+1);
    }
  }
  VI ans(N);
  rep(i,N){
    rep(j,X[i].size()){
      int nxt=X[i][j];
      if(Z[i]+1==Z[nxt]) ans[nxt]=i+1;
    }
  }
  ans[S]=0;
  rep(i,N) cout<<ans[i]<<endl;
}


Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define pii pair<int,int>
using namespace std;
signed main(){
    fast;
    string s;
    cin>>s;
    for(auto it:s){
        if(it == '7'){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 3636
#include <unordered_set>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <functional>
#include <set>


void run() {
	std::string str;
	std::cin >> str;
	str[3] = '8';
	std::cout << str << std::endl;
}
int main() {
	run();
	return 0;
}


Measured memory_bytes: 256