akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>

int N;
long long MOD = 1000000007;
std::vector<std::map<std::string, int>> memory;

bool Judge(std::string last){
   if(last[0]=='A' && last[3]=='C'){
      if(last[1]=='G' || last[2]=='G'){
	 return false;
      }
   }

   if(last[1]=='A' && last[2]=='G' && last[3]=='C') return false;
   if(last[1]=='G' && last[2]=='A' && last[3]=='C') return false;
   if(last[1]=='A' && last[2]=='C' && last[3]=='G') return false;

   return true;
}

long long Count(int index, std::string last){
   if(memory[index][last]>0){
      return memory[index][last];
   }
   if(index==N) return 1;

   long long count = 0;
   for(int i=0; i<4; ++i){
      char moji = 'A';
      if(i==1) moji = 'C';
      else if(i==2) moji = 'G';
      else if(i==3) moji = 'T';

      if(Judge(last+moji)){
	 std::string last_new = {last[1], last[2], moji};
	 count = (count + Count(index+1, last_new)) % MOD; 
      }
   }
   memory[index][last] = count;

   return count;
}

int main(){
   std::cin >> N;

   memory.resize(N+1);
   std::cout << Count(0, "TTT") << std::endl;
   
   return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int x;
    cin >> x;
    string ans = "No";
    if (x>=30) ans = "Yes";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <math.h>
#define _USE_MATH_DEFINES
using namespace std;

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

    double r;
    cin >> r;
    cout.precision(6);
    cout << fixed << r * r * M_PI << " " << fixed << 2 * M_PI * r << endl;

    return 0;
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    string s[N];
    int ans=0;
    int a=0,b=0,c=0;
    rep(i,N) {
        cin>>s[i];
        rep(j,s[i].size()-1){
            if(s[i].substr(j,2)=="AB") ans++;
        }
        if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A') c++;
        else if(s[i][0]=='B') b++;
        else if(s[i][s[i].size()-1]=='A') a++;
        
    }
    if(c==0) ans+=min(a,b);
    else{
        if(a+b==0) ans+=c-1;
        else ans+=c+min(a,b);
    }
    cout << ans << endl;
    




}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    std::vector<int> x;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    std::sort(x.begin(), x.end());
    
    long long int sum = 0;
    long long int ans = 100*100*100;
    for(int i=1; i<=x[n-1]; i++){
        sum = 0;
        //cout << "---" << endl;
        for(int j=0; j<n; j++){
            sum += (x[j]-i)*(x[j]-i);
            //cout << x[j] << ":" << sum << ", ";
        }
        //cout << endl ;
        if(ans > sum){
            ans = sum;
        }
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9;
const long double PI=acos(-1);



void solve(int T){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=(a[i]*a[j]);
        }
    }
    cout<<ans<<"\n";
}

int main() {
    //fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3536
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;

int main() {
	
	int a, b;

	cin >> a >> b;

	if (a != 1 && b != 1) cout << 1 << endl;
	else if (a != 2 && b != 2)cout << 2 << endl;
	else cout << 3 << endl;

	return 0;
}

Measured memory_bytes: 256
from functools import reduce

# 入力
N, M, K = map(int, input().split())

MOD = 10**9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )


ans = (N * M * (M * (N**2 - 1) + N * (M**2 - 1)) // 6) * reduce(
    lambda acc, i: acc * (N * M - 2 - i) / (K - 2 - i),
    range(K - 2),
    ModInt(1)
)
print(ans)


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

void ABC172C()
{
	int N, M, K;
	cin >> N >> M >> K;
	vl A(N), B(M);
	for(auto& x : A)
		cin >> x;
	for (auto& x : B)
		cin >> x;

	vl S(N+1);
	for (int i = 0; i < N; ++i)
		S[i+1] = S[i] + A[i];

	vl T(M+1);
	for (int i = 0; i < M; ++i)
		T[i+1] = T[i] + B[i];

	int maxCt = 0;
	for (int i = 0; i <= N; ++i)
	{
		int t = K - S[i];
		if (t < 0)
			break;
		int c = distance(T.begin(), upper_bound(T.begin(), T.end(), t)) - 1;
		maxCt = max(maxCt, i + c);
	}

	cout << maxCt << endl;
}
int main()
{
	ABC172C();
	return 0;
}

