akhauriyash/Code-Regression huggingface dataset:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      int A = nextInt();
      if((N % 500) > A){
        myout("No");
      }else{
        myout("Yes");
      }
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32480
#include<stdio.h>
#include<math.h>
int main() {
	int n, i, x[100], y[100];
	double l=0, m=0, D1=0, D2=0, D3=0, D4=0;
	scanf("%d", &n);
	for (i = 0;i < n;i++) {
		scanf("%d", &x[i]);
	}
	for (i = 0;i < n;i++) {
		scanf("%d", &y[i]);
	}
	D4 = abs(x[0] - y[0]);
	for (i = 0;i < n;i++) {
		D1 += abs(x[i] - y[i]);
		l += (x[i] - y[i])*(x[i] - y[i]);
		D2 = sqrt(l);
		m += abs(x[i] - y[i])*abs(x[i] - y[i])*abs(x[i] - y[i]);
		D3 = cbrt(m);
		if (abs(x[i] - y[i]) > D4) {
			D4 = abs(x[i] - y[i]);
		}
	}
	printf("%lf\n", D1);
	printf("%lf\n", D2);
	printf("%lf\n", D3);
	printf("%lf\n", D4);
	return 0;
}

Measured memory_bytes: 656
#include <stdio.h>

void insertionSort(int *, int);

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

  scanf("%d",&N);
  if(N < 1 || N > 100)return 0;

  for(i = 0;i < N;i++){
     scanf("%d",&A[i]);
  if(A[i] < 0 || A[i] > 1000)break;
}
   
   insertionSort(A,N);

  return 0;
}

void insertionSort(int A[],int N){
int i,j,k,v;

for(k = 0;k < N;k++){
     printf("%d",A[k]);
   if(k == N-1)break;
     printf(" ");
   }
     printf("\n");

 for(i = 1;i < N;i++){
   v = A[i];
   j = i-1;
   
    

   while(j>=0 && A[j] > v){
    A[j+1] = A[j];
    j--;
     A[j+1] = v;
}
   
   for(k = 0;k < N;k++){
     printf("%d",A[k]);
      if(k == N-1)break;
     printf(" ");
   }
     printf("\n");
  }
}



Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <stdio.h>

using namespace std;

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

	int result = 0;
	while (N != 0) {
		N /= K;
		result++;
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val (A, B) = readLine()!!.split(" ").map { it.toLong() }
    var gcd = gcd(A, B)
    val set = mutableSetOf<Int>()
    set.add(1)
    for(i in 2..Math.sqrt(gcd.toDouble()).toInt()){
        while(gcd % i == 0L){
            gcd /= i
            set.add(i)
        }
    }
    set.add(gcd.toInt())
    println(set.size)
}

fun gcd(a: Long, b: Long): Long {
    if (a < b) return gcd(b, a)
    if (b == 0L) return a
    return gcd(b, a % b)
}

Measured memory_bytes: 37708
#include <bits/stdc++.h>
#define INF 1e9
#define N 510
#define MAX_V N
using namespace std;
typedef unordered_map<int,int> M;
M g[N];
bool used[MAX_V];      //DFS??§?????§??????????????????????????°

