akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#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 <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second


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

char town[30][30];
int h,w,dir,x,y;

bool intown(int x,int y){
  return !(x<0 || y<0 || x>=h || y>=w || town[x][y]!='.');
}

void hou(int cx,int cy){
  if(cx<0 || cy<0 || cx>=h || cy>=w || town[cx][cy]=='#')return;
  if(town[cx][cy]=='.' || town[cx][cy]=='-')hou(cx+dx[dir],cy+dy[dir]);
  else if(town[cx][cy]=='*'){
    town[cx][cy]='.';
    return;
  }
}

main(){
  int n;
  cin>>n;
  while(n--){
    cin>>h>>w;
    rep(i,h){
      cin>>town[i];
      rep(j,w){
        switch(town[i][j]){
        case '^':
          dir=3;
          x=i,y=j;
          break;
        case '>':
          dir=0;
          x=i,y=j;
          break;
        case 'v':
          dir=1;
          x=i,y=j;
          break;
        case '<':
          dir=2;
          x=i,y=j;
          break;
        }
      }
    }

    int s;
    cin>>s;
    string str;
    cin>>str;
    rep(i,str.size()){
      switch(str[i]){
      case 'U':
        dir=3;
        if(intown(x+dx[dir],y+dy[dir])){
          town[x][y]='.';
          x+=dx[dir],y+=dy[dir];
        }
        town[x][y]='^';
        break;
      case 'D':
        dir=1;
        if(intown(x+dx[dir],y+dy[dir])){
          town[x][y]='.';
          x+=dx[dir],y+=dy[dir];
        }
        town[x][y]='v';
        break;
      case 'R':
        dir=0;
        if(intown(x+dx[dir],y+dy[dir])){
          town[x][y]='.';
          x+=dx[dir],y+=dy[dir];
        }
        town[x][y]='>';
        break;
      case 'L':
        dir=2;
        if(intown(x+dx[dir],y+dy[dir])){
          town[x][y]='.';
          x+=dx[dir],y+=dy[dir];
        }
        town[x][y]='<';
        break;
      case 'S':
        hou(x+dx[dir],y+dy[dir]);
        break;
      }
      //cout<<str[i]<<endl;
      //rep(i,h)cout<<town[i]<<endl;

    }
    rep(i,h)cout<<town[i]<<endl;
    if(n)cout<<endl;
  }
}

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

using namespace std;

int n;
int seq[1000050],a[200050];
int cnt[1000050];

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n; ++ i)
	{
		scanf("%d",&a[i]);
		cnt[a[i]] ++;
	}
	for(int i = 1;i <= 1000000; ++ i)
		for(int j = 1;j * i <= 1000000; ++ j)
			seq[j * i] += cnt[i];
	int c = 0;
	for(int i = 1;i <= n; ++ i)
		c += !(seq[a[i]] - 1);
	printf("%d\n",c);
}

Measured memory_bytes: 12308
import sys

L = 128

chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

count_table = {}
sub_passwords = []
length = 0
for i, c in enumerate(chars):
	print("? " + (c * L), flush = True)
	l = L - int(input())
	if l > 0:
		count_table[c] = l
		sub_passwords.append(c * l)
	length += l

#print("r>", length, sub_passwords, file = sys.stderr)

def merge(a, b):
#	length = len(a) + len(b)
	fixed = ""
	while True:
#		print("checking: {}-{}-{}".format(fixed, a, b) , flush = True, file = sys.stderr)
		pw = fixed + b[0] + a
		print("? " + pw, flush = True)
#		print("? " + pw, flush = True, file = sys.stderr)
		led = int(input())
#		print(">", pw, led, length, len(pw), file = sys.stderr)
		if led == length - len(pw):
			fixed += b[0]
			b = b[1:]
			if len(b) == 0:
				break
		else:
			fixed += a[0]
			a = a[1:]
			if len(a) == 0:
				break

	print("fixed: {}-{}-{}".format(fixed, a, b) , flush = True, file = sys.stderr)
	return fixed + a + b

import heapq

queue = []
for sub_password in sub_passwords:
	heapq.heappush(queue, (len(sub_password), sub_password))

