akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
int main(void){
    int N, i, j, minj;
    int count = 0, swap;
    
    scanf("%d", &N);
    
    int A[N];
    for(i = 0; i < N; i ++) scanf("%d", &A[i]);
    
    for(i = 0; i < N; i ++) {
        minj = i;
        for(j = i; j < N; j ++) {
            if(A[j] < A[minj]) {
                minj = j;
            }
        }
        swap = A[i];
        A[i] = A[minj];
        A[minj] = swap;
        if (minj != i) count ++;
    }
    
    for(i = 0; i < N-1; i ++) printf("%d ", A[i]);
    printf("%d\n", A[N-1]);
    printf("%d\n", count);
    
    return 0;
}

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

using namespace std;

int main() {
    set<char>s;
    for (int i = 0; i < 3; i++) {
        char d;
        cin >> d;
        s.insert(d);
    }
    if(s.size() >= 2) {
        cout << "Yes"<<endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N,K;
	cin>>N>>K;
	int all[N]={0};
	for(int i=0;i<K;i++)
	{
		int d;
		cin>>d;
		for(int j=0;j<d;j++)
		{
			//vector<int> temp;
			int t;
			cin>>t;
			all[t-1]++;
		}
	}
	int count=0;
	for(int i=0;i<N;i++)
	{
		if(all[i]==0)
		{
			count++;
		}
	}
	cout<<count;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll H, n;
    cin >> H >> n;

    vl a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    
    vvl dp(n+1, vl(H+1, INF));  //  dp[i][j] : i番目までの魔法でモンスターの体力がjのとき、モンスターの体力を0以下にするのに消耗する魔力の合計の最小値
    dp[0][0] = 0;
    rep(i, n) {
        exrep(j, 0, H) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(H, j + a[i])], dp[i+1][j] + b[i]);
        }
    }

    out(dp[n][H]);
    re0;
}

Measured memory_bytes: 81664
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s; cin >> s;
  
  int startofA = -1;
  int lastofZ = 0;
  
  rep(i, s.length()) {
    if ( startofA == -1 && s[i] == 'A' ) {
      startofA = i;
    }
    
    if ( s[i] == 'Z' ) {
      lastofZ = i;
    }
  }
  
  int res = lastofZ - (startofA - 1);
  
  if(res>0) {
    cout << res;
  } else {
    cout << 0;
  }
}

Measured memory_bytes: 720
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Consecutive Integers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  printf("%d\n", n - k + 1);
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

        List<Integer> nums = new ArrayList<>();
        nums.add(1);

        for (int i = 6; i <= 100000; i *= 6) {
            nums.add(i);
        }

        for (int i = 9; i <= 100000; i *= 9) {
            nums.add(i);
        }
        
        int[] steps = new int[100001];
        Arrays.fill(steps, Integer.MAX_VALUE);
        steps[0] = 0;
        for (int i = 0; i < steps.length - 1; i++) {
            for (int num : nums) {
                if (i + num <= 100000) {
                    steps[i + num] = Math.min(steps[i] + 1, steps[i + num]);
                }
            }
        }

        System.out.println(steps[n]);
    }
}

Measured memory_bytes: 40700
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long ll;

int K, A, B;

