akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a + b < 10) {
        cout << a + b << endl;
    } else {
        cout << "error" << endl;
    }
    return 0;
}

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

int main()
{

        int N, L;
        cin >> N >> L;
        std::vector<string> S(N);
        for (int i = 0; i < N; ++i) {
                std::string s;
                cin >> S.at(i);
        }
        sort(S.begin(), S.end());
        for (int i = 0; i < N; ++i)  {
                cout << S.at(i);
        }
        cout << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){

    int N; cin >> N;
    pair<long int, long int> A[N];
    for(int i = 0 ; i < N ; i++)   cin >> A[i].second >> A[i].first;  //firstに終わり時間が入ってる
    sort(A , A + N);
    long long time = 0; bool check = true;
    for(int i = 0 ; i < N ; i++){
        time += A[i].second;
        if(A[i].first < time)  check = false;
    }

    if(check)  cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;

const double pi = 3.14159265358979;

int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    double r;
    cin >> r;
    cout << setprecision(15) << fixed;
    cout << 2 * pi * r;


    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int R; cin >> R;
    cout << 2*R*3.1415926535;
}

Measured memory_bytes: 3796
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
    static void Main(){
        string[] input = Console.ReadLine().Split();
        bool f = input[0] == input[1] && input[1] == input[2];
        Console.WriteLine(f ? "Yes" : "No");
    }
}

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

using namespace std;
typedef long long ll;

struct node {
    vector<node*> children;
    int val;
    int ind;
};

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

    vector<node*> nodes(n);

    for(int i=0; i < n; i++) {
        nodes[i] = new node;
        nodes[i]->val = 0;
        nodes[i]->ind = i;
    }

    for(int i=0; i < n-1; i++) {
        int a,b;
        cin >> a >> b;

        nodes[a-1]->children.push_back(nodes[b-1]);
    }

    for(int i=0; i < q; i++) {
        int p,val;
        cin >> p >> val;

        nodes[p-1]->val += val;
    }

    vector<int> vals(n);
    function<void(node*, int)> calc_val = [&](node* nd, int cur) {
        if(nd == nullptr) return;

        cur += nd->val;
        vals[nd->ind] = cur;

        for(auto child : nd->children) {
            calc_val(child, cur);
        }
    };

    calc_val(nodes[0], 0);

    for(auto val : vals) {
        cout << val << " ";
    }
}

Measured memory_bytes: 32896
import numpy as np

n,m,x = map(int, input().split())

books = []
for i in range(n):
    l = [int(x) for x in input().split(' ')]
    books.append(l)

patterns = []
for i in range(2**n):
    tmp = [False] * n
    for j in range(n):
        if ((i >> j) & 1):
            tmp[j] = True
    patterns.append(tmp)

price = []
for pattern in patterns:
    info = np.array([0]*(m+1))
    for i in range(n):
        if (pattern[i] == True):
            l = np.array(books[i])
            info += l
    else:
        if (min(info.tolist()[1:]) >= x):
            price.append(info.tolist()[0])
            
if (len(price) == 0):
    print(-1)
else:
    print(min(price))

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

int atk(long int H){
    if(H<2){
        return cnt;
    }
    else{
        H=H/2;

        baibai*=2;
        cnt=baibai-1;
        return atk(H);
    }
}

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int long H;

    cin>>H;

    atk(H);

    cout<<cnt<<endl;



    return 0;
}



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

long long gcd(long long m, long long n){
   while (n != 0){
      long long t = n;
      n = m % n;
      m = t;
   }
   return m;
}
int main(){
   long long A, B;
   cin >> A >> B;
   long long Ans;
   Ans = A*B/gcd(A, B);
   //cout << gcd(A, B) << endl;
   cout << Ans << endl;
}



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


void solve(long long N, long long L){
  long long acc = 0;

  for(long long i = 0; i < N; i++){
    acc += (L+i);
  }

  if(L > 0){
    cout << (acc - L) << endl;
  }
  else if(L+(N-1) < 0) {
    cout << (acc - (L+(N-1))) << endl;
  }
  else {
    cout << acc << endl;
  }


}

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


Measured memory_bytes: 3668
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
print(n+n**2+n**3)

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

using namespace std;

int main(){
    int N;
    int a[300010];
    cin >> N;
    for(int i = 0; i < (3*N); i++){
        cin >> a[i];
    }

    sort(a, a+(3*N), greater<int>());

    long ans = 0;
/*
    for(int i =0; i< N; i++){
        ans = ans + a[N+(2*i)];
    }
*/
    for(int i = 0; i< N; i++){
        ans = ans +a[2*i+1];
    }

    cout << ans << endl;
/*
    for(int i = 0; i < 3*N; i++){
        cout << a[i] << endl;
    }
*/
}

