akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

i64 gcd(i64 a, i64 b) { return b ? gcd(b, a % b) : a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  i64 A, B, C, D;
  cin >> A >> B >> C >> D;

  // A以上B以下の整数のうち、xで割り切れるものの数
  auto cd = [&](i64 x) {
    i64 a = A / x, b = B / x;
    if (A % x) a ++;
    return b - a + 1;
  };

  i64 result = B - A + 1 - cd(C) - cd(D) + cd(::lcm(C, D));
  cout << result;
}
#endif


Measured memory_bytes: 3640
#coding:utf-8

n = int(input())
a = input().split()

list_n = [0 for i in range(n)]
basic = 0

for i in a:
    aa = int(i)
    count = list_n[aa - 1]
    basic += count
    list_n[aa - 1] += 1

ans = 0
for i in range(n):
    ans = 0
    a1 = int(a[i])
    ans = basic - list_n[a1 - 1] + 1
    print("{}".format(int(ans)))

Measured memory_bytes: 21676
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << " ";
    if(a + b > n)
    {
        cout << a + b - n << "\n";
    }
    else
    {
        cout << "0\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;(i) < (int)(n);i++)
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(m);
    vector<int> c(m);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,m){
        cin >> b[i] >> c[i];
    }
    priority_queue<pair<int ,int> > q;
    rep(i,n) {
        q.push(make_pair(a[i],1));
    }
    rep(i,m){
        q.push(make_pair(c[i], b[i]));
    }
    long long ans = 0;
    rep(i,n){
        auto p = q.top();
        q.pop();
        ans += p.first;
        if(p.second > 1){
            p.second--;
            q.push(p);
        }
    }
    printf("%lld\n",ans);
}

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

long long combo(int a, int b)
{
  if(b*2 > a) b = a-b;
  int i;
  long long ans = 1;
  for(i = 1; i <= b; i++)
  {
    ans = ans * (a+1-i)/i;
  }
  return ans;
}

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  vector<long long> v(n);
  int i, k;
  for(i = 0; i < n; i++)
  {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  long long sum = 0;
  for(i = 0; i < a; i++)
  {
    sum += v.at(i);
  }
  double average = sum/(double)a;
  cout << fixed << setprecision(10) << average << endl;
  long long ans = 0;
  for(k = a; k <= b; k++)
  {
    int count = 0;
    int check = -1;
    for(i = 0; i < n; i++)
    {
      if(v.at(i) == v.at(k-1))
      {
        count++;
        if(check == -1)
        {
          check = i;
        }
      } 
    }
    ans += combo(count, k-check);
    if(k != b)
    {
      if(v.at(k) < v.at(0))break;
    }
  } 
 cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

ll h,w,k;
ll mod=INF;
ll amida[101][10]={0};
bool used[8]={0};
ll bri[10][10]={0};

void cal(int t=1){   //縦tと縦t+1を繋ぐ橋tについて
    if(t==w){
        for(int i=1;i<=w-1;i++){
            if(used[i]&&used[i+1])return;
        }
        for(int i=0;i<=w-1;i++){
            if(used[i]){
                bri[i][i+1]++;
                bri[i+1][i]++;
            }else if(!used[i]&&!used[i+1]){
                bri[i+1][i+1]++;
            }
        }
        
    }else{
        used[t]=true;
        cal(t+1);
        used[t]=false;
        cal(t+1);
    }
    
    return;
}



int main(){
    
    cin >> h>> w>>k;
    
    amida[0][1]=1;
    
    cal();
    
    for(int i=0;i<h;i++){
        for(int j=1;j<=w;j++){
            for(int k=-1;k<2;k++){
                amida[i+1][j+k]=(amida[i+1][j+k]+amida[i][j]*bri[j][j+k])%mod;
            }
        }
    }
    
    
    
    cout << amida[h][k]<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int a=sc.nextInt();
			int b=sc.nextInt();
			int n=sc.nextInt();
			System.out.println(sum(a%b*10,b,n));
		}
	}
	static int sum(int a,int b,int n){
		if(n==0){
			return 0;
		}else{
			return sum(a%b*10,b,n-1)+a/b;
		}
	}
}

Measured memory_bytes: 20080
#include <stdio.h>

int main(void)
{
	int mon, date;
	int i, n;
	int d[12];
	
	d[0] = 0;
	d[1] = 31;
	d[2] = d[1] + 29;
	d[3] = d[2] + 31;
	d[4] = d[3] + 30;
	d[5] = d[4] + 31;
	d[6] = d[5] + 30;
	d[7] = d[6] + 31;
	d[8] = d[7] + 31;
	d[9] = d[8] + 30;
	d[10] = d[9] + 31;
	d[11] = d[10] + 30;
	
	while (1){
		
		scanf("%d %d", &mon, &date);
		
		if (mon == 0 && date == 0){
			break;
		}
		
		n = d[mon-1] + date;
		n = n % 7;
		
		switch (n){
			case 1:
			puts("Thursday");
			break;
			
			case 2:
			puts("Friday");
			break;
			
			case 3:
			puts("Saturday");
			break;
			
			case 4:
			puts("Sunday");
			break;
			
			case 5:
			puts("Monday");
			break;
			
			case 6:
			puts("Tuesday");
			break;
			
			case 0:
			puts("Wednesday");
			break;
		}
	}
	return (0);
}

