akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  bitset<70> s;
  ll t;
  re(i, n){
    std::cin >> t;
    s|=t;
  }
  for(int i=0;i<70;i++){
    if(s[i]){
      std::cout << i << '\n';
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;

#define M 1000000007

int main() {
    ll h, w;
    cin >> h >> w;
    vector<string> D(h);
    for (auto & d : D) {
        cin >> d;
    }
    vector<vector<ll>> R(h, vector<ll>(w, 0));
    vector<vector<ll>> C(h, vector<ll>(w, 0));
    for (ll i = 0; i < h; ++i) {
        ll counter = 0;
        for (ll j = 0; j <= w; ++j) {
            if (j == w || D[i][j] == '#') {
                for (ll k = j-1; k >= 0; --k) {
                    if (D[i][k] == '#') break;
                    R[i][k] = counter;
                }
                counter = 0;
                if (j == w) continue;
            } else {
                ++counter;
            }
        }
    }
    for (ll i = 0; i < w; ++i) {
        ll counter = 0;
        for (ll j = 0; j <= h; ++j) {
            if (j == h || D[j][i] == '#') {
                for (ll k = j-1; k >= 0; --k) {
                    if (D[k][i] == '#') break;
                    C[k][i] = counter;
                }
                counter = 0;
                if (j == h) continue;
            } else {
                ++counter;
            }
        }
    }

    ll res = 0;
    for (ll i = 0; i < h; ++i) {
        for (ll j = 0; j < w; ++j) {
            res = max(res, R[i][j] + C[i][j] - 1);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 67072
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define rep(i, a) for (int i = 0; i < (a); i++)
#define repd(i, a) for (int i = (a)-1; i >= 0; i--)
#define reps(i, a, j) for (int i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " "; cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define mp make_pair
#define eb emplace_back
#define FastOpen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pii pair < int , int >
#define all(a) a.begin(),a.end() 
//int power(int x,int p){if(p==0)return 1;if(p==1)return x;if(p%2)return x*power(x,p-1);int y=power(x,p/2);return y*y;}
/*
*/

const int mod = 1e9+7;
void solve() {
    int n,m; cin >> n >> m;
    vector < string > mat(n);
    rep(i,n) cin >> mat[i];
    int dp[n][m];ms(dp);
    rep(i,n) {
        rep(j,m) {
            if (i == 0 && j == 0) {
                dp[i][j] = 1;
            }else if (i == 0) {
                if (mat[i][j] == '.') dp[i][j] = dp[i][j-1];
            }else if (j == 0) {
                if (mat[i][j] == '.') dp[i][j] = dp[i-1][j];
            }else {
                if (mat[i][j] == '.') {
                    dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
                }
            }
        }
    }
    cout << dp[n-1][m-1] << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    FastOpen
    int t; t=1;
    while (t--) solve();
}





Measured memory_bytes: 12384
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    nitin;
    int cnt=0;
    int n;
    cin>>n;
    vector<int>v(n,0);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++)
            {
                if(v[i]+v[j]>v[k] && v[i]+v[k]>v[j] && v[j]+v[k]>v[i] && v[i]!=v[j] && v[i]!=v[k] && v[j]!=v[k])
                {
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3648
/*************************************************************************
    > File Name: A.cpp
    > Author: Drinkwater-cnyali
    > Created Time: 2017/7/29 20:24:26
************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

#define REP(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define DREP(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define mem(a, b) memset((a), b, sizeof(a))

int read()
{
	int sum = 0, fg = 1; char c = getchar();
	while(c < '0' || c > '9') { if (c == '-') fg = -1; c = getchar(); }
	while(c >= '0' && c <= '9') { sum = sum * 10 + c - '0'; c = getchar(); }
	return sum * fg;
}

int n;

int main()
{
	n = read();
	printf("ABC%d",n);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int kosu(int keta,ll kazu){
	if(keta==1){
		int ans=0;
		for(int i=0;i<=kazu%4;i++){
			ans+=i%2;
		}
		ans%=2;
		return ans;
	}
	else{
		ll kazumod=kazu%(1LL<<keta);
		//printf("keta:%d kazu:%lld kazumod:%lld\n",keta,kazu,kazumod);
		if(kazumod<(1LL<<(keta-1))){
			return 0;
		}
		else{
			return (kazumod-(1LL<<(keta-1))+1)%2;
		}
	}
}
int main(){
	ll A,B;
	scan(A);scan(B);
	ll ans=0;
	for(int keta=1;keta<=45;keta++){
		ans+=((kosu(keta,B)-kosu(keta,max(0LL,A-1))+2)%2)*(1LL<<(keta-1));
		//printf("keta:%d kosuB:%d kosuA:%d nowans:%lld\n",keta,kosu(keta,B),kosu(keta,max(0LL,A-1)),ans);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	ll n;
	cin >> n;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	ll x = 1000;
	for (ll i = 0; i < n - 1; i++) {
		while (i < n - 1 && v[i] >= v[i+1]) i++;
		ll p = v[i];
		while (i < n - 1 && v[i] <= v[i+1]) i++;
		ll q = v[i];
		x = (x / p) * q  + x - p * (x / p);
	}
	cout << x << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(m);
    rep(i,m)cin>>a[i];
    sort(a.rbegin(),a.rend());
    vector<int>nd(10);
    vector<int>dp(n+1,-1);
    
    vector<int>cnt(n+1);
    dp[0]=0;
   
    nd[1]=2;
    nd[2]=5;
    nd[3]=5;
    nd[4]=4;
    nd[5]=5;
    nd[6]=6;
    nd[7]=3;
    nd[8]=7;
    nd[9]=6;

    rep(i,n+1){
        rep(j,m){
            if(i>=nd[a[j]]&&dp[i-nd[a[j]]]>=0){
                
                dp[i]=max(dp[i],dp[i-nd[a[j]]]+1);
            }
        }
    }
    int num=dp[n];
    while(num>0){
        rep(j,m){
            if(n>=nd[a[j]]&&dp[n-nd[a[j]]]+1==dp[n]){
                cout<<a[j];
                num--;
                n-=nd[a[j]];
                break;
            }
        }
    }


    cout<<endl;
    return 0;
}

Measured memory_bytes: 384
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == -1) break;
            var alist = new List<int>();
            while (n > 0)
            {
                alist.Add(n % 4);
                n /= 4;
            }
            alist.Reverse();
            if (alist.Count() == 0) alist.Add(0);
            var res = "";
            foreach (var x in alist)
                res += x.ToString();
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 9696
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>

using namespace std;

typedef long long in;

int main(){
  ios::sync_with_stdio(false);
  string a;
  cin >> a;
  int n,s,w,e;
  n=0;
  s=0;
  e=0;
  w=0;
  for(int i=0;i<a.size();i++){
    if(a[i]=='N')
      n++;
    if(a[i]=='W')
      w++;
    if(a[i]=='E')
      e++;
    if(a[i]=='S')
      s++;
  }
  if((n!=0&&s==0)||(n==0&&s!=0)||(w==0&&e!=0)||(w!=0&&e==0))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
tot = sum(A)
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    B[i] = B[i-1]+A[i-1]
cmin = abs(tot-2*B[1])
for i in range(2,N):
    cmin = min(cmin,abs(tot-2*B[i]))
print(cmin)

Measured memory_bytes: 107028
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	int nowmin=0,nowmax=N;
	char memo[100000];
	prin(0);
	cout.flush();
	string s;
	scan(s);
	if(s[0]=='V') return 0;
	else memo[0]=s[0];
	rep1(i,N-1){
		int k=(nowmin+nowmax)/2;
		prin(k);
		cout.flush();
		scan(s);
		if(s[0]=='V') return 0;
		else if((s[0]==memo[nowmin])^(k%2==nowmin%2)) nowmax=k;
		else nowmin=k;
		memo[k]=s[0];
	}
	return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
 
using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string a,b;
  cin>>a>>b;
  cout<<b<<a<<endl;
  return 0;
}


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

int main()
{
    long long int a,b,c,d,e,f,g,h,i,j;

    cin >> a >> b;
    if (a == 1 && b == 1)
        {cout << 1 << endl;}
    else if (a == 1)
        {cout << b - 2 << endl;}
    else if (b== 1)
        {cout << a - 2 << endl;}
    else
        {cout << (b - 2)*(a - 2) << endl;}
    return 0;
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    fori(i, 1, 4) {
        if((a * b * i) & 1) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]

dp = [[0] * (W + 1) for _ in range(H + 1)]
F = 80 * 200 + 100
dp[0][0] = (1 << F)

for h in range(H):
    for w in range(W):
        a = A[h][w]
        b = B[h][w]
        d = dp[h][w]
        dp[h + 1][w] |= (d << abs(a - b)) | (d >> abs(a - b))
        dp[h][w + 1] |= (d << abs(a - b)) | (d >> abs(a - b))

res = dp[H][W - 1] | dp[H - 1][W]
ans = 10**18
for d in range(F * 2):
    if (res & (1 << d)) != 0:
        ans = min(ans, abs(d - F))
print(ans)


Measured memory_bytes: 23796
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
ll gcd(ll x, ll y) { return (y ? gcd(y, x % y) : x); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> p(N);
    for (int i = 0; i < N; i++) cin >> p[i];
    ll ans = p[0];
    for (int i = 1; i < N; i++) ans = lcm(ans, p[i]);
    cout << ans << '\n';
}


Measured memory_bytes: 3640
// abc132d.cpp : Blue and Red Balls
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);i++)
#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define downto(i,s,e,d) for(int i=(s);i>(e);i-=(d))
#define oute(x) cout<<(x)<<endl
#define out(x) cout<<(x)

#define MAX 2001
const ll MOD = 1000000007;
vector<ll> c((MAX)*(MAX+1)/2);

void init(int N){
  int k = 0;
  rep(i,N){
    rep(j,N-i){
      c[k] = (i==0 || j==0)? 1: (c[k-1] + c[k-N+i-1]) % MOD;
      k++;
    }
  }
}

ll comb(int N, int n, int r){
  if(n<r) return 0;
  int Nsum = (N)*(N+1)/2;
  int nsum = (N-n+r)*(N-n+r+1)/2;
  int r0 = Nsum - nsum;
  int k = r0 + r;
  return c[k];
}

int main(){
  int N,K; cin>>N>>K;
  int red = N-K, blue = K;
  init(N+1);
  upto(i,1,blue+1,1)
    oute((comb(N+1, red+1, i) * comb(N+1, blue-1, i-1)) % MOD);
}

Measured memory_bytes: 15872
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <cmath>
#include <iomanip>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>, int> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;
string s;
int k;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> s >> k;
    vector<string> q;
    for(int i = 0; i < s.length(); i++){
        string t = "";
        for(int j = i; j < s.length(); j++){
            if(j - i > 6) break;
            t += s[j];
            if(q.size() < k){
                q.pb(t);
            }else{
                int idx = 0;
                bool good = true;
                for(int w = 0; w < q.size(); w++){
                    if(q[w] == t){
                        good = false;
                        break;
                    }
                    if(q[w] > q[idx]) idx = w;
                }
                if(!good) continue;
                if(t < q[idx]) q[idx] = t;
            }
        }   
    }
    sort(q.begin(), q.end());
    cout << q[k-1];
}

Measured memory_bytes: 256
import numpy as np

n,w=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
dp=np.zeros(w+1,dtype=np.int64)
#print(np.max(dp[0:w-l[0][0]]+np.array(l[0][1]),dp[l[0][0]:w]))
for i in range(n):
    if l[i][0]<=w:
        dp[l[i][0]:w+1]=np.maximum(dp[0:w+1-l[i][0]]+np.array(l[i][1]),dp[l[i][0]:])
    #print(dp)
print(max(dp))

Measured memory_bytes: 15504
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  while(true)
    {
      int x,y,z;
      cin>>x>>y>>z;
      if(x==0 && y==0 && z==0)break;
      int n;
      cin>>n;
      for(int i=0;i<n;i++)
	{
	  int r;
	  cin>>r;
	  if(sqrt(pow((double)x/2,2)+pow((double)y/2,2))<r)cout<<"OK"<<endl;
	  else if(sqrt(pow((double)y/2,2)+pow((double)z/2,2))<r)cout<<"OK"<<endl;
	  else if(sqrt(pow((double)x/2,2)+pow((double)z/2,2))<r)cout<<"OK"<<endl;
	  else cout<<"NA"<<endl;
	}
    }
  return 0;
}

Measured memory_bytes: 1156
d1=tuple(map(int,input().split()))
d2=tuple(map(int,input().split()))

def rot(d, r):
    if r == 'N':
        return (d[1], d[5], d[2], d[3], d[0], d[4])
    if r == 'E':
        return (d[3], d[1], d[0], d[5], d[4], d[2])
    if r == 'W':
        return (d[2], d[1], d[5], d[0], d[4], d[3])
    if r == 'S':
        return (d[4], d[0], d[2], d[3], d[5], d[1])
    return d

def gen_all( d1 ):
    ds = { d1 }
    while 1:
        ds2 = { rot(d, r) for d in ds for r in list('NEWS') }.union(ds)
        if ds == ds2: break
        ds = ds2
    return ds

print('Yes' if d2 in gen_all(d1) else 'No')

Measured memory_bytes: 7776
W, H, x, y, r = map(int, input().split())
right = x - r
left = x + r
above = y + r
below = y - r

if x < 0 or y < 0:
    print('No')
else:
    if right >= 0 and left <= W and above <= H and below >= 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;
ll W;
vector<ll> w(110, 0);
vector<ll> v(110, 0);
vector< vector<ll> > dp(110, vector<ll>(100100, 0));

int main() {
    cin >> n >> W;
    for(int i = 0; i < n; ++i) {
        cin >> w.at(i) >> v.at(i);
    }

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= W; ++j) {
            if(j+w.at(i) <= W) chmax(dp[i+1][j+w.at(i)], dp[i][j]+v.at(i));
            chmax(dp[i+1][j], dp[i][j]);
        }
    }

    cout << dp[n][W] << endl;
}

Measured memory_bytes: 87296
N=int(input())
l=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
l2=[0]*100001

for i in range(1,100001):
  mn=100000000000000000
  for x in l:
    if i-x>=0 and l2[i-x]<mn:
      mn=l2[i-x]+1
  l2[i]=mn
print(l2[N])

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef priority_queue<int> P_QI;
typedef priority_queue<string> P_QS;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector< int > :: iterator $$;

#define SET(arr) memset(arr, -1, sizeof(arr))
#define CLR(arr) memset(arr, 0, sizeof(arr))

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

#define $ vector< int > :: iterator
#define m_p make_pair
#define p_b push_back
#define rep(i, n) for(int i=0; i<(n); i++)
#define forn(i, n) for (int i = 1; i <=(int)(n); ++i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define forba(i, b, a) for (int i = (int)(b); i >= (int)(a); --i)

#define forv(i,v) rep(i,SZ(v))
#define forit(i,s) for(auto i=(s).begin();i!=(s).end();++i)

#define Boost ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define _ <<" "<<
#define CS(i) cout<<"Case "<<(int)(i)<<": "

const int MOD = 1e9+7;
const int inf = 1e9+9;
const long long INF = 1e18+3;
const ld eps = 1e-9;
const ld PI=acos(-1.0);


int main() {
Boost;
//READ("in.txt");
//WRITE("out.txt");
    string s[3];
    rep(i,3) cin>>s[i];
    rep(i,3) cout<<s[i][i];
    cout<<endl;

return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        m1: usize,
        _d1: usize,
        m2: usize,
        _d2: usize
    }
    if m1 == m2 {
        println!("0");
    } else {
        println!("1");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e6+10,inf=1e9+10;

int n,h,w,ans;
point p[maxn];

int32_t main(){
	scanf("%d%d%d",&h,&w,&n);
	ans=h;
	rep(i,0,n){
		scanf("%d%d",&p[i].X,&p[i].Y);
	}
	sort(p,p+n);
	int mu=0;
	rep(i,0,n){
		int y=p[i].X+mu;
		if(p[i].Y>y){
			continue;
		}
		if(p[i].Y==y){
			mu--;
		}else{
			ans=p[i].X-1;
			break;
		}
	}
	printf("%d\n",ans);
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

ll N,M,K;
ll dp [2] [2017] [2017];
ll fact [4001];
const ll MOD = 924844033ll;

void merge(vector<ll>& a,ll x,ll y){
	vector<ll> res(a.size());

	FOR(i,0,a.size()) FOR(j,0,M) if(a [i] && dp [x] [y] [j]){
		(res [i + j] += a [i] * dp [x] [y] [j]) %= MOD;
	}

	a.swap(res);
}

int main()
{
	scanf("%lld%lld",&N,&K);
	M = N / K + 10;
	fact [0] = 1;
	for(ll i = 1;i <= N * 2;i++){
		fact [i] = fact [i - 1] * i % MOD;
	}

	dp [0] [0] [0] = dp [1] [0] [0] = 1;
	for(int i = 0;i * K < N;i++) FOR(j,0,M) if(dp [0] [i] [j]){
		(dp [0] [i + 1] [j] += dp [0] [i] [j]) %= MOD;
		if((i + 1) * K < N){
			(dp [0] [i + 2] [j + 1] += dp [0] [i] [j]) %= MOD;
		}
	}
	for(int i = 0;i * K + (K - 1) < N;i++) FOR(j,0,M) if(dp [1] [i] [j]){
		(dp [1] [i + 1] [j] += dp [1] [i] [j]) %= MOD;
		if((i + 1) * K + (K - 1) < N){
			(dp [1] [i + 2] [j + 1] += dp [1] [i] [j]) %= MOD;
		}
	}

	vector<ll> res(N * 2);
	res [0] = 1;
	for(int i = 0;i < K;i++) FOR(j,0,2){
		bool f = (N - 1 - i) / K != (N - 1) / K;
		if(f == false){
			merge(res,f,(N - 1) / K + 1);
		}
		else{
			merge(res,f,(N - K - 2) / K + 1);
		}
	}

	ll ans = fact [N];
	FOR(i,1,res.size()) if(res [i]){
		if(i % 2){
			(ans -= res [i] * fact [N - i]) %= MOD;
			(ans += MOD) %= MOD;
		}
		else{
			(ans += res [i] * fact [N - i]) %= MOD;
		}
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 32000
#include <cstdio>
#include <algorithm>
#include <utility>
#include <climits>

using namespace std;

struct S {
    int n, v;
    S() {
        v = INT_MIN;
    }
    S(int n, int v) : n(n), v(v) {}
    bool operator<(const S &o) const {
        if (v == o.v) {
            return n > o.n;
        } else {
            return v < o.v;
        }
    }
};

struct SegTree {
    // root: vs[1]
    S *vs;
    int n;
    SegTree(int _n) {
        n = 1;
        while (n < _n) n *= 2;
        vs = new S[2 * n];
        for (int i = n + 1; i < 2 * n; i++) {
            vs[i].n = i - n;
            vs[i].v = 0;
        }
    }
    void add(int index, int v) {
        //printf("\t%d %d\n", vs[1].n, vs[1].v);
        index += n;
        vs[index].v += v;
        index /= 2;
        while (index > 0) {
            vs[index] = max(vs[index*2], vs[index*2+1]);
            index /= 2;
        }
    }
    int get(int index) {
        return vs[index + n].v;
    }
    S maximum() {
        return vs[1];
    }
    ~SegTree() {
        delete[] vs;
    }
};

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    SegTree segt(n+1);
    for (int i = 0; i < q; i++) {
        int a, v; scanf("%d %d", &a, &v);
        segt.add(a, v);
        S result = segt.maximum();
        printf("%d %d\n", result.n, result.v);
    }
    return 0;
}

Measured memory_bytes: 17188
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

typedef pair<ll, int> P;
#define fs first
#define sc second

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

    P p[N];
    for(int i = 0; i < N; i++){
        cin >> p[i].fs;
        p[i].sc = i;
    }

    sort(p, p + N, greater<P>());

    /*for(int i = 0; i < N; i++){
        cout << p[i].fs << " " << p[i].sc << endl;
    }*/

    int mn[N];
    mn[0] = p[0].sc;
    for(int i = 1; i < N; i++){
        mn[i] = min(mn[i - 1], p[i].sc);
    }

    ll ans[N];
    fill(ans, ans + N, 0);

    for(int i = 0; i < N; i++){
        int id = mn[i];
        if(i == N - 1){
            ans[id] += p[i].fs * (i + 1);
        } else {
            ans[id] += (p[i].fs - p[i + 1].fs) * (i + 1);
        }
    }

    for(int i = 0; i < N; i++){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <string>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
const int INF = 1001001001;


int main() {
  
  int N;
  cin >> N;
  
  int Flag = 0;
  set<int> count;
  
  int X;
  REP(i, N) {
    cin >> X;
    auto www = count.insert(X);
    if(www.second == false) {
      Flag++;
    }
  }

  
  
  if(Flag == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

void trace(int A[100],int n){
    for ( int i = 0;i < n; i++ ){
        if ( i ) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[100],int n){
    int v,j;
    for ( int i = 0; i < n; i++){
        v=A[i];
        j = i - 1;
        while ((j >= 0) && (A[j] > v)){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        if(i>0)trace(A,n);
    }
}

int main(){
    int n,A[100];
    cin >> n;
    for ( int i = 0; i < n; i++)cin >>A[i];
   
    trace(A,n);
    insertionSort(A,n);
    
    return 0;
}

Measured memory_bytes: 1160
n=int(input())
xy=[]
for _ in range(n):
	xy+=[list(map(int,input().split()))]

dic={}
for e in xy:
	for f in xy:
		if e==f:continue
		tmp=(e[0]-f[0],e[1]-f[1])
		dic[tmp]=dic.get(tmp,0)+1

mx=max(dic.values()) if dic else 0
print(n-mx)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); i++)
 
int main() {
 ll n,fx,po,nco;
 fx=0;
 cin>>n;
  nco=n;
 for(int i=8;i>=0;i--){
   po=n/(pow(10,i));
   fx+=po;
   n=n-(po*(pow(10,i)));
 }
  if(nco%fx==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  if(s.at(s.size()-1)=='s') {
    cout << s << "es" << endl;
    return 0;
  }
  cout << s << 's' << endl;
  return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    i64 N;
    cin >> N;
    
    for(i64 h=1; h<=3500; ++h) for(i64 n=1; n<=3500; ++n){
        if((4*h*n-N*n-N*h)<=0 or (N*h*n)%(4*h*n-N*n-N*h)) continue;
        cout << h << " " << n << " " << (N*h*n)/(4*h*n-N*n-N*h) << endl;
        return;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<ctime>
#include<unordered_map>
const  int N = 2e6*1.0;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef long double lw;
#define sc(n) scanf("%d",&n)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
int h,w;
int ans;
char mp[2005][2005];
int main()
{
	cin>>h>>w;
	fo(i,0,h)
	scanf("%s",mp[i]);
	fo(i,0,h)
	{
		if(ans==h+w-1)
				break;
	fo(j,0,w)
	{
		if(mp[i][j]=='.')
		{
			int cnt=1;
			int k;
			k=i-1;
			while(mp[k][j]=='.')
			{
				k--;
				cnt++;
			}
			k=i+1;
			while(mp[k][j]=='.')
			{
				k++;
				cnt++;
			}
			k=j-1;
			while(mp[i][k]=='.')
			{
				k--;
				cnt++;
			}
			k=j+1;
		    while(mp[i][k]=='.')
			{
				k++;
				cnt++;
			}
			ans=max(cnt,ans);
			if(ans==h+w-1)
				break;
		}
	 }
    }
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 4224
#include<cstdio>

using namespace std;

int n,k;

int dp[100][3][2];
int yt[100];

const int MOD = 10000;

int next(int a){
	return (a + 1) % 3;
}
int prev(int a){
	return (a - 1 + 3) % 3;
}

int main(){
	scanf("%d %d",&n,&k);
	int a,b;
	for(int i=0;i<100;i++){
		yt[i] = -1;
	}
	for(int i=0;i<k;i++){
		scanf("%d %d",&a,&b);
		yt[a-1] = b-1;
	}
	if(yt[0] != -1){
		dp[0][yt[0]][0] = 1;
	}else{
		for(int j=0;j<3;j++){
			dp[0][j][0] = 1;
		}
	}
	for(int i=1;i<n;i++){
		if(yt[i] != -1){
			dp[i][yt[i]][0] = (
				dp[i - 1][next(yt[i])][0] +
				dp[i - 1][next(yt[i])][1] +
				dp[i - 1][prev(yt[i])][0] +
				dp[i - 1][prev(yt[i])][1]
			                  ) % MOD;
			dp[i][yt[i]][1] = (
				dp[i - 1][yt[i]][0]
							  ) % MOD;
		}else{
			for(int j=0;j<3;j++){
				dp[i][j][0] = (
					dp[i - 1][next(j)][0] +
					dp[i - 1][next(j)][1] +
					dp[i - 1][prev(j)][0] +
					dp[i - 1][prev(j)][1]
					              ) % MOD;
				dp[i][j][1] = (
					dp[i - 1][j][0]
								  ) % MOD;
			}
		}
	}
	//for(int i=0;i<n;i++){
	//	printf("%d:(%d,%d),(%d,%d),(%d,%d)\n",yt[i] + 1,dp[i][0][0],dp[i][0][1],dp[i][1][0],dp[i][1][1],dp[i][2][0],dp[i][2][1]);
	//}
	int ans = 0;
	if(yt[n - 1] != -1){
		ans += dp[n-1][yt[n-1]][0] + dp[n-1][yt[n-1]][1];
		ans %= MOD;
	}else{
		for(int i=0;i<3;i++){
			ans += dp[n-1][i][0] + dp[n-1][i][1];
			ans %= MOD;
		}
	}
	printf("%d\n",ans);
}

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

int main(){
   int a,b,c,d,e;
   cin>>a>>b>>c>>d>>e;
   if(a < 40) {
      a = 40;
   } 
   if(b < 40) {
      b = 40;
   }
   if(c < 40) {
      c = 40;
   }
   if(d < 40) {
      d = 40;
   }
   if(e < 40) {
      e = 40;
   }
   cout << (a+b+c+d+e)/5 << endl;
   return 0;
}


Measured memory_bytes: 3104
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 5010

/* Rolling Hash */
// n = 9973, 10007

struct RollingHash{
  int N, base;
  vector<ll> hash, pow;

  template <typename Type>
  RollingHash(int base, int n, Type *arr):
    N(n), base(base), hash(n+1), pow(n+1)
  {
    hash[0] = 0;
    pow[0] = 1;
    for(int i=0; i<N; i++){
      hash[i+1] = (hash[i] + arr[i]) * base % mod;
      pow[i+1] = pow[i] * base % mod;
    }
  }

  // get [l,r)
  ll getHash(int l, int r) {
    return (mod + hash[r] - hash[l] * pow[r-l] % mod) % mod;
  }
};

int main(){
  int N;
  char s[SIZE] = {};

  scanf("%d%s", &N, s);

  /*
  N = 5000;

  for(int i=0; i<N; i++) s[i] = 'a' + rand() % 26;

  cout << s << endl;
  */

  RollingHash hash1(9973, N, s), hash2(10007, N, s);

  int l = 0, r = N/2;

  while(l < r) {
    int mid = (l+r+1)/2;
    bool ok = false;

    set<ll> ss;

    for(int r=1; r<=N; r++) {
      int l = r - mid;
      if(l >= 0) {
        ll p = hash1.getHash(l, r) * INF + hash2.getHash(l, r);
        ss.insert(p);
      }

      int r2 = r + mid;
      if(r2 <= N) {
        ll p = hash1.getHash(r, r2) * INF + hash2.getHash(r, r2);
        if(ss.find(p) != ss.end()) {
          ok = true;
        }
      }
    }

    if(ok) {
      l = mid;
    } else {
      r = mid-1;
    }
  }

  cout << l << endl;

  return 0;
}


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

using namespace std;

int main()
{
    int n, k;

    cin>>n>>k;
    vector<int> A(n);
    for(int i=0;i<n;i++)
        cin>>A[i];
    vector<int> V(n);
    long long ans = 0;
    for(int left=0;left<=k && left<=n;left++)
    {
        for(int right=0;right<=k-left && left+right<=n;right++)
        {
            for(int i=0;i<left;i++)
                V[i] = A[i];
            for(int i=0;i<right;i++)
                V[i+left] = A[n-1-i];
            sort(V.begin(),V.begin()+left+right);
            for(int x=0;x<=k-left-right;x++)
            {
                long long sum=0;
                for(int i=x;i<left+right;i++)
                {
                    sum = sum + V[i];
                }
                ans = max(ans,sum);
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,a[100],i,f;
  scanf("%d",&n);
  f=0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0){
	f++;
      }
    }
  }
  if(f>0){
    printf("DENIED\n");
      }else{
    printf("APPROVED\n");
  }
  return 0;
}


Measured memory_bytes: 128
n = int(input())
A = sorted(map(int, input().split()))
U = A[-1]

line = [1]*(U+1)
ans = set()
depricated = set()
for a in A:
    if a in ans:
        depricated.add(a)
        continue
    if line[a]:
        ans.add(a)
        for p in range(2*a, U+1, a):
            line[p] = 0
print(len(ans-depricated))


Measured memory_bytes: 43420
#include <stdio.h>

int main()
{
    struct Dice {
        int dice1;
        int dice2;
        int dice3;
        int dice4;
        int dice5;
        int dice6;
    };
    int a[6], i;
    for(i = 0; i < 6; i++){
        scanf("%d", &a[i]);
    }
    struct Dice Dice_1 = {a[0], a[1], a[2], a[3], a[4], a[5]};
    struct Dice Dice_2;
    char c;
    c = getchar();
    while(1){
        c = getchar();
        if(c == '\n') break;
        Dice_2 = Dice_1;
        if(c == 'E'){
            Dice_1.dice1 = Dice_2.dice4;
            Dice_1.dice3 = Dice_2.dice1;
            Dice_1.dice4 = Dice_2.dice6;
            Dice_1.dice6 = Dice_2.dice3;
        } else if(c == 'N'){
            Dice_1.dice1 = Dice_2.dice2;
            Dice_1.dice2 = Dice_2.dice6;
            Dice_1.dice5 = Dice_2.dice1;
            Dice_1.dice6 = Dice_2.dice5;
        } else if(c == 'S'){
            Dice_1.dice1 = Dice_2.dice5;
            Dice_1.dice2 = Dice_2.dice1;
            Dice_1.dice5 = Dice_2.dice6;
            Dice_1.dice6 = Dice_2.dice2;
        } else if(c == 'W'){
            Dice_1.dice1 = Dice_2.dice3;
            Dice_1.dice3 = Dice_2.dice6;
            Dice_1.dice4 = Dice_2.dice1;
            Dice_1.dice6 = Dice_2.dice4;
        }
    }
    printf("%d\n", Dice_1.dice1);
    return 0;
}

Measured memory_bytes: 600
N = int(input())
if N >= 100000:
    print(9+900+90000)
elif N >= 10000:
    print(9+900+(N-9999))
elif N >= 1000:
    print(9+900)
elif N >= 100:
    print(9+(N-99))
elif N >= 10:
    print(9)
else:
    print(N)

Measured memory_bytes: 3060
s=input()
t="AKIHABARA"
pos=0
for i in range(len(t)):
  while pos<len(s):
    if t[i]==s[pos]:
      pos+=1
      break
    else:
      break
if pos!=len(s):
  print('NO')
else:
  if "K" in s and "I" in s and "H" in s and "B" in s and "R" in s:
    print('YES')
  else:
    print('NO')

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

int main()
{
  string a;
  cin >> a;
  if (a[0]=='S') cout << "Cloudy" << endl;
  if (a[0]=='C') cout << "Rainy" << endl;
  if (a[0]=='R') cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a, b;
  cin >> a >> b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * B - Minor Change
 * 文字列 S, T が与えられます。
 * 次の操作を繰り返して S を T に変更するとき、操作回数の最小値を求めてください。
 * 操作：S の 1 文字を選んで別の文字に書き換える
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 入力値
        String s = sc.next();
        String t = sc.next();

        int result = 0;
        for( int i = 0; i < s.length(); i++ ) {
            if( s.charAt( i ) != t.charAt( i ) ) ++result;
        }

        System.out.println( result );

        sc.close();
    }
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    int D;
    string str = "Christmas";
    cin >> D;
    REP(i, abs(D - 25)) str += " Eve";
    PRINT(str);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var list = new List<int>();
            var sum = 0;

            for(var x = 0; x < str.Count(); x++)
            {
                list.Add(str[x]);
            }

            sum = list.Max() - list.Min();

            Console.WriteLine(sum);
        }
    }
}


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

int main(void){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	
	int i;
	string s,t;
	cin>>s>>t;
	if(s==t){
		cout<<"Yes"<<endl;
		return 0;
	}
	for(i=1;i<s.length();i++){
		if(t.substr(i,s.length()-i)+t.substr(0,i)==s){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
A = 0
B = 0
for i in range(N):
	A += (X[i])**2
	B += X[i]
def ans(A,B,n,x):
	return A-2*x*B+n*(x**2)
	
res = 99999999999
for i in range(1,101):
	res = min(res,ans(A,B,N,i))
	
print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int gcd(int x,int y)
{
	if(y==0)
		return x;
	return gcd(y,x%y);
}
char s[101010],t[101010];
int main()
{
	int n,m,h,p1,p2;
	long long ans;
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	scanf("%s",t+1);
	ans=(long long)n*m/gcd(n,m);
	h=gcd(n,m);
	n/=h;
	m/=h;
	p1=p2=1;
	while(p1<=n*h)
	{
		if(s[p1]!=t[p2])
		{
			printf("-1");
			return 0;
		}
		p1+=n;
		p2+=m;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 764
# https://atcoder.jp/contests/abc059/tasks/arc072_a
# 累積和を作っておいて、その累積和の符号が交互になるようにしていく
# 累積和のi以降の要素をすべて変更する代わりにいくつ足せばいいのか持っておく(imos法のイメージ)

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


class cumsum1d:  # 一次元累積和クラス
    def __init__(self, ls: list):
        '''
        1次元リストを受け取る
        '''
        from itertools import accumulate
        self.ls_accum = [0] + list(accumulate(ls))

    def total(self, i, j):
        # もとの配列lsにおける[i,j)の中合計
        return self.ls_accum[j] - self.ls_accum[i]

    def __call__(self, i):
        # i番目までの合計
        return self.ls_accum[i + 1]


N = read_a_int()
A = read_ints()

A = cumsum1d(A)
# ただし第一項が0とか途中0になる場合がめんどくさい
# →二通りやって少ないほうでいいじゃん
ans1 = 0
bias = 0
pre_sign = 1  # 第一項が負と仮定
for i in range(N):
    now = A(i) + bias
    if pre_sign * now < 0:  # 異符号
        pass
    elif pre_sign * now >= 0:  # 同符号
        ans1 += abs(now) + 1
        bias += -pre_sign * (abs(now) + 1)
    pre_sign = 1 if pre_sign == -1 else -1

ans2 = 0
bias = 0
pre_sign = -1  # 第一項が正と仮定
for i in range(N):
    now = A(i) + bias
    if pre_sign * now < 0:  # 異符号
        pass
    elif pre_sign * now >= 0:  # 同符号
        ans2 += abs(now) + 1
        bias += -pre_sign * (abs(now) + 1)
    pre_sign = 1 if pre_sign == -1 else -1
print(min(ans1, ans2))


Measured memory_bytes: 61780
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var tokens = input.split(' ');
var stack = [];

tokens.forEach(function(token) {
	if (token - 0 == token) {
		stack.push(token);
	} else {
		var a = stack.pop();
		var b = stack.pop();
		stack.push(eval(b + token + a));
	}
});

console.log(stack.pop());

Measured memory_bytes: 7904
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        int[][] B = new int[2][M];
        long sum = 0;
        Map<Integer, Integer> map = new TreeMap<>();
        for(int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            sum += A[i];
        }
        for(int i = 0; i < M; i++){
            B[0][i] = sc.nextInt();
            B[1][i] = sc.nextInt();
            if(map.containsKey(B[1][i])){
                map.put(B[1][i], map.get(B[1][i])+B[0][i]);
            } else {
                map.put(B[1][i], B[0][i]);
            }
        }
        sc.close();

        Arrays.sort(A);
        int[][] C = new int[2][map.size()];
        int i = 0;
        for(Integer key: map.keySet()){
            C[0][i] = key;
            C[1][i] = map.get(key);
            i++;
        }

        int i_A = 0;
        int i_C = map.size()-1;
        while(i_A < N && i_C >= 0){
            if(A[i_A] < C[0][i_C] && C[1][i_C] > 0){
                sum += C[0][i_C] - A[i_A];
                C[1][i_C]--;
                if(C[1][i_C] == 0)
                    i_C--;
            }
            i_A++;
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 98664