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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int main() {
    fastIO;
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    int m[n];   // m[i] = 1 for red, 2 for green, 3 for blue at distance i
    for (int i = 1; i < n - 1; ++i) {
        memset(m, 0, sizeof(m));
        int bcnt = 0, rcnt = 0, gcnt = 0;
        for (int j = i - 1; j >= 0; j--) {
            m[i - j] = (s[j] == 'R') ? 1 : (s[j] == 'G' ? 2 : 3);
            bcnt += (s[j] == 'B');
            rcnt += (s[j] == 'R');
            gcnt += (s[j] == 'G'); 
        }
        for (int j = i + 1; j < n; ++j) {
            if (s[j] != s[i]) {
                if ((s[j] == 'R' && s[i] == 'G') || (s[j] == 'G' && s[i] == 'R')) {
                    ans += bcnt - (m[j - i] == 3);
                } else if ((s[j] == 'R' && s[i] == 'B') || (s[j] == 'B' && s[i] == 'R')) {
                    ans += gcnt - (m[j - i] == 2);
                } else  ans += rcnt - (m[j - i] == 1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int st[200005];
int en[200005];
int timer=0;
vector<vector<int>>adj;
int sz[200005];
int col[200005];
int ans[200005];
int node[800005];
set<pair<int,pair<int,int> > >s;

int dfs(int ver,int pr)
{
  st[ver]=++timer;
  node[timer]=ver;
  for(auto i:adj[ver])
  {
    if(i!=pr)
      sz[ver]+=dfs(i,ver);
  }
  en[ver]=++timer;
  sz[ver]++;
  return sz[ver];
}
int n;
void madar()
{
  for(int cc=1;cc<=n;cc++)
  {
    int tot=0;
    auto j=s.lower_bound({cc,{0,-1}});
    vector<pair<int,pair<int,int> > >temp;
    while (j!=s.end())
    {
      if(j->first!=cc)
        break;
      if(j->second.second>1e9)
        break;
      temp.push_back(*j);
      j++;
    }    
    tot+=sz[1];
    for(auto j:temp)
    {
      tot-=sz[node[j.second.first]];
      s.erase(j);
    }     
    ans[cc]+=(tot*(tot+1))/2;  
  }
}

void dfs2(int ver,int pr)
{
  for(auto i:adj[ver])
  {
    if(i!=pr)
    {
      dfs2(i,ver);
      int tot=0;
      auto j=s.lower_bound({col[ver],{st[ver],-1}});
      vector<pair<int,pair<int,int> > >temp;
      while (j!=s.end())
      {
        if(j->first!=col[ver])
          break;
        if(j->second.second>en[ver])
          break;
        temp.push_back(*j);
        j++;
      }     
      tot+=sz[i];
      for(auto j:temp)
      {
        tot-=sz[node[j.second.first]];
        s.erase(j);
      }     
      ans[col[ver]]+=(tot*(tot+1))/2;  
    }
  }
  s.insert({col[ver],{st[ver],en[ver]}});
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

  cin>>n;
  adj.resize(n+1);
  for(int i=1;i<=n;i++)
    cin>>col[i];
  int x,y;
  for(int i=0;i<n-1;i++)
  {
    cin>>x>>y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1,0);
  dfs2(1,0);
  madar();
  int fi=(n*(n+1))/2;
  for(int i=1;i<=n;i++)
  {
    cout<<(fi-ans[i])<<'\n';
  }
 
// -------------------------------------Code ends here------------------------------------------------------------------
    clock_t clk;
  clk = clock();

    clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
  return 0;
}


Measured memory_bytes: 68816
#include<iostream>

template <class T>
T calcQuot(T x, T y);
int calcRem(int x, int y);

int main()
{
	int a, b;

	std::cin >> a >> b;

	int quatInt = calcQuot(a, b);
	double quatDouble = calcQuot(static_cast<double>(a), static_cast<double>(b));
	int reminder = calcRem(a, b);

	std::cout<<std::fixed << quatInt << ' ' << reminder << ' ' << quatDouble << std::endl;		// fixedの使いどころとprintf

	return 0;
}

template<class T>
T calcQuot(T x, T y)
{
	T ans = x / y;
	return ans;
}

int calcRem(int x, int y)
{
	int ans = x % y;
	return ans;
}


Measured memory_bytes: 3264
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

using ll = long long;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define rloopi(i, a, b) for(int i = (int)a - 1; i >= (int)b; i--)
#define rloop(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define rloopeq(i, n) for (int i = (int)n - 1; i >= 1; i--)
#define all(a) (a).begin(), (a).end()

int main() {
	ll x; cin >> x;
	vector<ll> five;
	for (ll i = 0; i < 6209; i++) {
		five.push_back(i * i * i * i * i);
	}
	loop(i, 6209) {
		loop(j, 6209) {
			if (x == five[i] - five[j]) {
				cout << i << " " << j << endl;
				return 0;
			}
			if (x == five[i] + five[j]) {
				cout << i << " " << -j << endl;
				return 0;
			}
		}
	}
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5;

int a, b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> a >> b;
    cout << ((a >= b * 2) ? (a - b * 2) : 0);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll n,k;
  cin >> n >> k;
 vll snuke(n,0);
 while(k--){
  ll d;
   cin >> d;
  rep(i,0,d){
   ll a;
    cin >> a;
    --a;
    snuke[a]++;
  }
 }
  ll ans=0;
  rep(i,0,n) if(snuke[i]==0) ans++;
  cout << ans << endl;
 
}

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

Measured memory_bytes: 3660
#include <cstring>
#include <cstdio>
using namespace std;

typedef long long LL;
const int N = 1e3 + 10;
const int Mod = 1e9 + 7;
inline int mls(int x) {return x < 0 ? x + Mod : x;}
inline int pls(int x) {return x >= Mod ? x - Mod : x;}
struct mat {
	int a[2][2];
	friend mat operator * (mat s, mat t) {
		mat ret;
		ret.a[0][0] = pls(1LL * s.a[0][0] * t.a[0][0] % Mod + 1LL * s.a[0][1] * t.a[1][0] % Mod);
		ret.a[0][1] = pls(1LL * s.a[0][0] * t.a[0][1] % Mod + 1LL * s.a[0][1] * t.a[1][1] % Mod);
		ret.a[1][0] = pls(1LL * s.a[1][0] * t.a[0][0] % Mod + 1LL * s.a[1][1] * t.a[1][0] % Mod);
		ret.a[1][1] = pls(1LL * s.a[1][0] * t.a[0][1] % Mod + 1LL * s.a[1][1] * t.a[1][1] % Mod);
		return ret;
	}
} ans, ret, emat;
int n, m, A, B, cnt; char a[N][N], b[N][N]; LL K;

inline void swap(int &a, int &b) {int t = a; a = b, b = t;}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + (LL)ch-'0', ch = getchar();
	x *= f;
}

inline int calc() {
	for (int i = 1; i <= n; ++i)
		if (a[i][1] == '#' && a[i][m] == '#') return 1;
	return 0;
}

inline void turn() {
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			b[m - j + 1][i] = a[i][j];
	swap(n, m); memcpy(a, b, sizeof a);
}

inline int qpow(int A, LL B) {
	int S = 1;
	for (; B; B >>= 1, A = 1LL * A * A % Mod)
		if (B & 1) S = 1LL * S * A % Mod;
	return S;
}

inline mat Qow(mat A, LL B) {
	mat ret = emat;
	for (; B; B >>= 1, A = A * A)
		if (B & 1) ret = ret * A;
	return ret;
}

int main() {
	int b = 0, c = 0; in(n), in(m), in(K);
	emat.a[0][0] = emat.a[1][1] = 1;
	for (int i = 1; i <= n; ++i) {
		scanf("%s", a[i] + 1);
		for (int j = 1; j <= m; ++j) cnt += (a[i][j] == '#');
	}
	A = calc(), turn();
	B = calc(), turn();
	if ((A && B) || !K) {puts("1"); return 0;}
	if (!A && !B) {printf("%d\n", qpow(cnt, K - 1)); return 0;}
	if (!A) turn();
	for (int i = 1; i <= n; ++i)
		c += (a[i][1] == '#' && a[i][m] == '#');
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j < m; ++j)
			b += (a[i][j] == '#' && a[i][j + 1] == '#');
	ret.a[0][0] = cnt, ret.a[0][1] = b, ret.a[1][1] = c;
	ans = Qow(ret, K - 1);
	printf("%d\n", mls(ans.a[0][0] - ans.a[0][1]));
	return 0;
}

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

int main(){
	int i,j,n,len1,len2,len,plus,up,flag=0;
	char buf,enter[101],*str1,*str2,out[101];
	scanf("%d",&n);
	fgets(enter,sizeof(enter),stdin);
	for(i=0;i<n;i++){
		fgets(enter,sizeof(enter),stdin);
		len1=strlen(enter)-1;
		str1=(char*)calloc(len1+1,sizeof(char));
		for(j=0;j<len1;j++){
			str1[j]=enter[j];
		}
		str1[len1]='\0';
		for(j=0;j<(len1%2==0?len1/2:len1/2+1);j++){
			buf=str1[j];
			str1[j]=str1[len1-j-1];
			str1[len1-j-1]=buf;
		}
		fgets(enter,sizeof(enter),stdin);
		len2=strlen(enter)-1;
		str2=(char*)calloc(len1+1,sizeof(char));
		for(j=0;j<len2;j++){
			str2[j]=enter[j];
		}
		str2[len2]='\0';
		for(j=0;j<(len2%2==0?len2/2:len2/2+1);j++){
			buf=str2[j];
			str2[j]=str2[len2-j-1];
			str2[len2-j-1]=buf;
		}
		if(len1>=len2)len=len1;
		else len=len2;
		up=0;
		for(j=0;j<len;j++){
			plus=(j<len1?(str1[j]-'0'):0)+(j<len2?(str2[j]-'0'):0)+up;
			if(plus>9){
				up=1;
				plus-=10;
			}else{
				up=0;
			}
			out[j]=plus+'0';
		}
		if(up>0){
			out[j]='1';
			len+=1;
		}
		out[len]='\0';
		for(j=len-1;j>=0;j--){
			if(j>=80&&out[j]>'0'){
				flag=1;
				break;
			}else if(flag==0&&j<80) break;
		}
		if(flag){
			printf("overflow\n");
			flag=0;
		}
		else{
			for(j=len-1;j>=0;j--){
				printf("%c",out[j]);
			}
			printf("\n");
		}
	}
	return 0;
}

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

const int MAXN = 3e3 + 10, MOD = 1e9 + 7, I2 = (MOD + 1) / 2;

int n, Q;
int a[MAXN], P[MAXN][MAXN];

int main() {
	scanf("%d%d", &n, &Q);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) P[i][j] = a[i] > a[j];
	for (int i = 1, x, y; i <= Q; ++i) {
		scanf("%d%d", &x, &y), P[x][y] = P[y][x] = 1LL * (P[x][y] + P[y][x]) * I2 % MOD;
		for (int j = 1; j <= n; ++j) if (j != x && j != y) P[x][j] = P[y][j] = 1LL * (P[x][j] + P[y][j]) * I2 % MOD, P[j][x] = P[j][y] = 1LL * (P[j][x] + P[j][y]) * I2 % MOD;
	}
	int pro = 1, ans = 0;
	for (int i = 1; i <= Q; ++i) pro = pro * 2 % MOD;
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j) ans = (ans + P[i][j]) % MOD;
	printf("%d\n", 1LL * ans * pro % MOD);
	return 0;
}

Measured memory_bytes: 35584
def gcd(a, b):
	k = 0
	while b != 0:
		r = a % b
		a, b = b, r
		k += 1
	return [a, k]

while True:
	x, y = list(map(int, input().split()))
	if x == 0: break
	if x < y: x, y = y, x
	ans = gcd(x, y)
	print(*ans)


Measured memory_bytes: 5604
#include<stdio.h>
#define NIL -1
#define MAX 500000
int root = NIL;
int key[MAX];
int left[MAX];
int right[MAX];
int p[MAX];
 
void tree_insert(int z){
  int a = NIL;
  int b = root;
  while(b != NIL){
    a = b;
    if(key[z] < key[b]){
      b = left[b];
    }
    else b = right[b];
  }
 
  p[z] = a;
  if(a == NIL){
    root = z;
  }
  else if(key[z]<key[a]){
    left[a] = z;
  }
  else{
    right[a] = z;
  }
}
 
void preorder(int t){
  if(t == NIL)return;
  printf(" %d",key[t]);
  preorder(left[t]);
  preorder(right[t]);
}
  
void inorder(int t){
  if(t == NIL)return;
  inorder(left[t]);
  printf(" %d",key[t]);
  inorder(right[t]);
}
  
void print(){
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
}
  
int tree_find(int t){
  int i = 0;
  int y = NIL;
  int b = root;
  while(b != NIL){
    if(key[b] == t)return 1;
    y = b;
    if(t < key[b]){
      b = left[b];
    }
    else b = right[b];
  }
  return 0;
}
  
int main(){
    
  int i,n,x;
  int z = 0;
  char A[10];
  scanf("%d",&n);
  for(i = 0;i < MAX;i++){
    key[i] = NIL;
    left[i] = NIL;
    right[i] = NIL;
    p[i] = NIL;
  }
 
  for(i = 0;i < n;i++){
    scanf("%s", A);
    if(A[0] == 'i'){
      scanf("%d",&x);
      key[z] = x;
      tree_insert(z);
      z++;
    }
    else if(A[0] == 'p')print();
    else if(A[0] == 'f'){
      scanf("%d",&x);
      if(tree_find(x) == 1)printf("yes\n");
      else printf("no\n");
    }
  }
    
  return 0;
}

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


int main(){

    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if(e-a<=k){
        cout << "Yay!" << endl;
    } else{
        cout << ":(" << endl;
    }
    
    return 0;
}

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

long long int A, B, C, D;

int main(void) {
  cin >> A >> B >> C >> D;

  int ans = 0;
  while (A > 0 || C > 0){
    C -= B;
    if (C <= 0) {
      ans = 1;
      break;
    }
    A -= D;
    if (A <= 0) {
      ans = 0;
      break;
    }
  }
  if (ans == 1) cout << "Yes" << endl;
  else          cout << "No"  << endl;
  
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long h = sc.nextInt();
        long w = sc.nextInt();
        long ans = Math.min(h,w);
        if(h % 3 == 0 || w % 3 == 0){
            System.out.println(0);
            return;
        }
        for(int i = 1; i <= h/2; i++){
            long first = i*w;
            long max = Math.max((long)Math.ceil(w/2d)*(h-i),first);
            long min = Math.min((long)Math.floor(w/2d)*(h-i),first);
            ans = Math.min(ans,max-min);
        }
        for(int i = 1; i <= w/2; i++){
            long first = i*h;
            long max = Math.max((long)Math.ceil(h/2d)*(w-i),first);
            long min = Math.min((long)Math.floor(h/2d)*(w-i),first);
            ans = Math.min(ans,max-min);
        }
        System.out.println(ans);
    }
}

