akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main(void) {
    long long N, X[100005], L[100005], i;
    long long x, t, a, b;
    pair<long long, long long>A[100005];
    scanf("%lld", &N);
    for (i=0; i<N; i++) {
        scanf("%lld%lld", &X[i], &L[i]);
    }
    for (i=0; i<N; i++) {
        a=X[i]-L[i]; b=X[i]+L[i];
        A[i].first=b;
        A[i].second=a;
    }
    sort(A, A+N);
    x=0; t=-1000000001;
    for (i=0; i<N; i++) {
        if (t<=A[i].second) {
            x++;
            t=A[i].first;
            // printf("%lld\n", i);
        }
    }
    printf("%lld", x);
    /*
    for (i=0; i<N; i++) {
        printf("%lld %lld\n", A[i].first, A[i].second);
    }
    */
    return 0;
}

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

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

using namespace std;

typedef long long ll;
typedef vector<ll> V;
typedef vector<V> M;

M mul(const M& a, const M& b){
	int n = a.size(), m = b.size(), l = b[0].size();
	M c(n, V(l, 0));
	rep(i, n){
		rep(k, l){
			rep(j, m){
				c[i][k] += a[i][j] * b[j][k];
			}
		}
	}
	return c;
}

M read(int n, int m){
	M x(n, V(m, 0));
	rep(i, n){
		rep(j, m){
			cin >> x[i][j];
		}
	}
	return x;
}

void print(const M& x){
	int n = x.size(), m = x[0].size();
	rep(i, n){
		rep(j, m){
			cout << x[i][j] << (j == m - 1 ? '\n' : ' ');
		}
	}
}

int n, m, l;

int main(){
	cin >> n >> m >> l;
	M a = read(n, m);
	M b = read(m, l);

	M c = mul(a, b);
	print(c);
	return 0;
}

Measured memory_bytes: 3260
#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>;
#define INF 1000000010
const ll MOD = 1000000007;

int main(){
    int n,x;
    cin>>n>>x;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    ll ans=0;
    rep(i,n-1){
        if(a[i]+a[i+1]>x){
            int diff=a[i]+a[i+1]-x;
            ans+=diff;
            a[i+1]-=min(diff,a[i+1]);
        }
    }
    cout<<ans<<endl;
}

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

unsigned long long int Logn(unsigned long long int n, unsigned long long int r) 
{ 
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0; 
} 

int main()
{
   
    long long int n,k;
    cin>>n>>k;
    cout<<Logn(n,k)+1;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

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

	int b1,b2,b3;
	cin >> b1 >> b2 >> b3;

	int x,y,z;
	for(int i=0;i<2;i++){
		cin >> x >> y >> z;
		if(x-b1 != y-b2 || x-b1 != z-b3){
			cout << "No\n";
			return 0;
		}
	}		
	cout << "Yes\n";

	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int count = 0;
	int top = 0;
	for (int i = 0; i < n; i++)
	{
		int h;
		cin >> h;
		if (top <= h)
		{
			count++;
			top = h;
		}
		else {
			//cout << count;
			//return 0;
		}
	}
	cout << count;
}

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

X=[0]*N
for k in range(1,N+1):
    a,b=map(int,input().split())
    X[k-1]=(a,b)

X.sort(key=lambda x:x[1])

D=0
F=True
for (s,t) in X:
    D+=s
    F&=D<=t

if F:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 94200
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli c[3][3],a21,a31,b21,b31,sum,d[3][3];
    string s="No";
    lli i,j;
    rep(i,0,3){
        rep(j,0,3){
            cin>>c[i][j];
        }
    }
    a21=c[1][0]-c[0][0];                        //a2-a1を導出
    a31=c[2][0]-c[0][0];                        //a3-a1を導出
    b21=c[0][1]-c[0][0];                        //b2-b1を導出
    b31=c[0][2]-c[0][0];                        //b3-b1を導出
    sum=c[0][0]+c[1][1]+c[2][2];
    rep(i,0,c[0][0]+1){
        rep(j,0,c[0][0]-i+1){
            if(
                (c[0][0]==i+j)&&
                (c[0][1]==i+j+b21)&&
                (c[0][2]==i+j+b31)&&
                (c[1][0]==i+a21+j)&&
                (c[1][1]==i+a21+j+b21)&&
                (c[1][2]==i+a21+j+b31)&&
                (c[2][0]==i+a31+j)&&
                (c[2][1]==i+a31+j+b21)&&
                (c[2][2]==i+a31+j+b31)){
                    s="Yes";
                break;
            }
        }
        if(s=="Yes"){
            break;
        }
    }
    cout<<s<<endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << a + b + c + max({a, b, c}) * ((1 << k) - 1) << '\n';
    return (0);
}


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

