akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, std::vector<long long> W){
  vl s(N+1);
  rep(i,N) s[i+1] = s[i]+W[i];
  ll ans = LINF;
  rep(i,N){
    ll temp = abs(s[i+1]-(s[N]-s[i+1]));
    chmin(ans,temp);
  }
  cout << ans << endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> W(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&W[i]);
  }
  solve(N, std::move(W));
  return 0;
}


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

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

  int a = 200001, b = 0;
  for (int i = 0; i < s.size(); ++i) {
    if ('A' == s.at(i)) {
      if (i < a) a = i;
    } else if ('Z' == s.at(i)) {
      b = i;
    }
  }
  cout << b - a + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

long double mysqrt(long double x){
	long double a = sqrt((double)x);
	do{
		a=(a+x/a)/2.0L;
	}while (fabsl(x - a*a) > 1.0e-10);
	return a;
}

int main(void) {

	long double  a, b, c;

		cin >> a >> b >> c;

		if (mysqrt(a/c)+mysqrt(b/c)<1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    long long n, cnt=0, c;
    scanf("%lld",&n);
    for(int a=1; a<=n; a++){
        for(int b=1; b<=n/a; b++){
            c = n - a*b;
        	if( c && ceil(c) == floor(c) ){ cnt++; }
        }
    }
    printf("%lld",cnt);
    return 0;
}

Measured memory_bytes: 1720
package main

import (
	"bufio"
	"fmt"
	"os"
)

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	buf := make([]byte, 0)
	scanner.Buffer(buf, 1000000009)
	scanner.Split(bufio.ScanWords)
}

func main() {
	scanner.Scan()
	bs := []byte(scanner.Text())

	c0 := 0
	c1 := 0
	for _, b := range bs {
		if b == '0' {
			c0++
		} else if b == '1' {
			c1++
		}
	}
	if c0 > c1 {
		fmt.Println(c1 * 2)
	} else {
		fmt.Println(c0 * 2)
	}
}


Measured memory_bytes: 2212
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
#include <complex>
#include <random>
using namespace std;

random_device rd;
mt19937 mt(rd());

using Point = complex<double>;
double dot(Point p, Point q) { return (conj(p) * q).real(); }

int n;
double x, y;
vector<Point> ps;

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> x >> y;
    ps.emplace_back(x, y);
  }

  double ans = 0.0;
  uniform_real_distribution<> rand(-1.0, 1.0);
  for(int unko = 0; unko < 100000; ++unko) {
    vector<Point> engines;
    Point move(rand(mt), rand(mt));
    for(int i = 0; i < n; ++i) {
      if(dot(move , ps[i]) >= 0) {
        engines.push_back(ps[i]);
      }
    }

    x = 0.0, y = 0.0;
    for(auto engine : engines) {
      x += engine.real(), y += engine.imag();
    }
    ans = max(ans, sqrt(x*x + y*y));
  }
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e18
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

int main(){
	string s;
	cin >> s;
	vector<bool> a(3,false);
	a[2] = true;
	if (s[0] == 'A') a[0] = true;

	int cnt = 0;
	REP(i, 2, s.size()-1) {
		if (s[i] == 'C') cnt++;
	}

	if (cnt == 1) a[1] = true;

	rep(i, s.size()) {
		if (isupper(s[i])) {
			if (s[i] != 'A' &&s[i] != 'C') {
				a[2] = false;
			}
		}
	}

	if (a[0] && a[1] && a[2]) {
		cout << "AC" << endl;
	} else {
		cout << "WA" << endl;
	}

}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[205]={0},n,ans=0;
	cin>>n;
	n*=2;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i+=2)
		ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
	int n, k,p1,ans=0;
	
	cin >> n >> k;
	vector<int>p2(n);
	rep(i, n) {
		cin >> p1;
		p2.at(i)=p1;
	}
	sort(p2.begin(), p2.end());
	rep(i, k) {
		ans += p2.at(i);
	}
	cout << ans << endl;
	return 0;
}//どうして・・・(´･_･`)


Measured memory_bytes: 3608
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()

    return 10 - n // 200

