akhauriyash/Code-Regression huggingface dataset:
import os
import heapq
import sys
import math
import bisect
import operator
from collections import defaultdict
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]


# def bubbleSort(arr,b):
#     n = len(arr)
#     for i in range(n):
#         for j in range(0, n - i - 1):
#             if arr[j] > arr[j + 1] and b[j]!=b[j+1]:
#                 arr[j], arr[j + 1] = arr[j + 1], arr[j]
#                 b[j],b[j+1]=b[j+1],b[j]
def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    #for _ in range(int(input())):
    #n=int(input())
    a,b,c=map(int,input().split())
    k=int(input())
    counter=0
    while 1:
        if a<b<c or k==0:
            break
        if a>=b and k>0:
            b=b*2
            k-=1
            continue
        if b>=c and k>0:
            c=c*2
            k-=1
            continue
    if a<b<c:
        print("Yes")
    else:
        print("No")













BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


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

int main(){
	int n;
	cin >> n;
	int64_t t[n], a[n];
	for(int64_t &i:t) cin >> i;
	for(int64_t &i:a) cin >> i;
	pair<int64_t, int64_t> p[n], q[n];
	p[0] = {t[0], t[0]};
	for(int i = 1; i < n; i++){
		p[i] = {t[i - 1] < t[i] ? t[i] : 1, t[i]};
	}
	q[n - 1] = {a[n - 1], a[n - 1]};
	for(int i = n - 2; 0 <= i; i--){
		q[i] = {a[i + 1] < a[i] ? a[i] : 1, a[i]};
	}
	int64_t ans = 1;
	for(int i = 0; i < n; i++){
		ans *= max(int64_t(0), min(p[i].second, q[i].second) - max(p[i].first, q[i].first) + 1);
		ans %= int64_t(1e9 + 7);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  std::string S;
  std::cin >> S;

  size_t const N = S.length();

  std::vector<size_t> dp0(N+1);
  std::vector<size_t> dp1(N+1);
  std::vector<size_t> dp2(N+1);
  std::vector<size_t> dp3(N+1);

  dp0[N] = 0;
  dp1[N] = 0;
  dp2[N] = 0;
  dp3[N] = 1;

  for (ssize_t i=N-1; i>=0; i--) {
    if (S[i] == 'A') dp0[i] = dp0[i+1] + dp1[i+1];
    else if (S[i] == '?') dp0[i] = 3 * dp0[i+1] + dp1[i+1];
    else dp0[i] = dp0[i+1];

    if (S[i] == 'B') dp1[i] = dp1[i+1] + dp2[i+1];
    else if (S[i] == '?') dp1[i] = 3 * dp1[i+1] + dp2[i+1];
    else dp1[i] = dp1[i+1];

    if (S[i] == 'C') dp2[i] = dp2[i+1] + dp3[i+1];
    else if (S[i] == '?') dp2[i] = 3 * dp2[i+1] + dp3[i+1];
    else dp2[i] = dp2[i+1];

    if (S[i] == '?') dp3[i] = 3 * dp3[i+1];
    else dp3[i] = dp3[i+1];

    dp0[i] %= 1000000007;
    dp1[i] %= 1000000007;
    dp2[i] %= 1000000007;
    dp3[i] %= 1000000007;
  }

  std::cout << dp0[0] << std::endl;

  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = 0;
const int mod = 1000000007;

vector <int> lunlun;
set <int> vt;
set <int> bef;
int32_t main()
{
    int ct = 9;
    for (int i = 1; i<=9; i++)
    {
        bef.insert(i);
        lunlun.push_back(i);
    }
    while(ct<100000)
    {
        for (auto it:bef)
        {
            int u = it%10;
            if (u==0)
            {
                vt.insert(it*10+0);
                vt.insert(it*10+1);
            }
            else if (u == 9)
            {
                vt.insert(it*10+8);
                vt.insert(it*10+9);
            }
            else
            {
                vt.insert(it*10+u-1);
                vt.insert(it*10+u);
                vt.insert(it*10+u+1);
            }
        }
        bef = vt;
        for (auto it:vt)
        {
            lunlun.push_back(it);
            ct++;
        }
        vt.clear();
    }
    int n; cin >> n;
    cout << lunlun[n-1];
}

Measured memory_bytes: 14580
function Main(input) {
  // 入力値（文字列）をスペースで区切り、配列として格納し各要素の値を数値に変換
  const result = input
  .split(/\s/);
  var a = Number(result[0]);
  var b = Number(result[1]);
  var diff = b - a;
  var res =0;
  [...Array(diff).keys()].map(i => ++i).forEach((elm) =>{
    res = res + elm;
  });
  console.log(res- b);
  

};
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9652
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N; cin >> N;
  vector<int> H(N,0);
  REP(i,N) cin >> H[i];
  bool flg = true;
  H[0]--;
  REP2(i,1,N){
    if(H[i-1] - H[i] < 0) H[i]--; 
  }
  REP(i,N-1) if(H[i+1] - H[i] < 0) flg = false;
  if(flg) cout << "Yes";
  else cout << "No";

  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int dsnum,length[3],i;
	
	scanf("%d",&dsnum);
	
	while(dsnum>0)
	{
		scanf("%d%d%d",&length[0],&length[1],&length[2]);
		
		for(i=0;i<3;i++)
		{
			if(length[i]*length[i]+length[(i+1)%3]*length[(i+1)%3]==length[(i+2)%3]*length[(i+2)%3])
			{
				printf("YES\n");
				break;
			}
			if(i==2) printf("NO\n");
		}
		dsnum--;
	}
	return 0;
}

Measured memory_bytes: 1008
def h(temp):
    if temp[0] == "m":
        a = 0
    elif temp[0] == "r":
        if temp[2] == "m":
            a = 1
        else:
            a = 3
    else:
        a = 2
    return a 

def H(temp,y,a):
    c = 0
    if a == 0 or a == 2:
        for j in range(5):
            if y[a][4-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    elif a == 3:
        for j in range(6):
            if y[a][5-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    else:
        for j in range(7):
            if y[a][6-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    return c


s = input()
y = ['dream','dreamer','erase','eraser'] 
temp = []
t = []
k = len(s)
for i in range(k):
    temp.append(s[k-i-1])
c = 1
while len(temp) != 0 and c == 1:
    a = h(temp)
    c = H(temp,y,a)
if c == 1:
    print("YES")
else :
    print("NO")

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

using namespace std;

#define FaSt ios::sync_with_stdio(0),cin.tie(0);
#define random uniform_int_distribution<long long>(1, 2000000000000000LL)(rng)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * ((uint64_t) new char | 1));

const int N = 10004;
string s[N];
int n, ans, a, b, c;

int main() 
{
    FaSt
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int i = 0; i < s.size() - 1; i++)
        {
            if (s[i] == 'A' && s[i  + 1] == 'B')
            {
                ans ++;
            }
        }
        if (s[0] == 'B' && s[s.size() - 1] == 'A')
        {
            c++;
        }
        else if (s[0] == 'B')
        {
            b++;
        }
        else if (s[s.size() - 1] == 'A')
        {
            a++;
        }
    }
    
    int t = max(0, c - 1);
    ans += t;
    c -= t;
    
    if (c)
    {
        if (a > 0 && b > 0)
        {
            a--;
            b--;
            ans += 2;
        }
        else if (a > 0)
        {
            a--;
            ans++;
        }
        else if (b > 0)
        {
            b--;
            ans++;
        }
    }
    
    ans += min(a, b);
    
    cout << ans;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
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; }

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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    int N;
    cin>>N;
    set<P> s;
    rep(i,N){
        for(int j = i+1; j<N; j++){
            s.insert(make_pair(i,j));
        }
    }
    if(N%2==0){
        rep(i,N/2){
            s.erase(make_pair(i,N-i-1));
        }
    }
    if(N%2==1){
        rep(i,N/2){
            s.erase(make_pair(i,N-i-2));
        }
    }
    cout<<s.size()<<endl;
    auto ite = s.begin();
    rep(i,s.size()){
        cout<<(*ite).first+1<<" "<<(*ite).second+1<<endl;
        ite++;
    }
}

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

static const int N = 10000;
using namespace std;
int a[N];

int main() {
  int n;
  cin >> n;
  for (int i =0;i<n;i++){
      cin >> a[i];
  }
  int cnt=0;
  
  for (int i=0;i<n;i++){
      for (int j=n-1;j>=i+1;j--){
          if (a[j] < a[j-1]){
              swap(a[j],a[j-1]);
              cnt++;
          }
      }
   }
  
  for (int i=0;i<n;i++) {
    if(i == n - 1) {
            cout << a[i] << endl;
    } else {
            cout << a[i] << " ";
    }
    }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3128
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int t[N+1], x[N+1], y[N+1];
    t[0] = 0; x[0] = 0; y[0] = 0;
    for(int i = 1; i <= N; i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    bool F = true;
    int D, T;
    for(int i = 1; i <= N; i++){
        D = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
        T = t[i] - t[i-1];
        if(D == T){
            continue;;
        }else if(D > T){
            F = false;
            break;
        }else if((T-D)%2 == 1){
            F = false;
            break;
        }
    }

    if(F == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
typedef long long ll;

ll N;
int main(){
    cin >> N;
    ll ans = 0;
    for(ll i=1;i*i<=N;i++){
        if(N%i==0){
            if(i<N/i-1) ans += N/i-1;
            ll a = N/i;
            if(a<N/a-1) ans += N/a-1;        
        }
    }
    cout << ans << endl;
}

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

const int max_n = 8 + 1;
bool edge[max_n][max_n];
int n, m;

int dfs(int v, bool visited[max_n])
{
    bool visited_all = true;
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i])
        {
            visited_all = false;
        }
    }
    if (visited_all)
    {
        return 1;
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i] && edge[v][i])
        {
            visited[i] = true;
            cnt += dfs(i, visited);
            visited[i] = false;
        }
    }
    return cnt;
}