int main() {
  
  int n ;
  cin >> n;
  string s;
  cin >> s;
  
  int a=1;
  for(int i=1;i<n;i++){
    if(s.at(i)!=s.at(i-1))
      a++;
    }
    
 
  
  cout << a << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);        
        int[] ct = new int[26];
        while(sc.hasNext()) {
            String str = sc.nextLine();            
            for(int i = 0; i < str.length(); i++) {
            	char c = str.charAt(i);
                if ('a' <= c && c <= 'z')
                    ct[c-'a']++;
                else if ('A' <= c && c <= 'Z')
                    ct[c-'A']++;
            }
        }
        for(int i = 0; i < 26; i++) {
            System.out.println((char)('a'+i) + " : " + ct[i]);
        }
    }
}



Measured memory_bytes: 26176
import math as mh
A,B,C,D=map(int,input().split())
if mh.ceil(A/D)==mh.ceil(C/B):
    print("Yes")
elif mh.ceil(A/D)<mh.ceil(C/B):
    print("No")
elif mh.ceil(A/D)>mh.ceil(C/B):
    print("Yes")

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

  #define ll long long
  #define int long long
  #define f(i,l,n) for(ll i=l;i<n;i++)
  #define E "\n"
  #define bp __builtin_popcount
  const int M = 1e9+7;

  
  int32_t main()
  {

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

   int n,m;
   cin >> n >> m;
   vector<int> graph[n+1];

   f(i,0,m)
   {
    int x,y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
   }

   int ans=0;

   vector<bool> visted(n+1,0);

   f(i,1,n+1)
   {
      if(visted[i]==0)
      {
          visted[i]=1;
          queue<int> q;
          q.push(i);
          int cnt=1;

          while(!q.empty())
          {
              int cur=q.front();
              q.pop();

              for(auto x:graph[cur])
              {
                  if(visted[x]==0)
                  {
                      cnt++;
                      q.push(x);
                      visted[x]=1;
                  }
              }            
          }
          ans=max(ans,cnt);
      }
   }
   cout<<ans;


    return 0;
  }

Measured memory_bytes: 17292
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=2e18+500;
const int sz=5e3+100;
int mark[sz];

int main()
{
    Go_
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    ll d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;

    cin>>a>>b>>c>>d;
    
    vector<ll> test,best;
    test.push_back(a);
    test.push_back(b);
    best.push_back(c);
    best.push_back(d);

    ll ans=-MAX;
    
    if(a<=0 && 0<=b) test.push_back(0);
    if(c<=0 && 0<=d) best.push_back(0);

    for(auto xx: test){
        for(auto yy: best) ans=max(ans, xx*yy);
    }


    cout<<ans<<endl;
    

}


Measured memory_bytes: 3652
#include<stdio.h>
#define N 100
 
int main(){
  int n, r[N + 1], c[N +1][N + 1] = {0}, i, l, j, k;
   
  scanf("%d", &n);
  for(i = 1; i <= n; i++)
    scanf("%d%d", &r[i - 1], &r[i]);
 
  //  for(i = 1; i <= n; i++)
    //    printf("%d %d\n", i, r[i - 1], r[i]);
   
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;      
      //      printf("%d\t", c[i][j]);
      c[i][j] = (1 << 21);
      //      printf("%d\n", c[i][j]);
      for(k = i; k <= j - 1; k++){
    if(c[i][j] > c[i][k] + c[k + 1][j] + r[i - 1] * r[k] * r[j]){
      c[i][j] = c[i][k] + c[k + 1][j] + r[i - 1] * r[k] * r[j];
    }
      }
    }
  }
   
  printf("%d\n", c[1][n]);
  return 0;
}

Measured memory_bytes: 644
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        // char[] ss = new char[s.length()];
        // char[] tt = new char[s.length()];
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            char si = s.charAt(i);
            char ti = t.charAt(i);
            if(si != ti){
                count++;
            }
        }
        System.out.println(count);
        sc.close();
    }
}

Measured memory_bytes: 41488
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define inff 100000


ll modo=1e9+7;
vector<int> vv[200005];
int pp[200005]={0};
int vis[200005]={0};

void dfs(int node)
{
    //cout<<node<<endl;
    vis[node]=1;
    for(auto i:vv[node])
    {
        if(!vis[i])
        {
            pp[i]+=pp[node];
            dfs(i);
        }
    }
}


int main()
{
   faf;
   int n;
   int q;
   cin>>n>>q;
   int a,b;
   int i;
   for(i=1;i<=n-1;i++)
   {
       cin>>a>>b;
       //cout<<a<<" "<<b<<endl;
       vv[a].pb(b);
       vv[b].pb(a);
   }
   int p,x;
   while(q--)
   {
       cin>>p>>x;
       pp[p]+=x;
   }
  // cout<<"Sdsd"<<endl;
   dfs(1);
   for(i=1;i<=n;i++)
   {
       cout<<pp[i]<<" ";
   }
}

Measured memory_bytes: 21120
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>

