akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

struct edge{
	ll to;
	ll cost;
};

vector<edge>g[110];

vector<P>used;



int main(void){
	ll n,m,k;
	cin>>n>>m>>k;
	vector<ll>a(n),b(m);
	vector<ll>sum1(n+1),sum2(m+1);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<m;i++)cin>>b[i];
	for(int i=0;i<n;i++)sum1[i+1]=sum1[i]+a[i];
	for(int i=0;i<m;i++)sum2[i+1]=sum2[i]+b[i];
	ll ans = 0;
	for(int i=1;i<=n;i++){
		if(sum1[i]>k)break;
		ll tmp = i;
		ll rest = k -sum1[i];
		auto itr = upper_bound(sum2.begin(),sum2.end(),rest);
		if(itr==sum2.end())ans = max(ans,tmp);
		else{
			ll index = itr-(sum2.begin());
			if(index>0){
				index--;
				ans = max(ans,tmp+index);
			}
		}
	}
	for(int i=1;i<=m;i++){
		if(sum2[i]>k)break;
		ll tmp = i;
		ll rest = k -sum2[i];
		auto itr = upper_bound(sum1.begin(),sum1.end(),rest);
		if(itr==sum2.end())ans = max(ans,tmp);
		else{
			ll index = itr-(sum1.begin());
			if(index>0){
				index--;
				ans = max(ans,tmp+index);
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    string s;cin>>s;
    int aind=s.size(),zind=0;
    rep(i,s.size()){
        if(s[i]=='A')aind=min(aind,i);
        if(s[i]=='Z')zind=max(zind,i);
    }
    co(zind-aind+1);
}

Measured memory_bytes: 640
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
n = int(input())
#n, k = map(int, sys.stdin.readline().split())
#s = input()
l = list(map(int, sys.stdin.readline().split()))


ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] >= l[j] + l[k]:
                continue
            if l[j] >= l[i] + l[k]:
                continue
            if l[k] >= l[j] + l[i]:
                continue

            if l[i] == l[j]:
                continue
            if l[k] == l[j]:
                continue
            if l[i] == l[k]:
                continue
            

            ans += 1
            #print(l[i], l[j], l[k])

print(ans)


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int len = s.size();
    int cnt = 1;
    for (int i = 1; i < len; i++)
    {
        if (s[i] == s[i - 1])
            continue;
        cnt++;
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3728
from sys import stdin


def get_result(data):
    N, A, B = data
    if A == 0:
        return 0

    remainder = N % (A+B)
    tmp = remainder if remainder < A else A
    quotient = N // (A+B)
    ans = A * quotient + tmp
    return ans


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    result = get_result(data)
    print(result)


Measured memory_bytes: 3060
import sys
bbn=1000000007
	
#+++++

def get_m(says, state, person):
	if person == len(state):
		return sum(state)
	
	if state[person] == 0:
		return get_m(says,state,person+1)
		
	if state[person]==1:
		sss=state[:]
		for x,y in says[person]:
			if sss[x] == -1:
				sss[x]=y
			elif sss[x] != y:
				#mujun
				return 0
			else:
				continue
			
		return get_m(says,sss,person+1)
		
	
	sa=state[:]
	sa[person]=0
	a = get_m(says, sa, person+1)
	
	sb=state[:]
	sb[person]=1
	for x,y in says[person]:
		if sb[x] == -1:
			sb[x]=y
			
		elif sb[x] != y:
			#mujun
			return a
		else:
			continue
		
	b=get_m(says,sb,person+1)
	
	return max(a, b)
		
def main():
	n = int(input())
	says = [[] for _ in range(n)]
	for i in range(n):
		aij=int(input())
		for j in range(aij):
			x,y=map(int, input().split())
			says[i].append([x-1,y])
			
	a=[-1]*n
	
	ret=get_m(says, a,-1)
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

using namespace std;

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

int L = 55560;
bool a[55560];

int main() {
    memset(a, true, L);
    REP(i, 2, sqrt(L)) {
        if(a[i]) {
            for(int j=0; i*(j+2)<L; j++) {
                a[i*(j+2)] = false; 
            }
        }
    }
    
    int N; cin >> N;
    int ans = 0;
    for(int i=0, j=2; i<N; j++) {
        if(j%5 == 1 && a[j]) {cout << j << " "; i++;}
    }
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec V(N+1);
    REP(i,1,N+1) cin >> V[i];

    vector<pll> od(100001, {0, 0}), ev(100001, {0, 0});
    ll x = V[1];
    bool f = false;
    REP(i,1,N/2+1) {
        ++od[V[i*2-1]].first;
        ++ev[V[i*2]].first;
        od[V[i*2-1]].second = V[i*2-1];
        ev[V[i*2]].second = V[i*2]; 
        if(x != V[i]) f = true;
    }

    if(f) {
        DESC(od);
        DESC(ev); 
        ll mo = od[0].first, me = ev[0].first;
        if(od[0] == ev[0]) {
            if(od[1].first < ev[1].first) me = ev[1].first;
            else mo = od[1].first;
        } 
        PR(N-mo-me);
    }
    else PR(N/2);

    return 0;
}

/*



*/

Measured memory_bytes: 7164
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    int cnt[100010] = {};
    rep(i, N) {
        int a;
        cin >> a;
        if (a > 100000) ans++;
        else cnt[a]++;
    }
    rep(i, 100001) {
        if (cnt[i] < i) ans += cnt[i];
        else ans += cnt[i] - i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
<?php
fscanf(STDIN, "%s %s %s", $people, $start, $question);
for ($i=0; $i < $question; $i++)
{
	fscanf(STDIN, "%s", $answerer[$i]);
}

for ($i=0; $i < $people; $i++)
{ 
	$points[$i] = $start - $question;
}

for ($i=0; $i < $question; $i++)
{ 
	$points[$answerer[$i]-1] += 1;
}

for ($i=0; $i < $people; $i++)
{
	if($points[$i] > 0)
	{
		echo("Yes"."\n");
	}
	else
	{
		echo("No"."\n");
	}
}

Measured memory_bytes: 36084
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var a = int.Parse(Console.ReadLine());
        var sum = a + Math.Pow(a, 2) + Math.Pow(a, 3);
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 27776
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
ll calc_v(string s){
  ll dot_idx = s.size();
  ll n=s.size();
  ll res=0,keta;
  for(int i=0;i<n;i++){
    if(s[i]=='.'){
      dot_idx = i;
    }
  }
  keta = 1e9;
  for(int i=dot_idx-1;i>=0;i--){
    res += keta*(s[i]-'0');
    keta *= 10;
  }
  keta = 1e8;
  for(int i=dot_idx+1;i<n;i++){
    res += keta*(s[i]-'0');
    keta /= 10;
  }
  return res;
}
signed main(){
  init_io();
  ll n,ans=0;
  const ll MAX = 19;
  cin >> n;
  vector<string> s(n);
  vector<vector<ll>> pv(MAX,vector<ll>(MAX,0));
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  for(int i=0;i<n;i++){
    ll val = calc_v(s[i]);
    ll tc=0,fc=0;
    while(val%2==0){
      val /= 2;
      tc++;
    }
    while(val%5==0){
      val /= 5;
      fc++;
    }
    for(int j=0;j<MAX;j++){
      for(int k=0;k<MAX;k++){
        if(tc+j>=18&&fc+k>=18){
          ans += pv[j][k];
        }
      }
    }
    tc = min(tc,MAX-1);
    fc = min(fc,MAX-1);
    pv[tc][fc]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 9512
#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) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N;
int K;
int a[64][64];
int bx[64];
int by[64];
bool used[64][64];
bool dfs(int k, int sum, int sx, int sy){
  //printf("dfs : k = %d sum = %d sx = %d sy = %d\n", k, sum, sx, sy);
  if(k == K){
    bool ok = true;
    REP(y, N)REP(x, N) if(!used[y][x] && a[y][x] > 0) ok = false;
    return ok;
  }
  REP(r, 4){
    int nx = sx + dx[r];
    int ny = sy + dy[r];
    if(valid(nx, ny, N, N) && !used[ny][nx] && a[ny][nx] > 0){
      used[ny][nx] = true;
      if(sum - a[ny][nx] < 0){
      }else if(sum - a[ny][nx] == 0){
        if(k + 1 == K) {
          if(dfs(k + 1, 0, 0, 0)) return true;
        }else{
          if(dfs(k + 1, -a[by[k + 1]][bx[k + 1]], bx[k + 1], by[k + 1])) return true;
        }
      }else if(sum - a[ny][nx] > 0){
        if(dfs(k, sum - a[ny][nx], nx, ny)) return true;
      }
      used[ny][nx] = false;
    }
  }
  return false;
}
int main(){
  while(cin>>N && N){
    REP(i, N)REP(j, N) cin>>a[i][j];
    K = 0;
    REP(i, N)REP(j, N)if(a[i][j] < 0){
      by[K] = i;
      bx[K] = j;
      K++;
    }
    memset(used, 0, sizeof(used));
    bool ans = dfs(0, -a[by[0]][bx[0]], bx[0], by[0]);
    if(ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

int main()
{
    int k;
    cin >> k;
    set<int> s;
    bool flag = true;
    int c = 1;
    int a = 7;
    a %= k;
    s.insert(a);
    while (flag)
    {
        if (a == 0)
        {
            cout << c << endl;
            break;
        }
        else
        {
            a = a * 10 + 7;
            a %= k;
            c++;
            if (s.find(a) != s.end())
            {
                cout << -1 << endl;
                break;
            }
            else
            {
                s.insert(a);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 50456
#include <bits/stdc++.h>
#define int long long
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int n, k;
int arr[100001], dp[100001];
signed main(){
    cin >> n >> k;
    for(int i=0; n>i; i++){
        cin >> arr[i];
    }
    dp[0] = 0;
    for(int i=1; n>i; i++){
        int temp = INT_MAX;
        for(int j=1; k>=j; j++){
            if(i-j >= 0)
                temp = min(temp, dp[i-j] + abs(arr[i] - arr[i-j]));
            else
                break;
        }
        dp[i] = temp;
    }
    cout << dp[n-1] << endl;
}










Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;

int a, b;
int main() {
	cin >> a >> b;
	int cnt = 0;
	for (int i = 0; i <= b-a; i++) {
		string str = to_string(a + i);
		if (str[0] == str[4] && str[1] == str[3]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n,x;
    cin >> n >> x;
    vector<int> m(n,0);
    int ans = 0;
    rep(i,n){
        cin >> m.at(i);
        x -= m.at(i);
        ans ++;
    }
    ans += x/ *min_element(m.begin(),m.end());
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#AtCoder
N = int(input())
a = list(map(int, input().split()))

color = set()
mx = 0

for i in a:
    if 1 <= i <= 399:
        color.add('a')
    elif 400 <= i <= 799:
        color.add('b')
    elif 800 <= i <= 1199:
        color.add('c')
    elif 1200 <= i <= 1599:
        color.add('d')
    elif 1600 <= i <= 1999:
        color.add('e')
    elif 2000 <= i <= 2399:
        color.add('f')
    elif 2400 <= i <= 2799:
        color.add('g')
    elif 2800 <= i <= 3199:
        color.add('h')
    elif 3200 <= i:
        mx += 1

if len(color) == 0 and mx == 1:
    print(1, 1)
    exit()
if len(color) == 0 and mx >= 1:
    print(1, mx)
    exit()
if len(color):
    cn = len(color)

cx = cn + mx

print(cn, cx)

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

typedef long long int llint;

int n, m;
int i, j;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<int> edge[51];
bool done[51];

int solve(int now, int enode, int banto, int from);

int main()
{
  cin>> n >> m;

  for(i = 0; i < m; i++) {
    int a, b;
    cin>> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  int cnt = 0;
  for(i = 1; i <= n; i++) {
    for(j = 0; j < edge[i].size(); j++) {
      fill(done, done + n + 1, false);
      cnt += solve(i, edge[i][j], i, 0);
    }
  }

  cout<< m  - cnt / 2 <<endl;
  
  return 0;
}

int solve(int now, int enode, int banto, int from)
{
  if(now == enode) return 1;
  if(done[now]) return 0;
  done[now] = true;

  int rec = 0;
  
  for(int i = 0; i < edge[now].size(); i++) {
    if(now == banto && edge[now][i] == enode || from == edge[now][i]) continue;
    rec += solve(edge[now][i], enode, banto, now);

    if(rec) break;
  }

  return rec;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    map<int, int> mp;
    rep(i, n)mp[a[i]]++;
    vector<P> b;
    for(auto p : mp){
        b.push_back(p);
    }
    for(int i = b.size()-1; i > 0; i--){
        b[i-1].second += b[i].second;
    }

    vector<ll> ans(n, 0);
    ll pre = 0;
    int idx = 0;
    rep(i, n){
        if(idx < b.size()){
            while(b[idx].first <= a[i]){
                ll d = b[idx].first - pre;
                ans[i] += d * b[idx].second;
                pre = b[idx].first;
                idx++;
                if(idx == b.size())break;
            }
        }
    }
    
    rep(i, n)cout << ans[i] << endl;
}

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

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var w = new List<int>();
            var r = new List<int>();
            w.Add(0);
            r.Add(0);
            foreach (var v in S)
            {
                if (v == 'W')
                {
                    w.Add(w.Last() + 1);
                    r.Add(r.Last());
                }
                else
                {
                    w.Add(w.Last());
                    r.Add(r.Last() + 1);
                }
            }

            var ans = int.MaxValue;
            for (int i = 0; i <= N; i++)
            {
                var leftWhite = w[i] - w[0];
                var rightRed = r[N] - r[i];

                var max = Math.Max(leftWhite, rightRed);

                ans = max < ans ? max : ans;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 32000
#include <bits/stdc++.h>
typedef int integer;
#define int long long

using namespace std;

int m, n, t, k;

integer main() {
    ios_base::sync_with_stdio(false);
    int r, c;
    cin >> r >> c;
    if (r == 1){
        cout << 1 << endl;
        return 0;
    } else if (c == 1){
        cout << 1 << endl;
        return 0;
    }

    int x = r / 2;
    int tmp = ceil(c / 2.0) + c / 2;
    int ans = tmp * x;
    if (r % 2)
        ans += ceil(c/2.0);
    cout << ans << endl;
    
}



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

using namespace std;
typedef long long ll;

int main(void) {
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;

  ll a = min(s, 2 * min(h, 2 * q));
  if (n == 1) {
    cout << a << endl;
  } else {
    cout << n / 2 * min(d, 2 * a) + (n % 2) * a << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        Arrays.sort(h);
        int min = h[k-1] - h[0];
        for(int i = k; i < n; i++) {
            min = Math.min(min, h[i] - h[i-k+1]);
        }
        System.out.println(min);
    }
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int n;
  cin>>n;
  vector<double> v;
  REP(i,n){
    double d;
    cin>>d;
    v.push_back(d);
  }
  REP(i,n-1){
    sort(ALL(v));
    double tmp;
    tmp=(v[0]+v[1])/2.0;
    v.erase(v.begin());
    v[0]=tmp;
  }
  cout<<fixed<<setprecision(6)<<v[0]<<endl;
}


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

#define ran 11

int n;
int x[ran], y[ran];
double d[ran][ran];
double ans;

bool v[ran];

int sqr(int x) { return x*x; }
double get_dist(int id1, int id2) {
	return sqrt(sqr(x[id1]-x[id2]) + sqr(y[id1]-y[id2]));
}

void dfs(int dep, int cur, double dist) {
	if(dep>=n) {
		ans += dist;
		return;
	}
	for(int i=0;i<n;i++) {
		if(v[i]) continue;
		v[i] = true;
		dfs(dep+1, i, dist + d[cur][i]);
		v[i] = false;
	}
}

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++)
		scanf("%d%d", &x[i], &y[i]);
	memset(d, 0, sizeof d);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			d[i][j] = get_dist(i, j);

	ans = 0.;
	memset(v, false, sizeof v);
	dfs(0, n, 0);
	for(int i=n;i>1;i--)
		ans /= i;
	printf("%.10lf\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 500010


int main(){
  int n,k,sum;
  string s,t;

  int left[SIZE] = {}, right[SIZE] = {};
  
  cin >> n >> k >> s >> t;

  for(int i=0;i<n;i++){
    if(i == 0 || t[i-1] != t[i]) left[i]++;
    if(i == n-1 || t[i] != t[i+1]) right[i]++;
  }

  for(int i=0;i<n;i++) right[i+1] += right[i];
  for(int i=n;i>0;i--) left[i-1] += left[i];
  sum = left[0];
  
  priority_queue<pair<int,int> > pq0, pq1;
  int sameDP = 0;
  pq0.push({-INF, INF});
  pq1.push({-INF, INF});
  pq0.push({0, -1});
  
  for(int i=0;i<n;i++){
    while(pq0.size() && pq0.top().second < i - k){
      pq0.pop();
    }
    while(pq1.size() && pq1.top().second < i - k){
      pq1.pop();
    }
    
    if(t[i] != s[i]) sameDP = INF;
    
    int p0 = -1 * pq0.top().first;
    int p1 = -1 * pq1.top().first;
    int l0 = pq0.top().second;
    int l1 = pq1.top().second;
    int calc0, calc1;

    if(l0 == -1 || l0 == INF)
      calc0 = p0 + (sum - left[i+1])/2 + 1;
    else
      calc0 = p0 + right[l0]/2 + (sum - left[i+1] - right[l0])/2 + 1;

    if(l1 == -1 || l1 == INF)
      calc1 = p1 + (sum - left[i+1])/2 + 1;
    else
      calc1 = p1 + right[l1]/2 + (sum - left[i+1] - right[l1])/2 + 1;

    sameDP = min({calc0, calc1, sameDP});

    if(right[i]%2 == 0)
      pq0.push({-(sameDP - right[i]/2), i});
    else
      pq1.push({-(sameDP - right[i]/2), i});
  }

  printf("%d\n",sameDP);
  
  return 0;
}



Measured memory_bytes: 12344
import java.*;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int test = sc.nextInt();
		sc.nextLine();
		String s1 = new String();
		String s2 = new String();
		while (test > 0) {
			test--;
			s1 = sc.nextLine();
			s2 = sc.nextLine();
			//System.out.println(s1 + " " + s2);
			BigInteger b1 = new BigInteger(s1);
			BigInteger b2 = new BigInteger(s2);
			BigInteger result = new BigInteger("0");
			result = result.add(b1);
			result = result.add(b2);
			String s3 = ""+result;
			if(s1.length()>80 || s2.length()>80 || s3.length()>80)
				System.out.println("overflow");
			else
				System.out.println(result);
		}
	}
}

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

int main() {
	int a,b,c;
	cin >> a >> b;
	if (a != b) {
		if (a == 1) {
			cout << "Alice" << endl;
		} else if (b == 1) {
			cout << "Bob" << endl;
		} else if (a > b) {
			cout << "Alice" << endl;
		} else if (b > a) {
			cout << "Bob" << endl;
		}
	} else {
		cout << "Draw";
	}
 }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>

using namespace std;

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

int main()
{
  ll x;
  cin >> x;
  ll a = 100;
  int n = 0;
  while (a < x)
  {
    a *= 1.01;
    n++;
  }
  cout << n << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>  
#include<deque> 
#include<stack>
#include<string> 
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n) 
{ 
  vector<ll> result;
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
    int count=1;
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (ll i=p*p; i<=n; i += p) 
                {
                  prime[i] = false; 
                }
            count++;
        } 
    } 
  
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          {
            result.push_back(p);
          }
    return result;
}



vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

ll Div(ll n)
{
  for(ll i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
      return i;
  }
  return n;
}

int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}

 
int main()
{
  _FI 

  string a,b;
  cin>>a>>b;
  int x,y;
  cin>>x>>y;
 string c;
 cin>>c;
 if(c.compare(b)==0)
 {
  cout<<x<<" "<<y-1<<endl;
 }
 else
 {
  cout<<x-1<<" "<<y<<endl;
 }
  

  return 0;
}















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

void solve()
{
    string s,t;
    cin >> s >> t;
    int c = 0;
    for(int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) c++;
    }

    cout << c << endl;
}

int main(){cin.tie(0);ios_base::sync_with_stdio(false);solve();return 0;}

Measured memory_bytes: 3800
n = int(input())
xu = [list(input().split()) for i in range(n)]
sigma = 0

for j in range(n):
  if xu[j][1] == "BTC":
    sigma = sigma + float(xu[j][0])*380000
  else:
    sigma = sigma + float(xu[j][0])
    
print(sigma)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int n,l; cin >> n >> l;
    vector<string> s(n);
    REP(i,n) cin >> s[i];
    sort(ALL(s));
    REP(i,n){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define M 1000000007
ll ans=1,al[30];
int main(void){
    int n;cin>>n;
    string s;cin>>s;
    for(int i=0;i<n;i++){
        char c=s[i];
        al[c-'a']++;
    }
    for(int i=0;i<26;i++){
        ans=ans*(al[i]+1)%M;
    }
    cout<<ans-1<<endl;
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var L = new LinkedList<int>();
		for(int i=0;i<N;i++){
			if(i%2 == 0){
				L.AddLast(A[i]);
			} else {
				L.AddFirst(A[i]);
			}
		}
		
		var LL = L.ToList();
		if(N%2 == 1) LL.Reverse();
		Console.WriteLine(String.Join(" ",LL));
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 52136
#include<iostream>

using namespace std;
typedef long long ll;

int N;
ll ar[300];
const ll MOD = 998244353;
ll dp[300][90001];
ll dp2[300][45001];
int sum = 0;
int halfsum = -1;

ll modpow(int a, int b) {
	ll rtn = 1, kakeru = a;
	while (b > 0) {
		if (b & 1)rtn *= kakeru, rtn %= MOD;
		kakeru *= kakeru, kakeru %= MOD;
		b >>= 1;
	}
	return rtn;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> ar[i], sum += ar[i];
	if (sum % 2 == 0)halfsum = sum / 2;

	ll ans = modpow(3, N);

	dp[0][ar[0]] = 1;
	dp[0][0] = 2;
	dp2[0][ar[0]] = 1;
	dp2[0][0] = 1;
	for (int i = 1; i < N; i++) {
		for (int j = 0; j <= sum; j++) {
			dp[i][j] += dp[i - 1][j] * 2;
			if(j >= ar[i])dp[i][j] += dp[i - 1][j - ar[i]];
			dp[i][j] %= MOD;
			if (halfsum != -1) {
				if (j <= halfsum) {
					dp2[i][j] += dp2[i - 1][j];
					if (j >= ar[i])dp2[i][j] += dp2[i - 1][j - ar[i]];
					dp2[i][j] %= MOD;
				}
			}
		}
	}

	ll ans2 = 0;

	if (sum % 2 == 0)halfsum = sum / 2;
	else halfsum = (sum + 1) / 2;
	for (int i = halfsum; i <= sum; i++)ans2 += dp[N - 1][i];
	ans2 %= MOD;

	ll ans3 = 0;
	if (halfsum * 2 == sum) {
		ans3 = dp2[N - 1][halfsum];
	}

	cout << (MOD * 20 + ans - ans2 * 3 + ans3 * 3) % MOD << endl;

	return 0;
}

Measured memory_bytes: 316288
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextString() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	s, t := nextString(), nextString()
	fmt.Println(t + s)
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include <string>
#include<algorithm>
using namespace std;

int main()
{
    int a;
    cin >> a;
    int sum=0;
    
    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=a;j++)
        {
            if((i + j) % 2 == 0)
            {
                sum = sum + 0;
            }
            else
            {
                sum = sum + 1;
            }
        }
    }
    cout << sum/2;
}


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

using namespace std;

int solve(string str) {
    int res = 0;
    for (int i = 0; i <(int) str.length(); i++) {
        int count = 0;
        if (str[i] == 'R') {
            count++;
            for (int j = i + 1; j <(int) str.length(); j++) {
                if (str[j] == 'R') {
                    count++;
                }
                else {
                    break;
                }
            }
        }
        res = max(res, count);
    }
    return res;
}

int main() {
    string str;
    cin >> str;
    printf("%d\n", solve(str));
}

Measured memory_bytes: 3712
#include <stdio.h>

#define NUM_TRANSPORT 5

int main()
{
	int i, bottleneck_pos;
	unsigned long n, size_transport[NUM_TRANSPORT];

	scanf("%ld", &n);
	for (i = 0; i < NUM_TRANSPORT; i++)
		scanf("%ld", size_transport + i);

	for (i = 1, bottleneck_pos = 0; i < NUM_TRANSPORT; i++) {
		if (size_transport[bottleneck_pos] > size_transport[i])
			bottleneck_pos = i;
	}

	if (n % size_transport[bottleneck_pos] == 0)
		printf("%ld\n", n / size_transport[bottleneck_pos] + 4);
	else
		printf("%ld\n", n / size_transport[bottleneck_pos] + 5);

	return 0;
}
	


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int i,h,a=0,b=0,c=0;
    for(i=0;i<10;i++){
    cin >> h;
    if(a<h){
        c=b;
        b=a;
        a=h;
    }else if(b<h){
        c=b;
        b=h;
    }else if(c<h){
        c=h;
        }
    }
    cout << a << endl << b << endl << c << endl;
return 0;
}

Measured memory_bytes: 1160
from collections import deque
n,m,q=[int(_) for _ in input().split()]
lista=[[int(i) for i in input().split()] for j in range(q)]
v=deque()  #0,0,0,0,0....,0
def make(a,b,c): #a=list b=maxlen c=max
    global v
    if len(a)==b:
        v.append(a)
    else:
        for i in range(a[-1],c+1):
            make(a+[i],b,c)
for t in range(1,m+1):
    make([t],n,m)
max=0
for j in v:
    point=0
    for l in lista:
        if j[l[1]-1]-j[l[0]-1]==l[2]:
            point+=l[3]
    if max<point:
        max=point
print(max)


Measured memory_bytes: 92628
#include<stdio.h>
int main(void)
{
    int N,n;
    long a[200000],x=0,y=0;
    scanf("%d",&N);
    for(n=1;n<=N;n++)
        scanf("%ld",&a[n]);
    for(n=1;n<=N;n++)
    {
        if(a[n]%4==0)
            x++;
        if(a[n]%2!=0)
            y++;
    }
    if(x+y==N)
        if(y-x<=1) printf("Yes");
        else printf("No");
    else if(x>=y) printf("Yes");
            else printf("No");
    return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Change
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int input = int.Parse(Console.ReadLine());
                if (input == 0) break;
                int ans = 0;
                int[] changes = { 500, 100, 50, 10, 5, 1 };
                int change = 1000-input;
                for (int i = 0; i < changes.Length; ++i)
                {
                    while (change >= changes[i])
                    {
                        change -= changes[i];
                        ++ans;
                    }
                }
                Console.WriteLine(ans);
            }
        }
    }
}



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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

void solve() {
    int n;
    cin >> n;
    vt<int> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[--x] = i;
    }

    ll ans = 0;
    set<int> bigger_pos{-1, n};
    for (int i = n - 1; i >= 0; i--) {
        auto itr = bigger_pos.upper_bound(a[i]);
        auto itl = itr;
        itl--;

        ll cur = 0;
        if (*itr != n) {
            auto itr2 = itr;
            itr2++;
            cur += ll(*itr2 - *itr) * (a[i] - *itl);
        }

        if (*itl != -1) {
            auto itl2 = itl;
            itl2--;
            cur += ll(*itl - *itl2) * (*itr - a[i]);
        }

        ans += cur * (i + 1);
        bigger_pos.insert(a[i]);
    }

    cout << ans;
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 8276
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, m;
  cin >> n >> m;
  priority_queue<int> a;
  
  rep(i,n) {
    int p;
    cin >> p;
    a.push(p);
  }
  
  rep(i,m) {
    int r;
    r = a.top() / 2;
    a.pop();
    a.push(r);
  }
  
  int64_t ans=0;
  
  rep(i,n) {
    ans += a.top();
    a.pop();
  }
  cout << ans;
}

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

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    vector<bool> ans(n, false);
    vector<bool> del(n, false);
    int cnt = 0;

    vector<int> a(m);
    vector<int> b(m);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
        cin >> b[i];
    }

    for (int i = 0; i < m; i++)
    {
        if (h[a[i] - 1] < h[b[i] - 1])
        {
            del[a[i] - 1] = true;
        }
        else if (h[a[i] - 1] > h[b[i] - 1])
        {
            del[b[i] - 1] = true;
        }
        else
        {
            del[a[i] - 1] = true;
            del[b[i] - 1] = true;
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (!del[i])
        {
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 4576
#include <stdio.h>
#include <assert.h>

#define S 101

int main(void)
{
    char a[S], b[S], c[S];
    char *pa = a, *pb = b, *pc = c;
    scanf("%s %s %s", a, b, c);

    char d = *pa++;
    for (;;) {
        switch (d) {
            case 'a':
                if (*pa == '\0') {
                    puts("A");
                    return 0;
                }
                d = *pa++;
                break;
            case 'b':
                if (*pb == '\0') {
                    puts("B");
                    return 0;
                }
                d = *pb++;
                break;
            case 'c':
                if (*pc == '\0') {
                    puts("C");
                    return 0;
                }
                d = *pc++;
                break;
            default:
                assert(0);
        }
    }

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int cnt[4] = {};
	for(int i = 0; i < 3; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		cnt[a]++;
		cnt[b]++;
	}
	sort(cnt, cnt + 4);
	if(cnt[0] == 1 && cnt[1] == 1 && cnt[2] == 2 && cnt[3] == 2) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<string.h>
using namespace std;
//const int sss[10] = { 0, 6, 5, 4, 3, 2, 1 };
struct DICE
{
	int f[8];
};
DICE dice[101];
DICE rin(DICE x,char a)
{
	int k[10];
	for (int i = 1; i < 7; i++)
	{
		k[i] = x.f[i];
	}
	switch (a)
	{
	case'N':
		x.f[1] = k[2];
		x.f[5] = k[1];
		x.f[6] = k[5];
		x.f[2] = k[6];
		break;
	case'E':
		x.f[3] = k[1];
		x.f[1] = k[4];
		x.f[4] = k[6];
		x.f[6] = k[3];
		break;
	case'S':
		x.f[2] = k[1];
		x.f[1] = k[5];
		x.f[5] = k[6];
		x.f[6] = k[2];
		break;
	case'W':
		x.f[1] = k[3];
		x.f[3] = k[6];
		x.f[6] = k[4];
		x.f[4] = k[1];
		break;
	}
	return x;
}
DICE yok(DICE x)
{
	DICE a = x;
	x.f[2] = a.f[3];
	x.f[3] = a.f[5];
	x.f[5] = a.f[4];
	x.f[4] = a.f[2];
	return x;
}

bool sen(DICE x, DICE y)
{
	for (int i = 1; i < 8; i++)
	{
		for (int q = 0; q < 4; q++)
		{
			for (int z = 0; z < 6; z++)
			{
				if (x.f[z + 1] != y.f[z + 1])break;
				if (z == 5)
					return true;
			}
			y=yok(y);
		}
		if (i != 1&&i!=6)
		{
			y = rin(y, 'W');
		}
		else y = rin(y, 'N');
	}
	return false;
}

int main()
{
	int n;
	cin >> n;
	for (int s = 0; s < n; s++)
	{
		for (int i = 0; i < 6; i++)
		{
			cin >> dice[s].f[i + 1];
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int k = 0; k < n; k++)
		{
			if (k >= i)break;
			if (sen(dice[i], dice[k]))
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

}

Measured memory_bytes: 1164
import sys

# import re
# import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
# import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
MOD2 = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    d = na()

    c = collections.Counter(d)
    lim = max(c)

    flg = False
    if d[0] != 0:
        flg = True

    if c[0] != 1:
        flg = True

    for i in range(lim + 1):
        if i not in c.keys():
            flg = True
            break

    if flg:
        print(0)
        exit(0)

    ans = 1
    for i in range(2, lim + 1):
        ans *= pow(c[i - 1], c[i], MOD2)
        ans %= MOD2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19356
import sys
from math import sqrt
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    X=int(input())
    f=True
    while True:
        Z=int(sqrt(X))+1
        for i in range(2,Z):
            if X%i==0:
                f=False
                break
        if f==True:
            print(X)
            exit()
        else:
            f=True
            X+=1

if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1[1];
  long long int count=0;
  cin >> s1[0];
  for(int i=1;i<s1[0].size();i++){
    if(s1[0][i] != s1[0][i-1]){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX_ = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to;
    char cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(void){
    
    ll X, Y;
    cin >> X >> Y;
    COMinit();

    if((X+Y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    ll n = (X+Y)/3;
    X -= n;
    Y -= n;

    ll ans;
    ans = COM(X+Y, X);
    cout << ans << endl;
    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 23680
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

struct MaxFlow {
    static const int N = 512;
    int n, flow[N][N], capa[N][N], prev[N];
    void init(int _n) {
        n = _n;
        memset(flow, 0, sizeof(flow));
        memset(capa, 0, sizeof(capa));
    }
    void add_edge(int u, int v, int ca) { capa[u][v] = ca; }
    int max(int s, int t, int F=1<<30) {
        int total = 0;
        while(total < F) {
            memset(prev, -1, sizeof(prev));
            queue<int> q;
            prev[s] = s;
            q.push(s);
            while(!q.empty() && prev[t]<0) {
                const int u = q.front();
                q.pop();
                rep(i, n) if(prev[i]<0 && flow[u][i]<capa[u][i]) {
                    prev[i] = u;
                    q.push(i);
                }
            }
            if(prev[t]<0) return total;
            int inc = F-total;
            for(int j=t; prev[j]!=j; j=prev[j]) {
                inc = min(inc, capa[prev[j]][j]-flow[prev[j]][j]);
            }
            for(int j=t; prev[j]!=j; j=prev[j]) {
                flow[prev[j]][j] += inc;
                flow[j][prev[j]] -= inc;
            }
            total += inc;
        }
    return total;
    }
} mf;

int N, M, X[2000], Y[2000], S, T;

int main() {
    scanf("%d%d", &N, &M);
    rep(i, M) scanf("%d%d", X+i, Y+i);
    rep(i, M) X[i]--, Y[i]--;
    scanf("%d%d", &S, &T);
    S--, T--;
    mf.init(N);
    rep(i, M) {
        mf.add_edge(X[i], Y[i], 1);
        mf.add_edge(Y[i], X[i], 1);
    }
    printf("%d\n", mf.max(S, T));
    vector<int> ans;
    rep(i, M) if(mf.flow[X[i]][Y[i]]<0) ans.push_back(i+1);
    printf("%d\n", (int)ans.size());
    rep(i, ans.size()) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    vector<int>v(n);
    for(auto &x:v)
        cin>>x;
    int cnt=0;
    for(auto &x:v){
        while(x%2==0){
            x/=2;
            ++cnt;
        }
    }
    cout<<cnt;




}

Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  cout << a[2] * 10 + a[1] + a[0] << "\n";
}


Measured memory_bytes: 3608
L = list(raw_input())
for bit in range(1 << 3):
    P = [""] * 4
    for k in range(3):
        if bit & (1 << k):
            P[k] = "+"
        else:
            P[k] = "-"
    calc = ""
    for i in range(4):
        calc += L[i] + P[i]
    if eval(calc) == 7:
        ans = calc + "=7"
        break
print(ans)

Measured memory_bytes: 2568