akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define VFOR(x,begin,num) for(int x=(begin);x<((begin)+(num));x++)
#define INF__ ((long long)1 << 60)
int main(){
    int N, Q; string S;
    cin >> N >> S >> Q;
    S.insert(S.begin(),' ');
    set<int> CharPlace[26];
    VFOR(i,0,26){CharPlace[i].insert(-1); CharPlace[i].insert(98765432);}
    VFOR(i,1,N) CharPlace[(int)(S[i]-'a')].insert(i); 
    VFOR(i,0,Q){
        int q; cin >> q;
        if(q == 1){
            int a; string b,c="  ";
            cin >> a >> b;
            c[0] = S[a]; 
            S[a] = b[0];
            //{auto it = CharPlace[(int)(c[0]-'a')].begin();while(it != CharPlace[(int)(c[0]-'a')].end()  ) {cout<<*(it++) << " ";} cout << endl;}
            //{auto it = CharPlace[(int)(b[0]-'a')].begin();while(it != CharPlace[(int)(b[0]-'a')].end()  ) {cout<<*(it++) << " ";} cout << endl;}
            CharPlace[(int)(c[0]-'a')].erase(a);//{auto it = CharPlace[(int)(c[0]-'a')].begin();while(it != CharPlace[(int)(c[0]-'a')].end()  ) {cout<<*(it++) << " ";} cout << endl;}
            CharPlace[(int)(b[0]-'a')].insert(a);//{auto it = CharPlace[(int)(b[0]-'a')].begin();while(it != CharPlace[(int)(b[0]-'a')].end()  ) {cout<<*(it++) << " ";} cout << endl;}
        }
        else{
            int a, b,cnt=0;
            cin >> a >> b;
            VFOR(j,0,26){
                //if( lower_bound(CharPlace[j].begin(),CharPlace[j].end(),b) != lower_bound(CharPlace[j].begin(),CharPlace[j].end(),a-1)) cnt++;
                //if( distance(CharPlace[j].lower_bound(CharPlace[j].begin(),CharPlace[j].end(),b) , CharPlace[j].lower_bound(CharPlace[j].begin(),CharPlace[j].end(),a) ) ) cnt++;
                //{auto it = CharPlace[j].begin();while(it != CharPlace[j].end()  ) {cout<<*(it++) << " ";} cout << endl;}
                auto it = CharPlace[j].lower_bound(a);
                if(  *it <= b && it != CharPlace[j].end()) cnt++;
            }
            cout << cnt << endl;
        }
    }
}

Measured memory_bytes: 24196
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX =1e5+6;
const long long inf=1e18;
int main(){
	int n;
	cin>>n;
	double arr[n+1];
	double g=0;
	///long long l=1;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		
	}
	sort(arr, arr+n);
	double p=2;
	for(int i=n-1;i>=2;i--){
		g=g+(arr[i]/p);
		p=p*2;
	}
	g=g+(arr[0]/p)+(arr[1]/p);
//	cout<<l;
//	cout<<ans;
	cout<<setprecision(9)<<g;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,c=0;
    scanf("%lld",&n);
    long long int a[n+1],b[n+1];
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        b[i]=a[i];
    }
    sort(b,b+n);
    for(int i=0;i<n;i++)
    {
        if(b[i]!=a[i])
            c++;
    }
    if(c>2)
        printf("NO\n");
    else
        printf("YES\n");
}


Measured memory_bytes: 256
//エイシング2020_B
#include <stdio.h>
int main(){
	int n;
	int a[101];
	int cnt=0;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d ",&a[i]);
	}
	
	for(int i=0;i<n+1;i=i+2){
//テスト出力
//printf("i=%d [%d] \n",i,a[i]);
		if((a[i] % 2) != 0)	cnt = cnt +1;		
	}
	
	printf("%d",cnt);
	
	return 0;
}


Measured memory_bytes: 2148
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
e = 0
if c<d:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0 and s[b-2:d+1].count("...")>0:
    print("Yes")
  else:
    print("No")




Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
import copy

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, p: "List[int]"):
    p_sort = copy.deepcopy(p)
    p_sort.sort()

    n = 0
    for a,b in zip(p,p_sort):
        if a != b:
            n += 1

        if n > 2:
            print(NO)
            return

    print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3556
from typing import List


def answer(a: int, b: int, k: int) -> List[int]:
    a_k = set(range(a, min(a + k, b + 1)))
    k_b = set(range(max(b - k + 1, a + 1), b + 1))

    return sorted(a_k.union(k_b))