Measured memory_bytes: 584
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val n = jin.readLine().toInt()
    val xs = IntArray(n + 1)
    val ys = IntArray(n + 1)
    for (j in 1..n) {
        val (x, y) = jin.readLine().split(" ").map { it.toInt() }
        xs[j] = x
        ys[j] = y
    }
    val zs = (1..n).sortedBy { xs[it] }
    val union = IntArray(n + 1) { it }
    val uStack = Stack<Int>()
    fun getUnion(u: Int): Int {
        uStack.push(u)
        while (union[uStack.peek()] != union[union[uStack.peek()]]) {
            uStack.push(union[uStack.peek()])
        }
        val v = union[uStack.pop()]
        while (uStack.isNotEmpty()) {
            union[uStack.pop()] = v
        }
        return v
    }
    val stack = Stack<Int>()
    for (z in zs) {
        val m = if (stack.isEmpty() || ys[z] < ys[stack.peek()]) z else stack.peek()
        while (stack.isNotEmpty() && ys[z] > ys[stack.peek()]) {
            union[getUnion(stack.pop())] = getUnion(z)
        }
        stack.push(m)
    }
    val amts = IntArray(n + 1)
    for (j in 1..n) {
        amts[getUnion(j)]++
    }
    val joiner = StringJoiner("\n")
    for (j in 1..n) {
        joiner.add(amts[getUnion(j)].toString())
    }
    println(joiner)
}

