akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

string a,b="snuke";

int main(){
	int n,m; cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=0;j<m;j++){
			cin>>a;
			if(a==b){
				cout<<char(j+'A')<<i<<endl;
				return 0;
			}
		}
	return 0;
}

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

 
using namespace std;
 
int main() {
    int n,k;
    int num = 1;
    cin >> n >> k;
 
    for(int i = 0; i < n; i++){
        if(num < k) num *= 2;
        else num += k;
    }
 
    cout << num << endl;
};

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

int main()
{
    string s;
    string ans;
    cin >> s;
    ans.push_back(s[0]);

    for( int i = 0; i < (1<<3); ++i )
    {
        int sum = s[0] - '0';
        for( int j = 0; j < 3; ++j )
        {
            if( i & (1<<j) )
            {
                sum = sum + (s[j+1] - '0');
            }
            else
            {
                sum = sum - (s[j+1] - '0');
            }

            if( sum == 7 )
            {
                for( int z = 0; z < 3; z++ )
                {
                    if( i & (1<<z) )
                    {
                        ans.push_back('+');
                    }
                    else{
                        ans.push_back('-');
                    }
                    ans.push_back(s[z+1]);
                }
                ans.push_back('=');
                ans.push_back('7');
                cout << ans << endl;
                return 0;
            }
        }
    }
    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++)

int main() {
  int N, T, A, x;
  cin >> N >> T >> A;
  vector<double> diff(N);
  rep(i, N) {
    int H;
    cin >> H;
    diff[i] = abs(T-H*0.006-A);
  }

  int res = min_element(diff.begin(), diff.end()) - diff.begin()+1;
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3588
N = int(input())
Ws = list(map(int, input().split()))
sums = []
s = 0
for t in range(N):
  s += Ws[t]
  sums.append(s)
#print(sums)
total = sums[N-1]
diffs = [abs(total-s-s) for s in sums]
#print(diffs)
print(min(diffs))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+5;
    int n,m;
    queue<int> num[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<n;j++){
            cin>>m;
            num[i].push(m);
        }
    int ans=0;
    int i;
    int vis=0;
    int vv[maxn];
    for(i=1;;i++){
        int flag=0;
        memset(vv,0,sizeof(vv));
        for(int j=1;j<=n;j++){
            if(num[j].empty()) continue;
            int p=num[j].front();
            if(num[p].front()==j&&!vv[j]&&!vv[p]){
                num[j].pop();
                num[p].pop();
                vv[j]=1;
                vv[p]=1;
                //cout<<j<<' '<<p<<endl;
                ans++;
                flag=1;
            }
        }
        if(!flag) {vis=1;break;}
        if(ans==n*(n-1)/2) break;
    }
    if(vis) cout<<-1<<endl;
    else cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}

vll ls(51), ps(51);

ll rec(ll n, ll x)
{
        if (n == 0) return (x <= 0 ? 0 : 1);
        else if (x <= 1 + ls[n-1]) return rec(n-1, x-1);
        else return ps[n-1] + 1 + rec(n-1, x-2-ls[n-1]);

        // else if (1 <= x and x <= 1 + ls[n-1]) return rec(n-1, x-1);

        // else if (x ==  2 + ls[n-1] ) return 1 + ps[n-1] + rec(n-1, x - 2 - ls[n-1]);

        // else if (2 + ls[n-1] <= x and x <= 2 + 2 * ls[n-1]) return 2*ps[n-1] + rec(n-1, x - 2 - ls[n-1]);

        // else return rec(n-1, x - 2 - 2 * ls[n-1]);
}

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

        ls[0] = ps[0] = 1;

        rep(i, 1, 51) {
                ls[i] = 2*ls[i-1] + 3;
                ps[i] = 2*ps[i-1] + 1;
        }

        ll ans = rec(N, X);
        cout << ans << endl;
}


Measured memory_bytes: 3644
N, M = [int(i) for i in input().split()]
a = [list(input()) for _ in range(N)]
b = [list(input()) for _ in range(M)]

flag = False