Measured memory_bytes: 1408
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << 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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m, t, p;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> ans;
    while (true)
    {
        cin >> n >> m >> t >> p;
        if (n == 0)
            break;
        vector<vector<int> > board(m+1000,vector<int>(n+1000,0));
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                board[i][j]=1;
            }
        }
        int l=0;
        int down=0;
        rep(h, t)
        {
            int d, c;
            cin >> d >> c;
            if(d==1){
                l += c;
                for(int i=0;i<c;i++){
                    for(int j=down;j<m+down;j++){
                        board[j][l+i]+=board[j][l-i-1];
                    }
                }
            }
            else{
                down += c;
                for(int i=0;i<c;i++){
                    for(int j=l;j<n+l;j++){
                        board[down+i][j]+=board[down-i-1][j];
                    }
                }
            }
        }
        rep(h,p){
            int x,y;
            cin>>x>>y;
            ans.push_back(board[down+ y][l+x]);
        }
        //cout<<l<<" "<<down<<"\n";
        /*
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                cout<<board[i][j]<<" ";
            }
            cout<<"\n";
        }
        */
    }
    rep(i,ans.size())
    cout << ans[i] << "\n";
}



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


int a1,a2,a3;
int b1,b2,b3;
int cou[5];
int ok=1;
int main(){
    scanf("%d%d%d%d%d%d",&a1,&b1,&a2,&b2,&a3,&b3);
    cou[a1]++;
    cou[a2]++;
    cou[a3]++;
    cou[b1]++;
    cou[b2]++;
    cou[b3]++;
    for(int i=1;i<=4;i++){
    if(cou[i]<=0 || cou[i]>=3){
     ok=0;
    }
    }
    if(ok==0){
        printf("NO");
    }else{
        printf("YES");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 2000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl

//ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

char maze[60][60];
int d[60][60];

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main() {
    //入っている変数
    //高さH、幅W
    int H, W;
    cin >> H >> W;
    rep(i, H) {
        rep(j, W) {
            cin >> maze[i][j];
        }
    }
    //スタート地点(sy,sx) ゴール地点(gy,gx)
    int sy, sx, gy, gx;
    sy = 0;sx = 0;gy = H - 1;gx = W - 1;

    //初期化
    rep(i, 50)rep(j, 50)d[i][j] = INF;
           
    int cou = 0;
    rep(i, H)rep(j, W)if (maze[i][j] == '.')cou++;

    queue<pair<int, int>> que;//BFS用キュー

    que.push(pair<int, int>(sy, sx));//スタート地点
    d[sy][sx] = 0;

    //BFSの開始
    while (!que.empty()) {
        pair<int, int> p = que.front();//コピーして取り出し
        if (p.first == gy&&p.second == gx) break;//ゴールで終了

        que.pop();
        for (int i = 0; i < 4; i++) {
            int nx = p.second + dx[i];
            int ny = p.first + dy[i];
            if (maze[ny][nx] != '#'&&d[ny][nx] == INF && 0 <= ny&&ny < H && 0 <= nx&&nx < W) {//通行可能である条件
                que.push(pair<int, int>(ny, nx));
                d[ny][nx] = d[p.first][p.second] + 1;
            }
        }
    }
    //通行不可能 (d[gy][gx]==INF)
    if (d[gy][gx] == INF)cout << -1 << endl;
    else cout << cou-(d[gy][gx]+1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    int Arr[n],Brr[n],Crr[n];
    for(int i=0;i<n;i++)
    {
        cin >> Arr[i];
    }
    Brr[0]=0;
    Brr[1]=abs(Arr[1]-Arr[0]);
    if(n>2)
    {
       for(int i=2;i<n;i++)
       {
           int flag=0;
           for(int j=i-k;j<i;j++)
           {
               if(j<0)
                    continue;
               if(flag==0)
               {
                   Brr[i]=abs(Arr[i]-Arr[j])+Brr[j];
                   flag=1;
               }
               else if(flag==1 && (abs(Arr[i]-Arr[j])+Brr[j])<Brr[i])
               {
                   Brr[i]=abs(Arr[i]-Arr[j])+Brr[j];
               }
           }
       }
       cout << Brr[n-1];
    }
    else
    {
        cout << Brr[1];
    }

}


Measured memory_bytes: 1024
#include<stdio.h>
 
int main(void){
  int a[100000], b[50000], count=0;
  int i, right, left, center, n, q;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
  }
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &b[i]);
  }
  for(i=0; i<q; i++){
    right = n;
    left = 0;
    while(left<=right){
      center = (right + left)/2;
      if(a[center] == b[i]) {
    count++;
    break;
      }
      else if(a[center] < b[i])
    left = center + 1;
      else
    right = center - 1;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

#define INF 1000000000

int main(){
    int N;
    cin >> N;
    int X[N];
    for(int i=0; i<N; i++) cin >> X[i];
    long ans = INF;
    for(int i=1; i<= 100; i++){
        long temp = 0;
        for(int j=0; j<N; j++){
            temp += pow(X[j]-i, 2);
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

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

void f(int* x,int* y){
    int z = *x;
    *x = *y;
    *y = z;
}

int g(int* u,int n){
    int cnt = 0;
    bool flag = true;
    for(int i=0;flag;i++){
        flag = false;
        for(int j=n-1;j>=i+1;j--){
            if(u[j]<u[j-1]){
                f(u+j,u+j-1);
                flag = true;
                cnt++;
            }
        }
    }
    return cnt;
}

int main(){
    int n,res; cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    res = g(a,n);
    for(int i=0; i<n; i++){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3084
n = int(input())
w = list(map(int, input().split()))
ans = 99999

# print(n, w)

for i in range(n):
    s1 = sum(w[:i])
    s2 = sum(w[i:n+1])
    ans = min(ans, abs(s1-s2))
    # print(i, s1, s2, ans)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<pii> vpii;
typedef vector<vint> det1;
typedef vector<vpii> det2;

int main()
{
    char c;
    cin >> c;

    if (c == 'A') { cout << 'T' << endl; }
    if (c == 'C') { cout << 'G' << endl; }
    if (c == 'G') { cout << 'C' << endl; }
    if (c == 'T') { cout << 'A' << endl; }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int num = N * M;
        if(num % 2 == 0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }
        
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
int prime[20000000];
int a[300001];
map<int, int> mp;
vector<int> pr;
void sieve(int n)
{

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == 0)
        {

            for (int i = p * p; i <= n; i += p)
                prime[i] = p;
        }
    }
    for (int i = 2; i <= 20000000;i++){
        if(prime[i]==0)
            pr.pb(i);
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    sieve(20000000);
    //cin >> tc;
    while (tc--)
    {
        int n, m;
        cin >> n >> m;
        int ar[n];
        for (int i = 0; i < n;i++){
            cin >> ar[i];
        }
        int f = 0;
        map<int, int> mp;
        int a, b;
        for (int j = 0; j < m;j++){
            cin >> a >> b;
            a--;
            b--;
            if(ar[a]<=ar[b]){
                mp[a]++;
            }
            if(ar[b]<=ar[a]){
                mp[b]++;

            }
        }
        cout << n - mp.size();
    }

    return 0;
}

Measured memory_bytes: 89680
#include<bits/stdc++.h>
using namespace std;
const int N=17;
double dis[N][N],f[1<<N],x[N],y[N],a[N]; 
int n,m;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>y[i]>>a[i];
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) dis[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
	for(int i=0;i<=1<<n;i++) f[i]=1e18;
	f[0]=0;
	for(int i=0;i<n;i++) f[1<<i]=0;
	for(int s=0;s<1<<n;s++){
		for(int i=0;i<=n-1;i++)
			for(int j=0;j<=n-1;j++)
				if((s&(1<<i))&&(!(s&(1<<j)))) f[s|(1<<j)]=min(f[s|(1<<j)],f[s]+dis[i+1][j+1]);
	}
	for(int s=0;s<1<<n;s++){
		f[s]=-f[s];
		for(int i=0;i<n;i++)if(s&(1<<i)) f[s]+=a[i+1];
		f[s]/=__builtin_popcount(s);
		for(int t=(s-1)&s;t;t=(t-1)&s)
			f[s]=max(f[s],min(f[t],f[s-t]));
	}
	printf("%.10lf\n", f[(1<<n)-1]);
}

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

using namespace std;

#define ll long long

int main (){

    ll n,a,c=0;

    cin>>a>>n;

    while(1){

        a=a-n;
        c++;

        if(a <= 0) break;

    }

    cout<<c<<endl;

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  int k;
  cin>>k>>s;
  int si=s.size();
  if(si<=k){
    cout<<s<<'\n';
  }
  else{
    rep(i,k){
      cout<<s[i];
    }
    cout<<"..."<<'\n';
  }
  return(0);
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
ll mod=1000000007;

int main(){
    std::ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    if(k>((n+1)/2))cout<<"NO";
    else cout<<"YES";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
typedef long long ll;
int main()
{
    ll tar;
    cin>>tar;
    double res=100;
    ll ans=100;
    ll cnt=0;
    while(ans<tar)
    {
        res*=1.01;
        ans=res;
        res=ans;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;

int main()
{
	int n, v[55];
	double ans;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v, v + n);
	ans = v[0];
	for (int i = 1; i < n; i++) {
		ans = (ans + v[i]) / 2.;
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = list(input())
n = len(s)
# print(s)
np = False
for i in range(n//2):
    if s[i] != s[n-1-i]:
        np = True
s2 = s[:n//2]
# print(s2)
n = len(s2)
for i in range(n//2):
    if s2[i] != s2[n-1-i]:
        np = True
n = len(s)
s2 = s[(n+3)//2-1:]
# print(s2)
n = len(s2)
for i in range(n//2):
    if s2[i] != s2[n-1-i]:
        np = True
if np:
    print("No")
else:
    print("Yes")


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  int M;
  cin >> M;
  vector<pair<int,int>> pair(M);
  for(int j = 0;j < M;j++) {
    int A,B;
    cin >> A >> B;
    pair.at(j) = make_pair(A,B);
  }
  for(int k = 0;k < M;k++) {
    int answer = 0;
    for(int l = 0;l < N;l++) {
      if(l == pair[k].first - 1) {
        answer = answer + pair[k].second;
      }
      else {
        answer = answer + vec.at(l);
      }
    }
    cout << answer << endl;
  }
}

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

def main():
    n=int(input())
    l=input()
    q=int(input())
    kl=tuple(map(int,input().split()))
    for k in kl:
        d=0
        m=0
        dm=0
        ans=0
        for j in range(n):
            if l[j]=='D':
                d+=1
            elif l[j]=='M':
                m+=1
                dm+=d
            elif l[j]=='C':
                ans+=dm
            if j>=k-1:
                if l[j-k+1]=='D':
                    dm-=m
                    d-=1
                elif l[j-k+1]=='M':
                    m-=1
        print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 60012
#include <bits/stdc++.h>
using i64 = long long;

auto dot(const std::vector<int> &p, const std::vector<int> &q) {
    std::vector<int> ret(p.size());
    for (int i = 0; i < p.size(); i++) ret[i] = p[q[i]];
    return ret;
}

auto inv(const std::vector<int> &p) {
    std::vector<int> ret(p.size());
    for (int i = 0; i < p.size(); i++) ret[p[i]] = i;
    return ret;
}

auto f(const std::vector<int> &p, const std::vector<int> &q) {
    return dot(q, inv(p));
}

std::vector<int> operator*(const std::vector<int> &lhs, const std::vector<int> &rhs) {
    return dot(lhs, rhs);
}

int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<int> p(n), q(n);
    for (int i = 0; i < n; i++) { std::cin >> p[i]; p[i]--; }
    for (int i = 0; i < n; i++) { std::cin >> q[i]; q[i]--; }

    std::vector<int> ret(n);
    for (int i = 0; i < n; i++) ret[i] = i;
    auto m = q * inv(p) * inv(q) * p;
    for (int i = 0, t = (k - 1) / 6; (1 << i) <= t; i++) {
        if (t & (1 << i)) {
            ret = ret * m;
        }
        m = m * m;
    }
    int r = (k - 1) % 6;
    if (r >= 3) ret = ret * q;
    if (r >= 4) ret = ret * inv(p);

    std::vector<int> b;
    if (r == 0) b = p;
    else if (r == 1) b = q;
    else if (r == 2) b = q * inv(p);
    else if (r == 3) b = inv(p);
    else if (r == 4) b = inv(q);
    else b = inv(q) * p;

    ret = ret * b * inv(ret);
    for (int i = 0; i < n; i++) std::cout << ret[i] + 1 << " ";
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <assert.h>
#include <limits>
#include <cstdio>
using namespace std;

//#define RDEBUG 1
#ifdef RDEBUG
#define D(x) x
#else
#define D(x)
#endif
#define inf 0x7fffffff
#define MOD 1000000007

typedef long long ll;


ll add(ll a, ll b) {
    a += b;
    if(a >= MOD) {
        a -= MOD;
    }
    return a;
}
ll sub(ll a, ll b) {
    a -= b;
    if(a < 0) {
        a += MOD;
    }
    return a;
}
void add_self(ll& a, ll b) {
    a = add(a, b);
}
void sub_self(ll& a, ll b) {
    a = sub(a, b);
}

const ll MAXN = 1010;

// 0: weight, 1: strength, 2: value

pair<pair<ll, ll>, ll> boxes[MAXN];
ll N;
ll dp[MAXN][10010];

bool cmp(pair<pair<ll, ll>, ll> a, pair<pair<ll, ll>, ll> b) {return a.first.first+a.first.second<b.first.first+b.first.second;}

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    for (ll i = 0; i<N; i++) {
        cin >> boxes[i].first.first >> boxes[i].first.second >> boxes[i].second;
    }
    sort(boxes, boxes+N, cmp);
    for (ll i = 0; i<MAXN; i++) {
        for (ll j = 0; j<10010; j++) {
            dp[i][j] = numeric_limits<ll>::min();
        }
    }
    dp[0][0] = 0;
    for (ll i = 0; i<N; i++) {
        for (ll j = 0; j<=10001; j++) {
            if (boxes[i].first.second>=j) {
                dp[i+1][min(j+boxes[i].first.first, (ll)10001)] = max(dp[i+1][min(j+boxes[i].first.first, (ll)10001)], dp[i][j]+boxes[i].second);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    ll best = -numeric_limits<ll>::max();
    for (int i = 0; i<=10001; i++) {
        best = max(best, dp[N][i]);
    }
    cout << best << endl;
    return 0;
}





Measured memory_bytes: 79232
local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local n = io.read("*n")
local a = {}
local sum = 0
for i = 1, n do
  a[i] = 2 * io.read("*n")
  sum = sum + a[i]
end
sum = sum / 2
-- get t1
local t = {}
t[1] = sum
for i = 2, n, 2 do
  t[1] = t[1] - a[i]
end
-- print(t[1])
for i = 2, n do
  t[i] = a[i - 1] - t[i - 1]
end
io.write(t[1])
for i = 2, n do
  io.write(" " .. t[i])
end
io.write("\n")


Measured memory_bytes: 7920
from math import factorial
from itertools import permutations

n = int(input())
p = tuple(map(str, input().split()))
q = tuple(map(str, input().split()))

num = [str(i) for i in range(1, n+1)]

allnum = list(i for i in permutations(num, n))

print(abs(allnum.index(p) - allnum.index(q)))

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int n,x,m;
	cin >> n >> x >> m;

	map<int,int> mp;
	vi a;
	int cnt = 0;
	ll tot = 0;
	while(mp.count(x) == 0){
		a.pb(x);
		tot += x;
		mp[x] = cnt;
		++cnt;
		x = x*x%m;
	}
	if(n <= cnt){
		ll ans = 0;
		rep(i,n) ans += a[i];
		cout << ans << endl;
		return;
	}
	ll lp_sum = 0;
	int s = cnt - mp[x];
	FOR(i,mp[x],cnt) lp_sum += a[i];
	ll ans = tot;
	n -= cnt;
	ans += n/s*lp_sum;
	n %= s;
	int itr = mp[x];
	rep(i,n) ans += a[itr + i];
	cout << ans << endl;
	return;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

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

class Program
{
	static void Main()
	{
		var t = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number));
		long n = t[0] == 1 ? 1 : t[0] - 2;
		long m = t[1] == 1 ? 1 : t[1] - 2;
		long ans = n * m;

		Console.WriteLine(ans);

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 11092
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

x,y,a,b,c = [int(i) for i in readline().split()]
p = [int(i) for i in readline().split()]
q = [int(i) for i in readline().split()]
r = [int(i) for i in readline().split()]

p.sort(reverse=True)
q.sort(reverse=True)
r.sort()

from heapq import *

hq = sorted(p[:x]+q[:y],reverse=True)

ans = sum(hq)
while hq and r and hq[-1] < r[-1]:
    v = hq.pop()
    w = r.pop()
    ans += w-v

print(ans)




Measured memory_bytes: 95340
from collections import Counter

n = int(input())
v = [int(i) for i in input().split()]
v_0 = v[0::2]
v_1 = v[1::2]
ans = 0

c0 = Counter(v_0).most_common(2)
c1 = Counter(v_1).most_common(2)

# 要素が1つしか出てこない場合を判定
if len(set(v_0)) == len(set(v_1)) == 1:
    if v_0 == v_1:
        ans = min(len(v_0), len(v_1))

else:
    # mostが被っていないか判定
    if c0[0][0] != c1[0][0]:
        ans = (len(v_0) - c0[0][1]) + (len(v_1) - c1[0][1])
    else:
        w1 = (len(v_0) - c0[0][1]) + (len(v_1) - c1[1][1])
        w2 = (len(v_0) - c0[1][1]) + (len(v_1) - c1[0][1])
        ans = min(w1, w2)

print(ans)

Measured memory_bytes: 15972
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
		// スペース区切りの整数の入力
		int B = sc.nextInt();
		int C = sc.nextInt();
		//
    if (C >= A && C <= B) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
		
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 * 
 * https://atcoder.jp/contests/abc111/submissions/3312161 にも参考
 */
public class Main {

	/** モード一覧 */
	private static final char[] MODES = { 'L', 'D', 'U', 'R' };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] u = new int[n], v = new int[n];
			IntStream.range(0, n).forEach(i -> {
				int x = scanner.nextInt(), y = scanner.nextInt();
				u[i] = x + y;
				v[i] = x - y;
			});
			int r = u[0] & 1;
			for (int i = 1; i < n; i++) {
				if (r != (u[i] & 1)) {
					System.out.println("-1");
					return;
				}
			}
			r = 1 - r;
			int m = 31;
			System.out.println(m + r);
			StringBuilder answer = new StringBuilder();
			if (r > 0) {
				answer.append("1").append(" ");
			}
			IntStream.range(0, m).forEach(i -> answer.append(1 << i).append(" "));
			// 最後のスペースを削除
			answer.deleteCharAt(answer.length() - 1);
			System.out.println(answer.toString());

			long base = (1L << m) - 1 - r;
			for (int i = 0; i < n; i++) {
				StringBuilder sb = new StringBuilder();
				if (r > 0) {
					sb.append('R');
				}
				long uBase = (u[i] + base) >> 1, vBase = (v[i] + base) >> 1;
				for (int j = 0; j < m; j++) {
					int u1 = (int) (uBase & 1L) << 1;
					int v1 = (int) (vBase & 1L);
					sb.append(MODES[u1 + v1]);
					uBase >>= 1;
					vBase >>= 1;
				}
				System.out.println(sb.toString());
			}
		}
	}
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N, M;
  vector<llong> A;

  cin >> N >> M;
  A.resize(N);
  llong sum = 0;
  for (auto &in: A) {
    cin >> in;
    sum += in;
  }

  llong ans = 0;
  for (auto &a: A) {
    ans += 4 * M * a >= sum;
  }

  cout << (ans >= M ? "Yes" : "No") << endl;

  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
   char c;
   cin >>c;
   cout <<(char)(c+1)<<endl;
    return 0;
}



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

signed main()
{
  string S;
  int a = -1, z;

  cin >> S;
  Rep(i, S.size()) {
    if(a == -1 && S[i] == 'A') a = i;
    if(S[i] == 'Z') z = i;
  }

  cout << z - a + 1 << endl;

  return 0;
 }


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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

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

ll fun(ll x, int c, int d) {
  ll res = x;
  res -= x/c;
  res -= x/d;
  res += x/lcm(c, d); 
  return res;
}

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

  ll ans = fun(b,c,d) - fun(a-1,c,d);
  // ll count = num - (num/c) - (num/d) + (num/(c*d/gcd(c, d)));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
string s, t;

int main()
{
    cin >> s >> t;
    string sub = t.substr(0, t.length() - 1);
    // cout << sub << endl;
    if (s == sub)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3500
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    vvll X(N,vll(2));
    vll cnt1(N);
    REP(i,N){cin >> X[i][0] >> X[i][1];
    cnt1[i] = X[i][0]+X[i][1];
    }
    sort(ALL(cnt1));
    ll ans1=cnt1[N-1]-cnt1[0];

    vvll X2(N,vll(2));
    vll cnt2(N);
    REP(i,N){
      X2[i][0]=-X[i][0];
      X2[i][1]=X[i][1];
      cnt2[i] = X2[i][0]+ X2[i][1];
    }
    sort(ALL(cnt2));
    ll ans2=cnt2[N-1]-cnt2[0];

    vvll X3(N,vll(2));
    vll cnt3(N);
    REP(i,N){
      X3[i][0]=X[i][0];
      X3[i][1]=-X[i][1];
      cnt3[i] = X3[i][0]+ X3[i][1];
    }
    sort(ALL(cnt3));
    ll ans3=cnt3[N-1]-cnt3[0];
    

    //本文
    ll ans = max(ans1,max(ans2,ans3));

    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,ll md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    int n;string s;
    map<string,int>a;
    cin>>n;
    f(i,0,n){
        cin>>s;
        a[s]++;
    }
    set<string>ans;
    int m=0;
    fr(i,a){
        if(i.second>m){
            m=i.second;ans.clear();
            ans.insert(i.first);
        }
        else if(i.second==m){
            ans.insert(i.first);
        }
    }
    fr(i,ans)cout<<i<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 33280
from functools import reduce
N, X = map(int, raw_input().split())
cities = map(int, raw_input().split())
absolutes = [abs(X-c) for c in cities]

def gcd(a, b):
    if b > a:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)
print reduce(gcd, absolutes)

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;

  vector<int> arr(n);
  int sum = 0;
  for (int &x : arr) {
    cin >> x;
    sum += x;
    sum %= MOD;
  }
  int ans = 0;
  for (int x : arr) {
    sum -= x;
    sum += MOD;
    sum %= MOD;
    ans += x * (sum);
    ans %= MOD;
  }
  cout << ans << endl;
}

signed main() {
  // freopen(".in", "r", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

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

const int N = 2010, mod = 924844033;
long long dp[N][N][3], fact[N], p[N], n, K;

int main() { 
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> K;
	fact[0] = 1;
	for (int i = 1; i < N; i++)
		fact[i] = 1LL * fact[i - 1] * i % mod;
	int last = 1;
	for (int i = 1; i <= K * 2; i++) 
		for (int j = i; j <= n; j += K * 2)
			p[last++] = j;
	//for (int i = 1; i <= n; i++)
	//	cout << p[i] << ' ';
	//cout << '\n';
	dp[0][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i][0][0] = 1;
		for (int j = 1; j <= i; j++) {
			dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1] + dp[i - 1][j][2]) % mod;
			if (p[i] - K >= 1) {
				dp[i][j][1] = (dp[i - 1][j - 1][0] + dp[i - 1][j - 1][1]) % mod;
				if (p[i] - K != p[i - 1] + K)
					(dp[i][j][1] += dp[i - 1][j - 1][2]) %= mod;
			}
			if (p[i] + K <= n) {
				dp[i][j][2] = (dp[i - 1][j - 1][0] + dp[i - 1][j - 1][2]) % mod;
				if (p[i] + K != p[i - 1] - K)
					(dp[i][j][2] += dp[i - 1][j - 1][1]) %= mod;
			}
		}
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		int x = (dp[n][i][0] + dp[n][i][1] + dp[n][i][2]) % mod;
		if (i & 1)
			(ans += 1LL * (x) * fact[n - i] % mod) %= mod;
		else {
			ans = ((ans - (1LL * x * fact[n - i]) % mod) % mod + mod) % mod;
		}
	}
	cout << ((fact[n] - ans) % mod + mod) % mod << '\n';
	return 0;
}


Measured memory_bytes: 58168
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	double n,t,a,ix;
	double m = 100000;
	cin >> n >> t >> a;
	vector<int>h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (abs(a - (t - h[i] * 0.006)) < m) {
			m = min(m, abs(a - (t - h[i] * 0.006)));
			ix = i;
		}
	}
	cout <<(int) ix+1 << endl;
}


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

int cd(bool b){
  cout << (b?"Yes":"No");
  return 0;
}

int main(){
  int N; cin >> N;
  int alx; cin >> alx;
  int tmp;
  for(int i = 1; i < N; i++){
    cin >> tmp;
    alx ^= tmp;
  }
  if(alx) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 384
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w, k) = (v[0], v[1], v[2] as i64);

    let mut grid = vec![vec![]; h];
    for y in 0..h {
        grid[y] = read::<String>()
            .chars()
            .map(|x| x.to_digit(10).unwrap() as i64)
            .collect::<Vec<_>>();
    }
    let mut cum_sum = CumulativeSum2D::new(w, h);
    for y in 0..h {
        for x in 0..w {
            cum_sum.add(x, y, grid[y][x]);
        }
    }
    cum_sum.build();

    let mut ans = std::i64::MAX;
    'outer: for state in 0..1 << h - 1 {
        let mut count = 0;
        let mut spans = vec![];
        let mut cur = 0;
        for i in 0..h - 1 {
            if (state >> i) & 1 == 1 {
                spans.push((cur, i + 1));
                cur = i + 1;
            }
        }
        spans.push((cur, h));
        // debug!(spans);

        let mut start_x = 0;
        for last_x in 0..w {
            let mut found = false;
            for &(start_y, end_y) in &spans {
                let white_in_area = cum_sum.query(start_x, start_y, last_x + 1, end_y);
                if white_in_area > k {
                    if last_x == start_x {
                        continue 'outer;
                    }
                    found = true;
                }
            }
            if found {
                count += 1;
                start_x = last_x;
            }
        }

        ans = min(ans, count + (spans.len() - 1) as i64);
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

struct CumulativeSum2D {
    data: Vec<Vec<i64>>,
}

impl CumulativeSum2D {
    fn new(w: usize, h: usize) -> CumulativeSum2D {
        CumulativeSum2D {
            data: vec![vec![0; w + 1]; h + 1],
        }
    }

    fn add(&mut self, mut x: usize, mut y: usize, z: i64) {
        x += 1;
        y += 1;
        if x >= self.data[0].len() || y >= self.data.len() {
            return;
        }
        self.data[y][x] += z;
    }

    fn build(&mut self) {
        for i in 1..self.data.len() {
            for j in 1..self.data[i].len() {
                self.data[i][j] +=
                    self.data[i][j - 1] + self.data[i - 1][j] - self.data[i - 1][j - 1];
            }
        }
    }

    // sum of [sx, gx), [sy, gy)
    fn query(&self, sx: usize, sy: usize, gx: usize, gy: usize) -> i64 {
        self.data[gy][gx] + self.data[sy][sx] - self.data[gy][sx] - self.data[sy][gx]
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fast_io ios :: sync_with_stdio(false);
using namespace std;

int main() {
	cout << fixed << setprecision(3);
	fast_io;
	int n; cin >> n;
	string s; cin >> s;
	string r;
	char l;
	if(n != 0) {
		for (int i = 0; i < s.size(); i++) {
			if(int(s[i]) + n > int('Z')) {
				l = char(int(s[i]) + n - 26);		
			} else {
				l = int(s[i] + n);
			}
			if(r == "") {
				r = l; 
			} else {
				r += l;
			}
		}	
	} else {
		r = s;	
	}
	cout << r;
	return 0;	
}

Measured memory_bytes: 3672
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a, b = na()
ct = 1
step = 0
while ct < b:
    ct -= 1
    ct += a
    step += 1
print(step)


Measured memory_bytes: 3060
#include <stdio.h>

int num, sum, m;

void ans(long long n)
{
    num = 0;
    sum = 0;
    while(n > 0)
    {
        if(n < 10)
            m = n;
        num++;
        sum += n % 10;
        n /= 10;
    }
}

int main()
{
    long long n;
    scanf("%lld", &n);
    ans(n);
    int a = m + 9 * (num - 1);
    if(a != sum)
        a--;
    printf("%d\n", a);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
cnt = 0
startb = 0
enda = 0
both = 0
S = []
for i in range(n):
    s = input()
    S.append(s)
    cnt += s.count('AB')
    if s[0] == 'B':
        startb += 1
    if s[-1] == 'A':
        enda += 1
    if s[0] == 'B' and s[-1] == 'A':
        both += 1
if both == startb == enda and both != 0:
    print(cnt+both-1)
else:
    print(cnt+min(startb,enda))


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

int main(){
	int a,b;
	while(cin>>a>>b){
		int n=a+b;
		for(int i=0; i<9; i++){
			if(n==0){
				cout << i << endl;
				break;
			}
			n/=10;
		}
	}
	return 0;
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
#include<functional>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<pair<string, pair<int, int> > >pair(N);
  string S;
  int P, n;
  for (int i = 0; i < N;i++){
    cin >> S >> P;
    n = i + 1;
    pair[i] = make_pair(S, make_pair(-P, n));
  }
  sort(pair.begin(), pair.end());
  for (int i = 0; i < N;i++){
    // cout << pair[i].first << pair[i].second.first <<  endl;
    cout << pair[i].second.second <<  endl;
  }
}


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

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

    int n, m, x;
    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    const int INF = 1001001001;
    int res = INF;
    rep(i, 1<<n){
        vector<bool> use(n, false);
        int cost = 0;
        rep(j, n){
            if(i & (1<<j)) {
                use[j] = true;
                cost += c[j];
            }
        }

        vector<int> learned(m, 0);
        rep(j, n){
            if(use[j]){
                rep(k, m) learned[k] += a[j][k];
            }
        } 

        bool flg = true;
        rep(j, m){
            if(learned[j] < x) {
                flg = false;
                break;
            }
        }

        if(flg) res = min(res, cost);

    }

    if(res == INF) cout << -1 << endl;
    else cout << res << endl;

    return 0;
}

Measured memory_bytes: 3632