Measured memory_bytes: 71088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T = "CODEFESTIVAL2016";
  cin >> S;
  int count = 0;
  for(int i = 0; i < S.length(); i++){
  	if(S.at(i) != T.at(i)){
    	count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
#define INF 9999999999999999
using namespace std;

void solve()
{
   int n,w;
   cin>>n>>w;
   vector<vector<int> > v(n, vector<int>(2));
   vector<vector<int>> dp(n+1, vector<int>(100002,INF));
   // memset(dp,-1,sizeof dp);

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

   dp[0][0]=0;


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

    for(int j=0;j<=100000;j++)
    {
        if(dp[i-1][j]!=INF)
          dp[i][j]=dp[i-1][j];

        if(j-v[i-1][1]>=0)
          dp[i][j] = min(dp[i][j],dp[i-1][j-v[i-1][1]]+v[i-1][0]);  
    }


   }

   int ans = INT_MIN;
   
   for(int i = 100000;i>=0;i--)
   {
    bool flag=true;
    for(int j=0;j<=n;j++)
      if(dp[j][i]<=w)
      {
        cout<<i<<endl;
        flag=false;
        break;
      }
      if(flag==false)
        break;
   }





}
signed main()

{
    FAST_IO;
    int t = 1;

    // cin>>t;

    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 80256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> val2Pos(N+1);
    for (decltype(N) i = 1; i <= N; ++i) {
        int64_t t;
        std::cin >> t;
        val2Pos[t] = i;
    }

    std::set<int64_t> smallerPos;
    smallerPos.insert(0);
    smallerPos.insert(N+1);
    int64_t ans = 0;
    for (int64_t i = 1; i <= N; ++i) {
        auto val = i;
        auto pos = val2Pos[val];

        auto itr = smallerPos.upper_bound(pos);
        auto r = *itr;
        auto l = *(--itr);

        ans += i * (pos - l) * (r - pos);
        smallerPos.insert(pos);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 11136
local w,h,n=io.read("*n","*n","*n")
local rectangle={}
for i=1,h do
    rectangle[i]={}
    for j=1,w do
        rectangle[i][j]=1
    end
end
for i=1,n do
    local x,y,a=io.read("*n","*n","*n")
    if a==1 then
        for j=1,h do
            for k=1,x do
                rectangle[j][k]=0
            end
        end
    end
    if a==2 then
        for j=1,h do
            for k=x+1,w do
                rectangle[j][k]=0
            end
        end
    end
    if a==3 then
        for j=1,y do
            for k=1,w do
                rectangle[j][k]=0
            end
        end
    end
    if a==4 then
        for j=y+1,h do
            for k=1,w do
                rectangle[j][k]=0
            end
        end
    end
end

local total=0
for i=1,h do
    for j=1,w do
        total=total+rectangle[i][j]
    end
end
print(total)

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

int main() {
  	string s;
  	cin >> s;
  	int n = s.size();
  	int st=0;
  	for(int i = 0; i<s.size();i++) {
    	if(s[i] == 'S')
          	st++;
      	else if(st > 0) {
        	st--;
          	n-=2;
        }
    }
  	cout << n << endl;
}

Measured memory_bytes: 640
N = int(input())
a_list = [0] + list(map(int,input().split()))

m = 0
# あとで先頭削除
b_list = [0 for _ in range(N+1)]

result_list = []

for i in range(N,0,-1):
    tmp = 0
    for j in range(i+i, N+1, i):
#         print(j)
        tmp += b_list[j]
#     print(b_list)
    
    # これまでの結果（右側）とあまりが一致してない時は1にする
    if not tmp%2 == a_list[i]:
        b_list[i] = 1
        result_list.append(i)
        m += 1

print(m)
if m > 0:
    print(" ".join(map(str,result_list)))

Measured memory_bytes: 83560
#include <bits/stdc++.h>
using namespace std;
#define lint long long
#define P pair<int, int>

bool x_dp[8001][16002]; //x_dp[移動回数][位置]
bool y_dp[8001][16002]; //y_dp[移動回数][位置]

int main(){
    string s;
    cin >> s;
    
    memset(x_dp, false, sizeof x_dp);
    memset(y_dp, false, sizeof y_dp);
    x_dp[0][8001] = true;
    y_dp[0][8001] = true;
    
    int x, y;
    
    cin >> x >> y;
    
    vector<int> X = {0}, Y = {0};
    
    int cnt = 0;
    bool now = true; //trueでx方向
    
    for(int i = 0; i < s.length(); ++i){
        if(s[i] == 'F'){
            if(now){
                X[cnt]++;
            } else {
                Y[cnt]++;
            }
        } else {
            if(!now){
                cnt++;
                X.push_back(0);
                Y.push_back(0);
            }
            now = !now;
        }
        
    }
    
    x_dp[1][X[0] + 8001] = true;
    
    for(int i = 1; i <= cnt; ++i){
        for(int j = 0; j < 16002; ++j){
            if(j + X[i] <= 16002 && x_dp[i][j + X[i]]){
                x_dp[i + 1][j] = true;
            }
            if(j - X[i] >= 0 && x_dp[i][j - X[i]]){
                x_dp[i + 1][j] = true;
            }
        }
    }
    
    for(int i = 0; i <= cnt; ++i){
        for(int j = 0; j < 16002; ++j){
            if(j + Y[i] < 16002 && y_dp[i][j + Y[i]]){
                y_dp[i + 1][j] = true;
            }
            if(j - Y[i] >= 0 && y_dp[i][j - Y[i]]){
                y_dp[i + 1][j] = true;
            }
        }
    }
    
    
    if(x_dp[cnt + 1][x + 8001] && y_dp[cnt + 1][y + 8001]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 250496
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
	long long n, k; cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	
    long long ans = 0;
	for (int i = 0; i < n; ++i) {
        long long tmp = 0, tmp1 = 0;
		for (int j = 0; j < n; ++j) {
			if (a[i] > a[j]){
                tmp1 += 1;
                if(i<j){
                    tmp += 1;
                }
            }
            
		}
        ans += ((tmp * k) % MOD + (tmp1 * ((k * (k - 1) / 2) % MOD))) % MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <ostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using ll = long long;
using ld = long double;
//typedef long long ll;

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

#define INF ((1LL << 31) - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD (ll)(1e9+7)
#define EPS 1e-10
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define P "Yes"
#define NP "No"

template <typename T>
std::ostream& operator << (std::ostream& os, std::vector<T> v) {
  os << "[";
  for (int i = 0; i < int(v.size()); ++i) {
    cout << v[i] << (i == v.size() - 1 ? "]" : ", ");
  }
  return os;
}

int vx[4] = { -1, 0, 1, 0 }, vy[4] = { 0, -1, 0, 1 };
//int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

// [sx, se), [sy, ey)であることに注意
inline bool check(int sx, int ex, int sy, int ey, int x, int y) {
  return (sx <= x and x < ex and sy <= y and y < ey);
}

inline bool check(int ex, int ey, int x, int y) {
  return check(0, ex, 0, ey, x, y);
}

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

void solve() {
  int c[3][3];

  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> c[i][j];
    }
  }

  for (int i = 0; i <= 100; ++i) {
    for (int j = 0; j <= 100; ++j) {
      for (int k = 0; k <= 100; ++k) {
        int b[3] = { c[0][0] - i , c[0][1] - i, c[0][2] - i };

        if (b[0] == c[1][0] - j && b[0] == c[2][0] - k &&
          b[1] == c[1][1] - j && b[1] == c[2][1] - k &&
          b[2] == c[1][2] - j && b[2] == c[2][2] - k) {
          cout << P << endl;
          return;
        }
      }
    }
  }

  cout << NP << endl;
  return;
}

int main() {

  solve();

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, N);
  invar(ll, K);
  invar(int, Q);
  vi A(Q);
  vi points(N, K - Q);
  rep(i, Q) {
    cin >> A[i];
    --A[i];
    points[A[i]]++;
  }
  
  rep(i, N) {
    if(points[i] <= 0) {
      fin("No");
    } else {
      fin("Yes");
    }
  }
  
}

Measured memory_bytes: 1408
n, m = list(map(int, input().split()))
adj = [[] for _ in range(n+1)]
for i in range(m):
    ab = list(map(int, input().split()))
    adj[ab[0]].append(ab[1])
    adj[ab[1]].append(ab[0])

s = 1
stack = []
ans = 'IMPOSSIBLE'
if adj[s]:
    stack.extend(adj[s])
    for nextild in stack:
        if n in adj[nextild]:
            ans = 'POSSIBLE'
            break
print(ans)
    

Measured memory_bytes: 50864
using System;

namespace PluralForm
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int lenS = S.Length;

            if (S[lenS - 1] == 's')
            {
                S += "es";
            }
            else
            {
                S += 's';
            }

            Console.WriteLine(S);
        }
    }
}


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

using namespace std;

