akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int num[26];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            num[c - 'a']++;
        }
    }

    if (H % 2 == 0 and W % 2 == 0) {
        bool ok = true;
        for (int i = 0; i < 26; i++) {
            if (num[i] % 4 != 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (H % 2 == 0) {
        bool ok = true;
        for (int i = 0; i < 26; i++) {
            if (num[i] % 2 != 0) {
                ok = false;
                break;
            }
        }
        if (not ok) {
            cout << "No" << endl;
            return 0;
        }
        const int pnum = H / 2;
        int cnt = 0;
        for (int i = 0; i < 26; i++) {
            if (num[i] % 4 == 2) {
                cnt++;
            }
        }
        if (cnt <= pnum) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (W % 2 == 0) {
        bool ok = true;
        for (int i = 0; i < 26; i++) {
            if (num[i] % 2 != 0) {
                ok = false;
                break;
            }
        }
        if (not ok) {
            cout << "No" << endl;
            return 0;
        }
        const int pnum = W / 2;
        int cnt = 0;
        for (int i = 0; i < 26; i++) {
            if (num[i] % 4 == 2) {
                cnt++;
            }
        }
        if (cnt <= pnum) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        int odd = 0;
        for (int i = 0; i < 26; i++) {
            if (num[i] % 2 == 1) {
                odd++;
            }
        }
        if (odd > 1) {
            cout << "No" << endl;
            return 0;
        }
        int cnt = 0;
        for (int i = 0; i < 26; i++) {
            if (num[i] % 4 == 2) {
                cnt++;
            }
        }
        if (cnt <= (H + W - 1) / 2) {
            cout << "Yes" << endl;

        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
S = input().rstrip() + "#"
s0 = S[0]
A, cnt = [], 1
for s in S[1:]:
    if s==s0: cnt+=1
    else: A.append(cnt); cnt=1
    s0 = s
res, st = 0, 0
if S[0]==">":
    res += A[0]*(A[0]+1)//2
    st=1
for i in range(st,len(A),2):
    if i+1==len(A): res += A[i]*(A[i]+1)//2; break
    p, q = A[i], A[i+1]
    if p < q:
        res += q*(q+1)//2 + p*(p-1)//2
    else:
        res += q*(q-1)//2 + p*(p+1)//2
print(res)



Measured memory_bytes: 84984
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, m;
    cin >> n >> m;
    vector<P> a(n);
    rep(i, n) cin >> a[i].first >> a[i].second;
    sort(all(a));
    priority_queue<int> que;
    int ans = 0, pos = 0;
    Rep(i, 1, m + 1)
    {
        for (; pos < n; pos++)
        {
            if (a[pos].first <= i)
                que.push(a[pos].second);
            else
                break;
        }
        if (que.empty())
            continue;
        int num = que.top();
        que.pop();
        ans += num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2936
## ABC113B - Palace
n = int(input())
t, a = list(map(int, input().rstrip().split()))
data = list(map(int, input().rstrip().split()))

temp = [abs(max(a, t - data[i] * 0.006) - min(a, t - data[i] * 0.006)) for i in range(n)]
print(temp.index(min(temp)) + 1)

Measured memory_bytes: 3060
n = []
s = []
while True:
    n_value = int(input())
    if n_value == 0:
        break
    else:
        n.append(n_value)
        s_value = list(map(int,input().split()))
        s.append(s_value)

for indexi,i in enumerate(n):
    m = sum(list(s[indexi]))/i
    a = 0
    for s_row in s[indexi]:
        a += (s_row-m)**2
    print((a/i)**0.5)


Measured memory_bytes: 5672
//Created by:Coding_lover(26-07-2020 21:35:35)
#include <bits/stdc++.h>
#define ll long long
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define INF LLONG_MAX
#define f first
#define s second
#define LB lower_bound
#define UB upper_bound
#define pi pair<long long,long long>
#define pii pair<long long,pi>
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define vc vector
#define vll vector<long long>
#define rep(i, a, n) for (ll i = a; i < (long long)n; ++i)
#define repe(i, a, n) for (ll i = a; i <= (long long)n; ++i)
#define repr(i, n, a) for (ll i = n; i > (long long)a; --i)
#define repre(i, n, a) for (ll i = n; i >= (long long)a; --i)
#define dbg(x) cout<<"Debugging "<<#x<<":"<<endl;cout<<#x<<" = "<<x<<endl
#define dbgv(v) cout<<"Debugging "<<#v<<":"<<endl; for(ll i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl;
using namespace std;
const ll MAXA=1e5+10;
int main() {
  FASTER;
  ll t=1;
  //cin >> t;
  while (t--) {
 	ll n,w;
 	cin>>n>>w;
 	ll max_val=0;
 	vll dp(MAXA,1e9+100);
 	dp[0]=0;
 	rep(i,0,n)
 	{
 		ll v1,w1;
 		cin>>w1>>v1;
 		max_val+=v1;
 		for(ll j=MAXA;j>=v1;j--)
 		{
 			dp[j]=min(dp[j],dp[j-v1]+w1);
 		}
 	}
 	for(ll i=max_val;i>=0;--i)
 	{
 		if(dp[i]<=w){cout<<i<<endl;break;}
 	}
  }
  return 0;
}




Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
using P = pair<int64_t, int64_t>;
int main() {
    int N;
    cin >> N;
    vector<P> x(N);
    for(int i = 0; i < N; i++) {
        int64_t A, B;
        cin >> A >> B;
        x[i] = {B, A};
    }
    sort(x.begin(), x.end());
    int64_t T = 0;
    for (int i = 0; i < N; i++) {
        T += x[i].second;
        if(x[i].first < T) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3328
n = int(input())
d = list(map(int,input().split()))
d.sort()
cs = [0]
ans = 0
l= 0
for i in range(d[-1]):
  temp = 0
  while(True):
    if i == d[l]:
      temp += 1
      l += 1
    else:
      break

  cs.append(cs[i]+temp)

ans = cs.count(n/2)
print(ans)

Measured memory_bytes: 14556
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [None for i in range(N)]

for i in range(N):
  A[i] = list(map(int, input().split()))

ans = 0

for i in range(N):
  tmp = 0
  for j in range(M):
    tmp += A[i][j] * B[j]
  tmp += C
  
  if tmp > 0:
    ans += 1

print(ans)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

struct Pos {
    int x, y;
};

void solve() {
    int H, W;
    ll K;
    cin >> H >> W >> K;
    Pos s, t;
    cin >> s.x >> s.y >> t.x >> t.y;
    --s.x, --s.y, --t.x, --t.y;
    vector<vector<bool>> cell(H, vector<bool>(W));
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for (int j = 0; j < W; j++) {
            if (S[j] == '@') cell[i][j] = true;
        }
    }

    if (cell[s.x][s.y] == 1) {
        cout << -1 << "\n";
        return;
    }

    constexpr Pos step[] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};

    using Vert = tuple<int, int, int>;
    auto l2v = [&](ll a) -> Vert {
        int v = a % 4;
        a /= 4;
        int y = a % W;
        a /= W;
        int x = a;
        return {x, y, v};
    };
    auto v2l = [&](const Vert& a) -> ll {
        const auto& [x, y, v] = a;
        return (ll)x * 4 * W + y * 4 + v;
    };

    using Tup = pair<ll, ll>;
    unordered_map<ll, ll> dp;
    priority_queue<Tup, vector<Tup>, greater<Tup>> q;
    q.emplace(0, v2l({s.x, s.y, 0}));
    dp[v2l({s.x, s.y, 0})] = 0;
    while (!q.empty()) {
        auto [c, p] = q.top();
        q.pop();
        if (c > dp[p])
            continue;
        auto [x, y, v] = l2v(p);
        int xn, yn;
        ll cn;
        // 前進
        xn = x + step[v].x;
        yn = y + step[v].y;
        if (xn >= 0 && xn < H && yn >= 0 && yn < W) {
            if (!cell[xn][yn]) {
                cn = c + 1;
                ll nxt = v2l({xn, yn, v});
                if (dp.find(nxt) == dp.end()) {
                    dp[nxt] = L_INF;
                }
                if (cn < dp[nxt]) {
                    dp[nxt] = cn;
                    q.emplace(cn, nxt);
                }
            }
        }
        // 回転
        v = (v + 1) % 4;
        xn = x;
        yn = y;
        cn = (c + K - 1) / K * K;
        ll nxt = v2l({xn, yn, v});
        if (dp.find(nxt) == dp.end()) {
            dp[nxt] = L_INF;
        }
        if (cn < dp[nxt]) {
            dp[nxt] = cn;
            q.emplace(cn, nxt);
        }
    }

    ll ans = L_INF;
    for (ll i = 0; i < 4; i++) {
        ll p = v2l({t.x, t.y, i});
        if (dp.find(p) == dp.end()) continue;
        if (ll tmp = dp[p]; tmp != L_INF) {
            ans = min(ans, (tmp + K - 1) / K);
        }
    }

    if (ans != L_INF)
        cout << ans << "\n";
    else
        cout << -1 << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 133864
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cctype>
#include <algorithm>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif

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

    auto judge = [&]() -> bool
    {
        if (s[0] != 'A')
            return false;
        int nc = 0;
        for (int i = 1; i < s.size(); ++i)
        {
            if (i > 1 && i < s.size() - 1 && s[i] == 'C')
            {
                if (++nc > 1) return false;
            }
            else if (not islower(s[i]))
                return false;
        }
        return (nc == 1);
    };

    cout << (judge() ? "AC" : "WA") << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
d = {i + 1: [] for i in range(N)}

for i in range(M):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

ans = False
one_to_i = d[1]
for i in one_to_i:
    if N in d[i]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")



Measured memory_bytes: 57188
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
public static void Ans() {

			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S = inputArray[0].Select(x=>x).ToArray();
			var rev = S.Reverse();

			if (string.Join("",S)!=string.Join("",rev)) {
				Console.WriteLine("No");
				return;
			}

			var part = S.Take((S.Length - 1) / 2).ToArray();
			var partrev = part.Reverse();

			if (string.Join("", part) != string.Join("", partrev)) {
				Console.WriteLine("No");
				return;
			}

			//答えの出力
			var ans = "Yes";
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}



Measured memory_bytes: 26796
#include <stdio.h>

int main() {
	
	int N = 0, H = 0, W = 0;
	scanf("%d %d %d",&N ,&H ,&W);
	int A[N], B[N];
	
	for( int i = 0; i < N; i++ ){
		scanf("%d %d",&A[i], &B[i]);
	}
	
	int count = 0;
	for( int i = 0; i < N; i++ ){
		if( H <= A[i] && W <= B[i] ){
			count++;
		}
	}
	
	printf("%d",count);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include "lib.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define LLINF 1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second
#define db 0
#define MAXN 200006
#define MAXK 200006
#define MAXX 200006
#define rep(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define bg(ms) *ms.begin()
#define ed(ms) *prev(ms.end(), 1)
#define addedge(a, b, c) v[a].pb(pi(b, c)); v[b].pb(pi(a, c))
#define ph push
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
ll n, m, AB[MAXN], voided[MAXN], vis[MAXN], ans;
string ss;
queue <ll> q;
vector <ll> v[MAXN];
int main()
{
	FAST   //my macro check above(the ios_base speed one)
	cin >> n >> m >> ss;
	for(ll i = 1; i <= n; i++)AB[i] = ((ss[i-1]=='A')?0:1);
	for(ll i = 0; i < m; i++)
	{
		ll n1, n2;
		cin >> n1 >> n2;
		v[n1].pb(n2);
		v[n2].pb(n1);
	}
	for(ll i = 1; i <= n; i++)v[i].resize( unique(v[i].begin(), v[i].end()) - v[i].begin());
	for(ll i = 1; i <= n; i++)q.push(i);
	while(!q.empty())
	{
		ll node = q.front();
		q.pop();
		if(vis[node] || voided[node])continue;
		ll a = 0, b = 0;
		vis[node] = 1;
		for(auto i : v[node])
		{
			if(voided[i])continue;
			if(AB[i] == 0)a++;
			else b++;
		}
		if(a >= 1 && b >= 1)   //don't need to void is a valid node
		{
			continue;
		}
		voided[node] = 1;
		ans++;
		for(auto i : v[node]) //push in neighbours as u are no longer a valid node
		{
			if(voided[i] || !vis[i])continue;
			vis[i] = 0;
			q.push(i);
		}
	}
	cout << ((n-ans > 0) ? "Yes" : "No") << "\n";
}


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

int dict(const void *a, const void *b) {
	return strcmp((char *)a, (char *)b);
}

int main() {
	int i, L, N;
	scanf("%d%d", &N, &L);
	char S[N][101];
	for (i=0;i<N;i++) {
		scanf("%s", &S[i]);
	}

	qsort(S, N, sizeof(char)*101, dict);
	for (i=0;i<N;i++) {
		printf("%s", S[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <map>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;
const int MAXN = 2e3+55;
int main()
{
    string s;
    cin>>s;
    char ans[100];
    int len = 0;
    for(int i = 0 ;i <s.size(); ++i)
    {
        if(s[i] == 'B')
        {
            if(len) len--;
        }
        else ans[++len] = s[i];

    }
    for(int i=1;i<=len;++i)
        cout<<ans[i];
    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    ll n;
    cin >> n;
    FOR(a, 1, 3501) FOR(b, 1, 3501) {
        ll bunshi = n * a * b;
        ll bunbo = 4 * a * b - (a + b) * n;
        if(bunbo > 0 && bunshi % bunbo == 0 && bunshi / bunbo > 0) {
            cout << a << " " << b << " " << bunshi / bunbo << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val A = listOfInt()
    val M = A.groupBy { it }.map { it.key to it.value.size }.sortedBy { it.second }.toTypedArray()
    var k = M.size
    var ans = 0
    for (n in 0 until M.size) {
        if  (k <= K) break
        ans += M[n].second
        k -= 1
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map(String::toLong)


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


int main(){
  int N, i, b;
  cin >> N ;
  vector<int> a(N);
  
  for(i = 0; i < N; i++){
    cin >> a.at(i);
  }

  b = a.at(0);
  for(i=1;i<N;i++){
    if(b == 2){
      cout << i << endl;
      break;
    }
    b = a.at(b-1);
    if(i == N-1){
      cout << -1 << endl;
      break;
    }
  }



}


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

using namespace std;
typedef long long int lld;
typedef set<lld>::iterator sit;
#define rep(i,a,b) for(int i=a;i<b;i++)
set<lld> pos;
bool hasPrev(sit it){
  if(it==pos.begin())return false;
  return true;
}
bool hasNext(sit it){
  if(it==pos.end())return false;
  if(next(it)==pos.end())return false;
  return true;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  int per[n];
  int inv[n];
  rep(i,0,n){
    cin>>per[i];
    per[i]--;
    inv[per[i]]=i;
  }
  lld ans=0;
  for(int i=n-1;i>-1;i--){
    sit it=pos.insert(inv[i]).first;
    lld A,B,C,D;
    if(!hasPrev(it)){
      A=0;
      B=inv[i]+1;
    }else{
      B=inv[i]-*prev(it);
      if(hasPrev(prev(it))){
	A=*prev(it)-*prev(prev(it));
      }else{
	A=*prev(it)+1;
      }
    }
    if(!hasNext(it)){//ut<<"N"<<endl;
      D=0;
      C=n-inv[i];
    }else{
      C=*next(it)-inv[i];
      if(hasNext(next(it))){
	D=*next(next(it))-*next(it);
      }else{
	D=n-*next(it);
      }
    }
    //ut<<A<<" "<<B<<" "<<C<<" "<<D<<endl;
    lld can=i+1;
    can*=B*D+C*A;
    ans+=can;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t=1;
	while(t--)
	{
		string s;
		cin >> s;
		int cnt=0,mx=0;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='R')
			cnt++;
			else
			{
				mx=max(mx,cnt);
				cnt=0;
			}
		}
		mx=max(mx,cnt);
		cout << mx;
	}
}




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

int main(){
    int N,M;
    int A,B;
    cin >> N >> M;
    vector<int> place(N,1);
    vector<int> H(N);
    for(int i=0;i < N;i++){
        cin >> H[i];
    }
    for(int i=0;i < M;i++){
        cin >> A >> B;
        if (H[A - 1] > H[B - 1]){
            place[B - 1] = 0;
        }else if(H[A - 1] == H[B - 1]){
            place[B - 1] = 0;
            place[A - 1] = 0;
        }else{
            place[A - 1] = 0;
        }
    }
    int ans = 0;
    for(int i= 0;i < N;i++){
        if(place[i] == 1){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  
  if (s.at(0) == s.at(1) && s.at(1) == s.at(2)) {
    cout << "Yes" << endl;
  }else if (s.at(1) == s.at(2) && s.at(2) == s.at(3)) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  } 
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

// ??????g????????????????????\?????????
void insertionSort(int A[], int n, int g) {
	for (int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while ((j >= 0) && (A[j] > v)) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellsort(int A[], int n) {
	for (int h = 1; ;) {
		if (h > n) break;
		G.push_back(h);
		h = 3 * h + 1;
	}

	for (int i = G.size() - 1; i >= 0; i--) {
		insertionSort(A, n, G[i]);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];
	cnt = 0;

	shellsort(A, n);

	cout << G.size() << "\n";
	for (int i = G.size() - 1; i >= 0; i--) {
		cout << G[i];
		if (i) cout << " ";
	}
	cout << "\n";
	cout << cnt << "\n";
	for (int i = 0; i < n; i++) cout << A[i] << "\n";

	return 0;
}

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

int K;
vector<ll> ans;
const ll MAX = 3234566667;

void dfs(ll cur)
{
	if(cur > MAX) return;
	ans.push_back(cur);
	int last = cur%10;
	dfs(10*cur+last);
	if(last >= 1) dfs(10*cur+last-1);
	if(last <= 8) dfs(10*cur+last+1);
}

void solve()
{
	for(int i=1;i<=9;++i) dfs(i);
	sort(ans.begin(),ans.end());
	ans.erase(unique(ans.begin(), ans.end()), ans.end());
	cout << ans[K-1] << '\n';
}

int main()
{
	cin >> K;
	solve();
	return 0;
}

Measured memory_bytes: 4232
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))

A.sort()
B.sort()
C.sort()

counts = []
a = 0
for b in range(N):
    while a < N and B[b] > A[a]:
        a += 1
    counts.append(a)

cs = list(itertools.accumulate(counts))
s = sum(counts)
ans = 0
b = 0
for c in range(N):
    while b < N and C[c] > B[b]:
        b += 1

    ans += cs[b - 1] if b - 1 >= 0 else 0
print(ans)


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

typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const int MOD = 1e9+7;

int look[101];
int a[101];

void calc(){
	int x, n; cin >> x >> n;
	int v[2] = {-1, 1};
	for(int i=0; i<n; i++){
		cin >> a[i];
		look[a[i]]++;
	}

	int ans;
	for(int i=0; i<=x; i++){
		for(int j=0; j<=1; j++){
			ans = x + (v[j]*i);
			if(look[ans] == 0){
				cout << ans;
				return;
			}
		}
	}
}


int main() {
	calc();


return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int a, b;
    cin >> a >> b;

    print((a + b + 1 ) / 2);
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> h(n);
  for(int i=0;i<n;i++)
    cin >> h.at(i);
  vector<int> a(m);
  vector<int> b(m);
  for(int i=0;i<m;i++)
    cin >> a.at(i) >> b.at(i);
  
  vector<vector<int>> p(n,vector<int>(0));
  
  for(int i=0;i<m;i++){
    p.at(a.at(i)-1).push_back(b.at(i));
    p.at(b.at(i)-1).push_back(a.at(i));
  }
  
  int l=0;
  
  for(int i=0;i<n;i++){
    int x=0;
    int y=p.at(i).size();
    for(int j=0;j<y;j++){
      if(h.at(i)<=h.at(p.at(i).at(j)-1)){
        x++;
      }
    }
    if(x==0){
      l++;
    }
  }
  cout << l << endl;
}

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

using namespace std;

int n, l;

int main(void)
{
	cin >> n >> l;
	int sum = 0;
	for(int i = 1; i <= n; i++) sum += l+i-1;
	
	int mn = 1e9, mn_i;
	for(int i = 1; i <= n; i++){
		if(mn > abs(l+i-1)){
			mn = abs(l+i-1);
			mn_i = i;
		}
	}
	cout << sum - (l+mn_i-1) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
//	ios::sync_with_stdio(false);
	ll a, v, b, w, t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	ll cnt = abs(a - b);
	ll cmt = v - w;
	if (cmt <= 0)
		cout << "NO" << endl;
	else {
		ll p = cnt/cmt;
		if (cnt % cmt != 0)
			p++;
		if (p <= t)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
		return 0;
}

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')


def solve():
    S = list(input())
    T = list(input())

    ds = {}
    dt = {}
    ids = ''
    idt = ''
    cids = 0
    cidt = 0
    for i in range(len(S)):
        # S
        s = S[i]
        if s in ds:     # 出現済みの文字なら、その文字のIDを追加する
            idss = ds[s]
            ids = ids + str(idss)
        else:           # 新たに出現した文字なら、新しいIDを追加し、メモしておく
            cids += 1
            ds[s] = cids
            ids = ids + str(cids)

        # T
        t = T[i]
        if t in dt:
            idst = dt[t]
            idt = idt + str(idst)
        else:
            cidt += 1
            dt[t] = cidt
            idt = idt + str(cidt)

        if ids != idt:
            print('No')
            return

    print('Yes')



if __name__ == '__main__':
    solve()


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

// --- DEBUG begin --- cut here ---
template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

template <class Head>
void dbgLog(Head&& head) {
  cerr << head << endl;
}

template <class Head, class... Tail>
void dbgLog(Head&& head, Tail&&... tail)
{
  cerr << head << " ";
  dbgLog(forward<Tail>(tail)...);
}

#if DEBUG
  #define DLOG(...)        dbgLog(__VA_ARGS__)
  #define DFMT(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFMT(...)
  #define DCALL(func, ...)
#endif

// operator<< definitions for some classes

template <typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1,T2>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}

template <typename T>
ostream& operator<< (ostream& os, const vector<T>& v) {
  os << '[';
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  os << ']';

  return os;
}

template <typename T, typename T2, typename T3>
ostream& operator<< (ostream& os, const priority_queue<T, T2, T3>& orig) {
  priority_queue<T, T2, T3> pq(orig);
  bool first = true;
  os << '[';
  while (!pq.empty()) {
    T x = pq.top(); pq.pop();
    if (!first) os << ", ";
    os << x;
    first = false;
  }
  return os << ']';
}
// --- DEBUG end --- cut here ---


vector<int> zAlg(string s) {
  int n = s.size();
  vector<int> z(n);
  z.at(0) = n;
  int i = 1;
  int j = 0;
  while (i < n) {
    for ( ; i+j < n && s.at(j) == s.at(i+j); j++) {}
    z.at(i++) = j;
    if (j > 0) {
      for (int k = 1; i < n && z.at(k) < j-1; k++, j--, i++) z.at(i) = z.at(k);
      j--;
    }
  }
  return z;
}

// matches("abab", "xababab") --> [1,3]
vector<int> matches(string p, string s, char sepChar = '\xff') {
  auto v = zAlg(p + string(1, sepChar) + s);
  int n = p.size();
  vector<int> res;
  for (size_t i = 0; i < s.size() - (n-1); i++) {
    if (v.at(n+1 + i) == n) res.push_back(i);
  }
  return res;
}


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N), B(N), p(N), q(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  for (ll i = 0; i < N; i++) cin >> B.at(i);
  for (ll i = 0; i < N; i++) {
    p.at(i) = A.at(i) ^ A.at((i+1) % N);
    q.at(i) = B.at(i) ^ B.at((i+1) % N);
  }
  stringstream ssp, ssq;
  for (ll k = 0; k < N; k++) {
    ssp << setfill('0') << setw(8) << hex;
    ssp << p.at(k);
    ssq << setfill('0') << setw(8) << hex;
    ssq << q.at(k);
  }
  string p1 = ssp.str(); p1 += p1;
  string q1 = ssq.str();
  DLOG("p", p);
  DLOG("q", q);
  DLOG("p1", p1);
  DLOG("q1", q1);
  for (ll y : matches(q1, p1)) {
    if (y % 8 != 0) continue;
    ll k = y / 8;
    if (k == N) continue;
    cout << k << " " << (B.at(0) ^ A.at(k)) << endl;
  }

  return 0;
}



Measured memory_bytes: 47548
#include <iostream>
#include <cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)

using namespace std;
int main(){
  int n;
  int a[100100]={};
  cin >> n;
  rep(i,n){
    int t;
    cin >> t;
    a[t]++;
  }
  if(n%2==1){
    if(a[0]!=1){
      cout << 0 << endl;
      return 0;
    }
    REP(i,1,n/2+1){
      if(a[i*2]!=2){
        cout << 0 << endl;
        return 0;
      }
    }
  }else{
    rep(i,n/2){
      if(a[i*2+1]!=2){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  long long ans = 1;
  rep(i,n/2){
    ans *= 2;
    ans %= 1000000007;
  }
  cout << ans << endl;

  return 0;

}


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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    string s;
    cin>>s;
    sort(s.begin(), s.end());
    cout<<((s == "abc")?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N;
LL ans;
int A[202020], B[202020];
int D[4040][4040], C[8080][4040];

int main(){
    scanf("%d", &N);
    for (int i=1; i<=N; i++){
        scanf("%d %d", &A[i], &B[i]);
        D[2020-A[i]][2020-B[i]]++;
    }
    C[0][0] = 1;
    for (int i=1; i<=8000; i++){
        C[i][0] = 1;
        for (int j=1; j<=4000; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
    }
    for (int i=1; i<=4030; i++) for (int j=1; j<=4030; j++) D[i][j] = (D[i][j] + D[i-1][j] + D[i][j-1]) % MOD;
    for (int i=1; i<=N; i++){
        ans = (ans + D[2020+A[i]][2020+B[i]]) % MOD;
        ans = (ans - C[2*(A[i]+B[i])][2*A[i]] + MOD) % MOD;
    }
    printf("%lld\n", (ans * 500000004) % MOD);
    return 0;
}


Measured memory_bytes: 193276
import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import combinations, permutations

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
ans = 0
mozi = defaultdict(int)
for i in range(N):
	s = input()
	mozi[s] += 1
M = int(input())
for i in range(M):
	t = input()
	mozi[t] -= 1

for i in mozi:
	ans = max(ans, mozi[i])
print(ans)

Measured memory_bytes: 38384
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll k,x;
        cin>>k>>x;
        if(k*500>=x)
        	cout<<"Yes";
        else
        	cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 300005;

set<pair<int,int>> t;
map<int,int> r;
map<int,int> c;

bool cmp1(const int &a, const int &b) {
	return r[a]>r[b];
}
bool cmp2(const int &a, const int &b) {
	return c[a]>c[b];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int h,w;
	cin >> h >> w;
	
	int m;
	cin >> m;
	
	while(m--){
		int x, y;
		cin >> x >> y;
		t.insert({x,y});
		r[x]++;
		c[y]++;
	}
	
	vector<int> rows;
	vector<int> cols;
	
	for (auto &p : r) {
		rows.pb(p.F);
	}
	for (auto &p : c) {
		cols.pb(p.F);
	}	
	
	sort(rows.begin(),rows.end(),cmp1);
	sort(cols.begin(),cols.end(),cmp2);
	
	while(r[rows[0]]!=r[rows.back()]) {
		rows.pop_back();
	}
	while(c[cols[0]]!=c[cols.back()]) {
		cols.pop_back();
	}
	
	int ans = r[rows[0]]+c[cols[0]];
	
	if (rows.size() * cols.size() > m){
		cout << ans << "\n";
		return 0;
	}
	
	bool found = false;
	
	FOR(i,0,SZ(rows)) {
		FOR(j,0,SZ(cols)) {
			if (!t.count({rows[i],cols[j]})) {
				found = true;
				break;
			}
		}
		
	}
	
	if (! found) {
		ans--;
	}
	
	cout << ans << "\n";
	
	
}


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

int main() {
  ll a,b,c; cin >> a >> b >> c;
  ll ans = 0;
  if (a%2 == 0 || b%2 == 0 || c%2 == 0) ans = 0;
  else {
    vector<ll> v = {a,b,c};
    sort(v.begin(), v.end());
    ans = abs(((v[2]/2) - (v[2]+1)/2)) * v[0] * v[1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
import Control.Applicative
import Control.Monad
import Data.Function
import Data.List

type Dice = (Int, Int, Int, Int, Int, Int)

topd :: Dice -> Int
topd (a, _, _, _, _, _) = a

frontd :: Dice -> Int
frontd (_, b, _, _, _, _) = b

rightd :: Dice -> Int
rightd (_, _, c, _, _, _) = c

spinl :: Dice -> Dice
spinl (a, b, c, d, e, f) = (a, d, b, e, c, f)

spinr :: Dice -> Dice
spinr (a, b, c, d, e, f) = (a, c, e, b, d, f)

moven :: Dice -> Dice
moven (a, b, c, d, e, f) = (b, f, c, d, a, e)

moves :: Dice -> Dice
moves (a, b, c, d, e, f) = (e, a, c, d, f, b)

movee :: Dice -> Dice
movee (a, b, c, d, e, f) = (d, b, a, f, e, c)

movew :: Dice -> Dice
movew (a, b, c, d, e, f) = (c, b, f, a, e, d)

move :: Char -> Dice -> Dice
move 'N' = moven
move 'S' = moves
move 'E' = movee
move 'W' = movew

allMoves :: Dice -> [Dice]
allMoves d = concatMap spins $ map ($d) [id, moven, moves, movee, movew, moven . moven]
  where
    spins x = [x, spinl x, spinr x, spinl (spinl x)]

normalize :: Dice -> Dice
normalize = minimum . allMoves

makeDice [a, b, c, d, e, f] = (a, b, c, d, e, f)

main = do
    n <- readLn
    dices <- replicateM n (normalize . makeDice . map read . words <$> getLine)
    putStrLn $ if (length . group . sort) dices == n then "Yes" else "No"



Measured memory_bytes: 4200
s = input()
k = int(input())
m = 0
n = 0
j = 0
for i in range(len(s)):
    if s.count(s[0]) == len(s):
        print(len(s) * k // 2)
        exit()
    if len(s) <= j + 1:
        if s[0] == s[-1] == s[len(s) // 3] ==s[1]:
            n += 1
        break
    if s[j] == s[j + 1]:
        if j == len(s) - 1:
            n += 1
        else:
            m += 1
        j += 1
    j += 1
print(m * k + n * (k - 1))


Measured memory_bytes: 3064
k, n = map(int, input().split())
a = list(map(int, input().split()))
if a[0]==0:
    key = k - a[-1]
else:
    key = k-a[-1]+a[0]
l = []
ans = 0
for i in range(n-1):
    ans += abs(a[i]-a[i+1])
    l.append(abs(a[i]-a[i+1]))
ans += key
l.append(key)
print(ans - max(l))


Measured memory_bytes: 25840
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#define INF 1000001LL
#define INF2 100000001000000LL
using namespace std;

typedef long long ll;
typedef vector<ll> cord;

inline ll dis(cord &a, cord &b){
  if(a.size() != b.size())return INF2;
  ll res = 0;
  for(int i=0;i<a.size();i++)res += (a[i]-b[i]) * (a[i]-b[i]);
  return res;
}

struct KDTree{
  int n,d;
  vector<cord> v;

  void heap_sort(int l,int r,int &k){
    if(r-l<=1)return;
    int now,nxt;
    for(int i=1;i<r-l;i++){
      now = i;
      while(now){
	nxt = (now-1)>>1;
	if(v[l+nxt][k] < v[l+now][k])swap(v[l+nxt],v[l+now]);
	else break;
	now = nxt;
      }
    }

    for(int i=r-l-1;i>0;i--){
      swap(v[l+i],v[l]);
      now = 0; nxt = (now+1)<<1;
      while(nxt-1 < i){
	if(v[l+now][k] < v[l+nxt-1][k]){
	  if(nxt<i && v[l+nxt-1][k] < v[l+nxt][k]){
	    swap(v[l+now],v[l+nxt]);
	    now = nxt;
	  }else{
	    swap(v[l+now],v[l+nxt-1]);
	    now = nxt-1;
	  }
	}else if(nxt<i && v[l+now][k] < v[l+nxt][k]){
	  swap(v[l+now],v[l+nxt]);
	  now = nxt;
	}else break;
	nxt = (now+1)<<1;
      }
    }
  }

  void compose(int l, int r, int depth){
    if(r-l<1)return;
    heap_sort(l,r,depth);

    compose(l,(l+r)/2,(depth+1)%d);
    compose((l+r)/2+1,r,(depth+1)%d);
  }

  void search(int l,int r,vector<ll>& b, cord& p, int depth, ll& dist){
    if(r-l<1)return;

    int mid = (l+r)/2;
    ll tmp;
    dist = min(dist,dis(p,v[mid]));

    for(int i=0;i<d;i++){
      tmp = b[2*i]-p[i];
      if(tmp>0 && tmp*tmp >= dist)return;
      tmp = b[2*i+1]-p[i];
      if(tmp<0 && tmp*tmp >= dist)return;
    }

    for(int i=0;i<3;i++){
      if(p[depth]>v[mid][depth] && i==2)continue;
      if(p[depth]<=v[mid][depth] && i==0)continue;
      int f = i&1;
      tmp = b[2*depth+f];
      b[2*depth+f] = v[mid][depth]; 
      if(f)search(l,mid,b,p,(depth+1)%d,dist);
      else search(mid+1,r,b,p,(depth+1)%d,dist);
      b[2*depth+f] = tmp;
    }
  }
};

int n,q,m;
cord p(3),r(3);
KDTree kd;

int main(){
  vector<ll> box;
  for(int i=0;i<3;i++){
    box.push_back(-INF); 
    box.push_back(INF);
  }

  while(scanf("%d%d",&n,&q)!=EOF,n||q){
    kd.v.resize(n);
    kd.n = n; kd.d = 3;

    for(int i=0;i<n;i++){
      kd.v[i].resize(3);
      for(int j=0;j<3;j++)scanf("%lld",&kd.v[i][j]);
    }

    kd.compose(0,n,0);

    for(int i=0;i<q;i++){
      scanf("%d",&m);
      double ans = 0;
      ll now,prv;

      for(int j=0;j<3;j++)scanf("%lld",&p[j]);
      prv = INF2;
      kd.search(0,n,box,p,0,prv);

      for(int j=1;j<m;j++){
	for(int k=0;k<3;k++)scanf("%lld",&r[k]);
	now = INF2;
	kd.search(0,n,box,r,0,now);

	ans += min( sqrt(prv) + sqrt(now), sqrt(dis(p,r)) );
	prv = now; p = r;
      }
      printf("%.9lf\n",ans);
    }
  }
}

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

int main()
{

    int R;
    cin >> R;

    if(R<1200){
        cout << "ABC" << endl;
    }
    else if(R>=1200 && R<2800){
        cout << "ARC" << endl;
    }
    else if (R >= 2800 )
    {
        cout << "AGC" << endl;
    }
}


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



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N;
	cin >> N;

	priority_queue<double,vector<double>,greater<double>> PQ;

	rep(i, N) {
		double tmp;
		cin >> tmp;
		PQ.push(tmp);
	}

	while (PQ.size() != 1) {

		double a = PQ.top();
		PQ.pop();
		double b = PQ.top();
		PQ.pop();

		PQ.push((a + b) / 2);

	}

	cout << setprecision(15) << PQ.top();

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A<=9 && B<=9){
      System.out.println(A*B);
    }else{
      System.out.println(-1);
    }
  }
}

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

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

  // ここにプログラムを追記
  int sum = 1;
  for(int i = 0; i < N; i++){
    if(sum <K){
      sum *= 2;
    }else{
      sum += K;
    }
  }
  
  cout << sum << endl;
 
}


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

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  vector<int> a(n);
  for(int i=0; i<n; i++)cin>>a.at(i);

  vector<int> s;
  for(int i=0; i<n; i++){
    for(int j=0; j<a.at(i); j++)s.push_back(i+1);
  }

  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(i%2==0)cout<<s.at(i*w+j)<<" ";
      else cout<<s.at(i*w+w-1-j)<<" ";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int d;
    string ans = "Christmas";
    string plus = " Eve";
    cin >> d;
    rep(_,25-d) ans += plus;
    PRINT(ans);
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ans = [0 for i in range(n)]
    a_list = list(map(lambda x: int(x)-1,input().split()))
    for a in a_list:
        ans[a] += 1

    for a in ans:
        print(a)


    return

if __name__ == "__main__":
    main()

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

# どのようにしても合格できない場合
if sum(a) < sum(b):
    print(-1)
    exit()

sum_minus = 0
ans = 0
a_minus_b = []
for i in range(n):
    if a[i] < b[i]:
        sum_minus += a[i] - b[i]
        ans += 1
    a_minus_b.append(a[i] - b[i])

if sum_minus >= 0:
    print(ans)
    exit()

for i in sorted(a_minus_b, reverse=True):
    sum_minus += i
    ans += 1
    if sum_minus >= 0:
        print(ans)
        exit()

Measured memory_bytes: 18356
#include<iostream>
using namespace std;
 
void sort(int* a,int n){
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i]>a[j]){
        int temp=a[i];
        a[i]=a[j];
        a[j]=temp;
      }
    }
  }
}
 
int main(){
  
  int a,b;
  a=0;
  b=0;
  
  int N;
  cin>>N;
  int d[101];
  for(int i=0;i<N;i++)cin>>d[i];  
  
  sort(d,N);
  for(int i=0;i<N;i++){
    if(i%2==0)a+=d[i];
    else b+=d[i];
  }
  cout<<a-b;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    map<int64_t,int> data;
    rep(i,n){
        int64_t a;
        cin>>a;
        data[a]++;
    }
    int Sum=0;
    for(auto itr=data.begin();itr!=data.end();itr++){
        if((itr->second)%2==1) Sum++;
    }
    cout<<Sum<<endl;
}


Measured memory_bytes: 6528