int main()
{
    optimiza_io
    cin >> K >> A >> B;
    cout << ( ( ( B / K ) - ( ( A - 1 ) / K ) ) ? "OK\n" : "NG\n" );
        
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <complex>
#include <algorithm>
#include <sstream>
#include <cstring>

using namespace std;

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

typedef vector<int> vi;
double const eps=1e-8;
double const inf=1e100;
double dp[12][1<<12];
int w;
int r[12];
int n;

double hamilton(int v, int S){
    double& res=dp[v][S];
    if(res!=0) return res;
    if(S==(1<<n)-1){
        res=r[v];
    }else{
        res=inf;
        rep(i,n){
            if(S>>i&1) continue;
            double dy=abs(r[v]-r[i]);
            double a=r[v]+r[i];
            double dx=sqrt(a*a-dy*dy);
            res = min(res, dx + hamilton(i,S|(1<<i)));
        }
    }
    return res;
}

bool solve(){
    memset(dp,0,sizeof(dp));
    random_shuffle(r,r+n);
    rep(i,n){
        if(r[i]+hamilton(i,1<<i) <= w+eps) return true;
    }
    return false;
}

int main(){
    string s;
    while(getline(cin,s)){
        stringstream ss(s);
        ss>>w;
        int t;
        n=0;
        while(ss>>t) r[n++]=t;
        static const char ans[2][3]={"OK","NA"};
        cout << ans[1-solve()] << endl;
    }
}

Measured memory_bytes: 1608
S = input()
k1 = ''
k2 = ''
for i in range(0,(len(S) - 1) // 2):
  k1 += S[i]
for j in range(((len(S) + 3) // 2) - 1, len(S)):
  k2 += S[j]
if k1 == k1[::-1] and k2 == k2[::-1] and 3 <= len(S) <= 99 and len(S) % 2 == 1 and S == S[::-1]:
  print('Yes')
else:
  print('No')
#print(k2)

Measured memory_bytes: 3064
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    H, W = map(int, readline().split())
    top_end = '#' * (W+2)
    print(top_end)
    for _ in range(H):
        a = '#' + input() + '#'
        print(a)
    print(top_end)




if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    ll N,K; cin>>N>>K;
	ll num = N / K;
	cout << min(abs(N - num * K), abs(N - (num+1) * K)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}


int main(){
    int h,w,d;
    cin >> h >> w >> d;
    vector<vector<int>> a(h,vector<int>(w));
    map<int,pair<int,int>> m;
    REP(i,h){
        REP(j,w){
            cin >> a[i][j];
            m[a[i][j]]=make_pair(i,j);
        }
    }
    map<int,int> ans;
    for(int i=1;i<=d;i++){
        int j=i;
        ans[j]=0;
        while(j+d<=h*w){
            ans[j + d] = ans[j] + abs(m[j + d].first - m[j].first)+abs(m[j + d].second - m[j].second);
            j+=d;
        }   
    }
    int q;cin >> q;
    REP(i,q){
        int l,r;
        cin >> l >> r;
        cout << ans[r]-ans[l] << endl;
    }
}

Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
int main(){
    char c[100000];
    scanf("%s",c);
    int n=strlen(c);
    int cnt0=0,cnt1=0;
    for(int i=0;i<n;i++){
        if(c[i]=='0')cnt0++;
        else cnt1++;
    }
    printf("%d\n",min(cnt0,cnt1)*2);
}

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

int main(){
    int n,w;
    std::cin>>n>>w;
    std::vector<std::vector<long long>> dp(n,std::vector<long long>(w+1,0));
    int a,b;
    for (int i = 0; i < n; ++i) {
        std::cin>>a>>b;
        if(i==0){
            for (int j = 0; j <= w; ++j) {
                if(j<a)continue;
                else dp[i][j]=b;
            }
        }
        else{
            for (int j = 0; j <= w; ++j) {
                if(j<a)dp[i][j]=dp[i-1][j];
                else{
                    dp[i][j]=std::max(dp[i-1][j],dp[i-1][j-a]+b);
                }
            }
        }
    }
    std::cout<<dp[n-1][w]<<std::endl;
    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,X,Y;
  cin >> N >> X >> Y;
  vector<vector<int>> dis(N,vector<int>(N));
  vector<int> num(N,0);
  
    for(int i=0 ; i<N ; i++){
      for(int j=i+1 ; j<N ; j++){
        if((i+1)<=X&&(j+1)>=Y){
          dis.at(i).at(j)=j-i-(Y-X-1);
        }else if(X<(i+1)&&Y>(j+1)){
          dis.at(i).at(j)=min(j-i,(i+1)-X+Y-(j+1)+1);
        }else{
          if(X<(i+1)){
            dis.at(i).at(j)=min((i+1)-X+1,Y-(i+1))+(j+1)-Y;
          }else{
            dis.at(i).at(j)=X-(i+1)+min((j+1)-X,Y-(j+1)+1);
          }
      }
    }
    }
  
  	for(int i=0 ; i<N ; i++){
   		for(int j=i+1 ; j<N ; j++){
      		num.at(dis.at(i).at(j)-1)++;
        }
    }
  
    for(int i=0; i<N-1; i++){
      cout << num.at(i) << endl;
  }
}

Measured memory_bytes: 16000
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, S: str, T: str):
    ans = []
    for i in range(N):
        ans.append(S[i])
        ans.append(T[i])

    print(''.join(ans))
    return



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
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(N, S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N = int(input())
S = list(map(str, input()))

# 相手がいない()をカウントすればいい
left_stock = 0
left_short = 0

for s in S:
	if s == "(":
		left_stock += 1
	else:
		if left_stock > 0:
			left_stock -= 1
		else:
			left_short += 1
			
for _ in range(left_short):
	print("(", end = "")
for s in S:
	print(s, end = "")
for _ in range(left_stock):
	print(")", end = "")

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll a, b, x, y;
	cin >> a >> b >> x >> y;

	cout << (double)(a * b) / 2.0 << " "
		<< ((x * 2 == a) && (y * 2 == b)) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
int main()
{
    ll h, w, n;
    cin >> h >> w >> n;
    ll ww = max(h, w);
    ll ans = (ww + n - 1) / ww;
    cout << ans << endl;
}

Measured memory_bytes: 256
encode={' ': '11010', "'": '11110', '-': '11101', ',': '11100', '.': '11011', '\
?': '11111', 'A': '00000', 'C': '00010', 'B': '00001', 'E': '00100', 'D': '0001\
1', 'G': '00110', 'F': '00101', 'I': '01000', 'H': '00111', 'K': '01010', 'J': \
'01001', 'M': '01100', 'L': '01011', 'O': '01110', 'N': '01101', 'Q': '10000', \
'P': '01111', 'S': '10010', 'R': '10001', 'U': '10100', 'T': '10011', 'W': '101\
10', 'V': '10101', 'Y': '11000', 'X': '10111', 'Z': '11001'}

decode={"101":" ","000000":"'","000011":",","10010001":"-","010001":".","000001\
":"?","100101":"A","10011010":"B","0101":"C","0001":"D","110":"E","01001":"F","\
10011011":"G","010000":"H","0111":"I","10011000":"J","0110":"K","00100":"L","10\
011001":"M","10011110":"N","00101":"O","111":"P","10011111":"Q","1000":"R","001\
10":"S","00111":"T","10011100":"U","10011101":"V","000010":"W","10010010":"X","\
10010011":"Y","10010000":"Z"}

while True:
    try:
        s=raw_input()
    except EOFError:
        break
    L=[encode[c] for c in s]
    s="".join(L)
    i=0
    S=[]
    while i<len(s):
        for c in decode:
            if s[i:].startswith(c):
                S.append(decode[c])
                i+=len(c)
                break
        else:
            break
    print "".join(S)

Measured memory_bytes: 4316
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,s=0;
  cin>>n;
  int a[n],x[n+1]={};
  r(i,n)cin>>a[i];
  r(i,n){
    x[a[i]]=x[a[i]-1]+1;
    s=max(s,x[a[i]]);
  }
  cout<<n-s<<endl;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    Entry[] entryArray = new Entry[N];
    for (int i = 0; i < N; i++) {
      String city = sc.next();
      int point = sc.nextInt();
      entryArray[i] = new Entry(city, point, i+1);
    }
    Arrays.sort(entryArray, new Comparator<Entry>() {
      public int compare(Entry entry1, Entry entry2) {
        int comp = entry1.city.compareTo(entry2.city);
        return comp != 0 ? comp : entry2.point - entry1.point;
      }}); 
    
    for (int i = 0; i < N; i++) {
      System.out.println(entryArray[i].index);
    }
  }
  
  static class Entry {
    private final String city;
    private final int point;
    private final int index;
    Entry(String city, int point, int index) {
      this.city = city;
      this.point = point;
      this.index = index;
    }
  }
}



Measured memory_bytes: 20948
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 




int32_t main()
{
	IOS
	int n;cin>>n;
	vector<float>p(n+1);
	for(int i=1;i<=n;i++)cin>>p[i];
	vector<vector<float>> dp(n+2,vector<float>(n+2));
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i][j]   +=dp[i-1][j]*(1-p[i]);
			dp[i][j+1] +=dp[i-1][j]*p[i];
		}
	}
	
	float ans=0;
	for(int i=0;i<=n;i++)
	{
		if( i > n-i )ans+=dp[n][i];
	}
			 cout << fixed << setprecision(9) << ans <<endl;

			
	
	
	
}
		


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