class Point{
    double x,y;
    public Point(double x, double y){
        this.x = x;
        this.y = y;
    }
}
class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL a;
  string s;
  cin >> a >> s;
  if(a < 3200) cout << "red" << endl;
  else cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    s = input()
    count = 0
    b_count = []
    for v in s:
        if v == "B":
            count += 1
        if v == "W":
            b_count.append(count)
    print(sum(b_count))

def input_list():
    return map(int, input().split())

if __name__ == "__main__":
    main()

Measured memory_bytes: 86640
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
long long A[200000+10];
long long check(long long a,long long b)
{
   if(2*a>b)
    return 2*a-b;
   else
    return b-2*a;
}

int main()
{    int N;
     cin>>N;
      memset(A,0,sizeof(A));
      int i=0;
      int M=N;
      long long sum=0;
      while(N--)
       {  cin>>A[i++];
       sum+=A[i-1];
       }
       long long sum2=0;
       long long P=30000000000000000;

       //cout<<"DDDDDDDDDDD";
       for(int id=0;id<M-1;id++)
       {
           sum2+=A[id];
          // cout<<sum2<<' '<<sum<<endl;
           P=min(check(sum2,sum),P);
       }
       cout<<P<<endl;
    return 0;
}


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

double abs_( double x )
{
	return ( x > 0 ? x : -x );
}