Measured memory_bytes: 9508
#include<stdio.h>
int main()
{
	int N, K;
	scanf("%d", &N);
	scanf("%d", &K);
	int i, value=1;
	for ( i = 0; i < N; i++)
	{
		if (value + K > value * 2)
			value *= 2;
		else
			value += K;
	}
	printf("%d", value);
	return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    vll As(N);
    vll Bs(M);
    // ll As[N];
    // ll Bs[M];

    ll sum = 0;
    int aindex = -2;
    rep(i, N) {
        cin >> As[i];
        if (aindex == -2 && sum <= K - As[i]) {
            sum += As[i];
        } else if (aindex == -2) {
            aindex = i - 1;
        }
    }

    if (aindex == -2) {
        aindex = N-1;
    }
    // cout << sum << endl;

    int bindex = -2;
    rep(i, M) {
        cin >> Bs[i];
        // cout << sum << endl;
        if (bindex == -2 && sum <= K - Bs[i]) {
            sum += Bs[i];
        } else if (bindex == -2) {
            bindex = i - 1;
        }
    }
    // cout << sum << endl;

    if (bindex == -2) {
        bindex = M-1;
    }

    ll maxcount = aindex + bindex + 2;
    ll nowcount = aindex + bindex + 2;

    // cout << aindex << " " << bindex << " " << sum << endl;
    bindex++;
    
    for (int i = aindex; i >= 0; i--) {
        sum -= As[i];
        nowcount -= 1;
        while(bindex < M && sum <= K - Bs[bindex]) {
            sum += Bs[bindex];
            bindex++;
            nowcount++;
            if (bindex == M) {
                break;
            }
        }
        // cout << i << " " << bindex << " " << sum << " " << nowcount << endl;
        maxcount = std::max(maxcount, nowcount);
        if (bindex == M) {
            break;
        }
    }
    cout << maxcount << endl;
}

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

int main() {
  int N;
  int a,count;
  count=0;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> a;
    if(i%2==0 && a%2==1)
      count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
#define MAX 1073741824
int min(const int a, const int b){return a>b?b:a;}
int n, l, i, j, k;
int m;
int a[1000], b, c;
int key[1000];
int d[4096][1000];
int main(void){
	scanf("%d%d", &n, &m);
	for(i=0; i<m; i++){
		scanf("%d%d", a+i, &b);
		for(j=0; j<b; j++){
			scanf("%d", &c);
			key[i] |= 1<<(c-1);
		}
	}
	l = 1<<n;
	for(j=1; j<l; j++){
		if(((~key[0])&j)!=0){
			d[j][0]=MAX;
		}else{
			d[j][0]=a[0];
		}
	}
	for(i=1; i<m; i++){
		for(j=1; j<l; j++){
			k=j&(~key[i]);
			if(k==j){
				d[j][i] = d[j][i-1];
			}else{
				d[j][i] = min(d[j][i-1], d[k][i]+a[i]);
			}
		}
	}
	if(d[l-1][m-1]==MAX){
		printf("%d\n", -1);
	}else{
		printf("%d\n", d[l-1][m-1]);
	}
}


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

int main() {
	int X, A, B;
	cin >> X >> A >> B;

	if (A >= B) {
		cout << "delicious";
	}
	else if (A + X >= B) {
		cout << "safe";
	}
	else { cout << "dangerous"; }

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

NN = 202020
MOD = 10**9+7
# MOD = 998244353
INF = float("inf")

s = input()
d = defaultdict(int)
d[0] = 1
su = 0
for i in range(len(s)):
    t = pow(10, i, 2019)
    su = (su + int(s[-i-1])*t)%2019
    d[su] += 1

# print(d)
ans = 0
for k,v in d.items():
    ans += v*(v-1)//2

print(ans)



Measured memory_bytes: 69260
h, w = map(int, input().split())

table = [list(map(int, input().split())) for _ in range(10)]

def wf(table):
    from itertools import product
    for k, i, j in product(range(len(table)), repeat=3):
        table[i][j] = min(table[i][j], table[i][k] + table[k][j])

    return table

table = wf(table)

ans = 0
for _ in range(h):
    for i in map(int, input().split()):
        if i != -1:
            ans += table[i][1]

print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }

bool isprime(long long int val) {
 if (val <= 1)return false;
 for (long long int i = 2; i*i <= val; i++) {
   if (val%i == 0LL)return false;
 }
 return true;//素数
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i < n; i++){
    cnt += (n - 1) / i;
  }
  cout << cnt << endl;
  return 0;
}

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

