akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string s;
  cin >> s;
  int N = s.size();
  vector<int> dp(N + 1);
  vector<string> dic = {"dream", "dreamer", "erase", "eraser"};
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    if (!dp[i]) continue;
    for (int j = 0; j < dic.size(); j++) {
      if (s.substr(i, dic[j].size()) == dic[j]) {
        dp[i + dic[j].size()] |= dp[i];
      }
    }
  }
  if (dp[N]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 896
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


const ll MOD=1e9+7;
const int N=500000;


main(){
    int n,m,x,y;cin>>n>>m>>x>>y;
    vec a;
    vec b;
    a.pb(x);
    rep(i,n)a.pb(in());
    rep(i,m)b.pb(in());
    b.pb(y);
    sort(all(a));sort(all(b));
    if(a.back()<b[0]) cout<<"No War";
    else cout<<"War";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n,a,b,c;
    cin>>n;
    vector<vector<int>> v(n,vector<int>(3)),dp(n,vector<int>(3));
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
            cin>>v[i][j];
    dp[0][0]=v[0][0],dp[0][1]=v[0][1],dp[0][2]=v[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+v[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<'\n';
}

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

int main(){

    vector<int> a(3);
    for(int i = 0; i < 3; i++) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[2] * 10 + a[1] + a[0] << endl;
    return 0;

}

Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 1/27/2019, 9:07:00 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N = 0;
ll A[100010];
ll B[100010];
typedef tuple<ll, ll, ll> T;
T C[100010];
ll ans = 0;

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> A[i] >> B[i];
    C[i] = T(A[i] + B[i], A[i], B[i]);
  }
  sort(C, C + N);
  reverse(C, C + N);
  for (auto i = 0; i < N; i++)
  {
    if (i % 2 == 0)
    {
      ans += get<1>(C[i]);
    }
    else
    {
      ans -= get<2>(C[i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}



signed main(){
	string s; cin>>s; int n=s.size();
	rep(i,n/2){
		char c = s[i]; s[i] = s[n-1-i]; s[n-i-1] = c;
	}
	rep(i,n){
		if(s[i]=='m'){
			if(i+4>n||s[i+1]!='a'||s[i+2]!='e'||s[i+3]!='r'||s[i+4]!='d') return cout<<"NO"<<endl,0;
			else i+=4;
		}else if(s[i]=='e'){
			if(i+4>n||s[i+1]!='s'||s[i+2]!='a'||s[i+3]!='r'||s[i+4]!='e') return cout<<"NO"<<endl,0;
			else i+=4;
		}else if(s[i]=='r'){
			if(i+5>n||s[i+1]!='e') return cout<<"NO"<<endl,0;
			if(s[i+2]=='m'){
				if(i+6>n||s[i+3]!='a'||s[i+4]!='e'||s[i+5]!='r'||s[i+6]!='d') return cout<<"NO"<<endl,0;
				else i+=6;
			}else if(s[i+2]=='s'){
				if(s[i+3]!='a'||s[i+4]!='r'||s[i+5]!='e') return cout<<"NO"<<endl,0;
				else i+=5;
			}
		}else{
			return cout<<"NO"<<endl,0;
		}
	}
	cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define met(s) memset(s,0, sizeof(s))
const int mod=100000007;
const int maxn=1e5+10;
const int inf = 0x3f3f3f3f;
vector<int> pos[26];
char a[maxn],b[maxn];
int main()
{
    scanf("%s",a);
    scanf("%s",b);
    int lena=strlen(a),lenb=strlen(b),p=0;
    for(int i=0;i<lena;i++) pos[a[i]-'a'].push_back(i+1);
    ll now=0;
    bool fo=true;
    for(int i=0;i<lenb;i++)
    {
        if(pos[b[i]-'a'].size()==0)
        {
            fo=false;
            break;
        }
        else
        {
            int w=upper_bound(pos[b[i]-'a'].begin(),pos[b[i]-'a'].end(),p)-pos[b[i]-'a'].begin();
            if(w==pos[b[i]-'a'].size())
            {
                now++;
                p=pos[b[i]-'a'][0];
            }
            else p=pos[b[i]-'a'][w];
        }
    }
    if(fo)printf("%lld\n",now*lena+p);
    else printf("-1\n");
    return 0;
}

Measured memory_bytes: 1024
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}
const int N = 405;
const ll inf = (ll) 1e18;

ll dp[N][N], sum[N];
int ar[N];
int n;

void solve() {

   for (int i = 1; i <= n; ++i) dp[i][i] = 0;

   for (int len = 1; len <= n; ++len) {
      for (int i = 1; i + len <= n; ++i) {
         int j = i + len;
         dp[i][j] = inf;
         for (int k = i; k < j; ++k)
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + sum[j] - (i > 1 ? sum[i-1] : 0));
      }
   }
   cout << dp[1][n] << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;
   for (int i = 1; i <= n; ++i) {
      cin >> ar[i];
      if (i == 1) sum[i] = ar[i];
      else sum[i] = sum[i-1] + ar[i];
   }
   solve();


   return EXIT_SUCCESS;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void other(ll N, ll P, string S) {
  ll ans = 0;
  ll accum = 1;
  for (char c: S) {
    ll num = c - '0';
    if (num % P == 0) {
      ans += accum;
    }
    accum ++;
  }
  cout << ans << endl;
}

void solve() {
  ll N, P;
  string S;
  cin >> N >> P >> S;

  if (P == 2 or P == 5) {
    other(N, P, S);
    return;
  }

  vector<ll> foo;
  reverse(S.begin(), S.end());

  ll current = 1;
  ll m = 0;
  for (char c: S) {
    ll num = c - '0';
    m += num * current;
    m %= P;
    foo.push_back(m);
    current *= 10;
    current %= P;
  }

  ll ans = 0;

  unordered_map<ll, ll> memo;
  memo[0] = 1;

  for (auto it: foo) {
    ans += memo[it];
    memo[it] ++;
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 2700
#include <iostream>
#include <vector>

using namespace std;
#define long long long

int const N = 3e5 + 10;

struct fenwick{
    long n;
    vector<long> mx;
    fenwick(long n) : n(n), mx(n + 1) {}

    long getRes(int i) {
        long res = 0;
        for (; i; i -= i & (-i)) res = max(res, mx[i]);
        return res;
    }

    void add(int i, long var) {
        for (; i <= n; i += i & (-i)) mx[i] = max(mx[i], var);
    }
};

int n, h[N], a[N];
long val[N];

int main()
{
//    freopen("tam.inp", "r", stdin);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> h[i];
    for (int i = 1; i <= n; ++i) cin >> a[i];
    fenwick fen(n);

    long res = 0;
    for (int i = 1; i <= n; ++i) {
        long tmp = fen.getRes(h[i]);
        val[h[i]] = tmp + a[i];
        res = max(res, val[h[i]]);
        fen.add(h[i], val[h[i]]);
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 5632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

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

int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    int max_l=-1;
    int p_max = 0;
    REP(i,n){
      int p,d1,d2;
      cin>>p>>d1>>d2;
      if(d1+d2>max_l){
        max_l = d1+d2;
        p_max = p;
      }
    }
    printf("%d %d\n",p_max,max_l);
  }

  return 0;
}

Measured memory_bytes: 872
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
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 main()
{
    string s;
    cin >> s;

    bool ok = false;
    rep(i,3){
        if(s[i] == '7') ok = true; 
    }

    string ans;
    if(ok) ans = "Yes";
    else ans = "No";

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 3632
N, M, K = map(int, input().split())
a_books = list(map(int, input().split()))
b_books = list(map(int, input().split()))
a_time = 0
b_time = 0
a_times = [0 for _ in range(N+1)]
b_times = [0 for _ in range(M+1)]
for i, a in enumerate(a_books):
  a_time += a
  a_times[i+1] = a_time
  
for i, b in enumerate(b_books):
  b_time += b
  b_times[i+1] = b_time
  
result = 0
l = 0
for i in range(N+1):
  if l == M:
    break
  while(l <= M):
    if a_times[N-i] + b_times[l] <= K:
      result = max(result, N-i+l)
      l += 1
    else:
      break
print(result)

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

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

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

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

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, K, Q, A[100001];

int main() {
    int p[100001];
    cin >> N >> K >> Q;
    REP (i, N) {
        p[i] = K;
    }
    REP (i, Q) {
        cin >> A[i];
        A[i]--;
        p[A[i]]++;
    }
    REP (i, N) {
        p[i] -= Q;
        cout << ((p[i] > 0) ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <limits.h>
#include <iostream>
#define REP(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
const int inf=1<<30;
const int INF=INT_MAX;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
const int d[]={0,1,0,-1,0};//int nx=x+d[i],ny=y+d[i+1]

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  printf("%d\n", min(b/a, c));
  return 0;
}

Measured memory_bytes: 256
t0, t1 = map(int, input().split())
a0, a1 = map(int, input().split())
b0, b1 = map(int, input().split())
d0 = (a0 - b0) * t0
d1 = (a1 - b1) * t1
if d0 < 0:
    d0, d1 = -d0, -d1
if d0 + d1 == 0:
    print('infinity')
    exit()
if d0 + d1 > 0:
    print(0)
    exit()
q, r = d0 // (-(d0+d1)), d0 % (-(d0+d1))
if r == 0:
    print(2 * q)
else:
    print(2 * q + 1)


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

int N, X;

int main(){		
	int sum = 1;
	int pos = 0;
	scanf("%d%d", &N, &X);
	for(int i = 0; i < N; i++){
		int in;
		scanf("%d", &in);
		pos += in;
		if(pos <= X) sum++;
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 256
/*
 NOTE:
*/
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <stack>
#include <set>
#define MP make_pair
#define F first
#define S second
#define TIME (double)clock()/CLOCKS_PER_SEC
using namespace std;
typedef long long ll;

string s; 
int k;
string rk[11];
string hp[7];
int st = 0;


int main()
{
//	freopen("test.in", "r", stdin);
//	freopen("test.out", "w", stdout);
 	ios::sync_with_stdio(false);
	cin >> s >> k;
	for (int i = 1; i <= 10; i ++)
		rk[i] = (char)('z' + 1);
	for (int i = 0; i < s.size(); i ++) {
		string t = "";
		st = min(5, (int)(s.size() - i));
		for (int j = 1; j <= st; j ++)
			hp[j] = s.substr(i, j);
		sort(hp + 1, hp + st + 1);
		for (int j = 1; j <= 5; j ++)
			rk[j + 5] = (char)('z' + 1);
		for (int j = 1; j <= st; j ++)
			rk[j + 5] = hp[j];
		sort(rk + 1, rk + 10 + 1);
		for (int j = 10; j >= 2; j --)
			if (rk[j] == rk[j - 1])
				rk[j] = (char)('z' + 1);
		sort(rk + 1, rk + 10 + 1);
	}
	cout << rk[k] << endl;
	return 0;
}
/*
*/



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

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

        char[] c = cin.nextLine().toCharArray();
        int len = c.length;
        boolean ans = true;
        for(int i=1;i<=len;i++) {
            if(i % 2 == 0) { 
                if(c[i-1] == 'L' || c[i-1] == 'U' || c[i-1] == 'D') continue;
            }
            else {
                if(c[i-1] == 'R' || c[i-1] == 'U' || c[i-1] == 'D') continue;
            }
            ans = false;
            break;
        }

        cout.println(ans ? "Yes" : "No");
        cout.close();
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
int main(void){

	int A,B,C,X,Y,i,D;
	scanf("%d",&A);scanf("%d",&B);scanf("%d",&C);scanf("%d",&X);scanf("%d",&Y);
	
	if(X > Y){
	
		int pat1,pat2[1000001],pat3,D;
		if(A > 2*C){ 
			D = 2*C;
		}else{
			D = A;
		}
		
		int min;
		pat1 = B * Y + D * X; min = pat1;
		for(i = 0;i <  Y;i++){
			
			pat2[i] = B * i + 2 * C * (Y - i) + D * (X - Y + i);
			if( pat2[i] <= min){
				min = pat2[i];
			}
		
		}	
		pat3 = 2 * C * Y + D * (X - Y);
		if(pat3 <= min){
			min = pat3;
		}
		
		printf("%d",min);
		

		
			
	}else{
		int pat4,pat5[1000001],pat6,E;
		if(B > 2*C){ 
			D = 2*C;
		}else{
			D = B;
		}
		
		int min;
		pat4 = A * X + D * Y; min = pat4;
		for(i = 0;i <  X;i++){
			
			pat5[i] = A * i + 2 * C * (X - i) + D * (Y - X + i);
			if( pat5[i] <= min){
				min = pat5[i];
			}
		
		}	
		pat6 = 2 * C * X + D * (Y - X);
		if(pat6 <= min){
			min = pat6;
		}
		
		printf("%d",min);
	
	}
}

	

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

using namespace std;
typedef long long ll;

const int N = 200018;
const ll oo = 9e18;

ll x[N];
ll X;
int n;

ll mul(ll a, ll b){
	return a > oo / b ? oo : a * b;
}

ll add(ll a, ll b){
	return a > oo - b ? oo : a + b;
}
int main(){

	scanf("%d %lld", &n, &X);

	for(int i = 1; i <= n; i++) scanf("%lld", x+i);
	reverse(x+1,1 + x + n);
	ll psum[N];
	partial_sum(x+1, x + 1 + n, psum+1);
	
	ll ans = 1e18;
	for(int k = 1; k <= n; k++){
		int j = 1;
		ll sum = 0;
		int i;
		for(i = k; i <= n; i += k){
			if(j == 1)
				sum = add(sum, (psum[i] - psum[i - k]) * 5);
			else
				sum = add(sum, mul(psum[i] - psum[i - k] , (2*j + 1)));
			j++;
		}
		if(i - k < n){
			sum = add(sum, mul(psum[n] - psum[i - k] , (2*j + 1)));
		}
		ans = min(ans, sum + k * X);
	}
	printf("%lld\n", ans + X * n);
}


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

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

using namespace std;

bool nexts(string& str)
{
	bool f=true;
	rep(i, str.size()){
		if (str[i] != '7'){
			f = false;
			break;
		}
	}
	if (f) return false;
	str[str.size()-1] += 2;
	for(int i=str.size()-1; str[i] == '9'; i--){
		str[i] = '3';
		str[i-1] += 2;
	}
	return true;
}

bool find753(string& str){
	bool ret, f7=false, f5=false, f3=false;
	rep(i, str.size()){
		if (str[i] == '7') f7 = true;
		if (str[i] == '5') f5 = true;
		if (str[i] == '3') f3 = true;
	}
	return f7*f5*f3;
}

int main()
{
	bool bf = false;
	ll n, ans=0;
	cin >> n;
	for(int i=3;bf==false;i++){
		string s;
		rep(j, i) s.push_back('3');
		while(nexts(s)){
			if (stoll(s) > n){
				bf = true;
				break;
			}
			if (find753(s)){
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main extends App {
  def replace(i:Char) = i match {
    case '4' => '5'
    case '5' => '7'
    case '6' => '8'
    case '7' => '9'
    case x => x
  }

  Iterator.continually(readInt).takeWhile( _ != 0 ).foreach { n=>
    println("%o".format(n).map{replace})
  }
}

Measured memory_bytes: 101900
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

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

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

typedef long long LL;
static LL INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;	
	LL a = 0, b = 0 ,c  = 0;
	for(int i=0; i<S.size(); i++){
		switch(S[i]){
			case 'a' :
				a++; break;
			case 'b' :
				b++; break;
			case 'c' :
				c++; break;
			default:
				break;
		}
	}
	LL u = min(a, min(b, c));
	LL v = max(a, max(b, c));
	if(v - u <= 1){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 3760
#include <cstdio>
#include <cstring>
int n,a[200001],tot;
int main()
{
	scanf("%d",&n);for(int i=1;i<=n;++i)scanf("%d",a+i),tot^=a[i];
	for(int i=1;i<=n;++i)a[i]^=tot;for(int i=1;i<=n;++i)printf("%d ",a[i]);putchar(10);return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  for (ll i = 1; i <= N; ++i) {
    ll ans = 0;
    for (ll x = 1; x * x <= i; ++x) {
      for (ll y = x; y * y <= i; ++y) {
        for (ll z = y; z * z <= i; ++z) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z) {
              ans += 1;
            }
            else if (x == y || y == z || z == x) {
              ans += 3;
            }
            else {
              ans += 6;
            }
          }
        }
      }
    }
    cout << ans << "\n";
  }
}


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

using namespace std;

int main()
{
    int n, k, mod = 1e9 + 7;
    cin >> n >> k;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    long long ans = 1;
    int l = 0, r = n - 1, sign = 1;
    if (k % 2 == 1)
    {
        ans = a[r];
        r--;
        if (ans < 0) sign = -1;
        k--;
    }
    while (k)
    {
        long long x = (a[l] * 1ll * a[l + 1]), y = (a[r - 1] * 1ll * a[r]);
        if (sign == 1)
        {
            if (x < y)
            {
                ans = y % mod * ans % mod;
                r -= 2;
            }
            else {
                ans = x % mod * ans % mod;
                l += 2;
            }
        }
        else {
            if (x > y)
            {
                ans = y % mod * ans % mod;
                r -= 2;
            }
            else {
                ans = x % mod * ans % mod;
                l += 2;
            }
        }
        k -= 2;
    }
    cout << (ans + mod) % mod << endl;
}

Measured memory_bytes: 4020
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    string s;
    cin >> s;
    if(s[1]=='B')
        s[1]='R';
    else s[1]='B';
    cout << s;
    return 0;
}

Measured memory_bytes: 3624
kosu, aji = map(int, input().split())
mikaku = []
for k in range(1, kosu + 1):
  mikaku.append(k + aji - 1)
mikaku_dash = [abs(m) for m in mikaku]
point = mikaku_dash.index(min(mikaku_dash))
mikaku.remove(mikaku[point])
print(sum(mikaku))

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string.h>
#define DP(a,b,c,d) ((dpn[a][b][c][d]<<16)+(dpm[a][b][c][d]))
using namespace std;

int sum[32][32][33][33];
int dpn[32][32][33][33];
int dpm[32][32][33][33];
int S;

void dp(int X,int Y,int W,int H){
	int w,h;
	if(sum[X][Y][W][H]<S) return;
	dpn[X][Y][W][H] = 1;
	dpm[X][Y][W][H] = sum[X][Y][W][H]-S;
//	if(sum[X][Y][W][H]<2*S) return;
	for(h=1;h<H;h++){
		if(dpn[X][Y][W][h] && dpn[X][Y+h][W][H-h])
//			printf("dp(%d,%d,%d,%d) %d<%d+%d\n",X,Y,W,H,DP(X,Y,W,H), DP(X,Y,W,h), DP(X,Y+h,W,H-h));
			if(DP(X,Y,W,H) < DP(X,Y,W,h) + DP(X,Y+h,W,H-h) - max(dpm[X][Y][W][h],dpm[X][Y+h][W][H-h])){
				dpn[X][Y][W][H] = dpn[X][Y][W][h]+dpn[X][Y+h][W][H-h];
				dpm[X][Y][W][H] = min(dpm[X][Y][W][h],dpm[X][Y+h][W][H-h]);
			}
	}
	for(w=1;w<W;w++){
		if(dpn[X][Y][w][H] && dpn[X+w][Y][W-w][H])
//			printf("dp(%d,%d,%d,%d) %d<%d+%d\n",X,Y,W,H,DP(X,Y,W,H), DP(X,Y,w,H), DP(X+w,Y,W-w,H));
			if(DP(X,Y,W,H) < DP(X,Y,w,H) + DP(X+w,Y,W-w,H) - max(dpm[X][Y][w][H],dpm[X+w][Y][W-w][H])){
				dpn[X][Y][W][H] = dpn[X][Y][w][H]+dpn[X+w][Y][W-w][H];
				dpm[X][Y][W][H] = min(dpm[X][Y][w][H],dpm[X+w][Y][W-w][H]);
			}
	}
}

int main(){
	int i,j,H,W,x,y,h,w,s;
	while(cin>>H>>W>>s,H){
		memset(sum, 0, sizeof(sum));
		memset(dpn, 0, sizeof(dpn));
		memset(dpm, 0, sizeof(dpm));
		for(i=0;i<H;i++)
			for(j=0;j<W;j++)
				cin>>sum[j][i][1][1];
		for(h=1;h<=H;h++)
			for(w=1;w<=W;w++)
				for(y=0;y<=H-h;y++)
					for(x=0;x<=W-w;x++)
						if(w !=1)sum[x][y][w][h]=sum[x][y][w-1][h]+sum[x+w-1][y][1][h];
						else if(h!=1)sum[x][y][w][h]=sum[x][y][w][h-1]+sum[x][y+h-1][w][1];
		S=sum[0][0][W][H] - s;
//		cout<<"S="<<S<<endl;
		for(h=1;h<=H;h++)
			for(w=1;w<=W;w++)
				for(y=0;y<=H-h;y++)
					for(x=0;x<=W-w;x++)
						dp(x,y,w,h);
//		for(h=1;h<=H;h++)
//			for(w=1;w<=W;w++)
//				for(y=0;y<=H-h;y++)
//					for(x=0;x<=W-w;x++)
//						printf("(%d,%d) %d*%d = %d,%d,%d\n",x,y,w,h,sum[x][y][w][h],dpn[x][y][w][h],dpm[x][y][w][h]);
		
		cout<<dpn[0][0][W][H]<<' '<<dpm[0][0][W][H]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int charToInt(char c)
{
	char zero_num = '0';
	return (int)c - (int)zero_num;
}

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

	vec_int x(N);
	rep(i, N) cin >> x.at(i);

	ll DP[N+1][N+1][N*A+1];
	rep(i, N+1){
		rep(j, N+1){
			rep(k, N * A+1){
				DP[i][j][k] = 0;
			}
		}
	}
	DP[0][0][0] = 1;
	for(int i=1;i<N+1;i++){
		for(int j=0;j<N+1;j++){
			for(int k=0;k<N*A+1;k++){
				if(j>0 && k-x[i-1]>=0){
					DP[i][j][k] = DP[i-1][j][k] + DP[i-1][j-1][k-x[i-1]];
				}else{
					DP[i][j][k] = DP[i-1][j][k];
				}
			}
		}
	}

/*
	for(int i=0;i<=N*A;i++){
		cout<<"0 "<<i<<" "<<DP[0][0][i]<<endl;
	}
	for(int i=0;i<=N*A;i++){
		cout<<"1 0 "<<i<<" "<<DP[1][0][i]<<endl;
	}
	for(int i=0;i<=N*A;i++){
		cout<<"1 1 "<<i<<" "<<DP[1][1][i]<<endl;
	}
	for(int i=0;i<=N*A;i++){
		cout<<"2 0 "<<i<<" "<<DP[2][0][i]<<endl;
	}
	for(int i=0;i<=N*A;i++){
		cout<<"2 1 "<<i<<" "<<DP[2][1][i]<<endl;
	}
	for(int i=0;i<=N*A;i++){
		cout<<"2 2 "<<i<<" "<<DP[2][2][i]<<endl;
	}
	*/



	ll tot_num = 0;
	for(int i=1;i<=N;i++){
		tot_num += DP[N][i][A*i];
	//	cout<<tot_num<<endl;
	}
	cout<<tot_num<<endl;





	return 0;
}

Measured memory_bytes: 51072
import static java.lang.System.out;
import java.util.Scanner;
 
 
public class Main {
    public static void main(String...args) {
 
        int S = new Scanner(System.in).nextInt();
        int timer = (60 * 60);
        int h = S / timer;
        int m = S % timer / 60;
        int s = S % timer % 60;
        out.println(h + ":" + m + ":" + s);
    }
 
 
}

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

#define int long long


signed main(){
	
	int k,t;
	cin>>k>>t;
	vector<int>v;
	for(int i=0;i<t;i++){
		int t;
		cin>>t;
		v.push_back(t);
	}
	sort(v.begin(),v.end());
	int sum=1;
	for(int i=0;i<v.size();i++){
		if(i+1==v.size()){
			if(v[i]<=sum)cout<<0<<endl;
			else cout<<v[i]-sum<<endl;
		}
		else{
			sum+=v[i];
		}
	}
	
	return 0;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i=2;i*i<=n;++i) {
        while (n%i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

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

    auto tmp = prime_factor(N);
    ll ans = 0;
    for (auto & t : tmp) {
        ll cur = 1;
        while (t.second - cur >= 0) {
            ans++;
            t.second -= cur;
            cur++;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 3632
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

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

const int N = 800 + 10, inf = 1e9 + 20;
int n, m, k;
string s[N];

int sx, sy;

int ans = inf;
int dist[N][N];
queue <pii> que;

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

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

	cin >> n >> m >> k;
	
	for (int i = 0; i < n; i++) cin >> s[i];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (s[i][j] == 'S')
			{
				sx = i;
				sy = j;
			}

	memset(dist, 63, sizeof dist);
	dist[sx][sy] = 0;
	que.push({sx, sy});

	while (_sz(que))
	{
		int vx = que.front().F, vy = que.front().S;
		que.pop();

		if (!vx || vx == n - 1 || !vy || vy == m - 1)
			return cout << "1\n", 0;

		int res = min({vx, n - 1 - vx, vy, m - 1 - vy});

		ans = min(ans, 1 + (res + k - 1) / k);

		if (dist[vx][vy] == k) continue;

		for (int i = 0; i < 4; i++)
		{
			int ux = vx + dx[i], uy = vy + dy[i];

			if (s[ux][uy] != '#' && dist[vx][vy] + 1 < dist[ux][uy])
			{
				dist[ux][uy] = dist[vx][vy] + 1;
				que.push({ux, uy});
			}
		}
	}

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


Measured memory_bytes: 3584
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

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

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

int main() {
	int n;
	cin >> n;
	VI a(n);
	rep(i, n) cin >> a[i];

	int odd = 0, even = 0;
	rep(i, n) {
		if (a[i] % 2 == 0) even++;
		else odd++;
	}

	if (odd % 2 == 0) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
} 



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

const int INF = 1001001001;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n, 0);
	for (int i = 1; i < n; i++) {
		int x;
		cin >> x; x--;
		a.at(x)++;
	}
	rep(i,n) cout << a.at(i) << endl;
}


Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int k, s;
    cin >> k >> s;
    int x, y, z;
    int ans = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            //for(int t = 0; t <= k; t++){
                if(0 <= s - i - j && s - i - j <= k ) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	char str[101][101];
	int h, w,i,j;
	scanf("%d%d", &h, &w);
	for (i = 0; i < h; i++)
	{
		scanf("%s", &str[i]);
	}
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			printf("%c", str[i][j]);
		}
		printf("\n");
		for (j = 0; j < w; j++)
		{
			printf("%c", str[i][j]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 256
a=int(input())
b=list(map(int,input().split()))
c=[0,0,0]
ans=1
mod=1000000007
for i in b:
  d=0
  for j in c:
    if i==j:
      d+=1
  if d==0:
    ans = 0
    break
  else:
    ans=ans*d%mod
    for j in range(3):
      if i==c[j]:
        c[j]+=1
        break
print(ans)

Measured memory_bytes: 53044
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(),a.end(),greater<>());
    int alice = 0,bob = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0) alice += a[i];
        else bob += a[i];
    }
    cout << alice - bob << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// typedef pair<ll,ll> Pair;
// ll mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,c,i,j,k,temp,temp2,n,m,sum=0;
    // string a,b,tem;
    map <ll,ll> aa;
    for(i=0;i<9;i++){
        cin >> temp;
        aa.insert(make_pair(temp,i));
    }
    ll a[9]={0};
    cin >>n;
    for(i=0;i<n;i++){
        cin >> temp;
        if(aa.find(temp)!=aa.end()){
            a[aa[temp]]=1;
        }
    }
    for(i=0;i<3;i++){
        if(a[i]==1&&a[i+3]==1&&a[i+6]==1){
            cout << "Yes";
            return 0;
        }
        if(a[3*i]==1&&a[3*i+1]==1&&a[3*i+2]==1){
            cout << "Yes";
            return 0;
        }
    }
    if(a[0]==1&&a[4]==1&&a[8]==1){
            cout << "Yes";
            return 0;
    }
    if(a[2]==1&&a[4]==1&&a[6]==1){
            cout << "Yes";
            return 0;
    }
        cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}
/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*ここから*/
int main() {
    char c1,c2;
    cin >> c1;
    for(int i=0;i<3;i++){
        cin >> c2;
        if(c1==c2){
            cout << "Bad" << endl;
            exit(0);
        }else{
            c1 = c2;
        }
    }
    cout << "Good" << endl;
}

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

int main(){
  int n;
  cin >> n ;
  int m = n;
  int div = 0;
  while (n>0){
    div += n%10;
    n = n/10;
   }
  cout << (m%div==0 ? "Yes":"No") << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, W = map(int, input().split())
w = [0] * N
v = [0] * N

for i in range(N):
    w[i], v[i] = map(int, input().split())

#dp[i][j]...(i + 1)番目までの品物を考慮し，価値の合計がjとなるときの重さの合計
V = (10 ** 3) * N + 5
Inf = 10 ** 18
dp = [[Inf] * V for _ in range(N)]

#for i in range(v[0], V):
    #dp[0][i] = w[0]
dp[0][0] = 0
dp[0][v[0]] = w[0]

for i in range(1, N):
    for j in range(V):
        if j >= v[i]:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i])
        else:
            dp[i][j] = dp[i - 1][j]

ans = 0

for j in range(V):
    if dp[N - 1][j] <= W and j > ans:
        ans = j

print(ans)


Measured memory_bytes: 119660
#include <stdio.h>
#include <inttypes.h>

#define MAX 600000

char S[MAX];
int wariate[MAX];
int fromCount = 0;
int from[MAX];

int main(void) {
	int n, i;
	uint64_t sum;

	if (fgets(S, sizeof(S), stdin) == NULL) return 1;
	for (n = 0; S[n] != '\0' && S[n] != '\n'; n++);

	if (S[0] == '<') from[fromCount++] = 0;
	for (i = 1; i < n; i++) {
		if (S[i - 1] == '>' && S[i] == '<') from[fromCount++] = i;
	}
	if (S[n - 1] == '>') from[fromCount++] = n;

	for (i = 0; i < fromCount; i++) {
		int j;
		int youso = 0;
		for (j = from[i]; j >= 0; j--) {
			if (wariate[j] < youso) wariate[j] = youso;
			youso++;
			if (j > 0 && S[j - 1] != '>') break;
		}
		youso = 0;
		for (j = from[i]; j <= n; j++) {
			if (wariate[j] < youso) wariate[j] = youso;
			youso++;
			if (j < n && S[j] != '<') break;
		}
	}

	sum = 0;
	for (i = 0; i <= n; i++) {
		sum += wariate[i];
	}
	printf("%" PRIu64 "\n", sum);

	return 0;
}


Measured memory_bytes: 4608
import std.stdio, std.bigint, std.array;

void main()
{
    string a, b, l;
    loop:
    while(readf("%s+%s=%s\n", &a, &b, &l))
    {
        foreach(char c; '0' .. '9' + 1)
        {
            auto cantputzero = (string s) => s.length > 1 && s[0] == 'X';
            if(c == '0' && (cantputzero(a) || cantputzero(b) || cantputzero(l))) continue;
            if(a.replace("X", [c]).BigInt + b.replace("X", [c]).BigInt == l.replace("X", [c]).BigInt)
            {
                c.writeln;
                continue loop;
            }
        }
        "NA".writeln;
    }
}

Measured memory_bytes: 1252
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <numeric>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
constexpr long long int MOD = 1000000007LL;

int main() {
	int n; std::cin >> n;
	std::vector<long long int> factorial(n + 1, 1);
	auto div = factorial;
	auto inverse = factorial;
	for (auto i = 2; i < factorial.size(); ++i) {
		factorial[i] = i * factorial[i - 1] % MOD;
		div[i] = (MOD - MOD / i) * div[MOD % i] % MOD;
		inverse[i] = div[i] * inverse[i - 1] % MOD;
	}
	const auto combination = [&factorial, &inverse](const int n, const int r) {return factorial[n] * inverse[n - r] % MOD * inverse[r] % MOD; };
	long long int result = 0;
	for (auto len = 1; len * 3 <= n; ++len) {
		result += combination(n - len * 3 + len - 1, len - 1);
		result %= MOD;
	}
	std::cout << result << '\n';
}

Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main(){
	for (int a[4],b[4]; cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]; ) {
		int h = 0, v = 0;
		rep(i, 4) h += a[i] == b[i];
		rep(i, 4) rep(j, 4) if (i != j) v += a[i] == b[j];
		cout << h << ' ' << v << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
c=str(input())
cl=list(c)
for i in range(len(cl)):
    if cl[i].islower():
        cl[i]=cl[i].upper()
        print(cl[i],end='')
    elif cl[i].isupper():
        cl[i] =cl[i].lower()
        print(cl[i], end='')
    elif not cl[i].isalpha():
        print(cl[i], end='')
print('')

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

int main ()
{
  int X, N;
  cin >> X;
  cin >> N;
  set<int> p;


  for (auto i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    p.insert(tmp);
  }
  for (auto i = 0; i < 100; i++) {
    if (p.find(X - i) == p.end()) {
      cout << (X - i) << '\n';
      return 0;
    }
    if (p.find(X + i) == p.end()) {
      cout << (X + i) << '\n';
      return 0;
    }
  }
  return 0;
}


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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}
ll ALL_SNU_XOR(ll N, vector<ll> A)
{
    ll ret=0;
    for(ll i=0;i<N;i++)
    {
        ret = (ret ^ A[i]);
    }
    return ret;
}

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

    vector<ll> A(N);
    ALLIN1_NUMBER(A);

    ll all_snu_xor = ALL_SNU_XOR(N,A);

    vector<ll> ans(N);

    for(ll i=0;i<N;i++)
    {
        ans[i] = (all_snu_xor ^ A[i]);
    }

    ALLOUT_NUMBER(ans);

    return 0;
}

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

int main(void){
    int n;
    cin>>n;
    vector<int> l(n);
    rep(i,n)cin>>l[i];
    int ans=0,a,sum;
    rep(i,n-2){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                a=max({l[i],l[j],l[k]});
                sum=l[i]+l[j]+l[k];
                if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i] && sum-2*a>0)ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
// In the name of Allah the Most Merciful.

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

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

    int n;
    cin >> n;
    multiset<int>st;
    for(int i=0;i<n;i++){
        int in;
        cin >> in;
        if(st.size()==0)st.insert(-in);
        else{
            auto it = st.upper_bound(-in);
            if(it==st.end()){
                st.insert(-in);
            }
            else{
                st.erase(it);
                st.insert(-in);
            }
        }
    }
    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
long long read(){
    long long ret=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-f;ch=getchar();}
    while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    return ret*f;
}
int a[10];
int main(){
//	ios::sync_with_stdio(false);
    int n;
    n=read();
    int t=n;
    int len=0;
    while(t){
    	t/=10;
    	++len;
	}
	int ans=0;
	for(int i=1;i<len;i+=2){
		ans*=100;
		ans+=9;
	}
	if(len&1)
	ans+=(n-pow(10,len-1)+1);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
vi dy = { 0,0,1,-1 };
vi dx = { 1,-1,0,0 };
constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;



int main() {
	int n;
	cin >> n;
	vi gap(13, 0);
	rep(i, n) {
		int d;
		cin >> d;
		gap[d]++;
	}
	bool same = false;
	rep(i, 13)if (gap[i] >= 3)same = true;
	if (gap[0] > 0||gap[12]>=2)same = true;

	if (same) {
		cout << 0 << endl;
		return 0;
	}

	vi c = { 0,24 };
	bool mns = false;
	rep1(i, 11) {
		if (gap[i] == 0)continue;
		if (gap[i] == 1) {
			if (!mns) { c.push_back(i); mns = true; }
			else { c.push_back(24-i); mns = false; }
		}
		if (gap[i] == 2) {
			c.push_back(i);
			c.push_back(24-i);
		}
	}
	if (gap[12] == 1) {
		c.push_back(12);
	}

	sort(all(c));

	int ans = 12;

	rep(i, c.size() - 1) ans = min(ans, c[i + 1] - c[i]);
	
	cout << ans << endl;

}


Measured memory_bytes: 256
#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() {
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  int min_ans=1000000000;
  rep(i,n-k+1){
    min_ans=min(min_ans,h[k+i-1]-h[i]);
  }
  cout<<min_ans<<endl;
}

Measured memory_bytes: 640