int main()
{
	int N, T, A;
	std::cin >> N >> T >> A;

	std::vector<double> v( N );
	for ( int i = 0; i < N; i++ )
	{
		std::cin >> v[i];
		v[i] = T - v[i] * 0.006;
	}

	double j = 0;
	for ( int i = 1; i < N; i++ )
	{
		if ( abs_( v[i] - A ) < abs_( v[j] - A ) )
		{
			j = i;
		}
	}

	std::cout << j + 1 << std::endl;

	return ( 0 );
}


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
  double l;
  cin >> l;
  cout << fixed << setprecision(10) << (long double)((l*l*l)/27) << endl;
}

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

int main() {
	int n;
	cin >> n;
	int p[n];
	int check[n]= {};
	for (int i = 0; i<n; i++) {
		cin >> p[i];
	}
	int longest = 0;
	for (int i = 0; i<n; i++) {
		check[p[i]] = check[p[i] - 1] + 1;
		// cout << i <<": " << p[i] << " check: " << check[p[i]] << endl;
		longest = max(longest, check[p[i]]);
	}
	cout << n - longest << endl;
	return 0;
}

Measured memory_bytes: 1792
let () =
  let rec read () =
    let k = read_int () in
    if k = 0 then ()
    else
      begin
        let c = read_line ()
                |> Str.split (Str.regexp " ")
                |> List.fold_left (fun x y -> x + (int_of_string y) ) 0
        in
        Printf.printf "%d\n" (c/(k-1));
        read ()
      end
  in read ()