int main(int argc, char const *argv[]) {
int a,b,max;
std::cin >> a >> b;
max=a+b;
if(max<a-b) max=a-b;
if(max<a*b) max=a*b;

std::cout << max ;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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 long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  int diff = x-a;
  cout << diff%b << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

public static void main(String[] args) {
        Scanner scan = new Scanner (System.in);
        int H = scan.nextInt();
        int W = scan.nextInt();
        while( H != 0 || W != 0){
            for ( int x = 0; x < H; x++ ){
            for ( int y = 0; y < W; y++ ){    
           
            System.out.print("#");
            }
            System.out.println("");
            }
            System.out.println("");
        
            H = scan.nextInt();
            W = scan.nextInt();
           
            }
        }
}

            		       




        
        
        



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

import numpy as np
import scipy

#N = int(input())
#C = [[0 for i in range(3)] for j in range(3)]
#for i in range(3):
#    C[i] = list(map(int, input().split()))
S = list(map(int, input().split()))
#A, B, C = map(int, input().split())

def plus1(X, Y):
    return X+1, Y+1

def plus2(Z):
    return Z+2

c = 0
S = sorted(S)

while True:
    if S[1] == S[2]:
        break
    S[0], S[1] = plus1(S[0], S[1])
    c += 1

if (S[1] - S[0])%2 != 0:
    S[1], S[2] = plus1(S[1], S[2])
    c += 1

while True:
    if S[0] == S[1]:
        break
    S[0] = plus2(S[0])
    c += 1

print(c)


Measured memory_bytes: 21900
A = []
sweetsInfo = [0]*100
empty = 0

N,K = input().split()

for i in range(int(K)):
    d = int(input())
    A = input().split()
    for o in range(d):
        sweetsInfo[int(A[o]) - 1] = 1

for i in range(int(N)):
    if sweetsInfo[i] == 0:
        empty += 1

print(empty)

Measured memory_bytes: 9208
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
index=0
hashMap={}
while index < n:
    listS = list(input())
    listS.sort()
    key = "".join(listS)
    if key in hashMap:
        hashMap[key]+=1
    else:
        hashMap[key]=1
    index+=1
answer = 0
for key in hashMap:
    if hashMap[key] > 1:
        answer+=comb(hashMap[key], 2)
print(answer)

Measured memory_bytes: 17932
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <istream>
#include <algorithm>

#ifdef _MSC_VER
#define scanf scanf_s
#define KEYWAIT getchar();getchar();
#else
#define KEYWAIT
#endif

