akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

void solve(){
    char a;
    cin >> a;
    cout << (char)(a+1);
}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(long long i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l
int main() {
    string s;
    string sum = "keyence";
    cin >> s;
    int ss = s.size();
    int jg = ss - 7;
    bool ans=false;
    if (jg == 0) {
        cout << "YES" << endl;
        return 0;
    }
    else {
        for (int i = 0; i < ss - (jg - 1); i++) {
            string m = s.substr(0, i - 0);
            int cnt = ss - (i + jg);
            int cc = i + jg;
            string u = s.substr(cc,cnt);
            if (m + u == sum)ans = true;
        }
        if (ans==true)cout << "YES" << endl;
        else cout << "NO" << endl;

    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  char a;
  cin >> a;
  if(a == 'a'||a == 'i'||a == 'u'||a == 'e'||a == 'o'){
    cout << "vowel";
  }else{
    cout << "consonant";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200005],k,n;
int Min(int a,int b)
{
	if(a<b)return a;
	else return b;
}
int f(long long mid)//¶þ·ÖµØÕÒÓÐ¶àÉÙ¶ÔÑÏ¸ñÐ¡ÓÚx£¿
{
	long long b;long long ans=0;int pos1;int t;
	for(int i=1;i<n;++i)
	{
		b=a[i];
		if(b==0&&mid>0)ans+=n-i;
		else if(b>0)
		{
			if(mid>0)
			{
				if(mid%b==0)//Õû³ýÁË
				{
					pos1=lower_bound(a+1,a+1+n,mid/b)-a;
					if(pos1-i-1>0)ans+=pos1-i-1;
				}
				else//Ã»Õû³ý
				{
					pos1=lower_bound(a+1,a+1+n,mid/b+1)-a;
					if(pos1-i-1>0)ans+=pos1-i-1;
				}
			}
			else if(mid==0)
			{
				pos1=lower_bound(a+1,a+1+n,0)-a;
				if(pos1-i-1>0)ans+=pos1-i-1;
			}
			else if(mid<0)
			{
				pos1=lower_bound(a+1,a+1+n,mid/b)-a;
				if(pos1-i-1>0)ans+=pos1-i-1;
			}
		}
		else if(b<0)
		{
			if(mid>0)
			{
				if(mid%(-b)==0)//Õû³ýÁË
				{
					pos1=lower_bound(a+1,a+1+n,mid/b+1)-a;
					t=Min(n-i,n-pos1+1);
					if(t>0)ans+=t;
				}
				else//Ã»Õû³ý
				{
					pos1=lower_bound(a+1,a+1+n,mid/b)-a;
					t=Min(n-i,n-pos1+1);
					if(t>0)ans+=t;
				}
			}
			else if(mid==0)
			{
				pos1=lower_bound(a+1,a+1+n,1)-a;
				t=Min(n-i,n-pos1+1);
				if(t>0)ans+=t;
			}
			else if(mid<0)
			{
				if((-mid)%(-b)==0)//Õû³ýÁË
				{
					pos1=lower_bound(a+1,a+1+n,mid/b+1)-a;
					t=Min(n-i,n-pos1+1);
					if(t>0)ans+=t;
				}
				else//Ã»Õû³ý
				{
					pos1=lower_bound(a+1,a+1+n,mid/b+1)-a;
					t=Min(n-i,n-pos1+1);
					if(t>0)ans+=t;
				}
			}
		}
	}
	if(ans>k-1)return 1;
	if(ans==k-1)return 0;
	if(ans<k-1)return -1;
}
int main()
{
	long long t;scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;++i)scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	long long l=-1e18;long long r=1e18;long long mid;
	while(l<r)
	{
		mid=l+(r-l)/2;
		t=f(mid);
		if(t==0)break;
		else if(t<0)l=mid+1;
		else if(t>0)r=mid;
	}
	l=mid;
	while(l<r)
	{
		mid=l+(r-l)/2;
		if(f(mid))r=mid;
		else l=mid+1;
	}
	printf("%lld",l-1);
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
using namespace std;
int k;
long long ans;
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	cin >> k;
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			int d = gcd(a, b), e;
			for (int c = 1; c <= k; c++) {
				e = gcd(d, c);
				ans += e;
			}
		}
	}
	cout << ans;
	return 0;
}

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

namespace ABC144A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B;

            var word = Console.ReadLine().Split(' ');

            A = int.Parse(word[0]);
            B = int.Parse(word[1]);

            if ((1<=A && A<=9)&&(1<=B && B<=9))
                Console.WriteLine(A*B);
            else
                Console.WriteLine("-1");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;



std::vector<int> find_all(const std::string str, const std::string subStr) {
  std::vector<int> result;
 
  int subStrSize = subStr.size();
  int pos = str.find(subStr);
 
  while (pos != std::string::npos) {
    result.push_back(pos);
    pos = str.find(subStr, pos + subStrSize);
  }
 
  return result;
}