;;

Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vs vector<string>
#define mii map<int, int>

void show(auto a){
  int i = 0;
  while(i < a.size()){
    cout<<a[i]<<" ";
    i++;
  }
  cout<<endl;
}


int main(){
  ios_base::sync_with_stdio(false);

  string s, t;
  cin>>s>>t;

  int dp[s.length()+1][t.length()+1];

  for(int i = 0; i < s.length() + 1; i++){
  	for(int j = 0; j < t.length() + 1; j++) dp[i][j] = 0;
  }

  for(int i = 1; i < s.length() + 1; i++){
  	for(int j = 1; j < t.length() + 1; j++){
		if(s[i-1] == t[j-1]) {
			dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
		}else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
  	}
  }

  int lenS = s.length(), lenT = t.length();
  
  string ans2 = "";

  while(lenS >= 1 && lenT >= 1){
  	if(s[lenS-1] == t[lenT - 1]){ 
  		ans2 += s[lenS - 1];
  		lenS--;
  		lenT--;
  	}else if(dp[lenS-1][lenT] > dp[lenS][lenT-1]) lenS--;
  	else lenT--;
  	
  }
  reverse(ans2.begin(), ans2.end());
  cout<<ans2<<endl;
  // cout<<dp[s.length()][t.length()]<<endl;

}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

    int n, m; cin >> n >> m;
    int a[m]; rep(i, m) a[i] = 0;
    rep(i, n) {
        int k; cin >> k;
        rep(j, k) {
            int x; cin >> x;
            ++a[x-1];
        }
    }
    int ans = 0;
    rep(i, m) {
        if(a[i] == n) ++ans;
    } cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    int kazu=N;
    vector<int> ketas;

    while(1){
        ketas.push_back(N%10);
        N/=10;
        if(N==0)break;
    }
    int sum=0;
    for(int i=0;i<ketas.size();i++){
        sum += ketas[i];
    }
    if(kazu%sum==0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}


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

