akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using Node = vector<int>;
using Graph = vector<Node>;

int main (void) {
  int N, M;
  cin >> N >> M;
  Graph G(N);
  REP (i, M) {
    int a, b;
    cin >> a >> b;
    // 0-index;
    a -= 1;
    b -= 1;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  stack<pair<int, int>> st;
  st.push(make_pair(1, 0));
  int ans = 0;
  while (!st.empty()) {
    int visited, now;
    tie(visited, now) = st.top(); st.pop();
    // cout << visited << "," << now << endl;
    if (visited == (1 << N) - 1) {
      ans++;
      continue;
    }
    for (int& next : G[now]) {
      if ((visited & (1 << next)) == 0) {
        int new_visited = visited | (1 << next);
        // cout << "new: ";
        // cout << new_visited << "," << next << endl;
        st.push(make_pair(new_visited, next));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
    string s,p = "keyence",s1,s2,s3;
    bool ok = false;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        for(int j = i; j < s.length(); j++){
            s1 = "";
            s2 = "";
            s3 = "";
            for(int k = 0; k < i; k++)s1 += s[k];
            for(int k = i; k < j; k++)s2 += s[k];
            for(int k = j; k < s.length(); k++)s3 += s[k];
            if(s1 + s3 == p)ok = true;
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
}
main(){
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mid ((l+r)>>1)
using namespace std;
const int mxn=200010;
int n,m,a[mxn];
bool check(int x){
	int d0=n,d1=n;
	for (int i=2;i<=m;++i){
		if (a[i]<=x&&a[i-1]<=x) d0=m-i;
		if (a[i]>x&&a[i-1]>x) d1=m-i;
	}
	for (int i=m;i<n;++i){
		if (a[i]<=x&&a[i+1]<=x) d0=min(d0,i-m);
		if (a[i]>x&&a[i+1]>x) d1=min(d1,i-m);
	}
	return d0<d1||(d0==d1&&x==m);
}
int main()
{
	scanf("%d",&m);
	n=m*2-1;
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	int l=1,r=n;
	for (;l<=r;)
		if (check(mid)) r=mid-1;
		else l=mid+1;
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <stdio.h>
#include <boost/math/common_factor_rt.hpp>
#define EPS (1e-7)
using namespace std;
#define ll long long


int main() {

	int K, X;
	cin >> K >> X;

	int left, right;
	left = max(X - (K - 1),-1000000);
	right = min(X + (K - 1), 1000000);
	
	for (auto i = left; i < right; i++)
		{
			cout << i << " ";
		}
	cout << right << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
import sys
def input():
	return sys.stdin.readline()[:-1]


n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
c = Counter(a)
for i in range(1, n+1):
	if q - c[i] >= k:
		print("No")
	else:
		print("Yes")

Measured memory_bytes: 11904
"""
    Author : thekushalghosh
    Team   : CodeDiggers
"""
import sys,math,cmath,time
start_time = time.time()
################# ---- USER DEFINED INPUT FUNCTIONS ---- #################
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().split()))
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    c = 0
    for i in range(1,n + 1):
        for j in range(1,n + 1):
            for k in range(1,n + 1):
                c = c + math.gcd(math.gcd(i,j),k)
    print(c)
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
    sys.stdin = open('input.txt','r')
    sys.stdout = open('output.txt','w')
else:
    input = sys.stdin.readline
t = 1
for tt in range(t):
    solve()
if not ONLINE_JUDGE:
    print("Time Elapsed:",time.time() - start_time,"seconds")
sys.stdout.close()

Measured memory_bytes: 67832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll n;cin>>n;
    vector<double> x(n);
    vector<double> y(n);
    rep(i,n)cin>>x[i]>>y[i];

    double sum=0;
    vl order(n);
    rep(i,n)order[i]=i;
    do{
        double tmp=0;
        rep(i,n-1){
            tmp+=sqrt((x[order[i+1]]-x[order[i]])*(x[order[i+1]]-x[order[i]])
                        +(y[order[i+1]]-y[order[i]])*(y[order[i+1]]-y[order[i]]));
        }
        sum+=tmp;
    }while(next_permutation(all(order)));
    double ans=sum;
    fore(i,1,n)ans/=i;
    printf("%.7f\n",ans);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100000
struct edge{ int to,cost; };
typedef pair<int,int> P;
const int INF=1000000001;

int N,M;
int d[MAX_N];
vector<edge> G[MAX_N];

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    G[a].push_back((edge){b,c});
  }
  int ans=-1;  
  priority_queue< P , vector<P> , greater<P> > Q;
  fill(d,d+MAX_N,INF);
  Q.push(P(1,1));
  d[1]=1;
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int pos=p.second;
    int cost=p.first;
    if(d[pos]<cost)continue;
    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      if(e.cost<d[pos])continue;
      if(e.to==N)ans=max(ans,e.cost);
      if(d[e.to]>e.cost){
        d[e.to]=e.cost;
        Q.push(P(d[e.to],e.to));
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 9660
#include<iostream>
#include<string>
#include<cstring>
#include<cstdlib>
#include<typeinfo>
using namespace std;

int main(){
	string ss;
	while(cin>>ss){
		string ans;
		for(int i=0;i<ss.size();i++){
			if(ss[i]=='@'){
				i++;
				for(int j=0;j<(ss[i]-'0');j++){
					ans+=ss[i+1];
				}
				i++;
			}else{
				ans+=ss[i];
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
using System;

class Program
{
    static void Main()
    {
        while (true)
        {
            string str = Console.ReadLine();
            if (str == null)
                break;
            string[] s = str.Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int sum = a + b;
            string strsum = sum.ToString();
            Console.WriteLine("{0}", strsum.Length);
        }
    }

}

Measured memory_bytes: 9040
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    long a, b, c;
    scan(a, b, c);

    long ans = 0;

    if (b >= c) {
        ans = b + c;
    }
    else { // b < c
        ans = 2L*b;
        c -= b;
        ans += min(a+1, c);
    }

    writeln(ans);
}






























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define MOD 1000000007
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {

	string s;
	cin >> s;
	
	vector<vector<ll>> dp(3, vector<ll>(s.size()+1, 0));
	ll tmp = 1;
	
	rep(i, s.size()){
		if(s[i] == 'A'){
			dp[0][i+1] = (dp[0][i] + tmp) % MOD;
			dp[1][i+1] = dp[1][i];
			dp[2][i+1] = dp[2][i];
		}else if(s[i] == 'B'){
			dp[0][i+1] = dp[0][i];
			dp[1][i+1] = (dp[1][i] + dp[0][i]) % MOD;
			dp[2][i+1] = dp[2][i];
		}else if(s[i] == 'C'){
			dp[0][i+1] = dp[0][i];
			dp[1][i+1] = dp[1][i];
			dp[2][i+1] = (dp[2][i] + dp[1][i]) % MOD;
		}else{
			dp[0][i+1] = (dp[0][i] * 3 + tmp) % MOD;
			dp[1][i+1] = (dp[1][i] * 3 + dp[0][i]) % MOD;
			dp[2][i+1] = (dp[2][i] * 3 + dp[1][i]) % MOD;
			tmp = (tmp * 3) % MOD;
		}
	}
	
	cout << dp[2][s.size()] << endl;

	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a); i>=(b);i--) 

const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;

int n,k,sum,pos;
vector<int>v;
int a[500 +5], b[550], tot[550];


int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   cin >> n >> k;
   rep(i,1,n){
      cin >> a[i];
      sum += a[i];  
   }
   rep(i,1,(int)sqrt(sum)){
      if(sum % i == 0){
          if(sum == i * i) v.push_back(i);
          else v.push_back(i),v.push_back(sum / i);
      }
   }
   sort(v.rbegin(),v.rend());
   rep(i,0,v.size() - 1){
        int m = v[i];
        rep(i,1,n) b[i] = a[i] % m;
        sort(b + 1,b + n + 1);
        rep(i,1,n) tot[i] = tot[i - 1] + b[i];
        rep(i,1,n){
            if(tot[i] == ((n - i) * m - tot[n] + tot[i]) && tot[i] <= k) {
                cout << m << endl;
                return 0; 
            }
        }

   }
   return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a;
	int b;
	int c;

	cin >> a;
	cin >> b;
	cin >> c;

	if (a + b == c) {
		cout << "Yes" << endl;
	}
	else if (a + c == b) {
		cout << "Yes" << endl;
	}
	else if (b + c == a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}


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

using namespace std;

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

  vector<int> lens(N);
  for (int i = 0; i < N; ++i) {
    cin >> lens[i];
  }

  int64_t cur = 0; 

  auto left = lens.begin();
  auto right = lens.end() - 1;

  while (left <= right) {
    auto l = abs(cur + *left);
    auto r = abs(cur - *right);
    if (l < r) {
      cur += *left;
      ++left;
    } else {
      cur -= *right;
      --right;
    }
  }

  return abs(cur);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cout << solve() << endl;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 50005

int main()
{
    _FastIO;
    ll n , m;
    cin >> n >> m;
    if(n >= 2)
        n -= 2;
    if(m >= 2)
        m -= 2;
    ll ans = n * m;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
x0, y0, x1, y1 = map(int, input().split())
dx = x1 - x0
dy = y1 - y0
x2 = x1 - dy
y2 = y1 + dx
x3 = x0 - dy
y3 = y0 + dx
print(x2, y2, x3, y3)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int H = GetInt();
		int N = GetInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i = 0; i < N; i++)
		{
			A[i] = GetInt();
			B[i] = GetInt();
		}

		int[] dp = Enumerable.Repeat(int.MaxValue / 2, H + 1).ToArray();
		dp[0] = 0;
		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < N; j++)
			{
				int to = Min(H, i + A[j]);
				dp[to] = Min(dp[to], dp[i] + B[j]);
			}
		}
		WriteLine(dp[H]);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13340
#include<iostream>
#include <math.h>
using namespace std;

int gcd(int x, int y){
  if (x<y) {int tmp=y; y=x;x=tmp;}
  
  while (x%y!=0){
    int r=x%y;  x=y; y=r;
  }
  return y;
}

int main(void){
  int n, a[100000], g;
  cin>>n;
  for (int i=0;i<n;i++){
    cin>>a[i];
    if (i==0) g=a[0];
    else g=gcd(g,a[i]);
  }
  cout<<g<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
map<ll,ll> m;
while(n--)
{
	int x;
	cin>>x;
	m[-x]++;
}
ll ans=0;
tr(m,it)
{
	ll x=-(it->ff),cnt=it->ss,id;
	if(cnt<=0)continue;
	rep(i,0,32)
	{
		ll y=(1ll<<i);
		if(y>x)
		{
			id=y;
			break;
		}
	}
	if(2*x==id)
	{
		ans+=cnt/2;
		cnt%=2;
		continue;
	}
	if(cnt)
	{
		if(!present(m,x-id))continue;
		ll cc=m[x-id];
		if(cc>0)
		{
			int kk=min(cc,cnt);
			ans+=kk;
			m[x-id]-=kk;
		}
	}

}
ol(ans);
return 0;
}



Measured memory_bytes: 12800
N = int(input())
a = list(map(int, input().split()))
# print(N)
# print(a)
b = []

for i in range(N, 0, -1):
  for j in range(i, 0, -1):
    if a[j-1] == j:
      b.append(j)
      del a[j-1]
      break
    else:
      pass
  else:
    b = [-1]
    break

# print(b)
b.reverse()

for i in b:
  print(i)


Measured memory_bytes: 3060
#include<stdio.h>

int main()
{
  int  n, i, a[100001], c;

  scanf("%d", &n);
  for(i = 1; i <= n; i++){
    scanf("%d", &a[i]);
  }

  c = 0;
  for(i = 1; i <= n; i++){
    if(a[a[i]] == i){
      c++;
      a[a[i]] = 0;
    }
     a[i] = 0;
  }

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

  return 0;
} 

Measured memory_bytes: 512
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
st=s+t
u=set(s+t)
ans=0
for i in u:
  count=0
  for j in range(n+m):
    if i==st[j]:
      count+=1 if j<=n-1 else (-1)
  ans=max(ans,count)
print(ans)

Measured memory_bytes: 3064
// AOJ_C++.cpp : アプリケーションのエントリ ポイントを定義します。
//
#include <iostream>
#include <math.h>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a > b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	if (b > c) {
		int tmp = b;
		b = c;
		c = tmp;
	}
	if (a > b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	std::cout << a << " " << b << " " << c << std::endl;
    return 0;
}


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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 1000000007
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define N 200005

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


int n;
ll a[N], b[N];
bool los[N];

map<pair<int,pii>, ll> poj;
map<pair<int,pii>, bool>was;

ll st[N];

int main()
{

    //ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    st[0] = 1;
    ff(i,1,n){
        st[i] = 2 * st[i - 1];
        st[i] %= mod;
    }

    ff(i,1,n){
        cin >> a[i] >> b[i];
        if(a[i] != 0 && b[i] != 0){
            ll d = __gcd(a[i], b[i]);
            a[i] /= d; b[i] /= d;
        }
    }
    ll picke = 0;
    ll res = 1;
    ff(i,1,n){
        if(a[i] == 0 && b[i] == 0){los[i] = 1; picke++;}
        else{
            if(a[i] == 0){
                b[i] = 1;
                poj[{0,{1,0}}]++;
            }
            else if(b[i] == 0){
                a[i] = 1;
                poj[{1,{0,0}}]++;
            }
            else{
                int neg = 0;
                if(a[i] < 0)neg++;
                if(b[i] < 0)neg++;
                neg %= 2;
                poj[{abs(a[i]),{abs(b[i]),neg}}]++;
            }
        }
    }
    //cout << endl;
    ff(i,1,n){
        if(a[i] == 0 && b[i] == 0)continue;
        ll x = a[i];
        ll y = b[i];
        ll c = 0;
        if(a[i] < 0)c++;
        if(b[i] < 0)c++;
        c %= 2;
        a[i] = abs(a[i]);
        b[i] = abs(b[i]);
        x = a[i];
        y = b[i];
        if(was.find({a[i], {b[i], c}}) != was.end())continue;
        ll px,py,pc;
        if(x == 0){
            px = 1;
            py = 0;
            pc = 0;
        }
        else if(y == 0){
            px = 0;
            py = 1;
            pc = 0;
        }
        else{
            px = y;
            py = x;
            pc = c^1;
        }
        ll prvi = poj[{x,{y,c}}];
        ll drugi = poj[{px,{py,pc}}];
        //cout << prvi << " " << drugi << endl;
        //cout << x << " " << y << " " << c << endl;
        //cout << st[prvi] << " " << st[drugi] << endl << endl;
        was[{x,{y,c}}] = was[{px,{py,pc}}] = 1;
        ll sta = st[prvi] + st[drugi];
        sta--;
        sta %= mod;
        if(sta < 0)sta += mod;
        res = res * sta;
        res %= mod;
    }
    res += picke;
    res--;
    res %= mod;
    if(res < 0)res += mod;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 58224
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
A.sort(reverse=True)
 
total = 0
for a in A:
    total += a

word = "Yes"
for m in range(M):
    if (A[m] * 4 * M < total):
        word = "No"
 
print(word)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#define N 1000
using namespace std;

int lcs(string x, string y){
  int m = x.size();
  int n = y.size();
  int maxsize = 0;
  int c[N + 1][N + 1];

  x = ' ' + x;
  y = ' ' + y;

  for(int i = 1; i < m; i++){
    c[i][0] = 0;
  }

  for(int i = 0; i < n; i++){
    c[0][i] = 0;
  }

  for(int i = 1; i <= m; i++){
    for(int j = 1; j <= n; j++){
      if(x[i] == y[j]){
	c[i][j] = c[i-1][j-1] + 1;
      }

      else if(c[i-1][j] >= c[i][j-1]){
	c[i][j] = c[i-1][j];
      }

      else{
	c[i][j] = c[i][j-1];
      }

    maxsize = max(maxsize, c[i][j]);

    }
  }

  return maxsize;
  
}

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

  string x, y;

  for(int i = 0; i < n; i++){
    cin >> x >> y;

    cout << lcs(x, y) << endl;
    
  }

  return 0;

}



Measured memory_bytes: 7108
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;


int main(){
  ll k,q;
  cin >> k >> q;
  vector<ll> d(k);
  rep(i,k){
    cin >> d[i];
  }

  while(q--){
    ll n,x,m;
    cin >> n >> x >> m;
    vector<ll> z(k+1,0);
    vector<ll> r(k+1,0);
    rep(i,k){
      z[i+1] += z[i];
      if(d[i]%m==0){
        z[i+1]++;
      }
      r[i+1] = r[i] + d[i]%m;
    }
    ll ans = n-1 - (x%m+(r[k]*((n-1)/k))+r[(n-1)%k])/m - ((z[k]*((n-1)/k))+z[(n-1)%k]);
    ll A = (x+(r[k]*((n-1)/k))+r[(n-1)%k]);
    ll Z = ((z[k]*((n-1)/k))+z[(n-1)%k]);
    cout << ans << ln;
  }


  return 0;
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.Split.Int;
            return (line[1] - 1) * (line[0] - 1);
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> Split { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

Measured memory_bytes: 11348
r=range
def a(i,j,k,l="+"):print(l,i,j,k)
print(6484)
a(0,1,3)
a(2,3,3,L:="<")
for x in 0,1:
	a(x,3,x)
	for t in r(30):a(v:=x+4,v,v);a(v,3,6),exec('a(6,6,6);'*(29-t));a(6,x,T:=x*60+9+t,L);a(v,T,v)
for t in r(60):a(2,2,2);[(a(8+t-s,69+s,5),a(3,5,6,L),a(2,6,2))for s in r(t)]

Measured memory_bytes: 9336
import java.util.*;

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

        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double x = sc.nextDouble();
        sc.close();

        if (x / a <= a * b / 2) {
            System.out.println(Math.toDegrees(Math.atan(a * Math.pow(b, 2) / (2 * x))));
        } else {
            System.out.println(Math.toDegrees(Math.atan((2 * (b - x / Math.pow(a, 2)) / a))));
        }
    }
}

Measured memory_bytes: 24144
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void solve(ll a, ll b, ll c) {
  bool result;
  if (c - a - b < 0) {
    result = false;
  } else {
    ll l = c * c + a * a + b * b;
    ll r = 2 * a * c + 2 * b * c + 2 * a * b;
    result = l > r;
  }
  yesOrNo(result);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll a;
  scanf("%lld", &a);
  ll b;
  scanf("%lld", &b);
  ll c;
  scanf("%lld", &c);
  solve(a, b, c);
  return 0;
}


Measured memory_bytes: 256
table = list(map(int,input().split()))

for i in range(2,0,-1):
    k = 0
    while k < i:
        if table[k] > table[k+1]:
            table[k],table[k+1] = table[k+1],table[k]
        k += 1;


print(table[0],table[1],table[2])



Measured memory_bytes: 5596
#include <stdio.h>

int main() {
	int N, D, ans;

	scanf("%d", &N);
	scanf("%d", &D);

	ans = N / (2 * D + 1);
	if(N % (2 * D + 1)) {
		ans += 1;
	}
	printf("%d\n", ans);

	return 0;
}



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

int main()
{
    string S;
    cin >> S;
    
    if( S[0] == '1'){
        cout << "9";
    }else{
        cout << "1";
    }
    if (S[1] == '1')
    {
        cout << "9";
    }
    else
    {
        cout << "1";
    }
    if (S[2] == '1')
    {
        cout << "9";
    }
    else
    {
        cout << "1";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll ans = 0;
  for (ll i = 0; i < n - 2; i++) {
    if (s.substr(i, 3) == "ABC") ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using P = pair<int, int>;
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    set<P> g; //辺が2つ（ペア）あるノードで構成されるグラフ
    rep(i, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--; b--; //indexが0スタートだから
        g.insert({a, b}); //i番目の定期便（ノード）は、aからbに辺を作る
        g.insert({b, a}); //逆もしかり
    }
    for (int i = 1; i < n - 1; i++) { //島1から島Nへ定期便を2つ使って行けるか全探索。島2からスタートしてn-2まで調べる。
        if(g.count({0, i}) && g.count({i, n - 1})) { //もし、グラフの中に頂点0,iとi,n-1の2辺が1以上あれば。
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 22440
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;


int main() {
	vector<int>nums(2e5+10);
	string st;cin>>st;
	long long int ans=0;
	int num=1e5+5;
	for (auto c : st) {
		if (c == '(') {
			ans+=nums[num];
			nums[num]++;
			num++;
		}
		else {
			ans+=nums[num];
			nums[num]++;
			num--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    ll n,k,s;
    cin>>n>>k>>s;
    for(int i=0; i<k; i++){
        cout<<s<<" ";
    }
    if((n-k)>=s){
        for(int i=0; i<n-k; i++){
            cout<<s+1<<" ";
        }
    }else{
        for(int i=0; i<n-k; i++){
            cout<<1<<" ";
        }
    }

}


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int ans;
char s;

main() {
    rep(i,4) {
        cin >> s;
        if (s == '+') ans++;
        else ans--;
    }
    ct(ans)
}

Measured memory_bytes: 256
#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);
  }
  
  int count = 0;
  
  for(int i = 0;i < N-2;i++){
    if(a.at(i) < a.at(i+1) && a.at(i+1) < a.at(i+2) || a.at(i) > a.at(i+1) && a.at(i+1) > a.at(i+2)){
      count++;
    }
  }
  
  cout << count << endl;
  
  
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define repvin(n) vint a(n);r(i,n)cin>>a[i];
#define int long long
#define str string
#define vint vector<signed>
#define pint pair<signed,signed>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;

signed main(){
  int n,k;
  cin>>n>>k;
  vint a(n);
  repi(n)cin>>a[i];
  sort(all(a));
  int res=0;
  vint dif;
  rep(i,n-1){
    if(a[i]!=a[i+1])dif.pb(i+1);
  }
  dif.pb(n);
  if(dif.size()<=k){
    cout<<res<<endl;
    return 0;
  }
  for(int i=dif.size()-1;i>0;--i)dif[i]-=dif[i-1];
  sort(all(dif));
  repi(dif.size()-k)res+=dif[i];
  cout<<res<<endl;
  
  
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pll = pair<ll, ll>;

#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair


template <typename T>
using vv = vector<vector<T>>;

void solve() {
    int n; cin >> n;
    vi a(n);
    ll res = 0;
    for (auto &i : a) cin >> i;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) {
                    if (a[i] + a[j] > a[k] &&
                        a[i] + a[k] > a[j] &&
                        a[j] + a[k] > a[i]) res++;
                }
            }
        }
    }
    cout << res;
}



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


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

using namespace std;

int cnt[15]={0},cnt1[15]={0};


int main()
{
    int u,v;
    for(int i=1;i<=3;i++){
        scanf("%d %d",&u,&v);
        cnt[u]++;
        cnt[v]++;
    }
    for(int i=1;i<=4;i++){
        cnt1[cnt[i]]++;
    }
    if(cnt1[1]==2 && cnt1[2]==2)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  int K;
  cin >> N;
  cin >> S;
  cin >> K;
  for ( int i = 0; i < N; i++) {
    if ( S.at(K-1) != S.at(i) ) {
      S.at(i) = '*';
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[MAXn],cnt[MAXn];
int main(){
    IOS();
    int n;
    cin >> n;
    for (int i=0;i<n;++i) {
        cin >> d[i];
    }
    sort(d,d+n,greater<ll>());
    if (d[n-1] < (d[0]+1)/2) return cout << "Impossible" << endl,0;
    for (int i=0;i<n;++i) {
        cnt[d[i]]++;
    }
    int mid = (d[0]+1)/2;
    for (int i=d[0];i >= mid;i--) {
        if (i == mid) {
            if (d[0] % 2 == 0) {
                if (cnt[i] == 0) return cout << "Impossible" << endl,0;
                cnt[i]--;
                break;
            }
        }
        if (cnt[i] < 2) return cout << "Impossible" << endl,0;
        cnt[i] -= 2;
    }
    if (cnt[mid] != 0) return cout << "Impossible" << endl,0;
    cout << "Possible" << endl;
}


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

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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

int main()
{
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    if (H % h == 0 and W % w == 0) {
        cout << "No" << endl;
        return 0;
    }

    const ll minus_num = (H / h) * (W / w);
    const ll num = minus_num + 1;
    const ll minus = -num * h * w + num - 1;
    cout << "Yes" << endl;
    rep(i, H)
    {
        rep(j, W)
        {
            if (j > 0) {
                cout << " ";
            }
            if (i % h == h - 1 and j % w == w - 1) {
                cout << minus;
            } else {
                cout << num;
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[202020];
vector<vector<ll>> place(202020);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        place[c[i]].push_back(i);
    }
    dp[0] = 1;
    for (ll i = 0; i < n; i++)
    {
        (dp[i + 1] += dp[i]) %= MOD;
        ll color = c[i];
        ll itr = lower_bound(ALL(place[color]), i) - place[color].begin();
        if (itr > 0)
        {
            ll j = place[color][itr - 1];
            if (i - j > 1)
            {
                (dp[i + 1] += dp[j + 1]) %= MOD;
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

ll power(ll x, ll y) {
	if (y == 0)
		return 1;
	return x * power(x, y - 1);
}
int main() {
	run();
	int x;
	cin >> x;
	for (ll i = 0;; i++) {
		int st = -1e3, ed = 1e3;
		while (st <= ed) {
			int md = (st + ed >> 1);
			ll res = power(i, 5) - power(md, 5);
			if (res < x)
				ed = md - 1;
			else if (res > x)
				st = md + 1;
			else {
				cout << i << ' ' << md << endl;
				return 0;
			}
		}
		st = -1e3, ed = 1e3;
		while (st <= ed) {
			int md = (st + ed >> 1);
			ll res = -power(i, 5) - power(md, 5);
			if (res < x)
				ed = md - 1;
			else if (res > x)
				st = md + 1;
			else {
				cout << -i << ' ' << md << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	long long n;cin>>n;
	vector<long long int> l(100);
	l[0]=2;l[1]=1;
	for(int i=2;i<=n;i++)l[i]=l[i-1]+l[i-2];
	cout<<l[n]<<endl;
}

Measured memory_bytes: 256
import math
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
 
cs = [a,b,c,d,e]
 
min_cs = min(cs)
 
t = math.ceil(n / min_cs)

print(t + 4)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
using namespace std;

string addzero(string str,int n){
  string str_0;
  for(int i=0;i<(n-str.size());i++)
    str_0.insert(0,"0");
  str_0+=str;
  return str_0;
}

string getMin(string str){
  sort( str.begin(),str.end() );
  return str;
}

string getMax(string str){
  str=getMin(str);
  reverse( str.begin(),str.end() );
  return str;
}

string int_to_string(int& n){
  stringstream ss;
  ss << n;
  return ss.str();
}

int string_to_int(const string& s){
  int n;
  istringstream iss(s);
  iss >> n;
  return n;
}

string getSub(string maxstr,string minstr){
  int max,min,work;
  string str;
  max=atoi( maxstr.c_str() );
  min=atoi( minstr.c_str() );
  work=max-min;
  str=int_to_string(work);
  return str;
}

void printData(int data[]){
  for(int i=0;i<=20-1;i++)
    for(int j=i+1;j<=20;j++)
      if(data[i]==data[j]){
	cout<<i<<" "<<data[i]<<" "<<j-i<<endl;
	return ;
      }
}

int main(){
  int n,max_,min_;
  int data[21]={0};
  string str;

  while(1){
  cin>>str>>n;
  if(str=="0" && n==0) break;
    for(int i=0;i<=20;i++){
      data[i]=string_to_int(str);
      str=addzero(str,n);
      str=getSub(getMax(str),getMin(str));
    }
    printData(data);

    
  }
  return 0;
}

Measured memory_bytes: 1256
#![allow(unused_imports)]
#![allow(unused_macros)]
// use proconio::input;
use std::cmp::{Ordering::*, Reverse};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};
use std::io::{self, BufWriter, Write};
use std::str::{self, SplitAsciiWhitespace};

// I have no idea what I'm doing

macro_rules! answer {
    ($out:ident, $ans:expr) => {
        writeln!($out, "{}", $ans)
    };
}

fn cuts(a: &[i64], x: i64) -> i64 {
    a
        .iter()
        .map(|y| (y-1) / x)
        .sum()
}

fn main() -> Result<(), io::Error> {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = UnsafeScanner::new(stdin.lock());
    let mut out = BufWriter::new(stdout.lock());

    let n: usize = scan.token();
    let k: i64 = scan.token();

    let a: Vec<i64> = (0..n).map(|_| scan.token()).collect();

    let (mut l, mut r) = (1i64, 2_000_000_000i64);
    while l < r {
        let x = (l + r) / 2;
        if cuts(&a, x) <= k {
            r = x;
        } else {
            l = x + 1;
        }
    }

    answer!(out, l)
}

///////////////////////////////////////////////////////////////////////////////////////////////////

/// Mostly copied from https://github.com/EbTech/rust-algorithms/blob/master/src/scanner.rs
/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> UnsafeScanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_ascii_whitespace(),
        }
    }

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse [Scanner]");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }

    pub fn pair<T: str::FromStr>(&mut self) -> (T, T) {
        (self.token(), self.token())
    }
}

// aka #![feature(bool_to_option)]
trait BoolThen {
    fn then_<T>(self, f: impl FnOnce() -> T) -> Option<T>;
}

impl BoolThen for bool {
    fn then_<T>(self, f: impl FnOnce() -> T) -> Option<T> {
        if self {
            Some(f())
        } else {
            None
        }
    }
}

trait BoolToYes {
    fn yes(self) -> &'static str;
}

impl BoolToYes for bool {
    fn yes(self) -> &'static str {
        match self {
            true => "Yes",
            false => "No",
        }
    }
}


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

int main(void){
    int a, b;
    cin >> a >> b;
    if(a > 12) cout << b << endl;
    else if(5 < a && a <= 12) cout << b/2 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < m; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if(sum > n) {
        cout << -1 << endl;
    } else {
        cout << n - sum << endl;
    }
}


Measured memory_bytes: 11176
/*                                              不开long long见祖宗                                                           */
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int r; 
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>r;
	cout<<setiosflags(ios::fixed)<<setprecision(20);
	cout<<r*6.28318530717958623200;
	return 0;
}


Measured memory_bytes: 3776
#include <stdio.h>

int main() {
  int i, height, width;
  scanf("%d %d", &height, &width);
  char image_row[width+1];
  for(i = 0; i < height; i++) {
    scanf("%s", image_row);
    printf("%s\n", image_row);
    printf("%s\n", image_row);
  }
  return 0;
}


Measured memory_bytes: 128
S = input()
T = input()
s, t = [], []
for alp in "abcdefghijklmnopqrstuvwxyz":
  s.append(S.count(alp))
  t.append(T.count(alp))
s.sort()
t.sort()
if s == t:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3632
<?php
$s = trim(fgets(STDIN));
$c = strlen($s) - 2;
$ret = 999;
for ($i = 0; $i < $c; $i++) {
  $tmp = abs(substr($s, $i, 3) - 753);
  if ($tmp < $ret) $ret = $tmp;
}

echo $ret.PHP_EOL;

Measured memory_bytes: 3828