akhauriyash/Code-Regression huggingface dataset:
#ifdef __GNUC__ 
#include <bits/stdc++.h>
auto & in = std::cin;
#else
std::istringstream in;
#endif
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/dynamic_bitset.hpp>
using namespace std;
#define ALL(v) std::begin(v),std::end(v)
using u6 = std::uint64_t;
using u3 = std::uint32_t;
constexpr u6 moduloNo = 1'000'000'000 + 7; //'
constexpr u3 maxA = 0x10'0000;
struct State {
	array<u3, 3> buf;
	//State() :buf{ 1,0,1 } {}
	constexpr State() :buf{1,0,0}{}
	State(u3 zerocount) :buf{ 1,0,zerocount } { addX(zerocount); }
	void addX(u3 zero) {
		if (zero != buf[2]) {
			u6 zerodiff = zero - buf[2];
			buf[0] = (u3)(((u6)buf[0] + zerodiff * buf[1]) % moduloNo);
			buf[2] = zero;

		}

		buf[1] = buf[0] + buf[1];
		buf[1] = (buf[1] >= moduloNo) ? buf[1] - moduloNo : buf[1];
	}
};
u6 pow2(u6 n) {
	if (n < 64)return (u6(1) << n) % moduloNo;
	else if (n == 64)return (u6(0) - moduloNo) % moduloNo;
	u6 tmp = pow2(n / 2);
	tmp = tmp * tmp;
	if (n & 1)tmp *= 2;
	return tmp % moduloNo;
}

struct Calc {
	u6 N;

	//unordered_map<u3, State> stmap;
	State stmap[maxA];
	unordered_set<u3> nums;
	u6 calc(u6 N_) {
		N = N_;
		u3 st = 0;
		u3 tmp;
		u3 zerocount = 0;
		for (u3 index = 0; index < N; ++index) {
			in >> tmp;
			st ^= tmp;
			if (!st) {
				++zerocount;
				//cout << index << endl;
			}
			else {
				/*
				auto ite = stmap.find(st);
				if (ite == stmap.end()) {
					stmap.emplace(st, zerocount);
				}
				else {
					ite->second.addX(zerocount);
				}*/
				stmap[st].addX(zerocount);
				nums.insert(st);
			}
		}
		if (st != 0) {
			return stmap[st].buf[0];
		}
		else {
			u6 result = pow2(zerocount - 1);
			for (auto & num : nums) {
			//for (auto & stv : stmap) {
				//result = (result + stv.buf[1]) % moduloNo;
				result = (result + stmap[num].buf[1]) % moduloNo;
			}

			/*u6 sum0 = 0, sum1 = 0;
			for (auto & stv : stmap) {
				cout << stv.second.buf[0] << " " << stv.second.buf[1]  <<  " " << stv.second.buf[2] << endl;
				sum0 += stv.second.buf[0];
				sum1 += stv.second.buf[1];
			}
			cout << sum0 << " " << sum1 << endl;*/
			return result;
		}
	}
};
Calc calc;

int main() {

#ifndef __GNUC__ 
	in.str("32\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0");
#endif
	u6 N;
	cin >> N;
	cout << calc.calc(N) << endl;
	/*
	u6 i = 0; u6 maxnum = 0;
	for (auto & v : tbl.buf) {
		for (auto n : v.buf) {
			if (n > maxnum)maxnum = n;
		}
	}
	cout << maxnum << endl;
	for (auto & v : tbl.buf) {
		cout << i << "=" << v << endl;
		++i;
	}
	cout << maxnum << endl;*/
}