def main():
    a, b, k = map(int, input().split())
    for i in answer(a, b, k):
        print(i)


if __name__ == '__main__':
    main()


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

using namespace std;

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

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

int dp[101][10101];

int main() {
  int n, W;
  cin >> n >> W;
  int v[n], w[n];
  REP(i, n) cin >> v[i] >> w[i];
  REP(i, n) {
    for (int j = 0; j <= W; ++j) {
      if (j < w[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
      }
    }
  }
  cout << dp[n][W] << endl;
  return 0;
}


Measured memory_bytes: 7048
#include<stdio.h>

int a,b;
int c=0;
int d=0;
int t=0;
int main(void){
  scanf("%d%d",&a,&b);
  while(a!=0){
  	c=a%b;
	a=(a-c)/b;
	t++;
  }
  printf("%d",t);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define vec vector
#define mst(a,b) memset(a,b,sizeof(a))
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define all(v) v.begin(),v.end()
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res%mod)*(x%mod))%mod;
        }
        x=((x%mod)*(x%mod))%mod;
        y=y/2;
    }
    return res;
}
 
 struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(pair<uint64_t,uint64_t> x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};

void get_time(auto start,auto end){
    double time_taken =  
      chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
  
    time_taken *= 1e-9;
    cout<<"\n";
    cout<<"Time taken : "<<fixed<<time_taken<<setprecision(6);
}

  vec<ll>adj[100002];

  vec<vec<ll>>dp(100002,vec<ll>(2,1));

  void dfs(ll u,ll p){

    for(auto z:adj[u]){
      if(z!=p){
        dfs(z,u);
        ll x=(dp[z][0]+dp[z][1])%mod;
        dp[u][0]=(dp[u][0]*x)%mod;
        dp[u][1]=(dp[u][1]*dp[z][0])%mod;

      }
    }
  }

int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

  auto start = chrono::high_resolution_clock::now();

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

   ll n,x,y;

   cin>>n;

   for(int i=1;i<n;i++){
      cin>>x>>y;
      adj[x].pb(y);
      adj[y].pb(x);
   }
  
 
   dfs(1,0);

   cout<<(dp[1][0]+dp[1][1])%mod;

  



  auto end = chrono::high_resolution_clock::now();

 /* #ifndef ONLINE_JUDGE

   get_time(start,end); 

  #endif*/

    return 0;
 }

Measured memory_bytes: 21144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String s = br.readLine();
            StringBuffer strBuf = new StringBuffer();
            for (int i = 0; i < s.length(); i++) {
                char ch = s.charAt(i);
                if (ch == '1') {
                    strBuf.append("9");
                } else if (ch == '9') {
                    strBuf.append("1");
                } else {
                    strBuf.append(ch);
                }
            }
            System.out.println(strBuf.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


Measured memory_bytes: 23124
#include<iostream>
#include <iomanip>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  long double res = 0;
  int max = N;
  if (N > K-1) {
    res = (long double)(N-(K-1))/(long double)(N);
    max = K-1;
  }
  
  long double p = 1/2.;
  for (int i = max; i > 0; i--) {
    while (i/p < K) {
      p *= 1/2.;
    }
    res += p/N;
  }
 
  cout<<setprecision(12)<<res<<endl;
  
  return 0;
}


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