int main(){
  int n=0;
  int ans= 0;
  string str[10000];
  string search ="AB";

  scanf("%d\n",&n);
  for(int i=0;i<n;i++){
    cin >> str[i];
  }

  for(int i=0;i<n;i++){
    vector<int> findVec = find_all(str[i], search);
    ans += findVec.size();
  }

  int topbnum=0;
  int botanum=0;
  int Sflag = 1;
  int SSflag = 1;
  for(int i=0; i<n; i++){
    int flag = 0;
    if(str[i][0] == 'B'){
      topbnum++;
      flag++;
    }
    if(str[i][(str[i].size() -1)  ] == 'A'){
      botanum++;
      flag++;
    }

    if(flag==2){
      SSflag=0;
    }
    if(flag==1){
      Sflag = 0;
    }

  }


  int tmp=0;
  tmp = min(topbnum,botanum);
  //  tmp = min(tmp,n-1);
  ans += tmp;

  if(Sflag && (!SSflag) && (ans > 0)){ans--;}

  printf("%d",ans);

  return 0;
}


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

long long extended_gcd(long long a, long long b, long long &x, long long &y) {
    int d = a;
    if (b != 0) {
        d = extended_gcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

/*
    verified https://onlinejudge.u-aizu.ac.jp/problems/NTL_1_E
*/
int main() {
    long long a, b, x, y; cin >> a >> b;
    extended_gcd(a, b, x, y);
    cout << x << " " << y << endl;
}



Measured memory_bytes: 3096
#include<iostream>

using namespace std;

int main(){
  string s;
  cin>>s;
  if(s[0]!='A'){
    cout<<"WA"<<endl;
    return 0;
  }
  int c=0;
  for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C') c++;
    else if(s[i]<='Z'){
      cout<<"WA"<<endl;
      return 0;
    }
  }
  if(c!=1){
    cout<<"WA"<<endl;
    return 0;
  }
  if(s[1]<='Z' || s[s.size()-1]<='Z'){
    cout<<"WA"<<endl;
    return 0;
  }
  cout<<"AC"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(int argc, const char * argv[]) {
 
    int n,i;
    double x[100],y[100];
    double p1,p2,p22,p3,p33,p4,a;
     
    scanf("%d", &n);
     
    for(i=0; i<n; i++) scanf("%lf",&x[i]);
    for(i=0; i<n; i++) scanf("%lf",&y[i]);
     
    p1=0;
    for(i=0; i<n; i++) p1 += fabs(x[i]-y[i]);
     
    p2=0;
    for(i=0; i<n; i++) p2 += pow(fabs(x[i]-y[i]),2);
     
    p3=0;
    for(i=0; i<n; i++) p3 += pow(fabs(x[i]-y[i]),3);
     
    p4=0;
     
    for(i=0; i<n; i++) {
        a = fabs(x[i]-y[i]);
        if(a>p4) p4=a;
    }
     
     
    p22 = sqrt(p2);
    p33 = pow(p3, 1.0/3.0);
 
     
    printf("%lf\n%lf\n%lf\n%lf\n", p1, p22, p33 , p4);
    return 0;
}


Measured memory_bytes: 2072
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pque = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

struct str {
	int cost, mode, x, y;
	bool operator > (const str &x) const {
		return cost > x.cost;
	}
};

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	int sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;
	sx--; sy--; gx--; gy--;
	vector<string> a(h);
	cin >> a;
	vector dis(h, vector(w, vector(2, inf)));
	pque<str> que;
	que.push({ 0,0,sx,sy }); que.push({ 0,1,sx,sy });
	dis[sx][sy][0] = dis[sx][sy][1] = 0;
	while (!que.empty()) {
		str p = que.top(); que.pop();
		if (p.cost > dis[p.x][p.y][p.mode]) continue;
		rep(d, 4) {
			int nx = p.x + dx[d];
			int ny = p.y + dy[d];
			if (0 <= nx && nx < h && 0 <= ny && ny < w && a[nx][ny] == '.') {
				int nxt = p.cost + 1;
				if (p.mode == 0 && dx[d] == 0 || p.mode == 1 && dy[d] == 0) {
					nxt = p.cost;
					if (nxt % k == 0) nxt -= k;
					nxt -= p.cost % k;
					nxt += k + 1;
				}
				int m = 0;
				if (dy[d]) m = 1;
				if (dis[nx][ny][m] > nxt) {
					dis[nx][ny][m] = nxt;
					que.push({ nxt,m,nx,ny });
				}
			}
		}
	}
	int ans = min(dis[gx][gy][0], dis[gx][gy][1]);
	if (ans == inf) fail();
	ans = (ans + k - 1) / k;
	cout << ans << '\n';
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VL xs(N);
  cin >> xs;

  vector<bool> isp(2);
  VL sum(2);
  for(int i=0;i<N;++i){
	sum[i%2] += max(0ll, xs[i]);
	isp[i%2] = isp[i%2] || xs[i] >= 0;
  }
  if(!isp[0] && !isp[1]){
	int ix = 0;
	REP(i,N) if(xs[ix] < xs[i]) ix = i;

	cout << xs[ix] << endl
		 << N-1 << endl;
	REP(i,ix) cout << 1 << endl;
	int sz = N - ix;
	while(sz > 1) cout << sz-- << endl;
	
	return 0;
  }

  LL ans = max(sum[0], sum[1]);
  VI q;
  if(sum[0] < sum[1]){
	q.PB(0);
	xs.erase(begin(xs));
  }
  if(SZ(xs) % 2 == 0){
	q.PB(SZ(xs)-1);
	xs.pop_back();
  }

  VI np;
  for(int i=0;i<SZ(xs);i+=2){
	if(xs[i] < 0){
	  np.PB(i);
	}
  }
  for(int i=SZ(np)-1;i>=0;--i){
	if(np[i] == SZ(xs)-1){
	  q.PB(np[i]);
	  xs.pop_back();
	  q.PB(np[i]-1);
	  xs.pop_back();
	}
	else if(np[i] == 0){
	  q.PB(0);
	  q.PB(0);
	  xs.erase(begin(xs)+np[i], begin(xs)+np[i]+2);
	}
	else{
	  q.PB(np[i]);
	  xs.erase(begin(xs)+np[i], begin(xs)+np[i]+2);
	}
  }
  
  while(SZ(xs) > 1){
	q.PB(1);
	xs.pop_back();
	xs.pop_back();
  }

  cout << ans << endl
	   << SZ(q) << endl;
  for(auto x: q) cout << x+1 << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
count = 0
s = 'X' + s + 'X'
for i in range(1, n+1):
    #print(f's[i]: {s[i]} s[i-1]: {s[i-1]} s[i+1]:{s[i+1]}')
    if (s[i] == s[i-1] and s[i] == 'L') or \
        (s[i] == s[i+1] and s[i] == 'R'):
        count += 1
print(min(n-1, count + 2*k))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)
#define sz(a) (int)a.size()

vector<vector<int>> I;
int n, k;
const int MOD = 1e9 + 7;

vector<vector<int>> get() {
	vector<vector<int>> ans(n, vector<int> (n, 0));
	for(int i = 0; i < n; i++) {
		ans[i][i] = 1;
	}
	return ans;
}

vector<vector<int>> multiply(vector<vector<int>> A, vector<vector<int>> B) {
	vector<vector<int>> ans(n, vector<int> (n, 0));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			for(int k = 0; k < n; k++) {
				ans[i][j] = (ans[i][j] + (A[i][k] * B[k][j]) % MOD) % MOD;
			}
		}
	}
	return ans;
}

