akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 2* 1e5 + 5;
int a[nax], b[nax];
bool ok[nax][2][30];

vi pi(const string& s) {
	vi p(sz(s));
	rep(i,1,sz(s)) {
		int g = p[i-1];
		while (g && s[i] != s[g]) g = p[g-1];
		p[i] = g + (s[i] == s[g]);
	}
	return p;
}

vi match(const string& s, const string& pat) {
	// cout << imie(s) imie(pat);
	// cout << endl;
	vi p = pi(pat + '\0' + s), res;
	rep(i,sz(p)-sz(s),sz(p))
		if (p[i] == sz(pat)) res.push_back(i - 2 * sz(pat));
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	rep(i,0,n) cin >> a[i];
	rep(i,0,n) cin >> b[i];
	// debug() << "wczytalem";
	// cout << "wczytalem\n";
	ford(bit, 30, 0) {
		rep(zap,0,2) {
			string pattern;
			pattern.resize(n);
			string haystack;
			haystack.resize(2*n - 1);
			rep(i,0,n) {
				int pom;
				if (a[i]&(1 << bit)) {
					pom = 1;
				} else {
					pom = 0;
				}
				pattern[i] = (pom ^ zap) + '0';
			}
			rep(i,0,2*n-1) {
				int pom = (b[i%n] &(1<<bit)) > 0;
				haystack[i] = (pom + '0');
			}
			vi res = match(haystack, pattern);
			for (auto idx : res) {
				ok[idx][zap][bit] = true;
			}
		}
	}
	ford(k,n+1,1) {
		bool isOk = true;
		int x = 0;
		rep(bit, 0, 30) {
			if (!ok[k%n][0][bit] && !ok[k%n][1][bit]) {
				isOk = false;
				break;
			}
			if (ok[k%n][1][bit]) {
				x |= (1 << bit);
			}
		}
		if (isOk) {
			cout << (n - k) % n << ' ' << x << endl;
		}
	}
}

Measured memory_bytes: 20704
#include<iostream>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  int A[50],B[50],C[50],D[50];
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
  }
  for(int i=0;i<M;i++){
    cin>>C[i]>>D[i];
  }
  for(int i=0;i<N;i++){
    int ans=400000001;
    int num=0;
    for(int j=0;j<M;j++){
      int dis=abs(A[i]-C[j])+abs(B[i]-D[j]);
      if(dis<ans){
        ans=dis;
        num=j;
      }
    }
    cout<<num+1<<endl;
  }
}
      
    

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

using namespace std; 

int main() { 

  int n;
  int cnt=0;
  int cnt_max=0;
  cin >> n;
  int d[n][2];
  for (int i = 0; i < n; ++i) {
  cin >> d[i][0] >> d[i][1];
    if (d[i][0] == d[i][1]) cnt++;
    else cnt =0;
    if (cnt > cnt_max) cnt_max = cnt;
    
  }
  if (cnt_max >= 3) cout << "Yes" << endl;
  else cout << "No" << endl;
} 

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int length = sc.nextInt();
		int beforeHeight =sc.nextInt();
		boolean canAble = true;

		for(int i = 0;i < length - 1 ;i++) {
			int height = sc.nextInt();

			if(height > beforeHeight) {
				height--;
			}

			if(height < beforeHeight) {
				canAble = false;
				break;
			}

			beforeHeight = height;
		}

		System.out.println(canAble ? "Yes" : "No");

	}
}


Measured memory_bytes: 47212
N=int(input())
T=input()
S=[0 for _ in range(N)]
for i in range(N):
  if T[i]=='G':
    S[i]=1
  elif T[i]=='B':
    S[i]=2
    
ls=[(0,0,0) for _ in range(N)]
for i in range(N):
  if S[i]==0:
    ls[i]=(ls[i-1][0]+1,ls[i-1][1],ls[i-1][2])
  elif S[i]==1:
    ls[i]=(ls[i-1][0],ls[i-1][1]+1,ls[i-1][2])
  else:
    ls[i]=(ls[i-1][0],ls[i-1][1],ls[i-1][2]+1)


def count(x):
  val=0
  y=(x+1)%3
  z=(x+2)%3
  for i in range(N):
    if S[i]==x:
      for j in range(i+1,N):
        if S[j]==y:
          val+=ls[N-1][z]-ls[j][z]
          if 2*j-i<N and S[2*j-i]==z:
            val-=1
        if S[j]==z:
          val+=ls[N-1][y]-ls[j][y]
          if 2*j-i<N and S[2*j-i]==y:
            val-=1
  return val

print(count(0)+count(1)+count(2))
            
          
          