int dp[20][1000];
void Init(){
  for(int i=0;i<=10;i++)for(int j=0;j<1000;j++)dp[i][j]=0;
 
  for(int i=0;i<=9;i++){
    dp[0][i]++;	
    for(int j=0;j<=9;j++){
      if(i == j)continue;
      dp[1][i+j*2]++;
      for(int k=0;k<=9;k++){
	if(k==i||k==j)continue;
	dp[2][i+j*2+k*3]++;
	for(int l=0;l<=9;l++){
	  if(l==i||l==j||l==k)continue;
	  dp[3][i+j*2+k*3+l*4]++;
	  for(int m=0;m<=9;m++){
	    if(m==i||m==j||m==k||m==l)continue;
	    dp[4][i+j*2+k*3+l*4+m*5]++;
	    for(int n=0;n<=9;n++){
	      if(n==i||n==j||n==k||n==l||n==m)continue;
	      dp[5][i+j*2+k*3+l*4+m*5+n*6]++;
	      for(int o=0;o<=9;o++){
		if(o==i||o==j||o==k||o==l||o==m||o==n)continue;
		dp[6][i+j*2+k*3+l*4+m*5+n*6+o*7]++;
		for(int p=0;p<=9;p++){
		  if(p==i||p==j||p==k||p==l||p==m||p==n||p==o)continue;
		  dp[7][i+j*2+k*3+l*4+m*5+n*6+o*7+p*8]++;
		  for(int q=0;q<=9;q++){
		    if(q==i||q==j||q==k||q==l||q==m||q==n||q==o||q==p)continue;
		    dp[8][i+j*2+k*3+l*4+m*5+n*6+o*7+p*8+q*9]++;
		    for(int r=0;r<=9;r++){
		      if(r==i||r==j||r==k||r==l||r==m||r==n||r==o||r==p ||r==q)continue;
		      dp[9][i+j*2+k*3+l*4+m*5+n*6+o*7+p*8+q*9+r*10]++;
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
    }
  }
  // cout << maxx << endl;
}

int main(){
  int n,s;
  Init();
    while(cin >> n >> s){
      if(n == 0){
	if(s == 0)cout << "1" << endl;
	else cout << "0" << endl;
      }
      else cout << dp[n-1][s] << endl;
    }
  return 0;
}

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

lis = []

alps = "abcdefghijklmnopqrstuvwxyz"

for alp in alps:

    for i in range(len(s)):

        #print (s[i],alp)
        if s[i] == alp:

            #print ("ループ北")

            for j in range(6):

                j += 1
                #print (i+ j)
                #print (s[i:i+j] in lis,s[i:i+j],lis)
                if i + j <= len(s) and (s[i:i+j] not in lis):
                    #print ("来た！！")
                    lis.append(s[i:i+j])

    if len(lis) >= K:
        break


lis.sort()

#print (lis)
print (lis[K - 1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
	
typedef long long ll;
typedef unsigned long long ull;
typedef long double db;
	
#define MOD 1000000007
#define mini 18446744073709551615
#define ff first
#define ss second
#define pb push_back
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T=1;
	//cin>>T;
	while(T--)
	{
		ll n,ans=1,n9=1,b=1;
		cin>>n;
		if(n==1)
			cout<<"0";
		else
		{
			for(int i=0;i<n;i++)
			{
				ans=(ans*10)%MOD;
				n9=(n9*9)%MOD;
				b=(b*8)%MOD;
			}
			cout<<(ans-2*n9+b+2*MOD)%MOD;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int hito = y + z;
		x = x - z;
		System.out.println(x / hito);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*

*/
int main(){
  ll a,ans=0; cin>>a;
  ans = a+a*a+a*a*a;
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long double ll;

using pint = pair<ll, ll>;
int N;
vector<pint> v;

int main() {
  cin >> N;
  v.resize(N);
  for (int i = 0; i<N; i++){
    cin >> v[i].first >> v[i].second;
  }
  int P[N];
  for (int i = 1; i < N+1; i++) P[i-1] = i;
  ll total = 0;
  ll cnt = 0;
  do {
    for (int i = 0; i < N-1; i++){
      total += sqrt((v[P[i]-1].first - v[P[i + 1]-1].first) * (v[P[i]-1].first - v[P[i + 1]-1].first)+(v[P[i]-1].second - v[P[i + 1]-1].second)*(v[P[i]-1].second - v[P[i+1]-1].second));
    }
    cnt++;
  } while (next_permutation(P, P + N));
  //cout << total << ' ' << cnt <<endl;
  cout << fixed<<setprecision(6)<<total / cnt << endl;
  return 0;
}

Measured memory_bytes: 3856
package main

import "fmt"

func main() {
	var input string
	fmt.Scan(&input)

	ans := ""

	for _, r := range input {
		switch r {
		case '0':
			ans += "0"
		case '1':
			ans += "1"
		case 'B':
			length := len(ans)
			if length > 0 {
				ans = ans[:length-1]
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
function Main(input){
  var inputs = input.split("");
  var a = [];
  function Func(n,sum){
    if(n == 0){
      if(sum == 0){
        return true;}
    }else{
      if(Func(n-1,sum+new Number(inputs[n-1])) == true){
        a[n-1] = "-";
        return true;
      }else if(Func(n-1,sum-new Number(inputs[n-1])) == true){
        a[n-1] = "+";
        return true;
      }else{
        return false;
      }
    }
  }  
  if(Func(4,7) == true){
    console.log(inputs[0] + a[1] + inputs[1] + a[2] + inputs[2] + a[3] + inputs[3] + "=7" );
  }else{
    console.log("program error");
  }  
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

int n, A[50];
int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i+1, m) || solve(i+1, m - A[i]);
    return res;
}


int main() {

    int q, m;


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

    cin >> q;

    for (int i = 0; i<q; i++) {
	cin >> m;
	if (solve(0, m)) cout << "yes" << endl;
	else cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    int s = 0;
    for (int i = 0; i < m; ++i)
    {
        int x;
        cin >> x;
        s += x;
    }
    if (s > n)
        cout << "-1";
    else
        cout << n - s;
    return 0;
}


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

int main() {
    int T;
    cin >> T;
    for(;T>0;T--){
        vector<int> a;
        for(int x=1; x!=0;){
            cin >> x;
            if(x!=0) a.push_back(x);
        }
        int m = 1;
        stack<int> st;
        vector<int> deg, depth;
        vector<vector<int> > g;
        st.push(0);
        depth.push_back(0);
        deg.push_back(a[0]);
        g.push_back({});
        a.erase(a.begin());
        for(auto x : a){
            int prev = st.top();
            if(x > 0){
                deg.push_back(x);
                depth.push_back(depth[prev]+1);
                g.push_back({});
                g[m].push_back(prev);
                g[prev].push_back(m);
                deg[m]--;
                deg[prev]--;
                st.push(m);
                m++;
            }
            else{
                for(int i=0;i<m;i++){
                    if(depth[i]==depth[prev]+x && deg[i]>0){
                        g[i].push_back(prev);
                        g[prev].push_back(i);
                        deg[i]--;
                        deg[prev]--;
                        break;
                    }
                }
            }
            while(!st.empty() && deg[st.top()]==0) st.pop();
        }
        for(int i=0;i<m;i++){
            cout << i+1;
            sort(g[i].begin(), g[i].end());
            for(auto x : g[i]){
                cout << ' ' << x+1;
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3048
#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{
  int W, H, x, y; cin >> W >> H >> x >> y;

  cout << fixed << setprecision(10) << ((double)W*(double)H)/2 << " ";
  cout << ((W == x*2 && H == y*2) ? 1 : 0) << endl;
  
  return 0;
}


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

int ne(int n){
  int  k=1;
  for(int i=1; i<=n;i++)k*=i;
  return k;
}
int f(vector<int> &v,int n){
  vector<int> v1={1,2};
  vector<int> v2={2,1};
  if(v==v1){return 1;}
  if(v==v2){return 2;}
  
  int a=(v.at(0)-1)*ne(n-1);
  rep(i,v.size()){
    if(v.at(i)>v.at(0))v.at(i)--;}
  v.erase(v.begin());
  int g=f(v,n-1);
  return g+a;
  
}
int main() {

  int n,r,s; cin>>n;
  vector<int> p(n),q(n);
  rep(i, n){cin>>p.at(i)/*r;p.push_back(r)*/;}
  rep(i, n){cin>>q.at(i)/*s;p.push_back(s)*/;}
  int ans=f(p,n)-f(q,n);
  cout<<(ans>0 ? ans:-ans);
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int A, B, X; cin >> A >> B >> X;
    if(A <= X && X <= A + B) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())


int main(){
    lli money=100,x; cin>>x;
    int year=0;
    while(1){
        money*=1.01;
        year++;
        if(money>=x) break;
    }
    cout<<year<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[10000][2][5];
string s;
int n,k;
ll f(int len,bool tight,int cnt)
{
    if(cnt>k) return 0;
    if(len==n) return (cnt==k);
    if(dp[len][tight][cnt]!=-1) return dp[len][tight][cnt];
    ll ans=0;
    for(int i=0;i<10;i++)
    {
        if(tight && i>(s[len]-'0')) break;
        ans+=f(len+1,tight&(s[len]-'0'==i),cnt+(i!=0));
    }
    return dp[len][tight][cnt]=ans;
    
}

int main()
{
    cin>>s>>k;
    n=s.length();
    memset(dp,-1,sizeof(dp));
    ll ans=f(0,1,0);
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;

int main(){
    int n, k; cin >> n >> k;
    int sum = 0, res = 1e9;
    for(int i = 1; i <= n; i++)
        sum += i + k - 1;
    // cout << sum << endl;
    for(int i = 1; i <= n; i++)
        if(abs(res - sum) > abs(sum - (sum - (i + k - 1))))
            res = sum - (i + k - 1);
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
A=[input() for i in range(n)]
B=[input() for i in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            # print(i,j,k)
            if A[i+k][j:j+m] != B[k]:
                break
        else:
            print("Yes")
            exit()
        # print(i,j)
        continue
print("No")

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

int main() {
  int a,b;
  cin >>a>>b;
  if(a>b){
      cout<<"a > b"<<endl;
  }else if(a<b){
      cout<<"a < b"<<endl;
  }else if(a==b){
      cout<<"a == b"<<endl;
  }
}


Measured memory_bytes: 3116
N = int(input())
P = [int(x) for x in input().split()]

cnt = 0
for i in range(N-1):
  if P[i] == i+1:
    P[i],P[i+1] = P[i+1],P[i]
    cnt += 1

if P[-1] == N:
  cnt += 1

print(cnt)

Measured memory_bytes: 13880
N,M = map(int,input().split())
A = list(map(int,input().split()))

A.sort()

BC = [list(map(int,input().split())) for _ in range(M)]
#変えられるカードを格納
BC_sort = sorted(BC,key=lambda x: x[1])

BC_sort_index = M-1

for i in range(N):
    if BC_sort[BC_sort_index][1] > A[i]:
        A[i] = BC_sort[BC_sort_index][1]
        BC_sort[BC_sort_index][0] -= 1
        if BC_sort[BC_sort_index][0] == 0:
            BC_sort_index -= 1
            if BC_sort_index < 0:
                break

print(sum(A))

Measured memory_bytes: 33732
int main(void)
{
  int n;
  scanf("%d", &n);
  char s[n];
  scanf("%s", s);
  if (n % 2 != 0)
    printf("No");
  else
  {
    int i;
    for (i = 0; i < n / 2; i++)
    {
      if (s[i] != s[i + n / 2])
      {
        printf("No");
        return 0;
      }
    }
    printf("Yes");
  }
}


Measured memory_bytes: 128
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
for i in range(101):
    for j in range(101):
        H = []
        MIN = float('inf')
        for k in range(n):
            if a[k][2] == 0:
                MIN = min(MIN, abs(a[k][0] - i) + abs(a[k][1] - j))
            else:
                H.append(a[k][2] + abs(a[k][0] - i) + abs(a[k][1] - j))
        if len(set(H)) == 1 and H[0] <= MIN:
            print(i, j, H[0])
            exit()


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

int main(void){
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i += 2){
        if(a[i]%2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int d[4];
int s[4];
bool flag[4];

int
calc(int a, int op, int b)
{
	switch (op)
	{
	case 0:
		return a + b;

	case 1:
		return a - b;

	case 2:
	default:
		return a * b;
	}
}

bool
perm(int n, int lv)
{
	int memo[4];
	const char opc[3] = {'+', '-', '*'};
	int i, j;

	flag[n] = true;
	s[lv] = n;

	j = 0;
	for (i = 0; i < 4; ++i)
	{
		if (!flag[i])
			memo[j++] = i;
	}

	if (j == 1)
	{
		s[lv + 1] = memo[0];
		for (i = 0; i < 27; ++i)
		{
			int op1 = i % 3;
			int op2 = (i / 3) % 3;
			int op3 = i / 9;

			if (calc(calc(d[s[0]], op1, calc(d[s[1]], op2, d[s[2]])), op3, d[s[3]]) == 10)
			{
				printf("((%d %c (%d %c %d)) %c %d)\n", d[s[0]], opc[op1], d[s[1]], opc[op2], d[s[2]], opc[op3], d[s[3]]);
				return true;
			}
			else if (calc(calc(d[s[0]], op1, d[s[1]]), op2, calc(d[s[2]], op3, d[s[3]])) == 10)
			{
				printf("((%d %c %d) %c (%d %c %d))\n", d[s[0]], opc[op1], d[s[1]], opc[op2], d[s[2]], opc[op3], d[s[3]]);
				return true;
			}
		}

		flag[n] = false;
		return false;
	}

	for (i = 0; i < j; ++i)
	{
		if (perm(memo[i], lv + 1))
			return true;
	}

	flag[n] = false;
	return false;
}

int
main(int argc, char **argv)
{
	bool res;
	int i;

	while (true)
	{

		scanf("%d %d %d %d", &d[0], &d[1], &d[2], &d[3]);
		if ((d[0] | d[1] | d[2] | d[3]) == 0)
			break;

		for (i = 0; i < 4; ++i)
			flag[i] = false;

		for (i = 0; i < 4; ++i)
		{
			res = perm(i, 0);
			if (res)
				break;
		}

		if (!res)
			printf("0\n");
	}

	return 0;
}

Measured memory_bytes: 612
macro_rules! scan {
    ( $string:expr, $sep:expr, $( $x:ty ),+ ) => {{
        let mut iter = $string.split($sep);
        ($(iter.next().and_then(|word| word.parse::<$x>().ok()).unwrap(),)*)
    }}
}

fn is_cyclic(s: &str) -> bool {
    s.as_bytes()[0] == s.as_bytes()[4] && s.as_bytes()[1] == s.as_bytes()[3]
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let (min, max) = scan!(buf, char::is_whitespace, i32, i32);
    println!("{}", (min..(max + 1))
             .filter(|x| is_cyclic(&x.to_string()))
             .collect::<Vec<_>>().len());
}

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn test_is_cyclic() {
        assert!(is_cyclic("10101"));
        assert!(is_cyclic("10001"));
        assert!(is_cyclic("51415"));
        assert!(!is_cyclic("10100"));
        assert!(!is_cyclic("11332"));
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

char F[512][512];
int R[512][512], B[512][512];

int main() {
  int H = in();
  int W = in();
  for (int i = 0; i < H; ++i) {
    scanf("%s", F[i]);
    R[i][0] = 1;
    B[i][W - 1] = 1;
    for (int j = 0; j < W; ++j) {
      if (j != 0 && j != W - 1) {
        (i % 2 == 0 ? R[i][j] : B[i][j]) = 1;
      }
      if (F[i][j] == '#') {
        R[i][j] = B[i][j] = 1;
      }
    }
  }

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      putchar(".#"[R[i][j]]);
    }
    puts("");
  }

  puts("");

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      putchar(".#"[B[i][j]]);
    }
    puts("");
  }

  return 0;
}


Measured memory_bytes: 2944
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct data {
	int a;
	int b;
} data;

FILE *in, *ans;
int tno;


int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int fnc() {

	int a = geti();
	int b = geti();
	int t = geti();
	int c = t / a * b;
	outi(c);

	return 0;
}

int main() {
#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<math.h>
using namespace std ;
using ld = long double ;

ld sa(ld a,ld b){
    if(a>b) return a-b ;
    return b-a ;
}

int main(){
    int n ; cin >> n ;
    vector<ld> x(n) ;
    vector<ld> y(n) ;
    for(int i=0;i<n;i++) cin >> x.at(i) ;
    for(int i=0;i<n;i++) cin >> y.at(i) ;
    ld sub,a,b,c,d ;
    a = b = c = d = 0 ;
    for(int i=0;i<n;i++){
        sub = sa(x.at(i),y.at(i)) ;
        a += sub ;
        b += sub*sub ;
        c += sub*sub*sub ;
        if(sub>d) d = sub ;
    }
    cout << fixed << setprecision(10) << a << endl ;
    cout << sqrt(b) << endl ;
    cout << cbrt(c) << endl ;
    cout << d << endl ;
}


Measured memory_bytes: 3444
#include<iostream>
using namespace std;
int main(){
    int a,b;
    string s;
    cin>>a>>b>>s;
    bool no=false;
    for(int i=0;i<a;i++)
    {
        if(s[i]>='0'&&s[i]<='9')
        {
            continue;
        }
        no=true;
    }
    if(s[a]!='-')
    no=true;
    for(int i=a+1;i<s.size();i++)
    {
        if(s[i]>='0'&&s[i]<='9')
        {
            continue;
        }
        no=true;
    }
    if(no)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
}

Measured memory_bytes: 3628
import Data.List
f l k = if null l then 0 else if k==0 then (head l)+(f (tail l) (if mod (head l) 10 > 0 then 1 else 0)) else (head l)-(mod(head l)10)+10+f (tail l)1
main=do
 l<-sortBy (\a b->compare (mod a 10) (mod b 10)).map read.lines<$>getContents :: IO[Int]
 print$f l 0

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

int main(void)
{
	int N,ball,B = 0,C = 0;
	bool ans;
	cin >> N;
	for (int i = 0; i < N; i++) {
		C = 0;
		cin >> B;
		ans = true;
		for (int j = 1;j < 10; j++) {
			cin >> ball;

			int b = ball - B;
			int c = ball - C;

			if (b < 0 && c < 0 || !ans) {
				ans = false;
				continue;
			}
			else {
				if (b > 0 && c < 0 || b > 0 && c > 0 && b < c) {
					B = ball;
				}
				else if (b < 0 && c > 0 || b > 0 && c > 0 && b > c) {
					C = ball;
				}
			}
		}
		cout << (ans ? "YES" : "NO") << endl;
	}
	if (N == 0) {
		cout << endl;
	}
}


Measured memory_bytes: 3068
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, A[11];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	int j;
	long long ans = 0, x;
	for (i = 1; i <= N; i++) {
		x = 1;
		for (j = 1; j < i; j++) x *= 2 - (A[j] % 2);
		for (j = i + 1; j <= N; j++) x *= 3;
		ans += x * (A[i] % 2 + 1);
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define maxn 100000+10
int A[maxn];
int n;

int binarySearch(int key){
	int left = 0;
	int right = n;
	while ( left < right ){
		int mid = (left + right) / 2;
		if ( A[mid] == key ) return 1;
		else if ( A[mid] > key ) right = mid;
		else if ( A[mid] < key ) left = mid + 1;
	}
	return 0;
}

int main(){
	int q, temp, sum = 0;
	scanf("%d", &n);
	for( int i = 0; i < n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for( int i = 0; i < q; i++) {
		scanf("%d", &temp);
		if( binarySearch( temp ) ) sum++; 
	}
	printf("%d\n", sum);
	return 0;
}
 


Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(v) v.begin(),v.end()
#define vi vector<int> 
#define mod 1000000007
#define inf 1e17
#define fs first
#define ss second

template <typename T> 
void amax(T& x, T y) 
{ 
    if( x < y) x = y;
} 

template <typename T> 
void amin(T& x, T y) 
{ 
    if( x > y) x = y;
} 
/////////////////////////////////////////////////////////////
ll range[500][500];

ll power(ll x, ll y) {
	ll ans = 1;
	while (y) {
		if (y & 1)ans *= x;
		ans %= mod;
		y /= 2;
		x *= x;
		x %= mod;
	}
	return ans;
}


void init(ll x,ll l,ll r,ll d){
	
	ll ans = 0;
	
	for(int i =l;i<=r;i++){
		ans= (ans+power(i,d))%mod;
	}
	
	range[x][d] = ans;
}
ll dp[500][500];
	

int main(){
	
	int n,c;
	cin >> n >> c;
	
	ll a[n],b[n];
	
	for(int i =0;i<n;i++) cin >>a[i];
	for(int i =0;i<n;i++) cin >>b[i];
	
   	for(int i =0;i<n;i++)
   	 for(int j =0;j<=c;j++)
   	     init(i,a[i],b[i],j);
	
	
	dp[0][0] =1;
	
	for(int i = 0;i<=c;i++){
		for(int j = 0;j<n;j++){
 	        for(int k = 0;k<=c;k++){
 	                if( i + k > c) break;
	                dp[i+k][j+1] += (dp[i][j]*range[j][k]);
	                dp[i+k][j+1]%=mod;
	       }
 	   }
	}
	
	cout << (dp[c][n]%mod)<<endl;

}
	


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <stack>

using namespace std;


int main(){
    string S;
    // getline(cin, S);
    while(getline(cin, S)){
        if(S[0] == '.') break;
        bool isNo = false;
        stack<char> brackets;
        for(int i = 0; i < S.size(); ++i){
            char tmp;
            if(S[i] == '.'){
                if(brackets.empty() == false){
                    // cout << "no1" << endl;
                    isNo = true;
                    break;
                }
            }else if(S[i] == '(' || S[i] == '['){
                brackets.push(S[i]);
            }else if(S[i] == ')'){
                if(brackets.empty() == false){
                    tmp = brackets.top();
                    brackets.pop();
                    if(tmp != '('){
                        isNo = true;
                        break;
                    }
                }else{
                    isNo = true;
                }
            }else if(S[i] == ']'){
                if(brackets.empty() == false){
                    tmp = brackets.top();
                    brackets.pop();
                    if(tmp != '['){
                        isNo = true;;
                        break;
                    }
                }else{
                    isNo = true;
                }
            }
        }
        if(isNo == false)
            cout << "yes" << endl;
        else    
            cout << "no" << endl;
    }
    return 0;
}


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

int main(void){
    int n; cin >> n;
    for(int i = 0; i < n; i++){
    string a, b; cin >> a >> b;
    int num;
    int a_num = 0, b_num = 0;
    for(int i = 0; i < a.size(); i++){
        int temp;
        if('2' <= a[i] && a[i] <= '9'){
            temp = (int)a[i] - '0';
            i++;
        }else{
            temp = 1;
        }
        if(a[i] == 'm') a_num += 1000*temp;
        if(a[i] == 'c') a_num += 100*temp;
        if(a[i] == 'x') a_num += 10*temp;
        if(a[i] == 'i') a_num += temp;
    }
    for(int i = 0; i < b.size(); i++){
        int temp;
        if('2' <= b[i] && b[i] <= '9'){
            temp = (int)b[i] - '0';
            i++;
        }else{
            temp = 1;
        }
        if(b[i] == 'm') b_num += 1000*temp;
        if(b[i] == 'c') b_num += 100*temp;
        if(b[i] == 'x') b_num += 10*temp;
        if(b[i] == 'i') b_num += temp;
    }

    num = a_num + b_num;

    int array[4];
    array[3] = num / 1000;
    num %= 1000;
    array[2] = num / 100;
    num %= 100;
    array[1] = num / 10;
    num %= 10;
    array[0] = num;
    
    string c = "ixcm";
    for(int i = 3; i >= 0; i--){
        if(array[i] == 0) continue;
        else if(array[i] == 1){
            cout << c[i];
        }else{
            cout << array[i] << c[i];
        }
    }
    cout << endl;
    }
    return 0;
}

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

S = list(input().rstrip())
if len(S) % 2 == 0:
    S.pop()
    S.pop()
else:
    S.pop()
m = len(S) // 2
if S[:m] == S[m:]:
    print(len(S))
    sys.exit()
for i in range(len(S) // 2):
    S.pop()
    S.pop()
    m = len(S) // 2
    if S[:m] == S[m:]:
        print(len(S))
        sys.exit()

Measured memory_bytes: 3064
N = int(input())
W = [input() for _ in range(N)]
ans = 'Yes'
if len(set(W)) != N:
    ans = 'No'
prev = W[0]
for w in W[1:]:
    if w[0] != prev[-1]:
        ans = 'No'
    prev = w
print(ans)

Measured memory_bytes: 3060
from collections import*
I=9**9
(h,w),(s,t),(f,g)=eval('map(int,input().split()),'*3)
m,d=zip(*eval('(input(),[I]*w),'*h))
q=deque([(s-1,t-1,1)])
while q:
 y,x,c=q.popleft()
 if d[y][x]>c:
  for a in range(25):a,b=a//5-2,a%5-2;i=a+y;j=b+x;d[y][x]=c;h>i>-1<j<w!=m[i][j]>'#'!=(abs(a)+abs(b)<2!=q.appendleft((i,j,c)),q.append((i,j,c+1)))
print(d[f-1][g-1]%I-1)

Measured memory_bytes: 255684
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] t = new int[N + 1];
    int[] x = new int[N + 1];
    int[] y = new int[N + 1];
    for (int i = 1; i <= N; i++) {
      t[i] = sc.nextInt();
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
    }
    boolean flag = true;
    for (int i = 1; i <= N; i++) {
      int dt = t[i] - t[i - 1];
      int dist = Math.abs(x[i] - x[i - 1]) + Math.abs(y[i] - y[i - 1]);
      if (dt < dist) {
        flag = false;
      }
      if (dt % 2 != dist % 2) {
        flag = false;
      }
    }
    if (flag) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 93160