akhauriyash/Code-Regression huggingface dataset:
/**
 *   Author:  Wasi Ur Rahman
 *   FROM RMSTU
**/
#include <bits/stdc++.h>
#define ll                      long long
#define boost                   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ticktock                cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n"
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(d,min3(a,b,c))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(d,max3(a,b,c))
#define all(v)                  v.begin(),v.end()
#define revall(v)               v.rbegin(),v.rend()
#define pb                      push_back
#define Max(v)                  *max_element(all(v))
#define Min(v)                  *min_element(all(v))
#define eb                      emplace_back
#define vll                     vector<ll>
#define sci(t)                  scanf("%d",&t)
#define scl(t)                  scanf("%lld",&t)
#define memset(a, b)            memset(a, (b), sizeof(a))
#define setbits(x)              __builtin_popcountll(x)
#define zrobits(x)              __builtin_ctzll(x)
#define si(x)                   scanf("%d", &x)
#define sii(x, y)               scanf("%d %d", &x, &y)
#define siii(x, y, z)           scanf("%d %d %d", &x, &y, &z)
#define siiii(p,x, y, z)        scanf("%d %d %d %d",&p, &x, &y, &z)
#define sl(x)                   scanf("%lld", &x)
#define sll(x, y)               scanf("%lld %lld", &x, &y)
#define slll(x, y, z)           scanf("%lld %lld %lld", &x, &y, &z)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define println()               cout << endl
#define gcd(a,b)                __gcd(a,b)
#define lcm(a,b)                (a)*(b)/gcd(a,b)
#define printi(x)               printf("%d\n")
#define printii(x,y)            printf("%d %d\n")
#define printiii(x,y,z)         printf("%d %d %d\n")
#define printl(x)               printf("%lld\n")
#define printll(x,y)            printf("%lld %lld\n")
#define printlll(x,y,z)         printf("%lld %lld %lld\n")
#define chkbit(x,p)             ((x&(1LL<<p))?1:0)
#define setbit(x,p)             x|=(1LL<<p)
#define clrbit(x,p)             x=x&(~(1LL<<p))
#define revbit(x,p)             (chkbit(x,p)?clrbit(x,p):setbit(x,p))
using namespace std;
int main(){
    boost;
    string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int n = s.size();
    int p;
    cin >> p;
    string str;
    cin >> str;
    string a = "";
    for(int i = 0;i<str.size();i++)
    {
        a += str[i];
        int t = s.find(a);
        str[i] = s[(t+p)%n];
        a.clear();
    }
    cout << str << endl;
}


Measured memory_bytes: 3644
import sys
from collections import deque

def main(sa,sb,sc):
    sa=deque(sa)
    sb=deque(sb)
    sc=deque(sc)
    ms={'a':sa, 'b':sb, 'c':sc}
    ct='a'
    while True:
        cc=ms[ct].popleft()
        ct=cc
        if not ms[ct]:
            return ct.upper() 

sa=sys.stdin.readline().strip()
sb=sys.stdin.readline().strip()
sc=sys.stdin.readline().strip()

print(main(sa,sb,sc))


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

int h,w,a,b;
string s1,s2;

int main() {
	cin >> h >> w >> a >> b;
	for (int i = 0; i < a; i++) s1 += '1', s2 += '0';
	for (int i = a; i < w; i++) s1 += '0', s2 += '1';
	for (int i = 0; i < b; i++) cout << s1 << "\n";
	for (int i = b; i < h; i++) cout << s2 << "\n";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;
ll int gcd(ll x,ll y){
   return y ? gcd( y , x%y ) : x;
}

int main(){
  int k;    cin >> k;
  
  for(ll i=1;i<=k;i++){
      for(ll j=1;j<=k;j++){
          for(ll m=1;m<=k;m++){
              cnt+=gcd(gcd(i,j),m);
          }
      }
  }
  cout << cnt << endl;
}

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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<ll,ll>
#define INFINITY INT_MAX

const int maxn=4e5+10;
const ll maxN=1e18+10;

ll ST[maxn],a[maxn];

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s,t;
  cin >> s;
  FOR(i,1,s.length()) cout << 'x';
}
    

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(N)]
result = [[A[i][j]*B[j] for j in range(M)] for i in range(N)]
result = [1 for i in result if sum(i)+C > 0]
print(len(result))

Measured memory_bytes: 3064
import java.util.*;
import java.math.*;
public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Deque<Long> que = new ArrayDeque();
        for(long i = 1;i < 10;i++)que.add(i);
        int count = 0;
        for(int i = 0;i < n;i++){
            long poyo = que.pollFirst();
            if(poyo%10!=0)que.add(10*poyo-1+poyo%10);
            que.add(10*poyo+poyo%10);
            if(poyo%10!=9)que.add(10*poyo+1+poyo%10);
            if(i==n-1)System.out.println(poyo);
        }
        
    }    
    
    
}