vector<vector<int>> power(vector<vector<int>> A, int k) {
	if(k == 0)
		return I;
	if(k % 2) {
		auto ans = power(A, (k - 1) / 2);
		ans = multiply(ans, ans);
		return multiply(ans, A);
	}
	else {
		auto ans = power(A, k / 2);
		return multiply(ans, ans);
	}
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> k;
	I = get();
	vector<vector<int>> g(n, vector<int> (n));
	for(auto &x : g) {
		for(int &v : x) {
			cin >> v;
		}
	}
	auto ans = power(g, k);
	int res = 0;
	for(auto x : ans) {
		for(int v : x) {
			res = (res + v) % MOD;
		}
	}
	cout << res;

	return 0;
}

Measured memory_bytes: 5004
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

int main()
{
    // input
    char S[4];
    scanf( "%s", S );

    // process

    // output
    if ( S[1] == 'B' ) {
        printf( "ARC\n" );
    } else {
        printf( "ABC\n" );
    }

    return 0;
}


Measured memory_bytes: 1660
A,B,M = map(int,input().split())
A_ = list(map(int,input().split()))
B_ = list(map(int,input().split()))
mini =min(A_) + min(B_)
for i in range(M):
    array = list(map(int,input().split()))
    m = A_[array[0]-1] + B_[array[1]-1] -array[2]
    if(mini > m):
        mini = m
print(mini)