while len(queue) > 1:
	l_a, a = heapq.heappop(queue)
	l_b, b = heapq.heappop(queue)
	heapq.heappush(queue, (l_a + l_b, merge(a, b)))


print("! " + queue[0][1])


Measured memory_bytes: 9232
#include <stdio.h>
int main (void){
    long int n;
    char str[11];
    int i;
    
    while(1){
		scanf("%ld",&n);
        if(n != 0){
            sprintf(str,"%o",n);
            for(i=0;str[i] != '\0'; i++){
                str[i] += ((str[i]>='4')+(str[i]>='5'));
            }
            printf("%s\n",str);
        }else{
            break;
        }
    }
    return 0;
}


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

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    vector<vector<int>> d(n, vector<int>(n));
    map<int, int> m;
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            d[i][j]=abs(i-j);
        }
    }
    d[x-1][y-1]=1;
    d[y-1][x-1]=1;

    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            d[i][j]=min(d[i][j],d[i][x-1]+d[y-1][j]+1);
            d[i][j]=min(d[i][j],d[i][y-1]+d[x-1][j]+1);
        }
    }
    for(int i=0; i<n-1; i++) {
        for(int j=i+1; j<n; j++) {
            if(m.count(d[i][j])) m[d[i][j]]++;
            else m[d[i][j]]=1;
        }
    }
    for(int i=1; i<n; i++) {
        if(m.count(i)) cout << m.at(i) << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int k, a, b;
  cin >> k >> a >> b;
  if (a <= b/k*k) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#define S(n) scanf("%d",&n)
int n,q,i,j,s[10000],t,c;
main(){  
  for(S(n);i<n;S(s[i++]));
  for(S(q);j<q;++j)
    for(S(t),i=0;i<n;++i)
      if(t==s[i])c++,i=n;
  printf("%d\n",c);
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int n, ans = 0;
    cin >> n;
    string a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    rep(i, n){
        int temp = 0;
        if(a[i] == b[i]) temp++;
        if(a[i] == c[i]) temp++;
        if(c[i] == b[i]) temp++;
        if(temp == 0){
            ans += 2;
        }
        if(temp == 1){
            ans += 1;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}
int n,m;
int cnt=1;
int ans=1;
vector<int> adj[200001];
bool visited[200001]={0};
void dfs(int node){
  visited[node]=1;
  
  for(int next:adj[node]){
    if(!visited[next]){
      dfs(next);
      cnt++;
    }
  }
 
}
int main() {
   fast();
   cin>>n>>m;
   map<pair<int,int>,int> mt;
   for(int i=0;i<m;i++){
     int u,v;
     cin>>u>>v;
     --u;--v;
     if(mt[{u,v}]==1 ||  mt[{v,u}]==1){
         ;
     }else{
     adj[u].pb(v);
     adj[v].pb(u);
     mt[{u,v}]=1;
     }
   }
   for(int i=0;i<n;i++){
       if(!visited[i]){
         cnt=1;
        dfs(i);
         ans=max(cnt,ans);
       }
   }
   cout<<ans<<"\n";

   
   
}
 


Measured memory_bytes: 45944
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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;
    ll ans = 0;
    for(int i=1; i<=N; i++){
        ans += (ll)i*(N/i)*(N/i+1)/2;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    vector<ll> c = {-1};
    REP(i, n){
        ll t;
        cin >> t;
        if(c.back() != t){
            c.push_back(t);
        }
        else{
            i--;
            n--;
        }
    }
    vector<ll> dp(n + 1), memo(200005);
    dp[0] = 1;
    for(ll i = 1; i <= n; i++){
        dp[i] = dp[i - 1];
        dp[i] += memo[c[i]];
        dp[i] %= MOD;
        memo[c[i]] = dp[i];
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int limit = 100005;
vector<int> adj[limit];
int toFennec[limit], toSunuke[limit];

void dfsForFennec(int to, int from, int dis){
    toFennec[to] = dis;

    for(int i=0; i<adj[to].size(); i++){
        if(adj[to][i] == from) continue;

        dfsForFennec(adj[to][i], to, dis+1);
    }
}

void dfsForSunuke(int to, int from, int dis){
    toSunuke[to] = dis;

    for(int i=0; i<adj[to].size(); i++){
        if(adj[to][i] == from) continue;

        dfsForSunuke(adj[to][i], to, dis+1);
    }
}

int main(void){
    int N; cin >> N;
    for(int i=0; i<N-1; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    dfsForFennec(0, -1, 0);
    dfsForSunuke(N-1, -1, 0);

    int s = 0, f = 0;
    for(int i=0; i<N; i++){
        //cout << toFennec[i] << " " << toSunuke[i] << endl;
        if(toFennec[i] <= toSunuke[i]) f++;
        else s++;
    }
  
    cout << ((f > s)? "Fennec":"Snuke") << endl;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
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 FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll temp = gcd(a, b); return temp ? (a / temp * b) : 0; }
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 }, dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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; }

inline tuple<ll, ll> rotate45(tuple<ll, ll> point) { ll x = get<0>(point), y = get<1>(point); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }
void out_sequence(vector<ll> &out) { REP(i, (int)out.size()) { cout << out[i]; if (i == (int)out.size() - 1) cout << endl; else cout << " "; } }



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

  	ll N; cin >> N;
  ll ans = 0;
  	REP(i, N) {
      ll n = i + 1;
      if (even(n)) continue;
      ll cnt = 0;
      REP(j, n) {
        if (n % (j + 1) == 0) cnt++;
      }
      if (cnt == 8) ans++;
    }
  cout << ans << endl;
	

	return 0;
}

//*/

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define INF 1e+9
using namespace std;

int main() {
	int n, m;
	while(cin >> n >> m, n && m) {
		int s[2][101][101];

		for(int i = 0; i < 101; ++i) {
			for(int j = 0; j < 101; ++j) {
				s[0][i][j] = (i == j) ? 0 : INF;
				s[1][i][j] = (i == j) ? 0 : INF;
			}
		}

		for(int i = 0; i < n; ++i) {
			int a, b, cost, time;
			cin >> a >> b >> cost >> time;
			s[0][a][b] = cost;
			s[0][b][a] = cost;
			s[1][a][b] = time;
			s[1][b][a] = time;
		}

		for(int i = 1; i <= m; ++i) {
			for(int j = 1; j <= m; ++j) {
				for(int k = 1; k <= m; ++k) {
					s[0][j][k] = min(s[0][j][k], s[0][j][i] + s[0][i][k]);
					s[1][j][k] = min(s[1][j][k], s[1][j][i] + s[1][i][k]);
				}
			}
		}

		int k;
		cin >> k;
		for(int i = 0; i < k; ++i) {
			int p, q, r;
			cin >> p >> q >> r;
			cout << s[r][p][q] << endl;
		}
	}
}

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

typedef long long int ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b, c;
    cin >> a >> b >> c;
    
    int equalCnt = (a == b) + (b == c) + (a == c);
    if (equalCnt == 1)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>
using namespace std;
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define int long long

signed main(){
	int a,b,c;cin>>a>>b>>c;
	cout << b + min(a+b+1,c) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
  int key;
  struct Node *parent,*left,*right;
};
struct Node *root, *NIL;

void insert(int k){

  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key <x->key){
      x=x->left;
    }
    else {
      x=x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}
void inorder(struct Node *u){
  if(u==NIL){
    return;
  }

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n,i=0,x;
  char com[7];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");

    }

  }
  return 0;
}

Measured memory_bytes: 24040
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!int);
    auto M = s[0];
    auto K = s[1];

    if (K == 0) {
        foreach (i; 0..(1<<M)) {
            write(i, " ", i, " ");
        }
        writeln;
    } else if (M >= 2 && K < (1 << M)) {
        auto ans = new int[](1<<(M+1));
        int cnt = 0;
        foreach (i; 0..(1<<M)) {
            if (i == K) {
                ans[$-1] = i;
                ans[(1<<M)-1] = i;
            } else {
                ans[cnt] = i;
                ans[$-cnt-2] = i;
                cnt += 1;
            }
        }
        ans.map!(to!string).join(" ").writeln;
    } else {
        writeln("-1");
    }
}


