akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		string s;
		cin>>s;
		int ans=0;
		rep(i,0,(sz(s))/2){
			if(s[i]!=s[sz(s)-i-1]) ans++;
		}
		cout<<ans;
	}   
}     

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[200001];

int main(void) {
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> a[i];

	int breaks = 0;
	int snuke_satisfied = 0;
	for (int i = 1; i <= N; i++) {
		if (a[i]==(snuke_satisfied+1)) {
			snuke_satisfied++;
		} else { // break
			breaks++;
		}
	}
	if (snuke_satisfied > 0) {
		cout << breaks << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
ls = list(map(int, input().split()))
ls.sort()
ls.reverse()
lsa = []
lsb = []
for i in range(n):
    if i % 2 == 0:
        lsa += [ls[i]]
    else:
        lsb += [ls[i]]
a = sum(lsa)
b = sum(lsb)
c = a - b
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	long long i,n,a[11],tmp=1;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%2==0)tmp<<=1;
	}
	cout << pow(3,n)-tmp<<"\n";
}


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

int main(){
  double a;

  while(cin >> a){
    double sum = a;

    for(int i = 2; i <= 10; i++){
      double b;
      if(i % 2 == 0) b = a * 2;
      else           b = a / 3;
      sum += b;
      a = b;
    }

    printf("%.10f\n", sum);
  }
}

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

main() {
     string S; cin >> S; char c[4]={'A','C','G','T'};
     int ans=0; int tmp=0;
     rep(i,S.size()){
         bool can = false;
         rep(j,4){
             if(S[i]==c[j]) {can = true; break;}
         }
         if(can) tmp++;
         else {ans=max(ans,tmp); tmp=0;}
     }
     ans=max(ans,tmp);
     cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
まず1匹ずつ。
3
1 2
-1 1
2 -1

13
1*2 + 2*-1 = 0
123
1*-1*2 + 2*1*-1 =-4
ああ、13がだめだから。

1 2
とりあえず1引数を正に。
1 2

-2 1
2 -1
がだめ。

gcdでいれる
2^N - 1 が全通り。
OKのやつ同士の組み合わせ数


1 = 1
2 = +2
3 = +4
2 = 2がだめ。+4

ちがう
DPか
ちがわ

独立で倍。
排反のペアは個別加算。

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll MOD = 1e9+7, N; cin >> N;
  vector<ll> two(200010, 1);
  map<pair<ll,ll>, ll> M;
  rep(i, N) two[i+1] = (two[i] * 2) %MOD;
  rep(i, N){
    ll a, b; cin >> a >> b;
    if (a < 0){
      a *= -1;
      b *= -1;
    }
    ll c = gcd(a, b);
    if (c){
      a /= c;
      b /= c;
    }
    if (a == 0 && b == 0)
      M[{0, 0}]++;
    else if (a == 0)
      M[{0, 1}]++;
    else if (b == 0)
      M[{1, 0}]++;
    else
      M[{a, b}]++;
  }
  
  ll ans = 1;
  for(auto v: M){
    auto n1 = v.first.first;
    auto n2 = v.first.second;
    ans = (ans + MOD) %MOD;
    if (n1 == 0 && n2 == 0)
      continue;
    if (n1 == 0 || n2 == 0){
      ans *= (two[M[{0, 1}]] + two[M[{1, 0}]] - 1);
      M[{0, 1}] = 0;
      M[{1, 0}] = 0;
      continue;
    }
    ll nn2 = n2;
    ll nn1 = n1;
    if (nn2 < 0)
      nn2 *= -1;
    else
      nn1 *= -1;
    ans *= (two[M[{n1, n2}]] + two[M[{nn2, nn1}]] - 1);
    M[{n1, n2}] = 0;
    M[{nn2, nn1}] = 0;
  }
  ans += M[{0, 0}];
  ans--;
  ans = (ans + MOD) %MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 29748
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    vector<ll> A(3);
    ll sum = 0;
    rep(i, 3) {
        cin >> A[i];
        sum += A[i];
    }
    if (sum >= 22) {
        cout << "bust";
    } else {
        cout << "win";
    }
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if(s == "ABC") {
        cout << "ARC";
        return 0;
    }
    cout << "ABC";
    return 0;
}