using namespace std;
//using Graph = vector<vector<int>>;


string s, t;
int main() {
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
vector<int> vis(N);
int solve(string a, string b){
    int cnt = 0;
    for(int i = 0; i < a.length(); i++){
        if(a[i] != b[i]){
            cnt++;
        }
    }
    return cnt;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        string s, t;
        cin >> s >> t;
        int n = t.length();
        int ans = INF;
        for(int i = 0; i + n <= s.length(); i++){
            string curr = s.substr(i, n);
            ans = min(ans, solve(curr, t));
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 34612
def main():
  N = int(input())
  A_list = list(map(int, input().split()))

  SV = [0 for i in range(N)]

  for i in A_list:
    SV[i-1] += 1
  
  for i in SV:
    print(i)


if __name__ == "__main__":
  main()

Measured memory_bytes: 32304
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;

int d1[maxn], d2[maxn];
int n, m;
string s;
bool mark[maxn];
queue <int> que;
vector<int> g[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> m >> s;
	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		if(u != v) {
			g[u].push_back(v);
			g[v].push_back(u);
			if(s[v] == 'A')
				d1[u]++;
			else
				d2[u]++;
			if(s[u] == 'A')
				d1[v]++;
			else
				d2[v]++;
		}
		else {
			g[u].push_back(u);
			if(s[v] == 'A')
				d1[u]++;
			else
				d2[u]++;
		}
	}
	
	for(int i = 0; i < n; i++) {
		if(d1[i] == 0 || d2[i] == 0) {
			que.push(i);
		}
	}
	
	while(que.size()) {
		int u = que.front();
		mark[u] = true;
//		cout << "del : " << u + 1 << endl;
		
		for(int i = 0; i < g[u].size(); i++) {
			int v = g[u][i];
			if(!mark[v]) {
				if(s[u] == 'B')
					d2[v]--;
				else
					d1[v]--;
				if((d1[v] == 0 && s[u] == 'A') || (d2[v] == 0 && s[u] == 'B')) {
					que.push(v);
				}
			}
		}
		que.pop();
	}
	
	int x = 0;
	for(int i = 0; i < n; i++) {
		if(!mark[i])
			x++;//, cout << i + 1 << " ";
	}
	
	if(x != 0)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 12624
n = int(input())
a = list(map(int, input().split()))
yen = 1000
kabu = 0

for i in range(n):
    top_nxt = -1
    bot_nxt = -1
    for j in range(i+1, n):
        if a[i] < a[j]:
            top_nxt = j
            break
    for j in range(i+1, n):
        if a[i] > a[j]:
            bot_nxt = j
            break
    if top_nxt == -1 and bot_nxt == -1:
        yen += kabu*a[i]
        kabu = 0
    elif top_nxt == -1:
        yen += kabu*a[i]
        kabu = 0
    elif bot_nxt == -1:
        tmp = yen//a[i]
        kabu += tmp
        yen -= tmp*a[i]
    elif top_nxt < bot_nxt:
        tmp = yen//a[i]
        kabu += tmp
        yen -= tmp*a[i]
    elif bot_nxt < top_nxt:
        yen += kabu*a[i]
        kabu = 0
if kabu:
    yen += kabu*a[-1]
print(yen)


Measured memory_bytes: 9252
#include <stdio.h>

int main(void){
  int N, i, j, x=0, y=0;
  scanf("%d", &N);
  for(i=1; i<=N; i = i+2){
    for(j=1; j<=i; j++){
      if(i%j == 0){
        x ++;
      }
    }
    if(x == 8){
      y ++;
    }
    x = 0;
  }
  printf("%d", y);
  return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) int t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vi vector<ll>
const ll md=1e9 +7;const ll M1=998244353;
ll mod(ll n){return ((n%md)+md)%md;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=res*x;x=x*x;y=y>>1;}return res;}

unsigned long long power(unsigned long long x, 
                         int y, int p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
unsigned long long ncr(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    unsigned long long fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int n;cin>>n;ll res=0;
    f(i,1,n+1){
        if(n-2*i-1>=0 && n-2*i-1>=i-1){
            res=mod(res+mod(ncr(n-2*i-1,i-1,md)));
        }
    }
    cs(res);
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
const int N = 105;
char s[N];
inl bool chk(int l,int r){
	for(ri i=1;i<=r-l+1;++i)
		if(s[l+i-1]!=s[r-i+1])
			return false;
	return true;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%s",s+1);
	int n=strlen(s+1);
	if(chk(1,n)&&chk(1,(n-1)/2)&&chk((n+3)/2,n))
		puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i+j)%2 == 0) printf("#");
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2652
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
#include<cstring>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>
#define ll long long 

ll n,m;
ll t[10000];
const int MA=2000000;
ll s1[MA];
ll s2[MA];


int main(){

while(cin>>n>>m,n||m){
rep(i,MA)s1[i]=s2[i]=0;
rep(i,10000)t[i]=0;

for(int i=1;i<=n;i++)cin>>t[i];
int g=0;

for(int i=0;i<=n;i++){
	for(int j=0;j<=n;j++){
		s1[i*(n+1)+j]=t[i]+t[j];
		g++;
	}
}


sort(s1,s1+g);
rep(i,g)s2[i]=s1[i];

ll ans=0;

for(int i=0;i<g;i++){
	int now=s1[i];

	int l=0;
	int r=g-1;
	int mid=(l+r)/2;
	ll x=s2[mid];

	for(int i=0;i<70;i++){
		if(x+now==m)break;
		if(l>r)break;
		if(x+now>m){
			r=mid;
			mid=(r+l)/2;
			x=s2[mid];
		}
		else{
			l=mid;
			mid=(r+l)/2;
			x=s2[mid];
		}
	}

	//cout<<" "<<x<<" "<<now<<" "<<x+now<<endl;
	if(x+now<=m)
	ans=max(ans,x+now);
}
cout<<ans<<endl;
}
	return 0;
}



Measured memory_bytes: 34436
a = input().split()
b = input().split()
count = 0
for i in range(int(a[0])):
  ans = 0
  temp = []
  temp = input().split()
  for j in range(len(temp)):
    ans = ans + int(temp[j])*int(b[j])
  ans = ans + int(a[2])
  if ans> 0:
    count+=1
print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	int f[n];
	f[n-1]=0;
	for(int i=n-2;i>=0;--i)
		if(a[i]>=a[i+1])
			f[i]=f[i+1]+1;
		else
			f[i]=0;
	cout<<*max_element(f,f+n)<<endl;
	return 0;
}

Measured memory_bytes: 1024
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

s = input_s
t = input_s

max = 0
cnt = 0
(s.length).times do |i|
  cnt = 0
  break if s.length - t.length < i
  (t.length).times do |j|
    if s[i + j] == t[j]
      cnt += 1
      if max < cnt
        max = cnt
      end
    end
  end
end
puts t.length - max


Measured memory_bytes: 14400
Slist = list(input())
Q = int(input())

hanten = 0
mae = [] # 後で反転
ushiro = []

for q in range(Q):
    query = input()
    if query == "1":
        if hanten == 0:
            hanten = 1
        else:
            hanten = 0
    else:
        T,F,C = query.split()
        if F == "1":
            if hanten == 0:
                mae.append(C)
            else:
                ushiro.append(C)
        elif F =="2":
            if hanten == 0:
                ushiro.append(C)
            else:
                mae.append(C)
# print("hanten:",hanten,"mae:",mae,"ushiro:",ushiro)            
if hanten == 0:
    rmae = mae[::-1]
    goukei = rmae + Slist + ushiro
    print(''.join(goukei))
else:
    goukei =ushiro[::-1] + Slist[::-1] + mae
    print(''.join(goukei))


Measured memory_bytes: 11296
#include<iostream>
#include<vector>
#include<climits>
using namespace std;

// F : T x T -> T
// G : T x E -> T
// H : E x E -> E
// R : E x int(length of the range) -> E
template<typename T, typename E, typename F, typename G, typename H, typename R>
struct SegL{
private:
    vector<T> node;
    vector<E> lazy;
    int n;
    T defVal;
    E defOp;
    F f;    // merge elements(T)
    G g;    // update element(T) 
    H h;    // merge operators(E)
    R r;    // operator depends on length

public:
    SegL(int siz, T defVal, E defOp, F f, G g, H h, R r) : defVal(defVal), defOp(defOp), f(f), g(g), h(h), r(r){
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, defVal);
        lazy.resize(2*n-1, defOp);
    }
    SegL(vector<T> v, T defVal, E defOp, F f, G g, H h, R r) : defVal(defVal), defOp(defOp), f(f), g(g), h(h), r(r){
        n = 1;
        while(n < v.size())  n *= 2;
        node.resize(2*n-1, defVal);
        for(int i = 0; i < v.size(); i++)   node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = f(node[2*i+1], node[2*i+2]);
    }

    void eval(int k, int len){
        if(lazy[k] == defOp)    return;
        if(k < n-1){
            lazy[2*k+1] = h(lazy[2*k+1], lazy[k]);
            lazy[2*k+2] = h(lazy[2*k+2], lazy[k]);
        }
        node[k] = g(node[k], r(lazy[k], len));
        lazy[k] = defOp;
    }

    void update(int a, int b, E x, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k, r-l);
        if(b <= l || r <= a){
            return;
        }else if(a <= l && r <= b){
            lazy[k] = h(lazy[k], x);
            eval(k, r-l);
        }else{
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }

    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k, r-l);
        if(b <= l || r <= a)    return defVal;
        if(a <= l && r <= b)    return node[k];
        T lx = query(a, b, 2*k+1, l, (l+r)/2);
        T rx = query(a, b, 2*k+2, (l+r)/2, r);
        return f(lx, rx);
    }
};

