akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

#define MAX 200

int S[MAX];
int top=0;

void push(int x){
    if(top>=MAX-1){
        printf("Stack over flow\n");
    }
    top++;
    S[top]=x;
}

int pop(){
    if(top==0){
        printf("Stack is empty\n");
    }
    top--;
    return S[top+1];
}

int calculate(std::string op){
    if(op=="+"){
        return pop()+pop();
    }else if(op=="-"){
        int a,b;
        a = pop();
        b = pop();
        return b-a;
    }else if(op=="*"){
        return pop()*pop();
    }
    return 0;
}

int main(){
    int i;

    std::string str;
  
    for (int i = 0; i < MAX; ++i) {
      S[i] = 0;
    }

    while(std::cin >> str) {
        if (str == "+" || str == "-" || str == "*") {
            int tmp1=0;
            tmp1 = calculate(str);
            push(tmp1);
        } else {
            int tmp2=0;
            for (i = 0; i < (int)str.size(); i++) {
                tmp2 = tmp2 * 10;
                tmp2 = tmp2 + str[i] - '0';
            }
            push(tmp2);
        }
    }

    printf("%d\n", pop());
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  int h, m;
  h = c-a;
  m = d-b;
  int g = h*60 + m;
  cout << g-e << '\n';
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int a[105][105];
int main()
{
	int n;
	cin>>n;
	for(int i = 1; i <= 2; i++)
		for(int j = 1; j <= n; j++)
			cin>>a[i][j];
	int ans = 0;int t = 0;
	for(int i = 1; i <= n; i++){
		int cnt = 0;
		t += a[1][i];
		for(int j = i; j <= n; j++){
			cnt += a[2][j];
		}
		ans = max(ans,t+cnt);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPD(i,s,e,d) for(int i=s; i<=e; i+=d)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

struct circle
{
    double x, y, r;
};

inline double circle_dist(circle &a, circle &b)
{
    return max(0.00000000001, sqrt((b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y)) - (a.r+b.r));
}

int main()
{
    double x_s, y_s, x_t, y_t; in >> x_s >> y_s >> x_t >> y_t;
    int n; in >> n;

    vector< circle > C(n);
    REP(i, n)
    {
        in >> C[i].x >> C[i].y >> C[i].r;
    }

    C.pb({x_s, y_s, 0});
    C.pb({x_t, y_t, 0});

    vector<double> dist(C.size(), 5e18);
    vector<bool> inQ(C.size(), false);

    queue<int> Q;
    dist[n] = 0.0;
    Q.push(n);
    inQ[n] = true;

    while(Q.size())
    {
        int t = Q.front(); Q.pop();
        inQ[t] = false;
        REP(i, C.size())
        {
            if(i == t) continue;
            double w = circle_dist(C[t], C[i]);

            if(dist[t] + w < dist[i])
            {
                dist[i] = dist[t] + w;
                if(!inQ[i])
                {
                    inQ[i] = true;
                    Q.push(i);
                }
            }
        }
    }

    out << fixed << setprecision(10) << dist[n+1] << "\n";

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;

const int NN = 110000;
int n, k, a[NN], ans; 

int min(int a, int b){
	if (a < b) return a;
	else return b;
} 
 
int main(){
	scanf("%d%d", &n, &k);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	
	ans = 0x7fffffff;
	for (int i=1; i<=n-k+1; i++){
		if ((a[i] <= 0 && a[i+k-1] <= 0) || (a[i] >= 0 && a[i+k-1] >= 0)){
			if (a[i] <= 0) ans = min(abs(a[i]), ans);
			else ans = min(a[i+k-1], ans);
		} else {
			ans = min(a[i+k-1] - a[i] + min(abs(a[i+k-1]), abs(a[i])), ans);
		} 
	}
	
	printf("%d", ans); 
	
	return 0;
} 

Measured memory_bytes: 640
def examA():
    N, R = LI()
    ans = R+100*max(0,(10-N))
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()

"""

"""

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

int main(){
    int s,h,m,b;
    cin >> s;
    h = s / 3600;
    m = (s % 3600) / 60;
    b = ((s % 3600) % 60);
    cout << h << ":" << m << ":" << b << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, k;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	cin.get();
	for(int i = 1; i <= n; i++){
		char c = cin.get();
		if(i == k) cout << (char)tolower(c);
		else cout << c;
	}
	cout << "\n";
	return 0;
}

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

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

signed main() {
  string s;
  cin >> s;
  int R, B;
  R = count(ALL(s),'0');
  B = s.size() - R;
  cout << s.size() - abs(R-B) << endl;
}

Measured memory_bytes: 512
Module AAAAAAAA
    Sub Main(ByVal args() As String)
        Dim n As Integer = Console.ReadLine()
        Dim h As Integer = Console.ReadLine()
        Dim w As Integer = Console.ReadLine()
        dim ans as integer = 0 
      
    for x　as integer =1 to n
    for y as integer =1 to n
    if x+w-1 <= n then
            if y+h-1 <= n then
                ans +=1
            end if
        end if
      next
      next

    Console.WriteLine(ans)

    End Sub
End Module

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, aa, bb, cc;
  cin >> n >> a >> b;
  aa = 0; 
  bb = 0;
  cc = 0;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    if (vec.at(i) <= a) aa++;
    else if (vec.at(i) > a && vec.at(i) <= b) bb++;
    else cc++;
  }
  cout << min(aa, min(bb, cc)) << endl;
}

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

int main() {
 int n,k;
 long long int stl=1000000000;
 cin >> n >> k;
 vector<int> tree(n);
 for(int i=0;i<n;i++){
   cin >> tree[i];
 }
  sort(tree.begin(),tree.end());
  for(int i=0;i<n-k+1;i++){
   if(tree[i+k-1]-tree[i]<=stl){
    stl=tree[i+k-1]-tree[i];
   }
  }
  cout << stl << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
 
  while (x->l != NIL) {
    x = x->l;
  }
   
  return x;
   
}
 
Node treeSearch(Node x, int k){
   
  if (x == NIL || k == x->key) {
    return x;
  }
   
  if (k < x->key) {
    return treeSearch(x->l, k);
  } else {
    return treeSearch(x->r, k);
  }
   
   
}
 
Node treeSuccessor(Node x){
  Node y;
   
  if (x->r != NIL) {
    return treeMinimum(x->r);
  }
   
  y = x->p;
   
  while (y != NIL && x == y->r) {
    x = y;
    y = y->p;
  }
   
  return y;
   
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
  if (z->l == NIL || z->r == NIL) {
    y = z;
  } else { 
    y = treeSuccessor(z);
  }
   
  if (y->l != NIL) {
    x = y->l;
  } else {
    x = y->r;
  }
   
  if (x != NIL) {
    x->p = y->p;
  }
   
  if (y->p == NIL) {
    root = x;
  } else if (y == y->p->l) {
    y->p->l = x;
  } else {
    y->p->r = x;
  }
   
  if(y != z){
    z->key = y->key;
  }
 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  z->p = NIL;
 
  while(x != NIL){
    y = x;
 
    if(z->key < x->key){
      x = x->l;
    } else {
      x = x->r;
    }
  }
 
  z->p = y;
   
  if(y == NIL){
    root = z;
  } else if(z->key < y->key){
    y->l = z;
  } else {
    y->r = z;
  }
   
 
}
 
 
void inorder(Node u){
   
  if(u->l != NIL){
    inorder(u->l);
  }
   
  printf(" %d",u->key);
   
  if(u->r != NIL){
    inorder(u->r);
  }
   
}
 
void preorder(Node u){
 
  printf(" %d",u->key);
     
  if(u->l != NIL){
    preorder(u->l);
  }
   
  if(u->r != NIL){
    preorder(u->r);
  }
   
}
 
  
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
 
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
   
  return 0;
}

Measured memory_bytes: 19364
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

struct UnionFind {
    vector<int> par;
    vector<int> group_num;
    
    UnionFind(int N) : par(N), group_num(N, 1) {
        for(int n=0; n<N; n++) {
            par[n] = n;
        }
    }
    
    int root(int x) {
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        
        if(rx<ry) {
            par[ry] = rx;
            group_num[rx] += group_num[ry];
        } else {
            par[rx] = ry;
            group_num[ry] += group_num[rx];
        }
    }

    int group_size(int x) {
        return group_num[root(x)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<pair<int, int> > G;
    vector<long long int> ans(M);
    vector<pair<int, int> > rAB(M);
    ans[M-1] = (long long int)N*(long long int)(N-1)/2;
    
    UnionFind tree(N+1);
    
    for(int m=0; m<M; m++) {
        cin >> rAB[M-1-m].first >> rAB[M-1-m].second;
    }
    
    for(int m=0; m<M-1; m++) {
        if(tree.root(rAB[m].first)!=tree.root(rAB[m].second)) {
            int k = tree.group_size(rAB[m].first) * tree.group_size(rAB[m].second);
            ans[M-2-m] = ans[M-1-m] - k;
            tree.unite(rAB[m].first, rAB[m].second);
        } else {
            // cout << rAB[m].first << ", root = " << tree.root(rAB[m].first);
            // cout << endl;
            // cout << rAB[m].second << ", root = " << tree.root(rAB[m].second);
            // cout << endl;
            
            ans[M-2-m] = ans[M-1-m];
        }
    }

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

    return 0;
    
}

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

int main(void){
    long long int a,b,v,w,t,distance0,distance1;

    cin >> a >> v >> b >> w >> t;

    distance0 = abs(a-b);
    distance1 = (v-w) * t;
    if(distance0 <= distance1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  double tax = 1.08;
  cin >> n;

  for (int i = 1; i <= 50000; ++i) {
    if (floor((double)i * tax) == n) {
      cout << i << endl;
      return 0;
    }
  }
  
  cout << ":(" << endl;
  return 0;
}


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

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

int main() {
    int n; cin >> n;
    vector<pair<pair<string,int>,int>> v(n);
    rep(i,n){
        string s; cin >> s;
        int t; cin >> t;
        v[i].first.first = s;
        v[i].first.second = -t;
        v[i].second = i+1;
    }
    sort(v.begin(),v.end());
    rep(i,n){
        cout << v[i].second << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int X, Y; cin >> X >> Y;
    int ans = 0;
    for (int i = 1; i <= 3; i++)
    {
        if (i == X) {
            ans += (4 - i) * 100000;
        }
    }
    for (int i = 1; i <= 3; i++)
    {
        if (i == Y) {
            ans += (4 - i) * 100000;
        }
    }
    if (X == 1 && Y == 1) ans += 400000;
    printf("%d\n", ans);
}

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

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

    sort(a, a+n);
    reverse(a, a+n);
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < n; i += 2){
        alice += a[i];
    }
    for (int i = 1; i < n; i += 2){
        bob += a[i];
    }
    cout << alice - bob << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
h,w=map(int,input().split())
field = [['.' for i in range(w+2)]]
for i in range(h):
    field.append(['.']+list(input())+['.'])
field.append(['.' for i in range(w+2)])
v = [(-1,-1),(0,-1),(1,-1),(-1,0),(1,0),(-1,1),(0,1),(1,1)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if (field[i][j]=='.'):
            count=0
            for a,b in v:
                if field[i+b][j+a]=='#':
                    count+=1
            field[i][j]=str(count)
        print(field[i][j],end='')
    print('')
        

Measured memory_bytes: 3572
#include<stdio.h>
 
int main(){
int H, W, i = 1, j = 1;
while(1){
	scanf("%d %d",&H, &W);
	if(H == 0 && W == 0) break;
	while(i <= H){
		while(j <= W){
			printf("#");
			if(j + 1 <= W) printf(".");
			j = j+2;
		}
		j = 1;
		printf("\n");
		if(i + 1 <= H){
			while(j <= W){
			printf(".");
			if(j + 1 <= W) printf("#");
			j = j+2;
		}
		printf("\n");
		}
		j = 1;
		i = i+2;
	}
		printf("\n");
	i = 1;
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main(){
    int x,c=0;
    bool ok=1;
    cin>>x;
    string s;
    cin>>s;
    if(x%2==1)
    {
        cout<<"No";
    }
    if(x%2==0)
    {
        for(int i=0;i<s.size()/2;i++)
        {
            if(s[i]!=s[i+(x/2)])
            {
                ok=0;
                cout<<"No";

                break;
            }
        }
        if(ok==1)
        {
            cout<<"Yes";
        }
    }
return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define LLI long long int
int main() {
    cout << fixed << setprecision(10);
    int n,p;
    string s;
    cin >> n >> p >> s;

    if (p == 5 || p == 2) {
        LLI ans = 0;
        for (int i = 0; i < n; i++)if ((s[i] - '0') % p == 0)ans += i + 1;
        cout << ans;
        return 0;
    }

    LLI ans = 0;
    int num = 0;
    int power = 1;
    vector<LLI> v(p);
    v[0] = 1;
    for (int i = n - 1; 0 <= i; i--)
    {
        num = (num + power * (s[i] - '0')) % p;
        power = (power * 10) % p;
        ans += v[num];
        v[num]++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
function main(input) {
  input = input.trim();
  const [a,b,c] = input.split(' ').map(Number);
  i_max = Math.max(a,b,c)
  i_sum = a+b+c
  console.log((i_max*2==i_sum) ? 'Yes' : 'No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30384
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int ans=1;
	for(int i=0;i!=a;i++) {
		if(ans<b) {
			ans*=2;
		}
		else {
			ans+=b;
		}
	}
	System.out.println(ans);
	scan.close();
}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;
typedef long long ll;
ll a,b,c,i,j,k,n,m,t,r,s,p;
ll arr[100005];


int main(){
	scanf("%lld%lld%lld",&a,&b,&c);
	i=0; j=0;
	if(a==5) i++; if(a==7) j++;
	if(b==5) i++; if(b==7) j++;
	if(c==5) i++; if(c==7) j++;
	if(i==2&&j==1) printf("YES");
	else printf("NO");
	return 0;
}


Measured memory_bytes: 256
q, h, s, d = map(int, input().split())
n = int(input()) * 4
L = sorted([ [8*q, q, 1], [4*h, h, 2], [2*s, s, 4], [d, d, 8] ])
A = [ i[1:] for i in L ]
ans = 0
for p, a in A:
  ans += (n//a) * p
  n %= a
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main(){
    int n,k;
    cin >> n >> k;
    if(k%2==1){
        ll x=n/k;
        cout << x*x*x << endl;
        return 0;
    }
    else{
        ll x=n/k;
        ll l=k/2;
        ll y=n/l - x;
        cout << x*x*x + y*y*y << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let s: String = read!(String);
    let c: Vec<char> = s.chars().collect();

    // 最初は絶対引き分け（条件を満たすため）
    // TopCoDeerがどういう戦略で来ようとも gpgpgpgp...とgpを交互に出すのが最善である
    let mut point = 0;
    for i in 0..c.len() {
        if i % 2 == 0 {
            // このときはgをだす
            point += if c[i] == 'g' { 0 } else { -1 }
        } else {
            // pをだす
            point += if c[i] == 'g' { 1 } else { 0 }
        }
    }
    println!("{}", point);
}


Measured memory_bytes: 4352
import cmath
import math
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def det(a: complex, b: complex):
    # 外積
    return a.real * b.imag - a.imag * b.real


def graham_scan(points):
    """
    凸包
    :param list of complex|np.ndarray points:
    :rtype: list of complex
    """
    if len(points) <= 2:
        return list(points)
    points = np.sort_complex(points)
    # Graham Scan
    sz = 0
    #: :type: list of (complex|None)
    ret = [None] * (N * 2)
    for p in points:
        while sz > 1 and det(ret[sz - 1] - ret[sz - 2], p - ret[sz - 1]) <= 0:
            sz -= 1
        ret[sz] = p
        sz += 1
    floor = sz
    for p in reversed(points[:-1]):
        while sz > floor and det(ret[sz - 1] - ret[sz - 2], p - ret[sz - 1]) <= 0:
            sz -= 1
        ret[sz] = p
        sz += 1
    ret = ret[:sz - 1]
    return ret


N = int(sys.stdin.buffer.readline())
X, Y = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))
TAU = math.pi * 2

points = [complex(x, y) for x, y in zip(X, Y)]
pos = {p: i for i, p in enumerate(points)}

# 凸包
points = graham_scan(points)
points = np.array(points, dtype=complex)
assert len(points) >= 2

ans = [0.0] * N

if len(points) == 2:
    ans[pos[points[0]]] = 0.5
    ans[pos[points[1]]] = 0.5
    print(*ans, sep='\n')
    exit()

# 中心からの角度でソート
center = points.mean()
idx = np.angle(points - center).argsort()
points = points[idx]

for i in range(len(points)):
    pr = points[(i + 1) % len(points)]
    p = points[i]
    pl = points[(i - 1) % len(points)]

    # 凸包の内側から、頂点の両隣の辺に垂線をおろしたときの角度
    # pi - 角度
    ans[pos[p]] += (math.pi - (cmath.phase(pl - p) - cmath.phase(pr - p)) % TAU) / TAU

print(*ans, sep='\n')

# from matplotlib import pyplot as plt
#
# points -= center
# theta = [cmath.phase(p) for p in points]
# r = np.array([abs(p) for p in points])
#
# fig = plt.figure()
# ax = fig.add_subplot(111, projection='polar')
# ax.set_ylim([-max(r) * 1.2, max(r) * 1.2])
# ax.scatter(theta, r)
# plt.show()
# print(r)


Measured memory_bytes: 13588
#include<bits/stdc++.h>
#define MAXN 100005
#define inf 1000000000001
using namespace std;
 
int main (){
	
	//freopen("t.txt","r",stdin);
	int a,b;
	cin>>a>>b;
	int d=0;
	
	if (b==1){
		cout<<0;
	}
	
	else{
		
		if (b<=a){
		cout<<1;
	}
	else{
		while (b>=a){
			b-=a-1;
			d++;
		}
		
		if (b==1){
			cout<<d;
		}
		else{
			cout<<d+1;
		}
		
	}
		
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
ll a;
cin >> a;
cout << a/500*1000+a%500/5*5 << endl;
}

Measured memory_bytes: 256
N = int(input())
nums = list(map(int,input().split()))
count = 0
for i in range(N):
  if nums[i] == (i+1):
    if i <=N-2:
      nums[i] = nums[i+1]
      nums[i+1] = (i+1)
    count += 1
print(count)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
long long Abs(long long x){
	return x>0?x:-x;
}
void chkmin(long long &x,long long y){
	x=x<y?x:y;
}
int main(){
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	long long ans=n*2;
	if(a%2==b%2)
		ans=Abs(a-b)/2;
	else{
		chkmin(ans,(a-1+b)/2);
		chkmin(ans,(Abs(n-a)+Abs(n-b)+1)/2);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
class Main{
  public static void main(String[] args) {
    try {
        var stdin = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        while((line = stdin.readLine()) == null);
        if (line.equals("SSS") ) {
            System.out.println("0");
        } else if(line.equals("SSR") || line.equals("SRS") || line.equals("RSS") || line.equals("RSR")) {
            System.out.println("1");
        } else if (line.equals("RRR") ){
            System.out.println("3");
        } else {
            System.out.println("2");
        }
    } catch(Exception e) {
    }
   
  }
}

Measured memory_bytes: 32728
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;
string S,T;
ll fun ( int n )
{
   ll i,j=0;
   for (i = n; i-n < T.length() && i < S.length() ;i++)
   if(S[i]!=T[i-n])j++;
   return j;
}
int main()
{
    fio;
    ll t, a, n, q, k, i, l, m, c, u, f, j, p, x, y, b, d;
   
    cin >> S >> T;
 c= INT_MAX;
for(i=0;i+T.length()-1<S.length();i++)
c=min(fun(i),c);

cout<<c<<endl;
  

return 0;
}


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

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    /* 全探索の場合 */
    /*
    int min = 10e5;
  	int money;
    for(int i=0; i<=X; i++){
        for(int j=0; j<=Y; j++){
            for(int k=0; k<=2*max(X,Y); k++){
              	money = A*i+B*j+C*k;
                if(min > money && i+k/2 >= X && j+k/2 >= Y) min = money;
            }
        }
    }
    */

   /* O(1)探索の場合 */
   int money;
   if(A+B > 2*C){
       if(min(X,Y) == X){
           if(B > 2*C) money = 2*C*Y;
           else money = 2*C*X + B*(Y-X);
       }
       else{
           if(A > 2*C) money = 2*C*X;
           else money = 2*C*Y + A*(X-Y);
       }
   }
   else{
       money = A*X + B*Y;
   }

    cout << money;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<set>
using namespace std;
#define pb push_back
#define POP pop_back()
#define ll long long
#define db double
#define POP pop_back()
#define endl '\n'
#define PII pair<int,int>
#define FI first
#define SE second
#define VI vector<int>
#define QI queue<int>
#define SI stack<int>
#define debug cout<<"debug"<<endl;
#define PLL pair<LL,LL>
#define PDD pair<double,double>
#define ULL unsigned long long
#define fo(i,a,b) for (int i=a;i<=b;++i)
#define fd(i,a,b) for (int i=a;i>=b;--i)
#define mem(x,a) memset(x,a,sizeof(x))
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main(){
	int n;cin >> n;
	bool ok = 0;
	while(1){
		if(n == 0)break;
		int cnt = n%10;
		if(cnt == 7)ok = 1;
		n /= 10;
	}
	puts(ok?"Yes":"No");
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
<?php

$arr = array();
for ($i = 1; $i <= 100; $i++) {
    $arr[$i] = 0;
}

while (($line = trim(fgets(STDIN))) !== '') {
    sscanf($line, '%d', $n);
    $arr[$n]++;
}

$max = max($arr);
foreach ($arr as $n => $m) {
    if ($m === $max) {
        echo $n, PHP_EOL;
    }
}

Measured memory_bytes: 6620
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#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 set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int X,A,B;
  cin >> X;
  cin >> A;
  cin >> B;
  cout << (X-A) % B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define int long long int

main()
{
    int n, w;
    std::cin >> n >> w;

    int dp[110][100010] = { 0 };

    int weight, value;
    for (int i = 1; i <= n; ++i)
    {
        std::cin >> weight >> value;

        for (int j = 0; j <= w; ++j)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= weight)
                dp[i][j] = std::max(dp[i][j], dp[i - 1][j - weight] + value);
        }
    }

    std::cout << dp[n][w];
}


Measured memory_bytes: 86144
//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int arr[6];
		for(int i=1;i<=5;++i)
		{
			cin>>arr[i];
			if(arr[i]==0)
			{
				cout<<i;
				return 0;
			}
		}
    }
    return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n, x;
  cin >> n >> x;
  int a[110000];
  ll ans = 0;
  for(int i = 0; i < n; i++) cin >> a[i];
  if(a[0] > x){
    ans += a[0] - x;
    a[0] = x;
  }
  for(int i = 0; i < n-1; i++){
    if(a[i] + a[i+1] > x){
      ans += a[i+1] + a[i] - x;
      a[i+1] = x - a[i];
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool cmp(char a,char b){
	return a>b;
}
int main(){
	string s,t;
	cin>>s;
	cin>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	if(s<t)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    lli k, a, b;
    cin >> k >> a >> b;
    lli c = a - b;
    if (c <= 0) {
        if (k <= a) {
            cout << 1 << endl;
        } else {
            cout << -1 << endl;
        }
    } else {
        using ll = __int128;
        ll up = 2 * 1e18 + 10;
        ll low = -1;
        while (up - low > 1) {
            ll mid = (up + low) >> 1;
            if (mid * (a - b) + a >= k) {
                up = mid;
            } else {
                low = mid;
            }
        }
        cout << (lli)(2 * up + 1) << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/	
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

ll power( ll a, ll n, ll m= 1000000007){
  ll ans = 1;
  while(n){
  if(n&1)
  {
  ans *= a;
  ans%=m;
  }
  a*=a;
  a%=m;
  n/=2;
  }
  return ans ;
} 


vector< int > prm ;
vector < bool > vsp ;

void prime ( int nn = 100000 ) {
	vsp = vector < bool > ( nn+1, 0 );
	int size_prime = nn;
	for( ll i =2; i*i < size_prime ; i++){
		
		if( vsp[i] == 1)
		continue;
		for(ll j = i*i; j < size_prime ;j+=i){
			
			vsp[j] =1;
			
		}
		
		
	}
	
	for( int i= 2; i < size_prime ; i++)
	if (vsp[i] == 0)
	prm.pb(i);
	
	
}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...
// never forget  to recheck your predefined function in template .. 
// already defined ::  prime , power , gcd : ( ll ).. 








int Main(){
  
  
  string s;
  cin>>s;
  
  if( s[s.length() -1 ] == 's'){
	  s+="es";
	  
	 }
	 else
	 s+="s";
	 
	 cout<<s<<endl;	
	  
  
  
  
return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;
}


  




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

#define pii pair<int, int>
#define x first
#define y second

const int N = 1e5+5;

int n, s1, s2;
int A[N];
map<int, int> m1, m2;

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) scanf("%d", A+i);
    for(int i = 1; i <= n; ++i) {
        s1 += i & 1, s2 += ~i & 1;
        if(i & 1) m1[A[i]]++;
        else m2[A[i]]++;
    }
    vector<pii> v1, v2;
    v1.emplace_back(-1, 0), v2.emplace_back(-1, 0);
    for(auto x : m1) v1.emplace_back(x);
    for(auto x : m2) v2.emplace_back(x);
    sort(v1.begin(), v1.end(), [](const pii &a, const pii &b) { return a.y > b.y; });
    sort(v2.begin(), v2.end(), [](const pii &a, const pii &b) { return a.y > b.y; });
    if(v1[0].x == v2[0].x) printf("%d\n", min(s1 - v1[0].y + s2 - v2[1].y, s1 - v2[0].y + s2 - v1[1].y));
    else printf("%d\n", s1 + s2 - v1[0].y - v2[0].y);
}

Measured memory_bytes: 6520
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    
    
    cout<<n-k+1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int x,a;
  cin>>x>>a;
  if(x<a) cout<<0;
  else cout<<10<<endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n;
  cin >> n;

  vll a(n + 2);
  vll b(n + 2);

  REP(i, n + 2) {
    cin >> a[i];
  }

  REP(i, n + 1) {
    cin >> b[i];
  }

  ll ans = 0;
  REP(i, n + 2) {
    ll d = min(a[i], b[i - 1]);
    ans += d;
    a[i] -= d;
    b[i - 1] -= d;

    d = min(a[i], b[i]);
    ans += d;
    a[i] -= d;
    b[i] -= d;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
const int N=1e9+3;
#define int long long
#define double long double

int32_t main()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 IOS;
 
 	int n,k;
 	cin>>n>>k;
 	int a[n+1];
 	for (int i = 1; i <= n; ++i)
 	{
 		cin>>a[i];
 	}
 	int dp[n+1];
 	dp[1]=0;
 	for (int i = 2; i <= n; ++i)
 		dp[i]=INT_MAX;
 	for (int i = 2; i <= n; ++i)
 	{
 		int c=1;
 		for (int j =i-1; c<=k&&c<=n&&j>=1; j--)
 		{
 			c++;
 			dp[i]=min(dp[j]+abs(a[i]-a[j]),dp[i]);
 		}
 	}
 	cout<<dp[n]<<endl;
 	



  
 




  
return 0;
}


Measured memory_bytes: 5156
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

#define P 1000000007

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  vector<int> a;
  a.resize(n);
  vector<vector<int>> c;
  c.resize(h);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < h; i++) c[i].resize(w);
  int ww = 0, hh = 0;
  bool v = false;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < a[i]; j++) {
      if(v) {
        c[hh][ww] = i + 1;
        ww--;
        if(ww < 0) {
          ww = 0;
          hh++;
          v = false;
        }
      } else {
        c[hh][ww] = i + 1;
        ww++;
        if(ww >= w) {
          ww = w - 1;
          hh++;
          v = true;
        }
      }
    }
  }
  for(int i = 0; i < h; i++) {
    cout << c[i][0];
    for(int j = 1; j < w; j++) cout << " " << c[i][j];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            int X = Integer.valueOf(args.get(0).split(" ")[1]);
            List<Integer> numList = Arrays.stream(args.get(1).split(" ")).map(Integer::valueOf).collect(Collectors.toList());
            int ans = 1;
            int acm = 0;
            for (int num: numList) {
                acm += num;
                if (acm <= X) ans++;
            }
            System.out.println(ans);
        };
    }

}


Measured memory_bytes: 27092
#include<iostream>

using namespace std;

const int MAX_N = 100000;

/**
 * 入力
 * 1 <= N <= 10^5
 * 1 <= ai, bi, ci <= 10^4
 */
int N;
int A[MAX_N];
int B[MAX_N];
int C[MAX_N];
int P[MAX_N][3];


void solve() {

    P[0][0] = A[0];
    P[0][1] = B[0];
    P[0][2] = C[0];

    for (int i = 1; i < N; i++) {
        // A
        P[i][0] = A[i] + max(P[i-1][1], P[i-1][2]);
        // B
        P[i][1] = B[i] + max(P[i-1][0], P[i-1][2]);
        // C
        P[i][2] = C[i] + max(P[i-1][0], P[i-1][1]);
    }
    
    cout << max(P[N-1][0], max(P[N-1][1], P[N-1][2])) << endl;
}

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }

    solve();

}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int a,b,c,d = 0;
		String hantei = "No";

		Scanner scan = new Scanner(System.in);
		a = Integer.parseInt(scan.next());
		b = Integer.parseInt(scan.next());
		c = Integer.parseInt(scan.next());
		d = Integer.parseInt(scan.next());

		if(-d <= a-c && a-c <= d) {
			hantei = "Yes";
		}

		if((a <= b && b <= c) || (c <= b && b <= a)) {
			if((-d <= a-b && a-b <=d) && (-d <= c-b && c-b <=d)) {
			hantei = "Yes";
			}

		}

		System.out.println(hantei);

	}
}


Measured memory_bytes: 21972
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, m = [int(x) for x in input().split()]
g = [[] for _ in range(n)]
for _ in range(m):
    x, y = [int(x) for x in input().split()]
    g[x - 1].append(y - 1)

memo = [0]*n
visited = [False]*n

def dp(v):
    if visited[v]:
        return memo[v]
    else:
        res = 0
        for u in g[v]:
            res = max(res, dp(u) + 1)
        memo[v] = res
        visited[v] = True
        return res

for i in range(n):
    dp(i)
print(max(memo))




Measured memory_bytes: 59824
#include<bits/stdc++.h>
clock_t t=clock();
namespace IO
{
	using namespace std;
	char buf[1<<22],Out[1<<22],*p1=buf,*p2=buf;
	int p3=-1,f=0;
	inline void file()
	{
		#ifdef NTFOrz
		freopen("file.in","r",stdin);
		#endif
	}
	inline char getchar()
	{
		return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
	}
	inline void flush(){fwrite(Out,1,p3+1,stdout),p3=-1;}
	inline void check(){if (p3>(1<<21)) flush();}
	inline void putchar(char a){Out[++p3]=a;check();}
	inline void putline(string s)
	{
		int tmp=p3;
		while (p3-tmp<s.size()) putchar(s[p3-tmp]);
		putchar('\n');
	}
	inline char gc()
	{
		char c=getchar();
		while (!c||c=='\n'||c==' ') c=getchar();
		return c;
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		printf("%dms\n",clock()-t);
		#endif
	}
}
namespace my_std
{
	using namespace std;
//	#define getchar IO::getchar
//	#define putchar IO::putchar
    #define Re register
    #define rep(i,a,b) for (Re int i=(a);i<=(b);i++)
    #define drep(i,a,b) for (Re int i=(a);i>=(b);i--)
    #define repv(i,v) for (Re int i=0;i<v.size();i++)
    #define go(u) for (Re int i=head[(u)];i;i=e[i].nxt)
    #define writesp(x) write(x),putchar(' '),IO::check()
    #define writeln(x) write(x),putchar('\n'),IO::check()
    #define mem(x,v) memset(x,v,sizeof(x))
    #define pb push_back
    #define fir first
    #define sec second
    #define MP make_pair
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int,int> pii;
    const int INF=0x7fffffff;
    inline int read()
    {
        ll sum=0,f=0;char c=getchar();
        while (!isdigit(c)) f|=(c=='-'),c=getchar();
        while (isdigit(c)) sum=(sum<<1)+(sum<<3)+(c^48),c=getchar();
        return f?-sum:sum;
    }
    void write(int k)
    {
        if (k<0) putchar('-'),k=-k;
        if (k>=10) write(k/10);
        putchar(k%10+48);
    }
	#define templ template<typename T>
    templ inline void chkmax(T &x,T y){if (x<y) x=y;}
    templ inline void chkmin(T &x,T y){if (x>y) x=y;}
}
using namespace my_std;
char c[114514];
int ___[114514];
stack<int>s;
inline int query(int x,int y)
{
	printf("? %d %d\n",x,y);fflush(stdout);
	scanf("%s",c+1);
	return c[1]=='Y';
}
 
int main()
{
	IO::file();
	int a=read(),b=read(),n=a+b;
	if (a<=b) return printf("Impossible\n"),0;
	rep(i,0,n-1)
	{
		if (!s.size()) s.push(i);
		else
		{
			if (query(s.top(),i)) s.push(i);
			else s.pop();
		}
	}
	rep(i,0,n-1) ___[i]=query(s.top(),i);
	printf("! ");
	rep(i,0,n-1) printf("%d",___[i]);
	IO::flush();
	IO::chktime();
	return 0;
}

Measured memory_bytes: 3892
#include "bits/stdc++.h"

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

typedef pair< int, int > Pi;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

int n,a[1<<18];
P dp1[1<<18];
int dp2[1<<18];

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

void solve(){
	dp1[0]=P(0,0);
	for(int i=1;i<(1<<n);i++){
		vector<int>v;
		v.eb(i);
		for(int j=0;j<n;j++){
			if(!(i&(1<<j)))continue;
			v.eb(dp1[i-(1<<j)].fr);
			v.eb(dp1[i-(1<<j)].sc);
		}
		sort(ALL(v));
		v.erase(unique(ALL(v)),v.end());
		sort(ALL(v),[&](int c,int d){return a[c]>a[d];});
		dp1[i].fr=v[0];
		dp1[i].sc=v[1];
	}
	for(int i=1;i<(1<<n);i++){
		dp2[i]=a[dp1[i].fr]+a[dp1[i].sc];
	}
	for(int i=1;i<(1<<n);i++){
		dp2[i]=max(dp2[i],dp2[i-1]);
		cout<<max(dp2[i],dp2[i-1])<<endl;
	}
	return;
}

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


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

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

  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  cout << d.at(N/2) - d.at(N/2 - 1);
}

Measured memory_bytes: 640