akhauriyash/Code-Regression huggingface dataset:
#pragma comment (linker,"/STACK:1024000000") 
#pragma GCC optimize(2)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

#define all(A) (A).begin(), (A).end()
#define sz(A) int((A).size())

using namespace std;

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


inline int max (const int& a, const int& b) { return a <= b ? b : a; }

inline pii merge (pii x, pii y) {
  int first_mx = max(x.first, y.first);
  int second_mx = max(x.second, y.second);
  if (first_mx == x.first) second_mx = max(second_mx, y.first);
  if (first_mx == y.first) second_mx = max(second_mx, x.first);
  return std::move(pii(first_mx, second_mx));
}

const int MAX_N = 1e5 + 10;

int n;
pii st[2 * MAX_N];

void build () {
  for (int i = n - 1; i > 0; i--) st[i] = merge(st[i << 1], st[i << 1 | 1]);
}

pii getMax (int l, int r) {
  r++;
  pii res(-1, -1);
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) res = merge(res, st[l++]);
    if (r&1) res = merge(res, st[--r]);
  }
  return res;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  vector <int> arr(n + 1);
  vector <int> pos(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    pos[arr[i]] = i;
    st[n + i] = pii(arr[i], -1);
  }
  build();
  function <pii(int,int)> getRange = [&] (int num, int sec) -> pii {
    pii exp(num, sec);
    int l1 = 0, r1 = pos[num];
    while (l1 != r1) {
      int m = (l1 + r1) >> 1;
      pii cur = getMax(m, pos[sec]);
      if (exp == cur) r1 = m;
      else l1 = m + 1;
    }
    int l2 = pos[num], r2 = n - 1;
    while (l2 != r2) {
      int m = (l2 + r2 + 1) >> 1;
      pii cur = getMax(pos[sec], m);
      if (exp == cur) l2 = m;
      else r2 = m - 1;
    }
    return pii(l1, l2);
  };
  function <pii(int)> getRange2 = [&] (int num) -> pii {
    int l1 = 0, r1 = pos[num];
    while (l1 != r1) {
      int m = (l1 + r1) >> 1;
      pii cur = getMax(m, pos[num]);
      if (num == cur.first) r1 = m;
      else l1 = m + 1;
    }
    int l2 = pos[num], r2 = n - 1;
    while (l2 != r2) {
      int m = (l2 + r2 + 1) >> 1;
      pii cur = getMax(pos[num], m);
      if (num == cur.first) l2 = m;
      else r2 = m - 1;
    }
    return pii(l1, l2);
  };
  ll ans = 0;
  for (int sec = 1; sec < n; sec++) {
    pii ran = getRange2(sec);
    pii l = pii(-1, -1);
    pii r = pii(-1, -1);
    if (0 <= ran.first - 1) l = getRange(arr[ran.first - 1], sec);
    if (ran.second + 1 < n) r = getRange(arr[ran.second + 1], sec);
    if (l.first != -1) {
      l.second = ran.first - 1;
      ll x = l.second - l.first + 1;
      ll y = ran.second - pos[sec] + 1;
      ans += x * y * sec;
    }
    if (r.first != -1) {
      r.first = ran.second + 1;
      ll x = r.second - r.first + 1;
      ll y = pos[sec] - ran.first + 1;
      ans += x * y * sec;
    }
  }
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(void){
    int a, b, c;
    scanf("%d", &a);

    b = 1;

    for(int i = 0; i < 2; i++){
        b = b*a;
        c = b*a;
    }
    printf("%d\n", a+b+c);
    return 0;
}


Measured memory_bytes: 1712
import java.util.ArrayList
fun main(args :Array<String>){
    val N :Int = readLine()!!.toInt()
    val name : ArrayList<String> = ArrayList(N)
    var m :Long= 0
    var a :Long= 0
    var r :Long= 0
    var c :Long= 0
    var h :Long= 0
    var sum :Long
    var ans :Long = 0
    repeat(N){
        name.add(readLine()!!)
    }
    for(i in name.indices){
        if(name[i].get(0) == 'M'){
            m++
        }
        if(name[i].get(0) == 'A'){
            a++
        }
        if(name[i].get(0) == 'R'){
            r++
        }
        if(name[i].get(0) == 'C'){
            c++
        }
        if(name[i].get(0) == 'H'){
            h++
        }
    }
    //println("$m $a $r $c $h")
    val march : List<Long> = listOf(m ,a ,r ,c ,h)
    for(x in march.indices){
        for(y in march.indices){
            for(z in march.indices){
                if(x != y && x != z && y != z){
                    sum = 0
                    sum = march[x] * march[y] * march[z]
                    ans += sum
                    
                }
            }
        }
    }
    println(ans / 6)

}


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

