akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>

using namespace std;

int y,m,d;

int eraname(){
  string str = "";
  int data[3] = {d,m,y};
  for(int i = 0; i < 3; i++){
    int flg = 0;
    if(data[i] < 10) flg = 1;
    while(data[i]){
      str += data[i]%10+'0';
      data[i]/=10;
    }
    if(flg) str += "0";
  }
  reverse(str.begin(),str.end());
  // cout<< "str  " << str << endl;
  if(str < "18680908") return -1;
  if(str < "19120730") return 1868;
  if(str < "19261225") return 1912;
  if(str < "19890108") return 1926;
  return 1989;
  
}

void printera(int num){
  if(num == -1) cout << "pre-meiji" << endl;
  if(num == 1868) cout << "meiji ";
  if(num == 1912) cout << "taisho ";
  if(num == 1926) cout << "showa ";
  if(num == 1989) cout << "heisei ";
}
int main(){
  while(cin >> y >> m >> d){
    int now = eraname();
    printera(now);
    if(now != -1)
      cout << y-now+1 << " " << m << " "<<d << endl;
  }
  return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var S string
	var N, x, max int

	fmt.Scan(&N)
	fmt.Scan(&S)
	
	for i := 0; i < N; i++ {
		if S[i] == 'I' {
			x++
		} else if S[i] == 'D' {
			x--
		}

		if max < x {
			max = x
		}
	}
	
	fmt.Println(max)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define X first
#define Y second
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n;
string a, b, c;

int main () {

	cin >> n >> a >> b >> c;
	int sol = 0;
	for (int i = 0; i < n; i ++) {
		if (a[i] == b[i] && a[i] == c[i]) {}
		else if (a[i] == b[i] && a[i] != c[i]) {
			sol ++;
		}
		else if (a[i] == c[i] && a[i] != b[i]) {
			sol ++;
		}
		else if (b[i] == c[i] && b[i] != a[i]) {
			sol ++;
		}
		else {
			sol += 2;
		}
	}
	
	cout << sol;

	return 0;
}

Measured memory_bytes: 256
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    N := nextInt()
    K := nextInt()
    X := nextInt()
    Y := nextInt()

    l := (N - K)
	if l < 0 {
		l = 0
	}
	if N < K {
		K = N
	}
	fmt.Println(K * X + l * Y)
     
    
}
 
/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


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