int main()
{
    int N, W;
    cin >> N >> W;
    int v[N], w[N];
    for (int i = 0; i < N; i++)
    {
        cin >> v[i] >> w[i];
    }
    int dp[N + 1][W + 1];
    for (int i = 0; i <= W; i++)
    {
        dp[0][i] = 0;
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            if (j - w[i] >= 0)
            {
                dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
            }
            else
            {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;
}



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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	// your code goes here
	char c;
	scanf("%c",&c);
	
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') cout << "vowel";
	else cout << "consonant";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		sc.close();
		// 全部のマス目
		int goukei = H * W;
		// 塗りつぶす行数分のマス目を引く
		goukei -= (h * W);
		// 塗りつぶす列数分のマス目を引く
		// すでに塗りつぶした行分は引く
		goukei -= ((H - h) * w);
		// 出力
		prtln(goukei);
	}
	public static <T> void prtln(T t) { System.out.println(t); }
}

Measured memory_bytes: 23636
a,b = map(int,input().split())
sa = b-a

sigma = []
diff = []

tmp = 0
for i in range(1,1000):
    tmp += i
    sigma.append(tmp)

    if i >= 2:
        diff.append(sigma[i-1]-sigma[i-2]) 
        if sigma[i-1] - sigma[i-2] == sa:
            print(sigma[i-1] - b)

Measured memory_bytes: 3060
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        s: Chars
    };
    let mut arr = [true; 128];
    for c in s {
        arr[c as usize] = false;
    }
    for i in b'a'..=b'z' {
        if arr[i as usize] {
            println!("{}", i as char);
            return;
        }
    }
    println!("None");
}