class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	ll a[81];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	ll dp[81];
	dp[0] = 1000;
	for(int i = 1; i < n; i++){
		dp[i] = dp[i-1];
		for(int j = 0; j < i; j++){
			ll mai = dp[j]/a[j];
			if(a[i]*mai+dp[j]-a[j]*mai > dp[i]){
				dp[i] = a[i]*mai+dp[j]-a[j]*mai;
			} 
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 3660
mod = 10 ** 9 + 7
fac_table = [1 for i in range(200001)]
inv_table = [1 for i in range(200001)]


def make_table(h, w):

    for i in range(1, h + w - 1):
        fac_table[i] = fac_table[i - 1] * i % mod
        inv_table[i] = pow(fac_table[i], mod - 2, mod)


def comb(n, r):
    return fac_table[n] * inv_table[n - r] % mod * inv_table[r] % mod


def resolve():
    H, W, A, B = map(int, input().split())
    make_table(H, W)
    print(
        sum(
            [
                comb(H - A - 1 + i, i) * comb(A - 1 + W - i - 1, A - 1) % mod
                for i in range(B, W)
            ]
        )
        % mod
    )

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 54224
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using Vecint = vector<lint>;
using Llist = list<lint>;

ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

void Main() {
	int n, x, t;
	cin >> n >> x >> t;
	if ( n % x == 0 )
		cout << ( n / x ) * t << '\n';
	else
		cout << ( ( n / x ) + 1 ) * t << '\n';
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}

Measured memory_bytes: 3608
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int D=sc.nextInt();
    int N=sc.nextInt();
    int ANS=0;
    
    if(D==0){
      if(N!=100){
        ANS=N;
      }else{
        ANS=N+1;
      }
    }else if(D==1){
      if(N!=100){
        ANS=N*100;
      }else{
        ANS=(N+1)*100;
      }
    }else{
      if(N!=100){
        ANS=N*10000;
      }else{
        ANS=(N+1)*10000;
      }
    }
    
    System.out.println(ANS);
    
  }
}
  

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