int main(){
  vector<int> vec(5);
  int k;
  
  for(int i=0;i<5;i++){
    cin >> vec.at(i);
  }
  cin >> k;
  
  for(int i=0;i<4;i++){
    for(int j=i+1;j<5;j++){
      if(vec.at(j) - vec.at(i) > k) {
        cout << ":(" << endl;
      	return 0;
      }
    }
  }
  cout << "Yay!" <<endl;
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
/*
ll t;
cin>>t;

while(t--)
{
*/

ll n,b;
cin>>n>>b;
ll i=0;
ll te=b;

while(1)
{
  if(b>n)
    break;
  b*=te;
i++;
}

cout<<i+1<<endl;

return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 998244353;

int main() {
	vi a(3);
	rep(i, 3) cin >> a[i];
	vsort(a);
	int cnt = 0;
	while (!(a[2] == a[1] && a[1] == a[0])) {
		while (a[2] > a[1]) {
			a[1]++;
			a[0]++;
			cnt++;
		}
		while (a[1] > a[0]) {
			a[0]+=2;
			cnt++;
		}
		vsort(a);
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String target = scanner.nextLine();
        boolean flag = false;
        for (int i = 0; i < target.length(); i++) {
            if (target.charAt(i) == '7') {
                flag = true;
                System.out.println("Yes");
                break;
            }
        }
        if (!flag) {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 27032
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            int C = sc.nextInt();
            System.out.println((
                    (A == 5 && B == 5 && C == 7) || (A == 5 && B == 7 && C == 5) || (A == 7 && B == 5 && C == 5)
            ) ? "YES" : "NO");
        }
    }
}


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

using namespace std;

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

    int N;
    cin >> N;
    vector<int> B(N - 1);
    for (int i = 0; i < N - 1; ++i) {
        cin >> B[i];
    }
    int mx_sum = 0;
    for (int i = 0; i < N; ++i) {
        int cur = 100'000;
        if (i < N - 1) {
            cur = min(cur, B[i]);
        }
        if (i - 1 >= 0) {
            cur = min(cur, B[i - 1]);
        }
        mx_sum += cur;
    }
    cout << mx_sum << "\n";

    return 0;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int cnt=0,maxcnt=0;
	cin>>a;
	for (int i=0;i<a.size();i++)
	{
		if (a[i]=='A'||a[i]=='C'||a[i]=='G'||a[i]=='T')
			cnt++;
		else
		{
			maxcnt=max(cnt,maxcnt);
			cnt=0;
		}
	}
	maxcnt=max(cnt,maxcnt);
	cout<<maxcnt;
	return 0;
}

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