int main()
{
  int n, k;
  cin >> n >> k;
  int i = 1;
  while (1)
  {
    if (n < pow(k, i))
    {
      cout << i << endl;
      break;
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=1234567;
int a[MAXN],pr[MAXN],ne[MAXN],pos[MAXN];
int main() {
  int n;
  scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",a+i);
		pos[a[i]]=i;
    }
    for(int i=0;i<=n+1;i++)
	{
		pr[i]=i-1;
		ne[i]=i+1;
    }
    long long ans=0;
    for(int i=n;i>=1;i--)
	{
		int j=pos[i];
		ans+=i*1LL*(j-pr[j])*(ne[j]-j);
		pr[ne[j]]=pr[j];
		ne[pr[j]]=ne[j];
    }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
    long long int k, a, b;
    cin >> k >> a >> b;
    long long int max = 1;
    if (b - a > 2)
    {
        max = a;
        k -= a - 1;
        max += k / 2 * (b - a) + k % 2;
    }
    else
    {
        max += k;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	lint n, m, v, p;
	cin >> n >> m >> v >> p;

	vector<lint> a(n);
	for (lint i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	auto judge = [&](auto idx) {
		
        if(a[idx]+m<a[n-p]) return false;
        
		if (p + idx >= v) {
			return a[idx] + m >= a[n - p];
		}
		else {

			lint rem = v - (p + idx);
			lint sum = 0;
			lint A = a[idx] + m;

			for (lint i = idx + 1; i <= n - p; i++) {
				sum += A - a[i];
			}
			DMP(idx, sum, rem, m);
			return sum >= rem * m;

		}

	};

	auto binary_search = [&](auto f) {

		lint ng = -1LL;
		lint ok = n - p + 1;

		while (abs(ok - ng) > 1) {
			lint mid = (ok + ng) / 2;

			if (f(mid)) ok = mid;
			else ng = mid;
		}

		return ok;
	};

	lint ans = binary_search(judge);
	cout << n - ans << "\n";

	return 0;
}


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

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
int x,a,b;
  cin>>x>>a>>b;
  if(b-a>x)cout<<"dangerous"<<endl;
  else if(b-a<=0)cout<<"delicious"<<endl;
  else cout<<"safe"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        boolean[] isAc = new boolean[n];
        int[] waCounter = new int[n];
        for (int i = 0; i < m; i++) {
            int nOrder = sc.nextInt() - 1;
            String result = sc.next();
            if (!isAc[nOrder]){
                if (result.equals("AC")) isAc[nOrder]=true;
                else waCounter[nOrder]++;
            }
        }

        int ac = 0;
        int wa = 0;
        for (int i = 0; i < n; i++) {
            if (isAc[i]){
                ac++;
                wa+=waCounter[i];
            }
        }
        System.out.println(ac + " " + wa);
    }
}

Measured memory_bytes: 65136
import java.util.*;

class Main{
  public static int max2(int a,int b){
    return (a>b)?a:b;
  }
  
  public static int max3(int a,int b,int c){
    return (max2(a,b)<c)?c:max2(a,b);
  }
  
  public static int min2(int a,int b){
    return (a>b)?b:a;
  }
  
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int[] A=new int[N];
    int[] B=new int[N];
    int[] C=new int[N];
    int[][] Ans=new int[3][N];
    
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();
      B[i]=sc.nextInt();
      C[i]=sc.nextInt();
    }
    
    Ans[0][0]=A[0];
    Ans[1][0]=B[0];
    Ans[2][0]=C[0];
    
    for(int i=1;i<N;i++){
      Ans[0][i]=max2(Ans[1][i-1]+A[i],Ans[2][i-1]+A[i]);
      Ans[1][i]=max2(Ans[0][i-1]+B[i],Ans[2][i-1]+B[i]);
      Ans[2][i]=max2(Ans[0][i-1]+C[i],Ans[1][i-1]+C[i]);
    }
    
    System.out.print(max3(Ans[0][N-1],Ans[1][N-1],Ans[2][N-1]));
    
  }
}