print(main())





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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, m, k, t, ans;
int cnt[100];
int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> k;
        for (int j = 0; j < k; ++j) {
            cin >> t;
            ++cnt[t];
        }
    }
    for (int i = 1; i <= m; ++i) {
        if (cnt[i] == n)
            ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    int m = 0;
    m = n/2;
    m += n%2;
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, E;
  cin >> A >> B;
  
  vector<int> JNY(B);
  vector<int> OOT(102);
  
  for(int YUNI =0; YUNI < 102; YUNI++){
    OOT.at(YUNI) =YUNI;
  }
  
  for(int YUNI =0; YUNI < B; YUNI++){
    cin >> JNY.at(YUNI);
  }
  
  for(int YUNI =0; YUNI < 102; YUNI++){
    OOT.at(YUNI) -= A;
  }
  
  for(int YUNI =0; YUNI < B; YUNI++){
    OOT.at(JNY.at(YUNI)) = 200;
  }
  
  for(int YUNI =0; YUNI < 102; YUNI++){
    if(OOT.at(YUNI) < 0){
      OOT.at(YUNI) = -OOT.at(YUNI);
    }
  }
  
  int KYR = 200;
  
  for(int YUNI =0; YUNI < 102; YUNI++){
    D = OOT.at(YUNI);
    if(D < KYR){
      KYR = D;
      C = YUNI;
    }
  }
  
  cout << C << endl;
  //cout << OOT.at(2) << endl;
}
  

Measured memory_bytes: 3624
def main():
    s = input()
    max_length = 0
    cur_length = 0
    for i, si in enumerate(s):
        if si in ["A", "T", "G", "C"]:
            cur_length+=1
        else:
            if max_length<cur_length:
                max_length = cur_length
            cur_length = 0

    if max_length<cur_length:
        max_length = cur_length
    print(max_length)

if __name__=="__main__":
    main()



Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,p,m;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  
  int s =-2;
  
  for(int i=0;i<n;++i) cin >> a.at(i);
  for(int i=0;i<n;++i) cin >> b.at(i);
  for(int i=0;i<n-1;++i) cin >> c.at(i);
  
  for(int i =0;i<n;++i){
    p+=b.at(i);
    m=a.at(i);
      if(s>=0&&m-s==1){
        
        p+=c.at(s-1);
      }
    s = m;
  }
  
  cout << p << endl;
  
  
}

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

int main() {
  int N;
  while(cin >> N && N) {
    int arr[N];
    for(int i=0;i<N;i++)cin >> arr[i];
    for(int i=0;i<N;i++) {
      int j;
      for(j=i+1;j<N;j++) {
        if(arr[j-1]+1!=arr[j]) break;
      }
      if(i) cout << " ";
      cout << arr[i];
      if(j>i+1){
        cout << "-"; cout << arr[j-1];
        i=j-1;
      }
    }
    cout << endl;
  }
  return 0;
}

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

typedef int integer;
#define int long long

using namespace std;

vector<string> v;
int N;

void gen(string s, int n, char next){
    if (n == N){
        v.push_back(s);
        return;
    }
    set<char> S;
    for (auto c : s) S.insert(c);
    for (auto c : S){
        s.push_back(c);
        gen(s, n+1, next);
        s.pop_back();
    }
    s.push_back(next);
    gen(s, n+1, next+1);
    s.pop_back();
}

integer main() {
    ios_base::sync_with_stdio(false);
    cin >> N;
    gen("", 0, 'a');
    for (auto k : v){
        cout << k << endl;
    }
}



Measured memory_bytes: 9716
n = int(input())
arr = list(map(int,input().split()))
if n==2:
	print(abs(arr[0]-arr[1]))
elif n==3:
	x = abs(arr[0]-arr[2])
	y = abs(arr[0]-arr[1]+arr[1]-arr[2])
	print(min(x,y))
else:
	x = abs(arr[0]-arr[1])
	y = abs(arr[0]-arr[2])
	dp = [x,y]
	for i in range(3,n):
		x = dp[-1]+abs(arr[i]-arr[i-1])
		y = dp[-2]+abs(arr[i]-arr[i-2])
		dp.append(min(x,y))
	print(dp[-1])