for i in range(N-M+1):
    for j in range(N-M+1):
        if b == [a[k+i][j:j+M] for k in range(M)]:
            flag = True

if flag:
    print('Yes')
else :
    print('No')

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n ;
    cin >> n ;
    vll a(n,0) ;
    REP(i,n){
        cin >> a[i] ;
    }
    ll ans = 0 ;
    ans += a[0]/2 ;
    a[0] %= 2 ;
    FOR(i,1,n){
        if(a[i-1]<=a[i]){
            ans += a[i-1] ;
            a[i] -= a[i-1] ;
        }
        ans += a[i]/2 ;
        a[i] %= 2 ;
    }
    cout << ans << endl ;
    

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
 
int main(void){
  char k[15];
  int i;
  scanf("%s",k);
  for(i=0; k[i]!='\0'; ++i);
  int j=0;
  
  for(i=0;k[i];i++) {
	if(k[i]=='o') {
	  j++;
	}
  }
  
  if(8<=15-i+j){
    printf("YES");
  }else{
    printf("NO");
  }
  
  
 
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int linearSearch(int);
int n,S[10001];
int main(){
  int i,q,count=0;
  int judge;
  int T[500];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);
  for(i=0;i<q;i++){
    judge=linearSearch(T[i]);
  if(judge >= 0)
    count++;
  }
  printf("%d\n",count);
  
  return 0;
}

int linearSearch(int key){
  int i=0;

  S[n]=key;
  while(S[i] != key)
    i++;
  if(i == n)
    return -5;
  return i;
}

Measured memory_bytes: 636
n, m = map(int, input().split())
H = list(map(int, input().split()))
G = [1]*n 

import sys

for i in range(m):
  a, b = map(int, sys.stdin.readline().rstrip().split())
  a -= 1
  b -= 1
  if H[a]>=H[b]:
    G[b] = 0
  if H[b]>=H[a]:
    G[a] = 0
  
print(sum(G))

Measured memory_bytes: 19948
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

static const int N = 3;
static const int N2 = 9;

struct Puzzle {
    int f[N2];
    int space;
    string path;