int main(){
	long long int n;
	cin>>n;
	for(long long int i = n/4; i<=3500; i++){
		for(long long int j = i+1; j<=3500; j++){
			if((4*i*j - i*n - j*n) <= 0) continue;
			long long int w = (n*i*j)/(4*i*j - i*n - j*n);
			if ((n*i*j)%(4*i*j - i*n - j*n) == 0){
				cout<<i<<" "<<j<<" "<<w<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
	int n;
	while(std::cin>>n, n){
		int pm, pe, pj;
		for(int i = 0; i < n; ++i){
			std::cin>>pm>>pe>>pj;
			if((pm == 100 || pe == 100 || pj == 100) || (pm+pe >= 180) || (pm+pe+pj >= 240))std::cout<<'A'<<std::endl;
			else if(pm+pe+pj>=210 || (pm+pe+pj>=150 && pm >= 80 || pe >= 80))std::cout<<'B'<<std::endl;
			else std::cout<<'C'<<std::endl;
		}
	}
}

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

int main() {
    int64_t x;
    cin >> x;

    vector<int64_t> pow_5(205, 0);
    for(int64_t i = 0; i <= 200; i++) pow_5[i] = i * i * i * i * i;

    for(int i = 0; i <= 200; i++) {
        for(int j = 0; j <= 200; j++) {
            if(pow_5[i] - pow_5[j] == x) {
                cout << i << " " << j << endl;
                return 0;
            } else if(pow_5[i] + pow_5[j] == x) {
                cout << i << " " << -j << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int k,a,b,i,z,m=0;
    scanf("%d %d %d",&k,&a,&b);
    for(i=a; i<=b; i++){

        if(i%k==0){printf("OK\n");m=1;break;}
    }
    if(m==0)printf("NG\n");
return 0;
}


Measured memory_bytes: 1644
<?php
fscanf(STDIN, "%d %d %d %d", $tHp, $tAt, $aHp, $aAt);

// 両者のHPが残存している場合にバトル成立
while($tHp > 0 && $aHp > 0){
  
  // 高橋の攻撃 両者のHPが残存している場合に、攻撃が成立
  if($tHp > 0 && $aHp > 0){
	$aHp = $aHp - $tAt;
}
   // 青木の攻撃 両者のHPが残存している場合に、攻撃が成立
  if($aHp > 0 && $tHp > 0){
	$tHp = $tHp - $aAt;
}
}

if($tHp <= 0){
	echo 'No';
}elseif($aHp <= 0){
	echo 'Yes';
}

Measured memory_bytes: 16156
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

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

int main() {
  int n;
  cin >> n;
  ll a[n];
  REP(i, n) cin >> a[i];
  ll sum[n + 1];
  sum[0] = 0;
  REP(i, n) sum[i + 1] = sum[i] + a[i];
  map<ll, ll> mp;
  REP(i, n + 1) mp[sum[i]]++;
  ll ans = 0;
  for (auto a : mp) ans += a.second * (a.second - 1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;




int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    if(m>n) swap(n,m);
    
    if(n>m+1){
        cout<<0;
        return 0;
    }
    long long ans=1;
    while(n){
        ans*=n;
        ans%=MOD;
        if(m) ans*=m;
        ans%=MOD;
        n--,m--;
    }
    if(n==m) cout<<2*ans%MOD;
    else cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

int N;
while(1){
scanf("%d",&N);if(N==0)break;
int n[102]={};
bool f=false;int  k=N;int y;
for(int i=0;i<N;i++)
{
scanf("%d",&y);
if(y>1)f=true;
if(y==0)k--;
}
if(f==false)printf("NA\n");
else{printf("%d\n",k+1);
}
}
return 0;
}

Measured memory_bytes: 1040
/**
*    author:  boutarou
*    created: 14.06.2020 21:01:10
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const double PI = 3.1415926535897932;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x, y;
	cin >> x >> y;
	rep(i, 100) {
		rep(j, 100) {
			if (i + j == x && i * 2 + j * 4 == y) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main{
  static int x;

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

    x = sc.nextInt();
    if(x < 1200){
      System.out.println("ABC");
    }
    else{
      System.out.println("ARC");
    }
  }
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int A, B; cin >> A >> B;
	
	REP(i,100000){
		int x = i * 108 / 100 - i;
		int y = i * 110 / 100 - i;

		if(x == A and y == B){
			cout << i << endl;
			return 0;
		}


	}

	cout << -1 << endl;

	return 0;

}


Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))

count = 0
for i in range(n):
  a = list(map(int, input().split()))
  total = c 
  for j in range(len(b)):
    total += a[j] * b[j]

  if total > 0:
    count += 1

print(count)

Measured memory_bytes: 3060
#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>;



int64_t stoint64(string s) {
    int64_t ret = 0;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        ret += (s[i] - '0') * pow(10, n-i-1);
    }
    return ret;
} 

void make_runrun(string a, vector<int64_t> &runrun) {
    if (a.back() == '0') {
        string a2 = a;
        a.push_back('1');
        a2.push_back('0');
        runrun.push_back(stoint64(a));
        runrun.push_back(stoint64(a2));
        if (a.size() > 10) return;
        else {
            make_runrun(a, runrun);
            make_runrun(a2, runrun);
        }
    }
    else if (a.back() == '9') {
        string a2 = a;
        a.push_back('8');
        a2.push_back('9');
        runrun.push_back(stoint64(a));
        runrun.push_back(stoint64(a2));
        if (a.size() > 10) return;
        else {
            make_runrun(a, runrun);
            make_runrun(a2, runrun); 
        }
    }
    else {
        char c = a.back();
        string a2 = a;
        string a3 = a;
        a.push_back(c - 1);
        a2.push_back(c);
        a3.push_back(c + 1);
        runrun.push_back(stoint64(a));
        runrun.push_back(stoint64(a2));
        runrun.push_back(stoint64(a3)); 
        if (a.size() > 10) return;
        else {
            make_runrun(a, runrun);
            make_runrun(a2, runrun);
            make_runrun(a3, runrun);
        }
    }

}


int main() {
    int k;
    cin >> k;
    vector<int64_t> runrun;
    for (int i = 1; i <= 9; i++) {
        runrun.push_back(i);
        make_runrun(to_string(i), runrun);
    }
    sort(runrun.begin(), runrun.end());
    int64_t ans = runrun[k-1];
    cout << ans << endl;
}

Measured memory_bytes: 10480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  ll t = min(a, k);
  a -= t;
  k -= t;
  t = min(b, k);
  b -= t;
  k -= t;
  cout << a << " " << b << endl;
} 

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

typedef int Int;
typedef string::const_iterator Iter;

Int eval(const string&);
Int expr(Iter&);
Int term(Iter&);
Int factor(Iter&);
Int number(Iter&);

Int eval(const string &s){
	Iter it = s.begin();
	return expr(it);
}

Int expr(Iter &it){
	Int res = term(it);
	while (true){
		if (*it == '+'){
			++it;
			res += term(it);
		}
		else if (*it == '-'){
			++it;
			res -= term(it);
		}
		else return res;
	}
}

Int term(Iter &it){
	Int res = factor(it);
	while (true){
		if (*it == '*'){
			++it;
			res *= factor(it);
		}
		else if (*it == '/'){
			++it;
			res /= factor(it);
		}
		else return res;
	}
}

Int factor(Iter &it){
	if (*it == '('){
		++it;
		Int res = expr(it);
		++it;
		return res;
	}
	else return number(it);
}

Int number(Iter &it){
	Int res = 0;
	while (isdigit(*it)){
		res = res * 10 + (*it - '0');
		++it;
	}
	return res;
}

int main()
{
	int n;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++){
		string s;
		getline(cin, s);
		cout << eval(s) << endl;
	}
}

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

int main(){
    string a, b;
    cin >> a >> b;

    int ab = stoi(a + b);
    for (int i = 0; i <= 1000; i++){
        if(i * i == ab){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
type stack = ST of int * stack | NULL

let a_ = read_line () |> Str.split (Str.regexp " ") 
|> Array.of_list
let n = Array.length a_

let to_int st =
 match st with 
  ST (num1, ST (num2, s)) -> (num1, num2, s)
  |_ -> (0, 0, NULL)

let rec f a i st n =
 if i = n then 
  match st with
  ST (num, _) -> num
  |_ -> -1
 else if a.(i) = "+" then 
  let (num1, num2, s) = to_int st in
  f a (i+1) (ST (num1+num2, s)) n
 else if a.(i) = "-" then
  let (num1, num2, s) = to_int st in
  f a (i+1) (ST (num2-num1, s)) n
 else if a.(i) = "*" then
  let (num1, num2, s) = to_int st in
  f a (i+1) (ST (num1*num2, s)) n
 else let num = int_of_string a.(i) in
      f a (i+1) (ST (num, st)) n

let () =
 let n = Array.length a_ in
 f a_ 0 NULL n |> Printf.printf "%d\n" 

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

#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second

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

using namespace std;


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

   ll N; cin >> N;
   ll sum = 0;
   ll aux = N;
   while(aux > 0){
      sum+= aux%10;
      aux/=10;
   }
   if(N % sum == 0){
      cout << "Yes";
   }else{
      cout << "No";   
   }
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve()
{
    ll n,q,sum=0;
    cin>>n;
    ll arr[n+5];
    map<ll,ll>mp;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
        mp[arr[i]]++;
        sum+=arr[i];
    }
//    cout<<sum<<endl;
    cin>>q;
    while(q--)
    {
        ll b1,c1;
        cin>>b1>>c1;
        mp[c1]+=mp[b1];
        ll extra=mp[b1]*(c1-b1);
        mp[b1]=0;
        sum+=extra;
        cout<<sum<<endl;

    }


}

int main()
{
    int x,t;
    solve();

}





Measured memory_bytes: 10240
#include<iostream>
using namespace std;
int main(){
    int n,m;
    int a[1000],face;
    while(cin>>n>>m,n||m){
        int i;
        for(i=0;i<n;i++)cin>>a[i];
        int ans,pos=0;
        for(i=0;i<m;i++){
            cin>>face;
            pos += face;
            if(n-1<=pos){
                ans=i+1;
                break;
            }
            pos += a[pos];
            if(n-1<=pos){
                ans=i+1;
                break;
            }
        }
        for(i++;i<m;i++){
            cin>>face;
        }
        cout<<ans<<endl;
    }
    return 0;
}


 

Measured memory_bytes: 1164
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n;
	cin>>n;
	vector<string> s(n);
	vector<ll> t(n);
	REP(i,n){
		cin>>s[i];
		cin>>t[i];
	}
	string x;
	cin>>x;
	auto it=find(s.begin(),s.end(),x);
	ll st=it-s.begin();
	ll ans=0;
	FOR(i,st+1,n){
		ans+=t[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int n,m,a,b;
int cnt[100010];
int main(){
	cin>>n>>m;
	for(int i=0;i<=n;i++)cnt[i]=0;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		cnt[a]++,cnt[b]++;
	}
	bool ok=true;
	for(int i=0;i<=n;i++){
		if(cnt[i]%2==1)ok=false;
	}
	if(ok)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 640
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter O3 '(optimize (speed 3) (safety 0) (debug 0)))
  (defparameter O2 '(optimize (speed 3) (safety 1))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(deftype unum nil `(integer 0 ,(expt 10 9)))
(defun main ()
  (let ((n (read)))
    (loop repeat n
       do (when (eql (read) 'Y)
	    (print-line "Four")
	    (return-from main))
       finally (print-line "Three")
	 )))

#-swank(main)


;; Für Test
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

(defun test ()
  (with-input-from-string (*standard-input* (delete #\return (get-clipbrd)))
    (main)))


;; Für Benchmark
(defparameter *file-path* *load-pathname*)
(defparameter *dir-path* (pathname (directory-namestring *file-path*)))
(defparameter *dat-path* (merge-pathnames "test.dat" *dir-path*))

#+swank
(defun gendat ()
  (with-open-file (out *dat-path*
		       :direction :output :if-exists :supersede)
    ))

(defun bench ()
  (let ((*standard-output* (make-broadcast-stream)))
    (with-open-file (*standard-input* *dat-path*)
      (time (main)))))


Measured memory_bytes: 16736
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,a[101],b[101],_min,_max;
int main()
{
	cin>>n>>m>>x>>y;
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=m;i++)	cin>>b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	for(int i=x+1;i<=y;i++)
	{
		if(a[n]<i&&b[1]>=i)
		{
			puts("No War");
			return 0;
		}
	}
	puts("War");
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def is_prime(n):
        if n == 1:
            return False
        for k in range(2, int(pow(n, 0.5)) + 1):
            if n % k == 0:
                return False
        return True

    n = int(input())

    res = []
    for i in range(2, 55556):
        if is_prime(i):
            if i % 5 == 1:
                res.append(i)
        if len(res) == n:
            print(*res)
            break


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
  {
    long int n;
    scanf("%ld",&n);
    long int o=n;
    int s=0;
    while(n!=0)
    {
       s+=n%10;
       n/=10;
    }
  
    if((o%s)==0)
        printf("Yes");
  
    else
       printf("No");
           
  
  }

Measured memory_bytes: 256
import java.util.*;

class Main {

  static char n[];
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    n = sc.next().toCharArray();
    System.out.println(solve(0, 0, 0));
  }
  
  static long solve(int i, long a, long sum) {
    if (i == n.length) return a + sum;
    return solve(i + 1, a * 10 + Integer.valueOf(n[i]-'0'), sum) + solve(i + 1, 0, sum + a);
  }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {
        int itemCount = int.Parse(Console.ReadLine());
        int[] items = new int[itemCount];
        string[] inpt = Console.ReadLine().Split(' ');
        for(int i=0; i<itemCount; i++)
        {
            items[i] = int.Parse(inpt[i]);
        }

        int targetCount = int.Parse(Console.ReadLine());
        int[] targetList = new int[targetCount];

        inpt = Console.ReadLine().Split(" "[0]);
        for(int i=0; i<targetCount; i++)
        {
            targetList[i] = int.Parse(inpt[i]);
        }

        // ?????????????????????
        Array.Sort(items);
        this.Parts = new int[itemCount];
        for(int i=0; i<itemCount; i++)
        {
            Parts[i] = items[itemCount - 1 - i];
        }


        for(int i=0; i<targetCount; i++)
        {
            bool ret = this.CanGet(0, targetList[i]);
            Console.WriteLine(ret ? "yes" : "no");
        }

    }

    private int[] Parts;

    private Dictionary<int, Dictionary<int, bool>> dic = new Dictionary<int, Dictionary<int, bool>>();
    private bool CanGet(int idx, int num)
    {
        if(dic.ContainsKey(idx) && dic[idx].ContainsKey(num))
        {
            return dic[idx][num];
        }
        bool isMatch = false;

        for(int i=idx; i<Parts.Length; i++)
        {
            if(Parts[i] > num)
            {
                // ???????????????
            } else if(Parts[i] == num)
            {
                isMatch = true;
                break;
            } else
            {
                bool ret = this.CanGet(i + 1, num - Parts[i]);
                if(ret)
                {
                    isMatch = true;
                    break;
                }
            }
        }
        if (!dic.ContainsKey(idx))
        {
            dic.Add(idx, new Dictionary<int, bool>());
        }
        dic[idx].Add(num, isMatch);
        return isMatch;
    }

    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 10676
#include <stdio.h>
#include <stdlib.h>
 
typedef struct node{
    int p;
    int left;
    int right;
} Node;
 
int searchHight(int);
 
Node *tree;
 
int main(){
     
    int n,i,id,depth,tmpP,deg,nowNode,sibling;
 
    scanf("%d", &n);
 
    tree = malloc(sizeof(Node)*n);
 
    for (i = 0; i < n; ++i){
        tree[i].p = -1;
    }
 
    for (i = 0; i < n; ++i){
        scanf("%d",&id);
        scanf("%d%d",&tree[id].left,&tree[id].right);
        tree[tree[id].left].p = id;
        tree[tree[id].right].p = id;
    }
 
    nowNode = 0;
    while(1){
        if (tree[nowNode].left != -1 && tree[nowNode].right != -1)
        {
            break;
        } else if (tree[nowNode].left == -1)
        {
            nowNode = tree[nowNode].right;
        } else {
            nowNode = tree[nowNode].left;
        }
    }
 
    for (i = 0; i < n; ++i){
         
        tmpP = tree[i].p;
        if (tmpP == -1) sibling = -1;
        else if(tree[tmpP].left == i) sibling = tree[tmpP].right;
        else sibling = tree[tmpP].left;
 
        depth = 0;
        while(tmpP != -1){
            tmpP = tree[tmpP].p;
            depth++;
        }
 
        deg = 0;
        if (tree[i].left != -1) deg++;
        if (tree[i].right != -1) deg++;
 
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].p,sibling,deg,depth,searchHight(i));
 
        if(tree[i].p == -1) printf("root\n");
        else if(tree[i].left == -1 && tree[i].right == -1) printf("leaf\n");
        else printf("internal node\n");
    }
 
    return 0;
}
 
int searchHight(int index){
    int hLeft = 0;
    int hRight = 0;
 
    if (tree[index].left != -1){
        hLeft = searchHight(tree[index].left) +1;
    }
    if (tree[index].right != -1){
        hRight = searchHight(tree[index].right) +1;
    }
    if (hLeft < hRight) return hRight;
    else return hLeft;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 15, msksz = (1 << nsz) - 1, inf = 0x3f3f3f3f;
int n, m, to, sum, id[msksz + 5], g[nsz + 5][nsz + 5];
int dp[msksz + 5][nsz + 5], ts[msksz + 5][nsz + 5], s[msksz + 5], ans;

void inline link(int u, int v, int w) {
    g[u][v] = g[v][u] = w;
}

string inline str(int S) {
    string s;
    loop (i, n) {
        s += ((S >> i) & 1) + 48;
    }
    return s;
}

void inline init() {
    loop (i, n) {
        id[1 << i] = i;
    }
}

void inline upd(int &a, int b) {
    a < b && (a = b);
}

int main() {
    ios::sync_with_stdio(0);
    cin >> n >> m;
    init();
    to = (1 << n) - 1;
    cont (i, m) {
        int u, v, w;
        cin >> u >> v >> w;
        --u, --v;
        link(u, v, w);
        sum += w;
    }
    circ (S, 0, to) {
        int sum = 0;
        for (int t = S, d1 = t & -t; d1; t -= d1, d1 = t & -t) {
            int u = id[d1];
            for (int t = S, d2 = t & -t; d2; t -= d2, d2 = t & -t) {
                int v = id[d2];
                sum += (u < v) * g[u][v];
            }
        }
        s[S] = sum;
    }
    circ (S, 0, to) {
        int rS = to ^ S;
        for (int t = rS, d2 = t & -t; d2; t -= d2, d2 = t & -t) {
            int u = id[d2], sum = 0;
            for (int t = S, d1 = t & -t; d1; t -= d1, d1 = t & -t) {
                int v = id[d1];
                sum += g[u][v];
            }
            ts[S][u] = sum;
        }
    }
    memset(dp, -inf, sizeof(dp));
    dp[1][0] = 0;
    circ (S, 0, to) {
        if (!(S & 1))  continue;
        int rS = to ^ S;
        for (int tS = rS; tS; tS = rS & (tS - 1)) {
            if ((tS >> (n - 1)) & 1)  continue;
            int mx = 0;
            for (int t = S, d = t & -t; d; t -= d, d = t & -t) {
                int u = id[d];
                upd(mx, ts[tS][u]);
            }
            for (int t = S, d = t & -t; d; t -= d, d = t & -t) {
                int u = id[d];
                upd(dp[S | tS][u], dp[S][u] + mx + s[tS]);
            }
        }
        for (int t = S, d1 = t & -t; d1; t -= d1, d1 = t & -t) {
            int u = id[d1];
            for (int t = rS, d2 = t & -t; d2; t -= d2, d2 = t & -t) {
                int v = id[d2];
                if (!g[u][v])  continue;
                upd(dp[S | (1 << v)][v], dp[S][u] + g[u][v]);
            }
        }
    }
    circ (S, 0, to) {
        upd(ans, dp[S][n - 1]);
    }
    cout << sum - ans << ln;
}

Measured memory_bytes: 5632
#include <cstdio>
#include <cmath>
#include <queue>
#include <limits>
using namespace std;

typedef pair<double, int> P;

int x[1002], y[1002], r[1002];
double cost[1002][1002];
bool fixed[1002];
double d[1002];

int main()
{
    scanf("%d%d%d%d", &x[0], &y[0], &x[1], &y[1]);
    r[0] = r[1] = 0;

    int N;
    scanf("%d", &N);
    N += 2;
    for (int i = 2; i < N; i++)
        scanf("%d%d%d", &x[i], &y[i], &r[i]);

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cost[i][j] = max(hypot(x[i] - x[j], y[i] - y[j]) - r[i] - r[j], 0.);

    fill(fixed, fixed + N, false);
    fill(d, d + N, numeric_limits<double>::infinity());
    d[0] = 0;
    while (true) {
        int v = -1;
        for (int i = 0; i < N; i++) {
            if (!fixed[i] && (v == -1 || d[i] < d[v]))
                v = i;
        }
        if (v == -1)
            break;
        fixed[v] = true;
        for (int i = 0; i < N; i++) {
            d[i] = min(d[i], d[v] + cost[v][i]);
        }
    }

    printf("%.12f\n", d[1]);
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;
const int N = 6006;

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

    vector<pi> p(n);
    rep(i,n){
        int a,b;
        cin >>a >>b;
        p[i]={a,b};
    }
    sort(all(p));

    vector<int> dp(N);
    rep(i,n){
        int a = p[i].fi, b = p[i].se;
        for(int j=t-1; j>=0; --j){
            int nj = j+a;
            dp[nj] = max(dp[nj], dp[j]+b);
        }
    }

    int ans = 0;
    for(int i:dp) ans = max(ans, i);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		int n = scan.nextInt();
		String data[] = new String[n];
		String data1[] = new String[n];
		String data2[] = new String[n];
		
		for ( int i = 0; i < n; i++) {
			data1[i] = scan.next();
			data2[i] = data1[i];
			data[i] = data1[i];
		}
		scan.close();
		BubbleSort(data1, data ,n);
		SelectionSort(data2, data, n);
		
	}
	
	public static void BubbleSort(String str[], String array[], int n) {
		
		int min = 0, a;
		String c;
		boolean flg;
		
		for (int i = 0; i < n - 1; i++) {
			for (int j = n - 1; j > i; j--) {
				min = Integer.parseInt(str[j].substring(1));
				a = Integer.parseInt(str[j - 1].substring(1));
				if (min < a) {
					c = str[j - 1];
					str[j - 1] = str[j];
					str[j] = c;
				}
			}
				
		}
		
		for (int i = 0; i < n; i++) {
			if (i == n - 1) {
				System.out.println(str[i]);
				flg = isStable(str, array, n);
				if ( flg == true) {
					System.out.println("Stable");
				} else {
					System.out.println("Not stable");
				}
			} else {
				System.out.print(str[i] + " ");
			}
		}
		
	}
	
	public static void SelectionSort(String str1[], String array1[], int n) {
		int min;
		int a, b;
		String c;
		boolean flg;
		
		for (int i = 0; i < n - 1; i++) {
			min = i;
			for ( int j = i + 1; j < n; j++) {
				a = Integer.parseInt(str1[min].substring(1));
				b = Integer.parseInt(str1[j].substring(1));
				if (a > b) min = j;
			}
			if ( i != min) {
				c = str1[i];
				str1[i] = str1[min];
				str1[min] = c;
			}
		}
		
		for (int i = 0; i < n; i++) {
			if (i == n - 1) {
				System.out.println(str1[i]);
				flg = isStable(str1, array1, n);
				if ( flg == true) {
					System.out.println("Stable");
				} else {
					System.out.println("Not stable");
				}
			} else {
				System.out.print(str1[i] + " ");
			}
		}
	}
	
	public static boolean isStable(String str[], String array[], int n) {
		int x, y;
		
		for ( int i = 0; i < n - 1; i++ ) {
			x = Integer.parseInt(str[i].substring(1));
			for ( int j = i + 1; j < n - 1; j++) {
				y = Integer.parseInt(str[j].substring(1));
				if (x == y) {
					for ( int a = 0; a < n ; a++) {
						if ( str[i] == array[a]) {
							for (int b = 0; b < n ; b++) {
								if (str[j] == array[b]) {
									if ( a > b ) {
										return false;
									}
								}
							}
						}
					}
				}
			}
		}
		
		return true;
	}
	
}



Measured memory_bytes: 26644
#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, m;
int d[1000 + 5], c[1000 + 5];
int dp[1005][1005];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, n) cin >> d[i];
    rep(i, m) cin >> c[i];
    rep(i, n + 2)rep(j, m + 2) dp[i][j] = 1e12;
    rep(j, m + 1) dp[0][j] = 0;
    rep(i, n)rep(j, m) {
        dp[i + 1][j + 1] = min(dp[i + 1][j], dp[i][j] + c[j] * d[i]);
    }
    int ans = 1e12;
    rep(j, m + 1) ans = min(ans, dp[n][j]);
    cout << ans << endl;

}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n;
    cin >> n;
    map<int, pair<int, int>> ixy;
    vector<int> array(n);
    double sum = 0.0;
    double div = 0.0;
    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        ixy[i] = make_pair(x, y);
        array[i] = i;
    }
    do
    {
        rep(i, n - 1)
        {
            sum +=
                (sqrt((ixy[array[i]].first - ixy[array[i + 1]].first) * (ixy[array[i]].first - ixy[array[i + 1]].first) + (ixy[array[i]].second - ixy[array[i + 1]].second) * (ixy[array[i]].second - ixy[array[i + 1]].second)));
        }
        div++;
    } while (next_permutation(array.begin(), array.end()));
    c(sum / div);
    return 0;
}

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

int main() {
  int a;
  cin >> a;
  
 
 
  if (a < 2){
    cout << "1" <<endl;
  }
  else if(a<4){
    cout << "2" << endl;
  }
  else if(a<8){
    cout <<"4" <<endl;
    }
    else if(a<16){
      cout << "8" <<endl;
    }
    else if(a<32){
      cout <<"16"<<endl;
    }
    else if(a<64){
      cout <<"32"<<endl;
    }
else{
  cout <<"64" <<endl;
}
    }
      
       
     
   


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

class Union_Find {
private:
    std::vector<int> par;
    std::vector<int> rank;

public:
    Union_Find(int n) { // ?????????: O(n)
	par  = std::vector<int>(n);
	rank = std::vector<int>(n);
	for(int i=0; i<n; i++) {
	    par[i]  = i;
	    rank[0] = 0;
	}
    }

    int root(int x) { // ??¨??????????±???????: O(?±(n)) 
	if(par[x] == x)
	    return x;
	return par[x] = root(par[x]); // ??????????????????????????????????????????
    }

    void unite(int x, int y) { // x,y????????????????????????: O(?±(n)) 
	x = root(x);
	y = root(y);
	if( x == y ) return;

	if( rank[x] < rank[y] )
	    par[x] = y;
	else {
	    par[y] = x;
	    if( rank[x] == rank[y] ) rank[x]++;
	}
    }

    bool same(int x, int y) { //x,y??????????????????????????????????????????: O(?±(n)) 
	return root(x) == root(y);
    }
};

int main() {

    int n,q;
    std::cin >> n >> q;

    Union_Find uf(n);
    for(int i=0; i<q; i++) {

	int c,x,y;
	std::cin >> c >> x >> y;

	if(c==0)
	    uf.unite(x,y);
	else
	    std::cout << uf.same(x,y) << std::endl;
    }

}

    

Measured memory_bytes: 3260
while True:
    m, f, r = [int(i) for i in input().split()]
    if m == f == -1: break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif 65 <= m + f < 80:
        print('B')
    elif 50 <= m + f < 65:
        print('C')
    elif 30 <= m + f < 50 and r >= 50:
        print('C')
    elif 30 <= m + f < 50:
        print('D')
    else:
        print('F')

Measured memory_bytes: 7672
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<int> c(n - 1), s(n - 1), f(n - 1);
  for(int i = 0; i < n - 1; i++) cin >> c[i] >> s[i] >> f[i];
  for(int i = 0; i < n - 1; i++){
    long long int ans = 0;
    for(int j = i; j < n - 1; j++){
      if(ans < s[j]) ans += s[j] - ans;
      else if((ans - s[j]) % f[j] != 0) ans += f[j] - ((ans - s[j]) % f[j]);
      ans += c[j];
      //cout << ans << endl;
    }
    cout << ans << endl;
  }
  cout << 0 << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 205
#define MAXH 20
#define MAXM 52
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
const int N = 100005;

int main(){
	fast_io();
	int x;
	cin >> x;
	int n = 1;
	while(n * (n + 1)/2 < x)++n;
	cout << n << '\n';
}


Measured memory_bytes: 256
/*
      author : nishi5451
      created: 12.08.2020 14:56:20
*/

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


int main(){
    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1+1==m2 && d2==1)
        cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

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

    double a, b, x;
    cin >> a >> b >> x;

    auto vol = [&](double theta) {
        if (theta >= atan(a / b)) {
            return a * (b + b - a / tan(theta)) * a / 2;
        } else {
            return a * b * b * tan(theta) / 2;
        }
    };

    double l = acos(-1) / 2, r = 0;
    for (int i = 0; i < 100; i++) {
        double m = (l + r) / 2;
        if (vol(m) >= x)
            l = m;
        else
            r = m;
    }
    cout << setprecision(20) << fixed << 90 - l / acos(-1) * 180 << endl;
}


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

int main()
{
	int a_s,a_r,b_s,b_r,min,max;
	cin>>a_s>>a_r>>b_s>>b_r;
	min=a_r>b_r?b_r:a_r;
	max=a_s>b_s?a_s:b_s;
	if(min-max>0)
		cout<<min-max;
	else
		cout<<0;
	return 0;
 }
  

Measured memory_bytes: 256
#!/usr/bin/env python3
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))  # 各要素を-1倍

heapq.heapify(A)

if N == 1:
    MAX = heapq.heappop(A)//2**M 
    if MAX < 0:
        print(0)
    else:
        print(MAX)
    exit()

cnt = 0
while M > 0:
    MAX = heapq.heappop(A)
    if MAX % 2 == 0:
        heapq.heappush(A, MAX//2)
    else:
        heapq.heappush(A, MAX//2+1)

    M -= 1

print(-sum(A))


Measured memory_bytes: 14380
#include <iostream>
#include <vector>

using namespace std;
using lint = long long;

inline lint sq(lint a) { return a * a; }

struct Point {
    lint x, y, z;
};

inline Point sub(Point b, Point a) {
    return Point{b.x - a.x, b.y - a.y, b.z - a.z};
}

inline lint sqnorm(Point p) {
    return sq(p.x) + sq(p.y) + sq(p.z);
}

inline lint prod(Point a, Point b) {
    return a.x * b.x + a.y * b.y + a.z * b.z;
}

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<Point> P(N);
    vector<lint> r(N), l(N);
    for (int i = 0; i < N; ++i) {
        cin >> P[i].x >> P[i].y >> P[i].z >> r[i] >> l[i];
    }

    for (int q = 0; q < Q; ++q) {
        Point a, b;
        cin >> a.x >> a.y >> a.z >> b.x >> b.y >> b.z;

        lint ans = 0;
        Point ab = sub(b, a);
        for (int i = 0; i < N; ++i) {
            Point ac = sub(P[i], a);
            if (0 <= prod(ab, ac) && prod(ab, ac) <= sqnorm(ab) &&
                sqnorm(ab) * sqnorm(ac) - sq(prod(ab, ac)) <= sq(r[i]) * sqnorm(ab)) {
                ans += l[i];
            }
        }

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



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

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;



int main() {
    string s;
    cin >> s;
    int ans = 0;
    vector<int> v(3, 0);
    char joi[] = {'J', 'O', 'I', '?'};
    int cur = 0;
    for (auto &&i : s) {
        if(i == joi[cur]) v[cur]++;
        else if(i == joi[cur+1]) {
            cur++; v[cur]++;
        }else {
            if(v[0] >= v[1] && v[2] >= v[1]){
                ans = max(ans, v[1]);
            }
            fill(v.begin(), v.end(), 0);
            cur = 0;
            if(i == joi[cur]) v[cur]++;
        }
    }
    if(v[0] >= v[1] && v[2] >= v[1]){
        ans = max(ans, v[1]);
    }
    fill(v.begin(), v.end(), 0);
    cout << ans << "\n";
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

// can be applied to string type
#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T>
void Debug(const T &val) { cerr << val << End; }
template<typename T, typename... Args>
void Debug(const T &val, Args... args) {
    cerr << val << ' ';
	Debug(std::forward<Args>(args)...);
}

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

// can be applied to string type
#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
// array sorters
#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define a first
#define b second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    long n;

	cin >> n;

	long a[n];
	long ans = 0;

	long i;

	rep(i, n) {
		cin >> a[i];

		a[i]--;
	}

	rep(i, n) {
		if (0 <= a[i]) {
			if (0 <= a[a[i]]) {
				if (a[a[i]] == i) {
					ans++;

					a[a[i]] = -1;
					a[i] = -1;
				}
			}
		}
	}

	Out(ans);
	
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	m := make(map[int]int)
	for i := 0; i < k; i++ {
		if j := a + i; j <= b {
			m[j]++
		}
	}
	for i := 0; i < k; i++ {
		if j := b - k + 1 + i; a <= j {
			m[j]++
		}
	}
	var ls []int
	for k := range m {
		ls = append(ls, k)
	}
	sort.Ints(ls)
	for i := 0; i < len(ls); i++ {
		fmt.Println(ls[i])
	}
}


Measured memory_bytes: 640
import * as fs from 'fs';

function Picker(input) {
  var lines = input.split('\n');
  var fields = lines.reduce(function(all, line) { return all.concat(line.split(' ')); }, []);
  var p = 0;

  return {
    int: function() {
      return parseInt(fields[p++], 10);
    },
    float: function() {
      return parseFloat(fields[p++]);
    },
    str: function() {
      return fields[p++];
    }
  };
}

const input = fs.readFileSync("/dev/stdin", "utf8");
const pick = Picker(input);

//////////////////////////////////////////

const n = pick.int();
const v = [];
const c = [];

for (let i = 0; i < n; ++i) {
  v.push(pick.int());
}
for (let i = 0; i < n; ++i) {
  c.push(pick.int());
}

let sum = 0;
for (let i = 0; i < n; ++i) {
  if (v[i] > c[i]) {
    sum += v[i] - c[i];
  }
}

console.log(sum);

Measured memory_bytes: 7372
# -*- coding: utf-8 -*-

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

all = 0

all += (a // 10) * 10
if (a % 10) != 0:
    all += 10

all += (b // 10) * 10
if (b % 10) != 0:
    all += 10

all += (c // 10) * 10
if (c % 10) != 0:
    all += 10

all += (d // 10) * 10
if (d % 10) != 0:
    all += 10

all += (e // 10) * 10
if (e % 10) != 0:
    all += 10

l = [(a % 10), (b % 10), (c % 10), (d % 10), (e % 10)]
l = [x for x in l if x != 0]

#print(l)
if len(l) != 0:
    mi = min(l)
    if mi != 0:
        all -= (10 - mi)

print(all)



Measured memory_bytes: 3064
import sys
cup = {"A": 1, "B": 0, "C": 0}
for line in sys.stdin:
    if line == "\n":
        break
    x, y = line.rstrip().split(",")
    t = cup[x]
    cup[x] = cup[y]
    cup[y] = t
for key in cup:
    if cup[key] == 1:
        print(key)

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
  ll H,W,h,w;
    cin>>H>>W;
    cin>>h>>w;
    
    ll k=(H*W)-(h*W)-(H-h)*w;
    cout<<k;
  
  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	int n, k, s;
	cin >> n >> k >> s;
	if (s == 1000000000) {
		FOR(i, 1, k) {
			cout << 1000000000 << " ";
		}
		FOR(i, 1, n - k) {
			cout << 1 << " ";
		}
		cout << endl;
	}
	else {
		FOR(i, 1, k) {
			cout << s << " ";
		}
		FOR(i, 1, n - k) {
			cout << s+1 << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
import Data.List

solve :: String -> String
solve [] = ""
solve (x:xs) = char:solve xs
  where char = if x `elem` "ACGT" then 'o' else 'x'

main :: IO ()
main = do
  s <- getLine
  let count = map (\x -> if 'x' `elem` x then 0 else length x)
  print . maximum . count $ group $ solve s

Measured memory_bytes: 380