int main()
{
    scanf("%d %d", &n, &m);

    for (int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d %d", &a, &b);
        edge[a][b] = true;
        edge[b][a] = true;
    }

    bool visited[max_n];
    for (int i = 1; i <= n; i++)
    {
        visited[i] = false;
    }
    visited[1] = true;

    cout << dfs(1, visited) << endl;
}

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

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

P f(int x) {
	int a = x % 10;
	int b = 0;
	while (x) {
		b = x;
		x /= 10;
	}
	return P(a, b);
}

int main() {
	int n; cin >> n;
	map<P, int>freq;
	for (int i = 1; i <= n; i++) {
		P p = f(i);
		freq[p]++;
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		P p = f(i);
		P q(p.second, p.first);
		ans += freq[q];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int bits = 50;
		
		long[] mask = new long[bits];
		long curm = 1;
		for(int i = 0; i < bits; i++)
		{
			mask[i] = curm;
			curm *= 2;
		}
//		System.out.println(Long.toString(curm,2));
		
		long k = sc.nextLong();
		
		long[] bitocc = new long[bits];
		long[] kbit = new long[bits];
		
		for(int j = 0; j < bits; j++)
		{
			if((mask[j] & k) > 0)kbit[j]++;
		}
		
		long sum = 0;
		for(int i = 0; i < n; i++)
		{
			long cur = sc.nextLong();
			sum += cur;
			for(int j = 0; j < bits; j++)
			{
				if((mask[j] & cur) > 0)bitocc[j]++;
			}
		}
		
		if(k == 0)
		{
			System.out.println(sum);
			return;
		}		
		
		long idealnum = 0;
		boolean[] ideal = new boolean[bits];
		long[] idealr = new long[bits];
		for(int i = 0; i < bits; i++)
		{
			if(bitocc[i] < n/2 + n%2)
			{
				idealnum += mask[i];
				ideal[i] = true;
			}
			long mul = Math.max(bitocc[i], n-bitocc[i]);
			idealr[i] += mul * mask[i];
			if(i>0)idealr[i] += idealr[i-1];
		}
		
		boolean imp = true;
		
		int startbit = -1;
		long butimp = 0;
		long[] maxleft = new long[bits];
		for(int i = bits-1; i >= 0; i--)
		{
			long mul = 0;
			if(kbit[i] == 1)
				mul = n - bitocc[i];
			else mul = bitocc[i];
			maxleft[i] += mul * mask[i];
			if(i < bits-1)maxleft[i] += maxleft[i+1];
			
			if(startbit == -1 && kbit[i] == 1)
			{
				startbit = i;
			}
		}
		
//		System.out.println("Startbit " + startbit);
		long best = maxleft[0];
		for(int i = startbit; i >= 0; i--)
		{
			if(kbit[i] == 1)
			{
				long curb = 0;
				curb += bitocc[i] * mask[i];
				if(i>0)curb += idealr[i-1];
				if(i<bits-1)curb+=maxleft[i+1];
				best = Math.max(best, curb);
			}
		}
		
		System.out.println(best);
	}

}