    bool operator < (const Puzzle &p) const {
        for (int i = 0; i < N2; i++) {
            if (f[i] == p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p) {
    for (int i = 0; i < N2; i++) 
        if (p.f[i] != (i + 1)) return false;
    return true;
}

string bfs(Puzzle s) {
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true;

    while (!Q.empty()) {
        u = Q.front(); Q.pop();
        if (isTarget(u)) return u.path;
        int sx = u.space / N;
        int sy = u.space % N;
        for (int r = 0; r < 4; r++) {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
            v = u;
            swap(v.f[u.space], v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if (!V[v]) {
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }
    return "unsolvable";
}

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    Puzzle in;
    for (int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            in.f[i] = N2;
            in.space = i;
        }
    }
    string ans = bfs(in);
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 30548
#include<cstdio>

int n;
int f[111][4][4][4];

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
};
modular_arithmetic ma;

int main() {
	scanf("%d", &n);
	for(int i=0;i<4;i++)
	for(int j=0;j<4;j++)
	for(int k=0;k<4;k++)
		f[2][i][j][k] = 1;
	f[2][0][2][1] = f[2][2][0][1] = f[2][0][1][2] = 0;
	
	for(int x=3;x<n;x++) {
		for(int i=0;i<4;i++)
		for(int j=0;j<4;j++)
		for(int k=0;k<4;k++)
		for(int cur=0;cur<4;cur++) {
			if (!f[x-1][i][j][k]) continue;
			if (j==0 && k==2 && cur==1) continue;
			if (j==0 && k==1 && cur==2) continue;
			if (i==0 && k==2 && cur==1) continue;
			if (i==0 && j==2 && cur==1) continue;
			if (j==2 && k==0 && cur==1) continue;
			f[x][j][k][cur] = ma.add(f[x][j][k][cur], f[x-1][i][j][k]);
		}
	}
	
	int ans = 0;
	for(int i=0;i<4;i++)
	for(int j=0;j<4;j++)
	for(int k=0;k<4;k++)
		ans = ma.add(ans, f[n-1][i][j][k]);
	printf("%d\n", ans);
	
	return 0;
}	


Measured memory_bytes: 128
N=int(input())
T,A=map(int,input().split())

H=[int(x) for x in input().split()]

ans=0
cnt=10**10

for i in range(N):
  temp = T-H[i]*0.006
  if abs(A-temp) < abs(A-cnt):
    ans=i
    cnt=temp
print(ans+1)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-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 main(){
  ll N,num=0;
  string X;
  cin>>N>>X;
  REP(i,N){
    if(X[i]=='1') num++;
  }
  
  ll P[N+1],Q[N+1],PP=0,QQ=0;
  P[0]=1;
  Q[0]=1;
  for(int i=1; i<=N; ++i){
    if(num>1) P[i]=P[i-1]*2%(num-1);
    Q[i]=Q[i-1]*2%(num+1);
    if(X[N-i]=='1'){
      if(num>1) PP+=P[i-1];
      QQ+=Q[i-1];
    }
    if(num>1) PP%=num-1;
    QQ%=num+1;
  }
  
  for(int i=0; i<N; ++i){
    ll cnt=num;
    if(X[i]=='1') cnt--;
    if(X[i]=='0') cnt++;
    if(cnt==0){
      co(0);
      continue;
    }
    
    ll L=0;
    if(cnt==num-1){
      if(X[i]=='1') L=PP-P[N-1-i];
      else L=PP+P[N-1-i];
      L%=num-1;
      if(L<0) L+=num-1;
    }
    else{
      if(X[i]=='1') L=QQ-Q[N-1-i];
      else L=QQ+Q[N-1-i];
      L%=num+1;
      if(L<0) L+=num+1;
    }
    if(L==0) co(1);
    else{
      ll ans=1;
      while(L>0){
        cnt=0;
        for(int j=0; j<30; ++j){
          if(L&(1<<j)) cnt++;
        }
        L%=cnt;
        ans++;
      }
      co(ans);
    }
  }
  
  return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

const int mod = 998244353;

const int maxn = 1e5 + 5;

string s;
int cnt[10]; // 0 : 'R', 1 : 'G', 2 : 'B', 3 : 'RG', 4 : 'RB', 5 : 'GB'

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    cin >> s;  
    int ans = 1;
    for(int i = 0;i < 3 * n;i++){
        if(s[i] == 'R'){
            if(cnt[5] > 0){
                ans = 1LL * ans * cnt[5] % mod;
                cnt[5]--;
            }else{
                if(cnt[1] > 0){
                    ans = 1LL * ans * cnt[1] % mod;
                    cnt[1]--;
                    cnt[3]++;
                }else{
                    if(cnt[2] > 0){
                        ans = 1LL * ans * cnt[2] % mod;
                        cnt[2]--;
                        cnt[4]++;
                    }else{
                        cnt[0]++;
                    }
                }
            } 
        }else if(s[i] == 'G'){
            if(cnt[4] > 0){
                ans = 1LL * ans * cnt[4] % mod;
                cnt[4]--;
            }else{
                if(cnt[0] > 0){
                    ans = 1LL * ans * cnt[0] % mod;
                    cnt[0]--;
                    cnt[3]++;
                }else{
                    if(cnt[2] > 0){
                        ans = 1LL * ans * cnt[2] % mod;
                        cnt[2]--;
                        cnt[5]++;
                    }else{
                        cnt[1]++;
                    }
                }
            } 
        }else{
            if(cnt[3] > 0){
                ans = 1LL * ans * cnt[3] % mod;
                cnt[3]--;
            }else{
                if(cnt[0] > 0){
                    ans = 1LL * ans * cnt[0] % mod;
                    cnt[0]--;
                    cnt[4]++;
                }else{
                    if(cnt[1] > 0){
                        ans = 1LL * ans * cnt[1] % mod;
                        cnt[1]--;
                        cnt[5]++;
                    }else{
                        cnt[2]++;
                    }
                }
            } 
        }
    }
    for(int i = 1;i <= n;i++){
        ans = 1LL * ans * i % mod;
    }
    cout << ans << endl;
    return 0;
}


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

void solve()
{
   int  m,n;
   cin>>n>>m;
   vector<int> v(n); int res= 0;
   for(int i=0; i<n; i++)
   {
       cin>>v[i];
       res += v[i];

   }
   int cnt=0;

   for(int i=0; i<n; i++)
   {
       if(v[i]>=(res+4*m-1)/(4*m))
       {
           cnt++;
       }
   }
   if(cnt>=m)
   {
       cout<<"Yes"<<endl;
       return;
   }
   cout<<"No"<<endl;
}
int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();

    }
return 0;
}


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

class Main{
    public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            int K = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
            int A = Integer.parseInt(tmp[0]);
            int B = Integer.parseInt(tmp[1]);

            int max = Math.max(A, B);
            int min = Math.min(A, B);
            int result = 0;

            for(int i = min; i <= max; i++){
              if((i%K) == 0){
                result = 1;
              }else{
                continue;
              }
            }

            if(result == 1){
              System.out.println("OK");
            }else{
              System.out.println("NG");
            }
        }
    }
}

