akhauriyash/Code-Regression huggingface dataset:
// template version 1.7

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
#define INF 1e18
// #define INF 2147483647
#define MOD 1e9+7
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

bool isok(int l, int r){
}

int solve(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;

  int res = 0;
  int r = 0;
  bool zflag=false;
  if (s[0]=='0') {
    zflag=true;
    k--;
  }
  for (int l=0; l<n; ++l) {
    while (r<n-1) {
      dump(l, r, k, s[r+1], zflag);
      if (k==0 and s[r+1]=='0' and !zflag) break;

      dump(l, r);
      ++r;
      if (!zflag and s[r]=='0'){
        k--;
        zflag=true;
      }
      if (s[r]=='1' and zflag) zflag=false;
    }

    chmax(res, (r-l+1));  // 更新
    dump(l, r, res);
    if (l==n-1 || r==n-1) break;

    // prepare move l
    zflag=false;
    while (l<n-1){
      if (s[l]=='0') zflag=true;
      l++;
      if(zflag and s[l]=='1') break;
    }
    k++;
    l--;
    zflag=false;
  }
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

using namespace std;

#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";
#define FIO ios_base::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(10);cout.tie(nullptr);cin.tie(nullptr);

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

template < class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); }
template < class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); }
template < class T> inline T ison(T n, T pos) { return (bool)(n & ((T)1 << pos)); }
template < class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); }return a; }

template <class T> inline T bigmod(T p, T e, T m) {
	T ret = 1;
	for (; e > 0; e >>= 1) {
		if (e & 1) ret = (ret * p) % m; p = (p * p) % m;
	} return (T)ret;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " is " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
	int n,m;
	cin>>n>>m;

	for(int x=0;x<=n;x++){
		long long one=x;
		long long other=n-x;
		if(one*2+other*4==m){
         	cout<<"Yes"<<nl;
	        return;
		}
	}
    cout<<"No"<<nl;

}

int main()
{
	FIO;

	int t = 1;
	while (t--)
	{
		solve();
	}

	return 0;
}


Measured memory_bytes: 3656
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))
ls = []
for i in range(N):
    ls.append(abs(x[i]-X))
now = ls[0]
for i in range(1,N):
    now = math.gcd(ls[i],now)
print(now)

Measured memory_bytes: 20376
import math
n=int(input())
XY=[]
for _ in range(n):
    x,y=map(int,input().split())
    if x==y==0:
        continue
    XY.append((x,y))
l=len(XY)
if l:
    XY.sort(key=lambda x: math.atan2(x[1],x[0]))
    ans=0
    XY+=XY
    for i in range(l):
        x,y=0,0
        for j in range(i,i+l):
            x+=XY[j][0]
            y+=XY[j][1]
            ans=max(ans,x**2+y**2)
    print(ans**0.5)
else:
    print(0)

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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

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

    unordered_map<string,ll> M;
    REP(i,N){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        M[s]++;
    }

    ll ans = 0;
    for(auto m:M){
        if(m.second==1)continue;
        ll tmp = m.second-1;
        ans += (tmp*(tmp+1))/2;
    }

    cout << ans << endl;


}



Measured memory_bytes: 10660
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 100
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
print("? " +  " ".join(map(str, [i for i in range(1, n + 1)])))
flg = str(input())
ng = n + 1
ok = 1
while ok + 1 < ng:
    mid = (ok + ng) // 2
    print("? " + " ".join(map(str, [i for i in range(mid, mid + n)])))
    if flg != str(input()):
        ng = mid
    else:
        ok = mid


L = [i for i in range(ok + 1, ok + n)]
b_cnt = 0
r_cnt = 0
LL = []
R = []
B = []
if flg == "Red":
    R += [ok]
    B += [ok + n]
else:
    B += [ok]
    R += [ok + n]

for j in range(1, 2 * n + 1):
    if ok <= j <= ok + n:
        continue
    L += [j]
    print("? " + " ".join(map(str, L)))
    L.pop()
    s = str(input())
    if s == "Blue":
        B += [j]
    else:
        R += [j]