int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v]=true;
  
  for(M::iterator it=g[v].begin();it!=g[v].end() ;it++){
    int to=it->first;
    int &cap=it->second;
    if(!used[to] && cap > 0){
      int d = dfs(to ,t , min(f,cap));
      if(d > 0){
	cap -= d;
	g[to][v]+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

bool check(int s,int t){
  memset(used,0,sizeof(used));
  return dfs(s,t,1);
}

int main(){
  int n,m,q;
  cin>>n>>m>>q;
  for(int i=0,a,b;i<m;i++){
    scanf("%d%d",&a,&b),a--,b--;
    g[a][b]=g[b][a]=1;
  }
  
  int op,a,b,flow=max_flow(0,n-1);
  while(q--){
    scanf("%d%d%d",&op,&a,&b);a--,b--;
    if(op==1) g[a][b]=g[b][a]=1,flow+=max_flow(0,n-1);
    else {
      if(!g[a][b]||!g[b][a]){
	if(!g[b][a])swap(a,b);
	if(!check(a,b))flow--,check(a,0),check(n-1,b);
      }
      g[a][b]=g[b][a]=0;
    }
    cout <<flow<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 5056
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int H = int.Parse(str[0]);
		int W = int.Parse(str[1]);
		int[,]A = new int[H,W];
		for(var i=0;i<H;i++){
			string str2 = Console.ReadLine();
			for(var j=0;j<W;j++){
				if(str2.Substring(j,1)=="#"){
					A[i,j] = 1;
				}
			}
		}
		int[,]B = new int[H,W];
		if(A[0,0]==1){
			B[0,0]=1;
		}
		for(var i=1;i<W;i++){
			if(A[0,i]>A[0,i-1]){
				B[0,i] = B[0,i-1]+1;
			} else {
				B[0,i] = B[0,i-1];
			}
		}
		for(var i=1;i<H;i++){
			if(A[i,0]>A[i-1,0]){
				B[i,0] = B[i-1,0]+1;
			} else {
				B[i,0] = B[i-1,0];
			}
		}
		for(var i=1;i<H;i++){
			for(var j=1;j<W;j++){
				int a1 = B[i-1,j];
				if(A[i-1,j]<A[i,j]){
					a1++;
				}
				int a2 = B[i,j-1];
				if(A[i,j-1]<A[i,j]){
					a2++;
				}
				B[i,j] = Math.Min(a1,a2);
			}
		}
      for(var i=0;i<H;i++){
        for(var j=0;j<W;j++){
          //Console.Error.Write(B[i,j]);
        }
    //Console.Error.WriteLine();
      }
		Console.WriteLine(B[H-1,W-1]);
	}
}

Measured memory_bytes: 13180
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = 1; i < (ll)(n); i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(int x, int y){
  if(x % y == 1) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(int x, int y){
  return x * y / gcd(x, y);
}
// n個の最大公約数
ll ngcd(vector<int> a){
  int res;
  res = a[0];
  for(int i=1; i<a.size() && res!=1; i++){
    res = gcd(res, a[i]);
  }
  return res;
}
// n個の最小公倍数
ll nlcm(vector<int> a){
  int res;
  res = a[0];
  REP(i, a.size()){
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(int x){
  int i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
int digsum(int x){
  int res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n, t;
  cin >> n >> t;
  vector<P> route(n);
  rep(i,n){
    int a, b;
    cin >> a >> b;
    route[i] = make_pair(a, b);
  }
  int ans = 1001001001;
  rep(i,n){
    if(route[i].second <= t){
      ans = min(ans, route[i].first);
    }
  }
  if(ans != 1001001001){
    cout << ans << endl;
  }
  else{
    cout << "TLE" << endl;
  }
}






Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max()/100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
vector<LL>rest;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[310000], b[310000];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (i % 2==0)
			sum += a[i];
		else
			sum -= a[i];
	}
	b[0] = sum / 2;
	rep(i, n-1) {
		b[i + 1] = a[i] - b[i];
	}
	rep(i, n) {
		if (i)
			cout << " ";
		cout << b[i] * 2;
	}
	cout << endl;
	return 0;
}

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

#define chmin(x, y) (x = min(x, y))

int n;
int a[10000];
int dp[2][5010][2];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++){
		scanf("%d", a + i);
	}

	for (int i = 1; i <= n / 2; i++){
		dp[0][i][0] = dp[0][i][1] = 1e9;
	}
	for (int i = 0; i < n; i++){
		auto &src = dp[i & 1], &dst = dp[~i & 1];
		for (int j = 0; j <= n / 2; j++){
			dst[j][0] = dst[j][1] = 1e9;
		}
		for (int j = 0; j <= n / 2; j++){
			chmin(dst[j + 1][0], src[j][0]);
			chmin(dst[j + 1][1], src[j][0] + a[i]);
			chmin(dst[j][1], src[j][1]);
			chmin(dst[j][0], src[j][1] + a[i]);
		}
	}

	int res = min(dp[n & 1][n / 2][0], dp[n & 1][n / 2][1]);
	printf("%d\n", res);
}

Measured memory_bytes: 3324
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    a = list(map(int, input().split()))
    L = [0]*(N+1)
    R = [0]*(N+1)
    for i in range(N):
        L[i+1] = L[i]^a[i]
        R[N-i-1] = R[N-i]^a[N-i-1]
    ans = [None]*N
    for i in range(N):
        ans[i] = L[i]^R[i+1]
    print(*ans)
    # print(L,R)


if __name__ == "__main__":
    main()


Measured memory_bytes: 43728
#include <iostream>

using namespace std;

struct Node{
  int parent, left, right;
};

int n;
Node T[30];
int D[30], H[30];

void depth(int u, int d){
  if(u == -1) return;
  D[u] = d;
  depth(T[u].left, d+1);
  depth(T[u].right, d+1);
}

int height(int u){
  int ret1 = 0, ret2 = 0;
  if(T[u].left != -1) ret1 = height(T[u].left) + 1;
  if(T[u].right != -1) ret2 = height(T[u].right) + 1;
  return (H[u] = max(ret1, ret2));
}

signed main(){
  cin >> n;
  int u, l, r;

  for(int i = 0 ; i < 30 ; i++){
    T[i].parent = T[i].left = T[i].right = -1;
  }

  for(int i = 0 ; i < n ; i++){
    cin >> u >> l >> r;
    T[u].left = l;
    T[u].right = r;
    if(l != -1) T[l].parent = u;
    if(r != -1) T[r].parent = u;
  }

  int root;
  for(int i = 0 ; i < n ; i++){
    if(T[i].parent == -1) root = i;
  }
  
  depth(root, 0);
  height(root);
  
  for(int i = 0 ; i < n ; i++){
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", ";
    cout << "sibling = ";
    if(T[i].parent == -1){
      cout << -1 << ", ";
    }else if(T[T[i].parent].left != -1 && T[T[i].parent].left != i){
      cout << T[T[i].parent].left << ", ";
    }else if(T[T[i].parent].right != -1 && T[T[i].parent].right != i){
      cout << T[T[i].parent].right << ", ";
    }else{
      cout << -1 << ", ";
    }
    cout << "degree = " << (T[i].left!=-1?1:0)+(T[i].right!=-1?1:0) << ", ";
    cout << "depth = " << D[i] << ", ";
    cout << "height = " << H[i] << ", ";
    if(root == i) cout << "root" << endl;
    else if(T[i].left != -1 || T[i].right != -1) cout << "internal node" << endl;
    else cout << "leaf" << endl;
  }

}


Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool c) { if (c)print("Yes"); else print("No"); };

int B, C, D, E, M, N, X, Y, Z;
string S, T;
void solve() {
	cin >> N >> M;
	vector<int>A(N);
	int sum = 0;
	REP(i, M) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum <= N)print(N - sum);
	else print(-1);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




Measured memory_bytes: 11132
class monster:
    def __init__(self, hp: int, ap: int):
        self.hit_point = hp
        self.attack_point = ap
        self.status = 'healthy'

    def attack(self, enemy: 'monster'):
        enemy.defend(self.attack_point)

    def defend(self, enemy_ap: int):
        self.hit_point -= enemy_ap
        if self.hit_point <= 0:
            self.status = 'dead'

    def is_alive(self) -> bool:
        return not self.is_dead()

    def is_dead(self) -> bool:
        return self.status == 'dead'


def answer(t_hp: int, t_ap: int, a_hp: int, a_ap: int) -> str:
    taka_monster = monster(t_hp, t_ap)
    aoki_monster = monster(a_hp, a_ap)

    while taka_monster.is_alive() and aoki_monster.is_alive():

        taka_monster.attack(aoki_monster)
        if aoki_monster.is_dead():
            return 'Yes'

        aoki_monster.attack(taka_monster)
        if taka_monster.is_dead():
            return 'No'


def main():
    a, b, c, d = map(int, input().split())
    print(answer(a, b, c, d))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#define int long long
using namespace std;
int n, a[101], m;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		m = max(m, p);
		a[p]++;
	}
	int u = m / 2;
	if (m % 2 == 0) {
		if (a[u] != 1) {
			cout << "Impossible\n";
			return 0;
		}
	}
	else {
		u++;
		if (a[u] != 2) {
			cout << "Impossible\n";
			return 0;
		}
	}
	for (int i = u + 1; i <= m; i++)
		if (a[i] < 2) {
			cout << "Impossible\n";
			return 0;
		}
	for (int i = 1; i < u; i++)
		if (a[i] > 0) {
			cout << "Impossible\n";
			return 0;
		}
	cout << "Possible\n";
}

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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;