Measured memory_bytes: 9352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0002
{
	class Program
	{
		static void Main(string[] args)
		{
			string	s	= "";
			while( true ) {
				var	c	= Console.Read();
				if( c == -1 ) {
					break;
				}
				s	+= (char)c;
			}
			
			var	ss	= s.Split( new char[ 0 ], StringSplitOptions.RemoveEmptyEntries );
			var	num	= Array.ConvertAll( ss, sss => int.Parse( sss ) );
			for( int i = 0; i < num.Length; i += 2 ) {
				int	sum	= num[ i ] + num[ i + 1 ];
				var	str	= sum.ToString();
				Console.WriteLine( str.Length );
			}
		}
	}
}

Measured memory_bytes: 5668
#include <iostream>

int gcd(int a, int b)
{
    return (b == 0) ? a : gcd(b, a % b);
}
int a[100001];
int l[100001];
int r[100001];

int main(int argc, char **argv)
{
    int n;

    std::cin >> n;
    for (int i = 0; i < n; i++) std::cin >> a[i];
    l[0] = 0;
    for (int i = 1; i < n; i++) l[i] = gcd(l[i - 1], a[i - 1]);
    r[n - 1] = 0;
    for (int i = n - 2; i >= 0; i--) r[i] = gcd(r[i + 1], a[i + 1]);
    int m = 0;
    for (int i = 0; i < n; i++) m = std::max(m, gcd(r[i], l[i]));

    std::cout << m << std::endl;

    return 0;
}

Measured memory_bytes: 1408
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
void solve()
{
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll ans=-1e18;
   ans=max(ans,a*c);
   ans=max(ans,b*d);
   ans=max(ans,a*d);
   ans=max(ans,b*c);
   cout<<ans;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
parseInt(x) = parse(Int, x)

function main()
  N = readline() |> parseInt
  # A = readdlm(STDIN, Int)
  A = map(parseInt, split(readline()))

  a_gcd = Array{Int}(N)
  a_gcd[1] = A[1]
  for i in 2:N
    a_gcd[i] = gcd(a_gcd[i - 1], A[i])
  end

  a_gcd_r = Array{Int}(N)
  a_gcd_r[end] = A[end]
  for i in N-1:-1:1
    a_gcd_r[i] = gcd(a_gcd_r[i + 1], A[i])
  end

  a = map(1:N) do i
    if i == 1
      a_gcd_r[2]
    elseif i == N
      a_gcd[end - 1]
    else
      gcd(a_gcd[i - 1], a_gcd_r[i + 1])
    end
  end
  # println(a)
  result = maximum(a)

  println(result)
end

main()

Measured memory_bytes: 141580
#include <stdio.h>

int main(int argc, char **argv)
{
	int n, **a, i, j, t=0;
	
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		
		a = (int **)calloc(n, sizeof(int));
		for(i = 0; i < n; i++){
			a[i] = (int *)calloc(n, sizeof(int));
		}
		
		i = n/2+1;
		j = n/2;
		t = 1;
		while(t <= n*n){
			if(a[i][j] != 0){
				i++;
				j--;
			} else {
				a[i++][j++] = t++;
			}
			if(n == i){
				i = 0;
			}
			if(n == j){
				j = 0;
			} else if(j < 0){
				j = n-1;
			}
		}
		
		for(i = 0; i < n; i++){
			printf("%4d", a[i][0]);
			for(j = 1; j < n; j++){
				printf("%4d", a[i][j]);
			}
			printf("\n");
		}
		
		for(i = 0; i < n; i++){
			free(a[i]);
		}
		
		free(a);
	}
	
	return 0;
}