Measured memory_bytes: 32592
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  string s;
  cin >> n >> s;

  int b = 0, w = 0;
  REP(i,n){
    if(s[i] == '.') w++;
  }

  int ans = w;
  REP(i,n){
    if(s[i] == '.') w--;
    else b++;
    ans = min(ans,b+w);
  }

  cout << ans + min(b,w)<< endl;

  return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int main(){
    int n,x,a;
    while(~scanf("%d%d%d",&n,&x,&a)){
        ll ans=0;
        if(a>x)
            ans+=a-x,a=x;
        while(--n){
            int b;
            scanf("%d",&b);
            if(a+b>x)
                ans+=a+b-x,a=x-a;
            else
                a=b;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3192
<?php
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));

$gcd[0] = $a[0];
for($i = 1; $i < $n; $i++) {
    $gcd[$i] = gcd($gcd[$i - 1], $a[$i]);
}
$gcd_rev[$n - 1] = $a[$n - 1];
for($i = $n - 2; $i >= 0; $i--) {
    $gcd_rev[$i] = gcd($gcd_rev[$i + 1], $a[$i]);
}
$max = 0;
for($i = 0; $i < $n; $i++) {
    $val = gcd($gcd[$i - 1] ?? $gcd_rev[$i + 1], $gcd_rev[$i + 1] ?? $gcd[$i - 1]);
    $max = max($max, $val);
}
echo $max . PHP_EOL;

// 最大公約数
function gcd($m, $n){
    if($n > $m) list($m, $n) = [$n, $m];

    if ($m % $n === 0) return $n;
    else return gcd($n, $m % $n);
}

Measured memory_bytes: 23280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long int;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = (ll)b*d;
    if(ans < a*c) ans = a*c;
    if(ans < a*d) ans = a*d;
    if(ans < b*c) ans = b*c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

vector<string> g_maze;
vector<vector<bool>> g_visited;
vector<int> g_dy = { -1, 0, 0, 1 };
vector<int> g_dx = { 0, -1, 1, 0 };
int g_h;
int g_w;

int main()
{
    int n, a; cin >> n >> a;
    cout << n*n - a << endl;
}

Measured memory_bytes: 256
using AtCoderBeginnerContest132.Questions;
using AtCoderBeginnerContest132.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest132.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var d = inputStream.ReadIntArray();
            Array.Sort(d);

            var abcLast = d[n / 2 - 1];
            var arcFirst = d[n / 2];

            yield return arcFirst - abcLast;
        }
    }
}