#if DEBUG && !ONLINE_JUDGE
    #include "header.h"
#else
    #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
    return;
}
lli dp[405][405];
vector<lli> ar, pre;
lli solve(lli l, lli r) {
    if(l == r) {
        return dp[l][r] = 0;
    }
    if(l+1 == r) {
        return dp[l][r] = (ar[l] + ar[r]);
    }
    if(dp[l][r] != -1) return dp[l][r];
    lli ans = (lli)MOD*10000;
    rep(i,l,r) {
        ans = min(ans, solve(l,i) + solve(i+1,r) + pre[r] - pre[l-1]);
    }
    debug(l,r,ans);
    return dp[l][r] = ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preprocess();
    int n; cin>>n;
    ar.resize(n+1);
    pre.resize(n+1,0);
    memset(dp, -1, sizeof dp);
    rep(i,1,n+1) cin>>ar[i];
    rep(i,1,n+1) pre[i] = pre[i-1] + ar[i];
    cout<<solve(1,n)<<endl;
}



Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];
    for(int i=0; i<n; ++i)
        cin >> b[i];

    int aMaxIndex = find(a.begin(), a.end(), a.back()) - a.begin();
    int bMaxIndex = b.rend() - find(b.rbegin(), b.rend(), b.front()) - 1;
    if(a[aMaxIndex] != b[bMaxIndex] || aMaxIndex > bMaxIndex){
        cout << 0 << endl;
        return 0;
    }

    long long ans = 1;
    for(int i=1; i<bMaxIndex; ++i){
        if(a[i] == a[i-1]){
            ans *= a[i];
            ans %= MOD;
        }
    }
    for(int i=n-2; i>bMaxIndex; --i){
        if(b[i] == b[i+1]){
            ans *= b[i];
            ans %= MOD;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

K = int(input())
count = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      count+=gcd(a,b,c)
print(count)


Measured memory_bytes: 69996
#include <stdio.h>
#include <math.h>

int main(){
    int i,val,j=0,max,n,count=0;
    
    scanf("%d",&n);

    for(i=1;i<=n;i++){
        val=i*i;
        if(val>n){
            break;
        }
        else{
            max=val;
        }
    }
    
    printf("%d\n",max);
  
        
    return 0;
}

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

int main()
{
    int64_t n,a,b; cin >> n >> a >> b;

    int64_t l,ans=0;
    
    if(n%(a+b)>a) ans = n%(a+b)-a;

    l = n/(a+b);
    ans += l*b;


    cout << n-ans << endl; 
}

Measured memory_bytes: 256
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 998244353;

        public static void Main()
        {
            var a = Console.ReadLine();
            var b = Console.ReadLine();
            var ans = 0;

            for (int i = 0, l = a.Length; i < l; i++)
                if (a[i] != b[i]) ans++;

            Console.WriteLine(ans);


        }

    }

}