Measured memory_bytes: 98480
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
	cin>>x;
	int ans=1;
	for (int j=2;j<=x;j++)
	{
		int ret =j;
		while (ret<=x)
		{
			ret*=j;
			if (ret<=x)
			{
				ans =max(ans,ret);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
ll MOD = 1e9+7;
const double PI=3.14159265358979323846;


int main() {
  ll n,m;
  cin >> n>> m;
  vector<ll> a(m);
  ll sum = 0;
  REP(i,m){
    cin >> a.at(i);
    sum += a.at(i);
  }
  if(sum>n){
    cout << -1 << endl;
  }else{
    cout << n-sum << endl;
  }
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    long long sum = 0;
    rep(i, N) {
        long long n;
        cin >> n;
        sum += n;
    }

    cout << sum - N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vi f(3);
    fore(day, 0, n) {
        vi c(3), g(3);
        fore(i, 0, 3) cin >> c[i];
        fore(i, 0, 3) fore(j, 0, 3) if (i != j) g[j] = max(g[j], f[i] + c[j]);
        f = g;
    }
    cout << max({f[0], f[1], f[2]});
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c; cin>>a>>b>>c;
    if(c>b) swap(b,c);
    if(a<b) swap(b,a);
     print(b*c/2);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,a,b;cin>>n>>a>>b;
	if ((b - a) % 2 == 0){
		cout << "Alice" << endl;
	}
	else{
		cout << "Borys" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/abc145/tasks/abc145_e
# E - All-you-can-eat
"""
DP1[i][j] =the maximum sum of deliciousness of dishes, which are chosen from 1st- to i-th dishes,
such that he can finish them in j minutes

still WA!!!

"""


def gcd(a, b):
    if a < b:
        return gcd(b, a)
    elif a % b:
        return gcd(b, a % b)
    else:
        return b


N = gi()
K = gi()
V = [0] * N

for i in range(N):
    V[i] = gi()


def c(l):
    free = K - len(l)
    s = 0
    for v in l:
        if v < 0 and free:
            free -= 1
        else:
            s += v
    return s


ans = -1e9
for i in range(-1, N):
    for j in range(i + 1, N + 1):
        sub = V[0:i + 1] + V[j:N]
        if len(sub) > K:
            continue
        sub.sort()
        ans = max(ans, c(sub))

print(ans)


Measured memory_bytes: 13120
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,j,k;
    char a[101],b[101],c[101];
    cin>>a>>b>>c;
    char n=a[0];
    i=1;j=0;k=0;
    while(true){
        if(n=='a'){
            if(i>=strlen(a)) break;
            n=a[i];
            i++;
        }
        else if(n=='b'){
            if(j>=strlen(b)) break;
            n=b[j];
            j++;
        }
        else if(n=='c'){
            if(k>=strlen(c)) break;
            n=c[k];
            k++;
        }
    }
    if(n=='a') cout<<'A'<<endl;
    else if(n=='b') cout<<'B'<<endl;
    else if(n=='c') cout<<'C'<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
W,H,N = map(int,raw_input().split())
arr = []
for i in xrange(N):
    arr.append(map(int,raw_input().split()))

minx=0
miny=0
maxx=W
maxy=H

for r in arr:
    (x,y,a) = r
    if a==1 and x > minx:
        minx = x
    elif a==2 and x < maxx:
        maxx = x
    elif a==3 and y > miny:
        miny = y
    elif a==4 and y < maxy:
        maxy = y
xx = maxx-minx
yy = maxy-miny

r = 0 if xx < 0 or yy < 0 else (xx * yy)
print(r)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
// #include <atcoder/all>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
// using namespace atcoder;
typedef long long ll;

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl;
#else
#define DEBUG(x)
#endif

#define ALL(obj) (obj).begin(), (obj).end()
#define BIT(n) (1LL << (n))

const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

vector<int> count(int n)
{
    vector<int> l(n + 1, 0);
    for (int i = 1; i < n + 1; i++)
    {
        for (int j = i; j < n + 1; j += i)
        {
            l[j]++;
        }
    }
    l.erase(l.begin());
    return l;
}

std::vector<int> sieve(int n)
{
    std::vector<int> res(n);
    std::iota(res.begin(), res.end(), 0);
    for (int i = 2; i * i < n; ++i)
    {
        if (res[i] < i)
            continue;
        for (int j = i * i; j < n; j += i)
            if (res[j] == j)
                res[j] = i;
    }
    return res;
}

std::map<int, int> factor(int n, const std::vector<int> &min_factor)
{
    // min_factor は sieve() で得られたものとする
    // std::vector<int> res;
    std::map<int, int> res;
    while (n > 1)
    {
        // res.push_back(min_factor[n]);
        res[n]++;
        n /= min_factor[n];
        // 割った後の値についても素因数を知っているので順次求まる
    }
    return res;
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    // write code below
    int n;
    cin >> n;
    auto l = count(n);
    int res = 0;
    for (int i = 0; i < n - 1; i++)
    {
        res += l[i];
    }
    cout << res << endl;

    // write code above
    return 0;
}


Measured memory_bytes: 7024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

		String a = scan.next();
		String b = scan.next();
		
		StringBuffer sb = new StringBuffer(b);
		String c = sb.reverse().toString();

		if(a.equals(c))
			System.out.println("YES");
		else
			System.out.println("NO");
		

	}
}


Measured memory_bytes: 23252
import java.util.*;
import java.io.*;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] str = br.readLine().split(" ");
        int tHP = Integer.parseInt(str[0]);
        int tATK = Integer.parseInt(str[1]);
        int aHP = Integer.parseInt(str[2]);
        int aATK = Integer.parseInt(str[3]);
        int count = 0;
        
        for(int i = 0; i < 200; i++){
            aHP -= tATK;
            count++;
            if(aHP <= 0){
                break;
            }
            tHP -= aATK;
            count++;
            if(tHP <= 0){
                break;
            }
        }
        
        out.println(count % 2 != 0 ? "Yes" : "No");
        out.close();
        
    }
}