namespace AtCoderBeginnerContest132
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest132.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest132.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 19936
#include<iostream>
#include<cstdio>
using namespace std;
long long b,a,x;
long long dp[300][8000],ans;
int main()
{
    dp[0][0]=1;
    cin>>a>>b;
    for(int i=1;i<=a;i++)
	{
        cin>>x;
        for(int j=i;j>0;j--)
		{
            for(int k=a*b;k>=x;k--)
			{
                dp[j][k]+=dp[j-1][k-x];
            }
        }
    }
    for(int i=1;i<=a;i++)
	{
        ans+=dp[i][i*b];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3072
#include <cstdio>
int sg(int x, int y) {
  if (x < y) return 0;
  if (x % y == 0) return x / y;
  int v=x/y*y+x/y+1;
  v=(v/(x/y+1)+1)*(x/y+1)+x%(x/y+1); 
  if(v<x) return sg(v, y);
  else return sg(x - x / y - 1, y);
}
int main() {
  int n, ans = 0;
  scanf("%d", &n);
  while (n--) {
    int x, y; scanf("%d%d", &x, &y);
    ans ^= sg(x, y);
  }
  printf("%s", ans ? "Takahashi" : "Aoki");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
#define p(x) cout<<(x)<<endl

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

  int tmp = n;
  int hj = 0;
  while(tmp >= 1) {
    hj += tmp%10;
    tmp = tmp/10;
  }
  
  if (n%hj == 0) p("Yes");
  else p("No");
}


Measured memory_bytes: 256
from collections import deque


H, W = map(int, input().split())
CH, CW = map(int, input().split())
DH, DW = map(int, input().split())
S = ['#' * (W+4)] * 2
for i in range(H):
    S.append('##' + input() + '##')
S.append('#' * (W+4))
S.append('#' * (W+4))

CH += 2
CW += 2
DH += 2
DW += 2

dist = [[-1 for i in range(W + 4)] for j in range(H + 4)]
dist[CH - 1][CW - 1] = 0
q = deque()
q.append([CH, CW])

while len(q) != 0:
    current_pos = q.popleft()
    y = current_pos[0]
    x = current_pos[1]
    if (y, x) == (DH, DW):
        print(dist[DH - 1][DW - 1])
        exit()

    for i in range(-2, 3):
        for j in range(-2, 3):
            if i == j == 0:
                continue
            next_y = y + i
            next_x = x + j

            if S[next_y - 1][next_x - 1] == '#':
                continue
            if dist[next_y - 1][next_x - 1] == dist[y - 1][x - 1]:
                continue

            if dist[next_y - 1][next_x - 1] == -1 or dist[next_y - 1][next_x - 1] > dist[y - 1][x - 1]:
                if (i == 0 and j in (-1, 1)) or (j == 0 and i in (-1, 1)):
                    q.appendleft([next_y, next_x])
                    dist[next_y - 1][next_x - 1] = dist[y - 1][x - 1]
                else:
                    if dist[next_y - 1][next_x - 1] == -1:
                        q.append([next_y, next_x])
                        dist[next_y - 1][next_x - 1] = dist[y - 1][x - 1] + 1

print(-1)


Measured memory_bytes: 99476
#include <stdio.h>

int main(void){
    long int N, i, temp, ans;
    ans = 0;
    scanf("%ld",&N);
    for(i=1;i<N+1;++i){
        temp = N/i;
        ans += (1+temp)*temp*i/2;
    }
    printf("%ld\n",ans);
    return 0;
}

Measured memory_bytes: 1732
package main

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

func main() {
	H1, M1, H2, M2, K := ReadInt(), ReadInt(), ReadInt(), ReadInt(), ReadInt()
	fmt.Println(H2*60 + M2 - (H1*60 + M1) - K)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;
int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}
int fact(int n)
{
  if (n == 0)
    return 1;
  return n * fact(n - 1);
}
int main()
{
  string s;
  cin >> s;
  rep(i,s.size()){
  	if(s[i]==',')s[i]=' ';
  }
  cout <<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
int main(){
    int n;
    cin>>n;
    n=n%10;
    if(n==3){
        cout<<"bon";
    }
    else if(n==0||n==1||n==6||n==8){
        cout<<"pon";
    }
    else{
        cout<<"hon";
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}

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

//////////////////////////////////////////////////

const int mod = 1e9+7;

// combination c(n+10)
// c(n, k) => nCk
struct combination {
    const int max = 510000;
    vector<long long> fact, ifact, inv;
    combination() {
        fact.resize(max);
        ifact.resize(max);
        inv.resize(max);
        fact[0] = fact[1] = 1;
        ifact[0] = ifact[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < max; i++) {
            fact[i] = fact[i-1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod/i) % mod;
            ifact[i] = ifact[i-1] * inv[i] % mod;
        }
    }

    long long operator()(int n, int k) {
        if (n < k) return 0;
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
    }
};

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    combination c;

    rep(i,n) {
        ll cnt = c(i,k-1);
        ll mx = cnt*a[i]%mod, mn = cnt*a[n-i-1]%mod;
        ans = (ans+mx-mn) % mod;
        if (ans < 0) ans += mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string s;
  cin>>s;
  string k="";
  for(int i=0;i<5;i++){
    k += "hi";
    if(s==k){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


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

#define check cnt=0;for(j=0;j<6;j++)if(d1[j]==d2[j])cnt++;
#define r tmp=d2[1];d2[1]=d2[3];d2[3]=d2[4];d2[4]=d2[2];d2[2]=tmp;
#define y tmp=d2[0];d2[0]=d2[3];d2[3]=d2[5];d2[5]=d2[2];d2[2]=tmp;

int main(){
 int d1[6],d2[6],tmp,cnt,j,a=1,i,k;

 for(int i=0;i<6;i++){
  cin >> d1[i] ;
 }
 for(int i=0;i<6;i++){
  cin >> d2[i] ;
 }

 check
   if(cnt==6)a=0;

 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check
    if(cnt==6)break;
    r
   }
   check
   if(cnt==6)break;
   tmp=d2[0];
   d2[0]=d2[1];
   d2[1]=d2[5];
   d2[5]=d2[4];
   d2[4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  check
  if(cnt==6)break;
  y
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  check
  if(cnt==6)break;
  a=0;
 }

 if(cnt==6)cout << "Yes" << endl ;
 else cout << "No" << endl ;

 return 0;
}

Measured memory_bytes: 3092
#include <iostream>

bool f(std::string s) {
    
    int idx = s.size() - 1;
    while (idx >= 0) {
        if (idx >= 6 && s[idx - 6] == 'd' && s[idx - 5] == 'r' && s[idx - 4] == 'e' && s[idx - 3] == 'a' && s[idx - 2] == 'm' && s[idx - 1] == 'e' && s[idx] == 'r') {
            idx -= 7;
            continue;
        }
        if (idx >= 5 && s[idx - 5] == 'e' && s[idx - 4] == 'r' && s[idx - 3] == 'a' && s[idx - 2] == 's' && s[idx - 1] == 'e' && s[idx] == 'r') {
            idx -= 6;
            continue;
        }
        if (idx >= 4) {
            if (s[idx - 4] == 'd' && s[idx - 3] == 'r' && s[idx - 2] == 'e' && s[idx - 1] == 'a' && s[idx] == 'm') {
                idx -= 5;
                continue;
            }
            if (s[idx - 4] == 'e' && s[idx - 3] == 'r' && s[idx - 2] == 'a' && s[idx - 1] == 's' && s[idx] == 'e') {
                idx -= 5;
                continue;
            }
        }

        return false;
    }

    return true;
}

int main() {

    std::string s;
    std::cin >> s;

    if (f(s)) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}


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

long long N, A, B, C, D;
int main() {
    cin >> N >> A >> B >> C >> D;
    A *= 2, B *= 2, C *= 2, D *= 2;
    --N;
    long long diff = abs(A - B);
    long long gap = (C + D) / 2;
    long long center = 0;
    if (N & 1) center = gap;
    long long radius = (D - C) / 2 * N;

    bool ok = false;
    for (int i = 0; i < N*2; ++i) {
        long long left = center - radius, right = center + radius;
        if (right > D * N) break;
        if (left <= diff && diff <= right) ok = true;
        center += gap * 2;
    }
    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m;

int main()
{
	cin>>n>>m;
	int a=m-n*2;
	if(m%2==1||m<0)
	{
		puts("No");
		return 0;
	}
	int b=a/2,c=n-b;
	if(b<0||c<0) puts("No");
	else puts("Yes");
	return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
    ll N,x;
    cin>>N>>x;
    vector<ll> v(N);
    for(ll i = 0; i < N; i++) cin>>v[i];
    ll ans = 0;
    if(v[0]>x){
        ans+=v[0]-x;
        v[0]=x;
    }
    for(ll i = 0; i < N-1; i++){
        if(v[i]+v[i+1]>x){
            ll t = x-v[i];
            ans+=v[i+1]-t;
            v[i+1]=t;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
a,b,c,d,e,f=map(int,input().split())
water=[]
suguar=[]
for i in range((f+1)//100):
    for j in range((f+1)//100):
        x=100*i*a+100*j*b
        if 1<=x<=f:
            water.append(x)
for i in range(f+1):
    for j in range(f+1):
        y=c*i+d*j
        if y<=f:
            suguar.append(y)
ans=0
for i in water:
    for j in suguar:
        total=i+j
        if total<=f:
            if j<=i//100*e:
                con=100*j/(i+j)
                if ans<=con:
                    ans=con
                    ans_2=total
                    ans_3=j
print(ans_2,ans_3)


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

int n;
int parent[100005];
int depth[100005];
vector < int > child[100005];

void searchDepth(int v, int d = 0)
{
        if ( depth[v] != -1 ) return;
        depth[v] = d;
        for ( auto x : child[v] ) {
                searchDepth(x, d + 1);
        }
}

int main()
{

        fill_n(parent, 100005, -1);
        fill_n(depth, 100005, -1);      

        cin >> n;
        for ( int i = 0; i < n; i++ ) {
                int id, k;
                cin >> id >> k;
                for ( int j = 0; j < k; j++ ) {
                        int c;
                        cin >> c;
                        parent[c] = id;
                        child[id].push_back(c);
                }
        }
        
        for ( int i = 0; i < n; i++ ) {
                if ( parent[i] == -1 ) {
                        searchDepth(i);
                }
        }

        for ( int i = 0; i < n; i++ ) {
                cout << "node " << i << ": parent = " << parent[i];
                cout << ", depth = " << depth[i] << ", ";
                if ( parent[i] == -1 ) cout << "root, ";
                else if ( child[i].size() == 0 ) cout << "leaf, ";
                else cout << "internal node, ";
                cout << "[";
                for ( int j = 0; j < child[i].size(); j++ ) {
                        cout << child[i][j];
                        if ( j < child[i].size() - 1 ) cout << ", ";
                }
                cout << "]" << endl;
        }
                
        return ( 0 );
}



Measured memory_bytes: 6920
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
const int MAX = 5050;
using M = Mint<int>;
M dp[MAX][MAX]={};
M sm[MAX][MAX]={};

M ac[MAX]={};
M query(int x,int y){
  if(x<=0) x=0;
  return ac[y]-ac[x];
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n,a,b;
  cin>>n>>a>>b;
  if(!(a<=b)) swap(a,b);

  M ans{0};
  dp[0][0]=1;
  sm[0][0]=1;
  ac[1]=1;
  for(int i=1;i<=n;i++){
    // [i-a, i-1)
    dp[i][1]+=query(i-a,i-1);

    for(int j=0;j<=i;j++){
      // put '1'
      if(i>=1 and j>=1)
        dp[i][j]+=dp[i-1][j-1];

      // put '0'*k '1'
      if(i>=(a+1) and j>=(a+1))
        dp[i][j]+=sm[i-(a+1)][j-(a+1)];
    }

    ac[i+1]=ac[i];
    for(int j=0;j<b;j++){
      ac[i+1]+=dp[i][j];

      // put '0' * (n-i)
      if(i<n and (((n-i)<a) or (j+(n-i)<b))) ans+=dp[i][j];

      // accumulate
      sm[i][j]=((i-1>=0 and j-1>=0)?sm[i-1][j-1]:M(0))+dp[i][j];
    }

    // reset
    for(int j=b;j<=n;j++) dp[i][j]=0;
  }

  for(int j=0;j<b;j++)
    ans+=dp[n][j];

  cout<<M(2).pow(n)-ans<<newl;
  return 0;
}


Measured memory_bytes: 202948
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int N;
    cin >> N;
    int h[110];
    REP(i,N) cin >> h[i];
    int ans = 0, cnt = 0;

    for(int i = 0; i < N;i++){
        if(h[i] > cnt){
            ans += h[i] - cnt;
            cnt = h[i];
        }
        else if(h[i] <= cnt){
            cnt = h[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
#define int long long
int n;
int a[N];
int ans;
int last[N];
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

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

    last[1] = 0;
    for (int i = 2; i <= n; ++i)
    {
        last[i] = i - 1;
        if (a[i] == 0)
        {
            if (a[i - 1] == 0) last[i] = last[i - 1];
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        int cursum = 0;
        int curxor = 0;
        int j = i;
        while (j != 0)
        {
            cursum += a[j];
            curxor ^= a[j];
            if (cursum == curxor) ans += j - last[j];
            else break;
            j = last[j];

        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3328
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
distance = X[-1] - X[0]
X_dist = []
for i in range(M-1):
    X_dist.append(X[i+1]-X[i])
X_dist.sort(reverse = True)
print(distance - sum(X_dist[:N-1]))


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

int main()
{
  int w;
  int s;
  cin>>w;
  while(w!=-1){
    s=1150;
    if(w>30)
      s=s+10*125+10*140+(w-30)*160;
    else if(w>20)
      s=s+10*125+(w-20)*140;
    else if(w>10)
      s=s+(w-10)*125;
    s=4280-s;
    cout<<s<<'\n';
    cin>>w;
  }
  return(0);
}



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

int main() {
  int s;
  cin >> s;
  // 100
  //cout << s/100 << endl;
  // 10
  //cout << (s/10)%10 << endl;
  cout << (s%100)%10 + (s/10)%10 + s/100 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;

typedef pair<int, int> P;
int h,w;
int bw[1003][1003];


int main() {
	cin >> h >> w;
	char a;
	vector<queue<P>> temp(2003);
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> a;
			if (a == '#') {
				bw[i][j] = 1;
				temp[0].push(make_pair(i, j));
			}
		}
	}
	int ans = 0;
	int i = 0;
	while(temp[i].size())
	{
		int val = 0;
		for (int j = 0; temp[i].size(); j++)
		{
			int fir = temp[i].front().first;
			int sec = temp[i].front().second;
			temp[i].pop();
			if (fir+ 1 < h) 
				if (bw[fir + 1][sec] != 1) {
					bw[fir + 1][sec] = 1;
					temp[i + 1].push(make_pair(fir + 1, sec));
					val = 1;
				}
			if (fir -1 >=0)
				if (bw[fir - 1][sec] != 1) {
					bw[fir - 1][sec] = 1;
					temp[i + 1].push(make_pair(fir - 1, sec));
					val = 1;
				}
			if (sec + 1 < w)
				if (bw[fir][sec +1] != 1) {
					bw[fir][sec +1] = 1;
					temp[i + 1].push(make_pair(fir, sec +1));
					val = 1;
				}
			if (sec-1 >=0)
				if (bw[fir][sec -1] != 1) {
					bw[fir][sec -1] = 1;
					temp[i + 1].push(make_pair(fir, sec -1));
					val = 1;
				}
		}
		if(val==1)ans++;
		i++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 13712
#include <iostream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll N,M,C;
  cin>>N>>M>>C;
  vector<ll> B(M);
  FORi(M){
    cin>>B[i];
  }
  vector<vector<ll>> A;
  FORi(N){
    vector<ll> tmp(M);
    for(int ii=0;ii<M;++ii){
      cin>>tmp[ii];
    }
    A.push_back(tmp);
  }
  ll ans=0;
  FORi(N){
    ll sum=0;
    for(int ii=0;ii<M;++ii){
      sum+=A[i][ii]*B[ii];
    }
    if(sum>-C){
      ans++;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 888