int main()
{
    long a, b;

    std::cin >> a >> b;

    if(a==1&&b==1)
        std::cout << 1 << std::endl;
    else if (a == 1)
        std::cout << b - 2 << std::endl;
    else if( b == 1)
        std::cout << a - 2 << std::endl;
    else if(a>2&&b>2)
        std::cout << (a-2)*(b-2) << std::endl;
    else
        std::cout << 0 << std::endl;

    KEYWAIT

    return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

ans =  0
for i in range(n):
    if i == n-1:
        if x == a[i]:
            ans += 1
    else:
        if x >= a[i]:
            x -= a[i]
            ans += 1

print(ans)

Measured memory_bytes: 38384
h, w = map(int, input().split())
ss = []
ls = []

# 一回り大きくする
ss.append(['.']*(w+2))
for _ in range(h):
    ss.append(['.']+list(input())+['.'])
ss.append(['.']*(w+2))

for i in range(1, h+1):
    for j in range(1, w+1):
        if ss[i][j] == '.':
            n = (
                ss[i-1][j-1],
                ss[i-1][j],
                ss[i-1][j+1],
                ss[i][j-1],
                ss[i][j+1],
                ss[i+1][j-1],
                ss[i+1][j],
                ss[i+1][j+1],
            ).count('#')
            print(n, end='')
        else:
            print('#', end='')
    print()


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

    private static class Position {
        long x = 0;
        long y = 0;
    }

    private static boolean canTravel(long[] t, long[] x, long[] y) {
        Position pos = new Position();
        for (int i = 0; i < t.length; i++) {
            long dist;
            long dt;
            if (i == 0) {
                dist = Math.abs(x[i]) + Math.abs(y[i]);
                dt = t[i];
            } else {
                dist = Math.abs(x[i] - x[i - 1]) + Math.abs(y[i] - y[i - 1]);
                dt = t[i] - t[i - 1];
            }
            if (dist > dt || dist % 2 != dt % 2) {
                return false;
            }
            pos.x = x[i];
            pos.y = y[i];
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] t = new long[n];
        long[] x = new long[n];
        long[] y = new long[n];

        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        if (canTravel(t, x, y)) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 94880
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define ALL(v) v.begin(), v.end()

int N, X;

lint GCD(lint a, lint b) { return b ? GCD(b, a % b) : a; }

void resolve()
{
    cin >> N >> X;
    vector<lint> x(N);

    RPT0(i, N) cin >> x[i];
    sort(ALL(x));

    lint cur_gcd = min(abs(X - x[0]), abs(X - x[x.size() - 1]));
    RPT(i, 1, N - 1)
    {
        cur_gcd = GCD(cur_gcd, x[i] - x[i - 1]);
        if (cur_gcd == 1) break;
    }

    cout << cur_gcd << endl;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define sort(a) sort(a.begin(),a.end());
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
#define TC cin>>t;while(t--)
const int MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll LLMAX = LLONG_MAX;

int main()
{
    int n;
    cin>>n;
    ll sum=0;
    char a[n+2];
    int r[n+1]={0};
    int b[n+1]={0};
    int g[n+1]={0};
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]=='R')
        {
            r[i]=r[i-1]+1;
            g[i]=g[i-1];
            b[i]=b[i-1];
        }
        else if(a[i]=='G')
        {
            r[i]=r[i-1];
            g[i]=g[i-1]+1;
            b[i]=b[i-1];
        }
        else if(a[i]=='B')
        {
            r[i]=r[i-1];
            g[i]=g[i-1];
            b[i]=b[i-1]+1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(a[i]==a[j])continue;
            if(a[i]=='R')
            {
                if(a[j]=='G')
                {
                    sum+=b[n]-b[j];
                    if( 2*j-i<=n && a[2*j-i]=='B')sum-=1;
                }
                else if(a[j]=='B')
                {
                    sum+=g[n]-g[j];
                    if(2*j-i<=n && a[2*j-i]=='G')sum-=1;
                }
            }

            if(a[i]=='G')
            {
                if(a[j]=='R')
                {
                    sum+=b[n]-b[j];
                    if(2*j-i<=n && a[2*j-i]=='B')sum-=1;
                }
                else if(a[j]=='B')
                {
                    sum+=r[n]-r[j];
                    if(2*j-i<=n && a[2*j-i]=='R')sum-=1;
                }
            }

            if(a[i]=='B')
            {
                if(a[j]=='G')
                {
                    sum+=r[n]-r[j];
                    if(2*j-i<=n && a[2*j-i]=='R')sum-=1;
                }
                else if(a[j]=='R')
                {
                    sum+=g[n]-g[j];
                    if(2*j-i<=n && a[2*j-i]=='G')sum-=1;
                }
            }
        }
    }
    cout<<sum<<nl;
}

Measured memory_bytes: 3600
char buf[5];
char out[2<<17];
sz;outsz;
N;
main(){
	read(0,buf,5);
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(;--N;)
	{
		memcpy(out+outsz,"1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 9 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 ",2*N);
		outsz+=2*N;
	}
	write(1,out,outsz);
}

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

typedef long long ll;
#define rep(i,b,e) for(ll i=b;i<e;i++)

vector <long long> pre;
vector <vector<long long>> a;
vector <long long> dp;

void solve(int i,const vector<int>& not_taken,ll score_so_far,int mask,int group){
	if(i==(int)not_taken.size()){
		dp[mask]=max(dp[mask],score_so_far+pre[group]);
		return;
	}

	solve(i+1,not_taken,score_so_far,mask,group);
	solve(i+1,not_taken,score_so_far,mask^(1<<not_taken[i]),group^(1<<not_taken[i]));
}