LL = B[:n//2] + R[:n//2]
for k in range(ok + 1, ok + n):
    LL += [k]
    print("? " + " ".join(map(str, LL)))
    LL.pop()
    if str(input()) == "Blue":
        B += [k]
    else:
        R += [k]


ans = [""] * (2 * n)
for b in B:
    ans[b - 1] = "B"
for r in R:
    ans[r - 1] = "R"

print("! " + "".join(map(str, ans)))




Measured memory_bytes: 77792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int a, b, c;
    string s, t;

    cin >> s;

    string y(s.begin(), s.begin()+4);
    string m(s.begin()+5, s.begin()+7);
    string d(s.begin()+8, s.begin()+10);
    int yn = stoi(y);
    int mn = stoi(m);
    int dn = stoi(d);

    if (yn <= 2019) {
        if (mn <= 4) {
            if (dn <= 30) {
                cout << "Heisei" << endl;
            }
            else {
                cout << "TBD" << endl;
            }
        }
        else {
            cout << "TBD" << endl;
        }
    }
    else {
        cout << "TBD" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const ll LINF = 1LL << 50;
const int MAX = 405;
/* global variables */
vector<ll> a(MAX, 0), sum(MAX, 0);
/* function */
ll calcCost(int l, int r) { return sum[r+1] - sum[l]; }
/* main */
int main(){
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) sum[i+1] = sum[i] + a[i];

    vector<vector<ll>> dp(N, vector<ll>(N, LINF));
    for (int i = 0; i < N; i++) dp[i][i] = 0;

    // ex) a0, a1, a2
    // w=1 , a0+a1, a1+a2
    // w=2 , a0+a1+a2 = min{a0+(a1+a2),  (a0+a1)+a2)}
    //   | 0 | 1 | 2
    // 0 | 0 |w=1|w=2
    // 1 |   | 0 |w=1
    // 2 |   |   | 0
    for (int w = 1; w < N; w++) {  // a[i] ~ a[i+w]
        for (int s = 0; s < N-w; s++) {  // start
            int t = s + w;  // end
            // k : 分割候補
            // s | s+1 | ... | t-1 | t
            //   ^     ^     ^     ^
            // のw個
            for (int k = s; k < t; k++) {
                ll cost = calcCost(s, k) + calcCost(k+1, t);
                dp[s][t] = min(dp[s][t], dp[s][k] + dp[k+1][t] + cost);
            }
        }
    }
    cout << dp[0][N-1] << '\n';
}


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

using namespace std;

int w,h;
char map[20][20];
int cnt;

int dirx[4] = {1,0,-1,0};
int diry[4] = {0,1,0,-1};

bool inField(int x,int y){
	return (0<=x) && (x<w) && (0<=y) && (y<h);
}

//深さ優先探索
void dfs(int posx,int posy){
	cnt ++;
	map[posy][posx] = '#';
	for(int i=0;i<4;i++){
		int nextx = posx + dirx[i];
		int nexty = posy + diry[i];
		if(inField(nextx,nexty) && map[nexty][nextx] != '#'){
			dfs(nextx,nexty);
		}
	}
	
}
//名簿
int main(){
	while(true){
		cin >> w >> h;
		if(w==0){
			break;
		}
		cnt =0;
		int posx,posy;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> map[i][j];
				if(map[i][j] == '@'){
					posx = j;
					posy = i;
					map[i][j] = '.';
				}
				
			}
		}
		dfs(posx,posy);
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1168
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Tuple {
		int a, b;

		Tuple(int a, int b) {
			this.a = a;
			this.b = b;
		}

		@Override
		public String toString() {
			return (a + 1) + " " + (b + 1);
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		long[] a = new long[N];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			a[i] = Long.parseLong(tokens[i]);
		}
		long min = Long.MAX_VALUE, max = Long.MIN_VALUE;
		int minIndex = -1, maxIndex = -1;
		for (int i = 0; i < N; ++i) {
			if (min > a[i]) {
				min = a[i];
				minIndex = i;
			}
			if (max < a[i]) {
				max = a[i];
				maxIndex = i;
			}
		}
		List<Tuple> result = new ArrayList<>();
		if (Math.abs(min) > Math.abs(max)) {
			// 全体にminを足す
			for (int i = 0; i < N; ++i) {
				if (i == minIndex) {
					continue;
				}
				a[i] += min;
				result.add(new Tuple(minIndex, i));
			}
			// 後ろから順に足していく
			for (int i = N - 1; i > 0; --i) {
				result.add(new Tuple(i, i - 1));
				a[i - 1] += a[i];
			}
		} else {
			// 全体にmaxを足す
			for (int i = 0; i < N; ++i) {
				if (i == maxIndex) {
					continue;
				}
				a[i] += max;
				result.add(new Tuple(maxIndex, i));
			}
			// 前から順に足していく
			for (int i = 0; i + 1 < N; ++i) {
				result.add(new Tuple(i, i + 1));
				a[i + 1] += a[i];
			}
		}
		// 回答出力
		System.out.println(result.size());
		for (int i = 0; i < result.size(); ++i) {
			System.out.println(result.get(i).toString());
		}
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
ll exp(ll a,ll b)
{
	if(b==0)
	 return 1;
	if(b%2==0)
	 return exp(a*a%mod,b/2);
	return a*exp(a*a%mod,(b-1)/2)%mod;
}
int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll>dp(k+1);
	ll ans=0;
	for(ll i=k; i>=1; i--)
	{
		ll temp=exp(k/i,n);
		for(ll x=2; i*x<=k; x++)
		{
			temp=(temp-dp[i*x]+mod)%mod;
		}
	    dp[i]=temp;
	    ans=(ans+i*dp[i])%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3968
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mountainArray[] = new int[10];
        for(int i = 0; i < 10; i++){
            mountainArray[i] = sc.nextInt();
        }
        for(int i = 0; i < 10; i++){
            for(int j = i + 1; j < 10; j++){
                if(mountainArray[i] < mountainArray[j]){
                    int temp = mountainArray[i];
                    mountainArray[i] = mountainArray[j];
                    mountainArray[j] = temp; 
                    
                }
            }
        }
        for(int i = 0; i < 3; i++){
            System.out.println(mountainArray[i]);
            
        }
        
    }
}


Measured memory_bytes: 26312
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin >> N;
  VEC<string> S(N);
  REP(i, 0, N) {
    cin >> S[i];
    sort(ALL(S[i]));
  }
  S.push_back("zzzzzzzzzzzz");
  sort(ALL(S));
  // DUMP(S);
  LL cnt = 0;
  REP(l, 0, N) {
    int r = l + 1;
    while (S[l] == S[r]) {
      r++;
    }
    LL k = r - l;
    cnt += k * (k - 1) / 2;
    l=r-1;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 8064
# D - 756
# 75 = 3*5*5なので、(4個以上ある素因数のうち2つを選ぶ組合せ)×(残りから2個以上ある素因数1つを選ぶ組合せ) が解の一部
# 15*5, 25*3, 75についても同様

import collections, math

N = int(input())

# n以下の全ての素数のセットを返す関数
def prime_set(n):
    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))
    return primes