Measured memory_bytes: 18612
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  vvi dp(n+1,vi(m+1,0));
  vector<vector<pii>> list(n+m);
  rep(i,n){
    rep(j,m){
      if(s[i] == t[j]){
        dp[i+1][j+1] = max(dp[i][j] + 1, max(dp[i][j+1], dp[i+1][j]));
        list.at(dp[i+1][j+1]).push_back(pii(i,j));
      }else{
        dp[i+1][j+1] =  max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }
  int maxi = dp[n][m];
  string ans;
  int x = 4000;
  int y = 4000;
  for(int i=maxi;i>=0;i--){
    for(pii P : list.at(i)){
      int nx = P.first;
      int ny = P.second;
      //cout << i << endl;
      //cout << nx << " " << ny << endl;
      if(nx < x && ny < y){
        //cout << "s" << nx << " " << ny << endl;
        ans.push_back(s[nx]);
        x = nx;
        y = ny;
        break;
      }
    }
  }
  reverse(all(ans));
  cout << ans << endl;
}

Measured memory_bytes: 123928
let string_to_list str =
  let rec loop i limit =
    if i = limit then []
    else (String.get str i) :: (loop (i + 1) limit)
  in
  loop 0 (String.length str)

let solve list =
  let rec aux list ans =
    begin match list with
    | [] -> ans
    | '0'::rest -> aux rest ('0'::ans)
    | '1'::rest -> aux rest ('1'::ans)
    | 'B'::rest -> begin match ans with
                  | [] -> aux rest ans
                  | x::ansrest -> aux rest ansrest
                  end
    | _ -> ans
    end
  in
  List.rev @@ aux list []

let () =
  let rec read () =
    try let ans = (Scanf.scanf "%s\n" (fun x -> solve (string_to_list x)) ) in
        Printf.printf "%s\n" (List.fold_left (fun x y -> x ^ (String.make 1 y)) "" ans)
    with End_of_file -> ()
  in
  read ()
;;


Measured memory_bytes: 384
def MAX(a, b):
    return b + (((((a + ms - b) & ms) >> (K - 1)) * tt) & (ms + a - b))
def MIN(a, b):
    return a - (((((a + ms - b) & ms) >> (K - 1)) * tt) & (ms + a - b))

def tolist(n):
    sx = bin(n)[2:] + "_"
    return [int(sx[-(i+1) * K - 1:-i * K - 1], 2) for i in range((len(sx)+K-2) // K)]

K = 52
N, W = map(int, input().split())

ms = int(("1" + "0" * (K - 1)) * (W + 1), 2)
tt = (1 << K - 1) - 1
one = int(("0" * (K - 1) + "1") * (W + 1), 2)

a = 8
b = 39

s = 1 << K - 2 + (W * K)
for _ in range(N):
    w, v = map(int, input().split())
    s = MAX(s, (s >> w * K) + one * v)

print(max(tolist(s)) - (1 << K - 2))

Measured memory_bytes: 22796
#include <bits/stdc++.h>
using namespace std;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
int i,j,k;
void solve(){
    ll x,k,d;	
    cin>>x>>k>>d;	
    if(x<0) x*=-1;
    if((x/d)>=k){
        cout<<(x - k*d)<<"\n";
    }else{
        k-=(x/d);
        if(k&1) cout<<(d-x%d)<<"\n";
        else cout<<x%d<<"\n";
    }

    return;
}

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


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

int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<int>> s(h, vector<int>(w));
  rep(i, h) {
    string tmp;
    cin >> tmp;
    rep(j, w) { s[i][j] = tmp.at(j); }
  }

  vector<vector<int>> cnt1(h, vector<int>(w));
  rep(i, h) {
    int c = 0;
    rep(j, w) {
      if (s[i][j] == '#') {
        cnt1[i][j] = 0;
        for (int k = j - c; k < j; k++) {
          cnt1[i][k] = c;
        }
        c = 0;
      } else {
        c++;
      }
    }
    for (int k = w - c; k < w; k++) {
      cnt1[i][k] = c;
    }
  }

  vector<vector<int>> cnt2(h, vector<int>(w));
  rep(j, w) {
    int c = 0;
    rep(i, h) {
      if (s[i][j] == '#') {
        cnt2[i][j] = 0;
        for (int k = i - c; k < i; k++) {
          cnt2[k][j] = c;
        }
        c = 0;
      } else {
        c++;
      }
    }
    for (int k = h - c; k < h; k++) {
      cnt2[k][j] = c;
    }
  }

  int ans = 0;
  rep(i, h) {
    rep(j, w) { ans = max(ans, max(0, cnt1[i][j] + cnt2[i][j] - 1)); }
  }

  cout << ans << endl;
  return 0;
}

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

int N,P;
int D[55];


bool check(int ind){
  for(int i=0;i<N;i++){
    if( i == ind ) continue;
    if( D[i] ) return false;
  }
  return true;
}

int main(){
  while( cin >> N >> P && (N||P) ) {
    memset(D,0,sizeof(D));
    int ind = 0;
    while( 1 ){
      if( P ){
	P--;
	D[ind]++;
	if( P == 0 ){
	  if( check(ind) ) break;
	}
      } else {
	P += D[ind];
	D[ind]=0;
      }
      ind++;
      ind%=N;
    }
    cout << ind << endl;
  }
}

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



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

  int X,A;
  cin >> X >> A;
  if (X < A) cout << 0 << endl;
  else cout << 10 << endl;

  return 0;
}

Measured memory_bytes: 764
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			String a = sc.nextLine();
			boolean b;
			int c = a.length();
			char e;
			for(int d = 0 ; d < c ; d++){
				e = a.charAt(d);
				b = Character.isUpperCase(e);
				if(d!=c-1){
					if(b==true){
						System.out.print(Character.toLowerCase(e));
					}else{
						System.out.print(Character.toUpperCase(e));
					}
				}else{
					if(b==true){
						System.out.println(Character.toLowerCase(e));
					}else{
						System.out.println(Character.toUpperCase(e));
					}
				}
			}
	}

}

Measured memory_bytes: 26832
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef struct P{
  int tx,ty,kx,ky,c;
};
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
int d[55][55];
bool used[55][55][55][55];
int X,Y;
P fa;
int main(void){
  int ans;
  while(1){

    scanf("%d %d",&X,&Y);
    if(!X && !Y) break;
    scanf("%d %d %d %d",&fa.tx,&fa.ty,&fa.kx,&fa.ky);
    fa.c=0;
    for(int i=1;i<=Y;i++){
      for(int j=1;j<=X;j++){
	scanf("%d",&d[j][i]);
      }
    }


    ans=-1;
    memset(used,0,sizeof(used));
    queue<P> que;
    que.push(fa);

    while(!que.empty()){
      P p=que.front();
      que.pop();
      used[p.tx][p.ty][p.kx][p.ky]=true;
      if(p.c>100)break;
      if(p.tx==p.kx && p.ty==p.ky){
	ans=p.c;
	break;
      }
      if((abs(p.tx-p.kx)+abs(p.ty-p.ky)+1)/2>100-p.c)break;
      for(int i=0;i<4;i++){
	int f=0;
	int x[2]={p.tx,p.kx};
	int y[2]={p.ty,p.ky};
	for(int j=0;j<2;j++){
	  int t=1;
	  if(j)t=-1;
	  if(0<x[j]+dx[i]*t && x[j]+dx[i]*t<=X && 0<y[j]+dy[i]*t && y[j]+dy[i]*t<=Y){
	    if(!d[x[j]+dx[i]*t][y[j]+dy[i]*t]){
	      x[j]+=dx[i]*t;
	      y[j]+=dy[i]*t;
	      f++;
	    }
	  }
	}
	if(!f){
	  continue;
	}
	if(used[x[0]][y[0]][x[1]][y[1]]){
	  continue;
	}
	P pu={x[0],y[0],x[1],y[1],p.c+1};
	used[x[0]][y[0]][x[1]][y[1]]=true;
	que.push(pu);
      }
    }

    if(ans==-1)puts("NA");
    else printf("%d\n",ans);

  }
}

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