Measured memory_bytes: 3636
n, m = map(int, input().split())
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
if is_prime(m):
    print(1)
else:
    for i in range(m//n, 0, -1):
        if not m%i:
            print(i)
            break

Measured memory_bytes: 40044
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;


int main(void){
	ll i;

	ll N;
	cin >> N;
	ll p=-1,x=-1;
	for(i=1;i<=N;i++){
		x=i*(i+1)/2;
		if(x>=N){
			p=i; break;
		}
	}

	for(i=1;i<=p;i++){
		if(i==x-N) continue;
		cout << i << endl;
	}


	return 0;
}


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

#define LEN 100005

using std::cin;
using std::cout;
using std::endl;
using std::string;

struct P{
  string name;
  int time;
};

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1) % LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1) % LEN;
  return x;
}

int min(int a, int b){return a<b?a:b;}

int main(){
  int i,c,q,elaps=0;
  P u;
  cin >> n >> q;
  for(int i=1;i<=n;i++)
    cin >> Q[i].name >> Q[i].time;
  head=1;
  tail=n+1;
  while(head!=tail){
    u=dequeue();
    c=min(q,u.time);
    u.time-=c;
    elaps+=c;
    if(u.time>0) enqueue(u);
    else{
      cout << u.name << " " << elaps << endl;
    }
  } 
}



Measured memory_bytes: 6924
#include <iostream>
#include <math.h>

using namespace std;