Measured memory_bytes: 2476
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n){
    string s;
    for(int i=0;i<n;i++)s+='#';
    while(m--){
      string p;
      cin>>p;
      if(p=="A"){
        for(int i=0;i<n;i++)
          if(s[i]=='#'){
            s[i]='A';
            break;
          }
      }
      if(p=="B"){
        int pp=0;
        for(int i=n-1;i>=0;i--){
          if(i==n-1){if(s[i-1]!='A'&&s[i]=='#'){pp++,s[i]='B';break;}}
          else if(!i){if(s[i+1]!='A'&&s[i]=='#'){pp++,s[i]='B';break;}}
          else {if(s[i-1]!='A'&&s[i]=='#'&&s[i+1]!='A'){pp++,s[i]='B';break;}}
        }
        if(!pp)for(int i=0;i<n;i++)
             if(s[i]=='#'){
               s[i]='B';
               break;
            }
      }
      if(p=="C"){
        int pp=0;
        for(int i=0;i<n;i++)
          if(s[i]!='#'){
            
            if(i!=n-1){if(s[i+1]=='#'){s[i+1]='C';pp++;break;}}
            if(i){if(s[i-1]=='#'){s[i-1]='C';pp++;break;}}
          }
        if(!pp){
          if(n%2)s[(n+1)/2-1]='C';
          else s[n/2]='C';
        }
      }
      else if(p=="D"){
        int d[n]={},p=0,sp=0;
        for(int i=0;i<n;i++){

          int p1=0,p2=0;
          if(i==n-1)p1=1000;
          if(i==0)p2=1000;
          for(int j=i;j<n;j++)
            if(s[j]=='#')p1++;
            else break;
          for(int j=i;j>=0;j--)
            if(s[j]=='#')p2++;
            else break;
          p1=min(p1,p2);
          p=max(p,p1);
          d[i]=p1;//cout<<d[i];
        }//cout<<endl;
        for(int i=0;i<n;i++)if(s[i]!='#')sp++;
        if(!sp)s[0]='D';
        else for(int i=0;i<n;i++)
          if(d[i]==p){
            s[i]='D';
            break;
          }
      }

    }
    cout<<s<<endl;
  }
}

Measured memory_bytes: 3152
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;


int main(){
    int N,K;
    cin >> N >> K;
    int d[K],A[K][101];
    int okashi[N]={0},tmp;
    for (int i=0;i<K;++i){
        cin >> d[i];
        for(int j=0;j<d[i];++j){
            cin >> tmp;
            okashi[tmp-1]=1;
        }
    }
    int ita =0;
    for(int i=0;i<N;++i){
        if(okashi[i]==0)
        ita+=1;
    }
    cout << ita << endl;
    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
   ll a,b,x; cin >> a >> b >> x;
   if(a % x == 0){
        print(b / x - a / x + 1);
   }else{
       print(b / x - a / x);
   }

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
    int N, D;
    cin>>N>>D;
    int ans=0;
    ans = (N+2*D)/(2*D+1);
    cout<<ans<<endl;
  
}


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