Measured memory_bytes: 13928
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}
int func(int n){
  if(n%2 == 0){
    return n/2;
  }
  return 3*n + 1;
}
int main() {
  int s; cin >> s;
  map<int, int> mp;
  mp[s]++;
  for(int i=2; ; i++){
    s = func(s);
    mp[s]++;
    if(mp[s] == 2){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}



///


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, count, temp;
	uint64 hash64(uint64 key) {
		key = ~key;
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(8192, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 8191; count = 0;
	}
	hashmap64(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			for (uint64 t = 0;t <= mask >> 1;++t) {
				if (~map[t].first) {
					mkey = map[t];
					map[t].first = ~static_cast<std::uint_fast64_t>(0);
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap64<uint32> map(120);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 15184
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string x,y;
  cin>>x>>y;
  int n=x.length();
  int m=y.length();
  int dp[n+1][m+1];
  for(int i=0;i<=n;i++)
    for(int j=0;j<=m;j++)
    {
      if(i==0 || j==0)
        dp[i][j]=0;
    }
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
    {
      if(x[i-1]==y[j-1])
        dp[i][j]=1+dp[i-1][j-1];
      else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  //cout<<dp[n][m];
  int i=n,j=m;
  string s;
  while(i>0 && j>0)
  {
    if(x[i-1]==y[j-1])
    {
      s+=x[i-1];
      i--;
      j--;
    }
    else
    {
      if(dp[i-1][j]>dp[i][j-1])
        i--;
      else
        j--;
    }
  }
  reverse(s.begin(), s.end());
    cout<<s;
}

Measured memory_bytes: 38780
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

import itertools

ans = 0
for comb in itertools.combinations_with_replacement(list(range(1, m + 1)), n):
    l = list(comb)
    l.sort()
    tmp = 0

    for a, b, c, d in abcd:
        a -= 1
        b -= 1

        if l[b] - l[a] == c:
            tmp += d

    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 68244
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    double T, X;
    cin >> T >> X;
    double ans = T / X;
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    long N, K;
    cin >> N >> K;
    long sum = 0;
    const long MOD = 1000000007;
    for (int i = K; i <= N + 1; i++)
    {
        sum += i * (N + 1 - i) + 1;
        sum %= MOD;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
s = input()
ans = 'YES'
while len(s) > 0:
    if s[-5:] == 'dream' or s[-5:] == 'erase':
        s = s[:-5]
    elif s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    else:
        ans = 'NO'
        break
print(ans)


Measured memory_bytes: 3188
N = int(input())
if 1800 <= N <= 1999:
    print('1')
elif 1600 <= N <= 1799:
    print('2')
elif 1400 <= N <= 1599:
    print('3')
elif 1200 <= N <= 1399:
    print('4')
elif 1000 <= N <= 1199:
    print('5')
elif 800 <= N <= 999:
    print('6')
elif 600 <= N <= 799:
    print('7')
else :
    print('8')

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    while(cin>>n,n){
        long long int siz,ans=0;
        string str;
        cin>>siz>>str;
        for(int i=0;i<siz-2*n;i++){
            if(str[i]=='I'){
                int co=0;
                for(int j=i+1;j<siz;j+=2,co++){
                    if(str[j]!='O'||str[j+1]!='I')break;
                }
                if(co>=n){
                    ans+=co-n+1;
                    i+=1+2*co-n;
                }
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2104
#include <stdio.h>
void trace(int A[], int N)
{
	int  i;
	for (i = 0; i < N; i++) {
		if (i > 0)printf(" ");
		printf("%d", A[i]);
	}

	printf("\n");
}

void insertionSort(int A[], int N) {
	int i, v, j;
	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;
		}

		A[j + 1] = v;
		trace(A, N);
	}
}


int main() {
	int N, i, j;
	int A[100];

	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", &A[i]);

	trace(A, N);
	insertionSort(A, N);

	return 0;
}


Measured memory_bytes: 2740
# coding: utf-8
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = sr()
counter = Counter(S)
r = counter['R']; g = counter['G']; b = counter['B']
answer = r * g * b
for i in range(N):
    for j in range(i+1, N):
        if S[i] == S[j]:
            continue
        diff = j - i
        if j + diff >= N:
            break
        x = S[i]; y = S[j]
        z = S[j+diff]
        if x != z and y != z:
            answer -= 1

print(answer)


Measured memory_bytes: 68840
#include<iostream>
using namespace std;
bool has3(int x){
    while(x){
        if(x%10==3)return true;
        x/=10;
    }
    return false;
}
void call(int n){
    for (int x=1;x<=n;x++){
        if(x%3==0||has3(x)){
            cout<<" "<<x;
        }
    }
    cout<<endl;
}
int main(){
    int n;
    cin>>n;
    call(n);
    
    return 0;
}


Measured memory_bytes: 3100
#include<map>
#include<cstdio>
#include<vector>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	map<int,int> f;
	rep(i,n){
		int id; scanf("%d",&id);
		f[id]=i;
	}

	vector< pair<int,int> > a;
	map<int,int>::iterator it;
	for(it=f.begin();it!=f.end();++it) a.push_back(make_pair(-it->second,it->first));
	sort(a.begin(),a.end());
	rep(i,min((int)a.size(),m)) printf("%d\n",a[i].second);

	return 0;
}

Measured memory_bytes: 6584
###template###
import sys
input = sys.stdin.readline
def mi(): return map(int, input().split())
###template###

Rt, Gt, Bt, N = mi()

R = max(Rt, Gt, Bt)
B = min(Rt, Gt, Bt)
G = Rt+Gt+Bt-R-B

cnt = 0
if G == 1 and B == 1:
  for i in range(N//R+1):
    cnt += (N-R*i)+1
  print(cnt)
  exit()

for i in range(N//R+1):
  for j in range((N-R*i)//G+1):
    #残り必要ボール数
    if (N - R*i - G*j)%B == 0:
      cnt += 1

print(cnt)




Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int n;cin>>n;
    vector<long long int> Al(n);for(long long int i=0;i<n;i++)cin>>Al[i];
    vector<long long int> Bl(n);for(long long int i=0;i<n;i++)cin>>Bl[i];
    vector<long long int> Cl(n);for(long long int i=0;i<n;i++)cin>>Cl[i];
    sort(Al.begin(),Al.end(),greater<long long int>());
    sort(Bl.begin(),Bl.end(),greater<long long int>());
    sort(Cl.begin(),Cl.end(),greater<long long int>());
    vector<long long int> Il;
    long long int i=0;
    long long int zc=0,yc=0;
    for(long long int x=0;x<n;x++){
        /*
        if (x>=1 && Al[x]==Al[x-1])
        {
            i=i*2;
            continue;
            
        }
        */
        for(long long int y=yc;y<n;y++)
        {
            if(Al[x]>=Bl[y])break;
            i+=zc;
            for(long long int z=zc;z<n;z++)
            {
                if(Bl[y]>=Cl[z])break;
                
                i++;
                zc++;
            }
            yc++;
        }
        Il.push_back(i);
        
    }
    long long int sum=0;
    for(long long int j=0;j<n;j++){
        //cout << Il[i] << ':';
        sum+=Il[j];
    }
    //cout<<'\n';
    
    cout<<sum<<'\n';
    
}

Measured memory_bytes: 3704
n, a, b = map(int, input().split())

if a == 0:
    print(0)
else:
    if 0 <= n % (a+b) <= a:
        b = a * (n // (a+b)) + n % (a+b)
        print(b)
    else:
        b = a * (n // (a+b)) + a
        print(b)


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>

using namespace std;


double calcSimpleInterest(double money, int year, double rate)
{
    return money * (1.0 + (double)year * rate / 100.0);
}

double calcCompoundInterest(double money, int year, double rate)
{
    return money * pow(1.0 + rate / 100.0, (double)year);
}

int main()
{
    int n, year;
    int b, r, t;
    int result;
    double interest, tmpInterest;

    while(1){
        cin >> n;
        if(n == 0) {
            break;
        }
        
        result = 0;
        interest = 0.0;

        cin >> year;
        for(int i = 0; i < n; i += 1) {
            cin >> b >> r >> t;

            if(t == 1) {
                tmpInterest = calcSimpleInterest(1.0, year, (double)r);
            } else {
                tmpInterest = calcCompoundInterest(1.0, year, (double)r);
            }

            if(tmpInterest > interest) {
                result = b;
                interest = tmpInterest;
            }
        }

        cout << result << endl;
    }

    return 0;
}

Measured memory_bytes: 3404
def is_pali(s, start, end):
	cpy = s[start:end]
	rev = cpy[::-1]
	if cpy == rev:
		return 1
	else:
		return 0

s = input()
n = len(s)
if is_pali(s, 0, n) and is_pali(s, 0, (n - 1) // 2) and is_pali(s, ((n + 3) // 2) - 1, n):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
N, T = gets.split.map(&:to_i)
t = gets.split.map(&:to_i)

ans = 0
t.each_with_index do |ti, i|
  if i == 0
    ans += T
  else
    ans += [t[i] - t[i - 1], T].min
  end
end
puts ans



Measured memory_bytes: 19844
import sys

n, *ab = map(int, sys.stdin.buffer.read().split())
aaa = ab[0::2]
bbb = ab[1::2]

ans = 0
for a, b in zip(aaa[::-1], bbb[::-1]):
    d, m = divmod(a + ans, b)
    if m == 0:
        continue
    push = (d + 1) * b - (a + ans)
    ans += push
print(ans)


Measured memory_bytes: 21992
#include <stdio.h>

void gcd(int a, int b, int i)
{	
	if (b == 0){
		printf("%d %d\n", a, i);
		return;
	}
	gcd(b, a % b, i + 1);
}

int main(void)
{
	int a, b, i;
	
	while (1){
		scanf("%d %d", &a, &b);
		if (!a && !b){
			break;
		}
		
		if (a < b){
			gcd(b, a, 0);
		}
		else {
			gcd(a, b, 0);
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,s,x;
  cin>>k>>s;
  x=0;
  for(int i=k;i>=0;i--){
    for(int j=0;j<=k;j++){
      if(s-i-j>=0 &&s-i-j<=k){
        x++;
      }
    }
  }
  cout<<x<<endl;
}
    

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int) 1e5 + 10;
const int MAXA = (int) 1e9;
int n, k, a[MAXN], h[MAXN];
vector<int> adj[MAXN];

struct Range {
	int l, r;
	Range() {};
	Range(int l, int r): l(l), r(r) {};
	friend Range Merge(Range A, Range B) {
		Range C;
		C.l = max(A.l, B.l);
		C.r = min(A.r, B.r);
		return C;
	}
} f[MAXN], g[MAXN];

void DFS(int u, int p = -1) {
	if (a[u] != -1) g[u] = Range(a[u], a[u]); else g[u] = Range(0, MAXA);
	for (int i = 0; i < (int) adj[u].size(); ++i) {
		int v = adj[u][i];
		if (v != p) {
			h[v] = h[u] ^ 1;
			DFS(v, u);
			g[u] = Merge(g[u], Range(g[v].l - 1, g[v].r + 1));
		}
	}
}

void Compute(int u, int p = -1) {
	if (p != -1) f[u] = Merge(Range(f[p].l - 1, f[p].r + 1), g[u]);
	else f[u] = g[u];
	for (int i = 0; i < (int) adj[u].size(); ++i) {
		int v = adj[u][i];
		if (v != p) Compute(v, u);
	}
}

void Write(int u, int p = -1) {
	if (a[u] == -1) {
		if (f[u].l <= a[p] - 1) a[u] = a[p] - 1;
		else a[u] = a[p] + 1;
	}
	for (int i = 0; i < (int) adj[u].size(); ++i) {
		int v = adj[u][i];
		if (v != p) Write(v, u);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n - 1; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	int root = -1; scanf("%d", &k);
	for (int i = 1; i <= n; ++i) a[i] = -1;
	for (int i = 1; i <= k; ++i) {
		int u, x; scanf("%d%d", &u, &x);
		root = u; a[u] = x;
	}

	h[root] = a[root] % 2;
	DFS(root);
	Compute(root);

	for (int i = 1; i <= n; ++i) {
		int flag = 1;
		flag &= (f[i].l <= f[i].r);
		if (a[i] != -1) {
			flag &= (f[i].l <= a[i] && a[i] <= f[i].r);
			flag &= (a[i] % 2 == h[i]);
		}
		if (flag == 0) {
			puts("No");
			return 0;
		}
	}

	Write(root); puts("Yes");
	for (int i = 1; i <= n; ++i) printf("%d\n", a[i]);
	return 0;
}

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

#define endl '\n'

void solvetask(){
    int n; cin >> n;
    long long a[n], ans; for (int i=0; i<n; i++) cin >>a[i];
    sort(a, a+n, greater<int>());
    ans = a[0];
    for (int i=1, p=2; p<n; i++){
        ans += a[i];
        p++;
        if (p==n) break;
        ans += a[i];
        p++;
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;// cin >> t;
    while(t--) solvetask();
}

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

#define int long long 
#define dou double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int a;
	cin >> a;
	cout << a+pow(a,2)+pow(a,3) << endl;
	return;
}

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

	solve();
	return 0;
}


Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()

vector<vector<pair<int, int>> > g;
vector<int> ans;

void dfs(int mynode, int rootnode, int c_root) {
    int c_targ = 1;
    rep(i, 0, g[mynode].size()) {
        int to = g[mynode][i].first;
        int id = g[mynode][i].second;
        if (c_targ == c_root) c_targ++;
        if (g[mynode][i].first != rootnode) {
            ans[id] = c_targ;
            dfs(to, mynode, c_targ);
            c_targ++;
        }
    }
}

int main(void) {
    int n; cin >> n;
    g.resize(n);
    rep(i, 0, n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back({b, i});
        g[b].push_back({a, i});
    }
  
    ans.resize(n-1);  
    dfs(0, -1, 0);
 
    int cnt = 0;
    rep(i, 0, n-1) cnt = max(cnt, int(g[i].size()) );
    cout << cnt << endl;   
    
    rep(i, 0, ans.size()) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 8320
import collections
N = int(input())
s = [input() for i in range(N)]
 
counter = collections.Counter(s)
count = counter.most_common()
 
most = count[0][1]
 
c =[]
for i in range(len(counter)):
    if count[i][1] == most:
        c.append(count[i][0])
 
c.sort()
 
for i in range(len(c)):
    print(c[i])

Measured memory_bytes: 47640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
const ll MOD = 1e9+7 ;
ll Factorial(int k ){
ll sum = 1;
for (int i = 1; i <= k; ++i){
	sum *= i ;
  	sum %=MOD ;
	}
	return sum;
}

int main() {
  	int N , M ;
  	cin >> N >> M ;
  	int a = min(N,M) ;
  	int b = max(N,M) ;
    if(b-a>1){
		cout << 0 << endl;
      	return 0 ;
    }
  	if( b-a==1 ){
        //cout << Factorial(a)<< endl ;
		cout << Factorial(a)*Factorial(b)%MOD << endl ;
      return 0 ;
    }
  	else{
      	cout << 2*Factorial(a)%MOD*Factorial(b)%MOD << endl ;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define ll long long 
#define inf 1000000000
#define iPair pair< ll , ll >
using namespace std;
#define lp(n,i) for(ll i=0;i<n;i++)
#define rlp(n) for(ll i=n-1;i>=0;i--)
#define pq 	priority_queue<int, vector<int> , greater<int> >
 
/*ll pw(ll x, ll  y) ;
ll mi(ll  a) 
{ return pw(a, e-2); } 
 
ll pw(ll x, ll  y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = pw(x, y/2) % e; 
    p = (p * p) % e; 
  
    return (y%2 == 0)? p : (x * p) % e; 
} 
  
  
 bool sortbysec(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
int mod(string num, int a) 
{ 
    // Initialize result 
    int res = 0; 
  
    // One by one process all digits of 'num' 
    for (int i = 0; i < num.length(); i++) 
         res = (res*10 + (int)num[i] - '0') %a; 
  
    return res; 
} */
void dfs(vector < ll > ad[],ll cr,ll vis[],ll dp[] )
{
	vis[cr]=1;
	
	for(ll i=0;i<ad[cr].size();i++)
	{
		if(!vis[ad[cr][i]])dfs(ad,ad[cr][i],vis,dp);
		
		dp[cr]=max(dp[cr],1+dp[ad[cr][i]]);
	}
}
 	
 
int main()
{
ll n,m;
cin>>n>>m;
vector< ll > ad[n+1];
for(ll i=1;i<=m;i++)
{
	ll x,y;
	cin>>x>>y;
	ad[x].PB(y);
}
ll vis[n+1]={0};
ll dp[n+1]={0};
for(ll i=1;i<=n;i++)
{
	if(!vis[i])dfs(ad,i,vis,dp);
}

sort(dp,dp+n+1);
cout<<dp[n];
	
	cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
	return 0;
}
 
 
 
 
 

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

typedef long long ll;

#define MAX 26
#define NIL -1

struct Node{
    int p;
    int l,r;
};


Node tree[MAX];
int dep[MAX],hei[MAX];
int n;

void setdep(int r,int d){
    dep[r]=d;
    if(tree[r].l!=NIL)setdep(tree[r].l,d+1);
    if(tree[r].r!=NIL)setdep(tree[r].r,d+1);
}

int seth(int r){
    if(tree[r].l==tree[r].r){
        return hei[r]=0;
    }else{
        return hei[r]=max(seth(tree[r].r),seth(tree[r].l))+1;
    }
}

int getsib(int r){
    int p=tree[r].p;
    if(p==NIL)return NIL;
    else if(tree[p].l!=NIL && tree[p].l!=r)return tree[p].l;
    else if(tree[p].r!=NIL && tree[p].r!=r)return tree[p].r;
    else return NIL;
}

void print(){
    for(int i=0;i<n;i++){
        cout << "node "<<i;
        cout << ": parent = "<<tree[i].p;
        cout << ", sibling = " << getsib(i);
        int deg=0;
        if(tree[i].l!=NIL)deg++;
        if(tree[i].r!=NIL)deg++;
        cout << ", degree = " << deg;
        cout << ", depth = " <<dep[i];
        cout << ", height = " <<hei[i];
        cout <<", ";
        if(tree[i].p==NIL)cout << "root\n";
        else if(deg==0)cout << "leaf\n";
        else cout << "internal node\n";
    }
}

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

    cin >> n;
    for(int i=0;i<n;i++)tree[i].p=tree[i].l=tree[i].r=NIL;

    int id,l,r;
    for(int i=0;i<n;i++){
        cin >> id >> l >> r;
        tree[id].l=l;
        tree[id].r=r;
        tree[l].p=tree[r].p=id;;
    }

    int root;
    for(int i=0;i<n;i++){
        if(tree[i].p==NIL)root=i;
    }
    setdep(root,0);
    int maxh=seth(root);
    print();

}




Measured memory_bytes: 3180
S=input()
T=input()
N=len(S)

def rotate(word):
    last=word[-1]
    word=word[:-1]
    word=last+word
    return(word)

flag=0
for i in range(N):
    if S==T:
        flag=1
        break
    else:
        S=rotate(S)

print(['No','Yes'][flag])

Measured memory_bytes: 3064
def main():
    # n = int(input())
    a, b, c, d = map(int, input().split())
    # l = list(map(int, input().split()))
    # s = input()

    ans1 = a*c
    ans2 = a*d
    ans3 = b*c
    ans4 = b*d

    print(max(ans1, ans2, ans3, ans4))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61664
#include <iostream>

bool flags[7];

int main(){
    std::string s;
    std::cin >> s;
    std::string k = "keyence";
    for(int i = 0; i < 7; i++){
        flags[i] |= (k[i]==s[i]);
        flags[6-i] |= (k[6-i]==s[s.length()-1-i]);
    }
    bool flag = true;
    for(int i = 0; i < 7; i++){
        flag &= flags[i];
    }
    if(flag){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 5000+10;
const ll mod =   1e9+7;
int bo[1000006];
int main()
{  fast
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
	cin>>arr[i];
	bo[arr[i]]++;
}
int ans=0;
for(int i=0;i<n;i++){
	int x=arr[i];
	
	int cnt=0;
	for(int j=1;j*j<=x;j++){
		if(x%j==0){
			if(bo[j])
			cnt+=bo[j];
			if(j*j!=x){
			if(x/j==arr[i])
			{
				if(bo[arr[i]]>1)
				cnt++;
			}
			else if(bo[x/j])
			cnt++;}
		}
	}
	if(!cnt)ans++;
}
if(bo[1]==1)
ans++;
cout<<ans;
}

Measured memory_bytes: 8200
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
#include <numeric>
#include <iomanip>
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n<105){
        cout << 0;
    }else if(105<=n&&n<135){
        cout << 1;
    }else if(135<=n&&n<165){
        cout << 2;
    }else if(165<=n&&n<189){
        cout << 3;
    }else if(189<=n&&n<195){
        cout << 4;
    }else{
        cout << 5;
    }
}

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

int main()
{
  int n, flag_count = 0;
  char c;
  string s = "PWGY";
  vector<bool> flag(4, false);

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> c;
    for (int j = 0; j < 4; j++)
    {
      if (c == s[j])
        flag[j] = true;
    }
  }
  for (int i = 0; i < 4; i++)
  {
    if (flag[i])
      flag_count++;
  }
  cout << (flag_count == 3 ? "Three" : "Four") << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> C(H, vector<char>(W));

    rep (y, H)
    {
        rep (x, W)
        {
            cin >> C[y][x];
        }
    }

    rep (y, 2*H)
    {
        rep (x, W)
        {
            cout << C[y/2][x];
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int c=0,d=1;
    for(int i=0;d<b;i++){
        d+=a-1;
        c++;
    }
    cout<<c;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;

int harshad(int n) {
  int ret=0;
  while(n>0) {
    ret+=n%10;
    n/=10;
  }
  return ret;
}

int main() {
  INCANT;
  cin >> N;
  string ans = N%harshad(N)==0?"Yes":"No";
  cout << ans << "\n";
  return 0;
}

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

int main(void)
{
    int N=0;
    int ac=0,wa=0,tle=0,re=0;
    char array[4]={};

    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%s",array);
        if(strcmp(array,"AC")==0){
            ac+=1;
        }
        else if(strcmp(array,"WA")==0){
            wa+=1;
        }
        else if(strcmp(array,"TLE")==0){
            tle+=1;
        }
        else {
            re+=1;
        }
    }

    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);

    return 0;
}


Measured memory_bytes: 1716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  int n; cin>>n;
  vector<double> x(n);
  vector<double> y(n);
  rep(i, n) {
    cin>>x[i]>>y[i];
  }
  double sum = 0;
  vector<int> a(n);
  rep(i, n) a[i] = i;
  do {
    rep(i, n-1) {
      sum += sqrt(pow(x[a[i]]-x[a[i+1]], 2) + pow(y[a[i]]-y[a[i+1]], 2));
    }
  } while (next_permutation(a.begin(), a.end()));
  double div = 1;
  rep(i, n) div *= (i+1);
  printf("%.10lf\n", sum/div);

  return 0;
}


Measured memory_bytes: 256
n, k, s = map(int, input().split())

ans=[]
if n-k<s:
    ans.append([s]*k)
    ans.append([1]*(n-k))
elif n-k>s:
    ans.append([s+1]*(n-k-s+1))
    ans.append([1]*(s+k-1))
else:
    ans.append([s]*k)
    ans.append([1]*(n-k-1))
    ans.append([s+1])

print(" ".join([" ".join(map(str, l)) for l in ans]))

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

public class  Main{
	static int mod=(int)1e9+7;
    public static void main(String[] args) throws Exception{
        //MScanner sc = new MScanner("chess.in");
        MScanner sc = new MScanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[][]in=new int[m][n];
        int[]p=new int[m];
        int[]cs=new int[m];
        for(int i=0;i<m;i++) {
        	int k=sc.nextInt();
        	cs[i]=k;
        	for(int j=0;j<k;j++) {
        		in[i][j]=sc.nextInt()-1;
        	}
        }
        for(int i=0;i<m;i++)p[i]=sc.nextInt();
        int ans=0;
        for(int i=0;i<(1<<n);i++) {
        	boolean yes=true;
        	for(int k=0;k<m;k++) {
	        	int on=0;
	        	for(int j=0;j<cs[k];j++) {
	        		if(((1<<in[k][j])&i)!=0) {
	        			on++;
	        		}
	        	}
	        	if(on%2!=p[k]) {
	        		yes=false;break;
	        	}
	        	
        	}
        	if(yes)ans++;
        }
        pw.println(ans);
        
        pw.flush();
    }
    static class pair implements Comparable<pair>{
    	String t;int d;int idx;
    	pair(String x,int y,int i){
    		t=x;d=y;idx=i;
    	}
    	@Override
    	public int compareTo(pair o) {
    		if(t.compareTo(o.t)!=0) {
    			return t.compareTo(o.t);
    		}
    		return o.d-d;
    	}
    	 
    	public boolean equals(pair o) {
    		if(this.compareTo(o)==0)return true;
    		return false;
    	}
    	public String toString() {
    		return "("+t+" "+d+")";
    	}
    }
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<time.h>
using namespace std;


int main(void)
{
	int n,i,j,p;
	p = 0;
	scanf("%d", &n);
	for (i = 1; i < 10; i++)
	{
		for (j = 1; j < 10; j++)
		{
			if (n == j * i)
				p++;
		}
	}
	if (p > 0)
	{
		printf("Yes");
	}
	else
		printf("No");


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int n;
vector<int> size1(100010,0), size2(100010,0);

//解法
void solve() {

	int max_i1=0, max_i2=0;
	int pre_i1 = 0, pre_i2 = 0;
	rep(i, 100010) {
		if (size1[i] > size1[max_i1]) {
			pre_i1 = max_i1;
			max_i1 = i;
		}
		else if (size1[i] > size1[pre_i1]) {
			pre_i1 = i;
		}
		if (size2[i] > size2[max_i2]) {
			pre_i2 = max_i2;
			max_i2 = i;
		}
		else if (size2[i] > size2[pre_i2]) {
			pre_i2 = i;
		}
	}

	if (max_i1 != max_i2) {
		cout << n - size1[max_i1] - size2[max_i2];
	}
	else {
		int ans = max(size1[max_i1] + size2[pre_i2], size1[pre_i1] + size2[max_i2]);
		cout << n - ans;
	}



	return;
}

int main() {
	//入力
	cin >> n;
	int input1,input2;
	rep(i, n / 2) {
		cin >> input1 >> input2;
		size1[input1]++;
		size2[input2]++;
	}
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	long res = 0;
	int march[5] = {0};
	int map[10][5] = {
		{1,1,1,0,0},
		{1,1,0,1,0},
		{1,1,0,0,1},
		{1,0,1,1,0},
		{1,0,1,0,1},
		{1,0,0,1,1},
		{0,1,1,1,0},
		{0,1,1,0,1},
		{0,1,0,1,1},
		{0,0,1,1,1}
	};
 	for(int i=0;i<n;++i){
		string s;
		cin >> s;
		if(s[0] == 'M')march[0]++;
		else if(s[0] == 'A')march[1]++;
		else if(s[0] == 'R')march[2]++;
		else if(s[0] == 'C')march[3]++;
		else if(s[0] == 'H')march[4]++;
	}
	for(int i=0;i<10;i++){
		long box = 1;
		for(int j=0;j<5;j++){
			if(map[i][j])box *= map[i][j] * march[j];
		}
		res += box;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
n,c,k,*t=map(int,open(0).read().split())
t.sort()
busstart=t[0]
passenger=0
buscount=0
for i in t:
    if i>busstart+k or passenger==c:
        busstart=i
        passenger=1
        buscount+=1
    else:
        passenger+=1
print(buscount+1) 

Measured memory_bytes: 14052
N = int(input())
S = list(map(int, input().split()))

def f():
    if 0 in S:
        return 0
    elif 10 ** 18 in S:
        return -1
    else:
        ans = 1
        for s in S:
            ans *= s
            if ans > 10 ** 18:
                return -1
        return ans

print(f())

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,r;
    cin>>n>>r;
    if(n>9)
    {
        cout<<r<<endl;
    }
    else
    {
        cout<<r+(100*(10-n))<<endl;
    }
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    for (int i = 0; i < 26; i++) {
        char c = 'a' + i;
        bool check = false;
        for (int j = 0; j < (int)s.size(); j++) {
            if (c == s[j]) check = true;
        }
        if (!check) {
            cout << c << "\n";
            return 0;
        }
    }
    cout << "None\n";
}

Measured memory_bytes: 512
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, a, b) = readIntegerList()
    val hList = LongArray(n) { readLong() }

    val diff = a - b
    fun canDefeatAllBy(count: Long) = hList.map { it - count * b }
        .filter { it > 0L }
        .fold(0L) { acc, v -> acc + (v + (diff - 1)) / diff }
        .let { it <= count }

    var left = -1L
    var right = (hList.max()!! + (b - 1)) / b + 1
    while (right - left > 1L) {
        val mid = (right + left) / 2
        if (canDefeatAllBy(mid)) right = mid else left = mid
    }

    println(right)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 76616