Measured memory_bytes: 30164
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>

using namespace std;

int main(){
	long long a,b,c,d,x,v;
	cin>>a>>b>>c>>d;
	x=a*b;
	v=c*d;
	if(x>v)
	cout<<x<<endl;
	else
	cout<<v<<endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++) {
        cin >> S.at(i);
    }
    sort(S.begin(),S.end());
    S.erase(unique(S.begin(),S.end()),S.end());
    cout << (int)S.size() << endl;
}

Measured memory_bytes: 9548
#include <stdio.h>


int main(void) {

  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);

 int i = 0;
 int con;
  while(1){
      if ( a*i - i + 1 >= b ){
          con = i;
          break;
      }
      else {
          i++;
      }

  }


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



  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <set>


int n, p[200005], f[200005], a[200005], b[200005];
long long ans;
int find(int x) {return f[x] == x ? x : f[x] = find(f[x]); }
struct node {int c0, c1, id; };
bool operator < (const node &a, const node &b) {
	return 1LL * a.c0 * b.c1 == 1LL * a.c1 * b.c0 ? a.id < b.id : 1LL * a.c0 * b.c1 > 1LL * a.c1 * b.c0;
}
std::set<node> S;
int main() {
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) scanf("%d", &p[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &b[i]), a[i] = !b[i], f[i] = i;
	for (int i = 2; i <= n; i++) S.insert({a[i], b[i], i});
	while (S.size()) {
		node x = *S.begin(); S.erase(x);
		int y = f[x.id] = find(p[x.id]);
		if (y != 1) S.erase({a[y], b[y], y});
		ans += 1LL * b[y] * a[x.id];
		a[y] += a[x.id], b[y] += b[x.id];
		if (y != 1) S.insert({a[y], b[y], y});
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 15872
object Main extends App{
    val sc = new java.util.Scanner(System.in)
    val h, w = sc.nextInt
    val list = List.fill(h)(sc.next)
    val colBuf = (0 until w).map(x => {
        (0 until h).foldLeft(true)((acc, y) => acc && list(y)(x) == '.')
    })
    val rowBuf = (0 until h).map(y => {
        (0 until w).foldLeft(true)((acc, x) => acc && list(y)(x) == '.')
    })

    (0 until h).foreach(y => {
        (0 until w).foreach(x => {
            if(!colBuf(x) && !rowBuf(y)) {
                print(s"${list(y)(x)}")
        }})
        if(!rowBuf(y)) {
            println("")
        }
    })
}


Measured memory_bytes: 34996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main() { 
    ll n;
    std::cin >> n;
    std::vector<ll> a(n);
    rep(i,n){
        std::cin >> a[i];
        if(i!=0)a[i]+=a[i-1];
    }
    ll le=a[n-1];
 //   std::cout << le << std::endl;
    rep(i,n){
        //std::cout << a[i] << std::endl;
        if(a[i]>le/2){
            ll g=INF64,h=INF64;
            g=abs((a[n-1]-a[i])-a[i]);
            if(i!=0)h=abs(a[n-1]-a[i-1]-a[i-1]);
            std::cout << min(g,h) << std::endl;
            exit(0);    
            
        }
        
    }  
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    int H, W, D, Q;
    vector<vector<long long>> A;
    map<long long, vector<int>> v2xy;

    cin >> H >> W >> D;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            long long t2;
            cin >> t2;
            t2--;
            v2xy[t2] = vector<int>{i, j};
        }
    }
    cin >> Q;

    vector<long long> R2L(H * W, 0);
    for (long long i = 0; i < D; i++)
    {
        long long t = 0, x = v2xy[i][0], y = v2xy[i][1];
        for (long long j = 0; j * D + i < H * W; j++)
        {
            t += abs(v2xy[j * D + i][0] - x) + abs(v2xy[j * D + i][1] - y);
            x = v2xy[j * D + i][0];
            y = v2xy[j * D + i][1];
            R2L[j * D + i] = t;
        }
    }

    for (long long i = 0; i < Q; i++)
    {
        long long L, R;
        cin >> L >> R;
        L--;
        R--;
        cout << R2L[R] - R2L[L] << endl;
    }
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007

using namespace std;

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

    // code comes here
    string s;
    cin>>s;
    
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }


    return 0;
}





Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int gcd(int x,int y){
    if(x<y)swap(x,y);
    return (x%y==0?y:gcd(y,x%y));
}
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++)cin >> a[i];
    vector<int> front(n+1),back(n+1);
    front[0]=a[0];back[0]=a[n-1];
    for(int i=0; i<n; i++){
        front[i+1]=gcd(front[i],a[i]);
        back[i+1]=gcd(back[i],a[n-1-i]);
    }
    int ans=max(front[n-1],back[n-1]);
    for(int i=0; i<n; i++){
        ans=max(ans,gcd(front[i],back[n-i-1]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
A=input()
l=set(chr(ord('a') + i) for i in range(26))
l2=list(l-set(A))
l2.sort()
if len(A)!=26:
   print(A+l2[0])
else:
   for i in reversed(range(25)):
      for j in reversed(range(i+1,26)):
         if A[i] < A[j]:
            print(A[:i]+A[j])
            exit()
   else:
      print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int ap[1000000+20],n,a[200000+20];
int main(){
	fastio;
	cin>>n;
	rb(i,1,n) {
		cin>>a[i];
		
	}
	sort(a+1,a+1+n);
	rb(i,1,n){
		if(a[i]==a[i-1]){
			ap[a[i]]=1;
		}
	}
	int res=0;
	rb(i,1,n){
		if(!ap[a[i]])
			res++;
		if(a[i]!=a[i-1]){
			for(int j=2*a[i];j<=1000000;j+=a[i]){
				ap[j]=1;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, A[100100];
std::multiset<int> s;

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    for(int i=0;i<N;++i){
        auto it = s.lower_bound(A[i]);

        if(it == s.begin()){
            s.emplace(A[i]);
        }else{
            std::advance(it, -1);
            s.erase(it);
            s.emplace(A[i]);
        }
    }

    int res = s.size();
    std::cout << res << std::endl;
}


Measured memory_bytes: 5376
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


A, B, T = map(int, input().split())

i = 1
count = 0
while i*A < T + 0.5:
    count += B
    i += 1

print(count)


Measured memory_bytes: 8988
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <cstdio>

using std::endl;

#define ll long long int
#define FOR(a, s, n) for(int a = s; a < n; ++a)
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define MOD 1000000007
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std
#define asn ans

ll N, P;


char s[1234567], t[1234567];
int s_N, t_N;
int main()
{

	IN >> s >> t;

	for (int a = 0; a < 123; ++a)
	{
		if (s[a] == '\0')
		{
			s_N = a;
			break;
		}
	}
	for (int a = 0; a < 123; ++a)
	{
		if (t[a] == '\0')
		{
			t_N = a;
			break;
		}
	}

	std::sort(s, s + s_N);
	std::sort(t, t + t_N);

	std::reverse(t, t + t_N);

	for (int a = 0; a < 123; ++a)
	{

		if (s[a] == '\0' && t[a] != '\0')
		{

			puts("Yes");
			return 0;
		}

		if (s[a] != '\0' && t[a] == '\0')
		{

			puts("No");
			return 0;
		}

		if (s[a] < t[a])
		{
			puts("Yes");
			return 0;
		}
		if (s[a] > t[a])
		{
			puts("No");
			return 0;
		}
	}

	puts("No");

	return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
l=list(map(int,input().split()))

for i in range(n):
  l[i]=abs(l[i]-x)

def gcd(x,y):
    if y==0:
      return x
    else:
      return gcd(y,x%y) 
    
if n==1:
  x=l[0]
else:
  x=gcd(l[0],l[1])
  if n>2:
    for i in range(2,n):
      x=gcd(x,l[i])
print(x)

Measured memory_bytes: 14252
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    int[][] wa=new int['z'-'a'+1][n+1];
    for(int i=0;i<n;i++){
      wa[s.charAt(i)-'a'][i+1]=1;
    }
    for(int i=0;i<n;i++){
      for(int j='a'-'a';j<='z'-'a';j++){
        wa[j][i+1]+=wa[j][i];
      }
    }
    int max=0;
    for(int i=0;i<n;i++){
      int cnt=0;
      for(int j='a'-'a';j<='z'-'a';j++){
        if(wa[j][i+1]>0&&wa[j][n]-wa[j][i+1]>0){
          cnt++;
        }
      }
      max=Math.max(cnt,max);
    }
    System.out.println(max);
  }
}

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

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

  vector<int> v;

  for (int i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    v.push_back(x);
  }

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

  int d = (k - v[v.size() - 1]) + v[0];

  for (int i = 1; i < n; i++)
  {
    d = max(d, v[i] - v[i - 1]);
  }

  int distance = k - d;

  cout << distance << endl;
}

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

int main()
{
    string s;
    cin>>s;
    
    int l=0;
    
    for(int i=0;i<s.length();i++)
    {
        if(i%2==0)
        {
            if(s[i]=='L')
            {
                l=1;
                break;
            }
            
        }
        else
        {
            if(s[i]=='R')
            {
                l=1;
                break;
            }
        }
    }
    
    if(l==0)
    cout<<"Yes";
    else
    cout<<"No";
    
    return 0;
}


Measured memory_bytes: 256
import sys
import itertools
X = int(input())
N = 120
ABs = []
for i in range(N):
    ABs.append(i**5)
    
for i in range(N):
    for j in range(N):
        if ABs[i]-ABs[j] == X:
            print(i,j)
            sys.exit()
        elif ABs[i]+ABs[j] == X:
            print(i,-j)
            sys.exit()

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

#define int long long

signed main()
{
    int A[4];
    int N;

    for(int i = 0; i < 4; i++) cin >> A[i];
    cin >> N;

    N *= 4;

    int now = 0;
    int sum = A[0] * N;  //暫定
    for(int i = 1; i < 4; i++) {
        int val = 1 << i;
        int sa = N / val * val * A[now] / (1 << now) - N / val * A[i];
        if(sa > 0) {
            sum -= sa;
            now = i;
        }
    }

    cout << sum << endl;

    return (0);
}

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

ll func(ll a, ll x){
    if (a==-1) return 0;
    else return (ll)((a / x) + 1);
}

int main(){
    ll a , b , x;
    cin >> a >> b >> x;
    cout << func(b , x) - func(a-1 , x) << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

class UnionFind
{
private:
	vector<int> par;
	vector<int> rank; 
public:
	UnionFind(int n): par(n), rank(n)
	{
		for(int i=0; i<n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}
	int root(int x)
	{
		if (par[x] == x){
			return x;
		}else{
			return par[x] = root(par[x]);
		}
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		if (rank[rx] > rank[ry]){
			par[ry] = rx;
		}else{
			par[rx] = ry;
			if (rank[rx] == rank[ry]) rank[ry]++;
		}
	}
	int same(int x, int y)
	{
		return root(x) == root(y);
	}
};

typedef struct {ll u, v, cost;} edge;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	while(cin>>n>>m, n>0){
		vector<edge> es(m);
		rep(i, m){
			ll s, t, c;
			cin>>s>>t>>c;
			es[i].u = s-1;
			es[i].v = t-1;
			es[i].cost = c;
		}
		UnionFind uf(n);
		vll ans;
		sort(es.begin(), es.end(),
			[](edge &x, edge &y){return x.cost < y.cost;});
		rep(i, m){
			edge e = es[i];
			if (!uf.same(e.u, e.v)){
				uf.unite(e.u, e.v);
				ans.pb(e.cost);
			}
		}
		cout << ans[ans.size()/2] << "\n";
	}
	return 0;
}


Measured memory_bytes: 3372
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>

using namespace std;

int maxtime(int x) {
	// 1の位を切り上げ
	return (x + 9) / 10 * 10;
}

int main(void)
{
	int a[5];

	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

	int sum = 0;
	for (int i = 0; i < 5; i++) {
		sum += maxtime(a[i]);
	}
	int remtime, remtime_max = 0;
	for (int i = 0; i < 5; i++) {
		remtime = maxtime(a[i]) - a[i];
		if (remtime > remtime_max) {
			remtime_max = remtime;
		}
	}
	sum -= remtime_max;
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    string s;
    cin >> s;
    vi sa = suffix_array(s);
    ll ans = 1 * sz(s) * (sz(s) + 1) / 2;
    each(x, lcp_array(s, sa)) ans -= x;
    print(ans);
}

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

using namespace std;
inline void read(long long &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}
inline void write(long long x) {
    static const long long maxlen = 100;
    static char s[maxlen];
    if (x < 0) {   putchar('-'); x = -x;}
    if (!x) { putchar('0'); return; }
    long long len = 0; for (; x; x /= 10) s[len++] = x % 10 + '0';
    for (long long i = len - 1; i >= 0; --i) putchar(s[i]);
}

inline void read(int &x){
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}

const long long MAXN =1001000;

long long n,lim;
long long a[ MAXN ];
long long sum[ MAXN ];

long long val[ MAXN ];

long long tree[ MAXN ];


long long lowbit(long long x){
return x&(-x);
}

void add(long long x,long long val){
while (x<MAXN)
    {
        tree[x]+=val;
        x+=lowbit(x);
    }
}

long long query(long long x){
long long tmp=0;
while ( x)
    {
        tmp+=tree[x];
        x-=lowbit(x);
    }
return tmp;
}


int main(){
    read(n);read(lim);
    for (long long i=1;i<=n;i++)
    {
        read(a[i]);
        a[i]=a[i]-lim;
    }
    for (long long i=1;i<=n;i++)
        sum[i]=sum[i-1]+a[i];

    for (long long i=0;i<=n;i++)
        val[i]=sum[i];

    sort(val+1,val+n+1);
    long long cnt=unique(val+1,val+n+1)-(val+1);
    for (long long i=0;i<=n;i++)
        sum[i]=lower_bound(val+1,val+n+1,sum[i])-val;
    long long ans=0;
    for (long long i=0;i<=n;i++)
        {
            ans+=query(sum[i]);
            add(sum[i],1);
        }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 18176
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
bool ok[303][303][303];
bool ok1[303][303][303];
ll dp[303][303][303];
int main()
{
	string s; cin>>s;
	int n=s.size();
	ok[0][0][0]=1;
	for(int i=0; i<=n; i++){
		for(int j=n; j>=0; j--){
			for(int k=n; k>=0; k--){
				if(!ok[i][j][k]) continue;
				if(j && j+k>=2) ok[i][j-1][k]=1;
				if(k && j+k>=2) ok[i][j][k-1]=1;
				if(i+1<n && (s[i]=='0' || s[i+1]=='0')){
					ok[i+2][j+1][k]=1;
				}
				if(i+1<n && (s[i]=='1' || s[i+1]=='1')){
					ok[i+2][j][k+1]=1;
				}
				if(i<n && j && s[i]=='1'){
					ok[i+1][j-1][k+1]=1;
                  ok[i+1][j][k]=1;
				}
				if(i<n && j && s[i]=='0'){
					ok[i+1][j][k]=1;
				}
				if(i<n && k && s[i]=='0'){
					ok[i+1][j+1][k-1]=1;
                  ok[i+1][j][k]=1;
				}
				if(i<n && k && s[i]=='1'){
					ok[i+1][j][k]=1;
				}
			}
		}
	}
	for(int i=0; i<=n; i++) for(int j=0; j<=n; j++) for(int k=0; k<=n; k++) ok1[i][j][k]=ok[i][j][k];
	for(int i=n; i>=1; i--){
		for(int j=0; j<=n; j++){
			for(int k=0; k<=n; k++){
				if(!ok1[i][j][k]) continue;
				if(s[i-1]=='0' && j) ok1[i-1][j-1][k]=1;
				else if(s[i-1]=='1' && k) ok1[i-1][j][k-1]=1;
			}
		}
	}
	dp[0][0][0]=1;
	for(int i=0; i<=n; i++){
		for(int j=0; i+j<=n; j++){
			for(int k=0; i+j+k<=n; k++){
				(dp[i+1][j][k]+=dp[i][j][k])%=MOD;
				if(i<n && s[n-1-i]=='0'){
					(dp[i][j][k+1]+=dp[i][j][k])%=MOD;
				}else if(i<n){
					(dp[i][j+1][k]+=dp[i][j][k])%=MOD;
				}
			}
		}
	}
	ll ans=0;
	for(int i=0; i<=n; i++){
		for(int j=0; i+j<=n; j++){
			for(int k=0; i+j+k<=n; k++){
				if(i+j+k==0) continue;
				if(ok1[n-i][j][k]) (ans+=dp[i][j][k])%=MOD;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main() {

	long n,x,y;
	vector<long> res(2002);
	long dist;

	cin >> n >> x >> y;

	for (long i = 1; i < n; i++) {
		for (long j = i + 1; j < n+1; j++) {
			if ((i <= x && j <= x) || (i>=y && j >=y)) {
				dist = j - i;
			}
			else if (i > x && i < y && j >= y) {
				dist = min(j - i, j - y + 1 + i - x);
			}
			else if (i <= x && j > x && j < y) {
				dist = min(j - i, x - i + 1 + y - j);
			}
			else if (i >= x && i <= y && j >= x && j <= y) {
				dist = min(j - i, i - x + 1 + y - j);
			}
			else if (i <= x && j >= y) {
				dist = x - i + 1 + j - y;
			}
			res[dist]++;
		}
	}

	for (long i = 1; i < n; i++) {
		cout << res[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# BIT使ってC問題ちゃんとやろうとしたけど1時間かけて無を生成したので諦める。ぷえwwwww
import time
starttime=time.time()
from random import randint
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split()))for _ in range(d)]
for i in range(d):s.append(s[i][:])
for i in range(d):s.append(s[i][:])
def xyz():
  start=randint(0,d-1)
  ans=[0]*d
  score=0
  for i in range(start,start+d,26):
    dd=set()
    uu=set()
    h=[]
    for j in range(i,min(i+26,start+d)):
      for k in range(26):
        h.append([s[j][k],j,k])
    h.sort(reverse=1)
    for t,j,k in h:
      if j in dd or k in uu:continue
      score+=t
      ans[j%d]=k
      dd.add(j)
      uu.add(k)
  return [score,ans]
score,ans=xyz()
while time.time()-starttime<1.9:
  ss,aa=xyz()
  if ss>score:
    score,ans=ss,aa
for i in ans:print(i+1)

Measured memory_bytes: 10172
#include <cstdio>
#include <cctype>
#include <utility>
#include <array>
#include <algorithm>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	const array<int, 6>
		S{60, 80, 100, 120, 140, 160},
		W{2, 5, 10, 15, 20, 25},
		F{600, 800, 1000, 1200, 1400, 1600};
	auto lb {[](auto &o, int n) {return lower_bound(begin(o), end(o), n);}};
	for (int n; (n = in());) {
		int f{};
		while (n--) {
			auto s{lb(S, in() + in() + in())}, w{lb(W, in())};
			if (s != end(S) && w != end(W))
				f += F[max(s - begin(S), w - begin(W))];
		}
		outl(f);
	}
}


Measured memory_bytes: 2456
#include <stdio.h>


int main(void){
  int N;
  double sum = 0;
  double x;
  char u[4];
  
  scanf("%d", &N);
  
  for(int cnt_n = 0; cnt_n < N; cnt_n++){
   scanf("%lf %s", &x, u);
    if(u[0] == 'J'){
      sum += x;
    }else if(u[0] == 'B'){
      sum += (x*380000);
    }
  }
  
  printf("%f\n", sum);
  
 return 0; 
}


Measured memory_bytes: 128
def examB():
    N = I(); K = I(); x = LI()
    ans = 0
    for i in range(N):
        ans += min(abs(0-x[i]),abs(K-x[i]))
    print(ans*2)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 38384
#include <iostream>
#include <math.h>
#include <cstdio>

using namespace std;

int main(){
	int n;
	int a[100];
	int count = 0;
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = 0; i < n; i++){
		if (i != 0 && a[i] == a[i - 1]){
			count++;
			if(i != n && a[i] == a[i + 1]){
				i++;
			}
		}
	}
	cout << count;
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    string S;
    cin >> S;
    ll i;
    for(i=0;i<S.size()-1;i++){
        if(S[i]==S[i+1]){
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let a = Array.init (3 * n) (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort compare a;

    let rec loop i acc =
        if i = n then acc else loop (i + 1) (acc + a.(n + i * 2))
    in
    loop 0 0 |> Printf.printf "%d\n"
)

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

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

  int x=0;
  
  for(int kei=1;x<n;kei++)
  {
      x = pow(k,kei);
    
      if(x>n){
         cout<<kei<<endl;
         break;
      }
      else if(x==n)
      {
          cout<<kei+1<<endl;
          break;
      }
  
  }
  
   return 0;
}


Measured memory_bytes: 512
#include "stdio.h"
#include "ctype.h"

int main(void)
{
 	int i;
 	char ch;
 	int num[26] = {0};

 	while(scanf("%c", &ch) != EOF)
 	{
 		if (islower(ch))
 		{
 			i = ch - 'a';
 			num[i]++;

 		}else if (isupper(ch))
 		{
 			i = ch - 'A';
 			num[i]++;
 		}

 	}

 	for(i = 0; i < 26; i++)
 	{
 		printf("%c : %d\n", 'a'+i, num[i]);
 	}

 	return 0;
 }

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s; cin >> s;
	int n = s.size();
	if (s[0] == s[s.size()-1]) --n;

	if (n & 1) printf("First\n"); else printf("Second\n");
}

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

int main() {
    string S;
    int count=0;
    cin >>S;
    for(int i=0; i<(S.size()/2);i++){
        if(S.at(i) != S.at(S.size()-1-i)){
            count++;
        }
    }
    cout <<count <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

bool prime(int p){
	int i;
	for(i=2;i<p;i++){
		if(p%i==0)break;
	}
	return i==p;
}

int main() {
	int n;
	while(cin>>n){
		int p=n-1;
		while(!prime(p))p--;
		cout<<p<<" ";
		p=n+1;
		while(!prime(p))p++;
		cout<<p<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
cnt = 0
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])

    return arr

arr = factorization(n)
cnt = 0
for i in arr:
    if i[0] == 1:
        continue
    hiku = 1
    while i[1] > 0:
        i[1] = i[1] - hiku
        if i[1] < 0:
            break
        hiku +=1
        cnt += 1

print(cnt)




Measured memory_bytes: 9492
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int n,l[111111];
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
	    cin>>l[i];
	    sum+=l[i];
	}
	sort(l,l+n);
	if(l[n-1]<sum-l[n-1])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include<string.h>
using namespace std;
#define Max 103
typedef struct stack
{
	int data[Max];
	int top;
}sd;              
int main()
{
	char a[1000000];
	sd list;
	list.top=0;
	int i=0,n,m=0;
	gets(a);
	n=strlen(a);
	for(i=0;i<n;i++)
	{
		if(a[i]=='C')
		{
			list.data[list.top]=1;
			list.top=1;
		}
		else if(list.top==1&&a[i]=='F')
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MOD 2019
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.
long int power(long int x, unsigned int y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2)%MOD; 
    else
        return ((x * power(x, y / 2)%MOD) * power(x, y / 2))%MOD; 
}
int main(){   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      string s;cin>>s;
      LI n=s.length(),i,prev=0,ans=0;
      std::map<int, int> m;
      rfo(i,n-1,-1){
        LI md=(s[i]-'0')*power(10,n-1-i)%MOD;
        prev+=md;prev%=MOD;
        if(prev==0) ans++;
        ans+=m[prev];
        m[prev]++;
      }
      cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3760
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop, heapify
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X,Y,A,B,C=MI()
    R=LI()
    G=LI()
    W=LI()
    R.sort(reverse=True)
    G.sort(reverse=True)
    W.sort(reverse=True)
    
    tmp = []
    tmp.extend(R[:X])
    tmp.extend(G[:Y])
    heapify(tmp)
    for w in W:
        if(tmp[0]<w):
            heappushpop(tmp, w)
    print(sum(tmp))    
if __name__ == '__main__':
    main()

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

using namespace std;

typedef pair<int, int> P;
const int INF = numeric_limits<int>::max() / 2;

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

    int h,w;cin>>h>>w;
    vector<string> v(h);
    int sx,sy,px,py;
    for(int i=0;i<h;i++){
        cin>>v[i];
        for(int j=0;j<w;j++){
            if(v[i][j]=='%'){
                sx=i;sy=j;
            }
            else if(v[i][j]=='@'){
                px=i;py=j;
            }
        }
    }
    vector<vector<int> > dis(300,vector<int>(300,INF));
    dis[sx][sy]=0;
    int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
    queue<P> q;
    q.push(P(sx,sy));
    while(!q.empty()){
        P p=q.front();q.pop();
        int x=p.first,y=p.second;
        for(int i=0;i<4;i++){
            int nx=x+dx[i],ny=y+dy[i];
            if(nx<0 || h<=nx || ny<0 || w<=ny) continue;
            if(v[nx][ny]=='#') continue;
            if(dis[nx][ny]!=INF) continue;
            dis[nx][ny]=dis[x][y]+1;
            q.push(P(nx,ny));
        }
    }
    int pdis=dis[px][py];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(v[i][j]!='$') continue;
            if(dis[i][j]<=pdis){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 2010, md = 1e9 + 7;
int n, k;
int dp[2 * MAXN][MAXN], fact[MAXN * MAXN], inv_fact[MAXN * MAXN];
int combination(int k, int n) {
    if (k > n)
        return 0;
    return (fact[n] * inv_fact[k] % md) * inv_fact[n - k] % md;
}  
int power(int n, int p) {
    int res = 1;
    for (;p; p >>= 1, n = n * n % md)
        if (p & 1)
            res = res * n % md;
    return res;
}
int32_t main () {
    fact[0] = 1;
    for (int i = 1; i < MAXN * MAXN; ++i)
        fact[i] = fact[i - 1] * i % md;
    inv_fact[MAXN * MAXN - 1] = power(fact[MAXN * MAXN - 1], md - 2);
    for (int i = MAXN * MAXN - 1; i; --i)
        inv_fact[i - 1] = inv_fact[i] * i % md;
    cin >> n >> k;
    if (k == 1)
        return cout << 1, 0;
    dp[0][0] = 1;
    for (int i = 0; i < 2 * n; ++i) {
        for (int j = 0; j <= min(n, i); ++j) {
            if (j < n) {
                dp[i + 1][j + 1] += dp[i][j];
                if (dp[i + 1][j + 1] >= md)
                    dp[i + 1][j + 1] %= md;
            }
            if (j) {
                dp[i + 1][j - 1] += dp[i][j] * combination(k - 2, n * k - k * (i - j) / 2 - j - 1) % md;
                if (dp[i + 1][j - 1] >= md)
                    dp[i + 1][j - 1] %= md;
            }
            // cout << i << ' ' << j << '\n';
        }
    }
    for (int i= 1; i <= n; ++i)
        dp[2 * n][0] = dp[2 * n][0] * i % md;
    cout << dp[2 * n][0];
    return 0;
}

Measured memory_bytes: 126336
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        t: chars,
    }
    let mut s = s;
    let mut t = t;
    s.sort();
    t.sort();
    t.reverse();
    println!("{}",
        if s < t {"Yes"} else {"No"}
    );
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define INT long long int
#define oo 987654321
using namespace std;
INT h, w, dp[110][110], dp2[110][110];
string a[110];
int main()
{
    ios::sync_with_stdio(false);
    cin>>h>>w;
    for(int i = 0 ; i < h ; i++ ) cin>>a[i];
    for(int i = 0 ; i < h ; i++ ) for(int j = 0 ; j < w ; j++ )
        if( a[i][j] == '#' ) dp[i][j]=1;
        else dp2[i][j] = 1;
    for(int i = 0 ; i < h ; i++ )
        for(int j = 0 ; j < w ; j++ )
            if( i == 0 and j == 0 ) continue;
            else if( i == 0 ) dp[i][j] = dp[i][j-1]+ dp[i][j]+((a[i][j-1]==a[i][j] and a[i][j]=='#')?-1:0);
            else if( j == 0 ) dp[i][j] = dp[i-1][j]+ dp[i][j]+((a[i-1][j]==a[i][j] and a[i][j]=='#')?-1:0);
            else dp[i][j] = min(dp[i-1][j]+((a[i-1][j]==a[i][j] and a[i][j]=='#')?-1:0),
                                dp[i][j-1]+((a[i][j-1]==a[i][j] and a[i][j]=='#')?-1:0)
                                )+ dp[i][j];
    cout<<dp[h-1][w-1];
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0),cin.tie(0);
#define endl '\n'
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ll long long
#define F first
#define S second
#define pb push_back
const int N = 1e6 + 5;
typedef pair<int,int>ii;
int main(){
  fast;
  int n,a,b;
  string s;
  while(cin >> n >> s){
    int ans = 1;
    for(int i=1;i<n;i++)
      if(s[i]!=s[i-1])ans++;
    cout << ans << endl;
  }

}

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

int main()
{
    int n, i, a, o = 0;
    cin >> n;
    for(i = 0; i < n; i++)
    {
        cin >> a;
        if(a&1)
            o++;
    }

    cout << (o%2 == 0? "YES" : "NO");
}


Measured memory_bytes: 3640
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
ct = Counter(A)

if len(ct) == 1 and ct.most_common(1)[0][0] == 0:
  print('Yes')
elif len(ct) == 2:
  mc = ct.most_common(3)
  m1 = mc[0]
  m2 = mc[1]
  if m2[0] == 0 and m1[1] == m2[1] * 2:
    print('Yes')
  else:
    print('No')
elif len(ct) == 3:
  mc = ct.most_common(3)
  m1 = mc[0]
  m2 = mc[1]
  m3 = mc[2]
  if m1[1] == m2[1] == m3[1] and m1[0] ^ m2[0] == m3[0]:
    print('Yes')
  else:
    print('No')
else:
  print('No')

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


string enc(string s,char c){
	string r;
	for(auto i : s ) if( c == i ) r += '1'; else r += '0';
	return r;
}
void solve(string s){
	for(int i = 0 ; i < 26 ; i++){
		string t = enc(s,i+'a');
		int left = 0;
		int one = 0, zero = 0;
		for(int j = 0 ; j < t.size() ; j++){
			if( t[j] == '0' ){
				zero++;
			}else{
				one++;
			}
			if( zero > one ){
				zero = 0;
				one = 0;
				left = j + 1;
			}
			
			if( one > zero and zero + one >= 2 ){
				cout << left+1 << " " << j+1 << endl;
				exit(0);
			}
		}
	}
	cout << -1 << " " << -1 << endl;
}
int main(){	
	string s;
	cin >> s;
	solve(s);
}


Measured memory_bytes: 736
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define MP make_pair
#define BSZ  __builtin_popcount
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

string s, tmp, ans;
vector<string> v;
int w;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s >> w;
	for (int i = 0; i < s.size(); i++) {
		tmp += s[i];
		if (tmp.size() == w) {
			v.push_back(tmp);
			tmp = "";
		}
	}
	if (tmp.size())
		v.push_back(tmp);
	for (string t : v)
		ans += t[0];
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[111],b[111],f[111][111][310];
int main()
{
	
	cin>>n>>m;
	for (int i=0;i<n;i++)
	 cin>>a[i]>>b[i];
	for (int i=0;i<n;i++)
	 for (int j=0;j<=i;j++)
	  for (int k=0;k<=3*j;k++)
	  {
	  	f[i+1][j][k]=max(f[i+1][j][k],f[i][j][k]);
	  	f[i+1][j+1][k+a[i]-a[0]]=max(f[i+1][j+1][k+a[i]-a[0]],f[i][j][k]+b[i]);
	  }
	int ans=0;
	for (int i=0;i<=n;i++)
	 for (int j=0;j<=3*i;j++)
	 {
	 	long long W=(long long)a[0]*i+j;
	 	if (W<=m) ans=max(ans,f[n][i][j]);
	 }
	cout<<ans;
	return 0;
}


Measured memory_bytes: 12800