const ll INF = 1e18l+5;
int main(){
	int n;
  	cin>>n;
	a.resize(n,vector<long long>(n));
	pre.resize(1<<n,0);
	dp.resize(1<<n,-INF);

	rep(i,0,n)
		rep(j,0,n)
			cin>>a[i][j];

	rep(mask,0,(1<<n)){
		rep(i,0,n){
			if(mask&(1<<i)){
				rep(j,i+1,n){
                  if(mask&(1<<j))
					pre[mask]+=a[i][j];
				}
			}
		}
	}
	//calculating value of each group
	//O(2ⁿ*n²)
	dp[0]=0;
	rep(mask,0,(1<<n)){
		vector<int> not_taken;
		rep(i,0,n){
			if(!(mask&(1<<i)))
				not_taken.push_back(i);
		}
		solve(0,not_taken,dp[mask],mask,0);
      	//cout<<dp[mask]<<endl;
	}
	cout<<dp[(1<<n)-1]<<endl;
}


Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  REP(i, N) cin >> a[i];
  vector<ll> s(N + 1, 0);
  REP(i, N) s[i + 1] = s[i] + a[i];
  ll ans = INF;
  for (int i = 0; i < N;i++){
    ll sa = abs(s[N] - s[i + 1] * 2);
    ans = min(ans, sa);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M =1000000007;
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
ll mpow(ll x, ll n){ //x^n(mod M) ????pow(x,n)?????????????mod??
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
int main (){
  int i;
  ll a,b=0,x,t=100;
  char b_str[4];
  cin>>a>>b_str;
  int l = strlen(b_str);
  for(i=0;i<l;i++){
    x=b_str[i]-'0';
    if(i!=1){
      b+=x*t;
      t/=10;
    }
    /*if(i==0){
      b+=(b_str[i]-'0')*100;
    }
    else if(i==2){
      b+=(b_str[i]-'0')*10;
    }
    else if(i==3){
      b+=(b_str[i]-'0');
    }*/
  }
  cout<<(long)(a*b)/100<<endl;
  return 0;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int limit7 = N / 7;
		boolean check = false;
		for (int i = 0; i <= limit7; i++) {
			int left = N-(i*7);
			if (left % 4 == 0) {
				check = true;
			}
		}
		if (check) {
		System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
class UnionFind:

    def __init__(self,n):
        #par[x]==xならxというノードが根。xに親がいない
        self.par = [i for i in range(n+1)]
        self.rank = [0]*(n+1) 
    
    def find(self,x): #xの根を検索
        #xが根ならxを返す
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x]) #パス圧縮
            return self.par[x]

    def unite(self,x,y):
        #根を探す
        x = self.find(x)
        y = self.find(y)        
        #木の深さを比較し、小さい方を大きい方につなげる
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1 #rankが同じ木を繋げたとき根のランクを一つ上げる
    
    def same_check(self,x,y): #xとyが同じ集合に属しているか
        return self.find(x) == self.find(y)
        
n, m = map(int,input().split())
A=[list(map(int,input().split())) for i in range(m)]
ans = 0
for i in range(m):
    uf = UnionFind(n) #
    for j in range(m):
        if i != j: #
            uf.unite(A[j][0],A[j][1])
    f = 1
    g = uf.find(1) #
    for j in range(1,n+1):
        if g != uf.find(j): #1~n(iを除く)がすべて同じ集合に属しているか
            f = 0
            break
    if not f:
        ans += 1
print(ans)

Measured memory_bytes: 42480
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;
int long long ll;

int main() {

    int d,n;
    cin >> d >> n;
    
    if (n==100) {
        ll = (pow(100,d) * (n+1));
        cout << ll << endl;
    } else
    {
        cout << (pow(100, d) * n) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
N,K = map(int,input().split(" "))
x = N - K #red ball
for i in range(1,K+1):
    if x+1-i >= 0:
        a = math.factorial(x+1) // (math.factorial(i)*math.factorial(x+1-i))
    else:
        a = 0
    b = math.factorial(K-1) // (math.factorial(i-1)*math.factorial(K-i))
    print(a * b % (10**9+7))


Measured memory_bytes: 3316
#include<bits/stdc++.h> 
using namespace std;
int main()
{ 	
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&c!=a)
		cout<<"Yes";
	else if(b==c&&a!=b)
		cout<<"Yes";
	else if(a==c&&b!=a)	
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  vector<int> vec(3);
  vec.at(0)=a;
  vec.at(1)=b;
  vec.at(2)=c;
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  cout<<10*vec.at(0)+vec.at(1)+vec.at(2)<<endl;
}

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

int main(){
  int n;
  cin >> n;
  if (n % 1110 <= 9){
  cout << "Yes" << endl;
  }
  else if ((n - (n/1000)*1000) % 111 == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  
  

Measured memory_bytes: 3588
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<long long> A(N, 0);
	long long max_A = 0;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		max_A = max(max_A, A[i]);
	}

	long long diff = 1e9 + 1;
	long long close_value = 1e9;

	for (int i = 0; i < N; i++)
	{
		if (max_A == A[i]) continue;

		long long curr_diff = abs(max_A - (A[i] * 2));
		if (curr_diff < diff)
		{
			diff = curr_diff;
			close_value = A[i];
		}
	}

	cout << max_A << " " << close_value;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }



#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

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

  vector<bool> hoge(1e7);        // 39296 KB

  char a, b;
  cin >> a >> b;
  if(a==b) {
    cout << "H" << endl;
  } else {
    cout << "D" << endl;
  }


  return 0;
}


Measured memory_bytes: 1536
import numpy as np

N = input()
K = int(input())
lt,eq = 0,1
dp = np.zeros((101,2,5),dtype=int)

dn = len(N)
dp[0][eq][0] = 1
for i in range(dn):
    di = ord(N[i]) - ord('0')
    for k in range(K+1):
        dp[i+1][lt][k] = dp[i][lt][k] * 1 + dp[i][eq][k] * (1 if di >= 1 else 0)
        if k:
            dp[i+1][lt][k] += dp[i][lt][k-1] * 9 + dp[i][eq][k-1] * max(0,di-1)
        if dp[i][eq][k]:
            dp[i+1][eq][k+(di>0)] = 1

print(int(dp[dn][lt][K] + dp[dn][eq][K]))

Measured memory_bytes: 12504
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s.size()%2!=0){
		cout<<"No";
		return 0;
	}
	for(int i=0;i<s.size();i+=2)
		if(s[i]!='h'){
			cout<<"No";
			return 0;
		}
	for(int i=1;i<s.size();i+=2)
		if(s[i]!='i'){
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;		
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

struct HeavyLightDecomposition{
    int n;
    vector<int> size, par, in, in_rev, heavy_root, depth, heavy_depth;
    vector<vector<int>> childs;
    HeavyLightDecomposition(vector<vector<int>>& edges, int root = 0) : n(edges.size()), size(n, 1), par(n, -2), depth(n, 0), childs(n), in(n), in_rev(n), heavy_root(n), heavy_depth(n, 0){
        function<void(int)> swap_dfs = [&](int x){
            int size_max = 0;
            int max_idx = 0;
            for(int i = 0; i < edges[x].size(); ++i){
                int y = edges[x][i];
                if(par[y] == -2){
                    par[y] = x;
                    depth[y] = depth[x] + 1;
                    childs[x].push_back(y);
                    swap_dfs(y);
                    size[x] += size[y];
                    if(chmax(size_max, size[y])){
                        max_idx = childs[x].size() - 1;
                    }
                }
            }
            if(max_idx){
                swap(childs[x][0], childs[x][max_idx]);
            }
        };
        par[root] = -1;
        swap_dfs(root);

        int cnt = 0;
        function<void(int,int)> dfs = [&](int x, int segment_root){
            heavy_root[x] = segment_root;
            in_rev[cnt] = x;
            in[x] = ++cnt;
            for(int i = 0; i < childs[x].size(); ++i){
                int y = childs[x][i];
                if(i == 0){
                    dfs(y, segment_root);
                }
                else{
                    heavy_depth[y] = heavy_depth[segment_root] + 1;
                    dfs(y, y);
                }
            }
        };
        dfs(root, root);
    }
    int lca(int x, int y){
        while(heavy_root[x] != heavy_root[y]){
            if(get_heavy_depth(x) > get_heavy_depth(y))
                swap(x, y);
            y = par[heavy_root[y]];
        }
        return depth[x] < depth[y] ? x : y;
    }
    // 頂点xがEuler-Tour上で何番目に位置するかを返す
    // in[元の頂点index] = 内部でのindex
    // in_rev[内部でのindex] = 元の頂点index
    int get_idx(int x){
        return in[x];
    }
    // xが属するHeavy-Pathの深さを返す
    int get_heavy_depth(int x){
        return heavy_depth[heavy_root[x]];
    }
};

signed main(){

    int n;
    cin >> n;
    vector<vector<int>> edges(n);
    for(int i = 0; i < n; ++i){
        int cnt;
        cin >> cnt;
        for(int j = 0; j < cnt; ++j){
            int k;
            cin >> k;
            edges[i].push_back(k);
            edges[k].push_back(i);
        }
    }
    HeavyLightDecomposition hld(edges);
    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int a, b;
        cin >> a >> b;
        cout << hld.lca(a, b) << endl;
    }
    return 0;
}




Measured memory_bytes: 25748
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b)