typedef long long ll;

int main(){
    int n, q;
    cin >> n >> q;
    auto f = [](ll x, ll y)->ll{return x+y;};
    auto g = [](ll x, ll y)->ll{return y==1001?x:y;};
    auto h = [](ll x, ll y)->ll{return y==1001?x:y;};
    auto r = [](ll x, ll y)->ll{return x*y;};
    ll defv = 0;
    ll defop = 1001;
    SegL<ll, ll, decltype(f), decltype(g), decltype(h), decltype(r)> seg(n, defv, defop, f, g, h, r);
    while(q--){
        int op;
        cin >> op;
        if(op == 0){
            int s, t, x;
            cin >> s >> t >> x;
            seg.update(s, t+1, x);
        }else{
            int s, t;
            cin >> s >> t;
            cout << seg.query(s, t+1) << endl;
        }
        // for(int i = 0; i < n; i++)  cout << seg.query(i,i+1) << " \n"[i==n-1];
    }
    return 0;
}



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

int main(){
    int N;
    scanf("%d", &N);
    vector<int> A(1<<N);
    for (int i = 0; i < (1<<N); i++) scanf("%d", &A[i]);
    vector<vector<pair<int, int>>> dp(1<<N, vector<pair<int, int>>(N+1, {0,0}));
    for (int i = 0; i < (1<<N); i++) dp[i][0] = {A[i], 0};
    
    for (int i = 0; i < (1<<N); i++) {
        for (int j = 1; j <= N; j++) {
            if (i & (1 << (j-1))) {
                int k = i - (1<<(j-1));
                if (dp[k][j-1].first > dp[i][j-1].first) {
                    dp[i][j] = {dp[k][j-1].first, max(dp[k][j-1].second, dp[i][j-1].first)};
                }else {
                    dp[i][j] = {dp[i][j-1].first, max(dp[i][j-1].second, dp[k][j-1].first)};
                }
            }
            else dp[i][j] = dp[i][j-1];
            
        }
    }
    int ans = 0;
    for (int i = 1; i < (1<<N); i++) {
        ans = max(ans, dp[i][N].first+dp[i][N].second);
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 51200
#include<bits/stdc++.h>
using namespace std;
int n,x,a[1005],sum=0,ans=0;
int main()
{
	cin>>n>>x;
	for (int i=1; i<=n; ++i)
	  {
	    cin>>a[i]; sum+=a[i];
	  }
	ans=n;
	sort(a-1,a+n+1);
	while (sum+a[1]<=x)
	  {
	    sum+=a[1]; ans++;
	  }
	if(sum>x) ans-=1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  long K;
  cin >> N >> K;
  
  vector<vector<int>> data(N, vector<int>(2));
  for(int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;
    data.at(i).at(0)=a;
    data.at(i).at(1)=b;    
  }
  stable_sort(data.begin(), data.end(), [](auto&x, auto&y){return x[0]< y[0];});

  int ans;
  for(int i=0; i<N; i++){
    K-=data.at(i).at(1);
    if(K<=0){
      ans=data.at(i).at(0);
      break;
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef complex<double> Vec;

ll P;
vector<ll> Inv, InvFact;
vector<ll> A;
vector<ll> C;
vector<ll> F, B;

void prepare() {
  Inv.resize(P);
  InvFact.resize(P);
  Inv[1] = 1;
  InvFact[0] = InvFact[1] = 1;
  for (ll i = 2; i < P; ++i) {
    Inv[i] = P - P / i * Inv[P % i] % P;
    InvFact[i] = Inv[i] * InvFact[i - 1] % P;
  }
}
void find_c() {
  // c0 + c1 x + c2 x(x-1) + c3 x(x-1)(x-2) + ...
  for (ll i = 0; i < P; ++i) {
    C.push_back(A[0] * InvFact[i] % P);
    vector<ll> new_a;
    for (ll j = 0; j < P - 1; ++j) {
      new_a.push_back((A[j + 1] + P - A[j]) % P);
    }
    A = new_a;
  }
}
void find_b() {
  B.resize(P);
  F.resize(P);
  F[0] = 1;
  for (ll i = 0; i < P; ++i) {
    for (ll j = 0; j < P; ++j) {
      (B[j] += C[i] * F[j] % P) %= P;
    }
    vector<ll> new_f;
    new_f.resize(P);
    for (ll j = 0; j < P - 1; ++j) {
      (new_f[j] += F[j] * (P - i) % P) %= P;
      (new_f[j + 1] += F[j]) %= P;
    }
    F = new_f;
  }
}
int main() {
  cin >> P;
  prepare();
  for (ll i = 0; i < P; ++i) {
    ll a;
    cin >> a;
    A.push_back(a);
  }
  find_c();
  find_b();
  bool first = true;
  for (ll b : B) {
    cout << (first ? "" : " ") << b;
    first = false;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 512
x, y = map(int, input().split())
ans = 10 ** 10
l = ['020', '021', '120', '121']


def a(integer, count):
    d = abs(abs(y) - abs(integer))
    return integer + d, d + count


def b(integer, count):
    return -integer, count + 1


for i in l:
    cnt = 0
    X = x
    for j in i:
        if j == '1':
            X, cnt = b(X, cnt)
        elif j == '2':
            X, cnt = a(X, cnt)
    if y == X:
        ans = min(cnt, ans)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void) {
    int a,b;
    scanf("%d %d",&a,&b);
    if (a>b) {
        printf("a > b\n");
    } else if (a<b) {
        printf("a < b\n");
    } else {
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
import sys
sys.setrecursionlimit(1000000)
N, M = [int(n) for n in input().split()]
AB = []

P = list(range(N))
P_num = [1] * N

def root(x):
    if P[x] == x:
        return x
    else:
        P[x] = root(P[x])
        return P[x]
        
def unite(x, y):
    P[root(y)] = root(x)
    

for m in range(M):
    A, B = [int(n) - 1 for n in input().split()]
    AB.append((A, B))

convenience = [0]
for i in range(M):
    A, B = AB[M - 1 - i]
    convenience.append(convenience[-1])
    if root(A) != root(B):
        convenience[-1] += P_num[root(A)] * P_num[root(B)]
        next_num = P_num[root(A)] + P_num[root(B)]
        unite(A, B)
        P_num[root(A)] = next_num

for m in range(M):
    print(N * (N - 1) // 2 - convenience[M - 1 - m])

    

Measured memory_bytes: 36796
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define INF 1000000
using namespace std;
int main(){
    int n,x,y;
    cin >> n >> x >> y;
    --x; --y;
    queue<int> q;
    vector<int> dist(n);
    rep(i,n) dist[i]=0;
    rep(i,n){
        vector<int> d(n);
        rep(j,n) d[j]=INF;
        q.push(i);
        d[i]=0;
        dist[0]++;
        while(!q.empty()){
            int now=q.front(); q.pop();
            auto PUSH = [&](int now,int next){
                if(d[next]!=INF) return;
                q.push(next);
                d[next]=d[now]+1;
                dist[d[next]]++;
            };

            if(now!=0) PUSH(now,now-1);
            if(now!=n-1) PUSH(now,now+1);
            if(now==x) PUSH(x,y);
            if(now==y) PUSH(y,x);
        }
    }
    rep(i,n-1) cout << dist[i+1]/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }

const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

ll intpow(ll a,ll n, ll K){ll p=1;while(n){if(n&1)p=a*p%K;a=a*a%K;n>>=1;}return p;} 

int main()
{
        ll K;
        cin >> K;
        ll sm = 0;
        rep(i, 0, K+1000) {
                ll tmp = intpow(10, i, K) * 7;
                
                tmp %= K;
                sm = (sm + tmp) % K;
                
                if (sm == 0 or sm == K) {
                        cout << i+1 << endl;
                        return 0;
                }

        }
        cout << -1 << endl;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);
ll f(ll x, ll m) {
    return (x*x) % m;
}

int main() {

    ll N, X, M;
    cin >> N >> X >> M;

    set<ll> s, c;
    s.insert(X);
    ll t = X;
    vector<ll> v, w;
    v.push_back(X);

    for(int i = 0; i < N; i++) {
        t = f(t, M);

        if (s.count(t) == 1) {
            if (c.count(t) == 1) break;
            w.push_back(t);
            c.insert(t);
        }
        if (c.size() == 0) {
            s.insert(t);
            v.push_back(t);
        }
    }

    ll ans = 0;
    if (v.size() >= N) {
        for(int i = 0; i < N; i++) {
            ans += v[i];
        }
        cout << ans << endl;
        return 0;
    }

    for(ll i : v) {
        ans += i;
    }
    ll sum = 0;
    for (ll i : w) {
        sum += i;
    }

    N -= v.size();
    ll m = N / c.size();
    ans += sum * m;
    ll k = N - m*c.size();

    for(int i = 0; i < k; i++) {
        ans += w[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int  A,B,X; cin >> A >> B >> X;
    if(A > X){
        cout << "NO" << endl;
    }
    else if(X - A <= B){
        cout << "YES" << endl;
    }
    else if(X - A > B){
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import(
	"bufio"
	"strconv"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	sc.Split(bufio.ScanWords)
	buf := make([]byte, 10000)
	sc.Buffer(buf, 301000)

	n := nextInt()
	s := nextLine()

	data := strings.Split(s, "")

	min := 1000000
	right := make([]int, n+1)
	left := make([]int, n+1)

	for i := 1; i < n; i++ {
		if data[i-1] == "W" {
			left[i] = left[i-1] + 1
		} else {
			left[i] = left[i-1]
		}
	}

	for i := n-1; i > 0; i-- {
		if data[i] == "E" {
			right[i-1] = right[i] + 1
		} else {
			right[i-1] = right[i]
		}
	}

	for i := 0; i < n; i++ {
		sum := right[i] + left[i]
		if min > sum {
			min = sum
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 11264
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		char c[]=new char[n+2];
		String str=sc.next();
		for(int i=0;i<n;i++) {
			c[i]=str.charAt(i);
		}
		c[n]=c[0];
		c[n+1]=c[1];
		boolean a[]=new boolean [4];
		boolean t=true;
		for(int i=0;i<4;i++) {
			if(i==0) {
				a[0]=str(c,n,'s','s');
			}else if(i==1) {
				a[1]=str(c,n,'s','w');
			}else if(i==2) {
				a[2]=str(c,n,'w','s');
			}else if(i==3) {
				a[3]=str(c,n,'w','w');
			}
			
			if(a[i]) {
				t=false;
				break;
			}
		}
		
		if(t){
			System.out.println("-1");
		}
		
		
		
		
	}
	public static boolean str(char c[],int n,char c1,char c2){
		char s1[]=new char[c.length];
		s1[0]=c1;
		s1[1]=c2;
		for(int i=1;i<n+1;i++){
			if(c[i]=='o'){
				if(s1[i]=='s'){
					if(s1[i-1]=='s'){
						s1[i+1]='s';
					}else{
						s1[i+1]='w';
					}
				}else{
					if(s1[i-1]=='s'){
						s1[i+1]='w';
					}else{
						s1[i+1]='s';
					}
				}
				
			}else{
				if(s1[i]=='s'){
					if(s1[i-1]=='s'){
						s1[i+1]='w';
					}else{
						s1[i+1]='s';
					}
				}else{
					if(s1[i-1]=='s'){
						s1[i+1]='s';
					}else{
						s1[i+1]='w';
					}
				}
			}
		}
		if(s1[n]==s1[0]&&s1[n+1]==s1[1]) {
			for(int i=0;i<n;i++) {
				System.out.print(Character.toUpperCase(s1[i]));
			}
			return true;
		}else {
			return false;
		}
		
		
	}
	

}

Measured memory_bytes: 35472
#include <cstdio>
long long n, s, a, b;
int main() {
	scanf("%d", &n);
	while(n--) {
		scanf("%lld", &a);
		if(!a) b=0;
		b += a;
		s += b/2;
		b %= 2;
	}
	printf("%lld", s);
	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main() {

    cin.tie(nullptr);
    ios::sync_with_stdio(false);



    int N, K;
    cin >> N >> K;
    vector<vi> TD(N);
    REP(i,N) {
        int t, d;
        cin >> t >> d;
        TD[--t].emplace_back(d);
    }

    vi y0, y1;
    REP(i,N) {
        if (TD[i].empty()) continue;
        sort(ALL(TD[i]));
        y1.emplace_back(TD[i].back());
        TD[i].pop_back();
        y0.insert(y0.end(), ALL(TD[i]));
    }
    sort(ALL(y0), greater<>());
    sort(ALL(y1), greater<>());

    ll num_chose, sumn = 0;
    num_chose = max(0, (int)(K - y0.size()));
    REP(i,num_chose) sumn += y1[i];
    REP(i,K-num_chose) sumn += y0[i];
    ll res = 0;
    while (true) {
        res = max(res, sumn + num_chose * num_chose);
        if (num_chose >= K or num_chose >= y1.size()) break;
        sumn += y1[num_chose];
        sumn -= y0[K - num_chose - 1];
        num_chose++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	int ans=0,cnt=0;
	for(int i=1;i<=3;i++)
		if(s[i-1]=='R')
			cnt++;
		else
		{
			ans=max(ans,cnt);
			cnt=0;
		}
	ans=max(ans,cnt);
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  while(1){
    string s;
    vector<string> v;
    cin>>s;
    if(s=="#")break;
    string tmp="";
    for(int i=0;i<(int)s.size();i++){
      if(s[i]=='/'){
        v.push_back(tmp);
        tmp="";
      }else if(s[i]=='b'){
        tmp+='o';
      }else{
        for(int j=0;j<(s[i]-'0');j++)
          tmp+='.';
      }
    }
    v.push_back(tmp);
    
    int ax,ay,bx,by;
    cin>>ax>>ay>>bx>>by;
    v[ax-1][ay-1]='.';
    v[bx-1][by-1]='o';
    string ans="";
    for(int i=0;i<(int)v.size();i++){
      int cnt=0;
      for(int j=0;j<(int)v[i].size();j++){
        if(v[i][j]=='o'){
          if(cnt)ans+=('0'+cnt),cnt=0;
          ans+='b';
        }else{
          cnt++;
        }
      }
      if(cnt)ans+=('0'+cnt);
      if(i+1<(int)v.size())ans+='/';
    }

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

Measured memory_bytes: 3180
import math
import heapq
import sys
from collections import Counter

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

N,x=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
a=list(map(int,input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

heapq.heapify(a)  # リストを優先度付きキューへ

for i in range(N):
    x-=heapq.heappop(a)  # 最小値の取り出し
    #print(x,a)
    if x<=0 or i==N-1:
        if x==0:
            print(i+1)
        else:
            print(i)
        break
        




Measured memory_bytes: 3316
#include<stdio.h>
#include<algorithm>
using namespace std;
void output(int H[3][10])
{
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<10;j++)
        {
    printf(" %d",H[i][j]);
    }
    printf("\n");
}
}
int main()
{
    int H1[3][10],H2[3][10],H3[3][10],H4[3][10],n,h_num,f_num,r_num,div_num;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<10;j++)
        {
            H1[i][j]=H2[i][j]=H3[i][j]=H4[i][j]=0;
        }
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d%d",&h_num,&f_num,&r_num,&div_num);
        switch(h_num)
        {
        case 1:
            H1[f_num-1][r_num-1]+=div_num;
            break;
        case 2:
            H2[f_num-1][r_num-1]+=div_num;
            break;
        case 3:
            H3[f_num-1][r_num-1]+=div_num;
            break;
        case 4:
            H4[f_num-1][r_num-1]+=div_num;
            break;
        }
    }
output(H1);
printf("####################\n");
output(H2);
printf("####################\n");
output(H3);
printf("####################\n");
output(H4);


}



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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> Interval;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

int N,K;

int main()
{
    cin >> N >> K;
    if(K == 1) printf("0\n");
    else printf("%d\n",N-K);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000001];
int main()
{
	int n,k,s,i,j;
	cin>>n>>k>>s;
	if(n==k)
	for(i=1;i<=n;i++)
	a[i]=s;
	else if(k==0)
	{
	 if(s==1000000000)
	 for(i=1;i<=n;i++)
	 a[i]=1;
	 else
	 for(i=1;i<=n;i++)
	 a[i]=s+1;
	}
	else if(s==1)
	{
		for(i=1;i<=k;i++)
		a[i]=1;
		for(j=i;j<=n;j++)
		a[j]=2;
	}
	else
	{
	k++;
	for(i=1;i<=k;i++)
	{
		if(i%2==1)a[i]=1;
		else     a[i]=s-1;
	}
	int h=n-k;
	while(h)
	{
		if(s==1000000000)a[i]=2;
		else             a[i]=s+1;
		h--;
		i++;
	}
    }
	for(i=1;i<=n;i++)
	cout<<a[i]<<" "; 
} 

Measured memory_bytes: 1664
// Problem : D - Alter Altar
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

void solve() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  int r = 0;
  for (auto i : s) r += (i == 'R');
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (i < r && s[i] == 'W') {
      ans++;
    }
  }

  cout << ans;
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) a = b;
  return a > b;
}
template<class T> inline bool chmax(T&a, T b) {
  if (a < b) a = b;
  return a < b;
}

int gcd(int a, int b) {
  if (a < b) swap(a, b);
  int mod=a%b, div=b, temp;
  while (mod!=0) {
    temp=mod;
    mod=div%mod;
    div=temp;
  }
  return div;
}

signed main() {
  int W, H, C;
  cin >> W >> H >> C;
  int g = gcd(W,H);
  cout << (W/g)*(H/g)*C << endl;
}



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

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

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

    // start
    int a, b;
    cin >> a >> b;
    cout << ((a % 2 == 1) && (b % 2 == 1) ? "Yes" : "No") << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;

#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        L: [u64; N]
    }

    let mut ans = 0;

    for xs in (0..N).combinations(3) {
        let arr = [L[xs[0]], L[xs[1]], L[xs[2]]];

        if arr[0] == arr[1] || arr[1] == arr[2] || arr[2] == arr[0] {
            continue;
        }

        if arr.iter().sum::<u64>() <= 2 * arr.iter().max().unwrap() {
            continue;
        }

        ans += 1;
    }
    
    println!("{}", ans);
}

Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N, D;
    int cover;
    cin >> N >> D;

    cover = 2 * D + 1;

    if (N % cover){
        cout << N / cover + 1 << endl;
    }else{
        cout << N / cover << endl;
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		sc.close();
		
		for(int i=1; i<=s.length()/2; i++) {
			int subslength = (s.length()-2*i)/2;
			
			if(s.substring(0, subslength-1).equals(s.substring(subslength, s.length()-2*i-1))) {
				System.out.println(s.length()-2*i);
				break;
			
			}
		}
	}
}


Measured memory_bytes: 22612
# by the authority of GOD
import os,sys
from io import BytesIO, IOBase

def main():
    a,b,c,d=map(int,input().split())
    print(max(b*d,b*c,c*a,d*a))
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 62768