akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;

const int maxn = 1e6 + 10;      
int f[maxn], deg[maxn], dist[maxn];
vector<int> adj[maxn];

void getfail(string p) {
  int n = p.size();
  for (int i = 1; i < n; ++i) {
    int j = f[i];
    while (j && p[j] != p[i]) j = f[j];
    if (p[j] == p[i]) f[i + 1] = j + 1;
  }
}

int main() {
  #ifdef LOCAL
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
  #endif

  ios::sync_with_stdio(false);
  string s, t, s1;
  cin >> s >> t;
  getfail(t);
  s1 = s;
  int m = t.size(), n = s.size();
  while (s.size() < s1.size() + t.size()) s += s1;

  int j = 0;
  for (int i = 0; i < n + m; ++i) {
    while (j && t[j] != s[i]) j = f[j];
    if (t[j] == s[i]) ++j;
    if (j == m) adj[(i - m + 1) % n].push_back((i + 1) % n), ++deg[(i + 1) % n];
  }

  queue<int> q;
  int ans = 0;
  for (int i = 0; i < n; ++i) if (deg[i] == 0) q.push(i);
  while (!q.empty()) {
    int u = q.front(); q.pop();
    for (auto v : adj[u])
      if (--deg[v] == 0) q.push(v), dist[v] = max(dist[v], dist[u] + 1), ans = max(ans, dist[v]);;
  }
  
  int ok = 1;
  for (int i = 0; i < n; ++i) if (deg[i]) { ok = 0; break; }

  if (!ok) cout << -1;
  else cout << ans;
  return 0;
}

Measured memory_bytes: 51100
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <string>
#include <map>
#define ll long long

using namespace std;

const int M = 1000000007;

int n, k, c, x;

int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> n >> k;
	
	for (int i = 0; i < n; i++){
		cin >> x;
		if (x >= k) c++;
	}
	
	cout << c;
	
return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct node {
	ll l,r,k;
};

bool cmp(node &p, node &q) {
	return p.k < q.k;
}

int main() {
	ll t;
	cin>>t;
	while(t--) {
		ll n;
		cin>>n;
		ll i,ans=0,ind1=0,ind2=0;
		node p[n+1],q[n+1];
		for(i=1;i<=n;i++) {
			ll l,r,k;
			cin>>k>>l>>r;
			ans += min(l,r);
			if(l>r) {
				p[ind1].l=l;
				p[ind1].r=r;
				p[ind1].k=k;
				ind1++;
			}
			else {
				q[ind2].l=l;
				q[ind2].r=r;
				q[ind2].k=n-k;
				ind2++;
			}
		}
		// cout<<ind1<<" "<<ind2<<"\n";
		sort(p, p+ind1, cmp);
		sort(q, q+ind2, cmp);

		priority_queue<ll, vector<ll>, greater<ll>> pq1, pq2;
		for(i=0;i<ind1;i++) {
			if(p[i].k == 0)
				continue;
			else if(p[i].k > pq1.size())
				pq1.push(p[i].l - p[i].r);
			else if(p[i].k == pq1.size() && pq1.top()<(p[i].l-p[i].r)) {
				pq1.pop();
				pq1.push(p[i].l-p[i].r);
			}
		}
		for(i=0;i<ind2;i++) {
			if(q[i].k == 0)
				continue;
			else if(q[i].k > pq2.size())
				pq2.push(q[i].r - q[i].l);
			else if(q[i].k == pq2.size() && pq2.top()<(q[i].r-q[i].l)) {
				pq2.pop();
				pq2.push(q[i].r-q[i].l);
			}
		}
		while(!pq1.empty()) {
			ans += pq1.top();
			pq1.pop();
		}
		while(!pq2.empty()) {
			ans += pq2.top();
			pq2.pop();
		}
		cout<<ans<<"\n";
	}
} 

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {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;}

//-----------------------------------------
void p(string s){
  cout << s <<endl;
}
//-----------------------------------------

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

  while(1){
    int n, x;
    cin >> n >> x;
    int cnt = 0;
    if(n == 0 && x == 0) break;
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        for(int k =j+1;k<=n;k++){
          if(i+j+k == x) cnt++;
        }
      }
    }
    cout << cnt <<endl;
  }




  return 0;
}



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