#define lint long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef vector < int > vi ;
typedef pair < int, int > pii ;

const int N = 1e6 + 2 ;
const int MOD = 1e9 + 7 ;
const lint INF = 1e18 ;

bool cmp(const lint& x, const lint& y)
{
    return x > y ;
}

vector < lint > a, f ;
int n ; lint k ;

bool check(lint val)
{
    lint needed = 0 ;
    for(int i = 0; i < n; ++i)
    {
        lint req = max(0LL, a[i] - (val/f[i]));
        needed += req ;
    }
    return (needed <= k) ;
}

int main()
{
    cin >> n >> k ; a.resize(n); f.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i] ;
    for(int i = 0; i < n; i++) cin >> f[i] ;
    sort(all(a)); sort(all(f), cmp) ;

    lint low = 0, high = 1e12 ;
    while((high - low) > 1)
    {
        lint mid = low + high >>  1;
        if(check(mid)) high = mid ;
        else low = mid +  1;
    }
    if(check(low)) cout << low ;
    else cout << high ;
}




Measured memory_bytes: 3328
#include <iostream>

int main(int argc, char* argv[])
{
  int a = 0;
  int i = 1;
  
  while(1)
  {
    std::cin >> a;
    if (a == 0) break;
    std::cout << "Case " << i << ": " << a << std::endl;
    i++;
  }
  return 0;
} 

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