int main() {

int N,K; cin >> N ;

int ans = N%1000;
cout << (1000-ans)%1000 << endl;

return 0;
}

Measured memory_bytes: 3620
from bisect import bisect_left
from itertools import accumulate


N, x = map(int, input().split())
a = list(accumulate(sorted(map(int, input().split()))))
if x in a:
    print(bisect_left(a, x) + 1)
else:
    pos = bisect_left(a, x)
    print(N - 1) if pos == N else print(pos)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if((a < c && c < b) || (b < c && c < a)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
// #include <unordered_map>
#include <set>
#include <utility>
#include <bitset>
#include <limits>
#include <climits>
using namespace std;


typedef long long ll;

ll solve(ll q,ll h,ll s,ll d,ll n) {
    ll one = min({ q*4, h*2, s });
    ll two = min(one*2, d);
    
    ll nh = n/2, nl = n%2;
    return two*nh + one*nl;
}

int main() {
    ll q,h,s,d;cin>>q>>h>>s>>d;
    ll n;cin>>n;
    cout << solve(q,h,s,d,n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define rep(i , a , n) for (int i=a; i<(int)(n); i++)
#define re(i , n)      for (int i=0; i<(int)(n); i++)
#define pb push_back
#define em emplace_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

using namespace std;

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

const int mod=1000000007;
const int inf=1e9+5;
const ll  INF=(ll)1e18+5;
const int N=2e5+5;    /// check

vector<int>g[N];

void mul(int &a, int b)
{
    //a%=mod;
    //b%=mod;
    a = (((ll)a*b)%mod);
}

int k,ans;
void dfs(int u, int p = -1 )
{
    int cur=k-1 - (p!=-1);
    for(auto v:g[u])
    {
        if(v==p)continue;
        if(cur==0){  cout<<"0\n"; exit(0); }
        mul(ans,cur);
        --cur;
        dfs(v,u);
    }
}
int main()
{
#ifdef LOCAL
freopen("input.in","r",stdin);
#endif
    IOS;
    int n;
    cin>>n>>k;
    re(i,n-1)
    {
        int u,v;
        cin>>u>>v;
        g[u].em(v);
        g[v].em(u);
    }
    ans=k;
    dfs(1);
    cout<<ans<<endl;
    return 0;
}



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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<long long int> C(N-1);
    vector<long long int> S(N-1);
    vector<long long int> F(N-1);
    
    for(int n=0; n<N-1; n++) {
        cin >> C[n] >> S[n] >> F[n];
    }
    
    long long int ans;
    for(int s=0; s<N; s++) {
        if(s<N-1) {
            ans = C[s];
            ans += S[s];
        } else {
            ans = 0;
        }
        for(int cur=s+1; cur<N-1; cur++) {
            long long int tmp=ans;
            tmp = max(tmp, S[cur]);
            tmp += (F[cur]-tmp%F[cur])%F[cur];
            ans = tmp;
            ans += C[cur];
        }
        cout << ans << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    double n;
    cin >> n;
    vector<double> a(n);
    double sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    double ave = sum/n;

    double min_dist = 99999.0;
    double min_index = 0;
    for(int i = 0; i < n; i++){
        if(min_dist > abs(ave-a[i])){
            min_dist = abs(ave-a[i]);
            min_index = i;
        }
    }
    cout << min_index << endl;
    return 0;
}


Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "abc161_b.cpp"

int main() {
  int n, m;
  cin >> n >> m;
  vi a(n);
  int sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  sort(ALL(a), greater<int>());

  if (a[m - 1] < (double)sum / (4 * m)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
while True:
    n=int(input())
    if n == 0:
        break
    else:
        maxs=0
        mins=2000
        sums=0
        for i in range(n):
            s=int(input())
            sums=sums+s
            if s<mins:
                mins=s
            if s>maxs:
                maxs=s
        print((sums-maxs-mins)//(n-2))


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

int main(){
  map<int,int> mp;
  int s,n;
  
  cin >> s;
  n=1;
  mp[s] = 1;
  while (true){
    if (s%2==0) s /= 2;
    else s = s*3+1;
    n++;
    if (mp.find(s)!=mp.end()) break;
    mp[s] = 1;
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, m, p;
    cin >> n >> m;
    int array[n][m] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> p;
            array[i][j] = p;
        }
    }

    int array2[n+1][m+1] = {};
    int ysum = 0;
    int xsum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
                array2[i][j] = array[i][j];

            }
        }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m + 1; j++) {
            ysum += array2[i][j];
            if (j == m) {
                array2[i][j] = ysum;
            }
        } ysum = 0;
    }

    for (int i = 0; i < m + 1; i++) {
        for (int j = 0; j < n + 1; j++) {
            xsum += array2[j][i];
            if (j == n) {
                array2[j][i] = xsum;
            }
        } xsum = 0;
    }

    for (int i = 0; i < n + 1; i++) {
        for (int j = 0; j < m + 1; j++) {
            if (j < m) {
                cout << array2[i][j] << " ";
            } else {
                cout << array2[i][j] << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3156
def find(n):
    """
    tn = int(n/2)
    s = 2 * tn + 1
    :param n:
    :return:
    """
    tn = int(n / 2)
    s = 2 * tn + 1
    count = 0
    line_list = []
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i + j != s:
                line_list.append(str(i) + " " + str(j))
                count += 1

    return count, line_list


if __name__ == '__main__':
    n = int(input())

    count, line_list = find(n)
    print(count)
    for item in line_list:
        print(item)

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, p;
  cin >> n >> p;
  ll e = 0, o = 0;
  rep(i, n){
    int in;
    cin >> in;
    if(in % 2 == 0) e++;
    else o++;
  }
  ll ans = 1LL << e;
  if(p == 1 && o == 0) ans = 0;
  ll dpt = ans, dpf = 0;
  rep(i, o){
    ll ndp = dpf + dpt;
    dpt = dpf = ndp;
  }
  ans = dpt;
  cout << ans << endl;
  return 0;
}

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


int main(){
  int i,am,id,a,sum;
  sum=0;
  vector<int> mi(5);
  for(i=0;i<5;i++){
    cin >> mi[i];
  }
  am=100;

  for(i=0;i<5;++i){
    a=mi[i]%10;
    if(a>0 && am>a){
      am=a;
      id=i;
    }
  }

  for(i=0;i<5;++i){
    if(i==id){
      continue;
    }else{
      sum=sum+mi[i];
      while(sum%10!=0){
        sum=sum+1;
      }
    }
  }
  sum=sum+mi[id];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
AB = [tuple(map(int, input().split())) for _ in range(n)]
AB.sort(key = lambda x : x[0] + x[1], reverse = 1)
ans = 0
for i in range(n):
  a, b = AB[i]
  if i & 1:
    ans -= b
  else:
    ans += a
print(ans)

Measured memory_bytes: 92656
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
#define INFTY 3400000000

int main(){
  int H,W;
  char temp;
  cin>>H>>W;
  bool A[10][10];
  for(int i=0;i<H;i++){
    for(int k=0;k<W;k++){
      cin>>temp;
      if(temp=='#') A[i][k]=true;
      else A[i][k]=false;
    }
  }
  bool flag=false;
  int pre=0,last=-1;
  for(int i=0;i<H;i++){
    for(int k=0;k<W;k++){
      if(A[i][k]==true){
        if(pre>k) flag=true;
        if(last!=-1 && last!=k-1) flag=true;
        last=k;
      }
    }
    pre=last;
    last=-1;
  }
  if(flag) cout<<"Impossible"<<endl;
  else cout<<"Possible"<<endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,  digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag; vector<vpll> path, path2; vl D1, D2;
//***********//
int main() {
	cin >> N >> X;
	if (X == 1 || X == 2 * N - 1) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		if (N > 2) {
			vl Ans(2 * N - 1);
			vl used(2 * N + 1000000);
			if (X == 2) {
				Ans[N - 2] = 3;
				Ans[N - 1] = 2;
				Ans[N] = 1;
				Ans[N + 1] = 4;
				used[1] = 1; used[2] = 1; used[3] = 1; used[4] = 1;
			}
			else {
				Ans[N - 2] = X - 1;
				Ans[N - 1] = X;
				Ans[N] = X + 1;
				Ans[N + 1] = X - 2;
				used[X - 1] = 1; used[X] = 1; used[X + 1] = 1; used[X - 2] = 1;
			}
			ll now = 1;
			for (i = 0; i < 2 * N - 1; i++) {
				if (Ans[i] != 0) cout << Ans[i] << endl;
				else {
					while (true) {
						if (!used[now]) break;
						now++;
					}
					cout << now << endl;
					used[now] = 1;
				}
			}
		}
		else {
			cout << 1 << endl << 2 << endl << 3 << endl;
		}
	}
}

Measured memory_bytes: 12416
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll digit_sum(ll n,ll b){
  if(n<b) return n;
  else return digit_sum(n/b,b)+(n%b);
}
vector<int> used[100005];
int main(){
  ll n,s;
  cin>>n>>s;
  if(n==s){
    cout<<n+1<<endl;
    return 0;
  }
  if(n<s){
    cout<<-1<<endl;
    return 0;
  }
  for(ll i=2;i*i<=n;i++){
    if(digit_sum(n,i)==s){
      cout<<i<<endl;
      return 0;
    }
  }
  ll ans=-1;
  for(ll p=1;p*p<=n;p++){
    ll b=((n-s)/p)+1;
    if(b>1){
      if(digit_sum(n,b)==s) ans=b;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e'|| c == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

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

namespace abc047_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(x);
            if(x[0]+x[1]==x[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
long long a,b,c[200005],ans;
map<long long,int>n;
int main()
{
	cin>>a;
	n[0]=1;
	for(int s=1;s<=a;s++)
	{
		cin>>b;
		c[s]=b+c[s-1];
		ans=ans+n[c[s]];
		n[c[s]]++; 
	}
	cout<<ans<<endl;
}

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

int main(){
	char s[1500];
	int i, j, k;
	
	fgets(s, sizeof(s), stdin);

	for(i=0; i<strlen(s); i++){
		if((s[i] >= 'a') && (s[i] <= 'z'))
			s[i] = s[i] + ('A' - 'a');
		else if((s[i] >= 'A') && (s[i] <= 'Z')){
			s[i] = s[i] - ('A' - 'a');
		}
	}
	printf("%s", s);

	return 0;

}


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

using namespace std;
using ll = long long;

int n, k;
vector<int> a;
vector<int> dp; //dp[i] := iのときに勝てるか?

//numで自分の番が回ってきた時に勝てるならば1,まけるならば0
bool dfs(int num) {

    if(dp[num] != -1)return dp[num];

    bool res = false;
    for(int i = 0; i < n; i++) {
        if(num - a[i] >= 0 && dfs(num - a[i]) == false)res = true;
    }
    dp[num] = res;
    return res;
}


int main()
{
    cin >> n >> k;
    dp.resize(k + 1, -1), a.resize(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    cout << (dfs(k) ? "First" : "Second") << endl;
}

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

int main(){
    string A,B;
    cin>>A>>B;

    if(A.size()>B.size()) cout<<"GREATER"<<endl;
    else if(A.size()<B.size()) cout<<"LESS"<<endl;
    else{
        for(int i=0;i<A.size();i++){
            if(A[i]>B[i]){
                cout<<"GREATER"<<endl;
                return 0;
            }else if(A[i]<B[i]){
              cout<<"LESS"<<endl;
              return 0;
            }else if(i==A.size()-1){
                cout<<"EQUAL"<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

unordered_set<ll> calc_divisor(ll X) {
    unordered_set<ll> ret;
    for (ll x = 1; x * x <= X; x++) {
        if (X % x == 0) {
            ret.insert(x);
            ret.insert(X / x);
        }
    }
    return ret;
}

unordered_set<ll> calc_union(unordered_set<ll>& Aset, unordered_set<ll>& Bset) {
    unordered_set<ll> ret;
    for (auto &a : Aset) {
        if (Bset.find(a) != Bset.end())
            ret.insert(a);
    }
    return ret;
}

int main() {
    ll A, B;
    cin >> A >> B;
    auto A_divs = calc_divisor(A);
    //cout << A_divs.size() << endl;
    auto B_divs = calc_divisor(B);
    //cout << B_divs.size() << endl;
    auto C_divs = calc_union(A_divs, B_divs);
    //cout << C_divs.size() << endl;
    vll Cvec(C_divs.begin(), C_divs.end());
    sort(Cvec.begin(), Cvec.end());
    unordered_map<ll, bool> is_multi;
    for(auto &c : Cvec) {
        is_multi.insert(make_pair(c, false));
    }

    ll ans = 0;
    rep(i, Cvec.size()) {
        if (is_multi[Cvec[i]] == true) continue;
        if (Cvec[i] == 1) {
            ans++;
            continue;
        }
        ans++;
        REP(j, i + 1, Cvec.size()) {
            if (Cvec[j] % Cvec[i] == 0) is_multi[Cvec[j]] = true;
        }

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

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <limits>

int main() {

    int64_t N;
    std::cin >> N;

    std::vector<bool> flags(1000000100, false);

    for (int64_t i = 0; i < N; ++i) {
        int64_t v;
        std::cin >> v;
        if (flags.at(v) == true) {
            std::cout << "NO" << std::endl;
            return 0;
        }
        flags.at(v) = true;
    }

    std::cout << "YES" << std::endl;

    return 0;
}

Measured memory_bytes: 122368
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n,t,s,mn=1000000009;
    int ans;
    cin>>n>>t>>s;
   for(int i=1;i<=n;i++)
    {
        double x;
        cin>>x;
        x=(t-(x*0.006));
        x=abs(x-s);
        if(x<mn){mn=x;ans=i;}
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <random>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>
#include <unordered_set>
#include <unordered_map>

#include <random>
#include <ctime>

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

using namespace std;

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

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const long double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll M = 1000000007;
const ll LLINF = 1000000000000000000;
const double EPS = 1e-8;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin >> s;
    int n = s.size(), ans = 0;
    for (auto c : s) {
        if (c == 'p')
            --ans;
    }
    ans += n / 2;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3788
// ABC 087 B
#include <iostream>

int A, B, C, X;

int pattern(int value, int n500, int n100, int n50) {
	if(value >= 500 && n500 > 0) {
		return pattern(value - 500, n500 - 1, n100, n50)
			 + pattern(value, 0, n100, n50);
	} else if(value >= 100 && n100 > 0) {
		return pattern(value - 100, n500, n100 - 1, n50)
			 + pattern(value, 0, 0, n50);
	} else if(value >= 50 && n50 > 0) {
		return pattern(value - 50, n500, n100, n50 - 1)
			 + pattern(value, 0, 0, 0);
	} else if(value == 0) {
		return 1;
	}
	// 払えない
	return 0;
}

int main() {
	std::cin >> A >> B >> C >> X;

	std::cout << pattern(X, A, B, C) << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  bool flag = false;
  if(n%10 == 7) flag = true;
  if(n/100 == 7) flag = true;
  if(n/10%10 == 7) flag = true;

  if(flag) cout << "Yes\n";
  else cout << "No\n";
}


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

const int N = 200005, inf = 0x3f3f3f3f;

int n, m, ans;
int tag[N << 2], max[N << 2];

void build(int o = 1, int l = 0, int r = m) {
	max[o] = r - m;
	if (l == r) return; int mid = l + r >> 1;
	build(o << 1, l, mid), build(o << 1 | 1, mid + 1, r);
}
void pushup(int x) { max[x] = std::max(max[x << 1], max[x << 1 | 1]) + tag[x]; }
void modify(int p, int o = 1, int l = 0, int r = m) {
	if (p < l) return;
	if (p >= r) {++max[o], ++tag[o]; return;}
	int mid = l + r >> 1;
	modify(p, o << 1, l, mid), modify(p, o << 1 | 1, mid + 1, r);
	pushup(o);
}
int query(int p, int o = 1, int l = 0, int r = m) {
	if (p > r) return -inf;
	if (p <= l) return max[o];
	int mid = l + r >> 1;
	return std::max(query(p, o << 1, l, mid), query(p, o << 1 | 1, mid + 1, r)) + tag[o];
}

std::vector<int> v[N];
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m; int lmax = 0, rmin = inf;
	for (int i = 0, l, r; i < n; ++i) {
		std::cin >> l >> r, v[l].emplace_back(r);
		lmax = std::max(lmax, l), rmin = std::min(rmin, r);
	}
	if (lmax >= rmin) ans = std::max(ans, n - m);
	++m; build();
	for (int i = 0; i < m; ++i) {
		for (int p : v[i]) modify(p);
		ans = std::max(ans, query(i + 1) - i);
	}
	std::cout << ans << '\n';
	return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

#define MAX 500000
int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt;


signed main()
{   
    gearup;
    ll n;cin >>n;
    cout << n*n*n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    int length=0;
    rep(i,0,n+1){
        if(s.substr(n-i,i)==t.substr(0,i))length=i;   
    }
    cout<<n*2-length<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {
 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
           int h,w;
           h=sc.nextInt();
           w=sc.nextInt();
           if(h==0&&w==0)break;
           for(int i=0;i<h;i++){
               for(int j=0;j<w;j++){
                   if(i==0||j==0||i==(h-1)||j==(w-1))System.out.print("#");
                   else System.out.print(".");
               }
               System.out.println("");
           }
           System.out.println("");
       }
    }
}




Measured memory_bytes: 33976
#include <iostream>

int main(){
    while(true){
        int N;
        std::cin >> N;
        
        if(N == 0){
            break;
        }
        
        N = 1000 - N;
        
        int count = 0;
        
        count += N / 500;
        N %= 500;
        count += N / 100;
        N %= 100;
        count += N / 50;
        N %= 50;
        count += N / 10;
        N %= 10;
        count += N / 5;
        N %= 5;
        count += N / 1;
        N %= 1;
        
        std::cout << count << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3008