Measured memory_bytes: 49760
#include <iostream>
using namespace std;
#define A

#ifdef A
int main(void)
{
	int a, b;
	cin >> a >> b;
	if (a == b)
		cout << "a == b" << endl;
	else if (a < b)
		cout << "a < b" << endl;
	else
		cout << "a > b" << endl;

	return 0;
}
#endif
#ifdef B
int main()
{
	int A;
	cin >> A;
	cout << A*A*A << endl;
	return 0;
}
#endif
#ifdef C
int main()
{
	int a, b;
	cin >> a >> b;
	cout << a *b << " " << 2 * (a + b) << endl;
	return 0;
}
#endif
#ifdef D
int main()
{
	int S;
	cin >> S;
	int h = S / 3600, m = S / 60 % 60, s = S % 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}
#endif

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vp;

#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF 1e9
#define modulo 1000000007
#define forn(i, n) for(int i = 0; i < (n); i++)
#define FAST ios::sync_with_stdio(false); cin.tie(NULL);
#define end1 "\n" 
#define print(x) cout << x << end1
#define debug(x) cout<< #x <<" :: "<< x <<end1;
#define debug2(x, y) cout<< #x <<" :: "<< x << "\t" << #y <<" :: "<< y <<end1;



int main(){ 
FAST;
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif

////////
int n, k; cin >> n >> k;
ll ans = 0;
for(int i = 0, p; i < k; i++){
    cin >> p; ans += p;
}
ll ans1;
if(ans <= n) ans1 = n-ans;
else ans1 = -1;
print(ans1);
return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a,b,x;
	cin >> a >> b >> x;
	double ans;
	if(2*x<=a*a*b){
		ans=atan((a*b*b/2/x))*180/3.1415926535;
		printf("%.8lf\n",ans);
	}
	else{
		ans=atan(2*(a*a*b-x)/a/a/a)*180/3.1415926535;
		printf("%.8lf\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
import sys

def check(x):
  if(x[0] == 0 and x[1] == 0 and x[2] == 0):
    return 1
  else:
    return 0

def main():
  a1 = list(map(int, input().split()))
  a2 = list(map(int, input().split()))
  a3 = list(map(int, input().split()))
  num = int(input())
  a9 = a1 + a2 + a3
  x = 0
  z = [int(input()) for i in range(num)]
  for i in z:
    for k, name in enumerate(a9):
      if(i == name):
        a9[k] = 0
  a1 = []
  a2 = []
  a3 = []
  a4 = []
  a5 = []
  a6 = []
  a7 = []
  a8 = []  
  a1.extend([a9[0],a9[1],a9[2]])
  a2.extend([a9[3],a9[4],a9[5]])
  a3.extend([a9[6],a9[7],a9[8]])
  a4.extend([a9[0],a9[3],a9[6]])
  a5.extend([a9[1],a9[4],a9[7]])
  a6.extend([a9[2],a9[5],a9[8]])
  a7.extend([a9[0],a9[4],a9[8]])
  a8.extend([a9[2],a9[4],a9[6]])

  check_list = []
  check_list.append(check(a1))
  check_list.append(check(a2))
  check_list.append(check(a3))
  check_list.append(check(a4))
  check_list.append(check(a5))
  check_list.append(check(a6))
  check_list.append(check(a7))
  check_list.append(check(a8))

  for i in check_list:
    if(i == 1):
      print('Yes')
      x = 1
      sys.exit()
   
  if(x == 0):
    print('No')

if __name__ == '__main__':
  main()


        

    




Measured memory_bytes: 3192
/*
	DATE:		2020-03-02 14:19:14
	NAME:		
	PROBLEM:	ABC157B
*/
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5;

int a[4][4];

int main() {
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      cin >> a[i][j];
    }
  }

  int n;
  cin >> n;

  while (n--) {
    int x;
    cin >> x;
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (a[i][j] == x) {
          a[i][j] = -1;
        }
      }
    }
  }

  for (int i = 1; i <= 3; i++) {
    bool fl = true;
    for (int j = 1; j <= 3; j++) {
      if (a[i][j] != -1) {
        fl = false;
      }
    }
    if (fl) {
      printf("Yes\n");
      return 0;
    }
  }

  for (int j = 1; j <= 3; j++) {
    bool fl = true;
    for (int i = 1; i <= 3; i++) {
      if (a[i][j] != -1) {
        fl = false;
      }
    }
    if (fl) {
      printf("Yes\n");
      return 0;
    }
  }

  if (a[1][1] == a[2][2] and a[2][2] == a[3][3] and a[3][3] == -1) {
    printf("Yes\n");
    return 0;
  }

  if (a[1][3] == a[2][2] and a[2][2] == a[3][1] and a[3][1] == -1) {
    printf("Yes\n");
    return 0;
  }

  printf("No\n");

  return 0;
}

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