Measured memory_bytes: 26568
N=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
              divisors.append(n//i)
    divisors.sort()
    return divisors
  
ans=0
count=1
factor=make_divisors(N)

#print(factor)
factor.remove(N)
for f in factor:
  if f==N%((N-f)//f):
    ans+=(N-f)//f
  #print(ans,(N-f//f))
print(ans)

Measured memory_bytes: 3264
a, b, k = map(int, input().split())
for i in range(k):
    if a + i <= b: 
        print(a + i)
    else:
        break
for i in range(k, 0, -1):
    if b - i + 1 > a + k - 1:
        print(b - i + 1)
    else:
        continue

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

signed main()
{
    int n;
    cin>>n;
    vector<int> dp(3);
    for(int i=0;i<n;i++){
        vector<int> new_dp(3,0);
        vector<int> c(3);
        for(int i=0;i<3;i++)
            cin>>c[i];
        // cout<<c[0]<<" "<<c[1]<<" "<<c[2]<<endl;
    
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(i!=j){
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        
        dp = new_dp;
    }
    cout<<max({dp[0],dp[1],dp[2]});
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makei(n);
	makes(s);
	int hiraki = 0, tozi = 0;
	for (char x : s) {
		if (x == '(') ++hiraki;
		else {
			if (hiraki > 0)--hiraki;
			else ++tozi;
		}
	}
	rep(tozi)cout << "(";
	cout << s;
	rep(hiraki)cout << ")";
	cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
 public class Main{
   public static void main(String[]args){
     Scanner s = new Scanner(System.in);
     int a = s.nextInt();
     int b = s.nextInt();
     int c = a+b;
     int d = a-b;
     int e =a*b;
     System.out.println(Math.max(c,Math.max(d,e)));
   }
 }

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=100005;
int n,m,Q;
int a[N],b[N];
int main(){
	scanf("%d%d%d",&n,&m,&Q);
	int v1=1e9,v2=1e9;
	For(i,1,n) scanf("%d",&a[i]),v1=min(v1,a[i]);
	For(i,1,m) scanf("%d",&b[i]),v2=min(v2,b[i]);
	int ans=v1+v2;
	For(i,1,Q){
		int x,y,v;
		scanf("%d%d%d",&x,&y,&v);
		ans=min(ans,a[x]+b[y]-v);
	}
	printf("%d\n",ans);
} 

Measured memory_bytes: 1024
S = [int(_) for _ in input()]
ans = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        count = 2 ** i
        if j < len(S) - 1:
            count *= 2 ** (len(S) - 2 - j)
        ans += count * S[i] * 10 ** (j - i)
print(ans)


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

class P
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = I();
        int[] B = I();
        int[] C = I();
        int[] b = new int[N];
        long[] bb = new long[N + 1];
        int index = 0;
        for (int i = 0; i < B.Length; i++)
        {
            while (index < N && B[i] >= C[index])
            {
                index++;
            }
            b[i] = N - index;
        }
        bb[N - 1] = b[N - 1];
        for (int i = N - 2; i >= 0; i--)
        {
            bb[i] = bb[i + 1] + b[i];
        }
        long res = 0;
        index = 0;
        for (int i = 0; i < N; i++)
        {
            while (index < N && A[i] >= B[index])
            {
                index++;
            }
            res += bb[index];
        }
        Console.WriteLine(res);
    }
    static int[] I()
    {
        return Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
        /*List<int> Al = new List<int>();
        Al.Add(A[0]);
        for (int i = 1; i < A.Length; i++)
        {
            if (Al.Last() != A[i]) Al.Add(A[i]);
        }*/
    }
}

Measured memory_bytes: 39804
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int a,b; cin >> a >> b;
    if(a == b) cout << a+b << endl;
    else {
        cout << max(a,b)*2-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def compress(L):
    L2 = list(set(L))
    L2.sort()
    C = {v : k for k, v in enumerate(L2)}
    return L2, C

N, M = map(int, readline().split())
INF = 10**9+7

Wp = [tuple(map(int, readline().split())) for _ in range(N)]
Hp = [tuple(map(int, readline().split())) for _ in range(M)]


epx = [0, INF, -INF]
epy = [0, INF, -INF]

for X, st, en in Hp:
    epx.append(X)
    epy.append(st)
    epy.append(en)

for st, en, Y in Wp:
    epy.append(Y)
    epx.append(st)
    epx.append(en)
    

Elx, Cex = compress(epx)
Ely, Cey = compress(epy)
Lx = len(Elx)
Ly = len(Ely)


UD = [[0]*(Lx+1) for _ in range(Ly+1)]
LR = [[0]*(Lx+1) for _ in range(Ly+1)]
for X, st, en in Hp:
    LR[Cey[st]][Cex[X]] += 1
    LR[Cey[en]][Cex[X]] -= 1
for st, en, Y in Wp:
    UD[Cey[Y]][Cex[st]] += 1
    UD[Cey[Y]][Cex[en]] -= 1

for x in range(1, Lx):
    for y in range(Ly):
        UD[y][x] += UD[y][x-1]

for y in range(1, Ly):
    for x in range(Lx):
        LR[y][x] += LR[y-1][x]
      
ed = set()
for i in range(Lx):
    ed.add((i, 0))
    ed.add((i, Ly-1))
for j in range(Ly):
    ed.add((0, j))
    ed.add((Lx-1, j))

geta = Ly
st = Cex[0]*geta + Cey[0]
stack = [st]
used = [False]*(Lx*Ly)
used[st] = True
ans = 'INF'
area = 0
while stack:
    vx, vy = divmod(stack.pop(), geta)
    if (vx, vy) in ed:
        break
    area += (Elx[vx+1]-Elx[vx])*(Ely[vy+1]-Ely[vy])
    if not UD[vy+1][vx] and not used[vx*geta+vy+1]:
        used[vx*geta+vy+1] = True
        stack.append(vx*geta+vy+1)
    if not UD[vy][vx] and not used[vx*geta+vy-1]:
        used[vx*geta+vy-1] = True
        stack.append(vx*geta+vy-1)
    if not LR[vy][vx+1] and not used[(vx+1)*geta+vy]:
        used[(vx+1)*geta+vy] = True
        stack.append((vx+1)*geta+vy)
    if not LR[vy][vx] and not used[(vx-1)*geta+vy]:
        used[(vx-1)*geta+vy] = True
        stack.append((vx-1)*geta+vy)

else:
    ans = area
print(ans)


Measured memory_bytes: 482988
/*
ID: Barry Wang
LANG: C++11
TASK: 
*/
#include <bits/stdc++.h>
using namespace std;
/*---define tricks---*/
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define revsort(b,e) sort(b,e),reverse(b,e)
#define X first
#define Y second
#define Chtolly return 0
/*---define types---*/
typedef long long ll;
typedef list<int> li;
typedef queue<int> qi;
typedef deque<int> dqi;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef unsigned int uint;
/*---define variables---*/
const int inf=(1<<29);
short n,m;
string a,b;
short dp[3001][3001];
bool add[3001][3001];
string ans;
pair<short,short> p[3001][3001];
/*---define function---*/

/*---main code---*/
int main(){
	cin>>a>>b;
	n=a.size(),m=b.size();
	a=' '+a,b=' '+b;
	for(int i=0;i<=n;++i){
		for(int j=0;j<=m;++j){
			p[i][j]={-1,-1};
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(dp[i][j-1]>=dp[i][j]){
				dp[i][j]=dp[i][j-1];
				p[i][j]={i,j-1};
			}
			if(dp[i-1][j]>=dp[i][j]){
				dp[i][j]=dp[i-1][j];
				p[i][j]={i-1,j};
			}
			if(a[i]==b[j]){
				if((dp[i-1][j-1]+1)>dp[i][j]){
					dp[i][j]=(dp[i-1][j-1]+1);
					add[i][j]=1;
					p[i][j]={i-1,j-1};
				}
			}
		}
	} 
	pair<short,short> u={n,m};
	while(u!=make_pair(short(-1),short(-1))){
		int x=u.first,y=u.second;
		if(add[x][y]){
			ans=a[x]+ans;
		}
		u=p[x][y];
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 61824
def main():
    while True:
        H, W = map(int, input().split())
        if (H, W) == (0, 0):
            break

        print("#" * W)
        for _ in range(H - 2):
            print("#" + "." * (W - 2) + "#")
        print("#" * W)
        print("")

if __name__ == "__main__":
    main()

Measured memory_bytes: 5612
s = input()

s = s[::-1]
lis = ['dreamer', 'dream', 'eraser', 'erase']
nlis = []
for i in lis:
    nlis.append(i[::-1])


for i in range(10**5 + 1):
    for j in nlis:
        if s.startswith(j):
            s = s[len(j):]


if s == '':
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9160
#include <iomanip>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main(){
  int N;
  cin >>N;
  vector <int> x(N),y(N),A(N); 
  rep(i,N)
    cin >>x[i]>>y[i];
  rep(i,N)
    A[i]=i;
  double count=0,countN=0,X,Y;
  do{
    rep(i,N-1){
      X=pow((x[A[i+1]]-x[A[i]]),2.0);
      Y=pow((y[A[i+1]]-y[A[i]]),2.0);
      count+=sqrt(X+Y);
    }
    
    countN++;
  }while(next_permutation(A.begin(),A.end()));

  cout<<fixed<<setprecision(10)<<count/countN<<endl;








  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

   int W , H , x , y , r;
   scanf("%d%d%d%d%d" , &W , &H , &x , &y , &r);
   if ( 0 + r <= x && x <= W - r && 0 + r <= y && y <= H - r) { 
   printf ("Yes\n");
  } else {
   printf ("No\n");
  }

   
  return 0;
}






Measured memory_bytes: 2144
s = input()
K = int(input())

s_set = set()
for i in range(len(s)):
    for j in range(i + 1, i + K + 1):
        if j > len(s) + 1:
            break
        s_set.add(s[i:j])
s_list = list(s_set)
s_list.sort()
print(s_list[K - 1])


Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std; 
int main(){
	int a,b;
	cin>>a>>b;
	double ans=0;
	for(int i=1;i<=a;i++){
		double shit=1.0/a;
		int fuck=i;
		while(fuck<b){
			fuck*=2;
			shit/=2;
		}
		ans+=shit;
	}
	printf("%.12f\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)

using namespace std;
using ll = long long;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<int> a(n);

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

	vector<int> hist; // 訪れた頂点
	vector<int> ord(n + 1, -1); // 頂点番号,sのインデックスに対応,訪れた順番
	ll period = 1;
	ll per_st = 0;
	{
		int now = 1;
		while (ord[now] == -1) {
			ord[now] = hist.size();
			hist.emplace_back(now);
			now = a[now - 1];
		}
		per_st = ord[now];
		period = hist.size() - per_st;
	}

	if (k < per_st) cout << hist[k] << endl;
	else {
		k -= per_st;
		k %= period;
		cout << hist[k + per_st] << endl;
	}
	return 0;
}

Measured memory_bytes: 5888
/*  ex6_2
    yy8332  */

#include <stdio.h>
#include <string.h>

int main(void){

  int len_w;
  char word[101];

  //入力読み取り
  scanf("%s", word);

  //要素数の取得
  len_w = strlen(word);

  //出力
  printf("%c%d%c", word[0], len_w - 2, word[len_w - 1]);


  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

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

struct edge{int to,cost;};

void dump_line(int *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

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

	ll a,b,c;
	cin >> a >> b >> c;

	cout << min(a+b+1,c) + b << "\n";

	return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())

if a == 1:
    if b == 2:
        print(3)
    else:
        print(2)
elif a == 2:
    if b == 1:
        print(3)
    else:
        print(1)
else:
    if b == 1:
        print(2)
    else:
        print(1)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	long long int r,d,x;
  scanf("%lld %lld %lld",&r,&d,&x);
  for(int i=0;i<10;i++)
  {
    x=(r*x)-d;
    printf("%lld\n",x);
  }
  return 0;
}

Measured memory_bytes: 128
/*
 * src.cpp
 *
 *  Created on: 2016/07/27
 *      Author: joi
 */

#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

const int MAX_N=1e2,INF=1e8;

int n,m;

char chairs[MAX_N+1];

int dist(int a){
	int res=INF;
	REP(i,n){
		if (chairs[i]!='#'){
			res=min(res,abs(i-a));
		}
	}
	return res;
}

int main(){
	do{
		cin>>n>>m;
		if (n || m){
			cin.ignore();
			REP(i,n){
				chairs[i]='#';
			}
			chairs[n]=0;
			REP(i,m){
				char c;
				cin>>c;
				switch (c){
				case 'A':{
					REP(i,n){
						if (chairs[i]=='#'){
							chairs[i]='A';
							break;
						}
					}
					break;
				}
				case 'B':{
					int v=-1;
					for (int i=n-1;i>=0;i--){
						if (chairs[i]=='#'){
							if (i!=0){
								if (chairs[i-1]=='A'){
									continue;
								}
							}
							if (i+1!=n){
								if (chairs[i+1]=='A'){
									continue;
								}
							}
							v=i;
							break;
						}
					}
					if (v!=-1){
						chairs[v]='B';
					}else{
						REP(i,n){
							if (chairs[i]=='#'){
								chairs[i]='B';
								break;
							}
						}
					}
					break;
				}
				case 'C':{
					if (i==0){
						if (n%2==1){
							chairs[(n+1)/2-1]='C';
						}else{
							chairs[n/2]='C';
						}
					}else{
						REP(i,n){
							if (chairs[i]!='#'){
								if (i+1!=n && chairs[i+1]=='#'){
									chairs[i+1]='C';
									break;
								}
								if (i!=0 && chairs[i-1]=='#'){
									chairs[i-1]='C';
									break;
								}
							}
						}
					}
					break;
				}
				case 'D':{
					int a=0,d=dist(0);
					FOR(i,1,n){
						if (dist(i)>d){
							a=i;
							d=dist(i);
						}
					}
					chairs[a]='D';
					break;
				}
				}
			}
			cout<<chairs<<endl;
		}
	}while(n || m);
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
int main(void){
    int m, f, r, sum;
    
    while(1){
        scanf("%d %d %d\n", &m, &f, &r);
        sum = m + f;
        
        if(m<0 && f<0 && r<0){
            break;
        }
        
        if(m<0 || f<0){
            printf("F\n");
        }else if(80 <= sum){
            printf("A\n");
        }else if(65 <= sum && sum < 80){
            printf("B\n");
        }else if(50 <= sum && sum < 65){
            printf("C\n");
        }else if(30 <= sum && sum < 50){
            if(50 <= r){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else{
            printf("F\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

ll dp[maxN][2];
vector <int> G[maxN];

void DFS(int v, int p = -1){
	dp[v][0] = dp[v][1] = 1;
	for (auto u : G[v]){
		if (u == p) continue;
		DFS(u, v);
		dp[v][0] *= dp[u][0] + dp[u][1];
		dp[v][1] *= dp[u][0];
		dp[v][0] %= MOD;
		dp[v][1] %= MOD;
	}
	return;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i < n; i++){
		int u, v;
		cin >> u >> v;
		u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	DFS(0);
	cout << (dp[0][0] + dp[0][1]) % MOD << endl;
	return 0;
}



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

int main() {
  int x,y; cin >> x >> y;
  string ans = "No";
  rep(i,x+1) {
    rep(j,x+1) {
      if (i+j!=x) continue;
      int sum = 0;
      sum += i * 2;
      sum += j * 4;
      if (sum == y) ans = "Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n; cin >> n;
    // dp[新規追加文字][3文字前][2文字前][1文字前] 0:None 1:A 2:G 3:C 4:Tと置き換える
    vector<vector<vector<vector<ll>>>> dp(n+1, vector<vector<vector<ll>>>(5, vector<vector<ll>>(5, vector<ll>(5))));
    dp[0][0][0][0] = 1;

    for(ll i=0; i<n; i++){
        for(ll j=0; j<5; j++){
            for(ll k=0; k<5; k++){
                for(ll l=0; l<5; l++){
                    for(ll m=1; m<5; m++){
                        // i番目に文字mを採用できる場合の数
                        if(k == 1 && l == 2 && m == 3) continue;
                        if(k == 2 && l == 1 && m == 3) continue;
                        if(k == 1 && l == 3 && m == 2) continue;
                        if(j == 1 && l == 2 && m == 3) continue;
                        if(j == 1 && k == 2 && m == 3) continue;
                        dp[i+1][k][l][m] += dp[i][j][k][l];
                        dp[i+1][k][l][m] %= MODV;
                    }
                }
            }
        }
    }
    // 数え上げ
    ll ans = 0;
    for(ll i=1; i<5; i++){
        for(ll j=1; j<5; j++){
            for(ll k=1; k<5; k++){
                ans += dp[n][i][j][k];
                ans %= MODV;
            }
        }
    }
    cout << ans%MODV << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int memo[100010];

int rec(int n){
  if(n==0)return 0;
  if(memo[n] != -1)return memo[n];

  int res=n;
  for(int p6=1;p6<=n;p6*=6)res=min(res,rec(n-p6)+1);
  for(int p9=1;p9<=n;p9*=9)res=min(res,rec(n-p9)+1);

  return memo[n]=res;
}

signed main(){
  int N;cin>>N;
  memset(memo,-1,sizeof(memo));

  cout<<rec(N)<<"\n";
  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define fi first
#define se second
#define inf 0x3f3f3f3f
using namespace std;
const int N=305;
int n,m,q,l,tot,dis[N][N],head[N],nex[N*N],to[N*N];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
struct node
{
    int x,y;node(int x=0,int y=0):x(x),y(y){}
    bool operator<(const node&o)const{return x==o.x&&y>o.y||x>o.x;}
    node operator+(int o)const
    {
        if(y+o<=l) return node(x,y+o);
        return node(x+1,o);
    }
};
node dp[N][N];
bool vis[N][N];
typedef pair<node,int> pni;
void dijkstra()
{
    for(int j=1;j<=n;j++)
    {
        priority_queue<pni>q;
        q.push({dp[j][j],j});
        while(!q.empty())
        {
            int now=q.top().se;q.pop();
            if(vis[j][now]) continue;
            vis[j][now]=true;
            for(int i=head[now];i;i=nex[i])
            {
                int v=to[i];
                if(dis[now][v]<=l&&dp[j][v]<dp[j][now]+dis[now][v])
                {
                    dp[j][v]=dp[j][now]+dis[now][v];
                    q.push({dp[j][v],v});
                }
            }
        }
    }
}
int main()
{
    scanf("%d%d%d",&n,&m,&l);
    memset(dis,inf,sizeof(dis));memset(dp,inf,sizeof(dp));
    for(int i=1;i<=m;i++)
    {
        int u,v,w;scanf("%d%d%d",&u,&v,&w);
        dis[u][v]=dis[v][u]=min(w,dis[u][v]);
    }
    for(int i=1;i<=n;i++) dp[i][i].x=dp[i][i].y=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
        if(dis[i][j]<=l)
    {
        add(i,j);add(j,i);
    }
    dijkstra();
    scanf("%d",&q);
    while(q--)
    {
        int s,t;scanf("%d%d",&s,&t);
        int ans=dp[s][t].x;if(ans==inf) ans=-1;
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 2904
#include<stdio.h>

int main(){
  int a[3];
  int i, j, n, tmp;
  for (i = 0; i < 3; i++) {
    scanf("%d", &n);
    a[i] = n;
  }
  for (i = 2; i > 0; i--) {
    for (j = 1; j < i+1; j++) {
      if (a[j] < a[j-1]) {
        tmp = a[j];
        a[j] = a[j-1];
        a[j-1] = tmp;
      }
    }
  }
  printf("%d %d %d\n", a[0], a[1], a[2]);
  return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> s(M);
    int ac = 0;
    int wa = 0;
    vector<int> accept(N);
    vector<int> wrong(N);
    int i;
    for(i=0;i<M;i++){
        cin >> p[i] >> s[i];
        int num = p[i];
        if(s[i] == "AC"){
            if(accept[num] == 0){
                ac++;
                accept[num]++;
                wa += wrong[num];
                
            }
        }else{
            wrong[num]++;
        }
    }
    cout << ac <<" " << wa << endl;
    return 0;
}

Measured memory_bytes: 6912
L,R = (int(i) for i in input().split())

tmp = float("inf")
count_i = 0
count_j = 0

for i in range(L,R+1):
    if count_i > 2019:break
    
    count_j = 0
    for j in range(i+1,R+1):
        if count_j >2019:break
        mod = i*j%2019
        if mod<tmp:
            tmp = mod
            
        count_j += 1
    count_i += 1
print(tmp)

Measured memory_bytes: 3064
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int beki6[20],beki9[10];
    beki6[0] = 1;
    beki9[0] = 1;
    REP(i,19) beki6[i+1] = beki6[i] * 6;
    REP(i,9) beki9[i+1] = beki9[i] * 9;
    int dp[n+1];
    REP(i,n+1) dp[i] = INF;
    dp[0] = 0;
    REP(i,n){
        FOR(j,1,6) if(i + j <= n) chmin(dp[i + j], dp[i] + j);
        FOR(j,1,14) if(i + beki6[j] <= n) chmin(dp[i+beki6[j]],dp[i] + 1);
        FOR(j,1,10) if(i + beki9[j] <= n) chmin(dp[i+beki9[j]],dp[i] + 1);
    }
    cout << dp[n] << endl;
}

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using ll = long long;

using namespace std;

void Main() {
  int N;
  cin >> N;
  int a, b, flag = 0;
  cin >> a;
  REP(i, N - 1) {
    cin >> b;
    if (b < a - 1) {
      cout << "No" << endl;
      return;
    }
    if (a < b) flag = 0;
    if (a > b) {
      if (flag == 1) {
        cout << "No" << endl;
        return;
      }
      flag = 1;
    }
    a = b;
  }
  cout << "Yes" << endl;
  return;
}

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

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

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

typedef vector<P> G;

#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
enum { OUT, ON, IN };
int contains(const G& poly, const P& p) {
  bool in = false;
  for (int i = 0; i < poly.size(); ++i) {
    P a = curr(poly,i) - p, b = next(poly,i) - p;
    if (imag(a) > imag(b)) swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b))
      if (cross(a, b) < 0) in = !in;
    if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in ? IN : OUT;
}

int main(){
	G poly;
	P p;
	int n;
	double x,y;
	for(scanf("%d",&n);n--;poly.push_back(p))scanf("%lf%lf",&x,&y),p=P(x,y);
	for(scanf("%d",&n);n--;printf("%d\n",contains(poly,p)))scanf("%lf%lf",&x,&y),p=P(x,y);
}

Measured memory_bytes: 1080
N = int(input())
L1, L2 = [], []
for i in range(N):
  l = list(map(int, input().split()))
  L1.append(l[0]-l[1])
  L2.append(l[0]+l[1])
  
ans = max(max(L1)-min(L1), max(L2)-min(L2))
print(ans)

Measured memory_bytes: 24932
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		if (k * 500 >= x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21712
#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;
}

const long long INF = 1LL << 60;

int N;
long long h[100010];
long long dp[100010];

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> h[i];

    for (int i = 0; i < 100010; i++)
        dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    for (int i = 1; i < N; i++)
    {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1)
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
T = readInts()
sumT = sum(T)
p_ = I()
for i in range(p_):
    p,x = readInts()
    print(sumT - T[p-1] + x)


Measured memory_bytes: 10360
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

const int maxn = 2005;
const int P = 924844033;
int n, k, fact[maxn], dp[2][maxn][2][2];

void update(int &a, int b) {
	a += b;
	(a >= P) && (a -= P);
	(a < 0) && (a += P);
}

int main() {
	scanf("%d %d", &n, &k);
	fact[0] = 1;
	for (int i = 1; i <= 2000; i++) {
		fact[i] = 1ll * fact[i - 1] * i % P;
	}
 	int cur = 0, nxt = 1;
 	dp[0][0][1][0] = 1;
	for (int x = 1; x <= k; x++) {
		for (int j = x; j <= n; j += k) {
			memset(dp[nxt], 0, sizeof(dp[nxt]));
			for (int i = 0; i <= n; i++) {
				for (int v0 = 0; v0 < 2; v0++) {
					for (int v1 = 0; v1 < 2; v1++) {
						if (dp[cur][i][v0][v1]) {
							if (j + k > n) {
								update(dp[nxt][i][1][0], dp[cur][i][v0][v1]);
								if (v0 == 0) {
									update(dp[nxt][i + 1][1][0], dp[cur][i][v0][v1]);
								}
							} else {
								update(dp[nxt][i][v1][0], dp[cur][i][v0][v1]);
								if (v0 == 0) {
									update(dp[nxt][i + 1][v1][0], dp[cur][i][v0][v1]);
								}
								update(dp[nxt][i + 1][v1][1], dp[cur][i][v0][v1]);
							}
						}
					}
				}
			}
			swap(cur, nxt);
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		int temp = 0;
		for (int v0 = 0; v0 < 2; v0++) {
			for (int v1 = 0; v1 < 2; v1++) {
				update(temp, dp[cur][i][v0][v1]);
			}
		}
		temp = 1ll * temp * fact[n - i] % P;
		if (i & 1) {
			update(ans, -temp);
		} else {
			update(ans, temp);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn dfs(x: i64, N: i64) -> i64 {
    if x > N {
        0
    } else {
        let s = x.to_string();
        let mut ret = if s.contains(&"3") && s.contains(&"5") && s.contains(&"7") {1} else {0};
        for &n in [3, 5, 7].iter() {
            ret += dfs(x*10 + n, N);
        }
        ret
    }
}

fn main() {
    let N: i64 = read_line().parse().unwrap();
    println!("{}", dfs(0, N));
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
int a[1<<18];
int main(){
    int m,i,n,s1,s2,j,ans=0;
    scanf("%d",&n);
    m=1<<n;
    for(i=0;i<m;i++) scanf("%d",&a[i]);
    for(i=1;i<m;i++){
        s1=a[0];s2=0;
        for(j=i;j;j=(j-1)&i){
            if(a[j]>s1) s2=s1,s1=a[j];
            else if(a[j]>s2) s2=a[j];
        }
        ans=max(ans,s1+s2);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4096
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto n = readLong();
    auto a = readLongs();

    a.sort().reverse();

    long w, h;
    for(long i = 0; i < n-1; ++i) {
        if(a[i] == a[i+1]) {
            if(w == 0) {
                w = a[i];
            } else {
                h = a[i];
                break;
            }
            ++i;
        }
    }
    writeln(w * h);
}



Measured memory_bytes: 4524
import math
N, D = list(map(int, input().rstrip().split()))

ll = []
for i in range(N):
    l = [int(i) for i in input().rstrip().split()]
    ll.append(l)

num = 0
for i in range(N - 1):
    for j in range(i + 1, N):
#        print('i={}, j={}'.format(i, j))
        la = ll[i]
        lb = ll[j]
        x = 0
        for k in range(D):
            v = la[k] - lb[k]
            x = x + v ** 2

#        print(math.sqrt(x))
        if math.sqrt(x).is_integer():
            num = num + 1

print(num)


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 4005*4005;

/* ...o(^-^)o... */

typedef pair<string, string> item;

int main(){
    int n; cin >> n;
    string _s; cin >> _s;
    string s = _s.substr(0, n), t = _s.substr(n);
    reverse(all(t));

    map<item, lint> mp;
    rep(bit, (1<<n)){
        string x, y;
        rep(i, n){
            if(bit&(1<<i)) x += s[i];
            else y += s[i];
        }
        item it(x,y); mp[it]+=1;
    }

    lint ans = 0;
    rep(bit, (1<<n)){
        string x, y;
        rep(i, n){
            if(bit&(1<<i)) x += t[i];
            else y += t[i];
        }
        item it(x,y); ans += mp[it];
    }
    out(ans);
}


Measured memory_bytes: 91904
s = input()
if len(s)%2!=1:
    print('No')
else:
    res = False
    n = len(s)
    
    t = s[:(n-1)//2]
    u = s[(n+3)//2-1:]
    
    if s==s[::-1]:
        if t==t[::-1]:
            if u==u[::-1]:
                res = True
    print('Yes' if res else 'No')

Measured memory_bytes: 3064
implicit none
integer:: n,i
integer,allocatable,dimension(:):: d
integer,dimension(100):: count

read(5,*) n
allocate(d(n))

count=0

do i=1,n
    read(5,*) d(i)
    count(d(i))=1
enddo

write(6,*) sum(count)

end


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

int main() {
  int n;
  std::cin >> n;
  
  for (int i = 0; i <= n / 7; i++) {
    if ((n - 7 * i) % 4 == 0) {
      std::cout << "Yes\n";
      return 0;
    }
  }
  std::cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, n;
    cin >> h >> n;
    while(n--) {
        int x;
        cin >> x;
        h -= x;
    }
    cout << (h > 0 ? "No" : "Yes") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int par[100005];

int find(int x)
{
    if (x == par[x])
        return x;

    return par[x] = find(par[x]);
}

void merge(int x, int y)
{
    x = find(x);
    y = find(y);

    par[x] = y;
}

vector<int> lang[100005];

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

    for (int i = 1; i <= n; i++)
    {
        par[i] = i;

        int k;
        scanf("%d", &k);

        for (int j = 0; j < k; j++)
        {
            int l;
            scanf("%d", &l);
            lang[l].push_back(i);
        }
    }

    for (int l = 1; l <= m; l++)
    {
        for (int i = 1; i < lang[l].size(); i++)
            merge(lang[l][i - 1], lang[l][i]);
    }

    if (all_of(par + 1, par + n + 1, [](int k) { return find(k) == find(1); }))
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}

Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

int n,m;
vector<P>to[100005];
vector<ll>dist(100005,LLONG_MAX);
ll solve(){
    priority_queue<P,vector<P>,greater<P>>pq;
    dist[0]=0;
    pq.push(P(0,0));
    while(pq.size()>0)
    {
        P cur=pq.top();pq.pop();
        ll d=cur.first;
        ll u=cur.second;
        if(d>dist[u])continue;

        for(P nx:to[u]){
            ll duv=nx.first;
            ll v=nx.second;
            if(dist[v]>d+duv){
                dist[v]=d+duv;
                pq.push(P(dist[v],v));
            }
        }
    }
     return dist[n-1]==LLONG_MAX?-1:dist[n-1];
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);

cin>>n>>m;
rep(i,m){
    ll l,r,c;
    cin>>l>>r>>c;
    --l,--r;
    to[l].push_back(make_pair(c,r));
}
for(int j=0;j<n;j++){
        to[j+1].push_back(make_pair(0,j));
    }
cout<<solve()<<endl;
return 0;
}

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

using namespace std;

int main()
{
    int n,k;

    cin>>n>>k;
    vector<int> v(n),dp(n+k+1);

    for(int i=0;i<n;i++)
        cin>>v[i];

    dp[0]=0;

    for(int i=1;i<=n;i++)
        dp[i]=INT_MAX;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
            if(j<n) dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
            //cout <<"j "<<j<<" "<<dp[j]<<endl;
        }
    }

    cout <<dp[n-1]<<endl;

    return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int lmax = 1;
        int rmin = n;

        for(int i=0; i<m; i++) {
            lmax = Math.max(lmax, sc.nextInt());
            rmin = Math.min(rmin, sc.nextInt());
        }

        if(lmax > rmin) {
            System.out.println(0);
        } else {
            System.out.println(rmin - lmax + 1);
        }

    }

}


Measured memory_bytes: 62828
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> g(n);
  REP(i, m) {
    ll x, y;
    cin >> x >> y;
    x--, y--;
    g[x].push_back(y);
  }  

  vector<ll> dp(n, -1);
  function<ll(ll)> dfs = [&](ll v) {
    // cout << v << endl;
    if(dp[v] != -1) return dp[v];
    ll ret = 0;
    for(auto to: g[v]) {
      chmax(ret, dfs(to) + 1);
    }
    return dp[v] = ret;
  };

  ll ans = 0;
  REP(i, n) chmax(ans, dfs(i));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9216
import sys
input = sys.stdin.readline
n = int(input())
a = [0]+list(map(int, input().split( )))
tmp = 0
cnt =0
if 1 not in a:
    print(-1)
    exit()
for i in range(n+1):
    while tmp <= n and a[tmp]!=i:##<=
        tmp += 1
        cnt += 1
        #print(i,tmp,cnt)
    tmp += 1
    if tmp > n:##>
        break


print(cnt)


Measured memory_bytes: 73804
import sys


def resolve():
    """
    全パターンは2**12=4096通りだからbit全探索
    消さない行列だけ判定するコードの方がスマート？(解説動画より)
    """

    readline = sys.stdin.readline    # 1行だけ文字列にする

    H, W, K = map(int, readline().split())
    c = [list(readline().strip()) for _ in [0] * H]
    ans = 0

    # bit全探索
    for bit_i in range(1 << H):
        for bit_j in range(1 << W):
            cnt = 0
            for i in range(H):
                for j in range(W):
                    if (1
                            and bit_i & (1 << i)
                            and bit_j & (1 << j)
                            and c[i][j] == '#'):
                        cnt += 1
            if cnt == K:
                ans += 1
    print(ans)


resolve()

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> cnt(N);
  for (int i = 0; i < N - 1; i++) {
    int a;
    cin >> a;
    a--;
    cnt[a]++;
  }
  for (int i = 0; i < N; i++) {
    cout << cnt[i] << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3988
x, n = map(int, input().split())
p = set(map(int, input().split()))

if x not in p:
   print(x)
   exit()

for i in range(1, 200):
   if x - i not in p:
      print(x - i)
      exit()
   elif x + i not in p:
      print(x + i)
      exit()



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

int		main(void)
{
	ll		a, b, c, d;
	cin >> a >> b >> c;

	d = c - a - b;
	if (d * d > 4 * a * b && c - a - b > 0)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 256