Measured memory_bytes: 0
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n;
  string s;
  cin >> n >> s;
  rep(i, 4) {
    string t;
    t += string(i & 1 ? "W" : "S") + string(i >> 1 & 1 ? "W" : "S");
    rep(j, n - 2) {
      if (t[j + 1] == 'S') t += (s[j + 1] == 'o') ? t[j] : 'S' + 'W' - t[j];
      if (t[j + 1] == 'W') t += (s[j + 1] == 'o') ? 'S' + 'W' - t[j] : t[j];
    }
    bool valid = true;
    valid &= ((s[0] == 'o') == (t[0] == 'S')) == (t[1] == t[n - 1]);
    valid &= ((s[n - 1] == 'o') == (t[n - 1] == 'S')) == (t[0] == t[n - 2]);
    if (valid) {
      cout << t << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 776
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

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

#define uint unsigned int
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
using namespace std;
int n ;
ld a , t , h;
pair < ld , int > ans = mp(1e9 , 0);
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	
	
	cin >> n >> t >> a;
	for(int i = 1 ; i <= n ; i++){
		cin >> h;
		ans = min(ans , {abs(a - (t - h * 0.006)) , i});
	}
	cout << ans.second;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)

#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%lld\n",a)

#define stll(a) stoll(a,nullptr,10)
#define all(a) a.begin(),a.end()
#define PII pair<ll,ll>
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define EL printf("\n")
#define ff first
#define ss second
#define rev(a) reverse(all(a))


#define mem(ar,val) memset(ar,val,sizeof(ar))
#define ssort(ar) sort(ar.begin(),ar.end())
#define csort(ar,comp) sort(ar.begin(),ar.end(),comp)

#define bug1(a) cerr<<"test "<<a<<endl;
#define bug2(a,b) cerr<<"test "<<a<<" "<<b<<endl;
#define bug3(a,b,c) cerr<<"test "<<a<<" "<<b<<" "<<c<<endl;
#define bug4(a,b,c,d) cerr<<"test "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define fout freopen("output.txt","w",stdout)
#define fin  freopen("input.txt","r",stdin)

/// unordered_map<int,int>mp;
/// mp.reserve(1024);
/// mp.max_load_factor(0.25);

/// pbds
/// *find_by_order(k) - return k th largest element.. 0 based
/// order_of_key(k) - number of items strictly smaller than k

///  priority_queue <ll, vector<ll>, greater<ll> >

/*
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
*/

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


ll ar[100005];
int main()
{
    ll n,x,mx;
    cin>>n>>x;
    for(int i=1;i<=n;i++)
        cin>>ar[i];

    ll ans =0;
    for(int i=1;i<n;i++)
    {
        mx = ar[i]+ar[i+1];
        if(mx<=x)continue;
        ans+=min(ar[i+1],mx-x);
        ar[i+1]-=min(ar[i+1],mx-x);;
        mx=ar[i]+ar[i+1];
        if(mx<=x)continue;
        ans+=min(ar[i],mx-x);
        ar[i]-=min(ar[i],mx-x);
    }
    if(ar[n]>x)
        ans+=ar[n]-x;
    cout<<ans<<endl;
}













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

int main(){
	int n,m;
	while(cin>>n>>m){
		if(n==0)break;
		int t[n];
		int h[m];
		int tsum=0,hsum=0;
		for(int i=0;i<n;i++){
			cin>>t[i];
			tsum += t[i];
		}
		for(int i=0;i<m;i++){
			cin>>h[i];
			hsum += h[i];
		}
		int ans1,ans2;
		bool flag = false , fff = true;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				int tt = tsum-t[i]+h[j];
				int hh=hsum-h[j]+t[i];
				if(tt==hh){
					ans1 = t[i];ans2 = h[j];flag = true;break;
				}
			}
			if(flag)break;
			if(!flag&&i==n-1){
				fff=false;
			}
		}
		if(fff)cout<<ans1<<" "<<ans2<<endl;
		else cout<<-1<<endl;
	}
}


Measured memory_bytes: 3020
#include<stdio.h>
#define MAX 100000
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}node;

node T[MAX];
int n,D[MAX],H[MAX];

void Depth(int,int);
int Height(int);
int getSibling(int);
void print(int);


int main(){
  int v,l,r,i,root=0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }

  for(i=0;i<n;i++){
    if(T[i].parent==NIL) root=i;
  }

  Depth(root,0);
  Height(root);

  for(i=0;i<n;i++) print(i);
  

  return 0;
}

void Depth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  Depth(T[u].left,d+1);
  Depth(T[u].right,d+1);
}

int Height(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL){
    h1=Height(T[u].left)+1;
  }
  if(T[u].right!=NIL){
    h2=Height(T[u].right)+1;
  }
  return H[u]=(h1>h2 ? h1:h2);
}

int getSibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left !=u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg =0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent==NIL){
    printf("root\n");
  }else if(T[u].left==NIL && T[u].right == NIL){
    printf("leaf\n");
  }else {
    printf("internal node\n");
  }
}



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

int n,m,q;
vector<int> a,b,c,d;

int score(vector<int> &J){
  int res = 0;
  for(int i = 0; i < q; i++){
    if(J[b[i]]-J[a[i]] == c[i]) res += d[i];
  }
  return res;
}

int dfs(vector<int> &J){
  if(J.size() == n){
    return score(J);
  }
  int res = 0;
  int prev_last = (J.empty() ? 1:J.back());
  for(int v = prev_last; v <= m; v++){
    J.push_back(v);
    res = max(res,dfs(J));
    J.pop_back();
  }
  return res;
}