int main()
{
	int h,w;
	cin >> h >> w;
	vector<string>s(h);
	for(int i = 0;i<h;i++)cin >> s[i];
	vector<int> cnt(26);
	for(int i = 0;i<h;i++)
	{
		for(int j = 0;j<w;j++)
		{
			cnt[s[i][j]-'a']++;
		}
	}
	if(h%2==0&&w%2==0)
	{
		for(int i = 0;i<26;i++)
		{
			if(cnt[i]%4!=0)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
		cout<<"Yes"<<endl;
		return 0;
	}
	else if(h*w%2==1)
	{
		int a =0 ,b = 0;
		for(int i = 0;i<26;i++)
		{
			if(cnt[i]%2==1)a++;
			if(cnt[i]%4!=0&&cnt[i]%2==0)b++;
		}
		if(a>1||(b*2>h+w-1))
		{
			cout<<"No"<<endl;
			return 0;
		}
		else
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	else
	{
		if(h%2==1)swap(h,w);
		int a=0,b=0;
		for(int i = 0;i<26;i++)
		{
			if(cnt[i]%2==1)a++;
			if(cnt[i]%4!=0&&cnt[i]%2==0)b++;
		}
		if(a>0||(b*2>h))
		{
			cout<<"No"<<endl;
			return 0;
		}
		cout<<"Yes"<<endl;
	}
	return 0; 
}


Measured memory_bytes: 256
N=int(input())
height=list(map(int,input().split()))
humidai_list=[0]
total_height=[height[0]]
del height[0]
#リストの要素を消す
for i in height:
    if total_height[-1] > i :
        humidai=total_height[-1]-i
        humidai_list.append(humidai)
        total_height.append(i+humidai)
    else:
        total_height.append(i)
print(sum(humidai_list))

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int ans = 0;
    int idx = 1;
    int ok = false;
    for (size_t i = 0; i < n; i++) {
        if (a[i] == idx) {
            idx++;
            ok = true;
            continue;
        } else {
            ans++;
        }
    }

    if (ok)
        cout << ans << endl;
    else
        cout << -1 << endl;
}


Measured memory_bytes: 1024
N = int( input() )
A = input()
B = input()
C = input()


ans = 0
for i in range(N):
    if A[i] == B[i] and B[i] != C[i]: ans += 1
    if A[i] != B[i] and B[i] == C[i]: ans += 1
    if A[i] != B[i] and A[i] == C[i]: ans += 1
    if A[i] != B[i] and B[i] != C[i] and C[i] != A[i]: ans += 2

print( ans )

Measured memory_bytes: 3064
import sys
input=sys.stdin.readline

n,m=map(int,input().split())
a=[list(input().split()) for i in range(m)]
a=sorted(a, key=lambda x: x[0])
ac=0
wa=0
if m==0:
    print(0,0)
    exit()
now=a[0][0]
my_bool=True
wa_pre=0
for i in range(m):
    if now!=a[i][0]:
        now=a[i][0]
        my_bool=True
        wa_pre=0
    if not my_bool:
        continue
    if a[i][1]=="AC":
        ac+=1
        wa+=wa_pre
        my_bool=False
    else:
        wa_pre+=1
print(ac,wa)

Measured memory_bytes: 28292
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#define rep(i, n) for (int i=0; i<n; ++i)
using namespace std;
typedef long long ll;

int main()
{
    float r;
    cin >> r;
    r = r*r;
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;
using ll = long long;

string makeans(int i,string Sd,string T); 
int main() {
	string Sd,T;
	cin >> Sd >> T;

	string ans = "UNRESTORABLE";

	if(Sd.find(T) != string::npos) {
		cout << makeans(Sd.find(T),Sd,T) << endl;
		return 0;
	}

	for (int i = Sd.length() - T.length(); i >= 0; i--) {
		int countSpace = 0;
		for (int j = 0; j < T.length(); j++) {
			if (Sd[j + i] == '?' || Sd[j + i] == T[j]) {
				countSpace++;
				if (countSpace == T.length()) {
					cout << makeans(i,Sd,T) << endl;
					return 0;
				}
				continue;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

string makeans(int i,string Sd,string T) {
	for (int k = 0; k < T.length(); k++) {
		Sd[k + i] = T[k];
	}

	for (int k = 0; k < Sd.length(); k++) {
		if (Sd[k] == '?') {
			Sd[k] = 'a';
		}
	}

	return Sd;
}


Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

#define repeat(i,n) for(int i=0;i<n;i++)
int *s;		//学生の点数を格納する配列
void solve(int n){
	double m = 0;
	double bunsan=0;
	s = new int[n];

	//点数入力
	repeat(i,n)
	{
		cin >> s[i];
	}

	//平均を求める
	repeat(i, n)
	{
		m += s[i];
	}
	m = m / n;
		//cout << m << endl;

	//分散を求める
	repeat(i, n)
	{
		bunsan += (s[i] - m)*(s[i] - m);
	}
	bunsan = bunsan / n;

	//出力
	cout << fixed << setprecision(5) << sqrt(bunsan) << endl;
	
	delete[] s;
	return ;
}

int main()
{
	int n;
	while (1)
	{
		cin >> n;
		if (n == 0) break;
		solve(n);
	}
	return 0;
}

Measured memory_bytes: 1264
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from functools import lru_cache
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s

#main
N,w=map(int,input().split())
W=[0]*N
V=[0]*N
for a in range(N):
    W[a],V[a]=map(int,input().split())
dp=[[0 for _ in range(w+1)] for _ in range(N+1)]

for a in range(1,N+1):
    for b in range(1,w+1):
        if(b-W[a-1]>=0):dp[a][b]=max(dp[a-1][b],dp[a-1][b-W[a-1]]+V[a-1])
        else: dp[a][b]=dp[a-1][b]
print(dp[N][w])



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

using namespace std;

typedef long long ll;

const int N = 1e8;
const int INF = 1e9;
const int MOD = 998244353;



int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int l, r, d, u;
    l = d = 0;
    r = w, u = h;
    for (int i = 0; i < n; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        if (c == 1)
            l = max(x, l);
        if (c == 2)
            r = min(x, r);
        if (c == 3)
            d = max(y, d);
        if (c == 4)
            u = min(y, u);
    }
    if (r > l && u > d)
        cout << (r - l) * (u - d);
    else
        cout << 0;
}

Measured memory_bytes: 256
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(n); readl(k);
  vector<ll> a(n);
  rep(i, n){
    cin >> a[i];
  }
  ll x = 0;

  
  ll mask = 1;
  while((mask << 1) <= k){
    mask <<= 1;
  }

  if(k == 0){
    mask = 0;
  }
  
  for(; mask != 0;){
    ll r1 = 0;
    ll r0 = 0;
    rep(i, n){
      if(a[i] & mask){
        r0++;
      }else{
        r1++;
      }
    }
    // dump(mask);
    // dump(r1);
    // dump(r0);
    if((x | mask) > k){
      r1 = 0;
      r0 = 1;
    }
    if(r1 >= r0){
      x |= mask;
    }
    mask = mask >>= 1;
  }
  
  // dump(x);
  ll res = 0;
  rep(i, n){
    res += a[i] ^ x;
  }
  cout << res;
}
#endif


Measured memory_bytes: 1024
{-# LANGUAGE Strict #-}
import qualified Data.ByteString.Char8 as B
import           Data.Char             (digitToInt)
import qualified Data.Vector.Unboxed   as V


main :: IO ()
main = do
  s <- B.getLine
  print $ solve s

solve :: B.ByteString -> Int
solve s = V.sum $ V.map (\h -> h * (h - 1) `div` 2) hs
  where m = 2019
        hs = hist m $ subModNum s m

subModNum :: B.ByteString -> Int -> V.Vector Int
subModNum s m = V.map fst $ V.scanr' (\a (y, f) -> ((y + a * f) `mod` m, 10 * f `mod` m)) (0, 1) as
  where cs = V.unfoldr B.uncons s
        as = V.map digitToInt cs

hist :: Int -> V.Vector Int -> V.Vector Int
hist n xs = V.accumulate_ (+) (V.replicate n 0) xs (V.replicate m 1)
  where m = V.length xs


Measured memory_bytes: 9616
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    cout << fixed << setprecision(10);
    double a;
    double s[50] ;
    int n = 0;
    while(cin >> a ){
    
        s[n] = a;
        for(int i = 1;i < 10;i++){
           
            if(i % 2 == 0){
                a = a/3;
            }
            else{
                a = a*2;
            }
            s[n] += a;
        }
        
        n++;
    }
    for(int i = 0;i < n;i++){
        cout << s[i] <<endl; 
    }
    
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
    A.at(i)--;
  }
  
  vector<bool> passed(N, false);
  int now = 0, ans = 0;
  while (passed.at(now) == false){
    passed.at(now) = true;
    now = A.at(now);
    ans++;
    if (now == 1){
      cout << ans << endl;
      exit(0);
    }
  }
  
  cout << "-1" << endl;
}

Measured memory_bytes: 3996
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

int R, C, sum[105][105], sr, sc;
int dp[2][105][105][105];

int rangeSum(int t, int l, int b, int r){
    return sum[b][r] - sum[t-1][r] - sum[b][l-1] + sum[t-1][l-1];
}

int main(){

    ios :: sync_with_stdio(false);
    cin >> R >> C;
    FOR(i,R){
        FOR(j,C){
            char ch;
            cin >> ch;
            if(ch == 'E') sr=i, sc=j;
            sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + (ch == 'o');
        }
    }

    bool cur = 0;
    int ans = 0;
    REP(u, sr){
        REP(d, R-sr+1){
            REP(l, sc){
                REP(r, C-sc+1){
                    int res = dp[cur][d][l][r];

                    int top = max(d+1, sr-u);
                    int bot = min(sr+d, R-u);
                    int lft = max(r+1, sc-l);
                    int rgt = min(sc+r, C-l);

                    if(u>0 && sr-u-d>0)  res = max(res, dp[cur^1][d][l][r] + rangeSum(sr-u, lft, sr-u, rgt));
                    if(d>0 && sr+d+u<=R) res = max(res, dp[cur][d-1][l][r] + rangeSum(sr+d, lft, sr+d, rgt));
                    if(l>0 && sc-l-r>0)  res = max(res, dp[cur][d][l-1][r] + rangeSum(top, sc-l, bot, sc-l));
                    if(r>0 && sc+l+r<=C) res = max(res, dp[cur][d][l][r-1] + rangeSum(top, sc+r, bot, sc+r));

                    dp[cur][d][l][r] = res;
                    ans = max(ans, res);
                }
            }
        }
        cur ^= 1;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8960
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()

count = 0
d = defaultdict(int)
for i in range(1,10):
    for j in range(1,10):
        count = 0
        for k in range(1,N+1):
            if str(k)[0]==str(j) and str(k)[-1]==str(i):
                count += 1
        d[(i,j)] = count
#print(d)

ans = 0
for i in range(1,N+1):
    ans += d[(int(str(i)[0]),int(str(i)[-1]))]
    #print(i,d[(int(str(i)[0]),int(str(i)[-1]))])
print(ans)

Measured memory_bytes: 44152
#include <iostream>
#define N 3
void BSort(int* a);
void xswap(int*a, int x, int y);


int main(){
    int a[3];
    for(int i=0; i<N; ++i) std::cin>> a[i];
    BSort(a);
    for(int i=0; i<N-1; ++i) std::cout << a[i] <<" ";
    std::cout << a[N-1] <<"\n";
}
void xswap(int*a, int x, int y){
    int temp = a[x];
    a[x] = a[y];
    a[y] = temp;
}
void BSort(int* a){
    for(int i=0; i<N; ++i){
        for(int j=1; j<N-i; ++j){
            if(a[j]<a[j-1]) xswap(a, j, j-1);
        }
    }
}

Measured memory_bytes: 3108
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 10 ** 9 + 7

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def main():
    N = int(readline())
    factors = []
    for i in range(1, N+1):
        factors += factorize(i)
    c = Counter(factors)
    ans = 1
    for key, val in c.items():
        if key == 1:
            continue
        ans *= (val + 1)
        ans %= MOD
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import java.util.*;

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

        int resultX = -1,resultY = -1,resultZ = -1;
        boolean flag = false;
        int n = sc.nextInt();
        int total = sc.nextInt();
        
        for (int x = 0; x <= n; x++){
            for (int y = 0; y + x <= n; y++){
                int z = n - x - y;
                if (total == 10000*x + 5000*y + 1000*z) {
                    resultX = x;
                    resultY = y;
                    resultZ = z;
                    flag = true;
                    break;
                }
            }
            
            if (flag) break;
        }
        
        System.out.printf("%d %d %d", resultX, resultY, resultZ);
        sc.close();
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define sz(s) (int)(s.size())
int main(){
  string s;
  cin >> s;
  bool b = true;
  for(int i = 0;i<sz(s);i+=2){
    if(s[i] != 'h' || i + 1 >= sz(s) || s[i + 1] != 'i')
      b = false;
  }
  cout << (b?"Yes":"No");
}

Measured memory_bytes: 256
N, K = [int(x) for x in input().split()]
edges = []
cnt = sum(range(1, N-1))
for i in range(2, N+1):
    edges.append((1,i))
if (K > cnt):
    print(-1)
elif (K == cnt):
    print(len(edges))
    for edge in edges:
        print(edge[0], edge[1])
else:
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            edges.append((i,j))
            cnt -= 1
            if (K == cnt):
                print(len(edges))
                for edge in edges:
                    print(edge[0], edge[1])
                exit()


Measured memory_bytes: 43120
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

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

int main()
{
    long long int n;
    cin>>n;
    long long int c=0,x;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x%2==1 && i%2==1)
        c++;
    }
    cout<<c<<"\n";
    

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int P, Q, R;
double getx(double t){
  return (double)(P - Q) * cos(t) + (double)R * cos(t * (P - Q) / Q);
}
double dx(double t){
  return (double)(P - Q) * (-sin(t)) + (double)R * (P - Q) / Q * (-sin(t * (P - Q) / Q));
}
double gety(double t){
  return (double)(P - Q) * sin(t) - (double)R * sin(t * (P - Q) / Q);
}
double dy(double t){
  return (double)(P - Q) * (cos(t)) - (double)R * (P - Q) / Q * (cos(t * (P - Q) / Q));
}
double dist(double x1, double y1, double x2, double y2){
  return sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
}

int main(){
  while(cin>>P>>Q>>R && P){
    int time = -1;
    for(int k = 1; ; k++){
      if(R == 0){
        time = 1;
        break;
      }
      if(k * (P - Q) % Q == 0){
        time = k;
        break;
      }
    }
    const int ITER = 100000;
    const double delta = 2.0 * time * M_PI / ITER;
    double ans = 0;
    REP(iter, ITER){
      double t = delta * iter;
      ans += sqrt(dx(t) * dx(t) + dy(t) * dy(t)) * delta;
    }
    printf("%.2f\n", ans + EPS);
  }
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}



Measured memory_bytes: 256
use proconio::input;
use std::vec::Vec;

fn main() {
    input! {
        n: i32,
        a: [u64; n],
    }
    if a.contains(&0) {
        println!("{}", 0);
        return;
    }
    let mut ans: u64 = 1;
    let th: u64 = 1000000000000000000;
    for v in a.iter() {
        if ans > th / v {
            println!("-1");
            return;
        }
        ans = ans * v;
    }
    println!("{}", ans);
}


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

int main(){
  
  string N,a,b,c,d;
  
  cin >> N;
  
  a = N[0];
  b = N[1];
  c = N[2];
  d = N[3];
    
  if(a == b && b == c){
    cout << "Yes" << endl;
  }
  else if(b == c && c == d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main()
{
    int n, count = 0;
    float m, sum = 0;
    vector<int> a(300);

    cin >> n >> m;
    rep(i, n){
        cin >> a.at(i);
        sum += a.at(i);
    }
    rep(i, n){
        if (a.at(i) >= sum / (4 * m))
            count++;
    }
    if (count >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
vector<pair<ll,int>> prime_factors;

bool IsPrime (long n) {
  if (n < 2) return false;
  else if (n == 2) return true;
  else if (n % 2 == 0) return false;
  double sqrtNum = sqrt(n);
  for (long i = 3; i <= sqrtNum; i += 2) if (n % i == 0) return false;
  return true;
}

void PrimeFactors (ll n) {
  if (n < 2) return;
  ll p = 2;
  for (ll i = 2; i*i <= n; ++i) {
    int x = 0;
    while (n % i == 0) n /= i, ++x;
    if (x != 0) prime_factors.emplace_back(i,x);
  }
  if (n != 1) prime_factors.emplace_back(n,1);
  return;
}

int main () {
  ll A;
  cin >> A;
  PrimeFactors(A);
  int ans = 0;
  for (auto p: prime_factors) {
    int x =  p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      ++b;
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
  std::string s;
  std::cin >> s;
  int64_t ans = s.size();

  for (int64_t i = 1; i < s.size(); i++) {
    if (s[i - 1] != s[i]) {
      ans = std::min(ans, std::max<int64_t>(i, s.size() - i));
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
    ll n,x;
    cin >> n >> x;
    ll a[n];
    for (ll i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    int ans=0;
    ll i=0;
    while (x>=a[i]&&i<n){
        x-=a[i];
        ans++;
        i++;
    }
    
    
    if (x==0){
        cout << ans << endl;
    }else {
        if (i==n){
            cout << ans-1 << endl;
        }else {
            cout << ans <<endl;
        }
    }
}   

Measured memory_bytes: 764
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;

const int inf = 1e9 + 7;
#define EPS 1e-9

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> l(n+1,0), r(n+1,0);
	
	rep(i, n) {
		l[i + 1] = gcd(l[i], a[i]);
	}

	for (int i = n - 1; i >= 0; --i) {
		r[i] = gcd(r[i + 1], a[i]);
	}
	int ans = 0;
	rep(i,n) {
		ans = max(ans, gcd(l[i], r[i+1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>

using namespace std;

int main()
{
    int x;
    cin>>x;
    if(x==7 || x==5 || x==3)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int sum[200010][2];

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

	int N;
	string S;

	cin >> N >> S;
	rep(i, 0, N)
	{
		sum[i][S[i] == '#' ? 0 : 1]++;
		if (0 < i)
		{
			rep(j, 0, 2)
			{
				sum[i][j] += sum[i - 1][j];
			}
		}
	}

	int ans = INF;
	rep(i, 0, N + 1)
	{
		if (i == 0)
		{
			chmin(ans, sum[N - 1][1]);
		}
		else if (i == N)
		{
			chmin(ans, sum[N - 1][0]);
		}
		else
		{
			chmin(ans, sum[N - 1][1] - sum[i - 1][1] + sum[i - 1][0]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3732
(defun typical-stairs (n stair-table)
  (let ((a (make-array (+ n 2) :initial-element 0))
        (PRIME-NUMBER 1000000007))
    (setf (aref a 0) 1)
    (loop :for i :below n
          :do (if (cadr (multiple-value-list (gethash i stair-table)))
                  (setf (aref a i) 0)
                  (progn (setf (aref a (+ i 1))
                               (mod (+ (aref a (+ i 1)) (aref a i))
                                    PRIME-NUMBER))
                         (setf (aref a (+ i 2))
                               (mod (+ (aref a (+ i 2)) (aref a i))
                                    PRIME-NUMBER)))))
    (aref a n)))

(defun create-data ()
  (let* ((n (read))
         (m (read))
         (stair-table (make-hash-table)))
    (dotimes (i m)
      (setf (gethash (read) stair-table) T))
    (values n stair-table)))

(multiple-value-bind (n stair-table) (create-data)
  (format t "~A~%" (typical-stairs n stair-table)))



Measured memory_bytes: 77352