int main(void) {
	int n;
	int i = 0;

	cin >> n;
	while(1) {
		int s = n - i;
		int l = n + i;
		stringstream sstr1, sstr2;
		string str1, str2;
		string rev1, rev2;

		sstr1 << s; sstr2 << l;
		sstr1 >> str1; sstr2 >> str2;
		rev1.resize(str1.size()); rev2.resize(str2.size());
		reverse_copy(str1.begin(), str1.end(), rev1.begin());
		reverse_copy(str2.begin(), str2.end(), rev2.begin());

		if(str1 == rev1) {
			cout << s << endl;
			break;
		}

		if(str2 == rev2) {
			cout << l << endl;
			break;
		}
		i++;
	}

	return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A[100001];
	ll ans=0;
	scan(N);
	rep(i,N){
		scan(A[i]);
	}
	rep(i,N){
		ans+=A[i]/2;
		A[i]-=A[i]/2*2;
		if(i<N-1){
			ll hiku=min(A[i],A[i+1]);
			ans+=hiku;
			A[i]-=hiku;
			A[i+1]-=hiku;
		}
		
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 1024
n=int(input())
memo=[[0]*10 for _ in range(10)]
for i in range(1,n+1):
  a=int(str(i)[0])
  b=int(str(i)[-1])
  memo[a][b]+=1
ans=0
for i in range(1,n+1):
  b=int(str(i)[0])
  a=int(str(i)[-1])
  ans+=memo[a][b]
print(ans)

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
using ll = long long;
using Graph = vector<vector<int>>;

#include <iostream>
using namespace std;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;

int main(){
    int H,W,K; cin>>H>>W>>K;
    mint dp[10][110];//destination
    rep(i,10)rep(j,110)dp[i][j]=0;//destination,yokobo
    dp[1][0] = 1;

    for(int h = 0; h < H; h++){//階数
        for(int d = 1; d <= W; d++){//目的地
            for(int bit = 0; bit < (1<<(W-1)); bit++){
                bool ok = true;
                rep(i,W-2){
                    if((bit&(1<<i)&&(bit&(1<<(i+1))))){
                        ok = false;
                        break;
                    }
                }
                if(!ok)continue;

                int next_d = d;
                if(bit & (1<<(d-1)))next_d = d+1;
                else if(d > 1 && (bit & (1<<(d-2))))next_d = d-1;
                dp[next_d][h+1] += dp[d][h];
            }
        }
    }
    mint res = dp[K][H];
    cout<<res<<endl;
}


Measured memory_bytes: 256
k=int(input())
n = 55555
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
p1=[i for i in primes if i%5==1]
print(*p1[:k])

Measured memory_bytes: 8812
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============modpow============================
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//=================================================

//=============modinv============================
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//=================================================

int main() {
  ll mod = 998244353;
  ll two_inv = modinv(2, mod);
  ll N, S;
  cin >> N >> S;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  vector<ll> dp(S + 1);
  dp.at(0) = modpow(2, N, mod);
  for (ll i = 0; i < N; ++i) {
    vector<ll> temp = dp;
    ll a = A.at(i);
    for (ll i = 0; i < S; ++i) {
      if (a + i > S) {
        continue;
      }
      dp.at(i + a) += (temp.at(i) * two_inv) % mod;
      dp.at(i + a) %= mod;
    }
  }
  cout << dp.at(S) << "\n";
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}

  
int main()
 {  fast();
	ll t;
    ll n;
    cin>>n;
   
  vector<double> p(n+1);
   fore(i,n){
     cin>>p[i+1];
   }
   //dp[i][j]=probability of i heads in j total coins
   double dp[n+1][n+1];
   dp[0][0]=1;
  // p[0][1]=1-p[0];
   fore1(i,1,n+1)dp[0][i]=dp[0][i-1]*(1-p[i]);
   fore1(j,1,n+1)dp[j][0]=0;
   fore1(i,1,n+1){
       fore1(j,1,n+1){
           dp[i][j]=(dp[i-1][j-1]*(p[j]))+dp[i][j-1]*(1-p[j]);
          
       }
   }
 
   double sum=0.000000000;
     fore1(i,n/2+1,n+1)sum+=dp[i][n];
     cout<<fixed<<setprecision(9)<<sum<<endl;
 }
   
   

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

ll calc(ll l,ll r,ll n){
  l = ((l-1)/n+1)*n;
  if(l>r) return 0;
  return (r-l)/n+1;
}

ll calc(ll x){
  ll len=0,num = 1,cnt=1;
  while(num<=x){
    ll nx = min(x+1,num*10);
    ll d3 = calc(num,nx-1,3);
    ll d5 = calc(num,nx-1,5);
    ll d15= calc(num,nx-1,15);
    ll d  = d3+d5-d15;
    len+= ((nx-num) - d)*cnt;
    len+= (d3+d5)*4;
    num = nx;
    cnt++;
  }
  return len;
}

ll search(){
  ll L=0,M,R=1LL<<60;
  while(L<R){
    M = (L+R)/2;
    if(calc(M)>=n)R = M;
    else L = M+1;
  }
  return L-1;
}

string ItoS(ll a){
  if(a==0) return "0";
  string res;
  while(a)res=(char)(a%10+'0')+res,a/=10;
  return res;
}

int main(){
  cin>>n;
  ll num = search()+1;
  ll len = calc(num-1);
  string ans;
  while(ans.size()<100){
    if(num%3==0) ans+="Fizz";
    if(num%5==0) ans+="Buzz";
    if(num%3&&num%5) ans+=ItoS(num);
    num++;
  }
  cout<<ans.substr(n-len-1,20)<<endl;
  return 0;
}

Measured memory_bytes: 3228
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		System.out.println(((N * (N - 1)) / 2) + ((M * (M - 1)) / 2));
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 21844
num_a = gets.chomp.split("")
length = num_a.length
num_b = []
comparison = 0

v = 0
i = length - 1
while i >= 0
    num_b[v] = num_a[i]

    v = v + 1
    i = i - 1
end

for count in 0..length-1
    if num_a[count] == num_b[count]
        comparison = comparison + 1
    end
end

if comparison == length
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main(void) {
    int N;
    long long K;
    cin >> N >> K;

    long long mem[100001];
    for (int i = 1; i <= 100000; ++i) {
        mem[i] = 0;
    }

    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        mem[a] += b;
    }

    long long sum = 0;
    for (int i = 1; i <= 100000; ++i) {
        if (K <= mem[i]) {
            cout << i << endl;
            break;
        }
        K -= mem[i];
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int sum = a + b + c + d;
    int m = sum / 60;
    int s = sum % 60;
    cout << m << endl;
    cout << s << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    int N;
    cin >> N;

    vector<int> a(N);
    int minimum = 1000;
    int maximum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        minimum = min(minimum, a[i]);
        maximum = max(maximum, a[i]);
    }
    cout << maximum - minimum << endl;

    return (0);
}

Measured memory_bytes: 256
# coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    def pnum_check(self, n):
        if (n==1):
            return False
        elif (n==2):
            return True
        else:
            for x in range(2,n):
                if(n % x==0):
                    return False
            return True

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

def printA(A):
    N = len(A)
    for i, n in enumerate(A):
        print(n, end='')
        if i != N-1:
            print(' ', end='')
    print()

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート
# N = N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

while True:
    N = int(input())
    if N==0:
        break
    S = [int(x) for x in input().split()]

    ans = 0
    P = S.copy()

    while True:
        count = [0 for i in range(101)]
        for i in P:
            count[i] += 1
        C = []
        for i in P:
            C.append(count[i])
        
        ans += 1

        if P == C:
            break
        else:
            P = C.copy()
    
    print(ans-1)
    printA(P)




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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
/*
int checkstring(string s){
  if(s=="AAA") return 0;
  if(s=="AAB") return 1;
  if(s=="ABA") return 1;
  if()あれ ABだけでよくね

}
*/
signed main(){
  string s,t;
  cin>>s>>t;
  int q;
  cin>>q;
  int a[200000],b[200000];
  int sum=0;
  a[0]=0;
  b[0]=0;

  lp(i,s.size()){
    if(s[i]=='A') sum++;
    else sum+=2;
    a[i+1]=sum;
  }
  sum=0;
  lp(i,t.size()){
    if(t[i]=='A'){
      sum++;
    }
    else sum+=2;
    b[i+1]=sum;
  }
  lp(i,q){
    int w,x,y,z;
    cin>>w>>x>>y>>z;
    int asum=a[x]-a[w-1];
    int bsum=b[z]-b[y-1];
    if(asum%3==bsum%3) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3712
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      s: chars,
    }

    let n = s.len() + 1;
    let mut left = vec![0; n];
    let mut right = vec![0; n];

    let mut l = 0;
    for i in 0..s.len() {
        if s[i] == '<' {
            left[i+1] = l+1;
            l += 1;
        } else {
            l = 0;
        }
    }

    let mut r = 0;
    for i in (0..s.len()).rev() {
        if s[i] == '>' {
            right[i] = r+1;
            r += 1;
        } else {
            r = 0;
        }
    }

    let mut ans = vec![0; n];
    for i in 0..n {
        ans[i] = max(left[i], right[i]);
    }

    // debug!(ans);
    puts!("{}\n", ans.iter().sum::<usize>());
}


Measured memory_bytes: 19704
#include <iostream>
#include <string>

using namespace std;

bool isFound = false;
string input_s;
bool s_flg = false;

bool isTasai(string s)
{
	bool f['z' + 1] = {0};

	for (char c : s)
	{
		if (f[c] == 1) return false;
		f[c] = 1;
	}

	return true;
}

int main()
{
	cin >> input_s;

	if (input_s.length() < 26)
	{
		for (char c = 'a'; c <= 'z'; c++)
		{
			if (isTasai(input_s + c))
			{
				cout << input_s + c << endl;
				return 0;
			}
		}
	}

	string str = input_s;

	while ( true )
	{
		char last = str[str.length() - 1];
		str = str.substr(0, str.length() - 1);

		for (char c = last + 1; c <= 'z'; c++)
		{
			if (isTasai(str + c))
			{
				cout << str + c << endl;
				return 0;
			}
		}

		if ( str.length() == 0 ) break;
	}

	cout << "-1" << endl;

	return 0;
}


Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int a,b;
  cin >> a >> b;

  REP(c,3){
    if(a*b*c%2==1){
	  cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
group_A=[1,3,5,7,8,10,12]
group_B=[4,6,9,11]
if x in group_A and y in group_A :
  print("Yes")
elif x in group_B and y in group_B :
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9180
# numpyを使わない解法
import math
n, d = (int(i) for i in input().split())
list_x = [[int(i) for i in input().split()] for j in range(0, n)]
count = 0
tmp = 0
for i in range(0, n):
    for j in range(i + 1, n):
        for k in range(0, d):
            tmp += pow(list_x[i][k] - list_x[j][k], 2)
        tmp = math.sqrt(tmp)
        if tmp.is_integer(): count += 1
        tmp = 0
print(count)

Measured memory_bytes: 9132