ll c2(ll x)
{
  return x*(x-1)/2;
}

int main(){
  int n;cin>>n;
  vector<int> a(n);
  map<int,ll> mp1;
  for (auto &&i : a)
  {
    cin >> i;
    mp1[i]++;
  }
  vector<ll> ans;
  ll calc = 0;
  for (auto &&i : mp1)
  {
    calc += c2(i.second);
  }
  

  for (auto &&i : a)
  {
    ll tmp = calc;
    tmp -= mp1[i] - 1;
    ans.push_back(tmp);
  }
  for (auto &&i : ans)
  {
    cout << i << endl;
  }
  
}


Measured memory_bytes: 14032
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

   
int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S, T; cin >> S >> T;
    int N = S.size();

    bool ok = true;
    map<char, char> from, to;
    
    REP(i,N) {
        if (to.count(S[i])>0 || from.count(T[i])>0) {
            if (to[S[i]]!=T[i] || from[T[i]]!=S[i]) {
                ok = false;
                break;
            }
        }
         
        to[S[i]] = T[i];
        from[T[i]] = S[i];
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

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

int main(){
    int n, f, fy, ly;
    scanf("%d%d%d%d", &n, &f, &fy, &ly);
    if(n>f)
        printf("%d", ((n-f)*ly)+(n-(n-f))*fy);
    else
        printf("%d", n*fy);
return 0;
}


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

int main()
{
    cin.tie(0);
    int64_t n;
    cin >> n;

    vector<int64_t> as(n);

    int64_t sum = 0;
    for (auto& a : as) {
        cin >> a;
        sum += a;
    }

    // int64_t lo = 0, hi = sum;
    // while (hi - lo > 1) {
    //     int64_t mi = (hi + lo) / 2;

    //     int64_t tt = 0;
    //     for (auto& a : as) {
    //         tt += (a + mi) / (n + 1);
    //     }

    //     cout << lo << " - " << hi << ": " << tt << endl;

    //     if (mi >= tt) {
    //         lo = mi;
    //     } else {
    //         hi = mi;
    //     }
    // }

    // cout << lo << endl;

    int64_t v = 0;
    for (;;) {
        sort(as.begin(), as.end());
        if (as[n - 1] < n) {
            break;
        }

        // for (int i = 0; i < n; i++) {
        //     cout << as[i] << " ";
        // }
        // cout << endl;

        if (as[0] >= n) {
            int64_t dec = as[0] - (n - 1);
            for (int i = 0; i < n; i++) {
                as[i] -= dec;
            }
            v += dec * n;
            continue;
        }

        int64_t dec = as[n - 1] / n;
        as[n - 1] %= n;
        v += dec;
        for (int i = 0; i < n - 1; i++) {
            as[i] += dec;
        }
    }
    cout << v << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh

int main(){
	dhoom;
	int n;
	cin >> n;
	for(int i = 0 ; i < n ; i++)
	{
		int x;
		cin >> x;
		if(x & 1) continue;
		if(x % 3 != 0 && x % 5 != 0)
			{
				cout << "DENIED" << endl;
				return 0;
			}
		
	}
	cout << "APPROVED" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int H, W, d;
    cin >> H >> W >> d;
    char c[500][500];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int x = i+j;
            int y = i-j;
            int X, Y;
            if(x < 0 && x%d != 0) X = x/d-1;
            else X = x/d;
            if(y < 0 && y%d != 0) Y = y/d-1;
            else Y = y/d;
            //cout << X << ' ' << Y;
            if(X%2 == 0 && Y%2 == 0) cout << 'R';
            if(X%2 == 0 && Y%2 != 0) cout << 'Y';
            if(X%2 != 0 && Y%2 == 0) cout << 'G';
            if(X%2 != 0 && Y%2 != 0) cout << 'B';
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int s[201],k[201][4],o[201];
int main()
{
	int i,j,n,m;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>k[i][1]>>k[i][2]>>k[i][3];
	}
	for(i=1;i<=3;i++)
	{
		memset(s,0,sizeof(s));
		for(j=1;j<=n;j++)
		{
			for(m=j+1;m<=n;m++)
			{
				if(k[j][i]==k[m][i])
				{
					s[j]=1;
					s[m]=1;
					break;
				}
			}
		}
		for(j=1;j<=n;j++)
		{
			if(s[j]!=1)
			{
				o[j]=o[j]+k[j][i];
			}
		}
	}
	for(i=1;i<=n;i++)cout<<o[i]<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<utility>
#include<algorithm>
#include<functional>
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long int LL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VP;
const LL INF = 3e18;

LL n, m, c;
LL a[200010], b[200010], d[200010];

VP road[100010];
LL dist[100010];
PLL dist_road[200010];
priority_queue<PLL, VP, greater<PLL> > Q;

LL last = 0, ans = INF;
LL last_dist = 0;

void dijk()
{
  memset(dist, -1, sizeof dist);
  Q.push(MP(0, 1));

  while(!Q.empty()){
    PLL now = Q.top();
    Q.pop();

    if(dist[now.second] == -1){
      dist[now.second] = now.first;

      for(LL i = 0; i < road[now.second].size(); i++)
	Q.push(MP(now.first + road[now.second][i].first, road[now.second][i].second));
    }
  }
  return;
}
 
int main()
{
  scanf("%lld%lld%lld", &n, &m, &c);
  for(LL i = 0; i < m; i++){
    scanf("%lld%lld%lld", &a[i], &b[i], &d[i]);
    road[a[i]].PB(MP(d[i], b[i]));
    road[b[i]].PB(MP(d[i], a[i]));
  }
  
  dijk();

  for(LL i = 0; i < m; i++)
    dist_road[i] = MP(max(dist[a[i]], dist[b[i]]), i);

  sort(dist_road, dist_road + m);

  for(LL i = 0; i < m; i++)
    last += d[i];
  ans = last;

  for(LL i = 0; i < m; i++){
    last += c * (dist_road[i].first - last_dist);
    last_dist = dist_road[i].first;
    last -= d[dist_road[i].second];

    ans = min(ans, last);
  }
  
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 28256
a,b,c,x,y = map(int,input().split())

if a+b < 2*c:
    ans = a*x+b*y
else:
    if x > y:
        if a > 2*c:
            ans = 2*c*x
        else:
            ans = a*(x-y)+2*c*y
    else:
        if b > 2*c:
            ans = 2*c*y
        else:
            ans = b*(y-x)+2*c*x

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

int main()
{
	
ll n,a,b;
cin>>a>>b;ll i;
for(i=min(a,b);i<=1000000;i++)
{
	ll p=(i*8)/100;ll q=i/10;
	//cout<<p<<" "<<q<<endl;
	if(p==a && q==b)
	{
		cout<<i;return 0;
	}
}
if(i==1000001)cout<<"-1";
}

Measured memory_bytes: 256
def solve():
    n, k=map(int, input().split())
    p=list(map(int, input().split()))
    p.sort()

    t=0
    for i in range(k):
        t+=p[i]

    print(t)


if __name__ == '__main__':
    t=1
    for _ in range(t):
        solve()


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

//関数
    //const long INF=1000000000000000;
    
//main関数
int main() {
    
    
    //入力
    long N,K;
    cin>>N>>K;
    vector<long> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    
    
    
    
    //計算
    long maxi=0,tempKsum=0,tempKmaxi=0;
    for(int i=0;i<K;i++){
        tempKmaxi+=max((long)0,a.at(i));
        tempKsum+=a.at(i);
    }
    long rakusa=tempKmaxi-max((long)0,tempKsum);
    maxi=tempKmaxi;
    
    //cout<<maxi<<" "<<tempKsum<<" "<<tempKmaxi<<" "<<rakusa<<endl;
    for(int i=K;i<N;i++){
        maxi+=max((long)0,a.at(i));
        tempKsum+=(a.at(i)-a.at(i-K));
        tempKmaxi+=(max((long)0,a.at(i))-max((long)0,a.at(i-K)));
        rakusa=min(rakusa,tempKmaxi-max((long)0,tempKsum));
        
        //cout<<maxi<<" "<<tempKsum<<" "<<tempKmaxi<<" "<<rakusa<<endl;
    }
    
    //出力
    cout<<maxi-rakusa<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int SIZE = 55;
long long dp[SIZE][SIZE];
void make_pascal_triangle(){//パスカルの三角形を使って求める　O(n^2).
    for (int i = 0; i < SIZE; i++){
        dp[i][0] = dp[0][i] = 1;
    }
    for (int i = 1; i < SIZE; i++){
        for (int j = 1; j < SIZE; j++){
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
        }  
    }
}

long long C (int n, int k){//nCkを求める
    return dp[n-k][k];
}


int main(){
    make_pascal_triangle();
    int n, a, b; cin >> n >> a >> b;
    vector<long long> A;
    for (int i = 0; i < n; i++){
        long long v; cin >> v;
        A.push_back(v);
    }
    sort(A.begin(), A.end());
    double ave = 0;
    for (int i = 0; i < a; i++){
        ave += A[n-i-1];
    }
    ave /= a;
    cout << fixed << setprecision(7) << ave << endl;
    if (A[n-a] != A[n-1])
    {
        int cnt_0 = 0;
        for (int i = 1; i <= a; i++){
            cnt_0 += A[n-i] == A[n-a]; 
        }
        int cnt_1 = 0;
        for (int i = 1; i <= n; i++){
            cnt_1 += A[n-i] == A[n-a];
        }
        cout << C(cnt_1, cnt_0) << endl;
    }
    else{
        long long ans = 0;
        int cnt_1 = 0;
        for (int i = 1; i <= n; i++){
            cnt_1 += A[n-i] == A[n-a];
        }
        for (int i = a; i <= b; i++){
            if(A[n-a] == A[n-i])
                ans += C(cnt_1, i);
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 256
def factorial_cor(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in l:
  for j in l:
    for k in l:
      if i != j and j != k and k != i:
        if i + j > k:
          if j + k > i:
            if k + i > j:
              ans += 1
              
              
          
print(ans // factorial_cor(3))


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

//X,Y,Zを全部Kまで動かすと TLE
int main(){
  int K,S;cin>>K>>S;
  int count=0;
  for(int X=0;X<=K;X++){
    for(int Y=0;Y<=K;Y++){
      int Z=S-X-Y;
      if(Z>=0 && Z<=K) count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL)
    x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key)
    return u;
  if(k<u->key)
    return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL)
    y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL)
    x=y->left;
  else x=y->right;

  if(x!=NIL)
    x->parent=y->parent;

  if(y->parent==NIL)
    root=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else y->parent->right=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->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(Node u){
  if(u==NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


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: 25140
#include <bits/stdc++.h>

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    char c;
    cin>>c;

    cout << (char)(c+1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if((1<=a && a<= 9) && (1<=b && b<= 9)){
			System.out.println(a*b);
		}else {
			System.out.println(-1);
		}
	}
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    int s = accumulate(begin(A), end(A), 0);

    int k = 0;
    for(int c : A) {
        if(c * 4 * M >= s) ++k;
    }
    cout << (k >= M ? "Yes\n" : "No\n");
}

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

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	char c[3][3];
	rep(i, 0, 3)rep(j, 0, 3) cin >> c[i][j];

	cout << c[0][0] << c[1][1] << c[2][2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 10005
#define MOD 998244353
#define INF 10000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll dp[maxn];

void solve(){
    ll n, p;
    cin >> n >> p;
    string s;
    cin >> s;

    ll ans = 0;
    if(p == 2){
        for(ll i = 0; i  < n; i++){
            ll d = s[i] - '0';
            if(d%2 == 0){
                ans += i+1;
            }
        }
        cout << ans; return;
    }
    else if(p == 5){
        for(ll i = 0; i  < n; i++){
            ll d = s[i] - '0';
            if(d == 0 || d == 5){
                ans += i+1;
            }
        }
        cout << ans; return;
    }
    map<ll, ll> mp;
    ll sum = 0, base = 1;
    mp[sum]++;
    for(ll i = n-1; i >= 0; i--){
        sum += base * (s[i] - '0'); //cout << sum << " ";
        sum %= p; //cout << sum << " " << mp[sum] << endl;
        ans += mp[sum];
        mp[sum]++;
        base = (base * 10) % p;
    }
    cout << ans;
}

int main()
{
    fast();
    int t= 1; //cin >> t;
    while(t--){
        solve();
    }
}

/*
5
1 2
2 3
3 4
3 5
*/


Measured memory_bytes: 1044
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

typedef pair<string,int> P;

string change(string L,string R,int len){
  stringstream LL(L),RR(R),T;
  int l,r,t;

  LL >> l; RR >> r;
  t = l - r;
  T << t;

  string tmp,res = "";
  T >> tmp;
  
  for(int i = (int)tmp.size() ; i < len ; i++){
    res += "0";
  }
  res += tmp;
  return res;
}

int main(){
  int L;
  string a;

  while(true){
    cin >> a >> L;

    if(a == "0" && L == 0) break;

    vector<P> v;
    int cnt = 1;
    v.push_back(P(a,0));

    if((int)a.size() != L){
      for(int i = (int)a.size() ; i < L ; i++){
	a += "0";
      }
    }

    while(true){
      sort(a.begin(),a.end());
      string b = a;
      reverse(a.begin(),a.end());
      string c = a;
      // cout << b << " " << c << endl;
      a = change(c,b,L);
      
      if(cnt){
	for(int i = 0 ; i < (int)v.size() ; i++){
	  if(v[i].first == a){
	    string d = "";
	    int j;
 
	    for(j = 0 ; j < (int)a.size() ; j++){
	      if(a[j] == '0') continue;
	      else break;
	    }
	    for(int k = j ; k < (int)a.size() ; k++){
	      d += a[k];
	    }
	    if(d == "") d += "0";
	    a = d;
	    cout << v[i].second << " " << d << " " << (cnt - v[i].second) << endl;
	    goto end;
	  }
	}
      }

      v.push_back(P(a,cnt));
      cnt++;
    }
  end:;
  }

  return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cstring>
using namespace std;

typedef long long ll;

void solve()
{
    int a[10];
    for (int i = 1; i <= 5; i++)
        cin >> a[i];
    for (int i = 1; i <= 5; i++)
        if (a[i] != i)
        {
            cout << i << endl;
            return;
        }
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3632
n, a, b = map(int, input().split())
mod = 10**9 + 7

ans = pow(2, n, mod) - 1

def comb(m):
    x = 1
    y = 1
    for i in range(m):
        x = x*(n - i)%mod
        y = y*(i + 1)%mod
    return (x*pow(y, mod - 2, mod)%mod)

print((ans - comb(a) - comb(b))%mod)

Measured memory_bytes: 9196
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

struct Rec
{
	int w, h, v;
	Rec(int _w, int _h) : w(_w), h(_h) { v = w * w + h * h; }
	bool operator < (const Rec &a) const
	{
		if(v != a.v) return v < a.v;
		return h < a.h;
	}
};

int ind[1000][1000];
vector <Rec> rec;

int main(void)
{
	for(int i=1;i<1000;i++) for(int j=1;j<i;j++) rec.push_back(Rec(i, j));
	sort(rec.begin(), rec.end());
	for(int i=0;i<rec.size();i++) ind[rec[i].h][rec[i].w] = i;
	int h, w;
	while(scanf("%d %d", &h, &w), h)
	{
		int tarInd = ind[h][w];
		printf("%d %d\n", rec[tarInd + 1].h, rec[tarInd + 1].w);
	}

	return 0;
}

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

using namespace std;

#define long long long
#define INF ((long) 1e18)
#define MOD ((long) 1e9 + 7)
#define mll map<long, long>
#define pll pair<long, long>
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)
#define PRINTV(v) \
  FOR (_i, 0, v.size()) \
    cout << v[_i] << " "; \
  cout << "\n";

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

  long a, b;
  cin >> a >> b;

  long x = b - a;
  long y = (x+1)*x/2;
  printf("%lld\n", y - b);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

ll MOD = 1e9+7;
class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    
    mint operator -() const {
        return mint(-x);
    }
    
    mint &operator +=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator -=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator *=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator +(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator /=(const mint &a) {
        return (*this) *= a.inv();
    }

    mint operator /(const mint &a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};


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

    cin >> MOD;

    mint a(7);
    Rep (i, 1e7) {
        if (a.x == 0) {
            cout << i+1 << "\n";
            return 0;
        }
        a *= mint(10);
        a += mint(7);
    }

    cout << -1 << endl;
}

Measured memory_bytes: 3636
grades = []
lettergrade = []

while True:
    m, f, r = input().split()    
    m = int(m)
    f = int(f)
    r = int(r)
    if m == f == r == -1:
        break
    grades.append([m, f, r])

for x in grades:
    if x[0] == -1 or x[1] == -1 or (x[0] + x[1] >= 0 and x[0] + x[1] < 30):
        lettergrade.append('F')
    elif x[0] + x[1] >= 80:
        lettergrade.append('A')
    elif x[0] + x[1] >= 65 and x[0] + x[1] < 80:
        lettergrade.append('B')
    elif (x[0] + x[1] >= 50 and x[0] + x[1] < 65) or (x[2] >= 50):
        lettergrade.append('C')
    else:
        lettergrade.append('D')

print("\n".join(lettergrade))

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;
map<char,bool>mp;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
       mp[s[i]]=true;
    for(char i='a';i<='z';i++)
          if(!mp[i])   {
               cout<<i;
           return 0;
          }
   cout<<"None";
    return 0;
}


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

int main()
{
    cout << fixed << setprecision(8);
    int n, x[1002], y[1002];
    cin >> n;
    for(int i=0; i<n; ++i) cin >> x[i];
    for(int i=0; i<n; ++i) cin >> y[i];
    
    double d1=0, d2=0, d3=0 ,di=0;
    
    for(int i=0; i<n; ++i)
    {
        d1 += abs(x[i] - y[i]);
    }
    cout << d1 << endl;
    
    for(int i=0; i<n; ++i)
    {
        d2 += pow(x[i] - y[i],2);
    }
    cout << sqrt(d2) << endl;
    
    for(int i=0; i<n; ++i)
    {
        d3 += pow(abs(x[i] - y[i]), 3);
    }
    cout << pow(d3, (double)1/3) << endl;
    
    double max = abs(x[0] - y[0]);
    for(int i=1; i<n; ++i)
    {
        if(abs(x[i] - y[i]) > max) max = abs(x[i] - y[i]);
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 3484
from collections import defaultdict
N = int(input())
actions = [int(i) for i in input().split()]

d = defaultdict(int)
for a in actions:
    d[a-1] += 1
    d[a] += 1
    d[a+1] += 1
print(sorted(d.items(), key=lambda x: -x[1])[0][1])


Measured memory_bytes: 24432
#include <iostream>
#include <utility>
#include <string>

int main(int, char**) {
  std::string s;
  std::cin >> s;
  int diff{};

  for(int i{}; i < s.length(); ++i) {
    if(s[i] - '0' != i % 2) ++diff;
  }
  if(diff > s.length() / 2) {
    diff = s.length() - diff;
  }

  std::cout << diff << std::endl;

  return 0;
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename T>
struct cumulative_sum {
    int n;
    T ZERO;
    std::vector<T> data;
    template<typename I> cumulative_sum(I begin, I end, T ZERO = T())
        : n(end - begin), ZERO(ZERO), data(n + 1) {
        std::copy(begin, end, data.begin() + 1);
        for (int i = 0; i < n; i++) { data[i + 1] += data[i]; }
    }
    T get_sum(int l, int r) const {
        if (l >= r || l > n || r < 0) { return ZERO; }
        if (l < 0) { l = 0; }
        if (r > n) { r = n; }
        return data[r] - data[l];
    }
};

long long discrete_binary_search(long long ok, long long ng, const std::function<bool(long long)> &check) {
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    return ok;
}

int N, Q;
signed main() {
    cin >> N >> Q;
    vint A(N), X(Q);
    rep(i, N) { cin >> A[i]; }
    rep(i, Q) { cin >> X[i]; }

    vint Ac(A);
    rep(i, N) {
        if (N % 2 == i % 2) { Ac[i] = 0; }
    }
    cumulative_sum<int> cs0(all(A)), cs1(all(Ac));
    rep(i, Q) {
        int k = discrete_binary_search(0, N / 2 + 1 + N % 2, [&](int x) {
            return A[N - x] - X[i] >= X[i] - A[N - 2 * x + 1];
        });
        cout << cs0.get_sum(N - k, N) + cs1.get_sum(0, N - 2 * k) << endl;
    }
}

Measured memory_bytes: 5632
#include<stdio.h>

int main()
{
    int n, cpy=0;
    char s[101];
    scanf("%d%s",&n,&s);
    for(int i=0,j=n/2;i<n;i++,j++){
        if(s[i]==s[j]){
            cpy++;
        }
    }
    n%2==0&&cpy==n/2?puts("Yes"):puts("No");
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[105];
ll W[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }
    memset(W, 0, sizeof(W));
    REP(i, K) {
        if (W[i])
            continue;
        REP(j, N) {
            if (i + A[j] > K)
                break;
            W[i + A[j]] = true;
        }
    }
    if (W[K])
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 1024
import math
A, B, C, D = map(int, input().split())
L = C * D //math.gcd(C, D)
x = (A - 1) - (A -1) // C - (A - 1) // D + (A - 1) //L
y = B - B // C - B // D + B // L
print(y - x)

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

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

    vector<int> imos(n + 1, 0);
    rep(i, n) {
        if (s[i] == '#') {
            ++imos[0];
            --imos[i + 1];
        } else {
            ++imos[i + 1];
        }
    }

    rep(i, n) {
        imos[i + 1] += imos[i];
    }

    cout << n - *max_element(all(imos)) << endl;

    return 0;
}

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

int main(){
  int n,ans=0;cin>>n;

  REP(i,n){
    int a,b;cin>>a>>b;
    if(a==b){
      ans++;
      if(ans>=3){
        cout<<"Yes";
        return 0;
      }
    }
    else ans=0;
  }

  cout<<"No";
}

Measured memory_bytes: 3620
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int tmp,case_num = 1;
 
        while((tmp = sc.nextInt()) != 0){
            System.out.printf("Case %d: %d\n",case_num++, tmp);
        }
    }
}


Measured memory_bytes: 68212
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = (1<<17)+10;
const int INF = 2147483600;

int N,A,B; 
int f[23][MAXN+1],ans[MAXN+1],g[4]={0,1,1,0};

inline int Cnt(int x){
	if(!x) return 0; return Cnt(x>>1)+(x&1);
} bool Vis[MAXN+1];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),A=read(),B=read(); B^=A;
	for(int i=0;i<N;i++){
		for(int j=0;j<(1<<N);j++){
			f[i][j]=g[(j>>i)&3];//,cout<<f[i][j]<<" ";
		} //cout<<endl;
	} int n=Cnt(B),digt=0;
	if(!(n&1)){ puts("NO"); return 0; }
	--n; int pos=N-1;
	for(int i=N-2;n&&i>=0;i-=2){
		n-=2; int x=(1<<(i+1));
		for(int j=(1<<N)-1;j>=(1<<N)-x;j--)
			f[i][j]^=1,f[i-1][j]^=1,swap(f[i][j],f[i-1][j]);
		pos=i-1;
	}/* 
	fgx;
	for(int i=0;i<N;i++){
		for(int j=0;j<(1<<N);j++)
			cout<<f[i][j]<<" "; cout<<endl;}*/
	for(int i=0;i<pos;i++){
		while(B&(1<<digt)) ++digt;
		for(int j=0;j<(1<<N);j++)
			ans[j]|=(f[i][j]<<digt);
		++digt;
	}
	for(int i=0;i<N;i++){
		if(B&(1<<i)){
			for(int j=0;j<(1<<N);j++)
				ans[j]|=(f[pos][j]<<i);
			++pos;
		}
	}
	puts("YES");
	for(int i=0;i<(1<<N);i++)
		printf("%d ",ans[i]^A);
	for(int i=0;i<(1<<N)-1;i++)
		if(Cnt(ans[i]^ans[i+1])!=1) cout<<"noo:"<<i<<endl;
	for(int i=0;i<(1<<N);i++){
		if(Vis[ans[i]]) dgx;Vis[ans[i]]=1;}
	return 0;
}




Measured memory_bytes: 13108
#include <iostream>

using namespace std;

int main() {
    int D, N;
    int seed = 1;

    cin >> D >> N;

    for(int i = 0; i < D; i++) {
        seed *= 100;
    }

    int val = 0;
    int cnt = 1;
    while(cnt <= N) {
        while(1) {
            val+=seed;
            if(val/seed % 100 != 0) break;
        }
        cnt++;
    }
    std::cout << val << endl;
    return 0;

}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
l = na()
l.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                if l[i]+l[j] > l[k]:
                    ans += 1

print(ans)

Measured memory_bytes: 9212
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		while(true) {
			int m=sc.nextInt();
			int f=sc.nextInt();
			int r=sc.nextInt();
			if(m==-1 && f==-1 && r==-1) {
				break;
			}else if(m==-1 || f==-1) {
				System.out.println("F");
			}else if(m+f>=80){
				System.out.println("A");
			}else if(m+f<80 && m+f>=65) {
				System.out.println("B");
			}else if(m+f<65 && m+f>=50) {
				System.out.println("C");
			}else if(m+f<50 && m+f>=30) {
				if(r>=50) {
					System.out.println("C");
				}else {
				System.out.println("D");
				}
			}else {
				System.out.println("F");
			}

		}
	}
}


Measured memory_bytes: 26368
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    string s;
    while (cin >> s) {
        int size = s.length();
        char t[size*2];
        int j = 0;
        FOR(i,0,size)
            if (i % 2 == 0) {
                t[j] = s[i];
                j++;
            }
        cout << t << endl;
    }
}

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

typedef long long int ll;

bool prime[200010];

void sieve()
{

	for(int i=0;i<200010;i++){
		prime[i] = true;
	}

	for(int p=2;p*p<200010;p++){
		if(prime[p] == true){
			for(int i=p*p;i<200010;i+=p){
				prime[i] = false;
			}
		}
	}
}

int main()
{

	sieve();
	ll x; cin >> x;
	for(ll n =x;;n++){
		if(prime[n]){
			cout << n << endl;
			break;
		}
	}

	return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

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

    int r, g, b, n;
    int cnt = 0;
    int ans;
    cin >> r >> g >> b >> n;
    int l, m, u;
    for (int x = 0; x <= n; x++) {
        for (int y = 0; y <= n; y++) {
            int tmp = n - r * x - g * y;
            if (tmp >= 0 && tmp % b == 0) {
                ans++;
            }
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N,K,X,Y;
  scanf("%d\n%d\n%d\n%d\n",&N,&K,&X,&Y);
  if(N>=K){
    printf("%d\n",K*X+(N-K)*Y);
  }
  else{
    printf("%d\n",N*X);
  }
 
  return 0;
}

Measured memory_bytes: 1716
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol gou[300000]={};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol n,m,a,b,c,d;
  vector<int> k;
  lol sum=0;
  cin >>n;
  for(int i=0;i<n;i++){
    int r;
    cin >>r;
    k.emplace_back(r);
    gou[r]++;
  }
  for(int i=1;i<=n;i++){
    sum+=gou[i]*(gou[i]-1)/2;
  }
  for(int i=0;i<n;i++){
    lol u=gou[k[i]];
    lol q=u*(u-1)/2;
    u--;
    lol p=u*(u-1)/2;
    cout <<sum-q+p<<'\n';
  }
  return (0);
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;



int main(){
    int N; cin >> N;
    vi A(N);
    for(auto &x: A) cin >> x;

    vi L(N+1, 0), R(N+1, 0);
    for(int i=0; i<N; i++){
        L[i+1]=__gcd(L[i], A[i]);
        R[N-i-1]=__gcd(R[N-i], A[N-i-1]);
    }
    int ans=0;
    for(int i=0; i<N; i++){
        ans=max(ans, __gcd(L[i], R[i+1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int x, n;
bool vis[102];
vector<int> vec;
int a, b = 1e9;
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> x >> n;
    for(int i = 0; i < n; i++){
        int t; cin >> t;
        vis[t] = 1;
    }
    for(int i = -200; i <= 200; i++){
        if(i >= 0 && vis[i])continue;
        vec.push_back(i);
    }
    for(int i = 0; i < vec.size(); i++){
        int t = vec[i];
        if(abs(x-t) < b){
            b = abs(x-t);
            a = t;
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans; return 0;

}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ll long long int
using namespace std;

const ll mod = 1000000007;

void solve() {
	string s, t;
	cin >> s >> t;
	int m = s.size();
	int n = t.size();
	int ans = m;
	int match;
	for (int i = 0; i <= (m - n); i++) {
		int id = 0;
		match = 0;
		for (int j = i; j < i + n; j++) {
			if (s[j] == t[id]) match++;
			id++;
		}
		ans = min(ans, n - match);
	}

	cout << ans;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin >> t;
	t = 1;
	for (int i = 1; i <= t; i++) {
		solve();
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 3616
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""
n = onem()

print(-(-n//2))




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

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

    ll N, M;
    cin >> N >> M;
    if (N > M) swap(N, M);

    if (N == 1 && M == 1) {
        cout << 1 << endl;
    } else if (N == 1) {
        cout << M - 2 << endl;
    } else {
        cout << (N - 2) * (M - 2) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int x,y;
	cin>>x>>y;
	if((y>=2*x && y<=4*x) &&(y%2==0))	// dgt simple math.
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	// for(int i=0;i<=x;i++)
	// {
	// 	if((i*2)+(x-i)*4==y)
	// 	{
	// 		cout<<"Yes"<<endl;
	// 		return 0;
	// 	}
	// }
	// cout<<"No"<<endl;
}

Measured memory_bytes: 3648
def solve(H, N, AB):
    INF = 10e10
    dp = [[INF] * (H+1) for i in range(N+1)]
    dp[0][0] = 0
    A, B = AB[0]
    for j in range(H+1):
        dp[0][j] = min(dp[0][j], dp[0][max(0, j-A)]+B)
    for i in range(1,N):
        A, B = AB[i]
        for h in range(H+1):
            dp[i][h] = min(dp[i-1][h], dp[i][max(0, h-A)]+B)
        #print(i, *dp[i], sep="\t")
    
    return(dp[N-1][H])


def main():
    H, N = map(int, input().split())
    AB = []
    for i in range(N):
        A, B = map(int, input().split())
        AB.append((A, B))
    print(solve(H, N, AB))
main()


Measured memory_bytes: 283912
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int a[3];

int main()
{
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256