int main() {

#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    string str;
    cin >> n >> str;

    int cntB = 0, cntR = 0, cntG = 0;
    for (char c : str) {
        cntB += (c == 'B');
        cntR += (c == 'R');
        cntG += (c == 'G');
    }

    ll ans = 1LL * cntB * cntR * cntG;
    loop(i, n) {
        range(j, i + 1, n - 1) {
            if (str[i] == str[j])continue;
            int len = j - i;
            int k = j + len;
            if (k < n && str[k] != str[i] && str[k] != str[j]) {
                ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	char k;
	cin>>k;
	if(k<=90)
		cout<<"A"<<endl;
	else
		cout<<"a"<<endl;
	
	


	
	

	
	


	
	return 0;
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli n;
    cin1(n);
    double a[n];
    ncin1(n, a);

    double x = 0;
    REP(i, 0, n) {
        x += 1/a[i];
    }
    cout << fixed << 1/x << endl;
}


Measured memory_bytes: 256
N = int(input())
dict = {}
for i in range(N):
    a = int(input())
    if not a in dict.keys():
        dict[a] = 1
    else:
        dict[a] += 1
sum = 0
for i in dict.keys():
    if dict[i]%2 == 1:
        sum += 1
print(sum)


Measured memory_bytes: 15072
IN = lambda:list(map(int, input().split()))
n, m = IN()
n = n + 1

W = [0] + IN()
E = [IN() for i in range(m)]
E.sort(key = lambda x:x[2])

P = list(range(n))
R = [0] * n
C = [0] * n

def find(x):
    if P[x] != x:
        P[x] = find(P[x])
    return P[x]

def union(x, y, w):
    p, q = find(x), find(y)
    if R[p] < R[q]: p, q = q, p
    P[q] = p
    R[p] += R[p] == R[q]
    W[p] += W[q]
    C[p] = C[p] + C[q]+ 1 if W[p] < w else 0

for u, v, w in E:
    if find(u) == find(v):
        C[find(u)] += W[find(u)] < w
    else:
        union(u, v, w)

print(sum(C[i] for i in set(P) if i == P[i]))


Measured memory_bytes: 43324
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb push_back

typedef long long ll;

const int N = 20010;
int array[N],tmp[N];

void div(int n,int *a,int k){
  int now=1;
  rep(i,k+1){
    a[i]=now/n;
    now=(now%n)*10;
  }
}

void add(int k){
  int carry=0;
  for(int i=k;i>=0;i--){
    array[i]=(array[i]+carry+tmp[i]);
    carry=array[i]/10;
    array[i]%=10;
  }
}

void output(int *a,int k){
  rep(i,k+1){
    cout << a[i];
    if (i==0)cout <<".";
  }
  cout << endl;
}

void solve(int n,int m,int k){
  div(n,array,2*k);
  if (m == 1){
    REP(i,1,n){
      div(i*n,tmp,2*k);
      //output(tmp,2*k);
      add(2*k);
    }
  }
  output(array,k);
}

main(){
  int n,k,m,r;
  while(cin>> n >> k >> m >> r && n){
    solve(n,m,r);
  }
}

/*
const int N = 20;
ll fact[N];
void compute(){
  fact[0]=1;
  REP(i,1,20)fact[i]=i*fact[i-1];
}

bool solve(int n,stack<int> *in){
  int now=-1;
  rep(i,n){
    if (!in[i].empty()){
      now=i;
      break;
    }
  }
  while(!in[now].empty()){
    int tmp=in[now].top();
    in[now].pop();
    now=tmp;
  }
  rep(i,n)if (in[i].size() != 0)return false;
  return true;
}

void test(){
  stack<int> S[100];
  int n,k;
  while(cin>>n>>k && n){
    vector<int> a;
    rep(i,n){
      rep(j,k)a.pb(i);
    }
    int all=0,ok=0,ok2=0;
    do{
      int p=0;
      rep(i,n){
	rep(j,k)S[i].push(a[p++]);
      }
      all++;
      if (solve(n,S))ok++;
      else if (solve(n,S))ok2++;
      rep(i,n)while(!S[i].empty())S[i].pop();

    }while(next_permutation(a.begin(),a.end()));
    //cout << ok <<" " << all <<" " << ok/(double)all << endl;
    double ans=ok/(double)all;
    //cout << ans <<" " << 1./n << endl;
    cout <<n<<" " <<  ok <<" " << ok2 <<" " <<ok+ok2 <<" " <<  all << endl;
    cout <<"ok2 "<< (double)(ok2)/all << endl;
    
    cout <<"m=1 " << (double)(ok2+ok)/all << endl;
    //cout << (double)all/ok <<" " << (double)(ok+ok2)/all <<" " << endl;
    //cout << all-ok <<" "<< ok2 << endl;
    //cout << ok2/(double)ok << endl;
  }
}

main(){
  compute();
  test();
}
*/

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lcm(a,b)                ((abs(a) / gcd(a,b)) * abs(b))
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

//int dx[] = {-1, 0, 1, 0},                  dy[] = {0, 1, 0, -1};                  // 4 Direction
//int dx[] = {-1, 0, 1, 0, -1, 1, 1, -1},    dy[] = {0, 1, 0, -1, -1, 1, -1, 1};    // 8 Direction

inline ll power(ll a, ll p){
    ll res = 1, x = a;
    while (p){
        if (p & 1) res = (res * x);
        x = (x * x), p >>= 1;
    }
    return res;
}
inline ll big_mod(ll a, ll p, ll m){
    ll res = 1 % m, x = a % m;
    while (p){
        if (p & 1) res = (res * x) % m;
        x = (x * x) % m, p >>= 1;
    }
    return res;
}
inline ll gcd(ll a, ll b){
    a = abs(a), b = abs(b);
    while (b)
        a = a % b, swap (a, b);
    return a;
}

const ll INF = 1e15;

int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a[n] = {}, b[n] = {};
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	sort(a, a + n);
	sort(b, b + n);
	int mi = 0, mx = 0;
	if (n & 1) {
		mi = a[n / 2];
		mx = b[n / 2];
	} else {
		mi = a[n / 2 - 1] + a[n / 2];
		mx = b[n / 2 - 1] + b[n / 2];
	}
	cout << mx - mi + 1;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    int A[1000],B[1000],C[1000];
    int n;
    cin>>n;
    int count=0;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        if(a>b&&a>c){
            A[i]=a;
            if(b>c){B[i]=b;C[i]=c;}
            else{B[i]=c;C[i]=b;}
        }
        else if(b>a&&b>c){
            A[i]=b;
            if(a>c){B[i]=a;C[i]=c;}
            else{B[i]=c;C[i]=a;}
        }
        else if(c>a&&c>b){
            A[i]=c;
            if(a>b){B[i]=a;C[i]=b;}
            else{B[i]=b;C[i]=a;}
        }
        for(int j=i-1;j>=0;j--){
            if(A[j]==A[i]&&B[j]==B[i]&&C[j]==C[i]){count++;break;}
        }
    }
    cout<<count<<endl;
    return 0;
}


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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, d, h, u, v, x, y, t = 0;
    ll ans = 0;

    ll l = 0, r = 0;
    bool poss = true;

    boost;
    string s; 

    time_t tic, toc;
    tic = clock();

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        for(i = 0; i < 5; i++){
            cin >> x;
            if(x == 0){
                ans = i + 1;
            }
        }
        cout << ans << nl;
    }   
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define pb push_back
//#define int long long
#define mod 1000000007
#define fi first
#define se second
#define ll long long
#define scan() ll n; cin>>n ; ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;
typedef vector<int>vi ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<ll,ll> pll ;
int main()
{
	fast;
	ll n;
	cin>>n;
	vll lun;
	for(ll i=1;i<10;i++)
	{
		lun.pb(i);
	}
	ll j=0,k=1,i;
	while(lun.size()<100000)
	{
		for(i=j;lun[i]/k>0 && lun[i]/k<10;i++)
		{
			ll r=lun[i]%10;
			if(r-1>=0)
				lun.pb(lun[i]*10+r-1);
			lun.pb(lun[i]*10+r);
			if(r+1<10)
				lun.pb(lun[i]*10+r+1);
		}
		j=i;
		k*=10;
	}
	cout<<lun[n-1];
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2000050;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int num[maxn];

int main()
{
    int n;
    scanf("%d",&n);
    memset(num,0,sizeof(num));
    for(int i=1; i<=n; i++)
    {
        int t;
        scanf("%d",&t);
        /*if(num[t-1] != 0)
            num[t-1]++;*/
        num[t] = num[t-1]+1;
    }
    int m=0;
    //cout<<"           "<<endl;
    for(int i=1; i<=n; i++)
    {   //cout<<num[i]<<endl;
        m = max(m,num[i]);
    }
    cout<<n-m<<endl;

    return 0;
}




Measured memory_bytes: 8064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,X,M,ans=0;
  cin>>N>>X>>M;
  
  ll A[M+2],SUM[M+2],P[M+1]={};
  A[1]=X,P[A[1]]=1,SUM[0]=0,SUM[1]=X;
  for(int i=2; i<=M+1; ++i){
    A[i]=A[i-1]*A[i-1]%M;
    SUM[i]=SUM[i-1]+A[i];
    if(P[A[i]]>0){
      ll FI=P[A[i]],SE=i;
      ans+=SUM[FI-1]-SUM[0];
      ans+=(SUM[SE]-SUM[FI])*((N-FI+1)/(SE-FI));
      ans+=SUM[FI+(N-FI+1)%(SE-FI)-1]-SUM[FI-1];
      cout<<ans<<endl;
      return 0;
    }
    else P[A[i]]=i;
    
    if(i==N){
      cout<<SUM[i]<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 5100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	ll ans = 0;
	rep(i,n){
		int a;cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
// Crt. 2020-01-12  21:35:38
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#define N 100005
using namespace std;

struct Node {
    long long a, b;
    Node(long long x = 0, long long y = 0) {
        a = x, b = y;
    }
};

bool cmp(Node x, Node y) {
    return x.a - x.b > y.a - y.b;
}

int n, x, y, z;
long long mx[N];
Node a[N];
priority_queue<long long, vector<long long>, greater<long long> > q;

int main() {
#ifdef LOCAL_JUDGE
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif

    cin >> x >> y >> z, n = x + y + z;

    long long now = 0, ans = 0, res = -1e18;
    for (int i = 1; i <= n; ++i) {
        long long p, b, c;
        scanf("%lld%lld%lld", &p, &b, &c);
        ans += c, a[i] = Node(p - c, b - c);
    }
    
    sort(a + 1, a + n + 1, cmp);

//    for (int i = 1; i <= n; ++i)
//        cout << a[i].a << " # " << a[i].b << endl;
//
//    cout << ans << endl;

    for (int i = 1; i <= n - y; ++i) {
        q.push(a[i].a), now += a[i].a;
        while ((int)q.size() > x) now -= q.top(), q.pop();
        if ((int)q.size() == x) mx[i] = now;
    }

//    for (int i = x; i <= n - y; ++i)
//        cout << mx[i] << " "; cout << endl;

    while (!q.empty()) q.pop();

    now = 0;
    for (int i = n; i > x; --i) {
        q.push(a[i].b), now += a[i].b;
        while ((int)q.size() > y) now -= q.top(), q.pop();
        if ((int)q.size() == y) res = max(res, now + mx[i - 1]);
    }

    cout << ans + res << endl;

	return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=5e6+10;
const int mod=1e9+7;
int arr[N],iarr[N];
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
map<int,int> mp;
int arr1[1000001],arr2[1000001];

int solve()
{
	int a,b;
	cin>>a>>b;
	int g=__gcd(a,b);
	int l=(a*b)/g;
	cout<<l;
}
int32_t main()																																	
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c =='e' || c == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

dd=defaultdict(int)
#take care of 0
for i in range(0, 121):
    for j in range(i+1):
        temp = i**5 - j**5
        dd[temp] = (i, j)
        temp1 = i**5 + j**5
        dd[temp1] = (i, -j)
# print(dd[2066178367])
x = INT()
if(dd[x]!=0):
    print(dd[x][0], dd[x][1])

Measured memory_bytes: 69956
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  a--;
  b--;
  c--;
  d--;
  string s;
  cin >> s;
  bool retA = true, retB = true, retAB = false;
  for (int i = a; i < c; i++) {
    if (s[i] == '#' && s[i + 1] == '#') retA = false;
  }
  for (int i = b; i < d; i++) {
    if (s[i] == '#' && s[i + 1] == '#') retB = false;
  }
  if (c < d)
    retAB = true;
  else {
    int cnt = 0;
    for (int i = b - 1; i <= d - 1; i++) {
      if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') retAB = true;
    }
  }
  if (!retA || !retB || !retAB)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
from itertools import permutations
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
a = 0
b = 0
flagP = False
flagQ = False
count = 0
for x in permutations(range(1, N+1)):
    count += 1
    if flagP == False:
        for i in range(N):
            if x[i] != P[i]:
                break
            elif i == N-1:
                flagP = True
                a = count
    if flagQ == False:
        for i in range(N):
            if x[i] != Q[i]:
                break
            elif i == N-1:
                flagQ = True
                b = count

    if flagQ and flagP:
        break


print(abs(a-b))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int n;

int main(){
	while(cin>>n){
		if(n==0)return 0;
		int ans=9999;
		for(int i=0;i<26;i++)
		for(int j=0;j<26;j++)
		for(int k=0;k<26;k++){
			int w=200*i+300*j+500*k,v=380*0.8*(i-(i%5))+380*(i%5)+550*0.85*(j-(j%4))+550*(j%4)+850*0.88*(k-(k%3))+850*(k%3);
			if(w==n)ans=min(ans,v);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
n=int(input())
x=list(map(int,input().split()))
a=1
B=[1,1]
mod=10**9+7
for i in range(2,n):
  a=a*i%mod
  B.append(pow(i,mod-2,mod))
d=[0]*(n-1)
for i in range(n-1):
  d[i]=x[i+1]-x[i]
D=[d[-1]]
for i in range(n-2):
  D.append(D[-1]+d[-2-i])
D=D[::-1]
ans=0
for i in range(n-1):
  ans=(ans+D[i]*a*B[i+1])%mod
print(ans)

Measured memory_bytes: 19940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999
using namespace std;
int main() {
  int N ,M,count;
  count = 0;
  std::cin >> N >> M;
  std::vector<int> H(N);
  vector<vector<int>> G(N, vector<int>(0));
  for (int i = 0; i < N; i++) {
    int x;
    std::cin >> H[i];
  }
  for (int i = 0; i < M; i++) {
    int a,b;
    std::cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  for (int i = 0; i < N; i++) {
    bool ans = true;
    for (const auto& e : G[i]) {
      if (H[e] >= H[i]) {
        ans = false;
      }
   }
   if (ans) {
     count++;
   }
  }
  std::cout << count << '\n';
}


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

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;
    char c = s[k - 1];
    for (int i = 0; i < n; i++) {
        if (s[i] == c) continue;
        s[i] = '*';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long A(long long a){
  return a*a*a*a*a;
}

int main() {
	long long x;
  cin>>x;
  for(long long i=-1000;i<=1000;i++){
    for(long long j=-1000;j<=1000;j++){
      if(A(i)-A(j)==x) {cout<<i<<" "<<j<<endl; return 0;}
    }
  }
}

Measured memory_bytes: 3632
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    n <- readLn
    -- kaigyousuuretu
    ss <- map strToInt <$> replicateM n getLine
    let tens = filter ((== 0) . (`mod` 10)) ss
        ones = filter ((/= 0) . (`mod` 10)) ss
    if null ones then putStrLn "0"
                 else putStrLn $ if ((sum ones) `mod` 10 == 0) then show $ (sum ss - minimum ones) else show $ sum ss


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	map<int, int>mp;
	vector<int>a(n);
	for(int i=1;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		cout<<mp[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13488
#include <iostream>

auto is_prime (int x) -> bool
{
    for (auto i = 2; i * i <= x; ++ i)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

auto main () -> int
{
    int prime_num [1000000] = {0 , 0 , 1};
    for (auto i = 3; i < 1000000; ++ i)
    {
        prime_num [i] = prime_num [i - 1] + is_prime (i);
    }

    int n;
    while (std::cin >> n)
    {
        std::cout << prime_num [n] << std::endl;
    }
}

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

public class Situation
{
    public int ba { get; set; }
}


public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var hanako = Enumerable.Range(1, 2 * n).ToList();
            var taro = new List<int>();
            for (int i = 0; i < n; i++)
            {
                var temp = int.Parse(Console.ReadLine().Trim());
                taro.Add(temp);
                hanako.Remove(temp);
            }
            taro.Sort();
            hanako.Sort();
            var s = new Situation() { ba = -1 };
            var ttt = 0;  var hhh = 0;
            while (true)
            {
                 ttt = PlayGame(s, taro);
                if (ttt == 1) break;
                 hhh = PlayGame(s, hanako);
                if (hhh == 1) break;
            }
            if (ttt == 1) Console.WriteLine("{0}\n0", hanako.Count());
            else Console.WriteLine("0\n{0}", taro.Count());
        }
    }
    public static int PlayGame(Situation s, List<int> p)
    {
        if (s.ba == -1)
        {
            var a = p[0];
            s.ba = a;
            p.Remove(a);
            if (p.Count() == 0) return 1;
            else return 0;
        }
        else
        {
            if (p.Count(x => x > s.ba) == 0)
            {
                s.ba = -1;
                return 0;
            }
            else
            {
                var a = p.First(x => x > s.ba);
                s.ba = a;
                p.Remove(a);
                if (p.Count() == 0) return 1;
                else return 0;
            }
        }
    }
}

Measured memory_bytes: 10084
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mss map <string,string>
#define msl map <string,ll>
#define mll map <ll,ll>
#define mcl map <char,ll>
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
long long  int exponentiation(long long  int base, long long  int exp) 
{ 
  if (exp == 0) 
    return 1; 
 
  if (exp == 1) 
    return base % N; 
  long long int t = exponentiation(base, exp / 2); 
  t = (t * t); 
  if (exp % 2 == 0) 
    return t;
  else  
    return ((base ) * t) ; 
}

int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
  
  string s1,s2;
  cin>>s1>>s2;
  ll c=0;
  for(int i=0;i<3;i++){
    if(s1[i]==s2[i]) c++;
  }
  cout<<c;
}







Measured memory_bytes: 256
n=int(input())
ans=[0]*4
dict={"AC":0,"WA":1,"TLE":2,"RE":3}
for _ in range(n):
    temp=input()
    ans[dict[temp]]+=1
print("AC x ",ans[0])
print("WA x ",ans[1])
print("TLE x ",ans[2])
print("RE x ",ans[3])


Measured memory_bytes: 9212