using namespace std;

const int N=271199;

int main(){
	#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);cin.tie(0);
	/*Input*/
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i=0;i<n;i++)
		cin >> h[i];
	/*Process*/
	vector<int> dp(n,0);
	dp[1]=abs(h[1]-h[0]);
	for (int i=2;i<n;i++)
		dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
	//Ideas:
	cout << dp[n-1] << '\n';
	/*Out*/
	return 0;
}

Measured memory_bytes: 1024
import random as ra
import copy
import time

start_time = time.time()

D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]

### 得点計算用
#t = [int(input()) for i in range(D)]
def cal_point(t):
    score = 0
    last = [0]*26
    for d in range(D):
        score += s[d][t[d]-1]
        last[t[d]-1] = d+1
        for i in range(26):
            score -= c[i]*(d+1-last[i])
    #print(score)
    return score


t = []
last = [0]*26
for i in range(D):
    opt1 = s[i].index(max(s[i]))
    opt2 = last.index(min(last))
    if ra.random()<0.5:
        t.append(opt1)
        last[opt1] = i+1
    else:
        t.append(opt2)
        last[opt2] = i+1


t = [ra.randint(1,26) for i in range(D)]
max_score = 0
optimal_t = copy.deepcopy(t)
#M = 10**5
while (time.time()-start_time)<1.95:
#for i in range(M):
    d = ra.randint(1,D)
    q = ra.randint(1,26)
    td = t[d-1]
    t[d-1] = q
    now = cal_point(t)
    if now > max_score:
        optimal_t = copy.deepcopy(t)
        max_score = now
    else:
        t[d-1] = td

print(*optimal_t,sep='\n')


Measured memory_bytes: 10100
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9+3;
const int MOD = 1e9 + 7;

using namespace std;

int partition(vector<pair<int,char> >& A,int p,int r){
	int x = A[r-1].first;
	int i = p-1;
	FOR(j,p,r){
		if(A[j].first <= x) swap(A[j],A[++i]);//pair swap
	}
	return i;
}

//[p,r)
void quickSort(vector<pair<int,char> >& A,int p,int r){
	if(p+1 < r){
		int standard = partition(A,p,r);
		quickSort(A,p,standard);
		quickSort(A,standard + 1,r);
	}
}

pair<int,char> L[(int)1e5],R[(int)1e5];
void merge(vector<pair<int,char> >& A,int left,int right,int mid){
	int n1 = mid - left;
	int n2 = right - mid;
	REP(i,n1)L[i] = A[left + i];
	REP(i,n2)R[i] = A[mid + i];
	L[n1].first = R[n2].first = INF;
	int i =0,j=0;
	FOR(k,left,right){
		if(L[i].first <= R[j].first)A[k] = L[i++];//<=??????????????¨????????§???????????????
		else A[k] = R[j++];
	}
}
//[left,right)
void mergeSort(vector<pair<int,char> >& A,int left,int right){
	if(left+1 < right){
		int mid = (left + right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,right,mid);
	}
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;cin>>n;
	vector<pair<int,char> > A(n);REP(i,n)cin>>A[i].second>>A[i].first;
	vector<pair<int,char> > B(A);
	quickSort(A,0,n);
	mergeSort(B,0,n);
	bool stable = true;
	REP(i,n){
		if(A[i].second != B[i].second){stable = false;break;}
	}
	if(stable)cout << "Stable" << endl;
	else	cout << "Not stable" << endl;
	REP(i,n){
		cout << A[i].second << ' ' << A[i].first << '\n';
	}
	/*	REP(i,n){
		cout << B[i].second << ' ' << B[i].first << '\n';
		}*/
  return 0;
}

Measured memory_bytes: 5868
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<string> a;
  int w,h;
  string n;
  cin>>h>>w;
  for(int i=0;i<w+2;i++)
    n+="#";
  a.push_back(n);
  for(int i=0;i<h;i++){
    string s;
    cin>>s;
    s="#"+s+"#";
    a.push_back(s);
  }
  a.push_back(n);
  for(int i=0;i<h+2;i++)
    cout<<a.at(i)<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn = 3e2 + 5;
 