int main(void){
  cin >> n >> m >> q;
  a.resize(q); b.resize(q); c.resize(q); d.resize(q);
  rep(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  vector<int> J;
  cout << dfs(J) << endl;
  return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string s;
int x, y, memo[8001][16001];
std::vector<int>dx, dy;

int dp1(int k, int px)
{
	if (k == dx.size()) return (px == x ? 0 : 1);
	if (memo[k][px + 8000] != -1) return memo[k][px];
	auto res1 = dp1(k + 1, px + dx[k]);
	auto res2 = dp1(k + 1, px - dx[k]);
	return memo[k][px + 8000] = ((res1 == 0 || res2 == 0) ? 0 : 1);
}
int dp2(int k, int py)
{
	if (k == dy.size()) return (py == y ? 0 : 1);
	if (memo[k][py + 8000] != -1) return memo[k][py];
	auto res1 = dp2(k + 1, py + dy[k]);
	auto res2 = dp2(k + 1, py - dy[k]);
	return memo[k][py + 8000] = ((res1 == 0 || res2 == 0) ? 0 : 1);
}

int main()
{
	in >> s >> x >> y;
	int start = 0, cou = 0;
	rep(i, s.length())
	{
		if (s[i] == 'T')
		{
			if (cou % 2 == 0) dx.push_back(i - start);
			else dy.push_back(i - start);
			start = i + 1;
			++cou;
		}
		else if (i == s.length() - 1)
		{
			if (cou % 2 == 0) dx.push_back(i - start + 1);
			else dy.push_back(i - start + 1);
			break;
		}
	}
	memset(memo, -1, sizeof(memo));
	auto ans1 = dp1(1, dx[0]);
	memset(memo, -1, sizeof(memo));
	auto ans2 = dp2(0, 0);
	out << ((ans1 == 0 && ans2 == 0) ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 500608
h,n=map(int,input().split())

damage=[]
cost=[]
for i in range(n):
  a,b=map(int,input().split())
  damage.append(a)
  cost.append(b)

  
dp=[[float('inf')]*(h+1) for i in range(n+1)]
dp[0][0]=0

for i in range(n):
  for j in range(h+1):
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])
    dp[i+1][min(j+damage[i],h)]=min(dp[i+1][min(j+damage[i],h)],dp[i+1][j]+cost[i])


print(dp[-1][-1])

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

int N,K;
int M[105][105];

int main(){
    cin>>N;
    cout<<(N*(N-1))/2-N/2<<"\n";
    for(int i=0;i<N;i++)
        for(int j=i+1;j<N;j++)
            if(i!=N-j-1-(N%2))
                cout<<i+1<<" "<<j+1<<"\n";
}


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

string s;
long long n[35], m, sol;


void solve(){

    m = s.size();

    sol = m*(m-1)/2 + 1;

    for(int i=0;i<m;i++)
        n[s[i]-'a'] += 1;

    for(int i=0;i<26;i++)
        sol -= n[i]*(n[i]-1)/2;

    cout << sol;
}

int main(){

    cin >> s;
    solve();

    return 0;
}


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

int main() {
    int t,n;
    cin>>t;
    // vector<int>a;
    string ans="";
    while(t--) {
        ans = ans+"ACL";
        // cin>>n;
        // for(int i=0;i<n;i++) {
        //     a.push_back(0);
        //     cin>>a[i];
        // }
        // c
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
//InTheNameOfGod
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
const int maxn = 1e5+5;
ll n,a[maxn],l,r,md,f,s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    rep(i,0,n)cin>>a[i];
    f=l=1,s=r=2e18+5;
    while(r-l>1||s-f>1)
    {
        md=(l+r)>>1;
        ll x=md;
        rep(i,0,n)x-=x%a[i];
        if(x<=2)l=md;
        else r=md;
        if(s-f==1)continue;
        md=(f+s)>>1;
        x=md;
        rep(i,0,n)x-=x%a[i];
        if(x<2)f=md;
        else s=md;
    }
    ll x=s;
    rep(i,0,n)x-=x%a[i];
    if(x!=2)cout<<-1;
    else cout<<s<<' '<<l;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>

using namespace std;

const int MAX_N = 25;
const int MAX_K = 15;
const int MAX_S = 156 + 20;
int n, k, s;
int memo[MAX_N][MAX_K][MAX_S];

void init()
{
    for (int i = 0; i < MAX_N; i++)
        for (int j = 0; j < MAX_K; j++)
            for (int k = 0; k < MAX_S; k++)
                memo[i][j][k] = -1;
}

int rec(int add, int num, int sum)
{
    if (memo[add][num][sum] >= 0)
        return memo[add][num][sum];

    if (num == k && sum == s)
        return 1;

    if (add > n || num > k || sum > s)
        return 0;

    int res = rec(add + 1, num + 1, sum + add);
    res += rec(add + 1, num, sum);

    return memo[add][num][sum] = res;
}

int main()
{

    while (cin >> n >> k >> s, n || k || s) {
        init();
        cout << rec(1, 0, 0) << endl;
    }

    return 0;
}

Measured memory_bytes: 1416
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int gcd(int x, int y) { return x&&y? gcd(y%x,x): x+y; }
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &x: a) cin >> x;
  vector<int> lg(n), rg(n);
  lg[0]=0;
  for(int i=1;i<n;++i) lg[i]=gcd(lg[i-1],a[i-1]);
  rg[n-1]=0;
  for(int i=n-2;i>=0;--i) rg[i]=gcd(rg[i+1],a[i+1]);
  
  int answer = 0;
  REP(i,n) answer = max(answer, gcd(lg[i],rg[i]));
  cout << answer << endl;
  return 0;
}


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

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>

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

int main()
{
    int n;
    cin >> n;

    vector<int> a(n);
    rep(i, 0, n)
    {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a.begin(), a.end());
    int b = a[n / 2];
    ll sum = 0;
    rep(i, 0, n)
    {
        sum += abs(a[i] - b);
    }
    cout << sum << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long int 
    int main()
    {
        int n,i;
        cin>>n;
        double arr[n],sum=0;
        for(i=0;i<n;i++)
        {
        cin>>arr[i];
        sum+=(1/arr[i]);
        }
        printf("%0.6f",1/sum);
    } 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    bool ok=false;
    while(ok==false){
        if(n/100==7){
            ok=true;
        }if(n%10==7){
            ok=true;
        }if((n/10)%10==7){
            ok=true;
        }else{
            break;
        }
    }if(ok==false){
        cout<<"No";
    }else cout<<"Yes";
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, pair<ll, ll> > P;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define REP(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)((x).size()))

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e15+10;
const ll mod = 1e9+7;
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; }
#define print(x) cerr << #x << " is " << x << endl;
int printa(int a, int b, int N){
    cout << a << " " << b << endl;
    //cout << a << " " << b << " (" << (b - a) << "," << (N - (b - a)) << ")" << endl;
        return 0;
}
int main() {
    ll N, M, x, y;
    
    cin >> N >> M;
    x = 1;
    y = N;
    if (N % 2 == 1){
        rep(i, M){
            printa(x, y, N);
            x++;
            y--;
        }
        return 0;
    }

    rep(i, M){
        if (y - x <= N/2){
            y = N - x;
        }
        printa(x, y, N);
        x++;
        y--;
    }
    return 0;
}


Measured memory_bytes: 3596
N = int(input())
arr = [input().split() for _ in range(N)]
for i in range(2,N):
    if arr[i][0] == arr[i][1] and  arr[i-1][0] == arr[i-1][1] and arr[i-2][0] == arr[i-2][1]:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 9180
#include <iostream>

using namespace std;

int main(){
int a,b,c;
cin >> a >> b >> c ;
	if(a==5 && b == 5 && c ==7){
		cout << "YES" << endl;
		return 0;
	}else if(a==5 && b == 7 && c ==5){
		cout << "YES" << endl;
		return 0;
	}else if(a==7 && b == 5 && c ==5){
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    for (int i = 0; i < h; i++) cin >> field[i];
    vector<vector<int>> line(h, vector<int>(w)), row(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        int cnt = 0;
        for (int j = 0; j < w; j++) {
            if (field[i][j] == '#') {
                cnt = 0;
                continue;
            }
            cnt++;
            line[i][j] = cnt;
        }
        cnt = 0;
        for (int j = w - 1; j >= 0; j--) {
            if (field[i][j] == '#') {
                cnt = 0;
                continue;
            }
            if (cnt == 0) cnt = line[i][j];
            line[i][j] = cnt;
        }
    }
    for (int j = 0; j < w; j++) {
        int cnt = 0;
        for (int i = 0; i < h; i++) {
            if (field[i][j] == '#') {
                cnt = 0;
                continue;
            }
            cnt++;
            row[i][j] = cnt;
        }
        cnt = 0;
        for (int i = h - 1; i >= 0; i--) {
            if (field[i][j] == '#') {
                cnt = 0;
                continue;
            }
            if (cnt == 0) cnt = row[i][j];
            row[i][j] = cnt;
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (field[i][j] == '.') ans = max(ans, row[i][j] + line[i][j] - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 42340
n=int(input())
dic={}
for i in range(n):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=1
m=int(input())
for j in range(m):
    s=input()
    if s in dic:
        dic[s]-=1
print(max(max(dic.values()),0))

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

int main() {
    int n,count =0;
    cin >>n;
    vector<int> p(n);
    for(int i = 0;i < n; i++) {
        cin >> p[i];
    }

    for(int i = 1; i < n-1; i++) {
       if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i+1] < p[i])) {
           count++;
       }
    }
    cout << count <<endl;
}

Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


ans = []
loop {
  n = gif
  break if n == 0
  st = []
  en = []
  rep n do
    s,e = gs
    stt = s.split(':').map(&:to_i)
    enn = e.split(':').map(&:to_i)
    st << stt[0]*60*60 + stt[1]*60 + stt[2]
    en << enn[0]*60*60 + enn[1]*60 + enn[2]
  end
  max = 0
  st.sort!
  en.sort!
  rep n do |i|
    tmp = 0
    repl i, n-1 do |j|
      if en[i] > st[j] && en[i] <= en[j]
        tmp += 1
        max = tmp if tmp > max
      end
    end
  end
  ans << max
}

puts ans

Measured memory_bytes: 9528
#include<iostream>
#include<map>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// mint
template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};
int64_t const MOD = 1e9+7;
typedef mod_int<MOD> mint;

int64_t gcd(int64_t a, int64_t b) {
  int64_t r = a%b;
  while(r){ a=b; b=r; r=a%b; }
  return b;
}

int main() {
  int N; std::cin >> N;
  int z = 0;
  std::map<std::pair<int64_t,int64_t>,int> m1, m2;
  for(int i = 0; i < N; ++i) {
    int64_t A, B; std::cin >> A >> B;
    if(A == 0) {
      if(B == 0) ++z;
      else ++m1[std::make_pair(0,1)];
    } else {
      if(B == 0) ++m2[std::make_pair(0,1)];
      else {
        int64_t l = gcd(A, B); A/=l; B/=l;
        if(A < 0) { A=-A; B=-B; }
        if(B > 0) ++m1[std::make_pair(A, B)];
        else ++m2[std::make_pair(-B, A)];
      }
    }
  }
  int f = 0;
  for(auto const& p :m1) if(m2.count(p.first) < 1) f += p.second;
  for(auto const& p :m2) if(m1.count(p.first) < 1) f += p.second;
  mint ans = mint(2).pow(f);
  for(auto const& p :m1) if(m2.count(p.first)) {
    ans *= mint(2).pow(p.second) + mint(2).pow(m2[p.first]) - 1;
  }
  ans += z-1;
  fin(ans.v_);
  return 0;
}



Measured memory_bytes: 16020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int n; cin>>n;
    vector<P> sai;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        P v={a,b};
        sai.push_back(v);
    }
    bool judge=false;
    rep(i,n-2){
        if(sai[i].first==sai[i].second){
            if(sai[i+1].first==sai[i+1].second){
                if(sai[i+2].first==sai[i+2].second){
                    judge=true;
                }
            }
        }
        if(judge) break;
    }
    if(judge) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(){

  int x,y,z,tmp;

  scanf("%d %d",&x,&y);

  z = x % y;
  while(z!=0){
    x = y;
    y = z;
    z = x % y;
  }
  printf("%d\n",y);
  
  return 0;
}

Measured memory_bytes: 592
#include <stdio.h>

int main(void)
{
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	puts(x+r<=w&&x-r>=0&&y+r<=h&&y-r>=0?"Yes":"No");
	return 0;
}


Measured memory_bytes: 2104
from collections import deque
s = deque([i for i in input()])
q = int(input())
cnt = 0
for _ in range(q):
    s_ = input()
    if len(s_) == 1: cnt += 1
    else:
        if (int(s_[2]) + cnt % 2) % 2 == 0: s.append(s_[4])
        else: s.appendleft(s_[4])
if cnt % 2 == 1: print("".join(list(s)[::-1]))
else: print("".join(s))

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  string ans = "";
  for (int i = 0; i < N; ++i) {
    char c = S[i];
    if (i == K - 1) {
      c = tolower(c);
    }
    ans += c;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;
 
typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

//#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define loop(x,n) for(int x = 0; x < n; ++x)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;

string get_str() {
    string temp;
    cin >> temp;
    return temp;
}
int get_int() {
    int temp;
    cin >> temp;
    return temp;
}

void solve() {



}

int n, a[200000], b[200000], ans; 

int main() {
    
    cin >> n;
    vector<int> interest;
    loop(i, n) {
        cin >> a[i];
    }

    sort(a, a+n);

    vector<bool> dp(a[n-1]+1, true);

    loop(i, n) {
        if (!dp[a[i]]) continue;

        if (i > 0 && a[i] == a[i-1]) {
            dp[a[i]] = false;
            ans--;
            continue;
        }

        ans++;

        for(int j=a[i]*2; j <= a[n-1]; j+=a[i]) {
            dp[j] = false;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
   ll sum=0,i; ll a[n],q;
    for(i=0;i<n;i++)
   { cin>>a[i];sum=sum^a[i];}
     for(i=0;i<n;i++)
     {
       q=a[i]^sum;cout<<q<<" ";
     }
    
}

Measured memory_bytes: 5172
N = int(raw_input())
A = map(int,raw_input().split())

count=1
z1=0
for i in range(N-1):
    if A[i+1]-A[i]>0:
        z2 = 1
    elif A[i+1]-A[i]<0:
        z2 = -1
    elif A[i+1]-A[i]==0:
        z2 = 0
    if z2*z1<0:
        count+=1
        z1=0
    elif z2!=0:
        z1=z2

print str(count)

Measured memory_bytes: 11320
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
from fractions import gcd

NN = 202020
MOD = 10**9+7
INF = float("inf")

n = int(input())
min_time = n

for i in range(n+1):
    v6, v9 = i, n-i
    count = 0
    while v6 > 0:
        count += v6 % 6
        v6 //= 6
    while v9 > 0:
        count += v9 % 9
        v9 //= 9
    min_time = min(min_time, count)

print(min_time)


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

int main() {
    long long n, cap, time;
    long long max=0;
    cin >> n;
    for(int i=0; i<5; ++i) {
        cin >> cap;
        if(n % cap) time = n/cap + 1;
        else time = n/cap;
        if(max < time) max = time;
    }
    cout << max + 4 << endl;
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >>a>>b;
    int d = a/b;
    int r = a%b;
    double f = (double)a/(double)b;
    printf("%d %d %lf",d,r,f);
}


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

typedef long long ll;
const int MAXN = 60;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n;
int a[MAXN], b[MAXN];
vector<ll> v;
set<ll> S[MAXN];
set<ll>::iterator it, p;

ll s, ans;
void dfs(int lst, int cur, int to) {
	if(cur < to) return;
	if(cur == to) {
		v.push_back(s);
		return;
	}
	for(int i = min(lst-1, cur); i >= 1; i--) {
		s ^= (1LL<<(i-1));
		dfs(i, cur%i, to);
		s ^= (1LL<<(i-1));
	}
}

int main() {
	int i, j;
	n = read();
	generate(a+1, a+n+1, read);
	generate(b+1, b+n+1, read);
	for(i = 1; i <= n; i++) {
		v.clear();
		dfs(51, a[i], b[i]);
		if(v.size() == 0) {
			printf("-1\n");
			return 0;
		}
		for(j = 0; j < (int)v.size(); j++) 
			S[i].insert(v[j]);
	}
	//for(i = 1; i <= n; i++) {
	//	for(it = S[i].begin(); it != S[i].end(); it++) 
	//		printf("%lld ", *it);
	//	printf("\n");
	//}
	//printf("\n");
	for(j = 50; j >= 1; j--) {
		for(i = 1; i <= n; i++) {
			for(it = S[i].begin(); it != S[i].end(); it++) 
				if(!(((*it)>>(j-1))&1)) break;
			if(it != S[i].end()) continue;
			else break;
		}
		if(i <= n) {
			ans |= 1LL<<j;
//			printf("%d\n", j);
		}
		else {
			for(i = 1; i <= n; i++) {
				for(it = S[i].begin(); it != S[i].end(); ) {
					if(((*it)>>(j-1))&1) {
						p = it, p++;
						S[i].erase(it), it = p;
					}
					else it++;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int>p(n);
  rep(i,0,n) cin >> p[i];
  int ans = 0;
  rep(i,1,n-1){
    if(p[i] > p[i-1] && p[i] <= p[i+1]) ans++;
    else if(p[i] <= p[i-1] && p[i] > p[i+1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll X;
    cin >> X;
    if(X==1) cout << 1 << endl;
    for(ll x=X;x>0;x--){
        for(ll b=1;b<X;b++){
            for(ll p=2;p<X;p++){
                ll bp = 1;
                for(ll k=1;k<=p;k++){
                    bp*=b;
                }
                if(x==bp){
                    cout << x << endl;
                    return 0;
                }
                if(bp>x) break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let s = input::<String>();
    let k = input::<usize>();

    let leading1 = s.chars().take_while(|&c| c == '1').count();
    if k <= leading1 {
        println!("1");
    } else {
        let c = s.chars().skip_while(|&c| c == '1').nth(0).unwrap();
        println!("{}", c);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,k,l,x[101],y[101];
double r,d[205],P=acos(-1);
main(){
	cin>>n;++m=i=n;
	while(m--)cin>>x[m]>>y[m];
	while(i--){
		j=l=k=r=0;
		for(;j<n;j++)if(i-j)d[k++]=atan2(y[j]-y[i],x[j]-x[i]);
		sort(d,d+k);
		for(;l<k;l++)d[l+k]=d[l]+2*P;
		while(l--)r=max(r,P-d[l+k]+d[l+1]);
		cout<<r/2./P<<'\n';
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  int ans=sqrt(2*N);
  if(ans*(ans+1)/2<N) ans++;
  int memo=ans*(ans+1)/2-N;
  REP(i,1,ans){
    if(memo!=i) cout<<i<<endl;
  }
  }




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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1000000007
#define INF 100000000
#define fk first
#define sv second

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, s, ct = 0;
  cin >> k >> s;
  REP(i, k + 1){
    REP(j, k + 1){
      if (0 <= s - (i + j) && s - (i + j) <= k) ct++;
    }
  }
  cout << ct << endl;
}



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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    string s;
    cin >> s;
    cout << "2018" + s.substr(4) << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3568
N, M, C = map(int, input().split())
Bs = list(map(int, input().split()))
As = [list(map(int, input().split())) for _ in range(N)]
cr = 0
code_result = 0
for a in As:
  for i in range(M):
    code_result += a[i] * Bs[i]
  if code_result + C > 0:
    cr += 1
  code_result = 0
print(cr)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int count = 0;
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			if(count!=0) System.out.println();
			
			int[] a = new int[4];
			for(int i=0;i<4;i++) a[i] = sc.nextInt();
			int sum = a[0]*10 + a[1]*50 + a[2]*100 + a[3]*500 - n;
			
			a[3] -= sum/500;
			sum %= 500;
			a[2] -= sum/100;
			sum %= 100;
			a[1] -= sum/50;
			sum %= 50;
			a[0] -= sum/10;
			
			if(a[0]>0) System.out.println("10 " + a[0]);
			if(a[1]>0) System.out.println("50 " + a[1]);
			if(a[2]>0) System.out.println("100 " + a[2]);
			if(a[3]>0) System.out.println("500 " + a[3]);
			count++;
		}	
	}	
}

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

int main() {
  int h, w;
  while (cin >> h >> w) {
    if (h == 0 && w == 0) continue;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i != 0 && i != h - 1 && j != 0 && j != w - 1) {
          cout << '.';
        } else {
          cout << '#';
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3116
#include <stdio.h>

int main(void){
  int A, B, C;
  int max;
  int buf;

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

  max = A;
  if(B > max) max = B;
  if(C > max) max = C;

  printf("%d\n", A + B + C + 9*max);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
music = []

for i in range(N):
    s, t = input().split()
    t = int(t)

    music.append((s, t))

X = input()
for i in range(N):
    if music[i][0] == X:
        music = music[i+1:]
        break

ans = 0
for i in music:
    ans += i[1]

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
using namespace std;
#define NIL -2000000001
#define MAX 200000

int main() {
  int h,w;
  scanf("%d %d", &h, &w);
  int A[h][w];
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      scanf("%d", &A[i][j]);
    }
  }
  int y[MAX],x[MAX],yd[MAX],xd[MAX],count = 0;
  for (int i=0; i<h; i++) {
    if (i%2 == 0) {
      for (int j=0; j<w; j++) {
        if (j != w-1) {
          if (A[i][j]%2 == 1) {
            A[i][j]--;
            A[i][j+1]++;
            y[count] = i;
            x[count] = j;
            yd[count] = i;
            xd[count] = j+1;
            count++;
          }
        } else {
          if (A[i][j]%2 == 1 && i != h-1) {
            A[i][j]--;
            A[i+1][j]++;
            y[count] = i;
            x[count] = j;
            yd[count] = i+1;
            xd[count] = j;
            count++;
          }
        }
      }
    } else {
      for (int j=w-1; j>=0; j--) {
        if (j != 0) {
          if (A[i][j]%2 == 1) {
            A[i][j]--;
            A[i][j-1]++;
            y[count] = i;
            x[count] = j;
            yd[count] = i;
            xd[count] = j-1;
            count++;
          }
        } else {
          if (A[i][j]%2 == 1 && i != h-1) {
            A[i][j]--;
            A[i+1][j]++;
            y[count] = i;
            x[count] = j;
            yd[count] = i+1;
            xd[count] = j;
            count++;
          }
        }
      }
    }
  }

  printf("%d\n", count);
  for (int i=0; i<count; i++) {
    printf("%d %d %d %d\n", y[i]+1, x[i]+1, yd[i]+1, xd[i]+1);
  }

  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b;
	cin >> a >> b;
	if ((a < 0 && b>0) || a == 0 || b == 0) {
		cout << "Zero\n";
	}
	else if (a > 0 && b > 0) {
		cout << "Positive\n";
	}
	else {
		if (a % 2 == b % 2) {
			cout << "Negative\n";
		}
		else {
			cout << "Positive\n";
		}
	}
	return 0;
}

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

int main() {
	int h[10];
	for (int i = 0; i < 10;i++) {
		cin >> h[i];
	}
	sort(h,h+10);
	for (int i = 9; i > 6;i--) {
		cout << h[i] << endl;
	}
	return 0;
}

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

int main(){
    int n,r;
    cin >> n >> r;
    if(n<10){
        cout << r + 1000 - 100*n << endl;
    }else{
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 256