akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

int a[1000010];
map<int, bool> exist;

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

  int s;
  cin >> s;

  a[1] = s;
  exist[a[1]] = true;
  int i = 2;
  while (true) {
    if (a[i-1] % 2 == 0) a[i] = a[i-1] / 2;
    else if (a[i-1] % 2 != 0) a[i] = 3 * a[i-1] + 1;

    if(exist[a[i]]) {
      cout << i << "\n";
      return 0;
    }

    exist[a[i]] = true;

    ++i;
  }

  return 0;
}

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

ll gcd(ll a,ll b){
    ll c,d,e;
    c=max(a,b);
    d=min(a,b);
    while(1){
        c=c%d;
        if(c==0){
            break;
        }
        e=d;
        d=c;
        c=e;
    }
    return d;
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll c;

    c=gcd(a,b);
    int c2;
    c2=c;
    

    int k,ans;
    ans=1;
    ll l;
    l=ll(pow(c,0.5));
    
    rep(i,l-1){
        k=0;
        while(c%(i+2)==0){
            c/=(i+2);
            k=1;
        }
        if(k==1){
            ++ans;
        }
        if(c==1){
            break;
        }
        if(c!=1 and i==l-2){
            ++ans;
        }
    }
    
    

    if(c!=1 and ans==1) {
        ++ans;
    }
    

    cout << ans << endl;
    

    return 0;
}

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

int n;
int t[20][20];
int dp[1 << 20];

int main() {
	while (scanf("%d", &n), n) {
		rep(i, n)rep(j, n + 1)scanf("%d", &t[i][j]);
		memset(dp, 0x3f, sizeof(dp));
		rep(i, n)dp[1 << i] = t[i][0];
		rep(i, 1 << n){
			rep(j, n) {
				if (i >> j & 1)continue;
				dp[i | 1 << j] = min(dp[i | 1 << j], dp[i] + t[j][0]);
				rep(k, n) {
					if (i >> k & 1)
						dp[i | 1 << j] = min(dp[i | 1 << j], dp[i] + t[j][k + 1]);
				}
			}
		}
		printf("%d\n", dp[(1 << n) - 1]);
	}
}

Measured memory_bytes: 7288
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a, b;
    char op;
    
    cin >> a >> op >> b;
    if(op == '+'){
        cout << a + b << endl;
    }else{
        cout << a - b << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n, i, j, k=0;
  scanf("%d", &n);
  for(i=1; i<=9; i++){
    for(j=i; j<=9; j++){
      if(n==i*j){
        k=1;
        break;
      }
    }
  }
  if(k==0)
    printf("No");
  else
    printf("Yes");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{

	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s[]=new String[n];
		for(int i=0;i<n;i++){
			s[i]=sc.next();
		}
		int count=0;
		for(int i=0;i<n;i++){
			if(s[i].equals("P")){
				count++;
				break;
			}
		}
		for(int i=0;i<n;i++){
			if(s[i].equals("W")){
				count++;
				break;
			}
		}
		for(int i=0;i<n;i++){
			if(s[i].equals("G")){
				count++;
				break;
			}
		}
		for(int i=0;i<n;i++){
			if(s[i].equals("Y")){
				count++;
				break;
			}
		}
		if(count==3){
			System.out.println("Three");
		}else if(count==4){
			System.out.println("Four");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>                                          
#include <cstdio>                                            
using namespace std;                                         
                                                             
int main(void) {                                             
  int H, W;                                                  
  while (true) {                                             
    cin >> H >> W;                                           
    if (H==0 && W==0) {                                      
      break;                                                 
    }                                                        
    for (int i=0; i<H; i++) {                                
      for (int j=0; j<W; j++) {                              
        if (i==0 || i==H-1 || j==0 || j==W-1) {              
          printf("#");                                       
        } else {                                             
          printf(".");                                       
        }                                                    
      }                                                      
      printf("\n");                                          
    }                                                        
    printf("\n");                                            
  }                                                          
  return 0;                                                  
}                                                            
                                                             
                                                             
                                 

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

int main() {
  int n = 0; vector<int> vec(4);
  cin >> n;
  string a;
  for(int i = 0; i < n; i++){
    cin >> a;
    if (a =="P")
      vec.at(0)++;
    else if (a == "W")
      vec.at(1)++;
    else if (a == "G")
      vec.at(2)++;
    else if (a == "Y")
      vec.at(3)++;
    else
      ;
  }
  int cnt = 0;
  for(int i = 0; i < vec.size(); i++){
    //cout << vec.at(i) << endl;
    if (vec.at(i) > 0)
      cnt++;
  }
  //cout << cnt << endl;
  if(cnt == 4)
    cout << "Four" << endl;
  else if(cnt == 3)
    cout << "Three" << endl;
  else
    cout << "error" << endl;
}


Measured memory_bytes: 256
n = int(input())
cards = []
for i in range(n):
    sign, num = input().split(' ')
    cards.append((int(num), sign))

#in: A list of (num, sign) p:start r:end
#out: return i+1
def partition(A, p, r):
    pivot = A[r][0]
    i = p-1
    for j in range(p, r):
        if A[j][0]<= pivot:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

#in: list of (num, sign)
#out: none  overwrite list
def quick_sort(cards, p, r):
    if p >= r:
        return
    pivot = partition(cards, p, r)
    quick_sort(cards, p, pivot-1)
    quick_sort(cards, pivot+1, r)

def merge(list1, list2):
    output = []
    p1 = 0
    p2 = 0
    l1 = len(list1)
    l2 = len(list2)
    while p1 < l1 and p2 < l2:
        if list1[p1][0] <= list2[p2][0]:
            output.append(list1[p1])
            p1 += 1
        else:
            output.append(list2[p2])
            p2 += 1
    return output + list1[p1:] + list2[p2:]

#in: A list of (num, sign)
#out: none overwrite
def merge_sort(cards):
    if len(cards) <= 1:
        return cards
    else:
        pivot = len(cards)//2
        return merge(merge_sort(cards[:pivot]), merge_sort(cards[pivot:]))
        
quick = cards.copy()
quick_sort(quick, 0, len(quick)-1)
merge = merge_sort(cards)

for i in range(n):
    if quick[i][1] != merge[i][1]:
        print("Not stable")
        break
else:
    print("Stable")

for num, sign in quick:
    print( sign + ' ' + str(num))


Measured memory_bytes: 19820
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int K)
        {
            return (N - 1 + K - 2) / (K - 1);
        }
        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int[] A = ReadInts();
            Console.WriteLine(Solve(V[0], V[1]));
        }
    }
}