int mod, n, k;
LL dp[maxn][maxn][maxn], ans;
 
int main() {
	scanf("%d%d%d", &n, &k, &mod);
	dp[0][1][0] = 1;
	for(register int i = 0; i <= n; ++i)
		for(register int j = 1; j <= k; ++j)
			for(register int p = i; p >= 0; --p) {
				if(p) (dp[i][j][p - 1] += dp[i][j][p]) %= mod;
				else (dp[i][j + 1][i] += dp[i][j][p]) %= mod;
				(dp[i + 1][j][p] += dp[i][j][p] * (p + 1)) %= mod;
			}
	printf("%lld", dp[n][k + 1][n]);
	return 0;
}


Measured memory_bytes: 221440
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		System.out.println(A<=C&&C<=B?"Yes":"No");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21972
///*.......................Shadman Sakib Utshob............................*///

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define Boost           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define pb              push_back
#define inf             1e9+8
#define mp              make_pair
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define ll              long long
#define pii             pair<ll,ll >
#define MOD             1000000007
#define fileout         freopen("output.txt","w",stdout)
#define mem(x,i)        memset(x,i,sizeof x)
#define Ones(x)         __builtin_popcount(x);
#define PI              acos(-1.0)
#define ff              first
#define ss              second
#define T               int t;cin>>t;while(t--)
#define ok              cout<<"ok"<<endl;
#define all(x)          (x).begin(),(x).end()
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define nln	            cout<<endl;

int main()
{
    Boost;
    ll n,i,j,c,md,k=0,x=0;
    cin>>n;
    vector<ll>a;
    rep1(i,n)
    {
        cin>>c;
        a.pb(c);
    }
    for(i=1;;i++)
    {
        sort(all(a));k=0;
        for(j=0;j<n;j++)
        {
            if(a[j]==0)
                continue;
            else if(k==0)
            {
                if(j==n-1)
                {
                    //see(j)
                    x=1;break;
                }
                k=1;
                md=a[j];
                //see(md)
            }
            else
                a[j]%=md;
            if(md==1)
                break;

        }
        if(md==1)
            break;
        if(x==1)
            break;
    }
    if(md==1)
        cout<<md<<endl;
    else if(x==1)
    {
        sort(all(a));
        cout<<a[n-1]<<endl;
    }


}


Measured memory_bytes: 4272
import java.util.*;

    public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int a,b,c;
            int count;
            
            while(true){
                int x = sc.nextInt();
                int n = sc.nextInt();
                if(n==0 && x==0){
                    break;
                }
                count=0;
                for(a=1;a<=x;a++){
                   
                    for(b=1;b<a;b++){
                        for(c=1;c<b;c++){
                            if(a+b+c==n){
                        count++;
                            }
                            
                        }
                    }
                }
                    System.out.println(count);
            
        }
        }
    }


Measured memory_bytes: 26364
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static final int N_MAX = 1000000;
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		int N,cnt=0;
		boolean[] a = new boolean[N_MAX];
		for(int i=0;i<N_MAX;i++){
			a[i]=true;
		}
		a[0]=false;
		a[1]=false;
		
		for(int i=2;i<N_MAX;i++){
			if(a[i]==true){
				for(int j=2;i*j<N_MAX;j++){
					a[i*j]=false;
				}
			}
		}
		
		while(str != null){
			N=Integer.parseInt(str);
			
			for(int k=0;k<=N;k++){
				if(a[k]==true){
					cnt++;
				}
			}
			System.out.println(cnt);
			cnt=0;
			str=br.readLine();
		}
		
	}
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  
  vector<int> west(N+1);
  for(int i=0; i<N; i++){
      if(S.at(i)=='W'){
          west.at(i+1)=west.at(i)+1;
      }
      else{
          west.at(i+1)=west.at(i);
      }
    }

  int ans=N-1;
  for(int i=0; i<N; i++){
      ans=min(ans, west.at(i)+N-1-i-(west.at(N)-west.at(i+1)));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1796
//#pragma comment(linker,"/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
const int INF=0x3f3f3f3f;
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= b; ++i)
const int max_number=1000000;


struct points{
    double x, y;
};

int main()
{

    points x, y;
    scanf("%lf%lf%lf%lf", &x.x, &x.y, &y.x, &y.y);  //double

    double distance;
    double i = pow((x.x - y.x), 2);
    double j = pow((x.y - y.y), 2);

    distance = sqrt(i + j);

    printf("%.8f", distance);
    printf("\n");
    return 0;
}


Measured memory_bytes: 3204