Measured memory_bytes: 27312
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n; cin >> n;

  vector<int> mi(n);
  vector<int> ma(n);

  rep(i, n) {
    int t; cin >> t;
    if (i==0 || t > ma.at(i-1)) {
      mi.at(i) = t;
    } else {
      mi.at(i) = 1;
    }
    ma.at(i) = t;
    //debug(i), debugln(ma.at(i));
  }

  vector<int> a(n);
  rep(i, n) {
    cin >> a.at(i);
  }

  if (a.at(0) != ma.at(n-1)) {
    cout << 0 << endl;
    return 0;
  }

  for(int i=n-1; i>=0; i--) {
    if (i==n-1 || a.at(i) > a.at(i+1)) {
      //debug(i); debug(a.at(i)); debugln(ma.at(i));
      if (ma.at(i) < a.at(i)) {
        cout << 0 << endl;
        return 0;
      }
      mi.at(i) = a.at(i);
    } else {
      mi.at(i) = max(mi.at(i), 1);
    }
    ma.at(i) = min(ma.at(i), a.at(i));
  }

  ll ans = 1;
  rep(i, n) {
    ans = ans * (ma.at(i) - mi.at(i) + 1) % mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
long long x=1e18;

long long findTrailingZeros(long long n)
{
    long long count = 0;
    for (long long i = 5; n / i >= 1; i *= 5)
        count += n / i;

    return count;
}

int main()
{
    long long n;
    cin>>n;
    if(n%2==1) cout<<0<<endl;
    else cout<<findTrailingZeros(n/2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

    int max_num = max({a, b, c});
    int min_num = min({a, b, c});

    p(max_num - min_num);
}


Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int main(){
	int N,M;
	int K;
	int n;
	int num;
	int incre = 1;
  	set<int> m;

  	cin >> N >> K;
  	while(K--){
        cin >> n;
  	    m.insert(n);
    }

  	num = N;
    M = N;

    if(N!= 0)
  	{
  	    while(num){
  	    n = num%10;
        while(m.find(n)!=m.end()){
            n++;
            n = n%10;
            N+=incre;
        }
        incre*=10;
        num = N/(incre);
        }

        num = N;
        incre/= 10;
        while(incre){
            int i;
            int temp = num/incre;
            for(i = 0; i < 10;i++){
                if(N-temp*incre+i*incre > M && m.find(i)== m.end()){
                    N = N-temp*incre+i*incre;
                    num = num-temp*incre+i*incre;
                    break;
                }
            }

            num = num%incre;
            //cout << num <<endl;
            incre = incre/10;
            //cout << incre <<endl;
        }
  	}
  	else
    {
        while(m.find(N)!=m.end())
            N++;
    }

    cout << N <<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#define ll long long int
using namespace std;

int main() {

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

	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n + 1, 0);
	vector<int> node(n + 1, 0);
	vector<int> cycle;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	cycle.push_back(1);
	node[1] = 1;
	int last = 1;
	while (1)
	{
		if (node[a[last]] > 0)
		{
			cycle.push_back(a[last]);
			last = a[last];
			break;
		}
		else
		{
			cycle.push_back(a[last]);
			last = a[last];
			node[last]++;
		}
	}
	int l = cycle.size();
	int start;
	for (int i = l - 2; i >= 0; i--)
	{
		if (cycle[i] == last)
		{
			start = i;
			break;
		}
	}
	int clen = l - start - 1;
	if (k < start)
	{
		cout << cycle[k];
	}
	else
	{
		k -= start;
		k %= clen;
		cout << cycle[start + k];
	}

	return 0;

}

Measured memory_bytes: 5828
def readinput():
    n,x,t=map(int,input().split())
    return n,x,t

def main(n,x,t):
    count=n//x
    if n%x!=0:
        count+=1
    return count*t

if __name__=='__main__':
    n,x,t=readinput()
    ans=main(n,x,t)
    print(ans)


Measured memory_bytes: 9172
nmxy = [int(i) for i in input().split()]
xx = [int(i) for i in input().split()]
yy = [int(i) for i in input().split()]

if(nmxy[2]>=nmxy[3]):
  print("War")
elif(max(xx)>=min(yy) or max(xx)>=nmxy[3] or nmxy[2]>=min(yy)):
  print("War")
else:
  print("No War")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long long
using namespace std;

signed main() {
 	int N,K;
 	cin >> N >> K;
 	vector<pair<int,int>> vec(N);
 	for(int i = 0;i < N;i++) {
 		int A,B;
 		cin >> A >> B;
 		vec.at(i) = make_pair(A,B);
 	}
 	sort(vec.begin(),vec.end());
 	int count = 0;
 	int answer = 0;
 	for(int i = 0;i < N;i++) {
 		if(K - count <= vec[i].second) {
 			answer = vec[i].first;
 			break;
 		}
 		count += vec[i].second;
 	}
 	cout << answer << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int MAX_hw=1000+10;
const ll mod=1e9+7;
int h,w;
ll dp[MAX_hw][MAX_hw];
int main()
{
    cin>>h>>w;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            char s;
            cin>>s;
            if(s=='#')   dp[i][j]=inf;
        }
    }
    dp[1][1]=1;
    if(dp[2][1]!=inf)	dp[2][1]=1;
    if(dp[1][2]!=inf)	dp[1][2]=1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(dp[i][j]!=0)   continue;
            if(dp[i-1][j]!=inf) dp[i][j]+=dp[i-1][j];
            if(dp[i][j-1]!=inf) dp[i][j]+=dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    cout<<dp[h][w]%mod;
    return 0;
}

Measured memory_bytes: 8192
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
C = [int(a) - 1 for a in input().split()]
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

def EulerTour(n, X, i0):
    f = lambda k: k * (k + 1) // 2
    USED = [0] * n
    ORG = [0] * n
    TMP = [0] * n
    P = [-1] * n
    ct = -1
    ET1 = [0] * n
    ET2 = [0] * n
    ANS = [f(n)] * n
    IND = [len(x) for x in X]
    i = i0
    while i >= 0:
        ind = IND[i]
        if not ind:
            ET2[i] = ct
            USED[C[i]] += 1 + TMP[i]
            if i:
                k = ET2[i] - ET1[i] + 1 - USED[C[P[i]]] + ORG[i]
                ANS[C[P[i]]] -= f(k)
                TMP[P[i]] += k
            i = P[i]
            continue
        
        j = X[i][ind - 1]
        if P[i] == j:
            IND[i] -= 1
            continue
        
        P[j] = i
        IND[i] -= 1
        i = j
        ORG[i] = USED[C[P[i]]]
        ct += 1
        ET1[i] = ct
    
    for i in range(n):
        ANS[i] -= f(n - USED[i])
    return ANS

print(*EulerTour(N, X, 0), sep = "\n")

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


long best_half(int* a, long* calculated, int jumps, int i, int n) {
    if (i >= n)
        return 0;
    else if (calculated[3 * i + jumps] != -1)
        return calculated[3 * i + jumps];
    else {
        long result = best_half(a, calculated, jumps, i + 2, n);
        if (jumps < 2)
            result = max(result, best_half(a, calculated, jumps + 1, i + 3, n));
        if (jumps == 0)
            result = max(result, best_half(a, calculated, jumps + 2, i + 4, n));
        calculated[3 * i + jumps] = a[i] + result;
        return calculated[3 * i + jumps];
    }
}

int main() {
    int n;
    cin >> n;
    int* a = (int*) malloc(sizeof(int) * n);
    long* calculated = (long*) malloc(sizeof(long) * 3 * n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < 3 * n; i++)
        calculated[i] = -1;
    if (n % 2 == 0)
        cout << max(best_half(a, calculated, 1, 0, n), best_half(a, calculated, 2, 1, n));
    else
        cout << max(max(best_half(a, calculated, 0, 0, n), best_half(a, calculated, 1, 1, n)), best_half(a, calculated, 2, 2, n));
    return 0;
}

Measured memory_bytes: 14880
#include<iostream>
#include<cstring>
using namespace std;
int x[13][13]; char a;
int main() {
	while (cin >> a) {
		memset(x, 0, sizeof(x));
		if (a == '0') { 
			x[1][1] = 0; 
		}
		if (a == '1') { 
			x[1][1] = 1; 
		}
		for (int i = 1; i <= 8; i++) {
			for (int j = 1; j <= 8; j++) {
				if (i + j > 2) {
					cin >> a; if (a == '0') { x[i][j] = 0; }
					else { x[i][j] = 1; }
				}
			}
		}
		for (int i = 1; i <= 8; i++) {
			for (int j = 1; j <= 8; j++) {
				if (x[i][j] == 1) {
					if (x[i + 1][j] == 1 && x[i][j + 1] == 1 && x[i + 1][j + 1] == 1) {
						cout << 'A' << endl; goto Exit;
					}
					if (x[i + 1][j] == 1 && x[i + 2][j] == 1 && x[i + 3][j] == 1) {
						cout << 'B' << endl; goto Exit;
					}
					if (x[i][j + 1] == 1 && x[i][j + 2] == 1 && x[i][j + 3] == 1) {
						cout << 'C' << endl; goto Exit;
					}
					if (x[i + 1][j - 1] == 1 && x[i + 1][j] == 1 && x[i + 2][j - 1] == 1) {
						cout << 'D' << endl; goto Exit;
					}
					if (x[i][j + 1] == 1 && x[i + 1][j + 1] == 1 && x[i + 1][j + 2] == 1) {
						cout << 'E' << endl; goto Exit;
					}
					if (x[i + 1][j] == 1 && x[i + 1][j + 1] == 1 && x[i + 2][j + 1] == 1) {
						cout << 'F' << endl; goto Exit;
					}
					if (x[i][j + 1] == 1 && x[i + 1][j - 1] == 1 && x[i + 1][j] == 1) {
						cout << 'G' << endl; goto Exit;
					}
				}
			}
		}
	Exit:;
	}
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
template<class T> void chmax(T &a, const T &b){if(a<b) a=b;}
template<class T> void chmin(T &a, const T &b){if(b<a) a=b;}
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int n; cin >> n;
    vi dp(n + 1, INT_MAX);
    int a;
    rep(i, 0, n) {
        cin >> a;
        *lower_bound(all(dp), a) = a;
    }
    P(lower_bound(all(dp), INT_MAX) - dp.begin());
	return 0;
}

Measured memory_bytes: 3364
if __name__ == "__main__":
    N = int(input())
    c = input()

    r = N - 1
    l = 0
    r_ch, l_ch = True, True
    ans = 0
    while True:
        if l_ch:
            if c[l] == "W":
                l_ch = False
            l += 1
        if r_ch:
            if c[r] == "R":
                r_ch = False
            r -= 1
        if l_ch is False and r_ch is False:
            ans += 1
            r_ch, l_ch = True, True
        if l-1 >= r+1:
            break

    print(ans)

Measured memory_bytes: 9456
#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<bitset>
using namespace std;
//#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;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<max({a+b,a-b,a*b})<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> w(n);
    ll sum=0;
    rep(i,n){
      cin>>w[i];
      sum+=w[i];
    }
    ll ans=1e15;
    rep(i,n-1){
        ll a=0,b=0;
        rep(k,i+1){
          a+=w[k];
        }
        b=sum-a;
        ll cnt=abs(a-b);
        //cout<<a<<' '<<b<<' '<<cnt<<endl;
        if(ans>cnt) ans=cnt;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n; cin >> n;
    string s;cin >> s;
    int cntr = 0;
    int cnt2 = 0;
    rep(i,n) if(s[i]=='R') cntr++;
    rep(i,cntr) if(s[i]=='R') cnt2++;
    cout << cntr -cnt2<< '\n';
    
}


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,n,c=1;
    string s;
    cin>>n>>s;
      for(i=0;i<s.size()-1;i++)
      {
        if(s[i]!=s[i+1])
          c++;

      }

    cout<<c<<endl;

return 0;
}