int main(void) {

    long long N, P;
    cin >> N;
    cin >> P;

    long long ans = 1;
    int i;

    if (N == 1){
        ans = P;
    }else{
        for (i = 2; i <= 1000010; i++) {
            long long kn = pow(i, N);
            if ((P % kn) == 0) {
                ans = i;
            }
            if (P < kn) {
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#include <cstdio>
using namespace std;
#define MAXN 100005
ll n;
int hoge[MAXN],fuga[MAXN];
ll check(int x){
    int a = 0, b[2 * MAXN] = {}, s = MAXN;
    long long total, t = 0;
    total = (long long)n*(n+1)/2;
    b[MAXN] = 1;
    for (int j=0; j<n; ++j) {
        a = hoge[j];
        if (a >= x) { s++; t-=b[s]; }
        else        { t+=b[s]; s--; }
        b[s]++;
        total -= t;
    }
    return total;
}
int main() {
    cin >> n;
    rep(i,n){
        cin >> hoge[i];
        fuga[i] = hoge[i];
    }
    sort(fuga,fuga+n);
    int l = 0,r = (int)n;
    while(r-l>1){
        int mid = (l+r)/2;
        ll temp = check(fuga[mid]);
        //cout << mid << " " << fuga[mid] << " "  << temp << endl;
        if(temp<n*(n+1)/4){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << fuga[(l+r)/2] << endl;
    return 0;
}

Measured memory_bytes: 1792
import numpy as np
N=int(input())
D=np.array(list(map(int,input().split())))
# (i,j)要素がi,jを食べたときの回復量(i*j)
kachi_matrix= np.expand_dims(D,axis=0) * np.expand_dims(D,axis=1)
np.fill_diagonal(kachi_matrix,0.0)
print(np.sum(kachi_matrix)//2)


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string S;
    cin >> S;

    ll mn = INF;
    REP(i,0,SZ(S)-2) {
        ll N = 100*(S[i]-'0') + 10*(S[i+1]-'0') + (S[i+2]-'0');
        mn = MIN(mn,abs(N-753));
    }
    PR(mn);

    return 0;
}

/*



*/

Measured memory_bytes: 3604
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int H, W, D, Q;
    cin >> H >> W >> D;
    vector<pair<int, int>> yx(H * W);
    rep(i, H) rep(j, W) {
        int a;
        cin >> a;
        yx[a - 1] = mp(i, j);
    }
    cin >> Q;
    vi L(Q), R(Q);
    rep(i, Q) {
        int l, r;
        cin >> l >> r;
        L[i] = l - 1;
        R[i] = r - 1;
    }

    vv<ll> b = vvec(D, H * W / D + 1, 0LL);
    rep(i, D) {
        for (int d = 1; i + D * d < H * W; ++d) {
            auto &p = yx[i + D * d], q = yx[i + D * (d - 1)];
            b[i][d] = abs(p.first - q.first) + abs(p.second - q.second) + b[i][d - 1];
        }
    }

    rep(i, Q) {
        int k = L[i] % D;
        int s = L[i] / D, t = R[i] / D;
        write(b[k][t] - b[k][s]);
    }
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define fr first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define FILL(x) memset(x,0,sizeof(x))
#define prv(v) for(auto sss:v) cout<<sss<<"   "
#define dbg(x) cout<<"Debug   "<<x << endl


class Node
{
public:
	Node * left;
	Node* right;
	int data;
	Node(int x) {
		data = x;
		left = right = NULL;
	}
	~Node();
};

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c;
	 cin >> a >> b >> c;
	 if(a+b+c >= 22){
	 	cout << "bust\n";
	 }else{
	 	cout << "win" << "\n";
	 }
	return 0;
}



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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        int min=64;
        for(int i=0;i<n;i++){
            long a=fsc.nextLong();
            int cnt=0;
            while(a%2==0){
                a/=2;
                cnt++;
            }
            min=Math.min(min, cnt);
        }
        fsc.close();
        System.out.println(min);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 22996
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c;
		return 0;
	}
	if (b == c) {
		cout << a;
		return 0;
	}
	cout << b;
}

Measured memory_bytes: 256
n=gets.to_i
line=gets.chomp.split.map(&:to_i)
dp=[]
dp[0]=0
dp[1]=(line[0]-line[1]).abs
2.upto(n-1) do |i|
  dp[i]=[dp[i-1]+(line[i-1]-line[i]).abs,dp[i-2]+(line[i-2]-line[i]).abs].min
end  
puts dp[n-1]


Measured memory_bytes: 11908
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] S = Console.ReadLine().ToCharArray();
            char[] T = Console.ReadLine().ToCharArray();
            int length = S.Length;
            for (var i = 0; i < length; i++)
            {
                for (var j = 0; j < length; j++)
                {
                    if (S[i] == T[j])
                    {
                        int count = 0;
                        int sPos = i;
                        int tPos = j;
                        while (count < length)
                        {
                            if (S[sPos] == T[tPos])
                            {
                                count++;
                                sPos++;
                                tPos++;
                                if (sPos >= length) sPos = 0;
                                if (tPos >= length) tPos = 0;
                            }
                            else
                            {
                                break;
                            }
                        }
                        if (count == length)
                        {
                            Console.WriteLine("Yes");
                            return;
                        }
                    }
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

using namespace std;

int main() {
    
    int a,b;
    cin >> a >> b;
    
    cout << 100 << " " << 100 << endl;
    
    vector<vector<char>> x(50, vector<char>(100,'.'));
    vector<vector<char>> y(50, vector<char>(100,'#'));
    
    int p,q;
    p = (a-1)/49 + 1; //p段に及ぶ
    q = (a-1)%49; //最終段の個数
    
    FOR(i, 0, p){
        if(i!=p-1){
            FOR(j, 0, 49){
                y[2*i+1][2*j+1] = '.';
            }
        }else{
            FOR(j, 0, q){
                 y[2*i+1][2*j+1] = '.';
            }
        }
    }
    
    p = (b-1)/49 + 1; //p段に及ぶ
    q = (b-1)%49; //最終段の個数
    
    FOR(i, 0, p){
        if(i!=p-1){
            FOR(j, 0, 49){
                x[2*i+1][2*j+1] = '#';
            }
        }else{
            FOR(j, 0, q){
                x[2*i+1][2*j+1] = '#';
            }
        }
    }
    
    FOR(i, 0, 50){
        FOR(j, 0, 100){
            cout << x[i][j];
            if(j==99){
                cout << endl;
            }
        }
    }
    FOR(i, 0, 50){
        FOR(j, 0, 100){
            cout << y[i][j];
            if(j==99){
                cout << endl;
            }
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        H: usize,
        W: usize,
        S: [String; H],
    }
    for _ in 0..W+2{
        print!("#");
    }
    println!("{}","");

    for i in 0..H{
        print!("#");
        print!("{}", S[i]);
        println!("#");
    }

    for _ in 0..W+2{
        print!("#");
    }
    println!("{}","");
}

Measured memory_bytes: 4352
s=input()
t=input()
ANS=0
ans=0
for i in range(len(s)-len(t)+1):
    a=s[i:i+len(t)]
    ans=0
    for j in range(len(a)):
        if a[j]==t[j]:
            ans+=1
        if ans>ANS:
            ANS=ans
print(len(t)-ANS)

Measured memory_bytes: 9060
#include <cstdio>
#include <string.h>
#include <string>
#include <vector>
#include <array>

int main()
{
    int X;

    scanf("%d", &X);

    int c500 = X / 500;
    int c5 = (X - (c500 * 500)) / 5;

    printf("%d", c500 * 1000 + c5 * 5);
    return 0;
}



Measured memory_bytes: 128
# coding: utf-8
import os
import time
import re
import math

def main():
    n=int(input())
    W=list(map(int,input().split()))

    #W.sort()
    hf=sum(W)/2
    count=0
    for a in W:
        temp=count
        count+=a
        if abs(hf-count)>=abs(hf-temp):
            count=temp
            break
    print(abs(count-(sum(W)-count)))



start=time.time();
main()
#print(time.time()*1000-start*1000)

Measured memory_bytes: 3312
from collections import deque
n=int(raw_input())
c=map(int,raw_input().split())
if n==2:
    if c[0]==c[1]:
        print "YES"
    else:
        print "NO"
    exit()

g=[[] for _ in xrange(n)]
cnt=[0]*n
edge={}
for i in xrange(n-1):
    a,b=map(int,raw_input().split())
    a-=1;b-=1
    if a>b:
        a,b=b,a
    g[a].append(b)
    g[b].append(a)
    cnt[a]+=1
    cnt[b]+=1
    edge[(a,b)]=i
cost=[0]*(n-1)
used=[False]*(n-1)
leaf=deque([])
for i in xrange(n):
    if cnt[i]==1:
        leaf.append(i)
used=[False]*(n-1)
ok=True
while len(leaf)>0:
    now=leaf.popleft()
    sum_edge=[]
    if cnt[now]==0:
        for to in g[now]:
            if to>now:
                idx=edge[(now,to)]
            else:
                idx=edge[(to,now)]
            sum_edge.append(cost[idx])
        #print cost
        if sum(sum_edge)!=2*c[now]:
            ok=False
            break
        continue
    for to in g[now]:
        if to>now:
            idx=edge[(now,to)]
        else:
            idx=edge[(to,now)]
        if used[idx]:
            sum_edge.append(cost[idx])
            continue
        else:
            nx=to
            nxidx=idx
    used[nxidx]=True
    cnt[nx]-=1
    if cnt[nx]==1:
        leaf.append(nx)
    if len(g[now])==1:
        cost[nxidx]=c[now]
    else:
        sum_edge.sort(reverse=True)
        cost[nxidx]=2*c[now]-sum(sum_edge)
        if cost[nxidx]<0:
            ok=False
            break
        sum_edge.append(cost[nxidx])
        mx=max(sum_edge)
        if sum(sum_edge)-2*mx<0:
            ok=False
            break
"""
for now in xrange(n):
    if len(g[now])==1:continue
    for nx in g[now]:
        if now>nx:
            now,nx=nx,now
        idx=edge[(now,nx)]
        if cost[idx]==0:
            ok=False
            break
"""
print "YES" if ok else "NO"


Measured memory_bytes: 78624
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    int N, M;
    readf("%d %d\n", &N, &M);
    int[] ary = readln.split.to!(int[]).sort!((a, b) =>
        (a+b)%2==0 ? a<b : a%2==1
    ).array.pipe!"a[1..$]~a[0]";
    if (M==1) ary ~= 0;

    if (ary.count!"a%2==1" > 2) {
        writeln("Impossible");
        return;
    }

    ary.filter!"a>0".array.to!(string[]).join(" ").writeln;
    ary.front--;
    ary.back++;
    ary.filter!"a>0".array.pipe!((a) {
        a.length.writeln;
        a.to!(string[]).join(" ").writeln;
    });
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define all(c) c.begin(),c.end()
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007 
//bool good(ll d){
   
   
//}
int main()
{
   ios::sync_with_stdio(0);
   // cin.tie(0);
int n;
cin>>n;
vector<array<int,3>> v(n+1);
REP(i,1,n)
cin>>v[i][0]>>v[i][1]>>v[i][2];
vector<vi> dp(n+1,vi(3));
dp[0][0]=0;dp[0][1]=0;dp[0][2]=0;
for(int i=1;i<=n;++i){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i][0];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i][1];
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+v[i][2];

}
cout<<max({dp[n][0],dp[n][1],dp[n][2]});
 
   



    return 0;
}

Measured memory_bytes: 9844
n,w = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [[float("-inf")]*(w+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    a = wv[i]
    for j in range(w+1):
        if a[0] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j- a[0]] + a[1])
        else:
            dp[i+1][j] = dp[i][j]

print(max(dp[-1]))

Measured memory_bytes: 311772
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int ans;
char c[200];
int sub[200];

int main() {
	
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>c[i];
	for(int i=0;i<n;i++){
		bool letter1[50]={false};
		bool letter2[50]={false};
		for(int j=0;j<i;j++){
			for(char w='a';w<='z';w++){
				if(c[j]==w)letter1[w-'a']=true;
			}
		}
		for(int j=i;j<n;j++){
			for(char w='a';w<='z';w++){
				if(c[j]==w)letter2[w-'a']=true;
			}
		}
		for(char j='a';j<='z';j++){
			if(letter1[j-'a']&&letter2[j-'a'])sub[i]++;
		}
	}
	for(int i=0;i<n;i++)ans=max(ans,sub[i]);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

ll llmin(ll a, ll b){
  return a < b ? a : b;
}

int main(){
  ll N, K;
  string S;
  cin >> N >> K;
  cin >> S;

  vector<ll> sarr;
  if(S[0] == '0') sarr.push_back(0);
  char tmp = S[0];
  ll sum = 0;
  rep(i, N){
    if(S[i] == tmp) sum++;
    else{
      sarr.push_back(sum);
      tmp = '0' + ('1' - tmp);
      sum = 1;
    }
  }
  sarr.push_back(sum);
  if(sarr[0] == 0) N++;
  if(N % 2 == 0){
    N++;
    sarr.push_back(0);
  }

  ll ans_tmp = 0;
  rep(i, llmin(K * 2 + 1, sarr.size())) ans_tmp += sarr[i];
  ll l = 0, r = llmin(K * 2 + 1, sarr.size());
  ll ans = ans_tmp;
  while(r < sarr.size()){
    ans_tmp += -sarr[l] - sarr[l+1] + sarr[r] + sarr[r+1];
    l += 2;
    r += 2;
    if(ans < ans_tmp) ans = ans_tmp;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int max_n = 103;
const int INF = INT_MAX / 10;
int h, w;
string g[max_n];
int d[max_n][max_n];

void dfs(int r, int c, bool bla){
	for(int x = 0; x <= 1; x++){
		int nr = r + x;
		int nc = c + 1 - x;

		if(nr < h && nc < w){
			if(bla){
				if(d[nr][nc] > d[r][c]){
					d[nr][nc] = d[r][c];
					dfs(nr, nc, g[nr][nc] == '#');
				}
			}else{
				int k = (g[nr][nc] == '#' ? 1 : 0);
				if(d[nr][nc] > d[r][c] + k){
					d[nr][nc] = d[r][c] + k;
					dfs(nr, nc, g[nr][nc] == '#');
				}
			}
		}
	}
}

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

	cin >> h >> w;
	rep(i, h) cin >> g[i];

	rep(i, h) rep(j, w) d[i][j] = INF;
	if(g[0][0] == '.'){
		d[0][0] = 0;
	}else{
		d[0][0] = 1;
	}
	dfs(0, 0, g[0][0] == '#');

	cout << d[h - 1][w - 1] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int b[n-1];
    rep(i, n-1) {
        cin >> b[i];
    }

    if(n == 2) {
        cout << 2*b[0] << endl;
        return 0;
    }

    int ans = b[0];
    rep(i, n-2) {
        ans += min(b[i], b[i+1]);
    }
    ans += b[n-2];

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

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int N,C;
	std::cin >> N >> C;
	std::vector<std::vector<int>> D(C,std::vector<int> (C));
	std::vector<std::vector<int>> c(N,std::vector<int> (N));
	for (size_t i = 0; i < C; i++) {
		for (size_t j = 0; j < C; j++) {
			std::cin >> D[i][j];
		}
	}
	for (size_t i = 0; i < N; i++) {
		for (size_t j = 0; j < N; j++) {
			std::cin >> c[i][j];
			c[i][j]--;
		}
	}

	// 3種類のマスをそれぞれ色1~色Cに塗った時のコスト(違和感)
	std::vector<std::vector<int>> v(3,std::vector<int> (C,0));
	// 3種類のマス
	for (size_t i = 0; i < C; i++) {
		for (size_t j = 0; j < c.size(); j++) {
			for (size_t k = 0; k < c[j].size(); k++) {
				v[(j+k)%3][i] += D[c[j][k]][i];
			}
		}
	}

	int ans = INT_MAX / 3;
	for (size_t i = 0; i < C; i++) {
		for (size_t j = 0; j < C; j++) {
			for (size_t k = 0; k < C; k++) {
				if (i != j && j != k && k != i) {
					ans = min(ans, v[0][i]+v[1][j]+v[2][k]);
				}
			}
		}
	}

	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1280
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int x = sc.nextInt();
        int t = sc.nextInt();

        System.out.println(Math.max(0, x-t));
    }
}

Measured memory_bytes: 19924
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String s[] =  {"Sunny", "Cloudy", "Rainy"};

        if(S.equals(s[0])){
            System.out.println(s[1]);
        }
        if(S.equals(s[1])){
            System.out.println(s[2]);
        }
        if(S.equals(s[2])){
            System.out.println(s[0]);
        }



    }
}






Measured memory_bytes: 19924
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<string,pair<int,int>>> a(n);
    rep(i,n){
        string s;
        int q;
        cin >> s >> q;
        a[i].first=s;
        a[i].second.first=-q;
        a[i].second.second=i+1;
    }
    sort(a.begin(),a.end());
    // bool frag = false;
    // int cnt=0;
    // rep(i,n){
    //     if(!frag){
    //         if(a[i-1].first==a[i].first){
    //             cnt=2;
    //             frag = true;
    //         }
    //         else{
    //             continue;
    //         }
    //     }
    //     else{
    //         if(a[i-1].first==a[i].first){
    //             cnt++;
    //         }
    //         else{
    //             rep(j,cnt/2){
    //                 // cout << 4444<<endl;
    //                 swap(a[i-1-j].second.second,a[i-cnt+j].second.second);
    //             }
    //             frag=false;
    //             cnt=0;
    //         }
    //     }
    // }
    // if(frag){
    //     rep(j,cnt/2){
    //         swap(a[n-1-j].second.second,a[n-cnt+j].second.second);
    //     }
    // }
    rep(i,n){
        cout << a[i].second.second << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class BIT{
	public:
	//[1,i]
	int n;
	vi bit;
//	int bit[MAZ_N+1];
	BIT(int size){
		n=size;
		bit=vi(n+1);
	}
	Def query(int i){//sum
		Def s=0;
		while(i>0){
			s+=bit[i];
			i-=i&-i;
		}
		return s;
	}
	void add(int i,Def x){
		while(i<=n){
			bit[i]+=x;
			i+=i&-i;
		}
	}
};
int main(){
	string s;
	cin>>s;
	int n=s.size();
	vi co(26);
	rep(i,n)co[s[i]-'a']++;
	int c=0;
	rep(i,26)c+=co[i]%2;
	if(c>n%2){
		cout<<-1<<endl;
		return 0;
	}
	
	int w[26][2];
	rep(i,26)w[i][0]=0;
	rep(i,26)w[i][1]=n-1;
	
	BIT bit(n);
	
	ll out=0;
	rep(i,26){
		while(w[i][0]<n&&s[w[i][0]]!='a'+i)w[i][0]++;
		while(w[i][1]>=0&&s[w[i][1]]!='a'+i)w[i][1]--;
	}
	rep(i,n/2){
		ll mi=inf,mai;
		rep(j,26)if(w[j][0]<w[j][1]){
			int t=0;
			t+=w[j][0]-bit.query(1+w[j][0]);
			t+=n-1-w[j][1]-(2*i-bit.query(1+w[j][1]));
			if(mi>t){
				mi=t;
				mai=j;
			}
		}
		out+=mi;
		
		bit.add(1+w[mai][0],1);
		bit.add(1+w[mai][1],1);
		
		w[mai][0]++;w[mai][1]--;
		while(w[mai][0]<n&&s[w[mai][0]]!='a'+mai)w[mai][0]++;
		while(w[mai][1]>=0&&s[w[mai][1]]!='a'+mai)w[mai][1]--;
	}
	
	cout<<out<<endl;
}




Measured memory_bytes: 2180
import heapq
N,M = map(int,input().split())
As = list(map(int,input().split()))

As = sorted(As)
BCs = []
heapq.heapify(BCs)
for i in range(M):
    B,C =   map(int,input().split())
    heapq.heappush(BCs,(-C,B))

ind = 0
ans = 0
flg = False
for i in range(M):
    _C,B = heapq.heappop(BCs)
    for i in range(B):
        if As[ind+i] > -_C:
            flg = True
            ind += i
            break
        else:
            ans -= _C
        if ind+i+1 > N-1:
            flg = True
            ind += i+1
            break
    if flg: break
    ind += B
ans += sum(As[ind:])
print(ans)

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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

int const N = 1e7;

ll h[N], dp[N];

int n;

ll knapsack(int i)
{
    if (i >= n)
        return 0;

    if (dp[i] != -1)
        return dp[i];

    ll jump1 = inf;
    ll jump2 = inf;

    if (i+1 <= n)
        jump1= knapsack(i + 1) + abs(h[i] - h[i+1]);

    if (i+2 <= n)
        jump2 = knapsack(i + 2) + abs(h[i] - h[i+2]);

    return dp[i] = min(jump1, jump2);
}

int main ()
{
    cin >> n;

    memset(dp, -1, sizeof dp);

    for (int i = 1; i <= n; i++)
        cin >> h[i];

    cout << knapsack(1) << endl;

    return 0;
}


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

int f(int n) {
    if (n % 2 != 0){
        return 1;
    }
    return f(n / 2) + 1;
}

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

    int ans = -1;
    int c = -1;
    for (int i = 1; i <= n; i++) {
        int a = i;
        int cnt = 0;
        while(1) {
            if (a % 2 == 0) {
                cnt++;
                a /= 2;
            } else {
                break;
            }
        }
        if (cnt > c) {
            c = cnt;
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;

int main()
{
	int n;
	cin>>n;
	bool od=0;
	for(int i=0; i<n; i++){
		int a; cin>>a;
		if(a&1) od=1;
	}
	if(od) cout<<"first"<<endl;
	else cout<<"second"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define N_MAX 200002


using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];

void init(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll) i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll comb(ll n, ll r){
  ll ans;
  if(n < r){
      ans = 0;
  }else{
      ans = (fac[n]*finv[r])%MOD;
      ans = (ans*finv[n-r])%MOD;
      ans = (ans+MOD)%MOD;
  }
  return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    init();
    ll n, k;
    cin >> n >> k;
    if(k == 1){
        cout << n << endl;
        return 0;
    }
    ll ans = 0;
    for(int i = 0; i <= min(n, k); i++){
        ans += (comb(n, i)*comb(n-1, n-i-1))%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
import java.util.*;
import java.io.*;
public class Main {                
 
    public static void main(String[] args)throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String sa = br.readLine();
       String sb = br.readLine();
       String sc = br.readLine();
       Queue<Character> a[] = new LinkedList[3];
       a[0] = new LinkedList<>();
       a[1] = new LinkedList<>();
       a[2] = new LinkedList<>();
       for(int i=0;i<sa.length();i++){
           a[0].add(sa.charAt(i));
       }
       for(int i=0;i<sb.length();i++){
           a[1].add(sb.charAt(i));
       }
       for(int i=0;i<sc.length();i++){
           a[2].add(sc.charAt(i));
       }
       int turn = 0;
      
       while(a[turn].size()>0){
           char c = a[turn].poll();
           switch(c){
               case 'a': turn=0; break;
               case 'b': turn=1; break;
               case 'c': turn=2; break;
           }
       }
   
       switch(turn){
           case 0: System.out.println("A"); break;
           case 1: System.out.println("B"); break;
           case 2: System.out.println("C"); break;
       }
    }
}

Measured memory_bytes: 8020
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  string s;
  cin >> s;
  int a,b,c,d;
  a = count(ALL(s), 'K');
  b = count(ALL(s), 'U');
  c = count(ALL(s), 'P');
  d = count(ALL(s), 'C');
  int res = min(min(a,b),min(c,d));
  
  printf("%d\n",res);
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{

    char c;
    int charNo;
    cin>>c;
    if(c=='z'|| c=='Z'){
        cout<<"cann't"<<endl;
    }
    else{
    charNo=(int)c;
    cout<<(char)++charNo<<endl;}
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    C = list(input())
    C_ = sorted(C)

    wr = rw = 0
    for i in range(len(C_)):
        if C[i] != C_[i]:
            if C[i] == "R" and C_[i] == "W":
                rw += 1
            else:
                wr += 1

    print(max(wr, rw))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 12832
#include <iostream>

using namespace std;

int max(int& x, int& y) {
	if (x > y) {
		x--;
		return x;
	}
	else {
		y--;
		return y;
	}
}

int main() {
	int x1, x2;
	int count = 0;
	cin >> x1 >> x2;
	count += max(x1, x2) + 1;
	count += max(x1, x2) + 1;
	cout << count << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int N=1005000;
#define ll long long
ll a[100];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll i,j,k,m,n;
    ll cnt=0,ans,flag=1;
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>a[i];
    while(flag)
    {
        k=1;
        if(a[k]<n)
            flag=0;
        for(i=2; i<=n; i++)
            if(a[i]>a[k]&&a[i]>=n)
            {
                flag=1;
                k=i;
            }
        if(flag)
        {
            ans=a[k]/n;
            cnt+=ans;
            a[k]%=n;
            for(i=1; i<=n; i++)
                if(i!=k)
                    a[i]+=ans;
        }

    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           string a,b;
           cin >> a >> b;
           
           int lena = a.length();
           int lenb = b.length();
           
           int mx = INT_MAX;
           for(int i = 0 ; i <= lena - lenb ; i++)
           {
               int c = 0;
               for(int j = 0 ; j < lenb ; j++)
               {
                   if(a[i + j] != b[j])c++;
               }
               mx = min(mx , c);
           }
           
           cout << mx << endl;
        }
    }



Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

#define snd second
#define fst first

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }

const int MAXN = 3042;
int g[MAXN][MAXN];

int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    int a, b, c, d, e, f;
    while (cin >> a >> b >> c >> d >> e >> f) {
        memset(g, 0, sizeof(g));
        a *= 100;
        b *= 100;
        g[0][0] = true;

        int x, y;
        x = a;
        y = 0;

        for (int i = 1; i <= f; ++i) {
            for (int j = 0; j <= i; ++j) {
                if (a <= i) g[i][j] |= g[i - a][j];
                if (b <= i) g[i][j] |= g[i - b][j];
                if (c <= j) g[i][j] |= g[i - c][j - c];
                if (d <= j) g[i][j] |= g[i - d][j - d];

                if (g[i][j] && y * i < j * x && j * 100 <= (i - j) * e) {
                    x = i;
                    y = j;
                }
            }
        }
        cout << x << " " << y << endl;
    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 36480