# nを素因数分解して素因数の全リストを返す関数
def prime_factors_duplicating_list(n):
    f = []
    for i in prime_set(int(n**0.5) + 1):
        while n % i == 0:
            f.append(i)
            n //= i
    if n > 1:
        f.append(n)
    return f

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N_factorial_prime_factors = []
for i in range(1, N+1):
    N_factorial_prime_factors.extend(prime_factors_duplicating_list(i))

N_factorial_prime_factors = collections.Counter(N_factorial_prime_factors)

n_74plus_factors = set()
n_24plus_factors = set()
n_14plus_factors = set()
n_4plus_factors = set()
n_2plus_factors = set()

for key in N_factorial_prime_factors:
    for border in [2,4,14,24,74]:
        if N_factorial_prime_factors[key] >= border:
            eval("n_" + str(border) + "plus_factors.add(key)")

ans = 0
ans += comb(len(n_4plus_factors), 2) * (len(n_4plus_factors) - 2 + len(n_2plus_factors - n_4plus_factors)) # 3*5*5
ans += len(n_14plus_factors) * (len(n_14plus_factors) - 1 + len(n_4plus_factors - n_14plus_factors)) # 15*5
ans += len(n_24plus_factors) * (len(n_24plus_factors) - 1 + len(n_2plus_factors - n_24plus_factors)) # 25*3
ans += len(n_74plus_factors) # 75