Measured memory_bytes: 32836
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
using namespace std;
int main(){
    int n;
    int l[201]={};
    cin>>n;
    for(int i=0;i<2*n;i++){
        cin>>l[i];
    }
    int ans=0;
    sort(l,l+(2*n),std::greater<int>());
    for(int i = 0;i<2*n;i+=2){
        ans+=min(l[i],l[i+1]);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
while True:
  h,w = map(int, input().split())
  if h == 0 and w == 0:
    break
  for i in range(h):
    for k in range(w):
      if (i%2)==0:
        if (k%2)==0:
          print("#", end="")
        else:
          print(".", end="")
      else:
        if (k%2)==0:
          print(".", end="")
        else:
          print("#", end="")

    print()
  print() 


Measured memory_bytes: 7008
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max()

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n+1, 0); 
	for(int i=1; i<=n; i++) {
		cin >> h[i];
	}

	vector<int> opt(n+1, inf);
	opt[1] = 0;
	for(int i=2; i<=n; i++) {
		for(int j=1; j<min(i,k+1); j++) {
			opt[i] = min ( abs(h[i-j]-h[i]) + opt[i-j], opt[i]); 
		}
	}

	cout << opt[n] << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


signed main() {
	string s; int k; cin >> s >> k;
	if (k == 1) {
		int cnt = 1, memo = 0;
		rep(i, s.size() - 1) {
			if (s[i] == s[i + 1])cnt++;
			else {
				memo += cnt / 2; cnt = 1;
			}
		}
		memo += cnt / 2;
		cout << memo << endl; return 0;
	}
	rep(i, s.size() - 1) {
		if (s[i] != s[i + 1])goto ok;
	}
	cout << s.size() * k / 2 << endl;
	return 0;
ok:;
	string t = s + s;
	int l = s.size(), r = -1;
	int aida = 0;
	if (s.back() == s[0]) {
		for (int i = s.size() - 1; i >= 0; i--) {
			if (s[i] == s.back())l = i;
			else break;
		}
		rep(i, s.size()) {
			if (s[i] == s[0])r = i;
			else break;
		}
		aida = s.size() - l;
		aida += r + 1;
		aida /= 2;
	}
	int cnt = 1, memo3 = 0;
	for (int i = r + 1; i < l; i++) {
		if (s[i] == s[i + 1])cnt++;
		else {
			memo3 += cnt / 2; cnt = 1;
		}
	}
	cnt = 1;
	int memo = 0, memo2 = 0;
	rep(i, l) {
		if (s[i] == s[i + 1])cnt++;
		else {
			memo += cnt / 2; cnt = 1;
		}
	}
	memo += cnt / 2;
	cnt = 1;
	for (int i = r + 1; i < s.size(); i++) {
		if (s[i] == s[i + 1])cnt++;
		else {
			memo2 += cnt / 2; cnt = 1;
		}
	}
	memo2 += cnt / 2;
	cout << memo + memo2 + memo3 * max(0ll, k - 2) + aida * (k - 1) << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DDigitSumReplace {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int M;
        cin >> M;
        vector<int> d(M), c(M);

        int sum = 0;
        int keta = 0;
        REP(i, M) {
            cin >> d[i] >> c[i];
            sum += d[i] * c[i];
            keta += c[i];
        }

        int res = (sum - 1) / 9 + keta - 1;
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DDigitSumReplace solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int p=1;
  for(int i=0;i<n;i++){
    if(a.at(i)==p){
      p++;
    }
  }
  if(p==1){
    cout<<-1<<endl;
  }
  else{
    cout<<n-p+1<<endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    
    ll N;
    cin >> N;
    cout << 1000-(N-1)%1000-1 << endl;
    
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int A[200100];
int B[200100];
int main(){
    int N;
    cin >> N;
    REP(i,N){
        int a;
        cin >> a;
        A[i+1] = a;
    }

    int M = 0;
    for(ll i = N; i >= 1; i--){
        int m = 2;
        int tmp = 0;
        while(i*m <= N){
            tmp += B[i*m];
            m++;
        }
        tmp += A[i];
        B[i] = tmp % 2;

        if(B[i] == 1) M++;
    }

    cout << M << endl;
    REP(i,N){
        if(B[i+1])
            cout << i+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 2432
a=input()
ans="Yes"
if "W"in a and"E"not in a:
  ans="No"
elif "E"in a and"W"not in a:
  ans="No"
elif "N"in a and"S"not in a:
  ans="No"
elif "S"in a and"N"not in a:
  ans="No"
print(ans)

Measured memory_bytes: 2940
/* 
	Author: ankrypt
*/

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

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

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 100005
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
string S = "";

int main() {
	scanf("%lld", &N);
	if(N == 0) {
		printf("0\n");
		quit;
	}
	ll val = 1;
	while(N) {
		if(N % (2 * abs(val))) {
			S += '1';
			N -= val;
		}
		else {
			S += '0';
		}
		val *= -2; 
	}
	reverse(all(S));
	cout << S;
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int a,b,r,tmp;

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

  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }

  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  printf("%d\n",b);

  return 0;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int X, N; cin >> X >> N;
	bool flag[105] = {};
	vint P(N); cin >> P;
	for (auto &p : P) {
		flag[p] = true;
	}

	int minv = INF, minval = -1;
	for (int i = 0; i < 105; i++) {
		if (!flag[i]) {
			if (chmin(minv, abs(X-i))) {
				minval = i;
			}
		}
	}
	cout << minval << endl;
}

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
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; }

//modでの累乗(繰り返し二乗法)
ll modpow(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}

//modでの割り算
ll modinv(ll x, ll m) { return modpow(x, m - 2, m); }

//modでの安全な引き算
ll modsub(ll x, ll y, ll m){ return(x + m - y) % m; }

//乗算により二項係数を求める
ll binom(ll n, ll k, ll m)
{
    ll den = 1, num = 1;
    for (int i = 1; i <= k; ++i){
        den *= i;
        num *= (n + 1 - i);
        den %= m;
        num %= m;
    }
    return num * modinv(den,m);
}

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

    string S;
    cin >> S;
    ll N = len(S);

    vec coef;

    ll now = 1;
    ll sum = 0;
    rrep(i, N){
        if(S[i] == '?') coef.pb(now);
        else sum += (S[i] - '0') * now % 13;
        now *= 10;
        now %= 13;
    }

    ll K = (5 + 13 - sum % 13) % 13;
    N = len(coef);

    vec2 f(N + 1, vec(13, 0));
    f[0][0] = 1;

    rep(i, N) rep(j, 13) rep(k, 10) f[i + 1][(j + k * coef[i]) % 13] += f[i][j], f[i+1][j] %= MOD;

    print(f[N][K] % MOD);

    return 0;
}

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

using namespace std;

int main()
{
    int a,b,c,d,area_1,area_2;
    cin>>a>>b>>c>>d;
     area_1=a*b;
     area_2=c*d;

     if(area_1>=area_2)
      {
          cout<<area_1<<"\n";
      }
     else {
        cout<<area_2<<"\n";
     }

    return 0;
}


Measured memory_bytes: 256
from collections import Counter


def solve():
    n = int(input())
    s = input()
    cnt = Counter(s)
    ans = cnt['R'] * cnt['G'] * cnt['B']
    for i in range(n):
        for j in range(i + 1, n):
            k = j + j - i
            if k < n:
                if s[i] == s[j] or s[i] == s[k] or s[j] == s[k]:
                    continue
                ans -= 1
    return ans


print(solve())


Measured memory_bytes: 9400
#include<cstdio>
#include<cctype>
const int mod = 1e9 + 7;

template<class I>
inline I max(I a, I b) {return a > b ? a : b;}

template<class I>
inline I min(I a, I b) {return a < b ? a : b;}

template<class I>
inline void read(I & x) {
	x = 0;
	char c = ' ';
	int w = 1;
	while (!isdigit(c) && c != '-') c = getchar();
	if (c == '-') c = getchar(), w = -1;
	while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
	x *= w;
}

int n;
long long f[1000010][5];
/*
0 都没出现
1 0出现
2 1出现
3 都出现
*/

inline long long ksm(long long x, long long k, long long mod) {
	long long res = 1;
	while (k) {
		if (k & 1)
			res = res * x % mod;
		x = x * x % mod,
		k >>= 1;
	}
	return res;
}

int main(void) {
	read(n);
	f[0][0] = 1;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < 4; ++j)
			f[i + 1][j] += f[i][j] * 8,
			f[i + 1][j] %= mod,
			f[i + 1][j | 1] += f[i][j],
			f[i + 1][j | 1] %= mod,
			f[i + 1][j | 2] += f[i][j],
			f[i + 1][j | 2] %= mod;
	printf("%lld\n", f[n][3]);
	return 0;
}
/*

3
10^(n-1) *

*/

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

int main(){
	int n;
	cin>>n;
	for(int x=0;x<n;x++){
		string sa,sb;
		cin>>sa>>sb;
		
		int num[4]={};
		char k[4]={'m','c','x','i'};
		
		for(int i=0;i<sa.size();i++){
			if(sa[i]>='0'&&sa[i]<='9'){
				if(sa[i+1]=='m')num[0]+=sa[i]-'0';
				else if(sa[i+1]=='c')num[1]+=sa[i]-'0';
				else if(sa[i+1]=='x')num[2]+=sa[i]-'0';
				else if(sa[i+1]=='i')num[3]+=sa[i]-'0';
				i++;
				}
				
			else{
				if(sa[i]=='m')num[0]++;
				else if(sa[i]=='c')num[1]++;
				else if(sa[i]=='x')num[2]++;
				else if(sa[i]=='i')num[3]++;
				}	
			}
			
			for(int i=0;i<sb.size();i++){
			if(sb[i]>='0'&&sb[i]<='9'){
				if(sb[i+1]=='m')num[0]+=sb[i]-'0';
				else if(sb[i+1]=='c')num[1]+=sb[i]-'0';
				else if(sb[i+1]=='x')num[2]+=sb[i]-'0';
				else if(sb[i+1]=='i')num[3]+=sb[i]-'0';
				i++;
				}
				
			else{
				if(sb[i]=='m')num[0]++;
				else if(sb[i]=='c')num[1]++;
				else if(sb[i]=='x')num[2]++;
				else if(sb[i]=='i')num[3]++;
				}	
			}
			
			if(num[3]>=10){
				num[3]-=10;
				num[2]+=1;
				}
			if(num[2]>=10){
				num[2]-=10;
				num[1]++;
				}	
			if(num[1]>=10){
				num[1]-=10;
				num[0]++;
				}	
				
				for(int i=0;i<4;i++){
					if(num[i]==1)cout<<k[i];
					else if(num[i]!=0)cout<<num[i]<<k[i];
					}
					cout<<endl;
		}
		return 0;
	}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  vector <int> a;
  int n;
  cin >> n;
  REP(i,n){
    int b;
    cin >> b;
    a.pb(b);
  }
  sort(a.begin(),a.end(),greater<int>());
  int A = 0,B = 0;
  REP(i,a.size()){
    if(i%2 == 0)
      A += a[i];
    else
      B += a[i];
  }
  cout << A-B << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
struct segtree{
private:
  vector<ll> node,lazy;
  ll siz;
public:
  segtree(int n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2,0);
    lazy.resize(siz*2,0);
  }
  void eval(ll pos){
    node[pos]+=lazy[pos];
    node[pos]%=mod;
    if(pos<siz-1) {
      lazy[pos*2+1]+=(lazy[pos]*(ll)(1e9+8)/2)%mod;
      lazy[pos*2+2]+=(lazy[pos]*(ll)(1e9+8)/2)%mod;
      lazy[pos*2+1]%=mod;
      lazy[pos*2+2]%=mod;
    }
    lazy[pos]=0;
  }
  void add_q(ll a,ll b,ll x,ll l,ll r,ll pos){
    eval(pos);
    if(b<=l||r<=a) return;
    if(a<=l&&r<=b){
      lazy[pos]+=(x*(r-l));
      lazy[pos]%=mod;
      eval(pos);
      return;
    }
    ll mid=(l+r)/2;
    add_q(a,b,x,l,mid,pos*2+1);
    add_q(a,b,x,mid,r,pos*2+2);
    node[pos]=(node[pos*2+1]+node[pos*2+2])%mod;
  }
  ll sum_q(ll a,ll b,ll l,ll r,ll pos){
    if(b<=l||r<=a) return 0;
    eval(pos);
    if(a<=l&&r<=b){
      return node[pos]%mod;
    }
    ll mid=(l+r)/2;
    return (sum_q(a,b,l,mid,pos*2+1)+sum_q(a,b,mid,r,pos*2+2))%mod;
  }
  void add(ll a,ll b,ll x){
    add_q(a,b,x,0,siz,0);
  }
  ll sum(ll a,ll b){
    return sum_q(a,b,0,siz,0);
  }
};
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  if(a<b) swap(a,b);
  vector<ll> vec;
  vec.push_back(-(((ll)1e18)));
  for(int i=1;i<=n;i++){
    ll num;
    cin>>num;
    vec.push_back(num);
  }
  vec.push_back(((ll)1e18)*2);
  vector<ll> lb(n+5),rb(n+5);
  for(int i=1;i<=n;i++){
    lb[i]=lower_bound(vec.begin(),vec.end(),vec[i]+a)-vec.begin();
  }
  ll las=n+1;
  for(int i=n;i>0;i--){
    rb[i]=las;
    if(vec[i+1]-vec[i]<b) las=i+1;
  }

  segtree dp0(n+5),dp1(n+5);
  dp0.add(1,las+1,1);
  for(ll i=1;i<=n;i++){
    ll plus=dp1.sum(i,i+1);
    if(vec[i+1]-vec[i-1]>=b) plus+=dp0.sum(i,i+1);
    plus%=mod;
    if(vec[i+1]-vec[i]>=a) dp1.add(i+1,i+2,plus);
    ll L=max(i+2,lb[i]),R=rb[i];
    if(L>R) continue;
    dp0.add(L,R+1,plus);
  }
  cout<<(dp0.sum(n+1,n+2)+dp1.sum(n+1,n+2))%mod<<endl;
}