static const int N = 1000;

int lcs(string X, string Y) {
    int c[N + 1][N + 1] = {};
    int m = X.length();
    int n = Y.length();

    X = ' ' + X;
    Y = ' ' + Y;
    
    int maxl = 0;
    for(int i = 1; i <= m; i++) {
        for(int j = 1; j <= n; j++) {
            if(X[i] == Y[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            }
            else {
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }

    return maxl;
}

int main() {
    int n;
    string X, Y;
    cin >> n;

    for(int i = 0; i < n; i++) {
        cin >> X >> Y;
        cout << lcs(X, Y) << endl;
    }
        
    return 0;
}



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

void shuffle( vector <int>& deck, int p, int c )
{
    vector <int> cut( c );
    copy( deck.begin() + p - 1, deck.begin() + p + c - 1, cut.begin() );
    deck.erase( deck.begin() + p - 1, deck.begin() + p + c - 1 );
    deck.insert( deck.begin(), cut.begin(), cut.end() );
}

int main( void )
{
    int n, r;
    while ( cin >> n >> r && n && r )
    {
        vector <int> deck( n );
        for ( int i = 0; i < n; i++ ) deck[i] = n - i;

        int p, c;
        for ( int i = 0; i < r; i++ )
        {
            cin >> p >> c;
            shuffle( deck, p, c );
        }

        cout << deck[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int,int> pa;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mp make_pair
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
int getgcd(int x,int y){return !x?y:getgcd(y%x,x);}
const int maxn=5005,maxm=205;
int n,m;
int st[maxm][maxn],top[maxn];
ll a[maxn],maxi[maxn<<2],tag[maxn<<2],b[maxn][maxm],ans=-1e18;
void M(int x,ll num){
	maxi[x]+=num;
	tag[x]+=num;
}
void PD(int x){
	M(ls,tag[x]);M(rs,tag[x]);
	tag[x]=0;
}
void U(int x){
	maxi[x]=max(maxi[ls],maxi[rs]);
}
void M(int x,int l,int r,int ll,int rr,long long num){
	if(l==ll&&r==rr){M(x,num);return;}
	PD(x);
	if(rr<=mid)M(ls,l,mid,ll,rr,num);
	else if(ll>mid)M(rs,mid+1,r,ll,rr,num);
	else M(ls,l,mid,ll,mid,num),M(rs,mid+1,r,mid+1,rr,num);
	U(x);
}
ll Q(int x,int l,int r,int ll,int rr){
	if(l==ll&&r==rr)return maxi[x];
	PD(x);
	if(rr<=mid)return Q(ls,l,mid,ll,rr);
	else if(ll>mid)return Q(rs,mid+1,r,ll,rr);
	else return max(Q(ls,l,mid,ll,mid),Q(rs,mid+1,r,mid+1,rr));
}
int main(){
	read(n);read(m);
	rep(i,2,n)read(a[i]);
	rep(i,2,n)a[i]+=a[i-1],M(1,1,n,i,i,a[i]);
	rep(j,1,m)st[j][top[j]=1]=0,b[0][j]=1e9+10;
	rep(i,1,n){
		rep(j,1,m){
			read(b[i][j]);
			M(1,1,n,i,i,b[i][j]);
			int R=i-1;
			while(b[st[j][top[j]]][j]<b[i][j]){
				M(1,1,n,st[j][top[j]-1]+1,R,b[i][j]-b[st[j][top[j]]][j]);
				R=st[j][--top[j]];
			}
			st[j][++top[j]]=i;
		}
		ans=max(ans,Q(1,1,n,1,i)-a[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12544
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split().Select(e => long.Parse(e)).ToArray();
        var a = s[0];
        var b = s[1];
        var c = s[2];
        var d = s[3];
        var ans = long.MinValue;
        foreach (var i in new long[] { a, b })
        {
            foreach (var j in new long[] { c, d })
            {
                ans = Math.Max(ans, i * j);
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 28156
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
  int num ;
  int a,b;
  int c,d;
  int data[5][4][11] = {0};
  cin >> num;
  for(int i = 0; i < num ; i++)
  {
    cin >> a >> b >> c >> d;
    data[a - 1][b - 1][c - 1] += d;
  }
  for(int i = 0; i < 4 ; i ++)
  {
    for(int j = 0; j < 3; j ++)
    {
      for(int k = 0 ;k < 10 ; k ++)
      {
        cout <<' '<< data[i][j][k] ;
      }
      cout << endl;
    }
    if(i < 3)cout << "####################"<< endl;
  }
  return 0;
}





Measured memory_bytes: 3068
N_K = list(map(int,input().split()))
A =  list(map(int,input().split()))
N = N_K[0]
K = N_K[1]

i = 0

while N > 0:
    if i == 0:
        N -= K
    else:
        N -= K - 1
    i +=1

print(i)





Measured memory_bytes: 14008
def main():
    N = int(input())

    ans1 = AC1(N)
    ans2 = AC2(N)
    assert ans1 == ans2

    print(ans1)


def AC1(N):
    for i in range(N, 999+1):
        if len(set(list(str(i)))) == 1:
            return i


def AC2(N):
    for i in range(1, 9+1):
        if N <= 111 * i:
            return 111 * i


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <utility>
#include <cfloat>
#include <cmath>
#include <cstdio>
using namespace std;
#define EPS 1e-8
 
struct P{
  double t;
  char v,p,pre;
  P(double T=0.0,int V=0,int pp=0,int PRE=0){
    t=T;v=V;p=pp;pre=PRE;
  };
  bool operator<(const P &p)const{
    return t>p.t;
  }
};
struct Path{
  char d,c;
  Path(int D=0,int C=0){ d=D;c=C;};
};
 
int main(){
  int n,m, s,g, x,y,d,c;
  Path path[30][30];

 
  while( cin>>n>>m && (n|m) ){
    cin >> s >> g;
    s--; g--;
    for( int i=0;i<n;i++ )
      for( int j=0;j<n;j++ ){
	path[i][j].d=-1.0; path[i][j].c=-1;
      }
 
    for( int i=0;i<m;i++ ){
      cin >> x >> y >> d >> c;
      x--;y--;
      path[x][y].d=d; path[x][y].c=c;
      path[y][x] = path[x][y];
    }
 
    double cost[30][35][30]; // place,velocity, pre
    int dv[3] = {1,0,-1};
    for( int i=0;i<n;i++ )
      for( int j=1;j<31;j++ )
	for( int k=0;k<n;k++ )
	  cost[i][j][k] = DBL_MAX;

    priority_queue<P> q;//    while( !q.empty() ) q.pop();
    for( int i=0;i<n;i++ ){
      if( path[s][i].c<0 ) continue;
      q.push( P(path[s][i].d,1,i,s) );//t ,v, np, pre
      cost[i][1][s] = path[s][i].d;
    }

    double ans = DBL_MAX; 
    while( !q.empty() ){
      P p = q.top(); q.pop();
      double t = p.t;
      int v=p.v, np=p.p, pre=p.pre;
      if( np==g && v==1 ){
	ans = t;
	break;
      }
 
      for( int i=0;i<n;i++ ){
	if( path[np][i].c<0 ) continue;// たどり着けないノード
	if( i==pre ) continue; // 前回のノード
	
	for( int j=0;j<3;j++ ){
	  int nv = v + dv[j];
	  if( nv==0 || nv>path[np][i].c )    continue;
	  double nCost = t + (double)path[np][i].d/nv;
	  if( nCost>cost[g][1][np] || fabs(nCost-cost[g][1][np])<EPS ) continue;
	  if( cost[i][nv][np] < nCost ) continue;
	  if( fabs(cost[i][nv][np]-nCost)<EPS ) continue;
	  cost[i][nv][np]=nCost;
	  
	  q.push( P(nCost,nv,i,np) );
	}
      }
      
    }
    if( fabs(ans-DBL_MAX)<EPS )
      cout << "unreachable" << endl;
    else
      printf("%.6lf\n",ans);
 
  }
  return 0;
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N = 0,M = 0;
  double c = 0.0;
  int re = 0;
  
  cin >> N >> M;
  
  vector<int> a(N,0);
  
  for(int i = 0;i < N;i++)
  {
    cin >> a[i];
    c += a[i];
  }
  
  for(int i = 0;i < N;i++)
  {
    if(a[i] < c / (4*M))
    {
      re++;
    }
  }
  if(N >= M + re)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
int MOD;
#ifndef HOME
#define cerr if(0)cerr
#endif
int add(int a,int b){
    return ((a % MOD) + (b % MOD)) % MOD;
}
int mul(int a,int b){
    return ((a % MOD) * (b % MOD)) % MOD;
}
int sub(int a,int b){
    return ((a % MOD) - (b % MOD) + MOD) % MOD;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    MOD = p;
    int ans = 0;
    if(p == 2 || p == 5){
        for(int i=0;i<n;i++){
            if((s[i] - '0') % p == 0){
                ans += i + 1;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    map<int,int>m;
    m[0]++;
    int cur = 0;
    int get = 1;
    for(int i=n-1;i>=0;i--){
        int x = mul(s[i] - '0',get);
        cur = add(cur,x);
        get = mul(get,10);
        ans += m[cur];
        m[cur]++;
    }
    cout<<ans<<endl;
    return 0;
    
}



Measured memory_bytes: 1044
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

func max(m map[string]int)int{
	var result int
	for _,val := range m {
		if result < val{
			result = val
		}
	}
	return result
}

func main(){
	var N,M int
	blueCards := make(map[string]int)
	redCards := make(map[string]int)

	input := bufio.NewScanner(os.Stdin)
	input.Scan()
	N,_ = strconv.Atoi(input.Text())

	for i := 0;i < N;i++ {
		input.Scan()
		blueCards[input.Text()]++
	}

	input.Scan()
	M,_ = strconv.Atoi(input.Text())
	for i:= 0;i < M;i++ {
		input.Scan()
		redCards[input.Text()]++
	}
	
	buffer := make(map[string]int)
	for blueWord,blueVal := range blueCards{
		buffer[blueWord] = blueVal
		for redWord,redVal := range redCards{
			if redWord == blueWord {
				buffer[blueWord] = blueVal - redVal
              	break
			}
		}
	}

	fmt.Print(max(buffer),"\n")
}



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

#define ll long long int

const int MOD = 1000000007;

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
int main() {

	ll A, B;
	char op;

	cin >> A >> op >> B;

	if (op == '+')cout << A + B << endl;
	else cout << A - B << endl;

	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
# include <map>
# include <bitset>
# include <queue>
# include <iomanip>
# include <string>

# define FILE
# define x first
# define y second
using namespace std;



int main()
{
    # ifdef FILEs
        freopen( "travel.in", "r", stdin );
        freopen( "travel.out", "w", stdout );
    # endif // FILE

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif // FILE
    ios_base::sync_with_stdio( false );
    int n; cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    char id = '$';
    for( auto c: s ){
        if ( c!= id ){
            cnt++;
            id = c;
        }
    }
    cout << cnt;








    # ifdef FILEs
        cout << endl << "------------------------";
        cout << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s. |";
        cout << endl << "------------------------";
    # endif
    return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int L;
    cin>>L;
    if(L<=7){
        cout <<L+1<<" "<<2*L-1<<"\n";
        rep(i,2,L+2) cout <<1<<" "<<i<<" "<<0<<"\n";
        rep(i,2,L+1)cout <<i<<" "<<i+1<<" "<<1<<"\n";
    }
    else{
        int res=1;
        int s=0;
        while(res<L){
            res*=2;
            s++;
        }
        if(res==L){
            cout <<s<<" "<<2*s<<"\n";
            rep(i,1,s){
                cout <<s-i<<" "<<s+1-i<<" "<<0<<"\n";
                cout <<s-i<<" "<<s+1-i<<" "<<(i<=2?pow(2,i-1):pow(2,i))<<"\n";
            }
            cout <<s-2<<" "<<s-1<<" "<<4<<"\n";
            cout <<s-2<<" "<<s-1<<" "<<6<<"\n";
        }
        else{
            vector<pair<P,int>> v;
            rer(i,20,1){
                if(L&1<<i){
                    if(i>=3){
                        v.pb(make_pair(P(s,i),L-(1<<i)));
                        L-=1<<i;
                    }
                    if(i<3){
                        while(L>=2){
                            v.pb(make_pair(P(s,i),L-(1<<(i-1))));
                            L-=1<<(i-1);
                        }
                    }
                }
            }
            if(L==1) v.pb(make_pair(P(s,1),0));
            cout <<s<<" "<<2*s-2+v.size()<<"\n";
            rep(i,1,s-1){
                cout <<s-i<<" "<<s+1-i<<" "<<0<<"\n";
                cout <<s-i<<" "<<s+1-i<<" "<<(i<=2?pow(2,i-1):pow(2,i))<<"\n";
            }
            cout <<s-2<<" "<<s-1<<" "<<4<<"\n";
            cout <<s-2<<" "<<s-1<<" "<<6<<"\n";
            rep(i,0,v.size()){
                cout <<s+1-v[i].fr.fr<<" "<<s+1-v[i].fr.sc<<" "<<v[i].sc<<"\n";
            }
        }
    }
}

Measured memory_bytes: 512
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int main(){
  int X = rd_int();
  if(X<30){
    wt_L("No");
    wt_L('\n');
  }
  else{
    wt_L("Yes");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// {
//   int X = rd_int();
//   wt(if[X<30, "No", "Yes"]);
// }


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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    ll max_h = 0;
    vector<ll> a(n,0);
    vector<ll> s(n,0);
    for(int i =0; i < n;i++){
        cin>>a[i];
        s[i] = a[i];
        max_h = max(max_h, a[i]);
    }
    sort(s.begin(), s.end());
    ll s_h = s[n-2];
    for(int i =0; i<n; i++){
        ll ans;
        ll t = a[i];
        if(t == max_h){
            ans = s_h;
        }else{
            ans = max_h;
        }
        cout<< ans <<endl;
    }
    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <stack>

using namespace std;

int main() {
    stack<int> st;
    int t;

    while(cin >> t) {
        if(t == 0) {
            cout << st.top() << endl;
            st.pop();
        } else {
            st.push(t);
        }    
    } 

    return 0;
}

Measured memory_bytes: 1200
n, k = map(int, input().split())
arr = list(map(int, input().split()))
visited = [-1] * n
visited[0] = 0

i = 0
ptr = 1
while True:
    ptr = arr[ptr-1]
    i += 1
    k -= 1
    if k == 0:
        break
    if visited[ptr-1] != -1:
        k %= i-visited[ptr-1]
    visited[ptr-1] = i
    if k == 0:
        break

print(ptr)


Measured memory_bytes: 100116
package main

import (
	"fmt"
)

func main() {
	var n, a, x, y, max int
	fmt.Scan(&n)

	statements := make([]statement, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a)

		s := make(statement)
		for j := 0; j < a; j++ {
			fmt.Scan(&x, &y)
			s[x-1] = y == 1
		}
		statements[i] = s
	}

	for bit := 0; bit < 1<<uint8(n); bit++ {
		var (
			checks    []int
			stt       = make(statement)
			conflicts bool
			cnt       int
		)

		for i := 0; i < n; i++ {
			if bit&(1<<uint8(i)) != 0 {
				checks = append(checks, i)
				stt[i] = true
			}
		}

		for len(checks) > 0 && !conflicts {
			cnt++
			i := checks[0]
			checks = checks[1:]

			for key, val := range statements[i] {
				v, ok := stt[key]
				if ok && v != val {
					conflicts = true
					break
				}

				if !ok {
					stt[key] = val
				}
				if !ok && val {
					checks = append(checks, key)
				}
			}
		}

		if !conflicts {
			max = Max(max, cnt)
		}
	}

	fmt.Println(max)
}

type statement map[int]bool

func Max(n ...int) int {
	max := n[0]
	for _, v := range n[1:] {
		if v > max {
			max = v
		}
	}
	return max
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
 
    long long x, k, d;
    cin >> x >> k >> d;

    x = abs(x);

    if (x / d >= k)
        cout << x - k * d << "\n";
    else if ((k - x / d) % 2 == 0)
        cout << x % d << "\n";
    else
        cout << d - x % d << "\n";
    
    return 0;
}


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

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


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

  using namespace std;

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

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

    sort(v.begin(), v.end(), greater<int>());

    int ans = 0;
    for (int i = 0; i < k; i++) {
      ans += v[i];
    }

    cout << ans << endl;

    return 0;
  }

Measured memory_bytes: 256
// The very basic /////////////////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ALL_H 1

// Debug it by D(x) ///////////////////////////////////////////////////////////
#define DEBUG 0
#if DEBUG
#define D(x) x
#else
#define D(x)
#endif

// Print elements of containers using << operator /////////////////////////////
// pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";}
// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  for (auto &elem : v) {
    s << elem;
    if (&elem != &v.back()) s << " ";
  }
  return s;
}
// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  for (auto &elem : vv) {
    s << elem;
    if (&elem != &vv.back()) s << endl;
  }
  return s;
}
// map
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
  s << "{" << endl;
  for (auto &elem: m) {
    s << " " << elem.first << " : " << elem.second << endl;
  }
  s << "}";
  return s;
}
//set
template<typename T> ostream& operator<<(ostream& s, const set<T>& m) {
  s << "{ ";
  for (auto &elem: m) {
    s << elem << " ";
  }
  s << "}";
  return s;
}

// Convenient macros //////////////////////////////////////////////////////////

// types
#define ll long long
#define ld long double
#define int ll
#define Pi pair<int, int>
#define Graph vector<vector<int>>
#define WeightGraph vector<vector<Pi>>

// other
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

// update max or min //////////////////////////////////////////////////////////

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; }

// gcd
int gcd(int a,int b){return b?gcd(b,a%b):a;}

// for grids
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

///////////////////////////////////////////////////////////////////////////////
//                             Start Coding Here                             //
///////////////////////////////////////////////////////////////////////////////

signed main() {
  string S; cin >> S;
  int N = 3;
  int P = 1 << 3;
  rep(i, P) {
    int ans = S[0] - '0';
    rep(j, N) {
      int mask = 1 << j;
      if (i & mask) {
        ans += S[j+1] -'0';
      } else {
        ans -= S[j+1] -'0';
      }
    }
    D(cout << ans << endl);
    D(cout << bitset<8>(i) << endl);
    if (ans == 7) {
      D(cout << "here" << endl);
      cout << S[0] << ((i & (1 << 0)) ? '+' : '-');
      cout << S[1] << ((i & (1 << 1)) ? '+' : '-');
      cout << S[2] << ((i & (1 << 2)) ? '+' : '-');
      cout << S[3] << "=7" << endl;
      return 0;
    }
  }
}




Measured memory_bytes: 768
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int X;
  cin >> X;
  vector<int> sosu;

  int i=1;
  bool flag=false;
  while(1){
    ++i;
    flag=true;
    for(int a: sosu){
      if(i%a==0){
	flag=false;
	break;
      }
    }
    if(flag==false) continue;
    sosu.push_back(i);
    if(X<=i) break;
  }

  cout << sosu.at(sosu.size()-1) << endl;
  
  return 0;
}


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

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

  if ((a + b) > (c + d)) {
    cout << "Left" << endl;
  }else if ((a + b) == (c + d)) {
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
S=list(map(int,input().split()))
ans = -1
minsa = 10**10
for point,s in enumerate(S):
  sa = (t-s*0.006 - a)**2
  if minsa > sa:
    minsa = sa
    ans = point

print(ans+1)

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

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; }

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

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

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

int main() {
    int N,R;
    cin>>N>>R;
    if(N>=10) cout<<R<<endl;
    else cout<<R+100*(10-N)<<endl;
}

Measured memory_bytes: 3532