print(ans)

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define MOD 1000000007;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> numCount(n, 0);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        numCount[x]++;
    }

    int ans = 1;
    if (n % 2 == 0) { // 要素数が偶数の時
        for (int i = 1; i < n; i+=2) {
            if (numCount[i] != 2) {
                printf("0\n");
                return 0;
            }
            ans = (ans * 2) % MOD;
        }
    } else { // 要素数が奇数
        if (numCount[0] != 1) {
            printf("0\n");
            return 0;
        }
        for (int i = 2; i < n; i+=2) {
            if (numCount[i] != 2) {
                printf("0\n");
                return 0;
            }
            ans = (ans * 2) % MOD;
        }
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>


using namespace std;

int main(int argc, char** argv) {
    string str;
    cin >> str;
    int count_1{0}, count_0{0};
    bool toggle{false};
    for (char c : str) {
        if (toggle) {
            if (c == '0') ++count_0;
            toggle = false;
        } else {
            if (c == '1') ++count_0;
            toggle = true;
        }
    }

    toggle = true;
    for (char c : str) {
        if (toggle) {
            if (c == '0') ++count_1;
            toggle = false;
        } else {
            if (c == '1') ++count_1;
            toggle = true;
        }
    }
    cout << min(count_0, count_1) << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.*;

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

		ArrayList<Integer> bData = new ArrayList<>();
		ArrayList<Integer> fData = new ArrayList<>();
		ArrayList<Integer> rData = new ArrayList<>();
		ArrayList<Integer> vData = new ArrayList<>();
		
		int firBuild[][] = new int[10][3];
		int secoBuild[][] = new int[10][3];
		int thiBuild[][] = new int[10][3];
		int forBuild[][] = new int[10][3];
		
		//??\?????????
		int n = sc.nextInt();
		int b, f, r, v = 0;
		for(int i = 0; i < n; i++) {
			b = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
			v = sc.nextInt();
			bData.add(b);
			fData.add(f);
			rData.add(r);
			vData.add(v);
		}
		
		//???????????????
		for(int j = 0; j < 3; j++) {
			for(int i = 0; i < 10; i++) {
				firBuild[i][j] = 0;
				secoBuild[i][j] = 0;
				thiBuild[i][j] = 0;
				forBuild[i][j] = 0;
			}
		}
		
		//?????????????´?
		for(int i = 0; i < n; i++) {
			if(bData.get(i) == 1) {
				firBuild[rData.get(i)-1][fData.get(i)-1] = vData.get(i) + firBuild[rData.get(i)-1][fData.get(i)-1];
			} else if(bData.get(i) == 2) {
				secoBuild[rData.get(i)-1][fData.get(i)-1] = vData.get(i) + secoBuild[rData.get(i)-1][fData.get(i)-1];
			} else if(bData.get(i) == 3) {
				thiBuild[rData.get(i)-1][fData.get(i)-1] = vData.get(i) + thiBuild[rData.get(i)-1][fData.get(i)-1];
			} else if(bData.get(i) == 4) {
				forBuild[rData.get(i)-1][fData.get(i)-1] = vData.get(i) + forBuild[rData.get(i)-1][fData.get(i)-1];
			}
		}
		
		//??????
		for(int k  = 0; k < 4; k++) {
			for(int j = 0; j < 3; j++) {
				for(int i = 0; i < 10; i++) {
					if(k == 0) {
						System.out.print(" " + firBuild[i][j]);
					} else if(k == 1) {
						System.out.print(" " + secoBuild[i][j]);
					} else if(k == 2) {
						System.out.print(" " + thiBuild[i][j]);
					} else if(k == 3) {
						System.out.print(" " + forBuild[i][j]);
					}
				}
				System.out.println();
			}
			if(k != 3) {
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 28952
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
	ll X, Y, A, B, C, d, sum = 0;
  cin >> X >> Y >> A >> B >> C;
  priority_queue<ll> p, q, apple;
  rep(i, 0, A) {
  	cin >> d; p.push(d);
  }
  rep(i, 0, X) {
  	apple.push(p.top()); p.pop();
  }
  rep(i, 0, B) {
  	cin >> d; q.push(d);
  }
  rep(i, 0, Y) {
  	apple.push(q.top()); q.pop();
  }
  rep(i, 0, C) {
  	cin >> d; apple.push(d);
  }
  rep(i, 0, X + Y) {
  	sum += apple.top(); apple.pop();
  }
  cout << sum << endl;
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0, r = n - 1, ans = 0;
    while(1) {
        while(s[l] == 'R' && l < n) l++;
        while(s[r] == 'W' && r >= 0 ) r--;
        if(l < r){
            swap(s[l], s[r]);
            ans++;
        }
        else break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3756
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <map>

using namespace std;

#define unomap unordered_map
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itr iterator
#define rtr reverse_iterator

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

typedef set<int> si;
typedef set<pi> spi;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;

typedef vector<vb> vmb;
typedef vector<vi> vmi;
typedef vector<si> vsi;
typedef vector<vpi> vmpi;
typedef vector<spi> vspi;

inline int readInt()       {char c;while(c=getchar(),c<'0'||c>'9');bool sign=(c=='-');if(sign)c=getchar();int n=c-'0';while(c=getchar(),!(c<'0'||c>'9'))n=10*n+c-'0';return(sign)?-n:n;}
inline int readLong()      {char c;while(c=getchar(),c<'0'||c>'9');bool sign=(c=='-');if(sign)c=getchar();ll  n=c-'0';while(c=getchar(),!(c<'0'||c>'9'))n=10*n+c-'0';return(sign)?-n:n;}
inline void getInt(int& n) {char c;while(c=getchar(),c<'0'||c>'9');bool sign=(c=='-');if(sign)c=getchar();    n=c-'0';while(c=getchar(),!(c<'0'||c>'9'))n=n*10+(c-'0');   if(sign)n=-n;}
inline void getLong(ll& n) {char c;while(c=getchar(),c<'0'||c>'9');bool sign=(c=='-');if(sign)c=getchar();    n=c-'0';while(c=getchar(),!(c<'0'||c>'9'))n=n*10+(c-'0');   if(sign)n=-n;}

int query()
{



    return 0;
}

int main()
{
    int n = readInt();
    int k = readInt();

    vi a(n);
    for (int &x : a) x = readInt();

    vi dp(n, 0);
    for (int i = 1; i < n; ++i)
    {
        dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        for (int j = 2; j <= k; ++j)
            if (i - j >= 0)
                dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
    }

    cout << dp[n - 1];
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll res = 0;
    vector<int> a(s.size() + 1);
    rep (i, s.size()) if (s[i] == '<') a[i + 1] = max(a[i + 1], a[i] + 1);
    rrep(i, s.size()) if (s[i] == '>') a[i] = max(a[i], a[i + 1] + 1);
    rep (i, a.size()) res += a[i];
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 2844
/*----- || Hare Krishna || -----*/

/*  "WHY DO WE FALL, BRUCE?"  */

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define elif else if
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384
#define MOD 1000000007
using namespace std;

char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

string s;
int t;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll a1,a2,a3,a4;
    a1 = a*c;
    a2 = a*d;
	a3 = b*c;
	a4 = b*d;
	a1 = max(a1,max(a2,max(a3,a4)));
	cout << a1 << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll N;
	ll res=0;
	string sres;
	cin>>N;
	map<string,VPLL> mp;
	REP(i, N) {
		string s;
		ll p;
		cin >> s>>p;
		mp[s].emplace_back(make_pair(p,i+1));
	}
	for(auto m:mp){
		VPLL tmp=m.second;
		SORTR(tmp);
		for(auto p:tmp){
			COUT(p.second);
		}
	}

	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
def d_double_landxcape(N, M, A, B):
    """
    N行M列のグリッドに1からNMまでの整数を重複なく書き込む。このとき、以下の条件を満たす。
    ・i行目に書き込まれている値のうち、最大の値はA_i
    ・j行目に書き込まれている値のうち、最大の値はA_j
    書き込み方の総数を10**9+7で割った余りを求めよ。
    """

    # Aの各要素、またはBの各要素の中で、同じ値があるならば解は0
    # (異なる行/列に同じ数字を書き込むことは不可能)。
    # グリッドの中のxが書かれうる場所について、xが大きな順に考える。

    # 1. xがA_iとB_jの両方に現れる場合
    # xの場所は一意に定まる。

    # 2. xがA_iとB_jの片方に現れる場合
    # xがA_iに現れている場合、xの場所としてありうるものの個数は、
    # (B_j >= x となるjの個数) である。
    # xはA_i行にしか書き込めないし、B_j < x となる列に書き込むと
    # 矛盾してしまうため。

    # 3. xがAにもBにも現れない場合
    # xの場所としてありうるものの個数は、
    # (A_i >= x となるiの個数) * (B_j >= x となるjの個数) である。
    # ただし、そのうち NM - x 個はxより大きな値が書き込まれている。

    # 以上の値の総乗が解である。
    from bisect import bisect_left
    MOD = 10**9 + 7

    a = sorted(A)
    b = sorted(B)
    a_set = set(A)
    b_set = set(B)
    if len(a) != len(a_set) or len(b) != len(b_set):
        return 0  # 重複する要素があった。矛盾する。

    ans = 1
    for k in range(N * M, 0, -1):
        cond1 = k in a_set
        cond2 = k in b_set
        # 順に、上にコメントした、条件1. 2. 3. を満たす場合
        if cond1 and cond2:
            continue
        elif cond1:
            idx = bisect_left(b, k)
            ans *= (M - idx)
        elif cond2:
            idx = bisect_left(a, k)
            ans *= (N - idx)
        else:
            idx_a = bisect_left(a, k)
            idx_b = bisect_left(b, k)
            ans *= (N - idx_a) * (M - idx_b) - (N * M - k)
        ans %= MOD
    return ans % MOD

N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
print(d_double_landxcape(N, M, A, B))

Measured memory_bytes: 44468
#include "bits/stdc++.h"
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int x = max(max(A, B), max(B, C));

    int K;
    cin >> K;

    cout << x * pow(2, K) + A + B + C - x << endl;
}

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

struct card{
	char suit, value;
};

void bubble_sort(struct card C[], int N){
	for(int i = 0; i < N; i++){
		for(int j = N - 1; j > i; j--){
			if(C[j].value < C[j - 1].value){
				card t = C[j]; C[j] = C[j - 1]; C[j - 1] = t;
			}
		}
	}
}

void selection_sort(struct card C[],int N){
	int minj;
	for(int i = 0; i < N; i++){
		minj = i;
		for(int j = i + 1; j < N; j++){
			if(C[j].value < C[minj].value) minj = j;
		}
		card t = C[minj]; C[minj] = C[i]; C[i] = t;
	}
}

void print(struct card C[], int N){
	for(int i = 0; i < N; i++){
		if(i) cout<<" ";
		cout<<C[i].suit<<C[i].value;
	}
	cout<<endl;
}

int stable_sort(struct card C1[], struct card C2[],int N){
	for(int i = 0; i < N; i++){
		if(C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main(){
	card C1[100], C2[100];
	int  N;
	char ch;
	cin>>N;
	for(int i = 0; i < N; i++){
		cin>>C1[i].suit>>C1[i].value;
	}
	for(int i = 0; i < N; i++) C2[i] =C1[i];
	bubble_sort(C1, N);
	selection_sort(C2,N);
	print(C1, N);
	cout<<"Stable"<<endl;
	print(C2, N);
	if(stable_sort(C1, C2, N)) cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;

	return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<cmath>
#include<algorithm>
#include<array>
#include<cstdio>
#include<functional>
using namespace std;
int main()
{
    long long int a,b,c,d,product;
    cin>>a>>b>>c>>d;
    array<long long int,4>m;
    m[0] = a*c;
    m[1] = a*d;
    m[2] = b*c;
    m[3] = b*d;

    sort(m.begin(),m.end());
    product = m.at(3);
    cout<<product<<'\n';
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int maze[25][25];
int mark[25][25];
int wayx[] = {0, 0, 1, -1};
int wayy[] = {1, -1, 0, 0};
struct node{
    int i, j;
    node(int a, int b) {
        i = a;
        j = b;
    }
};
int bfs(int x, int y, int ex, int ey, int h, int w) {
    memset(mark, 0, sizeof(mark));
    queue<node> qe;
    qe.push(node(x, y));
    mark[x][y] = 1;
    int i = 0, j = 0;
    while(!qe.empty()) {
        i = qe.front().i, j = qe.front().j;
        qe.pop();
        for(int n = 0; n < 4; ++ n) {
            if(i + wayx[n] >= 0 && i + wayx[n] < h && j + wayy[n] >= 0 && j + wayy[n] < w) {
                if(!mark[i + wayx[n]][j + wayy[n]] && maze[i + wayx[n]][j + wayy[n]]) {
                    mark[i + wayx[n]][j + wayy[n]] = mark[i][j] + 1;
                    qe.push(node(i + wayx[n], j + wayy[n]));
                }
            }
        }
    }
    // for(int _i = 0; _i < h; ++ _i) {
    //     for(int _j = 0; _j < w; ++ _j) {
    //         cout << mark[_i][_j] << " ";
    //     }
    //     cout << endl;
    // }
    return mark[ex][ey] - 1;
}
int main() {
    int h, w;
    cin >> h >> w;
    memset(maze, 0, sizeof(maze));
    getchar();
    for(int i = 0; i < h; ++ i) {
        // string input;
        // cin >> input;
        for(int j = 0; j < w; ++ j) {
            char s;
            scanf("%c", &s);
            // if(input[j] == '.') 
            if(s == '.')maze[i][j] = 1;
        }
        getchar();
    }
    int ans = 0;
    for(int i = 0; i < h; ++ i) {
        for(int j = 0; j < w; ++ j) {
            for(int k = 0; k < h; ++ k) {
                for(int l = 0; l < w; ++ l) {
                    if(maze[i][j] && maze[k][l]) {
                        ans = max(bfs(i, j, k, l, h, w), ans);
                        // cout << ans << endl;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 256
/*
Author:loceaner
*/
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lowbit(x) (x & (-x));
using namespace std;

const int A = 1e6 + 11;
const int B = 1e6 + 11;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

inline int read() {
  char c = getchar();
  int x = 0, f = 1;
  for ( ; !isdigit(c); c = getchar()) if (c == '-') f = -1;
  for ( ; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  return x * f;
}

struct node { int l, r, pos; }ask[A];
int n, m, c[A], num[A], tree[A], booll[A], nnn[A], ww;

void change(int x, int k) {
	while (x <= n) {
		c[x] += k;
		x += lowbit(x); 
	}
}

int query(int x) {
	int ans = 0;
	while (x) {
		ans += c[x];
		x -= lowbit(x);
	}
	return ans;
}

bool cmp (node a, node b) {
	return a.r < b.r;
}

int main() {
	scanf("%d",&n);
	scanf("%d",&m);
	for (int i = 1; i <= n; i++) scanf("%d",&num[i]);
	for (int i = 1; i <= m; i++){
		scanf("%d%d",&ask[i].l, &ask[i].r);
		ask[i].pos = i;
	}
	sort(ask + 1, ask + 1 + m, cmp);
	int next = 1;
	for (int i = 1; i <= m; i++) {
		for (int j = next; j <= ask[i].r; j++){
			if (booll[num[j]]) change(booll[num[j]], -1);
			change(j, 1), booll[num[j]] = j;
		}
		next = ask[i].r + 1;
		nnn[ask[i].pos] = query(ask[i].r)- query(ask[i].l - 1);
	}
	for (int i = 1; i <= m; i++) cout << nnn[i] << "\n";
	return 0;
}


Measured memory_bytes: 17476
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s;
	std::cin >> s;
	if(s[2]==s[3] && s[4]==s[5]) {
		print("Yes");
	} else print("No");
	return 0;
}


Measured memory_bytes: 256
import sys

judgeTable = {0: "AAA", 1: "AA", 2: "A",
              3: "B", 4: "C", 5: "D", 6: "E", 7: "NA"}


def Judge500(time):

    if time < 35.5:
        return 0
    elif time < 37.5:
        return 1
    elif time < 40.0:
        return 2
    elif time < 43.0:
        return 3
    elif time < 50.0:
        return 4
    elif time < 55.0:
        return 5
    elif time < 70.0:
        return 6
    else:
        return 7


def Judge1000(time):

    if time < 71.0:
        return 0
    elif time < 77.0:
        return 1
    elif time < 83.0:
        return 2
    elif time < 89.0:
        return 3
    elif time < 105.0:
        return 4
    elif time < 116.0:
        return 5
    elif time < 148.0:
        return 6
    else:
        return 7


for line in sys.stdin:
    line = line[:-1]

    time1, time2 = [float(item) for item in line.split(" ")]
    rank1, rank2 = Judge500(time1), Judge1000(time2)
    result = judgeTable[max(rank1, rank2)]
    print(result)



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

int main() {
	string s; cin >> s;
	string model = "CODEFESTIVAL2016";
	int ans = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != model[i]) ans++;
	}
	cout << ans << endl;

}

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

using namespace std;
const int N = 1e5 + 10;
typedef long long ll;
vector<vector<int> > graph;
ll c[N];
int h[N];

void dfs(int v, int p) {
    h[v] = p == -1 ? 0 : h[p] + 1;
    for (int u : graph[v]) {
        if (u == p) continue;
        dfs(u, v);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    graph.resize(n);
    for (int i = 0; i < n; i++)
        cin >> c[i];
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(0, -1);
    vector<pair<int, int> > q;
    for (int i = 0; i < n; i++)
        q.push_back(make_pair(-h[i], i));
    sort(q.begin(), q.end());
    for (int cur = 0; cur < n; cur++) {
        ll sum = 0;
        ll max_c = 0;
        int v = q[cur].second;
        if (cur != n - 1 && graph[v].size() == 1)
            continue;
        for (int u : graph[v]) {
            if (h[u] != h[v] + 1)
                continue;
            sum += c[u];
            max_c = max(max_c, c[u]);
        }
        ll max_t;
        if (sum - max_c >= max_c)
            max_t = sum / 2;
        else {
            max_t = sum - max_c;
        }
        ll t = sum - c[v];
        if (t < 0 || c[v] < t || t > max_t) {
            cout << "NO\n";
            return 0;
        }
        c[v] -= t;
    }
    if (c[0] == 0) {
        cout << "YES\n";
    } else if (graph[0].size() == 1) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 12024
#include <bits/stdc++.h>                                                           
#define rep(i,a,b) for(int i=a;i<b;i++)                                            
#define rrep(i,a,b) for(int i=a;i>=b;i--)                                          
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    ll N,D;
    cin >> N >> D;
    ll num;

    num =N/(2*D+1);
    if(N%(2*D+1)!=0){
        num++;
    }

    cout << num << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    multiset<int> s(A.begin(),A.end());
    int ans = 0;
    while (s.size()) {
        auto itr = s.end(); --itr;
        s.erase(itr);
        int a = *itr;
        int x = (1 << (32 - __builtin_clz(a))) - a;
        auto y = s.find(x);
        if (y != s.end()) {
            ++ans;
            s.erase(y);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 14288
#include <iostream>
using namespace std;
typedef long long int LLI;
string check( int a, int b, int c )
{
	if( a % b == c )
		return "YES";
	
	int start = a % b, tmp = (2 * start) % b;
	
	while( start != tmp ){
    	if( tmp == c )
    		return "YES";
    	tmp += a;
    	tmp %= b;
    }
	return "NO";
}
int main()
{
  	int a, b, c;
  	cin >> a >> b >> c;
  	cout << check(a,b,c);
	return 0;
}

Measured memory_bytes: 3092
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll a,b;
    cin>>a>>b;
    if(a>=13)
    {
        cout<<b<<"\n";
    }
    else if(a>=6&&a<=12)
    {
        cout<<b/2<<"\n";
    }
    else
    {
        cout<<"0\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
S=input()
N=len(S)
T=S[:N//2]
U=S[N//2+1:]

flg=0

for i in range(int((N-1)/2)):
  if(S[i]!=S[-i-1]):
    flg=1
    break
  
for j in range(len(T)//2):
  if(T[j]!=T[-j-1]):
    flg=1
    break
  
for k in range(len(U)//2):
  if(U[k]!=U[-k-1]):
    flg=1
    break

if(flg==0):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
def main():
    N, Q = map(int, input().split())
    S = input()

    lis = [0 for _ in range(len(S))]
    for i in range(len(S)):
        if i > 0:
            lis[i] += lis[i - 1]
        if i < len(S) - 1 and S[i] == 'A' and S[i + 1] == 'C':
            lis[i + 1] += 1

    for _ in range(Q):
        L = tuple(map(int, input().split()))
        print(lis[L[1] - 1] - lis[L[0] - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9324
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <iterator>
#include <list>
#include <unordered_map>
#include <string>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	int st = 0, end = 0, i;
	for (i = 0; i < s.length(); i++) {
		if (s[i] == 'A') {
			st = i;
			break;
		}
	}
	for (i; i < s.length(); i++) {
		if (s[i] == 'Z') {
			end = i;
		}
	}
	cout << end - st + 1;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll cnt[256] = {};
    ll H, W;
    cin >> H >> W;
    rep(i, H * W){
        char c;
        cin >> c;
        cnt[c]++;
    }        
    priority_queue<ll>Q1, Q2;
    for(char c = 'a'; c <= 'z'; c++)Q1.push(cnt[c]);
    for(ll y = 1; y <= H; y++){
        ll y2 = H - y + 1;
        if(y2 < y)continue;
        for(ll x = 1; x <= W; x++){
            ll x2 = W - x + 1;
            if(x2 < x)continue;
            if(y == y2 && x == x2)Q2.push(1);
            else if(x == x2)Q2.push(2);
            else if(y == y2)Q2.push(2);
            else Q2.push(4);
        }
    }
    while(!Q2.empty()){
        ll n = Q2.top();
        Q2.pop();
        ll m = Q1.top();
        Q1.pop();
        if(n > m){
            cout << "No" << endl;
            return 0;
        }
        Q1.push(m - n);
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int s;
    cin>>s;
    map<int,int> mp;
    mp[s]++;
    int pre=s;
    int i=1;
    while(true){
        int a;
        i++;
        if(pre%2==0){
            a=pre/2;
        }else{
            a=pre*3+1;
        }
        mp[a]++;
        if(mp[a]>1){
            cout<<i<<endl;
            return 0;
        }
        pre=a;
        
    }
    
    

return 0;
}


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

typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }

int main(){
  double x[4], y[4];
  double pab, pbc, pca;
  while(true){
    for(int i=0; i<4; ++i){
      cin >> x[i] >> y[i];
    }
    if(!cin) break;
    xy_t a(x[0],y[0]), b(x[1],y[1]), c(x[2],y[2]), p(x[3],y[3]);
    pab = cross_product(a-p,b-p) / 2;
    pbc = cross_product(b-p,c-p) / 2;
    pca = cross_product(c-p,a-p) / 2;
    bool ok = ((pab>0) && (pbc>0) && (pca>0)) || ((pab<0) && (pbc<0) && (pca<0));
    cout << (ok ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 3196
function main(input) {
  const S = input.trim();
  var arr=[];
  for(var i=0; i<S.length; i++){
    for(var j=i; j<S.length; j++){
      var temp=S.slice(i,j+1);
      if(/[^ACGT]/.test(temp)){
      }else{
        arr.push(temp.length)
      }
    }
  }
  if(arr.length>0){
    console.log(Math.max.apply(null, arr));
  }else{
    console.log(0);
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
    long long n;
    cin >> n;
    vector<string>s(n);
    for(long long i=0; i<n; ++i){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());
    string in=s[0];
    long long a=0;
    long long ans=0;
    for(long long i=1; i<n; ++i){
        if(in==s[i]){
            a +=1;
        }
        else{
            ans += (a+1)*a/2;
            in =s[i];
            a=0;
        }
    }
    if(a>0){
        ans += (a+1)*a/2;
    }    
    cout << ans << endl;
}

Measured memory_bytes: 7296
import random
class Dice:
    def __init__(self, dice):
        self.dice = dice
        self.rule={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
    def output(self):
        return self.dice
    def move(self, direction):
        for _ in direction: self.dice = [self.dice[y] for y in self.rule[_]]
        return self.dice

N, A = int(input()), []
for _ in range(N): A.append(Dice([int(x) for x in input().split()]))

Dir, Flag = 'NSEW', 0

for i in range(N):
    for j in range(i+1, N):
        for _ in range(100):
            A[i].move(Dir[random.randint(0,3)])
            if A[i].output() == A[j].output():
                Flag = 1
                break

print('No') if Flag else print('Yes')


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

int main() {

    string S, T;
    cin >> S >> T;

    int A, B;
    cin >> A >> B;

    map<string, int> m;
    m[S] = A;
    m[T] = B;

    string U;
    cin >> U;
    m[U] -= 1;

    cout << m[S] << " " << m[T] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	HashSet<Integer> set = new HashSet<Integer>();
	for(int i = 0; i< N; i++) {
	    set.add(sc.nextInt());
	}
	System.out.println(set.size());
    }
}

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

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    
    long long mi = 1;
    long long res = 0;
    for(int i=0; i<N; ++i) {
        if(A[i] > mi) {
            res += (A[i] - 1) / mi;
            A[i] = 1;
        }
        mi = max(mi, A[i] + 1);
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
S = list(input())
s = sorted(list(set(S)))
l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
     'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

if s == l:
    ans = 'None'
else:
    for i in range(26):
        if (len(s) - 1) < i:
            ans = l[i]
            break
        elif s[i] != l[i]:
            ans = l[i]
            break

print(ans)

Measured memory_bytes: 3956