Measured memory_bytes: 10996
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <set>
#include "time.h"
#include "math.h"

using namespace std;

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

  int n, q;
  string s;
  vector< set<int> > sets(26);

  cin >> n >> s >> q;

  for (int i = 0; i < n; i ++) {
    sets[s[i] - 'a'].insert(i);
  }

  for (int i = 0; i < q; i ++) {
    int mode;
    cin >> mode;
    if (mode == 1) {
      int i;
      char c;
      cin >> i >> c;
      i -= 1;
      sets[s[i] - 'a'].erase(i);
      s[i] = c;
      sets[c - 'a'].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      l -= 1; r -= 1;
      int count = 0;
      for (int j = 0; j < 26; j ++) {
        auto it = sets[j].lower_bound(l);
        if (it != sets[j].end() && *it <= r) {
          count += 1;
        }
      }
      cout << count << endl;
    }
  }
}

Measured memory_bytes: 27160
#include <cstdio>
#include <algorithm>
#define N 200010
using namespace std;

int cnt[N];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		cnt[a]++;
		cnt[b]++;
	}
	for (int i = 1; i <= n; ++i) {
		if (cnt[i] & 1) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static final double MAX_HEIGHT = 300.0;
	static final double[] heightTable = { 165.0, 170.0,
			175.0, 180.0, 185.0, MAX_HEIGHT };

	public static void main(String[] args) throws IOException{
		int[] studentHeightTable = createTable();
		for(int i = 0; i < studentHeightTable.length; i++){
			System.out.print((i + 1) + ":");
			for(int n = 0; n < studentHeightTable[i]; n++){
				System.out.print("*");
			}
			System.out.println();
		}
	}

	public static int[] createTable() throws IOException {
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));
		int numStudent = Integer.parseInt(br.readLine());
		int[] studentHeightTable = new int[heightTable.length];
		for (int i = 0; i < numStudent; i++) {
			double height = Double.parseDouble(br.readLine());
			for (int heightClass = 0; heightClass < heightTable.length; heightClass++) {
				if(height < heightTable[heightClass]){
					studentHeightTable[heightClass]++;
					break;
				}
			}
		}
		return studentHeightTable;
	}
}

Measured memory_bytes: 16916
#include <stdio.h>
#include <string.h>

int main(){
    int A,B;
    int i,j,k,cnt=0;
    char str1[6],str2[6];

    scanf("%d %d",&A,&B);

    for(i=A;i<=B;i++){
        snprintf(str1,6,"%d",i);
        j=0;
        while(str1[j]!='\0'){
            j++;
        }
        for(k=0;k<j;k++){
            str2[k] = str1[j-k-1];
        }
        str2[k] = '\0';
        if(strcmp(str1,str2)==0){
            cnt++;
        }
    }
    printf("%d",cnt);
    return 0;
}

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

int main(void){
    string str;
    int sum;
    sum = 0;

    cin >> str;
    
    for (int i = 0; i < str.length(); i++){
        sum += str[i] - '0';
    }
    
    if ((sum %  9) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3716