int main() {
    
    int X,Y;
    cin >> X >> Y;
    
    if(X*4<Y){
        cout << "No" << endl;
        return 0;
    }else if(Y < X*2){
        cout << "No" << endl;
        return 0;
    }else if(Y%2 != 0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3636
s=list(input())
ans=0
g_c,p_c=0,0
for i in range(len(s)):
    if i==0:
        g_c+=1
        if s[i]=='p':
            ans-=1
        continue
    if s[i]=='g':
        if p_c<g_c:
            p_c+=1
            ans+=1
        else:
            g_c+=1
    else:
        if p_c<g_c:
            p_c+=1
        else:
            g_c+=1
            ans-=1
print(ans)

Measured memory_bytes: 3956
Public Class Program
  Shared Sub Main()
    Dim ha As Integer() = Cin.IntArr()
    Dim h As Integer = ha(0)
    Dim a As Integer = ha(1)
    Dim ans As Integer = Math.Ceiling(h / a)
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class


Measured memory_bytes: 11220
// AOJ 2089 Mysterious Dungeons
// 2018.3.24 bal4u

#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define QMAX  230500
typedef unsigned char uchar;
typedef struct { char r, c; uchar s; int t; } Q;
Q q[QMAX+2]; int top, end;
short mk[31][31][1<<8];
char map[33][33];
char f['z'+1], id['z'+1]; int sz;
int  mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

int main()
{
	int W, H, i, r, c, nr, nc, t, s, ns, a, ans;
	int sr, sc, gr, gc;
	char buf[10], *p;
	
	while (fgets(p=buf, 10, stdin) && *p != '0') {
		sscanf(p, "%d%d", &W, &H);
		sz = 0; memset(f, 0, sizeof(f)), memset(id, 0, sizeof(id));
		for (r = 0; r < H; r++) {
			fgets(p=map[r], 33, stdin);
			for (c = 0; c < W; c++) {
				if      (*p == '@') sr = r, sc = c, *p = '.';
				else if (*p == '<') gr = r, gc = c, *p = '.';
				else if (islower(*p)) f[*p] |= 1, f[toupper(*p)] |= 1;
				else if (isupper(*p)) f[*p] |= 2, f[tolower(*p)] |= 2;
				p++;
			}
		}
		for (r = 0; r < H; r++) {
			for (p = map[r], c = 0; c < W; c++) {
				if (islower(*p)) {
					if (f[*p] != 3) *p = '.';
					else {
						if (!id[*p]) id[*p] = (sz<<2)|1, id[toupper(*p)] = ((sz++)<<2)|3;
						*p = id[*p]>>1;
					}
				} else if (isupper(*p)) {
					if (f[*p] != 3) *p = '#';
					else {
						if (!id[*p]) id[*p] = (sz<<2)|3, id[tolower(*p)] = ((sz++)<<2)|1;
						*p = id[*p]>>1;
					}
				}
				p++;
			}
		}

		memset(mk, 0x55, sizeof(mk));
		q[0].r = sr, q[0].c = sc, q[0].t = 0, q[0].s = 0, mk[sr][sc][0] = 0;
		top = 0, end = 1, ans = -1;
		while (top != end) {
			r = q[top].r, c = q[top].c, t = q[top].t, s = q[top++].s;

			if (r == gr && c == gc) { ans = t; break; }
			if (mk[r][c][s] < t) continue;

			for (i = 0; i < 4; i++) {
				nr = r + mv[i][0], nc = c + mv[i][1], ns = s;
				if (map[nr][nc] == '#') continue;
				if ((a = map[nr][nc]) < 32) {
					if (a & 1) { if (!(s & (1<<(a>>1)))) continue; }
					else ns = s ^ (1<<(a>>1));
				}
				if (mk[nr][nc][ns] > t+1) {
					mk[nr][nc][ns] = t+1;
					q[end].r = nr, q[end].c = nc, q[end].t = t+1, q[end++].s = ns;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
int n=D();
int x=n%10;
n/=10;
int y=n%10;
n/=10;
int z=n%10;
if(x==z)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

double d = 0.00001;
int build[25][3];

int main(){
    int r,n;
    while(true){
        cin >> r >> n;
        if(r + n == 0)break;
        double ans = 100.0;
        for(int i = 0;i < n;i++){ // cin
            for(int j = 0;j < 3;j++){
                cin >> build[i][j];
            }
        }
        for(int x = -r+1;x <= r;x++){
            int hmax = 0;
            for(int i = 0;i < n;i++){
                if(build[i][0] < x && x <= build[i][1]) hmax = max(hmax,build[i][2]);
            }
       //     cout << "x:" << x << ", hmax:" << hmax << endl;
            double a = -30.0,b = (double)hmax,xx;
            if(x <= 0){
                xx = (double) x;
            }else{
                xx = (double) (x-1);
            }
            while(b - a > d){
                double half = (a + b) / 2.0;
                if( (double)r*r > ((double)hmax - half)*((double)hmax - half) + xx*xx){
                    b = half;
                }else{
                    a = half;
                }
            }
            if(ans > a + (double)r) ans = a + (double)r;
        }
        cout << round(ans*10000)/10000 << endl;
    }
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;

bool check(string&s, int i, int j) {
    while (i < j) {
        if (s[i++] != s[j--]) return false;
    }
    return true;
}

int main() {
    string s; 
    cin >> s; 
    int n = s.size();
    if (check(s, 0, n-1) && check(s, 0, (n-3)/2) 
        && check(s, (n+1)/2, n -1))
        cout << "Yes" << endl;
    else cout << "No" << endl; 
}

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

main(){
	long long x;
	cin>>x;
	if(x-100<=100)cout<<x-100;
	else{
		long long  now=100,c=1;
		while(1){
			now=(ll)((double)now)*1.01;
			if(now>=x){
				cout<<c;
				break;
			}
			c++;
		}
		
	}
}

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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


int main(void) {
    string s, t;
    cin >> s >> t;

    int n;
    n = s.size();

    vector<int> dicst(26, -1);
    vector<int> dicts(26, -1);
    char cs, ct;
    for(int in=0;in<n;in++) {
        cs = s.at(in);
        ct = t.at(in);

        if(dicst.at(cs-'a')==-1) dicst.at(cs-'a')=ct-'a';
        else if(dicst.at(cs-'a')==ct-'a') continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }

    for(int in=0;in<n;in++) {
        cs = s.at(in);
        ct = t.at(in);

        if(dicts.at(ct-'a')==-1) dicts.at(ct-'a')=cs-'a';
        else if(dicts.at(ct-'a')==cs-'a') continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  vector<char> vec(W);

    
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
  

  for(int i = 0; i < H; i++){
   cout << "#";

    for(int j = 0; j < W ; j++){
      cin >> vec.at(j);
     cout << vec.at(j);
    }
   cout << "#";
   cout << endl; 
  }
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
   cout << endl; 
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n;
map<LL,LL>One,Two;
int main(){
	cin>>n;
    for(LL i=1;i<=n;i++){
        LL x;
        scanf("%lld",&x);
        One[x+i]++;
        Two[i-x]++;
    }
    LL ans=0;
    for(auto &Now:One)ans+=Two[Now.F]*Now.S;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 37896
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
using namespace std;

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



int main()
{
  int N; cin >>  N ;
  if(N == 1){
    cout << "1.0000" << endl;
  } else if( N%2 == 0){ 
    cout << "0.500" << endl;
  } else{
    double out = (double)( (N/2)+1.0 ) / N;
    cout <<  out << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,s=0;
  cin>>n>>k;
  vector<int>arr(n);
  for(int i=0;i<n;i++)
    cin>>arr[i];
  sort(arr.begin(),arr.end());
  for(int i=0;i<k;i++)
   s=s+arr[i];
  cout<<s;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 9223372036854775807;
const int MOD = 1000000007;

int main(){
	int n,k,q;
	std::cin >> n>>k>>q;
	std::vector<int> a(q),b(n,k);
	rep(i,q)std::cin >> a[i];
	rep(i,q){
		b[a[i]-1]++;
	}
	rep(i,n){
		if(b[i]-k>=q-k+1)std::cout << "Yes" << std::endl;
		else std::cout << "No" << std::endl;
	}
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int N; cin >> N;
  vector<int> B(N);
  vector<vector<int>> P(N, vector<int>(11));
  REP(i, N) {
    unsigned int b = 0;
    REP(k, 10) {
      int p; cin >> p;
      if(p == 1) b |= (1 << k); // 1つ1つがORを表す
    }
    B[i] = b;
  }
  REP(i, N) {
    REP(k, 11) {
      cin >> P[i][k];
    }
  }
  ll ans = -pow(10,17);
  for(int bit = 0; bit < (1 << 10); ++bit) {
    if(bit == 0) continue;
    unsigned int c;
    ll res = 0;
    for(int i = 0; i < N; ++i) {
      int cnt = 0;
      c = (bit & B[i]);
      cnt = __builtin_popcount( c );
      res += P[i][cnt];
    }
    if(ans < res) ans = res;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
n = int(input())
S = input()

if n <= 3:
    print(0)
    exit()

Rs = []
Gs = []
Bs = []

r = 0
g = 0
b = 0

for s in S:
    if s == 'R':
        r += 1
    if s == 'G':
        g += 1
    if s == 'B':
        b += 1

    Rs.append(r)
    Gs.append(g)
    Bs.append(b)

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if S[i] == S[j]:
            continue
        color = {'R', 'G', 'B'}
        color.discard(S[i])
        color.discard(S[j])
        desire = color.pop()

        pattern = 0
        if desire == 'R':
            pattern = Rs[-1] - Rs[j]
        elif desire == 'G':
            pattern = Gs[-1] - Gs[j]
        elif desire == 'B':
            pattern = Bs[-1] - Bs[j]
        delta = j-i
        if j+delta < n:
            if S[j+delta] == desire:
                pattern -= 1
        ans += pattern

print(ans)

Measured memory_bytes: 69200
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b;
    char s[20];
    
    scanf("%s", s);
    
    s[5]=' ';
    s[13]=' ';
    
    printf("%s", s);
    
    return 0;
}



Measured memory_bytes: 1692
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  vector<string> B(M);
  REP(i, N) cin >> A[i];
  REP(i, M) cin >> B[i];


  REP(i, N-M+1) REP(j, N-M+1){
    bool flag = false;
    REP(k, M){
      REP(l, M){
        if(A[i+k][j+l] != B[k][l]) flag = true;
        if(flag) break;
        if(k == M-1 && l == M-1){
          cout << "Yes" << endl;
          return 0;
        }
      }
      if(flag) break;
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<cmath>
#include<functional>
#include<numeric>
#include<map>
//#include<>
using namespace std;

#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 RREP(i, n) for(int i=(int)n-1;i>=0;i--)
#define RREPS(i, n) for(int i=(int)n;i>0;i--)
#define FOR(it, a) for(auto it = a.begin();it!=a.end();++it)
#define RFOR(it, a) for(auto it = a.rbegin();it!=a.rend();++it)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back

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

template<class T>
bool chmin(T& t, const T& s){
	if(s < t){
		t = s;
		return 1;
	}else return 0;
}

const int INF = 1<<28;
int n, m, l, k, a, h;

ll g[101][101], g2[101][101];

int main(){
	ios::sync_with_stdio(false);
	while(cin >> n >> m >> l >> k >> a >> h, n){
		
		REP(i, n)REP(j, n) g[i][j] = i==j ? 0 : INF;
		REP(i, n)REP(j, n) g2[i][j] = i==j ? 0 : INF;
		
		vi fr;
		fr.pb(a);
		fr.pb(h);
		REP(i, l){
			int x;
			cin >> x;
			fr.pb(x);
		}
		REP(i, k){
			int u, v, w;
			cin >> u >> v >> w;
			if(w > m) continue;
			g[u][v] = g[v][u] = w;
		}
		REP(k, n)REP(i, n)REP(j, n) chmin(g[i][j], g[i][k] + g[k][j]);
//		REP(i, n)REP(j, n) cout << g[i][j] << " \n"[j+1 == n];cout << endl;

		REP(i, l+2)REP(j, l+2) if(g[fr[i]][fr[j]] <= m) g2[fr[i]][fr[j]] = g[fr[i]][fr[j]];

		REP(k, n)REP(i, n)REP(j, n) chmin(g2[i][j], g2[i][k] + g2[k][j]);
//		REP(i, n)REP(j, n) cout << g2[i][j] << " \n"[j+1 == n];cout << endl;
		ll ans = g2[a][h];
		if(ans >= INF) cout << "Help!" << endl;
		else cout << max(ans, ans*2-m) << endl;
	}
	return 0;
}

Measured memory_bytes: 1380
S = int(input())
p=(10**9)+7

ans_=[0,0,0]

N = 2000
for s in range(3,N+1):
#     print('===',s)
    a = 1
    s = s-3
    while s >= 0:
        if s < 0:
            break
        a += ans_[s]
#         print(s,a)
        s-=1
    ans_.append(a)

print(ans_[S]%p)

Measured memory_bytes: 73796
import numpy

n,k = map(int,input().split())
p = list(map(int,input().split()))
q = []
for i in range(n):
    q.append(((((p[i]+1)*p[i])/2)/p[i]))

res = numpy.cumsum(q)
ans = []
ans.append(res[k-1])
for i in range(k,n):
  ans.append(res[i]-res[i-k])
print(max(ans))

Measured memory_bytes: 34892
def resolve():
    from collections import deque
    N = int(input())
    A = [int(i) for i in input().split()]
    Q = int(input())
    ans = [i for i in range(N)]
    for _ in range(Q):
        b, m, e = [int(i) for i in input().split()]
        tmp = deque(ans[b:e])
        tmp.rotate(e - m)
        for i in range(b, e):
            ans[i] = tmp[i - b]
    prt = [0] * N
    for i in range(N):
        prt[i] = A[ans[i]]
    print(*prt)


resolve()



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

int main(){
	 int a[50], b[50],N,M, cnt[50];
	 cin>>N>>M;
	 for(int i=0;i<M;++i) {
	 	cin>>a[i]>>b[i];
	 }
	 for(auto& c:cnt){
	 	c=0;
	 }
	 for(int i=0;i<M;++i) {
	 	for(int j=0;j<50;++j) {
	 		if(a[i]==j+1)
	 			cnt[j]++;
	 		if(b[i]==j+1)
	 			cnt[j]++;
	 		if(j+1>=N)
	 			break;
	 	}
	 }
	 int s=0;
	 for(auto& c:cnt){
	 	++s;
	 	cout<<c<<endl;
	 	if(s>=N)
	 		break;
	 	
	 }
	 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define nln printf("\n")
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll t, n, x;
    scl(n);
    x = n + (n * n) + (n * n * n);
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;


int main(){
    ios;
    ll N,K;
    cin >> N >> K;
    vector<ll> h(N+1,0);
    rep(i,N) cin >> h[i+1];

    vector<ll> dp(N+1,INF);
    dp[0] = 0; dp[1] = 0;
    ll a;
    for(int i=2;i<N+1;i++){
        for(int j=i-1;i-K<=j;j--){
            if(j == 0) break;
            a = abs(h[i]-h[j]);
            a += dp[j];
            if(a < dp[i]) dp[i] = a;
        }
    }
    
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
char s[101][102];

int n,m;
void solve()
{
	for(int i= 0 ; i < n; i++) cin>>s[i];
	int x = 0,y = 0;
	while(s[y][x] != '.'){
		char c = s[y][x];
		s[y][x] = '#';
		switch(c){
		case '#':
			puts("LOOP");
			return;
		case '>':
			x++;
			break;
		case '<':
			x--;
			break;
		case 'v':
			y++;
			break;
		case '^':
			y--;
			break;
		}
	}
	printf("%d %d\n",x,y);
}

int main(){
	while(cin>>n>>m,(n||m)){
		solve();
	}
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){

    ll n, k;
    cin >> n >> k;

    ll x = n % k;
    ll y = x - k;
    y *= -1;

    ll ans = min(x, y);

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

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%s", $S);

$strarr = str_split($S);
$new_arr = [];
#echo ord("Z");
#echo ord("A");
#echo "\n";
foreach($strarr as $str){
    #echo ord($str);
    #echo chr((ord($str) - 65 + $N) % 26 + 65);
    array_push($new_arr, chr((ord($str) - 65 + $N) % 26 + 65));
}
#echo count($strarr);
#var_dump(array_slice($strarr, $N, count($strarr)));
#var_dump(array_slice($strarr, 0, $N - 1));
#$new_arr = array_merge(array_slice($strarr, $N, count($strarr)), array_slice($strarr, 0, $N));
# var_dump($new_arr);

echo implode($new_arr);

Measured memory_bytes: 8180
#include<iostream>
#include<algorithm>
using namespace std;
int n,dp[1<<16];
int t[20][20];
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i<n;i++)for(int j=0;j<=n;j++)cin>>t[i][j];
		for(int i=0;i<1<<n;i++)dp[i]=1e9;
		dp[0]=0;
		for(int i=0;i<1<<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i&1<<j)continue;
				int m=t[j][0];
				for(int k=0;k<n;k++)if(i&1<<k)m=min(m,t[j][k+1]);
				dp[i|1<<j]=min(dp[i|1<<j],dp[i]+m);
			}
		}
		cout<<dp[(1<<n)-1]<<endl;
	}
}



Measured memory_bytes: 3340
from math import*
n=int(input())

ans=n*(n+1)//2

for i in range(1,n+1):
    for j in range(i+1,n+1):
        ans+=gcd(i,j)*6
        
for i in range(1,n+1):
    for j in range(i+1,n+1):
        for r in range(j+1,n+1):
            ans+=gcd(gcd(i,j),r)*6
print(ans)

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

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s=="SUN"){
    cout << 7 << endl;
  }
  else if(s=="SAT"){
    cout << 1 << endl;
  }
  else if(s=="MON"){
    cout << 6 << endl;
  }
  else if(s=="TUE"){
    cout << 5 << endl;
  }
  else if(s=="WED"){
    cout << 4 << endl;
  }
  else if(s=="THU"){
    cout << 3 << endl;
  }
  else if(s=="FRI"){
    cout << 2 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)

int main() {
	int N, M, X; cin >> N >> M >> X;
	vector<int> v(N+1);
	rep(i, M) {
		int a; cin >> a;
		v[a] = 1;
	}
	int ans = INF;
	int tmp = 0;
	for (int i = X; i <= N+1; i++) {
		if (v[i] == 1) tmp++;
	}
	ans = min(ans, tmp);
	tmp = 0;
	for (int i = X; i >= 0; i--) {
		if (v[i] == 1) tmp++;
	}
	ans = min(ans, tmp);
	cout << ans << endl;
}

Measured memory_bytes: 3532
#S= str(input())
#T= str(input())
N,X = map(int,input().split())
#N = int(input())
A = list(map(int,input().split()))
c=0
while X>=min(A):
    if len(A)==1:
        if X==A[0]:
            c+=1
            print(c)
            exit()
        else:
            print(c)
            exit()

    if X>=min(A):
        X-=min(A)
        A.remove(min(A))
        c+=1

print(c)


Measured memory_bytes: 3060
S = input()
max = 0
acgt = 'ACGT'
for i in range(len(S)):
    if S[i] not in acgt:
        continue
    count = 0
    for j in range(i, len(S)):
        if S[j] in acgt:
            count += 1
        else:
            break
    if count > max:
        max = count
print(max)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int N, K; std::cin >> N >> K;
  if ( K == 1 ) std::cout << 0 << std::endl;
  else std::cout << (N-(K-1)) - 1 << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  VEC<int>A(5);
  REP(i,0,5){
    cin>>A[i];
    if(A[i]!=i+1){
      cout<<i+1<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3624
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort()
    return divisors

def make_divisors_without_own(n):
    r = make_divisors(n)
    r.remove(1)
    r.remove(n)
    return r

a, b = map(int, input().split())
aa = set(make_divisors(a))
bb = set(make_divisors(b))
u = aa & bb
u = u - set([1])
#print(u)
u = list(u)
u.sort()
res = 0
for i in range(len(u)):
    if make_divisors_without_own(u[i]) == []:
        res += 1
print(res + 1)

Measured memory_bytes: 42340
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int s=n;
  vector<int>a(8);
  int sum=0;
  for (int i = 0; i < 8; i++){
    a[i]=s%10;
      s/=10;
      sum+=a[i];
  }
  if(n%sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int alp[26];
int main(){
 int n,k;cin>>n>>k;
  for(int i = 0; n > i; i++){
    string s;cin>>s;
    alp[s[0]-'A']++;
  }
  vector<int> a;
  for(int i = 0; 26 > i; i++){
    if(alp[i]){
      a.push_back(alp[i]);
    }
  }
  sort(a.begin(),a.end(),greater<int>());
  int ans = 0;
  while(a.size() >= k){
    for(int i = 0; k > i; i++)a[i]--;
    ans++;
    sort(a.begin(),a.end(),greater<int>());
    while(a[a.size()-1] == 0 && !a.empty())a.pop_back();
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int S, h, m, s;
   cin >> S;
   
   h = S / 3600;
   m = S % 3600 / 60;
   s = S % 60;
   
   cout << h << ":" << m << ":" << s << endl;
}



Measured memory_bytes: 3120
#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! get_chars {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().chars().collect::<Vec<_>>()
        }
    };
    ($n:expr) => {
        {
            (0..$n)
                .map(|_| get_chars!())
                .collect::<Vec<_>>()
        }
    };
}

fn main() {
    let (n, mut a, mut b, mut c) = get!(usize, i64, i64, i64);
    let s = get!(String; n);
    let mut res = vec![];

    for i in 0..n {
        let (t, v, tt, vv) = match s[i].as_str() {
            "AB" => (&mut a, &mut b, "A", "B"),
            "AC" => (&mut a, &mut c, "A", "C"),
            "BC" => (&mut b, &mut c, "B", "C"),
            _ => std::process::exit(0),
        };

        let (ad, sb, ch) =
            if *t == 0 && *v == 0 {
                println!("No");
                std::process::exit(0);
            } else if *t == 0 {
                (t, v, tt)
            } else if *v == 0 {
                (v, t, vv)
            } else {
                if i < n - 1  && s[i + 1].contains(tt) {
                    (t, v, tt)
                } else {
                    (v, t, vv)
                }
            };
        res.push(ch);
        *ad += 1;
        *sb -= 1;
    }

    println!("Yes");
    for nn in res {
        println!("{}", nn);
    }
}


Measured memory_bytes: 9252
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double EPS = 1e-8;

int main(){
  int total_imori_buses;
  while(~scanf("%d",&total_imori_buses)){
    set<int> buses;
    for(int imori_i = 0; imori_i < total_imori_buses; imori_i++){
      int hour,minute;
      scanf("%d %d",&hour,&minute);
      buses.insert(hour * 60 + minute);
    }
    int total_tsuruga_buses;
    scanf("%d",&total_tsuruga_buses);
    for(int tsuruga_i = 0; tsuruga_i < total_tsuruga_buses; tsuruga_i++){
      int hour,minute;
      scanf("%d %d",&hour,&minute);
      buses.insert(hour * 60 + minute);
    }

    bool is_first = true;
    for(set<int>::iterator it = buses.begin();
        it != buses.end();
        it++){
      printf("%s%d:%02d",is_first ? "" : " ",*it / 60,*it % 60);
      is_first = false;
    }
    printf("\n");
  }
}

Measured memory_bytes: 1212
def main():
    N, M = map(int, input().split())
    ans = [False for _ in range(N)]
    wa_list = [0 for _ in range(N)]
    ac = 0
    wa = 0
    for _ in range(M):
        i, result = input().split()
        i = int(i)
        if result == "AC":
            if ans[i-1] == False:
                ac += 1
                ans[i - 1] = True
                wa += wa_list[i-1]
        else:
            if ans[i - 1] == False:
                wa_list[i - 1] += 1
    if sum(ans) == 0:
        wa = 0
    print(ac, wa)
    return 0
if __name__ == '__main__':
    main()

Measured memory_bytes: 4760
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

double entropy(int N, const vector<int> &x) {
    double H = 0;
    for (int i=0; i<256; ++i) {
        if (x[i] != 0) {
            H -= (double)x[i] / N * log((double)x[i] / N);
        }
    }
    return H;
}

int main() {
    ios::sync_with_stdio(false);
    int N;
    while (cin >> N && N) {
        vector<int> I(N+1);
        for (int i=1; i<=N; ++i) cin >> I[i];
        int M = 256;
        double Hmin = 999999;
        vector<int> ans(3);
        for (int S=0; S<=15; ++S) {
            for (int A=0; A<=15; ++A) {
                for (int C=0; C<=15; ++C) {
                    vector<int> x(256, 0);
                    int R = S;
                    int O;
                    for (int i=1; i<=N; ++i) {
                        R = (A * R + C) % M;
                        O = (I[i] + R) % M;
                        x[O] ++;
                    }
                    double H = entropy(N, x);
                    if (H + 1e-8 < Hmin) {
                        Hmin = H;
                        ans[0] = S;
                        ans[1] = A;
                        ans[2] = C;
                    }
                }
            }
        }
        cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>
int main()
{
    int a, b, c;

    scanf("%d%d%d", &a, &b, &c);

    if(a == b){
        printf("%d\n", c);
    }
    else if(a == c){
        printf("%d\n", b);
    }
    else{
        printf("%d\n", a);
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int n; cin>>n;
  int cnt{}, mcnt{};
  for(int i=0; i<n; i++){
    int d1,d2; cin>>d1>>d2;
    if(d1==d2) cnt++;
    else cnt = 0;
    mcnt = max(cnt,mcnt);
  }
  if(mcnt>=3) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  
  
}


Measured memory_bytes: 3616
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;using vci=vector<int>;using vcl=vector<ll>;template<typename T>void _dbg(const char*_s,T _h){cerr<<_s<<" = "<<_h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*_s,T _h,Ts..._t){int _b=0;while(((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',')cerr<<*_s++;cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);}
#define f first
#define s second
#define pb emplace_back
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;
ll p[11],c[11];
int32_t main() {
    
    ll n,g;
    cin>>n>>g;
    for(int i=1;i<=n;++i)
        cin>>p[i]>>c[i];
    vector<int> v(n);
    iota(v.begin(), v.end(), 1);
    int ans=123456789;
    do{
        ll cur=g;
        int pot=0;
        for (int i : v){
            int w=p[i];
            int g=min(p[i],(cur+i*100-1)/(i*100));
            pot+=g;
            cur -= g*i*100;
            if(g==p[i])
                cur -= c[i];
            if(cur<0){
                break;
            }
        }
        ans=min(ans,pot);
    }while(next_permutation(v.begin(), v.end()));
    cout<<ans<<'\n';

    

    return 0;
}


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

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



struct Ant
{
	int x, y, hp, time;
	Ant(int x, int y, int hp, int time)
		: x(x), y(y), hp(hp), time(time) {}
};
int main()
{
	int w, h;
	while (cin >> w >> h, w | h)
	{
		const int INF = 1 << 25;
		int d[16][16], dis[16][16][7], sx, sy;
		CLEAR(d, 0);
		for (int i = 1; i <= h; ++i)
		{
			for (int j = 1; j <= w; ++j)
			{
				cin >> d[i][j];
				if (d[i][j] == 2)
					sx = j, sy = i;

				for (int k = 0; k <= 6; ++k)
					dis[i][j][k] = INF;
			}
		}

		int res = -1;

		queue<Ant> q;
		q.push(Ant(sx, sy, 6, 0));
		dis[sy][sx][6] = 0;
		while (!q.empty())
		{
			Ant cur = q.front(); q.pop();
			int x = cur.x, y = cur.y, hp = cur.hp, time = cur.time;

			if (d[y][x] == 4)
				hp = 6;
			else if (d[y][x] == 3)
			{
				res = time;
				break;
			}

			if (time > dis[y][x][hp] || hp == 1)
				continue;

			for (int i = 0; i < 4; ++i)
			{
				int tx = x + dx[i], ty = y + dy[i];
				if (d[ty][tx] != 0 && time + 1 < dis[ty][tx][hp - 1])
				{
					q.push(Ant(tx, ty, hp - 1, time + 1));
					dis[ty][tx][hp - 1] = time + 1;
				}
			}
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 0
const main = (input) => {
  const args = input.trim().split("\n");
  const N = parseInt(args[0], 10);
  const isAC = s=>s === "AC";
  const n_ac = args.filter(isAC).length;
  const isWA = s=>s === "WA";
  const n_wa = args.filter(isWA).length;
  const isTLE = s=>s === "TLE";
  const n_tle = args.filter(isTLE).length;
  const n_re = N - n_ac - n_wa - n_tle;

  console.log(`AC x ${n_ac}
  WA x ${n_wa}
  TLE x ${n_tle}
  RE x ${n_re}`)
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 40108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

ll sz, v, w;
vector<PII> g[400010];
void dfs(ll a, ll b, ll k=0, ll l=0, ll r=sz) {
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) {
        // dump(k, v, w);
        g[k].push_back({v, w});
        return;
    }

    ll mid = (l+r)/2;
    dfs(a, b, 2*k+1, l, mid);
    dfs(a, b, 2*k+2, mid, r);
}

int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<ll> l(m), r(m), c(m);
    REP(i, m) cin >> l[i] >> r[i] >> c[i], l[i]--, r[i]--;

    sz = 1;
    while(sz < n) sz *= 2;
    REP(i, sz-1) {
        g[i*2+1].push_back({i, 0});
        g[i*2+2].push_back({i, 0});
    }
    REP(i, m) {
        // dump(i);
        v = sz-1+r[i], w = c[i];
        dfs(l[i], r[i]);
    }

    vector<ll> dist(2*sz-1, INF);
    priority_queue<PII, vector<PII>, greater<PII>> que;
    que.push({0, sz-1});
    dist[sz-1] = 0;
    while(que.size()) {
        PII p = que.top(); que.pop();
        // dump(p);
        if(dist[p.second] < p.first) continue;
        for(auto to: g[p.second]) {
            if(dist[to.first] > dist[p.second] + to.second) {
                dist[to.first] = dist[p.second] + to.second;
                que.push({dist[to.first], to.first});
            }
        }
    }

    // REP(i, 2*sz-1) dump(i, dist[i]);

    if(dist[n-1+sz-1] == INF) cout << -1 << endl;
    else cout << dist[n-1+sz-1] << endl;

    return 0;
}

Measured memory_bytes: 53228
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);
//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static int K;
	public static void main(String[] args) {
		long A=sc.nextLong();
		long B=sc.nextLong();
		long C=sc.nextLong();
		long ctn=0;
		long t1,t2,t3;
		if(A%2==0&&A==B&&A==C) {
			p(-1);
		}else {
			while(A%2==0&&B%2==0&&C%2==0) {
			t1=A/2;
			t2=B/2;
			t3=C/2;
			A=t2+t3;
			B=t1+t3;
			C=t1+t2;
			ctn++;
			
			}
			p(ctn);
			
		}
		
	}
}


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

int main(void)
{
    long long int a,b,c,i,j,k,n;

    cin >> a;
    if(a==2){
        cin >> b >>c;
        cout << b+c;
        return 0;
    }
    cout << "Hello World";
    return 0;
}

Measured memory_bytes: 256