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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  int a[n];
  REP(i,n)cin >> a[i];

  int rgb[3] = {0};
  bool flg ;
  ll res = 1;
  REP(i,n){
    flg = true;
    int count = 0;
    REP(j,3){
      if(rgb[j] == a[i]){
        count++;
        if(flg){
          rgb[j]++;
          flg = false;
        }
      }
    }
    res *= count;
    res %= MOD;

  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4004
import java.io.*;
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int s=sc.nextInt();
    int w=sc.nextInt();
    if(w>=s)
      System.out.println("unsafe");
    
    else
      System.out.println("safe");
  }
}  


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

int64_t solve(int k, int a, int b) {
  if (a >= b - 2)
    return 1 + k;
  
  int64_t res = 1;
  res += std::min(a - 1, k);
  k -= std::min(a - 1, k);
  if (k >= 2) {
    res += (int64_t)(b - a) * (k / 2);
    k %= 2;
  }
  if (k == 1)
    ++res;
  return res;
}

int main() {
  int k, a, b;
  std::cin >> k >> a >> b;
  std::cout << solve(k, a, b) << std::endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = np.maximum(dp[n-1][w:W+1], dp[n-1][:W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])


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

#define FOR(i,a,b) for (ll i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (ll i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<ll>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll N, K; cin >> N >> K;

    vi HS (N);
    F0R(i, N) cin >> HS[i];

    sort(HS.begin(), HS.end(), greater<ll>());
    
    ll ans = 0;
    for (ll i = K; i < N; ++i) {
        ans += HS[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int A,B,C,K;
	cin >> A >> B >> C >> K;
	if(K % 2 == 1) {
		cout << B - A << endl;
	}
	else {
		cout << A - B << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
a = []
b = []
for i in range(n):
    a_e, b_e = map(int, input().split())
    a.append(a_e)
    b.append(b_e)

ans = 0

for i in range(n)[::-1]:
    mod = (a[i] + ans) % b[i]
    if mod != 0:
        ans += b[i] - mod

print(ans)

Measured memory_bytes: 11052
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }

        
         public static long gcd(long x, long y)
        {
            if (x < y) gcd(y, x);
            while (y != 0)
            {
                var z = x;
                x = y;
                y = z % y;
            }
            return x;
        }

        public static long lcm(long x, long y)
        {
            return x * y / gcd(x, y);
        } 

        public static long C(long n, long k)
        {
            long x = 1;
            for (long i = 1; i <= k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var a = ReadLine();
            var b = ReadLine();
            var c = ReadLine();
            var ac = 0;
            var bc = 0;
            var cc = 0;
            var flag ='a';
            var win = "";
          
            while (true)
            {
             
                if (flag == 'a')
                {
                    if (ac == a.Length)
                    {
                        win = "A";
                        break;
                    }
                    flag = a[ac];
                    ac++;             
                }
                else if (flag == 'b')
                {
                    if (bc == b.Length)
                    {
                        win = "B";
                        break;
                    }
                    flag = b[bc];
                    bc++;
                }
                else if (flag == 'c')
                {
                    if (cc == c.Length)
                    {
                        win = "C";
                        break;
                    }
                    flag = c[cc];
                    cc++;
                }
            }
            if (win=="A") WriteLine("A");
            else if (win=="B") WriteLine("B");
            else WriteLine("C");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 17264
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    char[] c = Console.ReadLine().Replace(" ", "").ToCharArray();
	    if(c[0] > c[1]) Console.WriteLine(">");
	    else if(c[0] < c[1]) Console.WriteLine("<");
	    else Console.WriteLine("=");
	    
	} 
}

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

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

    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    
    if(u == s) a--;
    else b--;

    cout << a << ' ' << b << 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 n = sc.nextInt();
                int m = 0;
                for (int i = 0; i < n; i++) {
                        if (sc.next().equals("(")) {
                                m += sc.nextInt();
                        } else {
                                m -= sc.nextInt();
                                if (m < 0) {
                                        System.out.println("NO");
                                        return;
                                }
                        }
                }
                if (m == 0) {
                        System.out.println("YES");
                } else {
                        System.out.println("NO");
                }
        }
}

Measured memory_bytes: 33140
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

const int N = (int)1e5;

char s[N+5];

int main(){
    scanf("%s", s);
    int rock = 0, res = 0;
    for (int i=0; s[i]; i++) {
        if (s[i] == 'g') {
            if (rock > 0) {
                rock -= 1;
                res += 1;
            } else {
                rock += 1;
            }
        } else {
            if (rock > 0) {
                rock -= 1;
            } else {
                rock += 1;
                res -= 1;
            }
        }
    }
    printf("%d\n", res);
    return 0;
}


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

int h, w;
const int MOD = 1000000007;

int main() {
	cin >> h >> w;
	char c[h+1][w+1];
	long long dp[h+1][w+1];
	for (int i=1; i<=h; i++) {
		for (int j=1; j<=w; j++) {
			cin >> c[i][j]; 
		}
	}
	for (int i=0; i<=h; i++) dp[i][0] = 0;
	for (int i=1; i<=w; i++) dp[0][i] = 0;
	dp[1][1] = 1;
	for (int i=1; i<=h; i++) {
		for (int j=1; j<=w; j++) {
			if (i == 1 & j==1) continue;
			dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
			if (c[i][j] == '#') dp[i][j] = 0;
		}
	}
	cout << dp[h][w] << endl;
}

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int gcd(int x,int y){
    return y ? gcd(y,x%y) : x;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> d(n);
    rep(i,0,n){
        cin >> d[i];
    }
    int res=0;
    rep(i,0,n){
        for(int j=i+1;j<n;j++){
            res += d[i]*d[j];
        }
    }
    cout << res << endl;
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

char field[30][30];

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};


struct P {
  int x, y, cost;
  long c;
};

int main() {
  int w, h, swn;
  while(cin >> w >> h, w | h) {
    vector<vector<set<long>>> G(h, vector<set<long>>(w));
    map<char, int> id;
    fill_n((char*)field, 30 * 30, '#');
    int sx, sy;
    int gx, gy;
    REP(y, h){
      REP(x, w){
        cin >> field[y][x];
        switch (field[y][x]) {
        case '<':
          gx = x;
          gy = y;
          break;
        case '@':
          sx = x;
          sy = y;
          break;
        case '.':
        case '#':
          break;
        default:
        {
          char c = tolower(field[y][x]);
          if (!EXIST(id, c)) {
            id[c] = id.size();
          }
        }
        break;
        }
      }
    }
    swn = id.size();

    queue<P> que;
    G[sy][sx].insert(0);
    que.push({sx, sy, 0, 0});
    int res = -1;
    while(!que.empty()) {
      P p = que.front(); que.pop();
      // LOG("%d %d %d %d\n", p.x, p.y, p.c, p.cost);
      if (p.x == gx && p.y == gy) {
        res = p.cost;
        break;
      }

      REP(i, 4){
        int nx = p.x + dx[i];
        int ny = p.y + dy[i];
        int ncost = p.cost + 1;
        long nc = p.c;
        if (field[ny][nx] == '#') continue;
        if ('a' <= field[ny][nx] && field[ny][nx] <= 'z') {
          nc ^= 1 << (field[ny][nx] - 'a');
        }
        if ('A' <= field[ny][nx] && field[ny][nx] <= 'Z') {
          if(!(nc & (1 << (field[ny][nx] - 'A')))) continue;
        }
        if (!EXIST(G[ny][nx],nc)) {
          G[ny][nx].insert(nc);
          que.push({nx, ny, ncost, nc});
        }
      }
    }

    cout << res << endl;
  }
}

Measured memory_bytes: 12680
x = int(input())

ans = []
if x == 1:
  print(1)
  exit()

for i in range(2,x+1):
  for j in range(2,x+1):
    if i**j > x:
      break
    ans.append(i**j)

if len(ans)==0:
  print(0)
else:
  print(max(ans))

Measured memory_bytes: 38384
const maxn = 100000;
var a:array[1..maxn] of string;
    cnt,i,n:longint;
    re:int64;

procedure sort(l,r:longint; var s:string);
var tmp,x:char;
    i,j:longint;
begin
	if l >= r then exit;
	i:=l; j:=r; x:=s[(l + r) shr 1];
	repeat
	  while s[i] < x do inc(i);
	  while s[j] > x do dec(j);
	  if i <= j then
	    begin
	      tmp:=s[i]; s[i]:=s[j]; s[j]:=tmp;
	      inc(i); dec(j);
	    end;
	until i > j;
	sort(l,j,s); sort(i,r,s);
end;

procedure arrange(l,r:longint);
var tmp,x:string;
    i,j:longint;
begin
	if l >= r then exit;
	i:=l; j:=r; x:=a[(l + r) shr 1];
	repeat
	  while a[i] < x do inc(i);
	  while a[j] > x do dec(j);
	  if i <= j then 
      begin
        tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;
        inc(i); dec(j);
      end;
	until i > j;
	arrange(l,j); arrange(i,r);
end;

function calc(x:longint):int64;
var ans,tmp:int64;
begin
	tmp:=x;
	ans:= (tmp * (tmp - 1)) shr 1;
	calc:=ans;
end;

begin
	readln(n);
	for i:=1 to n do readln(a[i]);
	for i:=1 to n do sort(1,10,a[i]);
	arrange(1,n);
	cnt:=1; re:=0;
	for i:=2 to n do
	  begin
	    if a[i] = a[i-1] then inc(cnt)
	    else if cnt >= 2 then 
	      begin
	        re:= re + calc(cnt);
	        cnt:=1;
	      end;
	    if (i = n) and (cnt >= 2) then re:= re + calc(cnt);
	  end;
	writeln(re);
end.

Measured memory_bytes: 29184
#include <stdio.h>
#include <stdlib.h>
#define int long long

int M;

int MOD(int a){
	a %= M;
	return a >= 0 ? a : a + M;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

signed main(){
	int N, i, j, ans, ways;
	scanf("%lld%lld", &N, &M);
	int *fact = (int *)malloc(sizeof(int) * (N + 1));
	int *fact_inv = (int *)malloc(sizeof(int) * (N + 1));
	int *comb = (int *)malloc(sizeof(int) * (N + 1));
	fact[0] = 1;
	for(i = 1; i <= N; i++){
		fact[i] = MOD(fact[i - 1] * i);
	}
	fact_inv[0] = 1;
	fact_inv[1] = 1;
	for(i = 2; i <= N; i++){
		fact_inv[i] = MOD(-(M / i) * fact_inv[M % i]);
	}
	for(i = 2; i <= N; i++){
		fact_inv[i] = MOD(fact_inv[i - 1] * fact_inv[i]);
	}
/*	for(i = 0; i <= N; i++){
		printf("fact[%lld] = %lld\n", i, fact[i]);
	}
	for(i = 0; i <= N; i++){
		printf("fact_inv[%lld] = %lld\n", i, fact_inv[i]);
	}
*/	for(i = 0; i <= N; i++){
		comb[i] = MOD(fact[N] * MOD(fact_inv[i] * fact_inv[N - i]));
	}
	int **dp = (int **)malloc(sizeof(int *) * (N + 1));
	for(i = 0; i <= N; i++){
		dp[i] = (int *)malloc(sizeof(int) * (N + 1));
		dp[i][0] = 1;
	}
	for(j = 1; j <= N; j++){
		dp[0][j] = 0;
	}
	for(i = 1; i <= N; i++){
		for(j = 1; j <= N; j++){
			dp[i][j] = MOD(dp[i - 1][j] + dp[i - 1][j - 1] + j * dp[i - 1][j]);
		}
	}
/*	for(i = 0; i <= N; i++){
		for(j = 0; j <= N; j++){
			printf("dp[%lld][%lld] = %lld  ", i, j, dp[i][j]);
		}
		printf("\n");

	}
*/	int *two_pow_mod_Mm1 = (int *)malloc(sizeof(int) * (N + 1));
	two_pow_mod_Mm1[0] = 1;
	for(i = 1; i <= N; i++){
		two_pow_mod_Mm1[i] = (2 * two_pow_mod_Mm1[i - 1]) % (M - 1);
	}
	for(i = 0, ans = 0; i <= N; i++){
//		printf("i = %lld\n", i);
		for(j = 0, ways = 0; j <= i; j++){
//			printf("j = %lld\n", j);
			ways = MOD(ways + dp[i][j] * power(2, ((N - i) * j + two_pow_mod_Mm1[N - i]) % (M - 1)));
//			printf("ways = %lld\n", ways);
		}
//		printf("ways = %lld\n", ways);
//		printf("comb[%lld] = %lld\n", i, comb[i]);
		ans = MOD(ans + ((i & 1) == 0 ? 1 : -1) * comb[i] * ways);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 72704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100005],w[100005],v[100005];
int main(){
	ll n,k,ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	fill(dp,dp+100004,1000000007);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=100000;j>=v[i];j--){
			if(dp[j-v[i]]!=1000000007)dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	for(int i=100000;i>=0;i--){
		if(dp[i]<=k and dp[i]!=1000000007){	
			cout<<i<<'\n';
			break;
		}
	}
//	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
int n;
ll a[5010];
char s[5010];
bool Check(int len) {
	if(len==0) return 1;
	int i,j,k;
	ll p=1;
	for(i=0;i<len;i++)p=p*26%mod;
	for(i=0;i<n;i++) {
		if(i==0) a[i]=s[i]-'a';
		else a[i]=(a[i-1]*26+s[i]-'a')%mod;
		if(i>=len) a[i]=(a[i]-p*(s[i-len]-'a')%mod+mod)%mod;
	}
	for(i=len-1;i<n;i++) {
		for(j=i+len;j<n;j++) {
			if(a[i]==a[j]) {
				bool f=1;
				for(k=0;k<len;k++)
					if(s[i-k]!=s[j-k]){f=0;break;}
				if(f) return 1;
			}
		}
	}
	return 0;
}
int main() {
	scanf("%d%s",&n,&s);
	int lo=0,hi=n;
	while(lo<hi) {
		int mid=(lo+hi+1)/2;
		if(Check(mid)) lo=mid;
		else hi=mid-1;
	}
	printf("%d",lo);
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

void dps(vector<vector<long>> &tree, vector<long> &res, map<pair<long, long>, long> &M, long now, long par, long &maxcol) {

	long parcol;
	if (par != -1) parcol = res[M.at(make_pair(par, now))];
	else parcol = -1;

	long col = 1;
	for (auto e : tree[now]) {
		if (e == par) continue;
		if (col == parcol) col++;
        maxcol = max(maxcol, col);
		res[M.at(make_pair(now, e))] = col; col++;
		dps(tree, res, M, e, now, maxcol);
	}
}


int main() {

	long N; cin >> N;
    long maxcol = INT_MIN;
	vector<vector<long>> tree(N);
	vector<long> res(N);
	map<pair<long, long>, long> M;
	for (int i = 0; i < N - 1; i++) {
		long a, b; cin >> a >> b; a--; b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
		M.emplace(make_pair(a, b),i);
		M.emplace(make_pair(b, a),i);
	}

	dps(tree, res, M, 0, -1, maxcol);
    cout << maxcol << endl;
	for (int i = 0; i < N - 1; i++) {
		cout << res[i] << endl;
	}
}

Measured memory_bytes: 19840
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

struct P{
	int x, y;
	P(){}
	P(int x_, int y_){
		x = x_; y = y_;
	}
};

const int INF = 1e+8;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};
int c[100][100], d[100][100];

int bfs(int w, int h){
	queue<P> q;
	d[0][0] = 0;
	q.push( P(0, 0) );
	while( !q.empty() ){
		int x = q.front().x, y = q.front().y; q.pop();
		
		if( x == w - 1 && y == h - 1 ) return d[y][x] + 1;
		
		for(int i = 0 ; i < 4 ; i++ ){
			int mx = x + dx[i], my = y + dy[i];
			if( 0 <= mx && 0 <= my && mx < w && my < h && c[my][mx] == 0 ){
				int nx = mx + dx[i], ny = my + dy[i];
				if( 0 <= nx && 0 <= ny && nx < w && ny < h && d[ny][nx] == INF ){
					d[ny][nx] = d[y][x] + 1;
					q.push( P(nx, ny) );
				}
			}
		}
	}
	return 0;
}

int main(){
	int w, h;
	while( cin >> w >> h , w || h ){
		for(int y = 0 ; y < 100 ; y++ ){
			fill(c[y], c[y] + 100, 0);
			fill(d[y], d[y] + 100, INF);
		}
		
		for(int y = 0 ; y < 2 * h - 1 ; y++ ){
			if( y % 2 == 0 ){
				for(int x = 0 ; x < w - 1 ; x++ ){
					cin >> c[y][x * 2 + 1];
				}
			}else{
				for(int x = 0 ; x < w ; x++ ){
					cin >> c[y][x * 2];
				}
			}
		}
		int ans = bfs(w * 2 - 1, h * 2 - 1);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1292
#include<iostream>
#include<vector>
#include<algorithm>

int main()
{
	std::vector<int> num(5);

	std::cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4];

	std::sort(num.begin(),num.end());

	for(size_t i=0; i<num.size()-1; ++i)
	{
		std::cout << num[num.size()-1-i] << ' ';
	}

	std::cout << num[0] << '\n';
}

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

int main() {
    int h, w, d;
    char t[] = { 'R', 'Y', 'G', 'B' };
    std::cin >> h >> w >> d;
    std::vector<std::vector<int>> b(500, std::vector<int>(500));

    if (d % 2) {
        for (int i = 0; i < 500; i++) {
            for (int j = 0; j < 500; j++) {
                b[i][j] = (i + j) % 2;
            }
        }
    } else {
        for (int i = 0; i < 500; i++) {
            for (int j = 0; j < 500; j++) {
                int p = (i - j + 500 * d) % (d * 500) / d % 2,
                    q = (i + j) / d % 2;
                b[i][j] = (p << 1) + q;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) std::cout << t[b[i][j]];
        std::cout << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1536
s = list(input())
l, r = -1, -1

for i in range(len(s)-1):
  if s[i] == s[i+1]:
    l, r = i+1, i+2
    break
  else:
    if i + 2 <= len(s)-1:
      if s[i] == s[i+2]:
        l, r = i+1, i+3
        break
print(l, r)

Measured memory_bytes: 3956
#include<iostream>
#include<cstring>
using namespace std;
int x[10000][1440],y[10000],n,m,r,q,i,j,a,b,c,d,s;
int main() {
	while (true) {
		memset(x, 0, sizeof(x));
		cin >> n >> m >> r; if (n == 0) { break; }
		for (i = 0; i < r; i++) {
			cin >> a >> b >> c >> d;
			if (d == 1) {
				y[c]++;
				for (j = a; j < 1440; j++) {
					x[c][j] = 1;
				}
			}
			else {
				y[c]--;
				if (y[c] == 0) {
					for (j = a; j < 1440; j++) {
						x[c][j] = 0;
					}
				}
			}
		}
		cin >> q;
		for (i = 0; i < q; i++) {
			s = 0;
			cin >> a >> b >> c;
			for (j = a; j < b; j++) {
				if (x[c][j] == 1) { s++; }
			}
			cout << s << endl;
		}
	}
}

Measured memory_bytes: 57456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int ans = 0;
        for (int i = 0; i < 5; i++) {
            int x = sc.nextInt();
            if (x == 0)
                ans = i+1;
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32864
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

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

    cout << 48-a << endl;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: Int -> [Int] -> Int
solve time [t] = time
solve time (t1:t2:ts) = result + solve time (t2:ts)
  where result = min time $ t2 - t1

main :: IO ()
main = do
  [n, t] <- map read . words <$> getLine
  ss <- readIntsLine
  print $ solve t ss

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

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

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

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

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long int dp[100030] = {};
int main() {
	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe";
	}
	else {
		cout << "safe";
	}
}

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

bool is_sosuu(int a){
  for(int i=2; i*i<=a; i++){
    if(a%i==0){
      return false;
    }
  }
  return true;
}

int main(){
  int x;cin>>x;
  for(int i=x; i<=100003; i++){
    if(is_sosuu(i)){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
  char c[5]={'a','i','u','e','o'};
  char a;
  bool ok=false;
  cin>>a;
  rep(i,5){
    if(c[i]==a)ok=true;
  }
  if(ok)cout<<"vowel"<<endl;
  else cout<<"consonant"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

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

    stack<char> stk;
    int ans = 0;
    rep(i,s.size()){
        if(stk.empty() || stk.top()==s[i]){
            stk.push(s[i]);
        }else{
            ans++;
            stk.pop();
        }
    }
    cout<<ans*2<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int d=a+b;
    if(d<c)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define inl inline
#define br break
#define con continue
#define mst(a,b) memset(a,b,sizeof(a))
#define fora(x,a,b) for(re nti (x)=(a);(x)<=(b);++(x))
#define forb(x,a,b) for(re nit (x)=(a);(x)>=(b);--(x))
#define re register
#define stt struct
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define abss(x) ((x)>(0)?(x):(-1)*(x))
#define maxx(a,b) ((a)>(b)?(a):(b))
#define minn(a,b) ((a)<(b)?(a):(b))
#define pf(_) ((_)*(_))
#define in(a) freopen("D:/""/in"a".in","r",stdin)
#define out(a) freopen("D:/""/out"a".out","w",stdout)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=10004;
const nit maxb=1e2;
const nit maxc=5;
#include<iostream>

string x;
tni p=0,s;
char ans[maxa]="";

tni main()
{
	//in("4");
	//
	cin>>x;
	s=x.size();
	//
	fora(i,0,s-1)
	{
		if(x[i]=='0')
		{
			ans[++p]='0';
		}
		else if(x[i]=='1')
		{
			ans[++p]='1';
		}
		else if(x[i]=='B')
		{
			if(p>0)
			{
				--p;
			}
		}
	}
	//
	fora(i,1,p)
	{
		pritnf("%c",ans[i]);
	}
	pritnf("\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String n = sc.next();

        char x = n.charAt(n.length() - 1);
        if (x == '3') {
            System.out.println("bon");
        } else if (x == '0' || x == '1' || x == '6' || x == '8') {
            System.out.println("pon");
        } else {
            System.out.println("hon");
        }
    }
}

Measured memory_bytes: 35544
#include <bits/stdc++.h>
#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++)
using namespace std;

int main() {
  int n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1)<<endl; 
}

Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
int n ,tmp;
string str;
char s;
bool b = 1;
 set<string> st;
int  main(){ios::sync_with_stdio(0) ,cout.tie(0) ,cin.tie(0);
    cin >> n >> str,st.insert(str) ,s = str[str.size() - 1];
    for(register int i = 1; i < n; i++){       
        cin >> str;
        tmp = st.size();
        str[0] != s ? b = 0 : b = b;
        s = str[str.size() - 1];
        st.insert(str),
        st.size() == tmp ? b = 0 : b = b;
    }
    b  ? cout << "Yes" : cout << "No";
    return 0;
}








Measured memory_bytes: 256
N = int(input())
Match = [0] * N
mod = 10**9 + 7
for i in range(N):
    A = list(map(int, input().split()))
    m = 0
    for j, a in enumerate(A):
        if a:
            m |= (1 << j)
    Match[i] = m

DP = [0] * (1 << N)
DP[0] = 1

bit_count = [0]
for _ in range(N):
    bit_count += [x+1 for x in bit_count]

for i in range((1 << N) - 1):
    c = bit_count[i]
    if DP[i] == 0:
        continue
    for j in range(N):
        if (Match[c] >> j) & 1 == 1:
            if (i >> j) & 1 == 0:
                DP[i| (1 << j)] += DP[i]
                DP[i| (1 << j)] %= mod
print(DP[-1] % mod)


Measured memory_bytes: 190360
import sys

H, W = map(int, input().split())

A = []
for i in range(H):
    A.append(list(input()))

# print(A)
for r in range(H):
    for line in range(W):
        # print(r, line)
        if(A[r][line] != "#"):
            continue

        # print(r, line, A[r][line])

        if(line == 0 or W == 1):
            L = False
        else:
            L = A[r][line - 1] == "#"

        if(r == 0 or H == 1):
            U = False
        else:
            U = A[r - 1][line] == "#"

        if(line == W - 1 or W == 1):
            R = False
        else:
            R = A[r][line + 1] == "#"

        if(r == H - 1 or H == 1):
            D = False
        else:
            D = A[r + 1][line] == "#"

        # print(L, U, R, D)
        # print(L or U or R or D)
        if((L or U or R or D) is False):
            print("No")
            sys.exit()

print("Yes")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;
    set<string> se;
    rep(i, s.size())
    {
        repi(j, i, s.size())
        {
            if (j - i >= k)
            {
                continue;
            }
            string t = s.substr(i, j - i + 1);
            se.insert(t);
        }
    }
    auto ite = se.begin();
    rep(i, k - 1)
    {
        ite++;
    }
    cout << *ite << endl;
    return 0;
}


Measured memory_bytes: 1664
#include<cstdio>
using namespace std;
int a,b;
int main()
{
    scanf("%d%d",&a,&b);
    if(a>0)
		puts("Positive");
    else if(b>=0)
		puts("Zero");
    else if((a&1)^(b&1))
		puts("Positive");
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	float high=0,low=0,x,ans=0;
	int i=0;
	while(scan.hasNext())
	    {		
		x=scan.nextFloat();
		if(i==0)
		    {
			low=x;
		    }
		
		if(high<x)high=low;
		if(low>x)low=x;
		ans=high-low;
		
		i++;
	    }
	System.out.println(ans);
    }
}

Measured memory_bytes: 18616
N = int(input())
t_x_y = [list(map(int, input().split())) for _ in range(N)]
t_x_y.insert(0, [0, 0, 0])

ans = 'Yes'
for i in range(N):
  dt = t_x_y[i+1][0] - t_x_y[i][0]
  dist = abs(t_x_y[i+1][1] - t_x_y[i][1]) + abs(t_x_y[i+1][2] - t_x_y[i][2])
  
  if dt < dist:
    ans = 'No'
    break
  else:
    # dt >= dist
    if (dt - dist) % 2 != 0:
      ans = 'No'
      break
  
print(ans)

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
    
    n = int(lines[0])
    x = [int(e) for e in lines[1].split(" ")]

    return (n, x)


def solve(n, x):


    result = float('inf')
    for p in range(1, 101):
        tmp = int(sum([(e - p)**2 for e in x]))
        if tmp < result:
            result = tmp

    return  result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 3188
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val S, T = sc.nextLine()
    val to = scala.collection.mutable.Map.empty[Char, Char]
    val used = scala.collection.mutable.Set.empty[Char]
    val res = S.zip(T).forall { case (s, t) =>
      if (to.contains(s)) {
        to(s) == t
      } else {
        if (!used.contains(t)) {
          to.put(s, t)
          used.add(t)
          true
        } else false
      }
    }
    println(if (res) "Yes" else "No")
  }

}

Measured memory_bytes: 42192
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll cnum = b/c - (a-1)/c;
    ll dnum = b/d - (a-1)/d;
    ll cdnum = b/((d*c)/mygcd(d,c)) - (a - 1)/((d*c)/mygcd(d,c));

    cout << b - a + 1 - (cnum + dnum - cdnum) << endl;

    return 0;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
a = [-int(i) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, ((heapq.heappop(a)*-1//2)*(-1)))
print(sum(a)*-1)

Measured memory_bytes: 14180
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int a = int.Parse(input[1]);
        int b = int.Parse(input[2]);
        char[] s = Console.ReadLine().ToCharArray();
        int cntJ = 0,cntF = 0;
        for(int i = 0;i<s.Length;i++)
        {
            if (s[i] == 'c')
            {
                Console.WriteLine("No");
            }
            else if (s[i] == 'a' && cntJ + cntF < a + b)
            {
                cntJ++;
                Console.WriteLine("Yes");
            }
            else if (s[i] == 'b')
            {
                if (cntJ + cntF < a + b && cntF < b)
                {
                    cntF++;
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
                Console.WriteLine("No");

        }
    }
}   

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  int ans = 0;
  while(C>0){
    if ( B - A < 0) break;
    ans++;
    B -= A;
    C--;
  }
  
  cout << ans << endl;
  
  return 0;
}


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

int main()
{
    std::unordered_map<std::string, int> mp;
    int n;
    std::cin >> n;
    std::string str;
    std::cin >> str;
    mp[str] = 1;
    char last = str.back();

    for(int i = 1; i < n; i++) {
        std::cin >> str;
        if (mp[str] == 1 || str[0] != last) {
            std::cout << "No" << std::endl;
            return 0;
        }
        mp[str] = 1;
        last = str.back();
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(
       n: usize,
       s: chars,
    );
    let mut e = 0;
    for i in 0..n {
        let mut j = 1;
        while j * 2 + i < n {
            if s[i] != s[i + j] && s[i] != s[i + 2 * j] && s[i + j] != s[i + 2 * j] { e += 1 }
            j += 1;
        }
    }
    let r = s.clone().into_iter().filter(|&x| x == 'R').count();
    let g = s.clone().into_iter().filter(|&x| x == 'G').count();
    let b = s.clone().into_iter().filter(|&x| x == 'B').count();
    let ans: usize = r * g * b - e;
    println!("{}", ans);
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


/*https://atcoder.jp/contests/atc002/tasks/atc002_c
ここで解説されているO(N^3)のDPを行う
Skew heapなどを使えばO(nlogn)でできるらしい
*/

ll dp[405][405];
int N;
vll a(405);
vll Sum(405);

ll rec(int i, int j) { //[i,j)における最小コスト
    if (j == i + 1) return a[i];
    if (dp[i][j] != -1) return dp[i][j];
    ll res = INF;
    ll tmp;
    for (int k = i + 1; k < j ; k++) {
        tmp = rec(i, k) + rec(k, j)
              + Sum[j] - Sum[i]
              - (k == i + 1 ? a[i] : 0)
              - (k == j - 1 ? a[j - 1] : 0);
        chmin(res, tmp);
    }

    return dp[i][j] = res;
}

int main() {
    cin >> N;
    rep(i, N) cin >> a[i];
    Sum[0] = 0;
    rep(i, N) Sum[i + 1] = Sum[i] + a[i];

    memset(dp, -1, sizeof(dp));

    cout << rec(0, N) << endl;

}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;

    int T, A;
    cin >> T >> A;

    int H[1100];

    double MIN = __DBL_MAX__;

    int res = 0;

    double temp;

    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
        temp = T - H[i]*0.006;

        if ((temp - A) * (temp - A) < MIN)
        {
            MIN = (temp - A) * (temp - A);
            res = i;
        }
    }

    cout << res + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(){
  int n =  0;
  string s;cin >> s;
  for(int i = 0;i<s.size();i++){
    if(s.at(i) == 'x'){
      n += 1;
    }
  }
  if(n <= 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int oo = 1e9 + 5;

string ans[N];

void solve() {
    string s;
    int k;
    cin >> k >> s;
    if (sz(s) <= k) {
        cout << s;
    }
    else {
        for (int i = 0; i < k; ++i) {
            cout << s[i];
        }
        cout << "...";
    }
}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	“I’m not gonna run away, I never go back on my word! That’s my nindo: my ninja way.” Naruto
*/


Measured memory_bytes: 9892
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

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

	class Node implements Comparable<Node> {
		double x, y;

		public Node(double x, double y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public int compareTo(Node o) {
			return Double.compare(Math.atan2(y, x), Math.atan2(o.y, o.x));
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double[] X = new double[N];
		double[] Y = new double[N];
		Node[] nodes = new Node[N];
		for (int i = 0; i < N; ++i) {
			X[i] = sc.nextDouble();
			Y[i] = sc.nextDouble();
			nodes[i] = new Node(X[i], Y[i]);
		}
		Arrays.sort(nodes);
		double ans = 0;
		for (int i = 0; i < N; ++i) {
			double curx = 0, cury = 0;
			for (int j = 0; j < N; ++j) {
				curx += nodes[(i + j) % N].x;
				cury += nodes[(i + j) % N].y;
				ans = Math.max(ans, curx * curx + cury * cury);
			}
		}
		ans=Math.sqrt(ans);
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 24916
#include<iostream>
using namespace std;
int main(){
int a,b,c,t;
cin >> a >> b >> c;
if(a>b) {t=a; a=b; b=t;}
if(b>c) {t=b; b=c; c=t;}
if(a>b) {t=a; a=b; b=t;}
cout << a << " " << b << " " << c <<endl;
return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>

int main(){
  int a,b;
  int temp;
  int i;

  for(i = 0; i < 100000; i++){
    scanf("%d %d",&a,&b);

    if(a == 0 && b == 0) break;

    if(a > b){
      temp = a;
      a = b;
      b = temp;
    }
    printf("%d %d\n",a,b);
  }
  return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
char s[maxn],t[maxn];
map<long long,char>v;
int gcd(int x,int y) {
	while(y^=x^=y^=x%=y);
	return x;
}
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	scanf("%s%s",s,t);
	for(int i=0;i<n;i++)v[1ll*i*m]=s[i];
	for(int i=0;i<m;i++)
		if(v[1ll*i*n]&&v[1ll*i*n]!=t[i]) {
			puts("-1");
			return 0;
		}
	printf("%lld\n",1ll*n*m/gcd(n,m));
	return 0;
}

Measured memory_bytes: 14156