Measured memory_bytes: 18784
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = 0;
            double m = 0,s,s2=0;
            n = sc.nextInt();
            if (n == 0)
                break;
            int[] d = new int[n];
            for (int i = 0; i < n; i++) {
                d[i] = sc.nextInt();
                m += d[i];
            }
            m /= n;
            for (int j = 0; j < n; j++)
                s2 += Math.pow(d[j]-m,2);
            s2 /= n;
            s = Math.sqrt(s2);

            System.out.println(s);
        }
    }
}


Measured memory_bytes: 31384
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)

  val a = sc.next
  val b = sc.next
  
  val res =
    if (a.length != b.length){
      if (a.length > b.length ) "GREATER"
      else                      "LESS"
    }
    else {
      val diff = (a zip b).find(t => t._1 != t._2)

      diff.map{case (aa, bb) =>
        if (aa > bb) "GREATER"
        else         "LESS"
      }.getOrElse("EQUAL")
      }

  println(res)
}

Measured memory_bytes: 25532
S = input()

ans = "Yes"
if "N" in S and "S" not in S:
        ans = "No"
if "S" in S and "N" not in S:
    ans = "No"
if "W" in S and "E" not in S:
    ans = "No"
if "E" in S and "W" not in S:
    ans = "No"
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
int main(){
	
	string s;
	cin >> s;
	
	string a = "CF";
	
	long int i = 0;
	for(long int j = 0 ; j < s.length() ; j++){
		
		if(a[i] == s[j]){
			
			i++;
			if(i == 2){
				
				break;
			}
		}
	}
	if(i == 2){
		
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

 	ll n, k;
 	cin >> n >> k;
 	ll w = n / k;
 	w = (w * w * w);
 	if(k % 2 == 1) cout << w << endl;
 	else
 	{	
 		ll v = n / k;
 		if(n % k >= k / 2) v += 1;
 		v = (v * v * v);
 		cout << w + v << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define nl cout<<endl;
#define inp 200005
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

// Pick yourself up, 'cause...

int main()
{
    jaldi
 
    int n,w;
    cin>>n>>w;

    vector<ll> dp(w+1,0);

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

        for(int j=w;j>=weight;j--) { dp[j]=max(dp[j],dp[j-weight]+value); }
    }

    ll ans=0;
    for(int i=1;i<=w;i++) ans=max(ans,dp[i]);
    cout<<ans;

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<vector>
#include<cstring>
#define rg register
typedef long long ll;
template <typename T> inline T max(const T a,const T b){return a>b?a:b;}
template <typename T> inline T min(const T a,const T b){return a<b?a:b;}
template <typename T> inline void mind(T&a,const T b){a=a<b?a:b;}
template <typename T> inline void maxd(T&a,const T b){a=a>b?a:b;}
template <typename T> inline void read(T&x)
{
	char cu=getchar();x=0;bool fla=0;
	while(!isdigit(cu)){if(cu=='-')fla=1;cu=getchar();}
	while(isdigit(cu))x=x*10+cu-'0',cu=getchar();
	if(fla)x=-x;
}
template <typename T> inline void printe(const T x)
{
	if(x>=10)printe(x/10);
	putchar(x%10+'0');
}
template <typename T> inline void print(const T x)
{
	if(x<0)putchar('-'),printe(-x);
	else printe(x);
}
char s[500001];
int n,a[500001];
ll ans;
int rmq[500001][21],bit[21],log_[1048576];
int p(int l,int r)
{
	const int LG=log_[r-l+1];
	const int L=rmq[l][LG],R=rmq[r-bit[LG]+1][LG];
	if(a[L]<a[R])return L;
	return R;
}
void solve(int l,int r)
{
	if(l>r)return;
	int P=p(l,r);
	int ll=P,rr=P;
	while(ll>l&&a[ll-1]-1==a[ll])ll--,ans+=a[ll]-a[P];
	solve(l,ll-1);
	while(rr<r&&a[rr+1]-1==a[rr])rr++,ans+=a[rr]-a[P];
	solve(rr+1,r);
}
int main()
{
	scanf("%s",s+1),n=strlen(s+1);
	for(rg int i=1;i<=n;i++)
	{
		a[i]=a[i-1]+(s[i]=='<'?1:-1);
		rmq[i][0]=i;
	}
	bit[0]=1;
	for(rg int i=1;i<=20;i++)
	{
		bit[i]=bit[i-1]<<1;
		for(rg int j=bit[i-1];j<bit[i];j++)log_[j]=i-1;
	}
	for(rg int i=1;i<=20;i++)
	{
		for(rg int j=0;j<=n;j++)
			if(j+bit[i-1]>n||a[rmq[j][i-1]]<a[rmq[j+bit[i-1]][i-1]])rmq[j][i]=rmq[j][i-1];
			else rmq[j][i]=rmq[j+bit[i-1]][i-1];
	}
	solve(0,n);
	print(ans);
	return 0;
}

Measured memory_bytes: 47744
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	std::ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	int h[n+1];
	for (int i = 1; i <= n; ++i)	cin>>h[i];
	int c[n+1];
	c[1]=0;
	c[2]=abs(h[2]-h[1]);
	for (int i = 3; i <= n; ++i)
	{
		c[i]=min((abs(h[i]-h[i-1])+c[i-1]), (abs(h[i]-h[i-2])+c[i-2]));
	}
	cout<<c[n];
	

	return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) { //WOOOOOOO AtCoder is HELPING!!!!!!!!!!
		//Arraylist cheese for the win
		Scanner input = new Scanner(System.in);
		PriorityQueue<Long> subs = new PriorityQueue<Long>(Comparator.reverseOrder());
		int N = input.nextInt();
		int M = input.nextInt();
		long ans = 0;
		for (int i = 0; i < N; i++) {
			long x = input.nextLong();
			ans+=x;
			while (x>0) {
				long sub = x-x/2;
				subs.add(sub);
				x/=2;
			}
		}
		int cnt = 0;
		while (cnt < M) {
			ans-=subs.poll();
			cnt++;
			if (subs.isEmpty()) break;
		}
		System.out.println(ans);
	}
}

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



int main(void) {

    int n , tg , pt , hasuu500;
    cin >> n;

    if (n < 500) {
       tg = n - (n % 5);
       pt = (tg / 5) * 5;
       cout << pt;
    }
    else {

        hasuu500 = n % 500;
        tg = n - hasuu500;

        pt = (tg / 500) * 1000;

        pt = pt + (hasuu500 / 5) * 5;
        cout << pt;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	if(read()>=30)puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin>>N;
  for(int i=9;i>=1;i--){
    if(N%i==0&&N/i<10){
      cout<<"Yes"<<endl;
      //cout<<N/i<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N, Z, W;
int A[2005];
int DP[2][2005];
void Read()
{
    cin >> N >> Z >> W;
    for(int i = 1; i <= N; i++)
        cin >> A[i];
    A[0] = W;
}
inline int mod(int x)
{
    return max(x, -x);
}
void Solve()
{
    for(int i = N; i >= 1; i--)
    {
        int Max = -2000000005, card = A[i - 1];
        for(int j = i + 1; j <= N; j++)
        {
            Max = max(Max, DP[1][j]);
        }
        Max = max(Max, mod(A[N] - card));
        DP[0][i] = Max;
        int Min = 2000000005;
        for(int j = i + 1; j <= N; j++)
        {
            Min = min(Min, DP[0][j]);
        }
        Min = min(Min, mod(card - A[N]));
        DP[1][i] = Min;
    }
    cout << DP[0][1] << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}



int main(){
  string S,T;
  cin >> S >> T;
  ll s=S.size(),t=T.size(),x=0;
  rep(i,s-t+1){
    rep(j,t){
      if(S.at(s-1-i-j)!=T.at(t-1-j)&&S.at(s-1-i-j)!='?'){
        break;
      }
      if(j==t-1){
        rep(k,t){
          S.at(s-1-i-k)=T.at(t-1-k);
        }
        rep(k,s){
          if(S.at(k)=='?'){
            S.at(k)='a';
          }
          x=1;
        }
      }
    }
    if(x==1){
      break;
    }
  }
  if(x==1){
    cout << S << endl;
  }else{
    cout << "UNRESTORABLE" << endl;
  }
}
          
          

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

int main() {
  int n, X;
  cin >> n >> X;
  vector<long> x(n);
  vector<long> diff(n);
  for (int i=0; i<n; i++){
    cin >> x[i];
    diff[i] = abs(X - x[i]);
  }
  sort(diff.begin(), diff.end());
  
  for (long i=diff[0]; i>0; i--){
    for (int j=0; j<n; j++){
      if (diff[j] % i != 0){
        break;
      }
      else if (j == n-1){
        cout << i << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int sec;
    int total = 0;
    for (int i = 0; i < 4; ++i) {
        cin >> sec;
        total += sec;
    }
    cout << total / 60 << endl;
    cout << total % 60 << endl;
    return 0;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] next = new int[n];
        for(int i=0; i<n; i++) {
            next[i] = sc.nextInt();
        }
        for(int i=0; i<k; i++) {
            int c = 0;
            int[] prev = next;
            int[] d = new int[n+1];
            for(int j=0; j<n; j++) {
                d[Math.max(j-prev[j], 0)]++;
                d[Math.min(j+prev[j]+1, n)]--;
            }
            next = new int[n];
            next[0] = d[0];
            if(next[0] == n) c++;
            for(int j=1; j<n; j++) {
                next[j] = next[j-1] + d[j];
                if(next[j] == n) c++;
            }
            if(c == n) break;
        }
        for(int i=0; i<n; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(next[i]);
        }
        System.out.println();

    }


}

Measured memory_bytes: 62196
#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int main(void){
  int N;
  signed T, A;
  cin >> N >> T >> A;
  vector<int> H(N);
  double min;
  int ans;
  min = 1000000, ans = 0;
  
  for(int i =0; i < N; i++) cin >> H[i];
  for(int i =0; i < N; i++){
    if(abs((T - H[i]*0.006) - A) < min){
      min = abs((T - H[i]*0.006) - A);
      ans = i+1;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int PS(int y) {
  int a=1;
  repl(i,1,y+1) {
    a *=2;
  }
  return a;
}
int main() {
int A;
  int B;
  int C;
  int K;
  cin >>A>>B>>C>>K;
  int x=max(max(A,B),C);
  if(A==x) {
    cout<<B+C+A*PS(K)<< endl;
  }
  else if(B==x) {
    cout<<A+C+B*PS(K)<< endl;
  }
  else if(C==x) {
    cout<<B+A+C*PS(K)<< endl;
  }
  
}
 

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

char cx[6];
int ketax;
inline void putx() {
	for (int i = ketax - 1; i >= 0; i--)* di++ = (*(cx + i));
	*di++ = '\n';
}

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


	int K, X, Y;
	scanf("%d", &K);
	scanf("%d", &X);
	scanf("%d", &Y);

	if (K == 1) {
		putint(X + Y);
		rep1(i, X) {
			putint(i);
			*di++ = '0';
			*di++ = '\n';
		}
		if (X == 0) {
			*cx = '0';
			ketax = 1;
		}
		while (X) {
			*(cx + ketax) = '0' + X % 10;
			X /= 10;
			ketax++;
		}
		rep1(i, Y) {
			putx();
			putint(i);
		}
		fwrite(dn, 1, di - dn, stdout);
		Would you please return 0;

	}

	vector<pair<int, int>> kotae;
	int m = abs(X) + abs(Y);
	int xpn, ypn;

	if (K % 2 == 0 && m % 2) {
		printf("-1");
		return 0;
	}
	while (m / K >= 2) {
		if (abs(X) < abs(Y)) {
			ypn = (Y >= 0) ? 1 : -1;
			kotae.pb(mp(0, ypn * K));
			Y -= ypn * K;
		}
		else {
			xpn = (X >= 0) ? 1 : -1;
			kotae.pb(mp(xpn * K, 0));
			X -= xpn * K;
		}
		m = abs(X) + abs(Y);
	}
	if (m == K) {
		kotae.pb(mp(X, Y));
	}
	else {
		if (m & 1) {
			if (abs(X) < abs(Y)) {
				ypn = (Y >= 0) ? 1 : -1;
				kotae.pb(mp(0, ypn * K));
				Y -= ypn * K;
			}
			else {
				xpn = (X >= 0) ? 1 : -1;
				kotae.pb(mp(xpn * K, 0));
				X -= xpn * K;
			}
		}

		int yorimiti = (2 * K - abs(X) - abs(Y)) / 2;
		if (abs(X) < abs(Y)) {
			xpn = (X >= 0) ? 1 : -1;
			ypn = (Y >= 0) ? 1 : -1;

			kotae.pb(mp(X + xpn * yorimiti, ypn * (K - abs(X + xpn * yorimiti))));
			Y -= ypn * (K - abs(X + xpn * yorimiti));
			X -= X + xpn * yorimiti;
			kotae.pb(mp(X, Y));
		}
		else {
			xpn = (X >= 0) ? 1 : -1;
			ypn = (Y >= 0) ? 1 : -1;
			kotae.pb(mp(xpn * (K - abs(Y + ypn * yorimiti)), Y + ypn * yorimiti));
			X -= xpn * (K - abs(Y + ypn * yorimiti));
			Y -= Y + ypn * yorimiti;
			kotae.pb(mp(X, Y));
		}
	}

	putint(kotae.size());
	int xp = 0, yp = 0;;
	rep(i, kotae.size()) {
		xp += kotae[i].first;
		yp += kotae[i].second;
		if (xp == 0) {
			*di++ = '0';
			*di++ = '\n';
		}
		else putint(xp);
		if (yp == 0) {
			*di++ = '0';
			*di++ = '\n';
		}
		else putint(yp);
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

using namespace std;

int n, tip;

int result(int x)
{
    cout << x << '\n'; fflush(stdout);
    string a; cin >> a;
    if(a == "Vacant") return 0;
    if(a == "Female") return 1;
    return 2;
}
int main()
{
    cin.sync_with_stdio(false);

    cin >> n;
    tip = result(0);
    if(!tip) return 0;

    int st = 1, dr = n-1, mid;
    while(st <= dr)
    {
        mid = (st+dr)/2;
        int x = result(mid);
        if(!x) return 0;
        if(mid&1) x = 3 - x;
        if(x == tip) st = mid + 1;
            else dr = mid - 1;
    }
    return 0;
}


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

int main(){
    int a, b, c, tmp;
    cin >> a >> b >> c;
    
    tmp = b;
    if (a > b) b = a, a = tmp;

    tmp = c;
    if (b > c) c = b, b = tmp;

    tmp = b;  
    if (a > b) b = a, a = tmp;

    cout << a << " " << b << " " << c << endl;    
}


Measured memory_bytes: 3096
#include<cstdio>
#include<algorithm>
#define mod 1000000007
#define maxn 105
using namespace std;
int n,a[maxn],f[maxn/2][maxn][maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<2*n;i++) scanf("%d",&a[i]);
	sort(a+1,a+2*n);
	f[n][1][0]=1;
	for(int i=n-1;i;i--)
	{
		int al=(a[i]!=a[i+1]),ar=(a[2*n-i]!=a[2*n-i-1]);
		for(int l=0;l<2*n;l++)
			for(int r=0;r+l<2*n;r++)
				if(f[i+1][l][r])
				{
					for(int dl=1;dl<=l+al;dl++) f[i][l+al-dl+1][r+ar+(dl>1)]=(f[i][l+al-dl+1][r+ar+(dl>1)]+f[i+1][l][r])%mod;
					for(int dr=1;dr<=r+ar;dr++) f[i][l+al+1][r+ar-dr]=(f[i][l+al+1][r+ar-dr]+f[i+1][l][r])%mod;
				}
	}
	int ans=0;
	for(int i=0;i<n*2;i++)
		for(int j=0;j<n*2;j++) ans=(ans+f[1][i][j])%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> D(N);
    int sum = 0;
    for (int & d : D) {
        cin >> d;
        sum += d;
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += D[i]*(sum-D[i]);
    }
    ans /= 2;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
long long n;
int main(){
	cin>>n;
	if(n&1ll) return puts("0"),0;
  	n>>=1;
	long long ans=0ll;
	while(n){
		ans+=n/5ll,n/=5ll;
	}
	cout<<ans;
	return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	deque<int> nums;

	for( int i = 0; i < 10; i++ )
	{
		int in;
		cin >> in;
		nums.push_back( in );
	}
	
	
	sort( nums.begin(), nums.end(), greater<int>() );
	int cnt = 1;

	deque<int>::iterator it = nums.begin();
	while( it != nums.end() )
	{
		cout << *it << endl;
		++it;
		cnt++;
		if( cnt == 4 ) break;
	}

	return 0;
}

Measured memory_bytes: 1220
N = int(input())

H = list(map(int,input().split()))

C = [0] * (N)

C[0] = 0
C[1] = abs(H[1] - H[0])

for i in range(2,N):

    a = abs(H[i] - H[i - 2]) + C[i - 2]
    b = abs(H[i] - H[i - 1]) + C[i - 1]
    C[i] = min(a,b)

print(C[-1])


Measured memory_bytes: 13928
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    n = int(input())
    ans = 0
    for i in range(1, n):
        ans += (n-1)//i
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68012
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,Q;
const int max_n = 200000+10;
const int insert = 1;
const int del = -1;
const int query = 3;

multiset<pair<pair<int,int>,int>> P; //time,pos,query
int ans[max_n];

void print_set(multiset<int> s) {
    for(auto v: s) {
        cout<<v<<" ";
    }
    cout<<endl;

    return;
}

int main(void) {
    cin>>N>>Q;

    for(int i = 0;i < N;i++) {
        int s,t,x;
        cin>>s>>t>>x;
        P.insert({make_pair(s-x,insert),x});
        P.insert({make_pair(t-x,del),x});
    }
    for(int i = 0;i < Q;i++) {
        int d;
        cin>>d;
        P.insert({make_pair(d,query), i});
    }
    
    multiset<int> R; //pos
    for(auto u: P) {
        int q = u.first.second;
        int p = u.second;
        
        if(q == insert) {
            R.insert(p);
        } else if(q == del) {
            R.erase(p);
        } else {
            if(R.empty()) {
                ans[p] = -1;
            } else {
                ans[p] = *R.begin();
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 48896
#include <stdio.h>

int main()
{
	int NUM[100];
	int BOOLEANS[100];
	for(int i = 0; i < 100; i++)
	{
		NUM[i] = 0;
		BOOLEANS[i] = 0;
	}
	int N = 0;
	scanf("%d", &N);
	char S[100];
	scanf("%s", S);
	
	for(int i = 0; i < N; i++)
	{
		if(BOOLEANS[i] == 0)
		{
			BOOLEANS[i] = 1;
			int tem = 0;
			for(int j = i + 1; j < N; j++)
			{
				if(S[i] == S[j])
				{
					//printf("%c %d\n", S[j], j);
					BOOLEANS[j] = 1;
					tem = j;
				}
			}
			for(int j = i; j < tem; j++)
			{
				//printf("%d ", j);
				NUM[j]++;
			}
		}
	}
	int max = 0;
	for(int i = 0; i < N; i++)
	{
		if(max < NUM[i]) max = NUM[i];
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 128
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
query = [list(map(int, input().split())) for i in range(Q)]

Asum = sum(A)
Adict = Counter(A)

for q in query:
  before = q[0]
  after = q[1]
  if before in Adict:
    Asum += (after-before) * Adict[before]
    if after in Adict:
      Adict[after] += Adict.pop(before)
    else:
      Adict[after] = Adict.pop(before)
  print(Asum)

Measured memory_bytes: 37572
#include<bits/stdc++.h>
#define ll long long
const int M=2e5+5;
using namespace std;
struct node{
	ll time;
	ll end;
}a[M];
bool cmp(node x,node y){
	return x.end<y.end;
}
int main(){
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
		cin>>a[i].time>>a[i].end;
	sort(a,a+n,cmp);
	ll ans=0,i;
	for(i=0;i<n;i++){
		ans+=a[i].time;
		if(ans>a[i].end) break;
	}
	if(i<n) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  set<int> st;
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (a == 0) {
      st.insert(b);
      cout << st.size() << endl;
    } else if (a == 1) {
      cout << (st.find(b) == st.end() ? 0 : 1) << endl;
    } else {
      st.erase(b);
    }
  }
  return 0;
}


Measured memory_bytes: 12432
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    bool flag=true;
    int n=s.size();
    for(int i=0; i<n; i++){
        if(s.at(i) != s.at(n-1-i)) {
            flag = false;
        }
    for(int i=0; i<n/2; i++){
        if(s.at(i) != s.at((n-1)/2 -1-i)) {
            flag = false;
            break;
        }
        if(s.at((n+3)/2 -1 +i) != s.at(n-1-i)){
            flag = false;
            break;
        }
    }    
    }

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

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vll ans1, ans2;
  {
    ll i = 0;
    while(i < n){
      if(s[i] == 'o'){
        ans1.emplace_back(i+1);
        i += c+1;
      }else{
        i++;
      }
      if(SZ(ans1) == k) break;
    }
  }
  {
    ll i = n-1;
    while(i >= 0){
      if(s[i] == 'o'){
        ans2.emplace_back(i+1);
        i -= c+1;
      }else{
        i--;
      }
      if(SZ(ans2) == k) break;
    }
  }
  reverse(ALL(ans2));
  rep(i, k){
    if(ans1[i] == ans2[i]){
      print(ans1[i]);
    }
  }
}


Measured memory_bytes: 5128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = [_ for _ in S()]
    s.sort()
    if s == ['a', 'b', 'c']:
        return 'Yes'


    return 'No'


print(main())




Measured memory_bytes: 5460
def main():

    N = int(input())
    A = [int(a) for a in input().split()]

    B = [abs(a) for a in A]
    if 0 in A:
        print(sum(B))
    else:

        count = 0
        for a in A:
            if a < 0:
                count += 1

        if count % 2 == 0:
            print(sum(B))
        else:
            print(sum(B) - 2*min(B))    


main()


Measured memory_bytes: 14412
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
A.sort(reverse=True)
ans = 0
for i in range(N-1):
    ans += A[0--i//2]
print(ans)


Measured memory_bytes: 32884
//abc143_d.cpp
//Sun Oct 20 15:22:42 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	vector<int> l;
	for (int i=0;i<n;i++){
		int temp;
		cin >> temp;
		l.push_back(temp);
	}

	sort(l.begin(),l.end());

	int ans = 0;
	for (int i=0;i<n-1;i++){
		for (int j=i+1;j<n;j++){
			int added = l[i]+l[j];
			int iter = lower_bound(l.begin(),l.end(),added)-l.begin()-1;
//			cout << i << " " << j << " " << iter << endl;
			if (iter>j){
				ans += iter-j;
			}
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
 char g[3];
 int i=0;

 scanf("%s",g);

 if(g[0]=='1')i++;
 if(g[1]=='1')i++;
 if(g[2]=='1')i++;

 printf("%d\n",i);

 return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;

  ll n = s.size();
  ll g = 0;
  ll p = 0;
  REP(i, n){
    if(s[i] == 'g')
      g++;
    else
      p++;
  }

  cout << n/2 - p << endl;

}


Measured memory_bytes: 512
#include<stdio.h>

typedef long long llong;

#define LIM 200001
#define SENTINEL 1000000001

llong merge(int A[], int left, int mid, int right) {
  llong cnt = 0;
  int l = mid - left;
  int r = right - mid;
  int L[l], R[r];
  for ( int i = 0; i < l; i++ ) L[i] = A[left + i];
  for ( int i = 0; i < r; i++ ) R[i] = A[mid + i];
  L[l] = R[r] = SENTINEL;

  l = r = 0;
  for ( int i = left; i < right; i++ ) {
    if ( L[l] <= R[r] ) A[i] = L[l++];
    else {
      A[i] = R[r++];
      cnt += mid - left - l;
    }
  }
  return cnt;
}

llong mergeSort(int A[], int left, int right) {
  if ( left + 1 < right ) {
    int mid = (left + right) / 2;
    llong v1 = mergeSort(A, left, mid);
    llong v2 = mergeSort(A, mid, right);
    llong v3 = merge(A, left, mid, right);
    return v1 + v2 + v3;
  }
  return 0;
}

int main() {
  int n, A[LIM];
  scanf("%d", &n);

  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  llong cnt = mergeSort(A, 0, n);

  printf("%lld\n", cnt);

  return 0;
}


Measured memory_bytes: 4324
#include<stdio.h>
int main(){
	char a, b, c;
	scanf("%c%c%c", &a, &b, &c);
	if(a==b&&a!=c||b==c&&b!=a||a==c&&b!=a){
		printf("Yes");
	} else if(a==b&&a==c){
		printf("No");
	}
	
}


Measured memory_bytes: 1596
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		String A = "";
		String B = "";

		for(int i=0;i<a;i++) {
			B += Integer.toString(b);
		}
		for(int i=0;i<b;i++) {
			A += Integer.toString(a);
		}
		if(A.compareTo(B)<0) {
			System.out.println(A);
		} else {
			System.out.println(B);
		}
	}
}

Measured memory_bytes: 21204
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main() {
int n,k;
cin>>n>>k;
int a[n+5];
for(int i=0;i<n;i++){
	cin>>a[i];
}
sort(a,a+n);
int sum=0;
for(int i=0;i<k;i++){
	sum+=a[i];
}
cout<<sum<<endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;

  vector<long long> vec(K);
  for (int i = 1; i <= N; i++) vec.at(i % K)++;

  long long ans = 0;

  for (int a = 0; a < K; a++) {
    int b = (K - a) % K;
    int c = (K - a) % K;
    if ((b + c) % K == 0) ans += vec.at(a) * vec.at(b) * vec.at(c);
  }

  cout << ans << "\n";
}

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

using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;

	if(a + b + c < 22) cout << "win\n";
	else cout << "bust\n";

	return 0;
}

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

int main() {
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  }

  if (R >= 1200 && R < 2800) {
    cout << "ARC" << endl;
  }

  if (R >= 2800 && R <= 4208) {
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn string() -> String {
    read()
}

fn int() -> i64 {
    read()
}

fn char() -> char {
    read::<String>().pop().unwrap()
}

fn vecchar() -> Vec<char> {
    string().chars().collect()
}

fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let x = int();
    let c = (x + 104) / 105;
    let sum = 105 * c;
    println!("{}", if sum - c * 5 <= x { "1" } else { "0" });
}


Measured memory_bytes: 4352
INF = 10 ** 20

def main():
  d, n = map(int,input().split())
  temp = [int(input()) for i in range(d)]
  temp.insert(0,0)
  
  alst = []
  blst = []
  clst = []
  
  for i in range(n):
    a,b,c = map(int,input().split())
    alst.append(a)
    blst.append(b)
    clst.append(c)
  
  dp = [[0] * n for i in range(d + 1)]
  
  t1 = temp[1]
  for i in range(n):
    if not (alst[i] <= t1 <= blst[i]):
      dp[1][i] = -INF
  
  for i in range(2, d + 1):
    t = temp[i]
    predp = dp[i - 1]

    for j in range(n):
      cj = clst[j]
      if alst[j] <= t <= blst[j]:
        save = 0
        for x in range(n):
          cx = clst[x]
          if cj >= cx:
            v = predp[x] + cj - cx
          else:
            v = predp[x] - cj + cx
          if save < v:
            save = v
        dp[i][j] = save

  print(max(dp[d]))

main()


Measured memory_bytes: 6176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N,M; cin >> N >> M;
    vector<int> G(N-1);
    rep(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        if(a != 0) G[a-1]++;
        if(b != 0) G[b-1]++;
    }
    bool ok = true;
    rep(i,N-1){
        if(G[i] % 2 != 0) ok = false;
    }
    cout << (ok ? "YES" : "NO") << endl;
}


Measured memory_bytes: 1148
#include <iostream>
using namespace std;
int main(){
	while(true){
		int t,n,sum = 0,kotae = 0;
		cin >> t;
		cin >> n;
		if(t == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			int s,f;
			cin >> s >> f;
			sum += (f-s);
		}
		kotae = t - sum;
		if(kotae <= 0){
			cout << "OK" << endl;
		}
		else if(kotae > 0){
			cout << kotae << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
S = input()
N = len(S)+1
a = [0] * N
for i in range(N-1):
	if S[i] == '<':
		a[i+1] = a[i]+1
for i in range(N-2, -1, -1):
  if S[i] == '>':
    a[i] = max(a[i+1]+1,a[i])

print(sum(a))

Measured memory_bytes: 23340