Measured memory_bytes: 3716
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ) {
    y = x;
    if ( z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if ( y == NIL) {
    root = z;
  } else {
    if ( z->key < y->key ) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i ,x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    cin >> com;
    if (com == "insert") {
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 26740
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n; long long a[100002] = {}, b[100002] = {},m=0;
    cin >> n;
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0;i <= n; i++) {
        if (b[i] >= a[i]) {
            m += a[i];
            b[i + 1] += min(a[i+1],b[i] - a[i]);
        }
        else m += b[i];

    }
    cout << m << endl;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <iostream>

bool f[100001];
int c[100002];
int N, L, R ;

using namespace std;

int main () {
for (int i = 2; i <= 100000; i ++) if (!f[i]) for(int j = i + i; j <= 100000; j+= i) f[j] = true;
for (int i = 3; i <= 100000; i += 2) if (!f[i] && !f[(i+1)/2]) c[i]++;
for (int i = 3; i <= 100000; i ++) c[i] += c[i-1];
cin >> N;
while (N--) {
  cin >> L >> R;
  cout << c[R] - c[L-1] << endl;
}
}


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

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


Measured memory_bytes: 3620
s = input()
res = 0
if s == "SUN":
  res = 7
elif s == "MON":
  res = 6
elif s == "TUE":
  res = 5
elif s == "WED":
  res = 4
elif s == "THU":
  res = 3
elif s == "FRI":
  res = 2
elif s == "SAT":
  res = 1
print(res)

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

int main()
{
	string s, t; cin >> s >> t;
	int sLen = s.length();
	int tLen = t.length();
	int ans = tLen;
	for(int pos = tLen-1; pos < sLen; ++pos)
	{
		int changes = 0;
		for(int i = 0; i < tLen; ++i)
		{
			changes += (s[pos-i] != t[tLen-1-i]) ? 1 : 0;
		}
		ans = min(ans, changes);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int N, counter;
    int d[110];
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> d[i];

    int num[110] = {0};
    for(int i = 0; i < N; ++i) {
        num[d[i]]++;
    }
    int res = 0;
    for(int i = 1; i <= 100; ++i) {
        if(num[i]) {
            ++res;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define mper make_pair
#define PI 3.14159
#define F first
#define S second
#define ll int
//#define forik(i, a, b) for(ll i = a; i <= b; ++i)
#define vl vector<ll>
#define pll pair<ll, ll>
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;

const ll MAXN = 1e5 + 100;
ll n, k, a[MAXN];

int main() {

mal

cin >> n >> k;


for(int i = 1; i <= n; ++i) {
    cin >> a[i];
}

ll pos = -1;

for(int i = 1; i < n; ++i) {

    if(a[i] + a[i + 1] >= k) {pos = i; break;}

}

vector <ll> ans;

if(pos == -1) {cout << "Impossible";}

else {

    cout << "Possible\n";

    for(int i = 1; i < pos; ++i) {

        ans.pb(i);

    }

    for(int i = n - 1; i >= pos; --i) {

        ans.pb(i);

    }

    for(auto to : ans)
        cout << to << '\n';


}

return 0;
}



Measured memory_bytes: 1784
month, day = map(int, raw_input().split())
days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
youbi = ["Sunday", "Monday", "Tuesday",
         "Wednesday", "Thursday", "Friday", "Saturday"]
while month != 0:
    Days = 0
    for i in range(month - 1):
        Days += days[i]
    Days += day
    print youbi[(Days + 3) % 7]
    month, day = map(int, raw_input().split())

Measured memory_bytes: 4648