akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});    

    let s = input[0][0].split("");
    let t = input[1][0].split("");


    var arr_dp = [];
    for (var j = 0; j <= t.length; j++){
        arr_dp.push([]);
        arr_dp[j][0] = 0;
    }
    for (var i = 0; i <= s.length; i++){
        arr_dp[0][i] = 0;
    }
    for (var j = 0; j < t.length; j++){
        for (var i = 0; i < s.length; i++){
            if (s[i] === t[j]) arr_dp[j + 1][i + 1] = arr_dp[j][i] + 1;
            else arr_dp[j + 1][i + 1] = Math.max(arr_dp[j + 1][i], arr_dp[j][i + 1]);
        }
    }
	let l = arr_dp[t.length][s.length];
	let tmpLocation1 = t.length;
	let tmpLocation2 = s.length;
	let tmpCharacter;
	let v_ans = [];
	for (let i = 0; i < l; i++){
		for (let j = tmpLocation2; j >= 1 ; j--){
			if (arr_dp[tmpLocation1][j] > arr_dp[tmpLocation1][j - 1]){
				tmpLocation2 = j - 1;
				break;
			}
		}
		tmpCharacter = s[tmpLocation2];
		for  (let j = tmpLocation1; j >= 1; j--){
			if (t[j - 1] === tmpCharacter){
				v_ans.push(tmpCharacter);
				tmpLocation1 = j - 1;
				break;
			}
		}
	}
	console.log(v_ans.reverse().join(""));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 167512
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		String[] W = new String[N];
		String ans = "Yes";
		out:for (int i = 0; i < N; i++) {
			if (i == 0) {
				W[0] = sc.next();
			} else {
				W[i] = sc.next();
				if (W[i-1].charAt(W[i-1].length()-1) != W[i].charAt(0)) {
					ans = "No";
					break;
				} else {
					for (int j = 0; j < i; j++) {
						if (W[j].equals(W[i])) {
							ans = "No";
							break out;
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}

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());
    }
}

Measured memory_bytes: 21076
def gcd(x,y):
  while y!=0:
    x,y=y,x%y
  return x

def lcm(x,y):
  return x*y//gcd(x,y)

a, b, c, d = map(int, input().split())
cd = lcm(c, d)

print(
    b - (b//c) - (b//d) + (b//cd) \
    -((a-1) - ((a-1)//c) - ((a-1)//d) + ((a-1)//cd))
    )


Measured memory_bytes: 38384
#include <math.h>

#include <cmath>
#include <iostream>
using namespace std;
int main() {
    string k, l;
    int s;
    cin >> s >> k;
    l = k.substr(0, s);
    if (k == l) {
        cout << k << endl;
    } else {
        cout << l << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3512
#include<iostream>
#include<string>
#include<stdlib.h>
#include<vector>

using namespace std;

int main(){
  int n,cnt=0;
  string s,before="",tmp,key;
  vector<string> keys{".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    if (s.length()==1) {
      cout << endl;
      continue;
    }
    for(int i=0;i<s.length();i++){
      tmp = s[i];
      if (tmp!="0" && tmp==before) cnt++;
      else if (tmp==before) continue;
      else if (tmp=="0"){
        key = keys[atoi(before.c_str())-1][(cnt-1)%(keys[atoi(before.c_str())-1].length())];
        cout << key;
        cnt=0;
        before="0";
      } else {
        before =tmp;
        cnt++;
      } 
    }
    cout << endl;
    
  }
  return 0;
    
}

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

/* */

int main(){
    // 入力スタンダード
    string s;
    cin >> s;

    if(s == "ABC"){
        cout << "ARC" <<endl;
    }else{
        cout << "ABC" <<endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;

int main(){
	int n;
	std::cin >> n;
	vector<int> a(n);
	rep(i,n)std::cin >> a[i];
	sort(all(a));
	int ans=0;
	rep(j,n){
		for (int i = j+1; i < n; i++) {
			/* code */
			auto dd=lb(all(a),a[i]+a[j]);
			int d=distance(a.begin(),dd);
	//		std::cout <<i<<" "<<j<<" "<< d << std::endl;
			d-=1;
			d-=i;
			ans+=max(0,d);
			
		}
	}
	std::cout << ans << std::endl;
}



Measured memory_bytes: 256
def main():
    n, legs = [int(x) for x in input().split(" ")]

    if legs % 2 != 0:
        print("No")
        exit(0)

    max = legs / 2
    min = int(legs / 4) + (legs % 4) / 2

    print("Yes" if n >= min and n <= max else "No")

main()


Measured memory_bytes: 9076
MOD = 10**9+7
import sys
from collections import Counter
from math import gcd
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
ans = 0
c = Counter()
zero = 0
for _ in range(n):
	a, b = map(int, input().split())
	if a == b == 0:
		zero += 1
		continue
	if a < 0:
		a, b = -a, -b
	if a == 0:
		a, b = 0, 1
	if b == 0:
		a, b = 1, 0
	g = gcd(a, b)
	c[(a//g, b//g)] += 1

ans = 1
for k, v in c.items():
	#print(k, v)
	if k[1] <= 0:
		x, y = -k[1], k[0]
		if c[(x, y)] > 0:
			continue
	else:
		x, y = k[1], -k[0]
	res = 0
	res += pow(2, v, MOD) - 1
	res += pow(2, c[(x, y)], MOD) - 1
	res += 1
	ans *= res
	ans %= MOD

ans += zero
ans -= 1
ans %= MOD
print(ans)

Measured memory_bytes: 115116
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(void) {
	long long a, b, n, i, minn;
	scanf("%lld %lld %lld", &a, &b, &n);
	minn=min(b - 1,n);

	printf("%lld", (a*minn)/b-a*(minn/b));
	return 0;
}

Measured memory_bytes: 1732
n = int(input())
ai = [int(x) for x in input().split()]

ai.sort()

temp = [abs(x) for x in ai[1:-1]]

o1 = -ai[0] + sum(temp) + ai[-1]

print(o1)

temp1 = ai.pop(-1)
num_p = sum(x >= 0 for x in ai)
if num_p == len(ai):
  num_p -= 1
for i in range(num_p):
  temp2 = ai.pop(-1)
  print(ai[0], temp2)
  ai[0] -= temp2

for i in range(len(ai)):
  temp2 = ai.pop(0)
  print(temp1, temp2)
  temp1 -= temp2
 


Measured memory_bytes: 14264
// 5/10 リアルタイム参加
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

// ll dp[100010];  // i番目の町が初めて到着した回数（未到着の場合は-1）
// bool seen[100010];  // i番目の町がこれまで到着したかどうか。

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

    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
    }

    vector<ll> dp(N, -1);

    // memset(dp, -1, sizeof(dp));
    // memset(seen, 0, sizeof(seen));

    ll pos = 0;
    dp[pos] = 0;
    // seen[pos] = true;

    ll loop_start_position, loop_start_time, loop_length;

    for(ll i = 0; i < N; i++) {
        int next_pos = A[pos];
        // printf("pos, next_pos = %d, %d\n", pos, next_pos);

        if (dp[next_pos] == -1) {
            dp[next_pos] = i + 1;
            pos = next_pos;
        } else {
            loop_start_position = next_pos;
            loop_start_time = dp[next_pos];
            loop_length = i + 1 - dp[next_pos];

            break;
        }
    }

    // cout << "here>" << endl;

    ll rest_time;
    ll start_pos;  //  = 0;

    if (K <= loop_start_time) {
        rest_time = K;
        start_pos = 0;
    } else {
        rest_time = (K - loop_start_time) % loop_length;
        start_pos = loop_start_position;
    }

    ll ans = start_pos;
    for(ll i = 0; i < rest_time; i++) {
        ans = A[ans];
    }

    // cout << "loop_start_position: " << loop_start_position << endl;
    // cout << "loop_start_time: " << loop_start_time << endl;
    // cout << "loop_length" << loop_length << endl;

    // cout << "rest_time: " << rest_time << endl;
    // cout << "start_pos: " << start_pos << endl;

    cout << ans + 1 << endl;
}


Measured memory_bytes: 6428
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,l,q,ans;
ll x[500005],y[500005],z[500005];
P table[500005];
char s[500005],t[500005];
bool flag,dame;

int main(){
    cin >> n >> m;
	for(i=0;i<n;i++){
		cin >> a >> b;
		table[i] = P(a,b);
	}
	sort(table,table + n);
	for(i=0;i<n;i++){
		if(m > table[i].second){
			ans += table[i].second * table[i].first;
			m -= table[i].second;
		}else{
			ans += m * table[i].first;
			break;
		}
	}
	p(ans);

	return 0;
}

Measured memory_bytes: 26880
S = input()

if S == "RRR":
    print(3);
elif S[1:3]=="RR" or S[0:2]=="RR":
    print(2);
elif S[0]=="R" or S[1]=="R":
    print(1);
elif S[2]=="R":
    print(1);
else:
    print(0);

Measured memory_bytes: 9048
#include<bits/stdc++.h>
#define int long long
using namespace std;
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; }

class SegmentTree
{
 private:
    int n;
    vector<int> node,lazy;
 public:
    SegmentTree(int sz){
        n=1;
        while(n<sz) n*=2;
        node.assign(2*n-1,0);
        lazy.assign(2*n-1,0);
    }
    void update(int a,int b,int x,int k,int l,int r){
        if(a<=l and r<=b) node[k]+=x,lazy[k]+=x;
        else{
            if(lazy[k]!=0) push(k),lazy[k]=0;
            if(check(a,b,l,(l+r)/2)) update(a,b,x,2*k+1,l,(l+r)/2);
            if(check(a,b,(l+r)/2,r)) update(a,b,x,2*k+2,(l+r)/2,r);
            node[k]=min(node[2*k+1],node[2*k+2]);
        }
    }
    int get(int a,int b,int k,int l,int r){
        if(a<=l and r<=b) return node[k];
        else{
            if(lazy[k]!=0) push(k),lazy[k]=0;
            int res=INT_MAX;
            if(check(a,b,l,(l+r)/2)) res=min(res,get(a,b,2*k+1,l,(l+r)/2));
            if(check(a,b,(l+r)/2,r)) res=min(res,get(a,b,2*k+2,(l+r)/2,r));
            return res;
        }
    }
    void push(int k){
        node[2*k+1]+=lazy[k]; node[2*k+2]+=lazy[k];
        lazy[2*k+1]+=lazy[k]; lazy[2*k+2]+=lazy[k];
    }
    bool check(int a,int b,int l,int r){
        return max(a,l)<min(b,r);
    }
    void update(int a,int b,int x){ update(a,b,x,0,0,n); }
    int get(int a,int b){ return get(a,b,0,0,n); }
};

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

    int N,Q; cin>>N>>Q;
    SegmentTree seg(N);
    while(Q--){
        int q; cin>>q;
        if(q==0){
            int s,t,x; cin>>s>>t>>x;
            seg.update(s,t+1,x);
        }else{
            int s,t; cin>>s>>t;
            cout<<seg.get(s,t+1)<<endl;
        }
        // seg.print();
    }
    return 0;
}


Measured memory_bytes: 7052
/* ITP1_4_D: Min, Max and Sum */
/* 20181119 AOJ */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <limits.h>

int main(void){
	int min, max, n, a;
	long long sum;

	scanf("%d", &n);
	scanf("%d", &a);
	min = max = sum = a;
	while(--n){
		scanf("%d", &a);
		if(a < min) min = a;
		if(a > max) max = a;
		sum += a;
	}

	printf("%d %d %lld\n", min, max, sum);

	return 0;
}


Measured memory_bytes: 1988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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 N;
    cin >> N;
    vector<int> cnt(N,0);
    int M=0;
    rep(i,N){
        int a;
        cin >> a;
        ++cnt[a],chmax(M,a);
    }
    bool ans=true;
    rep(i,M+1){
        if (i<(M+1)/2&&cnt[i]>0) ans=false;
        if (i==(M+1)/2){
            if (M%2==0&&cnt[i]!=1) ans=false;
            if (M%2==1&&cnt[i]!=2) ans=false;
            continue;
        }
        if (i>(M+1)/2&&cnt[i]<2){
            ans=false;
        }
    }
    if (ans) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
 }

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    string s;
    cin >> s;
    int index[26];
    rep(i, 26) { index[i] = -3; }
    int l = -2, r = -2;

    rep(l0, s.size()) {
        int num = s[l0] - 'a';
        if (l0 - index[num] <= 2) {
            l = index[num];
            r = l0;
            break;
        } else {
            index[num] = l0;
        }
    }

    cout << l + 1 << " " << r + 1 << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


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

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;
static const double PI = acos(-1.0);
static const int MAX_N = 16777216;
//static const int MOD = 1000000007;

class Segtree {
public:
    int n, dat[MAX_N * 4];

    void init(int pn) {
        n = 1;
        while (n < pn) n *= 2;

        fill(dat, dat + MAX_N * 4, -INF);
    }

    void update(int i, int x) {
        i = n + i - 1;
        dat[i] = x;

        while (0 < i) {
            i = (i - 1) / 2;

            dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    int getMax(int s, int t, int k, int l, int r) {
        if (t <= l || r <= s) return -INF;
        if (s <= l && r <= t) return dat[k];

        int t1 = getMax(s, t, k * 2 + 1, l, (l + r) / 2);
        int t2 = getMax(s, t, k * 2 + 2, (l + r) / 2, r);
        return max(t1, t2);
    }
};

Segtree seg;
int N, D, X[35], Y[35];
vector<pii> all1, all2;


void enumall(int depth, int dx, int dy, vector<pii> &result, int term) {
    if (depth == term) {
        result.PB(pii(dx, dy));
        return;
    }

    enumall(depth - 1, dx + X[depth], dy + Y[depth], result, term);
    enumall(depth - 1, dx - X[depth], dy - Y[depth], result, term);
    enumall(depth - 1, dx, dy, result, term);
}

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

    cin >> N >> D;
    for (int i = 1; i <= N; ++i) {
        cin >> X[i] >> Y[i];
    }

    all1.reserve(MAX_N);
    enumall(N / 2, 0, 0, all1, 0);

    all2.reserve(MAX_N);
    enumall(N, 0, 0, all2, N / 2);
    sort(all2.begin(), all2.end());

    seg.init(all2.size());
    for (int i = 0; i < all2.size(); ++i) {
        seg.update(i, all2[i].second);
    }

    int ans = 0;
    for (int i = 0; i < all1.size(); ++i) {
        int tx = all1[i].first, ty = all1[i].second;
        int a = -tx + D, b = -tx - D;
        int s = lower_bound(all2.begin(), all2.end(), pii(min(a, b), -INF)) - all2.begin();
        if (s == all2.size()) continue;
        int t = upper_bound(all2.begin(), all2.end(), pii(max(a, b), INF)) - all2.begin();

        if (t - s <= 0) continue;
        ans = max(ans, abs(seg.getMax(s, t, 0, 0, seg.n) + ty));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 974556
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

typedef complex<double> C;
typedef pair<C,C> pp;
typedef vector<C> VP;
typedef vector<pp> VPP;
#define eq(a,b) (fabs(a-b)<eps)
#define veq(a,b) (eq(a.real(),b.real())&&eq(a.imag(),b.imag()))
const C O{0,0};

void In(C& p){
	double x,y;
	cin>>x>>y;
	p=C(x,y);
}

void Out(C p){
	cout<<(int)p.real()<<' '<<(int)p.imag()<<endl;
}

double Dot(C p,C q){
	return p.real()*q.real()+p.imag()*q.imag();
}

double Det(C p,C q){
	return p.real()*q.imag()-q.real()*p.imag();
}

int Circles(C a,double r,C b,double R){
	int t=abs(a-b);
	if(t<abs(R-r)) return 0;
	if(t==abs(R-r)) return 1;
	if(t<R+r) return 2;
	if(t==R+r) return 3;
	return 4;
}

C a,b;
double r,R;

int main(){
	In(a);cin>>r;
	In(b);cin>>R;
	cout<<Circles(a,r,b,R)<<endl;
	
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[4003],dif[4003][10],ans;
char a1[4003];
signed main()
{
	scanf("%lld",&n);
	scanf("%s",a1+1);
	for(int i=1;i<=n;i++)
		if(a1[i]=='R')
			a[i]=1;
		else if(a1[i]=='G')
			a[i]=2;
		else if(a1[i]=='B')
			a[i]=3;
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++)
			dif[i][a[j]]++;
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++)
			if(a[i]!=a[j])
			{
				if(a[i]!=1&&a[j]!=1)
					ans+=dif[j][1];
				if(a[i]!=2&&a[j]!=2)
					ans+=dif[j][2];
				if(a[i]!=3&&a[j]!=3)
					ans+=dif[j][3];
				if(j-(i-j)>=1&&a[j-(i-j)]!=a[i]&&a[j-(i-j)]!=a[j])
					ans--;					
			}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4032
from collections import defaultdict


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    d = defaultdict(int)
    for a in A:
        d[a] += 1

    d_sorted = sorted(d.items(), key=lambda x: x[1], reverse=True)

    tmp = 0
    for i, k in enumerate(d_sorted):
        if i < K:
            tmp += k[1]
        else:
            break

    print(N-tmp)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44520
import scala.io.StdIn.{readInt, readLine};

object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val arr = readLine.split(" ").map(_.toLong);
        val cnt = mergeSort(arr, n);
        println(arr.mkString(" "));
        println(cnt);
        
    }
    def mergeSort(arr: Array[Long], n: Int): Int = {
        def _mergeSort(first: Int, last: Int): Int = {
            if (last - first > 0) {
                val pivot = (first + last) / 2;
                val cnt1 = _mergeSort(first, pivot);
                val cnt2 = _mergeSort(pivot + 1, last);
                merge(arr, first, last, pivot);
                cnt1 + cnt2 + (last - first + 1);
            } else {
                0;
            }
        }
        _mergeSort(0, n - 1);
    }
    
    def merge(arr: Array[Long], first: Int, last: Int, pivot: Int): Unit = {
        val tmpArr = (first to pivot).map(arr(_)).toArray;
        var ptr1 = 0;
        var ptr2 = pivot + 1;
        for (i <- (first to last)) {
            if (ptr1 >= tmpArr.length) {
                arr(i) = arr(ptr2);
                ptr2 += 1;
            } else if (ptr2 > last) {
                arr(i) = tmpArr(ptr1);
                ptr1 += 1;
            } else {
                if (arr(ptr2) < tmpArr(ptr1)) {
                    arr(i) = arr(ptr2);
                    ptr2 += 1;
                } else {
                    arr(i) = tmpArr(ptr1);
                    ptr1 += 1;
                }
            }
        }
    }
}



Measured memory_bytes: 456760
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(map(int, input().split()))

a,b = inpl()

if a*b%2 == 0:
	print('Even')
else:
	print('Odd')


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll h, w;
    cin >> h >> w;
    vector<vector<char>> a;
    vector<char> p;

    for (ll i = 0; i < w + 2; i++)
    {
        p.push_back('#');
    }
    a.push_back(p);
    for (ll i = 0; i < h; i++)
    {
        vector<char> t;
        t.push_back('#');
        for (ll k = 0; k < w; k++)
        {
            char temp;
            cin >> temp;
            t.push_back(temp);
        }
        t.push_back('#');
        a.push_back(t);
    }
    a.push_back(p);

    for (auto k : a)
    {
        for (auto p : k)
        {
            cout << p;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int sento;
int data[1000];

void push(int);
int pop();

int main(){
  int change1;
  int change2;
  char set[100];
  sento = 0;

  while(scanf("%s",set) != EOF){
    if(set[0] == '+'){
      change1 = pop();
      change2 = pop();
      push(change1 + change2);
    }
    else if(set[0] == '-'){
      change2 = pop();
      change1 = pop();
      push(change1 - change2);
    }
    else if(set[0] == '*'){
      change1 = pop();
      change2 = pop();
      push(change1 * change2);
    }
    else{
      push(atoi(set));
    }
  }
  printf("%d\n",pop());
  return 0;
}


void push(int x){
  data[++sento] = x;
}

int pop(){
  sento--;
  return data[sento + 1];
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL  0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[2000];
int dp[2000][2000];

signed main(){
	int n;cin>>n;
	rep(i,n)cin>>a[i];
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	rep(i,n)rep(j,n+1){
		rep(k,n+1){
			if(j==k)continue;
			dp[i+1][k]=min(dp[i+1][k],dp[i][j]+(k!=a[i]));
		}
	}
	cout<<*min_element(dp[n],dp[n]+n+1)<<endl;
}

Measured memory_bytes: 15872
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n==0)
			System.out.println("1");
		else if(n==1)
			System.out.println("0");
	}
}

Measured memory_bytes: 35600
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define count_ones __builtin_popcountl
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
/* -------------------------------------- */

/* -------------------------------------- */
int main() {
	boost();
	int n;cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		int j =i,count=0;
		while(j!=0){
			count++;j/=10;
		}
		if(count%2) ans++;
	}cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
	S[++top] = x;
}

int pop(){
	top--;
	return S[top+1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	while( scanf("%s", s )!= EOF ){
		if ( s[0] == '+' ){
			a = pop();
			b = pop();
			push(a + b);
		}else if ( s[0] == '-'){
			b = pop();
			a = pop();
			push(a - b);
		}else if ( s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}
	printf("%d\n",pop());

	return 0;
}


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

#define MOD 1000000007
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  vector<int> ans(n);
  int ord;
  for (int i = 0; i < n; i++) {
    cin >> ord;
    ans.at(ord - 1) = i;
  }
  cout << ans[0] + 1;
  for (int i = 1; i < n; i++) {
    cout << ' ' << ans[i] + 1;
  }
}


Measured memory_bytes: 1152
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
ulong MIDDLE = 100_000;
alias Pair = Tuple!(long, "flag", long, "num");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto s = new long[](n);
    foreach (ref e; s)
        e = lread();
    auto score = s.sum();
    if (!(score % 10))
    {
        long subscore;
        foreach (e; s)
        {
            auto tmp = score - e;
            if (tmp % 10)
                subscore = max(tmp, subscore);
        }
        if(subscore)
            score = subscore;
        else
            score = 0;
    }
    score.writeln();
}


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

#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

const int mod =1e9+7;
int dp[105][100005];
int n,k;
int a[105];

int solve(){
    for(int j=0;j<=k;j++) {
        if(j<=a[1]) dp[1][j]=1;
        else dp[1][j]=0;
    }
    for(int i=2;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(j==0){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=(mod+dp[i][j-1]+ dp[i-1][j]- ((j-1-a[i])>=0 ? dp[i-1][j-1-a[i]] : 0))%mod;
            }
        }
    }
    return dp[n][k];
}
int32_t main(){
    
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    cout<<solve();

}

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

#define endl '\n'

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

    string s;
    cin >> s;
    for(int i = 0; i < 4; i++) {
        s[i] -= '0';
    }
    for(int op = 0; op < (1 << 3); op++) {
        int v = s[0];
        string res = "";
        res += (s[0] + '0');
        for(int i = 0; i <= 2; i++) {
            if((1 << i) & op) {
                v += s[i + 1];
                res += "+";
            }
            else {
                v -= s[i + 1];
                res += "-";
            }
            res += (s[i + 1] + '0');
        }
        if(v == 7) {
            cout << res << "=7";
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N, W;
	cin >> N >> W;
	int w[110], v[110];
	for (int i = 0; i < N; ++i)cin >> w[i] >> v[i];
	ll dp[110][100100];//dp[i][j]でi個目で価値の総和がjの時の重さの最小値
	for (int i = 0; i < 110; ++i) {
		for (int j = 0; j < 100100; ++j) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 100100; ++j) {
			if (v[i] <= j) {
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= 100100; ++i) {
		if (dp[N][i] <= W) {
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 86272
public class Main {
 public static void main(String[] args) {
		java.util.Scanner scanner = new java.util.Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		if (a <= 5) {
			System.out.println(0);
		} else if (a <= 12) {
			System.out.println(b / 2);
		} else {
			System.out.println(b);
		}
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

struct node{
  int p;
  int left;
  int right;
};

int n;
struct node A[10000];

void preParse(int );
void inParse(int );
void postParse(int );

int main(){
  int id, left, right, root;
  int i, j, k, x, y;
  
  scanf("%d",&n);
  if(n<1 || n>25) exit(1);
  
  for(i=0; i<n; i++) A[i].p = -1;
  
  for(i=0;i<n;i++){
    scanf("%d %d %d", &id, &left, &right);
    A[id].left = left;
    A[id].right = right;
    k = 0;
    if( right != -1 ) A[right].p = id;
    x = 0;
    if( left != -1 ) A[left].p = id;
    y = 0;
  }

  for(i=0; i<n; i++)
    if(A[i].p == -1) root = i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  
return 0;
}

void preParse(int root){
  int i;
  
  if(root == -1) return;
  printf(" %d", root);
  preParse(A[root].left);
  preParse(A[root].right);

  i = 0;
  
  return ;
}

void inParse(int root){
  int j;
  
  if(root == -1) return;
  inParse(A[root].left);
  printf(" %d", root);
  inParse(A[root].right);

  j =0;
  
  return ;
}

void postParse(int root){
  int k;
  
  if(root == -1) return;
  postParse(A[root].left);
  postParse(A[root].right);
  printf(" %d", root);

  k = 0;
  
  return ;
}



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

using namespace std;

const int N = 5;

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

    int ans = 0, minmod = 10;
    for (int i = 0; i < N; i++) {
        if (a[i] % 10 != 0) {
            ans += a[i] / 10 * 10 + 10;
            minmod = min(minmod, a[i] % 10);
        } else {
            ans += a[i];
        }
    }

    ans -= 10 - minmod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split(' ').map(&:to_i)

es = []
m.times do
  es << gets.chomp.split(' ').map { |v| v.to_i - 1 }
end
g = (0...n).map { [0] * n }
es.each do |e|
  g[e[0]][e[1]] = 1
  g[e[1]][e[0]] = 1
end

answer = 0
es.each do |e|
  g[e[0]][e[1]] = 0
  g[e[1]][e[0]] = 0

  q = [0]
  visited = [0]
  until q.empty?
    v = q.shift
    (0...n).select { |i| g[v][i] == 1 }.each do |i|
      next if visited.include?(i)
      visited << i
      q.push(i)
    end
  end
  answer += 1 if visited.length < n

  g[e[0]][e[1]] = 1
  g[e[1]][e[0]] = 1
end

puts answer


Measured memory_bytes: 1916
S = gets.chomp

ans = 0
max = 0
S.chars.each do |s|
  if s == 'A'
    ans += 1
  elsif s == 'T'
    ans += 1
  elsif s == 'C'
    ans += 1
  elsif s == 'G'
    ans += 1
  else
    if ans > max
      max = ans
    end
    ans = 0
  end
end

puts [ans, max].max


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

int main(void){
		int m,f,r;
		while(1){
				cin >> m >> f >>r;
				if(m == -1 && f == -1 && r == -1) break;
				if( m == -1 || f == -1){
						cout << "F" <<endl;
				}else if( m + f >= 80){
						cout << "A" << endl;
				}else if( m + f >= 65){
						cout << "B" << endl;
				}else if( m + f >= 50 || r >= 50){
						cout << "C" << endl;
				}else if( m + f >= 30){
						cout << "D" << endl;
				}else
						cout << "F" << endl;
		}
		return 0;
}

				

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
	int N,M,R,L,Lmax,Rmin;
	scanf("%d %d",&N,&M);
	scanf("%d %d",&Lmax,&Rmin);
	for(int i=0;i<M-1;i++)
	{
		scanf("%d %d",&L,&R);
		if(Lmax<L)Lmax=L;
		if(Rmin>R)Rmin=R;
	}
	if(Rmin-Lmax<0)printf("0");
	else printf("%d",Rmin-Lmax+1);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

    //input
    int x = sc.nextInt();

    //output
    /*
    int value = (int)(x/100);
    if( value == 4 || value == 5 ){
      System.out.println("8");
    }else if( value == 6 || value == 7 ){
      System.out.println("7");
    }else if( value == 8 || value == 9 ){
      System.out.println("6");
    }else if( value == 10 || value == 11 ){
      System.out.println("5");
    }else if( value == 12 || value == 13 ){
      System.out.println("4");
    }else if( value == 14 || value == 15 ){
      System.out.println("3");
    }else if( value == 16 || value == 17 ){
      System.out.println("2");
    }else if( value == 18 || value == 19 ){
      System.out.println("1");
    }
    */

    int value = (int)(x/100);

    int rank = 8;
    int lowerVal = 4;
    int higherVal = 5;

    while( rank > 0 ){
      if( value == lowerVal || value == higherVal ){
        System.out.println(rank);
        break;
      }
      lowerVal += 2;
      higherVal += 2;
      rank--;
    }

  }
}


Measured memory_bytes: 27016
import collections

N=int(input())
D=list(map(int,input().split()))

c=collections.Counter(D)

max_D=max(D)
ans=1
previous_leaf=1

if D[0]!=0:
    ans=0
elif c[0]!=1:
    ans=0
else:
    for i in range(1,max_D+1):
        ans*=(previous_leaf**c[i])
        ans%=998244353
        previous_leaf=c[i]

print(ans)

Measured memory_bytes: 19936
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final long N = Long.parseLong(sc.next());
        long blue = Long.parseLong(sc.next());
        long red = Long.parseLong(sc.next());
        
        out.println(N / (blue + red) * blue + Math.min(blue, N % (blue + red)));
        
        out.flush();
    }
}

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

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        //4棟・3階・10部屋の3次元配列
        int[][][] array = new int[4][3][10];
        
        for(int i=0;i<n;i++){
            //棟
            int b = Integer.parseInt(sc.next());
            //階
            int f = Integer.parseInt(sc.next());
            //部屋
            int r = Integer.parseInt(sc.next());
            //人数
            int v = Integer.parseInt(sc.next());
            //3次元配列に人数を追加
            int before = array[b-1][f-1][r-1];
            array[b-1][f-1][r-1] = before + v;
        }
        //出力
        //棟
        for(int i=0; i<4; i++){
            //階
            for(int j=0; j<3; j++){
                //部屋
                for(int k=0; k<10; k++){
                    System.out.print(" "+array[i][j][k]);
                }
                System.out.println("");
            }
            if(i<3)System.out.println("####################");
        }
        
    }

}



Measured memory_bytes: 28864
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int h,w,i;
  string s;
  cin >> h >> w;
  for(i=0;i<w+2;i++)
    cout << "#";
  cout << endl;
  for(i=0;i<h;i++){
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  for(i=0;i<w+2;i++)
    cout << "#";
  cout << endl;
  return 0;
}

Measured memory_bytes: 3596
n, k = map(int, input().split(" "))
nums = list(map(int, input().split(" ")))

nums_len = len(nums)

count = 0

index = nums.index(1)

former = index
later = nums_len - index - 1

former_c = (former + (k-2)) // (k-1)
later_c = (later + (k-2)) // (k-1)

f_mod = ((k-1) - former % (k-1)) % (k-1)
l_mod = ((k-1) - later % (k-1)) % (k-1)


count = former_c + later_c

if f_mod + l_mod >= k - 1:
    count -= 1

print(count)


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

using namespace std;

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    int counter=0,ans=10101;
    for(int i=a;i>=1;i--){
        if(a%i==0 && b%i==0){
            counter+=1;
            if(counter==k){
                ans=i;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

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

	int n;
	cin >> n;

	vector<int> l(n);

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

	sort(l.begin(), l.end());
	int ans = 0;

//	for(int i : l) cout << i << " ";
//	cout << endl;

	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int a = l[i], b = l[j];

			int pos = lower_bound(l.begin() + j + 1, l.end(), a + b) - l.begin();
//			cout << a + b << " " << pos << endl;

			ans += max(0, pos - 1 - j);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)

hash = {}
a_arr.each do |a|
  hash[a] ||= 0
  hash[a] += 1
  hash[a] %= 2
end

count = 0
even_num = 0
hash.each do |k, v|
  count += 1
  even_num += 1 if v % 2 == 0
end

if even_num % 2 == 1
  count -= 1
end

puts count


Measured memory_bytes: 25728
import sys

N = int(sys.stdin.readline())

S = input()

if N %2 == 1:
    print("No")
    sys.exit()
else:
    halfN = int(N/2)
    str1 = S[:halfN]
    str2 = S[halfN:]
    if str1 == str2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
n = int(input())
s = input()
listA=[0]
for i in range(n):
  if s[i]=="I":
    listA.append(listA[i]+1)
  elif s[i]=="D":
    listA.append(listA[i]-1)
listA.sort(reverse=True)
print(listA[0])

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int h,w,s;
int rem;
int u[35][35];
int rui[35][35];
P dp[35][35][35][35];
inline int sum(int t,int b,int l,int r){
	return rui[b][r]-rui[t-1][r]-rui[b][l-1]+rui[t-1][l-1];
}
P rec(int t,int b,int l,int r){
	if(dp[t][b][l][r]!=P(-1,-1))return dp[t][b][l][r];
	if(sum(t,b,l,r)<rem)return dp[t][b][l][r]=P(-INF,-INF);
	P ret = P(1,sum(t,b,l,r));
	for(int i=t;i<b;i++){
		rec(t,i,l,r);
		rec(i+1,b,l,r);
		int num = dp[t][i][l][r].fi+dp[i+1][b][l][r].fi;
		int smallest = min(dp[t][i][l][r].sec,dp[i+1][b][l][r].sec);
		if(num<0)continue;
		if(num>ret.fi){
			ret.fi = num;
			ret.sec = smallest;
		}else if(num==ret.fi){
			if(ret.sec<smallest)ret.sec = smallest;	
		}
	}
	for(int i=l;i<r;i++){
		rec(t,b,l,i);
		rec(t,b,i+1,r);
		int num = dp[t][b][l][i].fi+dp[t][b][i+1][r].fi;
		int smallest = min(dp[t][b][l][i].sec,dp[t][b][i+1][r].sec);
		if(num<0)continue;
		if(num>ret.fi){
			ret.fi = num;
			ret.sec = smallest;
		}else if(num==ret.fi){
			if(ret.sec<smallest)ret.sec = smallest;	
		}
	}
	//printf("t:%d b:%d l:%d r:%d number:%d smallest:%d\n",t,b,l,r,ret.fi,ret.sec);
	return dp[t][b][l][r]=ret;
}	
int solve(){
	scanf("%d %d %d",&h,&w,&s);
	if(h+w+s==0)return 1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%d",&u[i][j]);
			rui[i][j]=u[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			rui[i][j]+=rui[i][j-1];
		}
	}
	for(int j=1;j<=w;j++){
		for(int i=1;i<=h;i++){
			rui[i][j]+=rui[i-1][j];
		}
	}
	rem = sum(1,h,1,w)-s;
	for(int i=0;i<35;i++){
		for(int j=0;j<35;j++){
			for(int k=0;k<35;k++){
				for(int l=0;l<35;l++){
					dp[i][j][k][l]=P(-1,-1);
				}
			}
		}
	}
	/*while(1){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		cout << sum(a,b,c,d) << endl;
	}*/
	P ans = rec(1,h,1,w);
	printf("%d %d\n",ans.fi,s-(sum(1,h,1,w)-ans.sec));
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

Measured memory_bytes: 14936
#include<iostream>
using namespace std;
int main()
{int a,b,c;
 cin>>a;
 cin>>b;
 cin>>c;
 int one,r,two=0;
 one=b;
 two=c;
 r=a-b;
 if(r<c)
   r=c-r;
 else
   r=0;
 cout<<r;
  
  
  
  return 0;
 
}

Measured memory_bytes: 256
#include <cstdio>

int N, K;
int a[100];
bool dp[100001][2];

int main(){

    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; i++){
        scanf("%d", &a[i]);
    }

    for(int i = 0; i <= K; i++){
        dp[i][0] = false;
        dp[i][1] = true;
    }

    for(int i = a[0]; i <= K; i++){
        for(int j = 0; j < N; j++){
            int temp = a[j];
            if(temp > i){
                break;
            }
            else{
                if(dp[i - temp][1]){
                    dp[i][0] = true;
                }
                if(!dp[i - temp][0]){
                    dp[i][1] = false;
                }
            }
        }
    }

    if(dp[K][0]){
        printf("First\n");
    }
    else{
        printf("Second\n");
    }

    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    bool water[f + 1] = {}, sugger[f + 1] = {};
    set<int> w, s;
    water[0] = sugger[0] = true;
    s.insert(0);
    rep(i, f + 1) {
        if (water[i] && i + 100 * a <= f) {
            water[i + 100 * a] = true;
            w.insert(i + 100 * a);
        }
        if (water[i] && i + 100 * b <= f) {
            water[i + 100 * b] = true;
            w.insert(i + 100 * b);
        }
        if (sugger[i] && i + c <= f) {
            sugger[i + c] = true;
            s.insert(i + c);
        }
        if (sugger[i] && i + d <= f) {
            sugger[i + d] = true;
            s.insert(i + d);
        }
    }
    int p = 100 * a, q = 0;
    double maxi = 0;
    each(i, w)each(j, s) {
        if (i * e / 100 < j || i + j > f) break;
        if (maxi < (double)j / (double)(i + j)) {
            maxi = (double)j / (double)(i + j);
            p = i + j, q = j;
        }
    }
    cout << p << " " << q << endl;
    return 0;
}

Measured memory_bytes: 384
S=input()
mx=0
a=len(S)
for i in range(0,a):
  for j in range(1,a+1):
    x=S[i:j]
    f=False
    for y in x:
      if y not in 'ACGT':
        f=True
    if not f:
      mx=max(mx,len(x))
print(mx)

Measured memory_bytes: 3060